@@ -43,17 +43,19 @@ Read more about the background and motivations of the project [here](http://toma
43
43
44
44
## Updates
45
45
* 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.
47
47
* Fixes AccessViolationException when running Node.js code from C# [ PR #573 ] ( https://github.com/tjanczuk/edge/pull/573 ) .
48
48
* Fixes StackOverflowException [ PR #566 ] ( https://github.com/tjanczuk/edge/pull/566 ) that occurs when underlying C# code throws complex exception.
49
49
* Fixes issues [ #469 ] ( https://github.com/tjanczuk/edge/issues/469 ) , [ #713 ] ( https://github.com/tjanczuk/edge/issues/713 )
50
50
* Other PRs: [ PR #725 ] ( https://github.com/tjanczuk/edge/pull/725 ) , [ PR #640 ] ( https://github.com/tjanczuk/edge/pull/640 )
51
51
* Multiple bug fixes and improvements to the original code.
52
52
53
53
----
54
+
54
55
### NPM package [ ` edge-js ` ] ( https://www.npmjs.com/package/edge-js )
55
56
56
57
### NuGet package [ ` EdgeJs ` ] ( https://www.nuget.org/packages/EdgeJs )
58
+
57
59
----
58
60
59
61
## Electron
@@ -75,7 +77,7 @@ https://github.com/agracio/edge-js-quick-start
75
77
### Windows
76
78
77
79
| Version | x86 | x64 | arm64 |
78
- | ------- | ------------------ | ------------------ | ------------------ |
80
+ | --------- | -------------------- | -------------------- | -------------------- |
79
81
| 16.x | :heavy_check_mark : | :heavy_check_mark : | :x : |
80
82
| 18.x | :heavy_check_mark : | :heavy_check_mark : | :x : |
81
83
| 20.x | :heavy_check_mark : | :heavy_check_mark : | :heavy_check_mark : |
@@ -85,47 +87,48 @@ https://github.com/agracio/edge-js-quick-start
85
87
86
88
### macOS
87
89
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 : |
91
93
92
94
### Linux
93
95
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 : |
97
99
98
100
## Scripting CLR from Node.js and Node.js from CRL
99
101
100
102
<table >
101
103
<tr ><th >Script CLR from Node.js </th ><th >Script Node.js from CLR</th ></tr >
102
104
<tr ><td >
103
105
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 : |
109
111
110
112
</td ><td >
111
113
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 : |
117
119
118
120
</td ></tr > </table >
119
121
120
122
## Mono
121
123
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.
123
125
124
126
## Node.js application packaging
125
127
126
128
When packaging your application using Webpack make sure that ` edge-js ` is specified as external module.
127
129
128
130
### Webpack
131
+
129
132
``` js
130
133
externals: {
131
134
' edge-js' : ' commonjs2 edge-js' ,
@@ -162,47 +165,57 @@ export default nextConfig;
162
165
163
166
** NOTE** This functionality requires IronPython 3.4
164
167
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 : |
169
172
170
173
### PowerShell scripting
171
174
172
175
** NOTE** CoreCLR requires dotnet 8
173
176
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 : |
178
181
179
182
### MS SQL scripting
180
183
181
184
Provides simple access to MS SQL without the need to write separate C# code.
182
185
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 : |
187
190
188
191
### F# scripting
189
192
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 : |
194
197
195
198
---------
196
199
197
200
## How to use
198
201
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
201
204
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
203
206
----
204
207
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 )
206
219
207
220
### Inline C# code
208
221
@@ -240,32 +253,6 @@ helloWorld('JavaScript', function (error, result) {
240
253
});
241
254
```
242
255
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
-
269
256
### Passing parameters
270
257
271
258
``` js
@@ -382,7 +369,7 @@ namespace EdgeJsMethods
382
369
var edge = require (' edge-js' );
383
370
384
371
var getPerson = edge .func ({
385
- assemblyFile: myDll, // path to .dll
372
+ assemblyFile: myDll, // path to compiled .dll
386
373
typeName: ' EdgeJsMethods.Methods' ,
387
374
methodName: ' GetPerson'
388
375
});
@@ -403,6 +390,31 @@ public async Task<object> MyMethod(object|dynamic input)
403
390
}
404
391
```
405
392
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
+
406
418
### Executing synchronously without function callback
407
419
408
420
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 () {/*
432
444
433
445
// sync call will throw exception
434
446
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
+
435
468
```
436
469
----
437
470
438
- ### Scripting Node.js from CLR example
471
+ ### Scripting Node.js from CLR
439
472
440
473
``` cs
441
474
using System ;
0 commit comments