@devscholar/node-ps1-dotnet 0.0.0
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/EnsureBom.ps1 +27 -0
- package/LICENSE.md +22 -0
- package/README.md +65 -0
- package/examples/console/await-delay/await-delay.ts +14 -0
- package/examples/console/console-input/console-input.ts +18 -0
- package/examples/winforms/counter/counter.ts +47 -0
- package/examples/winforms/drag-box/drag-box.ts +62 -0
- package/examples/wpf/counter/counter.ts +55 -0
- package/examples/wpf/drag-box/drag-box.ts +84 -0
- package/examples/wpf/webview2-browser/WebView2Libs/Microsoft.Web.WebView2.Core.dll +0 -0
- package/examples/wpf/webview2-browser/WebView2Libs/Microsoft.Web.WebView2.Core.dll.backup +0 -0
- package/examples/wpf/webview2-browser/WebView2Libs/Microsoft.Web.WebView2.Wpf.dll +0 -0
- package/examples/wpf/webview2-browser/WebView2Libs/Microsoft.Web.WebView2.Wpf.dll.backup +0 -0
- package/examples/wpf/webview2-browser/WebView2Libs/WebView2License.txt +27 -0
- package/examples/wpf/webview2-browser/counter.html +31 -0
- package/examples/wpf/webview2-browser/webview2-browser.ts +90 -0
- package/package.json +19 -0
- package/scripts/PsBridge/BridgeState.cs +39 -0
- package/scripts/PsBridge/Protocol.cs +222 -0
- package/scripts/PsBridge/PsBridge.psd1 +10 -0
- package/scripts/PsBridge/PsBridge.psm1 +22 -0
- package/scripts/PsBridge/PsHost.cs +393 -0
- package/scripts/PsBridge/PsHostEntry.cs +23 -0
- package/scripts/PsBridge/Reflection.cs +830 -0
- package/scripts/PsHost.ps1 +11 -0
- package/src/index.ts +510 -0
- package/src/ipc.ts +182 -0
- package/src/types.ts +21 -0
- package/src/utils.ts +13 -0
- package/start.js +67 -0
- package/tsconfig.json +14 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/types.ts
|
|
2
|
+
export interface ProtocolResponse {
|
|
3
|
+
type: string;
|
|
4
|
+
value?: any;
|
|
5
|
+
id?: string;
|
|
6
|
+
message?: string;
|
|
7
|
+
args?: any[];
|
|
8
|
+
callbackId?: string;
|
|
9
|
+
memberType?: 'property' | 'method';
|
|
10
|
+
assemblyName?: string;
|
|
11
|
+
assemblyVersion?: string;
|
|
12
|
+
frameworkMoniker?: string;
|
|
13
|
+
runtimeVersion?: string;
|
|
14
|
+
resolvedPath?: string;
|
|
15
|
+
props?: Record<string, any>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface CommandRequest {
|
|
19
|
+
action: string;
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/utils.ts
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
|
|
4
|
+
declare const Deno: any;
|
|
5
|
+
|
|
6
|
+
export function getPowerShellPath(): string {
|
|
7
|
+
const isDeno = typeof Deno !== 'undefined';
|
|
8
|
+
if (isDeno) {
|
|
9
|
+
const windir = Deno.env.get('windir') || 'C:\\Windows';
|
|
10
|
+
return path.join(windir, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe');
|
|
11
|
+
}
|
|
12
|
+
return 'powershell.exe';
|
|
13
|
+
}
|
package/start.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// src/start.js
|
|
2
|
+
import { spawn } from 'child_process';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
let runtime = 'node';
|
|
12
|
+
let tsFile = null;
|
|
13
|
+
let extraArgs = [];
|
|
14
|
+
|
|
15
|
+
// Parse arguments
|
|
16
|
+
for (let i = 0; i < args.length; i++) {
|
|
17
|
+
const arg = args[i];
|
|
18
|
+
if (arg.startsWith('--runtime=')) {
|
|
19
|
+
runtime = arg.split('=')[1];
|
|
20
|
+
} else if (arg.startsWith('-r=')) {
|
|
21
|
+
runtime = arg.split('=')[1];
|
|
22
|
+
} else if (arg.endsWith('.ts') || arg.endsWith('.js')) {
|
|
23
|
+
tsFile = arg;
|
|
24
|
+
} else {
|
|
25
|
+
extraArgs.push(arg);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!tsFile) {
|
|
30
|
+
console.error('Usage: node start.js <ts-file> [--runtime=node|bun|deno] [args...]');
|
|
31
|
+
console.error('Example: node start.js examples/winforms/clock-app/clock-app.ts');
|
|
32
|
+
console.error('Example: node start.js app.ts --runtime=deno');
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const filePath = path.resolve(tsFile);
|
|
37
|
+
|
|
38
|
+
if (!fs.existsSync(filePath)) {
|
|
39
|
+
console.error(`Error: File not found: ${filePath}`);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const runtimeFlags = {
|
|
44
|
+
node: ['--experimental-transform-types'],
|
|
45
|
+
bun: [],
|
|
46
|
+
deno: ['run', '--allow-all', '--unstable-node-globals']
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const runtimeArgs = runtimeFlags[runtime] || [];
|
|
50
|
+
const runtimeCmd = runtime;
|
|
51
|
+
|
|
52
|
+
console.log(`Running with ${runtime}: ${tsFile}`);
|
|
53
|
+
|
|
54
|
+
const proc = spawn(runtimeCmd, [...runtimeArgs, filePath, ...extraArgs], {
|
|
55
|
+
stdio: 'inherit',
|
|
56
|
+
cwd: process.cwd(),
|
|
57
|
+
env: process.env
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
proc.on('exit', (code) => {
|
|
61
|
+
process.exit(code);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
proc.on('error', (err) => {
|
|
65
|
+
console.error(`Failed to start ${runtime}:`, err.message);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "NodeNext",
|
|
4
|
+
"target": "esnext",
|
|
5
|
+
"moduleResolution": "nodenext",
|
|
6
|
+
"allowImportingTsExtensions": true,
|
|
7
|
+
"noEmit": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"skipLibCheck": true
|
|
11
|
+
},
|
|
12
|
+
"include": ["src/**/*"],
|
|
13
|
+
"exclude": ["node_modules", "dist"]
|
|
14
|
+
}
|