ewvjs 1.0.7 → 1.0.9

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.
Files changed (41) hide show
  1. package/package.json +54 -55
  2. package/native/node_modules/node-api-dotnet/README.md +0 -80
  3. package/native/node_modules/node-api-dotnet/index.d.ts +0 -98
  4. package/native/node_modules/node-api-dotnet/linux-arm64/Microsoft.JavaScript.NodeApi.node +0 -0
  5. package/native/node_modules/node-api-dotnet/linux-x64/Microsoft.JavaScript.NodeApi.node +0 -0
  6. package/native/node_modules/node-api-dotnet/net472/Microsoft.Bcl.AsyncInterfaces.dll +0 -0
  7. package/native/node_modules/node-api-dotnet/net472/Microsoft.JavaScript.NodeApi.DotNetHost.dll +0 -0
  8. package/native/node_modules/node-api-dotnet/net472/Microsoft.JavaScript.NodeApi.dll +0 -0
  9. package/native/node_modules/node-api-dotnet/net472/Microsoft.JavaScript.NodeApi.runtimeconfig.json +0 -9
  10. package/native/node_modules/node-api-dotnet/net472/System.Memory.dll +0 -0
  11. package/native/node_modules/node-api-dotnet/net472/System.Runtime.CompilerServices.Unsafe.dll +0 -0
  12. package/native/node_modules/node-api-dotnet/net472/System.Threading.Tasks.Extensions.dll +0 -0
  13. package/native/node_modules/node-api-dotnet/net472.d.ts +0 -2
  14. package/native/node_modules/node-api-dotnet/net472.js +0 -2
  15. package/native/node_modules/node-api-dotnet/net8.0/Microsoft.JavaScript.NodeApi.DotNetHost.dll +0 -0
  16. package/native/node_modules/node-api-dotnet/net8.0/Microsoft.JavaScript.NodeApi.dll +0 -0
  17. package/native/node_modules/node-api-dotnet/net8.0/Microsoft.JavaScript.NodeApi.runtimeconfig.json +0 -14
  18. package/native/node_modules/node-api-dotnet/net8.0.d.ts +0 -2
  19. package/native/node_modules/node-api-dotnet/net8.0.js +0 -2
  20. package/native/node_modules/node-api-dotnet/net9.0.d.ts +0 -2
  21. package/native/node_modules/node-api-dotnet/osx-arm64/Microsoft.JavaScript.NodeApi.node +0 -0
  22. package/native/node_modules/node-api-dotnet/osx-x64/Microsoft.JavaScript.NodeApi.node +0 -0
  23. package/native/node_modules/node-api-dotnet/package.json +0 -27
  24. package/src/README.md +0 -125
  25. package/src/csharp/bin/Release/net10.0-windows/Microsoft.Web.WebView2.Core.dll +0 -0
  26. package/src/csharp/bin/Release/net10.0-windows/Microsoft.Web.WebView2.Core.xml +0 -6817
  27. package/src/csharp/bin/Release/net10.0-windows/Microsoft.Web.WebView2.WinForms.dll +0 -0
  28. package/src/csharp/bin/Release/net10.0-windows/Microsoft.Web.WebView2.WinForms.xml +0 -510
  29. package/src/csharp/bin/Release/net10.0-windows/Microsoft.Web.WebView2.Wpf.dll +0 -0
  30. package/src/csharp/bin/Release/net10.0-windows/Microsoft.Web.WebView2.Wpf.xml +0 -1902
  31. package/src/csharp/bin/Release/net10.0-windows/WebView.cjs +0 -26
  32. package/src/csharp/bin/Release/net10.0-windows/WebView.d.ts +0 -8
  33. package/src/csharp/bin/Release/net10.0-windows/WebView.deps.json +0 -260
  34. package/src/csharp/bin/Release/net10.0-windows/WebView.dll +0 -0
  35. package/src/csharp/bin/Release/net10.0-windows/WebView.mjs +0 -31
  36. package/src/csharp/bin/Release/net10.0-windows/WebView.pdb +0 -0
  37. package/src/csharp/bin/Release/net10.0-windows/import.cjs +0 -3
  38. package/src/csharp/bin/Release/net10.0-windows/runtimes/win-arm64/native/WebView2Loader.dll +0 -0
  39. package/src/csharp/bin/Release/net10.0-windows/runtimes/win-x64/native/WebView2Loader.dll +0 -0
  40. package/src/csharp/bin/Release/net10.0-windows/runtimes/win-x86/native/WebView2Loader.dll +0 -0
  41. /package/{README → README.md} +0 -0
package/package.json CHANGED
@@ -1,55 +1,54 @@
1
- {
2
- "name": "ewvjs",
3
- "version": "1.0.7",
4
- "description": "Embedded WebView for JavaScript - Edge WebView2 bindings for Node.js",
5
- "workspaces": [
6
- "packages/*"
7
- ],
8
- "main": "./dist/index.js",
9
- "types": "./dist/index.d.ts",
10
- "exports": {
11
- ".": {
12
- "types": "./dist/index.d.ts",
13
- "require": "./dist/index.js"
14
- }
15
- },
16
- "files": [
17
- "dist/**/*",
18
- "native/**/*",
19
- "src/csharp/bin/Release/**/*",
20
- "README.md",
21
- "LICENSE"
22
- ],
23
- "scripts": {
24
- "prebuild": "node scripts/copy-native.js",
25
- "build": "npm run prebuild && tsc",
26
- "build:webview": "dotnet build src/csharp/WebView.csproj -c Release"
27
- },
28
- "keywords": [
29
- "webview",
30
- "webview2",
31
- "windows",
32
- "electron-alternative",
33
- "gui",
34
- "native",
35
- "packaging",
36
- "cli"
37
- ],
38
- "author": "miukyo",
39
- "license": "MIT",
40
- "repository": {
41
- "type": "git",
42
- "url": "https://github.com/miukyo/ewvjs"
43
- },
44
- "type": "commonjs",
45
- "os": [
46
- "win32"
47
- ],
48
- "devDependencies": {
49
- "@types/node": "^25.2.0",
50
- "typescript": "^5.9.3"
51
- },
52
- "dependencies": {
53
- "node-api-dotnet": "^0.9.19"
54
- }
55
- }
1
+ {
2
+ "name": "ewvjs",
3
+ "version": "1.0.9",
4
+ "description": "Embedded WebView for JavaScript - Edge WebView2 bindings for Node.js",
5
+ "workspaces": [
6
+ "packages/*"
7
+ ],
8
+ "main": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "require": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist/**/*",
18
+ "native/**/*",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
22
+ "scripts": {
23
+ "prebuild": "node scripts/copy-native.js",
24
+ "build": "npm run prebuild && tsc",
25
+ "build:webview": "dotnet build src/csharp/WebView.csproj -c Release"
26
+ },
27
+ "keywords": [
28
+ "webview",
29
+ "webview2",
30
+ "windows",
31
+ "electron-alternative",
32
+ "gui",
33
+ "native",
34
+ "packaging",
35
+ "cli"
36
+ ],
37
+ "author": "miukyo",
38
+ "license": "MIT",
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/miukyo/ewvjs"
42
+ },
43
+ "type": "commonjs",
44
+ "os": [
45
+ "win32"
46
+ ],
47
+ "devDependencies": {
48
+ "@types/node": "^25.2.0",
49
+ "typescript": "^5.9.3"
50
+ },
51
+ "dependencies": {
52
+ "node-api-dotnet": "^0.9.19"
53
+ }
54
+ }
@@ -1,80 +0,0 @@
1
- # Node API for .NET: JavaScript + .NET Interop
2
-
3
- This project enables advanced interoperability between .NET and JavaScript in the same process.
4
-
5
- - Load .NET assemblies and call .NET APIs in-proc from a JavaScript application.
6
- - Load JavaScript packages and call JS APIs in-proc from a .NET application.
7
-
8
- Interop is high-performance and supports TypeScript type-definitions generation, async
9
- (tasks/promises), streams, and more. It uses [Node API](https://nodejs.org/api/n-api.html) so
10
- it is compatible with any Node.js version (without recompiling) or other JavaScript runtime that
11
- supports Node API.
12
-
13
- :warning: _**Status: Public Preview** - Most functionality works well, though there are some known
14
- limitations around the edges, and there may still be minor breaking API changes._
15
-
16
- ### Documentation
17
-
18
- Getting-started guidance, feature details, and API reference documentation are published at
19
- https://microsoft.github.io/node-api-dotnet
20
-
21
- ### Minimal example - JS calling .NET
22
- ```JavaScript
23
- // JavaScript
24
- const Console = require('node-api-dotnet').System.Console;
25
- Console.WriteLine('Hello from .NET!'); // JS writes to the .NET console API
26
- ```
27
-
28
- ### Minimal example - .NET calling JS
29
- ```C#
30
- // C#
31
- interface IConsole { void Log(string message); }
32
-
33
- var nodejs = new NodejsPlatform(libnodePath).CreateEnvironment();
34
- nodejs.Run(() =>
35
- {
36
- var console = nodejs.Import<IConsole>("global", "console");
37
- console.Log("Hello from JS!"); // C# writes to the JS console API
38
- });
39
- ```
40
-
41
- ## Packages
42
-
43
- Depending on the [scenario](https://microsoft.github.io/node-api-dotnet/scenarios/),
44
- either NPM or NuGet packages may be used:
45
- - NPM: [`node-api-dotnet`](https://www.npmjs.com/package/node-api-dotnet)
46
- - NuGet: [`Microsoft.JavaScript.NodeApi`](https://www.nuget.org/packages/Microsoft.JavaScript.NodeApi/)
47
-
48
- See [Packages & Releases](https://microsoft.github.io/node-api-dotnet/reference/packages-releases.html)
49
- for details.
50
-
51
- ## Development
52
-
53
- For information about building, testing, and debugging this project, see
54
- [README-DEV.md](./README-DEV.md).
55
-
56
- Contributions require agreement to the
57
- [Contributor License Agreement](https://microsoft.github.io/node-api-dotnet/contributing.html#contributor-license-agreement).
58
-
59
- ## Code of Conduct
60
-
61
- This project has adopted the
62
- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
63
- For more information see the
64
- [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
65
- contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or
66
- comments.
67
-
68
- ## Trademarks
69
-
70
- This project may contain trademarks or logos for projects, products, or services. Authorized use of
71
- Microsoft trademarks or logos is subject to and must follow
72
- [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
73
- Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion
74
- or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those
75
- third-party's policies.
76
-
77
- <br/>
78
- <br/>
79
-
80
- ![.NET + JS scene](./docs/images/dotnet-bot_scene_coffee-shop.png)
@@ -1,98 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
-
4
- /**
5
- * Use the `node-api-dotnet` package to load .NET assemblies into a Node.js application and
6
- * call public APIs defined in the assemblies.
7
- * ::: code-group
8
- * ```JavaScript [ES (TS or JS)]
9
- * import dotnet from 'node-api-dotnet';
10
- * ```
11
- * ```TypeScript [CommonJS (TS)]
12
- * import * as dotnet from 'node-api-dotnet';
13
- * ```
14
- * ```JavaScript [CommonJS (JS)]
15
- * const dotnet = require('node-api-dotnet');
16
- * ```
17
- * :::
18
- * To load a specific version of .NET, append the target framework moniker to the package name:
19
- * ::: code-group
20
- * ```JavaScript [ES (TS or JS)]
21
- * import dotnet from 'node-api-dotnet/net8.0';
22
- * ```
23
- * ```TypeScript [CommonJS (TS)]
24
- * import * as dotnet from 'node-api-dotnet/net8.0';
25
- * ```
26
- * ```JavaScript [CommonJS (JS)]
27
- * const dotnet = require('node-api-dotnet/net8.0');
28
- * ```
29
- * :::
30
- * Currently the supported target frameworks are `net472`, `net8.0`, and `net9.0`.
31
- * @module node-api-dotnet
32
- */
33
- declare module 'node-api-dotnet' {
34
- // APIs defined here are implemented by Microsoft.JavaScript.NodeApi.DotNetHost.
35
- // The explicit module declaration enables module members to be merged with imported namespaces.
36
-
37
- /**
38
- * Gets the current .NET runtime version, for example "8.0.1".
39
- */
40
- export const runtimeVersion: string;
41
-
42
- /**
43
- * Gets the framework monikier corresponding to the current .NET runtime version,
44
- * for example "net8.0" or "net472".
45
- */
46
- export const frameworkMoniker: string;
47
-
48
- /**
49
- * Loads a .NET assembly that was built to be a Node API module, using static binding to
50
- * the APIs the module specifically exports to JS.
51
- * @param dotnetAssemblyFilePath Path to the .NET assembly DLL file.
52
- * @returns The JavaScript module exported by the assembly. (Type information for the module
53
- * may be available in a separate generated type-definitions file.)
54
- * @description The .NET assembly must use `[JSExport]` attributes to export selected types
55
- * and/or members to JavaScript. These exports _do not_ use .NET namespaces.
56
- */
57
- export function require(dotnetAssemblyFilePath: string): any;
58
-
59
- /**
60
- * Loads an arbitrary .NET assembly that isn't necessarily designed as a JS module, enabling
61
- * dynamic invocation of any APIs in the assembly. After loading, types from the assembly are
62
- * available via namespaces on the main dotnet module.
63
- * @param assemblyNameOrFilePath Path to the .NET assembly DLL file, or name of a system assembly.
64
- * @description After loading an assembly, types in the assembly are merged into the .NET
65
- * namespace hierarchy, with top-level namespaces available as properties on the .NET module.
66
- * For example, if the assembly defines a type `Contoso.Business.Component`, it can be accessed as
67
- * `dotnet.Contoso.Business.Component`. (.NET core library types can be accessed the same way, for
68
- * example `dotnet.System.Console`.)
69
- */
70
- export function load(assemblyNameOrFilePath: string): void;
71
-
72
- /**
73
- * Adds a listener for the `resolving` event, which is raised when a .NET assembly requires
74
- * an additional dependent assembly to be resolved and loaded. The listener may call `resolve()`
75
- * to load the requested assembly from a resolved file path. If the listener does not call
76
- * `resolve()`, the runtime will then attempt to resolve the assembly by searching in the same
77
- * application directory as other already-loaded assemblies, if there were any.
78
- */
79
- export function addListener(
80
- event: 'resolving',
81
- /**
82
- * Resolving event listener funciton to be invokved when a .NET assembly is being resolved.
83
- * @param assemblyName Name of the assembly to be resolved.
84
- * @param assemblyVersion Version of the assembly to be resolved.
85
- * @param resolve Callback to invoke with the full path to the resolved assembly file.
86
- */
87
- listener: (assemblyName: string, assemblyVersion: string, resolve: (string) => void) => void,
88
- ): void;
89
-
90
- /**
91
- * Removes a listener for the `resolving` event.
92
- */
93
- export function removeListener(
94
- event: 'resolving',
95
- listener: (assemblyName: string, assemblyVersion: string) => void,
96
- ): void;
97
-
98
- }
@@ -1,9 +0,0 @@
1
- {
2
- "runtimeOptions": {
3
- "tfm": "net472",
4
- "configProperties": {
5
- "System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
6
- "System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting": true
7
- }
8
- }
9
- }
@@ -1,2 +0,0 @@
1
- import './index';
2
- export * from 'node-api-dotnet';
@@ -1,2 +0,0 @@
1
- const initialize = require('./init');
2
- module.exports = initialize('net472');
@@ -1,14 +0,0 @@
1
- {
2
- "runtimeOptions": {
3
- "tfm": "net8.0",
4
- "framework": {
5
- "name": "Microsoft.NETCore.App",
6
- "version": "8.0.0"
7
- },
8
- "configProperties": {
9
- "System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
10
- "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false,
11
- "System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting": true
12
- }
13
- }
14
- }
@@ -1,2 +0,0 @@
1
- import './index';
2
- export * from 'node-api-dotnet';
@@ -1,2 +0,0 @@
1
- const initialize = require('./init');
2
- module.exports = initialize('net8.0');
@@ -1,2 +0,0 @@
1
- import './index';
2
- export * from 'node-api-dotnet';
@@ -1,27 +0,0 @@
1
- {
2
- "name": "node-api-dotnet",
3
- "version": "0.9.19",
4
- "description": "Node-API bindings for .Net",
5
- "license": "MIT",
6
- "author": "Microsoft",
7
- "type": "commonjs",
8
- "exports": {
9
- ".": "./index.js",
10
- "./net10.0": "./net10.0.js",
11
- "./net9.0": "./net9.0.js",
12
- "./net8.0": "./net8.0.js",
13
- "./net472": "./net472.js"
14
- },
15
- "types": "./index.d.ts",
16
- "keywords": [
17
- "Node-API",
18
- "NAPI",
19
- ".Net",
20
- "dotnet"
21
- ],
22
- "repository": "github:microsoft/node-api-dotnet",
23
- "homepage": "https://github.com/microsoft/node-api-dotnet#readme",
24
- "bugs": {
25
- "url": "https://github.com/microsoft/node-api-dotnet/issues"
26
- }
27
- }
package/src/README.md DELETED
@@ -1,125 +0,0 @@
1
- # Source Code Structure
2
-
3
- The TypeScript source code is organized into logical modules for better readability and maintainability.
4
-
5
- ## Module Overview
6
-
7
- ### `index.ts`
8
- Main entry point that exports the public API. This is what users import when using ewvjs.
9
-
10
- **Exports:**
11
- - `WebView` class
12
- - `Window` class
13
- - All type definitions
14
- - Convenience functions: `create_window()`, `start()`, `expose()`
15
- - Default singleton instance
16
-
17
- ### `webview.ts`
18
- Contains the `WebView` class which manages the application lifecycle.
19
-
20
- **Responsibilities:**
21
- - Platform detection and initialization
22
- - Window creation and lifecycle management
23
- - Exposed function registry
24
- - Event loop management
25
-
26
- **Key Methods:**
27
- - `create_window()` - Creates a new window instance
28
- - `start()` - Starts the application event loop
29
- - `expose()` - Registers Node.js functions to be callable from WebView
30
-
31
- ### `window.ts`
32
- Contains the `Window` class which represents individual window instances.
33
-
34
- **Responsibilities:**
35
- - Window state management
36
- - Message routing between WebView and Node.js
37
- - Context menu handling
38
- - Exposed function call/response handling
39
- - API method delegation to platform
40
-
41
- **Method Categories:**
42
- - **Core**: `run()`, `close()`, `evaluate_js()`
43
- - **State**: `maximize()`, `minimize()`, `restore()`, `show()`, `hide()`, `focus()`
44
- - **Size/Position**: `getSize()`, `setSize()`, `getPosition()`, `setPosition()`, `move()`, `resize()`
45
- - **Title**: `setTitle()`, `set_title()`
46
- - **Title Bar**: `show_titlebar()`, `hide_titlebar()`
47
- - **Cookies**: `get_cookies()`, `set_cookie()`, `clear_cookies()`
48
-
49
- **Message Handling:**
50
- - `_on_message()` - Routes messages from C# to appropriate handlers
51
- - `_handleExposedFunction()` - Executes exposed Node.js functions
52
- - `_handleContextMenu()` - Processes context menu requests
53
- - `_handleMenuClick()` - Triggers menu item callbacks
54
-
55
- ### `types.ts`
56
- Type definitions and interfaces.
57
-
58
- **Types:**
59
- - `ContextMenuItem` - Context menu item definition
60
- - `WindowOptions` - Window configuration options
61
-
62
- ### `utils.ts`
63
- Utility functions used across modules.
64
-
65
- **Functions:**
66
- - `getParamNames()` - Extracts parameter names from a function
67
- - `generateId()` - Generates random IDs for menu items
68
-
69
- ## Data Flow
70
-
71
- ```
72
- User Code
73
-
74
- index.ts (exports)
75
-
76
- webview.ts (creates Window instances)
77
-
78
- window.ts (manages window lifecycle)
79
-
80
- platforms/windows.ts (platform-specific implementation)
81
-
82
- csharp/WebViewWindow.cs (native WebView2 integration)
83
- ```
84
-
85
- ## Message Flow (Exposed Functions)
86
-
87
- ```
88
- WebView JavaScript
89
- ↓ postMessage([funcName, params, id])
90
- C# WebViewWindow.CoreWebView2_WebMessageReceived
91
- ↓ SendMessageAsync()
92
- window.ts _on_message()
93
- ↓ _handleExposedFunction()
94
- Node.js Function Execution
95
- ↓ _sendSuccessResponse()
96
- window.evaluate_js()
97
- ↓ resolves promise in WebView
98
- WebView JavaScript receives result
99
- ```
100
-
101
- ## Best Practices
102
-
103
- 1. **Window Creation**: Always call `window.run()` after creating a window
104
- 2. **Exposed Functions**: Register with `expose()` before creating windows
105
- 3. **Cleanup**: Windows automatically clean up on close
106
- 4. **Error Handling**: All async methods can throw - use try/catch
107
- 5. **Threading**: All window operations are automatically marshaled to the correct thread
108
-
109
- ## Example Usage
110
-
111
- ```typescript
112
- import ewvjs from 'ewvjs';
113
-
114
- // Expose a Node.js function
115
- ewvjs.expose('greet', (name: string) => {
116
- return `Hello, ${name}!`;
117
- });
118
-
119
- // Create and run a window
120
- const win = ewvjs.create_window('My App', '<h1>Test</h1>');
121
- await win.run();
122
-
123
- // Start the event loop
124
- await ewvjs.start();
125
- ```