Skip to content

SunsetFi/suntime-js

Repository files navigation

Suntime JS

(static-js was taken (So was js-engine))

A (work in progress) JavaScript interpreter built on the TC39 ECMAScript standard, implementing asyncronous / non-blocking execution, sandboxing, modern language features, and full debugging support.

A spiritual successor to static-eval.

Try it out in the sandbox!

Spec Compliance

This project is being ran against the Test262 test suite to ensure spec compliance. This is a work-in-progress, and full coverage has not yet been obtained.

Current progress: Test262 Language Suite

Packages

@suntime-js/core

Core engine and javascript evaluator

import { StaticJsRealm, createTimeSharingTaskRunner } from "@suntime-js/core";

let myModuleResolveAwait;
const realm = StaticJsRealm({
  runTask: createTimeSharingTaskRunner({
    yieldTime: 100,
    operationsPerIteration: 1000,
    maxRunTime: 60 * 1000
  }),
  global: {
    properties: {
      sayHello: {
        value: () => console.log("Hello World");
      },
      registerCallback: {
        value: (cb) => myModuleResolveAwait = cb;
      }
    }
  },
  modules: {
    "my-module": `
      const { promise, resolve } = Promise.withResolvers();
      registerCallback(resolve);
      await promise;
      export const foo = 42;
    `
  }
});

const module = await realm.evaluateModule(`
  import { foo } from "my-module";
  export function addFoo(value) {
    return value + foo;
  }
`);

myModuleResolveAwait();

const addFoo = await module.getExportAsync("addFoo");

const result = await addFoo.callAsync(realm.types.undefined, realm.types.number(10));

See the documentation or readme for more information.

@suntime-js/debugger

A stepping debugger for @suntime-js/core, providing breakpoint support and stack inspection.

@suntime-js/dap

Provides a DAP (Debugger Adapter Protocol) adapter for visual studio code. Adapters for for both vscode (external process) and the web-based CodinGame/monaco-vscode-api are provided.

About

An ECMAScript 2025 (Modern JavaScript) interpreter written in Typescript

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages