node-api-dotnet 0.7.19 → 0.7.26
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 +4 -4
- package/index.d.ts +38 -3
- 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/net472/Microsoft.JavaScript.NodeApi.runtimeconfig.json +0 -2
- package/net6.0/Microsoft.JavaScript.NodeApi.DotNetHost.dll +0 -0
- package/net6.0/Microsoft.JavaScript.NodeApi.dll +0 -0
- package/net6.0/Microsoft.JavaScript.NodeApi.runtimeconfig.json +0 -3
- package/net8.0/Microsoft.JavaScript.NodeApi.DotNetHost.dll +0 -0
- package/net8.0/Microsoft.JavaScript.NodeApi.dll +0 -0
- package/net8.0/Microsoft.JavaScript.NodeApi.runtimeconfig.json +0 -3
- 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
|
@@ -110,7 +110,7 @@ dotnet.ExampleNamespace.ExampleClass.ExampleMethod(...args); // This call is typ
|
|
|
110
110
|
|
|
111
111
|
(CommonJS modules must use `require()` instead of `import`.)
|
|
112
112
|
|
|
113
|
-
For reference, there is a [list of C# type projections to TypeScript](/
|
|
113
|
+
For reference, there is a [list of C# type projections to TypeScript](/docs/typescript.md).
|
|
114
114
|
|
|
115
115
|
### Full async support
|
|
116
116
|
JavaScript code can `await` a call to a .NET method that returns a `Task`. The marshaller
|
|
@@ -282,12 +282,12 @@ For details, see [Using .NET Generics in JavaScript](./docs/generics.md).
|
|
|
282
282
|
|
|
283
283
|
#### Instructions
|
|
284
284
|
For calling .NET from JS, choose between one of the following scenarios:
|
|
285
|
-
- [Dynamically invoke .NET APIs from JavaScript](./
|
|
285
|
+
- [Dynamically invoke .NET APIs from JavaScript](./docs/dynamic-invoke.md)<br/>
|
|
286
286
|
Dynamic invocation is simpler to set up: all you need is the `node-api-dotnet` npm package and
|
|
287
287
|
the path to a .NET assembly you want to call. But it has some limitations (not all kinds of APIs
|
|
288
288
|
are supported), and is not quite as fast as a C# module, because marshalling code must be
|
|
289
289
|
generated at runtime.
|
|
290
|
-
- [Develop a Node module in C#](./
|
|
290
|
+
- [Develop a Node module in C#](./docs/node-module.md)<br/>
|
|
291
291
|
A C# Node module is appropriate for an application that has more advanced interop needs. It can
|
|
292
292
|
be faster because marshalling code can be generated at compile time, and the shape of the APIs
|
|
293
293
|
exposed to JavaScript can be adapted with JS interop in mind.
|
|
@@ -330,4 +330,4 @@ third-party's policies.
|
|
|
330
330
|
<br/>
|
|
331
331
|
<br/>
|
|
332
332
|
|
|
333
|
-

|
package/index.d.ts
CHANGED
|
@@ -1,10 +1,38 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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/net6.0';
|
|
22
|
+
* ```
|
|
23
|
+
* ```TypeScript [CommonJS (TS)]
|
|
24
|
+
* import * as dotnet from 'node-api-dotnet/net6.0';
|
|
25
|
+
* ```
|
|
26
|
+
* ```JavaScript [CommonJS (JS)]
|
|
27
|
+
* const dotnet = require('node-api-dotnet/net6.0');
|
|
28
|
+
* ```
|
|
29
|
+
* :::
|
|
30
|
+
* Currently the supported target frameworks are `net472`, `net6.0`, and `net8.0`.
|
|
31
|
+
* @module node-api-dotnet
|
|
32
|
+
*/
|
|
7
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.
|
|
8
36
|
|
|
9
37
|
/**
|
|
10
38
|
* Gets the current .NET runtime version, for example "8.0.1".
|
|
@@ -23,6 +51,8 @@ export const frameworkMoniker: string;
|
|
|
23
51
|
* @param dotnetAssemblyFilePath Path to the .NET assembly DLL file.
|
|
24
52
|
* @returns The JavaScript module exported by the assembly. (Type information for the module
|
|
25
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.
|
|
26
56
|
*/
|
|
27
57
|
export function require(dotnetAssemblyFilePath: string): any;
|
|
28
58
|
|
|
@@ -31,6 +61,11 @@ export function require(dotnetAssemblyFilePath: string): any;
|
|
|
31
61
|
* dynamic invocation of any APIs in the assembly. After loading, types from the assembly are
|
|
32
62
|
* available via namespaces on the main dotnet module.
|
|
33
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`.)
|
|
34
69
|
*/
|
|
35
70
|
export function load(assemblyNameOrFilePath: string): void;
|
|
36
71
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
"runtimeOptions": {
|
|
3
3
|
"tfm": "net472",
|
|
4
4
|
"configProperties": {
|
|
5
|
-
"System.Globalization.Invariant": true,
|
|
6
5
|
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
|
|
7
|
-
"System.Resources.UseSystemResourceKeys": true,
|
|
8
6
|
"System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting": true
|
|
9
7
|
}
|
|
10
8
|
}
|
|
Binary file
|
|
Binary file
|
|
@@ -6,10 +6,7 @@
|
|
|
6
6
|
"version": "6.0.0"
|
|
7
7
|
},
|
|
8
8
|
"configProperties": {
|
|
9
|
-
"System.Globalization.Invariant": true,
|
|
10
|
-
"System.Globalization.PredefinedCulturesOnly": true,
|
|
11
9
|
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
|
|
12
|
-
"System.Resources.UseSystemResourceKeys": true,
|
|
13
10
|
"System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting": true
|
|
14
11
|
}
|
|
15
12
|
}
|
|
Binary file
|
|
Binary file
|
|
@@ -6,10 +6,7 @@
|
|
|
6
6
|
"version": "8.0.0"
|
|
7
7
|
},
|
|
8
8
|
"configProperties": {
|
|
9
|
-
"System.Globalization.Invariant": true,
|
|
10
|
-
"System.Globalization.PredefinedCulturesOnly": true,
|
|
11
9
|
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
|
|
12
|
-
"System.Resources.UseSystemResourceKeys": true,
|
|
13
10
|
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false,
|
|
14
11
|
"System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting": true
|
|
15
12
|
}
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|