tylerjwatson / jint.commonjs Goto Github PK
View Code? Open in Web Editor NEWA CommonJS implementation for Jint, the .NET Javascript engine.
License: MIT License
A CommonJS implementation for Jint, the .NET Javascript engine.
License: MIT License
Writing a simple VSMac Jint/Jint.CommonJS console app, and I'm running into a MissingMethodException being tossed from this code:
var cjs = engine.CommonJS();
cjs.RegisterInternalModule("console", typeof(Console));
This is with 3.0beta of Jint, if that makes a difference.
The exception looks like:
System.MissingMethodException: "Method not found: 'Jint.Native.JsValue Jint.Native.JsValue.op_Implicit(Jint.Native.Object.ObjectInstance)'."
at Jint.CommonJS.ModuleLoadingEngine.RegisterInternalModule(String id, Type clrType)\n at JintExplorer.Program.Main(String[] args) in /Users/tedneward/Projects/JintExplorer/JintExplorer/Program.cs:46
Any insights appreciated, particularly if this is a user bug. (Just started playing with Jint.CJS.)
Hi,
in ModuleLoader.Tests.cs the test methods RunMainShouldLoadAnIndexFileOnDisk and RunMainShouldLoadAnIndexFileOnDisk seem to cover the same behaviour. Just wanted to let you know in case this was not intended.
Hello,
Thank you for providing this extension to Jint!
You are not able to load npm packages with Jint.CommonJS. Although the library loads modules in relatively the same format at NodeJS's Module specification, there are some important distinctions. The library does not support node_modules, or reading package.json files for modules.
Do you know of any Jint extension that can handle basic node require
s (no package.json)?
Thanks,
Ben
Im trying to create an instance of a function class from a js module and use it.
I have tried to do the following:
var AHRS = scriptEngine.CommonJS().RunMain(path + folder + "node_modules/ahrs/index");
where I assume AHRS
should contain the following function class called "AHRS": https://github.com/psiphi75/ahrs/blob/master/index.js used like so: https://github.com/psiphi75/ahrs
I run a second snippet with the same ScriptEngine
:
var value = scriptEngine.GetValue("update").Invoke(AHRS, 0, 0, 0, 1, 1, 1, 2, 2, 2);
Which looks like:
function update(ahrs, gX, gY, gZ, aX, aY, aZ, mX, mY, mZ) {
// let ahrs = new AHRS({ sampleInterval: 20, algorithm: 'Madgwick', beta: 0.4 });
// ahrs.update(gX, gY, gZ, aX, aY, aZ, mX, mY, mZ);
// ahrs.getEulerAngles()
const s = new ahrs(null);
return JSON.stringify(s);
}
where I am unable to call method on the AHRS
instance. Logging the return of update - I get an empty object: {}
;
Any help is very much appreciated. My overhead goal is to use the AHRS javascript library in C# in a Xamarin.Forms app.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.