@wailsio/runtime 3.0.0-alpha.6 → 3.0.0-alpha.7
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/package.json +2 -1
- package/types.d.ts +100 -95
- package/wml.js +15 -13
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,130 +1,135 @@
|
|
|
1
1
|
|
|
2
|
+
/**
|
|
3
|
+
* Describes the properties of a Button object.
|
|
4
|
+
*/
|
|
2
5
|
export interface Button {
|
|
3
|
-
//
|
|
6
|
+
// Text that appears within the button.
|
|
4
7
|
Label?: string;
|
|
5
|
-
// True if
|
|
8
|
+
// True if the button should cancel an operation when clicked.
|
|
6
9
|
IsCancel?: boolean;
|
|
7
|
-
// True if
|
|
10
|
+
// True if the button should be the default action when the user presses enter.
|
|
8
11
|
IsDefault?: boolean;
|
|
9
12
|
}
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Describes the properties of a FileFilter object.
|
|
16
|
+
*/
|
|
17
|
+
export interface FileFilter {
|
|
18
|
+
// Display name for the filter, it could be "Text Files", "Images" etc.
|
|
19
|
+
DisplayName?: string;
|
|
20
|
+
// Pattern to match for the filter, e.g. "*.txt;*.md" for text markdown files.
|
|
21
|
+
Pattern?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Describes the properties of a Position object.
|
|
26
|
+
*/
|
|
27
|
+
export interface Position {
|
|
28
|
+
X: number;
|
|
29
|
+
Y: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Describes the properties of a Size object.
|
|
34
|
+
* Extends the properties of Position.
|
|
35
|
+
*/
|
|
36
|
+
export type Size = Position;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Describes the properties of a Rect object.
|
|
40
|
+
* Extends the properties of Size.
|
|
41
|
+
*/
|
|
42
|
+
export type Rect = Size & Position;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Describes the possible rotations a Screen can have.
|
|
46
|
+
*/
|
|
47
|
+
export enum Rotation {
|
|
48
|
+
Zero = 0,
|
|
49
|
+
Ninety = 90,
|
|
50
|
+
OneEighty = 180,
|
|
51
|
+
TwoSeventy = 270
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Describes the properties of a Screen object.
|
|
56
|
+
*/
|
|
57
|
+
export interface Screen {
|
|
58
|
+
// Unique identifier for the screen.
|
|
59
|
+
Id: string;
|
|
60
|
+
// Human readable name of the screen.
|
|
61
|
+
Name: string;
|
|
62
|
+
// The resolution scale of the screen. 1 = standard resolution, 2 = high (Retina), etc.
|
|
63
|
+
Scale: number;
|
|
64
|
+
// Contains the X and Y coordinates of the screen's position.
|
|
65
|
+
Position: Position;
|
|
66
|
+
// Contains the width and height of the screen.
|
|
67
|
+
Size: Size;
|
|
68
|
+
// Contains the bounds of the screen in terms of X, Y, Width, and Height.
|
|
69
|
+
Bounds: Rect;
|
|
70
|
+
// Contains the area of the screen that is actually usable (excluding taskbar and other system UI).
|
|
71
|
+
WorkArea: Rect;
|
|
72
|
+
// True if this is the primary monitor selected by the user in the operating system.
|
|
73
|
+
IsPrimary: boolean;
|
|
74
|
+
// The rotation of the screen. Can be one of 0, 90, 180, 270 degrees.
|
|
75
|
+
Rotation: Rotation;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Describes the properties of a MessageDialogOptions object.
|
|
80
|
+
*/
|
|
81
|
+
export interface MessageDialogOptions {
|
|
82
|
+
// The title of the dialog window.
|
|
13
83
|
Title?: string;
|
|
14
|
-
// The message to
|
|
84
|
+
// The main message to show in the dialog.
|
|
15
85
|
Message?: string;
|
|
16
|
-
//
|
|
86
|
+
// Array of button options to show in the dialog.
|
|
17
87
|
Buttons?: Button[];
|
|
18
|
-
//
|
|
88
|
+
// True if the dialog should appear detached from the main window (if applicable).
|
|
19
89
|
Detached?: boolean;
|
|
20
90
|
}
|
|
21
91
|
|
|
22
|
-
|
|
23
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Describes the properties common to OpenFileDialogOptions and SaveFileDialogOptions objects.
|
|
94
|
+
*/
|
|
95
|
+
export interface DialogOptions {
|
|
24
96
|
CanChooseDirectories?: boolean;
|
|
25
|
-
// Allows the user to be able to select files
|
|
26
97
|
CanChooseFiles?: boolean;
|
|
27
|
-
// Provide an option to create directories in the dialog
|
|
28
98
|
CanCreateDirectories?: boolean;
|
|
29
|
-
// Makes the dialog show hidden files
|
|
30
99
|
ShowHiddenFiles?: boolean;
|
|
31
|
-
// Whether the dialog should follow filesystem aliases
|
|
32
100
|
ResolvesAliases?: boolean;
|
|
33
|
-
// Allow the user to select multiple files or directories
|
|
34
101
|
AllowsMultipleSelection?: boolean;
|
|
35
|
-
// Hide the extension when showing the filename
|
|
36
102
|
HideExtension?: boolean;
|
|
37
|
-
// Allow the user to select files where the system hides their extensions
|
|
38
103
|
CanSelectHiddenExtension?: boolean;
|
|
39
|
-
// Treats file packages as directories, e.g. .app on macOS
|
|
40
104
|
TreatsFilePackagesAsDirectories?: boolean;
|
|
41
|
-
// Allows selection of filetypes not specified in the filters
|
|
42
105
|
AllowsOtherFiletypes?: boolean;
|
|
43
|
-
// The file filters to use in the dialog
|
|
44
106
|
Filters?: FileFilter[];
|
|
45
|
-
// The title of the dialog
|
|
46
107
|
Title?: string;
|
|
47
|
-
// The message to display
|
|
48
108
|
Message?: string;
|
|
49
|
-
// The label for the select button
|
|
50
109
|
ButtonText?: string;
|
|
51
|
-
// The default directory to open the dialog in
|
|
52
110
|
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
111
|
Detached?: boolean;
|
|
85
112
|
}
|
|
86
113
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
}
|
|
114
|
+
/**
|
|
115
|
+
* Describes properties unique to OpenFileDialogOptions.
|
|
116
|
+
*/
|
|
117
|
+
export type OpenFileDialogOptions = DialogOptions;
|
|
115
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Describes properties unique to SaveFileDialogOptions.
|
|
121
|
+
*/
|
|
122
|
+
export type SaveFileDialogOptions = DialogOptions & {
|
|
123
|
+
// Default filename to use for the save dialog.
|
|
124
|
+
Filename?: string;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Describes the properties of a WailsEvent object.
|
|
129
|
+
*/
|
|
116
130
|
export interface WailsEvent {
|
|
117
|
-
// The name of the event
|
|
131
|
+
// The name of the event.
|
|
118
132
|
Name: string;
|
|
119
|
-
//
|
|
120
|
-
Data?:
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export interface Size {
|
|
124
|
-
Width: number;
|
|
125
|
-
Height: number;
|
|
126
|
-
}
|
|
127
|
-
export interface Position {
|
|
128
|
-
X: number;
|
|
129
|
-
Y: number;
|
|
133
|
+
// Any data associated with the event.
|
|
134
|
+
Data?: unknown;
|
|
130
135
|
}
|
package/wml.js
CHANGED
|
@@ -49,22 +49,23 @@ function addWMLEventListeners() {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
|
|
52
53
|
/**
|
|
53
|
-
* Calls a method on
|
|
54
|
-
*
|
|
55
|
-
* @param {string} method - The name of the method to call
|
|
56
|
-
*
|
|
57
|
-
* @return {void}
|
|
54
|
+
* Calls a method on a specified window.
|
|
55
|
+
* @param {string} windowName - The name of the window to call the method on.
|
|
56
|
+
* @param {string} method - The name of the method to call.
|
|
58
57
|
*/
|
|
59
|
-
function callWindowMethod(method) {
|
|
60
|
-
|
|
61
|
-
let windowName = '';
|
|
62
|
-
let targetWindow = Get('');
|
|
58
|
+
function callWindowMethod(windowName, method) {
|
|
59
|
+
let targetWindow = Get(windowName);
|
|
63
60
|
let methodMap = WindowMethods(targetWindow);
|
|
64
61
|
if (!methodMap.has(method)) {
|
|
65
62
|
console.log("Window method " + method + " not found");
|
|
66
63
|
}
|
|
67
|
-
|
|
64
|
+
try {
|
|
65
|
+
methodMap.get(method)();
|
|
66
|
+
} catch (e) {
|
|
67
|
+
console.error("Error calling window method '" + method + "': " + e);
|
|
68
|
+
}
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
/**
|
|
@@ -78,18 +79,19 @@ function addWMLWindowListeners() {
|
|
|
78
79
|
elements.forEach(function (element) {
|
|
79
80
|
const windowMethod = element.getAttribute('wml-window');
|
|
80
81
|
const confirm = element.getAttribute('wml-confirm');
|
|
81
|
-
const trigger = element.getAttribute('wml-trigger') ||
|
|
82
|
+
const trigger = element.getAttribute('wml-trigger') || 'click';
|
|
83
|
+
const targetWindow = element.getAttribute('wml-target-window') || '';
|
|
82
84
|
|
|
83
85
|
let callback = function () {
|
|
84
86
|
if (confirm) {
|
|
85
87
|
Question({Title: "Confirm", Message:confirm, Buttons:[{Label:"Yes"},{Label:"No", IsDefault:true}]}).then(function (result) {
|
|
86
88
|
if (result !== "No") {
|
|
87
|
-
callWindowMethod(windowMethod);
|
|
89
|
+
callWindowMethod(targetWindow, windowMethod);
|
|
88
90
|
}
|
|
89
91
|
});
|
|
90
92
|
return;
|
|
91
93
|
}
|
|
92
|
-
callWindowMethod(windowMethod);
|
|
94
|
+
callWindowMethod(targetWindow, windowMethod);
|
|
93
95
|
};
|
|
94
96
|
|
|
95
97
|
// Remove existing listeners
|