mirror of
https://github.com/HeyPuter/puter.git
synced 2026-01-02 11:10:37 -06:00
13 lines
512 B
JavaScript
13 lines
512 B
JavaScript
const vm = require('vm');
|
|
|
|
async function load_puterjs() {
|
|
const goodContext = {}
|
|
Object.getOwnPropertyNames(globalThis).forEach(name => { try { goodContext[name] = globalThis[name]; } catch { } })
|
|
goodContext.globalThis = goodContext
|
|
const code = await fetch("http://puter.localhost:4100/puter.js/v2").then(res => res.text());
|
|
const context = vm.createContext(goodContext);
|
|
const result = vm.runInNewContext(code, context);
|
|
return goodContext.puter;
|
|
}
|
|
|
|
module.exports = load_puterjs; |