From ebb190c9f3ada11da2c9ace6fd93cbdf11c9d696 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Wed, 26 Dec 2018 08:18:32 -0800 Subject: [PATCH] fix(build): Fixed build issues caused by updated Google Maps docs --- lib/components/GoogleMap.js | 1 - lib/components/GroundOverlay.js | 1 - lib/components/OverlayView.js | 1 - lib/components/StreetViewPanorama.js | 1 - lib/components/drawing/DrawingManager.js | 1 - lib/components/places/SearchBox.js | 1 - lib/components/places/StandaloneSearchBox.js | 2 -- src/components/Circle.jsx | 2 +- src/components/DirectionsRenderer.jsx | 4 +-- src/components/GoogleMap.jsx | 16 ++++------- src/components/GroundOverlay.jsx | 2 +- src/components/Marker.jsx | 23 ---------------- src/components/OverlayView.jsx | 4 +-- src/components/StreetViewPanorama.jsx | 8 +++--- src/components/addons/MarkerWithLabel.jsx | 23 ---------------- src/components/drawing/DrawingManager.jsx | 2 +- src/components/places/SearchBox.jsx | 2 +- src/components/places/StandaloneSearchBox.jsx | 2 +- src/tx/ClassDefinition.js | 27 +++++++++---------- src/tx/MapChild.js | 4 +-- 20 files changed, 33 insertions(+), 94 deletions(-) diff --git a/lib/components/GoogleMap.js b/lib/components/GoogleMap.js index 2909ed09..2e30a321 100644 --- a/lib/components/GoogleMap.js +++ b/lib/components/GoogleMap.js @@ -144,7 +144,6 @@ var Map = (exports.Map = (function(_React$PureComponent) { context ) ) - ;(0, _invariant2.default)( !!_this.context[_constants.MAP], "Did you wrap component with withGoogleMap() HOC?" diff --git a/lib/components/GroundOverlay.js b/lib/components/GroundOverlay.js index 662b20ea..f935e3a8 100644 --- a/lib/components/GroundOverlay.js +++ b/lib/components/GroundOverlay.js @@ -71,7 +71,6 @@ var GroundOverlay = (exports.GroundOverlay = (function(_React$PureComponent) { GroundOverlay.__proto__ || (0, _getPrototypeOf2.default)(GroundOverlay) ).call(this, props, context) ) - ;(0, _warning2.default)( !props.url || !props.bounds, "\nFor GroundOveray, url and bounds are passed in to constructor and are immutable\n after iinstantiated. This is the behavior of Google Maps JavaScript API v3 (\n See https://developers.google.com/maps/documentation/javascript/reference#GroundOverlay)\n Hence, use the corresponding two props provided by `react-google-maps`.\n They're prefixed with _default_ (defaultUrl, defaultBounds).\n\n In some cases, you'll need the GroundOverlay component to reflect the changes\n of url and bounds. You can leverage the React's key property to remount the\n component. Typically, just `key={url}` would serve your need.\n See https://github.com/tomchentw/react-google-maps/issues/655\n" diff --git a/lib/components/OverlayView.js b/lib/components/OverlayView.js index 01b03dfa..8aef2868 100644 --- a/lib/components/OverlayView.js +++ b/lib/components/OverlayView.js @@ -134,7 +134,6 @@ var OverlayView = (exports.OverlayView = (function(_React$PureComponent) { key: "draw", value: function draw() { var mapPaneName = this.props.mapPaneName - ;(0, _invariant2.default)( !!mapPaneName, "OverlayView requires either props.mapPaneName or props.defaultMapPaneName but got %s", diff --git a/lib/components/StreetViewPanorama.js b/lib/components/StreetViewPanorama.js index 163700bb..c7328c89 100644 --- a/lib/components/StreetViewPanorama.js +++ b/lib/components/StreetViewPanorama.js @@ -71,7 +71,6 @@ var StreetViewPanorama = (exports.StreetViewPanorama = (function( (0, _getPrototypeOf2.default)(StreetViewPanorama) ).call(this, props, context) ) - ;(0, _invariant2.default)( !!_this.context[_constants.MAP], "Did you render as a child of with withGoogleMap() HOC?" diff --git a/lib/components/drawing/DrawingManager.js b/lib/components/drawing/DrawingManager.js index b51a2e49..28583d63 100644 --- a/lib/components/drawing/DrawingManager.js +++ b/lib/components/drawing/DrawingManager.js @@ -72,7 +72,6 @@ var DrawingManager = (exports.DrawingManager = (function(_React$PureComponent) { (0, _getPrototypeOf2.default)(DrawingManager) ).call(this, props, context) ) - ;(0, _invariant2.default)( google.maps.drawing, 'Did you include "libraries=drawing" in the URL?' diff --git a/lib/components/places/SearchBox.js b/lib/components/places/SearchBox.js index eaf20e81..32c7974f 100644 --- a/lib/components/places/SearchBox.js +++ b/lib/components/places/SearchBox.js @@ -75,7 +75,6 @@ var SearchBox = (exports.SearchBox = (function(_React$PureComponent) { var _ref var _temp, _this, _ret - ;(0, _classCallCheck3.default)(this, SearchBox) for ( diff --git a/lib/components/places/StandaloneSearchBox.js b/lib/components/places/StandaloneSearchBox.js index 8e6f120f..12100dd5 100644 --- a/lib/components/places/StandaloneSearchBox.js +++ b/lib/components/places/StandaloneSearchBox.js @@ -74,7 +74,6 @@ var SearchBox = (function(_React$PureComponent) { var _ref var _temp, _this, _ret - ;(0, _classCallCheck3.default)(this, SearchBox) for ( @@ -127,7 +126,6 @@ var SearchBox = (function(_React$PureComponent) { this.props, searchBox ) - ;(0, _MapChildHelper.componentDidMount)(this, searchBox, eventMap) this.setState( (0, _defineProperty3.default)({}, _constants.SEARCH_BOX, searchBox) diff --git a/src/components/Circle.jsx b/src/components/Circle.jsx index 2ccc407a..8b43b5c0 100644 --- a/src/components/Circle.jsx +++ b/src/components/Circle.jsx @@ -195,7 +195,7 @@ export class Circle extends React.PureComponent { /** * Gets the `LatLngBounds` of this Circle. - * @type LatLngBoundsLatLngBounds + * @type LatLngBounds * @public */ getBounds() { diff --git a/src/components/DirectionsRenderer.jsx b/src/components/DirectionsRenderer.jsx index 1ecb51d9..41ed7bf9 100644 --- a/src/components/DirectionsRenderer.jsx +++ b/src/components/DirectionsRenderer.jsx @@ -129,7 +129,7 @@ export class DirectionsRenderer extends React.PureComponent { /** * Returns the panel `
` in which the `DirectionsResult` is rendered. - * @type Node
DirectionsResult + * @type Node * @public */ getPanel() { @@ -138,7 +138,7 @@ export class DirectionsRenderer extends React.PureComponent { /** * Returns the current (zero-based) route index in use by this `DirectionsRenderer` object. - * @type numberDirectionsRenderer + * @type number * @public */ getRouteIndex() { diff --git a/src/components/GoogleMap.jsx b/src/components/GoogleMap.jsx index caf6c71f..661c7a0e 100644 --- a/src/components/GoogleMap.jsx +++ b/src/components/GoogleMap.jsx @@ -192,11 +192,6 @@ export class Map extends React.PureComponent { */ onProjectionChanged: PropTypes.func, - /** - * function - */ - onResize: PropTypes.func, - /** * function */ @@ -275,7 +270,7 @@ export class Map extends React.PureComponent { /** * Returns the lat/lng bounds of the current viewport. If more than one copy of the world is visible, the bounds range in longitude from -180 to 180 degrees inclusive. If the map is not yet initialized (i.e. the mapType is still null), or center and zoom have not been set then the result is `null` or `undefined`. - * @type LatLngBoundsnullundefined + * @type LatLngBounds * @public */ getBounds() { @@ -284,7 +279,7 @@ export class Map extends React.PureComponent { /** * Returns the position displayed at the center of the map. Note that this `LatLng` object is _not_ wrapped. See `[LatLng](#LatLng)` for more information. - * @type LatLngLatLngLatLng + * @type LatLng * @public */ getCenter() { @@ -329,7 +324,7 @@ export class Map extends React.PureComponent { /** * Returns the current `Projection`. If the map is not yet initialized (i.e. the mapType is still null) then the result is null. Listen to `projection_changed` and check its value to ensure it is not null. - * @type ProjectionProjectionprojection_changed + * @type Projection * @public */ getProjection() { @@ -338,7 +333,7 @@ export class Map extends React.PureComponent { /** * Returns the default `StreetViewPanorama` bound to the map, which may be a default panorama embedded within the map, or the panorama set using `setStreetView()`. Changes to the map's `streetViewControl` will be reflected in the display of such a bound panorama. - * @type StreetViewPanoramaStreetViewPanoramasetStreetView()streetViewControl + * @type StreetViewPanorama * @public */ getStreetView() { @@ -347,7 +342,7 @@ export class Map extends React.PureComponent { /** * Returns the current angle of incidence of the map, in degrees from the viewport plane to the map plane. The result will be `0` for imagery taken directly overhead or `45` for 45° imagery. 45° imagery is only available for `satellite` and `hybrid` map types, within some locations, and at some zoom levels. **Note:** This method does not return the value set by `setTilt`. See `setTilt` for details. - * @type number045satellitehybridsetTiltsetTilt + * @type number * @public */ getTilt() { @@ -385,7 +380,6 @@ const eventMap = { onHeadingChanged: "heading_changed", onIdle: "idle", onProjectionChanged: "projection_changed", - onResize: "resize", onTiltChanged: "tilt_changed", onZoomChanged: "zoom_changed", } diff --git a/src/components/GroundOverlay.jsx b/src/components/GroundOverlay.jsx index 837f2262..4bf35a10 100644 --- a/src/components/GroundOverlay.jsx +++ b/src/components/GroundOverlay.jsx @@ -131,7 +131,7 @@ For GroundOveray, url and bounds are passed in to constructor and are immutable /** * Gets the `LatLngBounds` of this overlay. - * @type LatLngBoundsLatLngBounds + * @type LatLngBounds * @public */ getBounds() { diff --git a/src/components/Marker.jsx b/src/components/Marker.jsx index fb16f50f..8f49d34d 100644 --- a/src/components/Marker.jsx +++ b/src/components/Marker.jsx @@ -70,11 +70,6 @@ export class Marker extends React.PureComponent { */ defaultOptions: PropTypes.any, - /** - * @type MarkerPlace - */ - defaultPlace: PropTypes.any, - /** * @type LatLng|LatLngLiteral */ @@ -140,11 +135,6 @@ export class Marker extends React.PureComponent { */ options: PropTypes.any, - /** - * @type MarkerPlace - */ - place: PropTypes.any, - /** * @type LatLng|LatLngLiteral */ @@ -403,15 +393,6 @@ export class Marker extends React.PureComponent { return this.state[MARKER].getOpacity() } - /** - * - * @type MarkerPlace - * @public - */ - getPlace() { - return this.state[MARKER].getPlace() - } - /** * * @type LatLng @@ -517,10 +498,6 @@ const updaterMap = { instance.setOptions(options) }, - place(instance, place) { - instance.setPlace(place) - }, - position(instance, position) { instance.setPosition(position) }, diff --git a/src/components/OverlayView.jsx b/src/components/OverlayView.jsx index 4bbe0508..e63b838a 100644 --- a/src/components/OverlayView.jsx +++ b/src/components/OverlayView.jsx @@ -164,7 +164,7 @@ export class OverlayView extends React.PureComponent { /** * Returns the panes in which this OverlayView can be rendered. The panes are not initialized until `onAdd` is called by the API. - * @type MapPanesonAdd + * @type MapPanes * @public */ getPanes() { @@ -173,7 +173,7 @@ export class OverlayView extends React.PureComponent { /** * Returns the `MapCanvasProjection` object associated with this `OverlayView`. The projection is not initialized until `onAdd` is called by the API. - * @type MapCanvasProjectionMapCanvasProjectionOverlayViewonAdd + * @type MapCanvasProjection * @public */ getProjection() { diff --git a/src/components/StreetViewPanorama.jsx b/src/components/StreetViewPanorama.jsx index 9389b2f3..2309af3a 100644 --- a/src/components/StreetViewPanorama.jsx +++ b/src/components/StreetViewPanorama.jsx @@ -238,7 +238,7 @@ export class StreetViewPanorama extends React.PureComponent { /** * Returns the heading and pitch of the photographer when this panorama was taken. For Street View panoramas on the road, this also reveals in which direction the car was travelling. This data is available after the `pano_changed` event. - * @type StreetViewPovpano_changed + * @type StreetViewPov * @public */ getPhotographerPov() { @@ -247,7 +247,7 @@ export class StreetViewPanorama extends React.PureComponent { /** * Returns the current `LatLng` position for the Street View panorama. - * @type LatLngLatLng + * @type LatLng * @public */ getPosition() { @@ -265,7 +265,7 @@ export class StreetViewPanorama extends React.PureComponent { /** * Returns the status of the panorama on completion of the `setPosition()` or `setPano()` request. - * @type StreetViewStatussetPosition()setPano() + * @type StreetViewStatus * @public */ getStatus() { @@ -274,7 +274,7 @@ export class StreetViewPanorama extends React.PureComponent { /** * Returns `true` if the panorama is visible. It does not specify whether Street View imagery is available at the specified position. - * @type booleantrue + * @type boolean * @public */ getVisible() { diff --git a/src/components/addons/MarkerWithLabel.jsx b/src/components/addons/MarkerWithLabel.jsx index 945b2240..0199c902 100644 --- a/src/components/addons/MarkerWithLabel.jsx +++ b/src/components/addons/MarkerWithLabel.jsx @@ -103,11 +103,6 @@ export class MarkerWithLabel extends React.PureComponent { */ defaultOptions: PropTypes.any, - /** - * @type MarkerPlace - */ - defaultPlace: PropTypes.any, - /** * @type LatLng|LatLngLiteral */ @@ -173,11 +168,6 @@ export class MarkerWithLabel extends React.PureComponent { */ options: PropTypes.any, - /** - * @type MarkerPlace - */ - place: PropTypes.any, - /** * @type LatLng|LatLngLiteral */ @@ -452,15 +442,6 @@ export class MarkerWithLabel extends React.PureComponent { return this.state[MARKER_WITH_LABEL].getOpacity() } - /** - * - * @type MarkerPlace - * @public - */ - getPlace() { - return this.state[MARKER_WITH_LABEL].getPlace() - } - /** * * @type LatLng @@ -598,10 +579,6 @@ const updaterMap = { instance.setOptions(options) }, - place(instance, place) { - instance.setPlace(place) - }, - position(instance, position) { instance.setPosition(position) }, diff --git a/src/components/drawing/DrawingManager.jsx b/src/components/drawing/DrawingManager.jsx index c2c3c64f..e9333485 100644 --- a/src/components/drawing/DrawingManager.jsx +++ b/src/components/drawing/DrawingManager.jsx @@ -125,7 +125,7 @@ export class DrawingManager extends React.PureComponent { /** * Returns the `DrawingManager`'s drawing mode. - * @type OverlayTypeDrawingManager + * @type OverlayType * @public */ getDrawingMode() { diff --git a/src/components/places/SearchBox.jsx b/src/components/places/SearchBox.jsx index 7ad62fb3..1d01e8e4 100644 --- a/src/components/places/SearchBox.jsx +++ b/src/components/places/SearchBox.jsx @@ -186,7 +186,7 @@ export class SearchBox extends React.PureComponent { /** * Returns the query selected by the user, or `null` if no places have been found yet, to be used with `places_changed` event. - * @type Arraynullplaces_changed + * @type Array * @public */ getPlaces() { diff --git a/src/components/places/StandaloneSearchBox.jsx b/src/components/places/StandaloneSearchBox.jsx index 61f5a99d..3999f2b7 100644 --- a/src/components/places/StandaloneSearchBox.jsx +++ b/src/components/places/StandaloneSearchBox.jsx @@ -97,7 +97,7 @@ class SearchBox extends React.PureComponent { /** * Returns the query selected by the user, or `null` if no places have been found yet, to be used with `places_changed` event. - * @type Arraynullplaces_changed + * @type Array * @public */ getPlaces() { diff --git a/src/tx/ClassDefinition.js b/src/tx/ClassDefinition.js index 705c8fa9..2b3c57e6 100644 --- a/src/tx/ClassDefinition.js +++ b/src/tx/ClassDefinition.js @@ -11,6 +11,12 @@ const KlassName = process.argv[2] fetch( "https://developers.google.com/maps/documentation/javascript/3.exp/reference" ) + .then(it => it.text()) + .then(it => cheerio.load(it)) + .then($ => { + const href = $(`#${KlassName} a`).attr("href") + return fetch(href) + }) .then(it => it.text()) .then(it => cheerio.load(it)) .then($ => { @@ -33,11 +39,9 @@ function contentToJS(KlassName, $, $content) { const $constructorTable = $content.find( `[summary="class ${KlassName} - Constructor"]` ) - const [, constructorArgs] = $constructorTable - .find(`tr > td > code`) + const constructorArgs = $constructorTable + .find(`tbody .desc li code:first-child`) .text() - .match(/\S+\((.*)\)/) - const $methodsTable = $content.find( `[summary="class ${KlassName} - Methods"]` ) @@ -45,20 +49,15 @@ function contentToJS(KlassName, $, $content) { .find("tbody > tr") .map((i, tr) => { const $tr = $(tr) - const [, name, args] = $tr - .find("td:first-child") - .text() - .replace("\n", "") - .match(/(\S+)\((.*)\)/) - - const returnsDesc = toMarkdown( - $tr.find("td:nth-child(2) > div.desc").html() - ) + const name = $tr.find('[itemprop="property"]').text() + const args = $tr.find('.desc:contains("Parameters") li').text() + const returns = $tr.find('.desc:contains("Return Value") code').text() + const returnsDesc = toMarkdown($tr.find(".desc:last-child").html()) return { name, args, - returns: $tr.find("td:nth-child(2) > div > code").text(), + returns, returnsDesc, } }) diff --git a/src/tx/MapChild.js b/src/tx/MapChild.js index 1ff79c03..216c6398 100644 --- a/src/tx/MapChild.js +++ b/src/tx/MapChild.js @@ -122,7 +122,7 @@ export default function transformer(file, api) { return [ ...methodAsProps.map(({ name, args, desc }) => { const [, prop] = name.match(/^set(\S+)/) - const [, maybeType] = args.match(/\S+:(\S+)/) + const [, maybeType] = args.match(/\S+:\s*(\S+)/) return Object.assign( j.objectProperty( @@ -136,7 +136,7 @@ export default function transformer(file, api) { }), ...methodAsProps.map(({ name, args, desc }) => { const [, prop] = name.match(/^set(\S+)/) - const [, maybeType] = args.match(/\S+:(\S+)/) + const [, maybeType] = args.match(/\S+:\s*(\S+)/) return Object.assign( j.objectProperty(