kepler.gl
Version:
kepler.gl is a webgl based application to visualize large scale location data in the browser
234 lines (187 loc) • 23.7 kB
JavaScript
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ContainerFactory = ContainerFactory;
exports.injectComponents = injectComponents;
exports["default"] = exports.appInjector = exports.ERROR_MSG = void 0;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _react = _interopRequireWildcard(require("react"));
var _reactRedux = require("react-redux");
var _lodash = _interopRequireDefault(require("lodash.memoize"));
var _window = require("global/window");
var _injector = require("./injector");
var _keplerGl = _interopRequireDefault(require("./kepler-gl"));
var _actionWrapper = require("../actions/action-wrapper");
var _identityActions = require("../actions/identity-actions");
var _dataUtils = require("../utils/data-utils");
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
var 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"
};
exports.ERROR_MSG = ERROR_MSG;
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_
* 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
*/
var Container =
/*#__PURE__*/
function (_Component) {
(0, _inherits2["default"])(Container, _Component);
// default id and address if not provided
function Container(props, ctx) {
var _this;
(0, _classCallCheck2["default"])(this, Container);
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(Container).call(this, props, ctx));
_this.getSelector = (0, _lodash["default"])(function (id, getState) {
return function (state) {
if (!getState(state)) {
// log error
_window.console.error(ERROR_MSG.noState);
return null;
}
return getState(state)[id];
};
});
_this.getDispatch = (0, _lodash["default"])(function (id, dispatch) {
return (0, _actionWrapper.forwardTo)(id, dispatch);
});
return _this;
}
(0, _createClass2["default"])(Container, [{
key: "componentDidMount",
value: function componentDidMount() {
var _this$props = this.props,
id = _this$props.id,
mint = _this$props.mint,
mapboxApiAccessToken = _this$props.mapboxApiAccessToken,
mapboxApiUrl = _this$props.mapboxApiUrl,
mapStylesReplaceDefault = _this$props.mapStylesReplaceDefault; // add a new entry to reducer
this.props.dispatch((0, _identityActions.registerEntry)({
id: id,
mint: mint,
mapboxApiAccessToken: mapboxApiAccessToken,
mapboxApiUrl: mapboxApiUrl,
mapStylesReplaceDefault: mapStylesReplaceDefault
}));
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps) {
// check if id has changed, if true, copy state over
if ((0, _dataUtils.notNullorUndefined)(prevProps.id) && (0, _dataUtils.notNullorUndefined)(this.props.id) && prevProps.id !== this.props.id) {
this.props.dispatch((0, _identityActions.renameEntry)(prevProps.id, this.props.id));
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
if (this.props.mint !== false) {
// delete entry in reducer
this.props.dispatch((0, _identityActions.deleteEntry)(this.props.id));
}
}
}, {
key: "render",
value: function render() {
var _this$props2 = this.props,
id = _this$props2.id,
getState = _this$props2.getState,
dispatch = _this$props2.dispatch,
state = _this$props2.state;
var selector = this.getSelector(id, getState);
if (!selector || !selector(state)) {
// instance state hasn't been mounted yet
return _react["default"].createElement("div", null);
}
return _react["default"].createElement(KeplerGl, (0, _extends2["default"])({}, this.props, {
id: id,
selector: selector,
dispatch: this.getDispatch(id, dispatch)
}));
}
}]);
return Container;
}(_react.Component);
(0, _defineProperty2["default"])(Container, "defaultProps", {
id: 'map',
getState: function getState(state) {
return state.keplerGl;
},
mint: true
});
var mapStateToProps = function mapStateToProps(state, props) {
return _objectSpread({
state: state
}, props);
};
var dispatchToProps = function dispatchToProps(dispatch) {
return {
dispatch: dispatch
};
};
return (0, _reactRedux.connect)(mapStateToProps, dispatchToProps)(Container);
} // entryPoint
function flattenDeps(allDeps, factory) {
var addToDeps = allDeps.concat([factory]);
return Array.isArray(factory.deps) && factory.deps.length ? factory.deps.reduce(function (accu, dep) {
return flattenDeps(accu, dep);
}, addToDeps) : addToDeps;
}
var allDependencies = flattenDeps([], ContainerFactory); // provide all dependencies to appInjector
var appInjector = allDependencies.reduce(function (inj, factory) {
return inj.provide(factory, factory);
}, (0, _injector.injector)()); // Helper to inject custom components and return kepler.gl container
exports.appInjector = appInjector;
function injectComponents() {
var recipes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
return recipes.reduce(function (inj, recipe) {
var _inj;
if (!(0, _injector.typeCheckRecipe)(recipe)) {
return inj;
} // collect dependencies of custom factories, if there is any.
// Add them to the injector
var customDependencies = flattenDeps([], recipe[1]);
inj = customDependencies.reduce(function (ij, factory) {
return ij.provide(factory, factory);
}, inj);
return (_inj = inj).provide.apply(_inj, (0, _toConsumableArray2["default"])(recipe));
}, appInjector).get(ContainerFactory);
}
var InjectedContainer = appInjector.get(ContainerFactory);
var _default = InjectedContainer;
exports["default"] = _default;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb21wb25lbnRzL2NvbnRhaW5lci5qcyJdLCJuYW1lcyI6WyJFUlJPUl9NU0ciLCJub1N0YXRlIiwiQ29udGFpbmVyRmFjdG9yeSIsImRlcHMiLCJLZXBsZXJHbEZhY3RvcnkiLCJLZXBsZXJHbCIsIkNvbnRhaW5lciIsInByb3BzIiwiY3R4IiwiZ2V0U2VsZWN0b3IiLCJpZCIsImdldFN0YXRlIiwic3RhdGUiLCJDb25zb2xlIiwiZXJyb3IiLCJnZXREaXNwYXRjaCIsImRpc3BhdGNoIiwibWludCIsIm1hcGJveEFwaUFjY2Vzc1Rva2VuIiwibWFwYm94QXBpVXJsIiwibWFwU3R5bGVzUmVwbGFjZURlZmF1bHQiLCJwcmV2UHJvcHMiLCJzZWxlY3RvciIsIkNvbXBvbmVudCIsImtlcGxlckdsIiwibWFwU3RhdGVUb1Byb3BzIiwiZGlzcGF0Y2hUb1Byb3BzI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