windlg 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 kiyuu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # Node-Windlg
2
+
3
+ Windows native dialog library for Node.js
4
+
5
+ ## Features
6
+
7
+ - File open dialog (single and multi-select)
8
+ - Directory selection dialog
9
+ - File save dialog
10
+ - Message box dialog
11
+ - TypeScript support
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install windlg
Binary file
@@ -0,0 +1,38 @@
1
+ export interface FileFilter {
2
+ name: string;
3
+ exts: string[];
4
+ }
5
+ export interface OpenFileDialogOptions {
6
+ title?: string;
7
+ buttonLabel?: string;
8
+ filters?: FileFilter[];
9
+ defaultPath?: string;
10
+ }
11
+ export interface OpenDirectoryDialogOptions {
12
+ title?: string;
13
+ buttonLabel?: string;
14
+ defaultPath?: string;
15
+ }
16
+ export interface OpenMultiFileDialogOptions extends OpenFileDialogOptions {
17
+ }
18
+ export interface OpenSaveFileDialog {
19
+ title?: string;
20
+ buttonLabel?: string;
21
+ filters?: FileFilter[];
22
+ defaultPath?: string;
23
+ defaultExt?: string;
24
+ defaultFileName?: string;
25
+ }
26
+ export type MessageBoxButtons = 'yesno' | 'ok' | 'yesnocancel' | 'okcancel';
27
+ export type MessageBoxIcons = 'none' | 'info' | 'warning' | 'error' | 'question';
28
+ declare class Windlg {
29
+ private windlg;
30
+ constructor();
31
+ openFileDialog(options?: OpenFileDialogOptions): Promise<string | null>;
32
+ openMultiFileDialog(options?: OpenMultiFileDialogOptions): Promise<string[] | null>;
33
+ openDirectoryDialog(options?: OpenDirectoryDialogOptions): Promise<string | null>;
34
+ openSaveFileDialog(options?: OpenSaveFileDialog): Promise<string | null>;
35
+ showMessageBox(title: string, message: string, messageBoxButtons?: MessageBoxButtons, messageBoxIcons?: MessageBoxIcons): Promise<any>;
36
+ }
37
+ declare const windlg: Windlg;
38
+ export default windlg;
package/dist/index.js ADDED
@@ -0,0 +1,79 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ class Windlg {
13
+ constructor() {
14
+ if (process.platform === 'win32' && process.arch === 'x64') {
15
+ this.windlg = require('../bin/windlg_x64.node');
16
+ }
17
+ else {
18
+ throw new Error('Windlg only supports Windows x64 platform');
19
+ }
20
+ }
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
+ });
33
+ }
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
+ });
46
+ }
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
+ });
55
+ }
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
+ });
70
+ }
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
+ });
76
+ }
77
+ }
78
+ const windlg = new Windlg();
79
+ exports.default = windlg;
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "windlg",
3
+ "version": "1.0.0",
4
+ "description": "Windows native dialog library for Node.js",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "bin"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsc",
20
+ "prepublishOnly": "npm run build",
21
+ "test": "echo \"Error: no test specified\" && exit 1"
22
+ },
23
+ "keywords": [
24
+ "windows",
25
+ "dialog",
26
+ "file-dialog",
27
+ "native",
28
+ "messagebox"
29
+ ],
30
+ "author": "Your Name",
31
+ "license": "MIT",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/kiyonya/node-windlg.git"
35
+ },
36
+ "homepage": "https://github.com/kiyonya/node-windlg",
37
+ "engines": {
38
+ "node": ">=14.0.0"
39
+ },
40
+ "os": [
41
+ "win32"
42
+ ],
43
+ "cpu": [
44
+ "x64"
45
+ ],
46
+ "devDependencies": {
47
+ "@types/node": "^20.0.0",
48
+ "typescript": "^5.0.0"
49
+ }
50
+ }