ewvjs 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 +21 -0
- package/README.md +168 -0
- package/bin/ewvjs-cli.js +318 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +76 -0
- package/dist/js/api.js +256 -0
- package/dist/platforms/windows.d.ts +5 -0
- package/dist/platforms/windows.d.ts.map +1 -0
- package/dist/platforms/windows.js +143 -0
- package/dist/types.d.ts +42 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/utils.d.ts +9 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +22 -0
- package/dist/webview.d.ts +20 -0
- package/dist/webview.d.ts.map +1 -0
- package/dist/webview.js +92 -0
- package/dist/window.d.ts +55 -0
- package/dist/window.d.ts.map +1 -0
- package/dist/window.js +307 -0
- package/lib/assets.js +129 -0
- package/lib/icon.js +150 -0
- package/lib/packager.js +347 -0
- package/native/Microsoft.Web.WebView2.Core.dll +0 -0
- package/native/Microsoft.Web.WebView2.WinForms.dll +0 -0
- package/native/Microsoft.Web.WebView2.Wpf.dll +0 -0
- package/native/WebView.cjs +26 -0
- package/native/WebView.d.ts +8 -0
- package/native/WebView.deps.json +260 -0
- package/native/WebView.dll +0 -0
- package/native/WebView.mjs +31 -0
- package/native/import.cjs +3 -0
- package/native/node_modules/node-api-dotnet/README.md +80 -0
- package/native/node_modules/node-api-dotnet/index.d.ts +98 -0
- package/native/node_modules/node-api-dotnet/index.js +2 -0
- package/native/node_modules/node-api-dotnet/init.js +80 -0
- package/native/node_modules/node-api-dotnet/linux-arm64/Microsoft.JavaScript.NodeApi.node +0 -0
- package/native/node_modules/node-api-dotnet/linux-x64/Microsoft.JavaScript.NodeApi.node +0 -0
- package/native/node_modules/node-api-dotnet/net10.0/Microsoft.JavaScript.NodeApi.DotNetHost.dll +0 -0
- package/native/node_modules/node-api-dotnet/net10.0/Microsoft.JavaScript.NodeApi.dll +0 -0
- package/native/node_modules/node-api-dotnet/net10.0/Microsoft.JavaScript.NodeApi.runtimeconfig.json +14 -0
- package/native/node_modules/node-api-dotnet/net10.0.js +2 -0
- package/native/node_modules/node-api-dotnet/net472/Microsoft.Bcl.AsyncInterfaces.dll +0 -0
- package/native/node_modules/node-api-dotnet/net472/Microsoft.JavaScript.NodeApi.DotNetHost.dll +0 -0
- package/native/node_modules/node-api-dotnet/net472/Microsoft.JavaScript.NodeApi.dll +0 -0
- package/native/node_modules/node-api-dotnet/net472/Microsoft.JavaScript.NodeApi.runtimeconfig.json +9 -0
- package/native/node_modules/node-api-dotnet/net472/System.Memory.dll +0 -0
- package/native/node_modules/node-api-dotnet/net472/System.Runtime.CompilerServices.Unsafe.dll +0 -0
- package/native/node_modules/node-api-dotnet/net472/System.Threading.Tasks.Extensions.dll +0 -0
- package/native/node_modules/node-api-dotnet/net472.d.ts +2 -0
- package/native/node_modules/node-api-dotnet/net472.js +2 -0
- package/native/node_modules/node-api-dotnet/net8.0/Microsoft.JavaScript.NodeApi.DotNetHost.dll +0 -0
- package/native/node_modules/node-api-dotnet/net8.0/Microsoft.JavaScript.NodeApi.dll +0 -0
- package/native/node_modules/node-api-dotnet/net8.0/Microsoft.JavaScript.NodeApi.runtimeconfig.json +14 -0
- package/native/node_modules/node-api-dotnet/net8.0.d.ts +2 -0
- package/native/node_modules/node-api-dotnet/net8.0.js +2 -0
- package/native/node_modules/node-api-dotnet/net9.0/Microsoft.JavaScript.NodeApi.DotNetHost.dll +0 -0
- package/native/node_modules/node-api-dotnet/net9.0/Microsoft.JavaScript.NodeApi.dll +0 -0
- package/native/node_modules/node-api-dotnet/net9.0/Microsoft.JavaScript.NodeApi.runtimeconfig.json +14 -0
- package/native/node_modules/node-api-dotnet/net9.0.d.ts +2 -0
- package/native/node_modules/node-api-dotnet/net9.0.js +2 -0
- package/native/node_modules/node-api-dotnet/osx-arm64/Microsoft.JavaScript.NodeApi.node +0 -0
- package/native/node_modules/node-api-dotnet/osx-x64/Microsoft.JavaScript.NodeApi.node +0 -0
- package/native/node_modules/node-api-dotnet/package.json +27 -0
- package/native/node_modules/node-api-dotnet/win-arm64/Microsoft.JavaScript.NodeApi.node +0 -0
- package/native/node_modules/node-api-dotnet/win-x64/Microsoft.JavaScript.NodeApi.node +0 -0
- package/native/runtimes/win-arm64/native/WebView2Loader.dll +0 -0
- package/native/runtimes/win-x64/native/WebView2Loader.dll +0 -0
- package/native/runtimes/win-x86/native/WebView2Loader.dll +0 -0
- package/package.json +57 -0
- package/src/README.md +125 -0
- package/src/csharp/bin/Release/net10.0-windows/Microsoft.Web.WebView2.Core.dll +0 -0
- package/src/csharp/bin/Release/net10.0-windows/Microsoft.Web.WebView2.Core.xml +6817 -0
- package/src/csharp/bin/Release/net10.0-windows/Microsoft.Web.WebView2.WinForms.dll +0 -0
- package/src/csharp/bin/Release/net10.0-windows/Microsoft.Web.WebView2.WinForms.xml +510 -0
- package/src/csharp/bin/Release/net10.0-windows/Microsoft.Web.WebView2.Wpf.dll +0 -0
- package/src/csharp/bin/Release/net10.0-windows/Microsoft.Web.WebView2.Wpf.xml +1902 -0
- package/src/csharp/bin/Release/net10.0-windows/WebView.cjs +26 -0
- package/src/csharp/bin/Release/net10.0-windows/WebView.d.ts +8 -0
- package/src/csharp/bin/Release/net10.0-windows/WebView.deps.json +260 -0
- package/src/csharp/bin/Release/net10.0-windows/WebView.dll +0 -0
- package/src/csharp/bin/Release/net10.0-windows/WebView.mjs +31 -0
- package/src/csharp/bin/Release/net10.0-windows/WebView.pdb +0 -0
- package/src/csharp/bin/Release/net10.0-windows/import.cjs +3 -0
- package/src/csharp/bin/Release/net10.0-windows/runtimes/win-arm64/native/WebView2Loader.dll +0 -0
- package/src/csharp/bin/Release/net10.0-windows/runtimes/win-x64/native/WebView2Loader.dll +0 -0
- package/src/csharp/bin/Release/net10.0-windows/runtimes/win-x86/native/WebView2Loader.dll +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Miukyo
|
|
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,168 @@
|
|
|
1
|
+
# ewvjs
|
|
2
|
+
|
|
3
|
+
**Embedded WebView for JavaScript**
|
|
4
|
+
|
|
5
|
+
`ewvjs` allows you to create modern desktop applications using Node.js and the Microsoft Edge WebView2 control. It provides a lightweight, native GUI experience with full access to Node.js APIs.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- 🪟 **Native Window Management**: Create, control, and customize native Windows.
|
|
10
|
+
- 🌐 **Modern Web Technologies**: Build your UI with HTML, CSS, and JavaScript.
|
|
11
|
+
- ⚡ **Node.js Integration**: Call Node.js functions directly from your frontend code.
|
|
12
|
+
- 🖱️ **Context Menus**: Customizable native right-click context menus.
|
|
13
|
+
- 📦 **Packaging**: Built-in CLI tool to package your app into a standalone executable.
|
|
14
|
+
- 🔧 **Native Bindings**: High-performance C# bindings via `node-api-dotnet`.
|
|
15
|
+
- 🖼️ **Customization**: Support for frameless windows, transparency, dark mode, and more.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install ewvjs
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
Create a simple application:
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
const { create_window, start } = require('ewvjs');
|
|
29
|
+
|
|
30
|
+
// Create a new window
|
|
31
|
+
const win = create_window('My App', 'https://www.google.com', {
|
|
32
|
+
width: 1024,
|
|
33
|
+
height: 768,
|
|
34
|
+
dark_mode: true
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Run the window
|
|
38
|
+
win.run();
|
|
39
|
+
|
|
40
|
+
// Keep the application alive
|
|
41
|
+
start();
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Exposing Node.js Functions
|
|
45
|
+
|
|
46
|
+
You can expose Node.js functions to your frontend code easily:
|
|
47
|
+
|
|
48
|
+
**Backend (Node.js):**
|
|
49
|
+
```javascript
|
|
50
|
+
const { create_window, expose, start } = require('ewvjs');
|
|
51
|
+
const os = require('os');
|
|
52
|
+
|
|
53
|
+
// Expose a function to specific window or globally
|
|
54
|
+
expose('getSystemInfo', () => {
|
|
55
|
+
return {
|
|
56
|
+
platform: os.platform(),
|
|
57
|
+
arch: os.arch(),
|
|
58
|
+
cpus: os.cpus().length
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const win = create_window('System Info', 'index.html', { width: 400, height: 300 });
|
|
63
|
+
win.run();
|
|
64
|
+
start();
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Frontend (HTML/JS):**
|
|
68
|
+
```javascript
|
|
69
|
+
// Call the exposed function via window.ewvjs.api
|
|
70
|
+
async function showInfo() {
|
|
71
|
+
const info = await window.ewvjs.api.getSystemInfo();
|
|
72
|
+
console.log(info);
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## API Reference
|
|
77
|
+
|
|
78
|
+
### `create_window(title, url, options)`
|
|
79
|
+
|
|
80
|
+
Creates a new WebView window.
|
|
81
|
+
|
|
82
|
+
* `title` (string): The window title.
|
|
83
|
+
* `url` (string): The URL to load (http/https) or path to a local HTML file or HTML string.
|
|
84
|
+
* `options` (object): Configuration options.
|
|
85
|
+
|
|
86
|
+
### Window Options
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
{
|
|
90
|
+
title?: string; // Window title (overrides create_window arg)
|
|
91
|
+
url?: string; // URL to load (overrides create_window arg)
|
|
92
|
+
html?: string; // HTML content to load directly
|
|
93
|
+
width?: number; // Window width
|
|
94
|
+
height?: number; // Window height
|
|
95
|
+
x?: number; // X position
|
|
96
|
+
y?: number; // Y position
|
|
97
|
+
resizable?: boolean; // Allow resizing
|
|
98
|
+
fullscreen?: boolean; // Start in fullscreen
|
|
99
|
+
hidden?: boolean; // Start hidden
|
|
100
|
+
frameless?: boolean; // Remove window frame
|
|
101
|
+
focus?: boolean; // Focus window on creation
|
|
102
|
+
minimized?: boolean; // Start minimized
|
|
103
|
+
maximized?: boolean; // Start maximized
|
|
104
|
+
on_top?: boolean; // Keep window on top
|
|
105
|
+
confirm_close?: boolean; // Require confirmation before closing
|
|
106
|
+
transparent?: boolean; // Transparent background
|
|
107
|
+
background_color?: string; // Hex color (e.g. "#FFFFFF")
|
|
108
|
+
vibrancy?: boolean; // Enable window vibrancy/acrylic effect
|
|
109
|
+
dark_mode?: boolean; // Enable dark mode
|
|
110
|
+
title_bar?: boolean; // Show/hide title bar (if not frameless)
|
|
111
|
+
icon?: string; // Path to .ico file
|
|
112
|
+
session?: {
|
|
113
|
+
persist?: boolean; // Persist cookies/localStorage
|
|
114
|
+
path?: string; // Custom user data path
|
|
115
|
+
envname?: string; // WebView2 Environment name
|
|
116
|
+
};
|
|
117
|
+
additional_args?: string; // Additional WebView2 arguments
|
|
118
|
+
debug?: boolean; // Enable debug tools/console
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Window Methods
|
|
123
|
+
|
|
124
|
+
Once a window is created, you can control it using the returned `Window` instance:
|
|
125
|
+
|
|
126
|
+
* **Lifecycle**: `run()`, `close()`, `destroy()`
|
|
127
|
+
* **State**: `maximize()`, `minimize()`, `restore()`, `show()`, `hide()`, `focus()`, `blur()`
|
|
128
|
+
* **Size & Position**:
|
|
129
|
+
* `getSize()`, `setSize(w, h)`, `resize(w, h)`
|
|
130
|
+
* `getPosition()`, `setPosition(x, y)`, `move(x, y)`
|
|
131
|
+
* **Interaction**:
|
|
132
|
+
* `setTitle(title)`
|
|
133
|
+
* `navigate(url)`
|
|
134
|
+
* `evaluate(script)`: Execute JavaScript in the WebView.
|
|
135
|
+
* `setIcon(path)`
|
|
136
|
+
* **Cookies**: `get_cookies()`, `set_cookie(...)`, `clear_cookies()`
|
|
137
|
+
|
|
138
|
+
### Custom Context Menus
|
|
139
|
+
|
|
140
|
+
Define native context menus using `on_context_menu`:
|
|
141
|
+
|
|
142
|
+
```javascript
|
|
143
|
+
win.on_context_menu = (params) => {
|
|
144
|
+
return [
|
|
145
|
+
{ label: 'Refresh', click: () => win.reload() },
|
|
146
|
+
{ type: 'separator' },
|
|
147
|
+
{ label: 'Exit', click: () => win.close() }
|
|
148
|
+
];
|
|
149
|
+
};
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## CLI & Packaging
|
|
153
|
+
|
|
154
|
+
`ewvjs` comes with a CLI tool to package your application into a standalone executable.
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
npx ewvjs package app.js --output myapp.exe --icon icon.ico
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Options:**
|
|
161
|
+
* `--output, -o`: Output filename.
|
|
162
|
+
* `--icon, -i`: Path to application icon (.ico).
|
|
163
|
+
* `--assets, -a`: Directory of assets to copy.
|
|
164
|
+
* `--target, -t`: Target platform (default: node18-win-x64).
|
|
165
|
+
|
|
166
|
+
## License
|
|
167
|
+
|
|
168
|
+
MIT LICENSE
|
package/bin/ewvjs-cli.js
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { Command } = require('commander');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const packageApp = require('../lib/packager');
|
|
7
|
+
const { setIcon } = require('../lib/icon');
|
|
8
|
+
|
|
9
|
+
const program = new Command();
|
|
10
|
+
|
|
11
|
+
program
|
|
12
|
+
.name('ewvjs')
|
|
13
|
+
.description('CLI tool for packaging ewvjs applications')
|
|
14
|
+
.version(require('../package.json').version);
|
|
15
|
+
|
|
16
|
+
program
|
|
17
|
+
.command('package')
|
|
18
|
+
.description('Package your ewvjs application into a standalone executable')
|
|
19
|
+
.argument('<entry>', 'Entry point JavaScript file (e.g., app.js)')
|
|
20
|
+
.option('-o, --output <name>', 'Output executable name', 'app')
|
|
21
|
+
.option('-a, --assets <dir>', 'Assets directory to include (e.g., ./assets)', './assets')
|
|
22
|
+
.option('-i, --icon <file>', 'Application icon (.ico file)')
|
|
23
|
+
.option('-n, --name <name>', 'Application name', 'My App')
|
|
24
|
+
.option('-t, --target <target>', 'Target platform', 'node18-win-x64')
|
|
25
|
+
.option('-m, --modules <modules>', 'Additional node modules to bundle (comma-separated, e.g., "axios,lodash")')
|
|
26
|
+
.option('--compress', 'Compress the executable with UPX', false)
|
|
27
|
+
.option('--no-native', 'Skip bundling native DLLs (use if already included)')
|
|
28
|
+
.action(async (entry, options) => {
|
|
29
|
+
try {
|
|
30
|
+
console.log('📦 Packaging ewvjs application...\n');
|
|
31
|
+
|
|
32
|
+
// Validate entry file exists
|
|
33
|
+
const entryPath = path.resolve(process.cwd(), entry);
|
|
34
|
+
if (!fs.existsSync(entryPath)) {
|
|
35
|
+
console.error(`❌ Error: Entry file not found: ${entry}`);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Validate icon if provided
|
|
40
|
+
if (options.icon) {
|
|
41
|
+
const iconPath = path.resolve(process.cwd(), options.icon);
|
|
42
|
+
if (!fs.existsSync(iconPath)) {
|
|
43
|
+
console.error(`❌ Error: Icon file not found: ${options.icon}`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
if (!iconPath.endsWith('.ico')) {
|
|
47
|
+
console.error('❌ Error: Icon must be a .ico file');
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Parse additional modules if provided
|
|
53
|
+
const additionalModules = options.modules
|
|
54
|
+
? options.modules.split(',').map(m => m.trim()).filter(m => m)
|
|
55
|
+
: [];
|
|
56
|
+
|
|
57
|
+
const config = {
|
|
58
|
+
entry: entryPath,
|
|
59
|
+
output: options.output,
|
|
60
|
+
assets: options.assets ? path.resolve(process.cwd(), options.assets) : null,
|
|
61
|
+
icon: options.icon ? path.resolve(process.cwd(), options.icon) : null,
|
|
62
|
+
name: options.name,
|
|
63
|
+
target: options.target,
|
|
64
|
+
compress: options.compress,
|
|
65
|
+
includeNative: options.native,
|
|
66
|
+
additionalModules: additionalModules
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
await packageApp(config);
|
|
70
|
+
|
|
71
|
+
console.log('\n✅ Packaging complete!');
|
|
72
|
+
console.log(`📁 Output: ${path.join(process.cwd(), 'dist', options.output + '.exe')}`);
|
|
73
|
+
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.error('\n❌ Packaging failed:', error.message);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
program
|
|
81
|
+
.command('init')
|
|
82
|
+
.description('Initialize a new ewvjs project')
|
|
83
|
+
.argument('[name]', 'Project name', 'my-ewvjs-app')
|
|
84
|
+
.action((name) => {
|
|
85
|
+
const projectDir = path.join(process.cwd(), name);
|
|
86
|
+
|
|
87
|
+
if (fs.existsSync(projectDir)) {
|
|
88
|
+
console.error(`❌ Error: Directory ${name} already exists`);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
console.log(`📂 Creating new ewvjs project: ${name}\n`);
|
|
93
|
+
|
|
94
|
+
// Create directory structure
|
|
95
|
+
fs.mkdirSync(projectDir, { recursive: true });
|
|
96
|
+
fs.mkdirSync(path.join(projectDir, 'assets'), { recursive: true });
|
|
97
|
+
|
|
98
|
+
// Create package.json
|
|
99
|
+
const packageJson = {
|
|
100
|
+
name: name,
|
|
101
|
+
version: '1.0.0',
|
|
102
|
+
description: 'My ewvjs application',
|
|
103
|
+
main: 'app.js',
|
|
104
|
+
scripts: {
|
|
105
|
+
start: 'node app.js',
|
|
106
|
+
package: 'ewvjs package app.js -o myapp -n "My App"'
|
|
107
|
+
},
|
|
108
|
+
dependencies: {
|
|
109
|
+
ewvjs: '^1.0.0'
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
fs.writeFileSync(
|
|
114
|
+
path.join(projectDir, 'package.json'),
|
|
115
|
+
JSON.stringify(packageJson, null, 2)
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
// Create sample app.js
|
|
119
|
+
const appJs = `const { create_window, start, expose } = require('ewvjs');
|
|
120
|
+
|
|
121
|
+
expose('greet', (name) => {
|
|
122
|
+
return \`Hello, \${name}! This is from Node.js 🚀\`;
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
expose('getSystemInfo', () => {
|
|
126
|
+
return {
|
|
127
|
+
platform: process.platform,
|
|
128
|
+
arch: process.arch,
|
|
129
|
+
nodeVersion: process.version,
|
|
130
|
+
uptime: process.uptime()
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// Create main window
|
|
135
|
+
const window = create_window('Hello ewvjs', \`
|
|
136
|
+
<!DOCTYPE html>
|
|
137
|
+
<html>
|
|
138
|
+
<head>
|
|
139
|
+
<meta charset="UTF-8">
|
|
140
|
+
<title>Hello ewvjs</title>
|
|
141
|
+
<style>
|
|
142
|
+
* {
|
|
143
|
+
margin: 0;
|
|
144
|
+
padding: 0;
|
|
145
|
+
box-sizing: border-box;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
body {
|
|
149
|
+
font-family: sans-serif;
|
|
150
|
+
color: white;
|
|
151
|
+
display: flex;
|
|
152
|
+
align-items: center;
|
|
153
|
+
justify-content: center;
|
|
154
|
+
min-height: 100vh;
|
|
155
|
+
padding: 20px;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.container {
|
|
159
|
+
text-align: center;
|
|
160
|
+
max-width: 600px;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
h1 {
|
|
164
|
+
font-size: 3em;
|
|
165
|
+
margin-bottom: 20px;
|
|
166
|
+
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
p {
|
|
170
|
+
font-size: 1.2em;
|
|
171
|
+
margin-bottom: 30px;
|
|
172
|
+
opacity: 0.9;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
input {
|
|
176
|
+
width: 100%;
|
|
177
|
+
padding: 15px;
|
|
178
|
+
font-size: 16px;
|
|
179
|
+
border: none;
|
|
180
|
+
margin-bottom: 15px;
|
|
181
|
+
background: rgba(255, 255, 255, 0.9);
|
|
182
|
+
color: #333;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
button {
|
|
186
|
+
background: white;
|
|
187
|
+
color: #000000;
|
|
188
|
+
border: none;
|
|
189
|
+
padding: 15px 30px;
|
|
190
|
+
font-size: 18px;
|
|
191
|
+
font-weight: bold;
|
|
192
|
+
cursor: pointer;
|
|
193
|
+
transition: all 0.3s ease;
|
|
194
|
+
margin: 5px;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
button:hover {
|
|
198
|
+
transform: translateY(-2px);
|
|
199
|
+
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
button:active {
|
|
203
|
+
transform: translateY(0);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.result {
|
|
207
|
+
margin-top: 20px;
|
|
208
|
+
padding: 20px;
|
|
209
|
+
background: rgba(255, 255, 255, 0.15);
|
|
210
|
+
min-height: 60px;
|
|
211
|
+
display: flex;
|
|
212
|
+
align-items: center;
|
|
213
|
+
justify-content: center;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.info {
|
|
217
|
+
text-align: left;
|
|
218
|
+
font-size: 0.9em;
|
|
219
|
+
line-height: 1.6;
|
|
220
|
+
}
|
|
221
|
+
</style>
|
|
222
|
+
</head>
|
|
223
|
+
<body>
|
|
224
|
+
<div class="container">
|
|
225
|
+
<h1>🚀 Hello ewvjs!</h1>
|
|
226
|
+
<p>A lightweight WebView2 application for Windows</p>
|
|
227
|
+
|
|
228
|
+
<input type="text" id="nameInput" placeholder="Enter your name..." value="World">
|
|
229
|
+
|
|
230
|
+
<div>
|
|
231
|
+
<button onclick="sayHello()">Greet Me</button>
|
|
232
|
+
<button onclick="showSystemInfo()">System Info</button>
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
<div class="result" id="result">
|
|
236
|
+
Click a button to see the result...
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
|
|
240
|
+
<script>
|
|
241
|
+
async function sayHello() {
|
|
242
|
+
const name = document.getElementById('nameInput').value || 'World';
|
|
243
|
+
const result = await window.ewvjs.api.greet(name);
|
|
244
|
+
document.getElementById('result').innerHTML = '<strong>' + result + '</strong>';
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
async function showSystemInfo() {
|
|
248
|
+
const info = await window.ewvjs.api.getSystemInfo();
|
|
249
|
+
document.getElementById('result').innerHTML =
|
|
250
|
+
'<div class="info">' +
|
|
251
|
+
'<strong>System Information:</strong><br>' +
|
|
252
|
+
'Platform: ' + info.platform + '<br>' +
|
|
253
|
+
'Architecture: ' + info.arch + '<br>' +
|
|
254
|
+
'Node.js: ' + info.nodeVersion + '<br>' +
|
|
255
|
+
'Uptime: ' + Math.floor(info.uptime) + ' seconds' +
|
|
256
|
+
'</div>';
|
|
257
|
+
}
|
|
258
|
+
</script>
|
|
259
|
+
</body>
|
|
260
|
+
</html>
|
|
261
|
+
\`, {
|
|
262
|
+
width: 800,
|
|
263
|
+
height: 600,
|
|
264
|
+
vibrancy: true,
|
|
265
|
+
debug: true
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
window.run();
|
|
269
|
+
|
|
270
|
+
// Start the event loop
|
|
271
|
+
start();
|
|
272
|
+
`;
|
|
273
|
+
|
|
274
|
+
fs.writeFileSync(path.join(projectDir, 'app.js'), appJs);
|
|
275
|
+
|
|
276
|
+
// Create README
|
|
277
|
+
const readme = `# ${name}
|
|
278
|
+
|
|
279
|
+
A ewvjs application.
|
|
280
|
+
|
|
281
|
+
## Getting Started
|
|
282
|
+
|
|
283
|
+
1. Install dependencies:
|
|
284
|
+
\`\`\`bash
|
|
285
|
+
npm install
|
|
286
|
+
\`\`\`
|
|
287
|
+
|
|
288
|
+
2. Run the application:
|
|
289
|
+
\`\`\`bash
|
|
290
|
+
npm start
|
|
291
|
+
\`\`\`
|
|
292
|
+
|
|
293
|
+
3. Package the application:
|
|
294
|
+
\`\`\`bash
|
|
295
|
+
npm run package
|
|
296
|
+
\`\`\`
|
|
297
|
+
|
|
298
|
+
## Project Structure
|
|
299
|
+
|
|
300
|
+
- \`app.js\` - Main application entry point
|
|
301
|
+
- \`assets/\` - Static assets (images, fonts, etc.)
|
|
302
|
+
- \`package.json\` - Project configuration
|
|
303
|
+
|
|
304
|
+
## Documentation
|
|
305
|
+
|
|
306
|
+
Visit [ewvjs documentation](https://github.com/your-repo/ewvjs) for more information.
|
|
307
|
+
`;
|
|
308
|
+
|
|
309
|
+
fs.writeFileSync(path.join(projectDir, 'README.md'), readme);
|
|
310
|
+
|
|
311
|
+
console.log('✅ Project created successfully!\n');
|
|
312
|
+
console.log('Next steps:');
|
|
313
|
+
console.log(` cd ${name}`);
|
|
314
|
+
console.log(' npm install');
|
|
315
|
+
console.log(' npm start\n');
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
program.parse();
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
export { WebView } from './webview';
|
|
3
|
+
export { Window } from './window';
|
|
4
|
+
import { WebView } from './webview';
|
|
5
|
+
declare const ewvjs: WebView;
|
|
6
|
+
export default ewvjs;
|
|
7
|
+
export declare const create_window: (title: string, url_or_html?: string, options?: Partial<import("./types").WindowOptions>) => import("./window").Window;
|
|
8
|
+
export declare const start: () => Promise<void>;
|
|
9
|
+
export declare const expose: (name: string, func: Function) => void;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA2BA,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,QAAA,MAAM,KAAK,SAAgB,CAAC;AAC5B,eAAe,KAAK,CAAC;AAGrB,eAAO,MAAM,aAAa,wHAAkC,CAAC;AAC7D,eAAO,MAAM,KAAK,qBAA0B,CAAC;AAC7C,eAAO,MAAM,MAAM,wCAA2B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.expose = exports.start = exports.create_window = exports.Window = exports.WebView = void 0;
|
|
40
|
+
// Setup module resolution for node-api-dotnet BEFORE any imports
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const isPkg = typeof process.pkg !== 'undefined';
|
|
44
|
+
if (isPkg) {
|
|
45
|
+
const execDir = path.dirname(process.execPath);
|
|
46
|
+
const dllDir = path.join(execDir, 'native');
|
|
47
|
+
const nodeModulesPath = path.join(dllDir, 'node_modules');
|
|
48
|
+
if (fs.existsSync(nodeModulesPath)) {
|
|
49
|
+
// Set NODE_PATH environment variable
|
|
50
|
+
const existingNodePath = process.env.NODE_PATH || '';
|
|
51
|
+
process.env.NODE_PATH = existingNodePath
|
|
52
|
+
? `${nodeModulesPath};${existingNodePath}`
|
|
53
|
+
: nodeModulesPath;
|
|
54
|
+
// Since pkg locks Module properties, we need to intercept requires at a higher level
|
|
55
|
+
// Add the node_modules path to require.resolve paths by modifying module.paths
|
|
56
|
+
// This needs to be done for every module, so we'll hook into the module creation
|
|
57
|
+
if (typeof require.main !== 'undefined' && require.main.paths) {
|
|
58
|
+
require.main.paths.unshift(nodeModulesPath);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Export types
|
|
63
|
+
__exportStar(require("./types"), exports);
|
|
64
|
+
// Export classes
|
|
65
|
+
var webview_1 = require("./webview");
|
|
66
|
+
Object.defineProperty(exports, "WebView", { enumerable: true, get: function () { return webview_1.WebView; } });
|
|
67
|
+
var window_1 = require("./window");
|
|
68
|
+
Object.defineProperty(exports, "Window", { enumerable: true, get: function () { return window_1.Window; } });
|
|
69
|
+
// Create and export singleton instance
|
|
70
|
+
const webview_2 = require("./webview");
|
|
71
|
+
const ewvjs = new webview_2.WebView();
|
|
72
|
+
exports.default = ewvjs;
|
|
73
|
+
// Export convenience functions
|
|
74
|
+
exports.create_window = ewvjs.create_window.bind(ewvjs);
|
|
75
|
+
exports.start = ewvjs.start.bind(ewvjs);
|
|
76
|
+
exports.expose = ewvjs.expose.bind(ewvjs);
|