node-api-dotnet 0.4.26 → 0.4.33
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/index.d.ts +11 -0
- package/index.js +1 -1
- package/init.js +20 -2
- 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.d.ts +2 -0
- package/net6.0/Microsoft.JavaScript.NodeApi.DotNetHost.dll +0 -0
- package/net6.0/Microsoft.JavaScript.NodeApi.dll +0 -0
- package/net6.0.d.ts +2 -0
- package/net8.0/Microsoft.JavaScript.NodeApi.DotNetHost.dll +0 -0
- package/net8.0/Microsoft.JavaScript.NodeApi.dll +0 -0
- package/net8.0.d.ts +2 -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/index.d.ts
CHANGED
|
@@ -6,6 +6,17 @@
|
|
|
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
|
+
* Gets the current .NET runtime version, for example "8.0.1".
|
|
11
|
+
*/
|
|
12
|
+
export const runtimeVersion: string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Gets the framework monikier corresponding to the current .NET runtime version,
|
|
16
|
+
* for example "net8.0" or "net472".
|
|
17
|
+
*/
|
|
18
|
+
export const frameworkMoniker: string;
|
|
19
|
+
|
|
9
20
|
/**
|
|
10
21
|
* Loads a .NET assembly that was built to be a Node API module, using static binding to
|
|
11
22
|
* the APIs the module specifically exports to JS.
|
package/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const initialize = require('./init');
|
|
2
|
-
module.exports = initialize(
|
|
2
|
+
module.exports = initialize();
|
package/init.js
CHANGED
|
@@ -16,18 +16,36 @@ const ridPlatform =
|
|
|
16
16
|
const ridArch = process.arch === 'ia32' ? 'x86' : process.arch;
|
|
17
17
|
const rid = `${ridPlatform}-${ridArch}`;
|
|
18
18
|
|
|
19
|
+
const defaultTargetFramework = 'net8.0';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The loaded instance of the .NET Runtime. Only one instance/version may be loaded in the process.
|
|
23
|
+
*/
|
|
24
|
+
let dotnet = undefined;
|
|
25
|
+
|
|
19
26
|
/**
|
|
20
27
|
* Initializes the Node API .NET host.
|
|
21
|
-
* @param {string} targetFramework Minimum requested .NET version. Must be one of the target
|
|
28
|
+
* @param {string?} targetFramework Minimum requested .NET version. Must be one of the target
|
|
22
29
|
* framework monikers supported by the Node API .NET package. The actual loaded version of .NET
|
|
23
30
|
* may be higher, if the requested version is not installed.
|
|
24
31
|
* @returns {import('./index')} The Node API .NET host.
|
|
25
32
|
*/
|
|
26
33
|
function initialize(targetFramework) {
|
|
34
|
+
if (!targetFramework) {
|
|
35
|
+
// Some version was already loaded and no specific version was requested.
|
|
36
|
+
// Return the already-loaded version.
|
|
37
|
+
if (dotnet) {
|
|
38
|
+
return dotnet;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
targetFramework = defaultTargetFramework;
|
|
42
|
+
}
|
|
43
|
+
|
|
27
44
|
const assemblyName = 'Microsoft.JavaScript.NodeApi';
|
|
28
45
|
const nativeHostPath = __dirname + `/${rid}/${assemblyName}.node`;
|
|
29
46
|
const managedHostPath = __dirname + `/${targetFramework}/${assemblyName}.DotNetHost.dll`
|
|
30
47
|
|
|
31
48
|
const nativeHost = require(nativeHostPath);
|
|
32
|
-
|
|
49
|
+
dotnet = nativeHost.initialize(targetFramework, managedHostPath, require);
|
|
50
|
+
return dotnet;
|
|
33
51
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/net472.d.ts
ADDED
|
Binary file
|
|
Binary file
|
package/net6.0.d.ts
ADDED
|
Binary file
|
|
Binary file
|
package/net8.0.d.ts
ADDED
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|