From f160f540a079148d37d267bcec27c9ed6f86e583 Mon Sep 17 00:00:00 2001 From: Alan K Date: Tue, 2 Dec 2014 13:45:21 -0500 Subject: [PATCH] v0.0.36 --- bower.json | 2 +- dist/filer.js | 1802 ++++++++++++++++++++++++++++++++++++++++++++- dist/filer.min.js | 8 +- package.json | 2 +- 4 files changed, 1774 insertions(+), 40 deletions(-) diff --git a/bower.json b/bower.json index 591de26..77911fc 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "filer", - "version": "0.0.35", + "version": "0.0.36", "main": "dist/filer.js", "ignore": [ "build", diff --git a/dist/filer.js b/dist/filer.js index bb63985..469c0fe 100644 --- a/dist/filer.js +++ b/dist/filer.js @@ -87,7 +87,7 @@ }()); }).call(this,_dereq_("JkpR2F")) -},{"JkpR2F":9}],2:[function(_dereq_,module,exports){ +},{"JkpR2F":10}],2:[function(_dereq_,module,exports){ // Based on https://github.com/diy/intercom.js/blob/master/lib/events.js // Copyright 2012 DIY Co Apache License, Version 2.0 // http://www.apache.org/licenses/LICENSE-2.0 @@ -482,7 +482,7 @@ Intercom.getInstance = (function() { module.exports = Intercom; }).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../src/shared.js":26,"./eventemitter.js":2}],4:[function(_dereq_,module,exports){ +},{"../src/shared.js":30,"./eventemitter.js":2}],4:[function(_dereq_,module,exports){ // Cherry-picked bits of underscore.js, lodash.js /** @@ -2009,6 +2009,234 @@ exports.write = function(buffer, value, offset, isLE, mLen, nBytes) { }; },{}],9:[function(_dereq_,module,exports){ +(function (process){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// resolves . and .. elements in a path array with directory names there +// must be no slashes, empty elements, or device names (c:\) in the array +// (so also no leading and trailing slashes - it does not distinguish +// relative and absolute paths) +function normalizeArray(parts, allowAboveRoot) { + // if the path tries to go above the root, `up` ends up > 0 + var up = 0; + for (var i = parts.length - 1; i >= 0; i--) { + var last = parts[i]; + if (last === '.') { + parts.splice(i, 1); + } else if (last === '..') { + parts.splice(i, 1); + up++; + } else if (up) { + parts.splice(i, 1); + up--; + } + } + + // if the path is allowed to go above the root, restore leading ..s + if (allowAboveRoot) { + for (; up--; up) { + parts.unshift('..'); + } + } + + return parts; +} + +// Split a filename into [root, dir, basename, ext], unix version +// 'root' is just a slash, or nothing. +var splitPathRe = + /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/; +var splitPath = function(filename) { + return splitPathRe.exec(filename).slice(1); +}; + +// path.resolve([from ...], to) +// posix version +exports.resolve = function() { + var resolvedPath = '', + resolvedAbsolute = false; + + for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { + var path = (i >= 0) ? arguments[i] : process.cwd(); + + // Skip empty and invalid entries + if (typeof path !== 'string') { + throw new TypeError('Arguments to path.resolve must be strings'); + } else if (!path) { + continue; + } + + resolvedPath = path + '/' + resolvedPath; + resolvedAbsolute = path.charAt(0) === '/'; + } + + // At this point the path should be resolved to a full absolute path, but + // handle relative paths to be safe (might happen when process.cwd() fails) + + // Normalize the path + resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) { + return !!p; + }), !resolvedAbsolute).join('/'); + + return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; +}; + +// path.normalize(path) +// posix version +exports.normalize = function(path) { + var isAbsolute = exports.isAbsolute(path), + trailingSlash = substr(path, -1) === '/'; + + // Normalize the path + path = normalizeArray(filter(path.split('/'), function(p) { + return !!p; + }), !isAbsolute).join('/'); + + if (!path && !isAbsolute) { + path = '.'; + } + if (path && trailingSlash) { + path += '/'; + } + + return (isAbsolute ? '/' : '') + path; +}; + +// posix version +exports.isAbsolute = function(path) { + return path.charAt(0) === '/'; +}; + +// posix version +exports.join = function() { + var paths = Array.prototype.slice.call(arguments, 0); + return exports.normalize(filter(paths, function(p, index) { + if (typeof p !== 'string') { + throw new TypeError('Arguments to path.join must be strings'); + } + return p; + }).join('/')); +}; + + +// path.relative(from, to) +// posix version +exports.relative = function(from, to) { + from = exports.resolve(from).substr(1); + to = exports.resolve(to).substr(1); + + function trim(arr) { + var start = 0; + for (; start < arr.length; start++) { + if (arr[start] !== '') break; + } + + var end = arr.length - 1; + for (; end >= 0; end--) { + if (arr[end] !== '') break; + } + + if (start > end) return []; + return arr.slice(start, end - start + 1); + } + + var fromParts = trim(from.split('/')); + var toParts = trim(to.split('/')); + + var length = Math.min(fromParts.length, toParts.length); + var samePartsLength = length; + for (var i = 0; i < length; i++) { + if (fromParts[i] !== toParts[i]) { + samePartsLength = i; + break; + } + } + + var outputParts = []; + for (var i = samePartsLength; i < fromParts.length; i++) { + outputParts.push('..'); + } + + outputParts = outputParts.concat(toParts.slice(samePartsLength)); + + return outputParts.join('/'); +}; + +exports.sep = '/'; +exports.delimiter = ':'; + +exports.dirname = function(path) { + var result = splitPath(path), + root = result[0], + dir = result[1]; + + if (!root && !dir) { + // No dirname whatsoever + return '.'; + } + + if (dir) { + // It has a dirname, strip trailing slash + dir = dir.substr(0, dir.length - 1); + } + + return root + dir; +}; + + +exports.basename = function(path, ext) { + var f = splitPath(path)[2]; + // TODO: make this comparison case-insensitive on windows? + if (ext && f.substr(-1 * ext.length) === ext) { + f = f.substr(0, f.length - ext.length); + } + return f; +}; + + +exports.extname = function(path) { + return splitPath(path)[3]; +}; + +function filter (xs, f) { + if (xs.filter) return xs.filter(f); + var res = []; + for (var i = 0; i < xs.length; i++) { + if (f(xs[i], i, xs)) res.push(xs[i]); + } + return res; +} + +// String.prototype.substr - negative index don't work in IE8 +var substr = 'ab'.substr(-1) === 'b' + ? function (str, start, len) { return str.substr(start, len) } + : function (str, start, len) { + if (start < 0) start = str.length + start; + return str.substr(start, len); + } +; + +}).call(this,_dereq_("JkpR2F")) +},{"JkpR2F":10}],10:[function(_dereq_,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -2073,7 +2301,1379 @@ process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; -},{}],10:[function(_dereq_,module,exports){ +},{}],11:[function(_dereq_,module,exports){ +(function (process){ +;(function (_dereq_, exports, module, platform) { + +if (module) module.exports = minimatch +else exports.minimatch = minimatch + +if (!_dereq_) { + _dereq_ = function (id) { + switch (id) { + case "sigmund": return function sigmund (obj) { + return JSON.stringify(obj) + } + case "path": return { basename: function (f) { + f = f.split(/[\/\\]/) + var e = f.pop() + if (!e) e = f.pop() + return e + }} + case "lru-cache": return function LRUCache () { + // not quite an LRU, but still space-limited. + var cache = {} + var cnt = 0 + this.set = function (k, v) { + cnt ++ + if (cnt >= 100) cache = {} + cache[k] = v + } + this.get = function (k) { return cache[k] } + } + } + } +} + +minimatch.Minimatch = Minimatch + +var LRU = _dereq_("lru-cache") + , cache = minimatch.cache = new LRU({max: 100}) + , GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} + , sigmund = _dereq_("sigmund") + +var path = _dereq_("path") + // any single thing other than / + // don't need to escape / when using new RegExp() + , qmark = "[^/]" + + // * => any number of characters + , star = qmark + "*?" + + // ** when dots are allowed. Anything goes, except .. and . + // not (^ or / followed by one or two dots followed by $ or /), + // followed by anything, any number of times. + , twoStarDot = "(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?" + + // not a ^ or / followed by a dot, + // followed by anything, any number of times. + , twoStarNoDot = "(?:(?!(?:\\\/|^)\\.).)*?" + + // characters that need to be escaped in RegExp. + , reSpecials = charSet("().*{}+?[]^$\\!") + +// "abc" -> { a:true, b:true, c:true } +function charSet (s) { + return s.split("").reduce(function (set, c) { + set[c] = true + return set + }, {}) +} + +// normalizes slashes. +var slashSplit = /\/+/ + +minimatch.filter = filter +function filter (pattern, options) { + options = options || {} + return function (p, i, list) { + return minimatch(p, pattern, options) + } +} + +function ext (a, b) { + a = a || {} + b = b || {} + var t = {} + Object.keys(b).forEach(function (k) { + t[k] = b[k] + }) + Object.keys(a).forEach(function (k) { + t[k] = a[k] + }) + return t +} + +minimatch.defaults = function (def) { + if (!def || !Object.keys(def).length) return minimatch + + var orig = minimatch + + var m = function minimatch (p, pattern, options) { + return orig.minimatch(p, pattern, ext(def, options)) + } + + m.Minimatch = function Minimatch (pattern, options) { + return new orig.Minimatch(pattern, ext(def, options)) + } + + return m +} + +Minimatch.defaults = function (def) { + if (!def || !Object.keys(def).length) return Minimatch + return minimatch.defaults(def).Minimatch +} + + +function minimatch (p, pattern, options) { + if (typeof pattern !== "string") { + throw new TypeError("glob pattern string required") + } + + if (!options) options = {} + + // shortcut: comments match nothing. + if (!options.nocomment && pattern.charAt(0) === "#") { + return false + } + + // "" only matches "" + if (pattern.trim() === "") return p === "" + + return new Minimatch(pattern, options).match(p) +} + +function Minimatch (pattern, options) { + if (!(this instanceof Minimatch)) { + return new Minimatch(pattern, options, cache) + } + + if (typeof pattern !== "string") { + throw new TypeError("glob pattern string required") + } + + if (!options) options = {} + pattern = pattern.trim() + + // windows: need to use /, not \ + // On other platforms, \ is a valid (albeit bad) filename char. + if (platform === "win32") { + pattern = pattern.split("\\").join("/") + } + + // lru storage. + // these things aren't particularly big, but walking down the string + // and turning it into a regexp can get pretty costly. + var cacheKey = pattern + "\n" + sigmund(options) + var cached = minimatch.cache.get(cacheKey) + if (cached) return cached + minimatch.cache.set(cacheKey, this) + + this.options = options + this.set = [] + this.pattern = pattern + this.regexp = null + this.negate = false + this.comment = false + this.empty = false + + // make the set of regexps etc. + this.make() +} + +Minimatch.prototype.debug = function() {} + +Minimatch.prototype.make = make +function make () { + // don't do it more than once. + if (this._made) return + + var pattern = this.pattern + var options = this.options + + // empty patterns and comments match nothing. + if (!options.nocomment && pattern.charAt(0) === "#") { + this.comment = true + return + } + if (!pattern) { + this.empty = true + return + } + + // step 1: figure out negation, etc. + this.parseNegate() + + // step 2: expand braces + var set = this.globSet = this.braceExpand() + + if (options.debug) this.debug = console.error + + this.debug(this.pattern, set) + + // step 3: now we have a set, so turn each one into a series of path-portion + // matching patterns. + // These will be regexps, except in the case of "**", which is + // set to the GLOBSTAR object for globstar behavior, + // and will not contain any / characters + set = this.globParts = set.map(function (s) { + return s.split(slashSplit) + }) + + this.debug(this.pattern, set) + + // glob --> regexps + set = set.map(function (s, si, set) { + return s.map(this.parse, this) + }, this) + + this.debug(this.pattern, set) + + // filter out everything that didn't compile properly. + set = set.filter(function (s) { + return -1 === s.indexOf(false) + }) + + this.debug(this.pattern, set) + + this.set = set +} + +Minimatch.prototype.parseNegate = parseNegate +function parseNegate () { + var pattern = this.pattern + , negate = false + , options = this.options + , negateOffset = 0 + + if (options.nonegate) return + + for ( var i = 0, l = pattern.length + ; i < l && pattern.charAt(i) === "!" + ; i ++) { + negate = !negate + negateOffset ++ + } + + if (negateOffset) this.pattern = pattern.substr(negateOffset) + this.negate = negate +} + +// Brace expansion: +// a{b,c}d -> abd acd +// a{b,}c -> abc ac +// a{0..3}d -> a0d a1d a2d a3d +// a{b,c{d,e}f}g -> abg acdfg acefg +// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg +// +// Invalid sets are not expanded. +// a{2..}b -> a{2..}b +// a{b}c -> a{b}c +minimatch.braceExpand = function (pattern, options) { + return new Minimatch(pattern, options).braceExpand() +} + +Minimatch.prototype.braceExpand = braceExpand + +function pad(n, width, z) { + z = z || '0'; + n = n + ''; + return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n; +} + +function braceExpand (pattern, options) { + options = options || this.options + pattern = typeof pattern === "undefined" + ? this.pattern : pattern + + if (typeof pattern === "undefined") { + throw new Error("undefined pattern") + } + + if (options.nobrace || + !pattern.match(/\{.*\}/)) { + // shortcut. no need to expand. + return [pattern] + } + + var escaping = false + + // examples and comments refer to this crazy pattern: + // a{b,c{d,e},{f,g}h}x{y,z} + // expected: + // abxy + // abxz + // acdxy + // acdxz + // acexy + // acexz + // afhxy + // afhxz + // aghxy + // aghxz + + // everything before the first \{ is just a prefix. + // So, we pluck that off, and work with the rest, + // and then prepend it to everything we find. + if (pattern.charAt(0) !== "{") { + this.debug(pattern) + var prefix = null + for (var i = 0, l = pattern.length; i < l; i ++) { + var c = pattern.charAt(i) + this.debug(i, c) + if (c === "\\") { + escaping = !escaping + } else if (c === "{" && !escaping) { + prefix = pattern.substr(0, i) + break + } + } + + // actually no sets, all { were escaped. + if (prefix === null) { + this.debug("no sets") + return [pattern] + } + + var tail = braceExpand.call(this, pattern.substr(i), options) + return tail.map(function (t) { + return prefix + t + }) + } + + // now we have something like: + // {b,c{d,e},{f,g}h}x{y,z} + // walk through the set, expanding each part, until + // the set ends. then, we'll expand the suffix. + // If the set only has a single member, then'll put the {} back + + // first, handle numeric sets, since they're easier + var numset = pattern.match(/^\{(-?[0-9]+)\.\.(-?[0-9]+)\}/) + if (numset) { + this.debug("numset", numset[1], numset[2]) + var suf = braceExpand.call(this, pattern.substr(numset[0].length), options) + , start = +numset[1] + , needPadding = numset[1][0] === '0' + , startWidth = numset[1].length + , padded + , end = +numset[2] + , inc = start > end ? -1 : 1 + , set = [] + + for (var i = start; i != (end + inc); i += inc) { + padded = needPadding ? pad(i, startWidth) : i + '' + // append all the suffixes + for (var ii = 0, ll = suf.length; ii < ll; ii ++) { + set.push(padded + suf[ii]) + } + } + return set + } + + // ok, walk through the set + // We hope, somewhat optimistically, that there + // will be a } at the end. + // If the closing brace isn't found, then the pattern is + // interpreted as braceExpand("\\" + pattern) so that + // the leading \{ will be interpreted literally. + var i = 1 // skip the \{ + , depth = 1 + , set = [] + , member = "" + , sawEnd = false + , escaping = false + + function addMember () { + set.push(member) + member = "" + } + + this.debug("Entering for") + FOR: for (i = 1, l = pattern.length; i < l; i ++) { + var c = pattern.charAt(i) + this.debug("", i, c) + + if (escaping) { + escaping = false + member += "\\" + c + } else { + switch (c) { + case "\\": + escaping = true + continue + + case "{": + depth ++ + member += "{" + continue + + case "}": + depth -- + // if this closes the actual set, then we're done + if (depth === 0) { + addMember() + // pluck off the close-brace + i ++ + break FOR + } else { + member += c + continue + } + + case ",": + if (depth === 1) { + addMember() + } else { + member += c + } + continue + + default: + member += c + continue + } // switch + } // else + } // for + + // now we've either finished the set, and the suffix is + // pattern.substr(i), or we have *not* closed the set, + // and need to escape the leading brace + if (depth !== 0) { + this.debug("didn't close", pattern) + return braceExpand.call(this, "\\" + pattern, options) + } + + // x{y,z} -> ["xy", "xz"] + this.debug("set", set) + this.debug("suffix", pattern.substr(i)) + var suf = braceExpand.call(this, pattern.substr(i), options) + // ["b", "c{d,e}","{f,g}h"] -> + // [["b"], ["cd", "ce"], ["fh", "gh"]] + var addBraces = set.length === 1 + this.debug("set pre-expanded", set) + set = set.map(function (p) { + return braceExpand.call(this, p, options) + }, this) + this.debug("set expanded", set) + + + // [["b"], ["cd", "ce"], ["fh", "gh"]] -> + // ["b", "cd", "ce", "fh", "gh"] + set = set.reduce(function (l, r) { + return l.concat(r) + }) + + if (addBraces) { + set = set.map(function (s) { + return "{" + s + "}" + }) + } + + // now attach the suffixes. + var ret = [] + for (var i = 0, l = set.length; i < l; i ++) { + for (var ii = 0, ll = suf.length; ii < ll; ii ++) { + ret.push(set[i] + suf[ii]) + } + } + return ret +} + +// parse a component of the expanded set. +// At this point, no pattern may contain "/" in it +// so we're going to return a 2d array, where each entry is the full +// pattern, split on '/', and then turned into a regular expression. +// A regexp is made at the end which joins each array with an +// escaped /, and another full one which joins each regexp with |. +// +// Following the lead of Bash 4.1, note that "**" only has special meaning +// when it is the *only* thing in a path portion. Otherwise, any series +// of * is equivalent to a single *. Globstar behavior is enabled by +// default, and can be disabled by setting options.noglobstar. +Minimatch.prototype.parse = parse +var SUBPARSE = {} +function parse (pattern, isSub) { + var options = this.options + + // shortcuts + if (!options.noglobstar && pattern === "**") return GLOBSTAR + if (pattern === "") return "" + + var re = "" + , hasMagic = !!options.nocase + , escaping = false + // ? => one single character + , patternListStack = [] + , plType + , stateChar + , inClass = false + , reClassStart = -1 + , classStart = -1 + // . and .. never match anything that doesn't start with ., + // even when options.dot is set. + , patternStart = pattern.charAt(0) === "." ? "" // anything + // not (start or / followed by . or .. followed by / or end) + : options.dot ? "(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))" + : "(?!\\.)" + , self = this + + function clearStateChar () { + if (stateChar) { + // we had some state-tracking character + // that wasn't consumed by this pass. + switch (stateChar) { + case "*": + re += star + hasMagic = true + break + case "?": + re += qmark + hasMagic = true + break + default: + re += "\\"+stateChar + break + } + self.debug('clearStateChar %j %j', stateChar, re) + stateChar = false + } + } + + for ( var i = 0, len = pattern.length, c + ; (i < len) && (c = pattern.charAt(i)) + ; i ++ ) { + + this.debug("%s\t%s %s %j", pattern, i, re, c) + + // skip over any that are escaped. + if (escaping && reSpecials[c]) { + re += "\\" + c + escaping = false + continue + } + + SWITCH: switch (c) { + case "/": + // completely not allowed, even escaped. + // Should already be path-split by now. + return false + + case "\\": + clearStateChar() + escaping = true + continue + + // the various stateChar values + // for the "extglob" stuff. + case "?": + case "*": + case "+": + case "@": + case "!": + this.debug("%s\t%s %s %j <-- stateChar", pattern, i, re, c) + + // all of those are literals inside a class, except that + // the glob [!a] means [^a] in regexp + if (inClass) { + this.debug(' in class') + if (c === "!" && i === classStart + 1) c = "^" + re += c + continue + } + + // if we already have a stateChar, then it means + // that there was something like ** or +? in there. + // Handle the stateChar, then proceed with this one. + self.debug('call clearStateChar %j', stateChar) + clearStateChar() + stateChar = c + // if extglob is disabled, then +(asdf|foo) isn't a thing. + // just clear the statechar *now*, rather than even diving into + // the patternList stuff. + if (options.noext) clearStateChar() + continue + + case "(": + if (inClass) { + re += "(" + continue + } + + if (!stateChar) { + re += "\\(" + continue + } + + plType = stateChar + patternListStack.push({ type: plType + , start: i - 1 + , reStart: re.length }) + // negation is (?:(?!js)[^/]*) + re += stateChar === "!" ? "(?:(?!" : "(?:" + this.debug('plType %j %j', stateChar, re) + stateChar = false + continue + + case ")": + if (inClass || !patternListStack.length) { + re += "\\)" + continue + } + + clearStateChar() + hasMagic = true + re += ")" + plType = patternListStack.pop().type + // negation is (?:(?!js)[^/]*) + // The others are (?:) + switch (plType) { + case "!": + re += "[^/]*?)" + break + case "?": + case "+": + case "*": re += plType + case "@": break // the default anyway + } + continue + + case "|": + if (inClass || !patternListStack.length || escaping) { + re += "\\|" + escaping = false + continue + } + + clearStateChar() + re += "|" + continue + + // these are mostly the same in regexp and glob + case "[": + // swallow any state-tracking char before the [ + clearStateChar() + + if (inClass) { + re += "\\" + c + continue + } + + inClass = true + classStart = i + reClassStart = re.length + re += c + continue + + case "]": + // a right bracket shall lose its special + // meaning and represent itself in + // a bracket expression if it occurs + // first in the list. -- POSIX.2 2.8.3.2 + if (i === classStart + 1 || !inClass) { + re += "\\" + c + escaping = false + continue + } + + // finish up the class. + hasMagic = true + inClass = false + re += c + continue + + default: + // swallow any state char that wasn't consumed + clearStateChar() + + if (escaping) { + // no need + escaping = false + } else if (reSpecials[c] + && !(c === "^" && inClass)) { + re += "\\" + } + + re += c + + } // switch + } // for + + + // handle the case where we left a class open. + // "[abc" is valid, equivalent to "\[abc" + if (inClass) { + // split where the last [ was, and escape it + // this is a huge pita. We now have to re-walk + // the contents of the would-be class to re-translate + // any characters that were passed through as-is + var cs = pattern.substr(classStart + 1) + , sp = this.parse(cs, SUBPARSE) + re = re.substr(0, reClassStart) + "\\[" + sp[0] + hasMagic = hasMagic || sp[1] + } + + // handle the case where we had a +( thing at the *end* + // of the pattern. + // each pattern list stack adds 3 chars, and we need to go through + // and escape any | chars that were passed through as-is for the regexp. + // Go through and escape them, taking care not to double-escape any + // | chars that were already escaped. + var pl + while (pl = patternListStack.pop()) { + var tail = re.slice(pl.reStart + 3) + // maybe some even number of \, then maybe 1 \, followed by a | + tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) { + if (!$2) { + // the | isn't already escaped, so escape it. + $2 = "\\" + } + + // need to escape all those slashes *again*, without escaping the + // one that we need for escaping the | character. As it works out, + // escaping an even number of slashes can be done by simply repeating + // it exactly after itself. That's why this trick works. + // + // I am sorry that you have to see this. + return $1 + $1 + $2 + "|" + }) + + this.debug("tail=%j\n %s", tail, tail) + var t = pl.type === "*" ? star + : pl.type === "?" ? qmark + : "\\" + pl.type + + hasMagic = true + re = re.slice(0, pl.reStart) + + t + "\\(" + + tail + } + + // handle trailing things that only matter at the very end. + clearStateChar() + if (escaping) { + // trailing \\ + re += "\\\\" + } + + // only need to apply the nodot start if the re starts with + // something that could conceivably capture a dot + var addPatternStart = false + switch (re.charAt(0)) { + case ".": + case "[": + case "(": addPatternStart = true + } + + // if the re is not "" at this point, then we need to make sure + // it doesn't match against an empty path part. + // Otherwise a/* will match a/, which it should not. + if (re !== "" && hasMagic) re = "(?=.)" + re + + if (addPatternStart) re = patternStart + re + + // parsing just a piece of a larger pattern. + if (isSub === SUBPARSE) { + return [ re, hasMagic ] + } + + // skip the regexp for non-magical patterns + // unescape anything in it, though, so that it'll be + // an exact match against a file etc. + if (!hasMagic) { + return globUnescape(pattern) + } + + var flags = options.nocase ? "i" : "" + , regExp = new RegExp("^" + re + "$", flags) + + regExp._glob = pattern + regExp._src = re + + return regExp +} + +minimatch.makeRe = function (pattern, options) { + return new Minimatch(pattern, options || {}).makeRe() +} + +Minimatch.prototype.makeRe = makeRe +function makeRe () { + if (this.regexp || this.regexp === false) return this.regexp + + // at this point, this.set is a 2d array of partial + // pattern strings, or "**". + // + // It's better to use .match(). This function shouldn't + // be used, really, but it's pretty convenient sometimes, + // when you just want to work with a regex. + var set = this.set + + if (!set.length) return this.regexp = false + var options = this.options + + var twoStar = options.noglobstar ? star + : options.dot ? twoStarDot + : twoStarNoDot + , flags = options.nocase ? "i" : "" + + var re = set.map(function (pattern) { + return pattern.map(function (p) { + return (p === GLOBSTAR) ? twoStar + : (typeof p === "string") ? regExpEscape(p) + : p._src + }).join("\\\/") + }).join("|") + + // must match entire pattern + // ending in a * or ** will make it less strict. + re = "^(?:" + re + ")$" + + // can match anything, as long as it's not this. + if (this.negate) re = "^(?!" + re + ").*$" + + try { + return this.regexp = new RegExp(re, flags) + } catch (ex) { + return this.regexp = false + } +} + +minimatch.match = function (list, pattern, options) { + options = options || {} + var mm = new Minimatch(pattern, options) + list = list.filter(function (f) { + return mm.match(f) + }) + if (mm.options.nonull && !list.length) { + list.push(pattern) + } + return list +} + +Minimatch.prototype.match = match +function match (f, partial) { + this.debug("match", f, this.pattern) + // short-circuit in the case of busted things. + // comments, etc. + if (this.comment) return false + if (this.empty) return f === "" + + if (f === "/" && partial) return true + + var options = this.options + + // windows: need to use /, not \ + // On other platforms, \ is a valid (albeit bad) filename char. + if (platform === "win32") { + f = f.split("\\").join("/") + } + + // treat the test path as a set of pathparts. + f = f.split(slashSplit) + this.debug(this.pattern, "split", f) + + // just ONE of the pattern sets in this.set needs to match + // in order for it to be valid. If negating, then just one + // match means that we have failed. + // Either way, return on the first hit. + + var set = this.set + this.debug(this.pattern, "set", set) + + // Find the basename of the path by looking for the last non-empty segment + var filename; + for (var i = f.length - 1; i >= 0; i--) { + filename = f[i] + if (filename) break + } + + for (var i = 0, l = set.length; i < l; i ++) { + var pattern = set[i], file = f + if (options.matchBase && pattern.length === 1) { + file = [filename] + } + var hit = this.matchOne(file, pattern, partial) + if (hit) { + if (options.flipNegate) return true + return !this.negate + } + } + + // didn't get any hits. this is success if it's a negative + // pattern, failure otherwise. + if (options.flipNegate) return false + return this.negate +} + +// set partial to true to test if, for example, +// "/a/b" matches the start of "/*/b/*/d" +// Partial means, if you run out of file before you run +// out of pattern, then that's fine, as long as all +// the parts match. +Minimatch.prototype.matchOne = function (file, pattern, partial) { + var options = this.options + + this.debug("matchOne", + { "this": this + , file: file + , pattern: pattern }) + + this.debug("matchOne", file.length, pattern.length) + + for ( var fi = 0 + , pi = 0 + , fl = file.length + , pl = pattern.length + ; (fi < fl) && (pi < pl) + ; fi ++, pi ++ ) { + + this.debug("matchOne loop") + var p = pattern[pi] + , f = file[fi] + + this.debug(pattern, p, f) + + // should be impossible. + // some invalid regexp stuff in the set. + if (p === false) return false + + if (p === GLOBSTAR) { + this.debug('GLOBSTAR', [pattern, p, f]) + + // "**" + // a/**/b/**/c would match the following: + // a/b/x/y/z/c + // a/x/y/z/b/c + // a/b/x/b/x/c + // a/b/c + // To do this, take the rest of the pattern after + // the **, and see if it would match the file remainder. + // If so, return success. + // If not, the ** "swallows" a segment, and try again. + // This is recursively awful. + // + // a/**/b/**/c matching a/b/x/y/z/c + // - a matches a + // - doublestar + // - matchOne(b/x/y/z/c, b/**/c) + // - b matches b + // - doublestar + // - matchOne(x/y/z/c, c) -> no + // - matchOne(y/z/c, c) -> no + // - matchOne(z/c, c) -> no + // - matchOne(c, c) yes, hit + var fr = fi + , pr = pi + 1 + if (pr === pl) { + this.debug('** at the end') + // a ** at the end will just swallow the rest. + // We have found a match. + // however, it will not swallow /.x, unless + // options.dot is set. + // . and .. are *never* matched by **, for explosively + // exponential reasons. + for ( ; fi < fl; fi ++) { + if (file[fi] === "." || file[fi] === ".." || + (!options.dot && file[fi].charAt(0) === ".")) return false + } + return true + } + + // ok, let's see if we can swallow whatever we can. + WHILE: while (fr < fl) { + var swallowee = file[fr] + + this.debug('\nglobstar while', + file, fr, pattern, pr, swallowee) + + // XXX remove this slice. Just pass the start index. + if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { + this.debug('globstar found match!', fr, fl, swallowee) + // found a match. + return true + } else { + // can't swallow "." or ".." ever. + // can only swallow ".foo" when explicitly asked. + if (swallowee === "." || swallowee === ".." || + (!options.dot && swallowee.charAt(0) === ".")) { + this.debug("dot detected!", file, fr, pattern, pr) + break WHILE + } + + // ** swallows a segment, and continue. + this.debug('globstar swallow a segment, and continue') + fr ++ + } + } + // no match was found. + // However, in partial mode, we can't say this is necessarily over. + // If there's more *pattern* left, then + if (partial) { + // ran out of file + this.debug("\n>>> no match, partial?", file, fr, pattern, pr) + if (fr === fl) return true + } + return false + } + + // something other than ** + // non-magic patterns just have to match exactly + // patterns with magic have been turned into regexps. + var hit + if (typeof p === "string") { + if (options.nocase) { + hit = f.toLowerCase() === p.toLowerCase() + } else { + hit = f === p + } + this.debug("string match", p, f, hit) + } else { + hit = f.match(p) + this.debug("pattern match", p, f, hit) + } + + if (!hit) return false + } + + // Note: ending in / means that we'll get a final "" + // at the end of the pattern. This can only match a + // corresponding "" at the end of the file. + // If the file ends in /, then it can only match a + // a pattern that ends in /, unless the pattern just + // doesn't have any more for it. But, a/b/ should *not* + // match "a/b/*", even though "" matches against the + // [^/]*? pattern, except in partial mode, where it might + // simply not be reached yet. + // However, a/b/ should still satisfy a/* + + // now either we fell off the end of the pattern, or we're done. + if (fi === fl && pi === pl) { + // ran out of pattern and filename at the same time. + // an exact hit! + return true + } else if (fi === fl) { + // ran out of file, but still had pattern left. + // this is ok if we're doing the match as part of + // a glob fs traversal. + return partial + } else if (pi === pl) { + // ran out of pattern, still have file left. + // this is only acceptable if we're on the very last + // empty segment of a file with a trailing slash. + // a/* should match a/b/ + var emptyFileEnd = (fi === fl - 1) && (file[fi] === "") + return emptyFileEnd + } + + // should be unreachable. + throw new Error("wtf?") +} + + +// replace stuff like \* with * +function globUnescape (s) { + return s.replace(/\\(.)/g, "$1") +} + + +function regExpEscape (s) { + return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") +} + +})( typeof _dereq_ === "function" ? _dereq_ : null, + this, + typeof module === "object" ? module : null, + typeof process === "object" ? process.platform : "win32" + ) + +}).call(this,_dereq_("JkpR2F")) +},{"JkpR2F":10,"lru-cache":12,"path":9,"sigmund":13}],12:[function(_dereq_,module,exports){ +;(function () { // closure for web browsers + +if (typeof module === 'object' && module.exports) { + module.exports = LRUCache +} else { + // just set the global for non-node platforms. + this.LRUCache = LRUCache +} + +function hOP (obj, key) { + return Object.prototype.hasOwnProperty.call(obj, key) +} + +function naiveLength () { return 1 } + +function LRUCache (options) { + if (!(this instanceof LRUCache)) + return new LRUCache(options) + + if (typeof options === 'number') + options = { max: options } + + if (!options) + options = {} + + this._max = options.max + // Kind of weird to have a default max of Infinity, but oh well. + if (!this._max || !(typeof this._max === "number") || this._max <= 0 ) + this._max = Infinity + + this._lengthCalculator = options.length || naiveLength + if (typeof this._lengthCalculator !== "function") + this._lengthCalculator = naiveLength + + this._allowStale = options.stale || false + this._maxAge = options.maxAge || null + this._dispose = options.dispose + this.reset() +} + +// resize the cache when the max changes. +Object.defineProperty(LRUCache.prototype, "max", + { set : function (mL) { + if (!mL || !(typeof mL === "number") || mL <= 0 ) mL = Infinity + this._max = mL + if (this._length > this._max) trim(this) + } + , get : function () { return this._max } + , enumerable : true + }) + +// resize the cache when the lengthCalculator changes. +Object.defineProperty(LRUCache.prototype, "lengthCalculator", + { set : function (lC) { + if (typeof lC !== "function") { + this._lengthCalculator = naiveLength + this._length = this._itemCount + for (var key in this._cache) { + this._cache[key].length = 1 + } + } else { + this._lengthCalculator = lC + this._length = 0 + for (var key in this._cache) { + this._cache[key].length = this._lengthCalculator(this._cache[key].value) + this._length += this._cache[key].length + } + } + + if (this._length > this._max) trim(this) + } + , get : function () { return this._lengthCalculator } + , enumerable : true + }) + +Object.defineProperty(LRUCache.prototype, "length", + { get : function () { return this._length } + , enumerable : true + }) + + +Object.defineProperty(LRUCache.prototype, "itemCount", + { get : function () { return this._itemCount } + , enumerable : true + }) + +LRUCache.prototype.forEach = function (fn, thisp) { + thisp = thisp || this + var i = 0; + for (var k = this._mru - 1; k >= 0 && i < this._itemCount; k--) if (this._lruList[k]) { + i++ + var hit = this._lruList[k] + if (this._maxAge && (Date.now() - hit.now > this._maxAge)) { + del(this, hit) + if (!this._allowStale) hit = undefined + } + if (hit) { + fn.call(thisp, hit.value, hit.key, this) + } + } +} + +LRUCache.prototype.keys = function () { + var keys = new Array(this._itemCount) + var i = 0 + for (var k = this._mru - 1; k >= 0 && i < this._itemCount; k--) if (this._lruList[k]) { + var hit = this._lruList[k] + keys[i++] = hit.key + } + return keys +} + +LRUCache.prototype.values = function () { + var values = new Array(this._itemCount) + var i = 0 + for (var k = this._mru - 1; k >= 0 && i < this._itemCount; k--) if (this._lruList[k]) { + var hit = this._lruList[k] + values[i++] = hit.value + } + return values +} + +LRUCache.prototype.reset = function () { + if (this._dispose && this._cache) { + for (var k in this._cache) { + this._dispose(k, this._cache[k].value) + } + } + + this._cache = Object.create(null) // hash of items by key + this._lruList = Object.create(null) // list of items in order of use recency + this._mru = 0 // most recently used + this._lru = 0 // least recently used + this._length = 0 // number of items in the list + this._itemCount = 0 +} + +// Provided for debugging/dev purposes only. No promises whatsoever that +// this API stays stable. +LRUCache.prototype.dump = function () { + return this._cache +} + +LRUCache.prototype.dumpLru = function () { + return this._lruList +} + +LRUCache.prototype.set = function (key, value) { + if (hOP(this._cache, key)) { + // dispose of the old one before overwriting + if (this._dispose) this._dispose(key, this._cache[key].value) + if (this._maxAge) this._cache[key].now = Date.now() + this._cache[key].value = value + this.get(key) + return true + } + + var len = this._lengthCalculator(value) + var age = this._maxAge ? Date.now() : 0 + var hit = new Entry(key, value, this._mru++, len, age) + + // oversized objects fall out of cache automatically. + if (hit.length > this._max) { + if (this._dispose) this._dispose(key, value) + return false + } + + this._length += hit.length + this._lruList[hit.lu] = this._cache[key] = hit + this._itemCount ++ + + if (this._length > this._max) trim(this) + return true +} + +LRUCache.prototype.has = function (key) { + if (!hOP(this._cache, key)) return false + var hit = this._cache[key] + if (this._maxAge && (Date.now() - hit.now > this._maxAge)) { + return false + } + return true +} + +LRUCache.prototype.get = function (key) { + return get(this, key, true) +} + +LRUCache.prototype.peek = function (key) { + return get(this, key, false) +} + +LRUCache.prototype.pop = function () { + var hit = this._lruList[this._lru] + del(this, hit) + return hit || null +} + +LRUCache.prototype.del = function (key) { + del(this, this._cache[key]) +} + +function get (self, key, doUse) { + var hit = self._cache[key] + if (hit) { + if (self._maxAge && (Date.now() - hit.now > self._maxAge)) { + del(self, hit) + if (!self._allowStale) hit = undefined + } else { + if (doUse) use(self, hit) + } + if (hit) hit = hit.value + } + return hit +} + +function use (self, hit) { + shiftLU(self, hit) + hit.lu = self._mru ++ + self._lruList[hit.lu] = hit +} + +function trim (self) { + while (self._lru < self._mru && self._length > self._max) + del(self, self._lruList[self._lru]) +} + +function shiftLU (self, hit) { + delete self._lruList[ hit.lu ] + while (self._lru < self._mru && !self._lruList[self._lru]) self._lru ++ +} + +function del (self, hit) { + if (hit) { + if (self._dispose) self._dispose(hit.key, hit.value) + self._length -= hit.length + self._itemCount -- + delete self._cache[ hit.key ] + shiftLU(self, hit) + } +} + +// classy, since V8 prefers predictable objects. +function Entry (key, value, lu, length, now) { + this.key = key + this.value = value + this.lu = lu + this.length = length + this.now = now +} + +})() + +},{}],13:[function(_dereq_,module,exports){ +module.exports = sigmund +function sigmund (subject, maxSessions) { + maxSessions = maxSessions || 10; + var notes = []; + var analysis = ''; + var RE = RegExp; + + function psychoAnalyze (subject, session) { + if (session > maxSessions) return; + + if (typeof subject === 'function' || + typeof subject === 'undefined') { + return; + } + + if (typeof subject !== 'object' || !subject || + (subject instanceof RE)) { + analysis += subject; + return; + } + + if (notes.indexOf(subject) !== -1 || session === maxSessions) return; + + notes.push(subject); + analysis += '{'; + Object.keys(subject).forEach(function (issue, _, __) { + // pseudo-private values. skip those. + if (issue.charAt(0) === '_') return; + var to = typeof subject[issue]; + if (to === 'function' || to === 'undefined') return; + analysis += issue; + psychoAnalyze(subject[issue], session + 1); + }); + } + psychoAnalyze(subject, 0); + return analysis; +} + +// vim: set softtabstop=4 shiftwidth=4: + +},{}],14:[function(_dereq_,module,exports){ (function (Buffer){ function FilerBuffer (subject, encoding, nonZero) { @@ -2100,7 +3700,7 @@ Object.keys(Buffer).forEach(function (p) { module.exports = FilerBuffer; }).call(this,_dereq_("buffer").Buffer) -},{"buffer":6}],11:[function(_dereq_,module,exports){ +},{"buffer":6}],15:[function(_dereq_,module,exports){ var O_READ = 'READ'; var O_WRITE = 'WRITE'; var O_CREATE = 'CREATE'; @@ -2182,7 +3782,7 @@ module.exports = { } }; -},{}],12:[function(_dereq_,module,exports){ +},{}],16:[function(_dereq_,module,exports){ var MODE_FILE = _dereq_('./constants.js').MODE_FILE; module.exports = function DirectoryEntry(id, type) { @@ -2190,7 +3790,7 @@ module.exports = function DirectoryEntry(id, type) { this.type = type || MODE_FILE; }; -},{"./constants.js":11}],13:[function(_dereq_,module,exports){ +},{"./constants.js":15}],17:[function(_dereq_,module,exports){ (function (Buffer){ // Adapt encodings to work with Buffer or Uint8Array, they expect the latter function decode(buf) { @@ -2207,7 +3807,7 @@ module.exports = { }; }).call(this,_dereq_("buffer").Buffer) -},{"buffer":6}],14:[function(_dereq_,module,exports){ +},{"buffer":6}],18:[function(_dereq_,module,exports){ var errors = {}; [ /** @@ -2313,7 +3913,7 @@ var errors = {}; module.exports = errors; -},{}],15:[function(_dereq_,module,exports){ +},{}],19:[function(_dereq_,module,exports){ var _ = _dereq_('../../lib/nodash.js'); var Path = _dereq_('../path.js'); @@ -3129,6 +4729,8 @@ function read_data(context, ofd, buffer, offset, length, position, callback) { function read_file_data(error, result) { if(error) { callback(error); + } else if(result.mode === 'DIRECTORY') { + callback(new Errors.EISDIR('the named file is a directory', ofd.path)); } else { fileNode = result; context.getBuffer(fileNode.data, handle_file_data); @@ -4386,7 +5988,7 @@ module.exports = { ftruncate: ftruncate }; -},{"../../lib/nodash.js":4,"../buffer.js":10,"../constants.js":11,"../directory-entry.js":12,"../encoding.js":13,"../errors.js":14,"../node.js":19,"../open-file-description.js":20,"../path.js":21,"../stats.js":29,"../super-node.js":30}],16:[function(_dereq_,module,exports){ +},{"../../lib/nodash.js":4,"../buffer.js":14,"../constants.js":15,"../directory-entry.js":16,"../encoding.js":17,"../errors.js":18,"../node.js":23,"../open-file-description.js":24,"../path.js":25,"../stats.js":33,"../super-node.js":34}],20:[function(_dereq_,module,exports){ var _ = _dereq_('../../lib/nodash.js'); var isNullPath = _dereq_('../path.js').isNull; @@ -4476,6 +6078,9 @@ function FileSystem(options, callback) { fs.stdout = STDOUT; fs.stderr = STDERR; + // Expose Shell constructor + this.Shell = Shell.bind(undefined, this); + // Safely expose the list of open files and file // descriptor management functions var openFiles = {}; @@ -4723,13 +6328,9 @@ FileSystem.providers = providers; }; }); -FileSystem.prototype.Shell = function(options) { - return new Shell(this, options); -}; - module.exports = FileSystem; -},{"../../lib/intercom.js":3,"../../lib/nodash.js":4,"../constants.js":11,"../errors.js":14,"../fs-watcher.js":17,"../path.js":21,"../providers/index.js":22,"../shared.js":26,"../shell/shell.js":28,"./implementation.js":15}],17:[function(_dereq_,module,exports){ +},{"../../lib/intercom.js":3,"../../lib/nodash.js":4,"../constants.js":15,"../errors.js":18,"../fs-watcher.js":21,"../path.js":25,"../providers/index.js":26,"../shared.js":30,"../shell/shell.js":32,"./implementation.js":19}],21:[function(_dereq_,module,exports){ var EventEmitter = _dereq_('../lib/eventemitter.js'); var Path = _dereq_('./path.js'); var Intercom = _dereq_('../lib/intercom.js'); @@ -4793,15 +6394,16 @@ FSWatcher.prototype.constructor = FSWatcher; module.exports = FSWatcher; -},{"../lib/eventemitter.js":2,"../lib/intercom.js":3,"./path.js":21}],18:[function(_dereq_,module,exports){ +},{"../lib/eventemitter.js":2,"../lib/intercom.js":3,"./path.js":25}],22:[function(_dereq_,module,exports){ module.exports = { FileSystem: _dereq_('./filesystem/interface.js'), Buffer: _dereq_('./buffer.js'), Path: _dereq_('./path.js'), - Errors: _dereq_('./errors.js') + Errors: _dereq_('./errors.js'), + Shell: _dereq_('./shell/shell.js') }; -},{"./buffer.js":10,"./errors.js":14,"./filesystem/interface.js":16,"./path.js":21}],19:[function(_dereq_,module,exports){ +},{"./buffer.js":14,"./errors.js":18,"./filesystem/interface.js":20,"./path.js":25,"./shell/shell.js":32}],23:[function(_dereq_,module,exports){ var MODE_FILE = _dereq_('./constants.js').MODE_FILE; function Node(options) { @@ -4856,7 +6458,7 @@ Node.create = function(options, callback) { module.exports = Node; -},{"./constants.js":11}],20:[function(_dereq_,module,exports){ +},{"./constants.js":15}],24:[function(_dereq_,module,exports){ var Errors = _dereq_('./errors.js'); function OpenFileDescription(path, id, flags, position) { @@ -4889,7 +6491,7 @@ OpenFileDescription.prototype.getNode = function(context, callback) { module.exports = OpenFileDescription; -},{"./errors.js":14}],21:[function(_dereq_,module,exports){ +},{"./errors.js":18}],25:[function(_dereq_,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -4958,7 +6560,7 @@ function resolve() { resolvedAbsolute = false; for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { - // XXXidbfs: we don't have process.cwd() so we use '/' as a fallback + // XXXfiler: we don't have process.cwd() so we use '/' as a fallback var path = (i >= 0) ? arguments[i] : '/'; // Skip empty and invalid entries @@ -5076,7 +6678,7 @@ function basename(path, ext) { if (ext && f.substr(-1 * ext.length) === ext) { f = f.substr(0, f.length - ext.length); } - // XXXidbfs: node.js just does `return f` + // XXXfiler: node.js just does `return f` return f === "" ? "/" : f; } @@ -5098,7 +6700,19 @@ function isNull(path) { return false; } -// XXXidbfs: we don't support path.exists() or path.existsSync(), which +// Make sure we don't double-add a trailing slash (e.g., '/' -> '//') +function addTrailing(path) { + return path.replace(/\/*$/, '/'); +} + +// Deal with multiple slashes at the end, one, or none +// and make sure we don't return the empty string. +function removeTrailing(path) { + path = path.replace(/\/*$/, ''); + return path === '' ? '/' : path; +} + +// XXXfiler: we don't support path.exists() or path.existsSync(), which // are deprecated, and need a FileSystem instance to work. Use fs.stat(). module.exports = { @@ -5112,10 +6726,13 @@ module.exports = { basename: basename, extname: extname, isAbsolute: isAbsolute, - isNull: isNull + isNull: isNull, + // Non-node but useful... + addTrailing: addTrailing, + removeTrailing: removeTrailing }; -},{}],22:[function(_dereq_,module,exports){ +},{}],26:[function(_dereq_,module,exports){ var IndexedDB = _dereq_('./indexeddb.js'); var WebSQL = _dereq_('./websql.js'); var Memory = _dereq_('./memory.js'); @@ -5152,7 +6769,7 @@ module.exports = { }()) }; -},{"./indexeddb.js":23,"./memory.js":24,"./websql.js":25}],23:[function(_dereq_,module,exports){ +},{"./indexeddb.js":27,"./memory.js":28,"./websql.js":29}],27:[function(_dereq_,module,exports){ (function (global,Buffer){ var FILE_SYSTEM_NAME = _dereq_('../constants.js').FILE_SYSTEM_NAME; var FILE_STORE_NAME = _dereq_('../constants.js').FILE_STORE_NAME; @@ -5304,7 +6921,7 @@ IndexedDB.prototype.getReadWriteContext = function() { module.exports = IndexedDB; }).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer) -},{"../buffer.js":10,"../constants.js":11,"../errors.js":14,"buffer":6}],24:[function(_dereq_,module,exports){ +},{"../buffer.js":14,"../constants.js":15,"../errors.js":18,"buffer":6}],28:[function(_dereq_,module,exports){ var FILE_SYSTEM_NAME = _dereq_('../constants.js').FILE_SYSTEM_NAME; // NOTE: prefer setImmediate to nextTick for proper recursion yielding. // see https://github.com/js-platform/filer/pull/24 @@ -5396,7 +7013,7 @@ Memory.prototype.getReadWriteContext = function() { module.exports = Memory; -},{"../../lib/async.js":1,"../constants.js":11}],25:[function(_dereq_,module,exports){ +},{"../../lib/async.js":1,"../constants.js":15}],29:[function(_dereq_,module,exports){ (function (global){ var FILE_SYSTEM_NAME = _dereq_('../constants.js').FILE_SYSTEM_NAME; var FILE_STORE_NAME = _dereq_('../constants.js').FILE_STORE_NAME; @@ -5571,7 +7188,7 @@ WebSQL.prototype.getReadWriteContext = function() { module.exports = WebSQL; }).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../buffer.js":10,"../constants.js":11,"../errors.js":14,"base64-arraybuffer":5}],26:[function(_dereq_,module,exports){ +},{"../buffer.js":14,"../constants.js":15,"../errors.js":18,"base64-arraybuffer":5}],30:[function(_dereq_,module,exports){ function guid() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); @@ -5599,7 +7216,7 @@ module.exports = { nop: nop }; -},{}],27:[function(_dereq_,module,exports){ +},{}],31:[function(_dereq_,module,exports){ var defaults = _dereq_('../constants.js').ENVIRONMENT; module.exports = function Environment(env) { @@ -5616,12 +7233,13 @@ module.exports = function Environment(env) { }; }; -},{"../constants.js":11}],28:[function(_dereq_,module,exports){ +},{"../constants.js":15}],32:[function(_dereq_,module,exports){ var Path = _dereq_('../path.js'); var Errors = _dereq_('../errors.js'); var Environment = _dereq_('./environment.js'); var async = _dereq_('../../lib/async.js'); var Encoding = _dereq_('../encoding.js'); +var minimatch = _dereq_('minimatch'); function Shell(fs, options) { options = options || {}; @@ -6045,9 +7663,125 @@ Shell.prototype.mkdirp = function(path, callback) { _mkdirp(path, callback); }; +/** + * Recursively walk a directory tree, reporting back all paths + * that were found along the way. The `path` must be a dir. + * Valid options include a `regex` for pattern matching paths + * and an `exec` function of the form `function(path, next)` where + * `path` is the current path that was found (dir paths have an '/' + * appended) and `next` is a callback to call when done processing + * the current path, passing any error object back as the first argument. + * `find` returns a flat array of absolute paths for all matching/found + * paths as the final argument to the callback. + */ + Shell.prototype.find = function(path, options, callback) { + var sh = this; + var fs = sh.fs; + if(typeof options === 'function') { + callback = options; + options = {}; + } + options = options || {}; + callback = callback || function(){}; + + var exec = options.exec || function(path, next) { next(); }; + var found = []; + + if(!path) { + callback(new Errors.EINVAL('Missing path argument')); + return; + } + + function processPath(path, callback) { + exec(path, function(err) { + if(err) { + callback(err); + return; + } + + found.push(path); + callback(); + }); + } + + function maybeProcessPath(path, callback) { + // Test the path against the user's regex, name, path primaries (if any) + // and remove any trailing slashes added previously. + var rawPath = Path.removeTrailing(path); + + // Check entire path against provided regex, if any + if(options.regex && !options.regex.test(rawPath)) { + callback(); + return; + } + + // Check basename for matches against name primary, if any + if(options.name && !minimatch(Path.basename(rawPath), options.name)) { + callback(); + return; + } + + // Check dirname for matches against path primary, if any + if(options.path && !minimatch(Path.dirname(rawPath), options.path)) { + callback(); + return; + } + + processPath(path, callback); + } + + function walk(path, callback) { + path = Path.resolve(sh.pwd(), path); + + // The path is either a file or dir, and instead of doing + // a stat() to determine it first, we just try to readdir() + // and it will either work or not, and we handle the non-dir error. + fs.readdir(path, function(err, entries) { + if(err) { + if(err.code === 'ENOTDIR' /* file case, ignore error */) { + maybeProcessPath(path, callback); + } else { + callback(err); + } + return; + } + + // Path is really a dir, add a trailing / and report it found + maybeProcessPath(Path.addTrailing(path), function(err) { + if(err) { + callback(err); + return; + } + + entries = entries.map(function(entry) { + return Path.join(path, entry); + }); + + async.eachSeries(entries, walk, function(err) { + callback(err, found); + }); + }); + }); + } + + // Make sure we are starting with a dir path + fs.stat(path, function(err, stats) { + if(err) { + callback(err); + return; + } + if(!stats.isDirectory()) { + callback(new Errors.ENOTDIR(null, path)); + return; + } + + walk(path, callback); + }); +}; + module.exports = Shell; -},{"../../lib/async.js":1,"../encoding.js":13,"../errors.js":14,"../path.js":21,"./environment.js":27}],29:[function(_dereq_,module,exports){ +},{"../../lib/async.js":1,"../encoding.js":17,"../errors.js":18,"../path.js":25,"./environment.js":31,"minimatch":11}],33:[function(_dereq_,module,exports){ var Constants = _dereq_('./constants.js'); function Stats(fileNode, devName) { @@ -6084,7 +7818,7 @@ function() { module.exports = Stats; -},{"./constants.js":11}],30:[function(_dereq_,module,exports){ +},{"./constants.js":15}],34:[function(_dereq_,module,exports){ var Constants = _dereq_('./constants.js'); function SuperNode(options) { @@ -6112,6 +7846,6 @@ SuperNode.create = function(options, callback) { module.exports = SuperNode; -},{"./constants.js":11}]},{},[18]) -(18) +},{"./constants.js":15}]},{},[22]) +(22) }); \ No newline at end of file diff --git a/dist/filer.min.js b/dist/filer.min.js index e60d387..1a96580 100644 --- a/dist/filer.min.js +++ b/dist/filer.min.js @@ -1,4 +1,4 @@ -/*! filer 0.0.34 2014-10-24 */ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Filer=t()}}(function(){var t;return function e(t,n,r){function i(a,u){if(!n[a]){if(!t[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(o)return o(a,!0);throw Error("Cannot find module '"+a+"'")}var f=n[a]={exports:{}};t[a][0].call(f.exports,function(e){var n=t[a][1][e];return i(n?n:e)},f,f.exports,e,t,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;r.length>a;a++)i(r[a]);return i}({1:[function(e,n){(function(e){(function(){var r={};void 0!==e&&e.nextTick?(r.nextTick=e.nextTick,r.setImmediate="undefined"!=typeof setImmediate?function(t){setImmediate(t)}:r.nextTick):"function"==typeof setImmediate?(r.nextTick=function(t){setImmediate(t)},r.setImmediate=r.nextTick):(r.nextTick=function(t){setTimeout(t,0)},r.setImmediate=r.nextTick),r.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)return n();var r=0,i=function(){e(t[r],function(e){e?(n(e),n=function(){}):(r+=1,r>=t.length?n():i())})};i()},r.forEachSeries=r.eachSeries,t!==void 0&&t.amd?t([],function(){return r}):n!==void 0&&n.exports?n.exports=r:root.async=r})()}).call(this,e("JkpR2F"))},{JkpR2F:9}],2:[function(t,e){function n(t,e){for(var n=e.length-1;n>=0;n--)e[n]===t&&e.splice(n,1);return e}var r=function(){};r.createInterface=function(t){var e={};return e.on=function(e,n){this[t]===void 0&&(this[t]={}),this[t].hasOwnProperty(e)||(this[t][e]=[]),this[t][e].push(n)},e.off=function(e,r){void 0!==this[t]&&this[t].hasOwnProperty(e)&&n(r,this[t][e])},e.trigger=function(e){if(this[t]!==void 0&&this[t].hasOwnProperty(e))for(var n=Array.prototype.slice.call(arguments,1),r=0;this[t][e].length>r;r++)this[t][e][r].apply(this[t][e][r],n)},e.removeAllListeners=function(e){if(void 0!==this[t]){var n=this;n[t][e].forEach(function(t){n.off(e,t)})}},e};var i=r.createInterface("_handlers");r.prototype._on=i.on,r.prototype._off=i.off,r.prototype._trigger=i.trigger;var o=r.createInterface("handlers");r.prototype.on=function(){o.on.apply(this,arguments),Array.prototype.unshift.call(arguments,"on"),this._trigger.apply(this,arguments)},r.prototype.off=o.off,r.prototype.trigger=o.trigger,r.prototype.removeAllListeners=o.removeAllListeners,e.exports=r},{}],3:[function(t,e){(function(n){function r(t,e){var n=0;return function(){var r=Date.now();r-n>t&&(n=r,e.apply(this,arguments))}}function i(t,e){if(void 0!==t&&t||(t={}),"object"==typeof e)for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function o(){var t=this,e=Date.now();this.origin=u(),this.lastMessage=e,this.receivedIDs={},this.previousValues={};var r=function(){t._onStorageEvent.apply(t,arguments)};"undefined"!=typeof document&&(document.attachEvent?document.attachEvent("onstorage",r):n.addEventListener("storage",r,!1))}var a=t("./eventemitter.js"),u=t("../src/shared.js").guid,s=function(t){return t===void 0||t.localStorage===void 0?{getItem:function(){},setItem:function(){},removeItem:function(){}}:t.localStorage}(n);o.prototype._transaction=function(t){function e(){if(!a){var c=Date.now(),d=0|s.getItem(l);if(d&&r>c-d)return u||(o._on("storage",e),u=!0),f=setTimeout(e,i),void 0;a=!0,s.setItem(l,c),t(),n()}}function n(){u&&o._off("storage",e),f&&clearTimeout(f),s.removeItem(l)}var r=1e3,i=20,o=this,a=!1,u=!1,f=null;e()},o.prototype._cleanup_emit=r(100,function(){var t=this;t._transaction(function(){var t,e=Date.now(),n=e-d,r=0;try{t=JSON.parse(s.getItem(f)||"[]")}catch(i){t=[]}for(var o=t.length-1;o>=0;o--)n>t[o].timestamp&&(t.splice(o,1),r++);r>0&&s.setItem(f,JSON.stringify(t))})}),o.prototype._cleanup_once=r(100,function(){var t=this;t._transaction(function(){var e,n;Date.now();var r=0;try{n=JSON.parse(s.getItem(c)||"{}")}catch(i){n={}}for(e in n)t._once_expired(e,n)&&(delete n[e],r++);r>0&&s.setItem(c,JSON.stringify(n))})}),o.prototype._once_expired=function(t,e){if(!e)return!0;if(!e.hasOwnProperty(t))return!0;if("object"!=typeof e[t])return!0;var n=e[t].ttl||p,r=Date.now(),i=e[t].timestamp;return r-n>i},o.prototype._localStorageChanged=function(t,e){if(t&&t.key)return t.key===e;var n=s.getItem(e);return n===this.previousValues[e]?!1:(this.previousValues[e]=n,!0)},o.prototype._onStorageEvent=function(t){t=t||n.event;var e=this;this._localStorageChanged(t,f)&&this._transaction(function(){var t,n=Date.now(),r=s.getItem(f);try{t=JSON.parse(r||"[]")}catch(i){t=[]}for(var o=0;t.length>o;o++)if(t[o].origin!==e.origin&&!(t[o].timestampr;r++)if(e.call(n,t[r],r,t)===m)return}else{var o=o(t);for(r=0,i=o.length;i>r;r++)if(e.call(n,t[o[r]],o[r],t)===m)return}}function a(t,e,n){e||(e=i);var r=!1;return null==t?r:p&&t.some===p?t.some(e,n):(o(t,function(t,i,o){return r||(r=e.call(n,t,i,o))?m:void 0}),!!r)}function u(t,e){return null==t?!1:d&&t.indexOf===d?-1!=t.indexOf(e):a(t,function(t){return t===e})}function s(t){this.value=t}function f(t){return t&&"object"==typeof t&&!Array.isArray(t)&&g.call(t,"__wrapped__")?t:new s(t)}var c=Array.prototype,l=c.forEach,d=c.indexOf,p=c.some,h=Object.prototype,g=h.hasOwnProperty,v=Object.keys,m={},E=v||function(t){if(t!==Object(t))throw new TypeError("Invalid object");var e=[];for(var r in t)n(t,r)&&e.push(r);return e};s.prototype.has=function(t){return n(this.value,t)},s.prototype.contains=function(t){return u(this.value,t)},s.prototype.size=function(){return r(this.value)},e.exports=f},{}],5:[function(t,e,n){(function(t){"use strict";n.encode=function(e){var n,r=new Uint8Array(e),i=r.length,o="";for(n=0;i>n;n+=3)o+=t[r[n]>>2],o+=t[(3&r[n])<<4|r[n+1]>>4],o+=t[(15&r[n+1])<<2|r[n+2]>>6],o+=t[63&r[n+2]];return 2===i%3?o=o.substring(0,o.length-1)+"=":1===i%3&&(o=o.substring(0,o.length-2)+"=="),o},n.decode=function(e){var n,r,i,o,a,u=.75*e.length,s=e.length,f=0;"="===e[e.length-1]&&(u--,"="===e[e.length-2]&&u--);var c=new ArrayBuffer(u),l=new Uint8Array(c);for(n=0;s>n;n+=4)r=t.indexOf(e[n]),i=t.indexOf(e[n+1]),o=t.indexOf(e[n+2]),a=t.indexOf(e[n+3]),l[f++]=r<<2|i>>4,l[f++]=(15&i)<<4|o>>2,l[f++]=(3&o)<<6|63&a;return c}})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},{}],6:[function(t,e,n){function r(t,e,n){if(!(this instanceof r))return new r(t,e,n);var i=typeof t;"base64"===e&&"string"===i&&(t=N(t));var o;if("number"===i)o=_(t);else if("string"===i)o=r.byteLength(t,e);else{if("object"!==i)throw Error("First argument needs to be a number, array or string.");o=_(t.length)}var a;r._useTypedArrays?a=r._augment(new Uint8Array(o)):(a=this,a.length=o,a._isBuffer=!0);var u;if(r._useTypedArrays&&"number"==typeof t.byteLength)a._set(t);else if(L(t))if(r.isBuffer(t))for(u=0;o>u;u++)a[u]=t.readUInt8(u);else for(u=0;o>u;u++)a[u]=(t[u]%256+256)%256;else if("string"===i)a.write(t,0,e);else if("number"===i&&!r._useTypedArrays&&!n)for(u=0;o>u;u++)a[u]=0;return a}function i(t,e,n,r){n=Number(n)||0;var i=t.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;var o=e.length;W(0===o%2,"Invalid hex string"),r>o/2&&(r=o/2);for(var a=0;r>a;a++){var u=parseInt(e.substr(2*a,2),16);W(!isNaN(u),"Invalid hex string"),t[n+a]=u}return a}function o(t,e,n,r){var i=P(M(e),t,n,r);return i}function a(t,e,n,r){var i=P(F(e),t,n,r);return i}function u(t,e,n,r){return a(t,e,n,r)}function s(t,e,n,r){var i=P(k(e),t,n,r);return i}function f(t,e,n,r){var i=P(C(e),t,n,r);return i}function c(t,e,n){return 0===e&&n===t.length?z.fromByteArray(t):z.fromByteArray(t.slice(e,n))}function l(t,e,n){var r="",i="";n=Math.min(t.length,n);for(var o=e;n>o;o++)127>=t[o]?(r+=U(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return r+U(i)}function d(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;n>i;i++)r+=String.fromCharCode(t[i]);return r}function p(t,e,n){return d(t,e,n)}function h(t,e,n){var r=t.length;(!e||0>e)&&(e=0),(!n||0>n||n>r)&&(n=r);for(var i="",o=e;n>o;o++)i+=B(t[o]);return i}function g(t,e,n){for(var r=t.slice(e,n),i="",o=0;r.length>o;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function v(t,e,n,r){r||(W("boolean"==typeof n,"missing or invalid endian"),W(void 0!==e&&null!==e,"missing offset"),W(t.length>e+1,"Trying to read beyond buffer length"));var i=t.length;if(!(e>=i)){var o;return n?(o=t[e],i>e+1&&(o|=t[e+1]<<8)):(o=t[e]<<8,i>e+1&&(o|=t[e+1])),o}}function m(t,e,n,r){r||(W("boolean"==typeof n,"missing or invalid endian"),W(void 0!==e&&null!==e,"missing offset"),W(t.length>e+3,"Trying to read beyond buffer length"));var i=t.length;if(!(e>=i)){var o;return n?(i>e+2&&(o=t[e+2]<<16),i>e+1&&(o|=t[e+1]<<8),o|=t[e],i>e+3&&(o+=t[e+3]<<24>>>0)):(i>e+1&&(o=t[e+1]<<16),i>e+2&&(o|=t[e+2]<<8),i>e+3&&(o|=t[e+3]),o+=t[e]<<24>>>0),o}}function E(t,e,n,r){r||(W("boolean"==typeof n,"missing or invalid endian"),W(void 0!==e&&null!==e,"missing offset"),W(t.length>e+1,"Trying to read beyond buffer length"));var i=t.length;if(!(e>=i)){var o=v(t,e,n,!0),a=32768&o;return a?-1*(65535-o+1):o}}function y(t,e,n,r){r||(W("boolean"==typeof n,"missing or invalid endian"),W(void 0!==e&&null!==e,"missing offset"),W(t.length>e+3,"Trying to read beyond buffer length"));var i=t.length;if(!(e>=i)){var o=m(t,e,n,!0),a=2147483648&o;return a?-1*(4294967295-o+1):o}}function w(t,e,n,r){return r||(W("boolean"==typeof n,"missing or invalid endian"),W(t.length>e+3,"Trying to read beyond buffer length")),q.read(t,e,n,23,4)}function b(t,e,n,r){return r||(W("boolean"==typeof n,"missing or invalid endian"),W(t.length>e+7,"Trying to read beyond buffer length")),q.read(t,e,n,52,8)}function I(t,e,n,r,i){i||(W(void 0!==e&&null!==e,"missing value"),W("boolean"==typeof r,"missing or invalid endian"),W(void 0!==n&&null!==n,"missing offset"),W(t.length>n+1,"trying to write beyond buffer length"),V(e,65535));var o=t.length;if(!(n>=o)){for(var a=0,u=Math.min(o-n,2);u>a;a++)t[n+a]=(e&255<<8*(r?a:1-a))>>>8*(r?a:1-a);return n+2}}function O(t,e,n,r,i){i||(W(void 0!==e&&null!==e,"missing value"),W("boolean"==typeof r,"missing or invalid endian"),W(void 0!==n&&null!==n,"missing offset"),W(t.length>n+3,"trying to write beyond buffer length"),V(e,4294967295));var o=t.length;if(!(n>=o)){for(var a=0,u=Math.min(o-n,4);u>a;a++)t[n+a]=255&e>>>8*(r?a:3-a);return n+4}}function j(t,e,n,r,i){i||(W(void 0!==e&&null!==e,"missing value"),W("boolean"==typeof r,"missing or invalid endian"),W(void 0!==n&&null!==n,"missing offset"),W(t.length>n+1,"Trying to write beyond buffer length"),Y(e,32767,-32768));var o=t.length;if(!(n>=o))return e>=0?I(t,e,n,r,i):I(t,65535+e+1,n,r,i),n+2}function T(t,e,n,r,i){i||(W(void 0!==e&&null!==e,"missing value"),W("boolean"==typeof r,"missing or invalid endian"),W(void 0!==n&&null!==n,"missing offset"),W(t.length>n+3,"Trying to write beyond buffer length"),Y(e,2147483647,-2147483648));var o=t.length;if(!(n>=o))return e>=0?O(t,e,n,r,i):O(t,4294967295+e+1,n,r,i),n+4}function A(t,e,n,r,i){i||(W(void 0!==e&&null!==e,"missing value"),W("boolean"==typeof r,"missing or invalid endian"),W(void 0!==n&&null!==n,"missing offset"),W(t.length>n+3,"Trying to write beyond buffer length"),X(e,3.4028234663852886e38,-3.4028234663852886e38));var o=t.length;if(!(n>=o))return q.write(t,e,n,r,23,4),n+4}function S(t,e,n,r,i){i||(W(void 0!==e&&null!==e,"missing value"),W("boolean"==typeof r,"missing or invalid endian"),W(void 0!==n&&null!==n,"missing offset"),W(t.length>n+7,"Trying to write beyond buffer length"),X(e,1.7976931348623157e308,-1.7976931348623157e308));var o=t.length;if(!(n>=o))return q.write(t,e,n,r,52,8),n+8}function N(t){for(t=x(t).replace(Q,"");0!==t.length%4;)t+="=";return t}function x(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function D(t,e,n){return"number"!=typeof t?n:(t=~~t,t>=e?e:t>=0?t:(t+=e,t>=0?t:0))}function _(t){return t=~~Math.ceil(+t),0>t?0:t}function R(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function L(t){return R(t)||r.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function B(t){return 16>t?"0"+t.toString(16):t.toString(16)}function M(t){for(var e=[],n=0;t.length>n;n++){var r=t.charCodeAt(n);if(127>=r)e.push(r);else{var i=n;r>=55296&&57343>=r&&n++;for(var o=encodeURIComponent(t.slice(i,n+1)).substr(1).split("%"),a=0;o.length>a;a++)e.push(parseInt(o[a],16))}}return e}function F(t){for(var e=[],n=0;t.length>n;n++)e.push(255&t.charCodeAt(n));return e}function C(t){for(var e,n,r,i=[],o=0;t.length>o;o++)e=t.charCodeAt(o),n=e>>8,r=e%256,i.push(r),i.push(n);return i}function k(t){return z.toByteArray(t)}function P(t,e,n,r){for(var i=0;r>i&&!(i+n>=e.length||i>=t.length);i++)e[i+n]=t[i];return i}function U(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}function V(t,e){W("number"==typeof t,"cannot write a non-number as a number"),W(t>=0,"specified a negative value for writing an unsigned value"),W(e>=t,"value is larger than maximum value for type"),W(Math.floor(t)===t,"value has a fractional component")}function Y(t,e,n){W("number"==typeof t,"cannot write a non-number as a number"),W(e>=t,"value larger than maximum allowed value"),W(t>=n,"value smaller than minimum allowed value"),W(Math.floor(t)===t,"value has a fractional component")}function X(t,e,n){W("number"==typeof t,"cannot write a non-number as a number"),W(e>=t,"value larger than maximum allowed value"),W(t>=n,"value smaller than minimum allowed value")}function W(t,e){if(!t)throw Error(e||"Failed assertion")}var z=t("base64-js"),q=t("ieee754");n.Buffer=r,n.SlowBuffer=r,n.INSPECT_MAX_BYTES=50,r.poolSize=8192,r._useTypedArrays=function(){try{var t=new ArrayBuffer(0),e=new Uint8Array(t);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray}catch(n){return!1}}(),r.isEncoding=function(t){switch((t+"").toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},r.isBuffer=function(t){return!(null===t||void 0===t||!t._isBuffer)},r.byteLength=function(t,e){var n;switch(t=""+t,e||"utf8"){case"hex":n=t.length/2;break;case"utf8":case"utf-8":n=M(t).length;break;case"ascii":case"binary":case"raw":n=t.length;break;case"base64":n=k(t).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":n=2*t.length;break;default:throw Error("Unknown encoding")}return n},r.concat=function(t,e){if(W(R(t),"Usage: Buffer.concat(list[, length])"),0===t.length)return new r(0);if(1===t.length)return t[0];var n;if(void 0===e)for(e=0,n=0;t.length>n;n++)e+=t[n].length;var i=new r(e),o=0;for(n=0;t.length>n;n++){var a=t[n];a.copy(i,o),o+=a.length}return i},r.compare=function(t,e){W(r.isBuffer(t)&&r.isBuffer(e),"Arguments must be Buffers");for(var n=t.length,i=e.length,o=0,a=Math.min(n,i);a>o&&t[o]===e[o];o++);return o!==a&&(n=t[o],i=e[o]),i>n?-1:n>i?1:0},r.prototype.write=function(t,e,n,r){if(isFinite(e))isFinite(n)||(r=n,n=void 0);else{var c=r;r=e,e=n,n=c}e=Number(e)||0;var l=this.length-e;n?(n=Number(n),n>l&&(n=l)):n=l,r=((r||"utf8")+"").toLowerCase();var d;switch(r){case"hex":d=i(this,t,e,n);break;case"utf8":case"utf-8":d=o(this,t,e,n);break;case"ascii":d=a(this,t,e,n);break;case"binary":d=u(this,t,e,n);break;case"base64":d=s(this,t,e,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":d=f(this,t,e,n);break;default:throw Error("Unknown encoding")}return d},r.prototype.toString=function(t,e,n){var r=this;if(t=((t||"utf8")+"").toLowerCase(),e=Number(e)||0,n=void 0===n?r.length:Number(n),n===e)return"";var i;switch(t){case"hex":i=h(r,e,n);break;case"utf8":case"utf-8":i=l(r,e,n);break;case"ascii":i=d(r,e,n);break;case"binary":i=p(r,e,n);break;case"base64":i=c(r,e,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=g(r,e,n);break;default:throw Error("Unknown encoding")}return i},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.equals=function(t){return W(r.isBuffer(t),"Argument must be a Buffer"),0===r.compare(this,t)},r.prototype.compare=function(t){return W(r.isBuffer(t),"Argument must be a Buffer"),r.compare(this,t)},r.prototype.copy=function(t,e,n,i){var o=this;if(n||(n=0),i||0===i||(i=this.length),e||(e=0),i!==n&&0!==t.length&&0!==o.length){W(i>=n,"sourceEnd < sourceStart"),W(e>=0&&t.length>e,"targetStart out of bounds"),W(n>=0&&o.length>n,"sourceStart out of bounds"),W(i>=0&&o.length>=i,"sourceEnd out of bounds"),i>this.length&&(i=this.length),i-n>t.length-e&&(i=t.length-e+n);var a=i-n;if(100>a||!r._useTypedArrays)for(var u=0;a>u;u++)t[u+e]=this[u+n];else t._set(this.subarray(n,n+a),e)}},r.prototype.slice=function(t,e){var n=this.length;if(t=D(t,n,0),e=D(e,n,n),r._useTypedArrays)return r._augment(this.subarray(t,e));for(var i=e-t,o=new r(i,void 0,!0),a=0;i>a;a++)o[a]=this[a+t];return o},r.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},r.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},r.prototype.readUInt8=function(t,e){return e||(W(void 0!==t&&null!==t,"missing offset"),W(this.length>t,"Trying to read beyond buffer length")),t>=this.length?void 0:this[t]},r.prototype.readUInt16LE=function(t,e){return v(this,t,!0,e)},r.prototype.readUInt16BE=function(t,e){return v(this,t,!1,e)},r.prototype.readUInt32LE=function(t,e){return m(this,t,!0,e)},r.prototype.readUInt32BE=function(t,e){return m(this,t,!1,e)},r.prototype.readInt8=function(t,e){if(e||(W(void 0!==t&&null!==t,"missing offset"),W(this.length>t,"Trying to read beyond buffer length")),!(t>=this.length)){var n=128&this[t];return n?-1*(255-this[t]+1):this[t]}},r.prototype.readInt16LE=function(t,e){return E(this,t,!0,e)},r.prototype.readInt16BE=function(t,e){return E(this,t,!1,e)},r.prototype.readInt32LE=function(t,e){return y(this,t,!0,e)},r.prototype.readInt32BE=function(t,e){return y(this,t,!1,e)},r.prototype.readFloatLE=function(t,e){return w(this,t,!0,e)},r.prototype.readFloatBE=function(t,e){return w(this,t,!1,e)},r.prototype.readDoubleLE=function(t,e){return b(this,t,!0,e)},r.prototype.readDoubleBE=function(t,e){return b(this,t,!1,e)},r.prototype.writeUInt8=function(t,e,n){return n||(W(void 0!==t&&null!==t,"missing value"),W(void 0!==e&&null!==e,"missing offset"),W(this.length>e,"trying to write beyond buffer length"),V(t,255)),e>=this.length?void 0:(this[e]=t,e+1)},r.prototype.writeUInt16LE=function(t,e,n){return I(this,t,e,!0,n)},r.prototype.writeUInt16BE=function(t,e,n){return I(this,t,e,!1,n)},r.prototype.writeUInt32LE=function(t,e,n){return O(this,t,e,!0,n)},r.prototype.writeUInt32BE=function(t,e,n){return O(this,t,e,!1,n)},r.prototype.writeInt8=function(t,e,n){return n||(W(void 0!==t&&null!==t,"missing value"),W(void 0!==e&&null!==e,"missing offset"),W(this.length>e,"Trying to write beyond buffer length"),Y(t,127,-128)),e>=this.length?void 0:(t>=0?this.writeUInt8(t,e,n):this.writeUInt8(255+t+1,e,n),e+1)},r.prototype.writeInt16LE=function(t,e,n){return j(this,t,e,!0,n)},r.prototype.writeInt16BE=function(t,e,n){return j(this,t,e,!1,n)},r.prototype.writeInt32LE=function(t,e,n){return T(this,t,e,!0,n)},r.prototype.writeInt32BE=function(t,e,n){return T(this,t,e,!1,n)},r.prototype.writeFloatLE=function(t,e,n){return A(this,t,e,!0,n)},r.prototype.writeFloatBE=function(t,e,n){return A(this,t,e,!1,n)},r.prototype.writeDoubleLE=function(t,e,n){return S(this,t,e,!0,n)},r.prototype.writeDoubleBE=function(t,e,n){return S(this,t,e,!1,n)},r.prototype.fill=function(t,e,n){if(t||(t=0),e||(e=0),n||(n=this.length),W(n>=e,"end < start"),n!==e&&0!==this.length){W(e>=0&&this.length>e,"start out of bounds"),W(n>=0&&this.length>=n,"end out of bounds");var r;if("number"==typeof t)for(r=e;n>r;r++)this[r]=t;else{var i=M(""+t),o=i.length;for(r=e;n>r;r++)this[r]=i[r%o]}return this}},r.prototype.inspect=function(){for(var t=[],e=this.length,r=0;e>r;r++)if(t[r]=B(this[r]),r===n.INSPECT_MAX_BYTES){t[r+1]="...";break}return""},r.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(r._useTypedArrays)return new r(this).buffer;for(var t=new Uint8Array(this.length),e=0,n=t.length;n>e;e+=1)t[e]=this[e];return t.buffer}throw Error("Buffer.toArrayBuffer not supported in this browser")};var J=r.prototype;r._augment=function(t){return t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=J.get,t.set=J.set,t.write=J.write,t.toString=J.toString,t.toLocaleString=J.toString,t.toJSON=J.toJSON,t.equals=J.equals,t.compare=J.compare,t.copy=J.copy,t.slice=J.slice,t.readUInt8=J.readUInt8,t.readUInt16LE=J.readUInt16LE,t.readUInt16BE=J.readUInt16BE,t.readUInt32LE=J.readUInt32LE,t.readUInt32BE=J.readUInt32BE,t.readInt8=J.readInt8,t.readInt16LE=J.readInt16LE,t.readInt16BE=J.readInt16BE,t.readInt32LE=J.readInt32LE,t.readInt32BE=J.readInt32BE,t.readFloatLE=J.readFloatLE,t.readFloatBE=J.readFloatBE,t.readDoubleLE=J.readDoubleLE,t.readDoubleBE=J.readDoubleBE,t.writeUInt8=J.writeUInt8,t.writeUInt16LE=J.writeUInt16LE,t.writeUInt16BE=J.writeUInt16BE,t.writeUInt32LE=J.writeUInt32LE,t.writeUInt32BE=J.writeUInt32BE,t.writeInt8=J.writeInt8,t.writeInt16LE=J.writeInt16LE,t.writeInt16BE=J.writeInt16BE,t.writeInt32LE=J.writeInt32LE,t.writeInt32BE=J.writeInt32BE,t.writeFloatLE=J.writeFloatLE,t.writeFloatBE=J.writeFloatBE,t.writeDoubleLE=J.writeDoubleLE,t.writeDoubleBE=J.writeDoubleBE,t.fill=J.fill,t.inspect=J.inspect,t.toArrayBuffer=J.toArrayBuffer,t};var Q=/[^+\/0-9A-z]/g},{"base64-js":7,ieee754:8}],7:[function(t,e,n){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===a?62:e===u?63:s>e?-1:s+10>e?e-s+26+26:c+26>e?e-c:f+26>e?e-f+26:void 0}function n(t){function n(t){f[l++]=t}var r,i,a,u,s,f;if(t.length%4>0)throw Error("Invalid string. Length must be a multiple of 4");var c=t.length;s="="===t.charAt(c-2)?2:"="===t.charAt(c-1)?1:0,f=new o(3*t.length/4-s),a=s>0?t.length-4:t.length;var l=0;for(r=0,i=0;a>r;r+=4,i+=3)u=e(t.charAt(r))<<18|e(t.charAt(r+1))<<12|e(t.charAt(r+2))<<6|e(t.charAt(r+3)),n((16711680&u)>>16),n((65280&u)>>8),n(255&u);return 2===s?(u=e(t.charAt(r))<<2|e(t.charAt(r+1))>>4,n(255&u)):1===s&&(u=e(t.charAt(r))<<10|e(t.charAt(r+1))<<4|e(t.charAt(r+2))>>2,n(255&u>>8),n(255&u)),f}function i(t){function e(t){return r.charAt(t)}function n(t){return e(63&t>>18)+e(63&t>>12)+e(63&t>>6)+e(63&t)}var i,o,a,u=t.length%3,s="";for(i=0,a=t.length-u;a>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],s+=n(o);switch(u){case 1:o=t[t.length-1],s+=e(o>>2),s+=e(63&o<<4),s+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],s+=e(o>>10),s+=e(63&o>>4),s+=e(63&o<<2),s+="="}return s}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="+".charCodeAt(0),u="/".charCodeAt(0),s="0".charCodeAt(0),f="a".charCodeAt(0),c="A".charCodeAt(0);t.toByteArray=n,t.fromByteArray=i})(n===void 0?this.base64js={}:n)},{}],8:[function(t,e,n){n.read=function(t,e,n,r,i){var o,a,u=8*i-r-1,s=(1<>1,c=-7,l=n?i-1:0,d=n?-1:1,p=t[e+l];for(l+=d,o=p&(1<<-c)-1,p>>=-c,c+=u;c>0;o=256*o+t[e+l],l+=d,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=r;c>0;a=256*a+t[e+l],l+=d,c-=8);if(0===o)o=1-f;else{if(o===s)return a?0/0:1/0*(p?-1:1);a+=Math.pow(2,r),o-=f}return(p?-1:1)*a*Math.pow(2,o-r)},n.write=function(t,e,n,r,i,o){var a,u,s,f=8*o-i-1,c=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,h=r?1:-1,g=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||1/0===e?(u=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),1>e*(s=Math.pow(2,-a))&&(a--,s*=2),e+=a+l>=1?d/s:d*Math.pow(2,1-l),e*s>=2&&(a++,s/=2),a+l>=c?(u=0,a=c):a+l>=1?(u=(e*s-1)*Math.pow(2,i),a+=l):(u=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[n+p]=255&u,p+=h,u/=256,i-=8);for(a=a<0;t[n+p]=255&a,p+=h,a/=256,f-=8);t[n+p-h]|=128*g}},{}],9:[function(t,e){function n(){}var r=e.exports={};r.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var n=[];return window.addEventListener("message",function(t){var e=t.source;if((e===window||null===e)&&"process-tick"===t.data&&(t.stopPropagation(),n.length>0)){var r=n.shift();r()}},!0),function(t){n.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=n,r.addListener=n,r.once=n,r.off=n,r.removeListener=n,r.removeAllListeners=n,r.emit=n,r.binding=function(){throw Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(){throw Error("process.chdir is not supported")}},{}],10:[function(t,e){(function(t){function n(e,n,r){return e instanceof ArrayBuffer&&(e=new Uint8Array(e)),new t(e,n,r)}n.prototype=Object.create(t.prototype),n.prototype.constructor=n,Object.keys(t).forEach(function(e){t.hasOwnProperty(e)&&(n[e]=t[e])}),e.exports=n}).call(this,t("buffer").Buffer)},{buffer:6}],11:[function(t,e){var n="READ",r="WRITE",i="CREATE",o="EXCLUSIVE",a="TRUNCATE",u="APPEND",s="CREATE",f="REPLACE";e.exports={FILE_SYSTEM_NAME:"local",FILE_STORE_NAME:"files",IDB_RO:"readonly",IDB_RW:"readwrite",WSQL_VERSION:"1",WSQL_SIZE:5242880,WSQL_DESC:"FileSystem Storage",MODE_FILE:"FILE",MODE_DIRECTORY:"DIRECTORY",MODE_SYMBOLIC_LINK:"SYMLINK",MODE_META:"META",SYMLOOP_MAX:10,BINARY_MIME_TYPE:"application/octet-stream",JSON_MIME_TYPE:"application/json",ROOT_DIRECTORY_NAME:"/",FS_FORMAT:"FORMAT",FS_NOCTIME:"NOCTIME",FS_NOMTIME:"NOMTIME",FS_NODUPEIDCHECK:"FS_NODUPEIDCHECK",O_READ:n,O_WRITE:r,O_CREATE:i,O_EXCLUSIVE:o,O_TRUNCATE:a,O_APPEND:u,O_FLAGS:{r:[n],"r+":[n,r],w:[r,i,a],"w+":[r,n,i,a],wx:[r,i,o,a],"wx+":[r,n,i,o,a],a:[r,i,u],"a+":[r,n,i,u],ax:[r,i,o,u],"ax+":[r,n,i,o,u]},XATTR_CREATE:s,XATTR_REPLACE:f,FS_READY:"READY",FS_PENDING:"PENDING",FS_ERROR:"ERROR",SUPER_NODE_ID:"00000000-0000-0000-0000-000000000000",STDIN:0,STDOUT:1,STDERR:2,FIRST_DESCRIPTOR:3,ENVIRONMENT:{TMP:"/tmp",PATH:""}}},{}],12:[function(t,e){var n=t("./constants.js").MODE_FILE;e.exports=function(t,e){this.id=t,this.type=e||n}},{"./constants.js":11}],13:[function(t,e){(function(t){function n(t){return t.toString("utf8")}function r(e){return new t(e,"utf8")}e.exports={encode:r,decode:n}}).call(this,t("buffer").Buffer)},{buffer:6}],14:[function(t,e){var n={};["9:EBADF:bad file descriptor","10:EBUSY:resource busy or locked","18:EINVAL:invalid argument","27:ENOTDIR:not a directory","28:EISDIR:illegal operation on a directory","34:ENOENT:no such file or directory","47:EEXIST:file already exists","50:EPERM:operation not permitted","51:ELOOP:too many symbolic links encountered","53:ENOTEMPTY:directory not empty","55:EIO:i/o error","1000:ENOTMOUNTED:not mounted","1001:EFILESYSTEMERROR:missing super node, use 'FORMAT' flag to format filesystem.","1002:ENOATTR:attribute does not exist"].forEach(function(t){function e(t,e){Error.call(this),this.name=i,this.code=i,this.errno=r,this.message=t||o,e&&(this.path=e),this.stack=Error(this.message).stack}t=t.split(":");var r=+t[0],i=t[1],o=t[2];e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(){var t=this.path?", '"+this.path+"'":"";return this.name+": "+this.message+t},n[i]=n[r]=e}),e.exports=n},{}],15:[function(t,e){function n(t,e,n,r,i){function o(n){t.changes.push({event:"change",path:e}),i(n)}var a=t.flags;le(a).contains(Me)&&delete r.ctime,le(a).contains(Be)&&delete r.mtime;var u=!1;r.ctime&&(n.ctime=r.ctime,n.atime=r.ctime,u=!0),r.atime&&(n.atime=r.atime,u=!0),r.mtime&&(n.mtime=r.mtime,u=!0),u?t.putObject(n.id,n,o):o()}function r(t,e,r,o){function a(n,r){n?o(n):r.mode!==we?o(new Ce.ENOTDIR("a component of the path prefix is not a directory",e)):(l=r,i(t,e,u))}function u(n,r){!n&&r?o(new Ce.EEXIST("path name already exists",e)):!n||n instanceof Ce.ENOENT?t.getObject(l.data,s):o(n)}function s(e,n){e?o(e):(d=n,Ve.create({guid:t.guid,mode:r},function(e,n){return e?(o(e),void 0):(p=n,p.nlinks+=1,t.putObject(p.id,p,c),void 0)}))}function f(e){if(e)o(e);else{var r=Date.now();n(t,g,p,{mtime:r,ctime:r},o)}}function c(e){e?o(e):(d[h]=new ke(p.id,r),t.putObject(l.data,d,f))}if(r!==we&&r!==ye)return o(new Ce.EINVAL("mode must be a directory or file",e));e=pe(e);var l,d,p,h=ge(e),g=he(e);i(t,g,a)}function i(t,e,n){function r(e,r){e?n(e):r&&r.mode===Ie&&r.rnode?t.getObject(r.rnode,o):n(new Ce.EFILESYSTEMERROR)}function o(t,e){t?n(t):e?n(null,e):n(new Ce.ENOENT)}function a(r,i){r?n(r):i.mode===we&&i.data?t.getObject(i.data,u):n(new Ce.ENOTDIR("a component of the path prefix is not a directory",e))}function u(r,i){if(r)n(r);else if(le(i).has(c)){var o=i[c].id;t.getObject(o,s)}else n(new Ce.ENOENT(null,e))}function s(t,r){t?n(t):r.mode==be?(d++,d>Te?n(new Ce.ELOOP(null,e)):f(r.data)):n(null,r)}function f(e){e=pe(e),l=he(e),c=ge(e),Oe==c?t.getObject(je,r):i(t,l,a)}if(e=pe(e),!e)return n(new Ce.ENOENT("path is an empty string"));var c=ge(e),l=he(e),d=0;Oe==c?t.getObject(je,r):i(t,l,a)}function o(t,e,r,i,o,a,u){function s(i){i?u(i):n(t,e,r,{ctime:Date.now()},u)}var f=r.xattrs;a===Re&&f.hasOwnProperty(i)?u(new Ce.EEXIST("attribute already exists",e)):a!==Le||f.hasOwnProperty(i)?(f[i]=o,t.putObject(r.id,r,s)):u(new Ce.ENOATTR(null,e))}function a(t,e){function n(n,i){!n&&i?e():!n||n instanceof Ce.ENOENT?Ue.create({guid:t.guid},function(n,i){return n?(e(n),void 0):(o=i,t.putObject(o.id,o,r),void 0)}):e(n)}function r(n){n?e(n):Ve.create({guid:t.guid,id:o.rnode,mode:we},function(n,r){return n?(e(n),void 0):(a=r,a.nlinks+=1,t.putObject(a.id,a,i),void 0)})}function i(n){n?e(n):(u={},t.putObject(a.data,u,e))}var o,a,u;t.getObject(je,n)}function u(t,e,r){function o(n,o){!n&&o?r(new Ce.EEXIST(null,e)):!n||n instanceof Ce.ENOENT?i(t,v,a):r(n)}function a(e,n){e?r(e):(p=n,t.getObject(p.data,u))}function u(e,n){e?r(e):(h=n,Ve.create({guid:t.guid,mode:we},function(e,n){return e?(r(e),void 0):(l=n,l.nlinks+=1,t.putObject(l.id,l,s),void 0)}))}function s(e){e?r(e):(d={},t.putObject(l.data,d,c))}function f(e){if(e)r(e);else{var i=Date.now();n(t,v,p,{mtime:i,ctime:i},r)}}function c(e){e?r(e):(h[g]=new ke(l.id,we),t.putObject(p.data,h,f))}e=pe(e);var l,d,p,h,g=ge(e),v=he(e);i(t,e,o)}function s(t,e,r){function o(e,n){e?r(e):(g=n,t.getObject(g.data,a))}function a(n,i){n?r(n):Oe==m?r(new Ce.EBUSY(null,e)):le(i).has(m)?(v=i,p=v[m].id,t.getObject(p,u)):r(new Ce.ENOENT(null,e)) -}function u(n,i){n?r(n):i.mode!=we?r(new Ce.ENOTDIR(null,e)):(p=i,t.getObject(p.data,s))}function s(t,n){t?r(t):(h=n,le(h).size()>0?r(new Ce.ENOTEMPTY(null,e)):c())}function f(e){if(e)r(e);else{var i=Date.now();n(t,E,g,{mtime:i,ctime:i},l)}}function c(){delete v[m],t.putObject(g.data,v,f)}function l(e){e?r(e):t.delete(p.id,d)}function d(e){e?r(e):t.delete(p.data,r)}e=pe(e);var p,h,g,v,m=ge(e),E=he(e);i(t,E,o)}function f(t,e,r,o){function a(n,r){n?o(n):r.mode!==we?o(new Ce.ENOENT(null,e)):(v=r,t.getObject(v.data,u))}function u(n,i){n?o(n):(m=i,le(m).has(b)?le(r).contains(xe)?o(new Ce.ENOENT("O_CREATE and O_EXCLUSIVE are set, and the named file exists",e)):(E=m[b],E.type==we&&le(r).contains(Se)?o(new Ce.EISDIR("the named file is a directory and O_WRITE is set",e)):t.getObject(E.id,s)):le(r).contains(Ne)?l():o(new Ce.ENOENT("O_CREATE is not set and the named file does not exist",e)))}function s(t,n){if(t)o(t);else{var r=n;r.mode==be?(O++,O>Te?o(new Ce.ELOOP(null,e)):f(r.data)):c(void 0,r)}}function f(n){n=pe(n),I=he(n),b=ge(n),Oe==b&&(le(r).contains(Se)?o(new Ce.EISDIR("the named file is a directory and O_WRITE is set",e)):i(t,e,c)),i(t,I,a)}function c(t,e){t?o(t):(y=e,o(null,y))}function l(){Ve.create({guid:t.guid,mode:ye},function(e,n){return e?(o(e),void 0):(y=n,y.nlinks+=1,t.putObject(y.id,y,d),void 0)})}function d(e){e?o(e):(w=new Xe(0),w.fill(0),t.putBuffer(y.data,w,h))}function p(e){if(e)o(e);else{var r=Date.now();n(t,I,v,{mtime:r,ctime:r},g)}}function h(e){e?o(e):(m[b]=new ke(y.id,ye),t.putObject(v.data,m,p))}function g(t){t?o(t):o(null,y)}e=pe(e);var v,m,E,y,w,b=ge(e),I=he(e),O=0;Oe==b?le(r).contains(Se)?o(new Ce.EISDIR("the named file is a directory and O_WRITE is set",e)):i(t,e,c):i(t,I,a)}function c(t,e,r,i,o,a){function u(t){t?a(t):a(null,o)}function s(r){if(r)a(r);else{var i=Date.now();n(t,e.path,l,{mtime:i,ctime:i},u)}}function f(e){e?a(e):t.putObject(l.id,l,s)}function c(n,u){if(n)a(n);else{l=u;var s=new Xe(o);s.fill(0),r.copy(s,0,i,i+o),e.position=o,l.size=o,l.version+=1,t.putBuffer(l.data,s,f)}}var l;t.getObject(e.id,c)}function l(t,e,r,i,o,a,u){function s(t){t?u(t):u(null,o)}function f(r){if(r)u(r);else{var i=Date.now();n(t,e.path,p,{mtime:i,ctime:i},s)}}function c(e){e?u(e):t.putObject(p.id,p,f)}function l(n,s){if(n)u(n);else{if(h=s,!h)return u(new Ce.EIO("Expected Buffer"));var f=void 0!==a&&null!==a?a:e.position,l=Math.max(h.length,f+o),d=new Xe(l);d.fill(0),h&&h.copy(d),r.copy(d,f,i,i+o),void 0===a&&(e.position+=o),p.size=l,p.version+=1,t.putBuffer(p.data,d,c)}}function d(e,n){e?u(e):(p=n,t.getBuffer(p.data,l))}var p,h;t.getObject(e.id,d)}function d(t,e,n,r,i,o,a){function u(t,u){if(t)a(t);else{if(c=u,!c)return a(new Ce.EIO("Expected Buffer"));var s=void 0!==o&&null!==o?o:e.position;i=s+i>n.length?i-s:i,c.copy(n,r,s,s+i),void 0===o&&(e.position+=i),a(null,i)}}function s(e,n){e?a(e):(f=n,t.getBuffer(f.data,u))}var f,c;t.getObject(e.id,s)}function p(t,e,n){e=pe(e),ge(e),i(t,e,n)}function h(t,e,n){e.getNode(t,n)}function g(t,e,n){function r(e,r){e?n(e):(a=r,t.getObject(a.data,o))}function o(r,i){r?n(r):(u=i,le(u).has(s)?t.getObject(u[s].id,n):n(new Ce.ENOENT("a component of the path does not name an existing file",e)))}e=pe(e);var a,u,s=ge(e),f=he(e);Oe==s?i(t,e,n):i(t,f,r)}function v(t,e,r,o){function a(e){e?o(e):n(t,r,y,{ctime:Date.now()},o)}function u(e,n){e?o(e):(y=n,y.nlinks+=1,t.putObject(y.id,y,a))}function s(e){e?o(e):t.getObject(E[w].id,u)}function f(e,n){e?o(e):(E=n,le(E).has(w)?o(new Ce.EEXIST("newpath resolves to an existing file",w)):(E[w]=v[p],t.putObject(m.data,E,s)))}function c(e,n){e?o(e):(m=n,t.getObject(m.data,f))}function l(e,n){e?o(e):(v=n,le(v).has(p)?i(t,b,c):o(new Ce.ENOENT("a component of either path prefix does not exist",p)))}function d(e,n){e?o(e):(g=n,t.getObject(g.data,l))}e=pe(e);var p=ge(e),h=he(e);r=pe(r);var g,v,m,E,y,w=ge(r),b=he(r);i(t,h,d)}function m(t,e,r){function o(e){e?r(e):(delete d[h],t.putObject(l.data,d,function(){var e=Date.now();n(t,g,l,{mtime:e,ctime:e},r)}))}function a(e){e?r(e):t.delete(p.data,o)}function u(i,u){i?r(i):(p=u,p.nlinks-=1,1>p.nlinks?t.delete(p.id,a):t.putObject(p.id,p,function(){n(t,e,p,{ctime:Date.now()},o)}))}function s(t,e){t?r(t):"DIRECTORY"===e.mode?r(new Ce.EPERM("unlink not permitted on directories",h)):u(null,e)}function f(e,n){e?r(e):(d=n,le(d).has(h)?t.getObject(d[h].id,s):r(new Ce.ENOENT("a component of the path does not name an existing file",h)))}function c(e,n){e?r(e):(l=n,t.getObject(l.data,f))}e=pe(e);var l,d,p,h=ge(e),g=he(e);i(t,g,c)}function E(t,e,n){function r(t,e){if(t)n(t);else{u=e;var r=Object.keys(u);n(null,r)}}function o(i,o){i?n(i):o.mode!==we?n(new Ce.ENOTDIR(null,e)):(a=o,t.getObject(a.data,r))}e=pe(e),ge(e);var a,u;i(t,e,o)}function y(t,e,r,o){function a(e,n){e?o(e):(l=n,t.getObject(l.data,u))}function u(t,e){t?o(t):(d=e,le(d).has(h)?o(new Ce.EEXIST(null,h)):s())}function s(){Ve.create({guid:t.guid,mode:be},function(n,r){return n?(o(n),void 0):(p=r,p.nlinks+=1,p.size=e.length,p.data=e,t.putObject(p.id,p,c),void 0)})}function f(e){if(e)o(e);else{var r=Date.now();n(t,g,l,{mtime:r,ctime:r},o)}}function c(e){e?o(e):(d[h]=new ke(p.id,be),t.putObject(l.data,d,f))}r=pe(r);var l,d,p,h=ge(r),g=he(r);Oe==h?o(new Ce.EEXIST(null,h)):i(t,g,a)}function w(t,e,n){function r(e,r){e?n(e):(u=r,t.getObject(u.data,o))}function o(e,r){e?n(e):(s=r,le(s).has(f)?t.getObject(s[f].id,a):n(new Ce.ENOENT("a component of the path does not name an existing file",f)))}function a(t,r){t?n(t):r.mode!=be?n(new Ce.EINVAL("path not a symbolic link",e)):n(null,r.data)}e=pe(e);var u,s,f=ge(e),c=he(e);i(t,c,r)}function b(t,e,r,o){function a(n,r){n?o(n):r.mode==we?o(new Ce.EISDIR(null,e)):(c=r,t.getBuffer(c.data,u))}function u(e,n){if(e)o(e);else{if(!n)return o(new Ce.EIO("Expected Buffer"));var i=new Xe(r);i.fill(0),n&&n.copy(i),t.putBuffer(c.data,i,f)}}function s(r){if(r)o(r);else{var i=Date.now();n(t,e,c,{mtime:i,ctime:i},o)}}function f(e){e?o(e):(c.size=r,c.version+=1,t.putObject(c.id,c,s))}e=pe(e);var c;0>r?o(new Ce.EINVAL("length cannot be negative")):i(t,e,a)}function I(t,e,r,i){function o(e,n){e?i(e):n.mode==we?i(new Ce.EISDIR):(f=n,t.getBuffer(f.data,a))}function a(e,n){if(e)i(e);else{var o;if(!n)return i(new Ce.EIO("Expected Buffer"));n?o=n.slice(0,r):(o=new Xe(r),o.fill(0)),t.putBuffer(f.data,o,s)}}function u(r){if(r)i(r);else{var o=Date.now();n(t,e.path,f,{mtime:o,ctime:o},i)}}function s(e){e?i(e):(f.size=r,f.version+=1,t.putObject(f.id,f,u))}var f;0>r?i(new Ce.EINVAL("length cannot be negative")):e.getNode(t,o)}function O(t,e,r,o,a){function u(i,u){i?a(i):n(t,e,u,{atime:r,ctime:o,mtime:o},a)}e=pe(e),"number"!=typeof r||"number"!=typeof o?a(new Ce.EINVAL("atime and mtime must be number",e)):0>r||0>o?a(new Ce.EINVAL("atime and mtime must be positive integers",e)):i(t,e,u)}function j(t,e,r,i,o){function a(a,u){a?o(a):n(t,e.path,u,{atime:r,ctime:i,mtime:i},o)}"number"!=typeof r||"number"!=typeof i?o(new Ce.EINVAL("atime and mtime must be a number")):0>r||0>i?o(new Ce.EINVAL("atime and mtime must be positive integers")):e.getNode(t,a)}function T(t,e,n,r,a,u){function s(i,s){return i?u(i):(o(t,e,s,n,r,a,u),void 0)}e=pe(e),"string"!=typeof n?u(new Ce.EINVAL("attribute name must be a string",e)):n?null!==a&&a!==Re&&a!==Le?u(new Ce.EINVAL("invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE",e)):i(t,e,s):u(new Ce.EINVAL("attribute name cannot be an empty string",e))}function A(t,e,n,r,i,a){function u(u,s){return u?a(u):(o(t,e.path,s,n,r,i,a),void 0)}"string"!=typeof n?a(new Ce.EINVAL("attribute name must be a string")):n?null!==i&&i!==Re&&i!==Le?a(new Ce.EINVAL("invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE")):e.getNode(t,u):a(new Ce.EINVAL("attribute name cannot be an empty string"))}function S(t,e,n,r){function o(t,i){if(t)return r(t);var o=i.xattrs;o.hasOwnProperty(n)?r(null,o[n]):r(new Ce.ENOATTR(null,e))}e=pe(e),"string"!=typeof n?r(new Ce.EINVAL("attribute name must be a string",e)):n?i(t,e,o):r(new Ce.EINVAL("attribute name cannot be an empty string",e))}function N(t,e,n,r){function i(t,e){if(t)return r(t);var i=e.xattrs;i.hasOwnProperty(n)?r(null,i[n]):r(new Ce.ENOATTR)}"string"!=typeof n?r(new Ce.EINVAL):n?e.getNode(t,i):r(new Ce.EINVAL("attribute name cannot be an empty string"))}function x(t,e,r,o){function a(i,a){function u(r){r?o(r):n(t,e,a,{ctime:Date.now()},o)}if(i)return o(i);var s=a.xattrs;s.hasOwnProperty(r)?(delete s[r],t.putObject(a.id,a,u)):o(new Ce.ENOATTR(null,e))}e=pe(e),"string"!=typeof r?o(new Ce.EINVAL("attribute name must be a string",e)):r?i(t,e,a):o(new Ce.EINVAL("attribute name cannot be an empty string",e))}function D(t,e,r,i){function o(o,a){function u(r){r?i(r):n(t,e.path,a,{ctime:Date.now()},i)}if(o)return i(o);var s=a.xattrs;s.hasOwnProperty(r)?(delete s[r],t.putObject(a.id,a,u)):i(new Ce.ENOATTR)}"string"!=typeof r?i(new Ce.EINVAL("attribute name must be a string")):r?e.getNode(t,o):i(new Ce.EINVAL("attribute name cannot be an empty string"))}function _(t){return le(_e).has(t)?_e[t]:null}function R(t,e,n){return t?"function"==typeof t?t={encoding:e,flag:n}:"string"==typeof t&&(t={encoding:t,flag:n}):t={encoding:e,flag:n},t}function L(t,e){var n;return t?me(t)?n=new Ce.EINVAL("Path must be a string without null bytes.",t):ve(t)||(n=new Ce.EINVAL("Path must be absolute.",t)):n=new Ce.EINVAL("Path must be a string",t),n?(e(n),!1):!0}function B(t,e,n,r,i,o){function a(e,i){if(e)o(e);else{var a;a=le(r).contains(De)?i.size:0;var u=new Pe(n,i.id,r,a),s=t.allocDescriptor(u);o(null,s)}}o=arguments[arguments.length-1],L(n,o)&&(r=_(r),r||o(new Ce.EINVAL("flags is not valid"),n),f(e,n,r,a))}function M(t,e,n,r){le(t.openFiles).has(n)?(t.releaseDescriptor(n),r(null)):r(new Ce.EBADF)}function F(t,e,n,i,o){L(n,o)&&r(e,n,i,o)}function C(t,e,n,r,i){i=arguments[arguments.length-1],L(n,i)&&u(e,n,i)}function k(t,e,n,r){L(n,r)&&s(e,n,r)}function P(t,e,n,r){function i(e,n){if(e)r(e);else{var i=new Ye(n,t.name);r(null,i)}}L(n,r)&&p(e,n,i)}function U(t,e,n,r){function i(e,n){if(e)r(e);else{var i=new Ye(n,t.name);r(null,i)}}var o=t.openFiles[n];o?h(e,o,i):r(new Ce.EBADF)}function V(t,e,n,r,i){L(n,i)&&L(r,i)&&v(e,n,r,i)}function Y(t,e,n,r){L(n,r)&&m(e,n,r)}function X(t,e,n,r,i,o,a,u){function s(t,e){u(t,e||0,r)}i=void 0===i?0:i,o=void 0===o?r.length-i:o,u=arguments[arguments.length-1];var f=t.openFiles[n];f?le(f.flags).contains(Ae)?d(e,f,r,i,o,a,s):u(new Ce.EBADF("descriptor does not permit reading")):u(new Ce.EBADF)}function W(t,e,n,r,i){if(i=arguments[arguments.length-1],r=R(r,null,"r"),L(n,i)){var o=_(r.flag||"r");return o?(f(e,n,o,function(a,u){function s(){t.releaseDescriptor(c)}if(a)return i(a);var f=new Pe(n,u.id,o,0),c=t.allocDescriptor(f);h(e,f,function(o,a){if(o)return s(),i(o);var u=new Ye(a,t.name);if(u.isDirectory())return s(),i(new Ce.EISDIR("illegal operation on directory",n));var c=u.size,l=new Xe(c);l.fill(0),d(e,f,l,0,c,0,function(t){if(s(),t)return i(t);var e;e="utf8"===r.encoding?Fe.decode(l):l,i(null,e)})})}),void 0):i(new Ce.EINVAL("flags is not valid",n))}}function z(t,e,n,r,i,o,a,u){u=arguments[arguments.length-1],i=void 0===i?0:i,o=void 0===o?r.length-i:o;var s=t.openFiles[n];s?le(s.flags).contains(Se)?o>r.length-i?u(new Ce.EIO("intput buffer is too small")):l(e,s,r,i,o,a,u):u(new Ce.EBADF("descriptor does not permit writing")):u(new Ce.EBADF)}function q(t,e,n,r,i,o){if(o=arguments[arguments.length-1],i=R(i,"utf8","w"),L(n,o)){var a=_(i.flag||"w");if(!a)return o(new Ce.EINVAL("flags is not valid",n));r=r||"","number"==typeof r&&(r=""+r),"string"==typeof r&&"utf8"===i.encoding&&(r=Fe.encode(r)),f(e,n,a,function(i,u){if(i)return o(i);var s=new Pe(n,u.id,a,0),f=t.allocDescriptor(s);c(e,s,r,0,r.length,function(e){return t.releaseDescriptor(f),e?o(e):(o(null),void 0)})})}}function J(t,e,n,r,i,o){if(o=arguments[arguments.length-1],i=R(i,"utf8","a"),L(n,o)){var a=_(i.flag||"a");if(!a)return o(new Ce.EINVAL("flags is not valid",n));r=r||"","number"==typeof r&&(r=""+r),"string"==typeof r&&"utf8"===i.encoding&&(r=Fe.encode(r)),f(e,n,a,function(i,u){if(i)return o(i);var s=new Pe(n,u.id,a,u.size),f=t.allocDescriptor(s);l(e,s,r,0,r.length,s.position,function(e){return t.releaseDescriptor(f),e?o(e):(o(null),void 0)})})}}function Q(t,e,n,r){function i(t){r(t?!1:!0)}P(t,e,n,i)}function H(t,e,n,r,i){L(n,i)&&S(e,n,r,i)}function K(t,e,n,r,i){var o=t.openFiles[n];o?N(e,o,r,i):i(new Ce.EBADF)}function G(t,e,n,r,i,o,a){"function"==typeof o&&(a=o,o=null),L(n,a)&&T(e,n,r,i,o,a)}function $(t,e,n,r,i,o,a){"function"==typeof o&&(a=o,o=null);var u=t.openFiles[n];u?le(u.flags).contains(Se)?A(e,u,r,i,o,a):a(new Ce.EBADF("descriptor does not permit writing")):a(new Ce.EBADF)}function Z(t,e,n,r,i){L(n,i)&&x(e,n,r,i)}function te(t,e,n,r,i){var o=t.openFiles[n];o?le(o.flags).contains(Se)?D(e,o,r,i):i(new Ce.EBADF("descriptor does not permit writing")):i(new Ce.EBADF)}function ee(t,e,n,r,i,o){function a(t,e){t?o(t):0>e.size+r?o(new Ce.EINVAL("resulting file offset would be negative")):(u.position=e.size+r,o(null,u.position))}var u=t.openFiles[n];u||o(new Ce.EBADF),"SET"===i?0>r?o(new Ce.EINVAL("resulting file offset would be negative")):(u.position=r,o(null,u.position)):"CUR"===i?0>u.position+r?o(new Ce.EINVAL("resulting file offset would be negative")):(u.position+=r,o(null,u.position)):"END"===i?h(e,u,a):o(new Ce.EINVAL("whence argument is not a proper value"))}function ne(t,e,n,r){L(n,r)&&E(e,n,r)}function re(t,e,n,r,i,o){if(L(n,o)){var a=Date.now();r=r?r:a,i=i?i:a,O(e,n,r,i,o)}}function ie(t,e,n,r,i,o){var a=Date.now();r=r?r:a,i=i?i:a;var u=t.openFiles[n];u?le(u.flags).contains(Se)?j(e,u,r,i,o):o(new Ce.EBADF("descriptor does not permit writing")):o(new Ce.EBADF)}function oe(t,e,n,r,i){function o(t){t?i(t):m(e,n,i)}L(n,i)&&L(r,i)&&v(e,n,r,o)}function ae(t,e,n,r,i,o){o=arguments[arguments.length-1],L(n,o)&&L(r,o)&&y(e,n,r,o)}function ue(t,e,n,r){L(n,r)&&w(e,n,r)}function se(t,e,n,r){function i(e,n){if(e)r(e);else{var i=new Ye(n,t.name);r(null,i)}}L(n,r)&&g(e,n,i)}function fe(t,e,n,r,i){i=arguments[arguments.length-1],r=r||0,L(n,i)&&b(e,n,r,i)}function ce(t,e,n,r,i){i=arguments[arguments.length-1],r=r||0;var o=t.openFiles[n];o?le(o.flags).contains(Se)?I(e,o,r,i):i(new Ce.EBADF("descriptor does not permit writing")):i(new Ce.EBADF)}var le=t("../../lib/nodash.js"),de=t("../path.js"),pe=de.normalize,he=de.dirname,ge=de.basename,ve=de.isAbsolute,me=de.isNull,Ee=t("../constants.js"),ye=Ee.MODE_FILE,we=Ee.MODE_DIRECTORY,be=Ee.MODE_SYMBOLIC_LINK,Ie=Ee.MODE_META,Oe=Ee.ROOT_DIRECTORY_NAME,je=Ee.SUPER_NODE_ID,Te=Ee.SYMLOOP_MAX,Ae=Ee.O_READ,Se=Ee.O_WRITE,Ne=Ee.O_CREATE,xe=Ee.O_EXCLUSIVE;Ee.O_TRUNCATE;var De=Ee.O_APPEND,_e=Ee.O_FLAGS,Re=Ee.XATTR_CREATE,Le=Ee.XATTR_REPLACE,Be=Ee.FS_NOMTIME,Me=Ee.FS_NOCTIME,Fe=t("../encoding.js"),Ce=t("../errors.js"),ke=t("../directory-entry.js"),Pe=t("../open-file-description.js"),Ue=t("../super-node.js"),Ve=t("../node.js"),Ye=t("../stats.js"),Xe=t("../buffer.js");e.exports={ensureRootDirectory:a,open:B,close:M,mknod:F,mkdir:C,rmdir:k,unlink:Y,stat:P,fstat:U,link:V,read:X,readFile:W,write:z,writeFile:q,appendFile:J,exists:Q,getxattr:H,fgetxattr:K,setxattr:G,fsetxattr:$,removexattr:Z,fremovexattr:te,lseek:ee,readdir:ne,utimes:re,futimes:ie,rename:oe,symlink:ae,readlink:ue,lstat:se,truncate:fe,ftruncate:ce}},{"../../lib/nodash.js":4,"../buffer.js":10,"../constants.js":11,"../directory-entry.js":12,"../encoding.js":13,"../errors.js":14,"../node.js":19,"../open-file-description.js":20,"../path.js":21,"../stats.js":29,"../super-node.js":30}],16:[function(t,e){function n(t){return"function"==typeof t?t:function(t){if(t)throw t}}function r(t,e){function n(){R.forEach(function(t){t.call(this)}.bind(x)),R=null}function r(t){return function(e){function n(e){var r=T();t.getObject(r,function(t,i){return t?(e(t),void 0):(i?n(e):e(null,r),void 0)})}return i(g).contains(p)?(e(null,T()),void 0):(n(e),void 0)}}function u(t){if(t.length){var e=v.getInstance();t.forEach(function(t){e.emit(t.event,t.path)})}}t=t||{},e=e||a;var g=t.flags,T=t.guid?t.guid:y,A=t.provider||new h.Default(t.name||s),S=t.name||A.name,N=i(g).contains(f),x=this;x.readyState=l,x.name=S,x.error=null,x.stdin=w,x.stdout=b,x.stderr=I;var D={},_=O;Object.defineProperty(this,"openFiles",{get:function(){return D}}),this.allocDescriptor=function(t){var e=_++;return D[e]=t,e},this.releaseDescriptor=function(t){delete D[t]};var R=[];this.queueOrRun=function(t){var e;return c==x.readyState?t.call(x):d==x.readyState?e=new E.EFILESYSTEMERROR("unknown error"):R.push(t),e},this.watch=function(t,e,n){if(o(t))throw Error("Path must be a string without null bytes.");"function"==typeof e&&(n=e,e={}),e=e||{},n=n||a;var r=new m;return r.start(t,!1,e.recursive),r.on("change",n),r},A.open(function(t){function i(t){function i(t){var e=A[t]();return e.flags=g,e.changes=[],e.guid=r(e),e.close=function(){var t=e.changes;u(t),t.length=0},e}x.provider={openReadWriteContext:function(){return i("getReadWriteContext")},openReadOnlyContext:function(){return i("getReadOnlyContext")}},x.readyState=t?d:c,n(),e(t,x)}if(t)return i(t);var o=A.getReadWriteContext();o.guid=r(o),N?o.clear(function(t){return t?i(t):(j.ensureRootDirectory(o,i),void 0)}):j.ensureRootDirectory(o,i)})}var i=t("../../lib/nodash.js"),o=t("../path.js").isNull,a=t("../shared.js").nop,u=t("../constants.js"),s=u.FILE_SYSTEM_NAME,f=u.FS_FORMAT,c=u.FS_READY,l=u.FS_PENDING,d=u.FS_ERROR,p=u.FS_NODUPEIDCHECK,h=t("../providers/index.js"),g=t("../shell/shell.js"),v=t("../../lib/intercom.js"),m=t("../fs-watcher.js"),E=t("../errors.js"),y=t("../shared.js").guid,w=u.STDIN,b=u.STDOUT,I=u.STDERR,O=u.FIRST_DESCRIPTOR,j=t("./implementation.js");r.providers=h,["open","close","mknod","mkdir","rmdir","stat","fstat","link","unlink","read","readFile","write","writeFile","appendFile","exists","lseek","readdir","rename","readlink","symlink","lstat","truncate","ftruncate","utimes","futimes","setxattr","getxattr","fsetxattr","fgetxattr","removexattr","fremovexattr"].forEach(function(t){r.prototype[t]=function(){var e=this,r=Array.prototype.slice.call(arguments,0),i=r.length-1,o="function"!=typeof r[i],a=n(r[i]),u=e.queueOrRun(function(){function n(){u.close(),a.apply(e,arguments)}var u=e.provider.openReadWriteContext();if(d===e.readyState){var s=new E.EFILESYSTEMERROR("filesystem unavailable, operation canceled");return a.call(e,s)}o?r.push(n):r[i]=n;var f=[e,u].concat(r);j[t].apply(null,f)});u&&a(u)}}),r.prototype.Shell=function(t){return new g(this,t)},e.exports=r},{"../../lib/intercom.js":3,"../../lib/nodash.js":4,"../constants.js":11,"../errors.js":14,"../fs-watcher.js":17,"../path.js":21,"../providers/index.js":22,"../shared.js":26,"../shell/shell.js":28,"./implementation.js":15}],17:[function(t,e){function n(){function t(t){(n===t||u&&0===t.indexOf(e))&&a.trigger("change","change",t)}r.call(this);var e,n,a=this,u=!1;a.start=function(r,a,s){if(!n){if(i.isNull(r))throw Error("Path must be a string without null bytes.");n=i.normalize(r),u=s===!0,u&&(e="/"===n?"/":n+"/");var f=o.getInstance();f.on("change",t)}},a.close=function(){var e=o.getInstance();e.off("change",t),a.removeAllListeners("change")}}var r=t("../lib/eventemitter.js"),i=t("./path.js"),o=t("../lib/intercom.js");n.prototype=new r,n.prototype.constructor=n,e.exports=n},{"../lib/eventemitter.js":2,"../lib/intercom.js":3,"./path.js":21}],18:[function(t,e){e.exports={FileSystem:t("./filesystem/interface.js"),Buffer:t("./buffer.js"),Path:t("./path.js"),Errors:t("./errors.js")}},{"./buffer.js":10,"./errors.js":14,"./filesystem/interface.js":16,"./path.js":21}],19:[function(t,e){function n(t){var e=Date.now();this.id=t.id,this.mode=t.mode||i,this.size=t.size||0,this.atime=t.atime||e,this.ctime=t.ctime||e,this.mtime=t.mtime||e,this.flags=t.flags||[],this.xattrs=t.xattrs||{},this.nlinks=t.nlinks||0,this.version=t.version||0,this.blksize=void 0,this.nblocks=1,this.data=t.data}function r(t,e,n){t[e]?n(null):t.guid(function(r,i){t[e]=i,n(r)})}var i=t("./constants.js").MODE_FILE;n.create=function(t,e){r(t,"id",function(i){return i?(e(i),void 0):(r(t,"data",function(r){return r?(e(r),void 0):(e(null,new n(t)),void 0)}),void 0)})},e.exports=n},{"./constants.js":11}],20:[function(t,e){function n(t,e,n,r){this.path=t,this.id=e,this.flags=n,this.position=r}var r=t("./errors.js");n.prototype.getNode=function(t,e){function n(t,n){return t?e(t):n?(e(null,n),void 0):e(new r.EBADF("file descriptor refers to unknown node",o))}var i=this.id,o=this.path;t.getObject(i,n)},e.exports=n},{"./errors.js":14}],21:[function(t,e,n){function r(t,e){for(var n=0,r=t.length-1;r>=0;r--){var i=t[r];"."===i?t.splice(r,1):".."===i?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}function i(){for(var t="",e=!1,n=arguments.length-1;n>=-1&&!e;n--){var i=n>=0?arguments[n]:"/";"string"==typeof i&&i&&(t=i+"/"+t,e="/"===i.charAt(0))}return t=r(t.split("/").filter(function(t){return!!t}),!e).join("/"),(e?"/":"")+t||"."}function o(t){var e="/"===t.charAt(0);return"/"===t.substr(-1),t=r(t.split("/").filter(function(t){return!!t}),!e).join("/"),t||e||(t="."),(e?"/":"")+t}function a(){var t=Array.prototype.slice.call(arguments,0);return o(t.filter(function(t){return t&&"string"==typeof t}).join("/"))}function u(t,e){function r(t){for(var e=0;t.length>e&&""===t[e];e++);for(var n=t.length-1;n>=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=n.resolve(t).substr(1),e=n.resolve(e).substr(1);for(var i=r(t.split("/")),o=r(e.split("/")),a=Math.min(i.length,o.length),u=a,s=0;a>s;s++)if(i[s]!==o[s]){u=s;break}for(var f=[],s=u;i.length>s;s++)f.push("..");return f=f.concat(o.slice(u)),f.join("/")}function s(t){var e=h(t),n=e[0],r=e[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."}function f(t,e){var n=h(t)[2];return e&&n.substr(-1*e.length)===e&&(n=n.substr(0,n.length-e.length)),""===n?"/":n}function c(t){return h(t)[3]}function l(t){return"/"===t.charAt(0)?!0:!1}function d(t){return-1!==(""+t).indexOf("\0")?!0:!1}var p=/^(\/?)([\s\S]+\/(?!$)|\/)?((?:\.{1,2}$|[\s\S]+?)?(\.[^.\/]*)?)$/,h=function(t){var e=p.exec(t);return[e[1]||"",e[2]||"",e[3]||"",e[4]||""]};e.exports={normalize:o,resolve:i,join:a,relative:u,sep:"/",delimiter:":",dirname:s,basename:f,extname:c,isAbsolute:l,isNull:d}},{}],22:[function(t,e){var n=t("./indexeddb.js"),r=t("./websql.js"),i=t("./memory.js");e.exports={IndexedDB:n,WebSQL:r,Memory:i,Default:n,Fallback:function(){function t(){throw"[Filer Error] Your browser doesn't support IndexedDB or WebSQL."}return n.isSupported()?n:r.isSupported()?r:(t.isSupported=function(){return!1},t)}()}},{"./indexeddb.js":23,"./memory.js":24,"./websql.js":25}],23:[function(t,e){(function(n,r){function i(t,e){var n=t.transaction(f,e);this.objectStore=n.objectStore(f)}function o(t,e,n){try{var r=t.get(e);r.onsuccess=function(t){var e=t.target.result;n(null,e)},r.onerror=function(t){n(t)}}catch(i){n(i)}}function a(t,e,n,r){try{var i=t.put(n,e);i.onsuccess=function(t){var e=t.target.result;r(null,e)},i.onerror=function(t){r(t)}}catch(o){r(o)}}function u(t){this.name=t||s,this.db=null}var s=t("../constants.js").FILE_SYSTEM_NAME,f=t("../constants.js").FILE_STORE_NAME,c=t("../constants.js").IDB_RW;t("../constants.js").IDB_RO;var l=t("../errors.js"),d=t("../buffer.js"),p=n.indexedDB||n.mozIndexedDB||n.webkitIndexedDB||n.msIndexedDB;i.prototype.clear=function(t){try{var e=this.objectStore.clear();e.onsuccess=function(){t()},e.onerror=function(e){t(e)}}catch(n){t(n)}},i.prototype.getObject=function(t,e){o(this.objectStore,t,e)},i.prototype.getBuffer=function(t,e){o(this.objectStore,t,function(t,n){return t?e(t):(e(null,new d(n)),void 0)})},i.prototype.putObject=function(t,e,n){a(this.objectStore,t,e,n)},i.prototype.putBuffer=function(t,e,n){var i;i=r._useTypedArrays?e.buffer:e.toArrayBuffer(),a(this.objectStore,t,i,n)},i.prototype.delete=function(t,e){try{var n=this.objectStore.delete(t);n.onsuccess=function(t){var n=t.target.result;e(null,n)},n.onerror=function(t){e(t)}}catch(r){e(r)}},u.isSupported=function(){return!!p},u.prototype.open=function(t){var e=this;if(e.db)return t();var n=p.open(e.name);n.onupgradeneeded=function(t){var e=t.target.result;e.objectStoreNames.contains(f)&&e.deleteObjectStore(f),e.createObjectStore(f)},n.onsuccess=function(n){e.db=n.target.result,t()},n.onerror=function(){t(new l.EINVAL("IndexedDB cannot be accessed. If private browsing is enabled, disable it."))}},u.prototype.getReadOnlyContext=function(){return new i(this.db,c)},u.prototype.getReadWriteContext=function(){return new i(this.db,c)},e.exports=u}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"../buffer.js":10,"../constants.js":11,"../errors.js":14,buffer:6}],24:[function(t,e){function n(t,e){this.readOnly=e,this.objectStore=t}function r(t){this.name=t||i}var i=t("../constants.js").FILE_SYSTEM_NAME,o=t("../../lib/async.js").setImmediate,a=function(){var t={};return function(e){return t.hasOwnProperty(e)||(t[e]={}),t[e]}}();n.prototype.clear=function(t){if(this.readOnly)return o(function(){t("[MemoryContext] Error: write operation on read only context")}),void 0;var e=this.objectStore;Object.keys(e).forEach(function(t){delete e[t]}),o(t)},n.prototype.getObject=n.prototype.getBuffer=function(t,e){var n=this;o(function(){e(null,n.objectStore[t])})},n.prototype.putObject=n.prototype.putBuffer=function(t,e,n){return this.readOnly?(o(function(){n("[MemoryContext] Error: write operation on read only context")}),void 0):(this.objectStore[t]=e,o(n),void 0)},n.prototype.delete=function(t,e){return this.readOnly?(o(function(){e("[MemoryContext] Error: write operation on read only context")}),void 0):(delete this.objectStore[t],o(e),void 0)},r.isSupported=function(){return!0},r.prototype.open=function(t){this.db=a(this.name),o(t)},r.prototype.getReadOnlyContext=function(){return new n(this.db,!0)},r.prototype.getReadWriteContext=function(){return new n(this.db,!1)},e.exports=r},{"../../lib/async.js":1,"../constants.js":11}],25:[function(t,e){(function(n){function r(t,e){var n=this;this.getTransaction=function(r){return n.transaction?(r(n.transaction),void 0):(t[e?"readTransaction":"transaction"](function(t){n.transaction=t,r(t)}),void 0)}}function i(t,e,n){function r(t,e){var r=0===e.rows.length?null:e.rows.item(0).data;n(null,r)}function i(t,e){n(e)}t(function(t){t.executeSql("SELECT data FROM "+s+" WHERE id = ? LIMIT 1;",[e],r,i)})}function o(t,e,n,r){function i(){r(null)}function o(t,e){r(e)}t(function(t){t.executeSql("INSERT OR REPLACE INTO "+s+" (id, data) VALUES (?, ?);",[e,n],i,o)})}function a(t){this.name=t||u,this.db=null}var u=t("../constants.js").FILE_SYSTEM_NAME,s=t("../constants.js").FILE_STORE_NAME,f=t("../constants.js").WSQL_VERSION,c=t("../constants.js").WSQL_SIZE,l=t("../constants.js").WSQL_DESC,d=t("../errors.js"),p=t("../buffer.js"),h=t("base64-arraybuffer");r.prototype.clear=function(t){function e(e,n){t(n)}function n(){t(null)}this.getTransaction(function(t){t.executeSql("DELETE FROM "+s+";",[],n,e)})},r.prototype.getObject=function(t,e){i(this.getTransaction,t,function(t,n){if(t)return e(t);try{n&&(n=JSON.parse(n))}catch(r){return e(r)}e(null,n)})},r.prototype.getBuffer=function(t,e){i(this.getTransaction,t,function(t,n){if(t)return e(t);if(n||""===n){var r=h.decode(n);n=new p(r)}e(null,n)})},r.prototype.putObject=function(t,e,n){var r=JSON.stringify(e);o(this.getTransaction,t,r,n)},r.prototype.putBuffer=function(t,e,n){var r=h.encode(e.buffer);o(this.getTransaction,t,r,n)},r.prototype.delete=function(t,e){function n(){e(null)}function r(t,n){e(n)}this.getTransaction(function(e){e.executeSql("DELETE FROM "+s+" WHERE id = ?;",[t],n,r)})},a.isSupported=function(){return!!n.openDatabase},a.prototype.open=function(t){function e(e,n){5===n.code&&t(new d.EINVAL("WebSQL cannot be accessed. If private browsing is enabled, disable it.")),t(n)}function r(){i.db=o,t()}var i=this;if(i.db)return t();var o=n.openDatabase(i.name,f,l,c);return o?(o.transaction(function(t){function n(t){t.executeSql("CREATE INDEX IF NOT EXISTS idx_"+s+"_id"+" on "+s+" (id);",[],r,e)}t.executeSql("CREATE TABLE IF NOT EXISTS "+s+" (id unique, data TEXT);",[],n,e)}),void 0):(t("[WebSQL] Unable to open database."),void 0)},a.prototype.getReadOnlyContext=function(){return new r(this.db,!0)},a.prototype.getReadWriteContext=function(){return new r(this.db,!1)},e.exports=a}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../buffer.js":10,"../constants.js":11,"../errors.js":14,"base64-arraybuffer":5}],26:[function(t,e){function n(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=0|16*Math.random(),n="x"==t?e:8|3&e;return n.toString(16)}).toUpperCase()}function r(){}function i(t){for(var e=[],n=t.length,r=0;n>r;r++)e[r]=t[r];return e}e.exports={guid:n,u8toArray:i,nop:r}},{}],27:[function(t,e){var n=t("../constants.js").ENVIRONMENT;e.exports=function(t){t=t||{},t.TMP=t.TMP||n.TMP,t.PATH=t.PATH||n.PATH,this.get=function(e){return t[e]},this.set=function(e,n){t[e]=n}}},{"../constants.js":11}],28:[function(t,e){function n(t,e){e=e||{};var n=new o(e.env),a="/";Object.defineProperty(this,"fs",{get:function(){return t},enumerable:!0}),Object.defineProperty(this,"env",{get:function(){return n},enumerable:!0}),this.cd=function(e,n){e=r.resolve(a,e),t.stat(e,function(t,r){return t?(n(new i.ENOTDIR(null,e)),void 0):("DIRECTORY"===r.type?(a=e,n()):n(new i.ENOTDIR(null,e)),void 0)})},this.pwd=function(){return a}}var r=t("../path.js"),i=t("../errors.js"),o=t("./environment.js"),a=t("../../lib/async.js");t("../encoding.js"),n.prototype.exec=function(t,e,n){var i=this,o=i.fs;"function"==typeof e&&(n=e,e=[]),e=e||[],n=n||function(){},t=r.resolve(i.pwd(),t),o.readFile(t,"utf8",function(t,r){if(t)return n(t),void 0;try{var i=Function("fs","args","callback",r);i(o,e,n)}catch(a){n(a)}})},n.prototype.touch=function(t,e,n){function i(t){u.writeFile(t,"",n)}function o(t){var r=Date.now(),i=e.date||r,o=e.date||r;u.utimes(t,i,o,n)}var a=this,u=a.fs;"function"==typeof e&&(n=e,e={}),e=e||{},n=n||function(){},t=r.resolve(a.pwd(),t),u.stat(t,function(r){r?e.updateOnly===!0?n():i(t):o(t)})},n.prototype.cat=function(t,e){function n(t,e){var n=r.resolve(o.pwd(),t);u.readFile(n,"utf8",function(t,n){return t?(e(t),void 0):(s+=n+"\n",e(),void 0)})}var o=this,u=o.fs,s="";return e=e||function(){},t?(t="string"==typeof t?[t]:t,a.eachSeries(t,n,function(t){t?e(t):e(null,s.replace(/\n$/,""))}),void 0):(e(new i.EINVAL("Missing files argument")),void 0)},n.prototype.ls=function(t,e,n){function o(t,n){var i=r.resolve(u.pwd(),t),f=[];s.readdir(i,function(t,u){function c(t,n){t=r.join(i,t),s.stat(t,function(a,u){if(a)return n(a),void 0;var s={path:r.basename(t),links:u.nlinks,size:u.size,modified:u.mtime,type:u.type};e.recursive&&"DIRECTORY"===u.type?o(r.join(i,s.path),function(t,e){return t?(n(t),void 0):(s.contents=e,f.push(s),n(),void 0)}):(f.push(s),n())})}return t?(n(t),void 0):(a.eachSeries(u,c,function(t){n(t,f)}),void 0)})}var u=this,s=u.fs;return"function"==typeof e&&(n=e,e={}),e=e||{},n=n||function(){},t?(o(t,n),void 0):(n(new i.EINVAL("Missing dir argument")),void 0)},n.prototype.rm=function(t,e,n){function o(t,n){t=r.resolve(u.pwd(),t),s.stat(t,function(u,f){return u?(n(u),void 0):"FILE"===f.type?(s.unlink(t,n),void 0):(s.readdir(t,function(u,f){return u?(n(u),void 0):0===f.length?(s.rmdir(t,n),void 0):e.recursive?(f=f.map(function(e){return r.join(t,e)}),a.eachSeries(f,o,function(e){return e?(n(e),void 0):(s.rmdir(t,n),void 0)}),void 0):(n(new i.ENOTEMPTY(null,t)),void 0)}),void 0)})}var u=this,s=u.fs;return"function"==typeof e&&(n=e,e={}),e=e||{},n=n||function(){},t?(o(t,n),void 0):(n(new i.EINVAL("Missing path argument")),void 0)},n.prototype.tempDir=function(t){var e=this,n=e.fs,r=e.env.get("TMP");t=t||function(){},n.mkdir(r,function(){t(null,r)})},n.prototype.mkdirp=function(t,e){function n(t,e){a.stat(t,function(o,u){if(u){if(u.isDirectory())return e(),void 0;if(u.isFile())return e(new i.ENOTDIR(null,t)),void 0}else{if(o&&"ENOENT"!==o.code)return e(o),void 0;var s=r.dirname(t);"/"===s?a.mkdir(t,function(t){return t&&"EEXIST"!=t.code?(e(t),void 0):(e(),void 0) -}):n(s,function(n){return n?e(n):(a.mkdir(t,function(t){return t&&"EEXIST"!=t.code?(e(t),void 0):(e(),void 0)}),void 0)})}})}var o=this,a=o.fs;return e=e||function(){},t?"/"===t?(e(),void 0):(n(t,e),void 0):(e(new i.EINVAL("Missing path argument")),void 0)},e.exports=n},{"../../lib/async.js":1,"../encoding.js":13,"../errors.js":14,"../path.js":21,"./environment.js":27}],29:[function(t,e){function n(t,e){this.node=t.id,this.dev=e,this.size=t.size,this.nlinks=t.nlinks,this.atime=t.atime,this.mtime=t.mtime,this.ctime=t.ctime,this.type=t.mode}var r=t("./constants.js");n.prototype.isFile=function(){return this.type===r.MODE_FILE},n.prototype.isDirectory=function(){return this.type===r.MODE_DIRECTORY},n.prototype.isSymbolicLink=function(){return this.type===r.MODE_SYMBOLIC_LINK},n.prototype.isSocket=n.prototype.isFIFO=n.prototype.isCharacterDevice=n.prototype.isBlockDevice=function(){return!1},e.exports=n},{"./constants.js":11}],30:[function(t,e){function n(t){var e=Date.now();this.id=r.SUPER_NODE_ID,this.mode=r.MODE_META,this.atime=t.atime||e,this.ctime=t.ctime||e,this.mtime=t.mtime||e,this.rnode=t.rnode}var r=t("./constants.js");n.create=function(t,e){t.guid(function(r,i){return r?(e(r),void 0):(t.rnode=t.rnode||i,e(null,new n(t)),void 0)})},e.exports=n},{"./constants.js":11}]},{},[18])(18)}); \ No newline at end of file +/*! filer 0.0.35 2014-12-02 */ +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Filer=t()}}(function(){var t;return function e(t,n,r){function i(a,s){if(!n[a]){if(!t[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);throw Error("Cannot find module '"+a+"'")}var c=n[a]={exports:{}};t[a][0].call(c.exports,function(e){var n=t[a][1][e];return i(n?n:e)},c,c.exports,e,t,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;r.length>a;a++)i(r[a]);return i}({1:[function(e,n){(function(e){(function(){var r={};void 0!==e&&e.nextTick?(r.nextTick=e.nextTick,r.setImmediate="undefined"!=typeof setImmediate?function(t){setImmediate(t)}:r.nextTick):"function"==typeof setImmediate?(r.nextTick=function(t){setImmediate(t)},r.setImmediate=r.nextTick):(r.nextTick=function(t){setTimeout(t,0)},r.setImmediate=r.nextTick),r.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)return n();var r=0,i=function(){e(t[r],function(e){e?(n(e),n=function(){}):(r+=1,r>=t.length?n():i())})};i()},r.forEachSeries=r.eachSeries,t!==void 0&&t.amd?t([],function(){return r}):n!==void 0&&n.exports?n.exports=r:root.async=r})()}).call(this,e("JkpR2F"))},{JkpR2F:10}],2:[function(t,e){function n(t,e){for(var n=e.length-1;n>=0;n--)e[n]===t&&e.splice(n,1);return e}var r=function(){};r.createInterface=function(t){var e={};return e.on=function(e,n){this[t]===void 0&&(this[t]={}),this[t].hasOwnProperty(e)||(this[t][e]=[]),this[t][e].push(n)},e.off=function(e,r){void 0!==this[t]&&this[t].hasOwnProperty(e)&&n(r,this[t][e])},e.trigger=function(e){if(this[t]!==void 0&&this[t].hasOwnProperty(e))for(var n=Array.prototype.slice.call(arguments,1),r=0;this[t][e].length>r;r++)this[t][e][r].apply(this[t][e][r],n)},e.removeAllListeners=function(e){if(void 0!==this[t]){var n=this;n[t][e].forEach(function(t){n.off(e,t)})}},e};var i=r.createInterface("_handlers");r.prototype._on=i.on,r.prototype._off=i.off,r.prototype._trigger=i.trigger;var o=r.createInterface("handlers");r.prototype.on=function(){o.on.apply(this,arguments),Array.prototype.unshift.call(arguments,"on"),this._trigger.apply(this,arguments)},r.prototype.off=o.off,r.prototype.trigger=o.trigger,r.prototype.removeAllListeners=o.removeAllListeners,e.exports=r},{}],3:[function(t,e){(function(n){function r(t,e){var n=0;return function(){var r=Date.now();r-n>t&&(n=r,e.apply(this,arguments))}}function i(t,e){if(void 0!==t&&t||(t={}),"object"==typeof e)for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function o(){var t=this,e=Date.now();this.origin=s(),this.lastMessage=e,this.receivedIDs={},this.previousValues={};var r=function(){t._onStorageEvent.apply(t,arguments)};"undefined"!=typeof document&&(document.attachEvent?document.attachEvent("onstorage",r):n.addEventListener("storage",r,!1))}var a=t("./eventemitter.js"),s=t("../src/shared.js").guid,u=function(t){return t===void 0||t.localStorage===void 0?{getItem:function(){},setItem:function(){},removeItem:function(){}}:t.localStorage}(n);o.prototype._transaction=function(t){function e(){if(!a){var f=Date.now(),h=0|u.getItem(l);if(h&&r>f-h)return s||(o._on("storage",e),s=!0),c=setTimeout(e,i),void 0;a=!0,u.setItem(l,f),t(),n()}}function n(){s&&o._off("storage",e),c&&clearTimeout(c),u.removeItem(l)}var r=1e3,i=20,o=this,a=!1,s=!1,c=null;e()},o.prototype._cleanup_emit=r(100,function(){var t=this;t._transaction(function(){var t,e=Date.now(),n=e-h,r=0;try{t=JSON.parse(u.getItem(c)||"[]")}catch(i){t=[]}for(var o=t.length-1;o>=0;o--)n>t[o].timestamp&&(t.splice(o,1),r++);r>0&&u.setItem(c,JSON.stringify(t))})}),o.prototype._cleanup_once=r(100,function(){var t=this;t._transaction(function(){var e,n;Date.now();var r=0;try{n=JSON.parse(u.getItem(f)||"{}")}catch(i){n={}}for(e in n)t._once_expired(e,n)&&(delete n[e],r++);r>0&&u.setItem(f,JSON.stringify(n))})}),o.prototype._once_expired=function(t,e){if(!e)return!0;if(!e.hasOwnProperty(t))return!0;if("object"!=typeof e[t])return!0;var n=e[t].ttl||d,r=Date.now(),i=e[t].timestamp;return r-n>i},o.prototype._localStorageChanged=function(t,e){if(t&&t.key)return t.key===e;var n=u.getItem(e);return n===this.previousValues[e]?!1:(this.previousValues[e]=n,!0)},o.prototype._onStorageEvent=function(t){t=t||n.event;var e=this;this._localStorageChanged(t,c)&&this._transaction(function(){var t,n=Date.now(),r=u.getItem(c);try{t=JSON.parse(r||"[]")}catch(i){t=[]}for(var o=0;t.length>o;o++)if(t[o].origin!==e.origin&&!(t[o].timestampr;r++)if(e.call(n,t[r],r,t)===m)return}else{var o=o(t);for(r=0,i=o.length;i>r;r++)if(e.call(n,t[o[r]],o[r],t)===m)return}}function a(t,e,n){e||(e=i);var r=!1;return null==t?r:d&&t.some===d?t.some(e,n):(o(t,function(t,i,o){return r||(r=e.call(n,t,i,o))?m:void 0}),!!r)}function s(t,e){return null==t?!1:h&&t.indexOf===h?-1!=t.indexOf(e):a(t,function(t){return t===e})}function u(t){this.value=t}function c(t){return t&&"object"==typeof t&&!Array.isArray(t)&&g.call(t,"__wrapped__")?t:new u(t)}var f=Array.prototype,l=f.forEach,h=f.indexOf,d=f.some,p=Object.prototype,g=p.hasOwnProperty,v=Object.keys,m={},y=v||function(t){if(t!==Object(t))throw new TypeError("Invalid object");var e=[];for(var r in t)n(t,r)&&e.push(r);return e};u.prototype.has=function(t){return n(this.value,t)},u.prototype.contains=function(t){return s(this.value,t)},u.prototype.size=function(){return r(this.value)},e.exports=c},{}],5:[function(t,e,n){(function(t){"use strict";n.encode=function(e){var n,r=new Uint8Array(e),i=r.length,o="";for(n=0;i>n;n+=3)o+=t[r[n]>>2],o+=t[(3&r[n])<<4|r[n+1]>>4],o+=t[(15&r[n+1])<<2|r[n+2]>>6],o+=t[63&r[n+2]];return 2===i%3?o=o.substring(0,o.length-1)+"=":1===i%3&&(o=o.substring(0,o.length-2)+"=="),o},n.decode=function(e){var n,r,i,o,a,s=.75*e.length,u=e.length,c=0;"="===e[e.length-1]&&(s--,"="===e[e.length-2]&&s--);var f=new ArrayBuffer(s),l=new Uint8Array(f);for(n=0;u>n;n+=4)r=t.indexOf(e[n]),i=t.indexOf(e[n+1]),o=t.indexOf(e[n+2]),a=t.indexOf(e[n+3]),l[c++]=r<<2|i>>4,l[c++]=(15&i)<<4|o>>2,l[c++]=(3&o)<<6|63&a;return f}})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},{}],6:[function(t,e,n){function r(t,e,n){if(!(this instanceof r))return new r(t,e,n);var i=typeof t;"base64"===e&&"string"===i&&(t=T(t));var o;if("number"===i)o=D(t);else if("string"===i)o=r.byteLength(t,e);else{if("object"!==i)throw Error("First argument needs to be a number, array or string.");o=D(t.length)}var a;r._useTypedArrays?a=r._augment(new Uint8Array(o)):(a=this,a.length=o,a._isBuffer=!0);var s;if(r._useTypedArrays&&"number"==typeof t.byteLength)a._set(t);else if(L(t))if(r.isBuffer(t))for(s=0;o>s;s++)a[s]=t.readUInt8(s);else for(s=0;o>s;s++)a[s]=(t[s]%256+256)%256;else if("string"===i)a.write(t,0,e);else if("number"===i&&!r._useTypedArrays&&!n)for(s=0;o>s;s++)a[s]=0;return a}function i(t,e,n,r){n=Number(n)||0;var i=t.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;var o=e.length;z(0===o%2,"Invalid hex string"),r>o/2&&(r=o/2);for(var a=0;r>a;a++){var s=parseInt(e.substr(2*a,2),16);z(!isNaN(s),"Invalid hex string"),t[n+a]=s}return a}function o(t,e,n,r){var i=P(M(e),t,n,r);return i}function a(t,e,n,r){var i=P(C(e),t,n,r);return i}function s(t,e,n,r){return a(t,e,n,r)}function u(t,e,n,r){var i=P(F(e),t,n,r);return i}function c(t,e,n,r){var i=P(k(e),t,n,r);return i}function f(t,e,n){return 0===e&&n===t.length?W.fromByteArray(t):W.fromByteArray(t.slice(e,n))}function l(t,e,n){var r="",i="";n=Math.min(t.length,n);for(var o=e;n>o;o++)127>=t[o]?(r+=U(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return r+U(i)}function h(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;n>i;i++)r+=String.fromCharCode(t[i]);return r}function d(t,e,n){return h(t,e,n)}function p(t,e,n){var r=t.length;(!e||0>e)&&(e=0),(!n||0>n||n>r)&&(n=r);for(var i="",o=e;n>o;o++)i+=B(t[o]);return i}function g(t,e,n){for(var r=t.slice(e,n),i="",o=0;r.length>o;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function v(t,e,n,r){r||(z("boolean"==typeof n,"missing or invalid endian"),z(void 0!==e&&null!==e,"missing offset"),z(t.length>e+1,"Trying to read beyond buffer length"));var i=t.length;if(!(e>=i)){var o;return n?(o=t[e],i>e+1&&(o|=t[e+1]<<8)):(o=t[e]<<8,i>e+1&&(o|=t[e+1])),o}}function m(t,e,n,r){r||(z("boolean"==typeof n,"missing or invalid endian"),z(void 0!==e&&null!==e,"missing offset"),z(t.length>e+3,"Trying to read beyond buffer length"));var i=t.length;if(!(e>=i)){var o;return n?(i>e+2&&(o=t[e+2]<<16),i>e+1&&(o|=t[e+1]<<8),o|=t[e],i>e+3&&(o+=t[e+3]<<24>>>0)):(i>e+1&&(o=t[e+1]<<16),i>e+2&&(o|=t[e+2]<<8),i>e+3&&(o|=t[e+3]),o+=t[e]<<24>>>0),o}}function y(t,e,n,r){r||(z("boolean"==typeof n,"missing or invalid endian"),z(void 0!==e&&null!==e,"missing offset"),z(t.length>e+1,"Trying to read beyond buffer length"));var i=t.length;if(!(e>=i)){var o=v(t,e,n,!0),a=32768&o;return a?-1*(65535-o+1):o}}function b(t,e,n,r){r||(z("boolean"==typeof n,"missing or invalid endian"),z(void 0!==e&&null!==e,"missing offset"),z(t.length>e+3,"Trying to read beyond buffer length"));var i=t.length;if(!(e>=i)){var o=m(t,e,n,!0),a=2147483648&o;return a?-1*(4294967295-o+1):o}}function E(t,e,n,r){return r||(z("boolean"==typeof n,"missing or invalid endian"),z(t.length>e+3,"Trying to read beyond buffer length")),J.read(t,e,n,23,4)}function w(t,e,n,r){return r||(z("boolean"==typeof n,"missing or invalid endian"),z(t.length>e+7,"Trying to read beyond buffer length")),J.read(t,e,n,52,8)}function O(t,e,n,r,i){i||(z(void 0!==e&&null!==e,"missing value"),z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==n&&null!==n,"missing offset"),z(t.length>n+1,"trying to write beyond buffer length"),V(e,65535));var o=t.length;if(!(n>=o)){for(var a=0,s=Math.min(o-n,2);s>a;a++)t[n+a]=(e&255<<8*(r?a:1-a))>>>8*(r?a:1-a);return n+2}}function I(t,e,n,r,i){i||(z(void 0!==e&&null!==e,"missing value"),z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==n&&null!==n,"missing offset"),z(t.length>n+3,"trying to write beyond buffer length"),V(e,4294967295));var o=t.length;if(!(n>=o)){for(var a=0,s=Math.min(o-n,4);s>a;a++)t[n+a]=255&e>>>8*(r?a:3-a);return n+4}}function _(t,e,n,r,i){i||(z(void 0!==e&&null!==e,"missing value"),z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==n&&null!==n,"missing offset"),z(t.length>n+1,"Trying to write beyond buffer length"),Y(e,32767,-32768));var o=t.length;if(!(n>=o))return e>=0?O(t,e,n,r,i):O(t,65535+e+1,n,r,i),n+2}function j(t,e,n,r,i){i||(z(void 0!==e&&null!==e,"missing value"),z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==n&&null!==n,"missing offset"),z(t.length>n+3,"Trying to write beyond buffer length"),Y(e,2147483647,-2147483648));var o=t.length;if(!(n>=o))return e>=0?I(t,e,n,r,i):I(t,4294967295+e+1,n,r,i),n+4}function A(t,e,n,r,i){i||(z(void 0!==e&&null!==e,"missing value"),z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==n&&null!==n,"missing offset"),z(t.length>n+3,"Trying to write beyond buffer length"),X(e,3.4028234663852886e38,-3.4028234663852886e38));var o=t.length;if(!(n>=o))return J.write(t,e,n,r,23,4),n+4}function x(t,e,n,r,i){i||(z(void 0!==e&&null!==e,"missing value"),z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==n&&null!==n,"missing offset"),z(t.length>n+7,"Trying to write beyond buffer length"),X(e,1.7976931348623157e308,-1.7976931348623157e308));var o=t.length;if(!(n>=o))return J.write(t,e,n,r,52,8),n+8}function T(t){for(t=S(t).replace($,"");0!==t.length%4;)t+="=";return t}function S(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function N(t,e,n){return"number"!=typeof t?n:(t=~~t,t>=e?e:t>=0?t:(t+=e,t>=0?t:0))}function D(t){return t=~~Math.ceil(+t),0>t?0:t}function R(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function L(t){return R(t)||r.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function B(t){return 16>t?"0"+t.toString(16):t.toString(16)}function M(t){for(var e=[],n=0;t.length>n;n++){var r=t.charCodeAt(n);if(127>=r)e.push(r);else{var i=n;r>=55296&&57343>=r&&n++;for(var o=encodeURIComponent(t.slice(i,n+1)).substr(1).split("%"),a=0;o.length>a;a++)e.push(parseInt(o[a],16))}}return e}function C(t){for(var e=[],n=0;t.length>n;n++)e.push(255&t.charCodeAt(n));return e}function k(t){for(var e,n,r,i=[],o=0;t.length>o;o++)e=t.charCodeAt(o),n=e>>8,r=e%256,i.push(r),i.push(n);return i}function F(t){return W.toByteArray(t)}function P(t,e,n,r){for(var i=0;r>i&&!(i+n>=e.length||i>=t.length);i++)e[i+n]=t[i];return i}function U(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}function V(t,e){z("number"==typeof t,"cannot write a non-number as a number"),z(t>=0,"specified a negative value for writing an unsigned value"),z(e>=t,"value is larger than maximum value for type"),z(Math.floor(t)===t,"value has a fractional component")}function Y(t,e,n){z("number"==typeof t,"cannot write a non-number as a number"),z(e>=t,"value larger than maximum allowed value"),z(t>=n,"value smaller than minimum allowed value"),z(Math.floor(t)===t,"value has a fractional component")}function X(t,e,n){z("number"==typeof t,"cannot write a non-number as a number"),z(e>=t,"value larger than maximum allowed value"),z(t>=n,"value smaller than minimum allowed value")}function z(t,e){if(!t)throw Error(e||"Failed assertion")}var W=t("base64-js"),J=t("ieee754");n.Buffer=r,n.SlowBuffer=r,n.INSPECT_MAX_BYTES=50,r.poolSize=8192,r._useTypedArrays=function(){try{var t=new ArrayBuffer(0),e=new Uint8Array(t);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray}catch(n){return!1}}(),r.isEncoding=function(t){switch((t+"").toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},r.isBuffer=function(t){return!(null===t||void 0===t||!t._isBuffer)},r.byteLength=function(t,e){var n;switch(t=""+t,e||"utf8"){case"hex":n=t.length/2;break;case"utf8":case"utf-8":n=M(t).length;break;case"ascii":case"binary":case"raw":n=t.length;break;case"base64":n=F(t).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":n=2*t.length;break;default:throw Error("Unknown encoding")}return n},r.concat=function(t,e){if(z(R(t),"Usage: Buffer.concat(list[, length])"),0===t.length)return new r(0);if(1===t.length)return t[0];var n;if(void 0===e)for(e=0,n=0;t.length>n;n++)e+=t[n].length;var i=new r(e),o=0;for(n=0;t.length>n;n++){var a=t[n];a.copy(i,o),o+=a.length}return i},r.compare=function(t,e){z(r.isBuffer(t)&&r.isBuffer(e),"Arguments must be Buffers");for(var n=t.length,i=e.length,o=0,a=Math.min(n,i);a>o&&t[o]===e[o];o++);return o!==a&&(n=t[o],i=e[o]),i>n?-1:n>i?1:0},r.prototype.write=function(t,e,n,r){if(isFinite(e))isFinite(n)||(r=n,n=void 0);else{var f=r;r=e,e=n,n=f}e=Number(e)||0;var l=this.length-e;n?(n=Number(n),n>l&&(n=l)):n=l,r=((r||"utf8")+"").toLowerCase();var h;switch(r){case"hex":h=i(this,t,e,n);break;case"utf8":case"utf-8":h=o(this,t,e,n);break;case"ascii":h=a(this,t,e,n);break;case"binary":h=s(this,t,e,n);break;case"base64":h=u(this,t,e,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":h=c(this,t,e,n);break;default:throw Error("Unknown encoding")}return h},r.prototype.toString=function(t,e,n){var r=this;if(t=((t||"utf8")+"").toLowerCase(),e=Number(e)||0,n=void 0===n?r.length:Number(n),n===e)return"";var i;switch(t){case"hex":i=p(r,e,n);break;case"utf8":case"utf-8":i=l(r,e,n);break;case"ascii":i=h(r,e,n);break;case"binary":i=d(r,e,n);break;case"base64":i=f(r,e,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=g(r,e,n);break;default:throw Error("Unknown encoding")}return i},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.equals=function(t){return z(r.isBuffer(t),"Argument must be a Buffer"),0===r.compare(this,t)},r.prototype.compare=function(t){return z(r.isBuffer(t),"Argument must be a Buffer"),r.compare(this,t)},r.prototype.copy=function(t,e,n,i){var o=this;if(n||(n=0),i||0===i||(i=this.length),e||(e=0),i!==n&&0!==t.length&&0!==o.length){z(i>=n,"sourceEnd < sourceStart"),z(e>=0&&t.length>e,"targetStart out of bounds"),z(n>=0&&o.length>n,"sourceStart out of bounds"),z(i>=0&&o.length>=i,"sourceEnd out of bounds"),i>this.length&&(i=this.length),i-n>t.length-e&&(i=t.length-e+n);var a=i-n;if(100>a||!r._useTypedArrays)for(var s=0;a>s;s++)t[s+e]=this[s+n];else t._set(this.subarray(n,n+a),e)}},r.prototype.slice=function(t,e){var n=this.length;if(t=N(t,n,0),e=N(e,n,n),r._useTypedArrays)return r._augment(this.subarray(t,e));for(var i=e-t,o=new r(i,void 0,!0),a=0;i>a;a++)o[a]=this[a+t];return o},r.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},r.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},r.prototype.readUInt8=function(t,e){return e||(z(void 0!==t&&null!==t,"missing offset"),z(this.length>t,"Trying to read beyond buffer length")),t>=this.length?void 0:this[t]},r.prototype.readUInt16LE=function(t,e){return v(this,t,!0,e)},r.prototype.readUInt16BE=function(t,e){return v(this,t,!1,e)},r.prototype.readUInt32LE=function(t,e){return m(this,t,!0,e)},r.prototype.readUInt32BE=function(t,e){return m(this,t,!1,e)},r.prototype.readInt8=function(t,e){if(e||(z(void 0!==t&&null!==t,"missing offset"),z(this.length>t,"Trying to read beyond buffer length")),!(t>=this.length)){var n=128&this[t];return n?-1*(255-this[t]+1):this[t]}},r.prototype.readInt16LE=function(t,e){return y(this,t,!0,e)},r.prototype.readInt16BE=function(t,e){return y(this,t,!1,e)},r.prototype.readInt32LE=function(t,e){return b(this,t,!0,e)},r.prototype.readInt32BE=function(t,e){return b(this,t,!1,e)},r.prototype.readFloatLE=function(t,e){return E(this,t,!0,e)},r.prototype.readFloatBE=function(t,e){return E(this,t,!1,e)},r.prototype.readDoubleLE=function(t,e){return w(this,t,!0,e)},r.prototype.readDoubleBE=function(t,e){return w(this,t,!1,e)},r.prototype.writeUInt8=function(t,e,n){return n||(z(void 0!==t&&null!==t,"missing value"),z(void 0!==e&&null!==e,"missing offset"),z(this.length>e,"trying to write beyond buffer length"),V(t,255)),e>=this.length?void 0:(this[e]=t,e+1)},r.prototype.writeUInt16LE=function(t,e,n){return O(this,t,e,!0,n)},r.prototype.writeUInt16BE=function(t,e,n){return O(this,t,e,!1,n)},r.prototype.writeUInt32LE=function(t,e,n){return I(this,t,e,!0,n)},r.prototype.writeUInt32BE=function(t,e,n){return I(this,t,e,!1,n)},r.prototype.writeInt8=function(t,e,n){return n||(z(void 0!==t&&null!==t,"missing value"),z(void 0!==e&&null!==e,"missing offset"),z(this.length>e,"Trying to write beyond buffer length"),Y(t,127,-128)),e>=this.length?void 0:(t>=0?this.writeUInt8(t,e,n):this.writeUInt8(255+t+1,e,n),e+1)},r.prototype.writeInt16LE=function(t,e,n){return _(this,t,e,!0,n)},r.prototype.writeInt16BE=function(t,e,n){return _(this,t,e,!1,n)},r.prototype.writeInt32LE=function(t,e,n){return j(this,t,e,!0,n)},r.prototype.writeInt32BE=function(t,e,n){return j(this,t,e,!1,n)},r.prototype.writeFloatLE=function(t,e,n){return A(this,t,e,!0,n)},r.prototype.writeFloatBE=function(t,e,n){return A(this,t,e,!1,n)},r.prototype.writeDoubleLE=function(t,e,n){return x(this,t,e,!0,n)},r.prototype.writeDoubleBE=function(t,e,n){return x(this,t,e,!1,n)},r.prototype.fill=function(t,e,n){if(t||(t=0),e||(e=0),n||(n=this.length),z(n>=e,"end < start"),n!==e&&0!==this.length){z(e>=0&&this.length>e,"start out of bounds"),z(n>=0&&this.length>=n,"end out of bounds");var r;if("number"==typeof t)for(r=e;n>r;r++)this[r]=t;else{var i=M(""+t),o=i.length;for(r=e;n>r;r++)this[r]=i[r%o]}return this}},r.prototype.inspect=function(){for(var t=[],e=this.length,r=0;e>r;r++)if(t[r]=B(this[r]),r===n.INSPECT_MAX_BYTES){t[r+1]="...";break}return""},r.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(r._useTypedArrays)return new r(this).buffer;for(var t=new Uint8Array(this.length),e=0,n=t.length;n>e;e+=1)t[e]=this[e];return t.buffer}throw Error("Buffer.toArrayBuffer not supported in this browser")};var q=r.prototype;r._augment=function(t){return t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=q.get,t.set=q.set,t.write=q.write,t.toString=q.toString,t.toLocaleString=q.toString,t.toJSON=q.toJSON,t.equals=q.equals,t.compare=q.compare,t.copy=q.copy,t.slice=q.slice,t.readUInt8=q.readUInt8,t.readUInt16LE=q.readUInt16LE,t.readUInt16BE=q.readUInt16BE,t.readUInt32LE=q.readUInt32LE,t.readUInt32BE=q.readUInt32BE,t.readInt8=q.readInt8,t.readInt16LE=q.readInt16LE,t.readInt16BE=q.readInt16BE,t.readInt32LE=q.readInt32LE,t.readInt32BE=q.readInt32BE,t.readFloatLE=q.readFloatLE,t.readFloatBE=q.readFloatBE,t.readDoubleLE=q.readDoubleLE,t.readDoubleBE=q.readDoubleBE,t.writeUInt8=q.writeUInt8,t.writeUInt16LE=q.writeUInt16LE,t.writeUInt16BE=q.writeUInt16BE,t.writeUInt32LE=q.writeUInt32LE,t.writeUInt32BE=q.writeUInt32BE,t.writeInt8=q.writeInt8,t.writeInt16LE=q.writeInt16LE,t.writeInt16BE=q.writeInt16BE,t.writeInt32LE=q.writeInt32LE,t.writeInt32BE=q.writeInt32BE,t.writeFloatLE=q.writeFloatLE,t.writeFloatBE=q.writeFloatBE,t.writeDoubleLE=q.writeDoubleLE,t.writeDoubleBE=q.writeDoubleBE,t.fill=q.fill,t.inspect=q.inspect,t.toArrayBuffer=q.toArrayBuffer,t};var $=/[^+\/0-9A-z]/g},{"base64-js":7,ieee754:8}],7:[function(t,e,n){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===a?62:e===s?63:u>e?-1:u+10>e?e-u+26+26:f+26>e?e-f:c+26>e?e-c+26:void 0}function n(t){function n(t){c[l++]=t}var r,i,a,s,u,c;if(t.length%4>0)throw Error("Invalid string. Length must be a multiple of 4");var f=t.length;u="="===t.charAt(f-2)?2:"="===t.charAt(f-1)?1:0,c=new o(3*t.length/4-u),a=u>0?t.length-4:t.length;var l=0;for(r=0,i=0;a>r;r+=4,i+=3)s=e(t.charAt(r))<<18|e(t.charAt(r+1))<<12|e(t.charAt(r+2))<<6|e(t.charAt(r+3)),n((16711680&s)>>16),n((65280&s)>>8),n(255&s);return 2===u?(s=e(t.charAt(r))<<2|e(t.charAt(r+1))>>4,n(255&s)):1===u&&(s=e(t.charAt(r))<<10|e(t.charAt(r+1))<<4|e(t.charAt(r+2))>>2,n(255&s>>8),n(255&s)),c}function i(t){function e(t){return r.charAt(t)}function n(t){return e(63&t>>18)+e(63&t>>12)+e(63&t>>6)+e(63&t)}var i,o,a,s=t.length%3,u="";for(i=0,a=t.length-s;a>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],u+=n(o);switch(s){case 1:o=t[t.length-1],u+=e(o>>2),u+=e(63&o<<4),u+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],u+=e(o>>10),u+=e(63&o>>4),u+=e(63&o<<2),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="+".charCodeAt(0),s="/".charCodeAt(0),u="0".charCodeAt(0),c="a".charCodeAt(0),f="A".charCodeAt(0);t.toByteArray=n,t.fromByteArray=i})(n===void 0?this.base64js={}:n)},{}],8:[function(t,e,n){n.read=function(t,e,n,r,i){var o,a,s=8*i-r-1,u=(1<>1,f=-7,l=n?i-1:0,h=n?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-f)-1,d>>=-f,f+=s;f>0;o=256*o+t[e+l],l+=h,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=r;f>0;a=256*a+t[e+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return a?0/0:1/0*(d?-1:1);a+=Math.pow(2,r),o-=c}return(d?-1:1)*a*Math.pow(2,o-r)},n.write=function(t,e,n,r,i,o){var a,s,u,c=8*o-i-1,f=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,p=r?1:-1,g=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||1/0===e?(s=isNaN(e)?1:0,a=f):(a=Math.floor(Math.log(e)/Math.LN2),1>e*(u=Math.pow(2,-a))&&(a--,u*=2),e+=a+l>=1?h/u:h*Math.pow(2,1-l),e*u>=2&&(a++,u/=2),a+l>=f?(s=0,a=f):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[n+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;t[n+d]=255&a,d+=p,a/=256,c-=8);t[n+d-p]|=128*g}},{}],9:[function(t,e,n){(function(t){function e(t,e){for(var n=0,r=t.length-1;r>=0;r--){var i=t[r];"."===i?t.splice(r,1):".."===i?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}function r(t,e){if(t.filter)return t.filter(e);for(var n=[],r=0;t.length>r;r++)e(t[r],r,t)&&n.push(t[r]);return n}var i=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,o=function(t){return i.exec(t).slice(1)};n.resolve=function(){for(var n="",i=!1,o=arguments.length-1;o>=-1&&!i;o--){var a=o>=0?arguments[o]:t.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(n=a+"/"+n,i="/"===a.charAt(0))}return n=e(r(n.split("/"),function(t){return!!t}),!i).join("/"),(i?"/":"")+n||"."},n.normalize=function(t){var i=n.isAbsolute(t),o="/"===a(t,-1);return t=e(r(t.split("/"),function(t){return!!t}),!i).join("/"),t||i||(t="."),t&&o&&(t+="/"),(i?"/":"")+t},n.isAbsolute=function(t){return"/"===t.charAt(0)},n.join=function(){var t=Array.prototype.slice.call(arguments,0);return n.normalize(r(t,function(t){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))},n.relative=function(t,e){function r(t){for(var e=0;t.length>e&&""===t[e];e++);for(var n=t.length-1;n>=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=n.resolve(t).substr(1),e=n.resolve(e).substr(1);for(var i=r(t.split("/")),o=r(e.split("/")),a=Math.min(i.length,o.length),s=a,u=0;a>u;u++)if(i[u]!==o[u]){s=u;break}for(var c=[],u=s;i.length>u;u++)c.push("..");return c=c.concat(o.slice(s)),c.join("/")},n.sep="/",n.delimiter=":",n.dirname=function(t){var e=o(t),n=e[0],r=e[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."},n.basename=function(t,e){var n=o(t)[2];return e&&n.substr(-1*e.length)===e&&(n=n.substr(0,n.length-e.length)),n},n.extname=function(t){return o(t)[3]};var a="b"==="ab".substr(-1)?function(t,e,n){return t.substr(e,n)}:function(t,e,n){return 0>e&&(e=t.length+e),t.substr(e,n)}}).call(this,t("JkpR2F"))},{JkpR2F:10}],10:[function(t,e){function n(){}var r=e.exports={};r.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var n=[];return window.addEventListener("message",function(t){var e=t.source;if((e===window||null===e)&&"process-tick"===t.data&&(t.stopPropagation(),n.length>0)){var r=n.shift();r()}},!0),function(t){n.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=n,r.addListener=n,r.once=n,r.off=n,r.removeListener=n,r.removeAllListeners=n,r.emit=n,r.binding=function(){throw Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(){throw Error("process.chdir is not supported")}},{}],11:[function(t,e){(function(n){(function(t,e,n,r){function i(t){return t.split("").reduce(function(t,e){return t[e]=!0,t},{})}function o(t,e){return e=e||{},function(n){return s(n,t,e)}}function a(t,e){t=t||{},e=e||{};var n={};return Object.keys(e).forEach(function(t){n[t]=e[t]}),Object.keys(t).forEach(function(e){n[e]=t[e]}),n}function s(t,e,n){if("string"!=typeof e)throw new TypeError("glob pattern string required");return n||(n={}),n.nocomment||"#"!==e.charAt(0)?""===e.trim()?""===t:new u(e,n).match(t):!1}function u(t,e){if(!(this instanceof u))return new u(t,e,b);if("string"!=typeof t)throw new TypeError("glob pattern string required");e||(e={}),t=t.trim(),"win32"===r&&(t=t.split("\\").join("/"));var n=t+"\n"+w(e),i=s.cache.get(n);return i?i:(s.cache.set(n,this),this.options=e,this.set=[],this.pattern=t,this.regexp=null,this.negate=!1,this.comment=!1,this.empty=!1,this.make(),void 0)}function c(){if(!this._made){var t=this.pattern,e=this.options;if(!e.nocomment&&"#"===t.charAt(0))return this.comment=!0,void 0;if(!t)return this.empty=!0,void 0;this.parseNegate();var n=this.globSet=this.braceExpand();e.debug&&(this.debug=console.error),this.debug(this.pattern,n),n=this.globParts=n.map(function(t){return t.split(x)}),this.debug(this.pattern,n),n=n.map(function(t){return t.map(this.parse,this)},this),this.debug(this.pattern,n),n=n.filter(function(t){return-1===t.indexOf(!1)}),this.debug(this.pattern,n),this.set=n}}function f(){var t=this.pattern,e=!1,n=this.options,r=0;if(!n.nonegate){for(var i=0,o=t.length;o>i&&"!"===t.charAt(i);i++)e=!e,r++;r&&(this.pattern=t.substr(r)),this.negate=e}}function l(t,e,n){return n=n||"0",t+="",t.length>=e?t:Array(e-t.length+1).join(n)+t}function h(t,e){function n(){b.push(I),I=""}if(e=e||this.options,t=t===void 0?this.pattern:t,t===void 0)throw Error("undefined pattern");if(e.nobrace||!t.match(/\{.*\}/))return[t];var r=!1;if("{"!==t.charAt(0)){this.debug(t);for(var i=null,o=0,a=t.length;a>o;o++){var s=t.charAt(o);if(this.debug(o,s),"\\"===s)r=!r;else if("{"===s&&!r){i=t.substr(0,o);break}}if(null===i)return this.debug("no sets"),[t];var u=h.call(this,t.substr(o),e);return u.map(function(t){return i+t})}var c=t.match(/^\{(-?[0-9]+)\.\.(-?[0-9]+)\}/);if(c){this.debug("numset",c[1],c[2]);for(var f,d=h.call(this,t.substr(c[0].length),e),p=+c[1],g="0"===c[1][0],v=c[1].length,m=+c[2],y=p>m?-1:1,b=[],o=p;o!=m+y;o+=y){f=g?l(o,v):o+"";for(var E=0,w=d.length;w>E;E++)b.push(f+d[E])}return b}var o=1,O=1,b=[],I="",r=!1;this.debug("Entering for");t:for(o=1,a=t.length;a>o;o++){var s=t.charAt(o);if(this.debug("",o,s),r)r=!1,I+="\\"+s;else switch(s){case"\\":r=!0;continue;case"{":O++,I+="{";continue;case"}":if(O--,0===O){n(),o++;break t}I+=s;continue;case",":1===O?n():I+=s;continue;default:I+=s;continue}}if(0!==O)return this.debug("didn't close",t),h.call(this,"\\"+t,e);this.debug("set",b),this.debug("suffix",t.substr(o));var d=h.call(this,t.substr(o),e),_=1===b.length;this.debug("set pre-expanded",b),b=b.map(function(t){return h.call(this,t,e)},this),this.debug("set expanded",b),b=b.reduce(function(t,e){return t.concat(e)}),_&&(b=b.map(function(t){return"{"+t+"}"}));for(var j=[],o=0,a=b.length;a>o;o++)for(var E=0,w=d.length;w>E;E++)j.push(b[o]+d[E]);return j}function d(t,e){function n(){if(o){switch(o){case"*":s+=I,u=!0;break;case"?":s+=O,u=!0;break;default:s+="\\"+o}g.debug("clearStateChar %j %j",o,s),o=!1}}var r=this.options;if(!r.noglobstar&&"**"===t)return E;if(""===t)return"";for(var i,o,a,s="",u=!!r.nocase,c=!1,f=[],l=!1,h=-1,d=-1,p="."===t.charAt(0)?"":r.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",g=this,m=0,y=t.length;y>m&&(a=t.charAt(m));m++)if(this.debug("%s %s %s %j",t,m,s,a),c&&A[a])s+="\\"+a,c=!1; +else switch(a){case"/":return!1;case"\\":n(),c=!0;continue;case"?":case"*":case"+":case"@":case"!":if(this.debug("%s %s %s %j <-- stateChar",t,m,s,a),l){this.debug(" in class"),"!"===a&&m===d+1&&(a="^"),s+=a;continue}g.debug("call clearStateChar %j",o),n(),o=a,r.noext&&n();continue;case"(":if(l){s+="(";continue}if(!o){s+="\\(";continue}i=o,f.push({type:i,start:m-1,reStart:s.length}),s+="!"===o?"(?:(?!":"(?:",this.debug("plType %j %j",o,s),o=!1;continue;case")":if(l||!f.length){s+="\\)";continue}switch(n(),u=!0,s+=")",i=f.pop().type){case"!":s+="[^/]*?)";break;case"?":case"+":case"*":s+=i;case"@":}continue;case"|":if(l||!f.length||c){s+="\\|",c=!1;continue}n(),s+="|";continue;case"[":if(n(),l){s+="\\"+a;continue}l=!0,d=m,h=s.length,s+=a;continue;case"]":if(m===d+1||!l){s+="\\"+a,c=!1;continue}u=!0,l=!1,s+=a;continue;default:n(),c?c=!1:!A[a]||"^"===a&&l||(s+="\\"),s+=a}if(l){var b=t.substr(d+1),w=this.parse(b,T);s=s.substr(0,h)+"\\["+w[0],u=u||w[1]}for(var _;_=f.pop();){var j=s.slice(_.reStart+3);j=j.replace(/((?:\\{2})*)(\\?)\|/g,function(t,e,n){return n||(n="\\"),e+e+n+"|"}),this.debug("tail=%j\n %s",j,j);var x="*"===_.type?I:"?"===_.type?O:"\\"+_.type;u=!0,s=s.slice(0,_.reStart)+x+"\\("+j}n(),c&&(s+="\\\\");var S=!1;switch(s.charAt(0)){case".":case"[":case"(":S=!0}if(""!==s&&u&&(s="(?=.)"+s),S&&(s=p+s),e===T)return[s,u];if(!u)return v(t);var N=r.nocase?"i":"",D=RegExp("^"+s+"$",N);return D._glob=t,D._src=s,D}function p(){if(this.regexp||this.regexp===!1)return this.regexp;var t=this.set;if(!t.length)return this.regexp=!1;var e=this.options,n=e.noglobstar?I:e.dot?_:j,r=e.nocase?"i":"",i=t.map(function(t){return t.map(function(t){return t===E?n:"string"==typeof t?m(t):t._src}).join("\\/")}).join("|");i="^(?:"+i+")$",this.negate&&(i="^(?!"+i+").*$");try{return this.regexp=RegExp(i,r)}catch(o){return this.regexp=!1}}function g(t,e){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return""===t;if("/"===t&&e)return!0;var n=this.options;"win32"===r&&(t=t.split("\\").join("/")),t=t.split(x),this.debug(this.pattern,"split",t);var i=this.set;this.debug(this.pattern,"set",i);for(var o,a=t.length-1;a>=0&&!(o=t[a]);a--);for(var a=0,s=i.length;s>a;a++){var u=i[a],c=t;n.matchBase&&1===u.length&&(c=[o]);var f=this.matchOne(c,u,e);if(f)return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}function v(t){return t.replace(/\\(.)/g,"$1")}function m(t){return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}n?n.exports=s:e.minimatch=s,t||(t=function(t){switch(t){case"sigmund":return function(t){return JSON.stringify(t)};case"path":return{basename:function(t){t=t.split(/[\/\\]/);var e=t.pop();return e||(e=t.pop()),e}};case"lru-cache":return function(){var t={},e=0;this.set=function(n,r){e++,e>=100&&(t={}),t[n]=r},this.get=function(e){return t[e]}}}}),s.Minimatch=u;var y=t("lru-cache"),b=s.cache=new y({max:100}),E=s.GLOBSTAR=u.GLOBSTAR={},w=t("sigmund"),O=(t("path"),"[^/]"),I=O+"*?",_="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",j="(?:(?!(?:\\/|^)\\.).)*?",A=i("().*{}+?[]^$\\!"),x=/\/+/;s.filter=o,s.defaults=function(t){if(!t||!Object.keys(t).length)return r;var e=r,n=function r(n,r,i){return e.minimatch(n,r,a(t,i))};return n.Minimatch=function(n,r){return new e.Minimatch(n,a(t,r))},n},u.defaults=function(t){return t&&Object.keys(t).length?s.defaults(t).Minimatch:u},u.prototype.debug=function(){},u.prototype.make=c,u.prototype.parseNegate=f,s.braceExpand=function(t,e){return new u(t,e).braceExpand()},u.prototype.braceExpand=h,u.prototype.parse=d;var T={};s.makeRe=function(t,e){return new u(t,e||{}).makeRe()},u.prototype.makeRe=p,s.match=function(t,e,n){n=n||{};var r=new u(e,n);return t=t.filter(function(t){return r.match(t)}),r.options.nonull&&!t.length&&t.push(e),t},u.prototype.match=g,u.prototype.matchOne=function(t,e,n){var r=this.options;this.debug("matchOne",{"this":this,file:t,pattern:e}),this.debug("matchOne",t.length,e.length);for(var i=0,o=0,a=t.length,s=e.length;a>i&&s>o;i++,o++){this.debug("matchOne loop");var u=e[o],c=t[i];if(this.debug(e,u,c),u===!1)return!1;if(u===E){this.debug("GLOBSTAR",[e,u,c]);var f=i,l=o+1;if(l===s){for(this.debug("** at the end");a>i;i++)if("."===t[i]||".."===t[i]||!r.dot&&"."===t[i].charAt(0))return!1;return!0}t:for(;a>f;){var h=t[f];if(this.debug("\nglobstar while",t,f,e,l,h),this.matchOne(t.slice(f),e.slice(l),n))return this.debug("globstar found match!",f,a,h),!0;if("."===h||".."===h||!r.dot&&"."===h.charAt(0)){this.debug("dot detected!",t,f,e,l);break t}this.debug("globstar swallow a segment, and continue"),f++}return n&&(this.debug("\n>>> no match, partial?",t,f,e,l),f===a)?!0:!1}var d;if("string"==typeof u?(d=r.nocase?c.toLowerCase()===u.toLowerCase():c===u,this.debug("string match",u,c,d)):(d=c.match(u),this.debug("pattern match",u,c,d)),!d)return!1}if(i===a&&o===s)return!0;if(i===a)return n;if(o===s){var p=i===a-1&&""===t[i];return p}throw Error("wtf?")}})("function"==typeof t?t:null,this,"object"==typeof e?e:null,"object"==typeof n?n.platform:"win32")}).call(this,t("JkpR2F"))},{JkpR2F:10,"lru-cache":12,path:9,sigmund:13}],12:[function(t,e){(function(){function t(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function n(){return 1}function r(t){return this instanceof r?("number"==typeof t&&(t={max:t}),t||(t={}),this._max=t.max,(!this._max||"number"!=typeof this._max||0>=this._max)&&(this._max=1/0),this._lengthCalculator=t.length||n,"function"!=typeof this._lengthCalculator&&(this._lengthCalculator=n),this._allowStale=t.stale||!1,this._maxAge=t.maxAge||null,this._dispose=t.dispose,this.reset(),void 0):new r(t)}function i(t,e,n){var r=t._cache[e];return r&&(t._maxAge&&Date.now()-r.now>t._maxAge?(u(t,r),t._allowStale||(r=void 0)):n&&o(t,r),r&&(r=r.value)),r}function o(t,e){s(t,e),e.lu=t._mru++,t._lruList[e.lu]=e}function a(t){for(;t._lrut._max;)u(t,t._lruList[t._lru])}function s(t,e){for(delete t._lruList[e.lu];t._lru=t)&&(t=1/0),this._max=t,this._length>this._max&&a(this)},get:function(){return this._max},enumerable:!0}),Object.defineProperty(r.prototype,"lengthCalculator",{set:function(t){if("function"!=typeof t){this._lengthCalculator=n,this._length=this._itemCount;for(var e in this._cache)this._cache[e].length=1}else{this._lengthCalculator=t,this._length=0;for(var e in this._cache)this._cache[e].length=this._lengthCalculator(this._cache[e].value),this._length+=this._cache[e].length}this._length>this._max&&a(this)},get:function(){return this._lengthCalculator},enumerable:!0}),Object.defineProperty(r.prototype,"length",{get:function(){return this._length},enumerable:!0}),Object.defineProperty(r.prototype,"itemCount",{get:function(){return this._itemCount},enumerable:!0}),r.prototype.forEach=function(t,e){e=e||this;for(var n=0,r=this._mru-1;r>=0&&this._itemCount>n;r--)if(this._lruList[r]){n++;var i=this._lruList[r];this._maxAge&&Date.now()-i.now>this._maxAge&&(u(this,i),this._allowStale||(i=void 0)),i&&t.call(e,i.value,i.key,this)}},r.prototype.keys=function(){for(var t=Array(this._itemCount),e=0,n=this._mru-1;n>=0&&this._itemCount>e;n--)if(this._lruList[n]){var r=this._lruList[n];t[e++]=r.key}return t},r.prototype.values=function(){for(var t=Array(this._itemCount),e=0,n=this._mru-1;n>=0&&this._itemCount>e;n--)if(this._lruList[n]){var r=this._lruList[n];t[e++]=r.value}return t},r.prototype.reset=function(){if(this._dispose&&this._cache)for(var t in this._cache)this._dispose(t,this._cache[t].value);this._cache=Object.create(null),this._lruList=Object.create(null),this._mru=0,this._lru=0,this._length=0,this._itemCount=0},r.prototype.dump=function(){return this._cache},r.prototype.dumpLru=function(){return this._lruList},r.prototype.set=function(e,n){if(t(this._cache,e))return this._dispose&&this._dispose(e,this._cache[e].value),this._maxAge&&(this._cache[e].now=Date.now()),this._cache[e].value=n,this.get(e),!0;var r=this._lengthCalculator(n),i=this._maxAge?Date.now():0,o=new c(e,n,this._mru++,r,i);return o.length>this._max?(this._dispose&&this._dispose(e,n),!1):(this._length+=o.length,this._lruList[o.lu]=this._cache[e]=o,this._itemCount++,this._length>this._max&&a(this),!0)},r.prototype.has=function(e){if(!t(this._cache,e))return!1;var n=this._cache[e];return this._maxAge&&Date.now()-n.now>this._maxAge?!1:!0},r.prototype.get=function(t){return i(this,t,!0)},r.prototype.peek=function(t){return i(this,t,!1)},r.prototype.pop=function(){var t=this._lruList[this._lru];return u(this,t),t||null},r.prototype.del=function(t){u(this,this._cache[t])}})()},{}],13:[function(t,e){function n(t,e){function n(t,a){return a>e||"function"==typeof t||void 0===t?void 0:"object"!=typeof t||!t||t instanceof o?(i+=t,void 0):(-1===r.indexOf(t)&&a!==e&&(r.push(t),i+="{",Object.keys(t).forEach(function(e){if("_"!==e.charAt(0)){var r=typeof t[e];"function"!==r&&"undefined"!==r&&(i+=e,n(t[e],a+1))}})),void 0)}e=e||10;var r=[],i="",o=RegExp;return n(t,0),i}e.exports=n},{}],14:[function(t,e){(function(t){function n(e,n,r){return e instanceof ArrayBuffer&&(e=new Uint8Array(e)),new t(e,n,r)}n.prototype=Object.create(t.prototype),n.prototype.constructor=n,Object.keys(t).forEach(function(e){t.hasOwnProperty(e)&&(n[e]=t[e])}),e.exports=n}).call(this,t("buffer").Buffer)},{buffer:6}],15:[function(t,e){var n="READ",r="WRITE",i="CREATE",o="EXCLUSIVE",a="TRUNCATE",s="APPEND",u="CREATE",c="REPLACE";e.exports={FILE_SYSTEM_NAME:"local",FILE_STORE_NAME:"files",IDB_RO:"readonly",IDB_RW:"readwrite",WSQL_VERSION:"1",WSQL_SIZE:5242880,WSQL_DESC:"FileSystem Storage",MODE_FILE:"FILE",MODE_DIRECTORY:"DIRECTORY",MODE_SYMBOLIC_LINK:"SYMLINK",MODE_META:"META",SYMLOOP_MAX:10,BINARY_MIME_TYPE:"application/octet-stream",JSON_MIME_TYPE:"application/json",ROOT_DIRECTORY_NAME:"/",FS_FORMAT:"FORMAT",FS_NOCTIME:"NOCTIME",FS_NOMTIME:"NOMTIME",FS_NODUPEIDCHECK:"FS_NODUPEIDCHECK",O_READ:n,O_WRITE:r,O_CREATE:i,O_EXCLUSIVE:o,O_TRUNCATE:a,O_APPEND:s,O_FLAGS:{r:[n],"r+":[n,r],w:[r,i,a],"w+":[r,n,i,a],wx:[r,i,o,a],"wx+":[r,n,i,o,a],a:[r,i,s],"a+":[r,n,i,s],ax:[r,i,o,s],"ax+":[r,n,i,o,s]},XATTR_CREATE:u,XATTR_REPLACE:c,FS_READY:"READY",FS_PENDING:"PENDING",FS_ERROR:"ERROR",SUPER_NODE_ID:"00000000-0000-0000-0000-000000000000",STDIN:0,STDOUT:1,STDERR:2,FIRST_DESCRIPTOR:3,ENVIRONMENT:{TMP:"/tmp",PATH:""}}},{}],16:[function(t,e){var n=t("./constants.js").MODE_FILE;e.exports=function(t,e){this.id=t,this.type=e||n}},{"./constants.js":15}],17:[function(t,e){(function(t){function n(t){return t.toString("utf8")}function r(e){return new t(e,"utf8")}e.exports={encode:r,decode:n}}).call(this,t("buffer").Buffer)},{buffer:6}],18:[function(t,e){var n={};["9:EBADF:bad file descriptor","10:EBUSY:resource busy or locked","18:EINVAL:invalid argument","27:ENOTDIR:not a directory","28:EISDIR:illegal operation on a directory","34:ENOENT:no such file or directory","47:EEXIST:file already exists","50:EPERM:operation not permitted","51:ELOOP:too many symbolic links encountered","53:ENOTEMPTY:directory not empty","55:EIO:i/o error","1000:ENOTMOUNTED:not mounted","1001:EFILESYSTEMERROR:missing super node, use 'FORMAT' flag to format filesystem.","1002:ENOATTR:attribute does not exist"].forEach(function(t){function e(t,e){Error.call(this),this.name=i,this.code=i,this.errno=r,this.message=t||o,e&&(this.path=e),this.stack=Error(this.message).stack}t=t.split(":");var r=+t[0],i=t[1],o=t[2];e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(){var t=this.path?", '"+this.path+"'":"";return this.name+": "+this.message+t},n[i]=n[r]=e}),e.exports=n},{}],19:[function(t,e){function n(t,e,n,r,i){function o(n){t.changes.push({event:"change",path:e}),i(n)}var a=t.flags;le(a).contains(Me)&&delete r.ctime,le(a).contains(Be)&&delete r.mtime;var s=!1;r.ctime&&(n.ctime=r.ctime,n.atime=r.ctime,s=!0),r.atime&&(n.atime=r.atime,s=!0),r.mtime&&(n.mtime=r.mtime,s=!0),s?t.putObject(n.id,n,o):o()}function r(t,e,r,o){function a(n,r){n?o(n):r.mode!==Ee?o(new ke.ENOTDIR("a component of the path prefix is not a directory",e)):(l=r,i(t,e,s))}function s(n,r){!n&&r?o(new ke.EEXIST("path name already exists",e)):!n||n instanceof ke.ENOENT?t.getObject(l.data,u):o(n)}function u(e,n){e?o(e):(h=n,Ve.create({guid:t.guid,mode:r},function(e,n){return e?(o(e),void 0):(d=n,d.nlinks+=1,t.putObject(d.id,d,f),void 0)}))}function c(e){if(e)o(e);else{var r=Date.now();n(t,g,d,{mtime:r,ctime:r},o)}}function f(e){e?o(e):(h[p]=new Fe(d.id,r),t.putObject(l.data,h,c))}if(r!==Ee&&r!==be)return o(new ke.EINVAL("mode must be a directory or file",e));e=de(e);var l,h,d,p=ge(e),g=pe(e);i(t,g,a)}function i(t,e,n){function r(e,r){e?n(e):r&&r.mode===Oe&&r.rnode?t.getObject(r.rnode,o):n(new ke.EFILESYSTEMERROR)}function o(t,e){t?n(t):e?n(null,e):n(new ke.ENOENT)}function a(r,i){r?n(r):i.mode===Ee&&i.data?t.getObject(i.data,s):n(new ke.ENOTDIR("a component of the path prefix is not a directory",e))}function s(r,i){if(r)n(r);else if(le(i).has(f)){var o=i[f].id;t.getObject(o,u)}else n(new ke.ENOENT(null,e))}function u(t,r){t?n(t):r.mode==we?(h++,h>je?n(new ke.ELOOP(null,e)):c(r.data)):n(null,r)}function c(e){e=de(e),l=pe(e),f=ge(e),Ie==f?t.getObject(_e,r):i(t,l,a)}if(e=de(e),!e)return n(new ke.ENOENT("path is an empty string"));var f=ge(e),l=pe(e),h=0;Ie==f?t.getObject(_e,r):i(t,l,a)}function o(t,e,r,i,o,a,s){function u(i){i?s(i):n(t,e,r,{ctime:Date.now()},s)}var c=r.xattrs;a===Re&&c.hasOwnProperty(i)?s(new ke.EEXIST("attribute already exists",e)):a!==Le||c.hasOwnProperty(i)?(c[i]=o,t.putObject(r.id,r,u)):s(new ke.ENOATTR(null,e))}function a(t,e){function n(n,i){!n&&i?e():!n||n instanceof ke.ENOENT?Ue.create({guid:t.guid},function(n,i){return n?(e(n),void 0):(o=i,t.putObject(o.id,o,r),void 0)}):e(n)}function r(n){n?e(n):Ve.create({guid:t.guid,id:o.rnode,mode:Ee},function(n,r){return n?(e(n),void 0):(a=r,a.nlinks+=1,t.putObject(a.id,a,i),void 0)})}function i(n){n?e(n):(s={},t.putObject(a.data,s,e))}var o,a,s;t.getObject(_e,n)}function s(t,e,r){function o(n,o){!n&&o?r(new ke.EEXIST(null,e)):!n||n instanceof ke.ENOENT?i(t,v,a):r(n)}function a(e,n){e?r(e):(d=n,t.getObject(d.data,s))}function s(e,n){e?r(e):(p=n,Ve.create({guid:t.guid,mode:Ee},function(e,n){return e?(r(e),void 0):(l=n,l.nlinks+=1,t.putObject(l.id,l,u),void 0)}))}function u(e){e?r(e):(h={},t.putObject(l.data,h,f))}function c(e){if(e)r(e);else{var i=Date.now();n(t,v,d,{mtime:i,ctime:i},r)}}function f(e){e?r(e):(p[g]=new Fe(l.id,Ee),t.putObject(d.data,p,c))}e=de(e);var l,h,d,p,g=ge(e),v=pe(e);i(t,e,o)}function u(t,e,r){function o(e,n){e?r(e):(g=n,t.getObject(g.data,a))}function a(n,i){n?r(n):Ie==m?r(new ke.EBUSY(null,e)):le(i).has(m)?(v=i,d=v[m].id,t.getObject(d,s)):r(new ke.ENOENT(null,e))}function s(n,i){n?r(n):i.mode!=Ee?r(new ke.ENOTDIR(null,e)):(d=i,t.getObject(d.data,u))}function u(t,n){t?r(t):(p=n,le(p).size()>0?r(new ke.ENOTEMPTY(null,e)):f())}function c(e){if(e)r(e);else{var i=Date.now();n(t,y,g,{mtime:i,ctime:i},l)}}function f(){delete v[m],t.putObject(g.data,v,c)}function l(e){e?r(e):t.delete(d.id,h)}function h(e){e?r(e):t.delete(d.data,r)}e=de(e);var d,p,g,v,m=ge(e),y=pe(e);i(t,y,o)}function c(t,e,r,o){function a(n,r){n?o(n):r.mode!==Ee?o(new ke.ENOENT(null,e)):(v=r,t.getObject(v.data,s))}function s(n,i){n?o(n):(m=i,le(m).has(w)?le(r).contains(Se)?o(new ke.ENOENT("O_CREATE and O_EXCLUSIVE are set, and the named file exists",e)):(y=m[w],y.type==Ee&&le(r).contains(xe)?o(new ke.EISDIR("the named file is a directory and O_WRITE is set",e)):t.getObject(y.id,u)):le(r).contains(Te)?l():o(new ke.ENOENT("O_CREATE is not set and the named file does not exist",e)))}function u(t,n){if(t)o(t);else{var r=n;r.mode==we?(I++,I>je?o(new ke.ELOOP(null,e)):c(r.data)):f(void 0,r)}}function c(n){n=de(n),O=pe(n),w=ge(n),Ie==w&&(le(r).contains(xe)?o(new ke.EISDIR("the named file is a directory and O_WRITE is set",e)):i(t,e,f)),i(t,O,a)}function f(t,e){t?o(t):(b=e,o(null,b))}function l(){Ve.create({guid:t.guid,mode:be},function(e,n){return e?(o(e),void 0):(b=n,b.nlinks+=1,t.putObject(b.id,b,h),void 0)})}function h(e){e?o(e):(E=new Xe(0),E.fill(0),t.putBuffer(b.data,E,p))}function d(e){if(e)o(e);else{var r=Date.now();n(t,O,v,{mtime:r,ctime:r},g)}}function p(e){e?o(e):(m[w]=new Fe(b.id,be),t.putObject(v.data,m,d))}function g(t){t?o(t):o(null,b)}e=de(e);var v,m,y,b,E,w=ge(e),O=pe(e),I=0;Ie==w?le(r).contains(xe)?o(new ke.EISDIR("the named file is a directory and O_WRITE is set",e)):i(t,e,f):i(t,O,a)}function f(t,e,r,i,o,a){function s(t){t?a(t):a(null,o)}function u(r){if(r)a(r);else{var i=Date.now();n(t,e.path,l,{mtime:i,ctime:i},s)}}function c(e){e?a(e):t.putObject(l.id,l,u)}function f(n,s){if(n)a(n);else{l=s;var u=new Xe(o);u.fill(0),r.copy(u,0,i,i+o),e.position=o,l.size=o,l.version+=1,t.putBuffer(l.data,u,c)}}var l;t.getObject(e.id,f)}function l(t,e,r,i,o,a,s){function u(t){t?s(t):s(null,o)}function c(r){if(r)s(r);else{var i=Date.now();n(t,e.path,d,{mtime:i,ctime:i},u)}}function f(e){e?s(e):t.putObject(d.id,d,c)}function l(n,u){if(n)s(n);else{if(p=u,!p)return s(new ke.EIO("Expected Buffer"));var c=void 0!==a&&null!==a?a:e.position,l=Math.max(p.length,c+o),h=new Xe(l);h.fill(0),p&&p.copy(h),r.copy(h,c,i,i+o),void 0===a&&(e.position+=o),d.size=l,d.version+=1,t.putBuffer(d.data,h,f)}}function h(e,n){e?s(e):(d=n,t.getBuffer(d.data,l))}var d,p;t.getObject(e.id,h)}function h(t,e,n,r,i,o,a){function s(t,s){if(t)a(t);else{if(f=s,!f)return a(new ke.EIO("Expected Buffer"));var u=void 0!==o&&null!==o?o:e.position;i=u+i>n.length?i-u:i,f.copy(n,r,u,u+i),void 0===o&&(e.position+=i),a(null,i)}}function u(n,r){n?a(n):"DIRECTORY"===r.mode?a(new ke.EISDIR("the named file is a directory",e.path)):(c=r,t.getBuffer(c.data,s))}var c,f;t.getObject(e.id,u)}function d(t,e,n){e=de(e),ge(e),i(t,e,n)}function p(t,e,n){e.getNode(t,n)}function g(t,e,n){function r(e,r){e?n(e):(a=r,t.getObject(a.data,o))}function o(r,i){r?n(r):(s=i,le(s).has(u)?t.getObject(s[u].id,n):n(new ke.ENOENT("a component of the path does not name an existing file",e)))}e=de(e);var a,s,u=ge(e),c=pe(e);Ie==u?i(t,e,n):i(t,c,r)}function v(t,e,r,o){function a(e){e?o(e):n(t,r,b,{ctime:Date.now()},o)}function s(e,n){e?o(e):(b=n,b.nlinks+=1,t.putObject(b.id,b,a))}function u(e){e?o(e):t.getObject(y[E].id,s)}function c(e,n){e?o(e):(y=n,le(y).has(E)?o(new ke.EEXIST("newpath resolves to an existing file",E)):(y[E]=v[d],t.putObject(m.data,y,u)))}function f(e,n){e?o(e):(m=n,t.getObject(m.data,c))}function l(e,n){e?o(e):(v=n,le(v).has(d)?i(t,w,f):o(new ke.ENOENT("a component of either path prefix does not exist",d)))}function h(e,n){e?o(e):(g=n,t.getObject(g.data,l))}e=de(e);var d=ge(e),p=pe(e);r=de(r);var g,v,m,y,b,E=ge(r),w=pe(r);i(t,p,h)}function m(t,e,r){function o(e){e?r(e):(delete h[p],t.putObject(l.data,h,function(){var e=Date.now();n(t,g,l,{mtime:e,ctime:e},r)}))}function a(e){e?r(e):t.delete(d.data,o)}function s(i,s){i?r(i):(d=s,d.nlinks-=1,1>d.nlinks?t.delete(d.id,a):t.putObject(d.id,d,function(){n(t,e,d,{ctime:Date.now()},o)}))}function u(t,e){t?r(t):"DIRECTORY"===e.mode?r(new ke.EPERM("unlink not permitted on directories",p)):s(null,e)}function c(e,n){e?r(e):(h=n,le(h).has(p)?t.getObject(h[p].id,u):r(new ke.ENOENT("a component of the path does not name an existing file",p)))}function f(e,n){e?r(e):(l=n,t.getObject(l.data,c))}e=de(e);var l,h,d,p=ge(e),g=pe(e);i(t,g,f)}function y(t,e,n){function r(t,e){if(t)n(t);else{s=e;var r=Object.keys(s);n(null,r)}}function o(i,o){i?n(i):o.mode!==Ee?n(new ke.ENOTDIR(null,e)):(a=o,t.getObject(a.data,r))}e=de(e),ge(e);var a,s;i(t,e,o)}function b(t,e,r,o){function a(e,n){e?o(e):(l=n,t.getObject(l.data,s))}function s(t,e){t?o(t):(h=e,le(h).has(p)?o(new ke.EEXIST(null,p)):u())}function u(){Ve.create({guid:t.guid,mode:we},function(n,r){return n?(o(n),void 0):(d=r,d.nlinks+=1,d.size=e.length,d.data=e,t.putObject(d.id,d,f),void 0)})}function c(e){if(e)o(e);else{var r=Date.now();n(t,g,l,{mtime:r,ctime:r},o)}}function f(e){e?o(e):(h[p]=new Fe(d.id,we),t.putObject(l.data,h,c))}r=de(r);var l,h,d,p=ge(r),g=pe(r);Ie==p?o(new ke.EEXIST(null,p)):i(t,g,a)}function E(t,e,n){function r(e,r){e?n(e):(s=r,t.getObject(s.data,o))}function o(e,r){e?n(e):(u=r,le(u).has(c)?t.getObject(u[c].id,a):n(new ke.ENOENT("a component of the path does not name an existing file",c)))}function a(t,r){t?n(t):r.mode!=we?n(new ke.EINVAL("path not a symbolic link",e)):n(null,r.data)}e=de(e);var s,u,c=ge(e),f=pe(e);i(t,f,r)}function w(t,e,r,o){function a(n,r){n?o(n):r.mode==Ee?o(new ke.EISDIR(null,e)):(f=r,t.getBuffer(f.data,s))}function s(e,n){if(e)o(e);else{if(!n)return o(new ke.EIO("Expected Buffer"));var i=new Xe(r);i.fill(0),n&&n.copy(i),t.putBuffer(f.data,i,c)}}function u(r){if(r)o(r);else{var i=Date.now();n(t,e,f,{mtime:i,ctime:i},o)}}function c(e){e?o(e):(f.size=r,f.version+=1,t.putObject(f.id,f,u))}e=de(e);var f;0>r?o(new ke.EINVAL("length cannot be negative")):i(t,e,a)}function O(t,e,r,i){function o(e,n){e?i(e):n.mode==Ee?i(new ke.EISDIR):(c=n,t.getBuffer(c.data,a))}function a(e,n){if(e)i(e);else{var o;if(!n)return i(new ke.EIO("Expected Buffer"));n?o=n.slice(0,r):(o=new Xe(r),o.fill(0)),t.putBuffer(c.data,o,u)}}function s(r){if(r)i(r);else{var o=Date.now();n(t,e.path,c,{mtime:o,ctime:o},i)}}function u(e){e?i(e):(c.size=r,c.version+=1,t.putObject(c.id,c,s))}var c;0>r?i(new ke.EINVAL("length cannot be negative")):e.getNode(t,o)}function I(t,e,r,o,a){function s(i,s){i?a(i):n(t,e,s,{atime:r,ctime:o,mtime:o},a)}e=de(e),"number"!=typeof r||"number"!=typeof o?a(new ke.EINVAL("atime and mtime must be number",e)):0>r||0>o?a(new ke.EINVAL("atime and mtime must be positive integers",e)):i(t,e,s)}function _(t,e,r,i,o){function a(a,s){a?o(a):n(t,e.path,s,{atime:r,ctime:i,mtime:i},o)}"number"!=typeof r||"number"!=typeof i?o(new ke.EINVAL("atime and mtime must be a number")):0>r||0>i?o(new ke.EINVAL("atime and mtime must be positive integers")):e.getNode(t,a)}function j(t,e,n,r,a,s){function u(i,u){return i?s(i):(o(t,e,u,n,r,a,s),void 0)}e=de(e),"string"!=typeof n?s(new ke.EINVAL("attribute name must be a string",e)):n?null!==a&&a!==Re&&a!==Le?s(new ke.EINVAL("invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE",e)):i(t,e,u):s(new ke.EINVAL("attribute name cannot be an empty string",e))}function A(t,e,n,r,i,a){function s(s,u){return s?a(s):(o(t,e.path,u,n,r,i,a),void 0)}"string"!=typeof n?a(new ke.EINVAL("attribute name must be a string")):n?null!==i&&i!==Re&&i!==Le?a(new ke.EINVAL("invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE")):e.getNode(t,s):a(new ke.EINVAL("attribute name cannot be an empty string"))}function x(t,e,n,r){function o(t,i){if(t)return r(t);var o=i.xattrs;o.hasOwnProperty(n)?r(null,o[n]):r(new ke.ENOATTR(null,e))}e=de(e),"string"!=typeof n?r(new ke.EINVAL("attribute name must be a string",e)):n?i(t,e,o):r(new ke.EINVAL("attribute name cannot be an empty string",e))}function T(t,e,n,r){function i(t,e){if(t)return r(t);var i=e.xattrs;i.hasOwnProperty(n)?r(null,i[n]):r(new ke.ENOATTR)}"string"!=typeof n?r(new ke.EINVAL):n?e.getNode(t,i):r(new ke.EINVAL("attribute name cannot be an empty string"))}function S(t,e,r,o){function a(i,a){function s(r){r?o(r):n(t,e,a,{ctime:Date.now()},o)}if(i)return o(i);var u=a.xattrs;u.hasOwnProperty(r)?(delete u[r],t.putObject(a.id,a,s)):o(new ke.ENOATTR(null,e))}e=de(e),"string"!=typeof r?o(new ke.EINVAL("attribute name must be a string",e)):r?i(t,e,a):o(new ke.EINVAL("attribute name cannot be an empty string",e))}function N(t,e,r,i){function o(o,a){function s(r){r?i(r):n(t,e.path,a,{ctime:Date.now()},i)}if(o)return i(o);var u=a.xattrs;u.hasOwnProperty(r)?(delete u[r],t.putObject(a.id,a,s)):i(new ke.ENOATTR)}"string"!=typeof r?i(new ke.EINVAL("attribute name must be a string")):r?e.getNode(t,o):i(new ke.EINVAL("attribute name cannot be an empty string"))}function D(t){return le(De).has(t)?De[t]:null}function R(t,e,n){return t?"function"==typeof t?t={encoding:e,flag:n}:"string"==typeof t&&(t={encoding:t,flag:n}):t={encoding:e,flag:n},t}function L(t,e){var n;return t?me(t)?n=new ke.EINVAL("Path must be a string without null bytes.",t):ve(t)||(n=new ke.EINVAL("Path must be absolute.",t)):n=new ke.EINVAL("Path must be a string",t),n?(e(n),!1):!0}function B(t,e,n,r,i,o){function a(e,i){if(e)o(e);else{var a;a=le(r).contains(Ne)?i.size:0;var s=new Pe(n,i.id,r,a),u=t.allocDescriptor(s);o(null,u)}}o=arguments[arguments.length-1],L(n,o)&&(r=D(r),r||o(new ke.EINVAL("flags is not valid"),n),c(e,n,r,a))}function M(t,e,n,r){le(t.openFiles).has(n)?(t.releaseDescriptor(n),r(null)):r(new ke.EBADF)}function C(t,e,n,i,o){L(n,o)&&r(e,n,i,o)}function k(t,e,n,r,i){i=arguments[arguments.length-1],L(n,i)&&s(e,n,i)}function F(t,e,n,r){L(n,r)&&u(e,n,r)}function P(t,e,n,r){function i(e,n){if(e)r(e);else{var i=new Ye(n,t.name);r(null,i)}}L(n,r)&&d(e,n,i)}function U(t,e,n,r){function i(e,n){if(e)r(e);else{var i=new Ye(n,t.name);r(null,i)}}var o=t.openFiles[n];o?p(e,o,i):r(new ke.EBADF)}function V(t,e,n,r,i){L(n,i)&&L(r,i)&&v(e,n,r,i)}function Y(t,e,n,r){L(n,r)&&m(e,n,r)}function X(t,e,n,r,i,o,a,s){function u(t,e){s(t,e||0,r)}i=void 0===i?0:i,o=void 0===o?r.length-i:o,s=arguments[arguments.length-1];var c=t.openFiles[n];c?le(c.flags).contains(Ae)?h(e,c,r,i,o,a,u):s(new ke.EBADF("descriptor does not permit reading")):s(new ke.EBADF)}function z(t,e,n,r,i){if(i=arguments[arguments.length-1],r=R(r,null,"r"),L(n,i)){var o=D(r.flag||"r");return o?(c(e,n,o,function(a,s){function u(){t.releaseDescriptor(f)}if(a)return i(a);var c=new Pe(n,s.id,o,0),f=t.allocDescriptor(c);p(e,c,function(o,a){if(o)return u(),i(o);var s=new Ye(a,t.name);if(s.isDirectory())return u(),i(new ke.EISDIR("illegal operation on directory",n));var f=s.size,l=new Xe(f);l.fill(0),h(e,c,l,0,f,0,function(t){if(u(),t)return i(t);var e;e="utf8"===r.encoding?Ce.decode(l):l,i(null,e)})})}),void 0):i(new ke.EINVAL("flags is not valid",n))}}function W(t,e,n,r,i,o,a,s){s=arguments[arguments.length-1],i=void 0===i?0:i,o=void 0===o?r.length-i:o;var u=t.openFiles[n];u?le(u.flags).contains(xe)?o>r.length-i?s(new ke.EIO("intput buffer is too small")):l(e,u,r,i,o,a,s):s(new ke.EBADF("descriptor does not permit writing")):s(new ke.EBADF)}function J(t,e,n,r,i,o){if(o=arguments[arguments.length-1],i=R(i,"utf8","w"),L(n,o)){var a=D(i.flag||"w");if(!a)return o(new ke.EINVAL("flags is not valid",n));r=r||"","number"==typeof r&&(r=""+r),"string"==typeof r&&"utf8"===i.encoding&&(r=Ce.encode(r)),c(e,n,a,function(i,s){if(i)return o(i);var u=new Pe(n,s.id,a,0),c=t.allocDescriptor(u);f(e,u,r,0,r.length,function(e){return t.releaseDescriptor(c),e?o(e):(o(null),void 0)})})}}function q(t,e,n,r,i,o){if(o=arguments[arguments.length-1],i=R(i,"utf8","a"),L(n,o)){var a=D(i.flag||"a");if(!a)return o(new ke.EINVAL("flags is not valid",n));r=r||"","number"==typeof r&&(r=""+r),"string"==typeof r&&"utf8"===i.encoding&&(r=Ce.encode(r)),c(e,n,a,function(i,s){if(i)return o(i);var u=new Pe(n,s.id,a,s.size),c=t.allocDescriptor(u);l(e,u,r,0,r.length,u.position,function(e){return t.releaseDescriptor(c),e?o(e):(o(null),void 0)})})}}function $(t,e,n,r){function i(t){r(t?!1:!0)}P(t,e,n,i)}function Q(t,e,n,r,i){L(n,i)&&x(e,n,r,i)}function H(t,e,n,r,i){var o=t.openFiles[n];o?T(e,o,r,i):i(new ke.EBADF)}function G(t,e,n,r,i,o,a){"function"==typeof o&&(a=o,o=null),L(n,a)&&j(e,n,r,i,o,a)}function K(t,e,n,r,i,o,a){"function"==typeof o&&(a=o,o=null);var s=t.openFiles[n];s?le(s.flags).contains(xe)?A(e,s,r,i,o,a):a(new ke.EBADF("descriptor does not permit writing")):a(new ke.EBADF)}function Z(t,e,n,r,i){L(n,i)&&S(e,n,r,i)}function te(t,e,n,r,i){var o=t.openFiles[n];o?le(o.flags).contains(xe)?N(e,o,r,i):i(new ke.EBADF("descriptor does not permit writing")):i(new ke.EBADF)}function ee(t,e,n,r,i,o){function a(t,e){t?o(t):0>e.size+r?o(new ke.EINVAL("resulting file offset would be negative")):(s.position=e.size+r,o(null,s.position))}var s=t.openFiles[n];s||o(new ke.EBADF),"SET"===i?0>r?o(new ke.EINVAL("resulting file offset would be negative")):(s.position=r,o(null,s.position)):"CUR"===i?0>s.position+r?o(new ke.EINVAL("resulting file offset would be negative")):(s.position+=r,o(null,s.position)):"END"===i?p(e,s,a):o(new ke.EINVAL("whence argument is not a proper value"))}function ne(t,e,n,r){L(n,r)&&y(e,n,r)}function re(t,e,n,r,i,o){if(L(n,o)){var a=Date.now();r=r?r:a,i=i?i:a,I(e,n,r,i,o)}}function ie(t,e,n,r,i,o){var a=Date.now();r=r?r:a,i=i?i:a;var s=t.openFiles[n];s?le(s.flags).contains(xe)?_(e,s,r,i,o):o(new ke.EBADF("descriptor does not permit writing")):o(new ke.EBADF)}function oe(t,e,n,r,i){function o(t){t?i(t):m(e,n,i)}L(n,i)&&L(r,i)&&v(e,n,r,o)}function ae(t,e,n,r,i,o){o=arguments[arguments.length-1],L(n,o)&&L(r,o)&&b(e,n,r,o)}function se(t,e,n,r){L(n,r)&&E(e,n,r)}function ue(t,e,n,r){function i(e,n){if(e)r(e);else{var i=new Ye(n,t.name);r(null,i)}}L(n,r)&&g(e,n,i)}function ce(t,e,n,r,i){i=arguments[arguments.length-1],r=r||0,L(n,i)&&w(e,n,r,i)}function fe(t,e,n,r,i){i=arguments[arguments.length-1],r=r||0;var o=t.openFiles[n];o?le(o.flags).contains(xe)?O(e,o,r,i):i(new ke.EBADF("descriptor does not permit writing")):i(new ke.EBADF)}var le=t("../../lib/nodash.js"),he=t("../path.js"),de=he.normalize,pe=he.dirname,ge=he.basename,ve=he.isAbsolute,me=he.isNull,ye=t("../constants.js"),be=ye.MODE_FILE,Ee=ye.MODE_DIRECTORY,we=ye.MODE_SYMBOLIC_LINK,Oe=ye.MODE_META,Ie=ye.ROOT_DIRECTORY_NAME,_e=ye.SUPER_NODE_ID,je=ye.SYMLOOP_MAX,Ae=ye.O_READ,xe=ye.O_WRITE,Te=ye.O_CREATE,Se=ye.O_EXCLUSIVE;ye.O_TRUNCATE;var Ne=ye.O_APPEND,De=ye.O_FLAGS,Re=ye.XATTR_CREATE,Le=ye.XATTR_REPLACE,Be=ye.FS_NOMTIME,Me=ye.FS_NOCTIME,Ce=t("../encoding.js"),ke=t("../errors.js"),Fe=t("../directory-entry.js"),Pe=t("../open-file-description.js"),Ue=t("../super-node.js"),Ve=t("../node.js"),Ye=t("../stats.js"),Xe=t("../buffer.js");e.exports={ensureRootDirectory:a,open:B,close:M,mknod:C,mkdir:k,rmdir:F,unlink:Y,stat:P,fstat:U,link:V,read:X,readFile:z,write:W,writeFile:J,appendFile:q,exists:$,getxattr:Q,fgetxattr:H,setxattr:G,fsetxattr:K,removexattr:Z,fremovexattr:te,lseek:ee,readdir:ne,utimes:re,futimes:ie,rename:oe,symlink:ae,readlink:se,lstat:ue,truncate:ce,ftruncate:fe}},{"../../lib/nodash.js":4,"../buffer.js":14,"../constants.js":15,"../directory-entry.js":16,"../encoding.js":17,"../errors.js":18,"../node.js":23,"../open-file-description.js":24,"../path.js":25,"../stats.js":33,"../super-node.js":34}],20:[function(t,e){function n(t){return"function"==typeof t?t:function(t){if(t)throw t}}function r(t,e){function n(){L.forEach(function(t){t.call(this)}.bind(N)),L=null}function r(t){return function(e){function n(e){var r=A();t.getObject(r,function(t,i){return t?(e(t),void 0):(i?n(e):e(null,r),void 0)})}return i(j).contains(d)?(e(null,A()),void 0):(n(e),void 0)}}function s(t){if(t.length){var e=v.getInstance();t.forEach(function(t){e.emit(t.event,t.path)})}}t=t||{},e=e||a;var j=t.flags,A=t.guid?t.guid:b,x=t.provider||new p.Default(t.name||u),T=t.name||x.name,S=i(j).contains(c),N=this;N.readyState=l,N.name=T,N.error=null,N.stdin=E,N.stdout=w,N.stderr=O,this.Shell=g.bind(void 0,this);var D={},R=I;Object.defineProperty(this,"openFiles",{get:function(){return D}}),this.allocDescriptor=function(t){var e=R++;return D[e]=t,e},this.releaseDescriptor=function(t){delete D[t]};var L=[];this.queueOrRun=function(t){var e;return f==N.readyState?t.call(N):h==N.readyState?e=new y.EFILESYSTEMERROR("unknown error"):L.push(t),e},this.watch=function(t,e,n){if(o(t))throw Error("Path must be a string without null bytes.");"function"==typeof e&&(n=e,e={}),e=e||{},n=n||a;var r=new m;return r.start(t,!1,e.recursive),r.on("change",n),r},x.open(function(t){function i(t){function i(t){var e=x[t]();return e.flags=j,e.changes=[],e.guid=r(e),e.close=function(){var t=e.changes;s(t),t.length=0},e}N.provider={openReadWriteContext:function(){return i("getReadWriteContext")},openReadOnlyContext:function(){return i("getReadOnlyContext") +}},N.readyState=t?h:f,n(),e(t,N)}if(t)return i(t);var o=x.getReadWriteContext();o.guid=r(o),S?o.clear(function(t){return t?i(t):(_.ensureRootDirectory(o,i),void 0)}):_.ensureRootDirectory(o,i)})}var i=t("../../lib/nodash.js"),o=t("../path.js").isNull,a=t("../shared.js").nop,s=t("../constants.js"),u=s.FILE_SYSTEM_NAME,c=s.FS_FORMAT,f=s.FS_READY,l=s.FS_PENDING,h=s.FS_ERROR,d=s.FS_NODUPEIDCHECK,p=t("../providers/index.js"),g=t("../shell/shell.js"),v=t("../../lib/intercom.js"),m=t("../fs-watcher.js"),y=t("../errors.js"),b=t("../shared.js").guid,E=s.STDIN,w=s.STDOUT,O=s.STDERR,I=s.FIRST_DESCRIPTOR,_=t("./implementation.js");r.providers=p,["open","close","mknod","mkdir","rmdir","stat","fstat","link","unlink","read","readFile","write","writeFile","appendFile","exists","lseek","readdir","rename","readlink","symlink","lstat","truncate","ftruncate","utimes","futimes","setxattr","getxattr","fsetxattr","fgetxattr","removexattr","fremovexattr"].forEach(function(t){r.prototype[t]=function(){var e=this,r=Array.prototype.slice.call(arguments,0),i=r.length-1,o="function"!=typeof r[i],a=n(r[i]),s=e.queueOrRun(function(){function n(){s.close(),a.apply(e,arguments)}var s=e.provider.openReadWriteContext();if(h===e.readyState){var u=new y.EFILESYSTEMERROR("filesystem unavailable, operation canceled");return a.call(e,u)}o?r.push(n):r[i]=n;var c=[e,s].concat(r);_[t].apply(null,c)});s&&a(s)}}),e.exports=r},{"../../lib/intercom.js":3,"../../lib/nodash.js":4,"../constants.js":15,"../errors.js":18,"../fs-watcher.js":21,"../path.js":25,"../providers/index.js":26,"../shared.js":30,"../shell/shell.js":32,"./implementation.js":19}],21:[function(t,e){function n(){function t(t){(n===t||s&&0===t.indexOf(e))&&a.trigger("change","change",t)}r.call(this);var e,n,a=this,s=!1;a.start=function(r,a,u){if(!n){if(i.isNull(r))throw Error("Path must be a string without null bytes.");n=i.normalize(r),s=u===!0,s&&(e="/"===n?"/":n+"/");var c=o.getInstance();c.on("change",t)}},a.close=function(){var e=o.getInstance();e.off("change",t),a.removeAllListeners("change")}}var r=t("../lib/eventemitter.js"),i=t("./path.js"),o=t("../lib/intercom.js");n.prototype=new r,n.prototype.constructor=n,e.exports=n},{"../lib/eventemitter.js":2,"../lib/intercom.js":3,"./path.js":25}],22:[function(t,e){e.exports={FileSystem:t("./filesystem/interface.js"),Buffer:t("./buffer.js"),Path:t("./path.js"),Errors:t("./errors.js"),Shell:t("./shell/shell.js")}},{"./buffer.js":14,"./errors.js":18,"./filesystem/interface.js":20,"./path.js":25,"./shell/shell.js":32}],23:[function(t,e){function n(t){var e=Date.now();this.id=t.id,this.mode=t.mode||i,this.size=t.size||0,this.atime=t.atime||e,this.ctime=t.ctime||e,this.mtime=t.mtime||e,this.flags=t.flags||[],this.xattrs=t.xattrs||{},this.nlinks=t.nlinks||0,this.version=t.version||0,this.blksize=void 0,this.nblocks=1,this.data=t.data}function r(t,e,n){t[e]?n(null):t.guid(function(r,i){t[e]=i,n(r)})}var i=t("./constants.js").MODE_FILE;n.create=function(t,e){r(t,"id",function(i){return i?(e(i),void 0):(r(t,"data",function(r){return r?(e(r),void 0):(e(null,new n(t)),void 0)}),void 0)})},e.exports=n},{"./constants.js":15}],24:[function(t,e){function n(t,e,n,r){this.path=t,this.id=e,this.flags=n,this.position=r}var r=t("./errors.js");n.prototype.getNode=function(t,e){function n(t,n){return t?e(t):n?(e(null,n),void 0):e(new r.EBADF("file descriptor refers to unknown node",o))}var i=this.id,o=this.path;t.getObject(i,n)},e.exports=n},{"./errors.js":18}],25:[function(t,e,n){function r(t,e){for(var n=0,r=t.length-1;r>=0;r--){var i=t[r];"."===i?t.splice(r,1):".."===i?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}function i(){for(var t="",e=!1,n=arguments.length-1;n>=-1&&!e;n--){var i=n>=0?arguments[n]:"/";"string"==typeof i&&i&&(t=i+"/"+t,e="/"===i.charAt(0))}return t=r(t.split("/").filter(function(t){return!!t}),!e).join("/"),(e?"/":"")+t||"."}function o(t){var e="/"===t.charAt(0);return"/"===t.substr(-1),t=r(t.split("/").filter(function(t){return!!t}),!e).join("/"),t||e||(t="."),(e?"/":"")+t}function a(){var t=Array.prototype.slice.call(arguments,0);return o(t.filter(function(t){return t&&"string"==typeof t}).join("/"))}function s(t,e){function r(t){for(var e=0;t.length>e&&""===t[e];e++);for(var n=t.length-1;n>=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=n.resolve(t).substr(1),e=n.resolve(e).substr(1);for(var i=r(t.split("/")),o=r(e.split("/")),a=Math.min(i.length,o.length),s=a,u=0;a>u;u++)if(i[u]!==o[u]){s=u;break}for(var c=[],u=s;i.length>u;u++)c.push("..");return c=c.concat(o.slice(s)),c.join("/")}function u(t){var e=v(t),n=e[0],r=e[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."}function c(t,e){var n=v(t)[2];return e&&n.substr(-1*e.length)===e&&(n=n.substr(0,n.length-e.length)),""===n?"/":n}function f(t){return v(t)[3]}function l(t){return"/"===t.charAt(0)?!0:!1}function h(t){return-1!==(""+t).indexOf("\0")?!0:!1}function d(t){return t.replace(/\/*$/,"/")}function p(t){return t=t.replace(/\/*$/,""),""===t?"/":t}var g=/^(\/?)([\s\S]+\/(?!$)|\/)?((?:\.{1,2}$|[\s\S]+?)?(\.[^.\/]*)?)$/,v=function(t){var e=g.exec(t);return[e[1]||"",e[2]||"",e[3]||"",e[4]||""]};e.exports={normalize:o,resolve:i,join:a,relative:s,sep:"/",delimiter:":",dirname:u,basename:c,extname:f,isAbsolute:l,isNull:h,addTrailing:d,removeTrailing:p}},{}],26:[function(t,e){var n=t("./indexeddb.js"),r=t("./websql.js"),i=t("./memory.js");e.exports={IndexedDB:n,WebSQL:r,Memory:i,Default:n,Fallback:function(){function t(){throw"[Filer Error] Your browser doesn't support IndexedDB or WebSQL."}return n.isSupported()?n:r.isSupported()?r:(t.isSupported=function(){return!1},t)}()}},{"./indexeddb.js":27,"./memory.js":28,"./websql.js":29}],27:[function(t,e){(function(n,r){function i(t,e){var n=t.transaction(c,e);this.objectStore=n.objectStore(c)}function o(t,e,n){try{var r=t.get(e);r.onsuccess=function(t){var e=t.target.result;n(null,e)},r.onerror=function(t){n(t)}}catch(i){n(i)}}function a(t,e,n,r){try{var i=t.put(n,e);i.onsuccess=function(t){var e=t.target.result;r(null,e)},i.onerror=function(t){r(t)}}catch(o){r(o)}}function s(t){this.name=t||u,this.db=null}var u=t("../constants.js").FILE_SYSTEM_NAME,c=t("../constants.js").FILE_STORE_NAME,f=t("../constants.js").IDB_RW;t("../constants.js").IDB_RO;var l=t("../errors.js"),h=t("../buffer.js"),d=n.indexedDB||n.mozIndexedDB||n.webkitIndexedDB||n.msIndexedDB;i.prototype.clear=function(t){try{var e=this.objectStore.clear();e.onsuccess=function(){t()},e.onerror=function(e){t(e)}}catch(n){t(n)}},i.prototype.getObject=function(t,e){o(this.objectStore,t,e)},i.prototype.getBuffer=function(t,e){o(this.objectStore,t,function(t,n){return t?e(t):(e(null,new h(n)),void 0)})},i.prototype.putObject=function(t,e,n){a(this.objectStore,t,e,n)},i.prototype.putBuffer=function(t,e,n){var i;i=r._useTypedArrays?e.buffer:e.toArrayBuffer(),a(this.objectStore,t,i,n)},i.prototype.delete=function(t,e){try{var n=this.objectStore.delete(t);n.onsuccess=function(t){var n=t.target.result;e(null,n)},n.onerror=function(t){e(t)}}catch(r){e(r)}},s.isSupported=function(){return!!d},s.prototype.open=function(t){var e=this;if(e.db)return t();var n=d.open(e.name);n.onupgradeneeded=function(t){var e=t.target.result;e.objectStoreNames.contains(c)&&e.deleteObjectStore(c),e.createObjectStore(c)},n.onsuccess=function(n){e.db=n.target.result,t()},n.onerror=function(){t(new l.EINVAL("IndexedDB cannot be accessed. If private browsing is enabled, disable it."))}},s.prototype.getReadOnlyContext=function(){return new i(this.db,f)},s.prototype.getReadWriteContext=function(){return new i(this.db,f)},e.exports=s}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"../buffer.js":14,"../constants.js":15,"../errors.js":18,buffer:6}],28:[function(t,e){function n(t,e){this.readOnly=e,this.objectStore=t}function r(t){this.name=t||i}var i=t("../constants.js").FILE_SYSTEM_NAME,o=t("../../lib/async.js").setImmediate,a=function(){var t={};return function(e){return t.hasOwnProperty(e)||(t[e]={}),t[e]}}();n.prototype.clear=function(t){if(this.readOnly)return o(function(){t("[MemoryContext] Error: write operation on read only context")}),void 0;var e=this.objectStore;Object.keys(e).forEach(function(t){delete e[t]}),o(t)},n.prototype.getObject=n.prototype.getBuffer=function(t,e){var n=this;o(function(){e(null,n.objectStore[t])})},n.prototype.putObject=n.prototype.putBuffer=function(t,e,n){return this.readOnly?(o(function(){n("[MemoryContext] Error: write operation on read only context")}),void 0):(this.objectStore[t]=e,o(n),void 0)},n.prototype.delete=function(t,e){return this.readOnly?(o(function(){e("[MemoryContext] Error: write operation on read only context")}),void 0):(delete this.objectStore[t],o(e),void 0)},r.isSupported=function(){return!0},r.prototype.open=function(t){this.db=a(this.name),o(t)},r.prototype.getReadOnlyContext=function(){return new n(this.db,!0)},r.prototype.getReadWriteContext=function(){return new n(this.db,!1)},e.exports=r},{"../../lib/async.js":1,"../constants.js":15}],29:[function(t,e){(function(n){function r(t,e){var n=this;this.getTransaction=function(r){return n.transaction?(r(n.transaction),void 0):(t[e?"readTransaction":"transaction"](function(t){n.transaction=t,r(t)}),void 0)}}function i(t,e,n){function r(t,e){var r=0===e.rows.length?null:e.rows.item(0).data;n(null,r)}function i(t,e){n(e)}t(function(t){t.executeSql("SELECT data FROM "+u+" WHERE id = ? LIMIT 1;",[e],r,i)})}function o(t,e,n,r){function i(){r(null)}function o(t,e){r(e)}t(function(t){t.executeSql("INSERT OR REPLACE INTO "+u+" (id, data) VALUES (?, ?);",[e,n],i,o)})}function a(t){this.name=t||s,this.db=null}var s=t("../constants.js").FILE_SYSTEM_NAME,u=t("../constants.js").FILE_STORE_NAME,c=t("../constants.js").WSQL_VERSION,f=t("../constants.js").WSQL_SIZE,l=t("../constants.js").WSQL_DESC,h=t("../errors.js"),d=t("../buffer.js"),p=t("base64-arraybuffer");r.prototype.clear=function(t){function e(e,n){t(n)}function n(){t(null)}this.getTransaction(function(t){t.executeSql("DELETE FROM "+u+";",[],n,e)})},r.prototype.getObject=function(t,e){i(this.getTransaction,t,function(t,n){if(t)return e(t);try{n&&(n=JSON.parse(n))}catch(r){return e(r)}e(null,n)})},r.prototype.getBuffer=function(t,e){i(this.getTransaction,t,function(t,n){if(t)return e(t);if(n||""===n){var r=p.decode(n);n=new d(r)}e(null,n)})},r.prototype.putObject=function(t,e,n){var r=JSON.stringify(e);o(this.getTransaction,t,r,n)},r.prototype.putBuffer=function(t,e,n){var r=p.encode(e.buffer);o(this.getTransaction,t,r,n)},r.prototype.delete=function(t,e){function n(){e(null)}function r(t,n){e(n)}this.getTransaction(function(e){e.executeSql("DELETE FROM "+u+" WHERE id = ?;",[t],n,r)})},a.isSupported=function(){return!!n.openDatabase},a.prototype.open=function(t){function e(e,n){5===n.code&&t(new h.EINVAL("WebSQL cannot be accessed. If private browsing is enabled, disable it.")),t(n)}function r(){i.db=o,t()}var i=this;if(i.db)return t();var o=n.openDatabase(i.name,c,l,f);return o?(o.transaction(function(t){function n(t){t.executeSql("CREATE INDEX IF NOT EXISTS idx_"+u+"_id"+" on "+u+" (id);",[],r,e)}t.executeSql("CREATE TABLE IF NOT EXISTS "+u+" (id unique, data TEXT);",[],n,e)}),void 0):(t("[WebSQL] Unable to open database."),void 0)},a.prototype.getReadOnlyContext=function(){return new r(this.db,!0)},a.prototype.getReadWriteContext=function(){return new r(this.db,!1)},e.exports=a}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../buffer.js":14,"../constants.js":15,"../errors.js":18,"base64-arraybuffer":5}],30:[function(t,e){function n(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=0|16*Math.random(),n="x"==t?e:8|3&e;return n.toString(16)}).toUpperCase()}function r(){}function i(t){for(var e=[],n=t.length,r=0;n>r;r++)e[r]=t[r];return e}e.exports={guid:n,u8toArray:i,nop:r}},{}],31:[function(t,e){var n=t("../constants.js").ENVIRONMENT;e.exports=function(t){t=t||{},t.TMP=t.TMP||n.TMP,t.PATH=t.PATH||n.PATH,this.get=function(e){return t[e]},this.set=function(e,n){t[e]=n}}},{"../constants.js":15}],32:[function(t,e){function n(t,e){e=e||{};var n=new o(e.env),a="/";Object.defineProperty(this,"fs",{get:function(){return t},enumerable:!0}),Object.defineProperty(this,"env",{get:function(){return n},enumerable:!0}),this.cd=function(e,n){e=r.resolve(a,e),t.stat(e,function(t,r){return t?(n(new i.ENOTDIR(null,e)),void 0):("DIRECTORY"===r.type?(a=e,n()):n(new i.ENOTDIR(null,e)),void 0)})},this.pwd=function(){return a}}var r=t("../path.js"),i=t("../errors.js"),o=t("./environment.js"),a=t("../../lib/async.js");t("../encoding.js");var s=t("minimatch");n.prototype.exec=function(t,e,n){var i=this,o=i.fs;"function"==typeof e&&(n=e,e=[]),e=e||[],n=n||function(){},t=r.resolve(i.pwd(),t),o.readFile(t,"utf8",function(t,r){if(t)return n(t),void 0;try{var i=Function("fs","args","callback",r);i(o,e,n)}catch(a){n(a)}})},n.prototype.touch=function(t,e,n){function i(t){s.writeFile(t,"",n)}function o(t){var r=Date.now(),i=e.date||r,o=e.date||r;s.utimes(t,i,o,n)}var a=this,s=a.fs;"function"==typeof e&&(n=e,e={}),e=e||{},n=n||function(){},t=r.resolve(a.pwd(),t),s.stat(t,function(r){r?e.updateOnly===!0?n():i(t):o(t)})},n.prototype.cat=function(t,e){function n(t,e){var n=r.resolve(o.pwd(),t);s.readFile(n,"utf8",function(t,n){return t?(e(t),void 0):(u+=n+"\n",e(),void 0)})}var o=this,s=o.fs,u="";return e=e||function(){},t?(t="string"==typeof t?[t]:t,a.eachSeries(t,n,function(t){t?e(t):e(null,u.replace(/\n$/,""))}),void 0):(e(new i.EINVAL("Missing files argument")),void 0)},n.prototype.ls=function(t,e,n){function o(t,n){var i=r.resolve(s.pwd(),t),c=[];u.readdir(i,function(t,s){function f(t,n){t=r.join(i,t),u.stat(t,function(a,s){if(a)return n(a),void 0;var u={path:r.basename(t),links:s.nlinks,size:s.size,modified:s.mtime,type:s.type};e.recursive&&"DIRECTORY"===s.type?o(r.join(i,u.path),function(t,e){return t?(n(t),void 0):(u.contents=e,c.push(u),n(),void 0)}):(c.push(u),n())})}return t?(n(t),void 0):(a.eachSeries(s,f,function(t){n(t,c)}),void 0)})}var s=this,u=s.fs;return"function"==typeof e&&(n=e,e={}),e=e||{},n=n||function(){},t?(o(t,n),void 0):(n(new i.EINVAL("Missing dir argument")),void 0)},n.prototype.rm=function(t,e,n){function o(t,n){t=r.resolve(s.pwd(),t),u.stat(t,function(s,c){return s?(n(s),void 0):"FILE"===c.type?(u.unlink(t,n),void 0):(u.readdir(t,function(s,c){return s?(n(s),void 0):0===c.length?(u.rmdir(t,n),void 0):e.recursive?(c=c.map(function(e){return r.join(t,e)}),a.eachSeries(c,o,function(e){return e?(n(e),void 0):(u.rmdir(t,n),void 0)}),void 0):(n(new i.ENOTEMPTY(null,t)),void 0)}),void 0)})}var s=this,u=s.fs;return"function"==typeof e&&(n=e,e={}),e=e||{},n=n||function(){},t?(o(t,n),void 0):(n(new i.EINVAL("Missing path argument")),void 0)},n.prototype.tempDir=function(t){var e=this,n=e.fs,r=e.env.get("TMP");t=t||function(){},n.mkdir(r,function(){t(null,r)})},n.prototype.mkdirp=function(t,e){function n(t,e){a.stat(t,function(o,s){if(s){if(s.isDirectory())return e(),void 0;if(s.isFile())return e(new i.ENOTDIR(null,t)),void 0}else{if(o&&"ENOENT"!==o.code)return e(o),void 0;var u=r.dirname(t);"/"===u?a.mkdir(t,function(t){return t&&"EEXIST"!=t.code?(e(t),void 0):(e(),void 0)}):n(u,function(n){return n?e(n):(a.mkdir(t,function(t){return t&&"EEXIST"!=t.code?(e(t),void 0):(e(),void 0)}),void 0)})}})}var o=this,a=o.fs;return e=e||function(){},t?"/"===t?(e(),void 0):(n(t,e),void 0):(e(new i.EINVAL("Missing path argument")),void 0)},n.prototype.find=function(t,e,n){function o(t,e){h(t,function(n){return n?(e(n),void 0):(d.push(t),e(),void 0)})}function u(t,n){var i=r.removeTrailing(t);return e.regex&&!e.regex.test(i)?(n(),void 0):e.name&&!s(r.basename(i),e.name)?(n(),void 0):e.path&&!s(r.dirname(i),e.path)?(n(),void 0):(o(t,n),void 0)}function c(t,e){t=r.resolve(f.pwd(),t),l.readdir(t,function(n,i){return n?("ENOTDIR"===n.code?u(t,e):e(n),void 0):(u(r.addTrailing(t),function(n){return n?(e(n),void 0):(i=i.map(function(e){return r.join(t,e)}),a.eachSeries(i,c,function(t){e(t,d)}),void 0)}),void 0)})}var f=this,l=f.fs;"function"==typeof e&&(n=e,e={}),e=e||{},n=n||function(){};var h=e.exec||function(t,e){e()},d=[];return t?(l.stat(t,function(e,r){return e?(n(e),void 0):r.isDirectory()?(c(t,n),void 0):(n(new i.ENOTDIR(null,t)),void 0)}),void 0):(n(new i.EINVAL("Missing path argument")),void 0)},e.exports=n},{"../../lib/async.js":1,"../encoding.js":17,"../errors.js":18,"../path.js":25,"./environment.js":31,minimatch:11}],33:[function(t,e){function n(t,e){this.node=t.id,this.dev=e,this.size=t.size,this.nlinks=t.nlinks,this.atime=t.atime,this.mtime=t.mtime,this.ctime=t.ctime,this.type=t.mode}var r=t("./constants.js");n.prototype.isFile=function(){return this.type===r.MODE_FILE},n.prototype.isDirectory=function(){return this.type===r.MODE_DIRECTORY},n.prototype.isSymbolicLink=function(){return this.type===r.MODE_SYMBOLIC_LINK},n.prototype.isSocket=n.prototype.isFIFO=n.prototype.isCharacterDevice=n.prototype.isBlockDevice=function(){return!1},e.exports=n},{"./constants.js":15}],34:[function(t,e){function n(t){var e=Date.now();this.id=r.SUPER_NODE_ID,this.mode=r.MODE_META,this.atime=t.atime||e,this.ctime=t.ctime||e,this.mtime=t.mtime||e,this.rnode=t.rnode}var r=t("./constants.js");n.create=function(t,e){t.guid(function(r,i){return r?(e(r),void 0):(t.rnode=t.rnode||i,e(null,new n(t)),void 0)})},e.exports=n},{"./constants.js":15}]},{},[22])(22)}); \ No newline at end of file diff --git a/package.json b/package.json index e84534f..1bae81c 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "idb", "websql" ], - "version": "0.0.35", + "version": "0.0.36", "author": "Alan K (http://blog.modeswitch.org)", "homepage": "http://filerjs.github.io/filer", "bugs": "https://github.com/filerjs/filer/issues",