Socket
Socket
Sign inDemoInstall

quickjs-emscripten

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quickjs-emscripten - npm Package Compare versions

Comparing version 0.20.0 to 0.21.0

1

dist/generated/ffi.WASM_DEBUG_ASYNCIFY.d.ts

@@ -22,2 +22,3 @@ import { QuickJSAsyncEmscriptenModule } from "../emscripten-types";

QTS_BuildIsSanitizeLeak: () => number;
QTS_RuntimeSetMaxStackSize: (rt: JSRuntimePointer, stack_size: number) => void;
QTS_GetUndefined: () => JSValueConstPointer;

@@ -24,0 +25,0 @@ QTS_GetNull: () => JSValueConstPointer;

@@ -24,2 +24,3 @@ "use strict";

this.QTS_BuildIsSanitizeLeak = this.module.cwrap("QTS_BuildIsSanitizeLeak", "number", []);
this.QTS_RuntimeSetMaxStackSize = this.module.cwrap("QTS_RuntimeSetMaxStackSize", null, ["number", "number"]);
this.QTS_GetUndefined = this.module.cwrap("QTS_GetUndefined", "number", []);

@@ -26,0 +27,0 @@ this.QTS_GetNull = this.module.cwrap("QTS_GetNull", "number", []);

@@ -22,2 +22,3 @@ import { QuickJSEmscriptenModule } from "../emscripten-types";

QTS_BuildIsSanitizeLeak: () => number;
QTS_RuntimeSetMaxStackSize: (rt: JSRuntimePointer, stack_size: number) => void;
QTS_GetUndefined: () => JSValueConstPointer;

@@ -24,0 +25,0 @@ QTS_GetNull: () => JSValueConstPointer;

@@ -23,2 +23,3 @@ "use strict";

this.QTS_BuildIsSanitizeLeak = this.module.cwrap("QTS_BuildIsSanitizeLeak", "number", []);
this.QTS_RuntimeSetMaxStackSize = this.module.cwrap("QTS_RuntimeSetMaxStackSize", null, ["number", "number"]);
this.QTS_GetUndefined = this.module.cwrap("QTS_GetUndefined", "number", []);

@@ -25,0 +26,0 @@ this.QTS_GetNull = this.module.cwrap("QTS_GetNull", "number", []);

@@ -22,2 +22,3 @@ import { QuickJSAsyncEmscriptenModule } from "../emscripten-types";

QTS_BuildIsSanitizeLeak: () => number;
QTS_RuntimeSetMaxStackSize: (rt: JSRuntimePointer, stack_size: number) => void;
QTS_GetUndefined: () => JSValueConstPointer;

@@ -24,0 +25,0 @@ QTS_GetNull: () => JSValueConstPointer;

@@ -24,2 +24,3 @@ "use strict";

this.QTS_BuildIsSanitizeLeak = this.module.cwrap("QTS_BuildIsSanitizeLeak", "number", []);
this.QTS_RuntimeSetMaxStackSize = this.module.cwrap("QTS_RuntimeSetMaxStackSize", null, ["number", "number"]);
this.QTS_GetUndefined = this.module.cwrap("QTS_GetUndefined", "number", []);

@@ -26,0 +27,0 @@ this.QTS_GetNull = this.module.cwrap("QTS_GetNull", "number", []);

@@ -22,2 +22,3 @@ import { QuickJSEmscriptenModule } from "../emscripten-types";

QTS_BuildIsSanitizeLeak: () => number;
QTS_RuntimeSetMaxStackSize: (rt: JSRuntimePointer, stack_size: number) => void;
QTS_GetUndefined: () => JSValueConstPointer;

@@ -24,0 +25,0 @@ QTS_GetNull: () => JSValueConstPointer;

@@ -23,2 +23,3 @@ "use strict";

this.QTS_BuildIsSanitizeLeak = this.module.cwrap("QTS_BuildIsSanitizeLeak", "number", []);
this.QTS_RuntimeSetMaxStackSize = this.module.cwrap("QTS_RuntimeSetMaxStackSize", null, ["number", "number"]);
this.QTS_GetUndefined = this.module.cwrap("QTS_GetUndefined", "number", []);

@@ -25,0 +26,0 @@ this.QTS_GetNull = this.module.cwrap("QTS_GetNull", "number", []);

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

14

dist/module-asyncify.js

@@ -44,8 +44,6 @@ "use strict";

});
(0, module_1.applyBaseRuntimeOptions)(runtime, options);
if (options.moduleLoader) {
runtime.setModuleLoader(options.moduleLoader);
}
if (options.interruptHandler) {
runtime.setInterruptHandler(options.interruptHandler);
}
return runtime;

@@ -84,11 +82,3 @@ }

const vm = scope.manage(this.newContext());
if (options.moduleLoader) {
vm.runtime.setModuleLoader(options.moduleLoader);
}
if (options.shouldInterrupt) {
vm.runtime.setInterruptHandler(options.shouldInterrupt);
}
if (options.memoryLimitBytes !== undefined) {
vm.runtime.setMemoryLimit(options.memoryLimitBytes);
}
(0, module_1.applyModuleEvalRuntimeOptions)(vm.runtime, options);
const result = await vm.evalCodeAsync(code, "eval.js");

@@ -95,0 +85,0 @@ if (options.memoryLimitBytes !== undefined) {

@@ -5,3 +5,3 @@ import { QuickJSContext } from "./context";

import { InterruptHandler, QuickJSRuntime } from "./runtime";
import { ContextOptions, EitherFFI, JSModuleLoader, RuntimeOptions } from "./types";
import { ContextOptions, EitherFFI, JSModuleLoader, RuntimeOptions, RuntimeOptionsBase } from "./types";
declare type EmscriptenCallback<BaseArgs extends any[], Result> = (...args: [Asyncify | undefined, ...BaseArgs]) => Result | AsyncifySleepResult<Result>;

@@ -40,2 +40,7 @@ declare type MaybeAsyncEmscriptenCallback<T extends EmscriptenCallback<any, any>> = T extends EmscriptenCallback<infer Args, infer Result> ? (...args: Args) => Result | Promise<Result> : never;

/**
* Stack size limit for this vm, in bytes
* To remove the limit, set to `0`.
*/
maxStackSizeBytes?: number;
/**
* Module loader for any `import` statements or expressions.

@@ -67,2 +72,12 @@ */

/**
* Process RuntimeOptions and apply them to a QuickJSRuntime.
* @private
*/
export declare function applyBaseRuntimeOptions(runtime: QuickJSRuntime, options: RuntimeOptionsBase): void;
/**
* Process ModuleEvalOptions and apply them to a QuickJSRuntime.
* @private
*/
export declare function applyModuleEvalRuntimeOptions<T extends QuickJSRuntime>(runtime: T, options: ModuleEvalOptions): void;
/**
* This class presents a Javascript interface to QuickJS, a Javascript interpreter

@@ -69,0 +84,0 @@ * that supports EcmaScript 2020 (ES2020).

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.QuickJSWASMModule = exports.QuickJSModuleCallbacks = void 0;
exports.QuickJSWASMModule = exports.applyModuleEvalRuntimeOptions = exports.applyBaseRuntimeOptions = exports.QuickJSModuleCallbacks = void 0;
const debug_1 = require("./debug");

@@ -154,2 +154,37 @@ const errors_1 = require("./errors");

/**
* Process RuntimeOptions and apply them to a QuickJSRuntime.
* @private
*/
function applyBaseRuntimeOptions(runtime, options) {
if (options.interruptHandler) {
runtime.setInterruptHandler(options.interruptHandler);
}
if (options.maxStackSizeBytes !== undefined) {
runtime.setMaxStackSize(options.maxStackSizeBytes);
}
if (options.memoryLimitBytes !== undefined) {
runtime.setMemoryLimit(options.memoryLimitBytes);
}
}
exports.applyBaseRuntimeOptions = applyBaseRuntimeOptions;
/**
* Process ModuleEvalOptions and apply them to a QuickJSRuntime.
* @private
*/
function applyModuleEvalRuntimeOptions(runtime, options) {
if (options.moduleLoader) {
runtime.setModuleLoader(options.moduleLoader);
}
if (options.shouldInterrupt) {
runtime.setInterruptHandler(options.shouldInterrupt);
}
if (options.memoryLimitBytes !== undefined) {
runtime.setMemoryLimit(options.memoryLimitBytes);
}
if (options.maxStackSizeBytes !== undefined) {
runtime.setMaxStackSize(options.maxStackSizeBytes);
}
}
exports.applyModuleEvalRuntimeOptions = applyModuleEvalRuntimeOptions;
/**
* This class presents a Javascript interface to QuickJS, a Javascript interpreter

@@ -194,8 +229,6 @@ * that supports EcmaScript 2020 (ES2020).

});
applyBaseRuntimeOptions(runtime, options);
if (options.moduleLoader) {
runtime.setModuleLoader(options.moduleLoader);
}
if (options.interruptHandler) {
runtime.setInterruptHandler(options.interruptHandler);
}
return runtime;

@@ -242,11 +275,3 @@ }

const vm = scope.manage(this.newContext());
if (options.moduleLoader) {
vm.runtime.setModuleLoader(options.moduleLoader);
}
if (options.shouldInterrupt) {
vm.runtime.setInterruptHandler(options.shouldInterrupt);
}
if (options.memoryLimitBytes !== undefined) {
vm.runtime.setMemoryLimit(options.memoryLimitBytes);
}
applyModuleEvalRuntimeOptions(vm.runtime, options);
const result = vm.evalCode(code, "eval.js");

@@ -253,0 +278,0 @@ if (options.memoryLimitBytes !== undefined) {

@@ -49,3 +49,4 @@ import { QuickJSContext } from "./context";

* Implement memory and CPU constraints with [[setInterruptHandler]]
* (called regularly while the interpreter runs) and [[setMemoryLimit]].
* (called regularly while the interpreter runs), [[setMemoryLimit]], and
* [[setMaxStackSize]].
* Use [[computeMemoryUsage]] or [[dumpMemoryUsage]] to guide memory limit

@@ -163,2 +164,7 @@ * tuning.

/**
* Set the max stack size for this runtime, in bytes.
* To remove the limit, set to `0`.
*/
setMaxStackSize(stackSize: number): void;
/**
* Assert that `handle` is owned by this runtime.

@@ -165,0 +171,0 @@ * @throws QuickJSWrongOwner if owned by a different runtime.

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

* Implement memory and CPU constraints with [[setInterruptHandler]]
* (called regularly while the interpreter runs) and [[setMemoryLimit]].
* (called regularly while the interpreter runs), [[setMemoryLimit]], and
* [[setMaxStackSize]].
* Use [[computeMemoryUsage]] or [[dumpMemoryUsage]] to guide memory limit

@@ -274,2 +275,12 @@ * tuning.

/**
* Set the max stack size for this runtime, in bytes.
* To remove the limit, set to `0`.
*/
setMaxStackSize(stackSize) {
if (stackSize < 0) {
throw new Error("Cannot set memory limit to negative number. To unset, pass 0.");
}
this.ffi.QTS_RuntimeSetMaxStackSize(this.rt.value, stackSize);
}
/**
* Assert that `handle` is owned by this runtime.

@@ -276,0 +287,0 @@ * @throws QuickJSWrongOwner if owned by a different runtime.

@@ -89,7 +89,7 @@ import type { QuickJSFFI, QuickJSAsyncFFI } from "./variants";

interruptHandler?: InterruptHandler;
maxStackSizeBytes?: number;
memoryLimitBytes?: number;
promiseRejectionHandler?: TODO<"JSHostPromiseRejectionTracker">;
runtimeInfo?: TODO<"JS_SetRuntimeInfo", string>;
memoryLimit?: TODO<"JS_SetMemoryLimit", number>;
gcThreshold?: TODO<"JS_SetGCThreshold", number>;
maxStackSize?: TODO<"JS_SetMaxStackSize", number>;
sharedArrayBufferFunctions?: TODO<"JS_SetJSSharedArrayBufferFunctions", {

@@ -96,0 +96,0 @@ sab_alloc: TODO;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

{
"name": "quickjs-emscripten",
"version": "0.20.0",
"version": "0.21.0",
"main": "dist/index.js",
"sideEffects": false,
"license": "MIT",

@@ -31,3 +32,4 @@ "keywords": [

"clean": "make clean",
"build": "make -j 8 dist",
"tsc": "node_modules/.bin/tsc",
"build": "make dist",
"doc": "typedoc",

@@ -34,0 +36,0 @@ "test": "TS_NODE_TYPE_CHECK=false mocha",

@@ -41,4 +41,4 @@ # quickjs-emscripten

[npm]: https://www.npmjs.com/package/quickjs-emscripten
[api]: https://github.com/justjake/quickjs-emscripten/blob/master/doc/modules.md
[tests]: https://github.com/justjake/quickjs-emscripten/blob/master/ts/quickjs.test.ts
[api]: https://github.com/justjake/quickjs-emscripten/blob/main/doc/modules.md
[tests]: https://github.com/justjake/quickjs-emscripten/blob/main/ts/quickjs.test.ts
[values]: #interfacing-with-the-interpreter

@@ -61,3 +61,3 @@ [asyncify]: #asyncify

See [QuickJS.evalCode](https://github.com/justjake/quickjs-emscripten/blob/master/doc/classes/quickjs.md#evalcode)
See [QuickJS.evalCode](https://github.com/justjake/quickjs-emscripten/blob/main/doc/classes/quickjs.md#evalcode)

@@ -78,3 +78,3 @@ ```typescript

You can use [QuickJSContext](https://github.com/justjake/quickjs-emscripten/blob/master/doc/classes/QuickJSContext.md)
You can use [QuickJSContext](https://github.com/justjake/quickjs-emscripten/blob/main/doc/classes/QuickJSContext.md)
to build a scripting environment by modifying globals and exposing functions

@@ -88,3 +88,3 @@ into the QuickJS interpreter.

Every context is created inside a
[QuickJSRuntime](https://github.com/justjake/quickjs-emscripten/blob/master/doc/classes/QuickJSRuntime.md).
[QuickJSRuntime](https://github.com/justjake/quickjs-emscripten/blob/main/doc/classes/QuickJSRuntime.md).
A runtime represents a Javascript heap, and you can even share values between

@@ -125,2 +125,4 @@ contexts in the same runtime.

runtime.setMemoryLimit(1024 * 640)
// Limit stack size
runtime.setMaxStackSize(1024 * 320)
// Interrupt computation after 1024 calls to the interrupt handler

@@ -172,3 +174,3 @@ let interruptCycles = 0

A
[`Scope`](https://github.com/justjake/quickjs-emscripten/blob/master/doc/classes/scope.md#class-scope)
[`Scope`](https://github.com/justjake/quickjs-emscripten/blob/main/doc/classes/scope.md#class-scope)
instance manages a set of disposables and calls their `.dispose()`

@@ -204,3 +206,3 @@ method in the reverse order in which they're added to the scope. Here's the

[`Lifetime.consume`](https://github.com/justjake/quickjs-emscripten/blob/master/doc/classes/lifetime.md#consume)
[`Lifetime.consume`](https://github.com/justjake/quickjs-emscripten/blob/main/doc/classes/lifetime.md#consume)
is sugar for the common pattern of using a handle and then

@@ -363,5 +365,5 @@ immediately disposing of it. `Lifetime.consume` takes a `map` function that

[newasyncruntime]: https://github.com/justjake/quickjs-emscripten/blob/master/doc/modules.md#newasyncruntime
[newasynccontext]: https://github.com/justjake/quickjs-emscripten/blob/master/doc/modules.md#newasynccontext
[newquickjsasyncwasmmodule]: https://github.com/justjake/quickjs-emscripten/blob/master/doc/modules.md#newquickjsasyncwasmmodule
[newasyncruntime]: https://github.com/justjake/quickjs-emscripten/blob/main/doc/modules.md#newasyncruntime
[newasynccontext]: https://github.com/justjake/quickjs-emscripten/blob/main/doc/modules.md#newasynccontext
[newquickjsasyncwasmmodule]: https://github.com/justjake/quickjs-emscripten/blob/main/doc/modules.md#newquickjsasyncwasmmodule

@@ -494,5 +496,5 @@ These functions are asynchronous because they always create a new underlying

[ts]: https://github.com/justjake/quickjs-emscripten/blob/master/ts
[debug_sync]: https://github.com/justjake/quickjs-emscripten/blob/master/doc/modules.md#debug_sync
[testquickjswasmmodule]: https://github.com/justjake/quickjs-emscripten/blob/master/doc/classes/TestQuickJSWASMModule.md
[ts]: https://github.com/justjake/quickjs-emscripten/blob/main/ts
[debug_sync]: https://github.com/justjake/quickjs-emscripten/blob/main/doc/modules.md#debug_sync
[testquickjswasmmodule]: https://github.com/justjake/quickjs-emscripten/blob/main/doc/classes/TestQuickJSWASMModule.md

@@ -556,3 +558,3 @@ ### Debugging

- Duktape wrapped in Wasm: https://github.com/maple3142/duktape-eval/blob/master/src/Makefile
- Duktape wrapped in Wasm: https://github.com/maple3142/duktape-eval/blob/main/src/Makefile
- QuickJS wrapped in C++: https://github.com/ftk/quickjspp

@@ -559,0 +561,0 @@

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

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 too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc