diff --git a/.yarn/releases/yarn-1.19.0.cjs b/.yarn/releases/yarn-1.19.0.cjs index b1a221dd6..792ecb6a9 100755 --- a/.yarn/releases/yarn-1.19.0.cjs +++ b/.yarn/releases/yarn-1.19.0.cjs @@ -98,192 +98,192 @@ module.exports = require("path"); /* unused harmony export __makeTemplateObject */ /* unused harmony export __importStar */ /* unused harmony export __importDefault */ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ -/* global Reflect, Promise */ - -var extendStatics = function(d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); -}; - -function __extends(d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -} - -var __assign = function() { - __assign = Object.assign || function __assign(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; - } - return __assign.apply(this, arguments); -} - -function __rest(s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) - t[p[i]] = s[p[i]]; - return t; -} - -function __decorate(decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -} - -function __param(paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -} - -function __metadata(metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); -} - -function __awaiter(thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -} - -function __generator(thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -} - -function __exportStar(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; -} - -function __values(o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -} - -function __read(o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -} - -function __spread() { - for (var ar = [], i = 0; i < arguments.length; i++) - ar = ar.concat(__read(arguments[i])); - return ar; -} - -function __await(v) { - return this instanceof __await ? (this.v = v, this) : new __await(v); -} - -function __asyncGenerator(thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; - function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } - function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } - function fulfill(value) { resume("next", value); } - function reject(value) { resume("throw", value); } - function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } -} - -function __asyncDelegator(o) { - var i, p; - return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } -} - -function __asyncValues(o) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator], i; - return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); - function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } - function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } -} - -function __makeTemplateObject(cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; - -function __importStar(mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result.default = mod; - return result; -} - -function __importDefault(mod) { - return (mod && mod.__esModule) ? mod : { default: mod }; -} +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +/* global Reflect, Promise */ + +var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); +}; + +function __extends(d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +var __assign = function() { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + } + return __assign.apply(this, arguments); +} + +function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; + return t; +} + +function __decorate(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} + +function __param(paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +} + +function __metadata(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); +} + +function __awaiter(thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +} + +function __exportStar(m, exports) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} + +function __values(o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +} + +function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +function __spread() { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; +} + +function __await(v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); +} + +function __asyncGenerator(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +} + +function __asyncDelegator(o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } +} + +function __asyncValues(o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +} + +function __makeTemplateObject(cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; + +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result.default = mod; + return result; +} + +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { default: mod }; +} /***/ }), @@ -4333,7 +4333,7 @@ function coerce(version) { if (match == null) return null; - return parse((match[1] || '0') + '.' + (match[2] || '0') + '.' + (match[3] || '0')); + return parse((match[1] || '0') + '.' + (match[2] || '0') + '.' + (match[3] || '0')); } @@ -37396,7 +37396,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de // This will be bundled directly in the .js file for production builds var _require = __webpack_require__(194); /** * Determines the current version of Yarn itself. - * + * */ const version = _require.version, @@ -39989,7 +39989,7 @@ ECFieldElementFp.prototype.modReduce = function(x) { u = u.multiply(this.getR()); } - x = u.add(v); + x = u.add(v); } while (x.compareTo(q) >= 0) { @@ -40521,18 +40521,18 @@ function mkdirP (p, opts, f, made) { else if (!opts || typeof opts !== 'object') { opts = { mode: opts }; } - + var mode = opts.mode; var xfs = opts.fs || fs; - + if (mode === undefined) { mode = _0777 & (~process.umask()); } if (!made) made = null; - + var cb = f || function () {}; p = path.resolve(p); - + xfs.mkdir(p, mode, function (er) { if (!er) { made = made || p; @@ -40565,10 +40565,10 @@ mkdirP.sync = function sync (p, opts, made) { if (!opts || typeof opts !== 'object') { opts = { mode: opts }; } - + var mode = opts.mode; var xfs = opts.fs || fs; - + if (mode === undefined) { mode = _0777 & (~process.umask()); } @@ -43884,28 +43884,28 @@ function extractWorkspaces(manifest) { /* 163 */ /***/ (function(module, exports) { -module.exports = function(module) { - if(!module.webpackPolyfill) { - module.deprecate = function() {}; - module.paths = []; - // module.parent = undefined by default - if(!module.children) module.children = []; - Object.defineProperty(module, "loaded", { - enumerable: true, - get: function() { - return module.l; - } - }); - Object.defineProperty(module, "id", { - enumerable: true, - get: function() { - return module.i; - } - }); - module.webpackPolyfill = 1; - } - return module; -}; +module.exports = function(module) { + if(!module.webpackPolyfill) { + module.deprecate = function() {}; + module.paths = []; + // module.parent = undefined by default + if(!module.children) module.children = []; + Object.defineProperty(module, "loaded", { + enumerable: true, + get: function() { + return module.l; + } + }); + Object.defineProperty(module, "id", { + enumerable: true, + get: function() { + return module.i; + } + }); + module.webpackPolyfill = 1; + } + return module; +}; /***/ }), @@ -81092,11 +81092,11 @@ exports.ECKey = function(curve, key, isPublic) // var y = key.slice(bytes+1); // this.P = new ECPointFp(curve, // curve.fromBigInteger(new BigInteger(x.toString("hex"), 16)), -// curve.fromBigInteger(new BigInteger(y.toString("hex"), 16))); +// curve.fromBigInteger(new BigInteger(y.toString("hex"), 16))); this.P = curve.decodePointHex(key.toString("hex")); }else{ if(key.length != bytes) return false; - priv = new BigInteger(key.toString("hex"), 16); + priv = new BigInteger(key.toString("hex"), 16); } }else{ var n1 = n.subtract(BigInteger.ONE); @@ -81118,7 +81118,7 @@ exports.ECKey = function(curve, key, isPublic) if(!key || !key.P) return false; var S = key.P.multiply(priv); return Buffer.from(unstupid(S.getX().toBigInteger().toString(16),bytes*2),"hex"); - } + } } } @@ -88561,7 +88561,7 @@ inherits(DestroyableTransform, Transform) DestroyableTransform.prototype.destroy = function(err) { if (this._destroyed) return this._destroyed = true - + var self = this process.nextTick(function() { if (err) @@ -88682,7 +88682,7 @@ function bytesToUuid(buf, offset) { var i = offset || 0; var bth = byteToHex; // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4 - return ([bth[buf[i++]], bth[buf[i++]], + return ([bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', @@ -89034,7 +89034,7 @@ threshold'), { code: 'ECOMPROMISED' })); // on process exit // We first check that `lock.updateTimeout.unref` exists because some users - // may be using this module outside of NodeJS (e.g., in an electron app), + // may be using this module outside of NodeJS (e.g., in an electron app), // and in those cases `setTimeout` return an integer. if (lock.updateTimeout.unref) { lock.updateTimeout.unref(); @@ -94880,7 +94880,7 @@ var crypto = __webpack_require__(12) * Valid keys. */ -var keys = +var keys = [ 'acl' , 'location' , 'logging' @@ -94919,7 +94919,7 @@ module.exports.authorization = authorization * @param {Object} options * @return {String} * @api private - */ + */ function hmacSha1 (options) { return crypto.createHmac('sha1', options.secret).update(options.message).digest('base64') @@ -94928,8 +94928,8 @@ function hmacSha1 (options) { module.exports.hmacSha1 = hmacSha1 /** - * Create a base64 sha1 HMAC for `options`. - * + * Create a base64 sha1 HMAC for `options`. + * * @param {Object} options * @return {String} * @api private @@ -94942,10 +94942,10 @@ function sign (options) { module.exports.sign = sign /** - * Create a base64 sha1 HMAC for `options`. + * Create a base64 sha1 HMAC for `options`. * * Specifically to be used with S3 presigned URLs - * + * * @param {Object} options * @return {String} * @api private @@ -94961,7 +94961,7 @@ module.exports.signQuery= signQuery * Return a string for sign() with the given `options`. * * Spec: - * + * * \n * \n * \n @@ -94977,7 +94977,7 @@ module.exports.signQuery= signQuery function stringToSign (options) { var headers = options.amazonHeaders || '' if (headers) headers += '\n' - var r = + var r = [ options.verb , options.md5 , options.contentType @@ -94993,7 +94993,7 @@ module.exports.stringToSign = stringToSign * for S3 presigned URLs * * Spec: - * + * * \n * * @@ -109615,155 +109615,155 @@ module.exports = function (fromModel) { /* 610 */ /***/ (function(module, exports) { -module.exports = { - "aliceblue": [240, 248, 255], - "antiquewhite": [250, 235, 215], - "aqua": [0, 255, 255], - "aquamarine": [127, 255, 212], - "azure": [240, 255, 255], - "beige": [245, 245, 220], - "bisque": [255, 228, 196], - "black": [0, 0, 0], - "blanchedalmond": [255, 235, 205], - "blue": [0, 0, 255], - "blueviolet": [138, 43, 226], - "brown": [165, 42, 42], - "burlywood": [222, 184, 135], - "cadetblue": [95, 158, 160], - "chartreuse": [127, 255, 0], - "chocolate": [210, 105, 30], - "coral": [255, 127, 80], - "cornflowerblue": [100, 149, 237], - "cornsilk": [255, 248, 220], - "crimson": [220, 20, 60], - "cyan": [0, 255, 255], - "darkblue": [0, 0, 139], - "darkcyan": [0, 139, 139], - "darkgoldenrod": [184, 134, 11], - "darkgray": [169, 169, 169], - "darkgreen": [0, 100, 0], - "darkgrey": [169, 169, 169], - "darkkhaki": [189, 183, 107], - "darkmagenta": [139, 0, 139], - "darkolivegreen": [85, 107, 47], - "darkorange": [255, 140, 0], - "darkorchid": [153, 50, 204], - "darkred": [139, 0, 0], - "darksalmon": [233, 150, 122], - "darkseagreen": [143, 188, 143], - "darkslateblue": [72, 61, 139], - "darkslategray": [47, 79, 79], - "darkslategrey": [47, 79, 79], - "darkturquoise": [0, 206, 209], - "darkviolet": [148, 0, 211], - "deeppink": [255, 20, 147], - "deepskyblue": [0, 191, 255], - "dimgray": [105, 105, 105], - "dimgrey": [105, 105, 105], - "dodgerblue": [30, 144, 255], - "firebrick": [178, 34, 34], - "floralwhite": [255, 250, 240], - "forestgreen": [34, 139, 34], - "fuchsia": [255, 0, 255], - "gainsboro": [220, 220, 220], - "ghostwhite": [248, 248, 255], - "gold": [255, 215, 0], - "goldenrod": [218, 165, 32], - "gray": [128, 128, 128], - "green": [0, 128, 0], - "greenyellow": [173, 255, 47], - "grey": [128, 128, 128], - "honeydew": [240, 255, 240], - "hotpink": [255, 105, 180], - "indianred": [205, 92, 92], - "indigo": [75, 0, 130], - "ivory": [255, 255, 240], - "khaki": [240, 230, 140], - "lavender": [230, 230, 250], - "lavenderblush": [255, 240, 245], - "lawngreen": [124, 252, 0], - "lemonchiffon": [255, 250, 205], - "lightblue": [173, 216, 230], - "lightcoral": [240, 128, 128], - "lightcyan": [224, 255, 255], - "lightgoldenrodyellow": [250, 250, 210], - "lightgray": [211, 211, 211], - "lightgreen": [144, 238, 144], - "lightgrey": [211, 211, 211], - "lightpink": [255, 182, 193], - "lightsalmon": [255, 160, 122], - "lightseagreen": [32, 178, 170], - "lightskyblue": [135, 206, 250], - "lightslategray": [119, 136, 153], - "lightslategrey": [119, 136, 153], - "lightsteelblue": [176, 196, 222], - "lightyellow": [255, 255, 224], - "lime": [0, 255, 0], - "limegreen": [50, 205, 50], - "linen": [250, 240, 230], - "magenta": [255, 0, 255], - "maroon": [128, 0, 0], - "mediumaquamarine": [102, 205, 170], - "mediumblue": [0, 0, 205], - "mediumorchid": [186, 85, 211], - "mediumpurple": [147, 112, 219], - "mediumseagreen": [60, 179, 113], - "mediumslateblue": [123, 104, 238], - "mediumspringgreen": [0, 250, 154], - "mediumturquoise": [72, 209, 204], - "mediumvioletred": [199, 21, 133], - "midnightblue": [25, 25, 112], - "mintcream": [245, 255, 250], - "mistyrose": [255, 228, 225], - "moccasin": [255, 228, 181], - "navajowhite": [255, 222, 173], - "navy": [0, 0, 128], - "oldlace": [253, 245, 230], - "olive": [128, 128, 0], - "olivedrab": [107, 142, 35], - "orange": [255, 165, 0], - "orangered": [255, 69, 0], - "orchid": [218, 112, 214], - "palegoldenrod": [238, 232, 170], - "palegreen": [152, 251, 152], - "paleturquoise": [175, 238, 238], - "palevioletred": [219, 112, 147], - "papayawhip": [255, 239, 213], - "peachpuff": [255, 218, 185], - "peru": [205, 133, 63], - "pink": [255, 192, 203], - "plum": [221, 160, 221], - "powderblue": [176, 224, 230], - "purple": [128, 0, 128], - "rebeccapurple": [102, 51, 153], - "red": [255, 0, 0], - "rosybrown": [188, 143, 143], - "royalblue": [65, 105, 225], - "saddlebrown": [139, 69, 19], - "salmon": [250, 128, 114], - "sandybrown": [244, 164, 96], - "seagreen": [46, 139, 87], - "seashell": [255, 245, 238], - "sienna": [160, 82, 45], - "silver": [192, 192, 192], - "skyblue": [135, 206, 235], - "slateblue": [106, 90, 205], - "slategray": [112, 128, 144], - "slategrey": [112, 128, 144], - "snow": [255, 250, 250], - "springgreen": [0, 255, 127], - "steelblue": [70, 130, 180], - "tan": [210, 180, 140], - "teal": [0, 128, 128], - "thistle": [216, 191, 216], - "tomato": [255, 99, 71], - "turquoise": [64, 224, 208], - "violet": [238, 130, 238], - "wheat": [245, 222, 179], - "white": [255, 255, 255], - "whitesmoke": [245, 245, 245], - "yellow": [255, 255, 0], - "yellowgreen": [154, 205, 50] +module.exports = { + "aliceblue": [240, 248, 255], + "antiquewhite": [250, 235, 215], + "aqua": [0, 255, 255], + "aquamarine": [127, 255, 212], + "azure": [240, 255, 255], + "beige": [245, 245, 220], + "bisque": [255, 228, 196], + "black": [0, 0, 0], + "blanchedalmond": [255, 235, 205], + "blue": [0, 0, 255], + "blueviolet": [138, 43, 226], + "brown": [165, 42, 42], + "burlywood": [222, 184, 135], + "cadetblue": [95, 158, 160], + "chartreuse": [127, 255, 0], + "chocolate": [210, 105, 30], + "coral": [255, 127, 80], + "cornflowerblue": [100, 149, 237], + "cornsilk": [255, 248, 220], + "crimson": [220, 20, 60], + "cyan": [0, 255, 255], + "darkblue": [0, 0, 139], + "darkcyan": [0, 139, 139], + "darkgoldenrod": [184, 134, 11], + "darkgray": [169, 169, 169], + "darkgreen": [0, 100, 0], + "darkgrey": [169, 169, 169], + "darkkhaki": [189, 183, 107], + "darkmagenta": [139, 0, 139], + "darkolivegreen": [85, 107, 47], + "darkorange": [255, 140, 0], + "darkorchid": [153, 50, 204], + "darkred": [139, 0, 0], + "darksalmon": [233, 150, 122], + "darkseagreen": [143, 188, 143], + "darkslateblue": [72, 61, 139], + "darkslategray": [47, 79, 79], + "darkslategrey": [47, 79, 79], + "darkturquoise": [0, 206, 209], + "darkviolet": [148, 0, 211], + "deeppink": [255, 20, 147], + "deepskyblue": [0, 191, 255], + "dimgray": [105, 105, 105], + "dimgrey": [105, 105, 105], + "dodgerblue": [30, 144, 255], + "firebrick": [178, 34, 34], + "floralwhite": [255, 250, 240], + "forestgreen": [34, 139, 34], + "fuchsia": [255, 0, 255], + "gainsboro": [220, 220, 220], + "ghostwhite": [248, 248, 255], + "gold": [255, 215, 0], + "goldenrod": [218, 165, 32], + "gray": [128, 128, 128], + "green": [0, 128, 0], + "greenyellow": [173, 255, 47], + "grey": [128, 128, 128], + "honeydew": [240, 255, 240], + "hotpink": [255, 105, 180], + "indianred": [205, 92, 92], + "indigo": [75, 0, 130], + "ivory": [255, 255, 240], + "khaki": [240, 230, 140], + "lavender": [230, 230, 250], + "lavenderblush": [255, 240, 245], + "lawngreen": [124, 252, 0], + "lemonchiffon": [255, 250, 205], + "lightblue": [173, 216, 230], + "lightcoral": [240, 128, 128], + "lightcyan": [224, 255, 255], + "lightgoldenrodyellow": [250, 250, 210], + "lightgray": [211, 211, 211], + "lightgreen": [144, 238, 144], + "lightgrey": [211, 211, 211], + "lightpink": [255, 182, 193], + "lightsalmon": [255, 160, 122], + "lightseagreen": [32, 178, 170], + "lightskyblue": [135, 206, 250], + "lightslategray": [119, 136, 153], + "lightslategrey": [119, 136, 153], + "lightsteelblue": [176, 196, 222], + "lightyellow": [255, 255, 224], + "lime": [0, 255, 0], + "limegreen": [50, 205, 50], + "linen": [250, 240, 230], + "magenta": [255, 0, 255], + "maroon": [128, 0, 0], + "mediumaquamarine": [102, 205, 170], + "mediumblue": [0, 0, 205], + "mediumorchid": [186, 85, 211], + "mediumpurple": [147, 112, 219], + "mediumseagreen": [60, 179, 113], + "mediumslateblue": [123, 104, 238], + "mediumspringgreen": [0, 250, 154], + "mediumturquoise": [72, 209, 204], + "mediumvioletred": [199, 21, 133], + "midnightblue": [25, 25, 112], + "mintcream": [245, 255, 250], + "mistyrose": [255, 228, 225], + "moccasin": [255, 228, 181], + "navajowhite": [255, 222, 173], + "navy": [0, 0, 128], + "oldlace": [253, 245, 230], + "olive": [128, 128, 0], + "olivedrab": [107, 142, 35], + "orange": [255, 165, 0], + "orangered": [255, 69, 0], + "orchid": [218, 112, 214], + "palegoldenrod": [238, 232, 170], + "palegreen": [152, 251, 152], + "paleturquoise": [175, 238, 238], + "palevioletred": [219, 112, 147], + "papayawhip": [255, 239, 213], + "peachpuff": [255, 218, 185], + "peru": [205, 133, 63], + "pink": [255, 192, 203], + "plum": [221, 160, 221], + "powderblue": [176, 224, 230], + "purple": [128, 0, 128], + "rebeccapurple": [102, 51, 153], + "red": [255, 0, 0], + "rosybrown": [188, 143, 143], + "royalblue": [65, 105, 225], + "saddlebrown": [139, 69, 19], + "salmon": [250, 128, 114], + "sandybrown": [244, 164, 96], + "seagreen": [46, 139, 87], + "seashell": [255, 245, 238], + "sienna": [160, 82, 45], + "silver": [192, 192, 192], + "skyblue": [135, 206, 235], + "slateblue": [106, 90, 205], + "slategray": [112, 128, 144], + "slategrey": [112, 128, 144], + "snow": [255, 250, 250], + "springgreen": [0, 255, 127], + "steelblue": [70, 130, 180], + "tan": [210, 180, 140], + "teal": [0, 128, 128], + "thistle": [216, 191, 216], + "tomato": [255, 99, 71], + "turquoise": [64, 224, 208], + "violet": [238, 130, 238], + "wheat": [245, 222, 179], + "white": [255, 255, 255], + "whitesmoke": [245, 245, 245], + "yellow": [255, 255, 0], + "yellowgreen": [154, 205, 50] }; /***/ }), @@ -111163,7 +111163,7 @@ var CacheObject = function (conf) { conf = conf || {}; conf.ttl = parseInt(conf.ttl, 10) || 300; //0 is not permissible conf.cachesize = parseInt(conf.cachesize, 10) || 1000; //0 is not permissible - + this.ttl = conf.ttl * 1000; this.max = conf.cachesize; @@ -111304,7 +111304,7 @@ var EnhanceDns = function (conf) { //cache already exists, means this code has already execute ie method are already overwritten return dns; } - + // original function storage var backup_object = { lookup : dns.lookup, @@ -111320,7 +111320,7 @@ var EnhanceDns = function (conf) { }, // cache storage instance cache = conf.cache ? /*istanbul ignore next*/ new conf.cache(conf) : new CacheObject(conf); - + // insert cache object to the instance dns.internalCache = cache; @@ -112886,8 +112886,8 @@ var util = __webpack_require__(3) , net = __webpack_require__(164) , tls = __webpack_require__(467) , AgentSSL = __webpack_require__(195).Agent - -function getConnectionName(host, port) { + +function getConnectionName(host, port) { var name = '' if (typeof host === 'string') { name = host + ':' + port @@ -112896,7 +112896,7 @@ function getConnectionName(host, port) { name = host.host + ':' + host.port + ':' + (host.localAddress ? (host.localAddress + ':') : ':') } return name -} +} function ForeverAgent(options) { var self = this @@ -112914,7 +112914,7 @@ function ForeverAgent(options) { } else if (self.sockets[name].length < self.minSockets) { if (!self.freeSockets[name]) self.freeSockets[name] = [] self.freeSockets[name].push(socket) - + // if an error happens while we don't use the socket anyway, meh, throw the socket away var onIdleError = function() { socket.destroy() @@ -112940,7 +112940,7 @@ ForeverAgent.prototype.createConnection = net.createConnection ForeverAgent.prototype.addRequestNoreuse = Agent.prototype.addRequest ForeverAgent.prototype.addRequest = function(req, host, port) { var name = getConnectionName(host, port) - + if (typeof host !== 'string') { var options = host port = options.port @@ -112969,7 +112969,7 @@ ForeverAgent.prototype.removeSocket = function(s, name, host, port) { delete this.sockets[name] delete this.requests[name] } - + if (this.freeSockets[name]) { var index = this.freeSockets[name].indexOf(s) if (index !== -1) { @@ -117012,7 +117012,7 @@ class BottomBar extends Base { */ write(message) { var msgLines = message.split(/\n/); - this.height = msgLines.length; + this.maxHeight = msgLines.length; // Write message to screen and setPrompt to control backspace this.rl.setPrompt(_.last(msgLines)); @@ -119696,7 +119696,7 @@ function DBCSCodec(codecOptions, iconv) { this.decodeTables = []; this.decodeTables[0] = UNASSIGNED_NODE.slice(0); // Create root node. - // Sometimes a MBCS char corresponds to a sequence of unicode chars. We store them as arrays of integers here. + // Sometimes a MBCS char corresponds to a sequence of unicode chars. We store them as arrays of integers here. this.decodeTableSeq = []; // Actual mapping tables consist of chunks. Use them to fill up decode tables. @@ -119705,7 +119705,7 @@ function DBCSCodec(codecOptions, iconv) { this.defaultCharUnicode = iconv.defaultCharUnicode; - + // Encode tables: Unicode -> DBCS. // `encodeTable` is array mapping from unicode char to encoded char. All its values are integers for performance. @@ -119714,7 +119714,7 @@ function DBCSCodec(codecOptions, iconv) { // == UNASSIGNED -> no conversion found. Output a default char. // <= SEQ_START -> it's an index in encodeTableSeq, see below. The character starts a sequence. this.encodeTable = []; - + // `encodeTableSeq` is used when a sequence of unicode characters is encoded as a single code. We use a tree of // objects where keys correspond to characters in sequence and leafs are the encoded dbcs values. A special DEF_CHAR key // means end of sequence (needed when one sequence is a strict subsequence of another). @@ -119732,7 +119732,7 @@ function DBCSCodec(codecOptions, iconv) { for (var j = val.from; j <= val.to; j++) skipEncodeChars[j] = true; } - + // Use decode trie to recursively fill out encode tables. this._fillEncodeTable(0, 0, skipEncodeChars); @@ -119769,7 +119769,7 @@ function DBCSCodec(codecOptions, iconv) { thirdByteNode[i] = NODE_START - fourthByteNodeIdx; for (var i = 0x30; i <= 0x39; i++) fourthByteNode[i] = GB18030_CODE - } + } } DBCSCodec.prototype.encoder = DBCSEncoder; @@ -119834,7 +119834,7 @@ DBCSCodec.prototype._addDecodeChunk = function(chunk) { else writeTable[curAddr++] = code; // Basic char } - } + } else if (typeof part === "number") { // Integer, meaning increasing sequence starting with prev character. var charCode = writeTable[curAddr - 1] + 1; for (var l = 0; l < part; l++) @@ -119865,7 +119865,7 @@ DBCSCodec.prototype._setEncodeChar = function(uCode, dbcsCode) { } DBCSCodec.prototype._setEncodeSequence = function(seq, dbcsCode) { - + // Get the root of character tree according to first character of the sequence. var uCode = seq[0]; var bucket = this._getEncodeBucket(uCode); @@ -119926,7 +119926,7 @@ function DBCSEncoder(options, codec) { // Encoder state this.leadSurrogate = -1; this.seqObj = undefined; - + // Static data this.encodeTable = codec.encodeTable; this.encodeTableSeq = codec.encodeTableSeq; @@ -119948,7 +119948,7 @@ DBCSEncoder.prototype.write = function(str) { } else { var uCode = nextChar; - nextChar = -1; + nextChar = -1; } // 1. Handle surrogates. @@ -119970,7 +119970,7 @@ DBCSEncoder.prototype.write = function(str) { // Incomplete surrogate pair - only trail surrogate found. uCode = UNASSIGNED; } - + } } else if (leadSurrogate !== -1) { @@ -120011,7 +120011,7 @@ DBCSEncoder.prototype.write = function(str) { var subtable = this.encodeTable[uCode >> 8]; if (subtable !== undefined) dbcsCode = subtable[uCode & 0xFF]; - + if (dbcsCode <= SEQ_START) { // Sequence start seqObj = this.encodeTableSeq[SEQ_START-dbcsCode]; continue; @@ -120034,7 +120034,7 @@ DBCSEncoder.prototype.write = function(str) { // 3. Write dbcsCode character. if (dbcsCode === UNASSIGNED) dbcsCode = this.defaultCharSingleByte; - + if (dbcsCode < 0x100) { newBuf[j++] = dbcsCode; } @@ -120081,7 +120081,7 @@ DBCSEncoder.prototype.end = function() { newBuf[j++] = this.defaultCharSingleByte; this.leadSurrogate = -1; } - + return newBuf.slice(0, j); } @@ -120105,21 +120105,21 @@ function DBCSDecoder(options, codec) { DBCSDecoder.prototype.write = function(buf) { var newBuf = Buffer.alloc(buf.length*2), - nodeIdx = this.nodeIdx, + nodeIdx = this.nodeIdx, prevBuf = this.prevBuf, prevBufOffset = this.prevBuf.length, seqStart = -this.prevBuf.length, // idx of the start of current parsed sequence. uCode; if (prevBufOffset > 0) // Make prev buf overlap a little to make it easier to slice later. prevBuf = Buffer.concat([prevBuf, buf.slice(0, 10)]); - + for (var i = 0, j = 0; i < buf.length; i++) { var curByte = (i >= 0) ? buf[i] : prevBuf[i + prevBufOffset]; // Lookup in current trie node. var uCode = this.decodeTables[nodeIdx][curByte]; - if (uCode >= 0) { + if (uCode >= 0) { // Normal character, just use it. } else if (uCode === UNASSIGNED) { // Unknown char. @@ -120151,7 +120151,7 @@ DBCSDecoder.prototype.write = function(buf) { throw new Error("iconv-lite internal error: invalid decoding table value " + uCode + " at " + nodeIdx + "/" + curByte); // Write the character to buffer, handling higher planes using surrogate pair. - if (uCode > 0xFFFF) { + if (uCode > 0xFFFF) { uCode -= 0x10000; var uCodeLead = 0xD800 + Math.floor(uCode / 0x400); newBuf[j++] = uCodeLead & 0xFF; @@ -120221,11 +120221,11 @@ function findIdx(table, val) { // require()-s are direct to support Browserify. module.exports = { - + // == Japanese/ShiftJIS ==================================================== // All japanese encodings are based on JIS X set of standards: // JIS X 0201 - Single-byte encoding of ASCII + ¥ + Kana chars at 0xA1-0xDF. - // JIS X 0208 - Main set of 6879 characters, placed in 94x94 plane, to be encoded by 2 bytes. + // JIS X 0208 - Main set of 6879 characters, placed in 94x94 plane, to be encoded by 2 bytes. // Has several variations in 1978, 1983, 1990 and 1997. // JIS X 0212 - Supplementary plane of 6067 chars in 94x94 plane. 1990. Effectively dead. // JIS X 0213 - Extension and modern replacement of 0208 and 0212. Total chars: 11233. @@ -120243,7 +120243,7 @@ module.exports = { // 0x8F, (0xA1-0xFE)x2 - 0212 plane (94x94). // * JIS X 208: 7-bit, direct encoding of 0208. Byte ranges: 0x21-0x7E (94 values). Uncommon. // Used as-is in ISO2022 family. - // * ISO2022-JP: Stateful encoding, with escape sequences to switch between ASCII, + // * ISO2022-JP: Stateful encoding, with escape sequences to switch between ASCII, // 0201-1976 Roman, 0208-1978, 0208-1983. // * ISO2022-JP-1: Adds esc seq for 0212-1990. // * ISO2022-JP-2: Adds esc seq for GB2313-1980, KSX1001-1992, ISO8859-1, ISO8859-7. @@ -120355,7 +120355,7 @@ module.exports = { // * Windows CP 951: Microsoft variant of Big5-HKSCS-2001. Seems to be never public. http://me.abelcheung.org/articles/research/what-is-cp951/ // * Big5-2003 (Taiwan standard) almost superset of cp950. // * Unicode-at-on (UAO) / Mozilla 1.8. Falling out of use on the Web. Not supported by other browsers. - // * Big5-HKSCS (-2001, -2004, -2008). Hong Kong standard. + // * Big5-HKSCS (-2001, -2004, -2008). Hong Kong standard. // many unicode code points moved from PUA to Supplementary plane (U+2XXXX) over the years. // Plus, it has 4 combining sequences. // Seems that Mozilla refused to support it for 10 yrs. https://bugzilla.mozilla.org/show_bug.cgi?id=162431 https://bugzilla.mozilla.org/show_bug.cgi?id=310299 @@ -120366,7 +120366,7 @@ module.exports = { // In the encoder, it might make sense to support encoding old PUA mappings to Big5 bytes seq-s. // Official spec: http://www.ogcio.gov.hk/en/business/tech_promotion/ccli/terms/doc/2003cmp_2008.txt // http://www.ogcio.gov.hk/tc/business/tech_promotion/ccli/terms/doc/hkscs-2008-big5-iso.txt - // + // // Current understanding of how to deal with Big5(-HKSCS) is in the Encoding Standard, http://encoding.spec.whatwg.org/#big5-encoder // Unicode mapping (http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/OTHER/BIG5.TXT) is said to be wrong. @@ -120412,7 +120412,7 @@ var modules = [ __webpack_require__(711), ]; -// Put all encoding/alias/codec definitions to single object and export it. +// Put all encoding/alias/codec definitions to single object and export it. for (var i = 0; i < modules.length; i++) { var module = modules[i]; for (var enc in module) @@ -120564,7 +120564,7 @@ function InternalDecoderCesu8(options, codec) { } InternalDecoderCesu8.prototype.write = function(buf) { - var acc = this.acc, contBytes = this.contBytes, accBytes = this.accBytes, + var acc = this.acc, contBytes = this.contBytes, accBytes = this.accBytes, res = ''; for (var i = 0; i < buf.length; i++) { var curByte = buf[i]; @@ -120625,17 +120625,17 @@ InternalDecoderCesu8.prototype.end = function() { var Buffer = __webpack_require__(15).Buffer; // Single-byte codec. Needs a 'chars' string parameter that contains 256 or 128 chars that -// correspond to encoded bytes (if 128 - then lower half is ASCII). +// correspond to encoded bytes (if 128 - then lower half is ASCII). exports._sbcs = SBCSCodec; function SBCSCodec(codecOptions, iconv) { if (!codecOptions) throw new Error("SBCS codec is called without the data.") - + // Prepare char buffer for decoding. if (!codecOptions.chars || (codecOptions.chars.length !== 128 && codecOptions.chars.length !== 256)) throw new Error("Encoding '"+codecOptions.type+"' has incorrect 'chars' (must be of len 128 or 256)"); - + if (codecOptions.chars.length === 128) { var asciiString = ""; for (var i = 0; i < 128; i++) @@ -120644,7 +120644,7 @@ function SBCSCodec(codecOptions, iconv) { } this.decodeBuf = Buffer.from(codecOptions.chars, 'ucs2'); - + // Encoding buffer. var encodeBuf = Buffer.alloc(65536, iconv.defaultCharSingleByte.charCodeAt(0)); @@ -120666,7 +120666,7 @@ SBCSEncoder.prototype.write = function(str) { var buf = Buffer.alloc(str.length); for (var i = 0; i < str.length; i++) buf[i] = this.encodeBuf[str.charCodeAt(i)]; - + return buf; } @@ -121485,7 +121485,7 @@ Utf16Decoder.prototype.write = function(buf) { // Codec is not chosen yet. Accumulate initial bytes. this.initialBytes.push(buf); this.initialBytesLen += buf.length; - + if (this.initialBytesLen < 16) // We need more bytes to use space heuristic (see below) return ''; @@ -121581,8 +121581,8 @@ Utf7Encoder.prototype.write = function(str) { // Naive implementation. // Non-direct chars are encoded as "+-"; single "+" char is encoded as "+-". return Buffer.from(str.replace(nonDirectChars, function(chunk) { - return "+" + (chunk === '+' ? '' : - this.iconv.encode(chunk, 'utf16-be').toString('base64').replace(/=+$/, '')) + return "+" + (chunk === '+' ? '' : + this.iconv.encode(chunk, 'utf16-be').toString('base64').replace(/=+$/, '')) + "-"; }.bind(this))); } @@ -121604,7 +121604,7 @@ var base64Chars = []; for (var i = 0; i < 256; i++) base64Chars[i] = base64Regex.test(String.fromCharCode(i)); -var plusChar = '+'.charCodeAt(0), +var plusChar = '+'.charCodeAt(0), minusChar = '-'.charCodeAt(0), andChar = '&'.charCodeAt(0); @@ -121933,7 +121933,7 @@ module.exports = function (iconv) { } var nodeNativeEncodings = { - 'hex': true, 'utf8': true, 'utf-8': true, 'ascii': true, 'binary': true, + 'hex': true, 'utf8': true, 'utf-8': true, 'ascii': true, 'binary': true, 'base64': true, 'ucs2': true, 'ucs-2': true, 'utf16le': true, 'utf-16le': true, }; @@ -122157,7 +122157,7 @@ iconv.encode = function encode(str, encoding, options) { var res = encoder.write(str); var trail = encoder.end(); - + return (trail && trail.length > 0) ? Buffer.concat([res, trail]) : res; } @@ -122197,7 +122197,7 @@ iconv._codecDataCache = {}; iconv.getCodec = function getCodec(encoding) { if (!iconv.encodings) iconv.encodings = __webpack_require__(712); // Lazy load all encoding definitions. - + // Canonicalize encoding name: strip all non-alphanumeric chars and appended year. var enc = iconv._canonicalizeEncoding(encoding); @@ -122221,7 +122221,7 @@ iconv.getCodec = function getCodec(encoding) { if (!codecOptions.encodingName) codecOptions.encodingName = enc; - + enc = codecDef.type; break; @@ -122300,7 +122300,7 @@ var Buffer = __webpack_require__(64).Buffer, // == Exports ================================================================== module.exports = function(iconv) { - + // Additional Public API. iconv.encodeStream = function encodeStream(encoding, options) { return new IconvLiteEncoderStream(iconv.getEncoder(encoding, options), options); @@ -122395,7 +122395,7 @@ IconvLiteDecoderStream.prototype._transform = function(chunk, encoding, done) { IconvLiteDecoderStream.prototype._flush = function(done) { try { var res = this.conv.end(); - if (res && res.length) this.push(res, this.encoding); + if (res && res.length) this.push(res, this.encoding); done(); } catch (e) { @@ -122832,280 +122832,280 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ /* 744 */ /***/ (function(module, exports, __webpack_require__) { -var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/** - * JSONSchema Validator - Validates JavaScript objects using JSON Schemas - * (http://www.json.com/json-schema-proposal/) - * - * Copyright (c) 2007 Kris Zyp SitePen (www.sitepen.com) - * Licensed under the MIT (MIT-LICENSE.txt) license. -To use the validator call the validate function with an instance object and an optional schema object. -If a schema is provided, it will be used to validate. If the instance object refers to a schema (self-validating), -that schema will be used to validate and the schema parameter is not necessary (if both exist, -both validations will occur). -The validate method will return an array of validation errors. If there are no errors, then an -empty list will be returned. A validation error will have two properties: -"property" which indicates which property had the error -"message" which indicates what the error was - */ -(function (root, factory) { - if (true) { - // AMD. Register as an anonymous module. - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function () { - return factory(); +var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/** + * JSONSchema Validator - Validates JavaScript objects using JSON Schemas + * (http://www.json.com/json-schema-proposal/) + * + * Copyright (c) 2007 Kris Zyp SitePen (www.sitepen.com) + * Licensed under the MIT (MIT-LICENSE.txt) license. +To use the validator call the validate function with an instance object and an optional schema object. +If a schema is provided, it will be used to validate. If the instance object refers to a schema (self-validating), +that schema will be used to validate and the schema parameter is not necessary (if both exist, +both validations will occur). +The validate method will return an array of validation errors. If there are no errors, then an +empty list will be returned. A validation error will have two properties: +"property" which indicates which property had the error +"message" which indicates what the error was + */ +(function (root, factory) { + if (true) { + // AMD. Register as an anonymous module. + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function () { + return factory(); }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else if (typeof module === 'object' && module.exports) { - // Node. Does not work with strict CommonJS, but - // only CommonJS-like environments that support module.exports, - // like Node. - module.exports = factory(); - } else { - // Browser globals - root.jsonSchema = factory(); - } -}(this, function () {// setup primitive classes to be JSON Schema types -var exports = validate -exports.Integer = {type:"integer"}; -var primitiveConstructors = { - String: String, - Boolean: Boolean, - Number: Number, - Object: Object, - Array: Array, - Date: Date -} -exports.validate = validate; -function validate(/*Any*/instance,/*Object*/schema) { - // Summary: - // To use the validator call JSONSchema.validate with an instance object and an optional schema object. - // If a schema is provided, it will be used to validate. If the instance object refers to a schema (self-validating), - // that schema will be used to validate and the schema parameter is not necessary (if both exist, - // both validations will occur). - // The validate method will return an object with two properties: - // valid: A boolean indicating if the instance is valid by the schema - // errors: An array of validation errors. If there are no errors, then an - // empty list will be returned. A validation error will have two properties: - // property: which indicates which property had the error - // message: which indicates what the error was - // - return validate(instance, schema, {changing: false});//, coerce: false, existingOnly: false}); - }; -exports.checkPropertyChange = function(/*Any*/value,/*Object*/schema, /*String*/property) { - // Summary: - // The checkPropertyChange method will check to see if an value can legally be in property with the given schema - // This is slightly different than the validate method in that it will fail if the schema is readonly and it will - // not check for self-validation, it is assumed that the passed in value is already internally valid. - // The checkPropertyChange method will return the same object type as validate, see JSONSchema.validate for - // information. - // - return validate(value, schema, {changing: property || "property"}); - }; -var validate = exports._validate = function(/*Any*/instance,/*Object*/schema,/*Object*/options) { - - if (!options) options = {}; - var _changing = options.changing; - - function getType(schema){ - return schema.type || (primitiveConstructors[schema.name] == schema && schema.name.toLowerCase()); - } - var errors = []; - // validate a value against a property definition - function checkProp(value, schema, path,i){ - - var l; - path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; - function addError(message){ - errors.push({property:path,message:message}); - } - - if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function') && !(schema && getType(schema))){ - if(typeof schema == 'function'){ - if(!(value instanceof schema)){ - addError("is not an instance of the class/constructor " + schema.name); - } - }else if(schema){ - addError("Invalid schema/property definition " + schema); - } - return null; - } - if(_changing && schema.readonly){ - addError("is a readonly field, it can not be changed"); - } - if(schema['extends']){ // if it extends another schema, it must pass that schema as well - checkProp(value,schema['extends'],path,i); - } - // validate a value against a type definition - function checkType(type,value){ - if(type){ - if(typeof type == 'string' && type != 'any' && - (type == 'null' ? value !== null : typeof value != type) && - !(value instanceof Array && type == 'array') && - !(value instanceof Date && type == 'date') && - !(type == 'integer' && value%1===0)){ - return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; - } - if(type instanceof Array){ - var unionErrors=[]; - for(var j = 0; j < type.length; j++){ // a union type - if(!(unionErrors=checkType(type[j],value)).length){ - break; - } - } - if(unionErrors.length){ - return unionErrors; - } - }else if(typeof type == 'object'){ - var priorErrors = errors; - errors = []; - checkProp(value,type,path); - var theseErrors = errors; - errors = priorErrors; - return theseErrors; - } - } - return []; - } - if(value === undefined){ - if(schema.required){ - addError("is missing and it is required"); - } - }else{ - errors = errors.concat(checkType(getType(schema),value)); - if(schema.disallow && !checkType(schema.disallow,value).length){ - addError(" disallowed value was matched"); - } - if(value !== null){ - if(value instanceof Array){ - if(schema.items){ - var itemsIsArray = schema.items instanceof Array; - var propDef = schema.items; - for (i = 0, l = value.length; i < l; i += 1) { - if (itemsIsArray) - propDef = schema.items[i]; - if (options.coerce) - value[i] = options.coerce(value[i], propDef); - errors.concat(checkProp(value[i],propDef,path,i)); - } - } - if(schema.minItems && value.length < schema.minItems){ - addError("There must be a minimum of " + schema.minItems + " in the array"); - } - if(schema.maxItems && value.length > schema.maxItems){ - addError("There must be a maximum of " + schema.maxItems + " in the array"); - } - }else if(schema.properties || schema.additionalProperties){ - errors.concat(checkObj(value, schema.properties, path, schema.additionalProperties)); - } - if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ - addError("does not match the regex pattern " + schema.pattern); - } - if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ - addError("may only be " + schema.maxLength + " characters long"); - } - if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ - addError("must be at least " + schema.minLength + " characters long"); - } - if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && - schema.minimum > value){ - addError("must have a minimum value of " + schema.minimum); - } - if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && - schema.maximum < value){ - addError("must have a maximum value of " + schema.maximum); - } - if(schema['enum']){ - var enumer = schema['enum']; - l = enumer.length; - var found; - for(var j = 0; j < l; j++){ - if(enumer[j]===value){ - found=1; - break; - } - } - if(!found){ - addError("does not have a value in the enumeration " + enumer.join(", ")); - } - } - if(typeof schema.maxDecimal == 'number' && - (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ - addError("may only have " + schema.maxDecimal + " digits of decimal places"); - } - } - } - return null; - } - // validate an object against a schema - function checkObj(instance,objTypeDef,path,additionalProp){ - - if(typeof objTypeDef =='object'){ - if(typeof instance != 'object' || instance instanceof Array){ - errors.push({property:path,message:"an object is required"}); - } - - for(var i in objTypeDef){ - if(objTypeDef.hasOwnProperty(i)){ - var value = instance[i]; - // skip _not_ specified properties - if (value === undefined && options.existingOnly) continue; - var propDef = objTypeDef[i]; - // set default - if(value === undefined && propDef["default"]){ - value = instance[i] = propDef["default"]; - } - if(options.coerce && i in instance){ - value = instance[i] = options.coerce(value, propDef); - } - checkProp(value,propDef,path,i); - } - } - } - for(i in instance){ - if(instance.hasOwnProperty(i) && !(i.charAt(0) == '_' && i.charAt(1) == '_') && objTypeDef && !objTypeDef[i] && additionalProp===false){ - if (options.filter) { - delete instance[i]; - continue; - } else { - errors.push({property:path,message:(typeof value) + "The property " + i + - " is not defined in the schema and the schema does not allow additional properties"}); - } - } - var requires = objTypeDef && objTypeDef[i] && objTypeDef[i].requires; - if(requires && !(requires in instance)){ - errors.push({property:path,message:"the presence of the property " + i + " requires that " + requires + " also be present"}); - } - value = instance[i]; - if(additionalProp && (!(objTypeDef && typeof objTypeDef == 'object') || !(i in objTypeDef))){ - if(options.coerce){ - value = instance[i] = options.coerce(value, additionalProp); - } - checkProp(value,additionalProp,path,i); - } - if(!_changing && value && value.$schema){ - errors = errors.concat(checkProp(value,value.$schema,path,i)); - } - } - return errors; - } - if(schema){ - checkProp(instance,schema,'',_changing || ''); - } - if(!_changing && instance && instance.$schema){ - checkProp(instance,instance.$schema,'',''); - } - return {valid:!errors.length,errors:errors}; -}; -exports.mustBeValid = function(result){ - // summary: - // This checks to ensure that the result is valid and will throw an appropriate error message if it is not - // result: the result returned from checkPropertyChange or validate - if(!result.valid){ - throw new TypeError(result.errors.map(function(error){return "for property " + error.property + ': ' + error.message;}).join(", \n")); - } -} - -return exports; -})); + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else if (typeof module === 'object' && module.exports) { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like environments that support module.exports, + // like Node. + module.exports = factory(); + } else { + // Browser globals + root.jsonSchema = factory(); + } +}(this, function () {// setup primitive classes to be JSON Schema types +var exports = validate +exports.Integer = {type:"integer"}; +var primitiveConstructors = { + String: String, + Boolean: Boolean, + Number: Number, + Object: Object, + Array: Array, + Date: Date +} +exports.validate = validate; +function validate(/*Any*/instance,/*Object*/schema) { + // Summary: + // To use the validator call JSONSchema.validate with an instance object and an optional schema object. + // If a schema is provided, it will be used to validate. If the instance object refers to a schema (self-validating), + // that schema will be used to validate and the schema parameter is not necessary (if both exist, + // both validations will occur). + // The validate method will return an object with two properties: + // valid: A boolean indicating if the instance is valid by the schema + // errors: An array of validation errors. If there are no errors, then an + // empty list will be returned. A validation error will have two properties: + // property: which indicates which property had the error + // message: which indicates what the error was + // + return validate(instance, schema, {changing: false});//, coerce: false, existingOnly: false}); + }; +exports.checkPropertyChange = function(/*Any*/value,/*Object*/schema, /*String*/property) { + // Summary: + // The checkPropertyChange method will check to see if an value can legally be in property with the given schema + // This is slightly different than the validate method in that it will fail if the schema is readonly and it will + // not check for self-validation, it is assumed that the passed in value is already internally valid. + // The checkPropertyChange method will return the same object type as validate, see JSONSchema.validate for + // information. + // + return validate(value, schema, {changing: property || "property"}); + }; +var validate = exports._validate = function(/*Any*/instance,/*Object*/schema,/*Object*/options) { + + if (!options) options = {}; + var _changing = options.changing; + + function getType(schema){ + return schema.type || (primitiveConstructors[schema.name] == schema && schema.name.toLowerCase()); + } + var errors = []; + // validate a value against a property definition + function checkProp(value, schema, path,i){ + + var l; + path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; + function addError(message){ + errors.push({property:path,message:message}); + } + + if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function') && !(schema && getType(schema))){ + if(typeof schema == 'function'){ + if(!(value instanceof schema)){ + addError("is not an instance of the class/constructor " + schema.name); + } + }else if(schema){ + addError("Invalid schema/property definition " + schema); + } + return null; + } + if(_changing && schema.readonly){ + addError("is a readonly field, it can not be changed"); + } + if(schema['extends']){ // if it extends another schema, it must pass that schema as well + checkProp(value,schema['extends'],path,i); + } + // validate a value against a type definition + function checkType(type,value){ + if(type){ + if(typeof type == 'string' && type != 'any' && + (type == 'null' ? value !== null : typeof value != type) && + !(value instanceof Array && type == 'array') && + !(value instanceof Date && type == 'date') && + !(type == 'integer' && value%1===0)){ + return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; + } + if(type instanceof Array){ + var unionErrors=[]; + for(var j = 0; j < type.length; j++){ // a union type + if(!(unionErrors=checkType(type[j],value)).length){ + break; + } + } + if(unionErrors.length){ + return unionErrors; + } + }else if(typeof type == 'object'){ + var priorErrors = errors; + errors = []; + checkProp(value,type,path); + var theseErrors = errors; + errors = priorErrors; + return theseErrors; + } + } + return []; + } + if(value === undefined){ + if(schema.required){ + addError("is missing and it is required"); + } + }else{ + errors = errors.concat(checkType(getType(schema),value)); + if(schema.disallow && !checkType(schema.disallow,value).length){ + addError(" disallowed value was matched"); + } + if(value !== null){ + if(value instanceof Array){ + if(schema.items){ + var itemsIsArray = schema.items instanceof Array; + var propDef = schema.items; + for (i = 0, l = value.length; i < l; i += 1) { + if (itemsIsArray) + propDef = schema.items[i]; + if (options.coerce) + value[i] = options.coerce(value[i], propDef); + errors.concat(checkProp(value[i],propDef,path,i)); + } + } + if(schema.minItems && value.length < schema.minItems){ + addError("There must be a minimum of " + schema.minItems + " in the array"); + } + if(schema.maxItems && value.length > schema.maxItems){ + addError("There must be a maximum of " + schema.maxItems + " in the array"); + } + }else if(schema.properties || schema.additionalProperties){ + errors.concat(checkObj(value, schema.properties, path, schema.additionalProperties)); + } + if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ + addError("does not match the regex pattern " + schema.pattern); + } + if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ + addError("may only be " + schema.maxLength + " characters long"); + } + if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ + addError("must be at least " + schema.minLength + " characters long"); + } + if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && + schema.minimum > value){ + addError("must have a minimum value of " + schema.minimum); + } + if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && + schema.maximum < value){ + addError("must have a maximum value of " + schema.maximum); + } + if(schema['enum']){ + var enumer = schema['enum']; + l = enumer.length; + var found; + for(var j = 0; j < l; j++){ + if(enumer[j]===value){ + found=1; + break; + } + } + if(!found){ + addError("does not have a value in the enumeration " + enumer.join(", ")); + } + } + if(typeof schema.maxDecimal == 'number' && + (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ + addError("may only have " + schema.maxDecimal + " digits of decimal places"); + } + } + } + return null; + } + // validate an object against a schema + function checkObj(instance,objTypeDef,path,additionalProp){ + + if(typeof objTypeDef =='object'){ + if(typeof instance != 'object' || instance instanceof Array){ + errors.push({property:path,message:"an object is required"}); + } + + for(var i in objTypeDef){ + if(objTypeDef.hasOwnProperty(i)){ + var value = instance[i]; + // skip _not_ specified properties + if (value === undefined && options.existingOnly) continue; + var propDef = objTypeDef[i]; + // set default + if(value === undefined && propDef["default"]){ + value = instance[i] = propDef["default"]; + } + if(options.coerce && i in instance){ + value = instance[i] = options.coerce(value, propDef); + } + checkProp(value,propDef,path,i); + } + } + } + for(i in instance){ + if(instance.hasOwnProperty(i) && !(i.charAt(0) == '_' && i.charAt(1) == '_') && objTypeDef && !objTypeDef[i] && additionalProp===false){ + if (options.filter) { + delete instance[i]; + continue; + } else { + errors.push({property:path,message:(typeof value) + "The property " + i + + " is not defined in the schema and the schema does not allow additional properties"}); + } + } + var requires = objTypeDef && objTypeDef[i] && objTypeDef[i].requires; + if(requires && !(requires in instance)){ + errors.push({property:path,message:"the presence of the property " + i + " requires that " + requires + " also be present"}); + } + value = instance[i]; + if(additionalProp && (!(objTypeDef && typeof objTypeDef == 'object') || !(i in objTypeDef))){ + if(options.coerce){ + value = instance[i] = options.coerce(value, additionalProp); + } + checkProp(value,additionalProp,path,i); + } + if(!_changing && value && value.$schema){ + errors = errors.concat(checkProp(value,value.$schema,path,i)); + } + } + return errors; + } + if(schema){ + checkProp(instance,schema,'',_changing || ''); + } + if(!_changing && instance && instance.$schema){ + checkProp(instance,instance.$schema,'',''); + } + return {valid:!errors.length,errors:errors}; +}; +exports.mustBeValid = function(result){ + // summary: + // This checks to ensure that the result is valid and will throw an appropriate error message if it is not + // result: the result returned from checkPropertyChange or validate + if(!result.valid){ + throw new TypeError(result.errors.map(function(error){return "for property " + error.property + ': ' + error.message;}).join(", \n")); + } +} + +return exports; +})); /***/ }), @@ -128202,7 +128202,7 @@ Emoji.replace = function replace (str, replacement, cleanSpaces) { var replaced = words.map(function(word, idx) { var emoji = Emoji.findByCode(word); - + if (emoji && cleanSpaces && words[idx + 1] === ' ') { words[idx + 1] = ''; } @@ -128518,7 +128518,7 @@ function compare (a, b) { } function generateBase (httpMethod, base_uri, params) { - // adapted from https://dev.twitter.com/docs/auth/oauth and + // adapted from https://dev.twitter.com/docs/auth/oauth and // https://dev.twitter.com/docs/auth/creating-signature // Parameter normalization @@ -145489,7 +145489,7 @@ function fileSync(options) { const name = tmpNameSync(opts); var fd = fs.openSync(name, CREATE_FLAGS, opts.mode || FILE_MODE); if (opts.discardDescriptor) { - fs.closeSync(fd); + fs.closeSync(fd); fd = undefined; } @@ -147188,4 +147188,4 @@ module.exports = require("dns"); module.exports = require("domain"); /***/ }) -/******/ ]); \ No newline at end of file +/******/ ]); diff --git a/docs-validation/1_introduction/NativeModules.tsx b/docs-validation/1_introduction/NativeModules.tsx index 792b62a47..950086200 100644 --- a/docs-validation/1_introduction/NativeModules.tsx +++ b/docs-validation/1_introduction/NativeModules.tsx @@ -16,12 +16,10 @@ import { import Clipboard from '@react-native-clipboard/clipboard'; import { CameraRoll } from '@react-native-camera-roll/camera-roll'; import RNFBMessaging from '@react-native-firebase/messaging'; -import Video from 'react-native-video'; import * as DocumentPicker from 'react-native-document-picker'; import * as FileAccess from 'react-native-file-access'; import * as ImagePicker from 'react-native-image-picker'; import * as Permissions from 'react-native-permissions'; -import * as CreateThumbnail from 'react-native-create-thumbnail'; const NativeClipboardService = createNativeClipboardService(Clipboard); const NativeNotificationService = createNativeNotificationService({ @@ -35,10 +33,7 @@ const NativeFileService = createNativeFileService({ mediaLibraryModule: CameraRoll, documentPickerModule: DocumentPicker, }); -const NativeMediaService = createNativeMediaService({ - VideoComponent: Video, - thumbnailModule: CreateThumbnail, -}); +const NativeMediaService = createNativeMediaService(); /** ------------------ **/ /** diff --git a/packages/uikit-react-native/package.json b/packages/uikit-react-native/package.json index 120ef3aa6..8281c9fd6 100644 --- a/packages/uikit-react-native/package.json +++ b/packages/uikit-react-native/package.json @@ -46,6 +46,7 @@ "@sendbird/uikit-utils": "2.2.0" }, "devDependencies": { + "@bam.tech/react-native-image-resizer": "^3.0.4", "@react-native-camera-roll/camera-roll": "^5.0.4", "@react-native-clipboard/clipboard": "^1.8.5", "@react-native-community/netinfo": "^9.3.0", @@ -59,6 +60,7 @@ "expo-clipboard": "^2.1.1", "expo-document-picker": "^10.1.3", "expo-file-system": "^13.1.4", + "expo-image-manipulator": "^11.0.0", "expo-image-picker": "^12.0.2", "expo-media-library": "^14.0.1", "expo-notifications": "^0.14.1", @@ -89,6 +91,7 @@ "expo-clipboard": ">=2.1.1", "expo-document-picker": ">=10.1.3", "expo-file-system": ">=13.1.4", + "expo-image-manipulator": ">=11.0.0", "expo-image-picker": ">=12.0.2", "expo-notifications": ">=0.14.1", "expo-video-thumbnails": ">=6.4.0", @@ -103,6 +106,9 @@ "react-native-video": ">=5.2.0" }, "peerDependenciesMeta": { + "@bam.tech/react-native-image-resizer": { + "optional": true + }, "@react-native-camera-roll/camera-roll": { "optional": true }, @@ -124,6 +130,9 @@ "expo-file-system": { "optional": true }, + "expo-image-manipulator": { + "optional": true + }, "expo-image-picker": { "optional": true }, diff --git a/packages/uikit-react-native/src/components/FileViewer.tsx b/packages/uikit-react-native/src/components/FileViewer.tsx index 5441456e9..ed9d726b0 100644 --- a/packages/uikit-react-native/src/components/FileViewer.tsx +++ b/packages/uikit-react-native/src/components/FileViewer.tsx @@ -63,10 +63,8 @@ const FileViewer = ({ const fileType = getFileType(fileMessage.type || getFileExtension(fileMessage.url)); useEffect(() => { - if (!mediaService?.VideoComponent || fileType === 'file') { - onClose(); - } - }, [mediaService]); + if (fileType === 'file') onClose(); + }, []); const fileViewer = useIIFE(() => { switch (fileType) { @@ -83,7 +81,6 @@ const FileViewer = ({ case 'video': case 'audio': { - if (!mediaService?.VideoComponent) return null; return ( { const { mediaService } = usePlatformService(); const fetchThumbnail = () => { - return mediaService?.getVideoThumbnail({ url: videoFileUrl, timeMills: 1000 }).then((result) => { + return mediaService.getVideoThumbnail({ url: videoFileUrl, timeMills: 1000 }).then((result) => { setState({ loading: false, thumbnail: result?.path ?? null }); }); }; diff --git a/packages/uikit-react-native/src/components/MessageRenderer/FileMessage/index.tsx b/packages/uikit-react-native/src/components/MessageRenderer/FileMessage/index.tsx index f4c2015f9..261669a0d 100644 --- a/packages/uikit-react-native/src/components/MessageRenderer/FileMessage/index.tsx +++ b/packages/uikit-react-native/src/components/MessageRenderer/FileMessage/index.tsx @@ -2,7 +2,6 @@ import React from 'react'; import { SendbirdFileMessage, getFileExtension, getFileType } from '@sendbird/uikit-utils'; -import { usePlatformService } from '../../../hooks/useContext'; import type { MessageRendererInterface } from '../index'; import BaseFileMessage from './BaseFileMessage'; import ImageFileMessage from './ImageFileMessage'; @@ -10,12 +9,10 @@ import VideoFileMessage from './VideoFileMessage'; export type FileMessageProps = MessageRendererInterface; const FileMessage = (props: FileMessageProps) => { - const { mediaService } = usePlatformService(); - const fileType = getFileType(props.message.type || getFileExtension(props.message.name)); if (fileType === 'image') return ; - if (fileType === 'video' && mediaService?.getVideoThumbnail) return ; + if (fileType === 'video') return ; return ; }; diff --git a/packages/uikit-react-native/src/containers/SendbirdUIKitContainer.tsx b/packages/uikit-react-native/src/containers/SendbirdUIKitContainer.tsx index a36365b09..15381425e 100644 --- a/packages/uikit-react-native/src/containers/SendbirdUIKitContainer.tsx +++ b/packages/uikit-react-native/src/containers/SendbirdUIKitContainer.tsx @@ -30,11 +30,14 @@ import type { UIKitFeaturesInSendbirdChatContext } from '../contexts/SendbirdCha import { SendbirdChatProvider } from '../contexts/SendbirdChatCtx'; import { UserProfileProvider } from '../contexts/UserProfileCtx'; import EmojiManager from '../libs/EmojiManager'; +import type { ImageCompressionConfigInterface } from '../libs/ImageCompressionConfig'; +import ImageCompressionConfig from '../libs/ImageCompressionConfig'; import InternalLocalCacheStorage from '../libs/InternalLocalCacheStorage'; import MentionConfig, { MentionConfigInterface } from '../libs/MentionConfig'; import MentionManager from '../libs/MentionManager'; import StringSetEn from '../localization/StringSet.en'; import type { StringSet } from '../localization/StringSet.type'; +import createNativeMediaService from '../platform/createMediaService.native'; import SBUDynamicModule from '../platform/dynamicModule'; import type { ClipboardServiceInterface, @@ -57,6 +60,7 @@ export const SendbirdUIKit = Object.freeze({ CHANNEL_LIST_MESSAGE_RECEIPT_STATUS: false, USE_USER_ID_FOR_NICKNAME: false, USER_MENTION: false, + IMAGE_COMPRESSION: true, }, }); @@ -82,6 +86,10 @@ export type SendbirdUIKitContainerProps = React.PropsWithChildren<{ defaultHeaderHeight?: number; HeaderComponent?: HeaderStyleContextType['HeaderComponent']; }; + errorBoundary?: { + onError?: (props: ErrorBoundaryProps) => void; + ErrorInfoComponent?: (props: ErrorBoundaryProps) => JSX.Element; + }; toast?: { dismissTimeout?: number; }; @@ -93,10 +101,7 @@ export type SendbirdUIKitContainerProps = React.PropsWithChildren<{ ) => SendbirdGroupChannelCreateParams | Promise; }; userMention?: Pick, 'mentionLimit' | 'suggestionLimit' | 'debounceMills'>; - errorBoundary?: { - onError?: (props: ErrorBoundaryProps) => void; - ErrorInfoComponent?: (props: ErrorBoundaryProps) => JSX.Element; - }; + imageCompression?: ImageCompressionConfigInterface; }>; const SendbirdUIKitContainer = ({ @@ -106,10 +111,11 @@ const SendbirdUIKitContainer = ({ platformServices, localization, styles, + errorBoundary, toast, userProfile, userMention, - errorBoundary, + imageCompression, }: SendbirdUIKitContainerProps) => { const defaultStringSet = localization?.stringSet ?? StringSetEn; @@ -125,7 +131,9 @@ const SendbirdUIKitContainer = ({ unsubscribes.current = sendbird.unsubscribes; return sendbird.chatSDK; }); + const emojiManager = useMemo(() => new EmojiManager(internalStorage), [internalStorage]); + const mentionManager = useMemo(() => { const config = new MentionConfig({ mentionLimit: userMention?.mentionLimit || MentionConfig.DEFAULT.MENTION_LIMIT, @@ -137,6 +145,16 @@ const SendbirdUIKitContainer = ({ return new MentionManager(config, chatOptions?.enableUserMention ?? SendbirdUIKit.DEFAULT.USER_MENTION); }, [userMention?.mentionLimit, userMention?.suggestionLimit, userMention?.debounceMills]); + const imageCompressionConfig = useMemo( + () => + new ImageCompressionConfig({ + compressionRate: imageCompression?.compressionRate || ImageCompressionConfig.DEFAULT.COMPRESSION_RATE, + width: imageCompression?.width, + height: imageCompression?.height, + }), + [imageCompression], + ); + useLayoutEffect(() => { if (!isFirstMount) { const sendbird = initializeSendbird(appId, internalStorage, chatOptions?.onInitialized); @@ -161,6 +179,7 @@ const SendbirdUIKitContainer = ({ sdkInstance={sdkInstance} emojiManager={emojiManager} mentionManager={mentionManager} + imageCompressionConfig={imageCompressionConfig} enableAutoPushTokenRegistration={ chatOptions?.enableAutoPushTokenRegistration ?? SendbirdUIKit.DEFAULT.AUTO_PUSH_TOKEN_REGISTRATION } @@ -175,13 +194,14 @@ const SendbirdUIKitContainer = ({ chatOptions?.enableUseUserIdForNickname ?? SendbirdUIKit.DEFAULT.USE_USER_ID_FOR_NICKNAME } enableUserMention={chatOptions?.enableUserMention ?? SendbirdUIKit.DEFAULT.USER_MENTION} + enableImageCompression={chatOptions?.enableImageCompression ?? SendbirdUIKit.DEFAULT.IMAGE_COMPRESSION} > ; export const PlatformServiceContext = React.createContext(null); diff --git a/packages/uikit-react-native/src/contexts/SendbirdChatCtx.tsx b/packages/uikit-react-native/src/contexts/SendbirdChatCtx.tsx index 194afc0c7..29d39b732 100644 --- a/packages/uikit-react-native/src/contexts/SendbirdChatCtx.tsx +++ b/packages/uikit-react-native/src/contexts/SendbirdChatCtx.tsx @@ -11,6 +11,7 @@ import type { import { confirmAndMarkAsDelivered, useForceUpdate } from '@sendbird/uikit-utils'; import type EmojiManager from '../libs/EmojiManager'; +import type ImageCompressionConfig from '../libs/ImageCompressionConfig'; import type MentionManager from '../libs/MentionManager'; import type { FileType } from '../platform/types'; @@ -20,18 +21,21 @@ export interface UIKitFeaturesInSendbirdChatContext { enableChannelListMessageReceiptStatus: boolean; enableUseUserIdForNickname: boolean; enableUserMention: boolean; + enableImageCompression: boolean; } interface Props extends UIKitFeaturesInSendbirdChatContext, React.PropsWithChildren { sdkInstance: SendbirdChatSDK; emojiManager: EmojiManager; mentionManager: MentionManager; + imageCompressionConfig: ImageCompressionConfig; } type Context = { sdk: SendbirdChatSDK; emojiManager: EmojiManager; mentionManager: MentionManager; + imageCompressionConfig: ImageCompressionConfig; currentUser?: SendbirdUser; setCurrentUser: React.Dispatch>; @@ -46,6 +50,7 @@ type Context = { channelListMessageReceiptStatusEnabled: boolean; useUserIdForNicknameEnabled: boolean; userMentionEnabled: boolean; + imageCompressionEnabled: boolean; // Sendbird application features deliveryReceiptEnabled: boolean; @@ -61,11 +66,13 @@ export const SendbirdChatProvider = ({ sdkInstance, emojiManager, mentionManager, + imageCompressionConfig, enableAutoPushTokenRegistration, enableChannelListMessageReceiptStatus, enableChannelListTypingIndicator, enableUseUserIdForNickname, enableUserMention, + enableImageCompression, }: Props) => { const [currentUser, _setCurrentUser] = useState(); const forceUpdate = useForceUpdate(); @@ -131,6 +138,7 @@ export const SendbirdChatProvider = ({ sdk: sdkInstance, emojiManager, mentionManager, + imageCompressionConfig, currentUser, setCurrentUser, @@ -144,6 +152,7 @@ export const SendbirdChatProvider = ({ channelListMessageReceiptStatusEnabled: enableChannelListMessageReceiptStatus, useUserIdForNicknameEnabled: enableUseUserIdForNickname, userMentionEnabled: enableUserMention, + imageCompressionEnabled: enableImageCompression, }, }; diff --git a/packages/uikit-react-native/src/domain/groupChannel/component/GroupChannelInput/SendInput.tsx b/packages/uikit-react-native/src/domain/groupChannel/component/GroupChannelInput/SendInput.tsx index aa49e1f3a..141b2eff2 100644 --- a/packages/uikit-react-native/src/domain/groupChannel/component/GroupChannelInput/SendInput.tsx +++ b/packages/uikit-react-native/src/domain/groupChannel/component/GroupChannelInput/SendInput.tsx @@ -18,7 +18,7 @@ import { useToast, useUIKitTheme, } from '@sendbird/uikit-react-native-foundation'; -import { conditionChaining } from '@sendbird/uikit-utils'; +import { conditionChaining, isImage, shouldCompressImage } from '@sendbird/uikit-utils'; import { useLocalization, usePlatformService, useSendbirdChat } from '../../../../hooks/useContext'; import SBUError from '../../../../libs/SBUError'; @@ -49,9 +49,9 @@ const SendInput = forwardRef(function SendInput( }, ref, ) { - const { mentionManager } = useSendbirdChat(); + const { mentionManager, imageCompressionConfig, features } = useSendbirdChat(); const { STRINGS } = useLocalization(); - const { fileService } = usePlatformService(); + const { fileService, mediaService } = usePlatformService(); const { colors } = useUIKitTheme(); const { openSheet } = useBottomSheet(); const { alert } = useAlert(); @@ -75,7 +75,7 @@ const SendInput = forwardRef(function SendInput( title: STRINGS.GROUP_CHANNEL.DIALOG_ATTACHMENT_CAMERA, icon: 'camera', onPress: async () => { - const photo = await fileService.openCamera({ + const mediaFile = await fileService.openCamera({ mediaType: 'all', onOpenFailure: (error) => { if (error.code === SBUError.CODE.ERR_PERMISSIONS_DENIED) { @@ -93,8 +93,28 @@ const SendInput = forwardRef(function SendInput( }, }); - if (photo) { - onSendFileMessage(photo).catch(() => toast.show(STRINGS.TOAST.SEND_MSG_ERROR, 'error')); + if (mediaFile) { + // Image compression + if ( + isImage(mediaFile.uri, mediaFile.type) && + shouldCompressImage(mediaFile.uri, features.imageCompressionEnabled) + ) { + await SBUUtils.safeRun(async () => { + const compressed = await mediaService.compressImage({ + path: mediaFile.uri, + maxWidth: imageCompressionConfig.width, + maxHeight: imageCompressionConfig.height, + compressionRate: imageCompressionConfig.compressionRate, + }); + + if (compressed) { + mediaFile.uri = compressed.path; + mediaFile.size = compressed.size; + } + }); + } + + onSendFileMessage(mediaFile).catch(() => toast.show(STRINGS.TOAST.SEND_MSG_ERROR, 'error')); } }, }, @@ -102,7 +122,7 @@ const SendInput = forwardRef(function SendInput( title: STRINGS.GROUP_CHANNEL.DIALOG_ATTACHMENT_PHOTO_LIBRARY, icon: 'photo', onPress: async () => { - const photo = await fileService.openMediaLibrary({ + const mediaFiles = await fileService.openMediaLibrary({ selectionLimit: 1, mediaType: 'all', onOpenFailure: (error) => { @@ -121,8 +141,30 @@ const SendInput = forwardRef(function SendInput( }, }); - if (photo && photo[0]) { - onSendFileMessage(photo[0]).catch(() => toast.show(STRINGS.TOAST.SEND_MSG_ERROR, 'error')); + if (mediaFiles && mediaFiles[0]) { + const mediaFile = mediaFiles[0]; + + // Image compression + if ( + isImage(mediaFile.uri, mediaFile.type) && + shouldCompressImage(mediaFile.uri, features.imageCompressionEnabled) + ) { + await SBUUtils.safeRun(async () => { + const compressed = await mediaService.compressImage({ + path: mediaFile.uri, + maxWidth: imageCompressionConfig.width, + maxHeight: imageCompressionConfig.height, + compressionRate: imageCompressionConfig.compressionRate, + }); + + if (compressed) { + mediaFile.uri = compressed.path; + mediaFile.size = compressed.size; + } + }); + } + + onSendFileMessage(mediaFiles[0]).catch(() => toast.show(STRINGS.TOAST.SEND_MSG_ERROR, 'error')); } }, }, @@ -130,12 +172,32 @@ const SendInput = forwardRef(function SendInput( title: STRINGS.GROUP_CHANNEL.DIALOG_ATTACHMENT_FILES, icon: 'document', onPress: async () => { - const file = await fileService.openDocument({ + const documentFile = await fileService.openDocument({ onOpenFailure: () => toast.show(STRINGS.TOAST.OPEN_FILES_ERROR, 'error'), }); - if (file) { - onSendFileMessage(file).catch(() => toast.show(STRINGS.TOAST.SEND_MSG_ERROR, 'error')); + if (documentFile) { + // Image compression + if ( + isImage(documentFile.uri, documentFile.type) && + shouldCompressImage(documentFile.uri, features.imageCompressionEnabled) + ) { + await SBUUtils.safeRun(async () => { + const compressed = await mediaService.compressImage({ + path: documentFile.uri, + maxWidth: imageCompressionConfig.width, + maxHeight: imageCompressionConfig.height, + compressionRate: imageCompressionConfig.compressionRate, + }); + + if (compressed) { + documentFile.uri = compressed.path; + documentFile.size = compressed.size; + } + }); + } + + onSendFileMessage(documentFile).catch(() => toast.show(STRINGS.TOAST.SEND_MSG_ERROR, 'error')); } }, }, diff --git a/packages/uikit-react-native/src/libs/ImageCompressionConfig.ts b/packages/uikit-react-native/src/libs/ImageCompressionConfig.ts new file mode 100644 index 000000000..97ee41b52 --- /dev/null +++ b/packages/uikit-react-native/src/libs/ImageCompressionConfig.ts @@ -0,0 +1,27 @@ +export interface ImageCompressionConfigInterface { + compressionRate: number; + width?: number; + height?: number; +} + +class ImageCompressionConfig { + static DEFAULT = { + COMPRESSION_RATE: 0.7, + }; + + constructor(private _config: ImageCompressionConfigInterface) {} + + get compressionRate() { + return this._config.compressionRate; + } + + get width() { + return this._config.width; + } + + get height() { + return this._config.height; + } +} + +export default ImageCompressionConfig; diff --git a/packages/uikit-react-native/src/platform/createMediaService.expo.tsx b/packages/uikit-react-native/src/platform/createMediaService.expo.tsx index b9ec0fcbd..537ff6d71 100644 --- a/packages/uikit-react-native/src/platform/createMediaService.expo.tsx +++ b/packages/uikit-react-native/src/platform/createMediaService.expo.tsx @@ -1,15 +1,27 @@ import type * as ExpoAV from 'expo-av'; +import type * as ExpoFS from 'expo-file-system'; +import type * as ExpoImageManipulator from 'expo-image-manipulator'; import type * as ExpoVideoThumbnail from 'expo-video-thumbnails'; import React from 'react'; +import { getDownscaleSize } from '@sendbird/uikit-utils'; + +import SBUUtils from '../libs/SBUUtils'; import type { MediaServiceInterface } from './types'; type Modules = { avModule: typeof ExpoAV; thumbnailModule: typeof ExpoVideoThumbnail; + imageManipulator: typeof ExpoImageManipulator; + fsModule: typeof ExpoFS; }; -const createExpoMediaService = ({ avModule, thumbnailModule }: Modules): MediaServiceInterface => { +const createExpoMediaService = ({ + avModule, + thumbnailModule, + imageManipulator, + fsModule, +}: Modules): MediaServiceInterface => { return { VideoComponent({ source, resizeMode, onLoad, ...props }) { // FIXME: type error https://github.com/expo/expo/issues/17101 @@ -24,6 +36,17 @@ const createExpoMediaService = ({ avModule, thumbnailModule }: Modules): MediaSe return null; } }, + async compressImage({ maxWidth, maxHeight, compressionRate = 1, path }) { + const originSize = await SBUUtils.getImageSize(path); + const resizingSize = getDownscaleSize(originSize, { width: maxWidth, height: maxHeight }); + + const { uri } = await imageManipulator.manipulateAsync(path, [{ resize: resizingSize }], { + compress: Math.min(Math.max(0, compressionRate), 1), + }); + const { size = 0 } = await fsModule.getInfoAsync(uri); + + return { path: uri, size }; + }, }; }; diff --git a/packages/uikit-react-native/src/platform/createMediaService.native.tsx b/packages/uikit-react-native/src/platform/createMediaService.native.tsx index d12bacdc6..d528ff1f8 100644 --- a/packages/uikit-react-native/src/platform/createMediaService.native.tsx +++ b/packages/uikit-react-native/src/platform/createMediaService.native.tsx @@ -1,26 +1,28 @@ import React from 'react'; -import type * as CreateThumbnail from 'react-native-create-thumbnail'; -import type Video from 'react-native-video'; +import { getDownscaleSize, getFileExtension, hash } from '@sendbird/uikit-utils'; + +import SBUUtils from '../libs/SBUUtils'; +import SBUDynamicModule from './dynamicModule'; import type { MediaServiceInterface } from './types'; type Modules = { - VideoComponent: typeof Video; - thumbnailModule: typeof CreateThumbnail; + VideoComponent?: unknown; + thumbnailModule?: unknown; }; -function hash(str: string) { - return String(Math.abs(str.split('').reduce((a, c) => ((a << 5) - a + c.charCodeAt(0)) | 0, 0))); -} +const createNativeMediaService = (_?: Modules): MediaServiceInterface => { + const Thumbnail = SBUDynamicModule.get('react-native-create-thumbnail'); + const Video = SBUDynamicModule.get('react-native-video'); + const ImageResizer = SBUDynamicModule.get('@bam.tech/react-native-image-resizer'); -const createNativeMediaService = ({ VideoComponent, thumbnailModule }: Modules): MediaServiceInterface => { return { VideoComponent({ source, resizeMode, onLoad, ...props }) { - return ; + return ; }, async getVideoThumbnail({ url, timeMills }) { try { - const { path } = await thumbnailModule.createThumbnail({ + const { path } = await Thumbnail.createThumbnail({ url, format: 'jpeg', timeStamp: timeMills, @@ -31,6 +33,23 @@ const createNativeMediaService = ({ VideoComponent, thumbnailModule }: Modules): return null; } }, + async compressImage({ path, maxWidth, maxHeight, compressionRate = 1 }) { + const originSize = await SBUUtils.getImageSize(path); + const { width, height } = getDownscaleSize(originSize, { width: maxWidth, height: maxHeight }); + const extension = (() => { + return { 'png': 'PNG', 'jpeg': 'JPEG', 'jpg': 'JPEG' }[getFileExtension(path)] ?? 'JPEG'; + })() as 'PNG' | 'JPEG'; + + const { path: resizedPath, size: resizedSize } = await ImageResizer.default.createResizedImage( + path, + width, + height, + extension, + Math.min(Math.max(0, compressionRate), 1) * 100, + ); + + return { path: resizedPath, size: resizedSize }; + }, }; }; diff --git a/packages/uikit-react-native/src/platform/dynamicModule.ts b/packages/uikit-react-native/src/platform/dynamicModule.ts index ddeeaaeb6..cecbe2834 100644 --- a/packages/uikit-react-native/src/platform/dynamicModule.ts +++ b/packages/uikit-react-native/src/platform/dynamicModule.ts @@ -1,43 +1,39 @@ /* eslint-disable no-console */ -import type RNNetInfo from '@react-native-community/netinfo'; -import { NativeModules } from 'react-native'; -import type RNFastImage from 'react-native-fast-image'; -import type RNFileAccess from 'react-native-file-access'; +import type * as RNImageResizer from '@bam.tech/react-native-image-resizer'; +import type * as RNNetInfo from '@react-native-community/netinfo'; +import { NativeModules, UIManager } from 'react-native'; +import type * as CreateThumbnail from 'react-native-create-thumbnail'; +import type * as RNFileAccess from 'react-native-file-access'; +import type * as Permissions from 'react-native-permissions'; +import type * as Video from 'react-native-video'; import { Logger } from '@sendbird/uikit-utils'; export interface DynamicModules { - 'react-native-file-access': typeof RNFileAccess; - 'react-native-fast-image': typeof RNFastImage; '@react-native-community/netinfo': typeof RNNetInfo; + '@bam.tech/react-native-image-resizer': typeof RNImageResizer; + 'react-native-create-thumbnail': typeof CreateThumbnail; + 'react-native-video': typeof Video; + 'react-native-permissions': typeof Permissions; + 'react-native-file-access': typeof RNFileAccess; } + export type SBUNativeModule = keyof DynamicModules; interface SBUDynamicModuleInfo { packageName: SBUNativeModule; - minVersion: string; - moduleName: string; + nativeModuleNamespace: string; getPackage: (logLevel: 'error' | 'warn' | 'none') => T; url: string; -} - -export function checkVersion(minVersion: string, currentVersion: string) { - const [minMajor, minMinor, minPatch] = minVersion.split('.'); - const [currMajor, currMinor, currPatch] = currentVersion.split('.'); - - if (minMajor < currMajor) return true; - if (minMajor === currMajor) { - if (minMinor < currMinor) return true; - if (minMinor === currMinor) { - return minPatch <= currPatch; - } - return false; - } - return false; + isComponent?: boolean; } function checkLink(dmi: SBUDynamicModuleInfo, logLevel: 'error' | 'warn' | 'none') { - const nativeModule = NativeModules[dmi.moduleName]; + const nativeModule = (() => { + if (dmi.isComponent) return UIManager.getViewManagerConfig(dmi.nativeModuleNamespace); + else return NativeModules[dmi.nativeModuleNamespace]; + })(); + if (!nativeModule) { const message = `[UIKit] Cannot use native module, you should install and link ${dmi.packageName} (${dmi.url})`; if (logLevel === 'error') console.error(message); @@ -47,9 +43,8 @@ function checkLink(dmi: SBUDynamicModuleInfo, logLevel: 'error' | 'warn' | 'none const SBUDynamicModuleRegistry: Record = { 'react-native-file-access': { - minVersion: '2.4.3', packageName: 'react-native-file-access', - moduleName: 'RNFileAccess', + nativeModuleNamespace: 'RNFileAccess', url: 'https://github.com/alpha0010/react-native-file-access', getPackage(logLevel) { checkLink(this, logLevel); @@ -61,25 +56,66 @@ const SBUDynamicModuleRegistry: Record = } }, }, - 'react-native-fast-image': { - minVersion: '8.5.11', - packageName: 'react-native-fast-image', - moduleName: 'FastImageView', - url: 'https://github.com/DylanVann/react-native-fast-image', + 'react-native-permissions': { + packageName: 'react-native-permissions', + nativeModuleNamespace: 'RNPermissions', + url: 'https://github.com/zoontek/react-native-permissions', + getPackage(logLevel) { + checkLink(this, logLevel); + + try { + return require('react-native-permissions'); + } catch (e) { + return null; + } + }, + }, + 'react-native-video': { + packageName: 'react-native-video', + nativeModuleNamespace: 'RCTVideo', + isComponent: true, + url: 'https://github.com/react-native-video/react-native-video', + getPackage(logLevel) { + checkLink(this, logLevel); + + try { + return require('react-native-video'); + } catch (e) { + return null; + } + }, + }, + 'react-native-create-thumbnail': { + packageName: 'react-native-create-thumbnail', + nativeModuleNamespace: 'CreateThumbnail', + url: 'https://github.com/souvik-ghosh/react-native-create-thumbnail', + getPackage(logLevel) { + checkLink(this, logLevel); + + try { + return require('react-native-create-thumbnail'); + } catch (e) { + return null; + } + }, + }, + '@bam.tech/react-native-image-resizer': { + packageName: '@bam.tech/react-native-image-resizer', + nativeModuleNamespace: 'ImageResizer', + url: 'https://github.com/bamlab/react-native-image-resizer', getPackage(logLevel) { checkLink(this, logLevel); try { - return require('react-native-fast-image'); + return require('@bam.tech/react-native-image-resizer'); } catch (e) { return null; } }, }, '@react-native-community/netinfo': { - minVersion: '9.3.0', packageName: '@react-native-community/netinfo', - moduleName: 'RNCNetInfo', + nativeModuleNamespace: 'RNCNetInfo', url: 'https://github.com/react-native-netinfo/react-native-netinfo', getPackage(logLevel) { checkLink(this, logLevel); @@ -95,7 +131,7 @@ const SBUDynamicModuleRegistry: Record = const SBUDynamicModule = { register(mdi: SBUDynamicModuleInfo) { - SBUDynamicModuleRegistry[mdi.moduleName as SBUNativeModule] = mdi; + SBUDynamicModuleRegistry[mdi.nativeModuleNamespace as SBUNativeModule] = mdi; }, getInfo(name: SBUNativeModule) { return SBUDynamicModuleRegistry[name] ?? null; diff --git a/packages/uikit-react-native/src/platform/types.ts b/packages/uikit-react-native/src/platform/types.ts index 8a799e27c..c1c7d7b5d 100644 --- a/packages/uikit-react-native/src/platform/types.ts +++ b/packages/uikit-react-native/src/platform/types.ts @@ -66,13 +66,35 @@ interface GetVideoThumbnailOptions { timeMills?: number; quality?: number; } + +interface CompressImageOptions { + /** + * A path of image file to compress + * */ + path: string; + + /** + * A resize width, apply only to downscale + * */ + maxWidth?: number; + + /** + * A resize height, apply only to downscale + * */ + maxHeight?: number; + + /** + * A value in range 0.0 - 1.0 specifying compression level of the result image. + * 1 means highest quality and 0 the lowest quality. + * */ + compressionRate?: number; +} + +type GetVideoThumbnailResult = Promise<{ path: string } | null>; +type CompressImageResult = Promise<{ path: string; size: number } | null>; + export interface MediaServiceInterface { VideoComponent(props: VideoProps & Props): JSX.Element; - getVideoThumbnail(options: GetVideoThumbnailOptions): Promise<{ path: string } | null>; - // compressImage(options: { - // path: string; - // compressionRate: number; - // resizingWidth: number; - // resizingHeight: number; - // }): Promise<{ path: string }>; + getVideoThumbnail(options: GetVideoThumbnailOptions): GetVideoThumbnailResult; + compressImage(options: CompressImageOptions): CompressImageResult; } diff --git a/sample/ios/Podfile.lock b/sample/ios/Podfile.lock index 303430abc..50a282b26 100644 --- a/sample/ios/Podfile.lock +++ b/sample/ios/Podfile.lock @@ -357,6 +357,8 @@ PODS: - ZIPFoundation (= 0.9.11) - react-native-image-picker (4.8.4): - React-Core + - react-native-image-resizer (3.0.4): + - React-Core - react-native-netinfo (9.3.0): - React-Core - react-native-safe-area-context (3.4.1): @@ -526,6 +528,7 @@ DEPENDENCIES: - react-native-document-picker (from `../node_modules/react-native-document-picker`) - react-native-file-access (from `../node_modules/react-native-file-access`) - react-native-image-picker (from `../node_modules/react-native-image-picker`) + - "react-native-image-resizer (from `../node_modules/@bam.tech/react-native-image-resizer`)" - "react-native-netinfo (from `../../node_modules/@react-native-community/netinfo`)" - react-native-safe-area-context (from `../../node_modules/react-native-safe-area-context`) - "react-native-slider (from `../node_modules/@react-native-community/slider`)" @@ -640,6 +643,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native-file-access" react-native-image-picker: :path: "../node_modules/react-native-image-picker" + react-native-image-resizer: + :path: "../node_modules/@bam.tech/react-native-image-resizer" react-native-netinfo: :path: "../../node_modules/@react-native-community/netinfo" react-native-safe-area-context: @@ -748,6 +753,7 @@ SPEC CHECKSUMS: react-native-document-picker: f68191637788994baed5f57d12994aa32cf8bf88 react-native-file-access: 204693d308701ba232dcf91facef05498fcde9a2 react-native-image-picker: cffb727cf2f59bd5c0408e30b3dbe0b935f88835 + react-native-image-resizer: 794abf75ec13ed1f0dbb1f134e27504ea65e9e66 react-native-netinfo: 129bd99f607a2dc5bb096168f3e5c150fd1f1c95 react-native-safe-area-context: 9e40fb181dac02619414ba1294d6c2a807056ab9 react-native-slider: cecabb58ecffad671d2ad3ccc58c7f4d2d029e95 diff --git a/sample/package.json b/sample/package.json index c3a11b48b..ee30a3e16 100644 --- a/sample/package.json +++ b/sample/package.json @@ -14,6 +14,7 @@ "storybook-watcher": "sb-rn-watcher" }, "dependencies": { + "@bam.tech/react-native-image-resizer": "^3.0.4", "@faker-js/faker": "^6.0.0-alpha.7", "@notifee/react-native": "^5.3.0", "@react-native-async-storage/async-storage": "^1.15.17", diff --git a/sample/src/factory/index.ts b/sample/src/factory/index.ts index 090be15c1..258363e21 100644 --- a/sample/src/factory/index.ts +++ b/sample/src/factory/index.ts @@ -4,12 +4,10 @@ import RNFBMessaging from '@react-native-firebase/messaging'; import { createNativeStackNavigator } from '@react-navigation/native-stack'; import axios from 'axios'; import { Platform, StatusBar } from 'react-native'; -import * as CreateThumbnail from 'react-native-create-thumbnail'; import * as DocumentPicker from 'react-native-document-picker'; import * as FileAccess from 'react-native-file-access'; import * as ImagePicker from 'react-native-image-picker'; import * as Permissions from 'react-native-permissions'; -import Video from 'react-native-video'; import { createNativeClipboardService, @@ -38,7 +36,7 @@ export const FileService = createNativeFileService({ fsModule: FileAccess, mediaLibraryModule: CameraRoll, }); -export const MediaService = createNativeMediaService({ VideoComponent: Video, thumbnailModule: CreateThumbnail }); +export const MediaService = createNativeMediaService(); export const GetTranslucent = (state = true) => { Platform.OS === 'android' && StatusBar.setTranslucent(state); diff --git a/yarn.lock b/yarn.lock index 7d07431de..7e4d752a4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1186,6 +1186,11 @@ "@babel/helper-validator-identifier" "^7.18.6" to-fast-properties "^2.0.0" +"@bam.tech/react-native-image-resizer@^3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@bam.tech/react-native-image-resizer/-/react-native-image-resizer-3.0.4.tgz#3e127818e88df89e5c51a07e2556bf6ef872df26" + integrity sha512-p2Ecs469bntk4Ke4CEYyEoVBKBT+8JyaXXPz4Fm55s9G+jEg99p1V9MHkza2k7OAq1iUF8oAtZ/wZ9zKn6b43Q== + "@bcoe/v8-coverage@^0.2.3": version "0.2.3" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" @@ -7487,6 +7492,18 @@ expo-file-system@^13.1.4: "@expo/config-plugins" "^4.0.14" uuid "^3.4.0" +expo-image-loader@~4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/expo-image-loader/-/expo-image-loader-4.0.0.tgz#a17e5f95a4c1671791168dd5dfc221bf2f88480c" + integrity sha512-hVMhXagsO1cSng5s70IEjuJAuHy2hX/inu5MM3T0ecJMf7L/7detKf22molQBRymerbk6Tzu+20h11eU0n/3jQ== + +expo-image-manipulator@^11.0.0: + version "11.0.0" + resolved "https://registry.yarnpkg.com/expo-image-manipulator/-/expo-image-manipulator-11.0.0.tgz#f863bfcbc1534d92e9efc6f9265cf152cf7988c1" + integrity sha512-CDiqOrhN1TSWw/4t7Xo97U+Xzoc437oCHbZH7+4RhhmPBlu5/2b4UjoEiw/gPWu9DD7OS/TRvO027axod9QNDQ== + dependencies: + expo-image-loader "~4.0.0" + expo-image-picker@^12.0.2: version "12.0.2" resolved "https://registry.yarnpkg.com/expo-image-picker/-/expo-image-picker-12.0.2.tgz#4789c5419208ff8ede557784368a7f18f3878c30"