elsaland / elsa Goto Github PK
View Code? Open in Web Editor NEW❄️ Elsa is a minimal runtime for JavaScript and TypeScript written in Go
License: MIT License
❄️ Elsa is a minimal runtime for JavaScript and TypeScript written in Go
License: MIT License
add TCP and UDP support
A Deno compatibility layer would be nice to allow the use of Deno modules within Elsa.
split the standard library and the runtime into different repositories
a while ago I made a small color library per terminal for dart based on ANSI, I think it can be implemented within the color library, this is the repo of my implementation
Scott McPeak's C++ front-end is called elsa: http://dsw.users.sonic.net/oink/elsa_features.html
This is not an obscure project: it was used by Mozilla to do source-to-source transforms on C++, the first time that had been done in history, as it preceded Clang/LLVM.
Currently none of the Elsa functions (Elsa.stats
, Elsa.readFile
, etc) throw any exceptions in JS when they encounter errors, they instead print the error and exit with status code 1. There is no way to gracefully handle these errors from the JS code. These functions should throw exceptions instead of exiting so that the script (example below) can catch and handle them.
try {
Elsa.stats("non-existent");
} catch (error) {
console.error(error);
}
Related: https://github.com/elsaland/elsa/runs/2045590464#step:8:11
Rather spin up a local test server.
For example, I have a javascript game loop, I use a Go grpc server to run it.
When the player sends an operation request, the Go grpc server will change the status of javascript game loop.
Can I do it with elsa?
The goal right now is to implement all the file system APIs provided by Deno - https://github.com/denoland/deno/blob/master/cli/ops/fs.rs
There is already a Elsa.readFile
binding in core/dispatch.go
with it's corresponding js call at js/01_namespace.js
.
Looking forward to recieve PRs 😄
I think it would be great to see a GitHub Actions Workflow for Elsa. I see many possible use cases for this as well.
Perhaps something similar to: https://github.com/marketplace/actions/setup-deno-environment
Looking forward to seeing where Elsa goes! Can't wait to support it.
Currently elsa doesn't have any async capabilities.
We should be able to dispatch async ops and return a promise to the client
Hi there,
Is there downloadable binary anywhere of elsa, or do I need to compile it myself?
I can see this step in the github actions to generate and upload a binary, but it wasn't obvious to me where I might try to download a binary for linux or OS X:
- name: Upload Elsa executables
uses: actions/upload-artifact@v2
with:
name: elsa-${{ matrix.os }}
path: ./src/github.com/elsaland/elsa/elsa-${{ matrix.os }}
I'm not a confident go programmer, so there might be something really obvious I'm missing, and I'm happy to update the README once I know the answer.
Hello, the project looks really cool, looking forward to the http API!
However, I'd like to suggest to add a comparison table with Deno, e.g. perf, features, size comparison.
I've seen Deno vs Elsa benchmarks, but a comparison table (either in readme or separate file) with feature lists would be cool as well :D
Add tests for all the js/ts files inside testing/
and std/
The test file should be named in the pattern *_test.js
for elsa to identify it as a test file.
Example:
// some_test.js
import { eq } from "./utils.ts";
Elsa.tests({
"test mode == `test`": function () {
eq(Elsa.mode, "test");
},
});
and run ./elsa test
Marking as a good first issue as anyone with Deno.test experience can give it a try 😄
Once an HTTP server will be ready I will be able to make an Elsa port of my web framework, so creating this issue to track the progress
Tracking issue for support for top level await - because, why not? :)
PS: This will be a bundling step (esbuild) rather than runtime
Waiting for esbuild to support top level await for bundling - evanw/esbuild#253
I would like to add a nix build to add elsa to nixpkgs.
Currently the build is stuck
# default.nix; usage: nix-build --pure -E 'let pkgs = import <nixpkgs> {}; in pkgs.callPackage ./. {}'
{ stdenv, fetchFromGitHub, buildGoModule, go-bindata, go-bindata-assetfs }:
buildGoModule rec {
pname = "elsa";
version = "master";
revision = "0375d76d2c802b497cec44e5069920643287cc98";
goPackagePath = "github.com/elsaland/elsa";
nativeBuildInputs = [ go-bindata go-bindata-assetfs ];
preBuild = ''
# https://github.com/elsaland/elsa/blob/5419ed2/Makefile#L2
go generate;
go run ./bootstrap/;
# go build -o elsa .
'';
src = fetchFromGitHub {
owner = "elsaland";
repo = "elsa";
rev = revision;
sha256 = "0ny2fsj7r05711d7k3xpl35k4pz86y2vnrk4bqqrdb5xqlh1i7aq";
};
doCheck = false;
vendorSha256 = "1n3yj3p5nikbr5fwk44rpjk3wvay015k0gvl6pwdyx0yvpazrl4p";
subPackages = [ "." ];
meta = with stdenv.lib; {
maintainer = with maintainers; [ ];
license = licenses.mit;
description = "Elsa is a minimal, fast and secure runtime for Javascript and Typescript written in Go";
};
}
Running the nix-build
command I get:
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/a5bg5xqns8lzal9a6f04sdc9d1pr1vjp-source
source root is source
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
@nix { "action": "setPhase", "phase": "buildPhase" }
building
2020/09/30 08:10:43 Bundling 00_core.js
2020/09/30 08:10:43 Bundling 01_namespace.js
2020/09/30 08:10:43 Bundling 02_console.js
2020/09/30 08:10:43 Bundling 03_fetch.js
2020/09/30 08:10:43 Bundling 04_event.js
2020/09/30 08:10:43 Bundling 05_compiler.js
2020/09/30 08:10:43 Bundling 10_window.js
2020/09/30 08:10:43 Running command and waiting for it to finish...
2020/09/30 08:10:43 Command finished with error: exit status 1
Building subPackage ./.
github.com/asaskevich/govalidator
github.com/go-bindata/go-bindata
github.com/elsaland/elsa/packager
github.com/spf13/pflag
github.com/spf13/cobra
github.com/elsaland/elsa/cmd
github.com/elsaland/quickjs
github.com/imroc/req
github.com/spf13/afero/mem
golang.org/x/text/transform
golang.org/x/text/unicode/norm
github.com/spf13/afero
github.com/elsaland/elsa/core/ops
golang.org/x/sys/internal/unsafeheader
golang.org/x/sys/unix
github.com/mattn/go-isatty
github.com/mattn/go-colorable
github.com/fatih/color
github.com/logrusorgru/aurora
github.com/elsaland/elsa/core
# github.com/elsaland/elsa/core
core/run.go:37:13: undefined: Asset
github.com/evanw/esbuild/internal/compat
github.com/evanw/esbuild/internal/logger
github.com/evanw/esbuild/internal/js_ast
github.com/evanw/esbuild/internal/config
github.com/evanw/esbuild/internal/fs
github.com/evanw/esbuild/internal/js_lexer
github.com/evanw/esbuild/internal/renamer
github.com/evanw/esbuild/internal/runtime
github.com/evanw/esbuild/internal/sourcemap
github.com/evanw/esbuild/internal/js_parser
github.com/evanw/esbuild/internal/js_printer
github.com/evanw/esbuild/internal/resolver
github.com/evanw/esbuild/internal/bundler
github.com/evanw/esbuild/pkg/api
add read-eval-print-loop support
Similar implementation as done in Deno.
elsa/quickjs forks lithdew/quickjs:
https://github.com/elsaland/quickjs
But it's not an official repository and its owner is not an author.
Recently the author of quickjs created their account at GitHub and hosted quickjs repository:
https://github.com/bellard/quickjs
It's official and maintained. I strongly recommend elsa to fork the official repository.
Leverage the power of JS_ExecutePendingJob
to execute pending jobs.
Respect an existing tsconfig.json both at bundling and typechecking at dev mode.
It build on windows but to 'elsa' with no extension '.exe' so I can't execute it with the elsa command on command line
Windows 10 x64
We should have some streamlined way to do integration tests for elsa
Hey everyone 👋
Been busy with several other projects recently which made it hard for me and @filipporeds to be able to work full-time on this.
It's time to resume work on elsa:
Elsa as an embedded runtime is a major goal. Certain applications include k8 using elsa for built-in typescript support, etc.
Contributions and feature requests are accepted in the issue tracker. Feel free to hop on the discord server.
Update quickjs to 2020-09-06 release.
bellard/quickjs@7c312df
We're currently using https://github.com/elsaland/quickjs/blob/master/version.h . Marking this as a good first issue.
lithdew/quickjs not eval import xx from "xx.js"
Can I build a http server in Elsa?
There is a PR for arm32 builds but I'm unable to proceed because of a cgo
issue in the quickjs bindings.
https://github.com/elsaland/elsa/pull/16/checks?check_run_id=1166845295
This is the tracking issue for the above error and how it could be fixed.
Is there a way to use this library akin to how something like Goja or Otto usage looks like? I'm working on a CLI where I want to have a JS runtime that will run perhaps many scripts (both files and from variables in go) in the same context. Right now I'm using Otto, and it works, but I'd like something that supports ES6 (especially modules). Here's an example of what I'm doing to setup a vm:
vm := otto.New()
err = vm.Set("someFunc", func(call otto.FunctionCall) otto.Value {
message := call.Argument(0).String()
// some go code here
return otto.Value{}
})
_, err := vm.Run(` // some setup scripts `);
Then later I have some user-defined scripts I want to execute against that vm (via the Run
method), using some of those pre-defined setup/functions and interop as necessary. It doesn't look like this is something Elsa currently can handle, but is this a direction you're going in? If not I have some other options, just none as attractive as what you're doing here I think.
Thanks in advance, and best of luck!
Tons of good improvements that can be made to the codebase:
https://deepsource.io/gh/elsaland/elsa/issues/?category=recommended
Or elsa install myapp.ts
to make standalone script.
The typechecker implementation is not as mature as the bundler, it lacks URL imports and breaks on certain relative imports. This is the tracking issue for until we implement the lacking features.
Leverage the esbuild bundle API's Minify option to produce minified output when -m
|| --minify
is provided
I noticed that there is no license in the repo. Is there a reason for the lack of a license or was it just forgotten?
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.