@@ -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,48 +87,70 @@ 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 | Mono 6.x | CoreCLR |
105
- | ------- | ------------------ | ------------------ | ------------------ |
106
- | Windows | :heavy_check_mark : | :heavy_check_mark : | :heavy_check_mark : |
107
- | Linux | :x : | :x : | :heavy_check_mark : |
108
- | macOS | :x : | :heavy_check_mark : | :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 | Mono | CoreCLR |
113
- | ------- | -- ---------------- | ---------- | ------------- |
114
- | Windows | :heavy_check_mark : | :x : | :x : |
115
- | Linux | :x : | :x : | :x : |
116
- | macOS | :x : | :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 actively supported. Existing code will remain In Edge.Js but focus will be on .NET Core.
123
- Mono tests are excluded from CI.
124
+ Mono is no longer actively supported. Existing code will remain In Edge.Js but focus will be on .NET Core.
125
+
126
+ ` * ` Edge.js does not have a flag to force it to run in Mono environment on Windows, it would only be possible to run if you have Windows without .NET Framework present.
127
+ ` * ` Mono does not appear to work on macOS x64.
128
+ ` * ` On Linux there is a known bug that will throw exception when executing C# code under certain conditions. Use one of the following options.
129
+
130
+ 1 . Set ` LD_PRELOAD ` env variable before running Edge.js with Mono
131
+ ``` bash
132
+ EXPORT LD_PRELOAD=" libmono-2.0.so libmonosgen-2.0.so libstdc++.so.6"
133
+ ```
134
+
135
+ 2 . Set ` LD_PRELOAD ` in your Node.js app entry point using Javascript
136
+
137
+ ``` js
138
+ Object .assign (process .env , {
139
+ // Work around Mono problem: undefined symbol: mono_add_internal_call_with_flags
140
+ LD_PRELOAD : ' libmono-2.0.so libmonosgen-2.0.so libstdc++.so.6' ,
141
+ });
142
+ ```
143
+ Source: https://github.com/mono/mono/issues/17079#issuecomment-1195918648
144
+
145
+ Edge.js uses this code in test setup: https://github.com/agracio/edge-js/blob/8bab03aca2abaea66e78c3af2f29e35ac2fcb8cf/tools/test.js#L19-L24
146
+
124
147
125
148
## Node.js application packaging
126
149
127
150
When packaging your application using Webpack make sure that ` edge-js ` is specified as external module.
128
151
129
152
### Webpack
153
+
130
154
``` js
131
155
externals: {
132
156
' edge-js' : ' commonjs2 edge-js' ,
@@ -163,47 +187,57 @@ export default nextConfig;
163
187
164
188
** NOTE** This functionality requires IronPython 3.4
165
189
166
- | Framework | Platform | NPM Package | Language code | Documentation |
167
- | ----------- | ------------ | ------------ | -------------- | ------------- |
168
- | .NET 4.5 | Windows | ` edge-py ` | ` py ` | [ Script Python in Node.js] ( https://github.com/agracio/edge-py ) :link : |
169
- | CoreCLR | Any | ` edge-py ` | ` py ` | [ Script Python in Node.js] ( https://github.com/agracio/edge-py ) :link : |
190
+ | Framework | Platform | NPM Package | Language code | Documentation |
191
+ | -----------| ----------| ------------- | --------------- | ----------------------------------------------------------------------- |
192
+ | .NET 4.5 | Windows | ` edge-py ` | ` py ` | [ Script Python in Node.js] ( https://github.com/agracio/edge-py ) :link : |
193
+ | CoreCLR | Any | ` edge-py ` | ` py ` | [ Script Python in Node.js] ( https://github.com/agracio/edge-py ) :link : |
170
194
171
195
### PowerShell scripting
172
196
173
197
** NOTE** CoreCLR requires dotnet 8
174
198
175
- | Framework | Platform | NPM Package | Language code | Documentation |
176
- | ----------- | ------------ | ----------- | -------------- | ------------- |
177
- | .NET 4.5 | Windows | ` edge-ps ` | ` ps ` | [ Script PowerShell in Node.js] ( https://github.com/agracio/edge-ps ) :link : |
178
- | CoreCLR | Windows | ` edge-ps ` | ` ps ` | [ Script PowerShell in Node.js] ( https://github.com/agracio/edge-ps ) :link : |
199
+ | Framework | Platform | NPM Package | Language code | Documentation |
200
+ | -----------| ----------| -- -----------| --------------- | --------------------------------------------------------------------------- |
201
+ | .NET 4.5 | Windows | ` edge-ps ` | ` ps ` | [ Script PowerShell in Node.js] ( https://github.com/agracio/edge-ps ) :link : |
202
+ | CoreCLR | Windows | ` edge-ps ` | ` ps ` | [ Script PowerShell in Node.js] ( https://github.com/agracio/edge-ps ) :link : |
179
203
180
204
### MS SQL scripting
181
205
182
206
Provides simple access to MS SQL without the need to write separate C# code.
183
207
184
- | Framework | Platform | NPM Package | Language code | Documentation |
185
- | ------------- | ------------ | ----------- | -------------- | ------------- |
186
- | .NET 4.5 | Windows | ` edge-sql ` | ` sql ` | [ Script T-SQL in Node.js] ( https://github.com/agracio/edge-sql ) :link : |
187
- | CoreCLR | Any | ` edge-sql ` | ` sql ` | [ Script T-SQL in Node.js] ( https://github.com/agracio/edge-sql ) :link : |
208
+ | Framework | Platform | NPM Package | Language code | Documentation |
209
+ | -----------| ---------- | ------------- | --------------- | ----------------------------------------------------------------------- |
210
+ | .NET 4.5 | Windows | ` edge-sql ` | ` sql ` | [ Script T-SQL in Node.js] ( https://github.com/agracio/edge-sql ) :link : |
211
+ | CoreCLR | Any | ` edge-sql ` | ` sql ` | [ Script T-SQL in Node.js] ( https://github.com/agracio/edge-sql ) :link : |
188
212
189
213
### F# scripting
190
214
191
- | Framework | Platform | NPM Package | Language code | Documentation |
192
- | ----------- | ------------ | ----------- | -------------- | ------------- |
193
- | .NET 4.5 | Windows | ` edge-fs ` | ` fs ` | [ Script F# in Node.js] ( https://github.com/agracio/edge-fs ) :link : |
194
- | CoreCLR | Windows | ` edge-fs ` | ` fs ` | [ Script F# in Node.js] ( https://github.com/agracio/edge-fs ) :link : |
215
+ | Framework | Platform | NPM Package | Language code | Documentation |
216
+ | -----------| ----------| -- -----------| --------------- | ------------------------------------------------------------------- |
217
+ | .NET 4.5 | Windows | ` edge-fs ` | ` fs ` | [ Script F# in Node.js] ( https://github.com/agracio/edge-fs ) :link : |
218
+ | CoreCLR | Windows | ` edge-fs ` | ` fs ` | [ Script F# in Node.js] ( https://github.com/agracio/edge-fs ) :link : |
195
219
196
220
---------
197
221
198
222
## How to use
199
223
200
- #### [ Scripting CLR from Node.js] ( #scripting-clr-from-nodejs ) - full documentation
201
- #### [ Scripting Node.js from CLR] ( #how-to-integrate-nodejs-code-into-clr-code ) - full documentation
224
+ ### [ Scripting CLR from Node.js] ( #scripting-clr-from-nodejs ) - full documentation
225
+ ### [ Scripting Node.js from CLR] ( #how-to-integrate-nodejs-code-into-clr-code ) - full documentation
202
226
203
- #### Scripting CLR from Node.js sample app https://github.com/agracio/edge-js-quick-start
227
+ ### Scripting CLR from Node.js sample app https://github.com/agracio/edge-js-quick-start
204
228
----
205
229
206
- ### Scripting CLR from Node.js examples
230
+ ### Short guide
231
+
232
+ - [ Inline C# code] ( #inline-c-code )
233
+ - [ Passing parameters] ( #passing-parameters )
234
+ - [ Using C# class] ( #using-c-class )
235
+ - [ Using compiled dll] ( #using-compiled-assembly )
236
+ - [ Using CoreCLR] ( #coreclr )
237
+ - [ Executing synchronously without function callback] ( #executing-synchronously-without-function-callback )
238
+ - [ Using promises/async] ( #promises )
239
+ - [ Scripting Node.js from CLR] ( #scripting-nodejs-from-clr )
240
+ - [ Docker] ( #docker )
207
241
208
242
### Inline C# code
209
243
@@ -241,32 +275,6 @@ helloWorld('JavaScript', function (error, result) {
241
275
});
242
276
```
243
277
244
- #### CoreCLR
245
- * If not set Edge.js will run as .NET 4.5 on Windows and as Mono on macOS/Linux
246
- * Can be set using ` js ` code below or as an environment variable ` SET EDGE_USE_CORECLR=1 `
247
- * Check [ appveyor.yml] ( https://github.com/agracio/edge-js/blob/master/appveyor.yml ) ` test_script ` for reference on setting env variables
248
- * Must be set before ` var edge = require('edge-js'); `
249
-
250
- ``` js
251
- // set this variable before
252
- // var edge = require('edge-js');
253
-
254
- process .env .EDGE_USE_CORECLR = 1
255
-
256
- var edge = require (' edge-js' );
257
-
258
- var helloWorld = edge .func (function () {/*
259
- async (input) => {
260
- return ".NET Welcomes " + input.ToString();
261
- }
262
- */ });
263
-
264
- helloWorld (' JavaScript' , function (error , result ) {
265
- if (error) throw error;
266
- console .log (result);
267
- });
268
- ```
269
-
270
278
### Passing parameters
271
279
272
280
``` js
@@ -383,7 +391,7 @@ namespace EdgeJsMethods
383
391
var edge = require (' edge-js' );
384
392
385
393
var getPerson = edge .func ({
386
- assemblyFile: myDll, // path to .dll
394
+ assemblyFile: myDll, // path to compiled .dll
387
395
typeName: ' EdgeJsMethods.Methods' ,
388
396
methodName: ' GetPerson'
389
397
});
@@ -404,6 +412,31 @@ public async Task<object> MyMethod(object|dynamic input)
404
412
}
405
413
```
406
414
415
+ #### CoreCLR
416
+ * If not set Edge.js will run as .NET 4.5 on Windows and as Mono on macOS/Linux
417
+ * 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.
418
+ * Must be set before ` var edge = require('edge-js'); `
419
+
420
+ ``` js
421
+ // set this variable before
422
+ // var edge = require('edge-js');
423
+
424
+ process .env .EDGE_USE_CORECLR = 1
425
+
426
+ var edge = require (' edge-js' );
427
+
428
+ var helloWorld = edge .func (function () {/*
429
+ async (input) => {
430
+ return ".NET Welcomes " + input.ToString();
431
+ }
432
+ */ });
433
+
434
+ helloWorld (' JavaScript' , function (error , result ) {
435
+ if (error) throw error;
436
+ console .log (result);
437
+ });
438
+ ```
439
+
407
440
### Executing synchronously without function callback
408
441
409
442
If your C# implementation will complete synchronously you can call this function as any synchronous JavaScript function as follows:
@@ -433,10 +466,31 @@ var helloWorld = edge.func(function () {/*
433
466
434
467
// sync call will throw exception
435
468
var result = helloWorld (' JavaScript' , true );
469
+ ```
470
+
471
+ ### Promises
472
+
473
+ ``` js
474
+
475
+ var func = edge .func (function () {/*
476
+ async (dynamic input) => {
477
+ return "Welcome " + input.name + " " + input.surname;
478
+ }
479
+ */ });
480
+
481
+ function helloWorld (){
482
+ return new Promise < T > ((resolve , reject ) => {
483
+ func ({name: ' John' , surname: ' Smith' }, function (error , result ) {
484
+ if (error) reject (error);
485
+ else resolve (result);
486
+ });
487
+ });
488
+ }
489
+
436
490
```
437
491
----
438
492
439
- ### Scripting Node.js from CLR example
493
+ ### Scripting Node.js from CLR
440
494
441
495
``` cs
442
496
using System ;
0 commit comments