Comparing version 3.3.1 to 3.4.0-beta.1
@@ -9,3 +9,3 @@ "use strict"; | ||
exports.isMobile = isMobile; | ||
exports["default"] = getBrowser; | ||
exports.default = getBrowser; | ||
@@ -23,7 +23,7 @@ var _globals = require("./globals"); | ||
function getBrowser(mockUserAgent) { | ||
if (!mockUserAgent && !(0, _isBrowser["default"])()) { | ||
if (!mockUserAgent && !(0, _isBrowser.default)()) { | ||
return 'Node'; | ||
} | ||
if ((0, _isElectron["default"])(mockUserAgent)) { | ||
if ((0, _isElectron.default)(mockUserAgent)) { | ||
return 'Electron'; | ||
@@ -30,0 +30,0 @@ } |
@@ -17,3 +17,3 @@ "use strict"; | ||
document: typeof document !== 'undefined' && document, | ||
process: (typeof process === "undefined" ? "undefined" : (0, _typeof2["default"])(process)) === 'object' && process | ||
process: (typeof process === "undefined" ? "undefined" : (0, _typeof2.default)(process)) === 'object' && process | ||
}; | ||
@@ -20,0 +20,0 @@ var self_ = globals.self || globals.window || globals.global; |
@@ -5,3 +5,3 @@ "use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _typeof = require("@babel/runtime/helpers/typeof"); | ||
@@ -50,3 +50,3 @@ Object.defineProperty(exports, "__esModule", { | ||
get: function get() { | ||
return _isBrowser["default"]; | ||
return _isBrowser.default; | ||
} | ||
@@ -63,3 +63,3 @@ }); | ||
get: function get() { | ||
return _getBrowser["default"]; | ||
return _getBrowser.default; | ||
} | ||
@@ -76,3 +76,3 @@ }); | ||
get: function get() { | ||
return _isElectron["default"]; | ||
return _isElectron.default; | ||
} | ||
@@ -88,2 +88,6 @@ }); | ||
var _isElectron = _interopRequireDefault(require("./is-electron")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
//# sourceMappingURL=index.js.map |
@@ -8,3 +8,3 @@ "use strict"; | ||
}); | ||
exports["default"] = isBrowser; | ||
exports.default = isBrowser; | ||
exports.isBrowserMainThread = isBrowserMainThread; | ||
@@ -17,4 +17,4 @@ | ||
function isBrowser() { | ||
var isNode = (typeof process === "undefined" ? "undefined" : (0, _typeof2["default"])(process)) === 'object' && String(process) === '[object process]' && !process.browser; | ||
return !isNode || (0, _isElectron["default"])(); | ||
var isNode = (typeof process === "undefined" ? "undefined" : (0, _typeof2.default)(process)) === 'object' && String(process) === '[object process]' && !process.browser; | ||
return !isNode || (0, _isElectron.default)(); | ||
} | ||
@@ -21,0 +21,0 @@ |
@@ -8,3 +8,3 @@ "use strict"; | ||
}); | ||
exports["default"] = isElectron; | ||
exports.default = isElectron; | ||
@@ -14,11 +14,11 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
function isElectron(mockUserAgent) { | ||
if (typeof window !== 'undefined' && (0, _typeof2["default"])(window.process) === 'object' && window.process.type === 'renderer') { | ||
if (typeof window !== 'undefined' && (0, _typeof2.default)(window.process) === 'object' && window.process.type === 'renderer') { | ||
return true; | ||
} | ||
if (typeof process !== 'undefined' && (0, _typeof2["default"])(process.versions) === 'object' && Boolean(process.versions.electron)) { | ||
if (typeof process !== 'undefined' && (0, _typeof2.default)(process.versions) === 'object' && Boolean(process.versions.electron)) { | ||
return true; | ||
} | ||
var realUserAgent = (typeof navigator === "undefined" ? "undefined" : (0, _typeof2["default"])(navigator)) === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent; | ||
var realUserAgent = (typeof navigator === "undefined" ? "undefined" : (0, _typeof2.default)(navigator)) === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent; | ||
var userAgent = mockUserAgent || realUserAgent; | ||
@@ -25,0 +25,0 @@ |
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _typeof = require("@babel/runtime/helpers/typeof"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -13,3 +13,3 @@ value: true | ||
get: function get() { | ||
return _log["default"]; | ||
return _log.default; | ||
} | ||
@@ -62,3 +62,3 @@ }); | ||
get: function get() { | ||
return _isBrowser["default"]; | ||
return _isBrowser.default; | ||
} | ||
@@ -75,3 +75,3 @@ }); | ||
get: function get() { | ||
return _getBrowser["default"]; | ||
return _getBrowser.default; | ||
} | ||
@@ -88,3 +88,3 @@ }); | ||
get: function get() { | ||
return _isElectron["default"]; | ||
return _isElectron.default; | ||
} | ||
@@ -95,3 +95,3 @@ }); | ||
get: function get() { | ||
return _assert["default"]; | ||
return _assert.default; | ||
} | ||
@@ -132,3 +132,3 @@ }); | ||
get: function get() { | ||
return _localStorage["default"]; | ||
return _localStorage.default; | ||
} | ||
@@ -139,3 +139,3 @@ }); | ||
get: function get() { | ||
return _hiResTimestamp["default"]; | ||
return _hiResTimestamp.default; | ||
} | ||
@@ -155,3 +155,3 @@ }); | ||
}); | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
@@ -186,7 +186,11 @@ require("./init"); | ||
var _default = new _log["default"]({ | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var _default = new _log.default({ | ||
id: 'probe.gl' | ||
}); | ||
exports["default"] = _default; | ||
exports.default = _default; | ||
//# sourceMappingURL=index.js.map |
@@ -9,3 +9,3 @@ "use strict"; | ||
exports.normalizeArguments = normalizeArguments; | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
@@ -67,12 +67,14 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
function Log() { | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { | ||
id: '' | ||
}, | ||
id = _ref.id; | ||
(0, _classCallCheck2["default"])(this, Log); | ||
(0, _classCallCheck2.default)(this, Log); | ||
this.id = id; | ||
this.VERSION = _globals.VERSION; | ||
this._startTs = (0, _hiResTimestamp["default"])(); | ||
this._deltaTs = (0, _hiResTimestamp["default"])(); | ||
this._startTs = (0, _hiResTimestamp.default)(); | ||
this._deltaTs = (0, _hiResTimestamp.default)(); | ||
this.LOG_THROTTLE_TIMEOUT = 0; | ||
this._storage = new _localStorage["default"]("__probe-".concat(this.id, "__"), DEFAULT_SETTINGS); | ||
this._storage = new _localStorage.default("__probe-".concat(this.id, "__"), DEFAULT_SETTINGS); | ||
this.userData = {}; | ||
@@ -84,3 +86,11 @@ this.timeStamp("".concat(this.id, " started")); | ||
(0, _createClass2["default"])(Log, [{ | ||
(0, _createClass2.default)(Log, [{ | ||
key: "level", | ||
get: function get() { | ||
return this.getLevel(); | ||
}, | ||
set: function set(newLevel) { | ||
this.setLevel(newLevel); | ||
} | ||
}, { | ||
key: "isEnabled", | ||
@@ -98,3 +108,3 @@ value: function isEnabled() { | ||
value: function getTotal() { | ||
return Number(((0, _hiResTimestamp["default"])() - this._startTs).toPrecision(10)); | ||
return Number(((0, _hiResTimestamp.default)() - this._startTs).toPrecision(10)); | ||
} | ||
@@ -104,5 +114,13 @@ }, { | ||
value: function getDelta() { | ||
return Number(((0, _hiResTimestamp["default"])() - this._deltaTs).toPrecision(10)); | ||
return Number(((0, _hiResTimestamp.default)() - this._deltaTs).toPrecision(10)); | ||
} | ||
}, { | ||
key: "priority", | ||
get: function get() { | ||
return this.level; | ||
}, | ||
set: function set(newPriority) { | ||
this.level = newPriority; | ||
} | ||
}, { | ||
key: "getPriority", | ||
@@ -135,3 +153,3 @@ value: function getPriority() { | ||
value: function assert(condition, message) { | ||
(0, _assert2["default"])(condition, message); | ||
(0, _assert2.default)(condition, message); | ||
} | ||
@@ -234,3 +252,3 @@ }, { | ||
value: function set(setting, value) { | ||
this._storage.updateConfiguration((0, _defineProperty2["default"])({}, setting, value)); | ||
this._storage.updateConfiguration((0, _defineProperty2.default)({}, setting, value)); | ||
} | ||
@@ -320,6 +338,6 @@ }, { | ||
method = method || opts.method; | ||
(0, _assert2["default"])(method); | ||
(0, _assert2.default)(method); | ||
opts.total = this.getTotal(); | ||
opts.delta = this.getDelta(); | ||
this._deltaTs = (0, _hiResTimestamp["default"])(); | ||
this._deltaTs = (0, _hiResTimestamp.default)(); | ||
var tag = opts.tag || opts.message; | ||
@@ -329,3 +347,3 @@ | ||
if (!cache[tag]) { | ||
cache[tag] = (0, _hiResTimestamp["default"])(); | ||
cache[tag] = (0, _hiResTimestamp.default)(); | ||
} else { | ||
@@ -337,3 +355,3 @@ return noop; | ||
message = decorateMessage(this.id, opts.message, opts); | ||
return (_method = method).bind.apply(_method, [console, message].concat((0, _toConsumableArray2["default"])(opts.args))); | ||
return (_method = method).bind.apply(_method, [console, message].concat((0, _toConsumableArray2.default)(opts.args))); | ||
} | ||
@@ -343,18 +361,2 @@ | ||
} | ||
}, { | ||
key: "level", | ||
set: function set(newLevel) { | ||
this.setLevel(newLevel); | ||
}, | ||
get: function get() { | ||
return this.getLevel(); | ||
} | ||
}, { | ||
key: "priority", | ||
set: function set(newPriority) { | ||
this.level = newPriority; | ||
}, | ||
get: function get() { | ||
return this.level; | ||
} | ||
}]); | ||
@@ -364,3 +366,3 @@ return Log; | ||
exports["default"] = Log; | ||
exports.default = Log; | ||
Log.VERSION = _globals.VERSION; | ||
@@ -375,3 +377,3 @@ | ||
switch ((0, _typeof2["default"])(logLevel)) { | ||
switch ((0, _typeof2.default)(logLevel)) { | ||
case 'number': | ||
@@ -389,3 +391,3 @@ resolvedLevel = logLevel; | ||
(0, _assert2["default"])(Number.isFinite(resolvedLevel) && resolvedLevel >= 0); | ||
(0, _assert2.default)(Number.isFinite(resolvedLevel) && resolvedLevel >= 0); | ||
return resolvedLevel; | ||
@@ -404,3 +406,3 @@ } | ||
switch ((0, _typeof2["default"])(logLevel)) { | ||
switch ((0, _typeof2.default)(logLevel)) { | ||
case 'string': | ||
@@ -426,4 +428,4 @@ case 'function': | ||
var messageType = (0, _typeof2["default"])(opts.message); | ||
(0, _assert2["default"])(messageType === 'string' || messageType === 'object'); | ||
var messageType = (0, _typeof2.default)(opts.message); | ||
(0, _assert2.default)(messageType === 'string' || messageType === 'object'); | ||
return Object.assign(opts, opts.opts); | ||
@@ -483,3 +485,3 @@ } | ||
(_console = console).log.apply(_console, (0, _toConsumableArray2["default"])(args)); | ||
(_console = console).log.apply(_console, (0, _toConsumableArray2.default)(args)); | ||
}; | ||
@@ -496,3 +498,3 @@ | ||
(_console2 = console).log.apply(_console2, (0, _toConsumableArray2["default"])((0, _formatters.formatImage)(image, message, scale))); | ||
(_console2 = console).log.apply(_console2, (0, _toConsumableArray2.default)((0, _formatters.formatImage)(image, message, scale))); | ||
@@ -508,3 +510,3 @@ return noop; | ||
return (_console3 = console).log.apply(_console3, (0, _toConsumableArray2["default"])((0, _formatters.formatImage)(_img, message, scale))); | ||
return (_console3 = console).log.apply(_console3, (0, _toConsumableArray2.default)((0, _formatters.formatImage)(_img, message, scale))); | ||
}; | ||
@@ -511,0 +513,0 @@ |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports["default"] = assert; | ||
exports.default = assert; | ||
@@ -9,0 +9,0 @@ function assert(condition, message) { |
@@ -8,5 +8,5 @@ "use strict"; | ||
function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } | ||
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
@@ -13,0 +13,0 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } |
@@ -52,4 +52,4 @@ "use strict"; | ||
exports.VERSION = VERSION; | ||
var isBrowser = (0, _isBrowser["default"])(); | ||
var isBrowser = (0, _isBrowser.default)(); | ||
exports.isBrowser = isBrowser; | ||
//# sourceMappingURL=globals.js.map |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports["default"] = getHiResTimestamp; | ||
exports.default = getHiResTimestamp; | ||
@@ -9,0 +9,0 @@ var _globals = require("./globals"); |
@@ -8,3 +8,3 @@ "use strict"; | ||
}); | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
@@ -30,3 +30,3 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'sessionStorage'; | ||
(0, _classCallCheck2["default"])(this, LocalStorage); | ||
(0, _classCallCheck2.default)(this, LocalStorage); | ||
this.storage = getStorage(type); | ||
@@ -40,3 +40,3 @@ this.id = id; | ||
(0, _createClass2["default"])(LocalStorage, [{ | ||
(0, _createClass2.default)(LocalStorage, [{ | ||
key: "getConfiguration", | ||
@@ -81,3 +81,3 @@ value: function getConfiguration() { | ||
exports["default"] = LocalStorage; | ||
exports.default = LocalStorage; | ||
//# sourceMappingURL=local-storage.js.map |
@@ -16,4 +16,4 @@ import { window } from './globals'; | ||
var navigator_ = typeof navigator !== 'undefined' ? navigator : {}; | ||
var userAgent = mockUserAgent || navigator_.userAgent || ''; | ||
const navigator_ = typeof navigator !== 'undefined' ? navigator : {}; | ||
const userAgent = mockUserAgent || navigator_.userAgent || ''; | ||
@@ -24,4 +24,4 @@ if (userAgent.indexOf('Edge') > -1) { | ||
var isMSIE = userAgent.indexOf('MSIE ') !== -1; | ||
var isTrident = userAgent.indexOf('Trident/') !== -1; | ||
const isMSIE = userAgent.indexOf('MSIE ') !== -1; | ||
const isTrident = userAgent.indexOf('Trident/') !== -1; | ||
@@ -28,0 +28,0 @@ if (isMSIE || isTrident) { |
@@ -1,3 +0,2 @@ | ||
import _typeof from "@babel/runtime/helpers/esm/typeof"; | ||
var globals = { | ||
const globals = { | ||
self: typeof self !== 'undefined' && self, | ||
@@ -7,11 +6,11 @@ window: typeof window !== 'undefined' && window, | ||
document: typeof document !== 'undefined' && document, | ||
process: (typeof process === "undefined" ? "undefined" : _typeof(process)) === 'object' && process | ||
process: typeof process === 'object' && process | ||
}; | ||
var self_ = globals.self || globals.window || globals.global; | ||
var window_ = globals.window || globals.self || globals.global; | ||
var global_ = globals.global || globals.self || globals.window; | ||
var document_ = globals.document || {}; | ||
var process_ = globals.process || {}; | ||
var console_ = console; | ||
const self_ = globals.self || globals.window || globals.global; | ||
const window_ = globals.window || globals.self || globals.global; | ||
const global_ = globals.global || globals.self || globals.window; | ||
const document_ = globals.document || {}; | ||
const process_ = globals.process || {}; | ||
const console_ = console; | ||
export { self_ as self, window_ as window, global_ as global, document_ as document, process_ as process, console_ as console }; | ||
//# sourceMappingURL=globals.js.map |
@@ -1,5 +0,4 @@ | ||
import _typeof from "@babel/runtime/helpers/esm/typeof"; | ||
import isElectron from './is-electron'; | ||
export default function isBrowser() { | ||
var isNode = (typeof process === "undefined" ? "undefined" : _typeof(process)) === 'object' && String(process) === '[object process]' && !process.browser; | ||
const isNode = typeof process === 'object' && String(process) === '[object process]' && !process.browser; | ||
return !isNode || isElectron(); | ||
@@ -6,0 +5,0 @@ } |
@@ -1,13 +0,12 @@ | ||
import _typeof from "@babel/runtime/helpers/esm/typeof"; | ||
export default function isElectron(mockUserAgent) { | ||
if (typeof window !== 'undefined' && _typeof(window.process) === 'object' && window.process.type === 'renderer') { | ||
if (typeof window !== 'undefined' && typeof window.process === 'object' && window.process.type === 'renderer') { | ||
return true; | ||
} | ||
if (typeof process !== 'undefined' && _typeof(process.versions) === 'object' && Boolean(process.versions.electron)) { | ||
if (typeof process !== 'undefined' && typeof process.versions === 'object' && Boolean(process.versions.electron)) { | ||
return true; | ||
} | ||
var realUserAgent = (typeof navigator === "undefined" ? "undefined" : _typeof(navigator)) === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent; | ||
var userAgent = mockUserAgent || realUserAgent; | ||
const realUserAgent = typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent; | ||
const userAgent = mockUserAgent || realUserAgent; | ||
@@ -14,0 +13,0 @@ if (userAgent && userAgent.indexOf('Electron') >= 0) { |
@@ -1,6 +0,1 @@ | ||
import _typeof from "@babel/runtime/helpers/esm/typeof"; | ||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray"; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/esm/createClass"; | ||
import { VERSION, isBrowser } from '../utils/globals'; | ||
@@ -11,5 +6,5 @@ import LocalStorage from '../utils/local-storage'; | ||
import { autobind } from '../utils/autobind'; | ||
import _assert from '../utils/assert'; | ||
import assert from '../utils/assert'; | ||
import getHiResTimestamp from '../utils/hi-res-timestamp'; | ||
var originalConsole = { | ||
const originalConsole = { | ||
debug: isBrowser ? console.debug || console.log : console.log, | ||
@@ -21,3 +16,3 @@ log: console.log, | ||
}; | ||
var DEFAULT_SETTINGS = { | ||
const DEFAULT_SETTINGS = { | ||
enabled: true, | ||
@@ -29,4 +24,4 @@ level: 0 | ||
var cache = {}; | ||
var ONCE = { | ||
const cache = {}; | ||
const ONCE = { | ||
once: true | ||
@@ -36,4 +31,4 @@ }; | ||
function getTableHeader(table) { | ||
for (var key in table) { | ||
for (var title in table[key]) { | ||
for (const key in table) { | ||
for (const title in table[key]) { | ||
return title || 'untitled'; | ||
@@ -46,9 +41,8 @@ } | ||
var Log = function () { | ||
function Log() { | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
id = _ref.id; | ||
_classCallCheck(this, Log); | ||
export default class Log { | ||
constructor({ | ||
id | ||
} = { | ||
id: '' | ||
}) { | ||
this.id = id; | ||
@@ -66,277 +60,231 @@ this.VERSION = VERSION; | ||
_createClass(Log, [{ | ||
key: "isEnabled", | ||
value: function isEnabled() { | ||
return this._storage.config.enabled; | ||
} | ||
}, { | ||
key: "getLevel", | ||
value: function getLevel() { | ||
return this._storage.config.level; | ||
} | ||
}, { | ||
key: "getTotal", | ||
value: function getTotal() { | ||
return Number((getHiResTimestamp() - this._startTs).toPrecision(10)); | ||
} | ||
}, { | ||
key: "getDelta", | ||
value: function getDelta() { | ||
return Number((getHiResTimestamp() - this._deltaTs).toPrecision(10)); | ||
} | ||
}, { | ||
key: "getPriority", | ||
value: function getPriority() { | ||
return this.level; | ||
} | ||
}, { | ||
key: "enable", | ||
value: function enable() { | ||
var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; | ||
set level(newLevel) { | ||
this.setLevel(newLevel); | ||
} | ||
this._storage.updateConfiguration({ | ||
enabled: enabled | ||
}); | ||
get level() { | ||
return this.getLevel(); | ||
} | ||
return this; | ||
} | ||
}, { | ||
key: "setLevel", | ||
value: function setLevel(level) { | ||
this._storage.updateConfiguration({ | ||
level: level | ||
}); | ||
isEnabled() { | ||
return this._storage.config.enabled; | ||
} | ||
return this; | ||
} | ||
}, { | ||
key: "assert", | ||
value: function assert(condition, message) { | ||
_assert(condition, message); | ||
} | ||
}, { | ||
key: "warn", | ||
value: function warn(message) { | ||
return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE); | ||
} | ||
}, { | ||
key: "error", | ||
value: function error(message) { | ||
return this._getLogFunction(0, message, originalConsole.error, arguments); | ||
} | ||
}, { | ||
key: "deprecated", | ||
value: function deprecated(oldUsage, newUsage) { | ||
return this.warn("`".concat(oldUsage, "` is deprecated and will be removed in a later version. Use `").concat(newUsage, "` instead")); | ||
} | ||
}, { | ||
key: "removed", | ||
value: function removed(oldUsage, newUsage) { | ||
return this.error("`".concat(oldUsage, "` has been removed. Use `").concat(newUsage, "` instead")); | ||
} | ||
}, { | ||
key: "probe", | ||
value: function probe(logLevel, message) { | ||
return this._getLogFunction(logLevel, message, originalConsole.log, arguments, { | ||
time: true, | ||
once: true | ||
getLevel() { | ||
return this._storage.config.level; | ||
} | ||
getTotal() { | ||
return Number((getHiResTimestamp() - this._startTs).toPrecision(10)); | ||
} | ||
getDelta() { | ||
return Number((getHiResTimestamp() - this._deltaTs).toPrecision(10)); | ||
} | ||
set priority(newPriority) { | ||
this.level = newPriority; | ||
} | ||
get priority() { | ||
return this.level; | ||
} | ||
getPriority() { | ||
return this.level; | ||
} | ||
enable(enabled = true) { | ||
this._storage.updateConfiguration({ | ||
enabled | ||
}); | ||
return this; | ||
} | ||
setLevel(level) { | ||
this._storage.updateConfiguration({ | ||
level | ||
}); | ||
return this; | ||
} | ||
assert(condition, message) { | ||
assert(condition, message); | ||
} | ||
warn(message) { | ||
return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE); | ||
} | ||
error(message) { | ||
return this._getLogFunction(0, message, originalConsole.error, arguments); | ||
} | ||
deprecated(oldUsage, newUsage) { | ||
return this.warn("`".concat(oldUsage, "` is deprecated and will be removed in a later version. Use `").concat(newUsage, "` instead")); | ||
} | ||
removed(oldUsage, newUsage) { | ||
return this.error("`".concat(oldUsage, "` has been removed. Use `").concat(newUsage, "` instead")); | ||
} | ||
probe(logLevel, message) { | ||
return this._getLogFunction(logLevel, message, originalConsole.log, arguments, { | ||
time: true, | ||
once: true | ||
}); | ||
} | ||
log(logLevel, message) { | ||
return this._getLogFunction(logLevel, message, originalConsole.debug, arguments); | ||
} | ||
info(logLevel, message) { | ||
return this._getLogFunction(logLevel, message, console.info, arguments); | ||
} | ||
once(logLevel, message) { | ||
return this._getLogFunction(logLevel, message, originalConsole.debug || originalConsole.info, arguments, ONCE); | ||
} | ||
table(logLevel, table, columns) { | ||
if (table) { | ||
return this._getLogFunction(logLevel, table, console.table || noop, columns && [columns], { | ||
tag: getTableHeader(table) | ||
}); | ||
} | ||
}, { | ||
key: "log", | ||
value: function log(logLevel, message) { | ||
return this._getLogFunction(logLevel, message, originalConsole.debug, arguments); | ||
} | ||
}, { | ||
key: "info", | ||
value: function info(logLevel, message) { | ||
return this._getLogFunction(logLevel, message, console.info, arguments); | ||
} | ||
}, { | ||
key: "once", | ||
value: function once(logLevel, message) { | ||
return this._getLogFunction(logLevel, message, originalConsole.debug || originalConsole.info, arguments, ONCE); | ||
} | ||
}, { | ||
key: "table", | ||
value: function table(logLevel, _table, columns) { | ||
if (_table) { | ||
return this._getLogFunction(logLevel, _table, console.table || noop, columns && [columns], { | ||
tag: getTableHeader(_table) | ||
}); | ||
} | ||
return noop; | ||
} | ||
image({ | ||
logLevel, | ||
priority, | ||
image, | ||
message = '', | ||
scale = 1 | ||
}) { | ||
if (!this._shouldLog(logLevel || priority)) { | ||
return noop; | ||
} | ||
}, { | ||
key: "image", | ||
value: function image(_ref2) { | ||
var logLevel = _ref2.logLevel, | ||
priority = _ref2.priority, | ||
_image = _ref2.image, | ||
_ref2$message = _ref2.message, | ||
message = _ref2$message === void 0 ? '' : _ref2$message, | ||
_ref2$scale = _ref2.scale, | ||
scale = _ref2$scale === void 0 ? 1 : _ref2$scale; | ||
if (!this._shouldLog(logLevel || priority)) { | ||
return noop; | ||
} | ||
return isBrowser ? logImageInBrowser({ | ||
image, | ||
message, | ||
scale | ||
}) : logImageInNode({ | ||
image, | ||
message, | ||
scale | ||
}); | ||
} | ||
return isBrowser ? logImageInBrowser({ | ||
image: _image, | ||
message: message, | ||
scale: scale | ||
}) : logImageInNode({ | ||
image: _image, | ||
message: message, | ||
scale: scale | ||
}); | ||
settings() { | ||
if (console.table) { | ||
console.table(this._storage.config); | ||
} else { | ||
console.log(this._storage.config); | ||
} | ||
}, { | ||
key: "settings", | ||
value: function settings() { | ||
if (console.table) { | ||
console.table(this._storage.config); | ||
} else { | ||
console.log(this._storage.config); | ||
} | ||
} | ||
}, { | ||
key: "get", | ||
value: function get(setting) { | ||
return this._storage.config[setting]; | ||
} | ||
}, { | ||
key: "set", | ||
value: function set(setting, value) { | ||
this._storage.updateConfiguration(_defineProperty({}, setting, value)); | ||
} | ||
}, { | ||
key: "time", | ||
value: function time(logLevel, message) { | ||
return this._getLogFunction(logLevel, message, console.time ? console.time : console.info); | ||
} | ||
}, { | ||
key: "timeEnd", | ||
value: function timeEnd(logLevel, message) { | ||
return this._getLogFunction(logLevel, message, console.timeEnd ? console.timeEnd : console.info); | ||
} | ||
}, { | ||
key: "timeStamp", | ||
value: function timeStamp(logLevel, message) { | ||
return this._getLogFunction(logLevel, message, console.timeStamp || noop); | ||
} | ||
}, { | ||
key: "group", | ||
value: function group(logLevel, message) { | ||
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : { | ||
collapsed: false | ||
}; | ||
opts = normalizeArguments({ | ||
logLevel: logLevel, | ||
message: message, | ||
opts: opts | ||
}); | ||
var _opts = opts, | ||
collapsed = _opts.collapsed; | ||
opts.method = (collapsed ? console.groupCollapsed : console.group) || console.info; | ||
return this._getLogFunction(opts); | ||
} | ||
}, { | ||
key: "groupCollapsed", | ||
value: function groupCollapsed(logLevel, message) { | ||
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
return this.group(logLevel, message, Object.assign({}, opts, { | ||
collapsed: true | ||
})); | ||
} | ||
}, { | ||
key: "groupEnd", | ||
value: function groupEnd(logLevel) { | ||
return this._getLogFunction(logLevel, '', console.groupEnd || noop); | ||
} | ||
}, { | ||
key: "withGroup", | ||
value: function withGroup(logLevel, message, func) { | ||
this.group(logLevel, message)(); | ||
} | ||
try { | ||
func(); | ||
} finally { | ||
this.groupEnd(logLevel)(); | ||
} | ||
} | ||
}, { | ||
key: "trace", | ||
value: function trace() { | ||
if (console.trace) { | ||
console.trace(); | ||
} | ||
} | ||
}, { | ||
key: "_shouldLog", | ||
value: function _shouldLog(logLevel) { | ||
return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel); | ||
} | ||
}, { | ||
key: "_getLogFunction", | ||
value: function _getLogFunction(logLevel, message, method) { | ||
var args = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
var opts = arguments.length > 4 ? arguments[4] : undefined; | ||
get(setting) { | ||
return this._storage.config[setting]; | ||
} | ||
if (this._shouldLog(logLevel)) { | ||
var _method; | ||
set(setting, value) { | ||
this._storage.updateConfiguration({ | ||
[setting]: value | ||
}); | ||
} | ||
opts = normalizeArguments({ | ||
logLevel: logLevel, | ||
message: message, | ||
args: args, | ||
opts: opts | ||
}); | ||
method = method || opts.method; | ||
time(logLevel, message) { | ||
return this._getLogFunction(logLevel, message, console.time ? console.time : console.info); | ||
} | ||
_assert(method); | ||
timeEnd(logLevel, message) { | ||
return this._getLogFunction(logLevel, message, console.timeEnd ? console.timeEnd : console.info); | ||
} | ||
opts.total = this.getTotal(); | ||
opts.delta = this.getDelta(); | ||
this._deltaTs = getHiResTimestamp(); | ||
var tag = opts.tag || opts.message; | ||
timeStamp(logLevel, message) { | ||
return this._getLogFunction(logLevel, message, console.timeStamp || noop); | ||
} | ||
if (opts.once) { | ||
if (!cache[tag]) { | ||
cache[tag] = getHiResTimestamp(); | ||
} else { | ||
return noop; | ||
} | ||
} | ||
group(logLevel, message, opts = { | ||
collapsed: false | ||
}) { | ||
opts = normalizeArguments({ | ||
logLevel, | ||
message, | ||
opts | ||
}); | ||
const { | ||
collapsed | ||
} = opts; | ||
opts.method = (collapsed ? console.groupCollapsed : console.group) || console.info; | ||
return this._getLogFunction(opts); | ||
} | ||
message = decorateMessage(this.id, opts.message, opts); | ||
return (_method = method).bind.apply(_method, [console, message].concat(_toConsumableArray(opts.args))); | ||
} | ||
groupCollapsed(logLevel, message, opts = {}) { | ||
return this.group(logLevel, message, Object.assign({}, opts, { | ||
collapsed: true | ||
})); | ||
} | ||
return noop; | ||
groupEnd(logLevel) { | ||
return this._getLogFunction(logLevel, '', console.groupEnd || noop); | ||
} | ||
withGroup(logLevel, message, func) { | ||
this.group(logLevel, message)(); | ||
try { | ||
func(); | ||
} finally { | ||
this.groupEnd(logLevel)(); | ||
} | ||
}, { | ||
key: "level", | ||
set: function set(newLevel) { | ||
this.setLevel(newLevel); | ||
}, | ||
get: function get() { | ||
return this.getLevel(); | ||
} | ||
trace() { | ||
if (console.trace) { | ||
console.trace(); | ||
} | ||
}, { | ||
key: "priority", | ||
set: function set(newPriority) { | ||
this.level = newPriority; | ||
}, | ||
get: function get() { | ||
return this.level; | ||
} | ||
_shouldLog(logLevel) { | ||
return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel); | ||
} | ||
_getLogFunction(logLevel, message, method, args = [], opts) { | ||
if (this._shouldLog(logLevel)) { | ||
opts = normalizeArguments({ | ||
logLevel, | ||
message, | ||
args, | ||
opts | ||
}); | ||
method = method || opts.method; | ||
assert(method); | ||
opts.total = this.getTotal(); | ||
opts.delta = this.getDelta(); | ||
this._deltaTs = getHiResTimestamp(); | ||
const tag = opts.tag || opts.message; | ||
if (opts.once) { | ||
if (!cache[tag]) { | ||
cache[tag] = getHiResTimestamp(); | ||
} else { | ||
return noop; | ||
} | ||
} | ||
message = decorateMessage(this.id, opts.message, opts); | ||
return method.bind(console, message, ...opts.args); | ||
} | ||
}]); | ||
return Log; | ||
}(); | ||
return noop; | ||
} | ||
export { Log as default }; | ||
} | ||
Log.VERSION = VERSION; | ||
@@ -349,5 +297,5 @@ | ||
var resolvedLevel; | ||
let resolvedLevel; | ||
switch (_typeof(logLevel)) { | ||
switch (typeof logLevel) { | ||
case 'number': | ||
@@ -365,4 +313,3 @@ resolvedLevel = logLevel; | ||
_assert(Number.isFinite(resolvedLevel) && resolvedLevel >= 0); | ||
assert(Number.isFinite(resolvedLevel) && resolvedLevel >= 0); | ||
return resolvedLevel; | ||
@@ -372,6 +319,8 @@ } | ||
export function normalizeArguments(opts) { | ||
var logLevel = opts.logLevel, | ||
message = opts.message; | ||
const { | ||
logLevel, | ||
message | ||
} = opts; | ||
opts.logLevel = normalizeLogLevel(logLevel); | ||
var args = opts.args ? Array.from(opts.args) : []; | ||
const args = opts.args ? Array.from(opts.args) : []; | ||
@@ -382,3 +331,3 @@ while (args.length && args.shift() !== message) {} | ||
switch (_typeof(logLevel)) { | ||
switch (typeof logLevel) { | ||
case 'string': | ||
@@ -404,6 +353,4 @@ case 'function': | ||
var messageType = _typeof(opts.message); | ||
_assert(messageType === 'string' || messageType === 'object'); | ||
const messageType = typeof opts.message; | ||
assert(messageType === 'string' || messageType === 'object'); | ||
return Object.assign(opts, opts.opts); | ||
@@ -414,3 +361,3 @@ } | ||
if (typeof message === 'string') { | ||
var time = opts.time ? leftPad(formatTime(opts.total)) : ''; | ||
const time = opts.time ? leftPad(formatTime(opts.total)) : ''; | ||
message = opts.time ? "".concat(id, ": ").concat(time, " ").concat(message) : "".concat(id, ": ").concat(message); | ||
@@ -423,9 +370,8 @@ message = addColor(message, opts.color, opts.background); | ||
function logImageInNode(_ref3) { | ||
var image = _ref3.image, | ||
_ref3$message = _ref3.message, | ||
message = _ref3$message === void 0 ? '' : _ref3$message, | ||
_ref3$scale = _ref3.scale, | ||
scale = _ref3$scale === void 0 ? 1 : _ref3$scale; | ||
var asciify = null; | ||
function logImageInNode({ | ||
image, | ||
message = '', | ||
scale = 1 | ||
}) { | ||
let asciify = null; | ||
@@ -437,10 +383,6 @@ try { | ||
if (asciify) { | ||
return function () { | ||
return asciify(image, { | ||
fit: 'box', | ||
width: "".concat(Math.round(80 * scale), "%") | ||
}).then(function (data) { | ||
return console.log(data); | ||
}); | ||
}; | ||
return () => asciify(image, { | ||
fit: 'box', | ||
width: "".concat(Math.round(80 * scale), "%") | ||
}).then(data => console.log(data)); | ||
} | ||
@@ -451,18 +393,13 @@ | ||
function logImageInBrowser(_ref4) { | ||
var image = _ref4.image, | ||
_ref4$message = _ref4.message, | ||
message = _ref4$message === void 0 ? '' : _ref4$message, | ||
_ref4$scale = _ref4.scale, | ||
scale = _ref4$scale === void 0 ? 1 : _ref4$scale; | ||
function logImageInBrowser({ | ||
image, | ||
message = '', | ||
scale = 1 | ||
}) { | ||
if (typeof image === 'string') { | ||
var img = new Image(); | ||
const img = new Image(); | ||
img.onload = function () { | ||
var _console; | ||
var args = formatImage(img, message, scale); | ||
(_console = console).log.apply(_console, _toConsumableArray(args)); | ||
img.onload = () => { | ||
const args = formatImage(img, message, scale); | ||
console.log(...args); | ||
}; | ||
@@ -474,9 +411,6 @@ | ||
var element = image.nodeName || ''; | ||
const element = image.nodeName || ''; | ||
if (element.toLowerCase() === 'img') { | ||
var _console2; | ||
(_console2 = console).log.apply(_console2, _toConsumableArray(formatImage(image, message, scale))); | ||
console.log(...formatImage(image, message, scale)); | ||
return noop; | ||
@@ -486,11 +420,7 @@ } | ||
if (element.toLowerCase() === 'canvas') { | ||
var _img = new Image(); | ||
const img = new Image(); | ||
_img.onload = function () { | ||
var _console3; | ||
img.onload = () => console.log(...formatImage(img, message, scale)); | ||
return (_console3 = console).log.apply(_console3, _toConsumableArray(formatImage(_img, message, scale))); | ||
}; | ||
_img.src = image.toDataURL(); | ||
img.src = image.toDataURL(); | ||
return noop; | ||
@@ -497,0 +427,0 @@ } |
@@ -1,37 +0,13 @@ | ||
function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } | ||
export function autobind(obj, predefined = ['constructor']) { | ||
const proto = Object.getPrototypeOf(obj); | ||
const propNames = Object.getOwnPropertyNames(proto); | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
export function autobind(obj) { | ||
var predefined = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['constructor']; | ||
var proto = Object.getPrototypeOf(obj); | ||
var propNames = Object.getOwnPropertyNames(proto); | ||
var _iterator = _createForOfIteratorHelper(propNames), | ||
_step; | ||
try { | ||
var _loop = function _loop() { | ||
var key = _step.value; | ||
if (typeof obj[key] === 'function') { | ||
if (!predefined.find(function (name) { | ||
return key === name; | ||
})) { | ||
obj[key] = obj[key].bind(obj); | ||
} | ||
for (const key of propNames) { | ||
if (typeof obj[key] === 'function') { | ||
if (!predefined.find(name => key === name)) { | ||
obj[key] = obj[key].bind(obj); | ||
} | ||
}; | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
_loop(); | ||
} | ||
} catch (err) { | ||
_iterator.e(err); | ||
} finally { | ||
_iterator.f(); | ||
} | ||
} | ||
//# sourceMappingURL=autobind.js.map |
import { isBrowser } from './globals'; | ||
export var COLOR = { | ||
export const COLOR = { | ||
BLACK: 30, | ||
@@ -4,0 +4,0 @@ RED: 31, |
export function formatTime(ms) { | ||
var formatted; | ||
let formatted; | ||
@@ -16,17 +16,15 @@ if (ms < 10) { | ||
} | ||
export function leftPad(string) { | ||
var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 8; | ||
var padLength = Math.max(length - string.length, 0); | ||
export function leftPad(string, length = 8) { | ||
const padLength = Math.max(length - string.length, 0); | ||
return "".concat(' '.repeat(padLength)).concat(string); | ||
} | ||
export function rightPad(string) { | ||
var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 8; | ||
var padLength = Math.max(length - string.length, 0); | ||
export function rightPad(string, length = 8) { | ||
const padLength = Math.max(length - string.length, 0); | ||
return "".concat(string).concat(' '.repeat(padLength)); | ||
} | ||
export function formatValue(v) { | ||
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var EPSILON = 1e-16; | ||
var _opts$isInteger = opts.isInteger, | ||
isInteger = _opts$isInteger === void 0 ? false : _opts$isInteger; | ||
export function formatValue(v, opts = {}) { | ||
const EPSILON = 1e-16; | ||
const { | ||
isInteger = false | ||
} = opts; | ||
@@ -53,4 +51,4 @@ if (Array.isArray(v) || ArrayBuffer.isView(v)) { | ||
var string = v.toPrecision(2); | ||
var decimal = string.indexOf('.0'); | ||
const string = v.toPrecision(2); | ||
const decimal = string.indexOf('.0'); | ||
return decimal === string.length - 2 ? string.slice(0, -1) : string; | ||
@@ -60,9 +58,9 @@ } | ||
function formatArrayValue(v, opts) { | ||
var _opts$maxElts = opts.maxElts, | ||
maxElts = _opts$maxElts === void 0 ? 16 : _opts$maxElts, | ||
_opts$size = opts.size, | ||
size = _opts$size === void 0 ? 1 : _opts$size; | ||
var string = '['; | ||
const { | ||
maxElts = 16, | ||
size = 1 | ||
} = opts; | ||
let string = '['; | ||
for (var i = 0; i < v.length && i < maxElts; ++i) { | ||
for (let i = 0; i < v.length && i < maxElts; ++i) { | ||
if (i > 0) { | ||
@@ -75,9 +73,8 @@ string += ",".concat(i % size === 0 ? ' ' : ''); | ||
var terminator = v.length > maxElts ? '...' : ']'; | ||
const terminator = v.length > maxElts ? '...' : ']'; | ||
return "".concat(string).concat(terminator); | ||
} | ||
export function formatImage(image, message, scale) { | ||
var maxWidth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 600; | ||
var imageUrl = image.src.replace(/\(/g, '%28').replace(/\)/g, '%29'); | ||
export function formatImage(image, message, scale, maxWidth = 600) { | ||
const imageUrl = image.src.replace(/\(/g, '%28').replace(/\)/g, '%29'); | ||
@@ -88,7 +85,7 @@ if (image.width > maxWidth) { | ||
var width = image.width * scale; | ||
var height = image.height * scale; | ||
var style = ['font-size:1px;', "padding:".concat(Math.floor(height / 2), "px ").concat(Math.floor(width / 2), "px;"), "line-height:".concat(height, "px;"), "background:url(".concat(imageUrl, ");"), "background-size:".concat(width, "px ").concat(height, "px;"), 'color:transparent;'].join(''); | ||
const width = image.width * scale; | ||
const height = image.height * scale; | ||
const style = ['font-size:1px;', "padding:".concat(Math.floor(height / 2), "px ").concat(Math.floor(width / 2), "px;"), "line-height:".concat(height, "px;"), "background:url(".concat(imageUrl, ");"), "background-size:".concat(width, "px ").concat(height, "px;"), 'color:transparent;'].join(''); | ||
return ["".concat(message, " %c+"), style]; | ||
} | ||
//# sourceMappingURL=formatters.js.map |
import checkIfBrowser from '../env/is-browser'; | ||
export { self, window, global, document, process, console } from '../env/globals'; | ||
export var VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'untranspiled source'; | ||
export var isBrowser = checkIfBrowser(); | ||
export const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'untranspiled source'; | ||
export const isBrowser = checkIfBrowser(); | ||
//# sourceMappingURL=globals.js.map |
import { window, process, isBrowser } from './globals'; | ||
export default function getHiResTimestamp() { | ||
var timestamp; | ||
let timestamp; | ||
@@ -8,3 +8,3 @@ if (isBrowser && window.performance) { | ||
} else if (process.hrtime) { | ||
var timeParts = process.hrtime(); | ||
const timeParts = process.hrtime(); | ||
timestamp = timeParts[0] * 1000 + timeParts[1] / 1e6; | ||
@@ -11,0 +11,0 @@ } else { |
@@ -1,8 +0,5 @@ | ||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/esm/createClass"; | ||
function getStorage(type) { | ||
try { | ||
var storage = window[type]; | ||
var x = '__storage_test__'; | ||
const storage = window[type]; | ||
const x = '__storage_test__'; | ||
storage.setItem(x, x); | ||
@@ -16,8 +13,4 @@ storage.removeItem(x); | ||
var LocalStorage = function () { | ||
function LocalStorage(id, defaultSettings) { | ||
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'sessionStorage'; | ||
_classCallCheck(this, LocalStorage); | ||
export default class LocalStorage { | ||
constructor(id, defaultSettings, type = 'sessionStorage') { | ||
this.storage = getStorage(type); | ||
@@ -31,44 +24,35 @@ this.id = id; | ||
_createClass(LocalStorage, [{ | ||
key: "getConfiguration", | ||
value: function getConfiguration() { | ||
return this.config; | ||
} | ||
}, { | ||
key: "setConfiguration", | ||
value: function setConfiguration(configuration) { | ||
this.config = {}; | ||
return this.updateConfiguration(configuration); | ||
} | ||
}, { | ||
key: "updateConfiguration", | ||
value: function updateConfiguration(configuration) { | ||
Object.assign(this.config, configuration); | ||
getConfiguration() { | ||
return this.config; | ||
} | ||
if (this.storage) { | ||
var serialized = JSON.stringify(this.config); | ||
this.storage.setItem(this.id, serialized); | ||
} | ||
setConfiguration(configuration) { | ||
this.config = {}; | ||
return this.updateConfiguration(configuration); | ||
} | ||
return this; | ||
updateConfiguration(configuration) { | ||
Object.assign(this.config, configuration); | ||
if (this.storage) { | ||
const serialized = JSON.stringify(this.config); | ||
this.storage.setItem(this.id, serialized); | ||
} | ||
}, { | ||
key: "_loadConfiguration", | ||
value: function _loadConfiguration() { | ||
var configuration = {}; | ||
if (this.storage) { | ||
var serializedConfiguration = this.storage.getItem(this.id); | ||
configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {}; | ||
} | ||
return this; | ||
} | ||
Object.assign(this.config, configuration); | ||
return this; | ||
_loadConfiguration() { | ||
let configuration = {}; | ||
if (this.storage) { | ||
const serializedConfiguration = this.storage.getItem(this.id); | ||
configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {}; | ||
} | ||
}]); | ||
return LocalStorage; | ||
}(); | ||
Object.assign(this.config, configuration); | ||
return this; | ||
} | ||
export { LocalStorage as default }; | ||
} | ||
//# sourceMappingURL=local-storage.js.map |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "3.3.1", | ||
"version": "3.4.0-beta.1", | ||
"keywords": [ | ||
@@ -19,3 +19,2 @@ "javascript", | ||
"module": "dist/esm/index.js", | ||
"esnext": "dist/es6/index.js", | ||
"files": [ | ||
@@ -36,5 +35,5 @@ "dist", | ||
"@babel/runtime": "^7.0.0", | ||
"@probe.gl/stats": "3.3.1" | ||
"@probe.gl/stats": "3.4.0-beta.1" | ||
}, | ||
"gitHead": "95750096e0fe48d2861fdc9c125ef5ef17cf3ec2" | ||
"gitHead": "0fc5548022dd43b46cbf81b0d2d4da5d7702b95f" | ||
} |
@@ -29,2 +29,3 @@ // Copyright (c) 2017 Uber Technologies, Inc. | ||
export function isMobile() { | ||
// @ts-ignore | ||
return typeof window.orientation !== 'undefined'; | ||
@@ -58,8 +59,11 @@ } | ||
} | ||
// @ts-ignore | ||
if (window.chrome) { | ||
return 'Chrome'; | ||
} | ||
// @ts-ignore | ||
if (window.safari) { | ||
return 'Safari'; | ||
} | ||
// @ts-ignore | ||
if (window.mozInnerScreenX) { | ||
@@ -66,0 +70,0 @@ return 'Firefox'; |
@@ -9,2 +9,3 @@ // This function is needed in initialization stages, | ||
const isNode = | ||
// @ts-ignore | ||
typeof process === 'object' && String(process) === '[object process]' && !process.browser; | ||
@@ -11,0 +12,0 @@ |
@@ -9,2 +9,3 @@ // based on https://github.com/cheton/is-electron | ||
typeof window.process === 'object' && | ||
// @ts-ignore | ||
window.process.type === 'renderer' | ||
@@ -18,2 +19,3 @@ ) { | ||
typeof process.versions === 'object' && | ||
// @ts-ignore | ||
Boolean(process.versions.electron) | ||
@@ -20,0 +22,0 @@ ) { |
import {global} from './utils/globals'; | ||
// @ts-ignore | ||
global.probe = {}; |
@@ -91,3 +91,3 @@ // Copyright (c) 2017 Uber Technologies, Inc. | ||
export default class Log { | ||
constructor({id} = {}) { | ||
constructor({id} = {id: ''}) { | ||
this.id = id; | ||
@@ -167,2 +167,3 @@ this.VERSION = VERSION; | ||
warn(message) { | ||
// @ts-ignore | ||
return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE); | ||
@@ -173,2 +174,3 @@ } | ||
error(message) { | ||
// @ts-ignore | ||
return this._getLogFunction(0, message, originalConsole.error, arguments); | ||
@@ -190,2 +192,3 @@ } | ||
probe(logLevel, message) { | ||
// @ts-ignore | ||
return this._getLogFunction(logLevel, message, originalConsole.log, arguments, { | ||
@@ -199,2 +202,3 @@ time: true, | ||
log(logLevel, message) { | ||
// @ts-ignore | ||
return this._getLogFunction(logLevel, message, originalConsole.debug, arguments); | ||
@@ -205,2 +209,3 @@ } | ||
info(logLevel, message) { | ||
// @ts-ignore | ||
return this._getLogFunction(logLevel, message, console.info, arguments); | ||
@@ -215,2 +220,3 @@ } | ||
originalConsole.debug || originalConsole.info, | ||
// @ts-ignore | ||
arguments, | ||
@@ -217,0 +223,0 @@ ONCE |
@@ -7,4 +7,5 @@ import checkIfBrowser from '../env/is-browser'; | ||
/* global __VERSION__ */ | ||
// @ts-ignore | ||
export const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'untranspiled source'; | ||
export const isBrowser = checkIfBrowser(); |
@@ -21,2 +21,4 @@ // Copyright (c) 2017 Uber Technologies, Inc. | ||
// @ts-nocheck | ||
/** | ||
@@ -23,0 +25,0 @@ * Common environment setup |
@@ -23,2 +23,4 @@ // Copyright (c) 2017 Uber Technologies, Inc. | ||
try { | ||
/** @type {Storage} */ | ||
// @ts-ignore | ||
const storage = window[type]; | ||
@@ -25,0 +27,0 @@ const x = '__storage_test__'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
208856
80
2531
2
+ Added@probe.gl/stats@3.4.0-beta.1(transitive)
- Removed@probe.gl/stats@3.3.1(transitive)
Updated@probe.gl/stats@3.4.0-beta.1