UNPKG

atma-io

Version:
747 lines (735 loc) 144 kB
!function(factory) { var _global = "undefined" == typeof window ? global : window, _module = { exports: {} }; factory(_module, _module.exports, _global), "object" == typeof module && module.exports && (module.exports = _module.exports), "function" == typeof define && define.amd ? define([], function() { return _module.exports; }) : _global.io = _module.exports; }(function(module, exports, global) { var _node_modules_atma_utils_lib_utils = {}, _src_Env = {}, _src_EnvBrowser = {}, _src_ExportsSetts = {}, _src_File = {}, _src_FileFactory = {}, _src_FileHookRegistration = {}, _src_FileHooks = {}, _src_constants = {}, _src_global = {}, _src_middleware_json = {}, _src_transport_custom = {}, _src_transport_file_transport = {}, _src_transport_http_HttpTransport = {}, _src_transport_http_http_dir = {}, _src_transport_http_http_file = {}, _src_util_arr = {}, _src_util_cb = {}, _src_util_is = {}, _src_util_logger = {}, _src_util_mimeType = {}, _src_util_path = {}, _src_util_rgx = {}, _src_util_uri = {}, _src_global, _node_modules_atma_utils_lib_utils, _src_EnvBrowser, _src_Env, _src_constants, _src_util_path, _src_transport_custom, _src_util_is, _src_util_cb, _src_util_mimeType, _src_transport_http_http_file, _src_transport_http_http_dir, _src_transport_http_HttpTransport, _src_transport_file_transport, _src_util_logger, _src_FileFactory, _src_util_arr, _src_util_rgx, _src_FileHookRegistration, _src_FileHooks, _src_middleware_json, _src_util_uri, _src_File, _src_ExportsSetts; !function() { var exports = null != _src_global ? _src_global : {}, module = { exports: exports }, $global = (Object.defineProperty(exports, "__esModule", { value: !0 }), (exports.io = exports.logger = exports.global = void 0) === global ? window : global), $global = (exports.global = $global).logger; null == (exports.logger = $global) && (exports.logger = console); function __isObj(x) { return null != x && "object" == typeof x && x.constructor === Object; } exports.io = {}, _src_global !== module.exports && (__isObj(_src_global) && __isObj(module.exports) ? Object.assign(_src_global, module.exports) : _src_global = module.exports); }(), !function() { var define = null, exports = null != _node_modules_atma_utils_lib_utils ? _node_modules_atma_utils_lib_utils : {}, module = { exports: exports }; function __isObj(x) { return null != x && "object" == typeof x && x.constructor === Object; } !function(factory) { var owner, property = void 0 !== module && module.exports ? (owner = module, "exports") : (owner = window, "Utils"); factory(owner, property); }(function(owner, property) { var _Array_slice, _Object_getOwnProp, _Object_defineProperty, _Array_slice, _Object_getOwnProp, _Object_defineProperty, _Array_slice, _Object_getOwnProp, _Object_defineProperty, is_Function, is_Object, is_Array, is_ArrayLike, is_String, is_notEmptyString, is_rawObject, is_Date, is_DOM, is_NODE, obj_copyProperty, obj_getProperty, obj_setProperty, obj_hasProperty, obj_defineProperty, obj_extend, obj_extendDefaults, obj_extendProperties, obj_extendPropertiesDefaults, obj_extendMany, obj_create, obj_defaults, obj_clean, obj_extendDescriptors, class_create, class_createEx, arr_remove, arr_each, arr_indexOf, arr_contains, arr_pushMany, str_format, str_dedent, error_createClass, fn_proxy, fn_apply, fn_doNothing, fn_createByPattern, class_Dfr, class_Uri, class_EventEmitter, mixin, promisify, Lib = (is_Function = function(x) { return "function" == typeof x; }, is_Object = function(x) { return null != x && "object" == typeof x; }, is_ArrayLike = is_Array = function(arr) { return null != arr && "object" == typeof arr && "number" == typeof arr.length && "function" == typeof arr.slice; }, is_String = function(x) { return "string" == typeof x; }, is_notEmptyString = function(x) { return "string" == typeof x && "" !== x; }, is_rawObject = function(x) { return null != x && "object" == typeof x && (x.constructor === Object || null == x.constructor); }, is_Date = function(x) { return null != x && "object" == typeof x && null != x.getFullYear && !1 === isNaN(x); }, is_DOM = "undefined" != typeof window && null != window.navigator, is_NODE = !is_DOM, !function() { !function() { _Array_slice = Array.prototype.slice; Array.prototype.splice, Array.prototype.indexOf, Object.hasOwnProperty, _Object_getOwnProp = Object.getOwnPropertyDescriptor, _Object_defineProperty = Object.defineProperty, void 0 === global && window; }(); var getDescriptor = Object.getOwnPropertyDescriptor, defineDescriptor = Object.defineProperty, extendPropertiesFactory = (obj_copyProperty = null == getDescriptor ? function(target, source, key) { return target[key] = source[key]; } : function(target, source, key) { var descr = getDescriptor(source, key); null == descr ? target[key] = source[key] : void 0 !== descr.value ? target[key] = descr.value : defineDescriptor(target, key, descr); }, obj_getProperty = function(obj_, path) { if (null == obj_) return null; if (-1 === path.indexOf(".")) return obj_[path]; for (var obj = obj_, chain = path.split("."), imax = chain.length, i = -1; null != obj && ++i < imax; ) var key = chain[i], obj = obj[key = 63 === key.charCodeAt(key.length - 1) ? key.slice(0, -1) : key]; return obj; }, obj_setProperty = function(obj_, path, val) { if (-1 === path.indexOf(".")) obj_[path] = val; else { for (var obj = obj_, chain = path.split("."), imax = chain.length - 1, i = -1; ++i < imax; ) var key, x = obj[key = 63 === (key = chain[i]).charCodeAt(key.length - 1) ? key.slice(0, -1) : key], obj = x = null == x ? obj[key] = {} : x; obj[chain[i]] = val; } }, obj_hasProperty = function(obj, path) { return void 0 !== obj_getProperty(obj, path); }, obj_defineProperty = function(obj, path, dscr) { for (var key, x = obj, chain = path.split("."), imax = chain.length - 1, i = -1; ++i < imax; ) null == x[key = chain[i]] && (x[key] = {}), x = x[key]; key = chain[imax], _Object_defineProperty ? (void 0 === dscr.writable && (dscr.writable = !0), void 0 === dscr.configurable && (dscr.configurable = !0), void 0 === dscr.enumerable && (dscr.enumerable = !0), _Object_defineProperty(x, key, dscr)) : x[key] = void 0 === dscr.value ? dscr.value : dscr.get && dscr.get(); }, obj_extend = function(a, b) { if (null == b) return a || {}; if (null == a) return obj_create(b); for (var key in b) a[key] = b[key]; return a; }, obj_extendDefaults = function(a, b) { if (null == b) return a || {}; if (null == a) return obj_create(b); for (var key in b) (null == a[key] || "toString" === key && a[key] === Object.prototype.toString) && (a[key] = b[key]); return a; }, function(overwriteProps) { return null == _Object_getOwnProp ? overwriteProps ? obj_extend : obj_extendDefaults : function(a, b) { if (null == b) return a || {}; if (null == a) return obj_create(b); var key, descr; for (key in b) null == (descr = _Object_getOwnProp(b, key)) || !0 !== overwriteProps && null != _Object_getOwnProp(a, key) || (descr.hasOwnProperty("value") ? a[key] = descr.value : _Object_defineProperty(a, key, descr)); return a; }; }); function obj_toFastProps(obj) { function F() {} F.prototype = obj, new F(); } obj_extendProperties = extendPropertiesFactory(!0), obj_extendPropertiesDefaults = extendPropertiesFactory(!1), obj_extendMany = function(a, arg1, arg2, arg3, arg4, arg5, arg6) { for (var imax = arguments.length, i = 1; i < imax; i++) a = obj_extend(a, arguments[i]); return a; }; var _Object_create = Object.create || function(x) { function Ctor() {} return Ctor.prototype = x, new Ctor(); }, obj_extendDescriptorsDefaults; function isDefault(x, opts) { return null == x || opts.removeFalsy && ("" === x || !1 === x) || !(!opts.removeEmptyArrays || !is_ArrayLike(x) || 0 !== x.length); } obj_create = _Object_create, obj_defaults = function(target, defaults) { for (var key in defaults) null == target[key] && (target[key] = defaults[key]); return target; }, obj_clean = function(json, opts) { var _a; if (void 0 === opts && (opts = { removePrivate: !1, skipProperties: null, removeEmptyArrays: !1, removeFalsy: !1 }), null != json && "object" == typeof json) if (is_ArrayLike(json)) { for (var val, arr = json, i = 0, notNullIndex = -1; i < arr.length; i++) null != (val = arr[i]) && (notNullIndex = i), obj_clean(val, opts); notNullIndex + 1 < arr.length && arr.splice(notNullIndex + 1); } else if (is_Object(json)) for (var key in json) null != opts.skipProperties && key in opts.skipProperties ? delete json[key] : null != opts.ignoreProperties && key in opts.ignoreProperties || (!0 === opts.removePrivate && "_" === key[0] || (val = json[key], null != (_a = opts.shouldRemove) && _a.call(opts, key, val)) ? delete json[key] : isDefault(val, opts) ? null != opts.strictProperties && key in opts.strictProperties && null != val || delete json[key] : (!1 !== opts.deep && obj_clean(val, opts), opts.removeEmptyArrays && is_ArrayLike(val) && 0 === val.length && delete json[key])); return json; }, !function() { function _extendDescriptors(target, source, defaultsOnly) { if (null == target) return {}; if (null == source) return source; var descr, key; for (key in source) !0 === defaultsOnly && null != target[key] || (null == (descr = getDescriptor(source, key)) ? obj_extendDescriptors(target, source.__proto__) : void 0 !== descr.value ? target[key] = descr.value : defineDescriptor(target, key, descr)); return target; } obj_extendDescriptorsDefaults = null == getDescriptor ? (obj_extendDescriptors = obj_extend, obj_defaults) : (obj_extendDescriptors = function(target, source) { return _extendDescriptors(target, source, !1); }, function(target, source) { return _extendDescriptors(target, source, !0); }); }(); }(), !function() { function createClassFactory(extendDefaultsFn) { return function(a, b, c, d, e, f, g, h) { for (var es6Method, Ctor, BaseCtor, x, args = _Array_slice.call(arguments), Proto = args.pop(), i = ((Proto = null == Proto ? {} : Proto).hasOwnProperty("constructor") ? void 0 === (Ctor = Proto.constructor).prototype && (es6Method = Ctor, Ctor = function() { for (var imax = arguments.length, i = -1, args = new Array(imax); ++i < imax; ) args[i] = arguments[i]; return es6Method.apply(this, args); }) : Ctor = function() {}, args.length); -1 < --i; ) "function" == typeof (x = args[i]) && (BaseCtor = wrapFn(x, BaseCtor), x = x.prototype), extendDefaultsFn(Proto, x); return function(Ctor, Proto) { return (Proto.constructor = Ctor).prototype = Proto, Ctor; }(wrapFn(BaseCtor, Ctor), Proto); }; } function wrapFn(fnA, fnB) { return null == fnA ? fnB : null == fnB ? fnA : function() { var args = _Array_slice.call(arguments), x = fnA.apply(this, args); return void 0 !== x ? x : fnB.apply(this, args); }; } class_create = createClassFactory(obj_extendDefaults), class_createEx = createClassFactory(obj_extendPropertiesDefaults); }(), arr_remove = function(array, x) { x = array.indexOf(x); return -1 !== x && (array.splice(x, 1), !0); }, arr_each = function(arr, fn, ctx) { arr.forEach(fn, ctx); }, arr_indexOf = function(arr, x) { return arr.indexOf(x); }, arr_contains = function(arr, x) { return -1 !== arr.indexOf(x); }, arr_pushMany = function(arr, arrSource) { if (null != arrSource && null != arr && arr !== arrSource) for (var il = arr.length, jl = arrSource.length, j = -1; ++j < jl; ) arr[il + j] = arrSource[j]; }, !function() { var rgxNum, cache_; str_format = function(str_, a, b, c, d) { for (var imax = arguments.length, i = 0; ++i < imax; ) { var x = arguments[i]; is_Object(x) && x.toJSON && (x = x.toJSON()), str_ = str_.replace(rgxNum(i - 1), String(x)); } return str_; }, str_dedent = function(str) { for (var replacer, rgx = /^[\t ]*\S/gm, match = rgx.exec(str), count = -1; null != match; ) { var x = match[0].length; (-1 === count || x < count) && (count = x), match = rgx.exec(str); } return --count < 1 ? str : (replacer = new RegExp("^[\\t ]{1," + count + "}", "gm"), str.replace(replacer, "").replace(/^[\t ]*\r?\n/, "").replace(/\r?\n[\t ]*$/, "")); }, rgxNum = function(num) { return cache_[num] || (cache_[num] = new RegExp("\\{" + num + "\\}", "g")); }, cache_ = {}; }(), error_createClass = function(name, Proto, stackSliceFrom) { stackSliceFrom = function(Proto, stackFrom) { var Ctor = Proto.hasOwnProperty("constructor") ? Proto.constructor : null; return function() { for (var sliceFrom, stack, _i = 0; _i < arguments.length; _i++) _i, 0; obj_defineProperty(this, "stack", { value: (sliceFrom = stackFrom || 3, null == (stack = new Error().stack) ? null : stack.split("\n").slice(sliceFrom).join("\n")) }), obj_defineProperty(this, "message", { value: str_format.apply(this, arguments) }), null != Ctor && Ctor.apply(this, arguments); }; }(Proto, stackSliceFrom); return stackSliceFrom.prototype = new Error(), Proto.constructor = Error, Proto.name = name, obj_extend(stackSliceFrom.prototype, Proto), stackSliceFrom; }, fn_proxy = function(fn, ctx) { return function() { for (var imax = arguments.length, args = new Array(imax), i = 0; i < imax; i++) args[i] = arguments[i]; return fn_apply(fn, ctx, args); }; }, fn_apply = function(fn, ctx, args) { var l = args.length; return 0 === l ? fn.call(ctx) : 1 === l ? fn.call(ctx, args[0]) : 2 === l ? fn.call(ctx, args[0], args[1]) : 3 === l ? fn.call(ctx, args[0], args[1], args[2]) : 4 === l ? fn.call(ctx, args[0], args[1], args[2], args[3]) : fn.apply(ctx, args); }, fn_doNothing = function() { return !1; }, fn_createByPattern = function(definitions, ctx) { var imax = definitions.length; return function() { var def, l = arguments.length, i = -1; outer: for (;++i < imax; ) if ((def = definitions[i]).pattern.length === l) { for (var j = -1; ++j < l; ) if (!1 === (0, def.pattern[j])(arguments[j])) continue outer; return def.handler.apply(ctx, arguments); } return console.error("InvalidArgumentException for a function", definitions, arguments), null; }; }, !function() { function delegate(dfr, name, fn) { return function() { if (null != fn) { var override = fn.apply(this, arguments); if (null != override && override !== dfr) return null != (x = override) && "object" == typeof x && is_Function(x.then) ? void override.then(delegate(dfr, "resolve"), delegate(dfr, "reject")) : void dfr[name](override); } var x; dfr[name].apply(dfr, arguments); }; } function dfr_bind(dfr, arguments_, listeners, callback) { return null != callback && (null != arguments_ ? fn_apply(callback, dfr, arguments_) : listeners.push(callback)), dfr; } function dfr_clearListeners(dfr) { dfr._done = null, dfr._fail = null, dfr._always = null; } function arr_callOnce(arr, ctx, args) { if (null != arr) { for (var fn, imax = arr.length, i = -1; ++i < imax; ) (fn = arr[i]) && fn_apply(fn, ctx, args); arr.length = 0; } } class_Dfr = function() { function class_Dfr() { this._isAsync = !0, this._done = null, this._fail = null, this._always = null, this._resolved = null, this._rejected = null; } return Object.defineProperty(class_Dfr.prototype, Symbol.toStringTag, { get: function() { return "Promise"; }, enumerable: !1, configurable: !0 }), class_Dfr.prototype.defer = function() { return this._rejected = null, this._resolved = null, this; }, class_Dfr.prototype.isResolved = function() { return null != this._resolved; }, class_Dfr.prototype.isRejected = function() { return null != this._rejected; }, class_Dfr.prototype.isBusy = function() { return null == this._resolved && null == this._rejected; }, class_Dfr.prototype.resolve = function(value) { for (var _i = 1; _i < arguments.length; _i++) _i - 1, 0; var done = this._done, always = this._always; return this._resolved = arguments, dfr_clearListeners(this), arr_callOnce(done, this, arguments), arr_callOnce(always, this, [ this ]), this; }, class_Dfr.prototype.reject = function(error) { for (var _i = 1; _i < arguments.length; _i++) _i - 1, 0; var fail = this._fail, always = this._always; return this._rejected = arguments, dfr_clearListeners(this), arr_callOnce(fail, this, arguments), arr_callOnce(always, this, [ this ]), this; }, class_Dfr.prototype.then = function(filterSuccess, filterError) { var dfr = new class_Dfr(); return this.done(delegate(dfr, "resolve", filterSuccess)).fail(delegate(dfr, "reject", filterError)), dfr; }, class_Dfr.prototype.done = function(callback) { return null != this._rejected ? this : dfr_bind(this, this._resolved, this._done || (this._done = []), callback); }, class_Dfr.prototype.fail = function(callback) { return null != this._resolved ? this : dfr_bind(this, this._rejected, this._fail || (this._fail = []), callback); }, class_Dfr.prototype.always = function(callback) { return dfr_bind(this, this._rejected || this._resolved, this._always || (this._always = []), callback); }, class_Dfr.prototype.pipe = function(mix) { var dfr, done_, fail_; if ("function" == typeof mix) return dfr = new class_Dfr(), done_ = mix, fail_ = 1 < arguments.length ? arguments[1] : null, this.done(delegate(dfr, "resolve", done_)).fail(delegate(dfr, "reject", fail_)), dfr; dfr = mix; for (var imax = arguments.length, done = 1 === imax, fail = 1 === imax, i = 0; ++i < imax; ) switch (arguments[i]) { case "done": done = !0; break; case "fail": fail = !0; break; default: console.error("Unsupported pipe channel", arguments[i]); } return done && this.done(delegate(dfr, "resolve")), fail && this.fail(delegate(dfr, "reject")), this; }, class_Dfr.prototype.pipeCallback = function() { var self = this; return function(error) { var args; null != error ? self.reject(error) : (args = _Array_slice.call(arguments, 1), fn_apply(self.resolve, self, args)); }; }, class_Dfr.prototype.resolveDelegate = function() { return fn_proxy(this.resolve, this); }, class_Dfr.prototype.rejectDelegate = function() { return fn_proxy(this.reject, this); }, class_Dfr.prototype.catch = function(cb) { return this.fail(cb); }, class_Dfr.prototype.finally = function(cb) { return this.always(cb); }, class_Dfr.resolve = function(a, b, c) { var dfr = new class_Dfr(); return dfr.resolve.apply(dfr, _Array_slice.call(arguments)); }, class_Dfr.reject = function(error) { return new class_Dfr().reject(error); }, class_Dfr.run = function(fn, ctx) { var dfr = new class_Dfr(); return fn.call(ctx = null == ctx ? dfr : ctx, fn_proxy(dfr.resolve, ctx), fn_proxy(dfr.reject, dfr), dfr), dfr; }, class_Dfr.all = function(promises) { var dfr = new class_Dfr(), arr = new Array(promises.length), wait = promises.length, error = null; if (0 === wait) return dfr.resolve(arr); function tick(index) { var args; null == error && (args = _Array_slice.call(arguments, 1), arr.splice.apply(arr, [ index, 0 ].concat(args)), 0 == --wait) && dfr.resolve(arr); } function onReject(err) { dfr.reject(error = err); } for (var imax = promises.length, i = -1; ++i < imax; ) { var x = promises[i]; null == x || null == x.then ? tick(i) : x.then(tick.bind(null, i), onReject); } return dfr; }, class_Dfr; }(); }(), !function() { class_Uri = function() { function class_Uri(uri) { if (this.protocol = null, this.host = null, this.path = null, this.file = null, this.extension = null, this.search = null, (this.value = null) != uri) { if (util_isUri(uri)) return util_clone(uri); uri = function(str) { str = str.replace(/\\/g, "/").replace(/^\.\//, ""); var double = /\/{2,}/g; for (;;) { var match = double.exec(str); if (null == match) break; 0 !== match.index && ":" !== str[match.index - 1] && (str = str.substring(0, match.index) + "/" + str.substring(match.index + match[0].length + 1)); } return str; }(uri), this.value = uri, !function(uri) { var match = rgx_protocol.exec(uri.value); null != match && (uri.protocol = match[1], uri.value = uri.value.substring(match[0].length)); }(this), !function(uri) { var match = rgx_win32Drive.exec(uri.value); match && (uri.protocol = "file", uri.host = match[1], uri.value = uri.value.substring(uri.host.length)); null != uri.protocol && "file" !== uri.protocol && (match = uri.value.indexOf("/", 2), uri.host = -1 !== match ? uri.value.substring(0, match) : uri.value, uri.value = uri.value.replace(uri.host, "")); }(this), parse_search(this), parse_file(this), this.path = normalize_pathsSlashes(this.value); } return this; } return class_Uri.prototype.cdUp = function() { var path = this.path; return null == path || "" === path || "/" === path ? this.path = "" : this.path = path.replace(/\/?[^\/]+\/?$/i, ""), this; }, class_Uri.prototype.combine = function(mix) { var path; if (util_isUri(mix)) { if (mix.protocol || mix.host) return util_clone(mix); path = mix.toString(); } else path = mix; if (null == path || "" === path) return util_clone(this); var uri = util_clone(this); if (uri.value = path, parse_search(uri), parse_file(uri), "" !== uri.value) if ("/" === (path = uri.value.replace(/^\.\//i, ""))[0]) uri.path = path; else { for (;/^(\.\.\/?)/gi.test(path) && (uri.cdUp(), path = path.substring(3), "" !== uri.path); ); uri.path = normalize_pathsSlashes(util_combinePathes(uri.path, path)); } return uri; }, class_Uri.prototype.toString = function() { var str = (this.protocol ? this.protocol + "://" : "") + (util_combinePathes(this.host, this.path, this.file) + (this.search || "")); return this.file || this.search || !this.path || (str += "/"), str; }, class_Uri.prototype.toPathAndQuery = function() { return util_combinePathes(this.path, this.file) + (this.search || ""); }, class_Uri.prototype.toRelativeString = function(uri) { if ("string" == typeof uri && (uri = new class_Uri(uri)), 0 === this.path.indexOf(uri.path)) return util_combinePathes(p = "/" === (p = this.path ? this.path.replace(uri.path, "") : "")[0] ? p.substring(1) : p, this.file) + (this.search || ""); for (var current = this.path.split("/"), relative = uri.path.split("/"), p = "", i = 0, length = Math.min(current.length, relative.length); i < length && current[i] === relative[i]; i++); if (p = 0 < i ? current.splice(0, i).join("/") : p) { for (var forward, sub = "", path = uri.path; path; ) { if (0 === this.path.indexOf(path)) { forward = this.path.replace(path, ""); break; } path = path.replace(/\/?[^\/]+\/?$/i, ""), sub += "../"; } return util_combinePathes(sub, forward, this.file); } return this.toString(); }, class_Uri.prototype.toLocalFile = function() { return util_win32Path(util_combinePathes(this.host, this.path, this.file)); }, class_Uri.prototype.toLocalDir = function() { return util_win32Path(util_combinePathes(this.host, this.path, "/")); }, class_Uri.prototype.toDir = function() { return (this.protocol ? this.protocol + "://" : "") + util_combinePathes(this.host, this.path, "/"); }, class_Uri.prototype.isRelative = function() { return !(this.protocol || this.host); }, class_Uri.prototype.getName = function() { return this.file.replace("." + this.extension, ""); }, class_Uri.combinePathes = util_combinePathes, class_Uri.combine = util_combinePathes, class_Uri; }(); var rgx_protocol = /^([\w\d]+):\/\//, rgx_extension = /\.([\w\d]+)$/i, rgx_win32Drive = /(^\/?\w{1}:)(\/|$)/, rgx_fileWithExt = /([^\/]+(\.[\w\d]+)?)$/i; function util_isUri(object) { return object && "object" == typeof object && "function" == typeof object.combine; } function util_combinePathes(a, b, c, d) { for (var x, str = "", i = 0, imax = arguments.length; i < imax; i++) (x = arguments[i]) && (str ? ("/" !== str[str.length - 1] && (str += "/"), str += "/" === x[0] ? x.substring(1) : x) : str = x); return str; } function normalize_pathsSlashes(str) { return "/" === str[str.length - 1] ? str.substring(0, str.length - 1) : str; } function util_clone(source) { var key, uri = new class_Uri(); for (key in source) "string" == typeof source[key] && (uri[key] = source[key]); return uri; } function util_win32Path(path) { return rgx_win32Drive.test(path) && "/" === path[0] ? path.substring(1) : path; } function parse_search(uri) { var question = uri.value.indexOf("?"); -1 !== question && (uri.search = uri.value.substring(question), uri.value = uri.value.substring(0, question)); } function parse_file(obj) { var match = rgx_fileWithExt.exec(obj.value), file = null == match ? null : match[1]; null != file && (obj.file = file, obj.value = obj.value.substring(0, obj.value.length - file.length), obj.value = normalize_pathsSlashes(obj.value), match = rgx_extension.exec(file), obj.extension = null == match ? null : match[1]); } }(), !function() { var __spreadArray = this && this.__spreadArray || function(to, from, pack) { if (pack || 2 === arguments.length) for (var ar, i = 0, l = from.length; i < l; i++) !ar && i in from || ((ar = ar || Array.prototype.slice.call(from, 0, i))[i] = from[i]); return to.concat(ar || Array.prototype.slice.call(from)); }; class_EventEmitter = function() { function class_EventEmitter() { this._listeners = {}; } return class_EventEmitter.prototype.on = function(event, fn) { return null != fn && (this._listeners[event] || (this._listeners[event] = [])).push(fn), this; }, class_EventEmitter.prototype.once = function(event, fn) { return null != fn && (fn._once = !0, (this._listeners[event] || (this._listeners[event] = [])).push(fn)), this; }, class_EventEmitter.prototype.pipe = function(event) { var _this = this; return function() { for (var args = [], _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i]; _this.emit.apply(_this, __spreadArray([ event ], args, !1)); }; }, class_EventEmitter.prototype.emit = function(event) { for (var args = [], _i = 1; _i < arguments.length; _i++) args[_i - 1] = arguments[_i]; var fns = this._listeners[event]; if (null != fns) for (var i = 0; i < fns.length; i++) { var fn = fns[i]; fn_apply(fn, this, args), fn !== fns[i] ? i-- : !0 === fn._once && (fns.splice(i, 1), i--); } return this; }, class_EventEmitter.prototype.trigger = function(event) { for (var args = [], _i = 1; _i < arguments.length; _i++) args[_i - 1] = arguments[_i]; return this.emit.apply(this, __spreadArray([ event ], args, !1)); }, class_EventEmitter.prototype.off = function(event, fn) { var listeners = this._listeners[event]; if (null != listeners) if (1 === arguments.length) listeners.length = 0; else for (var imax = listeners.length, i = -1; ++i < imax; ) listeners[i] === fn && (listeners.splice(i, 1), i--, imax--); return this; }, class_EventEmitter; }(); }(), !function() { var class_inherit, class_extendProtoObjects, proto_getKeys, ensureCallableSingle, ensureCallable, PROTO = "__proto__", _getProtoOf = Object.getPrototypeOf; function proto_extend(proto, source) { if (null != source) for (var key in "function" == typeof proto && (proto = proto.prototype), "function" == typeof source && (source = source.prototype), source = null != _getProtoOf ? function fillProtoHash(proto, target) { var keys = Object.getOwnPropertyNames(proto); for (var i = 0; i < keys.length; i++) { var key = keys[i]; null == target[key] && (target[key] = proto[key]); } var next = Object.getPrototypeOf(proto); if (null == next || next === Object.prototype) return target; return fillProtoHash(next, target); }(source, obj_create(null)) : source) { var val; "constructor" !== key && null != (val = source[key]) && (proto[key] = val); } } function directCaller(fn, self, args) { return fn.apply(self, args); } function newCaller(fn, self, args) { fn = new (fn.bind.apply(fn, [ null ].concat(args)))(); obj_extend(self, fn); } Object.prototype.toString, class_inherit = PROTO in Object.prototype ? function(_class, _base, _extends, original) { var prototype = original, protoCursor = original; prototype.constructor = _class.prototype.constructor, null != _extends && (protoCursor[PROTO] = {}, arr_each(_extends, function(x) { proto_extend(protoCursor[PROTO], x); }), protoCursor = protoCursor[PROTO]); null != _base && (protoCursor[PROTO] = _base.prototype); _class.prototype = prototype; } : function(_class, _base, _extends, original) { { var tmp; null != _base && ((tmp = function() {}).prototype = _base.prototype, _class.prototype = new tmp(), _class.prototype.constructor = _class); } null != _extends && arr_each(_extends, function(x) { delete x.constructor, proto_extend(_class, x); }); proto_extend(_class, original); }, class_extendProtoObjects = function(proto, _base, _extends) { var key, protoValue; for (key in proto) protoValue = proto[key], is_rawObject(protoValue) && (null != _base && is_rawObject(_base.prototype[key]) && obj_defaults(protoValue, _base.prototype[key]), null != _extends) && arr_each(_extends, function(target, key) { return function(source) { source = (is_Function(source = source) ? source.prototype : source)[key]; is_rawObject(source) && obj_defaults(target, source); }; }(protoValue, key)); }, proto_getKeys = function(mix) { var keys = null; if (null == _getProtoOf) for (var key in keys = [], mix) keys.push(key); else for (var cursor = mix, cursorEnd = null, cursorEnd = ("function" == typeof mix ? Function : Object).prototype; cursor != cursorEnd; ) var names = Object.getOwnPropertyNames(cursor), keys = null == keys ? names : keys.concat(names), cursor = Object.getPrototypeOf(cursor); return keys; }, mixin = function(mix1, mix2, mix3, mix4, mix5) { return function() { for (var mixins = [], _i = 0; _i < arguments.length; _i++) mixins[_i] = arguments[_i]; function _class() { for (var args = [], _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i]; for (var i = _callable.length - 1; -1 < i; i--) { var x = _callable[i]; "function" == typeof x && fn_apply(x, this, args); } } var _base = mixins[0], _extends = mixins.slice(1), _callable = ensureCallable(mixins); !1 === is_Function(_base) && (_extends.unshift(_base), _base = null); !function(Ctor, mixins) { for (var i = 0; i < mixins.length; i++) { var Fn = mixins[i]; if ("function" == typeof Fn) for (var keys = proto_getKeys(Fn), j = 0; j < keys.length; j++) { var key = keys[j]; key in Ctor == !1 && obj_copyProperty(Ctor, Fn, key); } } }(_class, mixins); var proto = {}; return class_extendProtoObjects(proto, _base, _extends), class_inherit(_class, _base, _extends, proto), _class; }(mix1, mix2, mix3, mix4, mix5); }, ensureCallable = function(arr) { for (var out = [], i = arr.length; -1 < --i; ) out[i] = ensureCallableSingle(arr[i]); return out; }, ensureCallableSingle = function(mix) { var fn, caller, safe; return !1 === is_Function(mix) ? mix : (fn = mix, caller = directCaller, safe = !1, function() { for (var args = [], _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i]; var x; if (!0 !== safe) { try { x = caller(fn, this, args), safe = !0; } catch (error) { safe = !0, (caller = newCaller)(fn, this, args); } return null != x ? x : void 0; } caller(fn, this, args); }); }; }(), !function() { var __awaiter = this && this.__awaiter || function(thisArg, _arguments, P, generator) { 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) { var value; result.done ? resolve(result.value) : ((value = result.value) instanceof P ? value : new P(function(resolve) { resolve(value); })).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }, __generator = this && this.__generator || function(thisArg, body) { var f, y, t, _ = { label: 0, sent: function() { if (1 & t[0]) throw t[1]; return t[1]; }, trys: [], ops: [] }, g = { next: verb(0), throw: verb(1), return: verb(2) }; return "function" == typeof Symbol && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function(v) { var op = [ n, v ]; if (f) throw new TypeError("Generator is already executing."); for (;_; ) try { if (f = 1, y && (t = 2 & op[0] ? y.return : op[0] ? y.throw || ((t = y.return) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; switch (y = 0, (op = t ? [ 2 & op[0], t.value ] : op)[0]) { case 0: case 1: t = op; break; case 4: return _.label++, { value: op[1], done: !1 }; case 5: _.label++, y = op[1], op = [ 0 ]; continue; case 7: op = _.ops.pop(), _.trys.pop(); continue; default: if (!(t = 0 < (t = _.trys).length && t[t.length - 1]) && (6 === op[0] || 2 === op[0])) { _ = 0; continue; } if (3 === op[0] && (!t || op[1] > t[0] && op[1] < t[3])) _.label = op[1]; else if (6 === op[0] && _.label < t[1]) _.label = t[1], t = op; else { if (!(t && _.label < t[2])) { t[2] && _.ops.pop(), _.trys.pop(); continue; } _.label = t[2], _.ops.push(op); } } op = body.call(thisArg, _); } catch (e) { op = [ 6, e ], y = 0; } finally { f = t = 0; } if (5 & op[0]) throw op[1]; return { value: op[0] ? op[1] : void 0, done: !0 }; }; } }; !function(promisify) { promisify.fromEvent = function(ctx, event, handlerFn, options) { return new Promise(function(resolve, reject) { var _this = this; ctx.once(event, function() { for (var args = [], _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i]; return __awaiter(_this, void 0, void 0, function() { var timeout, completed, ms, _a, r; return __generator(this, function(_b) { switch (_b.label) { case 0: completed = !1, (ms = null == options ? void 0 : options.timeout) && (timeout = setTimeout(function() { completed || (completed = !0, reject(new Error("Timeouted, event was not called within ".concat(ms, "ms")))); }, ms)), _b.label = 1; case 1: return (_b.trys.push([ 1, 5, 6, 7 ]), null != handlerFn) ? [ 3, 2 ] : (_a = args[0], [ 3, 4 ]); case 2: return [ 4, handlerFn.apply(void 0, args) ]; case 3: _a = _b.sent(), _b.label = 4; case 4: return r = _a, !1 === completed && (completed = !0, resolve(r)), [ 3, 7 ]; case 5: