3780 lines
392 KiB
JavaScript
3780 lines
392 KiB
JavaScript
|
'use strict';
|
|||
|
|
|||
|
var obsidian = require('obsidian');
|
|||
|
var path = require('path');
|
|||
|
var fs = require('fs');
|
|||
|
var process$1 = require('node:process');
|
|||
|
var childProcess = require('child_process');
|
|||
|
var _os = require('os');
|
|||
|
var require$$0 = require('assert');
|
|||
|
var require$$2 = require('events');
|
|||
|
var require$$0$2 = require('buffer');
|
|||
|
var require$$0$1 = require('stream');
|
|||
|
var require$$1 = require('util');
|
|||
|
var node_os = require('node:os');
|
|||
|
require('electron');
|
|||
|
|
|||
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|||
|
|
|||
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|||
|
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|||
|
var process__default = /*#__PURE__*/_interopDefaultLegacy(process$1);
|
|||
|
var childProcess__default = /*#__PURE__*/_interopDefaultLegacy(childProcess);
|
|||
|
var _os__default = /*#__PURE__*/_interopDefaultLegacy(_os);
|
|||
|
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|||
|
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
|
|||
|
var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
|
|||
|
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
|
|||
|
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|||
|
|
|||
|
/*! *****************************************************************************
|
|||
|
Copyright (c) Microsoft Corporation.
|
|||
|
|
|||
|
Permission to use, copy, modify, and/or distribute this software for any
|
|||
|
purpose with or without fee is hereby granted.
|
|||
|
|
|||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|||
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|||
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|||
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|||
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|||
|
PERFORMANCE OF THIS SOFTWARE.
|
|||
|
***************************************************************************** */
|
|||
|
/* global Reflect, Promise */
|
|||
|
|
|||
|
var extendStatics = function(d, b) {
|
|||
|
extendStatics = Object.setPrototypeOf ||
|
|||
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|||
|
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|||
|
return extendStatics(d, b);
|
|||
|
};
|
|||
|
|
|||
|
function __extends(d, b) {
|
|||
|
if (typeof b !== "function" && b !== null)
|
|||
|
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|||
|
extendStatics(d, b);
|
|||
|
function __() { this.constructor = d; }
|
|||
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|||
|
}
|
|||
|
|
|||
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
function __generator(thisArg, body) {
|
|||
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|||
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|||
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|||
|
function step(op) {
|
|||
|
if (f) throw new TypeError("Generator is already executing.");
|
|||
|
while (_) try {
|
|||
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|||
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|||
|
switch (op[0]) {
|
|||
|
case 0: case 1: t = op; break;
|
|||
|
case 4: _.label++; return { value: op[1], done: false };
|
|||
|
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|||
|
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|||
|
default:
|
|||
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|||
|
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|||
|
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|||
|
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|||
|
if (t[2]) _.ops.pop();
|
|||
|
_.trys.pop(); continue;
|
|||
|
}
|
|||
|
op = body.call(thisArg, _);
|
|||
|
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|||
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
function __values(o) {
|
|||
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|||
|
if (m) return m.call(o);
|
|||
|
if (o && typeof o.length === "number") return {
|
|||
|
next: function () {
|
|||
|
if (o && i >= o.length) o = void 0;
|
|||
|
return { value: o && o[i++], done: !o };
|
|||
|
}
|
|||
|
};
|
|||
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|||
|
}
|
|||
|
|
|||
|
function __read(o, n) {
|
|||
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|||
|
if (!m) return o;
|
|||
|
var i = m.call(o), r, ar = [], e;
|
|||
|
try {
|
|||
|
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|||
|
}
|
|||
|
catch (error) { e = { error: error }; }
|
|||
|
finally {
|
|||
|
try {
|
|||
|
if (r && !r.done && (m = i["return"])) m.call(i);
|
|||
|
}
|
|||
|
finally { if (e) throw e.error; }
|
|||
|
}
|
|||
|
return ar;
|
|||
|
}
|
|||
|
|
|||
|
function __asyncValues(o) {
|
|||
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|||
|
var m = o[Symbol.asyncIterator], i;
|
|||
|
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|||
|
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|||
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|||
|
}
|
|||
|
|
|||
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|||
|
|
|||
|
function createCommonjsModule(fn, basedir, module) {
|
|||
|
return module = {
|
|||
|
path: basedir,
|
|||
|
exports: {},
|
|||
|
require: function (path, base) {
|
|||
|
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
|
|||
|
}
|
|||
|
}, fn(module, module.exports), module.exports;
|
|||
|
}
|
|||
|
|
|||
|
function commonjsRequire () {
|
|||
|
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
|
|||
|
}
|
|||
|
|
|||
|
var windows = isexe$2;
|
|||
|
isexe$2.sync = sync$4;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
function checkPathExt (path, options) {
|
|||
|
var pathext = options.pathExt !== undefined ?
|
|||
|
options.pathExt : process.env.PATHEXT;
|
|||
|
|
|||
|
if (!pathext) {
|
|||
|
return true
|
|||
|
}
|
|||
|
|
|||
|
pathext = pathext.split(';');
|
|||
|
if (pathext.indexOf('') !== -1) {
|
|||
|
return true
|
|||
|
}
|
|||
|
for (var i = 0; i < pathext.length; i++) {
|
|||
|
var p = pathext[i].toLowerCase();
|
|||
|
if (p && path.substr(-p.length).toLowerCase() === p) {
|
|||
|
return true
|
|||
|
}
|
|||
|
}
|
|||
|
return false
|
|||
|
}
|
|||
|
|
|||
|
function checkStat$1 (stat, path, options) {
|
|||
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|||
|
return false
|
|||
|
}
|
|||
|
return checkPathExt(path, options)
|
|||
|
}
|
|||
|
|
|||
|
function isexe$2 (path, options, cb) {
|
|||
|
fs__default['default'].stat(path, function (er, stat) {
|
|||
|
cb(er, er ? false : checkStat$1(stat, path, options));
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
function sync$4 (path, options) {
|
|||
|
return checkStat$1(fs__default['default'].statSync(path), path, options)
|
|||
|
}
|
|||
|
|
|||
|
var mode = isexe$1;
|
|||
|
isexe$1.sync = sync$3;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
function isexe$1 (path, options, cb) {
|
|||
|
fs__default['default'].stat(path, function (er, stat) {
|
|||
|
cb(er, er ? false : checkStat(stat, options));
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
function sync$3 (path, options) {
|
|||
|
return checkStat(fs__default['default'].statSync(path), options)
|
|||
|
}
|
|||
|
|
|||
|
function checkStat (stat, options) {
|
|||
|
return stat.isFile() && checkMode(stat, options)
|
|||
|
}
|
|||
|
|
|||
|
function checkMode (stat, options) {
|
|||
|
var mod = stat.mode;
|
|||
|
var uid = stat.uid;
|
|||
|
var gid = stat.gid;
|
|||
|
|
|||
|
var myUid = options.uid !== undefined ?
|
|||
|
options.uid : process.getuid && process.getuid();
|
|||
|
var myGid = options.gid !== undefined ?
|
|||
|
options.gid : process.getgid && process.getgid();
|
|||
|
|
|||
|
var u = parseInt('100', 8);
|
|||
|
var g = parseInt('010', 8);
|
|||
|
var o = parseInt('001', 8);
|
|||
|
var ug = u | g;
|
|||
|
|
|||
|
var ret = (mod & o) ||
|
|||
|
(mod & g) && gid === myGid ||
|
|||
|
(mod & u) && uid === myUid ||
|
|||
|
(mod & ug) && myUid === 0;
|
|||
|
|
|||
|
return ret
|
|||
|
}
|
|||
|
|
|||
|
var core$1;
|
|||
|
if (process.platform === 'win32' || commonjsGlobal.TESTING_WINDOWS) {
|
|||
|
core$1 = windows;
|
|||
|
} else {
|
|||
|
core$1 = mode;
|
|||
|
}
|
|||
|
|
|||
|
var isexe_1 = isexe;
|
|||
|
isexe.sync = sync$2;
|
|||
|
|
|||
|
function isexe (path, options, cb) {
|
|||
|
if (typeof options === 'function') {
|
|||
|
cb = options;
|
|||
|
options = {};
|
|||
|
}
|
|||
|
|
|||
|
if (!cb) {
|
|||
|
if (typeof Promise !== 'function') {
|
|||
|
throw new TypeError('callback not provided')
|
|||
|
}
|
|||
|
|
|||
|
return new Promise(function (resolve, reject) {
|
|||
|
isexe(path, options || {}, function (er, is) {
|
|||
|
if (er) {
|
|||
|
reject(er);
|
|||
|
} else {
|
|||
|
resolve(is);
|
|||
|
}
|
|||
|
});
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
core$1(path, options || {}, function (er, is) {
|
|||
|
// ignore EACCES because that just means we aren't allowed to run it
|
|||
|
if (er) {
|
|||
|
if (er.code === 'EACCES' || options && options.ignoreErrors) {
|
|||
|
er = null;
|
|||
|
is = false;
|
|||
|
}
|
|||
|
}
|
|||
|
cb(er, is);
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
function sync$2 (path, options) {
|
|||
|
// my kingdom for a filtered catch
|
|||
|
try {
|
|||
|
return core$1.sync(path, options || {})
|
|||
|
} catch (er) {
|
|||
|
if (options && options.ignoreErrors || er.code === 'EACCES') {
|
|||
|
return false
|
|||
|
} else {
|
|||
|
throw er
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
const isWindows = process.platform === 'win32' ||
|
|||
|
process.env.OSTYPE === 'cygwin' ||
|
|||
|
process.env.OSTYPE === 'msys';
|
|||
|
|
|||
|
|
|||
|
const COLON = isWindows ? ';' : ':';
|
|||
|
|
|||
|
|
|||
|
const getNotFoundError = (cmd) =>
|
|||
|
Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' });
|
|||
|
|
|||
|
const getPathInfo = (cmd, opt) => {
|
|||
|
const colon = opt.colon || COLON;
|
|||
|
|
|||
|
// If it has a slash, then we don't bother searching the pathenv.
|
|||
|
// just check the file itself, and that's it.
|
|||
|
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? ['']
|
|||
|
: (
|
|||
|
[
|
|||
|
// windows always checks the cwd first
|
|||
|
...(isWindows ? [process.cwd()] : []),
|
|||
|
...(opt.path || process.env.PATH ||
|
|||
|
/* istanbul ignore next: very unusual */ '').split(colon),
|
|||
|
]
|
|||
|
);
|
|||
|
const pathExtExe = isWindows
|
|||
|
? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM'
|
|||
|
: '';
|
|||
|
const pathExt = isWindows ? pathExtExe.split(colon) : [''];
|
|||
|
|
|||
|
if (isWindows) {
|
|||
|
if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
|
|||
|
pathExt.unshift('');
|
|||
|
}
|
|||
|
|
|||
|
return {
|
|||
|
pathEnv,
|
|||
|
pathExt,
|
|||
|
pathExtExe,
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
const which = (cmd, opt, cb) => {
|
|||
|
if (typeof opt === 'function') {
|
|||
|
cb = opt;
|
|||
|
opt = {};
|
|||
|
}
|
|||
|
if (!opt)
|
|||
|
opt = {};
|
|||
|
|
|||
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|||
|
const found = [];
|
|||
|
|
|||
|
const step = i => new Promise((resolve, reject) => {
|
|||
|
if (i === pathEnv.length)
|
|||
|
return opt.all && found.length ? resolve(found)
|
|||
|
: reject(getNotFoundError(cmd))
|
|||
|
|
|||
|
const ppRaw = pathEnv[i];
|
|||
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|||
|
|
|||
|
const pCmd = path__default['default'].join(pathPart, cmd);
|
|||
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
|
|||
|
: pCmd;
|
|||
|
|
|||
|
resolve(subStep(p, i, 0));
|
|||
|
});
|
|||
|
|
|||
|
const subStep = (p, i, ii) => new Promise((resolve, reject) => {
|
|||
|
if (ii === pathExt.length)
|
|||
|
return resolve(step(i + 1))
|
|||
|
const ext = pathExt[ii];
|
|||
|
isexe_1(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|||
|
if (!er && is) {
|
|||
|
if (opt.all)
|
|||
|
found.push(p + ext);
|
|||
|
else
|
|||
|
return resolve(p + ext)
|
|||
|
}
|
|||
|
return resolve(subStep(p, i, ii + 1))
|
|||
|
});
|
|||
|
});
|
|||
|
|
|||
|
return cb ? step(0).then(res => cb(null, res), cb) : step(0)
|
|||
|
};
|
|||
|
|
|||
|
const whichSync = (cmd, opt) => {
|
|||
|
opt = opt || {};
|
|||
|
|
|||
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|||
|
const found = [];
|
|||
|
|
|||
|
for (let i = 0; i < pathEnv.length; i ++) {
|
|||
|
const ppRaw = pathEnv[i];
|
|||
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|||
|
|
|||
|
const pCmd = path__default['default'].join(pathPart, cmd);
|
|||
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
|
|||
|
: pCmd;
|
|||
|
|
|||
|
for (let j = 0; j < pathExt.length; j ++) {
|
|||
|
const cur = p + pathExt[j];
|
|||
|
try {
|
|||
|
const is = isexe_1.sync(cur, { pathExt: pathExtExe });
|
|||
|
if (is) {
|
|||
|
if (opt.all)
|
|||
|
found.push(cur);
|
|||
|
else
|
|||
|
return cur
|
|||
|
}
|
|||
|
} catch (ex) {}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (opt.all && found.length)
|
|||
|
return found
|
|||
|
|
|||
|
if (opt.nothrow)
|
|||
|
return null
|
|||
|
|
|||
|
throw getNotFoundError(cmd)
|
|||
|
};
|
|||
|
|
|||
|
var which_1 = which;
|
|||
|
which.sync = whichSync;
|
|||
|
|
|||
|
const pathKey = (options = {}) => {
|
|||
|
const environment = options.env || process.env;
|
|||
|
const platform = options.platform || process.platform;
|
|||
|
|
|||
|
if (platform !== 'win32') {
|
|||
|
return 'PATH';
|
|||
|
}
|
|||
|
|
|||
|
return Object.keys(environment).reverse().find(key => key.toUpperCase() === 'PATH') || 'Path';
|
|||
|
};
|
|||
|
|
|||
|
var pathKey_1 = pathKey;
|
|||
|
// TODO: Remove this for the next major release
|
|||
|
var _default$2 = pathKey;
|
|||
|
pathKey_1.default = _default$2;
|
|||
|
|
|||
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|||
|
const env = parsed.options.env || process.env;
|
|||
|
const cwd = process.cwd();
|
|||
|
const hasCustomCwd = parsed.options.cwd != null;
|
|||
|
// Worker threads do not have process.chdir()
|
|||
|
const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;
|
|||
|
|
|||
|
// If a custom `cwd` was specified, we need to change the process cwd
|
|||
|
// because `which` will do stat calls but does not support a custom cwd
|
|||
|
if (shouldSwitchCwd) {
|
|||
|
try {
|
|||
|
process.chdir(parsed.options.cwd);
|
|||
|
} catch (err) {
|
|||
|
/* Empty */
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
let resolved;
|
|||
|
|
|||
|
try {
|
|||
|
resolved = which_1.sync(parsed.command, {
|
|||
|
path: env[pathKey_1({ env })],
|
|||
|
pathExt: withoutPathExt ? path__default['default'].delimiter : undefined,
|
|||
|
});
|
|||
|
} catch (e) {
|
|||
|
/* Empty */
|
|||
|
} finally {
|
|||
|
if (shouldSwitchCwd) {
|
|||
|
process.chdir(cwd);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// If we successfully resolved, ensure that an absolute path is returned
|
|||
|
// Note that when a custom `cwd` was used, we need to resolve to an absolute path based on it
|
|||
|
if (resolved) {
|
|||
|
resolved = path__default['default'].resolve(hasCustomCwd ? parsed.options.cwd : '', resolved);
|
|||
|
}
|
|||
|
|
|||
|
return resolved;
|
|||
|
}
|
|||
|
|
|||
|
function resolveCommand(parsed) {
|
|||
|
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
|
|||
|
}
|
|||
|
|
|||
|
var resolveCommand_1 = resolveCommand;
|
|||
|
|
|||
|
// See http://www.robvanderwoude.com/escapechars.php
|
|||
|
const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|||
|
|
|||
|
function escapeCommand(arg) {
|
|||
|
// Escape meta chars
|
|||
|
arg = arg.replace(metaCharsRegExp, '^$1');
|
|||
|
|
|||
|
return arg;
|
|||
|
}
|
|||
|
|
|||
|
function escapeArgument(arg, doubleEscapeMetaChars) {
|
|||
|
// Convert to string
|
|||
|
arg = `${arg}`;
|
|||
|
|
|||
|
// Algorithm below is based on https://qntm.org/cmd
|
|||
|
|
|||
|
// Sequence of backslashes followed by a double quote:
|
|||
|
// double up all the backslashes and escape the double quote
|
|||
|
arg = arg.replace(/(\\*)"/g, '$1$1\\"');
|
|||
|
|
|||
|
// Sequence of backslashes followed by the end of the string
|
|||
|
// (which will become a double quote later):
|
|||
|
// double up all the backslashes
|
|||
|
arg = arg.replace(/(\\*)$/, '$1$1');
|
|||
|
|
|||
|
// All other backslashes occur literally
|
|||
|
|
|||
|
// Quote the whole thing:
|
|||
|
arg = `"${arg}"`;
|
|||
|
|
|||
|
// Escape meta chars
|
|||
|
arg = arg.replace(metaCharsRegExp, '^$1');
|
|||
|
|
|||
|
// Double escape meta chars if necessary
|
|||
|
if (doubleEscapeMetaChars) {
|
|||
|
arg = arg.replace(metaCharsRegExp, '^$1');
|
|||
|
}
|
|||
|
|
|||
|
return arg;
|
|||
|
}
|
|||
|
|
|||
|
var command$2 = escapeCommand;
|
|||
|
var argument = escapeArgument;
|
|||
|
|
|||
|
var _escape = {
|
|||
|
command: command$2,
|
|||
|
argument: argument
|
|||
|
};
|
|||
|
|
|||
|
var shebangRegex = /^#!(.*)/;
|
|||
|
|
|||
|
var shebangCommand = (string = '') => {
|
|||
|
const match = string.match(shebangRegex);
|
|||
|
|
|||
|
if (!match) {
|
|||
|
return null;
|
|||
|
}
|
|||
|
|
|||
|
const [path, argument] = match[0].replace(/#! ?/, '').split(' ');
|
|||
|
const binary = path.split('/').pop();
|
|||
|
|
|||
|
if (binary === 'env') {
|
|||
|
return argument;
|
|||
|
}
|
|||
|
|
|||
|
return argument ? `${binary} ${argument}` : binary;
|
|||
|
};
|
|||
|
|
|||
|
function readShebang(command) {
|
|||
|
// Read the first 150 bytes from the file
|
|||
|
const size = 150;
|
|||
|
const buffer = Buffer.alloc(size);
|
|||
|
|
|||
|
let fd;
|
|||
|
|
|||
|
try {
|
|||
|
fd = fs__default['default'].openSync(command, 'r');
|
|||
|
fs__default['default'].readSync(fd, buffer, 0, size, 0);
|
|||
|
fs__default['default'].closeSync(fd);
|
|||
|
} catch (e) { /* Empty */ }
|
|||
|
|
|||
|
// Attempt to extract shebang (null is returned if not a shebang)
|
|||
|
return shebangCommand(buffer.toString());
|
|||
|
}
|
|||
|
|
|||
|
var readShebang_1 = readShebang;
|
|||
|
|
|||
|
const isWin$1 = process.platform === 'win32';
|
|||
|
const isExecutableRegExp = /\.(?:com|exe)$/i;
|
|||
|
const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|||
|
|
|||
|
function detectShebang(parsed) {
|
|||
|
parsed.file = resolveCommand_1(parsed);
|
|||
|
|
|||
|
const shebang = parsed.file && readShebang_1(parsed.file);
|
|||
|
|
|||
|
if (shebang) {
|
|||
|
parsed.args.unshift(parsed.file);
|
|||
|
parsed.command = shebang;
|
|||
|
|
|||
|
return resolveCommand_1(parsed);
|
|||
|
}
|
|||
|
|
|||
|
return parsed.file;
|
|||
|
}
|
|||
|
|
|||
|
function parseNonShell(parsed) {
|
|||
|
if (!isWin$1) {
|
|||
|
return parsed;
|
|||
|
}
|
|||
|
|
|||
|
// Detect & add support for shebangs
|
|||
|
const commandFile = detectShebang(parsed);
|
|||
|
|
|||
|
// We don't need a shell if the command filename is an executable
|
|||
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|||
|
|
|||
|
// If a shell is required, use cmd.exe and take care of escaping everything correctly
|
|||
|
// Note that `forceShell` is an hidden option used only in tests
|
|||
|
if (parsed.options.forceShell || needsShell) {
|
|||
|
// Need to double escape meta chars if the command is a cmd-shim located in `node_modules/.bin/`
|
|||
|
// The cmd-shim simply calls execute the package bin file with NodeJS, proxying any argument
|
|||
|
// Because the escape of metachars with ^ gets interpreted when the cmd.exe is first called,
|
|||
|
// we need to double escape them
|
|||
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|||
|
|
|||
|
// Normalize posix paths into OS compatible paths (e.g.: foo/bar -> foo\bar)
|
|||
|
// This is necessary otherwise it will always fail with ENOENT in those cases
|
|||
|
parsed.command = path__default['default'].normalize(parsed.command);
|
|||
|
|
|||
|
// Escape command & arguments
|
|||
|
parsed.command = _escape.command(parsed.command);
|
|||
|
parsed.args = parsed.args.map((arg) => _escape.argument(arg, needsDoubleEscapeMetaChars));
|
|||
|
|
|||
|
const shellCommand = [parsed.command].concat(parsed.args).join(' ');
|
|||
|
|
|||
|
parsed.args = ['/d', '/s', '/c', `"${shellCommand}"`];
|
|||
|
parsed.command = process.env.comspec || 'cmd.exe';
|
|||
|
parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped
|
|||
|
}
|
|||
|
|
|||
|
return parsed;
|
|||
|
}
|
|||
|
|
|||
|
function parse(command, args, options) {
|
|||
|
// Normalize arguments, similar to nodejs
|
|||
|
if (args && !Array.isArray(args)) {
|
|||
|
options = args;
|
|||
|
args = null;
|
|||
|
}
|
|||
|
|
|||
|
args = args ? args.slice(0) : []; // Clone array to avoid changing the original
|
|||
|
options = Object.assign({}, options); // Clone object to avoid changing the original
|
|||
|
|
|||
|
// Build our parsed object
|
|||
|
const parsed = {
|
|||
|
command,
|
|||
|
args,
|
|||
|
options,
|
|||
|
file: undefined,
|
|||
|
original: {
|
|||
|
command,
|
|||
|
args,
|
|||
|
},
|
|||
|
};
|
|||
|
|
|||
|
// Delegate further parsing to shell or non-shell
|
|||
|
return options.shell ? parsed : parseNonShell(parsed);
|
|||
|
}
|
|||
|
|
|||
|
var parse_1 = parse;
|
|||
|
|
|||
|
const isWin = process.platform === 'win32';
|
|||
|
|
|||
|
function notFoundError(original, syscall) {
|
|||
|
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
|
|||
|
code: 'ENOENT',
|
|||
|
errno: 'ENOENT',
|
|||
|
syscall: `${syscall} ${original.command}`,
|
|||
|
path: original.command,
|
|||
|
spawnargs: original.args,
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
function hookChildProcess(cp, parsed) {
|
|||
|
if (!isWin) {
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
const originalEmit = cp.emit;
|
|||
|
|
|||
|
cp.emit = function (name, arg1) {
|
|||
|
// If emitting "exit" event and exit code is 1, we need to check if
|
|||
|
// the command exists and emit an "error" instead
|
|||
|
// See https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
|||
|
if (name === 'exit') {
|
|||
|
const err = verifyENOENT(arg1, parsed);
|
|||
|
|
|||
|
if (err) {
|
|||
|
return originalEmit.call(cp, 'error', err);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
function verifyENOENT(status, parsed) {
|
|||
|
if (isWin && status === 1 && !parsed.file) {
|
|||
|
return notFoundError(parsed.original, 'spawn');
|
|||
|
}
|
|||
|
|
|||
|
return null;
|
|||
|
}
|
|||
|
|
|||
|
function verifyENOENTSync(status, parsed) {
|
|||
|
if (isWin && status === 1 && !parsed.file) {
|
|||
|
return notFoundError(parsed.original, 'spawnSync');
|
|||
|
}
|
|||
|
|
|||
|
return null;
|
|||
|
}
|
|||
|
|
|||
|
var enoent = {
|
|||
|
hookChildProcess,
|
|||
|
verifyENOENT,
|
|||
|
verifyENOENTSync,
|
|||
|
notFoundError,
|
|||
|
};
|
|||
|
|
|||
|
function spawn(command, args, options) {
|
|||
|
// Parse the arguments
|
|||
|
const parsed = parse_1(command, args, options);
|
|||
|
|
|||
|
// Spawn the child process
|
|||
|
const spawned = childProcess__default['default'].spawn(parsed.command, parsed.args, parsed.options);
|
|||
|
|
|||
|
// Hook into child process "exit" event to emit an error if the command
|
|||
|
// does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
|||
|
enoent.hookChildProcess(spawned, parsed);
|
|||
|
|
|||
|
return spawned;
|
|||
|
}
|
|||
|
|
|||
|
function spawnSync(command, args, options) {
|
|||
|
// Parse the arguments
|
|||
|
const parsed = parse_1(command, args, options);
|
|||
|
|
|||
|
// Spawn the child process
|
|||
|
const result = childProcess__default['default'].spawnSync(parsed.command, parsed.args, parsed.options);
|
|||
|
|
|||
|
// Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
|||
|
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|||
|
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
var crossSpawn = spawn;
|
|||
|
var spawn_1 = spawn;
|
|||
|
var sync$1 = spawnSync;
|
|||
|
|
|||
|
var _parse = parse_1;
|
|||
|
var _enoent = enoent;
|
|||
|
crossSpawn.spawn = spawn_1;
|
|||
|
crossSpawn.sync = sync$1;
|
|||
|
crossSpawn._parse = _parse;
|
|||
|
crossSpawn._enoent = _enoent;
|
|||
|
|
|||
|
var stripFinalNewline = input => {
|
|||
|
const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
|
|||
|
const CR = typeof input === 'string' ? '\r' : '\r'.charCodeAt();
|
|||
|
|
|||
|
if (input[input.length - 1] === LF) {
|
|||
|
input = input.slice(0, input.length - 1);
|
|||
|
}
|
|||
|
|
|||
|
if (input[input.length - 1] === CR) {
|
|||
|
input = input.slice(0, input.length - 1);
|
|||
|
}
|
|||
|
|
|||
|
return input;
|
|||
|
};
|
|||
|
|
|||
|
var npmRunPath_1 = createCommonjsModule(function (module) {
|
|||
|
|
|||
|
|
|||
|
|
|||
|
const npmRunPath = options => {
|
|||
|
options = {
|
|||
|
cwd: process.cwd(),
|
|||
|
path: process.env[pathKey_1()],
|
|||
|
execPath: process.execPath,
|
|||
|
...options
|
|||
|
};
|
|||
|
|
|||
|
let previous;
|
|||
|
let cwdPath = path__default['default'].resolve(options.cwd);
|
|||
|
const result = [];
|
|||
|
|
|||
|
while (previous !== cwdPath) {
|
|||
|
result.push(path__default['default'].join(cwdPath, 'node_modules/.bin'));
|
|||
|
previous = cwdPath;
|
|||
|
cwdPath = path__default['default'].resolve(cwdPath, '..');
|
|||
|
}
|
|||
|
|
|||
|
// Ensure the running `node` binary is used
|
|||
|
const execPathDir = path__default['default'].resolve(options.cwd, options.execPath, '..');
|
|||
|
result.push(execPathDir);
|
|||
|
|
|||
|
return result.concat(options.path).join(path__default['default'].delimiter);
|
|||
|
};
|
|||
|
|
|||
|
module.exports = npmRunPath;
|
|||
|
// TODO: Remove this for the next major release
|
|||
|
module.exports.default = npmRunPath;
|
|||
|
|
|||
|
module.exports.env = options => {
|
|||
|
options = {
|
|||
|
env: process.env,
|
|||
|
...options
|
|||
|
};
|
|||
|
|
|||
|
const env = {...options.env};
|
|||
|
const path = pathKey_1({env});
|
|||
|
|
|||
|
options.path = env[path];
|
|||
|
env[path] = module.exports(options);
|
|||
|
|
|||
|
return env;
|
|||
|
};
|
|||
|
});
|
|||
|
|
|||
|
const mimicFn = (to, from) => {
|
|||
|
for (const prop of Reflect.ownKeys(from)) {
|
|||
|
Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop));
|
|||
|
}
|
|||
|
|
|||
|
return to;
|
|||
|
};
|
|||
|
|
|||
|
var mimicFn_1 = mimicFn;
|
|||
|
// TODO: Remove this for the next major release
|
|||
|
var _default$1 = mimicFn;
|
|||
|
mimicFn_1.default = _default$1;
|
|||
|
|
|||
|
const calledFunctions = new WeakMap();
|
|||
|
|
|||
|
const onetime = (function_, options = {}) => {
|
|||
|
if (typeof function_ !== 'function') {
|
|||
|
throw new TypeError('Expected a function');
|
|||
|
}
|
|||
|
|
|||
|
let returnValue;
|
|||
|
let callCount = 0;
|
|||
|
const functionName = function_.displayName || function_.name || '<anonymous>';
|
|||
|
|
|||
|
const onetime = function (...arguments_) {
|
|||
|
calledFunctions.set(onetime, ++callCount);
|
|||
|
|
|||
|
if (callCount === 1) {
|
|||
|
returnValue = function_.apply(this, arguments_);
|
|||
|
function_ = null;
|
|||
|
} else if (options.throw === true) {
|
|||
|
throw new Error(`Function \`${functionName}\` can only be called once`);
|
|||
|
}
|
|||
|
|
|||
|
return returnValue;
|
|||
|
};
|
|||
|
|
|||
|
mimicFn_1(onetime, function_);
|
|||
|
calledFunctions.set(onetime, callCount);
|
|||
|
|
|||
|
return onetime;
|
|||
|
};
|
|||
|
|
|||
|
var onetime_1 = onetime;
|
|||
|
// TODO: Remove this for the next major release
|
|||
|
var _default = onetime;
|
|||
|
|
|||
|
var callCount = function_ => {
|
|||
|
if (!calledFunctions.has(function_)) {
|
|||
|
throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
|
|||
|
}
|
|||
|
|
|||
|
return calledFunctions.get(function_);
|
|||
|
};
|
|||
|
onetime_1.default = _default;
|
|||
|
onetime_1.callCount = callCount;
|
|||
|
|
|||
|
var core = createCommonjsModule(function (module, exports) {
|
|||
|
Object.defineProperty(exports,"__esModule",{value:true});exports.SIGNALS=void 0;
|
|||
|
|
|||
|
const SIGNALS=[
|
|||
|
{
|
|||
|
name:"SIGHUP",
|
|||
|
number:1,
|
|||
|
action:"terminate",
|
|||
|
description:"Terminal closed",
|
|||
|
standard:"posix"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGINT",
|
|||
|
number:2,
|
|||
|
action:"terminate",
|
|||
|
description:"User interruption with CTRL-C",
|
|||
|
standard:"ansi"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGQUIT",
|
|||
|
number:3,
|
|||
|
action:"core",
|
|||
|
description:"User interruption with CTRL-\\",
|
|||
|
standard:"posix"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGILL",
|
|||
|
number:4,
|
|||
|
action:"core",
|
|||
|
description:"Invalid machine instruction",
|
|||
|
standard:"ansi"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGTRAP",
|
|||
|
number:5,
|
|||
|
action:"core",
|
|||
|
description:"Debugger breakpoint",
|
|||
|
standard:"posix"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGABRT",
|
|||
|
number:6,
|
|||
|
action:"core",
|
|||
|
description:"Aborted",
|
|||
|
standard:"ansi"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGIOT",
|
|||
|
number:6,
|
|||
|
action:"core",
|
|||
|
description:"Aborted",
|
|||
|
standard:"bsd"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGBUS",
|
|||
|
number:7,
|
|||
|
action:"core",
|
|||
|
description:
|
|||
|
"Bus error due to misaligned, non-existing address or paging error",
|
|||
|
standard:"bsd"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGEMT",
|
|||
|
number:7,
|
|||
|
action:"terminate",
|
|||
|
description:"Command should be emulated but is not implemented",
|
|||
|
standard:"other"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGFPE",
|
|||
|
number:8,
|
|||
|
action:"core",
|
|||
|
description:"Floating point arithmetic error",
|
|||
|
standard:"ansi"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGKILL",
|
|||
|
number:9,
|
|||
|
action:"terminate",
|
|||
|
description:"Forced termination",
|
|||
|
standard:"posix",
|
|||
|
forced:true},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGUSR1",
|
|||
|
number:10,
|
|||
|
action:"terminate",
|
|||
|
description:"Application-specific signal",
|
|||
|
standard:"posix"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGSEGV",
|
|||
|
number:11,
|
|||
|
action:"core",
|
|||
|
description:"Segmentation fault",
|
|||
|
standard:"ansi"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGUSR2",
|
|||
|
number:12,
|
|||
|
action:"terminate",
|
|||
|
description:"Application-specific signal",
|
|||
|
standard:"posix"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGPIPE",
|
|||
|
number:13,
|
|||
|
action:"terminate",
|
|||
|
description:"Broken pipe or socket",
|
|||
|
standard:"posix"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGALRM",
|
|||
|
number:14,
|
|||
|
action:"terminate",
|
|||
|
description:"Timeout or timer",
|
|||
|
standard:"posix"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGTERM",
|
|||
|
number:15,
|
|||
|
action:"terminate",
|
|||
|
description:"Termination",
|
|||
|
standard:"ansi"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGSTKFLT",
|
|||
|
number:16,
|
|||
|
action:"terminate",
|
|||
|
description:"Stack is empty or overflowed",
|
|||
|
standard:"other"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGCHLD",
|
|||
|
number:17,
|
|||
|
action:"ignore",
|
|||
|
description:"Child process terminated, paused or unpaused",
|
|||
|
standard:"posix"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGCLD",
|
|||
|
number:17,
|
|||
|
action:"ignore",
|
|||
|
description:"Child process terminated, paused or unpaused",
|
|||
|
standard:"other"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGCONT",
|
|||
|
number:18,
|
|||
|
action:"unpause",
|
|||
|
description:"Unpaused",
|
|||
|
standard:"posix",
|
|||
|
forced:true},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGSTOP",
|
|||
|
number:19,
|
|||
|
action:"pause",
|
|||
|
description:"Paused",
|
|||
|
standard:"posix",
|
|||
|
forced:true},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGTSTP",
|
|||
|
number:20,
|
|||
|
action:"pause",
|
|||
|
description:"Paused using CTRL-Z or \"suspend\"",
|
|||
|
standard:"posix"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGTTIN",
|
|||
|
number:21,
|
|||
|
action:"pause",
|
|||
|
description:"Background process cannot read terminal input",
|
|||
|
standard:"posix"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGBREAK",
|
|||
|
number:21,
|
|||
|
action:"terminate",
|
|||
|
description:"User interruption with CTRL-BREAK",
|
|||
|
standard:"other"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGTTOU",
|
|||
|
number:22,
|
|||
|
action:"pause",
|
|||
|
description:"Background process cannot write to terminal output",
|
|||
|
standard:"posix"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGURG",
|
|||
|
number:23,
|
|||
|
action:"ignore",
|
|||
|
description:"Socket received out-of-band data",
|
|||
|
standard:"bsd"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGXCPU",
|
|||
|
number:24,
|
|||
|
action:"core",
|
|||
|
description:"Process timed out",
|
|||
|
standard:"bsd"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGXFSZ",
|
|||
|
number:25,
|
|||
|
action:"core",
|
|||
|
description:"File too big",
|
|||
|
standard:"bsd"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGVTALRM",
|
|||
|
number:26,
|
|||
|
action:"terminate",
|
|||
|
description:"Timeout or timer",
|
|||
|
standard:"bsd"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGPROF",
|
|||
|
number:27,
|
|||
|
action:"terminate",
|
|||
|
description:"Timeout or timer",
|
|||
|
standard:"bsd"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGWINCH",
|
|||
|
number:28,
|
|||
|
action:"ignore",
|
|||
|
description:"Terminal window size changed",
|
|||
|
standard:"bsd"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGIO",
|
|||
|
number:29,
|
|||
|
action:"terminate",
|
|||
|
description:"I/O is available",
|
|||
|
standard:"other"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGPOLL",
|
|||
|
number:29,
|
|||
|
action:"terminate",
|
|||
|
description:"Watched event",
|
|||
|
standard:"other"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGINFO",
|
|||
|
number:29,
|
|||
|
action:"ignore",
|
|||
|
description:"Request for process information",
|
|||
|
standard:"other"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGPWR",
|
|||
|
number:30,
|
|||
|
action:"terminate",
|
|||
|
description:"Device running out of power",
|
|||
|
standard:"systemv"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGSYS",
|
|||
|
number:31,
|
|||
|
action:"core",
|
|||
|
description:"Invalid system call",
|
|||
|
standard:"other"},
|
|||
|
|
|||
|
{
|
|||
|
name:"SIGUNUSED",
|
|||
|
number:31,
|
|||
|
action:"terminate",
|
|||
|
description:"Invalid system call",
|
|||
|
standard:"other"}];exports.SIGNALS=SIGNALS;
|
|||
|
//# sourceMappingURL=core.js.map
|
|||
|
});
|
|||
|
|
|||
|
var realtime = createCommonjsModule(function (module, exports) {
|
|||
|
Object.defineProperty(exports,"__esModule",{value:true});exports.SIGRTMAX=exports.getRealtimeSignals=void 0;
|
|||
|
const getRealtimeSignals=function(){
|
|||
|
const length=SIGRTMAX-SIGRTMIN+1;
|
|||
|
return Array.from({length},getRealtimeSignal);
|
|||
|
};exports.getRealtimeSignals=getRealtimeSignals;
|
|||
|
|
|||
|
const getRealtimeSignal=function(value,index){
|
|||
|
return {
|
|||
|
name:`SIGRT${index+1}`,
|
|||
|
number:SIGRTMIN+index,
|
|||
|
action:"terminate",
|
|||
|
description:"Application-specific signal (realtime)",
|
|||
|
standard:"posix"};
|
|||
|
|
|||
|
};
|
|||
|
|
|||
|
const SIGRTMIN=34;
|
|||
|
const SIGRTMAX=64;exports.SIGRTMAX=SIGRTMAX;
|
|||
|
//# sourceMappingURL=realtime.js.map
|
|||
|
});
|
|||
|
|
|||
|
var signals$1 = createCommonjsModule(function (module, exports) {
|
|||
|
Object.defineProperty(exports,"__esModule",{value:true});exports.getSignals=void 0;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
const getSignals=function(){
|
|||
|
const realtimeSignals=(0, realtime.getRealtimeSignals)();
|
|||
|
const signals=[...core.SIGNALS,...realtimeSignals].map(normalizeSignal);
|
|||
|
return signals;
|
|||
|
};exports.getSignals=getSignals;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
const normalizeSignal=function({
|
|||
|
name,
|
|||
|
number:defaultNumber,
|
|||
|
description,
|
|||
|
action,
|
|||
|
forced=false,
|
|||
|
standard})
|
|||
|
{
|
|||
|
const{
|
|||
|
signals:{[name]:constantSignal}}=
|
|||
|
_os__default['default'].constants;
|
|||
|
const supported=constantSignal!==undefined;
|
|||
|
const number=supported?constantSignal:defaultNumber;
|
|||
|
return {name,number,description,supported,action,forced,standard};
|
|||
|
};
|
|||
|
//# sourceMappingURL=signals.js.map
|
|||
|
});
|
|||
|
|
|||
|
var main = createCommonjsModule(function (module, exports) {
|
|||
|
Object.defineProperty(exports,"__esModule",{value:true});exports.signalsByNumber=exports.signalsByName=void 0;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
const getSignalsByName=function(){
|
|||
|
const signals=(0, signals$1.getSignals)();
|
|||
|
return signals.reduce(getSignalByName,{});
|
|||
|
};
|
|||
|
|
|||
|
const getSignalByName=function(
|
|||
|
signalByNameMemo,
|
|||
|
{name,number,description,supported,action,forced,standard})
|
|||
|
{
|
|||
|
return {
|
|||
|
...signalByNameMemo,
|
|||
|
[name]:{name,number,description,supported,action,forced,standard}};
|
|||
|
|
|||
|
};
|
|||
|
|
|||
|
const signalsByName=getSignalsByName();exports.signalsByName=signalsByName;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
const getSignalsByNumber=function(){
|
|||
|
const signals=(0, signals$1.getSignals)();
|
|||
|
const length=realtime.SIGRTMAX+1;
|
|||
|
const signalsA=Array.from({length},(value,number)=>
|
|||
|
getSignalByNumber(number,signals));
|
|||
|
|
|||
|
return Object.assign({},...signalsA);
|
|||
|
};
|
|||
|
|
|||
|
const getSignalByNumber=function(number,signals){
|
|||
|
const signal=findSignalByNumber(number,signals);
|
|||
|
|
|||
|
if(signal===undefined){
|
|||
|
return {};
|
|||
|
}
|
|||
|
|
|||
|
const{name,description,supported,action,forced,standard}=signal;
|
|||
|
return {
|
|||
|
[number]:{
|
|||
|
name,
|
|||
|
number,
|
|||
|
description,
|
|||
|
supported,
|
|||
|
action,
|
|||
|
forced,
|
|||
|
standard}};
|
|||
|
|
|||
|
|
|||
|
};
|
|||
|
|
|||
|
|
|||
|
|
|||
|
const findSignalByNumber=function(number,signals){
|
|||
|
const signal=signals.find(({name})=>_os__default['default'].constants.signals[name]===number);
|
|||
|
|
|||
|
if(signal!==undefined){
|
|||
|
return signal;
|
|||
|
}
|
|||
|
|
|||
|
return signals.find(signalA=>signalA.number===number);
|
|||
|
};
|
|||
|
|
|||
|
const signalsByNumber=getSignalsByNumber();exports.signalsByNumber=signalsByNumber;
|
|||
|
//# sourceMappingURL=main.js.map
|
|||
|
});
|
|||
|
|
|||
|
const {signalsByName} = main;
|
|||
|
|
|||
|
const getErrorPrefix = ({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}) => {
|
|||
|
if (timedOut) {
|
|||
|
return `timed out after ${timeout} milliseconds`;
|
|||
|
}
|
|||
|
|
|||
|
if (isCanceled) {
|
|||
|
return 'was canceled';
|
|||
|
}
|
|||
|
|
|||
|
if (errorCode !== undefined) {
|
|||
|
return `failed with ${errorCode}`;
|
|||
|
}
|
|||
|
|
|||
|
if (signal !== undefined) {
|
|||
|
return `was killed with ${signal} (${signalDescription})`;
|
|||
|
}
|
|||
|
|
|||
|
if (exitCode !== undefined) {
|
|||
|
return `failed with exit code ${exitCode}`;
|
|||
|
}
|
|||
|
|
|||
|
return 'failed';
|
|||
|
};
|
|||
|
|
|||
|
const makeError = ({
|
|||
|
stdout,
|
|||
|
stderr,
|
|||
|
all,
|
|||
|
error,
|
|||
|
signal,
|
|||
|
exitCode,
|
|||
|
command,
|
|||
|
escapedCommand,
|
|||
|
timedOut,
|
|||
|
isCanceled,
|
|||
|
killed,
|
|||
|
parsed: {options: {timeout}}
|
|||
|
}) => {
|
|||
|
// `signal` and `exitCode` emitted on `spawned.on('exit')` event can be `null`.
|
|||
|
// We normalize them to `undefined`
|
|||
|
exitCode = exitCode === null ? undefined : exitCode;
|
|||
|
signal = signal === null ? undefined : signal;
|
|||
|
const signalDescription = signal === undefined ? undefined : signalsByName[signal].description;
|
|||
|
|
|||
|
const errorCode = error && error.code;
|
|||
|
|
|||
|
const prefix = getErrorPrefix({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled});
|
|||
|
const execaMessage = `Command ${prefix}: ${command}`;
|
|||
|
const isError = Object.prototype.toString.call(error) === '[object Error]';
|
|||
|
const shortMessage = isError ? `${execaMessage}\n${error.message}` : execaMessage;
|
|||
|
const message = [shortMessage, stderr, stdout].filter(Boolean).join('\n');
|
|||
|
|
|||
|
if (isError) {
|
|||
|
error.originalMessage = error.message;
|
|||
|
error.message = message;
|
|||
|
} else {
|
|||
|
error = new Error(message);
|
|||
|
}
|
|||
|
|
|||
|
error.shortMessage = shortMessage;
|
|||
|
error.command = command;
|
|||
|
error.escapedCommand = escapedCommand;
|
|||
|
error.exitCode = exitCode;
|
|||
|
error.signal = signal;
|
|||
|
error.signalDescription = signalDescription;
|
|||
|
error.stdout = stdout;
|
|||
|
error.stderr = stderr;
|
|||
|
|
|||
|
if (all !== undefined) {
|
|||
|
error.all = all;
|
|||
|
}
|
|||
|
|
|||
|
if ('bufferedData' in error) {
|
|||
|
delete error.bufferedData;
|
|||
|
}
|
|||
|
|
|||
|
error.failed = true;
|
|||
|
error.timedOut = Boolean(timedOut);
|
|||
|
error.isCanceled = isCanceled;
|
|||
|
error.killed = killed && !timedOut;
|
|||
|
|
|||
|
return error;
|
|||
|
};
|
|||
|
|
|||
|
var error = makeError;
|
|||
|
|
|||
|
const aliases = ['stdin', 'stdout', 'stderr'];
|
|||
|
|
|||
|
const hasAlias = options => aliases.some(alias => options[alias] !== undefined);
|
|||
|
|
|||
|
const normalizeStdio = options => {
|
|||
|
if (!options) {
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
const {stdio} = options;
|
|||
|
|
|||
|
if (stdio === undefined) {
|
|||
|
return aliases.map(alias => options[alias]);
|
|||
|
}
|
|||
|
|
|||
|
if (hasAlias(options)) {
|
|||
|
throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`);
|
|||
|
}
|
|||
|
|
|||
|
if (typeof stdio === 'string') {
|
|||
|
return stdio;
|
|||
|
}
|
|||
|
|
|||
|
if (!Array.isArray(stdio)) {
|
|||
|
throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
|
|||
|
}
|
|||
|
|
|||
|
const length = Math.max(stdio.length, aliases.length);
|
|||
|
return Array.from({length}, (value, index) => stdio[index]);
|
|||
|
};
|
|||
|
|
|||
|
var stdio = normalizeStdio;
|
|||
|
|
|||
|
// `ipc` is pushed unless it is already present
|
|||
|
var node$1 = options => {
|
|||
|
const stdio = normalizeStdio(options);
|
|||
|
|
|||
|
if (stdio === 'ipc') {
|
|||
|
return 'ipc';
|
|||
|
}
|
|||
|
|
|||
|
if (stdio === undefined || typeof stdio === 'string') {
|
|||
|
return [stdio, stdio, stdio, 'ipc'];
|
|||
|
}
|
|||
|
|
|||
|
if (stdio.includes('ipc')) {
|
|||
|
return stdio;
|
|||
|
}
|
|||
|
|
|||
|
return [...stdio, 'ipc'];
|
|||
|
};
|
|||
|
stdio.node = node$1;
|
|||
|
|
|||
|
var signals = createCommonjsModule(function (module) {
|
|||
|
// This is not the set of all possible signals.
|
|||
|
//
|
|||
|
// It IS, however, the set of all signals that trigger
|
|||
|
// an exit on either Linux or BSD systems. Linux is a
|
|||
|
// superset of the signal names supported on BSD, and
|
|||
|
// the unknown signals just fail to register, so we can
|
|||
|
// catch that easily enough.
|
|||
|
//
|
|||
|
// Don't bother with SIGKILL. It's uncatchable, which
|
|||
|
// means that we can't fire any callbacks anyway.
|
|||
|
//
|
|||
|
// If a user does happen to register a handler on a non-
|
|||
|
// fatal signal like SIGWINCH or something, and then
|
|||
|
// exit, it'll end up firing `process.emit('exit')`, so
|
|||
|
// the handler will be fired anyway.
|
|||
|
//
|
|||
|
// SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
|
|||
|
// artificially, inherently leave the process in a
|
|||
|
// state from which it is not safe to try and enter JS
|
|||
|
// listeners.
|
|||
|
module.exports = [
|
|||
|
'SIGABRT',
|
|||
|
'SIGALRM',
|
|||
|
'SIGHUP',
|
|||
|
'SIGINT',
|
|||
|
'SIGTERM'
|
|||
|
];
|
|||
|
|
|||
|
if (process.platform !== 'win32') {
|
|||
|
module.exports.push(
|
|||
|
'SIGVTALRM',
|
|||
|
'SIGXCPU',
|
|||
|
'SIGXFSZ',
|
|||
|
'SIGUSR2',
|
|||
|
'SIGTRAP',
|
|||
|
'SIGSYS',
|
|||
|
'SIGQUIT',
|
|||
|
'SIGIOT'
|
|||
|
// should detect profiler and enable/disable accordingly.
|
|||
|
// see #21
|
|||
|
// 'SIGPROF'
|
|||
|
);
|
|||
|
}
|
|||
|
|
|||
|
if (process.platform === 'linux') {
|
|||
|
module.exports.push(
|
|||
|
'SIGIO',
|
|||
|
'SIGPOLL',
|
|||
|
'SIGPWR',
|
|||
|
'SIGSTKFLT',
|
|||
|
'SIGUNUSED'
|
|||
|
);
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
var signalExit = createCommonjsModule(function (module) {
|
|||
|
// Note: since nyc uses this module to output coverage, any lines
|
|||
|
// that are in the direct sync flow of nyc's outputCoverage are
|
|||
|
// ignored, since we can never get coverage for them.
|
|||
|
// grab a reference to node's real process object right away
|
|||
|
var process = commonjsGlobal.process;
|
|||
|
|
|||
|
const processOk = function (process) {
|
|||
|
return process &&
|
|||
|
typeof process === 'object' &&
|
|||
|
typeof process.removeListener === 'function' &&
|
|||
|
typeof process.emit === 'function' &&
|
|||
|
typeof process.reallyExit === 'function' &&
|
|||
|
typeof process.listeners === 'function' &&
|
|||
|
typeof process.kill === 'function' &&
|
|||
|
typeof process.pid === 'number' &&
|
|||
|
typeof process.on === 'function'
|
|||
|
};
|
|||
|
|
|||
|
// some kind of non-node environment, just no-op
|
|||
|
/* istanbul ignore if */
|
|||
|
if (!processOk(process)) {
|
|||
|
module.exports = function () {
|
|||
|
return function () {}
|
|||
|
};
|
|||
|
} else {
|
|||
|
var assert = require$$0__default['default'];
|
|||
|
var signals$1 = signals;
|
|||
|
var isWin = /^win/i.test(process.platform);
|
|||
|
|
|||
|
var EE = require$$2__default['default'];
|
|||
|
/* istanbul ignore if */
|
|||
|
if (typeof EE !== 'function') {
|
|||
|
EE = EE.EventEmitter;
|
|||
|
}
|
|||
|
|
|||
|
var emitter;
|
|||
|
if (process.__signal_exit_emitter__) {
|
|||
|
emitter = process.__signal_exit_emitter__;
|
|||
|
} else {
|
|||
|
emitter = process.__signal_exit_emitter__ = new EE();
|
|||
|
emitter.count = 0;
|
|||
|
emitter.emitted = {};
|
|||
|
}
|
|||
|
|
|||
|
// Because this emitter is a global, we have to check to see if a
|
|||
|
// previous version of this library failed to enable infinite listeners.
|
|||
|
// I know what you're about to say. But literally everything about
|
|||
|
// signal-exit is a compromise with evil. Get used to it.
|
|||
|
if (!emitter.infinite) {
|
|||
|
emitter.setMaxListeners(Infinity);
|
|||
|
emitter.infinite = true;
|
|||
|
}
|
|||
|
|
|||
|
module.exports = function (cb, opts) {
|
|||
|
/* istanbul ignore if */
|
|||
|
if (!processOk(commonjsGlobal.process)) {
|
|||
|
return function () {}
|
|||
|
}
|
|||
|
assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler');
|
|||
|
|
|||
|
if (loaded === false) {
|
|||
|
load();
|
|||
|
}
|
|||
|
|
|||
|
var ev = 'exit';
|
|||
|
if (opts && opts.alwaysLast) {
|
|||
|
ev = 'afterexit';
|
|||
|
}
|
|||
|
|
|||
|
var remove = function () {
|
|||
|
emitter.removeListener(ev, cb);
|
|||
|
if (emitter.listeners('exit').length === 0 &&
|
|||
|
emitter.listeners('afterexit').length === 0) {
|
|||
|
unload();
|
|||
|
}
|
|||
|
};
|
|||
|
emitter.on(ev, cb);
|
|||
|
|
|||
|
return remove
|
|||
|
};
|
|||
|
|
|||
|
var unload = function unload () {
|
|||
|
if (!loaded || !processOk(commonjsGlobal.process)) {
|
|||
|
return
|
|||
|
}
|
|||
|
loaded = false;
|
|||
|
|
|||
|
signals$1.forEach(function (sig) {
|
|||
|
try {
|
|||
|
process.removeListener(sig, sigListeners[sig]);
|
|||
|
} catch (er) {}
|
|||
|
});
|
|||
|
process.emit = originalProcessEmit;
|
|||
|
process.reallyExit = originalProcessReallyExit;
|
|||
|
emitter.count -= 1;
|
|||
|
};
|
|||
|
module.exports.unload = unload;
|
|||
|
|
|||
|
var emit = function emit (event, code, signal) {
|
|||
|
/* istanbul ignore if */
|
|||
|
if (emitter.emitted[event]) {
|
|||
|
return
|
|||
|
}
|
|||
|
emitter.emitted[event] = true;
|
|||
|
emitter.emit(event, code, signal);
|
|||
|
};
|
|||
|
|
|||
|
// { <signal>: <listener fn>, ... }
|
|||
|
var sigListeners = {};
|
|||
|
signals$1.forEach(function (sig) {
|
|||
|
sigListeners[sig] = function listener () {
|
|||
|
/* istanbul ignore if */
|
|||
|
if (!processOk(commonjsGlobal.process)) {
|
|||
|
return
|
|||
|
}
|
|||
|
// If there are no other listeners, an exit is coming!
|
|||
|
// Simplest way: remove us and then re-send the signal.
|
|||
|
// We know that this will kill the process, so we can
|
|||
|
// safely emit now.
|
|||
|
var listeners = process.listeners(sig);
|
|||
|
if (listeners.length === emitter.count) {
|
|||
|
unload();
|
|||
|
emit('exit', null, sig);
|
|||
|
/* istanbul ignore next */
|
|||
|
emit('afterexit', null, sig);
|
|||
|
/* istanbul ignore next */
|
|||
|
if (isWin && sig === 'SIGHUP') {
|
|||
|
// "SIGHUP" throws an `ENOSYS` error on Windows,
|
|||
|
// so use a supported signal instead
|
|||
|
sig = 'SIGINT';
|
|||
|
}
|
|||
|
/* istanbul ignore next */
|
|||
|
process.kill(process.pid, sig);
|
|||
|
}
|
|||
|
};
|
|||
|
});
|
|||
|
|
|||
|
module.exports.signals = function () {
|
|||
|
return signals$1
|
|||
|
};
|
|||
|
|
|||
|
var loaded = false;
|
|||
|
|
|||
|
var load = function load () {
|
|||
|
if (loaded || !processOk(commonjsGlobal.process)) {
|
|||
|
return
|
|||
|
}
|
|||
|
loaded = true;
|
|||
|
|
|||
|
// This is the number of onSignalExit's that are in play.
|
|||
|
// It's important so that we can count the correct number of
|
|||
|
// listeners on signals, and don't wait for the other one to
|
|||
|
// handle it instead of us.
|
|||
|
emitter.count += 1;
|
|||
|
|
|||
|
signals$1 = signals$1.filter(function (sig) {
|
|||
|
try {
|
|||
|
process.on(sig, sigListeners[sig]);
|
|||
|
return true
|
|||
|
} catch (er) {
|
|||
|
return false
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
process.emit = processEmit;
|
|||
|
process.reallyExit = processReallyExit;
|
|||
|
};
|
|||
|
module.exports.load = load;
|
|||
|
|
|||
|
var originalProcessReallyExit = process.reallyExit;
|
|||
|
var processReallyExit = function processReallyExit (code) {
|
|||
|
/* istanbul ignore if */
|
|||
|
if (!processOk(commonjsGlobal.process)) {
|
|||
|
return
|
|||
|
}
|
|||
|
process.exitCode = code || /* istanbul ignore next */ 0;
|
|||
|
emit('exit', process.exitCode, null);
|
|||
|
/* istanbul ignore next */
|
|||
|
emit('afterexit', process.exitCode, null);
|
|||
|
/* istanbul ignore next */
|
|||
|
originalProcessReallyExit.call(process, process.exitCode);
|
|||
|
};
|
|||
|
|
|||
|
var originalProcessEmit = process.emit;
|
|||
|
var processEmit = function processEmit (ev, arg) {
|
|||
|
if (ev === 'exit' && processOk(commonjsGlobal.process)) {
|
|||
|
/* istanbul ignore else */
|
|||
|
if (arg !== undefined) {
|
|||
|
process.exitCode = arg;
|
|||
|
}
|
|||
|
var ret = originalProcessEmit.apply(this, arguments);
|
|||
|
/* istanbul ignore next */
|
|||
|
emit('exit', process.exitCode, null);
|
|||
|
/* istanbul ignore next */
|
|||
|
emit('afterexit', process.exitCode, null);
|
|||
|
/* istanbul ignore next */
|
|||
|
return ret
|
|||
|
} else {
|
|||
|
return originalProcessEmit.apply(this, arguments)
|
|||
|
}
|
|||
|
};
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;
|
|||
|
|
|||
|
// Monkey-patches `childProcess.kill()` to add `forceKillAfterTimeout` behavior
|
|||
|
const spawnedKill$1 = (kill, signal = 'SIGTERM', options = {}) => {
|
|||
|
const killResult = kill(signal);
|
|||
|
setKillTimeout(kill, signal, options, killResult);
|
|||
|
return killResult;
|
|||
|
};
|
|||
|
|
|||
|
const setKillTimeout = (kill, signal, options, killResult) => {
|
|||
|
if (!shouldForceKill(signal, options, killResult)) {
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
const timeout = getForceKillAfterTimeout(options);
|
|||
|
const t = setTimeout(() => {
|
|||
|
kill('SIGKILL');
|
|||
|
}, timeout);
|
|||
|
|
|||
|
// Guarded because there's no `.unref()` when `execa` is used in the renderer
|
|||
|
// process in Electron. This cannot be tested since we don't run tests in
|
|||
|
// Electron.
|
|||
|
// istanbul ignore else
|
|||
|
if (t.unref) {
|
|||
|
t.unref();
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
const shouldForceKill = (signal, {forceKillAfterTimeout}, killResult) => {
|
|||
|
return isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
|
|||
|
};
|
|||
|
|
|||
|
const isSigterm = signal => {
|
|||
|
return signal === _os__default['default'].constants.signals.SIGTERM ||
|
|||
|
(typeof signal === 'string' && signal.toUpperCase() === 'SIGTERM');
|
|||
|
};
|
|||
|
|
|||
|
const getForceKillAfterTimeout = ({forceKillAfterTimeout = true}) => {
|
|||
|
if (forceKillAfterTimeout === true) {
|
|||
|
return DEFAULT_FORCE_KILL_TIMEOUT;
|
|||
|
}
|
|||
|
|
|||
|
if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
|
|||
|
throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);
|
|||
|
}
|
|||
|
|
|||
|
return forceKillAfterTimeout;
|
|||
|
};
|
|||
|
|
|||
|
// `childProcess.cancel()`
|
|||
|
const spawnedCancel$1 = (spawned, context) => {
|
|||
|
const killResult = spawned.kill();
|
|||
|
|
|||
|
if (killResult) {
|
|||
|
context.isCanceled = true;
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
const timeoutKill = (spawned, signal, reject) => {
|
|||
|
spawned.kill(signal);
|
|||
|
reject(Object.assign(new Error('Timed out'), {timedOut: true, signal}));
|
|||
|
};
|
|||
|
|
|||
|
// `timeout` option handling
|
|||
|
const setupTimeout$1 = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise) => {
|
|||
|
if (timeout === 0 || timeout === undefined) {
|
|||
|
return spawnedPromise;
|
|||
|
}
|
|||
|
|
|||
|
let timeoutId;
|
|||
|
const timeoutPromise = new Promise((resolve, reject) => {
|
|||
|
timeoutId = setTimeout(() => {
|
|||
|
timeoutKill(spawned, killSignal, reject);
|
|||
|
}, timeout);
|
|||
|
});
|
|||
|
|
|||
|
const safeSpawnedPromise = spawnedPromise.finally(() => {
|
|||
|
clearTimeout(timeoutId);
|
|||
|
});
|
|||
|
|
|||
|
return Promise.race([timeoutPromise, safeSpawnedPromise]);
|
|||
|
};
|
|||
|
|
|||
|
const validateTimeout$1 = ({timeout}) => {
|
|||
|
if (timeout !== undefined && (!Number.isFinite(timeout) || timeout < 0)) {
|
|||
|
throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
// `cleanup` option handling
|
|||
|
const setExitHandler$1 = async (spawned, {cleanup, detached}, timedPromise) => {
|
|||
|
if (!cleanup || detached) {
|
|||
|
return timedPromise;
|
|||
|
}
|
|||
|
|
|||
|
const removeExitHandler = signalExit(() => {
|
|||
|
spawned.kill();
|
|||
|
});
|
|||
|
|
|||
|
return timedPromise.finally(() => {
|
|||
|
removeExitHandler();
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
var kill = {
|
|||
|
spawnedKill: spawnedKill$1,
|
|||
|
spawnedCancel: spawnedCancel$1,
|
|||
|
setupTimeout: setupTimeout$1,
|
|||
|
validateTimeout: validateTimeout$1,
|
|||
|
setExitHandler: setExitHandler$1
|
|||
|
};
|
|||
|
|
|||
|
const isStream = stream =>
|
|||
|
stream !== null &&
|
|||
|
typeof stream === 'object' &&
|
|||
|
typeof stream.pipe === 'function';
|
|||
|
|
|||
|
isStream.writable = stream =>
|
|||
|
isStream(stream) &&
|
|||
|
stream.writable !== false &&
|
|||
|
typeof stream._write === 'function' &&
|
|||
|
typeof stream._writableState === 'object';
|
|||
|
|
|||
|
isStream.readable = stream =>
|
|||
|
isStream(stream) &&
|
|||
|
stream.readable !== false &&
|
|||
|
typeof stream._read === 'function' &&
|
|||
|
typeof stream._readableState === 'object';
|
|||
|
|
|||
|
isStream.duplex = stream =>
|
|||
|
isStream.writable(stream) &&
|
|||
|
isStream.readable(stream);
|
|||
|
|
|||
|
isStream.transform = stream =>
|
|||
|
isStream.duplex(stream) &&
|
|||
|
typeof stream._transform === 'function';
|
|||
|
|
|||
|
var isStream_1 = isStream;
|
|||
|
|
|||
|
const {PassThrough: PassThroughStream} = require$$0__default$1['default'];
|
|||
|
|
|||
|
var bufferStream = options => {
|
|||
|
options = {...options};
|
|||
|
|
|||
|
const {array} = options;
|
|||
|
let {encoding} = options;
|
|||
|
const isBuffer = encoding === 'buffer';
|
|||
|
let objectMode = false;
|
|||
|
|
|||
|
if (array) {
|
|||
|
objectMode = !(encoding || isBuffer);
|
|||
|
} else {
|
|||
|
encoding = encoding || 'utf8';
|
|||
|
}
|
|||
|
|
|||
|
if (isBuffer) {
|
|||
|
encoding = null;
|
|||
|
}
|
|||
|
|
|||
|
const stream = new PassThroughStream({objectMode});
|
|||
|
|
|||
|
if (encoding) {
|
|||
|
stream.setEncoding(encoding);
|
|||
|
}
|
|||
|
|
|||
|
let length = 0;
|
|||
|
const chunks = [];
|
|||
|
|
|||
|
stream.on('data', chunk => {
|
|||
|
chunks.push(chunk);
|
|||
|
|
|||
|
if (objectMode) {
|
|||
|
length = chunks.length;
|
|||
|
} else {
|
|||
|
length += chunk.length;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
stream.getBufferedValue = () => {
|
|||
|
if (array) {
|
|||
|
return chunks;
|
|||
|
}
|
|||
|
|
|||
|
return isBuffer ? Buffer.concat(chunks, length) : chunks.join('');
|
|||
|
};
|
|||
|
|
|||
|
stream.getBufferedLength = () => length;
|
|||
|
|
|||
|
return stream;
|
|||
|
};
|
|||
|
|
|||
|
const {constants: BufferConstants} = require$$0__default$2['default'];
|
|||
|
|
|||
|
const {promisify} = require$$1__default['default'];
|
|||
|
|
|||
|
|
|||
|
const streamPipelinePromisified = promisify(require$$0__default$1['default'].pipeline);
|
|||
|
|
|||
|
class MaxBufferError extends Error {
|
|||
|
constructor() {
|
|||
|
super('maxBuffer exceeded');
|
|||
|
this.name = 'MaxBufferError';
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
async function getStream(inputStream, options) {
|
|||
|
if (!inputStream) {
|
|||
|
throw new Error('Expected a stream');
|
|||
|
}
|
|||
|
|
|||
|
options = {
|
|||
|
maxBuffer: Infinity,
|
|||
|
...options
|
|||
|
};
|
|||
|
|
|||
|
const {maxBuffer} = options;
|
|||
|
const stream = bufferStream(options);
|
|||
|
|
|||
|
await new Promise((resolve, reject) => {
|
|||
|
const rejectPromise = error => {
|
|||
|
// Don't retrieve an oversized buffer.
|
|||
|
if (error && stream.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
|
|||
|
error.bufferedData = stream.getBufferedValue();
|
|||
|
}
|
|||
|
|
|||
|
reject(error);
|
|||
|
};
|
|||
|
|
|||
|
(async () => {
|
|||
|
try {
|
|||
|
await streamPipelinePromisified(inputStream, stream);
|
|||
|
resolve();
|
|||
|
} catch (error) {
|
|||
|
rejectPromise(error);
|
|||
|
}
|
|||
|
})();
|
|||
|
|
|||
|
stream.on('data', () => {
|
|||
|
if (stream.getBufferedLength() > maxBuffer) {
|
|||
|
rejectPromise(new MaxBufferError());
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
|
|||
|
return stream.getBufferedValue();
|
|||
|
}
|
|||
|
|
|||
|
var getStream_1 = getStream;
|
|||
|
var buffer = (stream, options) => getStream(stream, {...options, encoding: 'buffer'});
|
|||
|
var array = (stream, options) => getStream(stream, {...options, array: true});
|
|||
|
var MaxBufferError_1 = MaxBufferError;
|
|||
|
getStream_1.buffer = buffer;
|
|||
|
getStream_1.array = array;
|
|||
|
getStream_1.MaxBufferError = MaxBufferError_1;
|
|||
|
|
|||
|
const { PassThrough } = require$$0__default$1['default'];
|
|||
|
|
|||
|
var mergeStream = function (/*streams...*/) {
|
|||
|
var sources = [];
|
|||
|
var output = new PassThrough({objectMode: true});
|
|||
|
|
|||
|
output.setMaxListeners(0);
|
|||
|
|
|||
|
output.add = add;
|
|||
|
output.isEmpty = isEmpty;
|
|||
|
|
|||
|
output.on('unpipe', remove);
|
|||
|
|
|||
|
Array.prototype.slice.call(arguments).forEach(add);
|
|||
|
|
|||
|
return output
|
|||
|
|
|||
|
function add (source) {
|
|||
|
if (Array.isArray(source)) {
|
|||
|
source.forEach(add);
|
|||
|
return this
|
|||
|
}
|
|||
|
|
|||
|
sources.push(source);
|
|||
|
source.once('end', remove.bind(null, source));
|
|||
|
source.once('error', output.emit.bind(output, 'error'));
|
|||
|
source.pipe(output, {end: false});
|
|||
|
return this
|
|||
|
}
|
|||
|
|
|||
|
function isEmpty () {
|
|||
|
return sources.length == 0;
|
|||
|
}
|
|||
|
|
|||
|
function remove (source) {
|
|||
|
sources = sources.filter(function (it) { return it !== source });
|
|||
|
if (!sources.length && output.readable) { output.end(); }
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
// `input` option
|
|||
|
const handleInput$1 = (spawned, input) => {
|
|||
|
// Checking for stdin is workaround for https://github.com/nodejs/node/issues/26852
|
|||
|
// @todo remove `|| spawned.stdin === undefined` once we drop support for Node.js <=12.2.0
|
|||
|
if (input === undefined || spawned.stdin === undefined) {
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (isStream_1(input)) {
|
|||
|
input.pipe(spawned.stdin);
|
|||
|
} else {
|
|||
|
spawned.stdin.end(input);
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
// `all` interleaves `stdout` and `stderr`
|
|||
|
const makeAllStream$1 = (spawned, {all}) => {
|
|||
|
if (!all || (!spawned.stdout && !spawned.stderr)) {
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
const mixed = mergeStream();
|
|||
|
|
|||
|
if (spawned.stdout) {
|
|||
|
mixed.add(spawned.stdout);
|
|||
|
}
|
|||
|
|
|||
|
if (spawned.stderr) {
|
|||
|
mixed.add(spawned.stderr);
|
|||
|
}
|
|||
|
|
|||
|
return mixed;
|
|||
|
};
|
|||
|
|
|||
|
// On failure, `result.stdout|stderr|all` should contain the currently buffered stream
|
|||
|
const getBufferedData = async (stream, streamPromise) => {
|
|||
|
if (!stream) {
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
stream.destroy();
|
|||
|
|
|||
|
try {
|
|||
|
return await streamPromise;
|
|||
|
} catch (error) {
|
|||
|
return error.bufferedData;
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
const getStreamPromise = (stream, {encoding, buffer, maxBuffer}) => {
|
|||
|
if (!stream || !buffer) {
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (encoding) {
|
|||
|
return getStream_1(stream, {encoding, maxBuffer});
|
|||
|
}
|
|||
|
|
|||
|
return getStream_1.buffer(stream, {maxBuffer});
|
|||
|
};
|
|||
|
|
|||
|
// Retrieve result of child process: exit code, signal, error, streams (stdout/stderr/all)
|
|||
|
const getSpawnedResult$1 = async ({stdout, stderr, all}, {encoding, buffer, maxBuffer}, processDone) => {
|
|||
|
const stdoutPromise = getStreamPromise(stdout, {encoding, buffer, maxBuffer});
|
|||
|
const stderrPromise = getStreamPromise(stderr, {encoding, buffer, maxBuffer});
|
|||
|
const allPromise = getStreamPromise(all, {encoding, buffer, maxBuffer: maxBuffer * 2});
|
|||
|
|
|||
|
try {
|
|||
|
return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]);
|
|||
|
} catch (error) {
|
|||
|
return Promise.all([
|
|||
|
{error, signal: error.signal, timedOut: error.timedOut},
|
|||
|
getBufferedData(stdout, stdoutPromise),
|
|||
|
getBufferedData(stderr, stderrPromise),
|
|||
|
getBufferedData(all, allPromise)
|
|||
|
]);
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
const validateInputSync$1 = ({input}) => {
|
|||
|
if (isStream_1(input)) {
|
|||
|
throw new TypeError('The `input` option cannot be a stream in sync mode');
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
var stream = {
|
|||
|
handleInput: handleInput$1,
|
|||
|
makeAllStream: makeAllStream$1,
|
|||
|
getSpawnedResult: getSpawnedResult$1,
|
|||
|
validateInputSync: validateInputSync$1
|
|||
|
};
|
|||
|
|
|||
|
const nativePromisePrototype = (async () => {})().constructor.prototype;
|
|||
|
const descriptors = ['then', 'catch', 'finally'].map(property => [
|
|||
|
property,
|
|||
|
Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property)
|
|||
|
]);
|
|||
|
|
|||
|
// The return value is a mixin of `childProcess` and `Promise`
|
|||
|
const mergePromise$1 = (spawned, promise) => {
|
|||
|
for (const [property, descriptor] of descriptors) {
|
|||
|
// Starting the main `promise` is deferred to avoid consuming streams
|
|||
|
const value = typeof promise === 'function' ?
|
|||
|
(...args) => Reflect.apply(descriptor.value, promise(), args) :
|
|||
|
descriptor.value.bind(promise);
|
|||
|
|
|||
|
Reflect.defineProperty(spawned, property, {...descriptor, value});
|
|||
|
}
|
|||
|
|
|||
|
return spawned;
|
|||
|
};
|
|||
|
|
|||
|
// Use promises instead of `child_process` events
|
|||
|
const getSpawnedPromise$1 = spawned => {
|
|||
|
return new Promise((resolve, reject) => {
|
|||
|
spawned.on('exit', (exitCode, signal) => {
|
|||
|
resolve({exitCode, signal});
|
|||
|
});
|
|||
|
|
|||
|
spawned.on('error', error => {
|
|||
|
reject(error);
|
|||
|
});
|
|||
|
|
|||
|
if (spawned.stdin) {
|
|||
|
spawned.stdin.on('error', error => {
|
|||
|
reject(error);
|
|||
|
});
|
|||
|
}
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
var promise = {
|
|||
|
mergePromise: mergePromise$1,
|
|||
|
getSpawnedPromise: getSpawnedPromise$1
|
|||
|
};
|
|||
|
|
|||
|
const normalizeArgs = (file, args = []) => {
|
|||
|
if (!Array.isArray(args)) {
|
|||
|
return [file];
|
|||
|
}
|
|||
|
|
|||
|
return [file, ...args];
|
|||
|
};
|
|||
|
|
|||
|
const NO_ESCAPE_REGEXP = /^[\w.-]+$/;
|
|||
|
const DOUBLE_QUOTES_REGEXP = /"/g;
|
|||
|
|
|||
|
const escapeArg = arg => {
|
|||
|
if (typeof arg !== 'string' || NO_ESCAPE_REGEXP.test(arg)) {
|
|||
|
return arg;
|
|||
|
}
|
|||
|
|
|||
|
return `"${arg.replace(DOUBLE_QUOTES_REGEXP, '\\"')}"`;
|
|||
|
};
|
|||
|
|
|||
|
const joinCommand$1 = (file, args) => {
|
|||
|
return normalizeArgs(file, args).join(' ');
|
|||
|
};
|
|||
|
|
|||
|
const getEscapedCommand$1 = (file, args) => {
|
|||
|
return normalizeArgs(file, args).map(arg => escapeArg(arg)).join(' ');
|
|||
|
};
|
|||
|
|
|||
|
const SPACES_REGEXP = / +/g;
|
|||
|
|
|||
|
// Handle `execa.command()`
|
|||
|
const parseCommand$1 = command => {
|
|||
|
const tokens = [];
|
|||
|
for (const token of command.trim().split(SPACES_REGEXP)) {
|
|||
|
// Allow spaces to be escaped by a backslash if not meant as a delimiter
|
|||
|
const previousToken = tokens[tokens.length - 1];
|
|||
|
if (previousToken && previousToken.endsWith('\\')) {
|
|||
|
// Merge previous token with current one
|
|||
|
tokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`;
|
|||
|
} else {
|
|||
|
tokens.push(token);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
return tokens;
|
|||
|
};
|
|||
|
|
|||
|
var command$1 = {
|
|||
|
joinCommand: joinCommand$1,
|
|||
|
getEscapedCommand: getEscapedCommand$1,
|
|||
|
parseCommand: parseCommand$1
|
|||
|
};
|
|||
|
|
|||
|
const {spawnedKill, spawnedCancel, setupTimeout, validateTimeout, setExitHandler} = kill;
|
|||
|
const {handleInput, getSpawnedResult, makeAllStream, validateInputSync} = stream;
|
|||
|
const {mergePromise, getSpawnedPromise} = promise;
|
|||
|
const {joinCommand, parseCommand, getEscapedCommand} = command$1;
|
|||
|
|
|||
|
const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100;
|
|||
|
|
|||
|
const getEnv = ({env: envOption, extendEnv, preferLocal, localDir, execPath}) => {
|
|||
|
const env = extendEnv ? {...process.env, ...envOption} : envOption;
|
|||
|
|
|||
|
if (preferLocal) {
|
|||
|
return npmRunPath_1.env({env, cwd: localDir, execPath});
|
|||
|
}
|
|||
|
|
|||
|
return env;
|
|||
|
};
|
|||
|
|
|||
|
const handleArguments = (file, args, options = {}) => {
|
|||
|
const parsed = crossSpawn._parse(file, args, options);
|
|||
|
file = parsed.command;
|
|||
|
args = parsed.args;
|
|||
|
options = parsed.options;
|
|||
|
|
|||
|
options = {
|
|||
|
maxBuffer: DEFAULT_MAX_BUFFER,
|
|||
|
buffer: true,
|
|||
|
stripFinalNewline: true,
|
|||
|
extendEnv: true,
|
|||
|
preferLocal: false,
|
|||
|
localDir: options.cwd || process.cwd(),
|
|||
|
execPath: process.execPath,
|
|||
|
encoding: 'utf8',
|
|||
|
reject: true,
|
|||
|
cleanup: true,
|
|||
|
all: false,
|
|||
|
windowsHide: true,
|
|||
|
...options
|
|||
|
};
|
|||
|
|
|||
|
options.env = getEnv(options);
|
|||
|
|
|||
|
options.stdio = stdio(options);
|
|||
|
|
|||
|
if (process.platform === 'win32' && path__default['default'].basename(file, '.exe') === 'cmd') {
|
|||
|
// #116
|
|||
|
args.unshift('/q');
|
|||
|
}
|
|||
|
|
|||
|
return {file, args, options, parsed};
|
|||
|
};
|
|||
|
|
|||
|
const handleOutput = (options, value, error) => {
|
|||
|
if (typeof value !== 'string' && !Buffer.isBuffer(value)) {
|
|||
|
// When `execa.sync()` errors, we normalize it to '' to mimic `execa()`
|
|||
|
return error === undefined ? undefined : '';
|
|||
|
}
|
|||
|
|
|||
|
if (options.stripFinalNewline) {
|
|||
|
return stripFinalNewline(value);
|
|||
|
}
|
|||
|
|
|||
|
return value;
|
|||
|
};
|
|||
|
|
|||
|
const execa = (file, args, options) => {
|
|||
|
const parsed = handleArguments(file, args, options);
|
|||
|
const command = joinCommand(file, args);
|
|||
|
const escapedCommand = getEscapedCommand(file, args);
|
|||
|
|
|||
|
validateTimeout(parsed.options);
|
|||
|
|
|||
|
let spawned;
|
|||
|
try {
|
|||
|
spawned = childProcess__default['default'].spawn(parsed.file, parsed.args, parsed.options);
|
|||
|
} catch (error$1) {
|
|||
|
// Ensure the returned error is always both a promise and a child process
|
|||
|
const dummySpawned = new childProcess__default['default'].ChildProcess();
|
|||
|
const errorPromise = Promise.reject(error({
|
|||
|
error: error$1,
|
|||
|
stdout: '',
|
|||
|
stderr: '',
|
|||
|
all: '',
|
|||
|
command,
|
|||
|
escapedCommand,
|
|||
|
parsed,
|
|||
|
timedOut: false,
|
|||
|
isCanceled: false,
|
|||
|
killed: false
|
|||
|
}));
|
|||
|
return mergePromise(dummySpawned, errorPromise);
|
|||
|
}
|
|||
|
|
|||
|
const spawnedPromise = getSpawnedPromise(spawned);
|
|||
|
const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise);
|
|||
|
const processDone = setExitHandler(spawned, parsed.options, timedPromise);
|
|||
|
|
|||
|
const context = {isCanceled: false};
|
|||
|
|
|||
|
spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned));
|
|||
|
spawned.cancel = spawnedCancel.bind(null, spawned, context);
|
|||
|
|
|||
|
const handlePromise = async () => {
|
|||
|
const [{error: error$1, exitCode, signal, timedOut}, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone);
|
|||
|
const stdout = handleOutput(parsed.options, stdoutResult);
|
|||
|
const stderr = handleOutput(parsed.options, stderrResult);
|
|||
|
const all = handleOutput(parsed.options, allResult);
|
|||
|
|
|||
|
if (error$1 || exitCode !== 0 || signal !== null) {
|
|||
|
const returnedError = error({
|
|||
|
error: error$1,
|
|||
|
exitCode,
|
|||
|
signal,
|
|||
|
stdout,
|
|||
|
stderr,
|
|||
|
all,
|
|||
|
command,
|
|||
|
escapedCommand,
|
|||
|
parsed,
|
|||
|
timedOut,
|
|||
|
isCanceled: context.isCanceled,
|
|||
|
killed: spawned.killed
|
|||
|
});
|
|||
|
|
|||
|
if (!parsed.options.reject) {
|
|||
|
return returnedError;
|
|||
|
}
|
|||
|
|
|||
|
throw returnedError;
|
|||
|
}
|
|||
|
|
|||
|
return {
|
|||
|
command,
|
|||
|
escapedCommand,
|
|||
|
exitCode: 0,
|
|||
|
stdout,
|
|||
|
stderr,
|
|||
|
all,
|
|||
|
failed: false,
|
|||
|
timedOut: false,
|
|||
|
isCanceled: false,
|
|||
|
killed: false
|
|||
|
};
|
|||
|
};
|
|||
|
|
|||
|
const handlePromiseOnce = onetime_1(handlePromise);
|
|||
|
|
|||
|
handleInput(spawned, parsed.options.input);
|
|||
|
|
|||
|
spawned.all = makeAllStream(spawned, parsed.options);
|
|||
|
|
|||
|
return mergePromise(spawned, handlePromiseOnce);
|
|||
|
};
|
|||
|
|
|||
|
var execa_1 = execa;
|
|||
|
|
|||
|
var sync = (file, args, options) => {
|
|||
|
const parsed = handleArguments(file, args, options);
|
|||
|
const command = joinCommand(file, args);
|
|||
|
const escapedCommand = getEscapedCommand(file, args);
|
|||
|
|
|||
|
validateInputSync(parsed.options);
|
|||
|
|
|||
|
let result;
|
|||
|
try {
|
|||
|
result = childProcess__default['default'].spawnSync(parsed.file, parsed.args, parsed.options);
|
|||
|
} catch (error$1) {
|
|||
|
throw error({
|
|||
|
error: error$1,
|
|||
|
stdout: '',
|
|||
|
stderr: '',
|
|||
|
all: '',
|
|||
|
command,
|
|||
|
escapedCommand,
|
|||
|
parsed,
|
|||
|
timedOut: false,
|
|||
|
isCanceled: false,
|
|||
|
killed: false
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
const stdout = handleOutput(parsed.options, result.stdout, result.error);
|
|||
|
const stderr = handleOutput(parsed.options, result.stderr, result.error);
|
|||
|
|
|||
|
if (result.error || result.status !== 0 || result.signal !== null) {
|
|||
|
const error$1 = error({
|
|||
|
stdout,
|
|||
|
stderr,
|
|||
|
error: result.error,
|
|||
|
signal: result.signal,
|
|||
|
exitCode: result.status,
|
|||
|
command,
|
|||
|
escapedCommand,
|
|||
|
parsed,
|
|||
|
timedOut: result.error && result.error.code === 'ETIMEDOUT',
|
|||
|
isCanceled: false,
|
|||
|
killed: result.signal !== null
|
|||
|
});
|
|||
|
|
|||
|
if (!parsed.options.reject) {
|
|||
|
return error$1;
|
|||
|
}
|
|||
|
|
|||
|
throw error$1;
|
|||
|
}
|
|||
|
|
|||
|
return {
|
|||
|
command,
|
|||
|
escapedCommand,
|
|||
|
exitCode: 0,
|
|||
|
stdout,
|
|||
|
stderr,
|
|||
|
failed: false,
|
|||
|
timedOut: false,
|
|||
|
isCanceled: false,
|
|||
|
killed: false
|
|||
|
};
|
|||
|
};
|
|||
|
|
|||
|
var command = (command, options) => {
|
|||
|
const [file, ...args] = parseCommand(command);
|
|||
|
return execa(file, args, options);
|
|||
|
};
|
|||
|
|
|||
|
var commandSync = (command, options) => {
|
|||
|
const [file, ...args] = parseCommand(command);
|
|||
|
return execa.sync(file, args, options);
|
|||
|
};
|
|||
|
|
|||
|
var node = (scriptPath, args, options = {}) => {
|
|||
|
if (args && !Array.isArray(args) && typeof args === 'object') {
|
|||
|
options = args;
|
|||
|
args = [];
|
|||
|
}
|
|||
|
|
|||
|
const stdio$1 = stdio.node(options);
|
|||
|
const defaultExecArgv = process.execArgv.filter(arg => !arg.startsWith('--inspect'));
|
|||
|
|
|||
|
const {
|
|||
|
nodePath = process.execPath,
|
|||
|
nodeOptions = defaultExecArgv
|
|||
|
} = options;
|
|||
|
|
|||
|
return execa(
|
|||
|
nodePath,
|
|||
|
[
|
|||
|
...nodeOptions,
|
|||
|
scriptPath,
|
|||
|
...(Array.isArray(args) ? args : [])
|
|||
|
],
|
|||
|
{
|
|||
|
...options,
|
|||
|
stdin: undefined,
|
|||
|
stdout: undefined,
|
|||
|
stderr: undefined,
|
|||
|
stdio: stdio$1,
|
|||
|
shell: false
|
|||
|
}
|
|||
|
);
|
|||
|
};
|
|||
|
execa_1.sync = sync;
|
|||
|
execa_1.command = command;
|
|||
|
execa_1.commandSync = commandSync;
|
|||
|
execa_1.node = node;
|
|||
|
|
|||
|
function ansiRegex({onlyFirst = false} = {}) {
|
|||
|
const pattern = [
|
|||
|
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
|
|||
|
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
|
|||
|
].join('|');
|
|||
|
|
|||
|
return new RegExp(pattern, onlyFirst ? undefined : 'g');
|
|||
|
}
|
|||
|
|
|||
|
function stripAnsi(string) {
|
|||
|
if (typeof string !== 'string') {
|
|||
|
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|||
|
}
|
|||
|
|
|||
|
return string.replace(ansiRegex(), '');
|
|||
|
}
|
|||
|
|
|||
|
const detectDefaultShell = () => {
|
|||
|
const {env} = process__default['default'];
|
|||
|
|
|||
|
if (process__default['default'].platform === 'win32') {
|
|||
|
return env.COMSPEC || 'cmd.exe';
|
|||
|
}
|
|||
|
|
|||
|
try {
|
|||
|
const {shell} = node_os.userInfo();
|
|||
|
if (shell) {
|
|||
|
return shell;
|
|||
|
}
|
|||
|
} catch {}
|
|||
|
|
|||
|
if (process__default['default'].platform === 'darwin') {
|
|||
|
return env.SHELL || '/bin/zsh';
|
|||
|
}
|
|||
|
|
|||
|
return env.SHELL || '/bin/sh';
|
|||
|
};
|
|||
|
|
|||
|
// Stores default shell when imported.
|
|||
|
const defaultShell = detectDefaultShell();
|
|||
|
|
|||
|
const args = [
|
|||
|
'-ilc',
|
|||
|
'echo -n "_SHELL_ENV_DELIMITER_"; env; echo -n "_SHELL_ENV_DELIMITER_"; exit',
|
|||
|
];
|
|||
|
|
|||
|
const env = {
|
|||
|
// Disables Oh My Zsh auto-update thing that can block the process.
|
|||
|
DISABLE_AUTO_UPDATE: 'true',
|
|||
|
};
|
|||
|
|
|||
|
const parseEnv = env => {
|
|||
|
env = env.split('_SHELL_ENV_DELIMITER_')[1];
|
|||
|
const returnValue = {};
|
|||
|
|
|||
|
for (const line of stripAnsi(env).split('\n').filter(line => Boolean(line))) {
|
|||
|
const [key, ...values] = line.split('=');
|
|||
|
returnValue[key] = values.join('=');
|
|||
|
}
|
|||
|
|
|||
|
return returnValue;
|
|||
|
};
|
|||
|
|
|||
|
function shellEnvSync(shell) {
|
|||
|
if (process__default['default'].platform === 'win32') {
|
|||
|
return process__default['default'].env;
|
|||
|
}
|
|||
|
|
|||
|
try {
|
|||
|
const {stdout} = execa_1.sync(shell || defaultShell, args, {env});
|
|||
|
return parseEnv(stdout);
|
|||
|
} catch (error) {
|
|||
|
if (shell) {
|
|||
|
throw error;
|
|||
|
} else {
|
|||
|
return process__default['default'].env;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
function shellPathSync() {
|
|||
|
const {PATH} = shellEnvSync();
|
|||
|
return PATH;
|
|||
|
}
|
|||
|
|
|||
|
function fixPath() {
|
|||
|
if (process__default['default'].platform === 'win32') {
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
process__default['default'].env.PATH = shellPathSync() || [
|
|||
|
'./node_modules/.bin',
|
|||
|
'/.nodebrew/current/bin',
|
|||
|
'/usr/local/bin',
|
|||
|
process__default['default'].env.PATH,
|
|||
|
].join(':');
|
|||
|
}
|
|||
|
|
|||
|
function isAnImage(ext) {
|
|||
|
return [".png", ".jpg", ".jpeg", ".bmp", ".gif", ".svg", ".tiff"].includes(ext.toLowerCase());
|
|||
|
}
|
|||
|
function isAssetTypeAnImage(path$1) {
|
|||
|
return ([".png", ".jpg", ".jpeg", ".bmp", ".gif", ".svg", ".tiff"].indexOf(path.extname(path$1).toLowerCase()) !== -1);
|
|||
|
}
|
|||
|
function getOS() {
|
|||
|
var appVersion = navigator.appVersion;
|
|||
|
if (appVersion.indexOf("Win") !== -1) {
|
|||
|
return "Windows";
|
|||
|
}
|
|||
|
else if (appVersion.indexOf("Mac") !== -1) {
|
|||
|
return "MacOS";
|
|||
|
}
|
|||
|
else if (appVersion.indexOf("X11") !== -1) {
|
|||
|
return "Linux";
|
|||
|
}
|
|||
|
else {
|
|||
|
return "Unknown OS";
|
|||
|
}
|
|||
|
}
|
|||
|
function streamToString(stream) {
|
|||
|
var stream_1, stream_1_1;
|
|||
|
var e_1, _a;
|
|||
|
return __awaiter(this, void 0, void 0, function () {
|
|||
|
var chunks, chunk, e_1_1;
|
|||
|
return __generator(this, function (_b) {
|
|||
|
switch (_b.label) {
|
|||
|
case 0:
|
|||
|
chunks = [];
|
|||
|
_b.label = 1;
|
|||
|
case 1:
|
|||
|
_b.trys.push([1, 6, 7, 12]);
|
|||
|
stream_1 = __asyncValues(stream);
|
|||
|
_b.label = 2;
|
|||
|
case 2: return [4 /*yield*/, stream_1.next()];
|
|||
|
case 3:
|
|||
|
if (!(stream_1_1 = _b.sent(), !stream_1_1.done)) return [3 /*break*/, 5];
|
|||
|
chunk = stream_1_1.value;
|
|||
|
chunks.push(Buffer.from(chunk));
|
|||
|
_b.label = 4;
|
|||
|
case 4: return [3 /*break*/, 2];
|
|||
|
case 5: return [3 /*break*/, 12];
|
|||
|
case 6:
|
|||
|
e_1_1 = _b.sent();
|
|||
|
e_1 = { error: e_1_1 };
|
|||
|
return [3 /*break*/, 12];
|
|||
|
case 7:
|
|||
|
_b.trys.push([7, , 10, 11]);
|
|||
|
if (!(stream_1_1 && !stream_1_1.done && (_a = stream_1.return))) return [3 /*break*/, 9];
|
|||
|
return [4 /*yield*/, _a.call(stream_1)];
|
|||
|
case 8:
|
|||
|
_b.sent();
|
|||
|
_b.label = 9;
|
|||
|
case 9: return [3 /*break*/, 11];
|
|||
|
case 10:
|
|||
|
if (e_1) throw e_1.error;
|
|||
|
return [7 /*endfinally*/];
|
|||
|
case 11: return [7 /*endfinally*/];
|
|||
|
case 12: return [2 /*return*/, Buffer.concat(chunks).toString("utf-8")];
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
}
|
|||
|
function getUrlAsset(url) {
|
|||
|
return (url = url.substr(1 + url.lastIndexOf("/")).split("?")[0]).split("#")[0];
|
|||
|
}
|
|||
|
function getLastImage(list) {
|
|||
|
var reversedList = list.reverse();
|
|||
|
var lastImage;
|
|||
|
reversedList.forEach(function (item) {
|
|||
|
if (item && item.startsWith("http")) {
|
|||
|
lastImage = item;
|
|||
|
return item;
|
|||
|
}
|
|||
|
});
|
|||
|
return lastImage;
|
|||
|
}
|
|||
|
function arrayToObject(arr, key) {
|
|||
|
var obj = {};
|
|||
|
arr.forEach(function (element) {
|
|||
|
obj[element[key]] = element;
|
|||
|
});
|
|||
|
return obj;
|
|||
|
}
|
|||
|
|
|||
|
var PicGoUploader = /** @class */ (function () {
|
|||
|
function PicGoUploader(settings) {
|
|||
|
this.settings = settings;
|
|||
|
}
|
|||
|
PicGoUploader.prototype.uploadFiles = function (fileList) {
|
|||
|
return __awaiter(this, void 0, void 0, function () {
|
|||
|
var response, data;
|
|||
|
return __generator(this, function (_a) {
|
|||
|
switch (_a.label) {
|
|||
|
case 0: return [4 /*yield*/, obsidian.requestUrl({
|
|||
|
url: this.settings.uploadServer,
|
|||
|
method: "POST",
|
|||
|
headers: { "Content-Type": "application/json" },
|
|||
|
body: JSON.stringify({ list: fileList }),
|
|||
|
})];
|
|||
|
case 1:
|
|||
|
response = _a.sent();
|
|||
|
data = response.json;
|
|||
|
return [2 /*return*/, data];
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
};
|
|||
|
PicGoUploader.prototype.uploadFileByClipboard = function () {
|
|||
|
return __awaiter(this, void 0, void 0, function () {
|
|||
|
var res, data;
|
|||
|
return __generator(this, function (_a) {
|
|||
|
switch (_a.label) {
|
|||
|
case 0: return [4 /*yield*/, obsidian.requestUrl({
|
|||
|
url: this.settings.uploadServer,
|
|||
|
method: "POST",
|
|||
|
})];
|
|||
|
case 1:
|
|||
|
res = _a.sent();
|
|||
|
data = res.json;
|
|||
|
if (res.status !== 200) {
|
|||
|
({ response: data, body: data.msg });
|
|||
|
return [2 /*return*/, {
|
|||
|
code: -1,
|
|||
|
msg: data.msg,
|
|||
|
data: "",
|
|||
|
}];
|
|||
|
}
|
|||
|
else {
|
|||
|
return [2 /*return*/, {
|
|||
|
code: 0,
|
|||
|
msg: "success",
|
|||
|
data: typeof data.result == "string" ? data.result : data.result[0],
|
|||
|
}];
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
};
|
|||
|
return PicGoUploader;
|
|||
|
}());
|
|||
|
var PicGoCoreUploader = /** @class */ (function () {
|
|||
|
function PicGoCoreUploader(settings) {
|
|||
|
this.settings = settings;
|
|||
|
}
|
|||
|
PicGoCoreUploader.prototype.uploadFiles = function (fileList) {
|
|||
|
return __awaiter(this, void 0, void 0, function () {
|
|||
|
var length, cli, command, res, splitList, splitListLength, data;
|
|||
|
return __generator(this, function (_a) {
|
|||
|
switch (_a.label) {
|
|||
|
case 0:
|
|||
|
length = fileList.length;
|
|||
|
cli = this.settings.picgoCorePath || "picgo";
|
|||
|
command = cli + " upload " + fileList
|
|||
|
.map(function (item) { return "\"" + item + "\""; })
|
|||
|
.join(" ");
|
|||
|
return [4 /*yield*/, this.exec(command)];
|
|||
|
case 1:
|
|||
|
res = _a.sent();
|
|||
|
splitList = res.split("\n");
|
|||
|
splitListLength = splitList.length;
|
|||
|
console.log(splitListLength);
|
|||
|
data = splitList.splice(splitListLength - 1 - length, length);
|
|||
|
if (res.includes("PicGo ERROR")) {
|
|||
|
return [2 /*return*/, {
|
|||
|
success: false,
|
|||
|
msg: "失败",
|
|||
|
}];
|
|||
|
}
|
|||
|
else {
|
|||
|
return [2 /*return*/, {
|
|||
|
success: true,
|
|||
|
result: data,
|
|||
|
}];
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
};
|
|||
|
// PicGo-Core 上传处理
|
|||
|
PicGoCoreUploader.prototype.uploadFileByClipboard = function () {
|
|||
|
return __awaiter(this, void 0, void 0, function () {
|
|||
|
var res, splitList, lastImage;
|
|||
|
return __generator(this, function (_a) {
|
|||
|
switch (_a.label) {
|
|||
|
case 0: return [4 /*yield*/, this.uploadByClip()];
|
|||
|
case 1:
|
|||
|
res = _a.sent();
|
|||
|
splitList = res.split("\n");
|
|||
|
lastImage = getLastImage(splitList);
|
|||
|
if (lastImage) {
|
|||
|
return [2 /*return*/, {
|
|||
|
code: 0,
|
|||
|
msg: "success",
|
|||
|
data: lastImage,
|
|||
|
}];
|
|||
|
}
|
|||
|
else {
|
|||
|
new obsidian.Notice("\"Please check PicGo-Core config\"\n" + res);
|
|||
|
return [2 /*return*/, {
|
|||
|
code: -1,
|
|||
|
msg: "\"Please check PicGo-Core config\"\n" + res,
|
|||
|
data: "",
|
|||
|
}];
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
};
|
|||
|
// PicGo-Core的剪切上传反馈
|
|||
|
PicGoCoreUploader.prototype.uploadByClip = function () {
|
|||
|
return __awaiter(this, void 0, void 0, function () {
|
|||
|
var command, res;
|
|||
|
return __generator(this, function (_a) {
|
|||
|
switch (_a.label) {
|
|||
|
case 0:
|
|||
|
if (this.settings.picgoCorePath) {
|
|||
|
command = this.settings.picgoCorePath + " upload";
|
|||
|
}
|
|||
|
else {
|
|||
|
command = "picgo upload";
|
|||
|
}
|
|||
|
return [4 /*yield*/, this.exec(command)];
|
|||
|
case 1:
|
|||
|
res = _a.sent();
|
|||
|
return [2 /*return*/, res];
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
};
|
|||
|
PicGoCoreUploader.prototype.exec = function (command) {
|
|||
|
return __awaiter(this, void 0, void 0, function () {
|
|||
|
var stdout, res;
|
|||
|
return __generator(this, function (_a) {
|
|||
|
switch (_a.label) {
|
|||
|
case 0: return [4 /*yield*/, childProcess.exec(command)];
|
|||
|
case 1:
|
|||
|
stdout = (_a.sent()).stdout;
|
|||
|
return [4 /*yield*/, streamToString(stdout)];
|
|||
|
case 2:
|
|||
|
res = _a.sent();
|
|||
|
return [2 /*return*/, res];
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
};
|
|||
|
return PicGoCoreUploader;
|
|||
|
}());
|
|||
|
|
|||
|
var REGEX_FILE = /\!\[(.*?)\]\((.*?)\)/g;
|
|||
|
var REGEX_WIKI_FILE = /\!\[\[(.*?)(\s\|.*?)?\]\]/g;
|
|||
|
var Helper = /** @class */ (function () {
|
|||
|
function Helper(app) {
|
|||
|
this.app = app;
|
|||
|
}
|
|||
|
Helper.prototype.getFrontmatterValue = function (key, defaultValue) {
|
|||
|
if (defaultValue === void 0) { defaultValue = undefined; }
|
|||
|
var file = this.app.workspace.getActiveFile();
|
|||
|
if (!file) {
|
|||
|
return undefined;
|
|||
|
}
|
|||
|
var path = file.path;
|
|||
|
var cache = this.app.metadataCache.getCache(path);
|
|||
|
var value = defaultValue;
|
|||
|
if ((cache === null || cache === void 0 ? void 0 : cache.frontmatter) && cache.frontmatter.hasOwnProperty(key)) {
|
|||
|
value = cache.frontmatter[key];
|
|||
|
}
|
|||
|
return value;
|
|||
|
};
|
|||
|
Helper.prototype.getEditor = function () {
|
|||
|
var mdView = this.app.workspace.getActiveViewOfType(obsidian.MarkdownView);
|
|||
|
if (mdView) {
|
|||
|
return mdView.editor;
|
|||
|
}
|
|||
|
else {
|
|||
|
return null;
|
|||
|
}
|
|||
|
};
|
|||
|
Helper.prototype.getValue = function () {
|
|||
|
var editor = this.getEditor();
|
|||
|
return editor.getValue();
|
|||
|
};
|
|||
|
Helper.prototype.setValue = function (value) {
|
|||
|
var editor = this.getEditor();
|
|||
|
var _a = editor.getScrollInfo(), left = _a.left, top = _a.top;
|
|||
|
var position = editor.getCursor();
|
|||
|
editor.setValue(value);
|
|||
|
editor.scrollTo(left, top);
|
|||
|
editor.setCursor(position);
|
|||
|
};
|
|||
|
// get all file urls, include local and internet
|
|||
|
Helper.prototype.getAllFiles = function () {
|
|||
|
var editor = this.getEditor();
|
|||
|
var value = editor.getValue();
|
|||
|
return this.getImageLink(value);
|
|||
|
};
|
|||
|
Helper.prototype.getImageLink = function (value) {
|
|||
|
var e_1, _a, e_2, _b;
|
|||
|
var matches = value.matchAll(REGEX_FILE);
|
|||
|
var WikiMatches = value.matchAll(REGEX_WIKI_FILE);
|
|||
|
var fileArray = [];
|
|||
|
try {
|
|||
|
for (var matches_1 = __values(matches), matches_1_1 = matches_1.next(); !matches_1_1.done; matches_1_1 = matches_1.next()) {
|
|||
|
var match = matches_1_1.value;
|
|||
|
var name_1 = match[1];
|
|||
|
var path$1 = match[2];
|
|||
|
var source = match[0];
|
|||
|
fileArray.push({
|
|||
|
path: path$1,
|
|||
|
name: name_1,
|
|||
|
source: source,
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|||
|
finally {
|
|||
|
try {
|
|||
|
if (matches_1_1 && !matches_1_1.done && (_a = matches_1.return)) _a.call(matches_1);
|
|||
|
}
|
|||
|
finally { if (e_1) throw e_1.error; }
|
|||
|
}
|
|||
|
try {
|
|||
|
for (var WikiMatches_1 = __values(WikiMatches), WikiMatches_1_1 = WikiMatches_1.next(); !WikiMatches_1_1.done; WikiMatches_1_1 = WikiMatches_1.next()) {
|
|||
|
var match = WikiMatches_1_1.value;
|
|||
|
var name_2 = path.parse(match[1]).name;
|
|||
|
var path$1 = match[1];
|
|||
|
var source = match[0];
|
|||
|
fileArray.push({
|
|||
|
path: path$1,
|
|||
|
name: name_2,
|
|||
|
source: source,
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|||
|
finally {
|
|||
|
try {
|
|||
|
if (WikiMatches_1_1 && !WikiMatches_1_1.done && (_b = WikiMatches_1.return)) _b.call(WikiMatches_1);
|
|||
|
}
|
|||
|
finally { if (e_2) throw e_2.error; }
|
|||
|
}
|
|||
|
return fileArray;
|
|||
|
};
|
|||
|
Helper.prototype.hasBlackDomain = function (src, blackDomains) {
|
|||
|
if (blackDomains.trim() === "") {
|
|||
|
return false;
|
|||
|
}
|
|||
|
var blackDomainList = blackDomains.split(",");
|
|||
|
var url = new URL(src);
|
|||
|
var domain = url.hostname;
|
|||
|
return blackDomainList.some(function (blackDomain) { return domain.includes(blackDomain); });
|
|||
|
};
|
|||
|
return Helper;
|
|||
|
}());
|
|||
|
|
|||
|
// العربية
|
|||
|
var ar = {};
|
|||
|
|
|||
|
// čeština
|
|||
|
var cz = {};
|
|||
|
|
|||
|
// Dansk
|
|||
|
var da = {};
|
|||
|
|
|||
|
// Deutsch
|
|||
|
var de = {};
|
|||
|
|
|||
|
// English
|
|||
|
var en = {
|
|||
|
// setting.ts
|
|||
|
"Plugin Settings": "Plugin Settings",
|
|||
|
"Auto pasted upload": "Auto pasted upload",
|
|||
|
"If you set this value true, when you paste image, it will be auto uploaded(you should set the picGo server rightly)": "If you set this value true, when you paste image, it will be auto uploaded(you should set the picGo server rightly)",
|
|||
|
"Default uploader": "Default uploader",
|
|||
|
"PicGo server": "PicGo server",
|
|||
|
"Please input PicGo server": "Please input PicGo server",
|
|||
|
"PicGo-Core path": "PicGo-Core path",
|
|||
|
"Please input PicGo-Core path, default using environment variables": "Please input PicGo-Core path, default using environment variables",
|
|||
|
"Work on network": "Work on network",
|
|||
|
"Work on network Description": "Allow upload network image by 'Upload all' command.\n Or when you paste, md standard image link in your clipboard will be auto upload.",
|
|||
|
fixPath: "fixPath",
|
|||
|
fixPathWarning: "This option is used to fix PicGo-core upload failures on Linux and Mac. It modifies the PATH variable within Obsidian. If Obsidian encounters any bugs, turn off the option, try again! ",
|
|||
|
"Upload when clipboard has image and text together": "Upload when clipboard has image and text together",
|
|||
|
"When you copy, some application like Excel will image and text to clipboard, you can upload or not.": "When you copy, some application like Excel will image and text to clipboard, you can upload or not.",
|
|||
|
"Network Domain Black List": "Network Domain Black List",
|
|||
|
"Network Domain Black List Description": "Image in the domain list will not be upload,use comma separated",
|
|||
|
};
|
|||
|
|
|||
|
// British English
|
|||
|
var enGB = {};
|
|||
|
|
|||
|
// Español
|
|||
|
var es = {};
|
|||
|
|
|||
|
// français
|
|||
|
var fr = {};
|
|||
|
|
|||
|
// हिन्दी
|
|||
|
var hi = {};
|
|||
|
|
|||
|
// Bahasa Indonesia
|
|||
|
var id = {};
|
|||
|
|
|||
|
// Italiano
|
|||
|
var it = {};
|
|||
|
|
|||
|
// 日本語
|
|||
|
var ja = {};
|
|||
|
|
|||
|
// 한국어
|
|||
|
var ko = {};
|
|||
|
|
|||
|
// Nederlands
|
|||
|
var nl = {};
|
|||
|
|
|||
|
// Norsk
|
|||
|
var no = {};
|
|||
|
|
|||
|
// język polski
|
|||
|
var pl = {};
|
|||
|
|
|||
|
// Português
|
|||
|
var pt = {};
|
|||
|
|
|||
|
// Português do Brasil
|
|||
|
// Brazilian Portuguese
|
|||
|
var ptBR = {};
|
|||
|
|
|||
|
// Română
|
|||
|
var ro = {};
|
|||
|
|
|||
|
// русский
|
|||
|
var ru = {};
|
|||
|
|
|||
|
// Türkçe
|
|||
|
var tr = {};
|
|||
|
|
|||
|
// 简体中文
|
|||
|
var zhCN = {
|
|||
|
// setting.ts
|
|||
|
"Plugin Settings": "插件设置",
|
|||
|
"Auto pasted upload": "剪切板自动上传",
|
|||
|
"If you set this value true, when you paste image, it will be auto uploaded(you should set the picGo server rightly)": "启用该选项后,黏贴图片时会自动上传(你需要正确配置picgo)",
|
|||
|
"Default uploader": "默认上传器",
|
|||
|
"PicGo server": "PicGo server",
|
|||
|
"Please input PicGo server": "请输入 PicGo server",
|
|||
|
"PicGo-Core path": "PicGo-Core 路径",
|
|||
|
"Please input PicGo-Core path, default using environment variables": "请输入 PicGo-Core path,默认使用环境变量",
|
|||
|
"Work on network": "应用网络图片",
|
|||
|
"Work on network Description": "当你上传所有图片时,也会上传网络图片。以及当你进行黏贴时,剪切板中的标准 md 图片会被上传",
|
|||
|
fixPath: "修正PATH变量",
|
|||
|
fixPathWarning: "此选项用于修复Linux和Mac上 PicGo-Core 上传失败的问题。它会修改 Obsidian 内的 PATH 变量,如果 Obsidian 遇到任何BUG,先关闭这个选项试试!",
|
|||
|
"Upload when clipboard has image and text together": "当剪切板同时拥有文本和图片剪切板数据时是否上传图片",
|
|||
|
"When you copy, some application like Excel will image and text to clipboard, you can upload or not.": "当你复制时,某些应用例如 Excel 会在剪切板同时文本和图像数据,确认是否上传。",
|
|||
|
"Network Domain Black List": "网络图片域名黑名单",
|
|||
|
"Network Domain Black List Description": "黑名单域名中的图片将不会被上传,用英文逗号分割",
|
|||
|
};
|
|||
|
|
|||
|
// 繁體中文
|
|||
|
var zhTW = {};
|
|||
|
|
|||
|
var localeMap = {
|
|||
|
ar: ar,
|
|||
|
cs: cz,
|
|||
|
da: da,
|
|||
|
de: de,
|
|||
|
en: en,
|
|||
|
'en-gb': enGB,
|
|||
|
es: es,
|
|||
|
fr: fr,
|
|||
|
hi: hi,
|
|||
|
id: id,
|
|||
|
it: it,
|
|||
|
ja: ja,
|
|||
|
ko: ko,
|
|||
|
nl: nl,
|
|||
|
nn: no,
|
|||
|
pl: pl,
|
|||
|
pt: pt,
|
|||
|
'pt-br': ptBR,
|
|||
|
ro: ro,
|
|||
|
ru: ru,
|
|||
|
tr: tr,
|
|||
|
'zh-cn': zhCN,
|
|||
|
'zh-tw': zhTW,
|
|||
|
};
|
|||
|
var locale = localeMap[obsidian.moment.locale()];
|
|||
|
function t(str) {
|
|||
|
return (locale && locale[str]) || en[str];
|
|||
|
}
|
|||
|
|
|||
|
var DEFAULT_SETTINGS = {
|
|||
|
uploadByClipSwitch: true,
|
|||
|
uploader: "PicGo",
|
|||
|
uploadServer: "http://127.0.0.1:36677/upload",
|
|||
|
picgoCorePath: "",
|
|||
|
workOnNetWork: false,
|
|||
|
fixPath: false,
|
|||
|
applyImage: true,
|
|||
|
newWorkBlackDomains: "",
|
|||
|
};
|
|||
|
var SettingTab = /** @class */ (function (_super) {
|
|||
|
__extends(SettingTab, _super);
|
|||
|
function SettingTab(app, plugin) {
|
|||
|
var _this = _super.call(this, app, plugin) || this;
|
|||
|
_this.plugin = plugin;
|
|||
|
return _this;
|
|||
|
}
|
|||
|
SettingTab.prototype.display = function () {
|
|||
|
var _this = this;
|
|||
|
var containerEl = this.containerEl;
|
|||
|
var os = getOS();
|
|||
|
containerEl.empty();
|
|||
|
containerEl.createEl("h2", { text: t("Plugin Settings") });
|
|||
|
new obsidian.Setting(containerEl)
|
|||
|
.setName(t("Auto pasted upload"))
|
|||
|
.setDesc(t("If you set this value true, when you paste image, it will be auto uploaded(you should set the picGo server rightly)"))
|
|||
|
.addToggle(function (toggle) {
|
|||
|
return toggle
|
|||
|
.setValue(_this.plugin.settings.uploadByClipSwitch)
|
|||
|
.onChange(function (value) { return __awaiter(_this, void 0, void 0, function () {
|
|||
|
return __generator(this, function (_a) {
|
|||
|
switch (_a.label) {
|
|||
|
case 0:
|
|||
|
this.plugin.settings.uploadByClipSwitch = value;
|
|||
|
return [4 /*yield*/, this.plugin.saveSettings()];
|
|||
|
case 1:
|
|||
|
_a.sent();
|
|||
|
return [2 /*return*/];
|
|||
|
}
|
|||
|
});
|
|||
|
}); });
|
|||
|
});
|
|||
|
new obsidian.Setting(containerEl)
|
|||
|
.setName(t("Default uploader"))
|
|||
|
.setDesc(t("Default uploader"))
|
|||
|
.addDropdown(function (cb) {
|
|||
|
return cb
|
|||
|
.addOption("PicGo", "PicGo(app)")
|
|||
|
.addOption("PicGo-Core", "PicGo-Core")
|
|||
|
.setValue(_this.plugin.settings.uploader)
|
|||
|
.onChange(function (value) { return __awaiter(_this, void 0, void 0, function () {
|
|||
|
return __generator(this, function (_a) {
|
|||
|
switch (_a.label) {
|
|||
|
case 0:
|
|||
|
this.plugin.settings.uploader = value;
|
|||
|
this.display();
|
|||
|
return [4 /*yield*/, this.plugin.saveSettings()];
|
|||
|
case 1:
|
|||
|
_a.sent();
|
|||
|
return [2 /*return*/];
|
|||
|
}
|
|||
|
});
|
|||
|
}); });
|
|||
|
});
|
|||
|
if (this.plugin.settings.uploader === "PicGo") {
|
|||
|
new obsidian.Setting(containerEl)
|
|||
|
.setName(t("PicGo server"))
|
|||
|
.setDesc(t("PicGo server"))
|
|||
|
.addText(function (text) {
|
|||
|
return text
|
|||
|
.setPlaceholder(t("Please input PicGo server"))
|
|||
|
.setValue(_this.plugin.settings.uploadServer)
|
|||
|
.onChange(function (key) { return __awaiter(_this, void 0, void 0, function () {
|
|||
|
return __generator(this, function (_a) {
|
|||
|
switch (_a.label) {
|
|||
|
case 0:
|
|||
|
this.plugin.settings.uploadServer = key;
|
|||
|
return [4 /*yield*/, this.plugin.saveSettings()];
|
|||
|
case 1:
|
|||
|
_a.sent();
|
|||
|
return [2 /*return*/];
|
|||
|
}
|
|||
|
});
|
|||
|
}); });
|
|||
|
});
|
|||
|
}
|
|||
|
if (this.plugin.settings.uploader === "PicGo-Core") {
|
|||
|
new obsidian.Setting(containerEl)
|
|||
|
.setName(t("PicGo-Core path"))
|
|||
|
.setDesc(t("Please input PicGo-Core path, default using environment variables"))
|
|||
|
.addText(function (text) {
|
|||
|
return text
|
|||
|
.setPlaceholder("")
|
|||
|
.setValue(_this.plugin.settings.picgoCorePath)
|
|||
|
.onChange(function (value) { return __awaiter(_this, void 0, void 0, function () {
|
|||
|
return __generator(this, function (_a) {
|
|||
|
switch (_a.label) {
|
|||
|
case 0:
|
|||
|
this.plugin.settings.picgoCorePath = value;
|
|||
|
return [4 /*yield*/, this.plugin.saveSettings()];
|
|||
|
case 1:
|
|||
|
_a.sent();
|
|||
|
return [2 /*return*/];
|
|||
|
}
|
|||
|
});
|
|||
|
}); });
|
|||
|
});
|
|||
|
if (os !== "Windows") {
|
|||
|
new obsidian.Setting(containerEl)
|
|||
|
.setName(t("fixPath"))
|
|||
|
.setDesc(t("fixPathWarning"))
|
|||
|
.addToggle(function (toggle) {
|
|||
|
return toggle
|
|||
|
.setValue(_this.plugin.settings.fixPath)
|
|||
|
.onChange(function (value) { return __awaiter(_this, void 0, void 0, function () {
|
|||
|
return __generator(this, function (_a) {
|
|||
|
switch (_a.label) {
|
|||
|
case 0:
|
|||
|
this.plugin.settings.fixPath = value;
|
|||
|
return [4 /*yield*/, this.plugin.saveSettings()];
|
|||
|
case 1:
|
|||
|
_a.sent();
|
|||
|
return [2 /*return*/];
|
|||
|
}
|
|||
|
});
|
|||
|
}); });
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
new obsidian.Setting(containerEl)
|
|||
|
.setName(t("Work on network"))
|
|||
|
.setDesc(t("Work on network Description"))
|
|||
|
.addToggle(function (toggle) {
|
|||
|
return toggle
|
|||
|
.setValue(_this.plugin.settings.workOnNetWork)
|
|||
|
.onChange(function (value) { return __awaiter(_this, void 0, void 0, function () {
|
|||
|
return __generator(this, function (_a) {
|
|||
|
switch (_a.label) {
|
|||
|
case 0:
|
|||
|
this.plugin.settings.workOnNetWork = value;
|
|||
|
this.display();
|
|||
|
return [4 /*yield*/, this.plugin.saveSettings()];
|
|||
|
case 1:
|
|||
|
_a.sent();
|
|||
|
return [2 /*return*/];
|
|||
|
}
|
|||
|
});
|
|||
|
}); });
|
|||
|
});
|
|||
|
new obsidian.Setting(containerEl)
|
|||
|
.setName(t("Network Domain Black List"))
|
|||
|
.setDesc(t("Network Domain Black List Description"))
|
|||
|
.addTextArea(function (textArea) {
|
|||
|
return textArea
|
|||
|
.setValue(_this.plugin.settings.newWorkBlackDomains)
|
|||
|
.onChange(function (value) { return __awaiter(_this, void 0, void 0, function () {
|
|||
|
return __generator(this, function (_a) {
|
|||
|
switch (_a.label) {
|
|||
|
case 0:
|
|||
|
this.plugin.settings.newWorkBlackDomains = value;
|
|||
|
return [4 /*yield*/, this.plugin.saveSettings()];
|
|||
|
case 1:
|
|||
|
_a.sent();
|
|||
|
return [2 /*return*/];
|
|||
|
}
|
|||
|
});
|
|||
|
}); });
|
|||
|
});
|
|||
|
new obsidian.Setting(containerEl)
|
|||
|
.setName(t("Upload when clipboard has image and text together"))
|
|||
|
.setDesc(t("When you copy, some application like Excel will image and text to clipboard, you can upload or not."))
|
|||
|
.addToggle(function (toggle) {
|
|||
|
return toggle
|
|||
|
.setValue(_this.plugin.settings.applyImage)
|
|||
|
.onChange(function (value) { return __awaiter(_this, void 0, void 0, function () {
|
|||
|
return __generator(this, function (_a) {
|
|||
|
switch (_a.label) {
|
|||
|
case 0:
|
|||
|
this.plugin.settings.applyImage = value;
|
|||
|
this.display();
|
|||
|
return [4 /*yield*/, this.plugin.saveSettings()];
|
|||
|
case 1:
|
|||
|
_a.sent();
|
|||
|
return [2 /*return*/];
|
|||
|
}
|
|||
|
});
|
|||
|
}); });
|
|||
|
});
|
|||
|
};
|
|||
|
return SettingTab;
|
|||
|
}(obsidian.PluginSettingTab));
|
|||
|
|
|||
|
var imageAutoUploadPlugin = /** @class */ (function (_super) {
|
|||
|
__extends(imageAutoUploadPlugin, _super);
|
|||
|
function imageAutoUploadPlugin() {
|
|||
|
return _super !== null && _super.apply(this, arguments) || this;
|
|||
|
}
|
|||
|
imageAutoUploadPlugin.prototype.loadSettings = function () {
|
|||
|
return __awaiter(this, void 0, void 0, function () {
|
|||
|
var _a, _b, _c, _d;
|
|||
|
return __generator(this, function (_e) {
|
|||
|
switch (_e.label) {
|
|||
|
case 0:
|
|||
|
_a = this;
|
|||
|
_c = (_b = Object).assign;
|
|||
|
_d = [DEFAULT_SETTINGS];
|
|||
|
return [4 /*yield*/, this.loadData()];
|
|||
|
case 1:
|
|||
|
_a.settings = _c.apply(_b, _d.concat([_e.sent()]));
|
|||
|
return [2 /*return*/];
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
};
|
|||
|
imageAutoUploadPlugin.prototype.saveSettings = function () {
|
|||
|
return __awaiter(this, void 0, void 0, function () {
|
|||
|
return __generator(this, function (_a) {
|
|||
|
switch (_a.label) {
|
|||
|
case 0: return [4 /*yield*/, this.saveData(this.settings)];
|
|||
|
case 1:
|
|||
|
_a.sent();
|
|||
|
return [2 /*return*/];
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
};
|
|||
|
imageAutoUploadPlugin.prototype.onunload = function () { };
|
|||
|
imageAutoUploadPlugin.prototype.onload = function () {
|
|||
|
return __awaiter(this, void 0, void 0, function () {
|
|||
|
var _this = this;
|
|||
|
return __generator(this, function (_a) {
|
|||
|
switch (_a.label) {
|
|||
|
case 0: return [4 /*yield*/, this.loadSettings()];
|
|||
|
case 1:
|
|||
|
_a.sent();
|
|||
|
this.helper = new Helper(this.app);
|
|||
|
this.picGoUploader = new PicGoUploader(this.settings);
|
|||
|
this.picGoCoreUploader = new PicGoCoreUploader(this.settings);
|
|||
|
if (this.settings.uploader === "PicGo") {
|
|||
|
this.uploader = this.picGoUploader;
|
|||
|
}
|
|||
|
else if (this.settings.uploader === "PicGo-Core") {
|
|||
|
this.uploader = this.picGoCoreUploader;
|
|||
|
if (this.settings.fixPath) {
|
|||
|
fixPath();
|
|||
|
}
|
|||
|
}
|
|||
|
else {
|
|||
|
new obsidian.Notice("unknown uploader");
|
|||
|
}
|
|||
|
obsidian.addIcon("upload", "<svg t=\"1636630783429\" class=\"icon\" viewBox=\"0 0 100 100\" version=\"1.1\" p-id=\"4649\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M 71.638 35.336 L 79.408 35.336 C 83.7 35.336 87.178 38.662 87.178 42.765 L 87.178 84.864 C 87.178 88.969 83.7 92.295 79.408 92.295 L 17.249 92.295 C 12.957 92.295 9.479 88.969 9.479 84.864 L 9.479 42.765 C 9.479 38.662 12.957 35.336 17.249 35.336 L 25.019 35.336 L 25.019 42.765 L 17.249 42.765 L 17.249 84.864 L 79.408 84.864 L 79.408 42.765 L 71.638 42.765 L 71.638 35.336 Z M 49.014 10.179 L 67.326 27.688 L 61.835 32.942 L 52.849 24.352 L 52.849 59.731 L 45.078 59.731 L 45.078 24.455 L 36.194 32.947 L 30.702 27.692 L 49.012 10.181 Z\" p-id=\"4650\" fill=\"#8a8a8a\"></path>\n </svg>");
|
|||
|
this.addSettingTab(new SettingTab(this.app, this));
|
|||
|
this.addCommand({
|
|||
|
id: "Upload all images",
|
|||
|
name: "Upload all images",
|
|||
|
checkCallback: function (checking) {
|
|||
|
var leaf = _this.app.workspace.activeLeaf;
|
|||
|
if (leaf) {
|
|||
|
if (!checking) {
|
|||
|
_this.uploadAllFile();
|
|||
|
}
|
|||
|
return true;
|
|||
|
}
|
|||
|
return false;
|
|||
|
},
|
|||
|
});
|
|||
|
this.addCommand({
|
|||
|
id: "Download all images",
|
|||
|
name: "Download all images",
|
|||
|
checkCallback: function (checking) {
|
|||
|
var leaf = _this.app.workspace.activeLeaf;
|
|||
|
if (leaf) {
|
|||
|
if (!checking) {
|
|||
|
_this.downloadAllImageFiles();
|
|||
|
}
|
|||
|
return true;
|
|||
|
}
|
|||
|
return false;
|
|||
|
},
|
|||
|
});
|
|||
|
this.setupPasteHandler();
|
|||
|
this.registerFileMenu();
|
|||
|
return [2 /*return*/];
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
};
|
|||
|
imageAutoUploadPlugin.prototype.downloadAllImageFiles = function () {
|
|||
|
return __awaiter(this, void 0, void 0, function () {
|
|||
|
var folderPath, fileArray, imageArray, fileArray_1, fileArray_1_1, file, url, asset, _a, name_1, ext, response, activeFolder, basePath, abstractActiveFolder, e_1_1, value;
|
|||
|
var e_1, _b;
|
|||
|
return __generator(this, function (_c) {
|
|||
|
switch (_c.label) {
|
|||
|
case 0:
|
|||
|
folderPath = this.getFileAssetPath();
|
|||
|
fileArray = this.helper.getAllFiles();
|
|||
|
if (!fs.existsSync(folderPath)) {
|
|||
|
fs.mkdirSync(folderPath);
|
|||
|
}
|
|||
|
imageArray = [];
|
|||
|
_c.label = 1;
|
|||
|
case 1:
|
|||
|
_c.trys.push([1, 6, 7, 8]);
|
|||
|
fileArray_1 = __values(fileArray), fileArray_1_1 = fileArray_1.next();
|
|||
|
_c.label = 2;
|
|||
|
case 2:
|
|||
|
if (!!fileArray_1_1.done) return [3 /*break*/, 5];
|
|||
|
file = fileArray_1_1.value;
|
|||
|
if (!file.path.startsWith("http")) {
|
|||
|
return [3 /*break*/, 4];
|
|||
|
}
|
|||
|
url = file.path;
|
|||
|
asset = getUrlAsset(url);
|
|||
|
if (!isAnImage(asset.substr(asset.lastIndexOf(".")))) {
|
|||
|
return [3 /*break*/, 4];
|
|||
|
}
|
|||
|
_a = __read([
|
|||
|
decodeURI(path.parse(asset).name).replaceAll(/[\\\\/:*?\"<>|]/g, "-"),
|
|||
|
path.parse(asset).ext,
|
|||
|
], 2), name_1 = _a[0], ext = _a[1];
|
|||
|
// 如果文件名已存在,则用随机值替换
|
|||
|
if (fs.existsSync(path.join(folderPath, encodeURI(asset)))) {
|
|||
|
name_1 = (Math.random() + 1).toString(36).substr(2, 5);
|
|||
|
}
|
|||
|
name_1 = "image-" + name_1;
|
|||
|
return [4 /*yield*/, this.download(url, path.join(folderPath, "" + name_1 + ext))];
|
|||
|
case 3:
|
|||
|
response = _c.sent();
|
|||
|
if (response.ok) {
|
|||
|
activeFolder = this.app.vault.getAbstractFileByPath(this.app.workspace.getActiveFile().path).parent.path;
|
|||
|
basePath = this.app.vault.adapter.getBasePath();
|
|||
|
abstractActiveFolder = path.resolve(basePath, activeFolder);
|
|||
|
imageArray.push({
|
|||
|
source: file.source,
|
|||
|
name: name_1,
|
|||
|
path: obsidian.normalizePath(path.relative(abstractActiveFolder, response.path)),
|
|||
|
});
|
|||
|
}
|
|||
|
_c.label = 4;
|
|||
|
case 4:
|
|||
|
fileArray_1_1 = fileArray_1.next();
|
|||
|
return [3 /*break*/, 2];
|
|||
|
case 5: return [3 /*break*/, 8];
|
|||
|
case 6:
|
|||
|
e_1_1 = _c.sent();
|
|||
|
e_1 = { error: e_1_1 };
|
|||
|
return [3 /*break*/, 8];
|
|||
|
case 7:
|
|||
|
try {
|
|||
|
if (fileArray_1_1 && !fileArray_1_1.done && (_b = fileArray_1.return)) _b.call(fileArray_1);
|
|||
|
}
|
|||
|
finally { if (e_1) throw e_1.error; }
|
|||
|
return [7 /*endfinally*/];
|
|||
|
case 8:
|
|||
|
value = this.helper.getValue();
|
|||
|
imageArray.map(function (image) {
|
|||
|
value = value.replace(image.source, " + ")");
|
|||
|
});
|
|||
|
this.helper.setValue(value);
|
|||
|
new obsidian.Notice("all: " + fileArray.length + "\nsuccess: " + imageArray.length + "\nfailed: " + (fileArray.length - imageArray.length));
|
|||
|
return [2 /*return*/];
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
};
|
|||
|
// 获取当前文件所属的附件文件夹
|
|||
|
imageAutoUploadPlugin.prototype.getFileAssetPath = function () {
|
|||
|
var basePath = this.app.vault.adapter.getBasePath();
|
|||
|
// @ts-ignore
|
|||
|
var assetFolder = this.app.vault.config.attachmentFolderPath;
|
|||
|
var activeFile = this.app.vault.getAbstractFileByPath(this.app.workspace.getActiveFile().path);
|
|||
|
// 当前文件夹下的子文件夹
|
|||
|
if (assetFolder.startsWith("./")) {
|
|||
|
var activeFolder = decodeURI(path.resolve(basePath, activeFile.parent.path));
|
|||
|
return path.join(activeFolder, assetFolder);
|
|||
|
}
|
|||
|
else {
|
|||
|
// 根文件夹
|
|||
|
return path.join(basePath, assetFolder);
|
|||
|
}
|
|||
|
};
|
|||
|
imageAutoUploadPlugin.prototype.download = function (url, path) {
|
|||
|
return __awaiter(this, void 0, void 0, function () {
|
|||
|
var response, buffer;
|
|||
|
return __generator(this, function (_a) {
|
|||
|
switch (_a.label) {
|
|||
|
case 0: return [4 /*yield*/, obsidian.requestUrl({ url: url })];
|
|||
|
case 1:
|
|||
|
response = _a.sent();
|
|||
|
if (response.status !== 200) {
|
|||
|
return [2 /*return*/, {
|
|||
|
ok: false,
|
|||
|
msg: "error",
|
|||
|
}];
|
|||
|
}
|
|||
|
buffer = Buffer.from(response.arrayBuffer);
|
|||
|
try {
|
|||
|
fs.writeFileSync(path, buffer);
|
|||
|
return [2 /*return*/, {
|
|||
|
ok: true,
|
|||
|
msg: "ok",
|
|||
|
path: path,
|
|||
|
}];
|
|||
|
}
|
|||
|
catch (err) {
|
|||
|
console.error(err);
|
|||
|
return [2 /*return*/, {
|
|||
|
ok: false,
|
|||
|
msg: err,
|
|||
|
}];
|
|||
|
}
|
|||
|
return [2 /*return*/];
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
};
|
|||
|
imageAutoUploadPlugin.prototype.registerFileMenu = function () {
|
|||
|
var _this = this;
|
|||
|
this.registerEvent(this.app.workspace.on("file-menu", function (menu, file, source) {
|
|||
|
if (!isAssetTypeAnImage(file.path)) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
menu.addItem(function (item) {
|
|||
|
item
|
|||
|
.setTitle("Upload")
|
|||
|
.setIcon("upload")
|
|||
|
.onClick(function () {
|
|||
|
if (!(file instanceof obsidian.TFile)) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
_this.fileMenuUpload(file);
|
|||
|
console.log(file);
|
|||
|
});
|
|||
|
});
|
|||
|
}));
|
|||
|
};
|
|||
|
imageAutoUploadPlugin.prototype.fileMenuUpload = function (file) {
|
|||
|
var e_2, _a;
|
|||
|
var _this = this;
|
|||
|
var content = this.helper.getValue();
|
|||
|
var basePath = this.app.vault.adapter.getBasePath();
|
|||
|
var imageList = [];
|
|||
|
var fileArray = this.helper.getAllFiles();
|
|||
|
try {
|
|||
|
for (var fileArray_2 = __values(fileArray), fileArray_2_1 = fileArray_2.next(); !fileArray_2_1.done; fileArray_2_1 = fileArray_2.next()) {
|
|||
|
var match = fileArray_2_1.value;
|
|||
|
var imageName = match.name;
|
|||
|
var encodedUri = match.path;
|
|||
|
var fileName = path.basename(decodeURI(encodedUri));
|
|||
|
if (file && file.name === fileName) {
|
|||
|
var abstractImageFile = path.join(basePath, file.path);
|
|||
|
if (isAssetTypeAnImage(abstractImageFile)) {
|
|||
|
imageList.push({
|
|||
|
path: abstractImageFile,
|
|||
|
name: imageName,
|
|||
|
source: match.source,
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|||
|
finally {
|
|||
|
try {
|
|||
|
if (fileArray_2_1 && !fileArray_2_1.done && (_a = fileArray_2.return)) _a.call(fileArray_2);
|
|||
|
}
|
|||
|
finally { if (e_2) throw e_2.error; }
|
|||
|
}
|
|||
|
if (imageList.length === 0) {
|
|||
|
new obsidian.Notice("没有解析到图像文件");
|
|||
|
return;
|
|||
|
}
|
|||
|
this.uploader.uploadFiles(imageList.map(function (item) { return item.path; })).then(function (res) {
|
|||
|
if (res.success) {
|
|||
|
var uploadUrlList_1 = res.result;
|
|||
|
imageList.map(function (item) {
|
|||
|
var uploadImage = uploadUrlList_1.shift();
|
|||
|
content = content.replaceAll(item.source, "");
|
|||
|
});
|
|||
|
_this.helper.setValue(content);
|
|||
|
}
|
|||
|
else {
|
|||
|
new obsidian.Notice("Upload error");
|
|||
|
}
|
|||
|
});
|
|||
|
};
|
|||
|
imageAutoUploadPlugin.prototype.filterFile = function (fileArray) {
|
|||
|
var e_3, _a;
|
|||
|
var imageList = [];
|
|||
|
try {
|
|||
|
for (var fileArray_3 = __values(fileArray), fileArray_3_1 = fileArray_3.next(); !fileArray_3_1.done; fileArray_3_1 = fileArray_3.next()) {
|
|||
|
var match = fileArray_3_1.value;
|
|||
|
if (this.settings.workOnNetWork && match.path.startsWith("http")) {
|
|||
|
if (!this.helper.hasBlackDomain(match.path, this.settings.newWorkBlackDomains)) {
|
|||
|
imageList.push({
|
|||
|
path: match.path,
|
|||
|
name: match.name,
|
|||
|
source: match.source,
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
else {
|
|||
|
imageList.push({
|
|||
|
path: match.path,
|
|||
|
name: match.name,
|
|||
|
source: match.source,
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|||
|
finally {
|
|||
|
try {
|
|||
|
if (fileArray_3_1 && !fileArray_3_1.done && (_a = fileArray_3.return)) _a.call(fileArray_3);
|
|||
|
}
|
|||
|
finally { if (e_3) throw e_3.error; }
|
|||
|
}
|
|||
|
return imageList;
|
|||
|
};
|
|||
|
imageAutoUploadPlugin.prototype.getFile = function (fileName, fileMap) {
|
|||
|
if (!fileMap) {
|
|||
|
fileMap = arrayToObject(this.app.vault.getFiles(), "name");
|
|||
|
}
|
|||
|
return fileMap[fileName];
|
|||
|
};
|
|||
|
// uploda all file
|
|||
|
imageAutoUploadPlugin.prototype.uploadAllFile = function () {
|
|||
|
var e_4, _a;
|
|||
|
var _this = this;
|
|||
|
var content = this.helper.getValue();
|
|||
|
var basePath = this.app.vault.adapter.getBasePath();
|
|||
|
var fileMap = arrayToObject(this.app.vault.getFiles(), "name");
|
|||
|
var imageList = [];
|
|||
|
var fileArray = this.filterFile(this.helper.getAllFiles());
|
|||
|
try {
|
|||
|
for (var fileArray_4 = __values(fileArray), fileArray_4_1 = fileArray_4.next(); !fileArray_4_1.done; fileArray_4_1 = fileArray_4.next()) {
|
|||
|
var match = fileArray_4_1.value;
|
|||
|
var imageName = match.name;
|
|||
|
var encodedUri = match.path;
|
|||
|
if (encodedUri.startsWith("http")) {
|
|||
|
imageList.push({
|
|||
|
path: match.path,
|
|||
|
name: imageName,
|
|||
|
source: match.source,
|
|||
|
});
|
|||
|
}
|
|||
|
else {
|
|||
|
var fileName = path.basename(decodeURI(encodedUri));
|
|||
|
var file = this.getFile(fileName, fileMap);
|
|||
|
if (file) {
|
|||
|
var abstractImageFile = path.join(basePath, file.path);
|
|||
|
if (isAssetTypeAnImage(abstractImageFile)) {
|
|||
|
imageList.push({
|
|||
|
path: abstractImageFile,
|
|||
|
name: imageName,
|
|||
|
source: match.source,
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|||
|
finally {
|
|||
|
try {
|
|||
|
if (fileArray_4_1 && !fileArray_4_1.done && (_a = fileArray_4.return)) _a.call(fileArray_4);
|
|||
|
}
|
|||
|
finally { if (e_4) throw e_4.error; }
|
|||
|
}
|
|||
|
if (imageList.length === 0) {
|
|||
|
new obsidian.Notice("没有解析到图像文件");
|
|||
|
return;
|
|||
|
}
|
|||
|
else {
|
|||
|
new obsidian.Notice("\u5171\u627E\u5230" + imageList.length + "\u4E2A\u56FE\u50CF\u6587\u4EF6\uFF0C\u5F00\u59CB\u4E0A\u4F20");
|
|||
|
}
|
|||
|
this.uploader.uploadFiles(imageList.map(function (item) { return item.path; })).then(function (res) {
|
|||
|
if (res.success) {
|
|||
|
var uploadUrlList_2 = res.result;
|
|||
|
imageList.map(function (item) {
|
|||
|
var uploadImage = uploadUrlList_2.shift();
|
|||
|
content = content.replaceAll(item.source, "");
|
|||
|
});
|
|||
|
_this.helper.setValue(content);
|
|||
|
}
|
|||
|
else {
|
|||
|
new obsidian.Notice("Upload error");
|
|||
|
}
|
|||
|
});
|
|||
|
};
|
|||
|
imageAutoUploadPlugin.prototype.setupPasteHandler = function () {
|
|||
|
var _this = this;
|
|||
|
this.registerEvent(this.app.workspace.on("editor-paste", function (evt, editor, markdownView) {
|
|||
|
var allowUpload = _this.helper.getFrontmatterValue("image-auto-upload", _this.settings.uploadByClipSwitch);
|
|||
|
evt.clipboardData.files;
|
|||
|
if (!allowUpload) {
|
|||
|
return;
|
|||
|
}
|
|||
|
// 剪贴板内容有md格式的图片时
|
|||
|
if (_this.settings.workOnNetWork) {
|
|||
|
var clipboardValue = evt.clipboardData.getData("text/plain");
|
|||
|
var imageList_1 = _this.helper
|
|||
|
.getImageLink(clipboardValue)
|
|||
|
.filter(function (image) { return image.path.startsWith("http"); });
|
|||
|
if (imageList_1.length !== 0) {
|
|||
|
_this.uploader
|
|||
|
.uploadFiles(imageList_1.map(function (item) { return item.path; }))
|
|||
|
.then(function (res) {
|
|||
|
var value = _this.helper.getValue();
|
|||
|
if (res.success) {
|
|||
|
var uploadUrlList_3 = res.result;
|
|||
|
imageList_1.map(function (item) {
|
|||
|
var uploadImage = uploadUrlList_3.shift();
|
|||
|
value = value.replaceAll(item.source, "");
|
|||
|
});
|
|||
|
_this.helper.setValue(value);
|
|||
|
}
|
|||
|
else {
|
|||
|
new obsidian.Notice("Upload error");
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
// 剪贴板中是图片时进行上传
|
|||
|
if (_this.canUpload(evt.clipboardData)) {
|
|||
|
_this.uploadFileAndEmbedImgurImage(editor, function (editor, pasteId) { return __awaiter(_this, void 0, void 0, function () {
|
|||
|
var res, url;
|
|||
|
return __generator(this, function (_a) {
|
|||
|
switch (_a.label) {
|
|||
|
case 0: return [4 /*yield*/, this.uploader.uploadFileByClipboard()];
|
|||
|
case 1:
|
|||
|
res = _a.sent();
|
|||
|
if (res.code !== 0) {
|
|||
|
this.handleFailedUpload(editor, pasteId, res.msg);
|
|||
|
return [2 /*return*/];
|
|||
|
}
|
|||
|
url = res.data;
|
|||
|
return [2 /*return*/, url];
|
|||
|
}
|
|||
|
});
|
|||
|
}); }, evt.clipboardData).catch();
|
|||
|
evt.preventDefault();
|
|||
|
}
|
|||
|
}));
|
|||
|
this.registerEvent(this.app.workspace.on("editor-drop", function (evt, editor, markdownView) { return __awaiter(_this, void 0, void 0, function () {
|
|||
|
var allowUpload, files, sendFiles_1, files_1, data;
|
|||
|
var _this = this;
|
|||
|
return __generator(this, function (_a) {
|
|||
|
switch (_a.label) {
|
|||
|
case 0:
|
|||
|
allowUpload = this.helper.getFrontmatterValue("image-auto-upload", this.settings.uploadByClipSwitch);
|
|||
|
files = evt.dataTransfer.files;
|
|||
|
if (!allowUpload) {
|
|||
|
return [2 /*return*/];
|
|||
|
}
|
|||
|
if (!(files.length !== 0 && files[0].type.startsWith("image"))) return [3 /*break*/, 2];
|
|||
|
sendFiles_1 = [];
|
|||
|
files_1 = evt.dataTransfer.files;
|
|||
|
Array.from(files_1).forEach(function (item, index) {
|
|||
|
sendFiles_1.push(item.path);
|
|||
|
});
|
|||
|
evt.preventDefault();
|
|||
|
return [4 /*yield*/, this.uploader.uploadFiles(sendFiles_1)];
|
|||
|
case 1:
|
|||
|
data = _a.sent();
|
|||
|
if (data.success) {
|
|||
|
data.result.map(function (value) {
|
|||
|
var pasteId = (Math.random() + 1).toString(36).substr(2, 5);
|
|||
|
_this.insertTemporaryText(editor, pasteId);
|
|||
|
_this.embedMarkDownImage(editor, pasteId, value, files_1[0].name);
|
|||
|
});
|
|||
|
}
|
|||
|
else {
|
|||
|
new obsidian.Notice("Upload error");
|
|||
|
}
|
|||
|
_a.label = 2;
|
|||
|
case 2: return [2 /*return*/];
|
|||
|
}
|
|||
|
});
|
|||
|
}); }));
|
|||
|
};
|
|||
|
imageAutoUploadPlugin.prototype.canUpload = function (clipboardData) {
|
|||
|
this.settings.applyImage;
|
|||
|
var files = clipboardData.files;
|
|||
|
var text = clipboardData.getData("text");
|
|||
|
var hasImageFile = files.length !== 0 && files[0].type.startsWith("image");
|
|||
|
if (hasImageFile) {
|
|||
|
if (!!text) {
|
|||
|
return this.settings.applyImage;
|
|||
|
}
|
|||
|
else {
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
else {
|
|||
|
return false;
|
|||
|
}
|
|||
|
};
|
|||
|
imageAutoUploadPlugin.prototype.uploadFileAndEmbedImgurImage = function (editor, callback, clipboardData) {
|
|||
|
return __awaiter(this, void 0, void 0, function () {
|
|||
|
var pasteId, name, url, e_5;
|
|||
|
return __generator(this, function (_a) {
|
|||
|
switch (_a.label) {
|
|||
|
case 0:
|
|||
|
pasteId = (Math.random() + 1).toString(36).substr(2, 5);
|
|||
|
this.insertTemporaryText(editor, pasteId);
|
|||
|
name = clipboardData.files[0].name;
|
|||
|
_a.label = 1;
|
|||
|
case 1:
|
|||
|
_a.trys.push([1, 3, , 4]);
|
|||
|
return [4 /*yield*/, callback(editor, pasteId)];
|
|||
|
case 2:
|
|||
|
url = _a.sent();
|
|||
|
this.embedMarkDownImage(editor, pasteId, url, name);
|
|||
|
return [3 /*break*/, 4];
|
|||
|
case 3:
|
|||
|
e_5 = _a.sent();
|
|||
|
this.handleFailedUpload(editor, pasteId, e_5);
|
|||
|
return [3 /*break*/, 4];
|
|||
|
case 4: return [2 /*return*/];
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
};
|
|||
|
imageAutoUploadPlugin.prototype.insertTemporaryText = function (editor, pasteId) {
|
|||
|
var progressText = imageAutoUploadPlugin.progressTextFor(pasteId);
|
|||
|
editor.replaceSelection(progressText + "\n");
|
|||
|
};
|
|||
|
imageAutoUploadPlugin.progressTextFor = function (id) {
|
|||
|
return "![Uploading file..." + id + "]()";
|
|||
|
};
|
|||
|
imageAutoUploadPlugin.prototype.embedMarkDownImage = function (editor, pasteId, imageUrl, name) {
|
|||
|
if (name === void 0) { name = ""; }
|
|||
|
var progressText = imageAutoUploadPlugin.progressTextFor(pasteId);
|
|||
|
var markDownImage = "";
|
|||
|
imageAutoUploadPlugin.replaceFirstOccurrence(editor, progressText, markDownImage);
|
|||
|
};
|
|||
|
imageAutoUploadPlugin.prototype.handleFailedUpload = function (editor, pasteId, reason) {
|
|||
|
console.error("Failed request: ", reason);
|
|||
|
var progressText = imageAutoUploadPlugin.progressTextFor(pasteId);
|
|||
|
imageAutoUploadPlugin.replaceFirstOccurrence(editor, progressText, "⚠️upload failed, check dev console");
|
|||
|
};
|
|||
|
imageAutoUploadPlugin.replaceFirstOccurrence = function (editor, target, replacement) {
|
|||
|
var lines = editor.getValue().split("\n");
|
|||
|
for (var i = 0; i < lines.length; i++) {
|
|||
|
var ch = lines[i].indexOf(target);
|
|||
|
if (ch != -1) {
|
|||
|
var from = { line: i, ch: ch };
|
|||
|
var to = { line: i, ch: ch + target.length };
|
|||
|
editor.replaceRange(replacement, from, to);
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
return imageAutoUploadPlugin;
|
|||
|
}(obsidian.Plugin));
|
|||
|
|
|||
|
module.exports = imageAutoUploadPlugin;
|
|||
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi5qcyIsInNvdXJjZXMiOlsibm9kZV9tb2R1bGVzL3RzbGliL3RzbGliLmVzNi5qcyIsIm5vZGVfbW9kdWxlcy9pc2V4ZS93aW5kb3dzLmpzIiwibm9kZV9tb2R1bGVzL2lzZXhlL21vZGUuanMiLCJub2RlX21vZHVsZXMvaXNleGUvaW5kZXguanMiLCJub2RlX21vZHVsZXMvd2hpY2gvd2hpY2guanMiLCJub2RlX21vZHVsZXMvcGF0aC1rZXkvaW5kZXguanMiLCJub2RlX21vZHVsZXMvY3Jvc3Mtc3Bhd24vbGliL3V0aWwvcmVzb2x2ZUNvbW1hbmQuanMiLCJub2RlX21vZHVsZXMvY3Jvc3Mtc3Bhd24vbGliL3V0aWwvZXNjYXBlLmpzIiwibm9kZV9tb2R1bGVzL3NoZWJhbmctcmVnZXgvaW5kZXguanMiLCJub2RlX21vZHVsZXMvc2hlYmFuZy1jb21tYW5kL2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL2Nyb3NzLXNwYXduL2xpYi91dGlsL3JlYWRTaGViYW5nLmpzIiwibm9kZV9tb2R1bGVzL2Nyb3NzLXNwYXduL2xpYi9wYXJzZS5qcyIsIm5vZGVfbW9kdWxlcy9jcm9zcy1zcGF3bi9saWIvZW5vZW50LmpzIiwibm9kZV9tb2R1bGVzL2Nyb3NzLXNwYXduL2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL3N0cmlwLWZpbmFsLW5ld2xpbmUvaW5kZXguanMiLCJub2RlX21vZHVsZXMvbnBtLXJ1bi1wYXRoL2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL21pbWljLWZuL2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL29uZXRpbWUvaW5kZXguanMiLCJub2RlX21vZHVsZXMvaHVtYW4tc2lnbmFscy9idWlsZC9zcmMvY29yZS5qcyIsIm5vZGVfbW9kdWxlcy9odW1hbi1zaWduYWxzL2J1aWxkL3NyYy9yZWFsdGltZS5qcyIsIm5vZGVfbW9kdWxlcy9odW1hbi1zaWduYWxzL2J1aWxkL3NyYy9zaWduYWxzLmpzIiwibm9kZV9tb2R1bGVzL2h1bWFuLXNpZ25hbHMvYnVpbGQvc3JjL21haW4uanMiLCJub2RlX21vZHVsZXMvZXhlY2EvbGliL2Vycm9yLmpzIiwibm9kZV9tb2R1bGVzL2V4ZWNhL2xpYi9zdGRpby5qcyIsIm5vZGVfbW9kdWxlcy9zaWduYWwtZXhpdC9zaWduYWxzLmpzIiwibm9kZV9tb2R1bGVzL3NpZ25hbC1leGl0L2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL2V4ZWNhL2xpYi9raWxsLmpzIiwibm9kZV9tb2R1bGVzL2lzLXN0cmVhbS9pbmRleC5qcyIsIm5vZGVfbW9kdWxlcy9leGVjYS9ub2RlX21vZHVsZXMvZ2V0LXN0cmVhbS9idWZmZXItc3RyZWFtLmpzIiwibm9kZV9tb2R1bGVzL2V4ZWNhL25vZGVfbW9kdWxlcy9nZXQtc3RyZWFtL2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL21lcmdlLXN0cmVhbS9pbmRleC5qcyIsIm5vZGVfbW9kdWxlcy9leGVjYS9saWIvc3RyZWFtLmpzIiwibm9kZV9tb2R1bGVzL2V4ZWNhL2xpYi9wcm9taXNlLmpzIiwibm9kZV9tb2R1bGVzL2V4ZWNhL2xpYi9jb21tYW5kLmpzIiwibm9kZV9tb2R1bGVzL2V4ZWNhL2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL2Fuc2ktcmVnZXgvaW5kZXguanMiLCJub2RlX21vZHVsZXMvc3RyaXAtYW5zaS9pbmRleC5qcyIsIm5vZGVfbW9kdWxlcy9kZWZhdWx0LXNoZWxsL2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL3NoZWxsLWVudi9pbmRleC5qcyIsIm5vZGVfbW9kdWxlcy9zaGVsbC1wYXRoL2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL2ZpeC1wYXRoL2luZGV4LmpzIiwic3JjL3V0aWxzLnRzIiwic3JjL3VwbG9hZGVyLnRzIiwic3JjL2hlbHBlci50cyIsInNyYy9sYW5nL2xvY2FsZS9hci50cyIsInNyYy9sYW5nL2xvY2FsZS9jei50cyIsInNyYy9sYW5nL2xvY2FsZS9kYS50cyIsInNyYy9sYW5nL2xvY2FsZS9kZS50cyIsInNyYy9sYW5nL2xvY2FsZS9lbi50cyIsInNyYy9sYW5nL2xvY2FsZS9lbi1nYi50cyIsInNyYy9sYW5nL2xvY2FsZS9lcy50cyIsInNyYy9sYW5nL2xvY2FsZS9mci50cyIsInNyYy9sYW5nL2xvY2FsZS9oaS50cyIsInNyYy9sYW5nL2xvY2FsZS9pZC50cyIsInNyYy9sYW5nL2xvY2FsZS9pdC50cyIsInNyYy9sYW5nL2xvY2FsZS9qYS50cyIsInNyYy9sYW5nL2xvY2FsZS9rby50cyIsInNyYy9sYW5nL2xvY2FsZS9ubC50cyIsInNyYy9sYW5nL2xvY2FsZS9uby50cyIsInNyYy9sYW5nL2xvY2FsZS9wbC50cyIsInNyYy9sYW5nL2xvY2FsZS9wdC50cyIsInNyYy9sYW5nL2xvY2FsZS9wdC1ici50cyIsInNyYy9sYW5nL2xvY2FsZS9yby50cyIsInNyYy9sYW5nL2xvY2FsZS9ydS50cyIsInNyYy9sYW5nL2xvY2FsZS90ci50cyIsInNyYy9sYW5nL2xvY2FsZS96aC1jbi50cyIsInNyYy9sYW5nL2xvY2FsZS96aC10dy50cyIsInNyYy9sYW5nL2hlbHBlcnMudHMiLCJzcmMvc2V0dGluZy50cyIsInNyYy9tYWluLnRzIl0sInNvdXJjZXNDb250ZW50IjpbIi8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKlxyXG5Db3B5cmlnaHQgKGMpIE1pY3Jvc29mdCBDb3Jwb3JhdGlvbi5cclxuXHJcblBlcm1pc3Npb24gdG8gdXNlLCBjb3B5LCBtb2RpZnksIGFuZC9vciBkaXN0cmlidXRlIHRoaXMgc29mdHdhcmUgZm9yIGFueVxyXG5wdXJwb3NlIHdpdGggb3Igd2l0aG91dCBmZWUgaXMgaGVyZWJ5IGdyYW50ZWQuXHJcblxyXG5USEUgU09GVFdBUkUgSVMgUFJPVklERUQgXCJBUyBJU1wiIEFORCBUSEUgQVVUSE9SIERJU0NMQUlNUyBBTEwgV0FSUkFOVElFUyBXSVRIXHJcblJFR0FSRCBUTyBUSElTIFNPRlRXQVJFIElOQ0xVRElORyBBTEwgSU1QTElFRCBXQVJSQU5USUVTIE9GIE1FUkNIQU5UQUJJTElUWVxyXG5BTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsXHJcbklORElSRUNULCBPUiBDT05TRVFVRU5USUFMIERBTUFHRVMgT1IgQU5ZIERBTUFHRVMgV0hBVFNPRVZFUiBSRVNVTFRJTkcgRlJPTVxyXG5MT1NTIE9GIFVTRSwgREFUQSBPUiBQUk9GSVRTLCBXSEVUSEVSIElOIEFOIEFDVElPTiBPRiBDT05UUkFDVCwgTkVHTElHRU5DRSBPUlxyXG5PVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1R
|