Browse Source

fix for babelHelper

windsome.feng 7 years ago
parent
commit
f0e0e87ba4
10 changed files with 226 additions and 256 deletions
  1. 11 8
      lib/APILoader.js
  2. 30 29
      lib/Map.js
  3. 29 29
      lib/Marker.js
  4. 29 29
      lib/MassMarks.js
  5. 29 29
      lib/Polygon.js
  6. 29 29
      lib/Polyline.js
  7. 42 55
      lib/api.js
  8. 5 13
      lib/loadScript.js
  9. 12 28
      lib/webservice.js
  10. 10 7
      package.json

+ 11 - 8
lib/APILoader.js

@@ -1,8 +1,9 @@
-'use strict';
+var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
-Object.defineProperty(exports, "__esModule", {
-  value: true
-});
 var DEFAULT_CONFIG = {
   v: '1.4.0',
   hostAndPath: 'webapi.amap.com/maps',
@@ -21,9 +22,10 @@ var APILoader = function () {
         useAMapUI = _ref.useAMapUI,
         version = _ref.version,
         protocol = _ref.protocol;
-    babelHelpers.classCallCheck(this, APILoader);
 
-    this.config = babelHelpers.extends({}, DEFAULT_CONFIG, { useAMapUI: useAMapUI, protocol: protocol });
+    _classCallCheck(this, APILoader);
+
+    this.config = _extends({}, DEFAULT_CONFIG, { useAMapUI: useAMapUI, protocol: protocol });
     if (typeof window !== 'undefined') {
       if (key) {
         this.config.key = key;
@@ -40,7 +42,7 @@ var APILoader = function () {
     }
   }
 
-  babelHelpers.createClass(APILoader, [{
+  _createClass(APILoader, [{
     key: 'getScriptSrc',
     value: function getScriptSrc(cfg) {
       return this.protocol + '//' + cfg.hostAndPath + '?v=' + cfg.v + '&key=' + cfg.key + '&callback=' + cfg.callback;
@@ -114,7 +116,8 @@ var APILoader = function () {
       });
     }
   }]);
+
   return APILoader;
 }();
 
-exports.default = APILoader;
+export default APILoader;

+ 30 - 29
lib/Map.js

@@ -1,31 +1,30 @@
-'use strict';
+var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
 
-Object.defineProperty(exports, "__esModule", {
-  value: true
-});
-exports.Map = undefined;
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
 
-var _react = require('react');
+function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
 
-var _react2 = babelHelpers.interopRequireDefault(_react);
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
-var _propTypes = require('prop-types');
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
 
-var _propTypes2 = babelHelpers.interopRequireDefault(_propTypes);
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
 
-var _api = require('./api');
+import React, { Component, PureComponent } from 'react';
+import PropTypes from 'prop-types';
+import { loadMap, createMap, updateMap } from './api';
 
 var __com__ = 'Map';
 //const debug = console.log;
 var debug = function debug() {};
 
-var Map = exports.Map = function (_Component) {
-  babelHelpers.inherits(Map, _Component);
+export var Map = function (_Component) {
+  _inherits(Map, _Component);
 
   function Map() {
-    babelHelpers.classCallCheck(this, Map);
+    _classCallCheck(this, Map);
 
-    var _this = babelHelpers.possibleConstructorReturn(this, (Map.__proto__ || Object.getPrototypeOf(Map)).call(this));
+    var _this = _possibleConstructorReturn(this, (Map.__proto__ || Object.getPrototypeOf(Map)).call(this));
 
     _this.refElement = null;
     _this._entity = null;
@@ -33,7 +32,7 @@ var Map = exports.Map = function (_Component) {
     return _this;
   }
 
-  babelHelpers.createClass(Map, [{
+  _createClass(Map, [{
     key: 'componentWillMount',
     value: function componentWillMount() {
       debug(__com__, 'componentWillMount', this.refElement, this._entity);
@@ -47,7 +46,7 @@ var Map = exports.Map = function (_Component) {
           options = _props.options,
           events = _props.events;
 
-      this._entity = (0, _api.createMap)(AMap, this.refElement, options, events);
+      this._entity = createMap(AMap, this.refElement, options, events);
       if (this._entity) {
         if (this.props.refer) this.props.refer(this._entity);
         this.setState({ __map__: this._entity });
@@ -73,7 +72,7 @@ var Map = exports.Map = function (_Component) {
           events = _props2.events;
 
       if (!this._entity) {
-        this._entity = (0, _api.createMap)(AMap, this.refElement, options, events);
+        this._entity = createMap(AMap, this.refElement, options, events);
         if (this._entity) {
           if (this.props.refer) this.props.refer(this._entity);
           this.setState({ __map__: this._entity });
@@ -82,7 +81,7 @@ var Map = exports.Map = function (_Component) {
       }
       // need check props changes, then update.
       //updateMap(this._entity, this.props, prevProps);
-      (0, _api.updateMap)(this._entity, options, events, prevProps.options, prevProps.events);
+      updateMap(this._entity, options, events, prevProps.options, prevProps.events);
     }
   }, {
     key: 'componentWillUnmount',
@@ -101,7 +100,7 @@ var Map = exports.Map = function (_Component) {
   }, {
     key: 'renderChildren',
     value: function renderChildren(children, __map__) {
-      return _react2.default.Children.map(children, function (child) {
+      return React.Children.map(children, function (child) {
         if (child) {
           var cType = child.type;
           /* 针对下面两种组件不注入地图相关属性
@@ -113,7 +112,7 @@ var Map = exports.Map = function (_Component) {
             return child;
           }
           debug(__com__, 'component renderChildren add __map__');
-          return _react2.default.cloneElement(child, {
+          return React.cloneElement(child, {
             __map__: __map__
           });
         }
@@ -139,6 +138,7 @@ var Map = exports.Map = function (_Component) {
       var _this2 = this;
 
       debug(__com__, 'component render', this._entity);
+
       var _props3 = this.props,
           AMap = _props3.AMap,
           options = _props3.options,
@@ -148,11 +148,11 @@ var Map = exports.Map = function (_Component) {
           history = _props3.history,
           children = _props3.children,
           staticContext = _props3.staticContext,
-          rest = babelHelpers.objectWithoutProperties(_props3, ['AMap', 'options', 'events', 'match', 'location', 'history', 'children', 'staticContext']);
+          rest = _objectWithoutProperties(_props3, ['AMap', 'options', 'events', 'match', 'location', 'history', 'children', 'staticContext']);
 
-      return _react2.default.createElement(
+      return React.createElement(
         'div',
-        babelHelpers.extends({
+        _extends({
           ref: function ref(ele) {
             _this2.refElement = ele;
           }
@@ -161,14 +161,15 @@ var Map = exports.Map = function (_Component) {
       );
     }
   }]);
+
   return Map;
-}(_react.Component);
+}(Component);
 
 Map.propTypes = {
-  AMap: _propTypes2.default.object,
-  refer: _propTypes2.default.func, // 类似ref的函数形式,可以让父组件调用_entity
-  options: _propTypes2.default.object,
-  events: _propTypes2.default.object
+  AMap: PropTypes.object,
+  refer: PropTypes.func, // 类似ref的函数形式,可以让父组件调用_entity
+  options: PropTypes.object,
+  events: PropTypes.object
   //   zoom: PropTypes.number, // 10, //设置地图显示的缩放级别
   //   center: PropTypes.array, // [116.397428, 39.90923],//设置地图中心点坐标
   //   layers: PropTypes.array, // [new AMap.TileLayer.Satellite()],  //设置图层,可设置成包含一个或多个图层的数组
@@ -177,4 +178,4 @@ Map.propTypes = {
   //   lang: PropTypes.string, // 'zh_cn',  //设置地图语言类型
   //   events: PropTypes.object, // {'click': function}, // 事件map
 };
-exports.default = Map;
+export default Map;

+ 29 - 29
lib/Marker.js

@@ -1,31 +1,29 @@
-'use strict';
+var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
 
-Object.defineProperty(exports, "__esModule", {
-  value: true
-});
-exports.Marker = undefined;
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
 
-var _react = require('react');
+function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
 
-var _react2 = babelHelpers.interopRequireDefault(_react);
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
-var _propTypes = require('prop-types');
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
 
-var _propTypes2 = babelHelpers.interopRequireDefault(_propTypes);
-
-var _api = require('./api');
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
 
+import React, { Component, PureComponent } from 'react';
+import PropTypes from 'prop-types';
+import { createMarker, updateMarker } from './api';
 var __com__ = 'Marker';
 //const debug = console.log;
 var debug = function debug() {};
 
-var Marker = exports.Marker = function (_Component) {
-  babelHelpers.inherits(Marker, _Component);
+export var Marker = function (_Component) {
+  _inherits(Marker, _Component);
 
   function Marker() {
-    babelHelpers.classCallCheck(this, Marker);
+    _classCallCheck(this, Marker);
 
-    var _this = babelHelpers.possibleConstructorReturn(this, (Marker.__proto__ || Object.getPrototypeOf(Marker)).call(this));
+    var _this = _possibleConstructorReturn(this, (Marker.__proto__ || Object.getPrototypeOf(Marker)).call(this));
 
     _this.refElement = null;
     _this._entity = null;
@@ -33,7 +31,7 @@ var Marker = exports.Marker = function (_Component) {
     return _this;
   }
 
-  babelHelpers.createClass(Marker, [{
+  _createClass(Marker, [{
     key: 'componentWillMount',
     value: function componentWillMount() {
       debug(__com__, 'componentWillMount', this.props.children, this._entity);
@@ -50,8 +48,8 @@ var Marker = exports.Marker = function (_Component) {
           children = _props.children;
       //let opts = { ...(options || {}), map: __map__, content: children };
 
-      var opts = babelHelpers.extends({}, options || {}, { map: __map__ });
-      this._entity = (0, _api.createMarker)(AMap, opts, events);
+      var opts = _extends({}, options || {}, { map: __map__ });
+      this._entity = createMarker(AMap, opts, events);
       if (this._entity) {
         if (this.props.refer) this.props.refer(this._entity);
       }
@@ -78,9 +76,9 @@ var Marker = exports.Marker = function (_Component) {
           children = _props2.children;
       //let opts = { ...(options || {}), map: __map__, content: children };
 
-      var opts = babelHelpers.extends({}, options || {}, { map: __map__ });
+      var opts = _extends({}, options || {}, { map: __map__ });
       if (!this._entity) {
-        this._entity = (0, _api.createMarker)(AMap, opts, events);
+        this._entity = createMarker(AMap, opts, events);
         if (this._entity) {
           if (this.props.refer) this.props.refer(this._entity);
         }
@@ -88,11 +86,11 @@ var Marker = exports.Marker = function (_Component) {
       }
 
       // need check props changes, then update.
-      var oldOpts = babelHelpers.extends({}, prevProps.options || {}, {
+      var oldOpts = _extends({}, prevProps.options || {}, {
         map: prevProps.__map__,
         content: prevProps.children
       });
-      (0, _api.updateMarker)(this._entity, opts, events, oldOpts, prevProps.events);
+      updateMarker(this._entity, opts, events, oldOpts, prevProps.events);
     }
   }, {
     key: 'componentWillUnmount',
@@ -125,6 +123,7 @@ var Marker = exports.Marker = function (_Component) {
     key: 'render',
     value: function render() {
       debug(__com__, 'render', this.props.children, this._entity);
+
       var _props3 = this.props,
           AMap = _props3.AMap,
           options = _props3.options,
@@ -133,7 +132,7 @@ var Marker = exports.Marker = function (_Component) {
           location = _props3.location,
           history = _props3.history,
           staticContext = _props3.staticContext,
-          rest = babelHelpers.objectWithoutProperties(_props3, ['AMap', 'options', 'events', 'match', 'location', 'history', 'staticContext']);
+          rest = _objectWithoutProperties(_props3, ['AMap', 'options', 'events', 'match', 'location', 'history', 'staticContext']);
 
       return null;
       // return (
@@ -142,14 +141,15 @@ var Marker = exports.Marker = function (_Component) {
       // )
     }
   }]);
+
   return Marker;
-}(_react.Component);
+}(Component);
 
 Marker.propTypes = {
-  AMap: _propTypes2.default.object,
-  __map__: _propTypes2.default.object,
-  options: _propTypes2.default.object,
-  events: _propTypes2.default.object
+  AMap: PropTypes.object,
+  __map__: PropTypes.object,
+  options: PropTypes.object,
+  events: PropTypes.object
   //   zoom: PropTypes.number, // 10, //设置地图显示的缩放级别
   //   center: PropTypes.array, // [116.397428, 39.90923],//设置地图中心点坐标
   //   layers: PropTypes.array, // [new AMap.TileLayer.Satellite()],  //设置图层,可设置成包含一个或多个图层的数组
@@ -158,4 +158,4 @@ Marker.propTypes = {
   //   lang: PropTypes.string, // 'zh_cn',  //设置地图语言类型
   //   events: PropTypes.object, // {'click': function}, // 事件map
 };
-exports.default = Marker;
+export default Marker;

+ 29 - 29
lib/MassMarks.js

@@ -1,31 +1,29 @@
-'use strict';
+var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
 
-Object.defineProperty(exports, "__esModule", {
-  value: true
-});
-exports.MassMarks = undefined;
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
 
-var _react = require('react');
+function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
 
-var _react2 = babelHelpers.interopRequireDefault(_react);
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
-var _propTypes = require('prop-types');
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
 
-var _propTypes2 = babelHelpers.interopRequireDefault(_propTypes);
-
-var _api = require('./api');
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
 
+import React, { Component, PureComponent } from 'react';
+import PropTypes from 'prop-types';
+import { createMassMarks, updateMassMarks } from './api';
 var __com__ = 'MassMarks';
 //const debug = console.log;
 var debug = function debug() {};
 
-var MassMarks = exports.MassMarks = function (_Component) {
-  babelHelpers.inherits(MassMarks, _Component);
+export var MassMarks = function (_Component) {
+  _inherits(MassMarks, _Component);
 
   function MassMarks() {
-    babelHelpers.classCallCheck(this, MassMarks);
+    _classCallCheck(this, MassMarks);
 
-    var _this = babelHelpers.possibleConstructorReturn(this, (MassMarks.__proto__ || Object.getPrototypeOf(MassMarks)).call(this));
+    var _this = _possibleConstructorReturn(this, (MassMarks.__proto__ || Object.getPrototypeOf(MassMarks)).call(this));
 
     _this.refElement = null;
     _this._entity = null;
@@ -33,7 +31,7 @@ var MassMarks = exports.MassMarks = function (_Component) {
     return _this;
   }
 
-  babelHelpers.createClass(MassMarks, [{
+  _createClass(MassMarks, [{
     key: 'componentWillMount',
     value: function componentWillMount() {
       debug(__com__, 'componentWillMount', this.props.children, this._entity);
@@ -50,8 +48,8 @@ var MassMarks = exports.MassMarks = function (_Component) {
           children = _props.children;
       //let opts = { ...(options || {}), map: __map__, content: children };
 
-      var opts = babelHelpers.extends({}, options || {}, { map: __map__ });
-      this._entity = (0, _api.createMassMarks)(AMap, opts, events);
+      var opts = _extends({}, options || {}, { map: __map__ });
+      this._entity = createMassMarks(AMap, opts, events);
     }
   }, {
     key: 'componentWillReceiveProps',
@@ -75,17 +73,17 @@ var MassMarks = exports.MassMarks = function (_Component) {
           children = _props2.children;
       //let opts = { ...(options || {}), map: __map__, content: children };
 
-      var opts = babelHelpers.extends({}, options || {}, { map: __map__ });
+      var opts = _extends({}, options || {}, { map: __map__ });
       if (!this._entity) {
-        this._entity = (0, _api.createMassMarks)(AMap, opts, events);
+        this._entity = createMassMarks(AMap, opts, events);
         return;
       }
 
       // need check props changes, then update.
-      var oldOpts = babelHelpers.extends({}, prevProps.options || {}, {
+      var oldOpts = _extends({}, prevProps.options || {}, {
         map: prevProps.__map__
       });
-      (0, _api.updateMassMarks)(this._entity, opts, events, oldOpts, prevProps.events);
+      updateMassMarks(this._entity, opts, events, oldOpts, prevProps.events);
     }
   }, {
     key: 'componentWillUnmount',
@@ -109,6 +107,7 @@ var MassMarks = exports.MassMarks = function (_Component) {
     key: 'render',
     value: function render() {
       debug(__com__, 'render', this.props.children, this._entity);
+
       var _props3 = this.props,
           AMap = _props3.AMap,
           options = _props3.options,
@@ -117,7 +116,7 @@ var MassMarks = exports.MassMarks = function (_Component) {
           location = _props3.location,
           history = _props3.history,
           staticContext = _props3.staticContext,
-          rest = babelHelpers.objectWithoutProperties(_props3, ['AMap', 'options', 'events', 'match', 'location', 'history', 'staticContext']);
+          rest = _objectWithoutProperties(_props3, ['AMap', 'options', 'events', 'match', 'location', 'history', 'staticContext']);
 
       return null;
       // return (
@@ -126,13 +125,14 @@ var MassMarks = exports.MassMarks = function (_Component) {
       // )
     }
   }]);
+
   return MassMarks;
-}(_react.Component);
+}(Component);
 
 MassMarks.propTypes = {
-  AMap: _propTypes2.default.object,
-  __map__: _propTypes2.default.object,
-  options: _propTypes2.default.object,
-  events: _propTypes2.default.object
+  AMap: PropTypes.object,
+  __map__: PropTypes.object,
+  options: PropTypes.object,
+  events: PropTypes.object
 };
-exports.default = MassMarks;
+export default MassMarks;

+ 29 - 29
lib/Polygon.js

@@ -1,31 +1,29 @@
-'use strict';
+var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
 
-Object.defineProperty(exports, "__esModule", {
-  value: true
-});
-exports.Polygon = undefined;
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
 
-var _react = require('react');
+function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
 
-var _react2 = babelHelpers.interopRequireDefault(_react);
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
-var _propTypes = require('prop-types');
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
 
-var _propTypes2 = babelHelpers.interopRequireDefault(_propTypes);
-
-var _api = require('./api');
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
 
+import React, { Component, PureComponent } from 'react';
+import PropTypes from 'prop-types';
+import { createPolygon, updatePolygon } from './api';
 var __com__ = 'Polygon';
 //const debug = console.log;
 var debug = function debug() {};
 
-var Polygon = exports.Polygon = function (_Component) {
-  babelHelpers.inherits(Polygon, _Component);
+export var Polygon = function (_Component) {
+  _inherits(Polygon, _Component);
 
   function Polygon() {
-    babelHelpers.classCallCheck(this, Polygon);
+    _classCallCheck(this, Polygon);
 
-    var _this = babelHelpers.possibleConstructorReturn(this, (Polygon.__proto__ || Object.getPrototypeOf(Polygon)).call(this));
+    var _this = _possibleConstructorReturn(this, (Polygon.__proto__ || Object.getPrototypeOf(Polygon)).call(this));
 
     _this.refElement = null;
     _this._entity = null;
@@ -33,7 +31,7 @@ var Polygon = exports.Polygon = function (_Component) {
     return _this;
   }
 
-  babelHelpers.createClass(Polygon, [{
+  _createClass(Polygon, [{
     key: 'componentWillMount',
     value: function componentWillMount() {
       debug(__com__, 'componentWillMount', this._entity);
@@ -50,8 +48,8 @@ var Polygon = exports.Polygon = function (_Component) {
           children = _props.children;
       //let opts = { ...(options || {}), map: __map__, content: children };
 
-      var opts = babelHelpers.extends({}, options || {}, { map: __map__ });
-      this._entity = (0, _api.createPolygon)(AMap, opts, events);
+      var opts = _extends({}, options || {}, { map: __map__ });
+      this._entity = createPolygon(AMap, opts, events);
     }
   }, {
     key: 'componentWillReceiveProps',
@@ -75,17 +73,17 @@ var Polygon = exports.Polygon = function (_Component) {
           children = _props2.children;
       //let opts = { ...(options || {}), map: __map__, content: children };
 
-      var opts = babelHelpers.extends({}, options || {}, { map: __map__ });
+      var opts = _extends({}, options || {}, { map: __map__ });
       if (!this._entity) {
-        this._entity = (0, _api.createPolygon)(AMap, opts, events);
+        this._entity = createPolygon(AMap, opts, events);
         return;
       }
 
       // need check props changes, then update.
-      var oldOpts = babelHelpers.extends({}, prevProps.options || {}, {
+      var oldOpts = _extends({}, prevProps.options || {}, {
         map: prevProps.__map__
       });
-      (0, _api.updatePolygon)(this._entity, opts, events, oldOpts, prevProps.events);
+      updatePolygon(this._entity, opts, events, oldOpts, prevProps.events);
     }
   }, {
     key: 'componentWillUnmount',
@@ -109,6 +107,7 @@ var Polygon = exports.Polygon = function (_Component) {
     key: 'render',
     value: function render() {
       debug(__com__, 'render', this._entity);
+
       var _props3 = this.props,
           AMap = _props3.AMap,
           options = _props3.options,
@@ -117,7 +116,7 @@ var Polygon = exports.Polygon = function (_Component) {
           location = _props3.location,
           history = _props3.history,
           staticContext = _props3.staticContext,
-          rest = babelHelpers.objectWithoutProperties(_props3, ['AMap', 'options', 'events', 'match', 'location', 'history', 'staticContext']);
+          rest = _objectWithoutProperties(_props3, ['AMap', 'options', 'events', 'match', 'location', 'history', 'staticContext']);
 
       return null;
       // return (
@@ -126,13 +125,14 @@ var Polygon = exports.Polygon = function (_Component) {
       // )
     }
   }]);
+
   return Polygon;
-}(_react.Component);
+}(Component);
 
 Polygon.propTypes = {
-  AMap: _propTypes2.default.object,
-  __map__: _propTypes2.default.object,
-  options: _propTypes2.default.object,
-  events: _propTypes2.default.object
+  AMap: PropTypes.object,
+  __map__: PropTypes.object,
+  options: PropTypes.object,
+  events: PropTypes.object
 };
-exports.default = Polygon;
+export default Polygon;

+ 29 - 29
lib/Polyline.js

@@ -1,31 +1,29 @@
-'use strict';
+var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
 
-Object.defineProperty(exports, "__esModule", {
-  value: true
-});
-exports.Polyline = undefined;
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
 
-var _react = require('react');
+function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
 
-var _react2 = babelHelpers.interopRequireDefault(_react);
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
-var _propTypes = require('prop-types');
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
 
-var _propTypes2 = babelHelpers.interopRequireDefault(_propTypes);
-
-var _api = require('./api');
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
 
+import React, { Component, PureComponent } from 'react';
+import PropTypes from 'prop-types';
+import { createPolyline, updatePolyline } from './api';
 var __com__ = 'Polyline';
 //const debug = console.log;
 var debug = function debug() {};
 
-var Polyline = exports.Polyline = function (_Component) {
-  babelHelpers.inherits(Polyline, _Component);
+export var Polyline = function (_Component) {
+  _inherits(Polyline, _Component);
 
   function Polyline() {
-    babelHelpers.classCallCheck(this, Polyline);
+    _classCallCheck(this, Polyline);
 
-    var _this = babelHelpers.possibleConstructorReturn(this, (Polyline.__proto__ || Object.getPrototypeOf(Polyline)).call(this));
+    var _this = _possibleConstructorReturn(this, (Polyline.__proto__ || Object.getPrototypeOf(Polyline)).call(this));
 
     _this.refElement = null;
     _this._entity = null;
@@ -33,7 +31,7 @@ var Polyline = exports.Polyline = function (_Component) {
     return _this;
   }
 
-  babelHelpers.createClass(Polyline, [{
+  _createClass(Polyline, [{
     key: 'componentWillMount',
     value: function componentWillMount() {
       debug(__com__, 'componentWillMount', this.props.children, this._entity);
@@ -50,8 +48,8 @@ var Polyline = exports.Polyline = function (_Component) {
           children = _props.children;
       //let opts = { ...(options || {}), map: __map__, content: children };
 
-      var opts = babelHelpers.extends({}, options || {}, { map: __map__ });
-      this._entity = (0, _api.createPolyline)(AMap, opts, events);
+      var opts = _extends({}, options || {}, { map: __map__ });
+      this._entity = createPolyline(AMap, opts, events);
     }
   }, {
     key: 'componentWillReceiveProps',
@@ -75,17 +73,17 @@ var Polyline = exports.Polyline = function (_Component) {
           children = _props2.children;
       //let opts = { ...(options || {}), map: __map__, content: children };
 
-      var opts = babelHelpers.extends({}, options || {}, { map: __map__ });
+      var opts = _extends({}, options || {}, { map: __map__ });
       if (!this._entity) {
-        this._entity = (0, _api.createPolyline)(AMap, opts, events);
+        this._entity = createPolyline(AMap, opts, events);
         return;
       }
 
       // need check props changes, then update.
-      var oldOpts = babelHelpers.extends({}, prevProps.options || {}, {
+      var oldOpts = _extends({}, prevProps.options || {}, {
         map: prevProps.__map__
       });
-      (0, _api.updatePolyline)(this._entity, opts, events, oldOpts, prevProps.events);
+      updatePolyline(this._entity, opts, events, oldOpts, prevProps.events);
     }
   }, {
     key: 'componentWillUnmount',
@@ -109,6 +107,7 @@ var Polyline = exports.Polyline = function (_Component) {
     key: 'render',
     value: function render() {
       debug(__com__, 'render', this.props.children, this._entity);
+
       var _props3 = this.props,
           AMap = _props3.AMap,
           options = _props3.options,
@@ -117,7 +116,7 @@ var Polyline = exports.Polyline = function (_Component) {
           location = _props3.location,
           history = _props3.history,
           staticContext = _props3.staticContext,
-          rest = babelHelpers.objectWithoutProperties(_props3, ['AMap', 'options', 'events', 'match', 'location', 'history', 'staticContext']);
+          rest = _objectWithoutProperties(_props3, ['AMap', 'options', 'events', 'match', 'location', 'history', 'staticContext']);
 
       return null;
       // return (
@@ -126,13 +125,14 @@ var Polyline = exports.Polyline = function (_Component) {
       // )
     }
   }]);
+
   return Polyline;
-}(_react.Component);
+}(Component);
 
 Polyline.propTypes = {
-  AMap: _propTypes2.default.object,
-  __map__: _propTypes2.default.object,
-  options: _propTypes2.default.object,
-  events: _propTypes2.default.object
+  AMap: PropTypes.object,
+  __map__: PropTypes.object,
+  options: PropTypes.object,
+  events: PropTypes.object
 };
-exports.default = Polyline;
+export default Polyline;

+ 42 - 55
lib/api.js

@@ -1,38 +1,24 @@
-'use strict';
+var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
 
-Object.defineProperty(exports, "__esModule", {
-  value: true
-});
-exports.updatePolyline = exports.createPolyline = exports.updatePolygon = exports.createPolygon = exports.updateMassMarks = exports.createMassMarks = exports.updateMarker = exports.createMarker = exports.updateMap = exports.commonUpdate = exports.createMap = exports.loadPlugin = exports.loadMap = exports.loadApi = undefined;
+function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
 
-var _forOwn = require('lodash/forOwn');
-
-var _forOwn2 = babelHelpers.interopRequireDefault(_forOwn);
-
-var _isEqual = require('lodash/isEqual');
-
-var _isEqual2 = babelHelpers.interopRequireDefault(_isEqual);
-
-var _isNil = require('lodash/isNil');
-
-var _isNil2 = babelHelpers.interopRequireDefault(_isNil);
-
-var _APILoader = require('./APILoader');
-
-var _APILoader2 = babelHelpers.interopRequireDefault(_APILoader);
+import forOwn from 'lodash/forOwn';
+import isEqual from 'lodash/isEqual';
+import isNil from 'lodash/isNil';
+//import loadjscssfile from './loadScript';
+import APILoader from './APILoader';
 
-var loadApi = exports.loadApi = function loadApi() {
+export var loadApi = function loadApi() {
   var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '0325e3d6d69cd56de4980b4f28906fd8';
 
-  return new _APILoader2.default({
+  return new APILoader({
     key: key,
     useAMapUI: false,
     version: '1.4.7',
     protocol: 'https'
   }).load();
 };
-//import loadjscssfile from './loadScript';
-var loadMap = exports.loadMap = function loadMap(key) {
+export var loadMap = function loadMap(key) {
   return new Promise(function (resolve, reject) {
     if (window.AMap) {
       resolve(window.AMap);
@@ -82,7 +68,7 @@ var loadMap = exports.loadMap = function loadMap(key) {
  *  map.addControl(toolbar);
  * @param {string} name 插件名或插件数组,如:AMap.ToolBar,['AMap.ToolBar','AMap.Driving']
  */
-var loadPlugin = exports.loadPlugin = function loadPlugin(name) {
+export var loadPlugin = function loadPlugin(name) {
   return new Promise(function (resolve, reject) {
     if (window.AMap) {
       window.AMap.plugin(name, function () {
@@ -98,7 +84,7 @@ var loadPlugin = exports.loadPlugin = function loadPlugin(name) {
 ////////////////////////////////////////////////////////////
 // Map
 ////////////////////////////////////////////////////////////
-var createMap = exports.createMap = function createMap(AMap, dom, options, events) {
+export var createMap = function createMap(AMap, dom, options, events) {
   var __func__ = 'createMap';
   if (!AMap) {
     console.log(__func__, 'fail! no AMap!');
@@ -108,8 +94,8 @@ var createMap = exports.createMap = function createMap(AMap, dom, options, event
     console.log(__func__, 'fail! no dom!');
     return null;
   }
-  var map = new AMap.Map(dom, babelHelpers.extends({}, options || {}));
-  (0, _forOwn2.default)(events, function (value, key) {
+  var map = new AMap.Map(dom, _extends({}, options || {}));
+  forOwn(events, function (value, key) {
     console.log(__func__, 'event on ' + key);
     map.on(key, value);
   });
@@ -117,7 +103,7 @@ var createMap = exports.createMap = function createMap(AMap, dom, options, event
   return map;
 };
 
-var commonUpdate = exports.commonUpdate = function commonUpdate(entity, newOptions, newEvents, oldOptions, oldEvents, operators) {
+export var commonUpdate = function commonUpdate(entity, newOptions, newEvents, oldOptions, oldEvents, operators) {
   var __func__ = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 'commonUpdate';
 
   // const __func__ = 'commonUpdate';
@@ -129,17 +115,17 @@ var commonUpdate = exports.commonUpdate = function commonUpdate(entity, newOptio
   // 找到改变的属性集合,包含添加,删除及修改的属性,删除的置为null
   var props = {};
   if (newOptions != oldOptions) {
-    oldOptions && (0, _forOwn2.default)(oldOptions, function (value, key) {
+    oldOptions && forOwn(oldOptions, function (value, key) {
       // 找到改变的旧属性,用新属性取代
       var newValue = newOptions && newOptions[key];
-      if (!(0, _isEqual2.default)(newValue, value)) {
-        if (!((0, _isNil2.default)(newValue) && (0, _isNil2.default)(value))) props[key] = newValue;
+      if (!isEqual(newValue, value)) {
+        if (!(isNil(newValue) && isNil(value))) props[key] = newValue;
       }
     });
-    newOptions && (0, _forOwn2.default)(newOptions, function (value, key) {
+    newOptions && forOwn(newOptions, function (value, key) {
       // 找到新加的属性,添加进去
       var oldValue = oldOptions && oldOptions[key];
-      if ((0, _isNil2.default)(oldValue) && !(0, _isNil2.default)(value)) {
+      if (isNil(oldValue) && !isNil(value)) {
         props[key] = value;
       }
     });
@@ -147,17 +133,17 @@ var commonUpdate = exports.commonUpdate = function commonUpdate(entity, newOptio
   // 找到改变的事件集合,包含添加,删除及修改的事件处理函数,删除的置为null
   var events = {};
   if (newEvents != oldEvents) {
-    oldEvents && (0, _forOwn2.default)(oldEvents, function (value, key) {
+    oldEvents && forOwn(oldEvents, function (value, key) {
       // 找到改变的旧属性,用新属性取代
       var newValue = newEvents && newEvents[key];
-      if (!(0, _isEqual2.default)(newValue, value)) {
-        if (!((0, _isNil2.default)(newValue) && (0, _isNil2.default)(value))) events[key] = newValue;
+      if (!isEqual(newValue, value)) {
+        if (!(isNil(newValue) && isNil(value))) events[key] = newValue;
       }
     });
-    newEvents && (0, _forOwn2.default)(newEvents, function (value, key) {
+    newEvents && forOwn(newEvents, function (value, key) {
       // 找到新加的属性,添加进去
       var oldValue = oldEvents && oldEvents[key];
-      if ((0, _isNil2.default)(oldValue) && !(0, _isNil2.default)(value)) {
+      if (isNil(oldValue) && !isNil(value)) {
         events[key] = value;
       }
     });
@@ -187,7 +173,7 @@ var commonUpdate = exports.commonUpdate = function commonUpdate(entity, newOptio
   //   label: v => entity.setLabel(v)
   // };
 
-  (0, _forOwn2.default)(props, function (value, key) {
+  forOwn(props, function (value, key) {
     if (value) {
       var func = operators[key];
       if (func) {
@@ -201,7 +187,7 @@ var commonUpdate = exports.commonUpdate = function commonUpdate(entity, newOptio
       console.log(__func__, 'warning! remove prop not support! key=' + key);
     }
   });
-  (0, _forOwn2.default)(events, function (value, key) {
+  forOwn(events, function (value, key) {
     var oldFunc = oldEvents && oldEvents[key];
     if (oldFunc) {
       entity.off(key, oldFunc);
@@ -219,7 +205,7 @@ var commonUpdate = exports.commonUpdate = function commonUpdate(entity, newOptio
   return true;
 };
 
-var updateMap = exports.updateMap = function updateMap(map, newOptions, newEvents, oldOptions, oldEvents) {
+export var updateMap = function updateMap(map, newOptions, newEvents, oldOptions, oldEvents) {
   var operators = {
     view: null,
     layers: function layers(v) {
@@ -297,7 +283,7 @@ var updateMap = exports.updateMap = function updateMap(map, newOptions, newEvent
  * @param {*} options 如果有dom用来显示,则其中的content字段即被填充为dom,不再用独立参数表示dom
  * @param {*} events
  */
-var createMarker = exports.createMarker = function createMarker(AMap, options, events) {
+export var createMarker = function createMarker(AMap, options, events) {
   var __func__ = 'createMarker';
   if (!AMap) {
     console.log(__func__, 'fail! no AMap!');
@@ -317,14 +303,14 @@ var createMarker = exports.createMarker = function createMarker(AMap, options, e
   // });
   // marker.setMap(map);
   var entity = new AMap.Marker(options);
-  (0, _forOwn2.default)(events, function (value, key) {
+  forOwn(events, function (value, key) {
     entity.on(key, value);
   });
   console.log(__func__, 'ok!');
   return entity;
 };
 
-var updateMarker = exports.updateMarker = function updateMarker(entity, newOptions, newEvents, oldOptions, oldEvents) {
+export var updateMarker = function updateMarker(entity, newOptions, newEvents, oldOptions, oldEvents) {
   var operators = {
     map: function map(v) {
       return entity.setMap(v);
@@ -404,12 +390,13 @@ var createMassMarks = function createMassMarks(AMap, options, events) {
     console.log(__func__, 'fail! no options!');
     return null;
   }
+
   var map = options.map,
       data = options.data,
-      restOpts = babelHelpers.objectWithoutProperties(options, ['map', 'data']);
+      restOpts = _objectWithoutProperties(options, ['map', 'data']);
 
   var entity = new AMap.MassMarks(data, restOpts);
-  (0, _forOwn2.default)(events, function (value, key) {
+  forOwn(events, function (value, key) {
     entity.on(key, value);
   });
   if (map) {
@@ -419,8 +406,8 @@ var createMassMarks = function createMassMarks(AMap, options, events) {
   return entity;
 };
 
-exports.createMassMarks = createMassMarks;
-var updateMassMarks = exports.updateMassMarks = function updateMassMarks(entity, newOptions, newEvents, oldOptions, oldEvents) {
+export { createMassMarks };
+export var updateMassMarks = function updateMassMarks(entity, newOptions, newEvents, oldOptions, oldEvents) {
   var operators = {
     zIndex: function zIndex(v) {
       return entity.setzIndex(v);
@@ -455,7 +442,7 @@ var updateMassMarks = exports.updateMassMarks = function updateMassMarks(entity,
  * @param {*} options 如果有dom用来显示,则其中的content字段即被填充为dom,不再用独立参数表示dom
  * @param {*} events
  */
-var createPolygon = exports.createPolygon = function createPolygon(AMap, options, events) {
+export var createPolygon = function createPolygon(AMap, options, events) {
   var __func__ = 'createPolygon';
   if (!AMap) {
     console.log(__func__, 'fail! no AMap!');
@@ -470,14 +457,14 @@ var createPolygon = exports.createPolygon = function createPolygon(AMap, options
     return null;
   }
   var entity = new AMap.Polygon(options);
-  (0, _forOwn2.default)(events, function (value, key) {
+  forOwn(events, function (value, key) {
     entity.on(key, value);
   });
   console.log(__func__, 'ok!');
   return entity;
 };
 
-var updatePolygon = exports.updatePolygon = function updatePolygon(entity, newOptions, newEvents, oldOptions, oldEvents) {
+export var updatePolygon = function updatePolygon(entity, newOptions, newEvents, oldOptions, oldEvents) {
   var operators = {
     map: function map(v) {
       return entity.setMap(v);
@@ -519,7 +506,7 @@ var updatePolygon = exports.updatePolygon = function updatePolygon(entity, newOp
  * @param {*} options 如果有dom用来显示,则其中的content字段即被填充为dom,不再用独立参数表示dom
  * @param {*} events
  */
-var createPolyline = exports.createPolyline = function createPolyline(AMap, options, events) {
+export var createPolyline = function createPolyline(AMap, options, events) {
   var __func__ = 'createPolyline';
   if (!AMap) {
     console.log(__func__, 'fail! no AMap!');
@@ -534,14 +521,14 @@ var createPolyline = exports.createPolyline = function createPolyline(AMap, opti
     return null;
   }
   var entity = new AMap.Polyline(options);
-  (0, _forOwn2.default)(events, function (value, key) {
+  forOwn(events, function (value, key) {
     entity.on(key, value);
   });
   console.log(__func__, 'ok!');
   return entity;
 };
 
-var updatePolyline = exports.updatePolyline = function updatePolyline(entity, newOptions, newEvents, oldOptions, oldEvents) {
+export var updatePolyline = function updatePolyline(entity, newOptions, newEvents, oldOptions, oldEvents) {
   var operators = {
     map: function map(v) {
       return entity.setMap(v);

+ 5 - 13
lib/loadScript.js

@@ -1,20 +1,12 @@
-'use strict';
-
-Object.defineProperty(exports, "__esModule", {
-  value: true
-});
-
-var _indexOf = require('lodash/indexOf');
-
-var _indexOf2 = babelHelpers.interopRequireDefault(_indexOf);
-
-var gFileList = []; //list of files already added
 /**
  * see: http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml
  */
+import indexOf from 'lodash/indexOf';
+
+var gFileList = []; //list of files already added
 var loadjscssfile = function loadjscssfile(filename, filetype) {
   return new Promise(function (resolve, reject) {
-    if ((0, _indexOf2.default)(gFileList, filename) >= 0) {
+    if (indexOf(gFileList, filename) >= 0) {
       console.log('loadScript: already load! ' + filename);
       resolve(true);
       return;
@@ -55,4 +47,4 @@ var loadjscssfile = function loadjscssfile(filename, filetype) {
   });
 };
 
-exports.default = loadjscssfile;
+export default loadjscssfile;

+ 12 - 28
lib/webservice.js

@@ -1,30 +1,14 @@
-'use strict';
+var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
 
-Object.defineProperty(exports, "__esModule", {
-  value: true
-});
-exports.getRequest = exports.infocode = exports.services = undefined;
-
-var _forOwn = require('lodash/forOwn');
-
-var _forOwn2 = babelHelpers.interopRequireDefault(_forOwn);
-
-var _isEqual = require('lodash/isEqual');
-
-var _isEqual2 = babelHelpers.interopRequireDefault(_isEqual);
-
-var _isNil = require('lodash/isNil');
-
-var _isNil2 = babelHelpers.interopRequireDefault(_isNil);
-
-var _isUndefined = require('lodash/isUndefined');
-
-var _isUndefined2 = babelHelpers.interopRequireDefault(_isUndefined);
+import forOwn from 'lodash/forOwn';
+import isEqual from 'lodash/isEqual';
+import isNil from 'lodash/isNil';
+import isUndefined from 'lodash/isUndefined';
 
 // M: Mandatory,必选
 // api调用限流说明: https://lbs.amap.com/api/webservice/guide/tools/flowlevel
 
-var services = exports.services = {
+export var services = {
   // 地理/逆地理编码: https://lbs.amap.com/api/webservice/guide/api/georegeo
   geocode_geo: {
     name: '地理编码',
@@ -350,7 +334,7 @@ var services = exports.services = {
 
 };
 
-var infocode = exports.infocode = {
+export var infocode = {
   "10000": {
     info: 'OK',
     desc: '请求正常',
@@ -368,7 +352,7 @@ var infocode = exports.infocode = {
   }
 };
 
-var getRequest = exports.getRequest = function getRequest(service, parameters, body) {
+export var getRequest = function getRequest(service, parameters, body) {
   if (!service) return null;
 
   var option = {};
@@ -378,12 +362,12 @@ var getRequest = exports.getRequest = function getRequest(service, parameters, b
       dfParameters = service.parameters,
       dfBody = service.body;
 
-  var destParameters = babelHelpers.extends({}, dfParameters || {}, parameters || {});
+  var destParameters = _extends({}, dfParameters || {}, parameters || {});
 
   // 组建url中参数
   var paramArr = [];
-  (0, _forOwn2.default)(destParameters, function (value, key) {
-    if (!(0, _isNil2.default)(value)) {
+  forOwn(destParameters, function (value, key) {
+    if (!isNil(value)) {
       paramArr.push(key + '=' + value);
     }
   });
@@ -398,7 +382,7 @@ var getRequest = exports.getRequest = function getRequest(service, parameters, b
       headers: { 'Content-Type': 'application/json' }
     };
   } else if (method === 'POST' || method === 'PUT' || method === 'PATCH') {
-    var destBody = babelHelpers.extends({}, dfBody || {}, body || {});
+    var destBody = _extends({}, dfBody || {}, body || {});
     option = {
       credentials: 'include',
       method: method,

+ 10 - 7
package.json

@@ -1,6 +1,6 @@
 {
   "name": "react-amap-next",
-  "version": "1.1.2",
+  "version": "1.1.3",
   "description": "这是高德地图的react版本,相比react-amap更加简单,更加贴合react用户",
   "keywords": [
     "react",
@@ -12,7 +12,7 @@
   "homepage": "https://github.com/windsome/react-amap-next",
   "author": "windsome.feng <36081189@qq.com> (https://github.com/windsome/)",
   "scripts": {
-    "build:umd": "cross-env BABEL_ENV=umd babel src/lib --out-dir lib",
+    "build:lib": "cross-env BABEL_ENV=es babel src/lib --out-dir lib",
     "start": "react-scripts start",
     "build": "react-scripts build",
     "test": "react-scripts test --env=jsdom",
@@ -38,16 +38,19 @@
   },
   "babel": {
     "env": {
-      "umd": {
+      "es": {
         "presets": [
-          "es2015",
-          "env",
+          [
+            "env",
+            {
+              "modules": false
+            }
+          ],
           "react"
         ],
         "plugins": [
           "transform-object-rest-spread",
-          "transform-class-properties",
-          "external-helpers"
+          "transform-class-properties"
         ]
       }
     }