Skip to content

Commit

Permalink
reverting accidental edge.js script commit, updating readme
Browse files Browse the repository at this point in the history
  • Loading branch information
agracio committed May 8, 2024
1 parent ddc31f7 commit e3f84a4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 165 deletions.
13 changes: 0 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,6 @@ For use with Electron refer to `electron-edge-js` https://github.com/agracio/ele
Sample app that shows how to work with .NET Core using inline code and compiled C# libraries.
https://github.com/agracio/edge-js-quick-start

## macOS

`edge-js` will fail to build on macOS if Visual Studio for Mac is installed.
VS installs incomplete Mono runtimes that `edge-js` fails to access during `npm install`.
Removing VS does not remove Mono fully and leaves behind an incomplete Mono install.
To remove Mono from macOS use this script

```bash
sudo rm -rf /Library/Frameworks/Mono.framework
sudo pkgutil --forget com.xamarin.mono-MDK.pkg
sudo rm /etc/paths.d/mono-commands
```

## Node.Js Versions

| Version | Status |
Expand Down
154 changes: 2 additions & 152 deletions lib/edge.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var versionMap = [
[ /^16\./, '16.20.2' ],
[ /^18\./, '18.19.1' ],
[ /^20\./, '20.11.1' ],
[ /^21\./, '21.7.1' ],
[ /^22\./, '22.1.0' ],
];

Expand Down Expand Up @@ -52,7 +53,7 @@ process.env.EDGE_NATIVE = edgeNative;

edge = require(edgeNative);

function func (language, options) {
exports.func = function(language, options) {
if (!options) {
options = language;
language = 'cs';
Expand Down Expand Up @@ -176,155 +177,4 @@ function func (language, options) {
}

return edge.initializeClrFunc(options);
}

function funcAsync(language, options){
let fn = func(language, options);
return new Promise((resolve, reject) => {
fn(language, options, function(error, result) {
if (error) reject(error);
resolve(result);
})
})
}

module.exports = {
func,
funcAsync,
};

// exports.funcAsync = function(language, options){
// return new Promise((resolve, reject) => {
// func(language, options, function(error, result) {
// if (error) reject(error);
// resolve(result);
// } )
// })
// }


// exports.func = function(language, options) {
// if (!options) {
// options = language;
// language = 'cs';
// }

// if (typeof options === 'string') {
// if (options.match(/\.dll$/i)) {
// options = { assemblyFile: options };
// }
// else {
// options = { source: options };
// }
// }
// else if (typeof options === 'function') {
// var originalPrepareStackTrace = Error.prepareStackTrace;
// var stack;
// try {
// Error.prepareStackTrace = function(error, stack) {
// return stack;
// };
// stack = new Error().stack;
// }
// finally
// {
// Error.prepareStackTrace = originalPrepareStackTrace;
// }

// options = { source: options, jsFileName: stack[1].getFileName(), jsLineNumber: stack[1].getLineNumber() };
// }
// else if (typeof options !== 'object') {
// throw new Error('Specify the source code as string or provide an options object.');
// }

// if (typeof language !== 'string') {
// throw new Error('The first argument must be a string identifying the language compiler to use.');
// }
// else if (!options.assemblyFile) {
// var compilerName = 'edge-' + language.toLowerCase();
// var compiler;
// try {
// compiler = require(compilerName);
// }
// catch (e) {
// throw new Error("Unsupported language '" + language + "'. To compile script in language '" + language +
// "' an npm module '" + compilerName + "' must be installed.");
// }

// try {
// options.compiler = compiler.getCompiler();
// }
// catch (e) {
// throw new Error("The '" + compilerName + "' module required to compile the '" + language + "' language " +
// "does not contain getCompiler() function.");
// }

// if (typeof options.compiler !== 'string') {
// throw new Error("The '" + compilerName + "' module required to compile the '" + language + "' language " +
// "did not specify correct compiler package name or assembly.");
// }

// if (process.env.EDGE_USE_CORECLR) {
// var defaultManifest = path.join(__dirname, 'bootstrap', 'bin', 'Release', 'bootstrap.deps.json');
// var compilerManifest;
// if(compiler.getBootstrapDependencyManifest){
// compilerManifest = compiler.getBootstrapDependencyManifest();
// }
// options.bootstrapDependencyManifest =
// compilerManifest && fs.existsSync(compilerManifest)
// ? compilerManifest
// : defaultManifest;
// }
// }

// if (!options.assemblyFile && !options.source) {
// throw new Error('Provide DLL or source file name or .NET script literal as a string parameter, or specify an options object '+
// 'with assemblyFile or source string property.');
// }
// else if (options.assemblyFile && options.source) {
// throw new Error('Provide either an asseblyFile or source property, but not both.');
// }

// if (typeof options.source === 'function') {
// var match = options.source.toString().match(/[^]*\/\*([^]*)\*\/\s*\}$/);
// if (match) {
// options.source = match[1];
// }
// else {
// throw new Error('If .NET source is provided as JavaScript function, function body must be a /* ... */ comment.');
// }
// }

// if (options.references !== undefined) {
// if (!Array.isArray(options.references)) {
// throw new Error('The references property must be an array of strings.');
// }

// options.references.forEach(function (ref) {
// if (typeof ref !== 'string') {
// throw new Error('The references property must be an array of strings.');
// }
// });
// }

// if (options.assemblyFile) {
// if (!options.typeName) {
// var matched = options.assemblyFile.match(/([^\\\/]+)\.dll$/i);
// if (!matched) {
// throw new Error('Unable to determine the namespace name based on assembly file name. ' +
// 'Specify typeName parameter as a namespace qualified CLR type name of the application class.');
// }

// options.typeName = matched[1] + '.Startup';
// }
// }
// else if (!options.typeName) {
// options.typeName = "Startup";
// }

// if (!options.methodName) {
// options.methodName = 'Invoke';
// }

// return edge.initializeClrFunc(options);
// };

0 comments on commit e3f84a4

Please sign in to comment.