Socket
Socket
Sign inDemoInstall

quickjs-emscripten

Package Overview
Dependencies
0
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.0 to 0.4.1

3

dist/emscripten-types.d.ts

@@ -25,5 +25,2 @@ declare namespace Emscripten {

export interface QuickJSEmscriptenModule {
onRuntimeInitialized: {
(): void;
};
addFunction(fn: Function, type: string): number;

@@ -30,0 +27,0 @@ removeFunction(pointer: number): void;

8

dist/quickjs.d.ts
import { QuickJSFFI, JSContextPointer, JSValuePointer, JSRuntimePointer, JSValueConstPointer } from './ffi';
import { LowLevelJavascriptVm, VmPropertyDescriptor, VmCallResult, VmFunctionImplementation } from './vm-interface';
declare const QuickJSModule: import("./emscripten-types").QuickJSEmscriptenModule;
import { QuickJSEmscriptenModule } from './emscripten-types';
/**
* @throws if not ready
*/
declare function getQuickJSEmscriptenModule(): QuickJSEmscriptenModule;
declare type CToHostCallbackFunctionImplementation = (ctx: JSContextPointer, this_ptr: JSValueConstPointer, argc: number, argv: JSValueConstPointer, fn_data_ptr: JSValueConstPointer) => JSValuePointer;

@@ -87,3 +91,3 @@ declare type CToHostInterruptImplementation = (rt: JSRuntimePointer) => 0 | 1;

constructor(args: {
module: typeof QuickJSModule;
module: ReturnType<typeof getQuickJSEmscriptenModule>;
ffi: QuickJSFFI;

@@ -90,0 +94,0 @@ ctx: Lifetime<JSContextPointer>;

@@ -57,4 +57,3 @@ "use strict";

var ffi_1 = require("./ffi");
var isReady = false;
var QuickJSModule = quickjs_emscripten_module_1.default();
var QuickJSModule = undefined;
/**

@@ -64,8 +63,15 @@ * This promise will be fufilled when the QuickJS emscripten module has initialized

*/
var ready = new Promise(function (resolve) {
QuickJSModule.onRuntimeInitialized = resolve;
}).then(function () {
isReady = true;
var ready = quickjs_emscripten_module_1.default().then(function (loadedModule) {
QuickJSModule = loadedModule;
});
/**
* @throws if not ready
*/
function getQuickJSEmscriptenModule() {
if (!QuickJSModule) {
throw new Error('QuickJS WASM module not initialized. Either wait for `ready` or use getQuickJS()');
}
return QuickJSModule;
}
/**
* A lifetime prevents access to a value after the lifetime has been

@@ -674,6 +680,6 @@ * [[dispose]]ed.

var _this = this;
this.ffi = new ffi_1.QuickJSFFI(QuickJSModule);
this.ffi = new ffi_1.QuickJSFFI(getQuickJSEmscriptenModule());
this.vmMap = new Map();
this.rtMap = new Map();
this.module = QuickJSModule;
this.module = getQuickJSEmscriptenModule();
// We need to send this into C-land

@@ -707,5 +713,3 @@ this.cToHostCallbackFunction = function (ctx, this_ptr, argc, argv, fn_data_ptr) {

};
if (!isReady) {
throw new Error('QuickJS WASM module not initialized. Either wait for `ready` or use getQuickJS()');
}
getQuickJSEmscriptenModule();
if (singleton) {

@@ -712,0 +716,0 @@ throw new Error('Cannot create another QuickJS instance. Use the instance already created (try getQuickJS())');

{
"name": "quickjs-emscripten",
"version": "0.4.0",
"version": "0.4.1",
"main": "dist/quickjs.js",
"license": "MIT",
"keywords": [
"eval",
"quickjs",
"vm",
"interpreter",
"runtime",
"safe",
"emscripten",
"wasm"
],
"repository": {

@@ -16,3 +26,3 @@ "type": "git",

"scripts": {
"prepare": "yarn make-release && yarn build && mocha ./dist/quickjs.test.js && yarn tarball && yarn smoketest",
"prepare": "yarn make-release && yarn build && mocha ./dist/quickjs.test.js && yarn tarball && yarn smoketest-node",
"update-quickjs": "git subtree pull --prefix=quickjs --squash git@github.com:ldarren/QuickJS.git mod",

@@ -25,6 +35,8 @@ "make-debug": "make DEBUG=1 -j 8",

"test": "yarn make-debug && mocha",
"prettier": "prettier --write ./*.json ./**/*.ts ./*.js ./*.md",
"prettier": "prettier --write ./*.json ./**/*.ts* ./*.js* ./*.md",
"prettier-check": "prettier --check ./*.json ./**/*.ts* ./*.js* ./*.md",
"run-n": "yarn make-debug && ./build/wrapper/native/test.exe",
"tarball": "yarn pack --filename build/quickjs-emscripten.tgz",
"smoketest": "cd examples/typescript-smoketest && yarn add ../../build/quickjs-emscripten.tgz && tsc --lib ES2015,dom index.ts && node index.js"
"tarball": "mkdir -p build && yarn pack --filename build/quickjs-emscripten.tgz",
"smoketest-node": "cd examples/typescript-smoketest && yarn add ../../build/quickjs-emscripten.tgz --update-checksums && tsc --lib ES2015,dom index.ts && node index.js",
"smoketest-cra": "cd examples/website && yarn add ../../build/quickjs-emscripten.tgz --update-checksums && yarn build"
},

@@ -35,3 +47,3 @@ "devDependencies": {

"@types/node": "^13.1.4",
"mocha": "^7.0.0",
"mocha": "7.2.0",
"prettier": "^1.19.1",

@@ -38,0 +50,0 @@ "source-map-support": "^0.5.16",

# quickjs-emscripten
Javascript/Typescript bindings for [QuickJS, a modern Javascript interpreter written in
C by Fabrice Bellard](https://bellard.org/quickjs/).
C by Fabrice Bellard](https://bellard.org/quickjs/) compiled to WebAssembly.

@@ -51,3 +51,3 @@ - Safely evaluate untrusted Javascript (up to ES2020).

getQuickJS.then(QuickJS => {
getQuickJS().then(QuickJS => {
const result = QuickJS.evalCode('1 + 1', {

@@ -143,5 +143,12 @@ shouldInterrupt: shouldInterruptAfterDeadline(Date.now() + 1000),

You'll need to install `emscripten`. Following the offical instructions here, using `emsdk`:
https://emscripten.org/docs/getting_started/downloads.html#installation-instructions
This project uses `emscripten 1.39.18`. First, install `emsdk` by following the official instructions here:
https://emscripten.org/docs/getting_started/downloads.html#installation-instructions.
Once you have `emsdk`, install emcc version 1.39.19 with `emsdk install 1.39.18`.
Your `emcc -v` output should look a little like this:
```
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.39.18
clang version 11.0.0 (/b/s/w/ir/cache/git/chromium.googlesource.com-external-github.com-llvm-llvm--project 613c4a87ba9bb39d1927402f4dd4c1ef1f9a02f7)
```
Related NPM scripts:

@@ -148,0 +155,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc