UNPKG

kepler.gl

Version:

kepler.gl is a webgl based application to visualize large scale location data in the browser

151 lines (145 loc) 23.8 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.ERROR_MSG = void 0; exports.flattenDeps = flattenDeps; exports.injector = injector; exports.provideRecipesToInjector = provideRecipesToInjector; exports.typeCheckRecipe = typeCheckRecipe; exports.withState = withState; var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); var _react = _interopRequireDefault(require("react")); var _reactRedux = require("react-redux"); var _redux = require("redux"); var _window = require("global/window"); var _context = _interopRequireDefault(require("./context")); var _excluded = ["state"]; // SPDX-License-Identifier: MIT // Copyright contributors to the kepler.gl project function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } var MissingComp = function MissingComp() { return /*#__PURE__*/_react["default"].createElement("div", null); }; var ERROR_MSG = exports.ERROR_MSG = { wrongRecipeType: "injectComponents takes an array of factories replacement pairs as input, " + "each pair be a array as [originalFactory, replacement].", noDep: function noDep(fac, parent) { return "".concat(fac.name, " is required as a dependency of ").concat(parent.name, ", ") + "but is not provided to injectComponents. It will not be rendered."; }, notFunc: 'factory and its replacement should be a function' }; function injector() { var map = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map(); var cache = new Map(); // map<factory, factory -> ?> var _get = function get(fac, parent) { var factory = map.get(fac); // factory is not injected if (!factory) { _window.console.error(ERROR_MSG.noDep(fac, parent)); return MissingComp; } // check if custom factory deps is declared var instances = cache.get(factory) || factory.apply(void 0, (0, _toConsumableArray2["default"])(factory.deps ? factory.deps.map(function (dep) { return _get(dep, factory); }) : [])); cache.set(fac, instances); return instances; }; // if you have two functions that happen to have the exactly same text // it will be override: 2018-02-05 return { provide: function provide(factory, replacement) { if (!typeCheckRecipe([factory, replacement])) { return injector(map); } return injector(new Map(map).set(factory, replacement)); }, get: _get }; } // entryPoint function flattenDeps(allDeps, factory) { var addToDeps = allDeps.includes(factory) ? allDeps : allDeps.concat([factory]); return Array.isArray(factory.deps) && factory.deps.length ? factory.deps.reduce(function (accu, dep) { return flattenDeps(accu, dep); }, addToDeps) : addToDeps; } function provideRecipesToInjector(recipes, appInjector) { var provided = new Map(); var injector = recipes.reduce(function (inj, recipe) { var _inj; if (!typeCheckRecipe(recipe)) { return inj; } // collect dependencies of custom factories, if there is any. // Add them to the appInjector var customDependencies = flattenDeps([], recipe[1]); inj = customDependencies.reduce(function (ij, factory) { if (provided.get(factory)) { _window.console.warn("".concat(factory.name, " already injected from ").concat(provided.get(factory).name, ", injecting ").concat(recipe[0].name, " after ").concat(provided.get(factory).name, " will override it")); } return ij.provide(factory, factory); }, inj); provided.set(recipe[0], recipe[1]); return (_inj = inj).provide.apply(_inj, (0, _toConsumableArray2["default"])(recipe)); }, appInjector); // make sure all component instance are cached provided.forEach(function (v) { injector.get(v); }); return injector; } function typeCheckRecipe(recipe) { if (!Array.isArray(recipe) || recipe.length < 2) { _window.console.error('Error injecting [factory, replacement]', recipe); _window.console.error(ERROR_MSG.wrongRecipeType); return false; } var _recipe = (0, _slicedToArray2["default"])(recipe, 2), factory = _recipe[0], replacement = _recipe[1]; if (typeof factory !== 'function') { _window.console.error('Error injecting factory: ', factory); _window.console.error(ERROR_MSG.notFunc); return false; } else if (typeof replacement !== 'function') { _window.console.error('Error injecting replacement for: ', factory); _window.console.error(ERROR_MSG.notFunc); return false; } return true; } var identity = function identity(state) { return state; }; // Helper to add reducer state to custom component function withState() { var lenses = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var mapStateToProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity; var actions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; return function (Component) { var WrappedComponent = function WrappedComponent(_ref) { var state = _ref.state, props = (0, _objectWithoutProperties2["default"])(_ref, _excluded); return /*#__PURE__*/_react["default"].createElement(_context["default"].Consumer, null, function (context) { return /*#__PURE__*/_react["default"].createElement(Component, lenses.reduce(function (totalState, lens) { return _objectSpread(_objectSpread({}, totalState), lens(context.selector(state))); }, props)); }); }; return (0, _reactRedux.connect)(function (state) { return _objectSpread(_objectSpread({}, mapStateToProps(state)), {}, { state: state }); }, function (dispatch) { return Object.keys(actions).reduce(function (accu, key) { return _objectSpread(_objectSpread({}, accu), {}, (0, _defineProperty2["default"])({}, key, (0, _redux.bindActionCreators)(actions[key], dispatch))); }, {}); })(WrappedComponent); }; } //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfcmVhY3QiLCJfaW50ZXJvcFJlcXVpcmVEZWZhdWx0IiwicmVxdWlyZSIsIl9yZWFjdFJlZHV4IiwiX3JlZHV4IiwiX3dpbmRvdyIsIl9jb250ZXh0IiwiX2V4Y2x1ZGVkIiwib3duS2V5cyIsImUiLCJyIiwidCIsIk9iamVjdCIsImtleXMiLCJnZXRPd25Qcm9wZXJ0eVN5bWJvbHMiLCJvIiwiZmlsdGVyIiwiZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yIiwiZW51bWVyYWJsZSIsInB1c2giLCJ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