@ankhorage/maps 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +2 -1
  3. package/dist/features/map-view/MapView.d.ts +4 -0
  4. package/dist/features/map-view/MapView.d.ts.map +1 -0
  5. package/dist/features/map-view/MapView.js +5 -0
  6. package/dist/features/map-view/MapView.js.map +1 -0
  7. package/dist/features/map-view/adapters/MapView.native.d.ts +5 -0
  8. package/dist/features/map-view/adapters/MapView.native.d.ts.map +1 -0
  9. package/dist/features/map-view/adapters/MapView.native.js +63 -0
  10. package/dist/features/map-view/adapters/MapView.native.js.map +1 -0
  11. package/dist/features/map-view/adapters/MapView.web.d.ts +6 -0
  12. package/dist/features/map-view/adapters/MapView.web.d.ts.map +1 -0
  13. package/dist/features/map-view/adapters/MapView.web.js +32 -0
  14. package/dist/features/map-view/adapters/MapView.web.js.map +1 -0
  15. package/dist/features/map-view/adapters/findMapMarker.d.ts +4 -0
  16. package/dist/features/map-view/adapters/findMapMarker.d.ts.map +1 -0
  17. package/dist/features/map-view/adapters/findMapMarker.js +7 -0
  18. package/dist/features/map-view/adapters/findMapMarker.js.map +1 -0
  19. package/dist/features/map-view/adapters/toExpoCameraPosition.d.ts +10 -0
  20. package/dist/features/map-view/adapters/toExpoCameraPosition.d.ts.map +1 -0
  21. package/dist/features/map-view/adapters/toExpoCameraPosition.js +10 -0
  22. package/dist/features/map-view/adapters/toExpoCameraPosition.js.map +1 -0
  23. package/dist/features/map-view/adapters/toMapLibreViewState.d.ts +10 -0
  24. package/dist/features/map-view/adapters/toMapLibreViewState.d.ts.map +1 -0
  25. package/dist/features/map-view/adapters/toMapLibreViewState.js +13 -0
  26. package/dist/features/map-view/adapters/toMapLibreViewState.js.map +1 -0
  27. package/dist/{defineMapsAdapter.d.ts → features/map-view/defineMapsAdapter.d.ts} +1 -1
  28. package/dist/features/map-view/defineMapsAdapter.d.ts.map +1 -0
  29. package/dist/features/map-view/defineMapsAdapter.js.map +1 -0
  30. package/dist/index.d.ts +3 -2
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +3 -1
  33. package/dist/index.js.map +1 -1
  34. package/dist/index.native.d.ts +4 -0
  35. package/dist/index.native.d.ts.map +1 -0
  36. package/dist/index.native.js +4 -0
  37. package/dist/index.native.js.map +1 -0
  38. package/dist/index.web.d.ts +4 -0
  39. package/dist/index.web.d.ts.map +1 -0
  40. package/dist/index.web.js +4 -0
  41. package/dist/index.web.js.map +1 -0
  42. package/dist/types/maps.d.ts +12 -0
  43. package/dist/types/maps.d.ts.map +1 -1
  44. package/dist/types/maps.js.map +1 -1
  45. package/package.json +42 -6
  46. package/dist/defineMapsAdapter.d.ts.map +0 -1
  47. package/dist/defineMapsAdapter.js.map +0 -1
  48. /package/dist/{defineMapsAdapter.js → features/map-view/defineMapsAdapter.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ankhorage/maps
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 3f4943c: Add automatically selected native Expo Maps and web MapLibre MapView implementations behind the shared maps contract.
8
+
3
9
  ## 0.1.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  # @ankhorage/maps
5
5
 
6
- ![license: MIT](././paradox/badges/license.svg) ![npm: v0.1.0](././paradox/badges/npm.svg) ![runtime: bun](././paradox/badges/runtime.svg) ![typescript: strict](././paradox/badges/typescript.svg) ![eslint: checked](././paradox/badges/eslint.svg) ![prettier: checked](././paradox/badges/prettier.svg) ![build: checked](././paradox/badges/build.svg) ![tests: checked](././paradox/badges/tests.svg) ![paradox: canonical](././paradox/badges/docs.svg)
6
+ ![license: MIT](././paradox/badges/license.svg) ![npm: v0.2.0](././paradox/badges/npm.svg) ![runtime: bun](././paradox/badges/runtime.svg) ![typescript: strict](././paradox/badges/typescript.svg) ![eslint: checked](././paradox/badges/eslint.svg) ![prettier: checked](././paradox/badges/prettier.svg) ![build: checked](././paradox/badges/build.svg) ![tests: checked](././paradox/badges/tests.svg) ![paradox: canonical](././paradox/badges/docs.svg)
7
7
 
8
8
  Cross-platform map primitives and adapters for Ankhorage.
9
9
 
@@ -15,3 +15,4 @@ Cross-platform map primitives and adapters for Ankhorage.
15
15
  - [Architecture overview](././paradox/diagrams/architecture-overview.mmd)
16
16
  - [Module relationships](././paradox/diagrams/module-relationships.mmd)
17
17
  - [Export graph](././paradox/diagrams/export-graph.mmd)
18
+ - [MapView sequence](././paradox/diagrams/sequences/map-view.mmd)
@@ -0,0 +1,4 @@
1
+ import type { MapViewProps } from '../../types/maps.js';
2
+ /*** Reject rendering when the host did not select a browser or React Native package condition. */
3
+ export declare function MapView(_props: MapViewProps): never;
4
+ //# sourceMappingURL=MapView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapView.d.ts","sourceRoot":"","sources":["../../../src/features/map-view/MapView.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,kGAAkG;AAClG,wBAAgB,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,KAAK,CAInD"}
@@ -0,0 +1,5 @@
1
+ /*** Reject rendering when the host did not select a browser or React Native package condition. */
2
+ export function MapView(_props) {
3
+ throw new Error('@ankhorage/maps MapView requires a browser or react-native package export condition.');
4
+ }
5
+ //# sourceMappingURL=MapView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapView.js","sourceRoot":"","sources":["../../../src/features/map-view/MapView.ts"],"names":[],"mappings":"AAEA,kGAAkG;AAClG,MAAM,UAAU,OAAO,CAAC,MAAoB;IAC1C,MAAM,IAAI,KAAK,CACb,sFAAsF,CACvF,CAAC;AACJ,CAAC","sourcesContent":["import type { MapViewProps } from '../../types/maps.js';\n\n/*** Reject rendering when the host did not select a browser or React Native package condition. */\nexport function MapView(_props: MapViewProps): never {\n throw new Error(\n '@ankhorage/maps MapView requires a browser or react-native package export condition.',\n );\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { ReactElement } from 'react';
2
+ import type { MapViewProps } from '../../../types/maps.js';
3
+ /*** Render the portable map contract through Expo Maps on iOS and Android. */
4
+ export declare function MapView(props: MapViewProps): ReactElement;
5
+ //# sourceMappingURL=MapView.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapView.native.d.ts","sourceRoot":"","sources":["../../../../src/features/map-view/adapters/MapView.native.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAa,YAAY,EAAgB,MAAM,wBAAwB,CAAC;AAMpF,8EAA8E;AAC9E,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,YAAY,CAWzD"}
@@ -0,0 +1,63 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { AppleMaps, GoogleMaps } from 'expo-maps';
3
+ import { Platform } from 'react-native';
4
+ import { findMapMarker } from './findMapMarker.js';
5
+ import { toExpoCameraPosition } from './toExpoCameraPosition.js';
6
+ const DEFAULT_NATIVE_STYLE = { flex: 1 };
7
+ /*** Render the portable map contract through Expo Maps on iOS and Android. */
8
+ export function MapView(props) {
9
+ const cameraPosition = toExpoCameraPosition(props.initialCamera);
10
+ const shared = {
11
+ props,
12
+ cameraProps: cameraPosition === undefined ? {} : { cameraPosition },
13
+ };
14
+ if (Platform.OS === 'ios')
15
+ return renderAppleMap(shared);
16
+ if (Platform.OS === 'android')
17
+ return renderGoogleMap(shared);
18
+ throw new Error('@ankhorage/maps native MapView supports only iOS and Android.');
19
+ }
20
+ /*** Render the Apple Maps implementation from portable map props. */
21
+ function renderAppleMap({ props, cameraProps }) {
22
+ const { markers = [], style, onCameraChange, onMarkerPress } = props;
23
+ return (_jsx(AppleMaps.View, { ...cameraProps, style: style ?? DEFAULT_NATIVE_STYLE, markers: markers.map(({ id, coordinate, title }) => ({
24
+ id,
25
+ coordinates: coordinate,
26
+ ...(title === undefined ? {} : { title }),
27
+ })), onCameraMove: (event) => {
28
+ onCameraChange?.({ camera: fromExpoCamera(event) });
29
+ }, onMarkerClick: (event) => {
30
+ const marker = findMapMarker(markers, event.id);
31
+ if (marker !== undefined)
32
+ onMarkerPress?.({ marker });
33
+ } }));
34
+ }
35
+ /*** Render the Google Maps implementation from portable map props. */
36
+ function renderGoogleMap({ props, cameraProps }) {
37
+ const { markers = [], style, onCameraChange, onMarkerPress } = props;
38
+ return (_jsx(GoogleMaps.View, { ...cameraProps, style: style ?? DEFAULT_NATIVE_STYLE, markers: markers.map(({ id, coordinate, title, description }) => ({
39
+ id,
40
+ coordinates: coordinate,
41
+ ...(title === undefined ? {} : { title }),
42
+ ...(description === undefined ? {} : { snippet: description }),
43
+ })), onCameraMove: (event) => {
44
+ onCameraChange?.({ camera: fromExpoCamera(event) });
45
+ }, onMarkerClick: (event) => {
46
+ const marker = findMapMarker(markers, event.id);
47
+ if (marker !== undefined)
48
+ onMarkerPress?.({ marker });
49
+ } }));
50
+ }
51
+ /*** Normalize an Expo Maps camera event into the portable map camera contract. */
52
+ function fromExpoCamera(event) {
53
+ return {
54
+ center: {
55
+ latitude: event.coordinates.latitude ?? 0,
56
+ longitude: event.coordinates.longitude ?? 0,
57
+ },
58
+ zoom: event.zoom,
59
+ bearing: event.bearing,
60
+ pitch: event.tilt,
61
+ };
62
+ }
63
+ //# sourceMappingURL=MapView.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapView.native.js","sourceRoot":"","sources":["../../../../src/features/map-view/adapters/MapView.native.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;A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AAE,aAAa,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QACxD,CAAC,GACD,CACH,CAAC;AACJ,CAAC;AAED,kFAAkF;AAClF,SAAS,cAAc,CAAC,KAQvB;IACC,OAAO;QACL,MAAM,EAAE;YACN,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,QAAQ,IAAI,CAAC;YACzC,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,SAAS,IAAI,CAAC;SAC5C;QACD,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,KAAK,EAAE,KAAK,CAAC,IAAI;KAClB,CAAC;AACJ,CAAC","sourcesContent":["import { AppleMaps, GoogleMaps } from 'expo-maps';\nimport type { ReactElement } from 'react';\nimport { Platform } from 'react-native';\n\nimport type { MapCamera, MapViewProps, MapViewStyle } from '../../../types/maps.js';\nimport { findMapMarker } from './findMapMarker.js';\nimport { toExpoCameraPosition } from './toExpoCameraPosition.js';\n\nconst DEFAULT_NATIVE_STYLE: MapViewStyle = { flex: 1 };\n\n/*** Render the portable map contract through Expo Maps on iOS and Android. */\nexport function MapView(props: MapViewProps): ReactElement {\n const cameraPosition = toExpoCameraPosition(props.initialCamera);\n const shared: NativeMapRenderProps = {\n props,\n cameraProps: cameraPosition === undefined ? {} : { cameraPosition },\n };\n\n if (Platform.OS === 'ios') return renderAppleMap(shared);\n if (Platform.OS === 'android') return renderGoogleMap(shared);\n\n throw new Error('@ankhorage/maps native MapView supports only iOS and Android.');\n}\n\n/*** Render the Apple Maps implementation from portable map props. */\nfunction renderAppleMap({ props, cameraProps }: NativeMapRenderProps): ReactElement {\n const { markers = [], style, onCameraChange, onMarkerPress } = props;\n return (\n <AppleMaps.View\n {...cameraProps}\n style={style ?? DEFAULT_NATIVE_STYLE}\n markers={markers.map(({ id, coordinate, title }) => ({\n id,\n coordinates: coordinate,\n ...(title === undefined ? {} : { title }),\n }))}\n onCameraMove={(event) => {\n onCameraChange?.({ camera: fromExpoCamera(event) });\n }}\n onMarkerClick={(event) => {\n const marker = findMapMarker(markers, event.id);\n if (marker !== undefined) onMarkerPress?.({ marker });\n }}\n />\n );\n}\n\n/*** Render the Google Maps implementation from portable map props. */\nfunction renderGoogleMap({ props, cameraProps }: NativeMapRenderProps): ReactElement {\n const { markers = [], style, onCameraChange, onMarkerPress } = props;\n return (\n <GoogleMaps.View\n {...cameraProps}\n style={style ?? DEFAULT_NATIVE_STYLE}\n markers={markers.map(({ id, coordinate, title, description }) => ({\n id,\n coordinates: coordinate,\n ...(title === undefined ? {} : { title }),\n ...(description === undefined ? {} : { snippet: description }),\n }))}\n onCameraMove={(event) => {\n onCameraChange?.({ camera: fromExpoCamera(event) });\n }}\n onMarkerClick={(event) => {\n const marker = findMapMarker(markers, event.id);\n if (marker !== undefined) onMarkerPress?.({ marker });\n }}\n />\n );\n}\n\n/*** Normalize an Expo Maps camera event into the portable map camera contract. */\nfunction fromExpoCamera(event: {\n readonly coordinates: {\n readonly latitude?: number;\n readonly longitude?: number;\n };\n readonly zoom: number;\n readonly bearing: number;\n readonly tilt: number;\n}): MapCamera {\n return {\n center: {\n latitude: event.coordinates.latitude ?? 0,\n longitude: event.coordinates.longitude ?? 0,\n },\n zoom: event.zoom,\n bearing: event.bearing,\n pitch: event.tilt,\n };\n}\n\ninterface NativeMapRenderProps {\n readonly props: MapViewProps;\n readonly cameraProps:\n | Record<string, never>\n | {\n readonly cameraPosition: NonNullable<ReturnType<typeof toExpoCameraPosition>>;\n };\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import 'maplibre-gl/dist/maplibre-gl.css';
2
+ import type { ReactElement } from 'react';
3
+ import type { MapViewProps } from '../../../types/maps.js';
4
+ /*** Render the portable map contract through MapLibre on the web. */
5
+ export declare function MapView({ initialCamera, markers, style, web, onCameraChange, onMarkerPress, }: MapViewProps): ReactElement;
6
+ //# sourceMappingURL=MapView.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapView.web.d.ts","sourceRoot":"","sources":["../../../../src/features/map-view/adapters/MapView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAC;AAE1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAa,YAAY,EAAgB,MAAM,wBAAwB,CAAC;AAKpF,qEAAqE;AACrE,wBAAgB,OAAO,CAAC,EACtB,aAAa,EACb,OAAY,EACZ,KAAK,EACL,GAAG,EACH,cAAc,EACd,aAAa,GACd,EAAE,YAAY,GAAG,YAAY,CAgC7B"}
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import 'maplibre-gl/dist/maplibre-gl.css';
3
+ import Map, { Marker } from 'react-map-gl/maplibre';
4
+ import { toMapLibreViewState } from './toMapLibreViewState.js';
5
+ const DEFAULT_WEB_STYLE = { width: '100%', height: '100%' };
6
+ /*** Render the portable map contract through MapLibre on the web. */
7
+ export function MapView({ initialCamera, markers = [], style, web, onCameraChange, onMarkerPress, }) {
8
+ if (web === undefined) {
9
+ throw new Error('@ankhorage/maps web MapView requires web.styleUrl and web.workerUrl.');
10
+ }
11
+ const initialViewState = toMapLibreViewState(initialCamera);
12
+ const initialViewProps = initialViewState === undefined ? {} : { initialViewState };
13
+ return (_jsx(Map, { ...initialViewProps, mapStyle: web.styleUrl, workerUrl: web.workerUrl, style: style ?? DEFAULT_WEB_STYLE, onMove: (event) => {
14
+ onCameraChange?.({ camera: fromMapLibreCamera(event.viewState) });
15
+ }, children: markers.map((marker) => (_jsx(Marker, { longitude: marker.coordinate.longitude, latitude: marker.coordinate.latitude, anchor: "bottom", onClick: (event) => {
16
+ event.originalEvent.stopPropagation();
17
+ onMarkerPress?.({ marker });
18
+ } }, marker.id))) }));
19
+ }
20
+ /*** Normalize a MapLibre view state into the portable map camera contract. */
21
+ function fromMapLibreCamera(viewState) {
22
+ return {
23
+ center: {
24
+ latitude: viewState.latitude,
25
+ longitude: viewState.longitude,
26
+ },
27
+ zoom: viewState.zoom,
28
+ bearing: viewState.bearing,
29
+ pitch: viewState.pitch,
30
+ };
31
+ }
32
+ //# sourceMappingURL=MapView.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapView.web.js","sourceRoot":"","sources":["../../../../src/features/map-view/adapters/MapView.web.tsx"],"names":[],"mappings":";AAAA,OAAO,kCAAkC,CAAC;AAG1C,OAAO,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,iBAAiB,GAAiB,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAE1E,qEAAqE;AACrE,MAAM,UAAU,OAAO,CAAC,EACtB,aAAa,EACb,OAAO,GAAG,EAAE,EACZ,KAAK,EACL,GAAG,EACH,cAAc,EACd,aAAa,GACA;IACb,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;IAC1F,CAAC;IAED,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAC5D,MAAM,gBAAgB,GAAG,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAEpF,OAAO,CACL,KAAC,GAAG,OACE,gBAAgB,EACpB,QAAQ,EAAE,GAAG,CAAC,QAAQ,EACtB,SAAS,EAAE,GAAG,CAAC,SAAS,EACxB,KAAK,EAAE,KAAK,IAAI,iBAAiB,EACjC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YAChB,cAAc,EAAE,CAAC,EAAE,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QACpE,CAAC,YAEA,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACvB,KAAC,MAAM,IAEL,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,EACtC,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ,EACpC,MAAM,EAAC,QAAQ,EACf,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;gBACjB,KAAK,CAAC,aAAa,CAAC,eAAe,EAAE,CAAC;gBACtC,aAAa,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YAC9B,CAAC,IAPI,MAAM,CAAC,EAAE,CAQd,CACH,CAAC,GACE,CACP,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,SAAS,kBAAkB,CAAC,SAM3B;IACC,OAAO;QACL,MAAM,EAAE;YACN,QAAQ,EAAE,SAAS,CAAC,QAAQ;YAC5B,SAAS,EAAE,SAAS,CAAC,SAAS;SAC/B;QACD,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,OAAO,EAAE,SAAS,CAAC,OAAO;QAC1B,KAAK,EAAE,SAAS,CAAC,KAAK;KACvB,CAAC;AACJ,CAAC","sourcesContent":["import 'maplibre-gl/dist/maplibre-gl.css';\n\nimport type { ReactElement } from 'react';\nimport Map, { Marker } from 'react-map-gl/maplibre';\n\nimport type { MapCamera, MapViewProps, MapViewStyle } from '../../../types/maps.js';\nimport { toMapLibreViewState } from './toMapLibreViewState.js';\n\nconst DEFAULT_WEB_STYLE: MapViewStyle = { width: '100%', height: '100%' };\n\n/*** Render the portable map contract through MapLibre on the web. */\nexport function MapView({\n initialCamera,\n markers = [],\n style,\n web,\n onCameraChange,\n onMarkerPress,\n}: MapViewProps): ReactElement {\n if (web === undefined) {\n throw new Error('@ankhorage/maps web MapView requires web.styleUrl and web.workerUrl.');\n }\n\n const initialViewState = toMapLibreViewState(initialCamera);\n const initialViewProps = initialViewState === undefined ? {} : { initialViewState };\n\n return (\n <Map\n {...initialViewProps}\n mapStyle={web.styleUrl}\n workerUrl={web.workerUrl}\n style={style ?? DEFAULT_WEB_STYLE}\n onMove={(event) => {\n onCameraChange?.({ camera: fromMapLibreCamera(event.viewState) });\n }}\n >\n {markers.map((marker) => (\n <Marker\n key={marker.id}\n longitude={marker.coordinate.longitude}\n latitude={marker.coordinate.latitude}\n anchor=\"bottom\"\n onClick={(event) => {\n event.originalEvent.stopPropagation();\n onMarkerPress?.({ marker });\n }}\n />\n ))}\n </Map>\n );\n}\n\n/*** Normalize a MapLibre view state into the portable map camera contract. */\nfunction fromMapLibreCamera(viewState: {\n readonly longitude: number;\n readonly latitude: number;\n readonly zoom: number;\n readonly bearing: number;\n readonly pitch: number;\n}): MapCamera {\n return {\n center: {\n latitude: viewState.latitude,\n longitude: viewState.longitude,\n },\n zoom: viewState.zoom,\n bearing: viewState.bearing,\n pitch: viewState.pitch,\n };\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { MapMarker } from '../../../types/maps.js';
2
+ /*** Resolve a portable marker by provider-emitted identifier. */
3
+ export declare function findMapMarker(markers: readonly MapMarker[] | undefined, markerId: string | undefined): MapMarker | undefined;
4
+ //# sourceMappingURL=findMapMarker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findMapMarker.d.ts","sourceRoot":"","sources":["../../../../src/features/map-view/adapters/findMapMarker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,iEAAiE;AACjE,wBAAgB,aAAa,CAC3B,OAAO,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,EACzC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,SAAS,GAAG,SAAS,CAGvB"}
@@ -0,0 +1,7 @@
1
+ /*** Resolve a portable marker by provider-emitted identifier. */
2
+ export function findMapMarker(markers, markerId) {
3
+ if (markerId === undefined)
4
+ return undefined;
5
+ return markers?.find(({ id }) => id === markerId);
6
+ }
7
+ //# sourceMappingURL=findMapMarker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findMapMarker.js","sourceRoot":"","sources":["../../../../src/features/map-view/adapters/findMapMarker.ts"],"names":[],"mappings":"AAEA,iEAAiE;AACjE,MAAM,UAAU,aAAa,CAC3B,OAAyC,EACzC,QAA4B;IAE5B,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC7C,OAAO,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import type { MapMarker } from '../../../types/maps.js';\n\n/*** Resolve a portable marker by provider-emitted identifier. */\nexport function findMapMarker(\n markers: readonly MapMarker[] | undefined,\n markerId: string | undefined,\n): MapMarker | undefined {\n if (markerId === undefined) return undefined;\n return markers?.find(({ id }) => id === markerId);\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type { MapCamera } from '../../../types/maps.js';
2
+ /*** Map the portable camera into the subset supported by Expo Maps initial camera positioning. */
3
+ export declare function toExpoCameraPosition(camera: MapCamera | undefined): {
4
+ readonly coordinates: {
5
+ readonly latitude: number;
6
+ readonly longitude: number;
7
+ };
8
+ readonly zoom?: number;
9
+ } | undefined;
10
+ //# sourceMappingURL=toExpoCameraPosition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toExpoCameraPosition.d.ts","sourceRoot":"","sources":["../../../../src/features/map-view/adapters/toExpoCameraPosition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,kGAAkG;AAClG,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAC9D;IACE,QAAQ,CAAC,WAAW,EAAE;QACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB,GACD,SAAS,CAOZ"}
@@ -0,0 +1,10 @@
1
+ /*** Map the portable camera into the subset supported by Expo Maps initial camera positioning. */
2
+ export function toExpoCameraPosition(camera) {
3
+ if (camera === undefined)
4
+ return undefined;
5
+ return {
6
+ coordinates: camera.center,
7
+ ...(camera.zoom === undefined ? {} : { zoom: camera.zoom }),
8
+ };
9
+ }
10
+ //# sourceMappingURL=toExpoCameraPosition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toExpoCameraPosition.js","sourceRoot":"","sources":["../../../../src/features/map-view/adapters/toExpoCameraPosition.ts"],"names":[],"mappings":"AAEA,kGAAkG;AAClG,MAAM,UAAU,oBAAoB,CAAC,MAA6B;IAShE,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAE3C,OAAO;QACL,WAAW,EAAE,MAAM,CAAC,MAAM;QAC1B,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;KAC5D,CAAC;AACJ,CAAC","sourcesContent":["import type { MapCamera } from '../../../types/maps.js';\n\n/*** Map the portable camera into the subset supported by Expo Maps initial camera positioning. */\nexport function toExpoCameraPosition(camera: MapCamera | undefined):\n | {\n readonly coordinates: {\n readonly latitude: number;\n readonly longitude: number;\n };\n readonly zoom?: number;\n }\n | undefined {\n if (camera === undefined) return undefined;\n\n return {\n coordinates: camera.center,\n ...(camera.zoom === undefined ? {} : { zoom: camera.zoom }),\n };\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type { MapCamera } from '../../../types/maps.js';
2
+ /*** Map the portable camera into MapLibre's initial view-state shape. */
3
+ export declare function toMapLibreViewState(camera: MapCamera | undefined): {
4
+ readonly longitude: number;
5
+ readonly latitude: number;
6
+ readonly zoom: number;
7
+ readonly bearing: number;
8
+ readonly pitch: number;
9
+ } | undefined;
10
+ //# sourceMappingURL=toMapLibreViewState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toMapLibreViewState.d.ts","sourceRoot":"","sources":["../../../../src/features/map-view/adapters/toMapLibreViewState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,yEAAyE;AACzE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAC7D;IACE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,GACD,SAAS,CAUZ"}
@@ -0,0 +1,13 @@
1
+ /*** Map the portable camera into MapLibre's initial view-state shape. */
2
+ export function toMapLibreViewState(camera) {
3
+ if (camera === undefined)
4
+ return undefined;
5
+ return {
6
+ longitude: camera.center.longitude,
7
+ latitude: camera.center.latitude,
8
+ zoom: camera.zoom ?? 0,
9
+ bearing: camera.bearing ?? 0,
10
+ pitch: camera.pitch ?? 0,
11
+ };
12
+ }
13
+ //# sourceMappingURL=toMapLibreViewState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toMapLibreViewState.js","sourceRoot":"","sources":["../../../../src/features/map-view/adapters/toMapLibreViewState.ts"],"names":[],"mappings":"AAEA,yEAAyE;AACzE,MAAM,UAAU,mBAAmB,CAAC,MAA6B;IAS/D,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAE3C,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS;QAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ;QAChC,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC;QACtB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,CAAC;QAC5B,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;KACzB,CAAC;AACJ,CAAC","sourcesContent":["import type { MapCamera } from '../../../types/maps.js';\n\n/*** Map the portable camera into MapLibre's initial view-state shape. */\nexport function toMapLibreViewState(camera: MapCamera | undefined):\n | {\n readonly longitude: number;\n readonly latitude: number;\n readonly zoom: number;\n readonly bearing: number;\n readonly pitch: number;\n }\n | undefined {\n if (camera === undefined) return undefined;\n\n return {\n longitude: camera.center.longitude,\n latitude: camera.center.latitude,\n zoom: camera.zoom ?? 0,\n bearing: camera.bearing ?? 0,\n pitch: camera.pitch ?? 0,\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { MapsAdapter } from './types/maps.js';
1
+ import type { MapsAdapter } from '../../types/maps.js';
2
2
  /*** Define one platform implementation against the canonical Maps adapter contract. */
3
3
  export declare function defineMapsAdapter<TElement>(adapter: MapsAdapter<TElement>): MapsAdapter<TElement>;
4
4
  //# sourceMappingURL=defineMapsAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineMapsAdapter.d.ts","sourceRoot":"","sources":["../../../src/features/map-view/defineMapsAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,uFAAuF;AACvF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,CAEjG"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineMapsAdapter.js","sourceRoot":"","sources":["../../../src/features/map-view/defineMapsAdapter.ts"],"names":[],"mappings":"AAEA,uFAAuF;AACvF,MAAM,UAAU,iBAAiB,CAAW,OAA8B;IACxE,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type { MapsAdapter } from '../../types/maps.js';\n\n/*** Define one platform implementation against the canonical Maps adapter contract. */\nexport function defineMapsAdapter<TElement>(adapter: MapsAdapter<TElement>): MapsAdapter<TElement> {\n return adapter;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export { defineMapsAdapter } from './defineMapsAdapter.js';
2
- export type { MapCamera, MapCameraChangeEvent, MapCoordinate, MapMarker, MapMarkerPressEvent, MapsAdapter, MapsPlatform, MapViewComponent, MapViewProps, } from './types/maps.js';
1
+ export { defineMapsAdapter } from './features/map-view/defineMapsAdapter.js';
2
+ export { MapView } from './features/map-view/MapView.js';
3
+ export type { MapCamera, MapCameraChangeEvent, MapCoordinate, MapDimension, MapMarker, MapMarkerPressEvent, MapsAdapter, MapsPlatform, MapViewComponent, MapViewProps, MapViewStyle, MapWebConfiguration, } from './types/maps.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EACV,SAAS,EACT,oBAAoB,EACpB,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,YAAY,GACb,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AACzD,YAAY,EACV,SAAS,EACT,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,mBAAmB,GACpB,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,4 @@
1
- export { defineMapsAdapter } from './defineMapsAdapter.js';
1
+ 'use client';
2
+ export { defineMapsAdapter } from './features/map-view/defineMapsAdapter.js';
3
+ export { MapView } from './features/map-view/MapView.js';
2
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["export { defineMapsAdapter } from './defineMapsAdapter.js';\nexport type {\n MapCamera,\n MapCameraChangeEvent,\n MapCoordinate,\n MapMarker,\n MapMarkerPressEvent,\n MapsAdapter,\n MapsPlatform,\n MapViewComponent,\n MapViewProps,\n} from './types/maps.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC","sourcesContent":["'use client';\n\nexport { defineMapsAdapter } from './features/map-view/defineMapsAdapter.js';\nexport { MapView } from './features/map-view/MapView.js';\nexport type {\n MapCamera,\n MapCameraChangeEvent,\n MapCoordinate,\n MapDimension,\n MapMarker,\n MapMarkerPressEvent,\n MapsAdapter,\n MapsPlatform,\n MapViewComponent,\n MapViewProps,\n MapViewStyle,\n MapWebConfiguration,\n} from './types/maps.js';\n"]}
@@ -0,0 +1,4 @@
1
+ export { MapView } from './features/map-view/adapters/MapView.native.js';
2
+ export { defineMapsAdapter } from './features/map-view/defineMapsAdapter.js';
3
+ export type { MapCamera, MapCameraChangeEvent, MapCoordinate, MapDimension, MapMarker, MapMarkerPressEvent, MapsAdapter, MapsPlatform, MapViewComponent, MapViewProps, MapViewStyle, MapWebConfiguration, } from './types/maps.js';
4
+ //# sourceMappingURL=index.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.native.d.ts","sourceRoot":"","sources":["../src/index.native.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,gDAAgD,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,YAAY,EACV,SAAS,EACT,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,mBAAmB,GACpB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,4 @@
1
+ 'use client';
2
+ export { MapView } from './features/map-view/adapters/MapView.native.js';
3
+ export { defineMapsAdapter } from './features/map-view/defineMapsAdapter.js';
4
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.native.js","sourceRoot":"","sources":["../src/index.native.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,OAAO,EAAE,MAAM,gDAAgD,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC","sourcesContent":["'use client';\n\nexport { MapView } from './features/map-view/adapters/MapView.native.js';\nexport { defineMapsAdapter } from './features/map-view/defineMapsAdapter.js';\nexport type {\n MapCamera,\n MapCameraChangeEvent,\n MapCoordinate,\n MapDimension,\n MapMarker,\n MapMarkerPressEvent,\n MapsAdapter,\n MapsPlatform,\n MapViewComponent,\n MapViewProps,\n MapViewStyle,\n MapWebConfiguration,\n} from './types/maps.js';\n"]}
@@ -0,0 +1,4 @@
1
+ export { MapView } from './features/map-view/adapters/MapView.web.js';
2
+ export { defineMapsAdapter } from './features/map-view/defineMapsAdapter.js';
3
+ export type { MapCamera, MapCameraChangeEvent, MapCoordinate, MapDimension, MapMarker, MapMarkerPressEvent, MapsAdapter, MapsPlatform, MapViewComponent, MapViewProps, MapViewStyle, MapWebConfiguration, } from './types/maps.js';
4
+ //# sourceMappingURL=index.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../src/index.web.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,6CAA6C,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,YAAY,EACV,SAAS,EACT,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,mBAAmB,GACpB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,4 @@
1
+ 'use client';
2
+ export { MapView } from './features/map-view/adapters/MapView.web.js';
3
+ export { defineMapsAdapter } from './features/map-view/defineMapsAdapter.js';
4
+ //# sourceMappingURL=index.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.web.js","sourceRoot":"","sources":["../src/index.web.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,OAAO,EAAE,MAAM,6CAA6C,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC","sourcesContent":["'use client';\n\nexport { MapView } from './features/map-view/adapters/MapView.web.js';\nexport { defineMapsAdapter } from './features/map-view/defineMapsAdapter.js';\nexport type {\n MapCamera,\n MapCameraChangeEvent,\n MapCoordinate,\n MapDimension,\n MapMarker,\n MapMarkerPressEvent,\n MapsAdapter,\n MapsPlatform,\n MapViewComponent,\n MapViewProps,\n MapViewStyle,\n MapWebConfiguration,\n} from './types/maps.js';\n"]}
@@ -20,9 +20,21 @@ export interface MapCameraChangeEvent {
20
20
  export interface MapMarkerPressEvent {
21
21
  readonly marker: MapMarker;
22
22
  }
23
+ export type MapDimension = number | `${number}%`;
24
+ export interface MapViewStyle {
25
+ readonly width?: MapDimension;
26
+ readonly height?: MapDimension;
27
+ readonly flex?: number;
28
+ }
29
+ export interface MapWebConfiguration {
30
+ readonly styleUrl: string;
31
+ readonly workerUrl: string;
32
+ }
23
33
  export interface MapViewProps {
24
34
  readonly initialCamera?: MapCamera;
25
35
  readonly markers?: readonly MapMarker[];
36
+ readonly style?: MapViewStyle;
37
+ readonly web?: MapWebConfiguration;
26
38
  readonly onCameraChange?: (event: MapCameraChangeEvent) => void;
27
39
  readonly onMarkerPress?: (event: MapMarkerPressEvent) => void;
28
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"maps.d.ts","sourceRoot":"","sources":["../../src/types/maps.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;CAC5B;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,CAAC;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IACxC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAChE,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;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IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,CAAC;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IACxC,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,GAAG,CAAC,EAAE,mBAAmB,CAAC;IACnC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAChE,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;CAC/D;AAED,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE5C,MAAM,MAAM,gBAAgB,CAAC,QAAQ,IAAI,CAAC,KAAK,EAAE,YAAY,KAAK,QAAQ,CAAC;AAE3E,MAAM,WAAW,WAAW,CAAC,QAAQ;IACnC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;CAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"maps.js","sourceRoot":"","sources":["../../src/types/maps.ts"],"names":[],"mappings":"","sourcesContent":["export interface MapCoordinate {\n readonly latitude: number;\n readonly longitude: number;\n}\n\nexport interface MapCamera {\n readonly center: MapCoordinate;\n readonly zoom?: number;\n readonly bearing?: number;\n readonly pitch?: number;\n}\n\nexport interface MapMarker {\n readonly id: string;\n readonly coordinate: MapCoordinate;\n readonly title?: string;\n readonly description?: string;\n}\n\nexport interface MapCameraChangeEvent {\n readonly camera: MapCamera;\n}\n\nexport interface MapMarkerPressEvent {\n readonly marker: MapMarker;\n}\n\nexport interface MapViewProps {\n readonly initialCamera?: MapCamera;\n readonly markers?: readonly MapMarker[];\n readonly onCameraChange?: (event: MapCameraChangeEvent) => void;\n readonly onMarkerPress?: (event: MapMarkerPressEvent) => void;\n}\n\nexport type MapsPlatform = 'native' | 'web';\n\nexport type MapViewComponent<TElement> = (props: MapViewProps) => TElement;\n\nexport interface MapsAdapter<TElement> {\n readonly platform: MapsPlatform;\n readonly MapView: MapViewComponent<TElement>;\n}\n"]}
1
+ {"version":3,"file":"maps.js","sourceRoot":"","sources":["../../src/types/maps.ts"],"names":[],"mappings":"","sourcesContent":["export interface MapCoordinate {\n readonly latitude: number;\n readonly longitude: number;\n}\n\nexport interface MapCamera {\n readonly center: MapCoordinate;\n readonly zoom?: number;\n readonly bearing?: number;\n readonly pitch?: number;\n}\n\nexport interface MapMarker {\n readonly id: string;\n readonly coordinate: MapCoordinate;\n readonly title?: string;\n readonly description?: string;\n}\n\nexport interface MapCameraChangeEvent {\n readonly camera: MapCamera;\n}\n\nexport interface MapMarkerPressEvent {\n readonly marker: MapMarker;\n}\n\nexport type MapDimension = number | `${number}%`;\n\nexport interface MapViewStyle {\n readonly width?: MapDimension;\n readonly height?: MapDimension;\n readonly flex?: number;\n}\n\nexport interface MapWebConfiguration {\n readonly styleUrl: string;\n readonly workerUrl: string;\n}\n\nexport interface MapViewProps {\n readonly initialCamera?: MapCamera;\n readonly markers?: readonly MapMarker[];\n readonly style?: MapViewStyle;\n readonly web?: MapWebConfiguration;\n readonly onCameraChange?: (event: MapCameraChangeEvent) => void;\n readonly onMarkerPress?: (event: MapMarkerPressEvent) => void;\n}\n\nexport type MapsPlatform = 'native' | 'web';\n\nexport type MapViewComponent<TElement> = (props: MapViewProps) => TElement;\n\nexport interface MapsAdapter<TElement> {\n readonly platform: MapsPlatform;\n readonly MapView: MapViewComponent<TElement>;\n}\n"]}
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@ankhorage/maps",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Cross-platform map primitives and adapters for Ankhorage.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "sideEffects": false,
7
+ "sideEffects": [
8
+ "./dist/features/map-view/adapters/MapView.web.js"
9
+ ],
8
10
  "repository": {
9
11
  "type": "git",
10
12
  "url": "git+https://github.com/ankhorage/maps.git"
@@ -31,8 +33,11 @@
31
33
  "types": "./dist/index.d.ts",
32
34
  "exports": {
33
35
  ".": {
36
+ "react-native": "./dist/index.native.js",
37
+ "browser": "./dist/index.web.js",
34
38
  "types": "./dist/index.d.ts",
35
- "import": "./dist/index.js"
39
+ "import": "./dist/index.js",
40
+ "default": "./dist/index.js"
36
41
  },
37
42
  "./package.json": "./package.json"
38
43
  },
@@ -58,12 +63,43 @@
58
63
  "version-packages": "ankhorage-changeset version",
59
64
  "docs": "paradox"
60
65
  },
66
+ "dependencies": {
67
+ "maplibre-gl": "^6.11.2",
68
+ "react-map-gl": "^8.0.0"
69
+ },
70
+ "peerDependencies": {
71
+ "expo": "^57.0.0",
72
+ "expo-maps": "~57.0.3",
73
+ "react": "^19.2.3",
74
+ "react-dom": "^19.2.3",
75
+ "react-native": "^0.86.3"
76
+ },
77
+ "peerDependenciesMeta": {
78
+ "expo": {
79
+ "optional": true
80
+ },
81
+ "expo-maps": {
82
+ "optional": true
83
+ },
84
+ "react-dom": {
85
+ "optional": true
86
+ },
87
+ "react-native": {
88
+ "optional": true
89
+ }
90
+ },
61
91
  "packageManager": "bun@1.4.2",
62
92
  "devDependencies": {
63
93
  "@ankhorage/devtools": "^2.1.19",
64
- "@types/bun": "^1.4.2",
65
- "typescript": "~6.0.3",
66
94
  "@ankhorage/paradox": "^0.2.28",
67
- "@types/node": "^26.6.4"
95
+ "@types/bun": "^1.4.2",
96
+ "@types/node": "^26.6.4",
97
+ "@types/react": "^19.2.2",
98
+ "expo": "^57.0.0",
99
+ "expo-maps": "~57.0.3",
100
+ "react": "^19.2.3",
101
+ "react-dom": "^19.2.3",
102
+ "react-native": "^0.86.3",
103
+ "typescript": "~6.0.3"
68
104
  }
69
105
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"defineMapsAdapter.d.ts","sourceRoot":"","sources":["../src/defineMapsAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,uFAAuF;AACvF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,CAEjG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"defineMapsAdapter.js","sourceRoot":"","sources":["../src/defineMapsAdapter.ts"],"names":[],"mappings":"AAEA,uFAAuF;AACvF,MAAM,UAAU,iBAAiB,CAAW,OAA8B;IACxE,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type { MapsAdapter } from './types/maps.js';\n\n/*** Define one platform implementation against the canonical Maps adapter contract. */\nexport function defineMapsAdapter<TElement>(adapter: MapsAdapter<TElement>): MapsAdapter<TElement> {\n return adapter;\n}\n"]}