@wailsio/runtime 3.0.0-alpha.5 → 3.0.0-alpha.55
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/Create.Any.html +2 -0
- package/docs/functions/Create.Array.html +4 -0
- package/docs/functions/Create.ByteSlice.html +3 -0
- package/docs/functions/Create.Map.html +4 -0
- package/docs/functions/Create.Nullable.html +3 -0
- package/docs/functions/Create.Struct.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/functions/init.html +1 -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.Rect.html +9 -0
- package/docs/interfaces/Screens.Screen.html +25 -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/Create.html +7 -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 +7 -0
- package/docs/modules/System.html +14 -0
- package/docs/modules/WML.html +3 -0
- package/docs/modules.html +14 -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 -98
- 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 +219 -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 -122
- 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 +52 -0
- package/types/dialogs.d.ts +184 -0
- package/types/event_types.d.ts +219 -0
- package/types/events.d.ts +271 -0
- package/types/flags.d.ts +7 -0
- package/types/index.d.ts +14 -0
- package/types/nanoid.d.ts +1 -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/dialogs.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
_ __ _ __
|
|
3
|
-
| | / /___ _(_) /____
|
|
4
|
-
| | /| / / __ `/ / / ___/
|
|
5
|
-
| |/ |/ / /_/ / / (__ )
|
|
6
|
-
|__/|__/\__,_/_/_/____/
|
|
7
|
-
The electron alternative for Go
|
|
8
|
-
(c) Lea Anthony 2019-present
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/* jshint esversion: 9 */
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @typedef {import("./types").MessageDialogOptions} MessageDialogOptions
|
|
15
|
-
* @typedef {import("./types").OpenDialogOptions} OpenDialogOptions
|
|
16
|
-
* @typedef {import("./types").SaveDialogOptions} SaveDialogOptions
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import {newRuntimeCallerWithID, objectNames} from "./runtime";
|
|
20
|
-
|
|
21
|
-
import { nanoid } from 'nanoid/non-secure';
|
|
22
|
-
|
|
23
|
-
// Define constants from the `methods` object in Title Case
|
|
24
|
-
const DialogInfo = 0;
|
|
25
|
-
const DialogWarning = 1;
|
|
26
|
-
const DialogError = 2;
|
|
27
|
-
const DialogQuestion = 3;
|
|
28
|
-
const DialogOpenFile = 4;
|
|
29
|
-
const DialogSaveFile = 5;
|
|
30
|
-
|
|
31
|
-
const call = newRuntimeCallerWithID(objectNames.Dialog, '');
|
|
32
|
-
const dialogResponses = new Map();
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Generates a unique id that is not present in dialogResponses.
|
|
36
|
-
* @returns {string} unique id
|
|
37
|
-
*/
|
|
38
|
-
function generateID() {
|
|
39
|
-
let result;
|
|
40
|
-
do {
|
|
41
|
-
result = nanoid();
|
|
42
|
-
} while (dialogResponses.has(result));
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Shows a dialog of specified type with the given options.
|
|
48
|
-
* @param {number} type - type of dialog
|
|
49
|
-
* @param {object} options - options for the dialog
|
|
50
|
-
* @returns {Promise} promise that resolves with result of dialog
|
|
51
|
-
*/
|
|
52
|
-
function dialog(type, options = {}) {
|
|
53
|
-
const id = generateID();
|
|
54
|
-
options["dialog-id"] = id;
|
|
55
|
-
return new Promise((resolve, reject) => {
|
|
56
|
-
dialogResponses.set(id, {resolve, reject});
|
|
57
|
-
call(type, options).catch((error) => {
|
|
58
|
-
reject(error);
|
|
59
|
-
dialogResponses.delete(id);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Handles the callback from a dialog.
|
|
66
|
-
*
|
|
67
|
-
* @param {string} id - The ID of the dialog response.
|
|
68
|
-
* @param {string} data - The data received from the dialog.
|
|
69
|
-
* @param {boolean} isJSON - Flag indicating whether the data is in JSON format.
|
|
70
|
-
*
|
|
71
|
-
* @return {undefined}
|
|
72
|
-
*/
|
|
73
|
-
export function dialogCallback(id, data, isJSON) {
|
|
74
|
-
let p = dialogResponses.get(id);
|
|
75
|
-
if (p) {
|
|
76
|
-
if (isJSON) {
|
|
77
|
-
p.resolve(JSON.parse(data));
|
|
78
|
-
} else {
|
|
79
|
-
p.resolve(data);
|
|
80
|
-
}
|
|
81
|
-
dialogResponses.delete(id);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Callback function for handling errors in dialog.
|
|
87
|
-
*
|
|
88
|
-
* @param {string} id - The id of the dialog response.
|
|
89
|
-
* @param {string} message - The error message.
|
|
90
|
-
*
|
|
91
|
-
* @return {void}
|
|
92
|
-
*/
|
|
93
|
-
export function dialogErrorCallback(id, message) {
|
|
94
|
-
let p = dialogResponses.get(id);
|
|
95
|
-
if (p) {
|
|
96
|
-
p.reject(message);
|
|
97
|
-
dialogResponses.delete(id);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
// Replace `methods` with constants in Title Case
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* @param {MessageDialogOptions} options - Dialog options
|
|
106
|
-
* @returns {Promise<string>} - The label of the button pressed
|
|
107
|
-
*/
|
|
108
|
-
export const Info = (options) => dialog(DialogInfo, options);
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* @param {MessageDialogOptions} options - Dialog options
|
|
112
|
-
* @returns {Promise<string>} - The label of the button pressed
|
|
113
|
-
*/
|
|
114
|
-
export const Warning = (options) => dialog(DialogWarning, options);
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* @param {MessageDialogOptions} options - Dialog options
|
|
118
|
-
* @returns {Promise<string>} - The label of the button pressed
|
|
119
|
-
*/
|
|
120
|
-
export const Error = (options) => dialog(DialogError, options);
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* @param {MessageDialogOptions} options - Dialog options
|
|
124
|
-
* @returns {Promise<string>} - The label of the button pressed
|
|
125
|
-
*/
|
|
126
|
-
export const Question = (options) => dialog(DialogQuestion, options);
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* @param {OpenDialogOptions} options - Dialog options
|
|
130
|
-
* @returns {Promise<string[]|string>} Returns selected file or list of files. Returns blank string if no file is selected.
|
|
131
|
-
*/
|
|
132
|
-
export const OpenFile = (options) => dialog(DialogOpenFile, options);
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* @param {SaveDialogOptions} options - Dialog options
|
|
136
|
-
* @returns {Promise<string>} Returns the selected file. Returns blank string if no file is selected.
|
|
137
|
-
*/
|
|
138
|
-
export const SaveFile = (options) => dialog(DialogSaveFile, options);
|
package/flags.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
_ __ _ __
|
|
3
|
-
| | / /___ _(_) /____
|
|
4
|
-
| | /| / / __ `/ / / ___/
|
|
5
|
-
| |/ |/ / /_/ / / (__ )
|
|
6
|
-
|__/|__/\__,_/_/_/____/
|
|
7
|
-
The electron alternative for Go
|
|
8
|
-
(c) Lea Anthony 2019-present
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/* jshint esversion: 9 */
|
|
12
|
-
|
|
13
|
-
let flags = new Map();
|
|
14
|
-
|
|
15
|
-
function convertToMap(obj) {
|
|
16
|
-
const map = new Map();
|
|
17
|
-
|
|
18
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
19
|
-
if (typeof value === 'object' && value !== null) {
|
|
20
|
-
map.set(key, convertToMap(value)); // Recursively convert nested object
|
|
21
|
-
} else {
|
|
22
|
-
map.set(key, value);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return map;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
fetch("/wails/flags").then((response) => {
|
|
30
|
-
response.json().then((data) => {
|
|
31
|
-
flags = convertToMap(data);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function getValueFromMap(keyString) {
|
|
37
|
-
const keys = keyString.split('.');
|
|
38
|
-
let value = flags;
|
|
39
|
-
|
|
40
|
-
for (const key of keys) {
|
|
41
|
-
if (value instanceof Map) {
|
|
42
|
-
value = value.get(key);
|
|
43
|
-
} else {
|
|
44
|
-
value = value[key];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (value === undefined) {
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return value;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Retrieves the value associated with the specified key from the flag map.
|
|
57
|
-
*
|
|
58
|
-
* @param {string} keyString - The key to retrieve the value for.
|
|
59
|
-
* @return {*} - The value associated with the specified key.
|
|
60
|
-
*/
|
|
61
|
-
export function GetFlag(keyString) {
|
|
62
|
-
return getValueFromMap(keyString);
|
|
63
|
-
}
|
package/index.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
_ __ _ __
|
|
3
|
-
| | / /___ _(_) /____
|
|
4
|
-
| | /| / / __ `/ / / ___/
|
|
5
|
-
| |/ |/ / /_/ / / (__ )
|
|
6
|
-
|__/|__/\__,_/_/_/____/
|
|
7
|
-
The electron alternative for Go
|
|
8
|
-
(c) Lea Anthony 2019-present
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import {setupContextMenus} from "./contextmenu";
|
|
12
|
-
import {setupDrag} from "./drag";
|
|
13
|
-
import {reloadWML} from "./wml";
|
|
14
|
-
import {Emit, Off, OffAll, On, Once, OnMultiple, WailsEvent} from './events';
|
|
15
|
-
import {ByID, ByName, Plugin} from "./calls";
|
|
16
|
-
import {Error, Info, OpenFile, Question, SaveFile, Warning} from "./dialogs";
|
|
17
|
-
|
|
18
|
-
export * as Application from "./application";
|
|
19
|
-
export * as Browser from "./browser";
|
|
20
|
-
export * as Clipboard from "./clipboard";
|
|
21
|
-
export * as ContextMenu from "./contextmenu";
|
|
22
|
-
export * as Flags from "./flags";
|
|
23
|
-
export * as Runtime from "./runtime";
|
|
24
|
-
export * as Screens from "./screens";
|
|
25
|
-
export * as System from "./system";
|
|
26
|
-
export * as Window from "./window";
|
|
27
|
-
|
|
28
|
-
export const Events = {
|
|
29
|
-
On,
|
|
30
|
-
Off,
|
|
31
|
-
OnMultiple,
|
|
32
|
-
WailsEvent,
|
|
33
|
-
OffAll,
|
|
34
|
-
Emit,
|
|
35
|
-
Once
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const Call = {
|
|
40
|
-
Plugin,
|
|
41
|
-
ByID,
|
|
42
|
-
ByName
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export const Dialogs = {
|
|
46
|
-
Info,
|
|
47
|
-
Error,
|
|
48
|
-
OpenFile, Question, Warning, SaveFile
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
setupContextMenus();
|
|
52
|
-
setupDrag();
|
|
53
|
-
|
|
54
|
-
document.addEventListener("DOMContentLoaded", function () {
|
|
55
|
-
reloadWML();
|
|
56
|
-
});
|
package/screens.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
_ __ _ __
|
|
3
|
-
| | / /___ _(_) /____
|
|
4
|
-
| | /| / / __ `/ / / ___/
|
|
5
|
-
| |/ |/ / /_/ / / (__ )
|
|
6
|
-
|__/|__/\__,_/_/_/____/
|
|
7
|
-
The electron alternative for Go
|
|
8
|
-
(c) Lea Anthony 2019-present
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/* jshint esversion: 9 */
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @typedef {import("./api/types").Screen} Screen
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import {newRuntimeCallerWithID, objectNames} from "./runtime";
|
|
18
|
-
const call = newRuntimeCallerWithID(objectNames.Screens, '');
|
|
19
|
-
|
|
20
|
-
const getAll = 0;
|
|
21
|
-
const getPrimary = 1;
|
|
22
|
-
const getCurrent = 2;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Gets all screens.
|
|
26
|
-
* @returns {Promise<Screen[]>} A promise that resolves to an array of Screen objects.
|
|
27
|
-
*/
|
|
28
|
-
export function GetAll() {
|
|
29
|
-
return call(getAll);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Gets the primary screen.
|
|
33
|
-
* @returns {Promise<Screen>} A promise that resolves to the primary screen.
|
|
34
|
-
*/
|
|
35
|
-
export function GetPrimary() {
|
|
36
|
-
return call(getPrimary);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Gets the current active screen.
|
|
40
|
-
*
|
|
41
|
-
* @returns {Promise<Screen>} A promise that resolves with the current active screen.
|
|
42
|
-
*/
|
|
43
|
-
export function GetCurrent() {
|
|
44
|
-
return call(getCurrent);
|
|
45
|
-
}
|
package/types.d.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export interface Button {
|
|
3
|
-
// The label of the button
|
|
4
|
-
Label?: string;
|
|
5
|
-
// True if this button is the cancel button (selected when pressing escape)
|
|
6
|
-
IsCancel?: boolean;
|
|
7
|
-
// True if this button is the default button (selected when pressing enter)
|
|
8
|
-
IsDefault?: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface MessageDialogOptions {
|
|
12
|
-
// The title for the dialog
|
|
13
|
-
Title?: string;
|
|
14
|
-
// The message to display
|
|
15
|
-
Message?: string;
|
|
16
|
-
// The buttons to use on the dialog
|
|
17
|
-
Buttons?: Button[];
|
|
18
|
-
// Whether the dialog is detached from the current window
|
|
19
|
-
Detached?: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface OpenFileDialogOptions {
|
|
23
|
-
// Allows the user to be able to select directories
|
|
24
|
-
CanChooseDirectories?: boolean;
|
|
25
|
-
// Allows the user to be able to select files
|
|
26
|
-
CanChooseFiles?: boolean;
|
|
27
|
-
// Provide an option to create directories in the dialog
|
|
28
|
-
CanCreateDirectories?: boolean;
|
|
29
|
-
// Makes the dialog show hidden files
|
|
30
|
-
ShowHiddenFiles?: boolean;
|
|
31
|
-
// Whether the dialog should follow filesystem aliases
|
|
32
|
-
ResolvesAliases?: boolean;
|
|
33
|
-
// Allow the user to select multiple files or directories
|
|
34
|
-
AllowsMultipleSelection?: boolean;
|
|
35
|
-
// Hide the extension when showing the filename
|
|
36
|
-
HideExtension?: boolean;
|
|
37
|
-
// Allow the user to select files where the system hides their extensions
|
|
38
|
-
CanSelectHiddenExtension?: boolean;
|
|
39
|
-
// Treats file packages as directories, e.g. .app on macOS
|
|
40
|
-
TreatsFilePackagesAsDirectories?: boolean;
|
|
41
|
-
// Allows selection of filetypes not specified in the filters
|
|
42
|
-
AllowsOtherFiletypes?: boolean;
|
|
43
|
-
// The file filters to use in the dialog
|
|
44
|
-
Filters?: FileFilter[];
|
|
45
|
-
// The title of the dialog
|
|
46
|
-
Title?: string;
|
|
47
|
-
// The message to display
|
|
48
|
-
Message?: string;
|
|
49
|
-
// The label for the select button
|
|
50
|
-
ButtonText?: string;
|
|
51
|
-
// The default directory to open the dialog in
|
|
52
|
-
Directory?: string;
|
|
53
|
-
// Whether the dialog is detached from the current window
|
|
54
|
-
Detached?: boolean;
|
|
55
|
-
}
|
|
56
|
-
export interface FileFilter {
|
|
57
|
-
// The display name for the filter, e.g. "Text Files"
|
|
58
|
-
DisplayName?: string;
|
|
59
|
-
// The pattern to use for the filter, e.g. "*.txt;*.md"
|
|
60
|
-
Pattern?: string;
|
|
61
|
-
}
|
|
62
|
-
export interface SaveFileDialogOptions {
|
|
63
|
-
// Provide an option to create directories in the dialog
|
|
64
|
-
CanCreateDirectories?: boolean;
|
|
65
|
-
// Makes the dialog show hidden files
|
|
66
|
-
ShowHiddenFiles?: boolean;
|
|
67
|
-
// Allow the user to select files where the system hides their extensions
|
|
68
|
-
CanSelectHiddenExtension?: boolean;
|
|
69
|
-
// Allows selection of filetypes not specified in the filters
|
|
70
|
-
AllowOtherFiletypes?: boolean;
|
|
71
|
-
// Hide the extension when showing the filename
|
|
72
|
-
HideExtension?: boolean;
|
|
73
|
-
// Treats file packages as directories, e.g. .app on macOS
|
|
74
|
-
TreatsFilePackagesAsDirectories?: boolean;
|
|
75
|
-
// The message to show in the dialog
|
|
76
|
-
Message?: string;
|
|
77
|
-
// The default directory to open the dialog in
|
|
78
|
-
Directory?: string;
|
|
79
|
-
// The default filename to use in the dialog
|
|
80
|
-
Filename?: string;
|
|
81
|
-
// The label for the select button
|
|
82
|
-
ButtonText?: string;
|
|
83
|
-
// Whether the dialog is detached from the current window
|
|
84
|
-
Detached?: boolean;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export interface Screen {
|
|
88
|
-
// The screen ID
|
|
89
|
-
Id: string;
|
|
90
|
-
// The screen name
|
|
91
|
-
Name: string;
|
|
92
|
-
// The screen scale. 1 = standard resolution, 2: 2x retina, etc.
|
|
93
|
-
Scale: number;
|
|
94
|
-
// The X position of the screen
|
|
95
|
-
X: number;
|
|
96
|
-
// The Y position of the screen
|
|
97
|
-
Y: number;
|
|
98
|
-
// The width and height of the screen
|
|
99
|
-
Size: Size;
|
|
100
|
-
// The bounds of the screen
|
|
101
|
-
Bounds: Rect;
|
|
102
|
-
// The work area of the screen
|
|
103
|
-
WorkArea: Rect;
|
|
104
|
-
// True if this is the primary screen
|
|
105
|
-
IsPrimary: boolean;
|
|
106
|
-
// The rotation of the screen
|
|
107
|
-
Rotation: number;
|
|
108
|
-
}
|
|
109
|
-
export interface Rect {
|
|
110
|
-
X: number;
|
|
111
|
-
Y: number;
|
|
112
|
-
Width: number;
|
|
113
|
-
Height: number;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export interface WailsEvent {
|
|
117
|
-
// The name of the event
|
|
118
|
-
Name: string;
|
|
119
|
-
// The data associated with the event
|
|
120
|
-
Data?: any;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export interface Size {
|
|
124
|
-
Width: number;
|
|
125
|
-
Height: number;
|
|
126
|
-
}
|
|
127
|
-
export interface Position {
|
|
128
|
-
X: number;
|
|
129
|
-
Y: number;
|
|
130
|
-
}
|
package/window.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
_ __ _ __
|
|
3
|
-
| | / /___ _(_) /____
|
|
4
|
-
| | /| / / __ `/ / / ___/
|
|
5
|
-
| |/ |/ / /_/ / / (__ )
|
|
6
|
-
|__/|__/\__,_/_/_/____/
|
|
7
|
-
The electron alternative for Go
|
|
8
|
-
(c) Lea Anthony 2019-present
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/* jshint esversion: 9 */
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @typedef {import("../api/types").Size} Size
|
|
15
|
-
* @typedef {import("../api/types").Position} Position
|
|
16
|
-
* @typedef {import("../api/types").Screen} Screen
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import {newRuntimeCallerWithID, objectNames} from "./runtime";
|
|
20
|
-
|
|
21
|
-
const center = 0;
|
|
22
|
-
const setTitle = 1;
|
|
23
|
-
const fullscreen = 2;
|
|
24
|
-
const unFullscreen = 3;
|
|
25
|
-
const setSize = 4;
|
|
26
|
-
const size = 5;
|
|
27
|
-
const setMaxSize = 6;
|
|
28
|
-
const setMinSize = 7;
|
|
29
|
-
const setAlwaysOnTop = 8;
|
|
30
|
-
const setRelativePosition = 9;
|
|
31
|
-
const relativePosition = 10;
|
|
32
|
-
const screen = 11;
|
|
33
|
-
const hide = 12;
|
|
34
|
-
const maximise = 13;
|
|
35
|
-
const unMaximise = 14;
|
|
36
|
-
const toggleMaximise = 15;
|
|
37
|
-
const minimise = 16;
|
|
38
|
-
const unMinimise = 17;
|
|
39
|
-
const restore = 18;
|
|
40
|
-
const show = 19;
|
|
41
|
-
const close = 20;
|
|
42
|
-
const setBackgroundColour = 21;
|
|
43
|
-
const setResizable = 22;
|
|
44
|
-
const width = 23;
|
|
45
|
-
const height = 24;
|
|
46
|
-
const zoomIn = 25;
|
|
47
|
-
const zoomOut = 26;
|
|
48
|
-
const zoomReset = 27;
|
|
49
|
-
const getZoomLevel = 28;
|
|
50
|
-
const setZoomLevel = 29;
|
|
51
|
-
|
|
52
|
-
const thisWindow = newRuntimeCallerWithID(objectNames.Window, '');
|
|
53
|
-
|
|
54
|
-
function createWindow(call) {
|
|
55
|
-
return {
|
|
56
|
-
Get: (windowName) => createWindow(newRuntimeCallerWithID(objectNames.Window, windowName)),
|
|
57
|
-
Center: () => call(center),
|
|
58
|
-
SetTitle: (title) => call(setTitle, {title}),
|
|
59
|
-
Fullscreen: () => call(fullscreen),
|
|
60
|
-
UnFullscreen: () => call(unFullscreen),
|
|
61
|
-
SetSize: (width, height) => call(setSize, {width, height}),
|
|
62
|
-
Size: () => call(size),
|
|
63
|
-
SetMaxSize: (width, height) => call(setMaxSize, {width, height}),
|
|
64
|
-
SetMinSize: (width, height) => call(setMinSize, {width, height}),
|
|
65
|
-
SetAlwaysOnTop: (onTop) => call(setAlwaysOnTop, {alwaysOnTop: onTop}),
|
|
66
|
-
SetRelativePosition: (x, y) => call(setRelativePosition, {x, y}),
|
|
67
|
-
RelativePosition: () => call(relativePosition),
|
|
68
|
-
Screen: () => call(screen),
|
|
69
|
-
Hide: () => call(hide),
|
|
70
|
-
Maximise: () => call(maximise),
|
|
71
|
-
UnMaximise: () => call(unMaximise),
|
|
72
|
-
ToggleMaximise: () => call(toggleMaximise),
|
|
73
|
-
Minimise: () => call(minimise),
|
|
74
|
-
UnMinimise: () => call(unMinimise),
|
|
75
|
-
Restore: () => call(restore),
|
|
76
|
-
Show: () => call(show),
|
|
77
|
-
Close: () => call(close),
|
|
78
|
-
SetBackgroundColour: (r, g, b, a) => call(setBackgroundColour, {r, g, b, a}),
|
|
79
|
-
SetResizable: (resizable) => call(setResizable, {resizable}),
|
|
80
|
-
Width: () => call(width),
|
|
81
|
-
Height: () => call(height),
|
|
82
|
-
ZoomIn: () => call(zoomIn),
|
|
83
|
-
ZoomOut: () => call(zoomOut),
|
|
84
|
-
ZoomReset: () => call(zoomReset),
|
|
85
|
-
GetZoomLevel: () => call(getZoomLevel),
|
|
86
|
-
SetZoomLevel: (zoomLevel) => call(setZoomLevel, {zoomLevel}),
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Gets the specified window.
|
|
92
|
-
*
|
|
93
|
-
* @param {string} windowName - The name of the window to get.
|
|
94
|
-
* @return {Object} - The specified window object.
|
|
95
|
-
*/
|
|
96
|
-
export function Get(windowName) {
|
|
97
|
-
return createWindow(newRuntimeCallerWithID(objectNames.Window, windowName));
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Returns a map of all methods in the current window.
|
|
102
|
-
* @returns {Map} - A map of window methods.
|
|
103
|
-
*/
|
|
104
|
-
export function WindowMethods(targetWindow) {
|
|
105
|
-
// Create a new map to store methods
|
|
106
|
-
let result = new Map();
|
|
107
|
-
|
|
108
|
-
// Iterate over all properties of the window object
|
|
109
|
-
for (let method in targetWindow) {
|
|
110
|
-
// Check if the property is indeed a method (function)
|
|
111
|
-
if(typeof targetWindow[method] === 'function') {
|
|
112
|
-
// Add the method to the map
|
|
113
|
-
result.set(method, targetWindow[method]);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
// Return the map of window methods
|
|
118
|
-
return result;
|
|
119
|
-
}
|
|
120
|
-
export default {
|
|
121
|
-
...Get('')
|
|
122
|
-
}
|
package/wml.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {Emit, WailsEvent} from "./events";
|
|
3
|
-
import {Question} from "./dialogs";
|
|
4
|
-
import {WindowMethods, Get} from "./window";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Sends an event with the given name and optional data.
|
|
8
|
-
*
|
|
9
|
-
* @param {string} eventName - The name of the event to send.
|
|
10
|
-
* @param {any} [data=null] - Optional data to send along with the event.
|
|
11
|
-
*
|
|
12
|
-
* @return {void}
|
|
13
|
-
*/
|
|
14
|
-
function sendEvent(eventName, data=null) {
|
|
15
|
-
let event = new WailsEvent(eventName, data);
|
|
16
|
-
Emit(event);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Adds event listeners to elements with `wml-event` attribute.
|
|
21
|
-
*
|
|
22
|
-
* @return {void}
|
|
23
|
-
*/
|
|
24
|
-
function addWMLEventListeners() {
|
|
25
|
-
const elements = document.querySelectorAll('[wml-event]');
|
|
26
|
-
elements.forEach(function (element) {
|
|
27
|
-
const eventType = element.getAttribute('wml-event');
|
|
28
|
-
const confirm = element.getAttribute('wml-confirm');
|
|
29
|
-
const trigger = element.getAttribute('wml-trigger') || "click";
|
|
30
|
-
|
|
31
|
-
let callback = function () {
|
|
32
|
-
if (confirm) {
|
|
33
|
-
Question({Title: "Confirm", Message:confirm, Detached: false, Buttons:[{Label:"Yes"},{Label:"No", IsDefault:true}]}).then(function (result) {
|
|
34
|
-
if (result !== "No") {
|
|
35
|
-
sendEvent(eventType);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
sendEvent(eventType);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// Remove existing listeners
|
|
44
|
-
element.removeEventListener(trigger, callback);
|
|
45
|
-
|
|
46
|
-
// Add new listener
|
|
47
|
-
element.addEventListener(trigger, callback);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Calls a method on the window object.
|
|
53
|
-
*
|
|
54
|
-
* @param {string} method - The name of the method to call on the window object.
|
|
55
|
-
*
|
|
56
|
-
* @return {void}
|
|
57
|
-
*/
|
|
58
|
-
function callWindowMethod(method) {
|
|
59
|
-
// TODO: Make this a parameter!
|
|
60
|
-
let windowName = '';
|
|
61
|
-
let targetWindow = Get('');
|
|
62
|
-
let methodMap = WindowMethods(targetWindow);
|
|
63
|
-
if (!methodMap.has(method)) {
|
|
64
|
-
console.log("Window method " + method + " not found");
|
|
65
|
-
}
|
|
66
|
-
methodMap.get(method)();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Adds window listeners for elements with the 'wml-window' attribute.
|
|
71
|
-
* Removes any existing listeners before adding new ones.
|
|
72
|
-
*
|
|
73
|
-
* @return {void}
|
|
74
|
-
*/
|
|
75
|
-
function addWMLWindowListeners() {
|
|
76
|
-
const elements = document.querySelectorAll('[wml-window]');
|
|
77
|
-
elements.forEach(function (element) {
|
|
78
|
-
const windowMethod = element.getAttribute('wml-window');
|
|
79
|
-
const confirm = element.getAttribute('wml-confirm');
|
|
80
|
-
const trigger = element.getAttribute('wml-trigger') || "click";
|
|
81
|
-
|
|
82
|
-
let callback = function () {
|
|
83
|
-
if (confirm) {
|
|
84
|
-
Question({Title: "Confirm", Message:confirm, Buttons:[{Label:"Yes"},{Label:"No", IsDefault:true}]}).then(function (result) {
|
|
85
|
-
if (result !== "No") {
|
|
86
|
-
callWindowMethod(windowMethod);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
callWindowMethod(windowMethod);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
// Remove existing listeners
|
|
95
|
-
element.removeEventListener(trigger, callback);
|
|
96
|
-
|
|
97
|
-
// Add new listener
|
|
98
|
-
element.addEventListener(trigger, callback);
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Adds a listener to elements with the 'wml-openurl' attribute.
|
|
104
|
-
* When the specified trigger event is fired on any of these elements,
|
|
105
|
-
* the listener will open the URL specified by the 'wml-openurl' attribute.
|
|
106
|
-
* If a 'wml-confirm' attribute is provided, a confirmation dialog will be displayed,
|
|
107
|
-
* and the URL will only be opened if the user confirms.
|
|
108
|
-
*
|
|
109
|
-
* @return {void}
|
|
110
|
-
*/
|
|
111
|
-
function addWMLOpenBrowserListener() {
|
|
112
|
-
const elements = document.querySelectorAll('[wml-openurl]');
|
|
113
|
-
elements.forEach(function (element) {
|
|
114
|
-
const url = element.getAttribute('wml-openurl');
|
|
115
|
-
const confirm = element.getAttribute('wml-confirm');
|
|
116
|
-
const trigger = element.getAttribute('wml-trigger') || "click";
|
|
117
|
-
|
|
118
|
-
let callback = function () {
|
|
119
|
-
if (confirm) {
|
|
120
|
-
Question({Title: "Confirm", Message:confirm, Buttons:[{Label:"Yes"},{Label:"No", IsDefault:true}]}).then(function (result) {
|
|
121
|
-
if (result !== "No") {
|
|
122
|
-
void wails.Browser.OpenURL(url);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
void wails.Browser.OpenURL(url);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
// Remove existing listeners
|
|
131
|
-
element.removeEventListener(trigger, callback);
|
|
132
|
-
|
|
133
|
-
// Add new listener
|
|
134
|
-
element.addEventListener(trigger, callback);
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Reloads the WML page by adding necessary event listeners and browser listeners.
|
|
140
|
-
*
|
|
141
|
-
* @return {void}
|
|
142
|
-
*/
|
|
143
|
-
export function reloadWML() {
|
|
144
|
-
console.log("Reloading WML");
|
|
145
|
-
addWMLEventListeners();
|
|
146
|
-
addWMLWindowListeners();
|
|
147
|
-
addWMLOpenBrowserListener();
|
|
148
|
-
}
|