diff --git a/package.json b/package.json index a583a6a4209ef..0998279bd6545 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "rollup-plugin-alias": "^1.4.0", "rollup-plugin-babel": "^4.0.3", "rollup-plugin-commonjs": "^9.1.6", - "rollup-plugin-node-resolve": "^3.4.0", + "rollup-plugin-node-resolve": "^4.2.3", "rollup-plugin-replace": "^2.0.0", "rollup-plugin-uglify": "^5.0.2" }, diff --git a/packages/cubejs-client-core/dist/cubejs-client-core.js b/packages/cubejs-client-core/dist/cubejs-client-core.js index 8c2d24d064ac2..c3603cd7ababd 100644 --- a/packages/cubejs-client-core/dist/cubejs-client-core.js +++ b/packages/cubejs-client-core/dist/cubejs-client-core.js @@ -30,7 +30,7 @@ var _regeneratorRuntime = _interopDefault(require('@babel/runtime/regenerator')) require('regenerator-runtime/runtime'); var _asyncToGenerator = _interopDefault(require('@babel/runtime/helpers/asyncToGenerator')); require('core-js/modules/es6.promise'); -var whatwgFetch = require('whatwg-fetch'); +require('isomorphic-fetch'); var moment = momentRange.extendMoment(Moment); var TIME_SERIES = { @@ -634,7 +634,8 @@ function () { _createClass(CubejsApi, [{ key: "request", value: function request(url, config) { - return whatwgFetch.fetch("".concat(this.apiUrl).concat(url), Object.assign({ + // eslint-disable-next-line no-undef + return fetch("".concat(this.apiUrl).concat(url), Object.assign({ headers: { Authorization: this.apiToken, 'Content-Type': 'application/json' @@ -727,7 +728,7 @@ function () { return _context.stop(); } } - }, _callee); + }, _callee, this); })); return function loadImpl() { diff --git a/packages/cubejs-client-core/dist/cubejs-client-core.umd.js b/packages/cubejs-client-core/dist/cubejs-client-core.umd.js index f074d33105814..01828950c4821 100644 --- a/packages/cubejs-client-core/dist/cubejs-client-core.umd.js +++ b/packages/cubejs-client-core/dist/cubejs-client-core.umd.js @@ -11,7 +11,7 @@ } function unwrapExports (x) { - return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x.default : x; + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } function createCommonjsModule(fn, module) { @@ -19,7 +19,7 @@ } var _core = createCommonjsModule(function (module) { - var core = module.exports = { version: '2.6.5' }; + var core = module.exports = { version: '2.5.7' }; if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef }); var _core_1 = _core.version; @@ -44,7 +44,7 @@ })('versions', []).push({ version: _core.version, mode: _library ? 'pure' : 'global', - copyright: '© 2019 Denis Pushkarev (zloirock.ru)' + copyright: '© 2018 Denis Pushkarev (zloirock.ru)' }); }); @@ -193,16 +193,14 @@ return hasOwnProperty.call(it, key); }; - var _functionToString = _shared('native-function-to-string', Function.toString); - var _redefine = createCommonjsModule(function (module) { var SRC = _uid('src'); - var TO_STRING = 'toString'; - var TPL = ('' + _functionToString).split(TO_STRING); + var $toString = Function[TO_STRING]; + var TPL = ('' + $toString).split(TO_STRING); _core.inspectSource = function (it) { - return _functionToString.call(it); + return $toString.call(it); }; (module.exports = function (O, key, val, safe) { @@ -222,7 +220,7 @@ } // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative })(Function.prototype, TO_STRING, function toString() { - return typeof this == 'function' && this[SRC] || _functionToString.call(this); + return typeof this == 'function' && this[SRC] || $toString.call(this); }); }); @@ -2670,201 +2668,43 @@ _export(_export.S + _export.F, 'Object', { assign: _objectAssign }); - // true -> String#at - // false -> String#codePointAt - var _stringAt = function (TO_STRING) { - return function (that, pos) { - var s = String(_defined(that)); - var i = _toInteger(pos); - var l = s.length; - var a, b; - if (i < 0 || i >= l) return TO_STRING ? '' : undefined; - a = s.charCodeAt(i); - return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff - ? TO_STRING ? s.charAt(i) : a - : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; - }; - }; - - var at = _stringAt(true); + var arraySlice = [].slice; + var factories = {}; - // `AdvanceStringIndex` abstract operation - // https://tc39.github.io/ecma262/#sec-advancestringindex - var _advanceStringIndex = function (S, index, unicode) { - return index + (unicode ? at(S, index).length : 1); + var construct = function (F, len, args) { + if (!(len in factories)) { + for (var n = [], i = 0; i < len; i++) n[i] = 'a[' + i + ']'; + // eslint-disable-next-line no-new-func + factories[len] = Function('F,a', 'return new F(' + n.join(',') + ')'); + } return factories[len](F, args); }; - var builtinExec = RegExp.prototype.exec; - - // `RegExpExec` abstract operation - // https://tc39.github.io/ecma262/#sec-regexpexec - var _regexpExecAbstract = function (R, S) { - var exec = R.exec; - if (typeof exec === 'function') { - var result = exec.call(R, S); - if (typeof result !== 'object') { - throw new TypeError('RegExp exec method returned something other than an Object or null'); - } - return result; - } - if (_classof(R) !== 'RegExp') { - throw new TypeError('RegExp#exec called on incompatible receiver'); - } - return builtinExec.call(R, S); - }; - - // 21.2.5.3 get RegExp.prototype.flags - - var _flags = function () { - var that = _anObject(this); - var result = ''; - if (that.global) result += 'g'; - if (that.ignoreCase) result += 'i'; - if (that.multiline) result += 'm'; - if (that.unicode) result += 'u'; - if (that.sticky) result += 'y'; - return result; - }; - - var nativeExec = RegExp.prototype.exec; - // This always refers to the native implementation, because the - // String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js, - // which loads this file before patching the method. - var nativeReplace = String.prototype.replace; - - var patchedExec = nativeExec; - - var LAST_INDEX = 'lastIndex'; - - var UPDATES_LAST_INDEX_WRONG = (function () { - var re1 = /a/, - re2 = /b*/g; - nativeExec.call(re1, 'a'); - nativeExec.call(re2, 'a'); - return re1[LAST_INDEX] !== 0 || re2[LAST_INDEX] !== 0; - })(); - - // nonparticipating capturing group, copied from es5-shim's String#split patch. - var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; - - var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED; - - if (PATCH) { - patchedExec = function exec(str) { - var re = this; - var lastIndex, reCopy, match, i; - - if (NPCG_INCLUDED) { - reCopy = new RegExp('^' + re.source + '$(?!\\s)', _flags.call(re)); - } - if (UPDATES_LAST_INDEX_WRONG) lastIndex = re[LAST_INDEX]; - - match = nativeExec.call(re, str); - - if (UPDATES_LAST_INDEX_WRONG && match) { - re[LAST_INDEX] = re.global ? match.index + match[0].length : lastIndex; - } - if (NPCG_INCLUDED && match && match.length > 1) { - // Fix browsers whose `exec` methods don't consistently return `undefined` - // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/ - // eslint-disable-next-line no-loop-func - nativeReplace.call(match[0], reCopy, function () { - for (i = 1; i < arguments.length - 2; i++) { - if (arguments[i] === undefined) match[i] = undefined; - } - }); - } - - return match; + var _bind = Function.bind || function bind(that /* , ...args */) { + var fn = _aFunction(this); + var partArgs = arraySlice.call(arguments, 1); + var bound = function (/* args... */) { + var args = partArgs.concat(arraySlice.call(arguments)); + return this instanceof bound ? construct(fn, args.length, args) : _invoke(fn, args, that); }; - } + if (_isObject(fn.prototype)) bound.prototype = fn.prototype; + return bound; + }; - var _regexpExec = patchedExec; + // 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg, args...) - _export({ - target: 'RegExp', - proto: true, - forced: _regexpExec !== /./.exec - }, { - exec: _regexpExec - }); - var SPECIES$3 = _wks('species'); - - var REPLACE_SUPPORTS_NAMED_GROUPS = !_fails(function () { - // #replace needs built-in support for named groups. - // #match works fine because it just return the exec results, even if it has - // a "grops" property. - var re = /./; - re.exec = function () { - var result = []; - result.groups = { a: '7' }; - return result; - }; - return ''.replace(re, '$') !== '7'; - }); - - var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = (function () { - // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec - var re = /(?:)/; - var originalExec = re.exec; - re.exec = function () { return originalExec.apply(this, arguments); }; - var result = 'ab'.split(re); - return result.length === 2 && result[0] === 'a' && result[1] === 'b'; - })(); + _export(_export.P, 'Function', { bind: _bind }); var _fixReWks = function (KEY, length, exec) { var SYMBOL = _wks(KEY); - - var DELEGATES_TO_SYMBOL = !_fails(function () { - // String methods call symbol-named RegEp methods + var fns = exec(_defined, SYMBOL, ''[KEY]); + var strfn = fns[0]; + var rxfn = fns[1]; + if (_fails(function () { var O = {}; O[SYMBOL] = function () { return 7; }; return ''[KEY](O) != 7; - }); - - var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL ? !_fails(function () { - // Symbol-named RegExp methods call .exec - var execCalled = false; - var re = /a/; - re.exec = function () { execCalled = true; return null; }; - if (KEY === 'split') { - // RegExp[@@split] doesn't call the regex's exec method, but first creates - // a new one. We need to return the patched regex when creating the new one. - re.constructor = {}; - re.constructor[SPECIES$3] = function () { return re; }; - } - re[SYMBOL](''); - return !execCalled; - }) : undefined; - - if ( - !DELEGATES_TO_SYMBOL || - !DELEGATES_TO_EXEC || - (KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS) || - (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC) - ) { - var nativeRegExpMethod = /./[SYMBOL]; - var fns = exec( - _defined, - SYMBOL, - ''[KEY], - function maybeCallNative(nativeMethod, regexp, str, arg2, forceStringMethod) { - if (regexp.exec === _regexpExec) { - if (DELEGATES_TO_SYMBOL && !forceStringMethod) { - // The native String method already delegates to @@method (this - // polyfilled function), leasing to infinite recursion. - // We avoid it by directly calling the native @@method method. - return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) }; - } - return { done: true, value: nativeMethod.call(str, regexp, arg2) }; - } - return { done: false }; - } - ); - var strfn = fns[0]; - var rxfn = fns[1]; - + })) { _redefine(String.prototype, KEY, strfn); _hide(RegExp.prototype, SYMBOL, length == 2 // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue) @@ -2877,115 +2717,16 @@ } }; - var max$1 = Math.max; - var min$2 = Math.min; - var floor$1 = Math.floor; - var SUBSTITUTION_SYMBOLS = /\$([$&`']|\d\d?|<[^>]*>)/g; - var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&`']|\d\d?)/g; - - var maybeToString = function (it) { - return it === undefined ? it : String(it); - }; - // @@replace logic - _fixReWks('replace', 2, function (defined, REPLACE, $replace, maybeCallNative) { - return [ - // `String.prototype.replace` method - // https://tc39.github.io/ecma262/#sec-string.prototype.replace - function replace(searchValue, replaceValue) { - var O = defined(this); - var fn = searchValue == undefined ? undefined : searchValue[REPLACE]; - return fn !== undefined - ? fn.call(searchValue, O, replaceValue) - : $replace.call(String(O), searchValue, replaceValue); - }, - // `RegExp.prototype[@@replace]` method - // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace - function (regexp, replaceValue) { - var res = maybeCallNative($replace, regexp, this, replaceValue); - if (res.done) return res.value; - - var rx = _anObject(regexp); - var S = String(this); - var functionalReplace = typeof replaceValue === 'function'; - if (!functionalReplace) replaceValue = String(replaceValue); - var global = rx.global; - if (global) { - var fullUnicode = rx.unicode; - rx.lastIndex = 0; - } - var results = []; - while (true) { - var result = _regexpExecAbstract(rx, S); - if (result === null) break; - results.push(result); - if (!global) break; - var matchStr = String(result[0]); - if (matchStr === '') rx.lastIndex = _advanceStringIndex(S, _toLength(rx.lastIndex), fullUnicode); - } - var accumulatedResult = ''; - var nextSourcePosition = 0; - for (var i = 0; i < results.length; i++) { - result = results[i]; - var matched = String(result[0]); - var position = max$1(min$2(_toInteger(result.index), S.length), 0); - var captures = []; - // NOTE: This is equivalent to - // captures = result.slice(1).map(maybeToString) - // but for some reason `nativeSlice.call(result, 1, result.length)` (called in - // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and - // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it. - for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j])); - var namedCaptures = result.groups; - if (functionalReplace) { - var replacerArgs = [matched].concat(captures, position, S); - if (namedCaptures !== undefined) replacerArgs.push(namedCaptures); - var replacement = String(replaceValue.apply(undefined, replacerArgs)); - } else { - replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue); - } - if (position >= nextSourcePosition) { - accumulatedResult += S.slice(nextSourcePosition, position) + replacement; - nextSourcePosition = position + matched.length; - } - } - return accumulatedResult + S.slice(nextSourcePosition); - } - ]; - - // https://tc39.github.io/ecma262/#sec-getsubstitution - function getSubstitution(matched, str, position, captures, namedCaptures, replacement) { - var tailPos = position + matched.length; - var m = captures.length; - var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; - if (namedCaptures !== undefined) { - namedCaptures = _toObject(namedCaptures); - symbols = SUBSTITUTION_SYMBOLS; - } - return $replace.call(replacement, symbols, function (match, ch) { - var capture; - switch (ch.charAt(0)) { - case '$': return '$'; - case '&': return matched; - case '`': return str.slice(0, position); - case "'": return str.slice(tailPos); - case '<': - capture = namedCaptures[ch.slice(1, -1)]; - break; - default: // \d\d? - var n = +ch; - if (n === 0) return match; - if (n > m) { - var f = floor$1(n / 10); - if (f === 0) return match; - if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1); - return match; - } - capture = captures[n - 1]; - } - return capture === undefined ? '' : capture; - }); - } + _fixReWks('replace', 2, function (defined, REPLACE, $replace) { + // 21.1.3.14 String.prototype.replace(searchValue, replaceValue) + return [function replace(searchValue, replaceValue) { + var O = defined(this); + var fn = searchValue == undefined ? undefined : searchValue[REPLACE]; + return fn !== undefined + ? fn.call(searchValue, O, replaceValue) + : $replace.call(String(O), searchValue, replaceValue); + }, $replace]; }); var _stringWs = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + @@ -3034,19 +2775,14 @@ return _isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : _cof(it) == 'RegExp'); }; - var $min = Math.min; - var $push = [].push; - var $SPLIT = 'split'; - var LENGTH = 'length'; - var LAST_INDEX$1 = 'lastIndex'; - var MAX_UINT32 = 0xffffffff; - - // babel-minify transpiles RegExp('x', 'y') -> /x/y and it causes SyntaxError - var SUPPORTS_Y = !_fails(function () { }); - // @@split logic - _fixReWks('split', 2, function (defined, SPLIT, $split, maybeCallNative) { - var internalSplit; + _fixReWks('split', 2, function (defined, SPLIT, $split) { + var isRegExp = _isRegexp; + var _split = $split; + var $push = [].push; + var $SPLIT = 'split'; + var LENGTH = 'length'; + var LAST_INDEX = 'lastIndex'; if ( 'abbc'[$SPLIT](/(b)*/)[1] == 'c' || 'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 || @@ -3055,32 +2791,41 @@ '.'[$SPLIT](/()()/)[LENGTH] > 1 || ''[$SPLIT](/.?/)[LENGTH] ) { + var NPCG = /()??/.exec('')[1] === undefined; // nonparticipating capturing group // based on es5-shim implementation, need to rework it - internalSplit = function (separator, limit) { + $split = function (separator, limit) { var string = String(this); if (separator === undefined && limit === 0) return []; // If `separator` is not a regex, use native split - if (!_isRegexp(separator)) return $split.call(string, separator, limit); + if (!isRegExp(separator)) return _split.call(string, separator, limit); var output = []; var flags = (separator.ignoreCase ? 'i' : '') + (separator.multiline ? 'm' : '') + (separator.unicode ? 'u' : '') + (separator.sticky ? 'y' : ''); var lastLastIndex = 0; - var splitLimit = limit === undefined ? MAX_UINT32 : limit >>> 0; + var splitLimit = limit === undefined ? 4294967295 : limit >>> 0; // Make `global` and avoid `lastIndex` issues by working with a copy var separatorCopy = new RegExp(separator.source, flags + 'g'); - var match, lastIndex, lastLength; - while (match = _regexpExec.call(separatorCopy, string)) { - lastIndex = separatorCopy[LAST_INDEX$1]; + var separator2, match, lastIndex, lastLength, i; + // Doesn't need flags gy, but they don't hurt + if (!NPCG) separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags); + while (match = separatorCopy.exec(string)) { + // `separatorCopy.lastIndex` is not reliable cross-browser + lastIndex = match.index + match[0][LENGTH]; if (lastIndex > lastLastIndex) { output.push(string.slice(lastLastIndex, match.index)); + // Fix browsers whose `exec` methods don't consistently return `undefined` for NPCG + // eslint-disable-next-line no-loop-func + if (!NPCG && match[LENGTH] > 1) match[0].replace(separator2, function () { + for (i = 1; i < arguments[LENGTH] - 2; i++) if (arguments[i] === undefined) match[i] = undefined; + }); if (match[LENGTH] > 1 && match.index < string[LENGTH]) $push.apply(output, match.slice(1)); lastLength = match[0][LENGTH]; lastLastIndex = lastIndex; if (output[LENGTH] >= splitLimit) break; } - if (separatorCopy[LAST_INDEX$1] === match.index) separatorCopy[LAST_INDEX$1]++; // Avoid an infinite loop + if (separatorCopy[LAST_INDEX] === match.index) separatorCopy[LAST_INDEX]++; // Avoid an infinite loop } if (lastLastIndex === string[LENGTH]) { if (lastLength || !separatorCopy.test('')) output.push(''); @@ -3089,74 +2834,16 @@ }; // Chakra, V8 } else if ('0'[$SPLIT](undefined, 0)[LENGTH]) { - internalSplit = function (separator, limit) { - return separator === undefined && limit === 0 ? [] : $split.call(this, separator, limit); + $split = function (separator, limit) { + return separator === undefined && limit === 0 ? [] : _split.call(this, separator, limit); }; - } else { - internalSplit = $split; - } - - return [ - // `String.prototype.split` method - // https://tc39.github.io/ecma262/#sec-string.prototype.split - function split(separator, limit) { - var O = defined(this); - var splitter = separator == undefined ? undefined : separator[SPLIT]; - return splitter !== undefined - ? splitter.call(separator, O, limit) - : internalSplit.call(String(O), separator, limit); - }, - // `RegExp.prototype[@@split]` method - // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@split - // - // NOTE: This cannot be properly polyfilled in engines that don't support - // the 'y' flag. - function (regexp, limit) { - var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== $split); - if (res.done) return res.value; - - var rx = _anObject(regexp); - var S = String(this); - var C = _speciesConstructor(rx, RegExp); - - var unicodeMatching = rx.unicode; - var flags = (rx.ignoreCase ? 'i' : '') + - (rx.multiline ? 'm' : '') + - (rx.unicode ? 'u' : '') + - (SUPPORTS_Y ? 'y' : 'g'); - - // ^(? + rx + ) is needed, in combination with some S slicing, to - // simulate the 'y' flag. - var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags); - var lim = limit === undefined ? MAX_UINT32 : limit >>> 0; - if (lim === 0) return []; - if (S.length === 0) return _regexpExecAbstract(splitter, S) === null ? [S] : []; - var p = 0; - var q = 0; - var A = []; - while (q < S.length) { - splitter.lastIndex = SUPPORTS_Y ? q : 0; - var z = _regexpExecAbstract(splitter, SUPPORTS_Y ? S : S.slice(q)); - var e; - if ( - z === null || - (e = $min(_toLength(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p - ) { - q = _advanceStringIndex(S, q, unicodeMatching); - } else { - A.push(S.slice(p, q)); - if (A.length === lim) return A; - for (var i = 1; i <= z.length - 1; i++) { - A.push(z[i]); - if (A.length === lim) return A; - } - q = p = e; - } - } - A.push(S.slice(p)); - return A; - } - ]; + } + // 21.1.3.17 String.prototype.split(separator, limit) + return [function split(separator, limit) { + var O = defined(this); + var fn = separator == undefined ? undefined : separator[SPLIT]; + return fn !== undefined ? fn.call(separator, O, limit) : $split.call(String(O), separator, limit); + }, $split]; }); var TYPED = _uid('typed_array'); @@ -4007,6 +3694,19 @@ _export(_export.S, 'Array', { isArray: _isArray }); + // 21.2.5.3 get RegExp.prototype.flags + + var _flags = function () { + var that = _anObject(this); + var result = ''; + if (that.global) result += 'g'; + if (that.ignoreCase) result += 'i'; + if (that.multiline) result += 'm'; + if (that.unicode) result += 'u'; + if (that.sticky) result += 'y'; + return result; + }; + // 21.2.5.3 get RegExp.prototype.flags() if (_descriptors && /./g.flags != 'g') _objectDp.f(RegExp.prototype, 'flags', { configurable: true, @@ -4518,7 +4218,7 @@ DOMException.prototype.constructor = DOMException; } - function fetch(input, init) { + function fetch$1(input, init) { return new Promise(function (resolve, reject) { var request = new Request(input, init); @@ -4585,15 +4285,21 @@ xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit); }); } - fetch.polyfill = true; + fetch$1.polyfill = true; if (!self.fetch) { - self.fetch = fetch; + self.fetch = fetch$1; self.Headers = Headers; self.Request = Request; self.Response = Response; } + // on the global object (window or self) + // + // Return that as the export for use in Webpack, Browserify etc. + + var fetchNpmBrowserify = self.fetch.bind(self); + var setPrototypeOf = _setProto.set; var _inheritIfRequired = function (that, target, C) { var S = target.constructor; @@ -4732,6 +4438,22 @@ } }); + // true -> String#at + // false -> String#codePointAt + var _stringAt = function (TO_STRING) { + return function (that, pos) { + var s = String(_defined(that)); + var i = _toInteger(pos); + var l = s.length; + var a, b; + if (i < 0 || i >= l) return TO_STRING ? '' : undefined; + a = s.charCodeAt(i); + return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff + ? TO_STRING ? s.charAt(i) : a + : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; + }; + }; + var $at = _stringAt(true); // 21.1.3.27 String.prototype[@@iterator]() @@ -5292,7 +5014,7 @@ * R.max('a', 'b'); //=> 'b' */ - var max$2 = + var max$1 = /*#__PURE__*/ _curry2(function max(a, b) { return b > a ? b : a; @@ -5880,9 +5602,9 @@ // 20.1.2.3 Number.isInteger(number) - var floor$2 = Math.floor; + var floor$1 = Math.floor; var _isInteger = function isInteger(it) { - return !_isObject(it) && isFinite(it) && floor$2(it) === it; + return !_isObject(it) && isFinite(it) && floor$1(it) === it; }; // 20.1.2.3 Number.isInteger(number) @@ -6516,37 +6238,13 @@ } // @@match logic - _fixReWks('match', 1, function (defined, MATCH, $match, maybeCallNative) { - return [ - // `String.prototype.match` method - // https://tc39.github.io/ecma262/#sec-string.prototype.match - function match(regexp) { - var O = defined(this); - var fn = regexp == undefined ? undefined : regexp[MATCH]; - return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O)); - }, - // `RegExp.prototype[@@match]` method - // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match - function (regexp) { - var res = maybeCallNative($match, regexp, this); - if (res.done) return res.value; - var rx = _anObject(regexp); - var S = String(this); - if (!rx.global) return _regexpExecAbstract(rx, S); - var fullUnicode = rx.unicode; - rx.lastIndex = 0; - var A = []; - var n = 0; - var result; - while ((result = _regexpExecAbstract(rx, S)) !== null) { - var matchStr = String(result[0]); - A[n] = matchStr; - if (matchStr === '') rx.lastIndex = _advanceStringIndex(S, _toLength(rx.lastIndex), fullUnicode); - n++; - } - return n === 0 ? null : A; - } - ]; + _fixReWks('match', 1, function (defined, MATCH, $match) { + // 21.1.3.11 String.prototype.match(regexp) + return [function match(regexp) { + var O = defined(this); + var fn = regexp == undefined ? undefined : regexp[MATCH]; + return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O)); + }, $match]; }); function _functionName(f) { @@ -7161,7 +6859,7 @@ var converge = /*#__PURE__*/ _curry2(function converge(after, fns) { - return curryN(reduce(max$2, 0, pluck('length', fns)), function () { + return curryN(reduce(max$1, 0, pluck('length', fns)), function () { var args = arguments; var context = this; return after.apply(context, _map(function (fn) { @@ -13614,36 +13312,14 @@ }); }); - // 7.2.9 SameValue(x, y) - var _sameValue = Object.is || function is(x, y) { - // eslint-disable-next-line no-self-compare - return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y; - }; - // @@search logic - _fixReWks('search', 1, function (defined, SEARCH, $search, maybeCallNative) { - return [ - // `String.prototype.search` method - // https://tc39.github.io/ecma262/#sec-string.prototype.search - function search(regexp) { - var O = defined(this); - var fn = regexp == undefined ? undefined : regexp[SEARCH]; - return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O)); - }, - // `RegExp.prototype[@@search]` method - // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@search - function (regexp) { - var res = maybeCallNative($search, regexp, this); - if (res.done) return res.value; - var rx = _anObject(regexp); - var S = String(this); - var previousLastIndex = rx.lastIndex; - if (!_sameValue(previousLastIndex, 0)) rx.lastIndex = 0; - var result = _regexpExecAbstract(rx, S); - if (!_sameValue(rx.lastIndex, previousLastIndex)) rx.lastIndex = previousLastIndex; - return result === null ? -1 : result.index; - } - ]; + _fixReWks('search', 1, function (defined, SEARCH, $search) { + // 21.1.3.15 String.prototype.search(regexp) + return [function search(regexp) { + var O = defined(this); + var fn = regexp == undefined ? undefined : regexp[SEARCH]; + return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O)); + }, $search]; }); // 19.1.2.3 / 15.2.3.7 Object.defineProperties(O, Properties) @@ -14920,6 +14596,7 @@ _createClass(CubejsApi, [{ key: "request", value: function request(url, config) { + // eslint-disable-next-line no-undef return fetch("".concat(this.apiUrl).concat(url), Object.assign({ headers: { Authorization: this.apiToken, @@ -15013,7 +14690,7 @@ return _context.stop(); } } - }, _callee); + }, _callee, this); })); return function loadImpl() { diff --git a/packages/cubejs-client-core/package.json b/packages/cubejs-client-core/package.json index a9031e3e9db7a..2d99f55a22828 100644 --- a/packages/cubejs-client-core/package.json +++ b/packages/cubejs-client-core/package.json @@ -7,10 +7,10 @@ "dependencies": { "@babel/runtime": "^7.1.2", "core-js": "^2.5.3", + "isomorphic-fetch": "^2.2.1", "moment": "^2.22.2", "moment-range": "^4.0.1", - "ramda": "^0.25.0", - "whatwg-fetch": "^3.0.0" + "ramda": "^0.25.0" }, "scripts": { "test": "jest" diff --git a/packages/cubejs-client-core/src/index.js b/packages/cubejs-client-core/src/index.js index 7eec50c913f78..03f11192b2a7a 100644 --- a/packages/cubejs-client-core/src/index.js +++ b/packages/cubejs-client-core/src/index.js @@ -1,4 +1,4 @@ -import { fetch } from 'whatwg-fetch'; +import 'isomorphic-fetch'; import ResultSet from './ResultSet'; import SqlQuery from './SqlQuery'; import Meta from './Meta'; @@ -24,10 +24,11 @@ class CubejsApi { } request(url, config) { + // eslint-disable-next-line no-undef return fetch( `${this.apiUrl}${url}`, Object.assign({ headers: { Authorization: this.apiToken, 'Content-Type': 'application/json' }}, config || {}) - ) + ); } loadMethod(request, toResult, options, callback) { diff --git a/packages/cubejs-client-core/yarn.lock b/packages/cubejs-client-core/yarn.lock index 24b19e4791954..08f142151ee32 100644 --- a/packages/cubejs-client-core/yarn.lock +++ b/packages/cubejs-client-core/yarn.lock @@ -1224,6 +1224,13 @@ electron-to-chromium@^1.3.103: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.113.tgz#b1ccf619df7295aea17bc6951dc689632629e4a9" integrity sha512-De+lPAxEcpxvqPTyZAXELNpRZXABRxf+uL/rSykstQhzj/B0l1150G/ExIIxKc16lI89Hgz81J0BHAcbTqK49g== +encoding@^0.1.11: + version "0.1.12" + resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb" + integrity sha1-U4tm8+5izRq1HsMjgp0flIDHS+s= + dependencies: + iconv-lite "~0.4.13" + end-of-stream@^1.1.0: version "1.4.1" resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.1.tgz#ed29634d19baba463b6ce6b80a37213eab71ec43" @@ -1673,7 +1680,7 @@ http-signature@~1.2.0: jsprim "^1.2.2" sshpk "^1.7.0" -iconv-lite@0.4.24, iconv-lite@^0.4.4: +iconv-lite@0.4.24, iconv-lite@^0.4.4, iconv-lite@~0.4.13: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== @@ -1853,7 +1860,7 @@ is-regex@^1.0.4: dependencies: has "^1.0.1" -is-stream@^1.1.0: +is-stream@^1.0.1, is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= @@ -1902,6 +1909,14 @@ isobject@^3.0.0, isobject@^3.0.1: resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= +isomorphic-fetch@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9" + integrity sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk= + dependencies: + node-fetch "^1.0.1" + whatwg-fetch ">=0.10.0" + isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" @@ -2705,6 +2720,14 @@ nice-try@^1.0.4: resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== +node-fetch@^1.0.1: + version "1.7.3" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef" + integrity sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ== + dependencies: + encoding "^0.1.11" + is-stream "^1.0.1" + node-int64@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" @@ -3890,7 +3913,7 @@ whatwg-encoding@^1.0.1, whatwg-encoding@^1.0.3: dependencies: iconv-lite "0.4.24" -whatwg-fetch@^3.0.0: +whatwg-fetch@>=0.10.0: version "3.0.0" resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz#fc804e458cc460009b1a2b966bc8817d2578aefb" diff --git a/packages/cubejs-react/dist/cubejs-react.js b/packages/cubejs-react/dist/cubejs-react.js index 44f7b9fde95e2..4f7800fb09eb7 100644 --- a/packages/cubejs-react/dist/cubejs-react.js +++ b/packages/cubejs-react/dist/cubejs-react.js @@ -293,11 +293,9 @@ function (_React$Component) { }, _callee, this); })); - function componentDidMount() { + return function componentDidMount() { return _componentDidMount.apply(this, arguments); - } - - return componentDidMount; + }; }() }, { key: "isQueryPresent", @@ -336,7 +334,7 @@ function (_React$Component) { add: function add(member) { var query = _this2.state.query; - _this2.setState(_this2.applyQueryChangeHeuristics({ + _this2.setState(_this2.applyStateChangeHeuristics({ query: _objectSpread({}, query, _defineProperty({}, memberType, (query[memberType] || []).concat(toQuery(member)))) })); }, @@ -344,7 +342,7 @@ function (_React$Component) { var query = _this2.state.query; var members = (query[memberType] || []).concat([]); members.splice(member.index, 1); - return _this2.setState(_this2.applyQueryChangeHeuristics({ + return _this2.setState(_this2.applyStateChangeHeuristics({ query: _objectSpread({}, query, _defineProperty({}, memberType, members)) })); }, @@ -352,7 +350,7 @@ function (_React$Component) { var query = _this2.state.query; var members = (query[memberType] || []).concat([]); members.splice(member.index, 1, toQuery(updateWith)); - return _this2.setState(_this2.applyQueryChangeHeuristics({ + return _this2.setState(_this2.applyStateChangeHeuristics({ query: _objectSpread({}, query, _defineProperty({}, memberType, members)) })); } @@ -430,7 +428,7 @@ function (_React$Component) { updateTimeDimensions: updateMethods('timeDimensions', toTimeDimension), updateFilters: updateMethods('filters', toFilter), updateChartType: function updateChartType(newChartType) { - return _this2.setState(_this2.applyQueryChangeHeuristics({ + return _this2.setState(_this2.applyStateChangeHeuristics({ chartType: newChartType })); } @@ -554,17 +552,17 @@ function (_React$Component) { return newState; } }, { - key: "applyQueryChangeHeuristics", - value: function applyQueryChangeHeuristics(newState) { + key: "applyStateChangeHeuristics", + value: function applyStateChangeHeuristics(newState) { var _this$props = this.props, - queryChangeHeuristics = _this$props.queryChangeHeuristics, + stateChangeHeuristics = _this$props.stateChangeHeuristics, disableHeuristics = _this$props.disableHeuristics; if (disableHeuristics) { return newState; } - return queryChangeHeuristics && queryChangeHeuristics(this.state, newState) || this.defaultHeuristics(newState); + return stateChangeHeuristics && stateChangeHeuristics(this.state, newState) || this.defaultHeuristics(newState); } }, { key: "render", @@ -592,14 +590,14 @@ function (_React$Component) { }(React.Component); QueryBuilder.propTypes = { render: PropTypes.func, - queryChangeHeuristics: PropTypes.func, + stateChangeHeuristics: PropTypes.func, cubejsApi: PropTypes.object.isRequired, disableHeuristics: PropTypes.bool, query: PropTypes.object }; QueryBuilder.defaultProps = { query: {}, - queryChangeHeuristics: null, + stateChangeHeuristics: null, disableHeuristics: false, render: null }; diff --git a/packages/cubejs-react/dist/cubejs-react.umd.js b/packages/cubejs-react/dist/cubejs-react.umd.js index d7986a35ac161..036ff2e35c380 100644 --- a/packages/cubejs-react/dist/cubejs-react.umd.js +++ b/packages/cubejs-react/dist/cubejs-react.umd.js @@ -20,7 +20,7 @@ }); var _core = createCommonjsModule(function (module) { - var core = module.exports = { version: '2.6.5' }; + var core = module.exports = { version: '2.5.7' }; if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef }); var _core_1 = _core.version; @@ -116,31 +116,14 @@ return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); }; - var _library = false; - - var _shared = createCommonjsModule(function (module) { - var SHARED = '__core-js_shared__'; - var store = _global[SHARED] || (_global[SHARED] = {}); - - (module.exports = function (key, value) { - return store[key] || (store[key] = value !== undefined ? value : {}); - })('versions', []).push({ - version: _core.version, - mode: _library ? 'pure' : 'global', - copyright: '© 2019 Denis Pushkarev (zloirock.ru)' - }); - }); - - var _functionToString = _shared('native-function-to-string', Function.toString); - var _redefine = createCommonjsModule(function (module) { var SRC = _uid('src'); - var TO_STRING = 'toString'; - var TPL = ('' + _functionToString).split(TO_STRING); + var $toString = Function[TO_STRING]; + var TPL = ('' + $toString).split(TO_STRING); _core.inspectSource = function (it) { - return _functionToString.call(it); + return $toString.call(it); }; (module.exports = function (O, key, val, safe) { @@ -160,7 +143,7 @@ } // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative })(Function.prototype, TO_STRING, function toString() { - return typeof this == 'function' && this[SRC] || _functionToString.call(this); + return typeof this == 'function' && this[SRC] || $toString.call(this); }); }); @@ -274,6 +257,21 @@ return _cof(arg) == 'Array'; }; + var _library = false; + + var _shared = createCommonjsModule(function (module) { + var SHARED = '__core-js_shared__'; + var store = _global[SHARED] || (_global[SHARED] = {}); + + (module.exports = function (key, value) { + return store[key] || (store[key] = value !== undefined ? value : {}); + })('versions', []).push({ + version: _core.version, + mode: _library ? 'pure' : 'global', + copyright: '© 2018 Denis Pushkarev (zloirock.ru)' + }); + }); + var _wks = createCommonjsModule(function (module) { var store = _shared('wks'); @@ -3809,172 +3807,16 @@ return _arity(arguments[0].length, reduce(_pipe, arguments[0], tail(arguments))); } - var at = _stringAt(true); - - // `AdvanceStringIndex` abstract operation - // https://tc39.github.io/ecma262/#sec-advancestringindex - var _advanceStringIndex = function (S, index, unicode) { - return index + (unicode ? at(S, index).length : 1); - }; - - var builtinExec = RegExp.prototype.exec; - - // `RegExpExec` abstract operation - // https://tc39.github.io/ecma262/#sec-regexpexec - var _regexpExecAbstract = function (R, S) { - var exec = R.exec; - if (typeof exec === 'function') { - var result = exec.call(R, S); - if (typeof result !== 'object') { - throw new TypeError('RegExp exec method returned something other than an Object or null'); - } - return result; - } - if (_classof(R) !== 'RegExp') { - throw new TypeError('RegExp#exec called on incompatible receiver'); - } - return builtinExec.call(R, S); - }; - - var nativeExec = RegExp.prototype.exec; - // This always refers to the native implementation, because the - // String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js, - // which loads this file before patching the method. - var nativeReplace = String.prototype.replace; - - var patchedExec = nativeExec; - - var LAST_INDEX = 'lastIndex'; - - var UPDATES_LAST_INDEX_WRONG = (function () { - var re1 = /a/, - re2 = /b*/g; - nativeExec.call(re1, 'a'); - nativeExec.call(re2, 'a'); - return re1[LAST_INDEX] !== 0 || re2[LAST_INDEX] !== 0; - })(); - - // nonparticipating capturing group, copied from es5-shim's String#split patch. - var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; - - var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED; - - if (PATCH) { - patchedExec = function exec(str) { - var re = this; - var lastIndex, reCopy, match, i; - - if (NPCG_INCLUDED) { - reCopy = new RegExp('^' + re.source + '$(?!\\s)', _flags.call(re)); - } - if (UPDATES_LAST_INDEX_WRONG) lastIndex = re[LAST_INDEX]; - - match = nativeExec.call(re, str); - - if (UPDATES_LAST_INDEX_WRONG && match) { - re[LAST_INDEX] = re.global ? match.index + match[0].length : lastIndex; - } - if (NPCG_INCLUDED && match && match.length > 1) { - // Fix browsers whose `exec` methods don't consistently return `undefined` - // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/ - // eslint-disable-next-line no-loop-func - nativeReplace.call(match[0], reCopy, function () { - for (i = 1; i < arguments.length - 2; i++) { - if (arguments[i] === undefined) match[i] = undefined; - } - }); - } - - return match; - }; - } - - var _regexpExec = patchedExec; - - _export({ - target: 'RegExp', - proto: true, - forced: _regexpExec !== /./.exec - }, { - exec: _regexpExec - }); - - var SPECIES$3 = _wks('species'); - - var REPLACE_SUPPORTS_NAMED_GROUPS = !_fails(function () { - // #replace needs built-in support for named groups. - // #match works fine because it just return the exec results, even if it has - // a "grops" property. - var re = /./; - re.exec = function () { - var result = []; - result.groups = { a: '7' }; - return result; - }; - return ''.replace(re, '$') !== '7'; - }); - - var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = (function () { - // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec - var re = /(?:)/; - var originalExec = re.exec; - re.exec = function () { return originalExec.apply(this, arguments); }; - var result = 'ab'.split(re); - return result.length === 2 && result[0] === 'a' && result[1] === 'b'; - })(); - var _fixReWks = function (KEY, length, exec) { var SYMBOL = _wks(KEY); - - var DELEGATES_TO_SYMBOL = !_fails(function () { - // String methods call symbol-named RegEp methods + var fns = exec(_defined, SYMBOL, ''[KEY]); + var strfn = fns[0]; + var rxfn = fns[1]; + if (_fails(function () { var O = {}; O[SYMBOL] = function () { return 7; }; return ''[KEY](O) != 7; - }); - - var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL ? !_fails(function () { - // Symbol-named RegExp methods call .exec - var execCalled = false; - var re = /a/; - re.exec = function () { execCalled = true; return null; }; - if (KEY === 'split') { - // RegExp[@@split] doesn't call the regex's exec method, but first creates - // a new one. We need to return the patched regex when creating the new one. - re.constructor = {}; - re.constructor[SPECIES$3] = function () { return re; }; - } - re[SYMBOL](''); - return !execCalled; - }) : undefined; - - if ( - !DELEGATES_TO_SYMBOL || - !DELEGATES_TO_EXEC || - (KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS) || - (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC) - ) { - var nativeRegExpMethod = /./[SYMBOL]; - var fns = exec( - _defined, - SYMBOL, - ''[KEY], - function maybeCallNative(nativeMethod, regexp, str, arg2, forceStringMethod) { - if (regexp.exec === _regexpExec) { - if (DELEGATES_TO_SYMBOL && !forceStringMethod) { - // The native String method already delegates to @@method (this - // polyfilled function), leasing to infinite recursion. - // We avoid it by directly calling the native @@method method. - return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) }; - } - return { done: true, value: nativeMethod.call(str, regexp, arg2) }; - } - return { done: false }; - } - ); - var strfn = fns[0]; - var rxfn = fns[1]; - + })) { _redefine(String.prototype, KEY, strfn); _hide(RegExp.prototype, SYMBOL, length == 2 // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue) @@ -3987,19 +3829,14 @@ } }; - var $min = Math.min; - var $push = [].push; - var $SPLIT = 'split'; - var LENGTH = 'length'; - var LAST_INDEX$1 = 'lastIndex'; - var MAX_UINT32 = 0xffffffff; - - // babel-minify transpiles RegExp('x', 'y') -> /x/y and it causes SyntaxError - var SUPPORTS_Y = !_fails(function () { }); - // @@split logic - _fixReWks('split', 2, function (defined, SPLIT, $split, maybeCallNative) { - var internalSplit; + _fixReWks('split', 2, function (defined, SPLIT, $split) { + var isRegExp = _isRegexp; + var _split = $split; + var $push = [].push; + var $SPLIT = 'split'; + var LENGTH = 'length'; + var LAST_INDEX = 'lastIndex'; if ( 'abbc'[$SPLIT](/(b)*/)[1] == 'c' || 'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 || @@ -4008,32 +3845,41 @@ '.'[$SPLIT](/()()/)[LENGTH] > 1 || ''[$SPLIT](/.?/)[LENGTH] ) { + var NPCG = /()??/.exec('')[1] === undefined; // nonparticipating capturing group // based on es5-shim implementation, need to rework it - internalSplit = function (separator, limit) { + $split = function (separator, limit) { var string = String(this); if (separator === undefined && limit === 0) return []; // If `separator` is not a regex, use native split - if (!_isRegexp(separator)) return $split.call(string, separator, limit); + if (!isRegExp(separator)) return _split.call(string, separator, limit); var output = []; var flags = (separator.ignoreCase ? 'i' : '') + (separator.multiline ? 'm' : '') + (separator.unicode ? 'u' : '') + (separator.sticky ? 'y' : ''); var lastLastIndex = 0; - var splitLimit = limit === undefined ? MAX_UINT32 : limit >>> 0; + var splitLimit = limit === undefined ? 4294967295 : limit >>> 0; // Make `global` and avoid `lastIndex` issues by working with a copy var separatorCopy = new RegExp(separator.source, flags + 'g'); - var match, lastIndex, lastLength; - while (match = _regexpExec.call(separatorCopy, string)) { - lastIndex = separatorCopy[LAST_INDEX$1]; + var separator2, match, lastIndex, lastLength, i; + // Doesn't need flags gy, but they don't hurt + if (!NPCG) separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags); + while (match = separatorCopy.exec(string)) { + // `separatorCopy.lastIndex` is not reliable cross-browser + lastIndex = match.index + match[0][LENGTH]; if (lastIndex > lastLastIndex) { output.push(string.slice(lastLastIndex, match.index)); + // Fix browsers whose `exec` methods don't consistently return `undefined` for NPCG + // eslint-disable-next-line no-loop-func + if (!NPCG && match[LENGTH] > 1) match[0].replace(separator2, function () { + for (i = 1; i < arguments[LENGTH] - 2; i++) if (arguments[i] === undefined) match[i] = undefined; + }); if (match[LENGTH] > 1 && match.index < string[LENGTH]) $push.apply(output, match.slice(1)); lastLength = match[0][LENGTH]; lastLastIndex = lastIndex; if (output[LENGTH] >= splitLimit) break; } - if (separatorCopy[LAST_INDEX$1] === match.index) separatorCopy[LAST_INDEX$1]++; // Avoid an infinite loop + if (separatorCopy[LAST_INDEX] === match.index) separatorCopy[LAST_INDEX]++; // Avoid an infinite loop } if (lastLastIndex === string[LENGTH]) { if (lastLength || !separatorCopy.test('')) output.push(''); @@ -4042,74 +3888,16 @@ }; // Chakra, V8 } else if ('0'[$SPLIT](undefined, 0)[LENGTH]) { - internalSplit = function (separator, limit) { - return separator === undefined && limit === 0 ? [] : $split.call(this, separator, limit); + $split = function (separator, limit) { + return separator === undefined && limit === 0 ? [] : _split.call(this, separator, limit); }; - } else { - internalSplit = $split; } - - return [ - // `String.prototype.split` method - // https://tc39.github.io/ecma262/#sec-string.prototype.split - function split(separator, limit) { - var O = defined(this); - var splitter = separator == undefined ? undefined : separator[SPLIT]; - return splitter !== undefined - ? splitter.call(separator, O, limit) - : internalSplit.call(String(O), separator, limit); - }, - // `RegExp.prototype[@@split]` method - // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@split - // - // NOTE: This cannot be properly polyfilled in engines that don't support - // the 'y' flag. - function (regexp, limit) { - var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== $split); - if (res.done) return res.value; - - var rx = _anObject(regexp); - var S = String(this); - var C = _speciesConstructor(rx, RegExp); - - var unicodeMatching = rx.unicode; - var flags = (rx.ignoreCase ? 'i' : '') + - (rx.multiline ? 'm' : '') + - (rx.unicode ? 'u' : '') + - (SUPPORTS_Y ? 'y' : 'g'); - - // ^(? + rx + ) is needed, in combination with some S slicing, to - // simulate the 'y' flag. - var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags); - var lim = limit === undefined ? MAX_UINT32 : limit >>> 0; - if (lim === 0) return []; - if (S.length === 0) return _regexpExecAbstract(splitter, S) === null ? [S] : []; - var p = 0; - var q = 0; - var A = []; - while (q < S.length) { - splitter.lastIndex = SUPPORTS_Y ? q : 0; - var z = _regexpExecAbstract(splitter, SUPPORTS_Y ? S : S.slice(q)); - var e; - if ( - z === null || - (e = $min(_toLength(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p - ) { - q = _advanceStringIndex(S, q, unicodeMatching); - } else { - A.push(S.slice(p, q)); - if (A.length === lim) return A; - for (var i = 1; i <= z.length - 1; i++) { - A.push(z[i]); - if (A.length === lim) return A; - } - q = p = e; - } - } - A.push(S.slice(p)); - return A; - } - ]; + // 21.1.3.17 String.prototype.split(separator, limit) + return [function split(separator, limit) { + var O = defined(this); + var fn = separator == undefined ? undefined : separator[SPLIT]; + return fn !== undefined ? fn.call(separator, O, limit) : $split.call(String(O), separator, limit); + }, $split]; }); /** @@ -4253,37 +4041,13 @@ } // @@match logic - _fixReWks('match', 1, function (defined, MATCH, $match, maybeCallNative) { - return [ - // `String.prototype.match` method - // https://tc39.github.io/ecma262/#sec-string.prototype.match - function match(regexp) { - var O = defined(this); - var fn = regexp == undefined ? undefined : regexp[MATCH]; - return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O)); - }, - // `RegExp.prototype[@@match]` method - // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match - function (regexp) { - var res = maybeCallNative($match, regexp, this); - if (res.done) return res.value; - var rx = _anObject(regexp); - var S = String(this); - if (!rx.global) return _regexpExecAbstract(rx, S); - var fullUnicode = rx.unicode; - rx.lastIndex = 0; - var A = []; - var n = 0; - var result; - while ((result = _regexpExecAbstract(rx, S)) !== null) { - var matchStr = String(result[0]); - A[n] = matchStr; - if (matchStr === '') rx.lastIndex = _advanceStringIndex(S, _toLength(rx.lastIndex), fullUnicode); - n++; - } - return n === 0 ? null : A; - } - ]; + _fixReWks('match', 1, function (defined, MATCH, $match) { + // 21.1.3.11 String.prototype.match(regexp) + return [function match(regexp) { + var O = defined(this); + var fn = regexp == undefined ? undefined : regexp[MATCH]; + return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O)); + }, $match]; }); function _functionName(f) { @@ -4593,115 +4357,16 @@ return _indexOf(list, a, 0) >= 0; } - var max$2 = Math.max; - var min$2 = Math.min; - var floor$2 = Math.floor; - var SUBSTITUTION_SYMBOLS = /\$([$&`']|\d\d?|<[^>]*>)/g; - var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&`']|\d\d?)/g; - - var maybeToString = function (it) { - return it === undefined ? it : String(it); - }; - // @@replace logic - _fixReWks('replace', 2, function (defined, REPLACE, $replace, maybeCallNative) { - return [ - // `String.prototype.replace` method - // https://tc39.github.io/ecma262/#sec-string.prototype.replace - function replace(searchValue, replaceValue) { - var O = defined(this); - var fn = searchValue == undefined ? undefined : searchValue[REPLACE]; - return fn !== undefined - ? fn.call(searchValue, O, replaceValue) - : $replace.call(String(O), searchValue, replaceValue); - }, - // `RegExp.prototype[@@replace]` method - // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace - function (regexp, replaceValue) { - var res = maybeCallNative($replace, regexp, this, replaceValue); - if (res.done) return res.value; - - var rx = _anObject(regexp); - var S = String(this); - var functionalReplace = typeof replaceValue === 'function'; - if (!functionalReplace) replaceValue = String(replaceValue); - var global = rx.global; - if (global) { - var fullUnicode = rx.unicode; - rx.lastIndex = 0; - } - var results = []; - while (true) { - var result = _regexpExecAbstract(rx, S); - if (result === null) break; - results.push(result); - if (!global) break; - var matchStr = String(result[0]); - if (matchStr === '') rx.lastIndex = _advanceStringIndex(S, _toLength(rx.lastIndex), fullUnicode); - } - var accumulatedResult = ''; - var nextSourcePosition = 0; - for (var i = 0; i < results.length; i++) { - result = results[i]; - var matched = String(result[0]); - var position = max$2(min$2(_toInteger(result.index), S.length), 0); - var captures = []; - // NOTE: This is equivalent to - // captures = result.slice(1).map(maybeToString) - // but for some reason `nativeSlice.call(result, 1, result.length)` (called in - // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and - // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it. - for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j])); - var namedCaptures = result.groups; - if (functionalReplace) { - var replacerArgs = [matched].concat(captures, position, S); - if (namedCaptures !== undefined) replacerArgs.push(namedCaptures); - var replacement = String(replaceValue.apply(undefined, replacerArgs)); - } else { - replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue); - } - if (position >= nextSourcePosition) { - accumulatedResult += S.slice(nextSourcePosition, position) + replacement; - nextSourcePosition = position + matched.length; - } - } - return accumulatedResult + S.slice(nextSourcePosition); - } - ]; - - // https://tc39.github.io/ecma262/#sec-getsubstitution - function getSubstitution(matched, str, position, captures, namedCaptures, replacement) { - var tailPos = position + matched.length; - var m = captures.length; - var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; - if (namedCaptures !== undefined) { - namedCaptures = _toObject(namedCaptures); - symbols = SUBSTITUTION_SYMBOLS; - } - return $replace.call(replacement, symbols, function (match, ch) { - var capture; - switch (ch.charAt(0)) { - case '$': return '$'; - case '&': return matched; - case '`': return str.slice(0, position); - case "'": return str.slice(tailPos); - case '<': - capture = namedCaptures[ch.slice(1, -1)]; - break; - default: // \d\d? - var n = +ch; - if (n === 0) return match; - if (n > m) { - var f = floor$2(n / 10); - if (f === 0) return match; - if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1); - return match; - } - capture = captures[n - 1]; - } - return capture === undefined ? '' : capture; - }); - } + _fixReWks('replace', 2, function (defined, REPLACE, $replace) { + // 21.1.3.14 String.prototype.replace(searchValue, replaceValue) + return [function replace(searchValue, replaceValue) { + var O = defined(this); + var fn = searchValue == undefined ? undefined : searchValue[REPLACE]; + return fn !== undefined + ? fn.call(searchValue, O, replaceValue) + : $replace.call(String(O), searchValue, replaceValue); + }, $replace]; }); function _quote(s) { @@ -7787,11 +7452,9 @@ }, _callee, this); })); - function componentDidMount() { + return function componentDidMount() { return _componentDidMount.apply(this, arguments); - } - - return componentDidMount; + }; }() }, { key: "isQueryPresent", @@ -7830,7 +7493,7 @@ add: function add(member) { var query = _this2.state.query; - _this2.setState(_this2.applyQueryChangeHeuristics({ + _this2.setState(_this2.applyStateChangeHeuristics({ query: _objectSpread({}, query, _defineProperty({}, memberType, (query[memberType] || []).concat(toQuery(member)))) })); }, @@ -7838,7 +7501,7 @@ var query = _this2.state.query; var members = (query[memberType] || []).concat([]); members.splice(member.index, 1); - return _this2.setState(_this2.applyQueryChangeHeuristics({ + return _this2.setState(_this2.applyStateChangeHeuristics({ query: _objectSpread({}, query, _defineProperty({}, memberType, members)) })); }, @@ -7846,7 +7509,7 @@ var query = _this2.state.query; var members = (query[memberType] || []).concat([]); members.splice(member.index, 1, toQuery(updateWith)); - return _this2.setState(_this2.applyQueryChangeHeuristics({ + return _this2.setState(_this2.applyStateChangeHeuristics({ query: _objectSpread({}, query, _defineProperty({}, memberType, members)) })); } @@ -7924,7 +7587,7 @@ updateTimeDimensions: updateMethods('timeDimensions', toTimeDimension), updateFilters: updateMethods('filters', toFilter), updateChartType: function updateChartType(newChartType) { - return _this2.setState(_this2.applyQueryChangeHeuristics({ + return _this2.setState(_this2.applyStateChangeHeuristics({ chartType: newChartType })); } @@ -8048,17 +7711,17 @@ return newState; } }, { - key: "applyQueryChangeHeuristics", - value: function applyQueryChangeHeuristics(newState) { + key: "applyStateChangeHeuristics", + value: function applyStateChangeHeuristics(newState) { var _this$props = this.props, - queryChangeHeuristics = _this$props.queryChangeHeuristics, + stateChangeHeuristics = _this$props.stateChangeHeuristics, disableHeuristics = _this$props.disableHeuristics; if (disableHeuristics) { return newState; } - return queryChangeHeuristics && queryChangeHeuristics(this.state, newState) || this.defaultHeuristics(newState); + return stateChangeHeuristics && stateChangeHeuristics(this.state, newState) || this.defaultHeuristics(newState); } }, { key: "render", @@ -8086,14 +7749,14 @@ }(React.Component); QueryBuilder.propTypes = { render: PropTypes.func, - queryChangeHeuristics: PropTypes.func, + stateChangeHeuristics: PropTypes.func, cubejsApi: PropTypes.object.isRequired, disableHeuristics: PropTypes.bool, query: PropTypes.object }; QueryBuilder.defaultProps = { query: {}, - queryChangeHeuristics: null, + stateChangeHeuristics: null, disableHeuristics: false, render: null }; diff --git a/rollup.config.js b/rollup.config.js index 15d1584a734f9..3e3ec59b8cda1 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -23,7 +23,7 @@ const bundle = (name, globalName, baseConfig) => { ...baseConfig.plugins, commonjs(), resolve({ - module: true + mainFields: ['browser', 'module', 'main'] }), babel({ exclude: ['node_modules/**', /\/core-js\//], diff --git a/yarn.lock b/yarn.lock index 23978e7f1e837..2897b8627f6dd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1290,6 +1290,13 @@ version "10.9.4" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.9.4.tgz#0f4cb2dc7c1de6096055357f70179043c33e9897" +"@types/resolve@0.0.8": + version "0.0.8" + resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-0.0.8.tgz#f26074d238e02659e323ce1a13d041eee280e194" + integrity sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ== + dependencies: + "@types/node" "*" + JSONStream@^1.0.4, JSONStream@^1.3.4: version "1.3.5" resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" @@ -1589,9 +1596,10 @@ buffer-from@^1.0.0: resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== -builtin-modules@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-2.0.0.tgz#60b7ef5ae6546bd7deefa74b08b62a43a232648e" +builtin-modules@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.1.0.tgz#aad97c15131eb76b65b50ef208e7584cd76a7484" + integrity sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw== builtins@^1.0.3: version "1.0.3" @@ -4736,7 +4744,7 @@ resolve-url@^0.2.1: resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= -resolve@^1.1.6, resolve@^1.1.7, resolve@^1.3.2, resolve@^1.5.0, resolve@^1.8.1: +resolve@^1.1.7, resolve@^1.3.2, resolve@^1.5.0, resolve@^1.8.1: version "1.8.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26" dependencies: @@ -4796,13 +4804,15 @@ rollup-plugin-commonjs@^9.1.6: resolve "^1.5.0" rollup-pluginutils "^2.0.1" -rollup-plugin-node-resolve@^3.4.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-3.4.0.tgz#908585eda12e393caac7498715a01e08606abc89" +rollup-plugin-node-resolve@^4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-4.2.3.tgz#638a373a54287d19fcc088fdd1c6fd8a58e4d90a" + integrity sha512-r+WaesPzdGEynpLZLALFEDugA4ACa5zn7bc/+LVX4vAXQQ8IgDHv0xfsSvJ8tDXUtprfBtrDtRFg27ifKjcJTg== dependencies: - builtin-modules "^2.0.0" + "@types/resolve" "0.0.8" + builtin-modules "^3.1.0" is-module "^1.0.0" - resolve "^1.1.6" + resolve "^1.10.0" rollup-plugin-replace@^2.0.0: version "2.0.0"