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 CHANGED
@@ -15,14 +15,14 @@ export interface OpenDirectoryDialogOptions {
15
15
  }
16
16
  export interface OpenMultiFileDialogOptions extends OpenFileDialogOptions {
17
17
  }
18
- export interface OpenSaveFileDialog {
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?: OpenSaveFileDialog): Promise<string | null>;
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
- return __awaiter(this, void 0, void 0, function* () {
23
- let nativeFilters = [];
24
- const title = (options === null || options === void 0 ? void 0 : options.title) || '';
25
- const buttonLabel = (options === null || options === void 0 ? void 0 : options.buttonLabel) || '';
26
- const defaultPath = (options === null || options === void 0 ? void 0 : options.defaultPath) || '';
27
- if (options === null || options === void 0 ? void 0 : options.filters) {
28
- nativeFilters = options.filters.map(filter => [filter.name, filter.exts.join(';')]);
29
- }
30
- const file = yield this.windlg.OpenFileDialog(title, buttonLabel, nativeFilters, defaultPath);
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
- return __awaiter(this, void 0, void 0, function* () {
36
- let nativeFilters = [];
37
- const title = (options === null || options === void 0 ? void 0 : options.title) || '';
38
- const buttonLabel = (options === null || options === void 0 ? void 0 : options.buttonLabel) || '';
39
- const defaultPath = (options === null || options === void 0 ? void 0 : options.defaultPath) || '';
40
- if (options === null || options === void 0 ? void 0 : options.filters) {
41
- nativeFilters = options.filters.map(filter => [filter.name, filter.exts.join(';')]);
42
- }
43
- const files = yield this.windlg.OpenMultiFileDialog(title, buttonLabel, nativeFilters, defaultPath);
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
- return __awaiter(this, void 0, void 0, function* () {
49
- const title = (options === null || options === void 0 ? void 0 : options.title) || '';
50
- const buttonLabel = (options === null || options === void 0 ? void 0 : options.buttonLabel) || '';
51
- const defaultPath = (options === null || options === void 0 ? void 0 : options.defaultPath) || '';
52
- const dir = yield this.windlg.OpenDirectoryDialog(title, buttonLabel, defaultPath);
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
- return __awaiter(this, void 0, void 0, function* () {
58
- let nativeFilters = [];
59
- const title = (options === null || options === void 0 ? void 0 : options.title) || '';
60
- const buttonLabel = (options === null || options === void 0 ? void 0 : options.buttonLabel) || '';
61
- const defaultPath = (options === null || options === void 0 ? void 0 : options.defaultPath) || '';
62
- const defaultExt = (options === null || options === void 0 ? void 0 : options.defaultExt) || '';
63
- const defaultFileName = (options === null || options === void 0 ? void 0 : options.defaultFileName) || '';
64
- if (options === null || options === void 0 ? void 0 : options.filters) {
65
- nativeFilters = options.filters.map(filter => [filter.name, filter.exts.join(';')]);
66
- }
67
- const file = yield this.windlg.OpenSaveFileDialog(title, buttonLabel, nativeFilters, defaultPath, defaultExt, defaultFileName);
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(title_1, message_1) {
72
- return __awaiter(this, arguments, void 0, function* (title, message, messageBoxButtons = 'ok', messageBoxIcons = 'none') {
73
- const result = yield this.windlg.ShowMessageBox(message, title, messageBoxButtons, messageBoxIcons);
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.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": "Your Name",
30
+ "author": "Kiyuu",
31
31
  "license": "MIT",
32
32
  "repository": {
33
33
  "type": "git",