windlg 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -3
- package/dist/index.js +42 -60
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -15,14 +15,14 @@ export interface OpenDirectoryDialogOptions {
|
|
|
15
15
|
}
|
|
16
16
|
export interface OpenMultiFileDialogOptions extends OpenFileDialogOptions {
|
|
17
17
|
}
|
|
18
|
-
export
|
|
18
|
+
export type OpenSaveFileDialogOptions = {
|
|
19
19
|
title?: string;
|
|
20
20
|
buttonLabel?: string;
|
|
21
21
|
filters?: FileFilter[];
|
|
22
22
|
defaultPath?: string;
|
|
23
23
|
defaultExt?: string;
|
|
24
24
|
defaultFileName?: string;
|
|
25
|
-
}
|
|
25
|
+
};
|
|
26
26
|
export type MessageBoxButtons = 'yesno' | 'ok' | 'yesnocancel' | 'okcancel';
|
|
27
27
|
export type MessageBoxIcons = 'none' | 'info' | 'warning' | 'error' | 'question';
|
|
28
28
|
declare class Windlg {
|
|
@@ -31,7 +31,7 @@ declare class Windlg {
|
|
|
31
31
|
openFileDialog(options?: OpenFileDialogOptions): Promise<string | null>;
|
|
32
32
|
openMultiFileDialog(options?: OpenMultiFileDialogOptions): Promise<string[] | null>;
|
|
33
33
|
openDirectoryDialog(options?: OpenDirectoryDialogOptions): Promise<string | null>;
|
|
34
|
-
openSaveFileDialog(options?:
|
|
34
|
+
openSaveFileDialog(options?: OpenSaveFileDialogOptions): Promise<string | null>;
|
|
35
35
|
showMessageBox(title: string, message: string, messageBoxButtons?: MessageBoxButtons, messageBoxIcons?: MessageBoxIcons): Promise<any>;
|
|
36
36
|
}
|
|
37
37
|
declare const windlg: Windlg;
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
class Windlg {
|
|
13
4
|
constructor() {
|
|
@@ -18,62 +9,53 @@ class Windlg {
|
|
|
18
9
|
throw new Error('Windlg only supports Windows x64 platform');
|
|
19
10
|
}
|
|
20
11
|
}
|
|
21
|
-
openFileDialog(options) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return file;
|
|
32
|
-
});
|
|
12
|
+
async openFileDialog(options) {
|
|
13
|
+
let nativeFilters = [];
|
|
14
|
+
const title = options?.title || '';
|
|
15
|
+
const buttonLabel = options?.buttonLabel || '';
|
|
16
|
+
const defaultPath = options?.defaultPath || '';
|
|
17
|
+
if (options?.filters) {
|
|
18
|
+
nativeFilters = options.filters.map(filter => [filter.name, filter.exts.join(';')]);
|
|
19
|
+
}
|
|
20
|
+
const file = await this.windlg.OpenFileDialog(title, buttonLabel, nativeFilters, defaultPath);
|
|
21
|
+
return file;
|
|
33
22
|
}
|
|
34
|
-
openMultiFileDialog(options) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return files;
|
|
45
|
-
});
|
|
23
|
+
async openMultiFileDialog(options) {
|
|
24
|
+
let nativeFilters = [];
|
|
25
|
+
const title = options?.title || '';
|
|
26
|
+
const buttonLabel = options?.buttonLabel || '';
|
|
27
|
+
const defaultPath = options?.defaultPath || '';
|
|
28
|
+
if (options?.filters) {
|
|
29
|
+
nativeFilters = options.filters.map(filter => [filter.name, filter.exts.join(';')]);
|
|
30
|
+
}
|
|
31
|
+
const files = await this.windlg.OpenMultiFileDialog(title, buttonLabel, nativeFilters, defaultPath);
|
|
32
|
+
return files;
|
|
46
33
|
}
|
|
47
|
-
openDirectoryDialog(options) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return dir;
|
|
54
|
-
});
|
|
34
|
+
async openDirectoryDialog(options) {
|
|
35
|
+
const title = options?.title || '';
|
|
36
|
+
const buttonLabel = options?.buttonLabel || '';
|
|
37
|
+
const defaultPath = options?.defaultPath || '';
|
|
38
|
+
const dir = await this.windlg.OpenDirectoryDialog(title, buttonLabel, defaultPath);
|
|
39
|
+
return dir;
|
|
55
40
|
}
|
|
56
|
-
openSaveFileDialog(options) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return file;
|
|
69
|
-
});
|
|
41
|
+
async openSaveFileDialog(options) {
|
|
42
|
+
let nativeFilters = [];
|
|
43
|
+
const title = options?.title || '';
|
|
44
|
+
const buttonLabel = options?.buttonLabel || '';
|
|
45
|
+
const defaultPath = options?.defaultPath || '';
|
|
46
|
+
const defaultExt = options?.defaultExt || '';
|
|
47
|
+
const defaultFileName = options?.defaultFileName || '';
|
|
48
|
+
if (options?.filters) {
|
|
49
|
+
nativeFilters = options.filters.map(filter => [filter.name, filter.exts.join(';')]);
|
|
50
|
+
}
|
|
51
|
+
const file = await this.windlg.OpenSaveFileDialog(title, buttonLabel, nativeFilters, defaultPath, defaultExt, defaultFileName);
|
|
52
|
+
return file;
|
|
70
53
|
}
|
|
71
|
-
showMessageBox(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return result;
|
|
75
|
-
});
|
|
54
|
+
async showMessageBox(title, message, messageBoxButtons = 'ok', messageBoxIcons = 'none') {
|
|
55
|
+
const result = await this.windlg.ShowMessageBox(message, title, messageBoxButtons, messageBoxIcons);
|
|
56
|
+
return result;
|
|
76
57
|
}
|
|
77
58
|
}
|
|
78
59
|
const windlg = new Windlg();
|
|
60
|
+
module.exports = windlg;
|
|
79
61
|
exports.default = windlg;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "windlg",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Windows native dialog library for Node.js",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"native",
|
|
28
28
|
"messagebox"
|
|
29
29
|
],
|
|
30
|
-
"author": "
|
|
30
|
+
"author": "Kiyuu",
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"repository": {
|
|
33
33
|
"type": "git",
|