From f827ad54d995911f8bf3feb9999113516f0dffe2 Mon Sep 17 00:00:00 2001 From: Xiaoji Chen Date: Tue, 22 Oct 2024 21:11:16 -0700 Subject: [PATCH] Fix type import paths --- src/components/attribution-control.ts | 2 +- src/components/fullscreen-control.ts | 2 +- src/components/geolocate-control.ts | 8 +++----- src/components/layer.ts | 3 ++- src/components/logo-control.ts | 2 +- src/components/map.tsx | 2 +- src/components/marker.ts | 9 ++------- src/components/navigation-control.ts | 2 +- src/components/popup.ts | 3 ++- src/components/scale-control.ts | 2 +- src/components/source.ts | 6 +++--- src/components/terrain-control.ts | 3 ++- src/components/use-control.ts | 2 +- src/maplibre/create-ref.ts | 2 +- src/maplibre/maplibre.ts | 20 +++++++++----------- src/types/{index.ts => internal.ts} | 5 ----- src/utils/deep-equal.ts | 2 +- src/utils/style-utils.ts | 3 ++- src/utils/transform.ts | 3 ++- 19 files changed, 36 insertions(+), 45 deletions(-) rename src/types/{index.ts => internal.ts} (91%) diff --git a/src/components/attribution-control.ts b/src/components/attribution-control.ts index 2b77d9f..6914570 100644 --- a/src/components/attribution-control.ts +++ b/src/components/attribution-control.ts @@ -3,7 +3,7 @@ import {useEffect, memo} from 'react'; import {applyReactStyle} from '../utils/apply-react-style'; import {useControl} from './use-control'; -import type {ControlPosition, AttributionControlOptions} from '../types'; +import type {ControlPosition, AttributionControlOptions} from '../types/lib'; export type AttributionControlProps = AttributionControlOptions & { /** Placement of the control relative to the map. */ diff --git a/src/components/fullscreen-control.ts b/src/components/fullscreen-control.ts index 2804a00..cf4d300 100644 --- a/src/components/fullscreen-control.ts +++ b/src/components/fullscreen-control.ts @@ -4,7 +4,7 @@ import {useEffect, memo} from 'react'; import {applyReactStyle} from '../utils/apply-react-style'; import {useControl} from './use-control'; -import type {ControlPosition, FullscreenControlOptions} from '../types'; +import type {ControlPosition, FullscreenControlOptions} from '../types/lib'; export type FullscreenControlProps = Omit & { /** Id of the DOM element which should be made full screen. By default, the map container diff --git a/src/components/geolocate-control.ts b/src/components/geolocate-control.ts index 80c78e1..0cd051f 100644 --- a/src/components/geolocate-control.ts +++ b/src/components/geolocate-control.ts @@ -6,11 +6,9 @@ import {useControl} from './use-control'; import type { ControlPosition, GeolocateControlInstance, - GeolocateControlOptions, - GeolocateEvent, - GeolocateResultEvent, - GeolocateErrorEvent -} from '../types'; + GeolocateControlOptions +} from '../types/lib'; +import type {GeolocateEvent, GeolocateResultEvent, GeolocateErrorEvent} from '../types/events'; export type GeolocateControlProps = GeolocateControlOptions & { /** Placement of the control relative to the map. */ diff --git a/src/components/layer.ts b/src/components/layer.ts index d0500f3..27adb26 100644 --- a/src/components/layer.ts +++ b/src/components/layer.ts @@ -3,7 +3,8 @@ import {MapContext} from './map'; import assert from '../utils/assert'; import {deepEqual} from '../utils/deep-equal'; -import type {MapInstance, CustomLayerInterface, AnyLayer} from '../types'; +import type {MapInstance, CustomLayerInterface} from '../types/lib'; +import type {AnyLayer} from '../types/style-spec'; // Omiting property from a union type, see // https://github.com/microsoft/TypeScript/issues/39556#issuecomment-656925230 diff --git a/src/components/logo-control.ts b/src/components/logo-control.ts index 93ed961..dcec9cc 100644 --- a/src/components/logo-control.ts +++ b/src/components/logo-control.ts @@ -3,7 +3,7 @@ import {useEffect, memo} from 'react'; import {applyReactStyle} from '../utils/apply-react-style'; import {useControl} from './use-control'; -import type {ControlPosition, LogoControlOptions} from '../types'; +import type {ControlPosition, LogoControlOptions} from '../types/lib'; export type LogoControlProps = LogoControlOptions & { /** Placement of the control relative to the map. */ diff --git a/src/components/map.tsx b/src/components/map.tsx index b14f6f9..7d8fe2a 100644 --- a/src/components/map.tsx +++ b/src/components/map.tsx @@ -8,7 +8,7 @@ import createRef, {MapRef} from '../maplibre/create-ref'; import type {CSSProperties} from 'react'; import useIsomorphicLayoutEffect from '../utils/use-isomorphic-layout-effect'; import setGlobals, {GlobalSettings} from '../utils/set-globals'; -import type {MapLib, MapOptions} from '../types'; +import type {MapLib, MapOptions} from '../types/lib'; export type MapContextValue = { mapLib: MapLib; diff --git a/src/components/marker.ts b/src/components/marker.ts index 2f4ef16..45406b4 100644 --- a/src/components/marker.ts +++ b/src/components/marker.ts @@ -4,13 +4,8 @@ import {createPortal} from 'react-dom'; import {useImperativeHandle, useEffect, useMemo, useRef, useContext, forwardRef, memo} from 'react'; import {applyReactStyle} from '../utils/apply-react-style'; -import type { - MarkerEvent, - MarkerDragEvent, - PopupInstance, - MarkerInstance, - MarkerOptions -} from '../types'; +import type {PopupInstance, MarkerInstance, MarkerOptions} from '../types/lib'; +import type {MarkerEvent, MarkerDragEvent} from '../types/events'; import {MapContext} from './map'; import {arePointsEqual} from '../utils/deep-equal'; diff --git a/src/components/navigation-control.ts b/src/components/navigation-control.ts index 2d2ec50..5014e90 100644 --- a/src/components/navigation-control.ts +++ b/src/components/navigation-control.ts @@ -3,7 +3,7 @@ import {useEffect, memo} from 'react'; import {applyReactStyle} from '../utils/apply-react-style'; import {useControl} from './use-control'; -import type {ControlPosition, NavigationControlOptions} from '../types'; +import type {ControlPosition, NavigationControlOptions} from '../types/lib'; export type NavigationControlProps = NavigationControlOptions & { /** Placement of the control relative to the map. */ diff --git a/src/components/popup.ts b/src/components/popup.ts index df90995..babee5a 100644 --- a/src/components/popup.ts +++ b/src/components/popup.ts @@ -4,7 +4,8 @@ import {createPortal} from 'react-dom'; import {useImperativeHandle, useEffect, useMemo, useRef, useContext, forwardRef, memo} from 'react'; import {applyReactStyle} from '../utils/apply-react-style'; -import type {PopupEvent, PopupInstance, PopupOptions} from '../types'; +import type {PopupInstance, PopupOptions} from '../types/lib'; +import type {PopupEvent} from '../types/events'; import {MapContext} from './map'; import {deepEqual} from '../utils/deep-equal'; diff --git a/src/components/scale-control.ts b/src/components/scale-control.ts index 924dd28..db6066b 100644 --- a/src/components/scale-control.ts +++ b/src/components/scale-control.ts @@ -3,7 +3,7 @@ import {useEffect, useRef, memo} from 'react'; import {applyReactStyle} from '../utils/apply-react-style'; import {useControl} from './use-control'; -import type {ControlPosition, ScaleControlOptions} from '../types'; +import type {ControlPosition, ScaleControlOptions} from '../types/lib'; export type ScaleControlProps = ScaleControlOptions & { // These props will be further constraint by OptionsT diff --git a/src/components/source.ts b/src/components/source.ts index d3bf074..ef13f34 100644 --- a/src/components/source.ts +++ b/src/components/source.ts @@ -5,12 +5,12 @@ import assert from '../utils/assert'; import {deepEqual} from '../utils/deep-equal'; import type { - MapInstance, GeoJSONSourceImplementation, ImageSourceImplemtation, - AnySource, AnySourceImplementation -} from '../types'; +} from '../types/internal'; +import type {AnySource} from '../types/style-spec'; +import type {MapInstance} from '../types/lib'; export type SourceProps = AnySource & { id?: string; diff --git a/src/components/terrain-control.ts b/src/components/terrain-control.ts index 3b4e48f..69650e6 100644 --- a/src/components/terrain-control.ts +++ b/src/components/terrain-control.ts @@ -3,7 +3,8 @@ import {useEffect, memo} from 'react'; import {applyReactStyle} from '../utils/apply-react-style'; import {useControl} from './use-control'; -import type {ControlPosition, Terrain} from '../types'; +import type {ControlPosition} from '../types/lib'; +import type {Terrain} from '../types/style-spec'; export type TerrainControlProps = Terrain & { /** Placement of the control relative to the map. */ diff --git a/src/components/use-control.ts b/src/components/use-control.ts index bd8e1c8..aa06fff 100644 --- a/src/components/use-control.ts +++ b/src/components/use-control.ts @@ -1,5 +1,5 @@ import {useContext, useMemo, useEffect} from 'react'; -import type {IControl, ControlPosition} from '../types'; +import type {IControl, ControlPosition} from '../types/lib'; import {MapContext} from './map'; import type {MapContextValue} from './map'; diff --git a/src/maplibre/create-ref.ts b/src/maplibre/create-ref.ts index 018174a..6c5407a 100644 --- a/src/maplibre/create-ref.ts +++ b/src/maplibre/create-ref.ts @@ -1,4 +1,4 @@ -import type {MapInstance} from '../types'; +import type {MapInstance} from '../types/lib'; import type Maplibre from './maplibre'; /** These methods may break the react binding if called directly */ diff --git a/src/maplibre/maplibre.ts b/src/maplibre/maplibre.ts index 498861e..e462c98 100644 --- a/src/maplibre/maplibre.ts +++ b/src/maplibre/maplibre.ts @@ -2,27 +2,25 @@ import {transformToViewState, applyViewStateToTransform} from '../utils/transfor import {normalizeStyle} from '../utils/style-utils'; import {deepEqual} from '../utils/deep-equal'; +import type {TransformLike} from '../types/internal'; import type { - TransformLike, ViewState, - ViewStateChangeEvent, Point, PointLike, PaddingOptions, - MapStyle, ImmutableLike, LngLatBoundsLike, + MapGeoJSONFeature +} from '../types/common'; +import type {MapStyle, Sky, Light, Terrain, Projection} from '../types/style-spec'; +import type {MapInstance} from '../types/lib'; +import type { MapCallbacks, - Sky, - Light, - Terrain, - Projection, + ViewStateChangeEvent, MapEvent, ErrorEvent, - MapMouseEvent, - MapGeoJSONFeature, - MapInstance -} from '../types'; + MapMouseEvent +} from '../types/events'; export type MaplibreProps = Partial & MapCallbacks & { diff --git a/src/types/index.ts b/src/types/internal.ts similarity index 91% rename from src/types/index.ts rename to src/types/internal.ts index 8c94895..0b0b6d1 100644 --- a/src/types/index.ts +++ b/src/types/internal.ts @@ -1,8 +1,3 @@ -export * from './common'; -export * from './lib'; -export * from './events'; -export * from './style-spec'; - // Internal types import type { LngLat, diff --git a/src/utils/deep-equal.ts b/src/utils/deep-equal.ts index abb2499..879d98e 100644 --- a/src/utils/deep-equal.ts +++ b/src/utils/deep-equal.ts @@ -1,4 +1,4 @@ -import type {PointLike} from '../types'; +import type {PointLike} from '../types/common'; /** * Compare two points diff --git a/src/utils/style-utils.ts b/src/utils/style-utils.ts index 51656a7..a265d96 100644 --- a/src/utils/style-utils.ts +++ b/src/utils/style-utils.ts @@ -1,4 +1,5 @@ -import {ImmutableLike, MapStyle} from '../types'; +import type {MapStyle} from '../types/style-spec'; +import type {ImmutableLike} from '../types/common'; const refProps = ['type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout']; diff --git a/src/utils/transform.ts b/src/utils/transform.ts index 10f109b..bd7f748 100644 --- a/src/utils/transform.ts +++ b/src/utils/transform.ts @@ -1,5 +1,6 @@ import type {MaplibreProps} from '../maplibre/maplibre'; -import type {TransformLike, ViewState} from '../types'; +import type {ViewState} from '../types/common'; +import type {TransformLike} from '../types/internal'; import {deepEqual} from './deep-equal'; /**