From 98294f2782c63222e179fd45f421a952ad9dbe3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Iv=C3=A1n=20Vieitez=20Parra?= <3857362+corrideat@users.noreply.github.com> Date: Sat, 19 Aug 2023 22:48:22 +0200 Subject: [PATCH] Rename package Small changes to build system --- README.md | 6 ++--- closure-externs.js | 66 ++++++++++++++++++++++++++++++++++++++++++++++ esbuild.mjs | 3 +++ package-lock.json | 8 +++--- package.json | 6 ++--- 5 files changed, 79 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ff18386..bd5b13b 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ -# 🏜️ @exact-realty/ecmascript-sandbox 🏖️ +# 🏜️ @exact-realty/lot 🏖️ [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=Exact-Realty_ecmascript-sandbox&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=Exact-Realty_ecmascript-sandbox) [![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=Exact-Realty_ecmascript-sandbox&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=Exact-Realty_ecmascript-sandbox) [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=Exact-Realty_ecmascript-sandbox&metric=bugs)](https://sonarcloud.io/summary/new_code?id=Exact-Realty_ecmascript-sandbox) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=Exact-Realty_ecmascript-sandbox&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=Exact-Realty_ecmascript-sandbox) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=Exact-Realty_ecmascript-sandbox&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=Exact-Realty_ecmascript-sandbox) - ![NPM Downloads](https://img.shields.io/npm/dw/@exact-realty/ecmascript-sandbox?style=flat-square) + ![NPM Downloads](https://img.shields.io/npm/dw/@exact-realty/lot?style=flat-square) -Welcome to `@exact-realty/ecmascript-sandbox` — the versatile ECMAScript sandbox +Welcome to `@exact-realty/lot` — the versatile ECMAScript sandbox you've been looking for! Our sandbox supports multiple runtimes and allows for bidirectional diff --git a/closure-externs.js b/closure-externs.js index 240a7b0..1943f10 100644 --- a/closure-externs.js +++ b/closure-externs.js @@ -3,3 +3,69 @@ var module = {}; function define() {} + +// Node.js modules +`/** @const */ +var vm = {}; + +/** + * @constructor + */ +vm.Context = function () {}; + +/** + * @param {string} code + * @param {vm.Context} context + * @param {string=} filename + */ +vm.runInContext = function (code, context, filename) {}; + +/** + * @param {Object.=} initSandbox + * @return {vm.Context} + * @nosideeffects + */ +vm.createContext = function (initSandbox) {}; + +/** + * @param {string} code + * @param {string[]} [params] + * @param {Object.} [options] + * @return {Function} + * @nosideeffects + */ +vm.compileFunction = function (code, params, options) {}; +; + +/** + * @const + */ +var worker_threads = {}; + +/** + * @type {boolean} + */ +worker_threads.isMainThread; + +/** + * @type {*} + */ +worker_threads.workerData; + +/** + * @constructor + * @param {string | URL} filename + * @param {Object.} [options] + */ +worker_threads.Worker = function (filename, options) {}; + +/** + * @param {MessagePort} port + * @param {vm.Context} contextifiedSandbox + * @return {MessagePort} + */ +worker_threads.moveMessagePortToContext = function ( + port, + contextifiedSandbox, +) {}; +`; diff --git a/esbuild.mjs b/esbuild.mjs index dd2774a..7d42dbf 100755 --- a/esbuild.mjs +++ b/esbuild.mjs @@ -64,6 +64,7 @@ const exactRealtyClosureBuilderPlugin = { process_closure_primitives: false, apply_input_source_maps: false, warning_level: 'QUIET', + isolate_polyfills: true, externs: './closure-externs.js', assume_function_wrapper: origFmt !== 'iife', ...(origFmt === 'esm' && { @@ -76,6 +77,8 @@ const exactRealtyClosureBuilderPlugin = { ? 'ES_MODULES' : 'GLOBAL_NAMESPACE', */ env: 'BROWSER', + // process_common_js_modules: true, // TODO + // module_resolution: 'NODE', // TODO }); return new Promise((resolve, reject) => { const process = compiler.run( diff --git a/package-lock.json b/package-lock.json index a47724f..a75a8f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "@exact-realty/ecmascript-sandbox", - "version": "0.0.16", + "name": "@exact-realty/lot", + "version": "0.0.17", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@exact-realty/ecmascript-sandbox", - "version": "0.0.16", + "name": "@exact-realty/lot", + "version": "0.0.17", "license": "ISC", "devDependencies": { "@exact-realty/esbuild-plugin-inline-js": "^1.1.4", diff --git a/package.json b/package.json index 5d4e878..95718f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "@exact-realty/ecmascript-sandbox", - "version": "0.0.16", + "name": "@exact-realty/lot", + "version": "0.0.17", "description": "Sandbox for isolating ECMAScript code", "main": "dist/index.js", "module": "./dist/index.mjs", @@ -126,7 +126,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/Exact-Realty/ecmascript-sandbox.git" + "url": "git+https://github.com/Exact-Realty/lot.git" }, "author": "Exact Realty Limited", "license": "ISC",