@dxos/react-ui-geo 0.8.2-main.fbd8ed0 → 0.8.2-staging.7ac8446

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 (36) hide show
  1. package/dist/lib/browser/index.mjs +55 -45
  2. package/dist/lib/browser/index.mjs.map +3 -3
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +50 -40
  5. package/dist/lib/node/index.cjs.map +3 -3
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/index.mjs +55 -45
  8. package/dist/lib/node-esm/index.mjs.map +3 -3
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
  11. package/dist/types/src/components/Map/Map.stories.d.ts +4 -5
  12. package/dist/types/src/components/Map/Map.stories.d.ts.map +1 -1
  13. package/dist/types/src/components/Toolbar/Controls.d.ts.map +1 -1
  14. package/dist/types/src/hooks/context.d.ts.map +1 -1
  15. package/dist/types/src/hooks/useDrag.d.ts.map +1 -1
  16. package/dist/types/src/hooks/useGlobeZoomHandler.d.ts.map +1 -1
  17. package/dist/types/src/hooks/useMapZoomHandler.d.ts.map +1 -1
  18. package/dist/types/src/hooks/useSpinner.d.ts.map +1 -1
  19. package/dist/types/src/hooks/useTour.d.ts +1 -1
  20. package/dist/types/src/hooks/useTour.d.ts.map +1 -1
  21. package/dist/types/src/util/debug.d.ts.map +1 -1
  22. package/dist/types/src/util/inertia.d.ts +2 -1
  23. package/dist/types/src/util/inertia.d.ts.map +1 -1
  24. package/dist/types/src/util/path.d.ts.map +1 -1
  25. package/dist/types/src/util/render.d.ts.map +1 -1
  26. package/dist/types/tsconfig.tsbuildinfo +1 -1
  27. package/package.json +11 -11
  28. package/src/components/Globe/Globe.stories.tsx +1 -1
  29. package/src/components/Globe/Globe.tsx +11 -20
  30. package/src/components/Map/Map.stories.tsx +5 -5
  31. package/src/hooks/useDrag.ts +3 -3
  32. package/src/hooks/useSpinner.ts +2 -2
  33. package/src/hooks/useTour.ts +13 -9
  34. package/src/util/inertia.ts +5 -4
  35. package/src/util/path.ts +5 -2
  36. package/src/util/render.ts +6 -5
@@ -1 +1 @@
1
- {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../../src/util/path.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,kBAAkB,EAA4B,MAAM,IAAI,CAAC;AACvE,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,MAAM,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAElD,eAAO,MAAM,kBAAkB,GAAI,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,aAAQ,KAAG,MAA+B,CAAC;AAE5G,eAAO,MAAM,aAAa,GAAI,cAAc,MAAM,KAAG,CAAC,MAAM,EAAE,MAAM,CAAe,CAAC;AAEpF,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,KAAG,KAA+D,CAAC;AAGzG,eAAO,MAAM,SAAS,GAAI,cAAc,MAAM,EAAE,QAAQ,MAAM,KAAG,OACd,CAAC;AAEpD,eAAO,MAAM,OAAO,GAAI,IAAI,MAAM,EAAE,IAAI,MAAM,KAAG,kBAM/C,CAAC;AAEH,eAAO,MAAM,YAAY,GAAI,QAAQ,QAAQ,EAAE,EAAE,QAAQ,QAAQ,KAAG,QAAQ,GAAG,IAiB9E,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,QAAQ,QAAQ,EAAE,QAAQ,QAAQ,KAAG,MAIhE,CAAC"}
1
+ {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../../src/util/path.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,kBAAkB,EAAE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KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAEtD,MAAM,MAAM,QAAQ,GAAG;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,qBAAqB,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,aAAc,QAAQ,YAAY,QAAQ,UAAU,QAAQ,KAAG,KAAK,EA2E5F,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,cAAe,OAAO,UAAU,KAAK,EAAE,SAAc,MAAM,UAAU,QAAQ,6BA0CrG,CAAC"}
@@ -1 +1 @@
1
- {"version":"5.8.3"}
1
+ {"version":"5.7.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-geo",
3
- "version": "0.8.2-main.fbd8ed0",
3
+ "version": "0.8.2-staging.7ac8446",
4
4
  "description": "Geo components.",
5
5
  "homepage": "https://github.com/dxos",
6
6
  "bugs": "https://github.com/dxos/issues",
@@ -45,11 +45,11 @@
45
45
  "topojson-client": "^3.1.0",
46
46
  "topojson-simplify": "^3.0.3",
47
47
  "versor": "^0.2.0",
48
- "@dxos/async": "0.8.2-main.fbd8ed0",
49
- "@dxos/debug": "0.8.2-main.fbd8ed0",
50
- "@dxos/node-std": "0.8.2-main.fbd8ed0",
51
- "@dxos/util": "0.8.2-main.fbd8ed0",
52
- "@dxos/log": "0.8.2-main.fbd8ed0"
48
+ "@dxos/async": "0.8.2-staging.7ac8446",
49
+ "@dxos/log": "0.8.2-staging.7ac8446",
50
+ "@dxos/node-std": "0.8.2-staging.7ac8446",
51
+ "@dxos/util": "0.8.2-staging.7ac8446",
52
+ "@dxos/debug": "0.8.2-staging.7ac8446"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@react-three/drei": "^9.99.0",
@@ -69,15 +69,15 @@
69
69
  "react": "~18.2.0",
70
70
  "react-dom": "~18.2.0",
71
71
  "three": "0.165.0",
72
- "@dxos/react-ui": "0.8.2-main.fbd8ed0",
73
- "@dxos/react-ui-theme": "0.8.2-main.fbd8ed0",
74
- "@dxos/storybook-utils": "0.8.2-main.fbd8ed0"
72
+ "@dxos/react-ui": "0.8.2-staging.7ac8446",
73
+ "@dxos/react-ui-theme": "0.8.2-staging.7ac8446",
74
+ "@dxos/storybook-utils": "0.8.2-staging.7ac8446"
75
75
  },
76
76
  "peerDependencies": {
77
77
  "react": "~18.2.0",
78
78
  "react-dom": "~18.2.0",
79
- "@dxos/react-ui": "0.8.2-main.fbd8ed0",
80
- "@dxos/react-ui-theme": "0.8.2-main.fbd8ed0"
79
+ "@dxos/react-ui": "0.8.2-staging.7ac8446",
80
+ "@dxos/react-ui-theme": "0.8.2-staging.7ac8446"
81
81
  },
82
82
  "publishConfig": {
83
83
  "access": "public"
@@ -222,7 +222,7 @@ const initialRotation: Vector = [0, -40, 0];
222
222
  const meta: Meta = {
223
223
  title: 'ui/react-ui-geo/Globe',
224
224
  component: Globe.Root,
225
- decorators: [withTheme, withLayout({ fullscreen: true, classNames: 'bg-[#000]' })],
225
+ decorators: [withTheme, withLayout({ fullscreen: true, classNames: 'bg-[#000]', tooltips: true })],
226
226
  };
227
227
 
228
228
  export default meta;
@@ -2,17 +2,8 @@
2
2
  // Copyright 2018 DXOS.org
3
3
  //
4
4
 
5
- import {
6
- type GeoProjection,
7
- geoMercator,
8
- geoOrthographic,
9
- geoPath,
10
- geoTransverseMercator,
11
- interpolateNumber,
12
- transition,
13
- easeLinear,
14
- easeSinOut,
15
- } from 'd3';
5
+ import * as d3 from 'd3';
6
+ import { type GeoProjection } from 'd3';
16
7
  import { type ControlPosition } from 'leaflet';
17
8
  import React, {
18
9
  type PropsWithChildren,
@@ -108,18 +99,18 @@ export type GlobeController = {
108
99
  export type ProjectionType = 'orthographic' | 'mercator' | 'transverse-mercator';
109
100
 
110
101
  const projectionMap: Record<ProjectionType, () => GeoProjection> = {
111
- orthographic: geoOrthographic,
112
- mercator: geoMercator,
113
- 'transverse-mercator': geoTransverseMercator,
102
+ orthographic: d3.geoOrthographic,
103
+ mercator: d3.geoMercator,
104
+ 'transverse-mercator': d3.geoTransverseMercator,
114
105
  };
115
106
 
116
107
  const getProjection = (type: GlobeCanvasProps['projection'] = 'orthographic'): GeoProjection => {
117
108
  if (typeof type === 'string') {
118
- const constructor = projectionMap[type] ?? geoOrthographic;
109
+ const constructor = projectionMap[type] ?? d3.geoOrthographic;
119
110
  return constructor();
120
111
  }
121
112
 
122
- return type ?? geoOrthographic();
113
+ return type ?? d3.geoOrthographic();
123
114
  };
124
115
 
125
116
  //
@@ -203,10 +194,10 @@ const GlobeCanvas = forwardRef<GlobeController, GlobeCanvasProps>(
203
194
  setCenter,
204
195
  setScale: (s) => {
205
196
  if (typeof s === 'function') {
206
- const is = interpolateNumber(scaleRef.current, s(scaleRef.current));
197
+ const is = d3.interpolateNumber(scaleRef.current, s(scaleRef.current));
207
198
  // Stop easing if already zooming.
208
- transition()
209
- .ease(zooming.current ? easeLinear : easeSinOut)
199
+ d3.transition()
200
+ .ease(zooming.current ? d3.easeLinear : d3.easeSinOut)
210
201
  .duration(200)
211
202
  .tween('scale', () => (t) => setScale(is(t)))
212
203
  .on('end', () => {
@@ -226,7 +217,7 @@ const GlobeCanvas = forwardRef<GlobeController, GlobeCanvasProps>(
226
217
  // https://d3js.org/d3-geo/path#geoPath
227
218
  // https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext
228
219
  const generator = useMemo(
229
- () => canvas && projection && geoPath(projection, canvas.getContext('2d', { alpha: false })),
220
+ () => canvas && projection && d3.geoPath(projection, canvas.getContext('2d', { alpha: false })),
230
221
  [canvas, projection],
231
222
  );
232
223
 
@@ -13,7 +13,7 @@ import { Map, type MapController } from './Map';
13
13
  import { useMapZoomHandler } from '../../hooks';
14
14
  import { type MapMarker } from '../../types';
15
15
 
16
- const DefaultStory = ({ markers = [] }: { markers?: MapMarker[] }) => {
16
+ const Render = ({ markers }) => {
17
17
  const [controller, setController] = useState<MapController>();
18
18
  const handleZoomAction = useMapZoomHandler(controller);
19
19
 
@@ -26,15 +26,15 @@ const DefaultStory = ({ markers = [] }: { markers?: MapMarker[] }) => {
26
26
  );
27
27
  };
28
28
 
29
- const meta: Meta<typeof DefaultStory> = {
29
+ const meta: Meta<typeof Render> = {
30
30
  title: 'ui/react-ui-geo/Map',
31
- render: DefaultStory,
32
- decorators: [withTheme, withLayout({ fullscreen: true })],
31
+ component: Render,
32
+ decorators: [withTheme, withLayout({ fullscreen: true, tooltips: true })],
33
33
  };
34
34
 
35
35
  export default meta;
36
36
 
37
- type Story = StoryObj<typeof DefaultStory>;
37
+ type Story = StoryObj<typeof Render>;
38
38
 
39
39
  export const Default: Story = {};
40
40
 
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { select } from 'd3';
5
+ import * as d3 from 'd3';
6
6
  import { useEffect } from 'react';
7
7
 
8
8
  import { type GlobeController } from '../components';
@@ -31,7 +31,7 @@ export const useDrag = (controller?: GlobeController | null, options: DragOption
31
31
  }
32
32
 
33
33
  geoInertiaDrag(
34
- select(canvas),
34
+ d3.select(canvas),
35
35
  () => {
36
36
  controller.setRotation(controller.projection.rotate());
37
37
  options.onUpdate?.({ type: 'move', controller });
@@ -47,7 +47,7 @@ export const useDrag = (controller?: GlobeController | null, options: DragOption
47
47
 
48
48
  // TODO(burdon): Cancel drag timer.
49
49
  return () => {
50
- cancelDrag(select(canvas));
50
+ cancelDrag(d3.select(canvas));
51
51
  };
52
52
  }, [controller, JSON.stringify(options)]);
53
53
  };
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { timer as d3Timer } from 'd3';
5
+ import * as d3 from 'd3';
6
6
  import { type Timer } from 'd3';
7
7
  import { useEffect, useState } from 'react';
8
8
 
@@ -27,7 +27,7 @@ export const useSpinner = (controller?: GlobeController | null, options: Spinner
27
27
 
28
28
  let t = 0;
29
29
  let lastRotation = controller.projection.rotate();
30
- timer = d3Timer((elapsed) => {
30
+ timer = d3.timer((elapsed) => {
31
31
  const dt = elapsed - t;
32
32
  t = elapsed;
33
33
 
@@ -2,10 +2,12 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { geoPath, geoInterpolate, geoDistance, selection as d3Selection } from 'd3';
6
- import { type SetStateAction, type Dispatch, useEffect, useState, useMemo } from 'react';
5
+ import * as d3 from 'd3';
6
+ import { type Dispatch, type SetStateAction, useEffect, useState } from 'react';
7
7
  import versor from 'versor';
8
8
 
9
+ import { log } from '@dxos/log';
10
+
9
11
  import type { GlobeController } from '../components';
10
12
  import { geoToPosition, type LatLng, positionToRotation, type StyleSet } from '../util';
11
13
 
@@ -32,7 +34,7 @@ export const useTour = (
32
34
  points?: LatLng[],
33
35
  options: TourOptions = {},
34
36
  ): [boolean, Dispatch<SetStateAction<boolean>>] => {
35
- const selection = useMemo(() => d3Selection(), []);
37
+ const selection = d3.selection();
36
38
  const [running, setRunning] = useState(options.running ?? false);
37
39
  useEffect(() => {
38
40
  if (!running) {
@@ -45,7 +47,7 @@ export const useTour = (
45
47
  t = setTimeout(async () => {
46
48
  const { canvas, projection, setRotation } = controller;
47
49
  const context = canvas.getContext('2d', { alpha: false });
48
- const path = geoPath(projection, context).pointRadius(2);
50
+ const path = d3.geoPath(projection, context).pointRadius(2);
49
51
 
50
52
  const tilt = options.tilt ?? 0;
51
53
  let last: LatLng;
@@ -63,8 +65,8 @@ export const useTour = (
63
65
  // Points.
64
66
  const p1 = last ? geoToPosition(last) : undefined;
65
67
  const p2 = geoToPosition(next);
66
- const ip = geoInterpolate(p1 || p2, p2);
67
- const distance = geoDistance(p1 || p2, p2);
68
+ const ip = d3.geoInterpolate(p1 || p2, p2);
69
+ const distance = d3.geoDistance(p1 || p2, p2);
68
70
 
69
71
  // Rotation.
70
72
  const r1 = p1 ? positionToRotation(p1, tilt) : controller.projection.rotate();
@@ -96,8 +98,10 @@ export const useTour = (
96
98
  context.restore();
97
99
 
98
100
  // TODO(burdon): This has to come after rendering above. Add to features to correct order?
99
- projection.rotate(iv(t));
100
- setRotation(projection.rotate());
101
+ if (options.autoRotate) {
102
+ projection.rotate(iv(t));
103
+ setRotation(projection.rotate());
104
+ }
101
105
  });
102
106
 
103
107
  // Throws if interrupted.
@@ -105,7 +109,7 @@ export const useTour = (
105
109
  last = next;
106
110
  }
107
111
  } catch (err) {
108
- // Ignore.
112
+ log.catch(err);
109
113
  } finally {
110
114
  setRunning(false);
111
115
  }
@@ -4,7 +4,7 @@
4
4
  // https://github.com/Fil/d3-inertia
5
5
  //
6
6
 
7
- import { select, drag, timer } from 'd3';
7
+ import * as d3 from 'd3';
8
8
  import versor from 'versor';
9
9
 
10
10
  export const restrictAxis =
@@ -26,7 +26,7 @@ export const geoInertiaDrag = (target, render, projection, options) => {
26
26
  if (target.node) {
27
27
  target = target.node();
28
28
  }
29
- target = select(target);
29
+ target = d3.select(target);
30
30
 
31
31
  // Complete params: (projection, render, startDrag, dragging, endDrag).
32
32
  const inertia = geoInertiaDragHelper({
@@ -45,7 +45,7 @@ export const geoInertiaDrag = (target, render, projection, options) => {
45
45
  hold: options.hold,
46
46
  });
47
47
 
48
- target.call(drag().on('start', inertia.start).on('drag', inertia.move).on('end', inertia.end));
48
+ target.call(d3.drag().on('start', inertia.start).on('drag', inertia.move).on('end', inertia.end));
49
49
  return inertia;
50
50
  };
51
51
 
@@ -119,7 +119,7 @@ function inertiaHelper(opt) {
119
119
  const inertia = {
120
120
  position: [0, 0],
121
121
  velocity: [0, 0], // Velocity in pixels/s.
122
- timer: timer(() => {}),
122
+ timer: d3.timer(() => {}),
123
123
  time: 0,
124
124
  t: 0,
125
125
 
@@ -135,6 +135,7 @@ function inertiaHelper(opt) {
135
135
 
136
136
  move: function (ev) {
137
137
  const position = [ev.x, ev.y];
138
+
138
139
  const time = performance.now();
139
140
  const deltaTime = time - inertia.time;
140
141
  const decay = 1 - Math.exp(-deltaTime / 1_000);
package/src/util/path.ts CHANGED
@@ -2,13 +2,16 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { type GeoGeometryObjects, geoCircle as d3GeoCircle } from 'd3';
5
+ import * as d3 from 'd3';
6
+ import { type GeoGeometryObjects } from 'd3';
6
7
  import { type Point, type Polygon, type Position } from 'geojson';
7
8
 
8
9
  import type { Vector } from '../hooks';
9
10
 
10
11
  export type LatLng = { lat: number; lng: number };
11
12
 
13
+ // TODO(burdon): Clean-up.
14
+
12
15
  export const positionToRotation = ([lng, lat]: [number, number], tilt = 0): Vector => [-lng, tilt - lat, 0];
13
16
 
14
17
  export const geoToPosition = ({ lat, lng }: LatLng): [number, number] => [lng, lat];
@@ -17,7 +20,7 @@ export const geoPoint = (point: LatLng): Point => ({ type: 'Point', coordinates:
17
20
 
18
21
  // https://github.com/d3/d3-geo#geoCircle
19
22
  export const geoCircle = ({ lat, lng }: LatLng, radius: number): Polygon =>
20
- d3GeoCircle().radius(radius).center([lng, lat])();
23
+ d3.geoCircle().radius(radius).center([lng, lat])();
21
24
 
22
25
  export const geoLine = (p1: LatLng, p2: LatLng): GeoGeometryObjects => ({
23
26
  type: 'LineString',
@@ -2,8 +2,9 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { type GeoPath, type GeoPermissibleObjects, geoGraticule } from 'd3';
6
- import { feature, mesh } from 'topojson-client';
5
+ import * as d3 from 'd3';
6
+ import { type GeoPath, type GeoPermissibleObjects } from 'd3';
7
+ import * as topojson from 'topojson-client';
7
8
  import { type Topology } from 'topojson-specification';
8
9
 
9
10
  import { type LatLng, geoLine, geoPoint } from './path';
@@ -52,7 +53,7 @@ export const createLayers = (topology: Topology, features: Features, styles: Sty
52
53
  if (styles.graticule) {
53
54
  layers.push({
54
55
  styles: styles.graticule,
55
- path: geoGraticule().step([6, 6])(),
56
+ path: d3.geoGraticule().step([6, 6])(),
56
57
  });
57
58
  }
58
59
 
@@ -64,14 +65,14 @@ export const createLayers = (topology: Topology, features: Features, styles: Sty
64
65
  if (topology.objects.land && styles.land) {
65
66
  layers.push({
66
67
  styles: styles.land,
67
- path: feature(topology, topology.objects.land),
68
+ path: topojson.feature(topology, topology.objects.land),
68
69
  });
69
70
  }
70
71
 
71
72
  if (topology.objects.countries && styles.border) {
72
73
  layers.push({
73
74
  styles: styles.border,
74
- path: mesh(topology, topology.objects.countries, (a: any, b: any) => a !== b),
75
+ path: topojson.mesh(topology, topology.objects.countries, (a: any, b: any) => a !== b),
75
76
  });
76
77
  }
77
78