@devscholar/node-ps1-dotnet 0.0.3 → 0.0.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 +1 -1
- package/package.json +8 -5
- package/scripts/PsBridge/Reflection.cs +19 -0
- package/src/index.ts +10 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
⚠️ This project is still in pre-alpha stage, and API is subject to change.
|
|
4
4
|
|
|
5
|
-
This is a project that mimics the [Node API for .NET](https://github.com/microsoft/node-api-dotnet), aiming to utilize the built-in PowerShell 5.1 in Windows to replace the full high-version .NET runtime, thereby reducing the program's size. Since this project uses IPC instead of C++ Addon, it is compatible not only with Node but also with Deno and Bun.
|
|
5
|
+
This is a project that mimics the [Node API for .NET](https://github.com/microsoft/node-api-dotnet), aiming to utilize the built-in PowerShell 5.1 in Windows to replace the full high-version .NET runtime, thereby reducing the program's size. Since this project uses IPC instead of C++ Addon, it is compatible not only with Node but also with Deno and Bun.
|
|
6
6
|
|
|
7
7
|
# Requirements
|
|
8
8
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devscholar/node-ps1-dotnet",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Node.js to .NET interop via IPC",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -16,12 +16,15 @@
|
|
|
16
16
|
"keywords": [
|
|
17
17
|
"dotnet",
|
|
18
18
|
"winforms",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
19
|
+
"wpf",
|
|
20
|
+
"webview2",
|
|
21
|
+
"netfx",
|
|
22
|
+
"deno",
|
|
23
|
+
"bun",
|
|
24
|
+
"gui"
|
|
22
25
|
],
|
|
23
26
|
"author": "",
|
|
24
|
-
"license": "
|
|
27
|
+
"license": "MIT",
|
|
25
28
|
"devDependencies": {
|
|
26
29
|
"@types/node": "^25.0.10",
|
|
27
30
|
"typescript": "^5.9.3",
|
|
@@ -647,6 +647,25 @@ public static class Reflection
|
|
|
647
647
|
return Protocol.ConvertToProtocol(asm);
|
|
648
648
|
}
|
|
649
649
|
|
|
650
|
+
if (action == "LoadFrom")
|
|
651
|
+
{
|
|
652
|
+
var filePath = cmd["filePath"].ToString();
|
|
653
|
+
if (!File.Exists(filePath))
|
|
654
|
+
{
|
|
655
|
+
throw new Exception("File not found: " + filePath);
|
|
656
|
+
}
|
|
657
|
+
Assembly asm = null;
|
|
658
|
+
try
|
|
659
|
+
{
|
|
660
|
+
asm = Assembly.LoadFrom(filePath);
|
|
661
|
+
}
|
|
662
|
+
catch (Exception ex)
|
|
663
|
+
{
|
|
664
|
+
throw new Exception("Failed to load assembly from file: " + ex.Message);
|
|
665
|
+
}
|
|
666
|
+
return Protocol.ConvertToProtocol(asm);
|
|
667
|
+
}
|
|
668
|
+
|
|
650
669
|
if (action == "Release")
|
|
651
670
|
{
|
|
652
671
|
Protocol.RemoveBridgeObject(cmd["targetId"].ToString());
|
package/src/index.ts
CHANGED
|
@@ -136,6 +136,13 @@ export const node_ps1_dotnet = {
|
|
|
136
136
|
return createProxy(res);
|
|
137
137
|
},
|
|
138
138
|
|
|
139
|
+
_loadFrom(filePath: string): any {
|
|
140
|
+
doInitialize();
|
|
141
|
+
const ipc = getIpc();
|
|
142
|
+
const res = ipc!.send({ action: 'LoadFrom', filePath });
|
|
143
|
+
return createProxy(res);
|
|
144
|
+
},
|
|
145
|
+
|
|
139
146
|
_getRuntimeInfo(): { frameworkMoniker: string; runtimeVersion: string } {
|
|
140
147
|
if (getCachedRuntimeInfo()) return getCachedRuntimeInfo()!;
|
|
141
148
|
doInitialize();
|
|
@@ -159,6 +166,9 @@ const dotnetProxy = new Proxy(function() {} as any, {
|
|
|
159
166
|
if (prop === 'load') return (assemblyNameOrFilePath: string) => {
|
|
160
167
|
node_ps1_dotnet._loadAssembly(assemblyNameOrFilePath);
|
|
161
168
|
};
|
|
169
|
+
if (prop === 'loadFrom') return (filePath: string) => {
|
|
170
|
+
node_ps1_dotnet._loadFrom(filePath);
|
|
171
|
+
};
|
|
162
172
|
if (prop === 'frameworkMoniker') {
|
|
163
173
|
return node_ps1_dotnet._getRuntimeInfo().frameworkMoniker;
|
|
164
174
|
}
|