UNPKG

kepler.gl

Version:

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

181 lines (173 loc) 26.2 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _typeof = require("@babel/runtime/helpers/typeof"); Object.defineProperty(exports, "__esModule", { value: true }); exports.ContainerFactory = ContainerFactory; exports["default"] = exports.appInjector = exports.ERROR_MSG = void 0; exports.injectComponents = injectComponents; var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _react = _interopRequireWildcard(require("react")); var _reactRedux = require("react-redux"); var _window = require("global/window"); var _injector = require("./injector"); var _keplerGl = _interopRequireDefault(require("./kepler-gl")); var _actions = require("@kepler.gl/actions"); var _utils = require("@kepler.gl/utils"); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; } 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; } // SPDX-License-Identifier: MIT // Copyright contributors to the kepler.gl project var ERROR_MSG = exports.ERROR_MSG = { noState: "kepler.gl state does not exist. " + "You might forget to mount keplerGlReducer in your root reducer." + "If it is not mounted as state.keplerGl by default, you need to provide getState as a prop" }; var mapStateToProps = function mapStateToProps(state, props) { return _objectSpread({ state: state }, props); }; var dispatchToProps = function dispatchToProps(dispatch) { return { dispatch: dispatch }; }; var connector = (0, _reactRedux.connect)(mapStateToProps, dispatchToProps); ContainerFactory.deps = [_keplerGl["default"]]; function ContainerFactory(KeplerGl) { /** @lends KeplerGl */ /** * Main Kepler.gl Component * @param {Object} props * * @param {string} props.id - _required_ * * - Default: `map` * The id of this KeplerGl instance. `id` is required if you have multiple * KeplerGl instances in your app. It defines the prop name of the KeplerGl state that is * stored in the KeplerGl reducer. For example, the state of the KeplerGl component with id `foo` is * stored in `state.keplerGl.foo`. * * In case you create multiple kepler.gl instances using the same id, the kepler.gl state defined by the entry will be * overridden by the latest instance and reset to a blank state. * @param {string} props.mapboxApiAccessToken - _required_ * @param {string} props.mapboxApiUrl - _optional_ * @param {Boolean} props.mapStylesReplaceDefault - _optional_ * @param {object} props.initialUiState - _optional_ * You can create a free account at [www.mapbox.com](www.mapbox.com) and create a token at * [www.mapbox.com/account/access-tokens](www.mapbox.com/account/access-tokens) * * * @param {Number} props.width - _required_ Width of the KeplerGl UI. * @public */ function usePreviousId(value) { var ref = (0, _react.useRef)(); (0, _react.useEffect)(function () { ref.current = value; }); return ref.current; } var Container = function Container(props) { var _props$id = props.id, id = _props$id === void 0 ? 'map' : _props$id, _props$getState = props.getState, getState = _props$getState === void 0 ? function (state) { return state.keplerGl; } : _props$getState, _props$mint = props.mint, mint = _props$mint === void 0 ? true : _props$mint, mapboxApiAccessToken = props.mapboxApiAccessToken, mapboxApiUrl = props.mapboxApiUrl, mapStylesReplaceDefault = props.mapStylesReplaceDefault, initialUiState = props.initialUiState, state = props.state; var prevId = usePreviousId(id); var dispatch = (0, _reactRedux.useDispatch)(); (0, _react.useEffect)(function () { // add a new entry to reducer dispatch((0, _actions.registerEntry)({ id: id, mint: mint, mapboxApiAccessToken: mapboxApiAccessToken, mapboxApiUrl: mapboxApiUrl, mapStylesReplaceDefault: mapStylesReplaceDefault, initialUiState: initialUiState })); // initialize plugins if ((0, _utils.getApplicationConfig)().plugins.length) { (0, _utils.getApplicationConfig)().plugins.forEach( /*#__PURE__*/function () { var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(plugin) { return _regenerator["default"].wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 2; return plugin.init(); case 2: case "end": return _context.stop(); } }, _callee); })); return function (_x) { return _ref.apply(this, arguments); }; }()); } // cleanup return function () { if (mint !== false) { // delete entry in reducer dispatch((0, _actions.deleteEntry)(id)); } }; }, [id, dispatch, initialUiState, mapStylesReplaceDefault, mapboxApiAccessToken, mapboxApiUrl, mint]); (0, _react.useEffect)(function () { // check if id has changed, if true, copy state over if (prevId && id && prevId !== id) { dispatch((0, _actions.renameEntry)(prevId, id)); } }, [dispatch, prevId, id]); var stateSelector = (0, _react.useMemo)(function () { return function (keplerState) { if (!getState(keplerState)) { // log error _window.console.error(ERROR_MSG.noState); return null; } return getState(keplerState)[id]; }; }, [id, getState]); var forwardDispatch = (0, _react.useMemo)(function () { return (0, _actions.forwardTo)(id, dispatch); }, [id, dispatch]); // const selector = getSelector(id, getState); if (!stateSelector || !stateSelector(state)) { // instance state hasn't been mounted yet return /*#__PURE__*/_react["default"].createElement("div", null); } return /*#__PURE__*/_react["default"].createElement(KeplerGl, (0, _extends2["default"])({}, props, { id: id, selector: stateSelector, dispatch: forwardDispatch })); }; return connector(Container); } var allDependencies = (0, _injector.flattenDeps)([], ContainerFactory); // provide all dependencies to appInjector var appInjector = exports.appInjector = allDependencies.reduce(function (inj, factory) { return inj.provide(factory, factory); }, (0, _injector.injector)()); // Helper to inject custom components and return kepler.gl container function injectComponents() { var recipes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; return (0, _injector.provideRecipesToInjector)(recipes, appInjector).get(ContainerFactory); } var InjectedContainer = appInjector.get(ContainerFactory); var _default = exports["default"] = InjectedContainer; //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfcmVhY3QiLCJfaW50ZXJvcFJlcXVpcmVXaWxkY2FyZCIsInJlcXVpcmUiLCJfcmVhY3RSZWR1eCIsIl93aW5kb3ciLCJfaW5qZWN0b3IiLCJfa2VwbGVyR2wiLCJfaW50ZXJvcFJlcXVpcmVEZWZhdWx0IiwiX2FjdGlvbnMiLCJfdXRpbHMiLCJfZ2V0UmVxdWlyZVdpbGRjYXJkQ2FjaGUiLCJlIiwiV2Vha01hcCIsInIiLCJ0IiwiX19lc01vZHVsZSIsIl90eXBlb2YiLCJoYXMiLCJnZXQiLCJuIiwiX19wcm90b19fIiwiYSIsIk9iamVjdCIsImRlZmluZVByb3BlcnR5IiwiZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yIiwidSIsImhhc093blByb3BlcnR5IiwiY2FsbCIsImkiLCJzZXQiLCJvd25LZXlzIiwia2V5cyIsImdldE93blByb3BlcnR5U3ltYm9scyIsIm8iLCJmaWx0ZXIiLCJlbnVtZXJhYmxlIiwicHVzaCIsImFwcGx5IiwiX29iamVjdFNwcmVhZCIsImFyZ3VtZW50cyIsImxlbmd0aCIsImZvckVhY2giLCJfZGVmaW5lUHJvcGVydHkyIiwiZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9ycyIsImRlZmluZVByb3BlcnRpZXMiLCJ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