@wailsio/runtime 3.0.0-alpha.65 → 3.0.0-alpha.69

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 (142) hide show
  1. package/{src → dist}/application.js +2 -16
  2. package/dist/browser.js +20 -0
  3. package/dist/callable.js +144 -0
  4. package/dist/calls.js +194 -0
  5. package/dist/cancellable.js +792 -0
  6. package/dist/clipboard.js +30 -0
  7. package/dist/contextmenu.js +80 -0
  8. package/{src → dist}/create.js +2 -33
  9. package/dist/dialogs.js +134 -0
  10. package/dist/drag.js +222 -0
  11. package/dist/event_types.js +232 -0
  12. package/dist/events.js +114 -0
  13. package/dist/flags.js +23 -0
  14. package/dist/index.js +38 -0
  15. package/dist/listener.js +44 -0
  16. package/{src → dist}/nanoid.js +7 -11
  17. package/dist/runtime.js +63 -0
  18. package/dist/screens.js +38 -0
  19. package/dist/system.js +146 -0
  20. package/{src → dist}/utils.js +29 -20
  21. package/dist/window.js +570 -0
  22. package/{src → dist}/wml.js +52 -123
  23. package/package.json +43 -19
  24. package/types/application.d.ts +3 -10
  25. package/types/browser.d.ts +4 -4
  26. package/types/callable.d.ts +3 -0
  27. package/types/calls.d.ts +43 -49
  28. package/types/cancellable.d.ts +434 -0
  29. package/types/clipboard.d.ts +6 -5
  30. package/types/contextmenu.d.ts +1 -0
  31. package/types/create.d.ts +6 -27
  32. package/types/dialogs.d.ts +99 -143
  33. package/types/drag.d.ts +1 -0
  34. package/types/event_types.d.ts +221 -219
  35. package/types/events.d.ts +46 -250
  36. package/types/flags.d.ts +3 -3
  37. package/types/index.d.ts +16 -14
  38. package/types/listener.d.ts +9 -0
  39. package/types/nanoid.d.ts +1 -1
  40. package/types/runtime.d.ts +18 -26
  41. package/types/screens.d.ts +42 -76
  42. package/types/system.d.ts +59 -79
  43. package/types/utils.d.ts +15 -8
  44. package/types/window.d.ts +123 -224
  45. package/types/wml.d.ts +2 -6
  46. package/docs/.nojekyll +0 -1
  47. package/docs/assets/highlight.css +0 -22
  48. package/docs/assets/icons.js +0 -15
  49. package/docs/assets/icons.svg +0 -1
  50. package/docs/assets/main.js +0 -59
  51. package/docs/assets/navigation.js +0 -1
  52. package/docs/assets/search.js +0 -1
  53. package/docs/assets/style.css +0 -1415
  54. package/docs/classes/Call.RuntimeError.html +0 -11
  55. package/docs/classes/Events.WailsEvent.html +0 -4
  56. package/docs/functions/Application.Hide.html +0 -2
  57. package/docs/functions/Application.Quit.html +0 -2
  58. package/docs/functions/Application.Show.html +0 -2
  59. package/docs/functions/Browser.OpenURL.html +0 -3
  60. package/docs/functions/Call.ByID.html +0 -8
  61. package/docs/functions/Call.ByName.html +0 -6
  62. package/docs/functions/Call.Call.html +0 -11
  63. package/docs/functions/Clipboard.SetText.html +0 -6
  64. package/docs/functions/Clipboard.Text.html +0 -3
  65. package/docs/functions/Create.Any.html +0 -2
  66. package/docs/functions/Create.Array.html +0 -4
  67. package/docs/functions/Create.ByteSlice.html +0 -3
  68. package/docs/functions/Create.Map.html +0 -4
  69. package/docs/functions/Create.Nullable.html +0 -3
  70. package/docs/functions/Create.Struct.html +0 -3
  71. package/docs/functions/Dialogs.Error.html +0 -5
  72. package/docs/functions/Dialogs.Info.html +0 -5
  73. package/docs/functions/Dialogs.OpenFile.html +0 -3
  74. package/docs/functions/Dialogs.Question.html +0 -5
  75. package/docs/functions/Dialogs.SaveFile.html +0 -3
  76. package/docs/functions/Dialogs.Warning.html +0 -5
  77. package/docs/functions/Events.Emit.html +0 -6
  78. package/docs/functions/Events.Off.html +0 -4
  79. package/docs/functions/Events.OffAll.html +0 -3
  80. package/docs/functions/Events.On.html +0 -7
  81. package/docs/functions/Events.OnMultiple.html +0 -8
  82. package/docs/functions/Events.Once.html +0 -7
  83. package/docs/functions/Events.setup.html +0 -1
  84. package/docs/functions/Flags.GetFlag.html +0 -6
  85. package/docs/functions/Screens.GetAll.html +0 -3
  86. package/docs/functions/Screens.GetCurrent.html +0 -3
  87. package/docs/functions/Screens.GetPrimary.html +0 -3
  88. package/docs/functions/System.Capabilities.html +0 -4
  89. package/docs/functions/System.Environment.html +0 -5
  90. package/docs/functions/System.IsAMD64.html +0 -3
  91. package/docs/functions/System.IsARM.html +0 -3
  92. package/docs/functions/System.IsARM64.html +0 -5
  93. package/docs/functions/System.IsDarkMode.html +0 -5
  94. package/docs/functions/System.IsDebug.html +0 -1
  95. package/docs/functions/System.IsLinux.html +0 -3
  96. package/docs/functions/System.IsMac.html +0 -3
  97. package/docs/functions/System.IsWindows.html +0 -3
  98. package/docs/functions/System.invoke.html +0 -1
  99. package/docs/functions/WML.Enable.html +0 -2
  100. package/docs/functions/WML.Reload.html +0 -2
  101. package/docs/functions/init.html +0 -1
  102. package/docs/index.html +0 -5
  103. package/docs/interfaces/Call.CallOptions.html +0 -7
  104. package/docs/interfaces/Dialogs.Button.html +0 -7
  105. package/docs/interfaces/Dialogs.FileFilter.html +0 -5
  106. package/docs/interfaces/Dialogs.MessageDialogOptions.html +0 -9
  107. package/docs/interfaces/Dialogs.OpenFileDialogOptions.html +0 -33
  108. package/docs/interfaces/Dialogs.SaveFileDialogOptions.html +0 -35
  109. package/docs/interfaces/Screens.Rect.html +0 -9
  110. package/docs/interfaces/Screens.Screen.html +0 -25
  111. package/docs/interfaces/Screens.Size.html +0 -5
  112. package/docs/interfaces/System.EnvironmentInfo.html +0 -11
  113. package/docs/interfaces/System.OSInfo.html +0 -9
  114. package/docs/modules/Application.html +0 -4
  115. package/docs/modules/Browser.html +0 -2
  116. package/docs/modules/Call.html +0 -6
  117. package/docs/modules/Clipboard.html +0 -3
  118. package/docs/modules/Create.html +0 -7
  119. package/docs/modules/Dialogs.html +0 -12
  120. package/docs/modules/Events.html +0 -10
  121. package/docs/modules/Flags.html +0 -2
  122. package/docs/modules/Screens.html +0 -7
  123. package/docs/modules/System.html +0 -14
  124. package/docs/modules/WML.html +0 -3
  125. package/docs/modules.html +0 -14
  126. package/docs/variables/Events.Types.html +0 -1
  127. package/docs/variables/Window.html +0 -2
  128. package/src/browser.js +0 -24
  129. package/src/calls.js +0 -221
  130. package/src/clipboard.js +0 -35
  131. package/src/contextmenu.js +0 -97
  132. package/src/dialogs.js +0 -200
  133. package/src/drag.js +0 -119
  134. package/src/event_types.js +0 -219
  135. package/src/events.js +0 -140
  136. package/src/flags.js +0 -25
  137. package/src/index.js +0 -60
  138. package/src/runtime.js +0 -92
  139. package/src/screens.js +0 -71
  140. package/src/system.js +0 -143
  141. package/src/window.js +0 -638
  142. package/tsconfig.json +0 -20
@@ -0,0 +1,434 @@
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
+ static [x: symbol]: PromiseConstructor;
112
+ /**
113
+ * Creates a new `CancellablePromise`.
114
+ *
115
+ * @param executor - A callback used to initialize the promise. This callback is passed two arguments:
116
+ * a `resolve` callback used to resolve the promise with a value
117
+ * or the result of another promise (possibly cancellable),
118
+ * and a `reject` callback used to reject the promise with a provided reason or error.
119
+ * If the value provided to the `resolve` callback is a thenable _and_ cancellable object
120
+ * (it has a `then` _and_ a `cancel` method),
121
+ * cancellation requests will be forwarded to that object and the oncancelled will not be invoked anymore.
122
+ * If any one of the two callbacks is called _after_ the promise has been cancelled,
123
+ * the provided values will be cancelled and resolved as usual,
124
+ * but their results will be discarded.
125
+ * However, if the resolution process ultimately ends up in a rejection
126
+ * that is not due to cancellation, the rejection reason
127
+ * will be wrapped in a {@link CancelledRejectionError}
128
+ * and bubbled up as an unhandled rejection.
129
+ * @param oncancelled - It is the caller's responsibility to ensure that any operation
130
+ * started by the executor is properly halted upon cancellation.
131
+ * This optional callback can be used to that purpose.
132
+ * It will be called _synchronously_ with a cancellation cause
133
+ * when cancellation is requested, _after_ the promise has already rejected
134
+ * with a {@link CancelError}, but _before_
135
+ * any {@link then}/{@link catch}/{@link finally} callback runs.
136
+ * If the callback returns a thenable, the promise returned from {@link cancel}
137
+ * will only fulfill after the former has settled.
138
+ * Unhandled exceptions or rejections from the callback will be wrapped
139
+ * in a {@link CancelledRejectionError} and bubbled up as unhandled rejections.
140
+ * If the `resolve` callback is called before cancellation with a cancellable promise,
141
+ * cancellation requests on this promise will be diverted to that promise,
142
+ * and the original `oncancelled` callback will be discarded.
143
+ */
144
+ constructor(executor: CancellablePromiseExecutor<T>, oncancelled?: CancellablePromiseCanceller);
145
+ /**
146
+ * Cancels immediately the execution of the operation associated with this promise.
147
+ * The promise rejects with a {@link CancelError} instance as reason,
148
+ * with the {@link CancelError#cause} property set to the given argument, if any.
149
+ *
150
+ * Has no effect if called after the promise has already settled;
151
+ * repeated calls in particular are safe, but only the first one
152
+ * will set the cancellation cause.
153
+ *
154
+ * The `CancelError` exception _need not_ be handled explicitly _on the promises that are being cancelled:_
155
+ * cancelling a promise with no attached rejection handler does not trigger an unhandled rejection event.
156
+ * Therefore, the following idioms are all equally correct:
157
+ * ```ts
158
+ * new CancellablePromise((resolve, reject) => { ... }).cancel();
159
+ * new CancellablePromise((resolve, reject) => { ... }).then(...).cancel();
160
+ * new CancellablePromise((resolve, reject) => { ... }).then(...).catch(...).cancel();
161
+ * ```
162
+ * Whenever some cancelled promise in a chain rejects with a `CancelError`
163
+ * with the same cancellation cause as itself, the error will be discarded silently.
164
+ * However, the `CancelError` _will still be delivered_ to all attached rejection handlers
165
+ * added by {@link then} and related methods:
166
+ * ```ts
167
+ * let cancellable = new CancellablePromise((resolve, reject) => { ... });
168
+ * cancellable.then(() => { ... }).catch(console.log);
169
+ * cancellable.cancel(); // A CancelError is printed to the console.
170
+ * ```
171
+ * If the `CancelError` is not handled downstream by the time it reaches
172
+ * a _non-cancelled_ promise, it _will_ trigger an unhandled rejection event,
173
+ * just like normal rejections would:
174
+ * ```ts
175
+ * let cancellable = new CancellablePromise((resolve, reject) => { ... });
176
+ * let chained = cancellable.then(() => { ... }).then(() => { ... }); // No catch...
177
+ * cancellable.cancel(); // Unhandled rejection event on chained!
178
+ * ```
179
+ * Therefore, it is important to either cancel whole promise chains from their tail,
180
+ * as shown in the correct idioms above, or take care of handling errors everywhere.
181
+ *
182
+ * @returns A cancellable promise that _fulfills_ after the cancel callback (if any)
183
+ * and all handlers attached up to the call to cancel have run.
184
+ * If the cancel callback returns a thenable, the promise returned by `cancel`
185
+ * will also wait for that thenable to settle.
186
+ * This enables callers to wait for the cancelled operation to terminate
187
+ * without being forced to handle potential errors at the call site.
188
+ * ```ts
189
+ * cancellable.cancel().then(() => {
190
+ * // Cleanup finished, it's safe to do something else.
191
+ * }, (err) => {
192
+ * // Unreachable: the promise returned from cancel will never reject.
193
+ * });
194
+ * ```
195
+ * Note that the returned promise will _not_ handle implicitly any rejection
196
+ * that might have occurred already in the cancelled chain.
197
+ * It will just track whether registered handlers have been executed or not.
198
+ * Therefore, unhandled rejections will never be silently handled by calling cancel.
199
+ */
200
+ cancel(cause?: any): CancellablePromise<void>;
201
+ /**
202
+ * Binds promise cancellation to the abort event of the given {@link AbortSignal}.
203
+ * If the signal has already aborted, the promise will be cancelled immediately.
204
+ * When either condition is verified, the cancellation cause will be set
205
+ * to the signal's abort reason (see {@link AbortSignal#reason}).
206
+ *
207
+ * Has no effect if called (or if the signal aborts) _after_ the promise has already settled.
208
+ * Only the first signal to abort will set the cancellation cause.
209
+ *
210
+ * For more details about the cancellation process,
211
+ * see {@link cancel} and the `CancellablePromise` constructor.
212
+ *
213
+ * This method enables `await`ing cancellable promises without having
214
+ * to store them for future cancellation, e.g.:
215
+ * ```ts
216
+ * await longRunningOperation().cancelOn(signal);
217
+ * ```
218
+ * instead of:
219
+ * ```ts
220
+ * let promiseToBeCancelled = longRunningOperation();
221
+ * await promiseToBeCancelled;
222
+ * ```
223
+ *
224
+ * @returns This promise, for method chaining.
225
+ */
226
+ cancelOn(signal: AbortSignal): CancellablePromise<T>;
227
+ /**
228
+ * Attaches callbacks for the resolution and/or rejection of the `CancellablePromise`.
229
+ *
230
+ * The optional `oncancelled` argument will be invoked when the returned promise is cancelled,
231
+ * with the same semantics as the `oncancelled` argument of the constructor.
232
+ * When the parent promise rejects or is cancelled, the `onrejected` callback will run,
233
+ * _even after the returned promise has been cancelled:_
234
+ * in that case, should it reject or throw, the reason will be wrapped
235
+ * in a {@link CancelledRejectionError} and bubbled up as an unhandled rejection.
236
+ *
237
+ * @param onfulfilled The callback to execute when the Promise is resolved.
238
+ * @param onrejected The callback to execute when the Promise is rejected.
239
+ * @returns A `CancellablePromise` for the completion of whichever callback is executed.
240
+ * The returned promise is hooked up to propagate cancellation requests up the chain, but not down:
241
+ *
242
+ * - if the parent promise is cancelled, the `onrejected` handler will be invoked with a `CancelError`
243
+ * and the returned promise _will resolve regularly_ with its result;
244
+ * - conversely, if the returned promise is cancelled, _the parent promise is cancelled too;_
245
+ * the `onrejected` handler will still be invoked with the parent's `CancelError`,
246
+ * but its result will be discarded
247
+ * and the returned promise will reject with a `CancelError` as well.
248
+ *
249
+ * The promise returned from {@link cancel} will fulfill only after all attached handlers
250
+ * up the entire promise chain have been run.
251
+ *
252
+ * If either callback returns a cancellable promise,
253
+ * cancellation requests will be diverted to it,
254
+ * and the specified `oncancelled` callback will be discarded.
255
+ */
256
+ 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>;
257
+ /**
258
+ * Attaches a callback for only the rejection of the Promise.
259
+ *
260
+ * The optional `oncancelled` argument will be invoked when the returned promise is cancelled,
261
+ * with the same semantics as the `oncancelled` argument of the constructor.
262
+ * When the parent promise rejects or is cancelled, the `onrejected` callback will run,
263
+ * _even after the returned promise has been cancelled:_
264
+ * in that case, should it reject or throw, the reason will be wrapped
265
+ * in a {@link CancelledRejectionError} and bubbled up as an unhandled rejection.
266
+ *
267
+ * It is equivalent to
268
+ * ```ts
269
+ * cancellablePromise.then(undefined, onrejected, oncancelled);
270
+ * ```
271
+ * and the same caveats apply.
272
+ *
273
+ * @returns A Promise for the completion of the callback.
274
+ * Cancellation requests on the returned promise
275
+ * will propagate up the chain to the parent promise,
276
+ * but not in the other direction.
277
+ *
278
+ * The promise returned from {@link cancel} will fulfill only after all attached handlers
279
+ * up the entire promise chain have been run.
280
+ *
281
+ * If `onrejected` returns a cancellable promise,
282
+ * cancellation requests will be diverted to it,
283
+ * and the specified `oncancelled` callback will be discarded.
284
+ * See {@link then} for more details.
285
+ */
286
+ catch<TResult = never>(onrejected?: ((reason: any) => (PromiseLike<TResult> | TResult)) | undefined | null, oncancelled?: CancellablePromiseCanceller): CancellablePromise<T | TResult>;
287
+ /**
288
+ * Attaches a callback that is invoked when the CancellablePromise is settled (fulfilled or rejected). The
289
+ * resolved value cannot be accessed or modified from the callback.
290
+ * The returned promise will settle in the same state as the original one
291
+ * after the provided callback has completed execution,
292
+ * unless the callback throws or returns a rejecting promise,
293
+ * in which case the returned promise will reject as well.
294
+ *
295
+ * The optional `oncancelled` argument will be invoked when the returned promise is cancelled,
296
+ * with the same semantics as the `oncancelled` argument of the constructor.
297
+ * Once the parent promise settles, the `onfinally` callback will run,
298
+ * _even after the returned promise has been cancelled:_
299
+ * in that case, should it reject or throw, the reason will be wrapped
300
+ * in a {@link CancelledRejectionError} and bubbled up as an unhandled rejection.
301
+ *
302
+ * This method is implemented in terms of {@link then} and the same caveats apply.
303
+ * It is polyfilled, hence available in every OS/webview version.
304
+ *
305
+ * @returns A Promise for the completion of the callback.
306
+ * Cancellation requests on the returned promise
307
+ * will propagate up the chain to the parent promise,
308
+ * but not in the other direction.
309
+ *
310
+ * The promise returned from {@link cancel} will fulfill only after all attached handlers
311
+ * up the entire promise chain have been run.
312
+ *
313
+ * If `onfinally` returns a cancellable promise,
314
+ * cancellation requests will be diverted to it,
315
+ * and the specified `oncancelled` callback will be discarded.
316
+ * See {@link then} for more details.
317
+ */
318
+ finally(onfinally?: (() => void) | undefined | null, oncancelled?: CancellablePromiseCanceller): CancellablePromise<T>;
319
+ /**
320
+ * Creates a CancellablePromise that is resolved with an array of results
321
+ * when all of the provided Promises resolve, or rejected when any Promise is rejected.
322
+ *
323
+ * Every one of the provided objects that is a thenable _and_ cancellable object
324
+ * will be cancelled when the returned promise is cancelled, with the same cause.
325
+ *
326
+ * @group Static Methods
327
+ */
328
+ static all<T>(values: Iterable<T | PromiseLike<T>>): CancellablePromise<Awaited<T>[]>;
329
+ static all<T extends readonly unknown[] | []>(values: T): CancellablePromise<{
330
+ -readonly [P in keyof T]: Awaited<T[P]>;
331
+ }>;
332
+ /**
333
+ * Creates a CancellablePromise that is resolved with an array of results
334
+ * when all of the provided Promises resolve or reject.
335
+ *
336
+ * Every one of the provided objects that is a thenable _and_ cancellable object
337
+ * will be cancelled when the returned promise is cancelled, with the same cause.
338
+ *
339
+ * @group Static Methods
340
+ */
341
+ static allSettled<T>(values: Iterable<T | PromiseLike<T>>): CancellablePromise<PromiseSettledResult<Awaited<T>>[]>;
342
+ static allSettled<T extends readonly unknown[] | []>(values: T): CancellablePromise<{
343
+ -readonly [P in keyof T]: PromiseSettledResult<Awaited<T[P]>>;
344
+ }>;
345
+ /**
346
+ * The any function returns a promise that is fulfilled by the first given promise to be fulfilled,
347
+ * or rejected with an AggregateError containing an array of rejection reasons
348
+ * if all of the given promises are rejected.
349
+ * It resolves all elements of the passed iterable to promises as it runs this algorithm.
350
+ *
351
+ * Every one of the provided objects that is a thenable _and_ cancellable object
352
+ * will be cancelled when the returned promise is cancelled, with the same cause.
353
+ *
354
+ * @group Static Methods
355
+ */
356
+ static any<T>(values: Iterable<T | PromiseLike<T>>): CancellablePromise<Awaited<T>>;
357
+ static any<T extends readonly unknown[] | []>(values: T): CancellablePromise<Awaited<T[number]>>;
358
+ /**
359
+ * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.
360
+ *
361
+ * Every one of the provided objects that is a thenable _and_ cancellable object
362
+ * will be cancelled when the returned promise is cancelled, with the same cause.
363
+ *
364
+ * @group Static Methods
365
+ */
366
+ static race<T>(values: Iterable<T | PromiseLike<T>>): CancellablePromise<Awaited<T>>;
367
+ static race<T extends readonly unknown[] | []>(values: T): CancellablePromise<Awaited<T[number]>>;
368
+ /**
369
+ * Creates a new cancelled CancellablePromise for the provided cause.
370
+ *
371
+ * @group Static Methods
372
+ */
373
+ static cancel<T = never>(cause?: any): CancellablePromise<T>;
374
+ /**
375
+ * Creates a new CancellablePromise that cancels
376
+ * after the specified timeout, with the provided cause.
377
+ *
378
+ * If the {@link AbortSignal.timeout} factory method is available,
379
+ * it is used to base the timeout on _active_ time rather than _elapsed_ time.
380
+ * Otherwise, `timeout` falls back to {@link setTimeout}.
381
+ *
382
+ * @group Static Methods
383
+ */
384
+ static timeout<T = never>(milliseconds: number, cause?: any): CancellablePromise<T>;
385
+ /**
386
+ * Creates a new CancellablePromise that resolves after the specified timeout.
387
+ * The returned promise can be cancelled without consequences.
388
+ *
389
+ * @group Static Methods
390
+ */
391
+ static sleep(milliseconds: number): CancellablePromise<void>;
392
+ /**
393
+ * Creates a new CancellablePromise that resolves after
394
+ * the specified timeout, with the provided value.
395
+ * The returned promise can be cancelled without consequences.
396
+ *
397
+ * @group Static Methods
398
+ */
399
+ static sleep<T>(milliseconds: number, value: T): CancellablePromise<T>;
400
+ /**
401
+ * Creates a new rejected CancellablePromise for the provided reason.
402
+ *
403
+ * @group Static Methods
404
+ */
405
+ static reject<T = never>(reason?: any): CancellablePromise<T>;
406
+ /**
407
+ * Creates a new resolved CancellablePromise.
408
+ *
409
+ * @group Static Methods
410
+ */
411
+ static resolve(): CancellablePromise<void>;
412
+ /**
413
+ * Creates a new resolved CancellablePromise for the provided value.
414
+ *
415
+ * @group Static Methods
416
+ */
417
+ static resolve<T>(value: T): CancellablePromise<Awaited<T>>;
418
+ /**
419
+ * Creates a new resolved CancellablePromise for the provided value.
420
+ *
421
+ * @group Static Methods
422
+ */
423
+ static resolve<T>(value: T | PromiseLike<T>): CancellablePromise<Awaited<T>>;
424
+ /**
425
+ * Creates a new CancellablePromise and returns it in an object, along with its resolve and reject functions
426
+ * and a getter/setter for the cancellation callback.
427
+ *
428
+ * This method is polyfilled, hence available in every OS/webview version.
429
+ *
430
+ * @group Static Methods
431
+ */
432
+ static withResolvers<T>(): CancellablePromiseWithResolvers<T>;
433
+ }
434
+ export {};
@@ -1,12 +1,13 @@
1
1
  /**
2
2
  * Sets the text to the Clipboard.
3
3
  *
4
- * @param {string} text - The text to be set to the Clipboard.
5
- * @return {Promise} - A Promise that resolves when the operation is successful.
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<any>;
7
+ export declare function SetText(text: string): Promise<void>;
8
8
  /**
9
9
  * Get the Clipboard text
10
- * @returns {Promise<string>} A promise that resolves with the text from the Clipboard.
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>;
@@ -0,0 +1 @@
1
+ export {};
package/types/create.d.ts CHANGED
@@ -1,52 +1,31 @@
1
1
  /**
2
2
  * Any is a dummy creation function for simple or unknown types.
3
- * @template T
4
- * @param {any} source
5
- * @returns {T}
6
3
  */
7
- export function Any<T>(source: any): T;
4
+ export declare function Any<T = any>(source: any): T;
8
5
  /**
9
6
  * ByteSlice is a creation function that replaces
10
7
  * null strings with empty strings.
11
- * @param {any} source
12
- * @returns {string}
13
8
  */
14
- export function ByteSlice(source: any): string;
9
+ export declare function ByteSlice(source: any): string;
15
10
  /**
16
11
  * Array takes a creation function for an arbitrary type
17
12
  * and returns an in-place creation function for an array
18
13
  * whose elements are of that type.
19
- * @template T
20
- * @param {(source: any) => T} element
21
- * @returns {(source: any) => T[]}
22
14
  */
23
- export function Array<T>(element: (source: any) => T): (source: any) => T[];
15
+ export declare function Array<T = any>(element: (source: any) => T): (source: any) => T[];
24
16
  /**
25
17
  * Map takes creation functions for two arbitrary types
26
18
  * and returns an in-place creation function for an object
27
19
  * whose keys and values are of those types.
28
- * @template K, V
29
- * @param {(source: any) => K} key
30
- * @param {(source: any) => V} value
31
- * @returns {(source: any) => { [_: K]: V }}
32
20
  */
33
- export function Map<K, V>(key: (source: any) => K, value: (source: any) => V): (source: any) => {};
21
+ export declare function Map<V = any>(key: (source: any) => string, value: (source: any) => V): (source: any) => Record<string, V>;
34
22
  /**
35
23
  * Nullable takes a creation function for an arbitrary type
36
24
  * and returns a creation function for a nullable value of that type.
37
- * @template T
38
- * @param {(source: any) => T} element
39
- * @returns {(source: any) => (T | null)}
40
25
  */
41
- export function Nullable<T>(element: (source: any) => T): (source: any) => T;
26
+ export declare function Nullable<T = any>(element: (source: any) => T): (source: any) => (T | null);
42
27
  /**
43
28
  * Struct takes an object mapping field names to creation functions
44
29
  * and returns an in-place creation function for a struct.
45
- * @template {{ [_: string]: ((source: any) => any) }} T
46
- * @template {{ [Key in keyof T]?: ReturnType<T[Key]> }} U
47
- * @param {T} createField
48
- * @returns {(source: any) => U}
49
30
  */
50
- export function Struct<T extends {
51
- [_: string]: (source: any) => any;
52
- }, U extends { [Key in keyof T]?: ReturnType<T[Key]>; }>(createField: T): (source: any) => U;
31
+ export declare function Struct(createField: Record<string, (source: any) => any>): <U extends Record<string, any> = any>(source: any) => U;