Skip to content

Commit 8bab03a

Browse files
committedMar 10, 2025·
updating readme
1 parent 8986ffe commit 8bab03a

File tree

1 file changed

+100
-67
lines changed

1 file changed

+100
-67
lines changed
 

‎README.md

+100-67
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,19 @@ Read more about the background and motivations of the project [here](http://toma
4343

4444
## Updates
4545
* Support for new versions of Node.Js.
46-
* Support for .NET Core 3.1 - 8.x on Windows/Linux/macOS.
46+
* Support for .NET Core 3.1 - 9.x on Windows/Linux/macOS.
4747
* Fixes AccessViolationException when running Node.js code from C# [PR #573](https://github.com/tjanczuk/edge/pull/573).
4848
* Fixes StackOverflowException [PR #566](https://github.com/tjanczuk/edge/pull/566) that occurs when underlying C# code throws complex exception.
4949
* Fixes issues [#469](https://github.com/tjanczuk/edge/issues/469), [#713](https://github.com/tjanczuk/edge/issues/713)
5050
* Other PRs: [PR #725](https://github.com/tjanczuk/edge/pull/725), [PR #640](https://github.com/tjanczuk/edge/pull/640)
5151
* Multiple bug fixes and improvements to the original code.
5252

5353
----
54+
5455
### NPM package [`edge-js`](https://www.npmjs.com/package/edge-js)
5556

5657
### NuGet package [`EdgeJs`](https://www.nuget.org/packages/EdgeJs)
58+
5759
----
5860

5961
## Electron
@@ -75,7 +77,7 @@ https://github.com/agracio/edge-js-quick-start
7577
### Windows
7678

7779
| Version | x86 | x64 | arm64 |
78-
| ------- | ------------------ | ------------------ | ------------------ |
80+
|---------|--------------------|--------------------|--------------------|
7981
| 16.x | :heavy_check_mark: | :heavy_check_mark: | :x: |
8082
| 18.x | :heavy_check_mark: | :heavy_check_mark: | :x: |
8183
| 20.x | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
@@ -85,47 +87,48 @@ https://github.com/agracio/edge-js-quick-start
8587

8688
### macOS
8789

88-
| Version | x64 | arm64 (M1+) |
89-
| -------------- | ------------------ | ------------------ |
90-
| 16.x - 23.x | :heavy_check_mark: | :heavy_check_mark: |
90+
| Version | x64 | arm64 (M1+) |
91+
|-------------|--------------------|--------------------|
92+
| 16.x - 23.x | :heavy_check_mark: | :heavy_check_mark: |
9193

9294
### Linux
9395

94-
| Version | x64 | arm64 |
95-
| -------------- | ------------------ | ------------------ |
96-
| 14.x - 23.x | :heavy_check_mark: | :heavy_check_mark: |
96+
| Version | x64 | arm64 |
97+
|-------------|--------------------|--------------------|
98+
| 14.x - 23.x | :heavy_check_mark: | :heavy_check_mark: |
9799

98100
## Scripting CLR from Node.js and Node.js from CRL
99101

100102
<table>
101103
<tr><th>Script CLR from Node.js </th><th>Script Node.js from CLR</th></tr>
102104
<tr><td>
103105

104-
| | .NET 4.5 | CoreCLR |
105-
| ------- | ------------------ | ------------------ |
106-
| Windows | :heavy_check_mark: | :heavy_check_mark: |
107-
| Linux | :x: | :heavy_check_mark: |
108-
| macOS | :x: | :heavy_check_mark: |
106+
| | .NET 4.5 | Mono 6.x | CoreCLR |
107+
|---------|--------------------|--------------------|--------------------|
108+
| Windows | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
109+
| Linux | :x: | :heavy_check_mark: | :heavy_check_mark: |
110+
| macOS | :x: | :heavy_check_mark: | :heavy_check_mark: |
109111

110112
</td><td>
111113

112-
| | .NET 4.5 | CoreCLR |
113-
| ------- | ------------------ | ------------- |
114-
| Windows | :heavy_check_mark: | :x: |
115-
| Linux | :x: | :x: |
116-
| macOS | :x: | :x: |
114+
| | .NET 4.5 | Mono | CoreCLR |
115+
|---------|--------------------|------|---------|
116+
| Windows | :heavy_check_mark: | :x: | :x: |
117+
| Linux | :x: | :x: | :x: |
118+
| macOS | :x: | :x: | :x: |
117119

118120
</td></tr> </table>
119121

120122
## Mono
121123

122-
Mono is no longer supported.
124+
Mono is no longer actively supported. Existing code will remain In Edge.Js but focus will be on .NET Core.
123125

124126
## Node.js application packaging
125127

126128
When packaging your application using Webpack make sure that `edge-js` is specified as external module.
127129

128130
### Webpack
131+
129132
```js
130133
externals: {
131134
'edge-js': 'commonjs2 edge-js',
@@ -162,47 +165,57 @@ export default nextConfig;
162165

163166
**NOTE** This functionality requires IronPython 3.4
164167

165-
| Framework | Platform | NPM Package | Language code | Documentation |
166-
| ----------- | ------------ | ------------ |-------------- | ------------- |
167-
| .NET 4.5 | Windows | `edge-py` | `py` | [Script Python in Node.js](https://github.com/agracio/edge-py) :link: |
168-
| CoreCLR | Any | `edge-py` | `py` | [Script Python in Node.js](https://github.com/agracio/edge-py) :link: |
168+
| Framework | Platform | NPM Package | Language code | Documentation |
169+
|-----------|----------|-------------|---------------|-----------------------------------------------------------------------|
170+
| .NET 4.5 | Windows | `edge-py` | `py` | [Script Python in Node.js](https://github.com/agracio/edge-py) :link: |
171+
| CoreCLR | Any | `edge-py` | `py` | [Script Python in Node.js](https://github.com/agracio/edge-py) :link: |
169172

170173
### PowerShell scripting
171174

172175
**NOTE** CoreCLR requires dotnet 8
173176

174-
| Framework | Platform | NPM Package | Language code | Documentation |
175-
| ----------- | ------------ | ----------- |-------------- | ------------- |
176-
| .NET 4.5 | Windows | `edge-ps` | `ps` | [Script PowerShell in Node.js](https://github.com/agracio/edge-ps) :link: |
177-
| CoreCLR | Windows | `edge-ps` | `ps` | [Script PowerShell in Node.js](https://github.com/agracio/edge-ps) :link: |
177+
| Framework | Platform | NPM Package | Language code | Documentation |
178+
|-----------|----------|-------------|---------------|---------------------------------------------------------------------------|
179+
| .NET 4.5 | Windows | `edge-ps` | `ps` | [Script PowerShell in Node.js](https://github.com/agracio/edge-ps) :link: |
180+
| CoreCLR | Windows | `edge-ps` | `ps` | [Script PowerShell in Node.js](https://github.com/agracio/edge-ps) :link: |
178181

179182
### MS SQL scripting
180183

181184
Provides simple access to MS SQL without the need to write separate C# code.
182185

183-
| Framework | Platform | NPM Package | Language code | Documentation |
184-
| ------------- | ------------ | ----------- |-------------- | ------------- |
185-
| .NET 4.5 | Windows | `edge-sql` | `sql`| [Script T-SQL in Node.js](https://github.com/agracio/edge-sql) :link: |
186-
| CoreCLR | Any | `edge-sql` | `sql`| [Script T-SQL in Node.js](https://github.com/agracio/edge-sql) :link: |
186+
| Framework | Platform | NPM Package | Language code | Documentation |
187+
|-----------|----------|-------------|---------------|-----------------------------------------------------------------------|
188+
| .NET 4.5 | Windows | `edge-sql` | `sql` | [Script T-SQL in Node.js](https://github.com/agracio/edge-sql) :link: |
189+
| CoreCLR | Any | `edge-sql` | `sql` | [Script T-SQL in Node.js](https://github.com/agracio/edge-sql) :link: |
187190

188191
### F# scripting
189192

190-
| Framework | Platform | NPM Package | Language code | Documentation |
191-
| ----------- | ------------ | ----------- |-------------- | ------------- |
192-
| .NET 4.5 | Windows | `edge-fs` | `fs` | [Script F# in Node.js](https://github.com/agracio/edge-fs) :link: |
193-
| CoreCLR | Windows | `edge-fs` | `fs` | [Script F# in Node.js](https://github.com/agracio/edge-fs) :link: |
193+
| Framework | Platform | NPM Package | Language code | Documentation |
194+
|-----------|----------|-------------|---------------|-------------------------------------------------------------------|
195+
| .NET 4.5 | Windows | `edge-fs` | `fs` | [Script F# in Node.js](https://github.com/agracio/edge-fs) :link: |
196+
| CoreCLR | Windows | `edge-fs` | `fs` | [Script F# in Node.js](https://github.com/agracio/edge-fs) :link: |
194197

195198
---------
196199

197200
## How to use
198201

199-
#### [Scripting CLR from Node.js](#scripting-clr-from-nodejs) - full documentation
200-
#### [Scripting Node.js from CLR](#how-to-integrate-nodejs-code-into-clr-code) - full documentation
202+
### [Scripting CLR from Node.js](#scripting-clr-from-nodejs) - full documentation
203+
### [Scripting Node.js from CLR](#how-to-integrate-nodejs-code-into-clr-code) - full documentation
201204

202-
#### Scripting CLR from Node.js sample app https://github.com/agracio/edge-js-quick-start
205+
### Scripting CLR from Node.js sample app https://github.com/agracio/edge-js-quick-start
203206
----
204207

205-
### Scripting CLR from Node.js examples
208+
### Short guide
209+
210+
- [Inline C# code](#inline-c-code)
211+
- [Passing parameters](#passing-parameters)
212+
- [Using C# class](#using-c-class)
213+
- [Using compiled dll](#using-compiled-assembly)
214+
- [Using CoreCLR](#coreclr)
215+
- [Executing synchronously without function callback](#executing-synchronously-without-function-callback)
216+
- [Using promises/async](#promises)
217+
- [Scripting Node.js from CLR](#scripting-nodejs-from-clr)
218+
- [Docker](#docker)
206219

207220
### Inline C# code
208221

@@ -240,32 +253,6 @@ helloWorld('JavaScript', function (error, result) {
240253
});
241254
```
242255

243-
#### CoreCLR
244-
* If not set Edge.js will run as .NET 4.5 on Windows and as Mono on macOS/Linux
245-
* Can be set using `js` code below or as an environment variable `SET EDGE_USE_CORECLR=1`
246-
* Check [appveyor.yml](https://github.com/agracio/edge-js/blob/master/appveyor.yml) `test_script` for reference on setting env variables
247-
* Must be set before `var edge = require('edge-js');`
248-
249-
```js
250-
// set this variable before
251-
// var edge = require('edge-js');
252-
253-
process.env.EDGE_USE_CORECLR=1
254-
255-
var edge = require('edge-js');
256-
257-
var helloWorld = edge.func(function () {/*
258-
async (input) => {
259-
return ".NET Welcomes " + input.ToString();
260-
}
261-
*/});
262-
263-
helloWorld('JavaScript', function (error, result) {
264-
if (error) throw error;
265-
console.log(result);
266-
});
267-
```
268-
269256
### Passing parameters
270257

271258
```js
@@ -382,7 +369,7 @@ namespace EdgeJsMethods
382369
var edge = require('edge-js');
383370

384371
var getPerson = edge.func({
385-
assemblyFile: myDll, // path to .dll
372+
assemblyFile: myDll, // path to compiled .dll
386373
typeName: 'EdgeJsMethods.Methods',
387374
methodName: 'GetPerson'
388375
});
@@ -403,6 +390,31 @@ public async Task<object> MyMethod(object|dynamic input)
403390
}
404391
```
405392

393+
#### CoreCLR
394+
* If not set Edge.js will run as .NET 4.5 on Windows and as Mono on macOS/Linux
395+
* Can be set using `js` code below or as an environment variable `SET EDGE_USE_CORECLR=1` or `EXPORT EDGE_USE_CORECLR=1` depending on your platform.
396+
* Must be set before `var edge = require('edge-js');`
397+
398+
```js
399+
// set this variable before
400+
// var edge = require('edge-js');
401+
402+
process.env.EDGE_USE_CORECLR=1
403+
404+
var edge = require('edge-js');
405+
406+
var helloWorld = edge.func(function () {/*
407+
async (input) => {
408+
return ".NET Welcomes " + input.ToString();
409+
}
410+
*/});
411+
412+
helloWorld('JavaScript', function (error, result) {
413+
if (error) throw error;
414+
console.log(result);
415+
});
416+
```
417+
406418
### Executing synchronously without function callback
407419

408420
If your C# implementation will complete synchronously you can call this function as any synchronous JavaScript function as follows:
@@ -432,10 +444,31 @@ var helloWorld = edge.func(function () {/*
432444

433445
// sync call will throw exception
434446
var result = helloWorld('JavaScript', true);
447+
```
448+
449+
### Promises
450+
451+
```js
452+
453+
var func = edge.func(function () {/*
454+
async (dynamic input) => {
455+
return "Welcome " + input.name + " " + input.surname;
456+
}
457+
*/});
458+
459+
function helloWorld(){
460+
return new Promise<T>((resolve, reject) =>{
461+
func({name: 'John', surname: 'Smith'}, function (error, result) {
462+
if(error) reject(error);
463+
else resolve(result);
464+
});
465+
});
466+
}
467+
435468
```
436469
----
437470

438-
### Scripting Node.js from CLR example
471+
### Scripting Node.js from CLR
439472

440473
```cs
441474
using System;

0 commit comments

Comments
 (0)
Please sign in to comment.