{"_id":"@jmfirth-arkane/quickjs","_rev":"1-268609cfbd00e11beac1085838104b63","name":"@jmfirth-arkane/quickjs","dist-tags":{"latest":"1.4.0"},"versions":{"1.3.1":{"name":"@jmfirth-arkane/quickjs","version":"1.3.1","keywords":["typescript","quickjs","runtime","wasm","webassembly","bun","hono","example","worker","pool","package","library"],"author":{"url":"https://sebastianwessel.de","name":"Sebastian Wessel"},"license":"ISC","_id":"@jmfirth-arkane/quickjs@1.3.1","maintainers":[{"name":"jmfirth-arkane","email":"justin.firth@arkanedigital.com"}],"homepage":"https://github.com/jmfirth-arkane/quickjs#readme","bugs":{"url":"https://github.com/jmfirth-arkane/quickjs/issues"},"dist":{"shasum":"1857a8ba5c9d29a7e29401fae17a1b9ba20bf1e0","tarball":"https://registry.npmjs.org/@jmfirth-arkane/quickjs/-/quickjs-1.3.1.tgz","fileCount":219,"integrity":"sha512-mA5oZw/cd445dAiWDeyVDU3wb2BMA+DhSiP2pjrtQ8FJL1+aNAybqT/f6p6xg6yKUmaL30dOciN4MJkKPzaz2w==","signatures":[{"sig":"MEQCICPr73TxYZSYc7u/4kYOUkfqW1jM9UkAW2UiKUf9hvi4AiBbV5K9KDb1I9tAh7wj8b6Ns7zCzXXfAKJlQ9QnrCJdUA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":703655},"main":"./dist/commonjs/index.js","tshy":{"exclude":["src/**/*.test.ts","vendor"],"exports":{".":"./src/index.ts","./package.json":"./package.json"},"dialects":["esm","commonjs"]},"type":"module","types":"./dist/commonjs/index.d.ts","module":"./dist/esm/index.js","engines":{"node":">=18.0.0"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","source":"./src/index.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","source":"./src/index.ts","default":"./dist/commonjs/index.js"}},"./package.json":"./package.json"},"gitHead":"a7e3d37ebf3991027f16adb4ee515be74916735f","scripts":{"lint":"bunx @biomejs/biome check","test":"bun test","build":"bun run build:vendor && tshy && bun run build:copy","start":"bun run --watch example/server/server.ts","lint:fix":"bunx @biomejs/biome check --write","test:dev":"bun test --watch","build:copy":"cp -r ./src/modules/build/ ./dist/esm/modules/build && cp -r ./src/modules/build/ ./dist/commonjs/modules/build","postpublish":"npx jsr publish","build:vendor":"bun vendor.ts","example:basic":"bun example/basic/server.ts","example:tests":"bun example/run-tests/index.ts","example:module":"bun example/custom-module/index.ts","example:server":"bun example/server/server.ts"},"_npmUser":{"name":"jmfirth-arkane","email":"justin.firth@arkanedigital.com"},"repository":{"url":"git+https://github.com/jmfirth-arkane/quickjs.git","type":"git"},"_npmVersion":"10.2.3","description":"A typescript package to execute JavaScript and TypeScript code in a webassembly quickjs sandbox","directories":{},"_nodeVersion":"20.10.0","dependencies":{"memfs":"^4.9.3","rate-limiter-flexible":"^5.0.3","quickjs-emscripten-core":"^0.29.2","@jitl/quickjs-ng-wasmfile-release-sync":"^0.29.2"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^5.1.1","hono":"^4.4.13","tshy":"^1.18.0","@types/bun":"^1.1.6","autocannon":"^7.15.0","typescript":"^5.5.3","@types/node":"^20.14.10","@biomejs/biome":"^1.8.3","@hono/swagger-ui":"^0.3.0","@hono/zod-openapi":"^0.14.9","@types/autocannon":"^7.12.5","quickjs-emscripten":"^0.29.2","poolifier-web-worker":"^0.4.14"},"peerDependencies":{"typescript":">= 5.5.3"},"peerDependenciesMeta":{"typescript":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/quickjs_1.3.1_1726862541499_0.23510797718777554","host":"s3://npm-registry-packages"}},"1.4.0":{"name":"@jmfirth-arkane/quickjs","version":"1.4.0","description":"A typescript package to execute JavaScript and TypeScript code in a webassembly quickjs sandbox","type":"module","engines":{"node":">=18.0.0"},"keywords":["typescript","quickjs","runtime","wasm","webassembly","bun","hono","example","worker","pool","package","library"],"tshy":{"exclude":["src/**/*.test.ts","vendor"],"dialects":["esm","commonjs"],"exports":{"./package.json":"./package.json",".":"./src/index.ts"}},"scripts":{"start":"bun run --watch example/server/server.ts","build":"bun run build:vendor && tshy && bun run build:copy","build:vendor":"bun vendor.ts","build:copy":"cp -r ./src/modules/build/ ./dist/esm/modules/build && cp -r ./src/modules/build/ ./dist/commonjs/modules/build","test":"bun test","test:dev":"bun test --watch","lint":"bunx @biomejs/biome check","lint:fix":"bunx @biomejs/biome check --write","postpublish":"npx jsr publish","example:basic":"bun example/basic/server.ts","example:server":"bun example/server/server.ts","example:tests":"bun example/run-tests/index.ts","example:module":"bun example/custom-module/index.ts"},"author":{"name":"Sebastian Wessel","url":"https://sebastianwessel.de"},"homepage":"https://github.com/jmfirth-arkane/quickjs#readme","bugs":{"url":"https://github.com/jmfirth-arkane/quickjs/issues"},"repository":{"type":"git","url":"git+https://github.com/jmfirth-arkane/quickjs.git"},"license":"ISC","devDependencies":{"@biomejs/biome":"^1.8.3","@hono/swagger-ui":"^0.3.0","@hono/zod-openapi":"^0.14.9","@types/autocannon":"^7.12.5","@types/bun":"^1.1.6","@types/node":"^20.14.10","autocannon":"^7.15.0","chai":"^5.1.1","hono":"^4.4.13","poolifier-web-worker":"^0.4.14","quickjs-emscripten":"^0.29.2","tshy":"^1.18.0","typescript":"^5.5.3"},"dependencies":{"@jitl/quickjs-ng-wasmfile-release-sync":"^0.29.2","memfs":"^4.9.3","quickjs-emscripten-core":"^0.29.2","rate-limiter-flexible":"^5.0.3"},"peerDependencies":{"typescript":">= 5.5.3"},"peerDependenciesMeta":{"typescript":{"optional":true}},"exports":{"./package.json":"./package.json",".":{"import":{"source":"./src/index.ts","types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"source":"./src/index.ts","types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}}},"main":"./dist/commonjs/index.js","types":"./dist/commonjs/index.d.ts","module":"./dist/esm/index.js","_id":"@jmfirth-arkane/quickjs@1.4.0","gitHead":"583ad1e57d19116ddc09ac7a7129030cf8dd5d83","_nodeVersion":"20.10.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-gyhLuPBAwCiQrimDW3+VT9oan1Nupo/mMZ3lG71iusUJ1QNJBbSrk3//8Ae+wxqIHxsPaZyuaBU8RVA8J3bdnQ==","shasum":"2badf42a2f98fceccae68c13833066a62f2fdd9d","tarball":"https://registry.npmjs.org/@jmfirth-arkane/quickjs/-/quickjs-1.4.0.tgz","fileCount":223,"unpackedSize":728037,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICM1b0rIG7dzEwvjx6nBVGNwIEmnIKWQT0dkkhDO9yu0AiEAzoYgEDih1td6u9OJCTy2GAUFdpRWg8miZY2npfNCVwE="}]},"_npmUser":{"name":"jmfirth-arkane","email":"justin.firth@arkanedigital.com"},"directories":{},"maintainers":[{"name":"jmfirth-arkane","email":"justin.firth@arkanedigital.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/quickjs_1.4.0_1726885791160_0.9665473600578394"},"_hasShrinkwrap":false}},"time":{"created":"2024-09-20T20:02:21.393Z","modified":"2024-09-21T02:29:51.606Z","1.3.1":"2024-09-20T20:02:21.745Z","1.4.0":"2024-09-21T02:29:51.432Z"},"bugs":{"url":"https://github.com/jmfirth-arkane/quickjs/issues"},"author":{"name":"Sebastian Wessel","url":"https://sebastianwessel.de"},"license":"ISC","homepage":"https://github.com/jmfirth-arkane/quickjs#readme","keywords":["typescript","quickjs","runtime","wasm","webassembly","bun","hono","example","worker","pool","package","library"],"repository":{"type":"git","url":"git+https://github.com/jmfirth-arkane/quickjs.git"},"description":"A typescript package to execute JavaScript and TypeScript code in a webassembly quickjs sandbox","maintainers":[{"name":"jmfirth-arkane","email":"justin.firth@arkanedigital.com"}],"readme":"# QuickJS - Execute JavaScript and TypeScript in a WebAssembly QuickJS Sandbox\n\nThis TypeScript package allows you to safely execute **JavaScript AND TypeScript code** within a WebAssembly sandbox using the QuickJS engine. Perfect for isolating and running untrusted code securely, it leverages the lightweight and fast QuickJS engine compiled to WebAssembly, providing a robust environment for code execution.\n\n## Features\n\n- **Security**: Run untrusted JavaScript and TypeScript code in a safe, isolated environment.\n- **Basic Node.js modules**: Provides basic standard Node.js module support for common use cases.\n- **File System**: Can mount a virtual file system.\n- **Custom Node Modules**: Custom node modules are mountable.\n- **Fetch Client**: Can provide a fetch client to make http(s) calls.\n- **Test-Runner**: Includes a test runner and chai based `expect`.\n- **Performance**: Benefit from the lightweight and efficient QuickJS engine.\n- **Versatility**: Easily integrate with existing TypeScript projects.\n- **Simplicity**: User-friendly API for executing and managing JavaScript and TypeScript code in the sandbox.\n\n**[View the full documentation](https://sebastianwessel.github.io/quickjs/)**\n\n**[Find examples in the repository](https://github.com/sebastianwessel/quickjs/tree/main/example)**\n\n## Version 1: Rolling Release\n\n### Fast Lane - Fast Pace\n\nWelcome to the first version of our npm package! This release follows a rolling release model, prioritizing rapid development and quick iterations. The approach is designed to deliver features swiftly, gather feedback promptly, and implement fixes without delay. This means you get the latest features and improvements as soon as they are ready, ensuring you always have access to the cutting-edge functionality.\n\nKey aspects of our rolling release model:\n\n- **Ship Fast:** Release new features and updates as soon as they are developed.\n- **Get Fast Feedback:** Your feedback is crucial. I listen and respond quickly to ensure the package meets your needs.\n- **Fix Quickly:** Bugs and issues are addressed promptly, minimizing any disruptions.\n- **Fast-Paced Development:** Our development cycle is agile, allowing us to adapt and evolve based on user input.\n\nStay tuned for frequent updates and enhancements.\n\n## Basic Usage\n\nHere's a simple example of how to use the package:\n\n```typescript\nimport { quickJS } from '@sebastianwessel/quickjs'\n\n// General setup like loading and init of the QuickJS wasm\n// It is a ressource intensive job and should be done only once if possible \nconst { createRuntime } = await quickJS()\n\n// Create a runtime instance (sandbox)\nconst { evalCode } = await createRuntime(undefined, {\n  allowFetch: true, // inject fetch and allow the code to fetch data\n  allowFs: true, // mount a virtual file system and provide node:fs module\n  env: {\n    MY_ENV_VAR: 'env var value'\n  },\n})\n\n\nconst result = await evalCode(`\nimport { join } as path from 'path'\n\nconst fn = async ()=>{\n  console.log(join('src','dist')) // logs \"src/dist\" on host system\n\n  console.log(env.MY_ENV_VAR) // logs \"env var value\" on host system\n\n  const url = new URL('https://example.com')\n\n  const f = await fetch(url)\n\n  return f.text()\n}\n  \nexport default await fn()\n`)\n\nconsole.log(result) // { ok: true, data: '<!doctype html>\\n<html>\\n[....]</html>\\n' }\n```\n\n## Credits\n\nThis lib is based on:\n\n- [quickjs-emscripten](https://github.com/justjake/quickjs-emscripten)\n- [quickjs-emscripten-sync](https://github.com/reearth/quickjs-emscripten-sync)\n- [memfs](https://github.com/streamich/memfs)\n- [Chai](https://www.chaijs.com)\n\nTools used:\n\n- [Bun](https://bun.sh)\n- [Biome](https://biomejs.dev)\n- [Hono](https://hono.dev)\n- [poolifier-web-worker](https://github.com/poolifier/poolifier-web-worker)\n- [tshy](https://github.com/isaacs/tshy)\n- [autocannon](https://github.com/mcollina/autocannon)\n\n## License\n\nThis project is licensed under the MIT License.\n\n---\n\nThis package is ideal for developers looking to execute JavaScript code securely within a TypeScript application, ensuring both performance and safety with the QuickJS WebAssembly sandbox.\n","readmeFilename":"README.md"}