@wailsio/runtime 3.0.0-alpha.4 → 3.0.0-alpha.40
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/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +22 -0
- package/docs/assets/icons.js +15 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +59 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1415 -0
- package/docs/classes/Events.WailsEvent.html +4 -0
- package/docs/functions/Application.Hide.html +2 -0
- package/docs/functions/Application.Quit.html +2 -0
- package/docs/functions/Application.Show.html +2 -0
- package/docs/functions/Browser.OpenURL.html +3 -0
- package/docs/functions/Call.ByID.html +7 -0
- package/docs/functions/Call.ByName.html +6 -0
- package/docs/functions/Call.Call.html +6 -0
- package/docs/functions/Call.Plugin.html +8 -0
- package/docs/functions/Clipboard.SetText.html +6 -0
- package/docs/functions/Clipboard.Text.html +3 -0
- package/docs/functions/Dialogs.Error.html +5 -0
- package/docs/functions/Dialogs.Info.html +5 -0
- package/docs/functions/Dialogs.OpenFile.html +3 -0
- package/docs/functions/Dialogs.Question.html +5 -0
- package/docs/functions/Dialogs.SaveFile.html +3 -0
- package/docs/functions/Dialogs.Warning.html +5 -0
- package/docs/functions/Events.Emit.html +6 -0
- package/docs/functions/Events.Off.html +4 -0
- package/docs/functions/Events.OffAll.html +3 -0
- package/docs/functions/Events.On.html +7 -0
- package/docs/functions/Events.OnMultiple.html +8 -0
- package/docs/functions/Events.Once.html +7 -0
- package/docs/functions/Events.setup.html +1 -0
- package/docs/functions/Flags.GetFlag.html +6 -0
- package/docs/functions/Screens.GetAll.html +3 -0
- package/docs/functions/Screens.GetCurrent.html +3 -0
- package/docs/functions/Screens.GetPrimary.html +3 -0
- package/docs/functions/System.Capabilities.html +4 -0
- package/docs/functions/System.Environment.html +5 -0
- package/docs/functions/System.IsAMD64.html +3 -0
- package/docs/functions/System.IsARM.html +3 -0
- package/docs/functions/System.IsARM64.html +5 -0
- package/docs/functions/System.IsDarkMode.html +5 -0
- package/docs/functions/System.IsDebug.html +1 -0
- package/docs/functions/System.IsLinux.html +3 -0
- package/docs/functions/System.IsMac.html +3 -0
- package/docs/functions/System.IsWindows.html +3 -0
- package/docs/functions/System.invoke.html +1 -0
- package/docs/functions/WML.Enable.html +2 -0
- package/docs/functions/WML.Reload.html +2 -0
- package/docs/index.html +5 -0
- package/docs/interfaces/Dialogs.Button.html +7 -0
- package/docs/interfaces/Dialogs.FileFilter.html +5 -0
- package/docs/interfaces/Dialogs.MessageDialogOptions.html +9 -0
- package/docs/interfaces/Dialogs.OpenFileDialogOptions.html +33 -0
- package/docs/interfaces/Dialogs.SaveFileDialogOptions.html +35 -0
- package/docs/interfaces/Screens.Position.html +5 -0
- package/docs/interfaces/Screens.Rect.html +9 -0
- package/docs/interfaces/Screens.Screen.html +19 -0
- package/docs/interfaces/Screens.Size.html +5 -0
- package/docs/interfaces/System.EnvironmentInfo.html +11 -0
- package/docs/interfaces/System.OSInfo.html +9 -0
- package/docs/modules/Application.html +4 -0
- package/docs/modules/Browser.html +2 -0
- package/docs/modules/Call.html +5 -0
- package/docs/modules/Clipboard.html +3 -0
- package/docs/modules/Dialogs.html +12 -0
- package/docs/modules/Events.html +10 -0
- package/docs/modules/Flags.html +2 -0
- package/docs/modules/Screens.html +8 -0
- package/docs/modules/System.html +14 -0
- package/docs/modules/WML.html +3 -0
- package/docs/modules.html +12 -0
- package/docs/variables/Events.Types.html +1 -0
- package/docs/variables/Window.html +2 -0
- package/package.json +38 -17
- package/{application.js → src/application.js} +46 -46
- package/{browser.js → src/browser.js} +24 -24
- package/src/calls.js +174 -0
- package/{clipboard.js → src/clipboard.js} +35 -35
- package/{contextmenu.js → src/contextmenu.js} +97 -96
- package/src/create.js +125 -0
- package/src/dialogs.js +200 -0
- package/{drag.js → src/drag.js} +119 -125
- package/src/event_types.js +217 -0
- package/{events.js → src/events.js} +140 -134
- package/src/flags.js +25 -0
- package/src/index.js +60 -0
- package/src/nanoid.js +42 -0
- package/{runtime.js → src/runtime.js} +123 -122
- package/src/screens.js +71 -0
- package/{system.js → src/system.js} +143 -118
- package/src/utils.js +86 -0
- package/src/window.js +638 -0
- package/src/wml.js +250 -0
- package/tsconfig.json +20 -0
- package/types/application.d.ts +19 -0
- package/types/browser.d.ts +6 -0
- package/types/calls.d.ts +33 -0
- package/types/clipboard.d.ts +12 -0
- package/types/create.d.ts +45 -0
- package/types/dialogs.d.ts +184 -0
- package/types/event_types.d.ts +217 -0
- package/types/events.d.ts +239 -0
- package/types/flags.d.ts +7 -0
- package/types/index.d.ts +13 -0
- package/types/runtime.d.ts +30 -0
- package/types/screens.d.ts +94 -0
- package/types/system.d.ts +112 -0
- package/types/utils.d.ts +14 -0
- package/types/window.d.ts +407 -0
- package/types/wml.d.ts +12 -0
- package/calls.js +0 -123
- package/dialogs.js +0 -138
- package/flags.js +0 -63
- package/index.js +0 -56
- package/screens.js +0 -45
- package/types.d.ts +0 -130
- package/window.js +0 -122
- package/wml.js +0 -148
package/src/wml.js
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/*
|
|
2
|
+
_ __ _ __
|
|
3
|
+
| | / /___ _(_) /____
|
|
4
|
+
| | /| / / __ `/ / / ___/
|
|
5
|
+
| |/ |/ / /_/ / / (__ )
|
|
6
|
+
|__/|__/\__,_/_/_/____/
|
|
7
|
+
The electron alternative for Go
|
|
8
|
+
(c) Lea Anthony 2019-present
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {OpenURL} from "./browser";
|
|
12
|
+
import {Question} from "./dialogs";
|
|
13
|
+
import {Emit, WailsEvent} from "./events";
|
|
14
|
+
import {canAbortListeners, whenReady} from "./utils";
|
|
15
|
+
import Window from "./window";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Sends an event with the given name and optional data.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} eventName - The name of the event to send.
|
|
21
|
+
* @param {any} [data=null] - Optional data to send along with the event.
|
|
22
|
+
*
|
|
23
|
+
* @return {void}
|
|
24
|
+
*/
|
|
25
|
+
function sendEvent(eventName, data=null) {
|
|
26
|
+
Emit(new WailsEvent(eventName, data));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Calls a method on a specified window.
|
|
31
|
+
* @param {string} windowName - The name of the window to call the method on.
|
|
32
|
+
* @param {string} methodName - The name of the method to call.
|
|
33
|
+
*/
|
|
34
|
+
function callWindowMethod(windowName, methodName) {
|
|
35
|
+
const targetWindow = Window.Get(windowName);
|
|
36
|
+
const method = targetWindow[methodName];
|
|
37
|
+
|
|
38
|
+
if (typeof method !== "function") {
|
|
39
|
+
console.error(`Window method '${methodName}' not found`);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
method.call(targetWindow);
|
|
45
|
+
} catch (e) {
|
|
46
|
+
console.error(`Error calling window method '${methodName}': `, e);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Responds to a triggering event by running appropriate WML actions for the current target
|
|
52
|
+
*
|
|
53
|
+
* @param {Event} ev
|
|
54
|
+
* @return {void}
|
|
55
|
+
*/
|
|
56
|
+
function onWMLTriggered(ev) {
|
|
57
|
+
const element = ev.currentTarget;
|
|
58
|
+
|
|
59
|
+
function runEffect(choice = "Yes") {
|
|
60
|
+
if (choice !== "Yes")
|
|
61
|
+
return;
|
|
62
|
+
|
|
63
|
+
const eventType = element.getAttribute('data-wml-event');
|
|
64
|
+
const targetWindow = element.getAttribute('data-wml-target-window') || "";
|
|
65
|
+
const windowMethod = element.getAttribute('data-wml-window');
|
|
66
|
+
const url = element.getAttribute('data-wml-openURL');
|
|
67
|
+
|
|
68
|
+
if (eventType !== null)
|
|
69
|
+
sendEvent(eventType);
|
|
70
|
+
if (windowMethod !== null)
|
|
71
|
+
callWindowMethod(targetWindow, windowMethod);
|
|
72
|
+
if (url !== null)
|
|
73
|
+
void OpenURL(url);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const confirm = element.getAttribute('data-wml-confirm');
|
|
77
|
+
|
|
78
|
+
if (confirm) {
|
|
79
|
+
Question({
|
|
80
|
+
Title: "Confirm",
|
|
81
|
+
Message: confirm,
|
|
82
|
+
Detached: false,
|
|
83
|
+
Buttons: [
|
|
84
|
+
{ Label: "Yes" },
|
|
85
|
+
{ Label: "No", IsDefault: true }
|
|
86
|
+
]
|
|
87
|
+
}).then(runEffect);
|
|
88
|
+
} else {
|
|
89
|
+
runEffect();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @type {symbol}
|
|
95
|
+
*/
|
|
96
|
+
const controller = Symbol();
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* AbortControllerRegistry does not actually remember active event listeners: instead
|
|
100
|
+
* it ties them to an AbortSignal and uses an AbortController to remove them all at once.
|
|
101
|
+
*/
|
|
102
|
+
class AbortControllerRegistry {
|
|
103
|
+
constructor() {
|
|
104
|
+
/**
|
|
105
|
+
* Stores the AbortController that can be used to remove all currently active listeners.
|
|
106
|
+
*
|
|
107
|
+
* @private
|
|
108
|
+
* @name {@link controller}
|
|
109
|
+
* @member {AbortController}
|
|
110
|
+
*/
|
|
111
|
+
this[controller] = new AbortController();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Returns an options object for addEventListener that ties the listener
|
|
116
|
+
* to the AbortSignal from the current AbortController.
|
|
117
|
+
*
|
|
118
|
+
* @param {HTMLElement} element An HTML element
|
|
119
|
+
* @param {string[]} triggers The list of active WML trigger events for the specified elements
|
|
120
|
+
* @returns {AddEventListenerOptions}
|
|
121
|
+
*/
|
|
122
|
+
set(element, triggers) {
|
|
123
|
+
return { signal: this[controller].signal };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Removes all registered event listeners.
|
|
128
|
+
*
|
|
129
|
+
* @returns {void}
|
|
130
|
+
*/
|
|
131
|
+
reset() {
|
|
132
|
+
this[controller].abort();
|
|
133
|
+
this[controller] = new AbortController();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @type {symbol}
|
|
139
|
+
*/
|
|
140
|
+
const triggerMap = Symbol();
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @type {symbol}
|
|
144
|
+
*/
|
|
145
|
+
const elementCount = Symbol();
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* WeakMapRegistry maps active trigger events to each DOM element through a WeakMap.
|
|
149
|
+
* This ensures that the mapping remains private to this module, while still allowing garbage
|
|
150
|
+
* collection of the involved elements.
|
|
151
|
+
*/
|
|
152
|
+
class WeakMapRegistry {
|
|
153
|
+
constructor() {
|
|
154
|
+
/**
|
|
155
|
+
* Stores the current element-to-trigger mapping.
|
|
156
|
+
*
|
|
157
|
+
* @private
|
|
158
|
+
* @name {@link triggerMap}
|
|
159
|
+
* @member {WeakMap<HTMLElement, string[]>}
|
|
160
|
+
*/
|
|
161
|
+
this[triggerMap] = new WeakMap();
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Counts the number of elements with active WML triggers.
|
|
165
|
+
*
|
|
166
|
+
* @private
|
|
167
|
+
* @name {@link elementCount}
|
|
168
|
+
* @member {number}
|
|
169
|
+
*/
|
|
170
|
+
this[elementCount] = 0;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Sets the active triggers for the specified element.
|
|
175
|
+
*
|
|
176
|
+
* @param {HTMLElement} element An HTML element
|
|
177
|
+
* @param {string[]} triggers The list of active WML trigger events for the specified element
|
|
178
|
+
* @returns {AddEventListenerOptions}
|
|
179
|
+
*/
|
|
180
|
+
set(element, triggers) {
|
|
181
|
+
this[elementCount] += !this[triggerMap].has(element);
|
|
182
|
+
this[triggerMap].set(element, triggers);
|
|
183
|
+
return {};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Removes all registered event listeners.
|
|
188
|
+
*
|
|
189
|
+
* @returns {void}
|
|
190
|
+
*/
|
|
191
|
+
reset() {
|
|
192
|
+
if (this[elementCount] <= 0)
|
|
193
|
+
return;
|
|
194
|
+
|
|
195
|
+
for (const element of document.body.querySelectorAll('*')) {
|
|
196
|
+
if (this[elementCount] <= 0)
|
|
197
|
+
break;
|
|
198
|
+
|
|
199
|
+
const triggers = this[triggerMap].get(element);
|
|
200
|
+
this[elementCount] -= (typeof triggers !== "undefined");
|
|
201
|
+
|
|
202
|
+
for (const trigger of triggers || [])
|
|
203
|
+
element.removeEventListener(trigger, onWMLTriggered);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
this[triggerMap] = new WeakMap();
|
|
207
|
+
this[elementCount] = 0;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const triggerRegistry = canAbortListeners() ? new AbortControllerRegistry() : new WeakMapRegistry();
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Adds event listeners to the specified element.
|
|
215
|
+
*
|
|
216
|
+
* @param {HTMLElement} element
|
|
217
|
+
* @return {void}
|
|
218
|
+
*/
|
|
219
|
+
function addWMLListeners(element) {
|
|
220
|
+
const triggerRegExp = /\S+/g;
|
|
221
|
+
const triggerAttr = (element.getAttribute('data-wml-trigger') || "click");
|
|
222
|
+
const triggers = [];
|
|
223
|
+
|
|
224
|
+
let match;
|
|
225
|
+
while ((match = triggerRegExp.exec(triggerAttr)) !== null)
|
|
226
|
+
triggers.push(match[0]);
|
|
227
|
+
|
|
228
|
+
const options = triggerRegistry.set(element, triggers);
|
|
229
|
+
for (const trigger of triggers)
|
|
230
|
+
element.addEventListener(trigger, onWMLTriggered, options);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Schedules an automatic reload of WML to be performed as soon as the document is fully loaded.
|
|
235
|
+
*
|
|
236
|
+
* @return {void}
|
|
237
|
+
*/
|
|
238
|
+
export function Enable() {
|
|
239
|
+
whenReady(Reload);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Reloads the WML page by adding necessary event listeners and browser listeners.
|
|
244
|
+
*
|
|
245
|
+
* @return {void}
|
|
246
|
+
*/
|
|
247
|
+
export function Reload() {
|
|
248
|
+
triggerRegistry.reset();
|
|
249
|
+
document.body.querySelectorAll('[data-wml-event], [data-wml-window], [data-wml-openURL]').forEach(addWMLListeners);
|
|
250
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": ["./src/**/*"],
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"lib": [
|
|
5
|
+
"dom",
|
|
6
|
+
"dom.iterable",
|
|
7
|
+
"esnext"
|
|
8
|
+
],
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"declarationMap": true,
|
|
12
|
+
"emitDeclarationOnly": true,
|
|
13
|
+
"esModuleInterop": true,
|
|
14
|
+
"module": "esnext",
|
|
15
|
+
"moduleResolution": "bundler",
|
|
16
|
+
"outDir": "dist",
|
|
17
|
+
"strict": true,
|
|
18
|
+
"target": "es6",
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides a certain method by calling the HideMethod function.
|
|
3
|
+
*
|
|
4
|
+
* @return {Promise<void>}
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
export function Hide(): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Calls the ShowMethod and returns the result.
|
|
10
|
+
*
|
|
11
|
+
* @return {Promise<void>}
|
|
12
|
+
*/
|
|
13
|
+
export function Show(): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Calls the QuitMethod to terminate the program.
|
|
16
|
+
*
|
|
17
|
+
* @return {Promise<void>}
|
|
18
|
+
*/
|
|
19
|
+
export function Quit(): Promise<void>;
|
package/types/calls.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Call method.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} options - The options for the method.
|
|
5
|
+
* @returns {Object} - The result of the call.
|
|
6
|
+
*/
|
|
7
|
+
export function Call(options: any): any;
|
|
8
|
+
/**
|
|
9
|
+
* Executes a method by name.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} name - The name of the method in the format 'package.struct.method'.
|
|
12
|
+
* @param {...*} args - The arguments to pass to the method.
|
|
13
|
+
* @throws {Error} If the name is not a string or is not in the correct format.
|
|
14
|
+
* @returns {*} The result of the method execution.
|
|
15
|
+
*/
|
|
16
|
+
export function ByName(name: string, ...args: any[]): any;
|
|
17
|
+
/**
|
|
18
|
+
* Calls a method by its ID with the specified arguments.
|
|
19
|
+
*
|
|
20
|
+
* @param {number} methodID - The ID of the method to call.
|
|
21
|
+
* @param {...*} args - The arguments to pass to the method.
|
|
22
|
+
* @return {*} - The result of the method call.
|
|
23
|
+
*/
|
|
24
|
+
export function ByID(methodID: number, ...args: any[]): any;
|
|
25
|
+
/**
|
|
26
|
+
* Calls a method on a plugin.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} pluginName - The name of the plugin.
|
|
29
|
+
* @param {string} methodName - The name of the method to call.
|
|
30
|
+
* @param {...*} args - The arguments to pass to the method.
|
|
31
|
+
* @returns {*} - The result of the method call.
|
|
32
|
+
*/
|
|
33
|
+
export function Plugin(pluginName: string, methodName: string, ...args: any[]): any;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets the text to the Clipboard.
|
|
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.
|
|
6
|
+
*/
|
|
7
|
+
export function SetText(text: string): Promise<any>;
|
|
8
|
+
/**
|
|
9
|
+
* Get the Clipboard text
|
|
10
|
+
* @returns {Promise<string>} A promise that resolves with the text from the Clipboard.
|
|
11
|
+
*/
|
|
12
|
+
export function Text(): Promise<string>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Any is a dummy creation function for simple or unknown types.
|
|
3
|
+
* @template T
|
|
4
|
+
* @param {any} source
|
|
5
|
+
* @returns {T}
|
|
6
|
+
*/
|
|
7
|
+
export function Any<T>(source: any): T;
|
|
8
|
+
/**
|
|
9
|
+
* Array takes a creation function for an arbitrary type
|
|
10
|
+
* and returns an in-place creation function for an array
|
|
11
|
+
* whose elements are of that type.
|
|
12
|
+
* @template T
|
|
13
|
+
* @param {(any) => T} element
|
|
14
|
+
* @returns {(any) => T[]}
|
|
15
|
+
*/
|
|
16
|
+
export function Array<T>(element: (any: any) => T): (any: any) => T[];
|
|
17
|
+
/**
|
|
18
|
+
* Map takes creation functions for two arbitrary types
|
|
19
|
+
* and returns an in-place creation function for an object
|
|
20
|
+
* whose keys and values are of those types.
|
|
21
|
+
* @template K, V
|
|
22
|
+
* @param {(any) => K} key
|
|
23
|
+
* @param {(any) => V} value
|
|
24
|
+
* @returns {(any) => { [_: K]: V }}
|
|
25
|
+
*/
|
|
26
|
+
export function Map<K, V>(key: (any: any) => K, value: (any: any) => V): (any: any) => {};
|
|
27
|
+
/**
|
|
28
|
+
* Nullable takes a creation function for an arbitrary type
|
|
29
|
+
* and returns a creation function for a nullable value of that type.
|
|
30
|
+
* @template T
|
|
31
|
+
* @param {(any) => T} element
|
|
32
|
+
* @returns {(any) => (T | null)}
|
|
33
|
+
*/
|
|
34
|
+
export function Nullable<T>(element: (any: any) => T): (any: any) => T;
|
|
35
|
+
/**
|
|
36
|
+
* Struct takes an object mapping field names to creation functions
|
|
37
|
+
* and returns an in-place creation function for a struct.
|
|
38
|
+
* @template {{ [_: string]: ((any) => any) }} T
|
|
39
|
+
* @template {{ [Key in keyof T]?: ReturnType<T[Key]> }} U
|
|
40
|
+
* @param {T} createField
|
|
41
|
+
* @returns {(any) => U}
|
|
42
|
+
*/
|
|
43
|
+
export function Struct<T extends {
|
|
44
|
+
[_: string]: (any: any) => any;
|
|
45
|
+
}, U extends { [Key in keyof T]?: ReturnType<T[Key]>; }>(createField: T): (any: any) => U;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
export function Info(options: MessageDialogOptions): Promise<string>;
|
|
2
|
+
export function Warning(options: MessageDialogOptions): Promise<string>;
|
|
3
|
+
export function Error(options: MessageDialogOptions): Promise<string>;
|
|
4
|
+
export function Question(options: MessageDialogOptions): Promise<string>;
|
|
5
|
+
export function OpenFile(options: OpenFileDialogOptions): Promise<string[] | string>;
|
|
6
|
+
export function SaveFile(options: SaveFileDialogOptions): Promise<string>;
|
|
7
|
+
export type OpenFileDialogOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* - Indicates if directories can be chosen.
|
|
10
|
+
*/
|
|
11
|
+
CanChooseDirectories?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* - Indicates if files can be chosen.
|
|
14
|
+
*/
|
|
15
|
+
CanChooseFiles?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* - Indicates if directories can be created.
|
|
18
|
+
*/
|
|
19
|
+
CanCreateDirectories?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* - Indicates if hidden files should be shown.
|
|
22
|
+
*/
|
|
23
|
+
ShowHiddenFiles?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* - Indicates if aliases should be resolved.
|
|
26
|
+
*/
|
|
27
|
+
ResolvesAliases?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* - Indicates if multiple selection is allowed.
|
|
30
|
+
*/
|
|
31
|
+
AllowsMultipleSelection?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* - Indicates if the extension should be hidden.
|
|
34
|
+
*/
|
|
35
|
+
HideExtension?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* - Indicates if hidden extensions can be selected.
|
|
38
|
+
*/
|
|
39
|
+
CanSelectHiddenExtension?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* - Indicates if file packages should be treated as directories.
|
|
42
|
+
*/
|
|
43
|
+
TreatsFilePackagesAsDirectories?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* - Indicates if other file types are allowed.
|
|
46
|
+
*/
|
|
47
|
+
AllowsOtherFiletypes?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* - Array of file filters.
|
|
50
|
+
*/
|
|
51
|
+
Filters?: FileFilter[];
|
|
52
|
+
/**
|
|
53
|
+
* - Title of the dialog.
|
|
54
|
+
*/
|
|
55
|
+
Title?: string;
|
|
56
|
+
/**
|
|
57
|
+
* - Message to show in the dialog.
|
|
58
|
+
*/
|
|
59
|
+
Message?: string;
|
|
60
|
+
/**
|
|
61
|
+
* - Text to display on the button.
|
|
62
|
+
*/
|
|
63
|
+
ButtonText?: string;
|
|
64
|
+
/**
|
|
65
|
+
* - Directory to open in the dialog.
|
|
66
|
+
*/
|
|
67
|
+
Directory?: string;
|
|
68
|
+
/**
|
|
69
|
+
* - Indicates if the dialog should appear detached from the main window.
|
|
70
|
+
*/
|
|
71
|
+
Detached?: boolean;
|
|
72
|
+
};
|
|
73
|
+
export type SaveFileDialogOptions = {
|
|
74
|
+
/**
|
|
75
|
+
* - Default filename to use in the dialog.
|
|
76
|
+
*/
|
|
77
|
+
Filename?: string;
|
|
78
|
+
/**
|
|
79
|
+
* - Indicates if directories can be chosen.
|
|
80
|
+
*/
|
|
81
|
+
CanChooseDirectories?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* - Indicates if files can be chosen.
|
|
84
|
+
*/
|
|
85
|
+
CanChooseFiles?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* - Indicates if directories can be created.
|
|
88
|
+
*/
|
|
89
|
+
CanCreateDirectories?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* - Indicates if hidden files should be shown.
|
|
92
|
+
*/
|
|
93
|
+
ShowHiddenFiles?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* - Indicates if aliases should be resolved.
|
|
96
|
+
*/
|
|
97
|
+
ResolvesAliases?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* - Indicates if multiple selection is allowed.
|
|
100
|
+
*/
|
|
101
|
+
AllowsMultipleSelection?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* - Indicates if the extension should be hidden.
|
|
104
|
+
*/
|
|
105
|
+
HideExtension?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* - Indicates if hidden extensions can be selected.
|
|
108
|
+
*/
|
|
109
|
+
CanSelectHiddenExtension?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* - Indicates if file packages should be treated as directories.
|
|
112
|
+
*/
|
|
113
|
+
TreatsFilePackagesAsDirectories?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* - Indicates if other file types are allowed.
|
|
116
|
+
*/
|
|
117
|
+
AllowsOtherFiletypes?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* - Array of file filters.
|
|
120
|
+
*/
|
|
121
|
+
Filters?: FileFilter[];
|
|
122
|
+
/**
|
|
123
|
+
* - Title of the dialog.
|
|
124
|
+
*/
|
|
125
|
+
Title?: string;
|
|
126
|
+
/**
|
|
127
|
+
* - Message to show in the dialog.
|
|
128
|
+
*/
|
|
129
|
+
Message?: string;
|
|
130
|
+
/**
|
|
131
|
+
* - Text to display on the button.
|
|
132
|
+
*/
|
|
133
|
+
ButtonText?: string;
|
|
134
|
+
/**
|
|
135
|
+
* - Directory to open in the dialog.
|
|
136
|
+
*/
|
|
137
|
+
Directory?: string;
|
|
138
|
+
/**
|
|
139
|
+
* - Indicates if the dialog should appear detached from the main window.
|
|
140
|
+
*/
|
|
141
|
+
Detached?: boolean;
|
|
142
|
+
};
|
|
143
|
+
export type MessageDialogOptions = {
|
|
144
|
+
/**
|
|
145
|
+
* - The title of the dialog window.
|
|
146
|
+
*/
|
|
147
|
+
Title?: string;
|
|
148
|
+
/**
|
|
149
|
+
* - The main message to show in the dialog.
|
|
150
|
+
*/
|
|
151
|
+
Message?: string;
|
|
152
|
+
/**
|
|
153
|
+
* - Array of button options to show in the dialog.
|
|
154
|
+
*/
|
|
155
|
+
Buttons?: Button[];
|
|
156
|
+
/**
|
|
157
|
+
* - True if the dialog should appear detached from the main window (if applicable).
|
|
158
|
+
*/
|
|
159
|
+
Detached?: boolean;
|
|
160
|
+
};
|
|
161
|
+
export type Button = {
|
|
162
|
+
/**
|
|
163
|
+
* - Text that appears within the button.
|
|
164
|
+
*/
|
|
165
|
+
Label?: string;
|
|
166
|
+
/**
|
|
167
|
+
* - True if the button should cancel an operation when clicked.
|
|
168
|
+
*/
|
|
169
|
+
IsCancel?: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* - True if the button should be the default action when the user presses enter.
|
|
172
|
+
*/
|
|
173
|
+
IsDefault?: boolean;
|
|
174
|
+
};
|
|
175
|
+
export type FileFilter = {
|
|
176
|
+
/**
|
|
177
|
+
* - Display name for the filter, it could be "Text Files", "Images" etc.
|
|
178
|
+
*/
|
|
179
|
+
DisplayName?: string;
|
|
180
|
+
/**
|
|
181
|
+
* - Pattern to match for the filter, e.g. "*.txt;*.md" for text markdown files.
|
|
182
|
+
*/
|
|
183
|
+
Pattern?: string;
|
|
184
|
+
};
|