voxels-scripting-server
Advanced tools
Comparing version 0.9.8 to 0.9.9
{ | ||
"name": "voxels-scripting-server", | ||
"version": "0.9.8", | ||
"version": "0.9.9", | ||
"description": "A basic server to run Voxels.com scripts", | ||
@@ -5,0 +5,0 @@ "lib": "dist/src/index.d.ts", |
@@ -12,5 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getScriptingBundle = exports.fetchLatestScriptingJS = exports.tryParse = exports.expressLog = exports.log = void 0; | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
exports.fetchLatestScriptingJS = exports.tryParse = exports.expressLog = exports.log = void 0; | ||
const node_fetch_1 = require("node-fetch"); | ||
@@ -34,62 +32,21 @@ const logger_1 = require("./logger"); | ||
/** @internal */ | ||
const fetchLatestScriptingJS = () => { | ||
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () { | ||
exports.log.info("Fetching latest scripting bundle"); | ||
let p; | ||
try { | ||
p = yield (0, node_fetch_1.default)(`https://www.cryptovoxels.com/scripting-host.js`); | ||
} | ||
catch (e) { | ||
reject(); | ||
throw new Error(e.toString()); | ||
} | ||
let r; | ||
try { | ||
r = yield (p === null || p === void 0 ? void 0 : p.text()); | ||
} | ||
catch (er) { | ||
reject(); | ||
throw new Error(er.toString()); | ||
} | ||
const res = () => resolve(true); | ||
if (!fs.existsSync("cache")) { | ||
fs.mkdirSync("cache"); | ||
} | ||
try { | ||
exports.log.info("Creating cache: " + r.length); | ||
console.log(path.join(__dirname, "..", "cache/scripting-host.js")); | ||
fs.writeFile(path.join(__dirname, "..", "cache/scripting-host.js"), r, res); | ||
} | ||
catch (e) { | ||
exports.log.error(e); | ||
reject(); | ||
} | ||
})); | ||
}; | ||
exports.fetchLatestScriptingJS = fetchLatestScriptingJS; | ||
/** @internal */ | ||
const getScriptingBundle = () => __awaiter(void 0, void 0, void 0, function* () { | ||
const readBundle = () => { | ||
let bundle; | ||
console.log(path.join(__dirname, "..", "cache/scripting-host.js")); | ||
try { | ||
bundle = fs | ||
.readFileSync(path.join(__dirname, "..", "cache/scripting-host.js")) | ||
.toString(); | ||
} | ||
catch (_a) { } | ||
return bundle; | ||
}; | ||
let file = readBundle(); | ||
if (!file) { | ||
exports.log.info("No cache found"); | ||
yield (0, exports.fetchLatestScriptingJS)(); | ||
file = readBundle(); | ||
const fetchLatestScriptingJS = () => __awaiter(void 0, void 0, void 0, function* () { | ||
exports.log.info("Fetching latest scripting bundle"); | ||
let p; | ||
try { | ||
p = yield (0, node_fetch_1.default)(`https://www.cryptovoxels.com/scripting-host.js`); | ||
} | ||
if (!file) { | ||
throw new Error("Could not fetch scripting bundle"); | ||
catch (e) { | ||
throw new Error(e.toString()); | ||
} | ||
return file; | ||
let r; | ||
try { | ||
r = yield (p === null || p === void 0 ? void 0 : p.text()); | ||
} | ||
catch (er) { | ||
throw new Error(er.toString()); | ||
} | ||
return r; | ||
}); | ||
exports.getScriptingBundle = getScriptingBundle; | ||
exports.fetchLatestScriptingJS = fetchLatestScriptingJS; | ||
//# sourceMappingURL=helpers.js.map |
@@ -55,3 +55,3 @@ "use strict"; | ||
const makeVSSForParcel = (id) => __awaiter(void 0, void 0, void 0, function* () { | ||
const bundle = yield (0, helpers_1.getScriptingBundle)(); | ||
const bundle = yield (0, helpers_1.fetchLatestScriptingJS)(); | ||
let context = new vm.VM({ allowAsync: true, timeout: 1000, sandbox }); | ||
@@ -58,0 +58,0 @@ const loadParcel = (parcelId) => __awaiter(void 0, void 0, void 0, function* () { |
{ | ||
"name": "voxels-scripting-server", | ||
"version": "0.9.8", | ||
"version": "0.9.9", | ||
"description": "A basic server to run Voxels.com scripts", | ||
@@ -5,0 +5,0 @@ "lib": "dist/src/index.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
8
23321
269