Files
bun.sh/src/js/node/vm.ts
dave caruso d712254128 internal: remove secret hidden internals and introduce new way to call native code from js (#8166)
* oooooh magic

* stuff

* run format

* ok

* yippee

* run the formatter back

* finish things up

* fix webkit

* more

* [autofix.ci] apply automated fixes

* fix compile

* fix compilation on windows, it seems to not work though :(

* update

* a

* v

* ok

* [autofix.ci] apply automated fixes

* OOPS

* bump bun to reduce ci bugs

* a

* js2native is done!

* improve array binding

* rebase

* some final stuff

* wasi fixes

* os

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-29 21:47:11 -07:00

55 lines
1.0 KiB
TypeScript

// Hardcoded module "node:vm"
const { throwNotImplemented } = require("internal/shared");
const vm = $cpp("NodeVM.cpp", "Bun::createNodeVMBinding");
const { createContext, isContext, Script, runInNewContext, runInThisContext } = vm;
function runInContext(code, context, options) {
return new Script(code, options).runInContext(context);
}
function createScript(code, options) {
return new Script(code, options);
}
function compileFunction() {
throwNotImplemented("node:vm compileFunction");
}
function measureMemory() {
throwNotImplemented("node:vm measureMemory");
}
class Module {
constructor() {
throwNotImplemented("node:vm Module");
}
}
class SourceTextModule {
constructor() {
throwNotImplemented("node:vm Module");
}
}
class SyntheticModule {
constructor() {
throwNotImplemented("node:vm Module");
}
}
export default {
createContext,
runInContext,
runInNewContext,
runInThisContext,
isContext,
compileFunction,
measureMemory,
Script,
Module,
SourceTextModule,
SyntheticModule,
createScript,
};