Update dist/ built versions of Filer

This commit is contained in:
David Humphrey 2018-10-30 14:35:33 -04:00
parent a5fc0e699a
commit ea95badc5b
4 changed files with 375 additions and 246 deletions

575
dist/filer.js vendored
View File

@ -202,6 +202,91 @@ function nodash(value) {
}
module.exports = nodash;
},{}],"0c0E":[function(require,module,exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
// Symbols is a better way to do this, but if we don't have support we'll just
// have to make do with an unlikely token
var customArgumentsToken = Symbol ? Symbol("__ES6-PROMISIFY--CUSTOM-ARGUMENTS__") : "__ES6-PROMISIFY--CUSTOM-ARGUMENTS__";
/**
* promisify()
* Transforms callback-based function -- func(arg1, arg2 .. argN, callback) -- into
* an ES6-compatible Promise. Promisify provides a default callback of the form (error, result)
* and rejects when `error` is truthy.
*
* @param {function} original - The function to promisify
* @return {function} A promisified version of `original`
*/
function promisify(original) {
// Ensure the argument is a function
if (typeof original !== "function") {
throw new TypeError("Argument to promisify must be a function");
}
// If the user has asked us to decode argument names for them, honour that
var argumentNames = original[customArgumentsToken];
// If the user has supplied a custom Promise implementation, use it. Otherwise
// fall back to whatever we can find on the global object.
var ES6Promise = promisify.Promise || Promise;
// If we can find no Promise implemention, then fail now.
if (typeof ES6Promise !== "function") {
throw new Error("No Promise implementation found; do you need a polyfill?");
}
return function () {
var _this = this;
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return new ES6Promise(function (resolve, reject) {
// Append the callback bound to the context
args.push(function callback(err) {
if (err) {
return reject(err);
}
for (var _len2 = arguments.length, values = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
values[_key2 - 1] = arguments[_key2];
}
if (values.length === 1 || !argumentNames) {
return resolve(values[0]);
}
var o = {};
values.forEach(function (value, index) {
var name = argumentNames[index];
if (name) {
o[name] = value;
}
});
resolve(o);
});
// Call the function.
original.call.apply(original, [_this].concat(args));
});
};
}
// Attach this symbol to the exported function, so users can use it
promisify.argumentNames = customArgumentsToken;
promisify.Promise = undefined;
// Export the public API
exports.promisify = promisify;
},{}],"UzoP":[function(require,module,exports) {
// Copyright Joyent, Inc. and other Node contributors.
//
@ -258,7 +343,7 @@ function normalizeArray(parts, allowAboveRoot) {
// Split a filename into [root, dir, basename, ext], unix version
// 'root' is just a slash, or nothing.
var splitPathRe = /^(\/?)([\s\S]+\/(?!$)|\/)?((?:\.{1,2}$|[\s\S]+?)?(\.[^.\/]*)?)$/;
var splitPathRe = /^(\/?)([\s\S]+\/(?!$)|\/)?((?:\.{1,2}$|[\s\S]+?)?(\.[^./]*)?)$/;
var splitPath = function splitPath(filename) {
var result = splitPathRe.exec(filename);
return [result[1] || '', result[2] || '', result[3] || '', result[4] || ''];
@ -295,8 +380,7 @@ function resolve() {
// path.normalize(path)
function normalize(path) {
var isAbsolute = path.charAt(0) === '/',
trailingSlash = path.substr(-1) === '/';
var isAbsolute = path.charAt(0) === '/';
// Normalize the path
path = normalizeArray(path.split('/').filter(function (p) {
@ -317,7 +401,7 @@ function normalize(path) {
function join() {
var paths = Array.prototype.slice.call(arguments, 0);
return normalize(paths.filter(function (p, index) {
return normalize(paths.filter(function (p) {
return p && typeof p === 'string';
}).join('/'));
}
@ -355,7 +439,7 @@ function relative(from, to) {
}
var outputParts = [];
for (var i = samePartsLength; i < fromParts.length; i++) {
for (i = samePartsLength; i < fromParts.length; i++) {
outputParts.push('..');
}
@ -389,7 +473,7 @@ function basename(path, ext) {
f = f.substr(0, f.length - ext.length);
}
// XXXfiler: node.js just does `return f`
return f === "" ? "/" : f;
return f === '' ? '/' : f;
}
function extname(path) {
@ -441,7 +525,107 @@ module.exports = {
addTrailing: addTrailing,
removeTrailing: removeTrailing
};
},{}],"p8GN":[function(require,module,exports) {
var errors = {};
[
/**
* node.js errors - we only use some of these, add as needed.
*/
//'-1:UNKNOWN:unknown error',
//'0:OK:success',
//'1:EOF:end of file',
//'2:EADDRINFO:getaddrinfo error',
//'3:EACCES:permission denied',
//'4:EAGAIN:resource temporarily unavailable',
//'5:EADDRINUSE:address already in use',
//'6:EADDRNOTAVAIL:address not available',
//'7:EAFNOSUPPORT:address family not supported',
//'8:EALREADY:connection already in progress',
'9:EBADF:bad file descriptor', '10:EBUSY:resource busy or locked',
//'11:ECONNABORTED:software caused connection abort',
//'12:ECONNREFUSED:connection refused',
//'13:ECONNRESET:connection reset by peer',
//'14:EDESTADDRREQ:destination address required',
//'15:EFAULT:bad address in system call argument',
//'16:EHOSTUNREACH:host is unreachable',
//'17:EINTR:interrupted system call',
'18:EINVAL:invalid argument',
//'19:EISCONN:socket is already connected',
//'20:EMFILE:too many open files',
//'21:EMSGSIZE:message too long',
//'22:ENETDOWN:network is down',
//'23:ENETUNREACH:network is unreachable',
//'24:ENFILE:file table overflow',
//'25:ENOBUFS:no buffer space available',
//'26:ENOMEM:not enough memory',
'27:ENOTDIR:not a directory', '28:EISDIR:illegal operation on a directory',
//'29:ENONET:machine is not on the network',
// errno 30 skipped, as per https://github.com/rvagg/node-errno/blob/master/errno.js
//'31:ENOTCONN:socket is not connected',
//'32:ENOTSOCK:socket operation on non-socket',
//'33:ENOTSUP:operation not supported on socket',
'34:ENOENT:no such file or directory',
//'35:ENOSYS:function not implemented',
//'36:EPIPE:broken pipe',
//'37:EPROTO:protocol error',
//'38:EPROTONOSUPPORT:protocol not supported',
//'39:EPROTOTYPE:protocol wrong type for socket',
//'40:ETIMEDOUT:connection timed out',
//'41:ECHARSET:invalid Unicode character',
//'42:EAIFAMNOSUPPORT:address family for hostname not supported',
// errno 43 skipped, as per https://github.com/rvagg/node-errno/blob/master/errno.js
//'44:EAISERVICE:servname not supported for ai_socktype',
//'45:EAISOCKTYPE:ai_socktype not supported',
//'46:ESHUTDOWN:cannot send after transport endpoint shutdown',
'47:EEXIST:file already exists',
//'48:ESRCH:no such process',
//'49:ENAMETOOLONG:name too long',
'50:EPERM:operation not permitted', '51:ELOOP:too many symbolic links encountered',
//'52:EXDEV:cross-device link not permitted',
'53:ENOTEMPTY:directory not empty',
//'54:ENOSPC:no space left on device',
'55:EIO:i/o error',
//'56:EROFS:read-only file system',
//'57:ENODEV:no such device',
//'58:ESPIPE:invalid seek',
//'59:ECANCELED:operation canceled',
/**
* Filer specific errors
*/
'1000:ENOTMOUNTED:not mounted', '1001:EFILESYSTEMERROR:missing super node, use \'FORMAT\' flag to format filesystem.', '1002:ENOATTR:attribute does not exist'].forEach(function (e) {
e = e.split(':');
var errno = +e[0];
var errName = e[1];
var defaultMessage = e[2];
function FilerError(msg, path) {
Error.call(this);
this.name = errName;
this.code = errName;
this.errno = errno;
this.message = msg || defaultMessage;
if (path) {
this.path = path;
}
this.stack = new Error(this.message).stack;
}
FilerError.prototype = Object.create(Error.prototype);
FilerError.prototype.constructor = FilerError;
FilerError.prototype.toString = function () {
var pathInfo = this.path ? ', \'' + this.path + '\'' : '';
return this.name + ': ' + this.message + pathInfo;
};
// We expose the error as both Errors.EINVAL and Errors[18]
errors[errName] = errors[errno] = FilerError;
});
module.exports = errors;
},{}],"3zBM":[function(require,module,exports) {
var Errors = require('./errors.js');
function guid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0,
@ -464,12 +648,26 @@ function u8toArray(u8) {
return array;
}
function validateInteger(value, name) {
var err = void 0;
if (typeof value !== 'number') err = new Errors.EINVAL(name, 'number', value);
if (err) {
Error.captureStackTrace(err, validateInteger);
throw err;
}
return value;
}
module.exports = {
guid: guid,
u8toArray: u8toArray,
nop: nop
nop: nop,
validateInteger: validateInteger
};
},{}],"iJA9":[function(require,module,exports) {
},{"./errors.js":"p8GN"}],"iJA9":[function(require,module,exports) {
var O_READ = 'READ';
var O_WRITE = 'WRITE';
var O_CREATE = 'CREATE';
@ -487,9 +685,9 @@ module.exports = {
IDB_RO: 'readonly',
IDB_RW: 'readwrite',
WSQL_VERSION: "1",
WSQL_VERSION: '1',
WSQL_SIZE: 5 * 1024 * 1024,
WSQL_DESC: "FileSystem Storage",
WSQL_DESC: 'FileSystem Storage',
NODE_TYPE_FILE: 'FILE',
NODE_TYPE_DIRECTORY: 'DIRECTORY',
@ -603,104 +801,6 @@ module.exports = {
COPYFILE_EXCL: 1
}
};
},{}],"p8GN":[function(require,module,exports) {
var errors = {};
[
/**
* node.js errors - we only use some of these, add as needed.
*/
//'-1:UNKNOWN:unknown error',
//'0:OK:success',
//'1:EOF:end of file',
//'2:EADDRINFO:getaddrinfo error',
//'3:EACCES:permission denied',
//'4:EAGAIN:resource temporarily unavailable',
//'5:EADDRINUSE:address already in use',
//'6:EADDRNOTAVAIL:address not available',
//'7:EAFNOSUPPORT:address family not supported',
//'8:EALREADY:connection already in progress',
'9:EBADF:bad file descriptor', '10:EBUSY:resource busy or locked',
//'11:ECONNABORTED:software caused connection abort',
//'12:ECONNREFUSED:connection refused',
//'13:ECONNRESET:connection reset by peer',
//'14:EDESTADDRREQ:destination address required',
//'15:EFAULT:bad address in system call argument',
//'16:EHOSTUNREACH:host is unreachable',
//'17:EINTR:interrupted system call',
'18:EINVAL:invalid argument',
//'19:EISCONN:socket is already connected',
//'20:EMFILE:too many open files',
//'21:EMSGSIZE:message too long',
//'22:ENETDOWN:network is down',
//'23:ENETUNREACH:network is unreachable',
//'24:ENFILE:file table overflow',
//'25:ENOBUFS:no buffer space available',
//'26:ENOMEM:not enough memory',
'27:ENOTDIR:not a directory', '28:EISDIR:illegal operation on a directory',
//'29:ENONET:machine is not on the network',
// errno 30 skipped, as per https://github.com/rvagg/node-errno/blob/master/errno.js
//'31:ENOTCONN:socket is not connected',
//'32:ENOTSOCK:socket operation on non-socket',
//'33:ENOTSUP:operation not supported on socket',
'34:ENOENT:no such file or directory',
//'35:ENOSYS:function not implemented',
//'36:EPIPE:broken pipe',
//'37:EPROTO:protocol error',
//'38:EPROTONOSUPPORT:protocol not supported',
//'39:EPROTOTYPE:protocol wrong type for socket',
//'40:ETIMEDOUT:connection timed out',
//'41:ECHARSET:invalid Unicode character',
//'42:EAIFAMNOSUPPORT:address family for hostname not supported',
// errno 43 skipped, as per https://github.com/rvagg/node-errno/blob/master/errno.js
//'44:EAISERVICE:servname not supported for ai_socktype',
//'45:EAISOCKTYPE:ai_socktype not supported',
//'46:ESHUTDOWN:cannot send after transport endpoint shutdown',
'47:EEXIST:file already exists',
//'48:ESRCH:no such process',
//'49:ENAMETOOLONG:name too long',
'50:EPERM:operation not permitted', '51:ELOOP:too many symbolic links encountered',
//'52:EXDEV:cross-device link not permitted',
'53:ENOTEMPTY:directory not empty',
//'54:ENOSPC:no space left on device',
'55:EIO:i/o error',
//'56:EROFS:read-only file system',
//'57:ENODEV:no such device',
//'58:ESPIPE:invalid seek',
//'59:ECANCELED:operation canceled',
/**
* Filer specific errors
*/
'1000:ENOTMOUNTED:not mounted', '1001:EFILESYSTEMERROR:missing super node, use \'FORMAT\' flag to format filesystem.', '1002:ENOATTR:attribute does not exist'].forEach(function (e) {
e = e.split(':');
var errno = +e[0];
var errName = e[1];
var defaultMessage = e[2];
function FilerError(msg, path) {
Error.call(this);
this.name = errName;
this.code = errName;
this.errno = errno;
this.message = msg || defaultMessage;
if (path) {
this.path = path;
}
this.stack = new Error(this.message).stack;
}
FilerError.prototype = Object.create(Error.prototype);
FilerError.prototype.constructor = FilerError;
FilerError.prototype.toString = function () {
var pathInfo = this.path ? ', \'' + this.path + '\'' : '';
return this.name + ': ' + this.message + pathInfo;
};
// We expose the error as both Errors.EINVAL and Errors[18]
errors[errName] = errors[errno] = FilerError;
});
module.exports = errors;
},{}],"yh9p":[function(require,module,exports) {
'use strict'
@ -2751,7 +2851,7 @@ function FilerBuffer(subject, encoding, nonZero) {
}
return new Buffer(subject, encoding, nonZero);
};
}
// Inherit prototype from Buffer
FilerBuffer.prototype = Object.create(Buffer.prototype);
@ -2771,7 +2871,6 @@ var FILE_SYSTEM_NAME = require('../constants.js').FILE_SYSTEM_NAME;
var FILE_STORE_NAME = require('../constants.js').FILE_STORE_NAME;
var IDB_RW = require('../constants.js').IDB_RW;
var IDB_RO = require('../constants.js').IDB_RO;
var Errors = require('../errors.js');
var FilerBuffer = require('../buffer.js');
var indexedDB = global.indexedDB || global.mozIndexedDB || global.webkitIndexedDB || global.msIndexedDB;
@ -2927,7 +3026,7 @@ IndexedDB.prototype.getReadWriteContext = function () {
};
module.exports = IndexedDB;
},{"../constants.js":"iJA9","../errors.js":"p8GN","../buffer.js":"xfwq"}],"vLJO":[function(require,module,exports) {
},{"../constants.js":"iJA9","../buffer.js":"xfwq"}],"vLJO":[function(require,module,exports) {
/*
* base64-arraybuffer
* https://github.com/niklasvh/base64-arraybuffer
@ -3032,11 +3131,11 @@ WebSQLContext.prototype.clear = function (callback) {
function onError(transaction, error) {
callback(error);
}
function onSuccess(transaction, result) {
function onSuccess() {
callback(null);
}
this.getTransaction(function (transaction) {
transaction.executeSql("DELETE FROM " + FILE_STORE_NAME + ";", [], onSuccess, onError);
transaction.executeSql('DELETE FROM ' + FILE_STORE_NAME + ';', [], onSuccess, onError);
});
};
@ -3050,7 +3149,7 @@ function _get(getTransaction, key, callback) {
callback(error);
}
getTransaction(function (transaction) {
transaction.executeSql("SELECT data FROM " + FILE_STORE_NAME + " WHERE id = ? LIMIT 1;", [key], onSuccess, onError);
transaction.executeSql('SELECT data FROM ' + FILE_STORE_NAME + ' WHERE id = ? LIMIT 1;', [key], onSuccess, onError);
});
}
WebSQLContext.prototype.getObject = function (key, callback) {
@ -3087,14 +3186,14 @@ WebSQLContext.prototype.getBuffer = function (key, callback) {
};
function _put(getTransaction, key, value, callback) {
function onSuccess(transaction, result) {
function onSuccess() {
callback(null);
}
function onError(transaction, error) {
callback(error);
}
getTransaction(function (transaction) {
transaction.executeSql("INSERT OR REPLACE INTO " + FILE_STORE_NAME + " (id, data) VALUES (?, ?);", [key, value], onSuccess, onError);
transaction.executeSql('INSERT OR REPLACE INTO ' + FILE_STORE_NAME + ' (id, data) VALUES (?, ?);', [key, value], onSuccess, onError);
});
}
WebSQLContext.prototype.putObject = function (key, value, callback) {
@ -3107,14 +3206,14 @@ WebSQLContext.prototype.putBuffer = function (key, uint8BackedBuffer, callback)
};
WebSQLContext.prototype.delete = function (key, callback) {
function onSuccess(transaction, result) {
function onSuccess() {
callback(null);
}
function onError(transaction, error) {
callback(error);
}
this.getTransaction(function (transaction) {
transaction.executeSql("DELETE FROM " + FILE_STORE_NAME + " WHERE id = ?;", [key], onSuccess, onError);
transaction.executeSql('DELETE FROM ' + FILE_STORE_NAME + ' WHERE id = ?;', [key], onSuccess, onError);
});
};
@ -3136,7 +3235,7 @@ WebSQL.prototype.open = function (callback) {
var db = global.openDatabase(that.name, WSQL_VERSION, WSQL_DESC, WSQL_SIZE);
if (!db) {
callback("[WebSQL] Unable to open database.");
callback('[WebSQL] Unable to open database.');
return;
}
@ -3146,7 +3245,7 @@ WebSQL.prototype.open = function (callback) {
}
callback(error);
}
function onSuccess(transaction, result) {
function onSuccess() {
that.db = db;
callback();
}
@ -3154,9 +3253,9 @@ WebSQL.prototype.open = function (callback) {
// Create the table and index we'll need to store the fs data.
db.transaction(function (transaction) {
function createIndex(transaction) {
transaction.executeSql("CREATE INDEX IF NOT EXISTS idx_" + FILE_STORE_NAME + "_id" + " on " + FILE_STORE_NAME + " (id);", [], onSuccess, onError);
transaction.executeSql('CREATE INDEX IF NOT EXISTS idx_' + FILE_STORE_NAME + '_id' + ' on ' + FILE_STORE_NAME + ' (id);', [], onSuccess, onError);
}
transaction.executeSql("CREATE TABLE IF NOT EXISTS " + FILE_STORE_NAME + " (id unique, data TEXT);", [], createIndex, onError);
transaction.executeSql('CREATE TABLE IF NOT EXISTS ' + FILE_STORE_NAME + ' (id unique, data TEXT);', [], createIndex, onError);
});
};
WebSQL.prototype.getReadOnlyContext = function () {
@ -3463,7 +3562,7 @@ function MemoryContext(db, readOnly) {
MemoryContext.prototype.clear = function (callback) {
if (this.readOnly) {
asyncCallback(function () {
callback("[MemoryContext] Error: write operation on read only context");
callback('[MemoryContext] Error: write operation on read only context');
});
return;
}
@ -3484,7 +3583,7 @@ MemoryContext.prototype.getObject = MemoryContext.prototype.getBuffer = function
MemoryContext.prototype.putObject = MemoryContext.prototype.putBuffer = function (key, value, callback) {
if (this.readOnly) {
asyncCallback(function () {
callback("[MemoryContext] Error: write operation on read only context");
callback('[MemoryContext] Error: write operation on read only context');
});
return;
}
@ -3495,7 +3594,7 @@ MemoryContext.prototype.putObject = MemoryContext.prototype.putBuffer = function
MemoryContext.prototype.delete = function (key, callback) {
if (this.readOnly) {
asyncCallback(function () {
callback("[MemoryContext] Error: write operation on read only context");
callback('[MemoryContext] Error: write operation on read only context');
});
return;
}
@ -3550,7 +3649,7 @@ module.exports = {
}
function NotSupported() {
throw "[Filer Error] Your browser doesn't support IndexedDB or WebSQL.";
throw '[Filer Error] Your browser doesn\'t support IndexedDB or WebSQL.';
}
NotSupported.isSupported = function () {
return false;
@ -3574,22 +3673,7 @@ module.exports = function Environment(env) {
env[name] = value;
};
};
},{"../constants.js":"iJA9"}],"03yF":[function(require,module,exports) {
var Buffer = require("buffer").Buffer;
// Adapt encodings to work with Buffer or Uint8Array, they expect the latter
function decode(buf) {
return buf.toString('utf8');
}
function encode(string) {
return new Buffer(string, 'utf8');
}
module.exports = {
encode: encode,
decode: decode
};
},{"buffer":"dskh"}],"UUq2":[function(require,module,exports) {
},{"../constants.js":"iJA9"}],"UUq2":[function(require,module,exports) {
var process = require("process");
// Copyright Joyent, Inc. and other Node contributors.
//
@ -5021,14 +5105,18 @@ function regExpEscape (s) {
}
},{"path":"UUq2","brace-expansion":"dwX/"}],"D1Ra":[function(require,module,exports) {
var _require = require('es6-promisify'),
promisify = _require.promisify;
var Path = require('../path.js');
var Errors = require('../errors.js');
var Environment = require('./environment.js');
var async = require('../../lib/async.js');
var Encoding = require('../encoding.js');
var minimatch = require('minimatch');
function Shell(fs, options) {
var _this = this;
options = options || {};
var env = new Environment(options.env);
@ -5084,6 +5172,14 @@ function Shell(fs, options) {
this.pwd = function () {
return cwd;
};
this.promises = {};
/**
* Public API for Shell converted to Promise based
*/
['cd', 'exec', 'touch', 'cat', 'ls', 'rm', 'tempDir', 'mkdirp', 'find'].forEach(function (methodName) {
_this.promises[methodName] = promisify(_this[methodName].bind(_this));
});
}
/**
@ -5114,7 +5210,7 @@ Shell.prototype.exec = function (path, args, callback) {
callback = callback || function () {};
path = Path.resolve(sh.pwd(), path);
fs.readFile(path, "utf8", function (error, data) {
fs.readFile(path, 'utf8', function (error, data) {
if (error) {
callback(error);
return;
@ -5158,7 +5254,7 @@ Shell.prototype.touch = function (path, options, callback) {
fs.utimes(path, atime, mtime, callback);
}
fs.stat(path, function (error, stats) {
fs.stat(path, function (error) {
if (error) {
if (options.updateOnly === true) {
callback();
@ -5375,7 +5471,7 @@ Shell.prototype.tempDir = function (callback) {
// Try and create it, and it will either work or fail
// but either way it's now there.
fs.mkdir(tmp, function (err) {
fs.mkdir(tmp, function () {
callback(null, tmp);
});
};
@ -5562,7 +5658,7 @@ Shell.prototype.find = function (path, options, callback) {
};
module.exports = Shell;
},{"../path.js":"UzoP","../errors.js":"p8GN","./environment.js":"QMiB","../../lib/async.js":"u4Zs","../encoding.js":"03yF","minimatch":"Nt/K"}],"J4Qg":[function(require,module,exports) {
},{"es6-promisify":"0c0E","../path.js":"UzoP","../errors.js":"p8GN","./environment.js":"QMiB","../../lib/async.js":"u4Zs","minimatch":"Nt/K"}],"J4Qg":[function(require,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
@ -6020,7 +6116,22 @@ FSWatcher.prototype = new EventEmitter();
FSWatcher.prototype.constructor = FSWatcher;
module.exports = FSWatcher;
},{"../lib/eventemitter.js":"J4Qg","./path.js":"UzoP","../lib/intercom.js":"u7Jv"}],"ZECt":[function(require,module,exports) {
},{"../lib/eventemitter.js":"J4Qg","./path.js":"UzoP","../lib/intercom.js":"u7Jv"}],"03yF":[function(require,module,exports) {
var Buffer = require("buffer").Buffer;
// Adapt encodings to work with Buffer or Uint8Array, they expect the latter
function decode(buf) {
return buf.toString('utf8');
}
function encode(string) {
return new Buffer(string, 'utf8');
}
module.exports = {
encode: encode,
decode: decode
};
},{"buffer":"dskh"}],"ZECt":[function(require,module,exports) {
var NODE_TYPE_FILE = require('./constants.js').NODE_TYPE_FILE;
module.exports = function DirectoryEntry(id, type) {
@ -6090,9 +6201,6 @@ module.exports = SuperNode;
var NODE_TYPE_FILE = require('./constants.js').NODE_TYPE_FILE;
var NODE_TYPE_DIRECTORY = require('./constants.js').NODE_TYPE_DIRECTORY;
var NODE_TYPE_SYMBOLIC_LINK = require('./constants.js').NODE_TYPE_SYMBOLIC_LINK;
var NODE_TYPE_META = require('./constants.js').NODE_TYPE_META;
var ROOT_DIRECTORY_NAME = require('./constants.js').ROOT_DIRECTORY_NAME;
var S_IFREG = require('./constants.js').S_IFREG;
var S_IFDIR = require('./constants.js').S_IFDIR;
@ -6229,8 +6337,6 @@ var NODE_TYPE_DIRECTORY = Constants.NODE_TYPE_DIRECTORY;
var NODE_TYPE_SYMBOLIC_LINK = Constants.NODE_TYPE_SYMBOLIC_LINK;
var NODE_TYPE_META = Constants.NODE_TYPE_META;
var DEFAULT_FILE_PERMISSIONS = Constants.DEFAULT_FILE_PERMISSIONS;
var DEFAULT_DIR_PERMISSIONS = Constants.DEFAULT_DIR_PERMISSIONS;
var FULL_READ_WRITE_EXEC_PERMISSIONS = Constants.FULL_READ_WRITE_EXEC_PERMISSIONS;
var ROOT_DIRECTORY_NAME = Constants.ROOT_DIRECTORY_NAME;
@ -6241,7 +6347,6 @@ var O_READ = Constants.O_READ;
var O_WRITE = Constants.O_WRITE;
var O_CREATE = Constants.O_CREATE;
var O_EXCLUSIVE = Constants.O_EXCLUSIVE;
var O_TRUNCATE = Constants.O_TRUNCATE;
var O_APPEND = Constants.O_APPEND;
var O_FLAGS = Constants.O_FLAGS;
@ -6259,10 +6364,15 @@ var Node = require('../node.js');
var Stats = require('../stats.js');
var Buffer = require('../buffer.js');
var _require = require('../shared.js'),
validateInteger = _require.validateInteger;
/**
* Update node times. Only passed times are modified (undefined times are ignored)
* and filesystem flags are examined in order to override update logic.
*/
function update_node_times(context, path, node, times, callback) {
// Honour mount flags for how we update times
var flags = context.flags;
@ -7056,7 +7166,6 @@ function read_data(context, ofd, buffer, offset, length, position, callback) {
function stat_file(context, path, callback) {
path = normalize(path);
var name = basename(path);
find_node(context, path, callback);
}
@ -7136,7 +7245,7 @@ function link_node(context, oldpath, newpath, callback) {
}
}
function read_file_node(error, result) {
function read_file_node(error) {
if (error) {
callback(error);
} else {
@ -7210,8 +7319,12 @@ function unlink_node(context, path, callback) {
} else {
delete directoryData[name];
context.putObject(directoryNode.data, directoryData, function (error) {
var now = Date.now();
update_node_times(context, parentPath, directoryNode, { mtime: now, ctime: now }, callback);
if (error) {
callback(error);
} else {
var now = Date.now();
update_node_times(context, parentPath, directoryNode, { mtime: now, ctime: now }, callback);
}
});
}
}
@ -7234,7 +7347,11 @@ function unlink_node(context, path, callback) {
context.delete(fileNode.id, delete_file_data);
} else {
context.putObject(fileNode.id, fileNode, function (error) {
update_node_times(context, path, fileNode, { ctime: Date.now() }, update_directory_data);
if (error) {
callback(error);
} else {
update_node_times(context, path, fileNode, { ctime: Date.now() }, update_directory_data);
}
});
}
}
@ -7277,7 +7394,6 @@ function unlink_node(context, path, callback) {
function read_directory(context, path, callback) {
path = normalize(path);
var name = basename(path);
var directoryNode;
var directoryData;
@ -7459,6 +7575,11 @@ function truncate_file(context, path, length, callback) {
if (!fileData) {
return callback(new Errors.EIO('Expected Buffer'));
}
try {
validateInteger(length, 'len');
} catch (error) {
return callback(error);
}
var data = new Buffer(length);
data.fill(0);
if (fileData) {
@ -7761,9 +7882,9 @@ function validate_flags(flags) {
function validate_file_options(options, enc, fileMode) {
if (!options) {
options = { encoding: enc, flag: fileMode };
} else if (typeof options === "function") {
} else if (typeof options === 'function') {
options = { encoding: enc, flag: fileMode };
} else if (typeof options === "string") {
} else if (typeof options === 'string') {
options = { encoding: options, flag: fileMode };
}
return options;
@ -7972,7 +8093,7 @@ function readFile(fs, context, path, options, callback) {
var buffer = new Buffer(size);
buffer.fill(0);
read_data(context, ofd, buffer, 0, size, 0, function (err, nbytes) {
read_data(context, ofd, buffer, 0, size, 0, function (err) {
cleanup();
if (err) {
@ -8020,10 +8141,10 @@ function writeFile(fs, context, path, data, options, callback) {
}
data = data || '';
if (typeof data === "number") {
if (typeof data === 'number') {
data = '' + data;
}
if (typeof data === "string" && options.encoding === 'utf8') {
if (typeof data === 'string' && options.encoding === 'utf8') {
data = Encoding.encode(data);
}
@ -8034,7 +8155,7 @@ function writeFile(fs, context, path, data, options, callback) {
var ofd = new OpenFileDescription(path, fileNode.id, flags, 0);
var fd = fs.allocDescriptor(ofd);
replace_data(context, ofd, data, 0, data.length, function (err, nbytes) {
replace_data(context, ofd, data, 0, data.length, function (err) {
fs.releaseDescriptor(fd);
if (err) {
@ -8057,10 +8178,10 @@ function appendFile(fs, context, path, data, options, callback) {
}
data = data || '';
if (typeof data === "number") {
if (typeof data === 'number') {
data = '' + data;
}
if (typeof data === "string" && options.encoding === 'utf8') {
if (typeof data === 'string' && options.encoding === 'utf8') {
data = Encoding.encode(data);
}
@ -8071,7 +8192,7 @@ function appendFile(fs, context, path, data, options, callback) {
var ofd = new OpenFileDescription(path, fileNode.id, flags, fileNode.size);
var fd = fs.allocDescriptor(ofd);
write_data(context, ofd, data, 0, data.length, ofd.position, function (err, nbytes) {
write_data(context, ofd, data, 0, data.length, ofd.position, function (err) {
fs.releaseDescriptor(fd);
if (err) {
@ -8083,15 +8204,15 @@ function appendFile(fs, context, path, data, options, callback) {
}
function exists(fs, context, path, callback) {
function cb(err, stats) {
function cb(err) {
callback(err ? false : true);
}
console.warn('This method is deprecated. For more details see https://nodejs.org/api/fs.html#fs_fs_exists_path_callback'); // eslint-disable-line no-console
stat(fs, context, path, cb);
}
// Based on https://github.com/nodejs/node/blob/c700cc42da9cf73af9fec2098520a6c0a631d901/lib/internal/validators.js#L21
var octalReg = /^[0-7]+$/;
var modeDesc = 'must be a 32-bit unsigned integer or an octal string';
function isUint32(value) {
return value === value >>> 0;
}
@ -8590,9 +8711,12 @@ module.exports = {
truncate: truncate,
ftruncate: ftruncate
};
},{"../../lib/nodash.js":"96cB","../path.js":"UzoP","../constants.js":"iJA9","../encoding.js":"03yF","../errors.js":"p8GN","../directory-entry.js":"ZECt","../open-file-description.js":"XWaV","../super-node.js":"33JE","../node.js":"KKNo","../stats.js":"6dsC","../buffer.js":"xfwq"}],"GMi4":[function(require,module,exports) {
},{"../../lib/nodash.js":"96cB","../path.js":"UzoP","../constants.js":"iJA9","../encoding.js":"03yF","../errors.js":"p8GN","../directory-entry.js":"ZECt","../open-file-description.js":"XWaV","../super-node.js":"33JE","../node.js":"KKNo","../stats.js":"6dsC","../buffer.js":"xfwq","../shared.js":"3zBM"}],"GMi4":[function(require,module,exports) {
var _ = require('../../lib/nodash.js');
var _require = require('es6-promisify'),
promisify = _require.promisify;
var isNullPath = require('../path.js').isNull;
var nop = require('../shared.js').nop;
@ -8622,7 +8746,7 @@ var impl = require('./implementation.js');
// node.js supports a calling pattern that leaves off a callback.
function maybeCallback(callback) {
if (typeof callback === "function") {
if (typeof callback === 'function') {
return callback;
}
return function (err) {
@ -8635,6 +8759,7 @@ function maybeCallback(callback) {
// Default callback that logs an error if passed in
function defaultCallback(err) {
if (err) {
/* eslint no-console: 0 */
console.error('Filer error: ', err);
}
}
@ -8697,7 +8822,7 @@ function FileSystem(options, callback) {
// descriptor management functions
var openFiles = {};
var nextDescriptor = FIRST_DESCRIPTOR;
Object.defineProperty(this, "openFiles", {
Object.defineProperty(this, 'openFiles', {
get: function get() {
return openFiles;
}
@ -8856,62 +8981,64 @@ function FileSystem(options, callback) {
impl.ensureRootDirectory(context, complete);
}
});
FileSystem.prototype.promises = {};
/**
* Public API for FileSystem
*/
['open', 'chmod', 'fchmod', 'chown', 'fchown', '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 (methodName) {
FileSystem.prototype[methodName] = function () {
var fs = this;
var args = Array.prototype.slice.call(arguments, 0);
var lastArgIndex = args.length - 1;
// We may or may not get a callback, and since node.js supports
// fire-and-forget style fs operations, we have to dance a bit here.
var missingCallback = typeof args[lastArgIndex] !== 'function';
var callback = maybeCallback(args[lastArgIndex]);
var error = fs.queueOrRun(function () {
var context = fs.provider.openReadWriteContext();
// Fail early if the filesystem is in an error state (e.g.,
// provider failed to open.
if (FS_ERROR === fs.readyState) {
var err = new Errors.EFILESYSTEMERROR('filesystem unavailable, operation canceled');
return callback.call(fs, err);
}
// Wrap the callback so we can explicitly close the context
function complete() {
context.close();
callback.apply(fs, arguments);
}
// Either add or replace the callback with our wrapper complete()
if (missingCallback) {
args.push(complete);
} else {
args[lastArgIndex] = complete;
}
// Forward this call to the impl's version, using the following
// call signature, with complete() as the callback/last-arg now:
// fn(fs, context, arg0, arg1, ... , complete);
var fnArgs = [fs, context].concat(args);
impl[methodName].apply(null, fnArgs);
});
if (error) {
callback(error);
}
};
FileSystem.prototype.promises[methodName] = promisify(FileSystem.prototype[methodName].bind(fs));
});
}
// Expose storage providers on FileSystem constructor
FileSystem.providers = providers;
/**
* Public API for FileSystem
*/
['open', 'chmod', 'fchmod', 'chown', 'fchown', '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 (methodName) {
FileSystem.prototype[methodName] = function () {
var fs = this;
var args = Array.prototype.slice.call(arguments, 0);
var lastArgIndex = args.length - 1;
// We may or may not get a callback, and since node.js supports
// fire-and-forget style fs operations, we have to dance a bit here.
var missingCallback = typeof args[lastArgIndex] !== 'function';
var callback = maybeCallback(args[lastArgIndex]);
var error = fs.queueOrRun(function () {
var context = fs.provider.openReadWriteContext();
// Fail early if the filesystem is in an error state (e.g.,
// provider failed to open.
if (FS_ERROR === fs.readyState) {
var err = new Errors.EFILESYSTEMERROR('filesystem unavailable, operation canceled');
return callback.call(fs, err);
}
// Wrap the callback so we can explicitly close the context
function complete() {
context.close();
callback.apply(fs, arguments);
}
// Either add or replace the callback with our wrapper complete()
if (missingCallback) {
args.push(complete);
} else {
args[lastArgIndex] = complete;
}
// Forward this call to the impl's version, using the following
// call signature, with complete() as the callback/last-arg now:
// fn(fs, context, arg0, arg1, ... , complete);
var fnArgs = [fs, context].concat(args);
impl[methodName].apply(null, fnArgs);
});
if (error) {
callback(error);
}
};
});
module.exports = FileSystem;
},{"../../lib/nodash.js":"96cB","../path.js":"UzoP","../shared.js":"3zBM","../constants.js":"iJA9","../providers/index.js":"AiW7","../shell/shell.js":"D1Ra","../../lib/intercom.js":"u7Jv","../fs-watcher.js":"VLEe","../errors.js":"p8GN","./implementation.js":"bsBG"}],"Focm":[function(require,module,exports) {
},{"../../lib/nodash.js":"96cB","es6-promisify":"0c0E","../path.js":"UzoP","../shared.js":"3zBM","../constants.js":"iJA9","../providers/index.js":"AiW7","../shell/shell.js":"D1Ra","../../lib/intercom.js":"u7Jv","../fs-watcher.js":"VLEe","../errors.js":"p8GN","./implementation.js":"bsBG"}],"Focm":[function(require,module,exports) {
module.exports = {
FileSystem: require('./filesystem/interface.js'),
Buffer: require('./buffer.js'),

2
dist/filer.map vendored

File diff suppressed because one or more lines are too long

42
dist/filer.min.js vendored

File diff suppressed because one or more lines are too long

2
dist/filer.min.map vendored

File diff suppressed because one or more lines are too long