node-api-dotnet
Advanced tools
Comparing version 0.4.27 to 0.4.33
@@ -10,2 +10,13 @@ // Copyright (c) Microsoft Corporation. | ||
/** | ||
* Gets the current .NET runtime version, for example "8.0.1". | ||
*/ | ||
export const runtimeVersion: string; | ||
/** | ||
* Gets the framework monikier corresponding to the current .NET runtime version, | ||
* for example "net8.0" or "net472". | ||
*/ | ||
export const frameworkMoniker: string; | ||
/** | ||
* Loads a .NET assembly that was built to be a Node API module, using static binding to | ||
@@ -12,0 +23,0 @@ * the APIs the module specifically exports to JS. |
const initialize = require('./init'); | ||
module.exports = initialize('net6.0'); | ||
module.exports = initialize(); |
22
init.js
@@ -19,5 +19,12 @@ // Copyright (c) Microsoft Corporation. | ||
const defaultTargetFramework = 'net8.0'; | ||
/** | ||
* The loaded instance of the .NET Runtime. Only one instance/version may be loaded in the process. | ||
*/ | ||
let dotnet = undefined; | ||
/** | ||
* Initializes the Node API .NET host. | ||
* @param {string} targetFramework Minimum requested .NET version. Must be one of the target | ||
* @param {string?} targetFramework Minimum requested .NET version. Must be one of the target | ||
* framework monikers supported by the Node API .NET package. The actual loaded version of .NET | ||
@@ -28,2 +35,12 @@ * may be higher, if the requested version is not installed. | ||
function initialize(targetFramework) { | ||
if (!targetFramework) { | ||
// Some version was already loaded and no specific version was requested. | ||
// Return the already-loaded version. | ||
if (dotnet) { | ||
return dotnet; | ||
} | ||
targetFramework = defaultTargetFramework; | ||
} | ||
const assemblyName = 'Microsoft.JavaScript.NodeApi'; | ||
@@ -34,3 +51,4 @@ const nativeHostPath = __dirname + `/${rid}/${assemblyName}.node`; | ||
const nativeHost = require(nativeHostPath); | ||
return nativeHost.initialize(targetFramework, managedHostPath, require); | ||
dotnet = nativeHost.initialize(targetFramework, managedHostPath, require); | ||
return dotnet; | ||
} |
{ | ||
"name": "node-api-dotnet", | ||
"version": "0.4.27", | ||
"version": "0.4.33", | ||
"description": "Node-API bindings for .Net", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12428030
28
144