Repository navigation
Astroctx v1.1.0
2023-10-01
Major updates
- Removed astro syntax with type option, now only supports common js syntax.
- Context updates
- Renamed to sandbox, example:
Astroctx.sandbox - To create new contexts you should use
Astroctx.sandbox({ myCtxVariable: 'test' }) - All presets still should be working properly with
Astroctx.sandbox[preset-key]
- Renamed to sandbox, example:
- Reader updates
- Joined with require, now require works as reader, examples:
Astroctx.require('./my-path/to/script.js'); Astroctx.require.script('./my-path/to/script.js'); Astroctx.require.dir('./my-path/to');
- New access controll feature, see access updates
- Joined with require, now require works as reader, examples:
- Access updates, now this option work for both sandbox and reader, you need to provide function
const option = { access: pathOrModule => pathOrModule === 'fs' || pathOrModule.endsWith('.js') }; Astroctx.execute('module.exports = require("fs")'); Astroctx.read('./path/to/script.js'); // But you still can controll them by each own function const option = { access: { internal: path => true, // Reader controll sandbox: module => {}, // Sandbox require controll }, };
Sandbox function can return object or boolean value, in case of object it will be used as stub
content
Minor updates
-
Created new tests, new tests coverage ~85%
-
NPM Isolation fix, now it should work properly
const script = Astroctx.execute(`module.exports = require('chalk')`, { access: { sandbox: () => true }, npmIsolation: true, ctx: sandbox.NODE, }); // Output: Chalk function