diff --git a/.eslintignore b/.eslintignore index ad2f907..4d3edc4 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,4 +2,4 @@ dist/ node_modules/ test/src/utils/mapbox-gl-mock/*.js **/vite.config.js -examples/vite.config.local.js +examples/ diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 4869572..3f70586 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -25,12 +25,12 @@ module.exports = getESLintConfig({ '@typescript-eslint/no-unsafe-member-access': 0, '@typescript-eslint/no-unsafe-assignment': 0, 'import/named': 0, - '@typescript-eslint/no-empty-function': ['warn', {allow: ['arrowFunctions']}], - '@typescript-eslint/restrict-template-expressions': 0, '@typescript-eslint/explicit-module-boundary-types': 0, '@typescript-eslint/no-unsafe-return': 0, '@typescript-eslint/no-unsafe-call': 0, - '@typescript-eslint/restrict-plus-operands': 0 + '@typescript-eslint/restrict-plus-operands': 0, + '@typescript-eslint/no-explicit-any': 0, + '@typescript-eslint/no-unsafe-argument': 0 } } ] diff --git a/.yarn/install-state.gz b/.yarn/install-state.gz index 8acc9a5..a6fe4d3 100644 Binary files a/.yarn/install-state.gz and b/.yarn/install-state.gz differ diff --git a/README.md b/README.md index 773dab4..c6e5c4a 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ npm install @vis.gl/react-maplibre maplibre-gl ```js import * as React from 'react'; -import Map from '@vis.gl/react-maplibre'; +import {Map} from '@vis.gl/react-maplibre'; import 'maplibre-gl/dist/maplibre-gl.css'; function App() { diff --git a/docs/api-reference/attribution-control.md b/docs/api-reference/attribution-control.md index 4c7afd3..cdb2d39 100644 --- a/docs/api-reference/attribution-control.md +++ b/docs/api-reference/attribution-control.md @@ -5,7 +5,7 @@ React component that wraps the base library's [AttributionControl](https://mapli ```tsx import * as React from 'react'; -import Map, {AttributionControl} from '@vis.gl/react-maplibre'; +import {Map, AttributionControl} from '@vis.gl/react-maplibre'; import 'maplibre-gl/dist/maplibre-gl.css'; function App() { diff --git a/docs/api-reference/fullscreen-control.md b/docs/api-reference/fullscreen-control.md index 96f7806..3d74b43 100644 --- a/docs/api-reference/fullscreen-control.md +++ b/docs/api-reference/fullscreen-control.md @@ -5,7 +5,7 @@ React component that wraps the base library's [FullscreenControl](https://maplib ```tsx import * as React from 'react'; -import Map, {FullscreenControl} from '@vis.gl/react-maplibre'; +import {Map, FullscreenControl} from '@vis.gl/react-maplibre'; import 'maplibre-gl/dist/maplibre-gl.css'; function App() { diff --git a/docs/api-reference/geolocate-control.md b/docs/api-reference/geolocate-control.md index 650b43f..0bee76c 100644 --- a/docs/api-reference/geolocate-control.md +++ b/docs/api-reference/geolocate-control.md @@ -4,7 +4,7 @@ React component that wraps the base library's [GeolocateControl](https://maplibr ```tsx import * as React from 'react'; -import Map, {GeolocateControl} from '@vis.gl/react-maplibre'; +import {Map, GeolocateControl} from '@vis.gl/react-maplibre'; import 'maplibre-gl/dist/maplibre-gl.css'; function App() { @@ -83,7 +83,7 @@ You may use it to call any imperative methods: ```tsx import * as React from 'react'; import {useRef, useEffect} from 'react'; -import Map, {GeolocateControl} from '@vis.gl/react-maplibre'; +import {Map, GeolocateControl} from '@vis.gl/react-maplibre'; import type maplibregl from 'maplibre-gl'; function App() { diff --git a/docs/api-reference/layer.md b/docs/api-reference/layer.md index f68775e..e06cbe3 100644 --- a/docs/api-reference/layer.md +++ b/docs/api-reference/layer.md @@ -5,7 +5,7 @@ This component allows apps to create a [map layer](https://maplibre.org/maplibre ```tsx import * as React from 'react'; -import Map, {Layer} from '@vis.gl/react-maplibre'; +import {Map, Layer} from '@vis.gl/react-maplibre'; import type {FillLayer} from '@vis.gl/react-maplibre'; const parkLayer: FillLayer = { diff --git a/docs/api-reference/map.md b/docs/api-reference/map.md index fdc8505..4291c3a 100644 --- a/docs/api-reference/map.md +++ b/docs/api-reference/map.md @@ -4,7 +4,7 @@ React component that wraps the base library's [Map](https://maplibre.org/maplibr ```tsx title="app.tsx" import * as React from 'react'; -import Map from '@vis.gl/react-maplibre'; +import {Map} from '@vis.gl/react-maplibre'; import 'maplibre-gl/dist/maplibre-gl.css'; function App() { @@ -443,7 +443,7 @@ By module import (and embedding in the final bundle): ```tsx import * as React from 'react'; -import Map from '@vis.gl/react-maplibre'; +import {Map} from '@vis.gl/react-maplibre'; import maplibregl from 'maplibre-gl'; function App() { @@ -455,7 +455,7 @@ By dynamic import (thus enable bundle splitting): ```tsx import * as React from 'react'; -import Map from '@vis.gl/react-maplibre'; +import {Map} from '@vis.gl/react-maplibre'; function App() { return ; @@ -470,7 +470,7 @@ Or to load a pre-bundled version of the library: ```tsx title="app.tsx" import * as React from 'react'; -import Map from '@vis.gl/react-maplibre'; +import {Map} from '@vis.gl/react-maplibre'; function App() { return ; @@ -522,7 +522,7 @@ Imperative methods are accessible via a [React ref](https://reactjs.org/docs/ref ```tsx import * as React from 'react'; import {useRef, useCallback} from 'react'; -import Map from '@vis.gl/react-maplibre'; +import {Map} from '@vis.gl/react-maplibre'; import type {MapRef} from '@vis.gl/react-maplibre'; function App() { diff --git a/docs/api-reference/marker.md b/docs/api-reference/marker.md index bb0c599..ddb10a5 100644 --- a/docs/api-reference/marker.md +++ b/docs/api-reference/marker.md @@ -5,7 +5,7 @@ React component that wraps the base library's [Marker](https://maplibre.org/mapl ```tsx import * as React from 'react'; -import Map, {Marker} from '@vis.gl/react-maplibre'; +import {Map, Marker} from '@vis.gl/react-maplibre'; import 'maplibre-gl/dist/maplibre-gl.css'; function App() { @@ -121,7 +121,7 @@ You may use it to call any imperative methods: ```tsx import * as React from 'react'; import {useRef, useMemo, useCallback} from 'react'; -import Map, {Marker} from '@vis.gl/react-maplibre'; +import {Map, Marker} from '@vis.gl/react-maplibre'; import maplibregl from 'maplibre-gl'; function App() { diff --git a/docs/api-reference/navigation-control.md b/docs/api-reference/navigation-control.md index 98d610b..2333edb 100644 --- a/docs/api-reference/navigation-control.md +++ b/docs/api-reference/navigation-control.md @@ -5,7 +5,7 @@ React component that wraps the base library's [NavigationControl](https://maplib ```tsx import * as React from 'react'; -import Map, {NavigationControl} from '@vis.gl/react-maplibre'; +import {Map, NavigationControl} from '@vis.gl/react-maplibre'; import 'maplibre-gl/dist/maplibre-gl.css'; function App() { diff --git a/docs/api-reference/popup.md b/docs/api-reference/popup.md index 56c8ea4..fbbfe6c 100644 --- a/docs/api-reference/popup.md +++ b/docs/api-reference/popup.md @@ -6,7 +6,7 @@ React component that wraps the base library's [Popup](https://maplibre.org/mapli ```tsx import * as React from 'react'; import {useState} from 'react'; -import Map, {Popup} from '@vis.gl/react-maplibre'; +import {Map, Popup} from '@vis.gl/react-maplibre'; import 'maplibre-gl/dist/maplibre-gl.css'; function App() { @@ -98,7 +98,7 @@ You may use it to call any imperative methods: ```tsx import * as React from 'react'; import {useRef, useEffect} from 'react'; -import Map, {Popup} from '@vis.gl/react-maplibre'; +import {Map, Popup} from '@vis.gl/react-maplibre'; import maplibregl from 'maplibre-gl'; function App() { diff --git a/docs/api-reference/scale-control.md b/docs/api-reference/scale-control.md index 2384614..8413562 100644 --- a/docs/api-reference/scale-control.md +++ b/docs/api-reference/scale-control.md @@ -4,7 +4,7 @@ React component that wraps the base library's [ScaleControl](https://maplibre.or ```tsx import * as React from 'react'; -import Map, {ScaleControl} from '@vis.gl/react-maplibre'; +import {Map, ScaleControl} from '@vis.gl/react-maplibre'; import 'maplibre-gl/dist/maplibre-gl.css'; function App() { diff --git a/docs/api-reference/source.md b/docs/api-reference/source.md index 6d65efa..63044ef 100644 --- a/docs/api-reference/source.md +++ b/docs/api-reference/source.md @@ -5,7 +5,7 @@ This component allows apps to create a [map source](https://maplibre.org/maplibr ```tsx import * as React from 'react'; -import Map, {Source, Layer} from '@vis.gl/react-maplibre'; +import {Map, Source, Layer} from '@vis.gl/react-maplibre'; import type {CircleLayer} from '@vis.gl/react-maplibre'; import type {FeatureCollection} from 'geojson'; diff --git a/docs/api-reference/use-control.md b/docs/api-reference/use-control.md index 61d1093..6ad4524 100644 --- a/docs/api-reference/use-control.md +++ b/docs/api-reference/use-control.md @@ -4,7 +4,7 @@ The `useControl` hook is used to create React wrappers for custom map controls. ```tsx import MapboxDraw from '@mapbox/mapbox-gl-draw'; -import Map, {useControl} from '@vis.gl/react-maplibre'; +import {Map, useControl} from '@vis.gl/react-maplibre'; function DrawControl(props: DrawControlProps) { useControl(() => new MapboxDraw(props), { diff --git a/docs/get-started/adding-custom-data.md b/docs/get-started/adding-custom-data.md index d764e47..22db136 100644 --- a/docs/get-started/adding-custom-data.md +++ b/docs/get-started/adding-custom-data.md @@ -6,7 +6,7 @@ You can inject data and Maplibre native layers using the [Source](../api-referen ```tsx import * as React from 'react'; -import Map, {Source, Layer} from '@vis.gl/react-maplibre'; +import {Map, Source, Layer} from '@vis.gl/react-maplibre'; import type {CircleLayer} from '@vis.gl/react-maplibre'; import type {FeatureCollection} from 'geojson'; diff --git a/docs/get-started/get-started.md b/docs/get-started/get-started.md index 9da0bd4..f4ab1be 100644 --- a/docs/get-started/get-started.md +++ b/docs/get-started/get-started.md @@ -14,7 +14,7 @@ npm install --save @vis.gl/react-maplibre maplibre-gl ```tsx title="app.tsx" import * as React from 'react'; -import Map from '@vis.gl/react-maplibre'; +import {Map} from '@vis.gl/react-maplibre'; import 'maplibre-gl/dist/maplibre-gl.css'; // See notes below function App() { diff --git a/docs/get-started/state-management.md b/docs/get-started/state-management.md index 893f4ff..a2bff41 100644 --- a/docs/get-started/state-management.md +++ b/docs/get-started/state-management.md @@ -12,7 +12,7 @@ You may clone a full app configuration for this example [here](https://github.co ```tsx import * as React from 'react'; -import Map from '@vis.gl/react-maplibre'; +import {Map} from '@vis.gl/react-maplibre'; function App() { return (null); -type MapInitOptions = Omit< +type MapInitOptions = Omit< MapOptions, 'style' | 'container' | 'bounds' | 'fitBoundsOptions' | 'center' >; -export type MapProps = MapInitOptions & +export type MapProps = MapInitOptions & MaplibreProps & GlobalSettings & { mapLib?: MapLib | Promise; diff --git a/src/components/source.ts b/src/components/source.ts index 61207f3..d3bf074 100644 --- a/src/components/source.ts +++ b/src/components/source.ts @@ -1,6 +1,5 @@ import * as React from 'react'; -import {useContext, useEffect, useMemo, useState, useRef} from 'react'; -import {cloneElement} from 'react'; +import {useContext, useEffect, useMemo, useState, useRef, cloneElement} from 'react'; import {MapContext} from './map'; import assert from '../utils/assert'; import {deepEqual} from '../utils/deep-equal'; diff --git a/src/maplibre/create-ref.ts b/src/maplibre/create-ref.ts index 257dc8d..018174a 100644 --- a/src/maplibre/create-ref.ts +++ b/src/maplibre/create-ref.ts @@ -27,7 +27,7 @@ const skipMethods = [ export type MapRef = { getMap(): MapInstance; -} & Omit; +} & Omit; export default function createRef(mapInstance: Maplibre): MapRef | null { if (!mapInstance) { diff --git a/src/maplibre/maplibre.ts b/src/maplibre/maplibre.ts index 39356c6..3c9b4c2 100644 --- a/src/maplibre/maplibre.ts +++ b/src/maplibre/maplibre.ts @@ -551,7 +551,7 @@ export default class Maplibre { } } - private _onPointerEvent = (e: MapMouseEvent | MapMouseEvent) => { + private _onPointerEvent = (e: MapMouseEvent) => { if (e.type === 'mousemove' || e.type === 'mouseout') { this._updateHover(e); } diff --git a/src/types/index.ts b/src/types/index.ts index e1cd06a..8c94895 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -4,7 +4,18 @@ export * from './events'; export * from './style-spec'; // Internal types -import type {LngLat, PaddingOptions} from 'maplibre-gl'; +import type { + LngLat, + PaddingOptions, + GeoJSONSource as GeoJSONSourceImplementation, + ImageSource as ImageSourceImplemtation, + CanvasSource as CanvasSourceImplemtation, + VectorTileSource as VectorSourceImplementation, + RasterTileSource as RasterSourceImplementation, + RasterDEMTileSource as RasterDemSourceImplementation, + VideoSource as VideoSourceImplementation, + Source +} from 'maplibre-gl'; /** * maplibre's Transform interface / CameraUpdateTransformFunction argument @@ -18,17 +29,6 @@ export type TransformLike = { padding: PaddingOptions; }; -import type { - GeoJSONSource as GeoJSONSourceImplementation, - ImageSource as ImageSourceImplemtation, - CanvasSource as CanvasSourceImplemtation, - VectorTileSource as VectorSourceImplementation, - RasterTileSource as RasterSourceImplementation, - RasterDEMTileSource as RasterDemSourceImplementation, - VideoSource as VideoSourceImplementation, - Source -} from 'maplibre-gl'; - export type { GeoJSONSourceImplementation, ImageSourceImplemtation, diff --git a/test/apps/reuse-maps/src/app.tsx b/test/apps/reuse-maps/src/app.tsx index 1057eef..96e5b45 100644 --- a/test/apps/reuse-maps/src/app.tsx +++ b/test/apps/reuse-maps/src/app.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import {useState} from 'react'; import {render} from 'react-dom'; -import Map, {MapProps} from '@vis.gl/react-maplibre'; +import {Map, MapProps} from '@vis.gl/react-maplibre'; const CONFIGS: MapProps[] = [ { diff --git a/test/render/index.jsx b/test/render/index.jsx index 4208867..3bb6635 100644 --- a/test/render/index.jsx +++ b/test/render/index.jsx @@ -1,8 +1,8 @@ /* global window, document, FontFace */ import test from 'tape-promise/tape'; import * as React from 'react'; -import Map from '@vis.gl/react-maplibre'; import {createRoot} from 'react-dom/client'; +import {Map} from '@vis.gl/react-maplibre'; import TEST_CASES from './test-cases';