node-api-dotnet 0.3.1 → 0.4.4
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/README.md +12 -0
- package/index.d.ts +11 -24
- package/linux-x64/Microsoft.JavaScript.NodeApi.node +0 -0
- package/net472/Microsoft.JavaScript.NodeApi.DotNetHost.dll +0 -0
- package/net472/Microsoft.JavaScript.NodeApi.dll +0 -0
- package/net6.0/Microsoft.JavaScript.NodeApi.DotNetHost.dll +0 -0
- package/net6.0/Microsoft.JavaScript.NodeApi.dll +0 -0
- package/net7.0/Microsoft.JavaScript.NodeApi.DotNetHost.dll +0 -0
- package/net7.0/Microsoft.JavaScript.NodeApi.dll +0 -0
- package/osx-arm64/Microsoft.JavaScript.NodeApi.node +0 -0
- package/osx-x64/Microsoft.JavaScript.NodeApi.node +0 -0
- package/package.json +1 -1
- package/win-arm64/Microsoft.JavaScript.NodeApi.node +0 -0
- package/win-x64/Microsoft.JavaScript.NodeApi.node +0 -0
package/README.md
CHANGED
|
@@ -48,6 +48,7 @@ For more examples, see the [examples](./examples/) directory.
|
|
|
48
48
|
- [Stream across .NET and JS](#stream-across-net-and-js)
|
|
49
49
|
- [Optional .NET native AOT compilation](#optional-net-native-aot-compilation)
|
|
50
50
|
- [High performance](#high-performance)
|
|
51
|
+
- [Work with .NET generic APIs in JS](#generics)
|
|
51
52
|
|
|
52
53
|
### Load and call .NET assemblies from JS
|
|
53
54
|
The `node-api-dotnet` package manages hosting the .NET runtime in the JS process
|
|
@@ -257,6 +258,17 @@ Thanks to these design choices, JS to .NET calls are [more than twice as fast](
|
|
|
257
258
|
https://github.com/jasongin/napi-dotnet/pull/23) when compared to `edge-js` using
|
|
258
259
|
[that project's benchmark](https://github.com/tjanczuk/edge/wiki/Performance).
|
|
259
260
|
|
|
261
|
+
### Generics
|
|
262
|
+
Even though the JavaScript runtime type system lacks generics, it is possible to work with .NET
|
|
263
|
+
generic types and methods from JavaScript:
|
|
264
|
+
|
|
265
|
+
```JavaScript
|
|
266
|
+
// JavaScript
|
|
267
|
+
System.Enum.Parse$(System.DayOfWeek)('Tuesday');
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
For details, see [Using .NET Generics in JavaScript](./docs/generics.md).
|
|
271
|
+
|
|
260
272
|
## Getting Started
|
|
261
273
|
#### Requirements
|
|
262
274
|
- .NET 6 or later
|
package/index.d.ts
CHANGED
|
@@ -6,18 +6,6 @@
|
|
|
6
6
|
// This explicit module declaration enables module members to be merged with imported namespaces.
|
|
7
7
|
declare module 'node-api-dotnet' {
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* A .NET assembly that was loaded dynamically by the .NET host. Types within the assembly
|
|
11
|
-
* can be accessed via properties on the assembly object.
|
|
12
|
-
*/
|
|
13
|
-
export interface Assembly {
|
|
14
|
-
/**
|
|
15
|
-
* Gets a type within the assembly.
|
|
16
|
-
* @param typeName Either a type full name or (if unambiguous) simple type name.
|
|
17
|
-
*/
|
|
18
|
-
[typeName: string]: any;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
9
|
/**
|
|
22
10
|
* Loads a .NET assembly that was built to be a Node API module, using static binding to
|
|
23
11
|
* the APIs the module specifically exports to JS.
|
|
@@ -25,33 +13,32 @@ export interface Assembly {
|
|
|
25
13
|
* @returns The JavaScript module exported by the assembly. (Type information for the module
|
|
26
14
|
* may be available in a separate generated type-definitions file.)
|
|
27
15
|
*/
|
|
28
|
-
export
|
|
16
|
+
export function require(dotnetAssemblyFilePath: string): any;
|
|
29
17
|
|
|
30
18
|
/**
|
|
31
|
-
* Loads an arbitrary .NET assembly that isn't necessarily designed as a JS module,
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* @
|
|
35
|
-
* is a public type in the assembly.
|
|
19
|
+
* Loads an arbitrary .NET assembly that isn't necessarily designed as a JS module, enabling
|
|
20
|
+
* dynamic invocation of any APIs in the assembly. After loading, types from the assembly are
|
|
21
|
+
* available via namespaces on the main dotnet module.
|
|
22
|
+
* @param assemblyNameOrFilePath Path to the .NET assembly DLL file, or name of a system assembly.
|
|
36
23
|
*/
|
|
37
|
-
export
|
|
24
|
+
export function load(assemblyNameOrFilePath: string): void;
|
|
38
25
|
|
|
39
26
|
/**
|
|
40
27
|
* Adds a listener for the `resolving` event, which is raised when a .NET assembly requires
|
|
41
28
|
* an additional dependent assembly to be resolved and loaded. The listener must call `load()`
|
|
42
29
|
* to load the requested assembly file.
|
|
43
30
|
*/
|
|
44
|
-
export
|
|
31
|
+
export function addListener(
|
|
45
32
|
event: 'resolving',
|
|
46
33
|
listener: (assemblyName: string, assemblyVersion: string) => void,
|
|
47
|
-
):
|
|
34
|
+
): void;
|
|
48
35
|
|
|
49
36
|
/**
|
|
50
37
|
* Removes a listener for the `resolving` event.
|
|
51
38
|
*/
|
|
52
|
-
export
|
|
39
|
+
export function removeListener(
|
|
53
40
|
event: 'resolving',
|
|
54
41
|
listener: (assemblyName: string, assemblyVersion: string) => void,
|
|
55
|
-
):
|
|
42
|
+
): void;
|
|
56
43
|
|
|
57
|
-
}
|
|
44
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|