magica
Version:
ImageMagick for browser and Node.js, easy setup, high level API and Command Line Interface, including WASM binary for an easy setup.
94 lines • 2.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const misc_utils_of_mine_generic_1 = require("misc-utils-of-mine-generic");
exports.isNode = misc_utils_of_mine_generic_1.isNode;
const options_1 = require("../options");
exports.getOptions = options_1.getOptions;
const magicaWasm_1 = require("../util/magicaWasm");
const { debug } = options_1.getOptions();
let _FS = null;
let _main = null;
exports.magickLoaded = new misc_utils_of_mine_generic_1.Deferred();
exports.magickLoaded.then(m => {
_FS = m.FS;
_main = m.main;
});
function getMagick() {
return {
FS: getFS(),
main: getMain()
};
}
exports.getMagick = getMagick;
function getFS() {
if (!_FS) {
throw new Error('getFS called too soon - FS object not ready yet');
}
return _FS;
}
exports.getFS = getFS;
function getMain() {
if (!_main) {
throw new Error('getMain called too soon - main function not ready yet');
}
return _main;
}
exports.getMain = getMain;
const stdout = [];
function pushStdout(...s) {
debug && console.log(`>> stdout >> ${s.join(' ')}`);
stdout.push(...s);
}
exports.pushStdout = pushStdout;
function resetStdout() {
stdout.length = 0;
}
exports.resetStdout = resetStdout;
function getStdout() {
return stdout.slice();
}
exports.getStdout = getStdout;
const stderr = [];
function pushStderr(...s) {
debug && console.log(`>> stderr >> ${s.join(' ')}`);
stderr.push(...s);
}
exports.pushStderr = pushStderr;
function resetStderr() {
stderr.length = 0;
}
exports.resetStderr = resetStderr;
function getStderr() {
return stderr.slice();
}
exports.getStderr = getStderr;
function moduleLocateFile(path, prefix) {
if (typeof MAGICA_WASM_LOCATION === 'string') {
return MAGICA_WASM_LOCATION;
}
else {
var thisScriptUrlParams = magicaWasm_1.getThisBrowserScriptTagSrcParams();
if (thisScriptUrlParams && thisScriptUrlParams.MAGICA_WASM_LOCATION) {
return decodeURIComponent(thisScriptUrlParams.MAGICA_WASM_LOCATION);
}
var thisScriptUrl = magicaWasm_1.getThisBrowserScriptTagSrc();
if (typeof thisScriptUrl === 'string') {
var d = misc_utils_of_mine_generic_1.dirname(thisScriptUrl);
if (d) {
return d;
}
}
}
return prefix + path;
}
exports.moduleLocateFile = moduleLocateFile;
setTimeout(function () {
try {
require('./compiled/nodeMagick');
}
catch (error) {
console.error(error);
throw error;
}
}, 0);
//# sourceMappingURL=magickLoaded.js.map