GithubHelp home page GithubHelp logo

elsaland / elsa Goto Github PK

View Code? Open in Web Editor NEW
2.8K 34.0 62.0 5.56 MB

❄️ Elsa is a minimal runtime for JavaScript and TypeScript written in Go

License: MIT License

Go 28.48% Makefile 0.92% TypeScript 70.59%
elsa javascript typescript runtime go quickjs

elsa's Introduction

Elsa

Discord invite

Elsa is a minimal JavaScript and TypeScript runtime written in Go. Built on top of quickjs and heavily inspired by Deno.

Features

  • URL imports.
  • useful Web APIs.
  • compiles TypeScript out of the box.
  • bundling. elsa bundle
  • compiling to native distributable binaries. elsa compile
// hello.ts
import { hello } from "https://x.nest.land/[email protected]/mod.ts";

hello("Elsa");
> elsa run hello.ts
Hello, Elsa

elsa's People

Contributors

buttercubz avatar deepsource-autofix[bot] avatar devsnek avatar fsmiamoto avatar github-actions[bot] avatar gsimone avatar layderv avatar littledivy avatar mattn avatar nightlyistaken avatar nminhnguyen avatar notfilippo avatar olyno avatar salemalem avatar samhza avatar siddhant-deepsource avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elsa's Issues

add repl

add read-eval-print-loop support

Can I interact with a JS script while it is running?

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?

GO interop

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!

Downloadable binary anywhere

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.

feat(fmt/colors)

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

HTTP server module

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

Comparison with Deno

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

Implement async layer

Currently elsa doesn't have any async capabilities.

We should be able to dispatch async ops and return a promise to the client

Project revival and long-term goals

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:

  1. Revive PRs
  2. Embedding friendly
  3. Adapt internal workings from Deno (resource tables, json_ops, etc). (:heart: Deno)
  4. Fix bundle issues
  5. Runtime backends (Switch backends from quickjs, ducktape, v8, etc)

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.

Feature request: Add nix build

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

Top level await

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

Interpreter

Nice project 👍

I believe Goja is 6-7x faster than Otto on average. Any particular reason you chose Otto as the interpreter?

Add tests to `testing/` and `std/` with Elsa.tests

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 😄

windows 10 build problem

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

OSS license

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?

Elsa functions don't throw exceptions for errors

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);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.