@dxos/react-ui-geo 0.7.5-labs.ff2ff30 → 0.7.5-main.6a330ac
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.
- package/dist/lib/browser/index.mjs +113 -48
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +111 -46
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +113 -48
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Globe/Globe.d.ts +5 -5
- package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.stories.d.ts +9 -10
- package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
- package/dist/types/src/components/Map/Map.d.ts +7 -7
- package/dist/types/src/components/Map/Map.d.ts.map +1 -1
- package/dist/types/src/components/Map/Map.stories.d.ts +6 -2
- package/dist/types/src/components/Map/Map.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Controls.d.ts +2 -3
- package/dist/types/src/components/Toolbar/Controls.d.ts.map +1 -1
- package/dist/types/src/components/types.d.ts +2 -1
- package/dist/types/src/components/types.d.ts.map +1 -1
- package/dist/types/src/hooks/context.d.ts +2 -2
- package/dist/types/src/hooks/context.d.ts.map +1 -1
- package/dist/types/src/hooks/useTour.d.ts +8 -3
- package/dist/types/src/hooks/useTour.d.ts.map +1 -1
- package/dist/types/src/util/debug.d.ts.map +1 -1
- package/dist/types/src/util/render.d.ts +2 -2
- package/dist/types/src/util/render.d.ts.map +1 -1
- package/package.json +12 -10
- package/src/components/Globe/Globe.stories.tsx +8 -11
- package/src/components/Globe/Globe.tsx +56 -32
- package/src/components/Map/Map.stories.tsx +28 -6
- package/src/components/Map/Map.tsx +93 -82
- package/src/components/types.ts +2 -1
- package/src/hooks/useDrag.ts +1 -1
- package/src/hooks/useTour.ts +31 -19
- package/src/util/debug.ts +1 -0
- package/src/util/render.ts +18 -4
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
import * as d37 from "d3";
|
|
7
7
|
import React3, { forwardRef, useEffect as useEffect4, useImperativeHandle, useMemo, useRef, useState as useState3 } from "react";
|
|
8
8
|
import { useResizeDetector } from "react-resize-detector";
|
|
9
|
-
import { useDynamicRef } from "@dxos/react-ui";
|
|
9
|
+
import { useDynamicRef, useThemeContext } from "@dxos/react-ui";
|
|
10
10
|
import { mx } from "@dxos/react-ui-theme";
|
|
11
11
|
|
|
12
12
|
// packages/ui/react-ui-geo/src/hooks/context.tsx
|
|
@@ -349,17 +349,22 @@ var createLayers = (topology, features, styles) => {
|
|
|
349
349
|
}
|
|
350
350
|
return layers;
|
|
351
351
|
};
|
|
352
|
-
var renderLayers = (generator, layers = [], scale) => {
|
|
352
|
+
var renderLayers = (generator, layers = [], scale, styles) => {
|
|
353
353
|
const context = generator.context();
|
|
354
354
|
const { canvas: { width, height } } = context;
|
|
355
355
|
context.reset();
|
|
356
|
-
|
|
357
|
-
|
|
356
|
+
if (styles.background) {
|
|
357
|
+
context.fillStyle = styles.background.fillStyle;
|
|
358
|
+
context.fillRect(0, 0, width, height);
|
|
359
|
+
} else {
|
|
360
|
+
context.clearRect(0, 0, width, height);
|
|
361
|
+
}
|
|
362
|
+
layers.forEach(({ path, styles: styles2 }) => {
|
|
358
363
|
context.save();
|
|
359
364
|
let fill = false;
|
|
360
365
|
let stroke = false;
|
|
361
|
-
if (
|
|
362
|
-
Object.entries(
|
|
366
|
+
if (styles2) {
|
|
367
|
+
Object.entries(styles2).forEach(([key, value]) => {
|
|
363
368
|
if (key === "pointRadius") {
|
|
364
369
|
generator.pointRadius(value * scale);
|
|
365
370
|
} else {
|
|
@@ -408,7 +413,7 @@ var useDrag = (controller, options = {}) => {
|
|
|
408
413
|
};
|
|
409
414
|
}, [
|
|
410
415
|
controller,
|
|
411
|
-
options
|
|
416
|
+
JSON.stringify(options)
|
|
412
417
|
]);
|
|
413
418
|
};
|
|
414
419
|
var cancelDrag = (node) => node.on(".drag", null);
|
|
@@ -514,11 +519,13 @@ var useSpinner = (controller, options = {}) => {
|
|
|
514
519
|
import * as d36 from "d3";
|
|
515
520
|
import { useEffect as useEffect3, useState as useState2 } from "react";
|
|
516
521
|
import versor2 from "versor";
|
|
522
|
+
import { log } from "@dxos/log";
|
|
523
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-geo/src/hooks/useTour.ts";
|
|
517
524
|
var TRANSITION_NAME = "globe-tour";
|
|
518
525
|
var defaultDuration = 1500;
|
|
519
|
-
var useTour = (controller,
|
|
526
|
+
var useTour = (controller, points, options = {}) => {
|
|
520
527
|
const selection2 = d36.selection();
|
|
521
|
-
const [running, setRunning] = useState2(false);
|
|
528
|
+
const [running, setRunning] = useState2(options.running ?? false);
|
|
522
529
|
useEffect3(() => {
|
|
523
530
|
if (!running) {
|
|
524
531
|
selection2.interrupt(TRANSITION_NAME);
|
|
@@ -532,10 +539,16 @@ var useTour = (controller, features, options = {}) => {
|
|
|
532
539
|
alpha: false
|
|
533
540
|
});
|
|
534
541
|
const path = d36.geoPath(projection, context).pointRadius(2);
|
|
535
|
-
const tilt = 0;
|
|
542
|
+
const tilt = options.tilt ?? 0;
|
|
536
543
|
let last;
|
|
537
544
|
try {
|
|
538
|
-
|
|
545
|
+
const p = [
|
|
546
|
+
...points
|
|
547
|
+
];
|
|
548
|
+
if (options.loop) {
|
|
549
|
+
p.push(p[0]);
|
|
550
|
+
}
|
|
551
|
+
for (const next of p) {
|
|
539
552
|
if (!running) {
|
|
540
553
|
break;
|
|
541
554
|
}
|
|
@@ -573,13 +586,22 @@ var useTour = (controller, features, options = {}) => {
|
|
|
573
586
|
context.fill();
|
|
574
587
|
}
|
|
575
588
|
context.restore();
|
|
576
|
-
|
|
577
|
-
|
|
589
|
+
if (options.autoRotate) {
|
|
590
|
+
projection.rotate(iv(t2));
|
|
591
|
+
setRotation(projection.rotate());
|
|
592
|
+
}
|
|
578
593
|
});
|
|
579
594
|
await transition2.end();
|
|
580
595
|
last = next;
|
|
581
596
|
}
|
|
582
597
|
} catch (err) {
|
|
598
|
+
log.catch(err, void 0, {
|
|
599
|
+
F: __dxlog_file,
|
|
600
|
+
L: 112,
|
|
601
|
+
S: void 0,
|
|
602
|
+
C: (f, a) => f(...a)
|
|
603
|
+
});
|
|
604
|
+
} finally {
|
|
583
605
|
setRunning(false);
|
|
584
606
|
}
|
|
585
607
|
});
|
|
@@ -590,15 +612,12 @@ var useTour = (controller, features, options = {}) => {
|
|
|
590
612
|
}
|
|
591
613
|
}, [
|
|
592
614
|
controller,
|
|
593
|
-
running
|
|
615
|
+
running,
|
|
616
|
+
JSON.stringify(options)
|
|
594
617
|
]);
|
|
595
618
|
return [
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
setRunning(true);
|
|
599
|
-
}
|
|
600
|
-
},
|
|
601
|
-
() => setRunning(false)
|
|
619
|
+
running,
|
|
620
|
+
setRunning
|
|
602
621
|
];
|
|
603
622
|
};
|
|
604
623
|
|
|
@@ -662,28 +681,45 @@ var ActionControls = ({ classNames, onAction }) => {
|
|
|
662
681
|
|
|
663
682
|
// packages/ui/react-ui-geo/src/components/Globe/Globe.tsx
|
|
664
683
|
var defaultStyles = {
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
684
|
+
light: {
|
|
685
|
+
background: {
|
|
686
|
+
fillStyle: "#EEE"
|
|
687
|
+
},
|
|
688
|
+
water: {
|
|
689
|
+
fillStyle: "#555"
|
|
690
|
+
},
|
|
691
|
+
land: {
|
|
692
|
+
fillStyle: "#999"
|
|
693
|
+
},
|
|
694
|
+
line: {
|
|
695
|
+
strokeStyle: "darkred"
|
|
696
|
+
},
|
|
697
|
+
point: {
|
|
698
|
+
fillStyle: "#111111",
|
|
699
|
+
strokeStyle: "#111111",
|
|
700
|
+
strokeWidth: 1,
|
|
701
|
+
pointRadius: 0.5
|
|
702
|
+
}
|
|
681
703
|
},
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
704
|
+
dark: {
|
|
705
|
+
background: {
|
|
706
|
+
fillStyle: "#111111"
|
|
707
|
+
},
|
|
708
|
+
water: {
|
|
709
|
+
fillStyle: "#123E6A"
|
|
710
|
+
},
|
|
711
|
+
land: {
|
|
712
|
+
fillStyle: "#032153"
|
|
713
|
+
},
|
|
714
|
+
line: {
|
|
715
|
+
strokeStyle: "#111111"
|
|
716
|
+
},
|
|
717
|
+
point: {
|
|
718
|
+
fillStyle: "#111111",
|
|
719
|
+
strokeStyle: "#111111",
|
|
720
|
+
strokeWidth: 1,
|
|
721
|
+
pointRadius: 0.5
|
|
722
|
+
}
|
|
687
723
|
}
|
|
688
724
|
};
|
|
689
725
|
var projectionMap = {
|
|
@@ -711,7 +747,12 @@ var GlobeRoot = ({ classNames, children, ...props }) => {
|
|
|
711
747
|
...props
|
|
712
748
|
}, children));
|
|
713
749
|
};
|
|
714
|
-
var GlobeCanvas = /* @__PURE__ */ forwardRef(({ projection: _projection, topology, features, styles
|
|
750
|
+
var GlobeCanvas = /* @__PURE__ */ forwardRef(({ projection: _projection, topology, features, styles: _styles }, forwardRef3) => {
|
|
751
|
+
const { themeMode } = useThemeContext();
|
|
752
|
+
const styles = useMemo(() => _styles ?? defaultStyles[themeMode], [
|
|
753
|
+
_styles,
|
|
754
|
+
themeMode
|
|
755
|
+
]);
|
|
715
756
|
const [canvas, setCanvas] = useState3(null);
|
|
716
757
|
const canvasRef = (canvas2) => setCanvas(canvas2);
|
|
717
758
|
const projection = useMemo(() => getProjection(_projection), [
|
|
@@ -779,7 +820,7 @@ var GlobeCanvas = /* @__PURE__ */ forwardRef(({ projection: _projection, topolog
|
|
|
779
820
|
0,
|
|
780
821
|
0
|
|
781
822
|
]);
|
|
782
|
-
renderLayers(generator, layers, scale);
|
|
823
|
+
renderLayers(generator, layers, scale, styles);
|
|
783
824
|
});
|
|
784
825
|
}
|
|
785
826
|
}, [
|
|
@@ -843,13 +884,13 @@ var Globe = {
|
|
|
843
884
|
|
|
844
885
|
// packages/ui/react-ui-geo/src/components/Map/Map.tsx
|
|
845
886
|
import "leaflet/dist/leaflet.css";
|
|
846
|
-
import { Control, DomEvent, DomUtil, latLngBounds } from "leaflet";
|
|
887
|
+
import L, { Control, DomEvent, DomUtil, latLngBounds } from "leaflet";
|
|
847
888
|
import React4, { forwardRef as forwardRef2, useEffect as useEffect5, useImperativeHandle as useImperativeHandle2 } from "react";
|
|
848
889
|
import { createRoot } from "react-dom/client";
|
|
849
890
|
import { MapContainer, Marker, Popup, TileLayer, useMap } from "react-leaflet";
|
|
850
891
|
import { useResizeDetector as useResizeDetector2 } from "react-resize-detector";
|
|
851
892
|
import { debounce } from "@dxos/async";
|
|
852
|
-
import {
|
|
893
|
+
import { ThemeProvider, Tooltip } from "@dxos/react-ui";
|
|
853
894
|
import { defaultTx, mx as mx2 } from "@dxos/react-ui-theme";
|
|
854
895
|
var defaults = {
|
|
855
896
|
// TODO(burdon): Guess location.
|
|
@@ -871,7 +912,7 @@ var MapRoot = ({ classNames, center = defaults.center, zoom = defaults.zoom, ...
|
|
|
871
912
|
...props
|
|
872
913
|
});
|
|
873
914
|
};
|
|
874
|
-
var MapCanvas = /* @__PURE__ */ forwardRef2(({ markers
|
|
915
|
+
var MapCanvas = /* @__PURE__ */ forwardRef2(({ markers, center, zoom, onChange }, forwardedRef) => {
|
|
875
916
|
const { ref, width, height } = useResizeDetector2({
|
|
876
917
|
refreshRate: 200
|
|
877
918
|
});
|
|
@@ -937,13 +978,37 @@ var MapCanvas = /* @__PURE__ */ forwardRef2(({ markers = [], center, zoom, onCha
|
|
|
937
978
|
}, /* @__PURE__ */ React4.createElement(TileLayer, {
|
|
938
979
|
className: "dark:filter dark:grayscale dark:invert",
|
|
939
980
|
url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
|
940
|
-
}), markers
|
|
981
|
+
}), markers?.map(({ id, title, location: { lat, lng } }) => {
|
|
941
982
|
return /* @__PURE__ */ React4.createElement(Marker, {
|
|
942
983
|
key: id,
|
|
943
984
|
position: {
|
|
944
985
|
lat,
|
|
945
986
|
lng
|
|
946
|
-
}
|
|
987
|
+
},
|
|
988
|
+
icon: (
|
|
989
|
+
// TODO(burdon): Create custom icon from bundled assets.
|
|
990
|
+
new L.Icon({
|
|
991
|
+
iconUrl: "https://dxos.network/marker-icon.png",
|
|
992
|
+
iconRetinaUrl: "https://dxos.network/marker-icon-2x.png",
|
|
993
|
+
shadowUrl: "https://dxos.network/marker-shadow.png",
|
|
994
|
+
iconSize: [
|
|
995
|
+
25,
|
|
996
|
+
41
|
|
997
|
+
],
|
|
998
|
+
iconAnchor: [
|
|
999
|
+
12,
|
|
1000
|
+
41
|
|
1001
|
+
],
|
|
1002
|
+
popupAnchor: [
|
|
1003
|
+
1,
|
|
1004
|
+
-34
|
|
1005
|
+
],
|
|
1006
|
+
shadowSize: [
|
|
1007
|
+
41,
|
|
1008
|
+
41
|
|
1009
|
+
]
|
|
1010
|
+
})
|
|
1011
|
+
)
|
|
947
1012
|
}, title && /* @__PURE__ */ React4.createElement(Popup, null, title));
|
|
948
1013
|
}));
|
|
949
1014
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/Globe/Globe.tsx", "../../../src/hooks/context.tsx", "../../../src/hooks/useDrag.ts", "../../../src/util/debug.ts", "../../../src/util/inertia.ts", "../../../src/util/path.ts", "../../../src/util/render.ts", "../../../src/hooks/useGlobeZoomHandler.ts", "../../../src/hooks/useMapZoomHandler.ts", "../../../src/hooks/useSpinner.ts", "../../../src/hooks/useTour.ts", "../../../src/components/Toolbar/Controls.tsx", "../../../src/components/Map/Map.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2018 DXOS.org\n//\n\nimport * as d3 from 'd3';\nimport { type GeoProjection } from 'd3';\nimport { type ControlPosition } from 'leaflet';\nimport React, {\n type PropsWithChildren,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useResizeDetector } from 'react-resize-detector';\nimport { type Topology } from 'topojson-specification';\n\nimport { type ThemedClassName, useDynamicRef } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport {\n GlobeContextProvider,\n type GlobeContextProviderProps,\n type GlobeContextType,\n useGlobeContext,\n} from '../../hooks';\nimport {\n type Features,\n type Styles,\n type StyleSet,\n createLayers,\n geoToPosition,\n positionToRotation,\n renderLayers,\n timer,\n} from '../../util';\nimport { ZoomControls, ActionControls, type ControlProps, controlPositions } from '../Toolbar';\n\n// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute\nconst defaultStyles: Styles = {\n background: {\n fillStyle: '#111111',\n },\n\n water: {\n fillStyle: '#123E6A',\n },\n\n hex: {\n strokeStyle: 'green',\n fillStyle: 'gray',\n pointRadius: 1,\n },\n\n land: {\n fillStyle: '#032153',\n },\n\n line: {\n strokeStyle: '#111111',\n },\n\n point: {\n fillStyle: '#111111',\n strokeStyle: '#111111',\n strokeWidth: 1,\n pointRadius: 0.5,\n },\n};\n\nexport type GlobeController = {\n canvas: HTMLCanvasElement;\n projection: GeoProjection;\n} & Pick<GlobeContextType, 'scale' | 'translation' | 'rotation' | 'setScale' | 'setTranslation' | 'setRotation'>;\n\nexport type ProjectionType = 'orthographic' | 'mercator' | 'transverse-mercator';\n\nconst projectionMap: Record<ProjectionType, () => GeoProjection> = {\n orthographic: d3.geoOrthographic,\n mercator: d3.geoMercator,\n 'transverse-mercator': d3.geoTransverseMercator,\n};\n\nconst getProjection = (type: GlobeCanvasProps['projection'] = 'orthographic'): GeoProjection => {\n if (typeof type === 'string') {\n const constructor = projectionMap[type] ?? d3.geoOrthographic;\n return constructor();\n }\n\n return type ?? d3.geoOrthographic();\n};\n\n//\n// Root\n//\n\ntype GlobeRootProps = PropsWithChildren<ThemedClassName<GlobeContextProviderProps>>;\n\nconst GlobeRoot = ({ classNames, children, ...props }: GlobeRootProps) => {\n const { ref, width, height } = useResizeDetector<HTMLDivElement>();\n return (\n <div ref={ref} className={mx('relative flex grow overflow-hidden', classNames)}>\n <GlobeContextProvider size={{ width, height }} {...props}>\n {children}\n </GlobeContextProvider>\n </div>\n );\n};\n\n//\n// Canvas\n//\n\ntype GlobeCanvasProps = {\n projection?: ProjectionType | GeoProjection;\n topology?: Topology;\n features?: Features;\n styles?: StyleSet;\n};\n\n/**\n * Basic globe renderer.\n * https://github.com/topojson/world-atlas\n */\nconst GlobeCanvas = forwardRef<GlobeController, GlobeCanvasProps>(\n ({ projection: _projection, topology, features, styles = defaultStyles }, forwardRef) => {\n // Canvas.\n const [canvas, setCanvas] = useState<HTMLCanvasElement>(null);\n const canvasRef = (canvas: HTMLCanvasElement) => setCanvas(canvas);\n\n // Projection.\n const projection = useMemo(() => getProjection(_projection), [_projection]);\n\n // Layers.\n // TODO(burdon): Generate on the fly based on what is visible.\n const layers = useMemo(() => {\n return timer(() => createLayers(topology as Topology, features, styles));\n }, [topology, features, styles]);\n\n // State.\n const { size, center, scale, translation, rotation, setCenter, setScale, setTranslation, setRotation } =\n useGlobeContext();\n\n const scaleRef = useDynamicRef(scale);\n\n // Update rotation.\n useEffect(() => {\n if (center) {\n setScale(1);\n setRotation(positionToRotation(geoToPosition(center)));\n }\n }, [center]);\n\n // External controller.\n const zooming = useRef(false);\n useImperativeHandle<GlobeController, GlobeController>(\n forwardRef,\n () => {\n return {\n canvas,\n projection,\n center,\n get scale() {\n return scaleRef.current;\n },\n translation,\n rotation,\n setCenter,\n setScale: (s) => {\n if (typeof s === 'function') {\n const is = d3.interpolateNumber(scaleRef.current, s(scaleRef.current));\n // Stop easing if already zooming.\n d3.transition()\n .ease(zooming.current ? d3.easeLinear : d3.easeSinOut)\n .duration(200)\n .tween('scale', () => (t) => setScale(is(t)))\n .on('end', () => {\n zooming.current = false;\n });\n } else {\n setScale(s);\n }\n },\n setTranslation,\n setRotation,\n };\n },\n [canvas],\n );\n\n // https://d3js.org/d3-geo/path#geoPath\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext\n const generator = useMemo(\n () => canvas && projection && d3.geoPath(projection, canvas.getContext('2d', { alpha: false })),\n [canvas, projection],\n );\n\n // Render on change.\n useEffect(() => {\n if (canvas && projection) {\n timer(() => {\n // https://d3js.org/d3-geo/projection\n projection\n .scale((Math.min(size.width, size.height) / 2) * scale)\n .translate([size.width / 2 + (translation?.x ?? 0), size.height / 2 + (translation?.y ?? 0)])\n .rotate(rotation ?? [0, 0, 0]);\n\n renderLayers(generator, layers, scale);\n });\n }\n }, [generator, size, scale, translation, rotation, layers]);\n\n if (!size.width || !size.height) {\n return null;\n }\n\n return <canvas ref={canvasRef} width={size.width} height={size.height} />;\n },\n);\n\nconst GlobeDebug = ({ position = 'topleft' }: { position?: ControlPosition }) => {\n const { size, scale, translation, rotation } = useGlobeContext();\n return (\n <div\n className={mx(\n 'z-10 absolute w-96 p-2 overflow-hidden border border-green-700 rounded',\n controlPositions[position],\n )}\n >\n <pre className='font-mono text-xs text-green-700'>\n {JSON.stringify({ size, scale, translation, rotation }, null, 2)}\n </pre>\n </div>\n );\n};\n\nconst GlobePanel = ({\n position,\n classNames,\n children,\n}: ThemedClassName<PropsWithChildren & { position?: ControlPosition }>) => {\n return <div className={mx('z-10 absolute overflow-hidden', controlPositions[position], classNames)}>{children}</div>;\n};\n\nconst CustomControl = ({ position, children }: PropsWithChildren<{ position: ControlPosition }>) => {\n return <div className={mx('z-10 absolute overflow-hidden', controlPositions[position])}>{children}</div>;\n};\n\ntype GlobeControlProps = { position?: ControlPosition } & Pick<ControlProps, 'onAction'>;\n\nexport const Globe = {\n Root: GlobeRoot,\n Canvas: GlobeCanvas,\n Zoom: ({ onAction, position = 'bottomleft', ...props }: GlobeControlProps) => (\n <CustomControl position={position} {...props}>\n <ZoomControls onAction={onAction} />\n </CustomControl>\n ),\n Action: ({ onAction, position = 'bottomright', ...props }: GlobeControlProps) => (\n <CustomControl position={position} {...props}>\n <ActionControls onAction={onAction} />\n </CustomControl>\n ),\n Debug: GlobeDebug,\n Panel: GlobePanel,\n};\n\nexport type { GlobeRootProps, GlobeCanvasProps };\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { createContext, type Dispatch, type PropsWithChildren, type SetStateAction, useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\nimport { useControlledState } from '@dxos/react-ui';\n\nimport { type LatLng } from '../util';\n\n// TODO(burdon): Factor out common geometry types.\nexport type Size = { width: number; height: number };\nexport type Point = { x: number; y: number };\nexport type Vector = [number, number, number];\n\nexport type GlobeContextType = {\n size: Size;\n center: LatLng;\n scale: number;\n translation: Point;\n rotation: Vector;\n setCenter: Dispatch<SetStateAction<LatLng>>;\n setScale: Dispatch<SetStateAction<number>>;\n setTranslation: Dispatch<SetStateAction<Point>>;\n setRotation: Dispatch<SetStateAction<Vector>>;\n};\n\nconst GlobeContext = createContext<GlobeContextType>(undefined);\n\nexport type GlobeContextProviderProps = PropsWithChildren<\n Partial<Pick<GlobeContextType, 'size' | 'center' | 'scale' | 'translation' | 'rotation'>>\n>;\n\nexport const GlobeContextProvider = ({\n children,\n size,\n center: _center,\n scale: _scale,\n translation: _translation,\n rotation: _rotation,\n}: GlobeContextProviderProps) => {\n const [center, setCenter] = useControlledState(_center);\n const [scale, setScale] = useControlledState(_scale);\n const [translation, setTranslation] = useControlledState<Point>(_translation);\n const [rotation, setRotation] = useControlledState<Vector>(_rotation);\n\n return (\n <GlobeContext.Provider\n value={{ size, center, scale, translation, rotation, setCenter, setScale, setTranslation, setRotation }}\n >\n {children}\n </GlobeContext.Provider>\n );\n};\n\nexport const useGlobeContext = () => {\n return useContext(GlobeContext) ?? raise(new Error('Missing GlobeContext'));\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as d3 from 'd3';\nimport { useEffect } from 'react';\n\nimport { type GlobeController } from '../components';\nimport { geoInertiaDrag } from '../util';\n\nexport type GlobeDragEvent = {\n type: 'start' | 'move' | 'end';\n controller: GlobeController;\n};\n\nexport type DragOptions = {\n disabled?: boolean;\n duration?: number;\n xAxis?: boolean; // TODO(burdon): Generalize.\n onUpdate?: (event: GlobeDragEvent) => void;\n};\n\n/**\n * Allows user to drag globe.\n */\nexport const useDrag = (controller?: GlobeController | null, options: DragOptions = {}) => {\n useEffect(() => {\n const canvas = controller?.canvas;\n if (!canvas || options.disabled) {\n return;\n }\n\n geoInertiaDrag(\n d3.select(canvas),\n () => {\n controller.setRotation(controller.projection.rotate());\n options.onUpdate?.({ type: 'move', controller });\n },\n controller.projection,\n {\n xAxis: options.xAxis,\n time: 3_000,\n start: () => options.onUpdate?.({ type: 'start', controller }),\n finish: () => options.onUpdate?.({ type: 'end', controller }),\n },\n );\n\n // TODO(burdon): Cancel drag timer.\n return () => {\n cancelDrag(d3.select(canvas));\n };\n }, [controller, options]);\n};\n\nconst cancelDrag = (node) => node.on('.drag', null);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nconst debug = false;\n\nexport const timer = <T = void>(cb: () => T): T => {\n const start = Date.now();\n const data = cb();\n const t = Date.now() - start / 1_000;\n if (debug) {\n // eslint-disable-next-line no-console\n console.log({ t, data });\n }\n return data;\n};\n", "//\n// Copyright 2017 Philippe Rivière\n// Copyright 2024 DXOS.org\n// https://github.com/Fil/d3-inertia\n//\n\nimport * as d3 from 'd3';\nimport versor from 'versor';\n\nexport const restrictAxis =\n (axis: boolean[]) =>\n (original: number[], current: number[]): number[] =>\n current.map((d, i) => (axis[i] ? d : original[i]));\n\n/**\n * Applies a drag handler to the specified target element.\n */\n// TODO(burdon): Define type.\nexport const geoInertiaDrag = (target, render, projection, options) => {\n if (!options) {\n options = {};\n }\n\n // Target can be an element, a selector, a function, or a selection\n // but in case of a selection we make sure to reselect it with d3-selection.\n if (target.node) {\n target = target.node();\n }\n target = d3.select(target);\n\n // Complete params: (projection, render, startDrag, dragging, endDrag).\n const inertia = geoInertiaDragHelper({\n projection,\n render: (rotation) => {\n projection.rotate(rotation);\n render && render();\n },\n axis: restrictAxis(options.xAxis ? [true, false, false] : [true, true, true]),\n start: options.start,\n move: options.move,\n end: options.end,\n stop: options.stop,\n finish: options.finish,\n time: options.time,\n hold: options.hold,\n });\n\n target.call(d3.drag().on('start', inertia.start).on('drag', inertia.move).on('end', inertia.end));\n return inertia;\n};\n\n/**\n * A versor is a compact way to describe a rotation in 3D space.\n * It consists of four components [𝑤,x,y,z], where:\n * 𝑤 is a scalar representing the angle of rotation.\n * x, y, z are the vector components, representing the axis of rotation.\n */\nconst geoInertiaDragHelper = (opt) => {\n const projection = opt.projection;\n\n let v0; // Mouse position in Cartesian coordinates at start of drag gesture.\n let r0; // Projection rotation as Euler angles at start.\n let q0; // Projection rotation as versor at start.\n let v10; // Mouse position in Cartesian coordinates just before end of drag gesture.\n let v11; // Mouse position in Cartesian coordinates at end.\n let q10; // Projection rotation as versor at end.\n\n const inertia = inertiaHelper({\n axis: opt.axis,\n\n start: () => {\n v0 = versor.cartesian(projection.invert(inertia.position));\n r0 = projection.rotate();\n q0 = versor(r0);\n opt.start && opt.start();\n },\n\n move: () => {\n const inv = projection.rotate(r0).invert(inertia.position);\n if (isNaN(inv[0])) {\n return;\n }\n const v1 = versor.cartesian(inv);\n const q1 = versor.multiply(q0, versor.delta(v0, v1));\n const r1 = versor.rotation(q1);\n const r2 = opt.axis(r0, r1);\n opt.render(r2);\n opt.move && opt.move();\n },\n\n end: () => {\n // Velocity.\n v10 = versor.cartesian(projection.invert(inertia.position.map((d, i) => d - inertia.velocity[i] / 1_000)));\n q10 = versor(projection.rotate());\n v11 = versor.cartesian(projection.invert(inertia.position));\n opt.end && opt.end();\n },\n\n stop: opt.stop,\n\n finish: opt.finish,\n\n render: (t) => {\n const r1 = versor.rotation(versor.multiply(q10, versor.delta(v10, v11, t * 1_000)));\n const r2 = opt.axis(r0, r1);\n opt.render && opt.render(r2);\n },\n\n time: opt.time,\n });\n\n return inertia;\n};\n\nfunction inertiaHelper(opt) {\n const A = opt.time || 5_000; // Reference time in ms.\n const limit = 1.0001;\n const B = -Math.log(1 - 1 / limit);\n const inertia = {\n position: [0, 0],\n velocity: [0, 0], // Velocity in pixels/s.\n timer: d3.timer(() => {}),\n time: 0,\n t: 0,\n\n start: function (ev) {\n const position = [ev.x, ev.y];\n inertia.position = position;\n inertia.velocity = [0, 0];\n inertia.timer.stop();\n this.classList.remove('inertia');\n this.classList.add('dragging');\n opt.start && opt.start.call(this, position);\n },\n\n move: function (ev) {\n const position = [ev.x, ev.y];\n\n const time = performance.now();\n const deltaTime = time - inertia.time;\n const decay = 1 - Math.exp(-deltaTime / 1_000);\n inertia.velocity = inertia.velocity.map((d, i) => {\n const deltaPos = position[i] - inertia.position[i];\n const deltaTime = time - inertia.time;\n return (1_000 * (1 - decay) * deltaPos) / deltaTime + d * decay;\n });\n\n // Clamp velocity axis.\n inertia.velocity = opt.axis([0, 0], inertia.velocity);\n\n inertia.time = time;\n inertia.position = position;\n opt.move && opt.move.call(this, position);\n },\n\n end: function (ev) {\n this.classList.remove('dragging', 'inertia');\n\n const v = inertia.velocity;\n if (v[0] * v[0] + v[1] * v[1] < 100) {\n inertia.timer.stop();\n return opt.stop && opt.stop();\n }\n\n const time = performance.now();\n const deltaTime = time - inertia.time;\n\n if (opt.hold === undefined) {\n opt.hold = 100;\n } // Default flick->drag threshold time (0 disables inertia).\n\n if (deltaTime >= opt.hold) {\n inertia.timer.stop();\n return opt.stop && opt.stop();\n }\n\n this.classList.add('inertia');\n opt.end && opt.end();\n\n const self = this;\n inertia.timer.restart((e) => {\n inertia.t = limit * (1 - Math.exp((-B * e) / A));\n opt.render && opt.render(inertia.t);\n if (inertia.t > 1) {\n inertia.timer.stop();\n self.classList.remove('inertia');\n inertia.velocity = [0, 0];\n inertia.t = 1;\n opt.finish && opt.finish();\n }\n });\n },\n };\n\n inertia.timer.stop();\n return inertia;\n}\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport * as d3 from 'd3';\nimport { type GeoGeometryObjects } from 'd3';\nimport { type Point, type Polygon, type Position } from 'geojson';\n\nimport type { Vector } from '../hooks';\n\nexport type LatLng = { lat: number; lng: number };\n\n// TODO(burdon): Clean-up.\n\nexport const positionToRotation = ([lng, lat]: [number, number], tilt = 0): Vector => [-lng, tilt - lat, 0];\n\nexport const geoToPosition = ({ lat, lng }: LatLng): [number, number] => [lng, lat];\n\nexport const geoPoint = (point: LatLng): Point => ({ type: 'Point', coordinates: geoToPosition(point) });\n\n// https://github.com/d3/d3-geo#geoCircle\nexport const geoCircle = ({ lat, lng }: LatLng, radius: number): Polygon =>\n d3.geoCircle().radius(radius).center([lng, lat])();\n\nexport const geoLine = (p1: LatLng, p2: LatLng): GeoGeometryObjects => ({\n type: 'LineString',\n coordinates: [\n [p1.lng, p1.lat],\n [p2.lng, p2.lat],\n ],\n});\n\nexport const closestPoint = (points: Position[], target: Position): Position | null => {\n if (points.length === 0) {\n return target;\n }\n\n let closestPoint = points[0];\n let minDistance = getDistance(points[0], target);\n\n for (const point of points) {\n const distance = getDistance(point, target);\n if (distance < minDistance) {\n minDistance = distance;\n closestPoint = point;\n }\n }\n\n return closestPoint;\n};\n\nexport const getDistance = (point1: Position, point2: Position): number => {\n const dx = point1[0] - point2[0];\n const dy = point1[1] - point2[1];\n return Math.sqrt(dx * dx + dy * dy);\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport * as d3 from 'd3';\nimport { type GeoPath, type GeoPermissibleObjects } from 'd3';\nimport * as topojson from 'topojson-client';\nimport { type Topology } from 'topojson-specification';\n\nimport { type LatLng, geoLine, geoPoint } from './path';\n\nexport type Styles = Record<string, any>;\n\nexport type Style = 'water' | 'graticule' | 'land' | 'border' | 'dots' | 'point' | 'line' | 'cursor' | 'arc';\n\nexport type StyleSet = Partial<Record<Style, Styles>>;\n\nexport type Features = {\n points?: LatLng[];\n lines?: { source: LatLng; target: LatLng }[];\n};\n\nexport type Layer = {\n styles: Styles;\n path: GeoPermissibleObjects;\n};\n\n/**\n * Create rendering layers.\n */\nexport const createLayers = (topology: Topology, features: Features, styles: StyleSet): Layer[] => {\n const layers: Layer[] = [];\n\n if (styles.water) {\n layers.push({\n styles: styles.water,\n path: {\n type: 'Sphere',\n },\n });\n }\n\n if (styles.graticule) {\n layers.push({\n styles: styles.graticule,\n path: d3.geoGraticule().step([6, 6])(),\n });\n }\n\n //\n // Topology.\n //\n\n if (topology) {\n if (topology.objects.land && styles.land) {\n layers.push({\n styles: styles.land,\n path: topojson.feature(topology, topology.objects.land),\n });\n }\n\n if (topology.objects.countries && styles.border) {\n layers.push({\n styles: styles.border,\n path: topojson.mesh(topology, topology.objects.countries, (a: any, b: any) => a !== b),\n });\n }\n\n if (topology.objects.dots && styles.dots) {\n layers.push({\n styles: styles.dots,\n path: topology.objects.dots as any, // TODO(burdon): Type.\n });\n }\n }\n\n //\n // Features.\n //\n\n if (features) {\n const { points, lines } = features;\n\n if (points && styles.point) {\n layers.push({\n styles: styles.point,\n path: {\n type: 'GeometryCollection',\n geometries: points.map((point) => geoPoint(point)),\n },\n });\n }\n\n if (lines && styles.line) {\n layers.push({\n styles: styles.line,\n path: {\n type: 'GeometryCollection',\n geometries: lines.map(({ source, target }) => geoLine(source, target)),\n },\n });\n }\n }\n\n return layers;\n};\n\n/**\n * Render layers created above.\n */\nexport const renderLayers = (generator: GeoPath, layers: Layer[] = [], scale: number) => {\n const context: CanvasRenderingContext2D = generator.context();\n const {\n canvas: { width, height },\n } = context;\n context.reset();\n\n // TODO(burdon): Option.\n // Clear background.\n context.clearRect(0, 0, width, height);\n\n // Render features.\n // https://github.com/d3/d3-geo#_path\n layers.forEach(({ path, styles }) => {\n context.save();\n let fill = false;\n let stroke = false;\n if (styles) {\n Object.entries(styles).forEach(([key, value]) => {\n if (key === 'pointRadius') {\n generator.pointRadius(value * scale);\n } else {\n context[key] = value;\n fill ||= key === 'fillStyle';\n stroke ||= key === 'strokeStyle';\n }\n });\n }\n\n context.beginPath();\n\n generator(path);\n fill && context.fill();\n stroke && context.stroke();\n context.restore();\n });\n\n return context;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useCallback } from 'react';\n\nimport { type GlobeController, type ControlProps } from '../components';\n\nexport const useGlobeZoomHandler = (controller: GlobeController | null | undefined): ControlProps['onAction'] => {\n return useCallback<ControlProps['onAction']>(\n (event) => {\n if (!controller) {\n return;\n }\n\n switch (event) {\n case 'zoom-in': {\n controller.setScale((scale) => scale * 1.1);\n break;\n }\n case 'zoom-out': {\n controller.setScale((scale) => scale * 0.9);\n break;\n }\n }\n },\n [controller],\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useCallback } from 'react';\n\nimport { type MapController, type ControlProps } from '../components';\n\nexport const useMapZoomHandler = (controller: MapController | null | undefined): ControlProps['onAction'] => {\n return useCallback<ControlProps['onAction']>(\n (event) => {\n if (!controller) {\n return;\n }\n\n switch (event) {\n case 'zoom-in': {\n controller.setZoom((scale) => scale + 1);\n break;\n }\n case 'zoom-out': {\n controller.setZoom((scale) => scale - 1);\n break;\n }\n }\n },\n [controller],\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as d3 from 'd3';\nimport { type Timer } from 'd3';\nimport { useEffect, useState } from 'react';\n\nimport { type Vector } from './context';\nimport { type GlobeController } from '../components';\n\nexport type SpinnerOptions = {\n disabled?: boolean;\n delta?: Vector;\n};\n\n/**\n * Rotates globe.\n */\nexport const useSpinner = (controller?: GlobeController | null, options: SpinnerOptions = {}) => {\n const [running, setRunning] = useState(false);\n useEffect(() => {\n let timer: Timer | undefined;\n\n const start = () => {\n const delta: Vector = options.delta ?? [0.001, 0, 0];\n\n let t = 0;\n let lastRotation = controller.projection.rotate();\n timer = d3.timer((elapsed) => {\n const dt = elapsed - t;\n t = elapsed;\n\n const rotation: Vector = [\n lastRotation[0] + delta[0] * dt,\n lastRotation[1] + delta[1] * dt,\n lastRotation[2] + delta[2] * dt,\n ];\n\n lastRotation = rotation;\n controller.setRotation(rotation);\n });\n };\n\n const stop = () => {\n if (timer) {\n timer.stop();\n timer = undefined;\n }\n };\n\n if (controller && running) {\n start();\n } else {\n stop();\n }\n\n return () => stop();\n }, [controller, running]);\n\n return [\n () => {\n if (!options.disabled) {\n setRunning(true);\n }\n },\n () => setRunning(false),\n ];\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as d3 from 'd3';\nimport { useEffect, useState } from 'react';\nimport versor from 'versor';\n\nimport type { GlobeController } from '../components';\nimport { type Features, geoToPosition, type LatLng, positionToRotation, type StyleSet } from '../util';\n\nconst TRANSITION_NAME = 'globe-tour';\n\nconst defaultDuration = 1_500;\n\nexport type TourOptions = {\n disabled?: boolean;\n styles?: StyleSet;\n duration?: number;\n};\n\n/**\n * Iterates between points.\n * Inspired by: https://observablehq.com/@mbostock/top-100-cities\n */\nexport const useTour = (controller?: GlobeController | null, features?: Features, options: TourOptions = {}) => {\n const selection = d3.selection();\n const [running, setRunning] = useState(false);\n useEffect(() => {\n if (!running) {\n selection.interrupt(TRANSITION_NAME);\n return;\n }\n\n let t: ReturnType<typeof setTimeout>;\n if (controller && running) {\n t = setTimeout(async () => {\n const { canvas, projection, setRotation } = controller;\n const context = canvas.getContext('2d', { alpha: false });\n const path = d3.geoPath(projection, context).pointRadius(2);\n\n const tilt = 0;\n let last: LatLng;\n try {\n for (const next of features.points) {\n if (!running) {\n break;\n }\n\n // Points.\n const p1 = last ? geoToPosition(last) : undefined;\n const p2 = geoToPosition(next);\n const ip = d3.geoInterpolate(p1 || p2, p2);\n const distance = d3.geoDistance(p1 || p2, p2);\n\n // Rotation.\n const r1 = p1 ? positionToRotation(p1, tilt) : controller.projection.rotate();\n const r2 = positionToRotation(p2, tilt);\n const iv = versor.interpolate(r1, r2);\n\n const transition = selection\n .transition(TRANSITION_NAME)\n .duration(Math.max(options.duration ?? defaultDuration, distance * 2_000))\n .tween('render', () => (t) => {\n const t1 = Math.max(0, Math.min(1, t * 2 - 1));\n const t2 = Math.min(1, t * 2);\n\n context.save();\n {\n context.beginPath();\n context.strokeStyle = options?.styles?.arc?.strokeStyle ?? 'yellow';\n context.lineWidth = (options?.styles?.arc?.lineWidth ?? 1.5) * (controller?.scale ?? 1);\n context.setLineDash(options?.styles?.arc?.lineDash ?? []);\n path({ type: 'LineString', coordinates: [ip(t1), ip(t2)] });\n context.stroke();\n\n context.beginPath();\n context.fillStyle = options?.styles?.cursor?.fillStyle ?? 'orange';\n path.pointRadius((options?.styles?.cursor?.pointRadius ?? 2) * (controller?.scale ?? 1));\n path({ type: 'Point', coordinates: ip(t2) });\n context.fill();\n }\n context.restore();\n\n // TODO(burdon): This has to come after rendering above. Add to features to correct order?\n projection.rotate(iv(t));\n setRotation(projection.rotate());\n });\n\n // Throws if interrupted.\n await transition.end();\n last = next;\n }\n } catch (err) {\n setRunning(false);\n }\n });\n\n return () => {\n clearTimeout(t);\n selection.interrupt(TRANSITION_NAME);\n };\n }\n }, [controller, running]);\n\n return [\n () => {\n if (!options.disabled) {\n setRunning(true);\n }\n },\n () => setRunning(false),\n ];\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ControlPosition } from 'leaflet';\nimport React from 'react';\n\nimport { IconButton, type ThemedClassName, Toolbar } from '@dxos/react-ui';\n\nexport type ControlAction = 'toggle' | 'start' | 'zoom-in' | 'zoom-out';\n\nexport type ControlProps = ThemedClassName<{\n onAction?: (action: ControlAction) => void;\n}>;\n\nexport const controlPositions: Record<ControlPosition, string> = {\n topleft: 'top-2 left-2',\n topright: 'top-2 right-2',\n bottomleft: 'bottom-2 left-2',\n bottomright: 'bottom-2 right-2',\n};\n\nexport const ZoomControls = ({ classNames, onAction }: ControlProps) => {\n return (\n <Toolbar.Root classNames={['gap-1', classNames]}>\n <IconButton\n //\n icon='ph--plus--regular'\n label='zoom in'\n iconOnly\n size={5}\n classNames='px-0 aspect-square'\n onClick={() => onAction?.('zoom-in')}\n />\n <IconButton\n //\n icon='ph--minus--regular'\n label='zoom out'\n iconOnly\n size={5}\n classNames='px-0 aspect-square'\n onClick={() => onAction?.('zoom-out')}\n />\n </Toolbar.Root>\n );\n};\n\nexport const ActionControls = ({ classNames, onAction }: ControlProps) => {\n return (\n <Toolbar.Root classNames={['gap-1', classNames]}>\n <IconButton\n //\n icon='ph--play--regular'\n label='start'\n iconOnly\n size={5}\n classNames='px-0 aspect-square'\n onClick={() => onAction?.('start')}\n />\n <IconButton\n //\n icon='ph--globe-hemisphere-west--regular'\n label='toggle'\n iconOnly\n size={5}\n classNames='px-0 aspect-square'\n onClick={() => onAction?.('toggle')}\n />\n </Toolbar.Root>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// eslint-disable-next-line no-restricted-imports\nimport 'leaflet/dist/leaflet.css';\n\nimport type L from 'leaflet';\nimport { type ControlPosition, Control, DomEvent, DomUtil, type LatLngExpression, latLngBounds } from 'leaflet';\nimport React, { forwardRef, type PropsWithChildren, useEffect, useImperativeHandle } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { MapContainer, Marker, Popup, TileLayer, useMap } from 'react-leaflet';\nimport { type MapContainerProps } from 'react-leaflet/lib/MapContainer';\nimport { useResizeDetector } from 'react-resize-detector';\n\nimport { debounce } from '@dxos/async';\nimport { Tooltip, ThemeProvider, type ThemedClassName } from '@dxos/react-ui';\nimport { defaultTx, mx } from '@dxos/react-ui-theme';\n\nimport { ActionControls, controlPositions, ZoomControls, type ControlProps } from '../Toolbar';\nimport { type MapCanvasProps } from '../types';\n\n// TODO(burdon): Explore plugins: https://www.npmjs.com/search?q=keywords%3Areact-leaflet-v4\n// TODO(burdon): react-leaflet v5 is not compatible with react 18.\n\nconst defaults = {\n // TODO(burdon): Guess location.\n center: { lat: 51, lng: 0 } as L.LatLngExpression,\n zoom: 4,\n};\n\n//\n// Root\n//\n\ntype MapRootProps = ThemedClassName<MapContainerProps>;\n\n// https://react-leaflet.js.org/docs/api-map\nconst MapRoot = ({ classNames, center = defaults.center, zoom = defaults.zoom, ...props }: MapRootProps) => {\n return (\n <MapContainer\n className={mx('relative flex w-full h-full grow bg-baseSurface', classNames)}\n attributionControl={false}\n // TODO(burdon): Only if attention.\n scrollWheelZoom={true}\n zoomControl={false}\n center={center}\n zoom={zoom}\n {...props}\n />\n );\n};\n\n//\n// Control\n//\n\n// TODO(burdon): Normalize with Globe.\ntype MapController = {\n setCenter: (center: LatLngExpression, zoom?: number) => void;\n setZoom: (cb: (zoom: number) => number) => void;\n};\n\nconst MapCanvas = forwardRef<MapController, MapCanvasProps>(\n ({ markers = [], center, zoom, onChange }, forwardedRef) => {\n const { ref, width, height } = useResizeDetector({ refreshRate: 200 });\n const map = useMap();\n\n useImperativeHandle(\n forwardedRef,\n () => ({\n setCenter: (center: LatLngExpression, zoom?: number) => {\n map.setView(center, zoom);\n },\n setZoom: (cb) => {\n map.setZoom(cb(map.getZoom()));\n },\n }),\n [map],\n );\n\n // Resize.\n useEffect(() => {\n if (width && height) {\n map.invalidateSize();\n }\n }, [width, height]);\n\n // Position.\n useEffect(() => {\n if (center) {\n map.setView(center, zoom);\n } else if (zoom !== undefined) {\n map.setZoom(zoom);\n }\n }, [center, zoom]);\n\n // Events.\n useEffect(() => {\n const handler = debounce(() => {\n onChange?.({ center: map.getCenter(), zoom: map.getZoom() });\n }, 100);\n map.on('move', handler);\n map.on('zoom', handler);\n return () => {\n map.off('move', handler);\n map.off('zoom', handler);\n };\n }, [map, onChange]);\n\n // Set the viewport around the markers, or show the whole world map if `markers` is empty.\n useEffect(() => {\n if (markers.length > 0) {\n const bounds = latLngBounds(markers.map((marker) => marker.location));\n map.fitBounds(bounds);\n } else {\n map.setView(defaults.center, defaults.zoom);\n }\n }, [markers]);\n\n return (\n <div ref={ref} className='flex w-full h-full overflow-hidden bg-baseSurface'>\n {/* Map tiles. */}\n <TileLayer\n className='dark:filter dark:grayscale dark:invert'\n url='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'\n />\n\n {/* Markers. */}\n {/* TODO(burdon): Marker icon doesn't load on mobile? */}\n {markers.map(({ id, title, location: { lat, lng } }) => {\n return (\n <Marker key={id} position={{ lat, lng }}>\n {title && <Popup>{title}</Popup>}\n </Marker>\n );\n })}\n </div>\n );\n },\n);\n\n//\n// Controls\n// Integrates with Leaflet custom controls.\n//\n\nconst CustomControl = ({\n position,\n children,\n}: PropsWithChildren<{\n position: ControlPosition;\n}>) => {\n const map = useMap();\n\n useEffect(() => {\n const control = new Control({ position });\n control.onAdd = () => {\n const container = DomUtil.create('div', mx('!m-0', controlPositions[position]));\n DomEvent.disableClickPropagation(container);\n DomEvent.disableScrollPropagation(container);\n\n const root = createRoot(container);\n root.render(\n <ThemeProvider tx={defaultTx}>\n <Tooltip.Provider>{children}</Tooltip.Provider>\n </ThemeProvider>,\n );\n\n return container;\n };\n\n control.addTo(map);\n return () => {\n control.remove();\n };\n }, [map, position, children]);\n\n return null;\n};\n\ntype MapControlProps = { position?: ControlPosition } & Pick<ControlProps, 'onAction'>;\n\n//\n// Map\n//\n\nexport const Map = {\n Root: MapRoot,\n Canvas: MapCanvas,\n Zoom: ({ onAction, position = 'bottomleft', ...props }: MapControlProps) => (\n <CustomControl position={position} {...props}>\n <ZoomControls onAction={onAction} />\n </CustomControl>\n ),\n Action: ({ onAction, position = 'bottomright', ...props }: MapControlProps) => (\n <CustomControl position={position} {...props}>\n <ActionControls onAction={onAction} />\n </CustomControl>\n ),\n};\n\nexport { type MapCanvasProps, type MapController };\n"],
|
|
5
|
-
"mappings": ";;;;;AAIA,YAAYA,SAAQ;AAGpB,OAAOC,UAELC,YACAC,aAAAA,YACAC,qBACAC,SACAC,QACAC,YAAAA,iBACK;AACP,SAASC,yB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D,gBAAAA;IAAcF;IAAqB,GAAG/C;KACrC,gBAAAC,OAAA,cAAC6E,gBAAAA;IAAeH;;AAGtB;",
|
|
6
|
-
"names": ["d3", "React", "forwardRef", "useEffect", "useImperativeHandle", "useMemo", "useRef", "useState", "useResizeDetector", "useDynamicRef", "mx", "React", "createContext", "useContext", "raise", "useControlledState", "GlobeContext", "createContext", "undefined", "GlobeContextProvider", "children", "size", "center", "_center", "scale", "_scale", "translation", "_translation", "rotation", "_rotation", "setCenter", "useControlledState", "setScale", "setTranslation", "setRotation", "Provider", "value", "useGlobeContext", "useContext", "raise", "Error", "d3", "useEffect", "debug", "timer", "cb", "start", "Date", "now", "data", "t", "console", "log", "d3", "versor", "restrictAxis", "axis", "original", "current", "map", "d", "i", "geoInertiaDrag", "target", "render", "projection", "options", "node", "select", "inertia", "geoInertiaDragHelper", "rotation", "rotate", "xAxis", "start", "move", "end", "stop", "finish", "time", "hold", "call", "drag", "on", "opt", "v0", "r0", "q0", "v10", "v11", "q10", "inertiaHelper", "versor", "cartesian", "invert", "position", "inv", "isNaN", "v1", "q1", "multiply", "delta", "r1", "r2", "velocity", "t", "A", "limit", "B", "Math", "log", "timer", "ev", "x", "y", "classList", "remove", "add", "performance", "now", "deltaTime", "decay", "exp", "deltaPos", "v", "undefined", "self", "restart", "e", "d3", "positionToRotation", "lng", "lat", "tilt", "geoToPosition", "geoPoint", "point", "type", "coordinates", "geoCircle", "radius", "center", "geoLine", "p1", "p2", "closestPoint", "points", "target", "length", "minDistance", "getDistance", "distance", "point1", "point2", "dx", "dy", "Math", "sqrt", "d3", "topojson", "createLayers", "topology", "features", "styles", "layers", "water", "push", "path", "type", "graticule", "geoGraticule", "step", "objects", "land", "feature", "countries", "border", "mesh", "a", "b", "dots", "points", "lines", "point", "geometries", "map", "geoPoint", "line", "source", "target", "geoLine", "renderLayers", "generator", "scale", "context", "canvas", "width", "height", "reset", "clearRect", "forEach", "save", "fill", "stroke", "Object", "entries", "key", "value", "pointRadius", "beginPath", "restore", "useDrag", "controller", "options", "useEffect", "canvas", "disabled", "geoInertiaDrag", "select", "setRotation", "projection", "rotate", "onUpdate", "type", "xAxis", "time", "start", "finish", "cancelDrag", "node", "on", "useCallback", "useGlobeZoomHandler", "controller", "useCallback", "event", "setScale", "scale", "useCallback", "useMapZoomHandler", "controller", "useCallback", "event", "setZoom", "scale", "d3", "useEffect", "useState", "useSpinner", "controller", "options", "running", "setRunning", "useState", "useEffect", "timer", "start", "delta", "t", "lastRotation", "projection", "rotate", "elapsed", "dt", "rotation", "setRotation", "stop", "undefined", "disabled", "d3", "useEffect", "useState", "versor", "TRANSITION_NAME", "defaultDuration", "useTour", "controller", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2018 DXOS.org\n//\n\nimport * as d3 from 'd3';\nimport { type GeoProjection } from 'd3';\nimport { type ControlPosition } from 'leaflet';\nimport React, {\n type PropsWithChildren,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useResizeDetector } from 'react-resize-detector';\nimport { type Topology } from 'topojson-specification';\n\nimport { type ThemedClassName, type ThemeMode, useDynamicRef, useThemeContext } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport {\n GlobeContextProvider,\n type GlobeContextProviderProps,\n type GlobeContextType,\n useGlobeContext,\n} from '../../hooks';\nimport {\n type Features,\n type StyleSet,\n createLayers,\n geoToPosition,\n positionToRotation,\n renderLayers,\n timer,\n} from '../../util';\nimport { ZoomControls, ActionControls, type ControlProps, controlPositions } from '../Toolbar';\n\n/**\n * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute\n */\nconst defaultStyles: Record<ThemeMode, StyleSet> = {\n light: {\n background: {\n fillStyle: '#EEE',\n },\n\n water: {\n fillStyle: '#555',\n },\n\n land: {\n fillStyle: '#999',\n },\n\n line: {\n strokeStyle: 'darkred',\n },\n\n point: {\n fillStyle: '#111111',\n strokeStyle: '#111111',\n strokeWidth: 1,\n pointRadius: 0.5,\n },\n },\n dark: {\n background: {\n fillStyle: '#111111',\n },\n\n water: {\n fillStyle: '#123E6A',\n },\n\n land: {\n fillStyle: '#032153',\n },\n\n line: {\n strokeStyle: '#111111',\n },\n\n point: {\n fillStyle: '#111111',\n strokeStyle: '#111111',\n strokeWidth: 1,\n pointRadius: 0.5,\n },\n },\n};\n\nexport type GlobeController = {\n canvas: HTMLCanvasElement;\n projection: GeoProjection;\n} & Pick<GlobeContextType, 'scale' | 'translation' | 'rotation' | 'setScale' | 'setTranslation' | 'setRotation'>;\n\nexport type ProjectionType = 'orthographic' | 'mercator' | 'transverse-mercator';\n\nconst projectionMap: Record<ProjectionType, () => GeoProjection> = {\n orthographic: d3.geoOrthographic,\n mercator: d3.geoMercator,\n 'transverse-mercator': d3.geoTransverseMercator,\n};\n\nconst getProjection = (type: GlobeCanvasProps['projection'] = 'orthographic'): GeoProjection => {\n if (typeof type === 'string') {\n const constructor = projectionMap[type] ?? d3.geoOrthographic;\n return constructor();\n }\n\n return type ?? d3.geoOrthographic();\n};\n\n//\n// Root\n//\n\ntype GlobeRootProps = PropsWithChildren<ThemedClassName<GlobeContextProviderProps>>;\n\nconst GlobeRoot = ({ classNames, children, ...props }: GlobeRootProps) => {\n const { ref, width, height } = useResizeDetector<HTMLDivElement>();\n return (\n <div ref={ref} className={mx('relative flex grow overflow-hidden', classNames)}>\n <GlobeContextProvider size={{ width, height }} {...props}>\n {children}\n </GlobeContextProvider>\n </div>\n );\n};\n\n//\n// Canvas\n//\n\ntype GlobeCanvasProps = {\n projection?: ProjectionType | GeoProjection;\n topology?: Topology;\n features?: Features;\n styles?: StyleSet;\n};\n\n/**\n * Basic globe renderer.\n * https://github.com/topojson/world-atlas\n */\nconst GlobeCanvas = forwardRef<GlobeController, GlobeCanvasProps>(\n ({ projection: _projection, topology, features, styles: _styles }, forwardRef) => {\n const { themeMode } = useThemeContext();\n const styles = useMemo(() => _styles ?? defaultStyles[themeMode], [_styles, themeMode]);\n\n // Canvas.\n const [canvas, setCanvas] = useState<HTMLCanvasElement>(null);\n const canvasRef = (canvas: HTMLCanvasElement) => setCanvas(canvas);\n\n // Projection.\n const projection = useMemo(() => getProjection(_projection), [_projection]);\n\n // Layers.\n // TODO(burdon): Generate on the fly based on what is visible.\n const layers = useMemo(() => {\n return timer(() => createLayers(topology as Topology, features, styles));\n }, [topology, features, styles]);\n\n // State.\n const { size, center, scale, translation, rotation, setCenter, setScale, setTranslation, setRotation } =\n useGlobeContext();\n\n const scaleRef = useDynamicRef(scale);\n\n // Update rotation.\n useEffect(() => {\n if (center) {\n setScale(1);\n setRotation(positionToRotation(geoToPosition(center)));\n }\n }, [center]);\n\n // External controller.\n const zooming = useRef(false);\n useImperativeHandle<GlobeController, GlobeController>(\n forwardRef,\n () => {\n return {\n canvas,\n projection,\n center,\n get scale() {\n return scaleRef.current;\n },\n translation,\n rotation,\n setCenter,\n setScale: (s) => {\n if (typeof s === 'function') {\n const is = d3.interpolateNumber(scaleRef.current, s(scaleRef.current));\n // Stop easing if already zooming.\n d3.transition()\n .ease(zooming.current ? d3.easeLinear : d3.easeSinOut)\n .duration(200)\n .tween('scale', () => (t) => setScale(is(t)))\n .on('end', () => {\n zooming.current = false;\n });\n } else {\n setScale(s);\n }\n },\n setTranslation,\n setRotation,\n };\n },\n [canvas],\n );\n\n // https://d3js.org/d3-geo/path#geoPath\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext\n const generator = useMemo(\n () => canvas && projection && d3.geoPath(projection, canvas.getContext('2d', { alpha: false })),\n [canvas, projection],\n );\n\n // Render on change.\n useEffect(() => {\n if (canvas && projection) {\n timer(() => {\n // https://d3js.org/d3-geo/projection\n projection\n .scale((Math.min(size.width, size.height) / 2) * scale)\n .translate([size.width / 2 + (translation?.x ?? 0), size.height / 2 + (translation?.y ?? 0)])\n .rotate(rotation ?? [0, 0, 0]);\n\n renderLayers(generator, layers, scale, styles);\n });\n }\n }, [generator, size, scale, translation, rotation, layers]);\n\n if (!size.width || !size.height) {\n return null;\n }\n\n return <canvas ref={canvasRef} width={size.width} height={size.height} />;\n },\n);\n\nconst GlobeDebug = ({ position = 'topleft' }: { position?: ControlPosition }) => {\n const { size, scale, translation, rotation } = useGlobeContext();\n return (\n <div\n className={mx(\n 'z-10 absolute w-96 p-2 overflow-hidden border border-green-700 rounded',\n controlPositions[position],\n )}\n >\n <pre className='font-mono text-xs text-green-700'>\n {JSON.stringify({ size, scale, translation, rotation }, null, 2)}\n </pre>\n </div>\n );\n};\n\nconst GlobePanel = ({\n position,\n classNames,\n children,\n}: ThemedClassName<PropsWithChildren & { position?: ControlPosition }>) => {\n return <div className={mx('z-10 absolute overflow-hidden', controlPositions[position], classNames)}>{children}</div>;\n};\n\nconst CustomControl = ({ position, children }: PropsWithChildren<{ position: ControlPosition }>) => {\n return <div className={mx('z-10 absolute overflow-hidden', controlPositions[position])}>{children}</div>;\n};\n\ntype GlobeControlProps = { position?: ControlPosition } & Pick<ControlProps, 'onAction'>;\n\nexport const Globe = {\n Root: GlobeRoot,\n Canvas: GlobeCanvas,\n Zoom: ({ onAction, position = 'bottomleft', ...props }: GlobeControlProps) => (\n <CustomControl position={position} {...props}>\n <ZoomControls onAction={onAction} />\n </CustomControl>\n ),\n Action: ({ onAction, position = 'bottomright', ...props }: GlobeControlProps) => (\n <CustomControl position={position} {...props}>\n <ActionControls onAction={onAction} />\n </CustomControl>\n ),\n Debug: GlobeDebug,\n Panel: GlobePanel,\n};\n\nexport type { GlobeRootProps, GlobeCanvasProps };\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { createContext, type Dispatch, type PropsWithChildren, type SetStateAction, useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\nimport { useControlledState } from '@dxos/react-ui';\n\nimport { type LatLng } from '../util';\n\n// TODO(burdon): Factor out common geometry types.\nexport type Size = { width: number; height: number };\nexport type Point = { x: number; y: number };\nexport type Vector = [number, number, number];\n\nexport type GlobeContextType = {\n size: Size;\n center: LatLng;\n scale: number;\n translation: Point;\n rotation: Vector;\n setCenter: Dispatch<SetStateAction<LatLng>>;\n setScale: Dispatch<SetStateAction<number>>;\n setTranslation: Dispatch<SetStateAction<Point>>;\n setRotation: Dispatch<SetStateAction<Vector>>;\n};\n\nconst GlobeContext = createContext<GlobeContextType>(undefined);\n\nexport type GlobeContextProviderProps = PropsWithChildren<\n Partial<Pick<GlobeContextType, 'size' | 'center' | 'scale' | 'translation' | 'rotation'>>\n>;\n\nexport const GlobeContextProvider = ({\n children,\n size,\n center: _center,\n scale: _scale,\n translation: _translation,\n rotation: _rotation,\n}: GlobeContextProviderProps) => {\n const [center, setCenter] = useControlledState(_center);\n const [scale, setScale] = useControlledState(_scale);\n const [translation, setTranslation] = useControlledState<Point>(_translation);\n const [rotation, setRotation] = useControlledState<Vector>(_rotation);\n\n return (\n <GlobeContext.Provider\n value={{ size, center, scale, translation, rotation, setCenter, setScale, setTranslation, setRotation }}\n >\n {children}\n </GlobeContext.Provider>\n );\n};\n\nexport const useGlobeContext = () => {\n return useContext(GlobeContext) ?? raise(new Error('Missing GlobeContext'));\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as d3 from 'd3';\nimport { useEffect } from 'react';\n\nimport { type GlobeController } from '../components';\nimport { geoInertiaDrag } from '../util';\n\nexport type GlobeDragEvent = {\n type: 'start' | 'move' | 'end';\n controller: GlobeController;\n};\n\nexport type DragOptions = {\n disabled?: boolean;\n duration?: number;\n xAxis?: boolean; // TODO(burdon): Generalize.\n onUpdate?: (event: GlobeDragEvent) => void;\n};\n\n/**\n * Allows user to drag globe.\n */\nexport const useDrag = (controller?: GlobeController | null, options: DragOptions = {}) => {\n useEffect(() => {\n const canvas = controller?.canvas;\n if (!canvas || options.disabled) {\n return;\n }\n\n geoInertiaDrag(\n d3.select(canvas),\n () => {\n controller.setRotation(controller.projection.rotate());\n options.onUpdate?.({ type: 'move', controller });\n },\n controller.projection,\n {\n xAxis: options.xAxis,\n time: 3_000,\n start: () => options.onUpdate?.({ type: 'start', controller }),\n finish: () => options.onUpdate?.({ type: 'end', controller }),\n },\n );\n\n // TODO(burdon): Cancel drag timer.\n return () => {\n cancelDrag(d3.select(canvas));\n };\n }, [controller, JSON.stringify(options)]);\n};\n\nconst cancelDrag = (node) => node.on('.drag', null);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nconst debug = false;\n\nexport const timer = <T = void>(cb: () => T): T => {\n const start = Date.now();\n const data = cb();\n const t = Date.now() - start / 1_000;\n if (debug) {\n // eslint-disable-next-line no-console\n console.log({ t, data });\n }\n\n return data;\n};\n", "//\n// Copyright 2017 Philippe Rivière\n// Copyright 2024 DXOS.org\n// https://github.com/Fil/d3-inertia\n//\n\nimport * as d3 from 'd3';\nimport versor from 'versor';\n\nexport const restrictAxis =\n (axis: boolean[]) =>\n (original: number[], current: number[]): number[] =>\n current.map((d, i) => (axis[i] ? d : original[i]));\n\n/**\n * Applies a drag handler to the specified target element.\n */\n// TODO(burdon): Define type.\nexport const geoInertiaDrag = (target, render, projection, options) => {\n if (!options) {\n options = {};\n }\n\n // Target can be an element, a selector, a function, or a selection\n // but in case of a selection we make sure to reselect it with d3-selection.\n if (target.node) {\n target = target.node();\n }\n target = d3.select(target);\n\n // Complete params: (projection, render, startDrag, dragging, endDrag).\n const inertia = geoInertiaDragHelper({\n projection,\n render: (rotation) => {\n projection.rotate(rotation);\n render && render();\n },\n axis: restrictAxis(options.xAxis ? [true, false, false] : [true, true, true]),\n start: options.start,\n move: options.move,\n end: options.end,\n stop: options.stop,\n finish: options.finish,\n time: options.time,\n hold: options.hold,\n });\n\n target.call(d3.drag().on('start', inertia.start).on('drag', inertia.move).on('end', inertia.end));\n return inertia;\n};\n\n/**\n * A versor is a compact way to describe a rotation in 3D space.\n * It consists of four components [𝑤,x,y,z], where:\n * 𝑤 is a scalar representing the angle of rotation.\n * x, y, z are the vector components, representing the axis of rotation.\n */\nconst geoInertiaDragHelper = (opt) => {\n const projection = opt.projection;\n\n let v0; // Mouse position in Cartesian coordinates at start of drag gesture.\n let r0; // Projection rotation as Euler angles at start.\n let q0; // Projection rotation as versor at start.\n let v10; // Mouse position in Cartesian coordinates just before end of drag gesture.\n let v11; // Mouse position in Cartesian coordinates at end.\n let q10; // Projection rotation as versor at end.\n\n const inertia = inertiaHelper({\n axis: opt.axis,\n\n start: () => {\n v0 = versor.cartesian(projection.invert(inertia.position));\n r0 = projection.rotate();\n q0 = versor(r0);\n opt.start && opt.start();\n },\n\n move: () => {\n const inv = projection.rotate(r0).invert(inertia.position);\n if (isNaN(inv[0])) {\n return;\n }\n const v1 = versor.cartesian(inv);\n const q1 = versor.multiply(q0, versor.delta(v0, v1));\n const r1 = versor.rotation(q1);\n const r2 = opt.axis(r0, r1);\n opt.render(r2);\n opt.move && opt.move();\n },\n\n end: () => {\n // Velocity.\n v10 = versor.cartesian(projection.invert(inertia.position.map((d, i) => d - inertia.velocity[i] / 1_000)));\n q10 = versor(projection.rotate());\n v11 = versor.cartesian(projection.invert(inertia.position));\n opt.end && opt.end();\n },\n\n stop: opt.stop,\n\n finish: opt.finish,\n\n render: (t) => {\n const r1 = versor.rotation(versor.multiply(q10, versor.delta(v10, v11, t * 1_000)));\n const r2 = opt.axis(r0, r1);\n opt.render && opt.render(r2);\n },\n\n time: opt.time,\n });\n\n return inertia;\n};\n\nfunction inertiaHelper(opt) {\n const A = opt.time || 5_000; // Reference time in ms.\n const limit = 1.0001;\n const B = -Math.log(1 - 1 / limit);\n const inertia = {\n position: [0, 0],\n velocity: [0, 0], // Velocity in pixels/s.\n timer: d3.timer(() => {}),\n time: 0,\n t: 0,\n\n start: function (ev) {\n const position = [ev.x, ev.y];\n inertia.position = position;\n inertia.velocity = [0, 0];\n inertia.timer.stop();\n this.classList.remove('inertia');\n this.classList.add('dragging');\n opt.start && opt.start.call(this, position);\n },\n\n move: function (ev) {\n const position = [ev.x, ev.y];\n\n const time = performance.now();\n const deltaTime = time - inertia.time;\n const decay = 1 - Math.exp(-deltaTime / 1_000);\n inertia.velocity = inertia.velocity.map((d, i) => {\n const deltaPos = position[i] - inertia.position[i];\n const deltaTime = time - inertia.time;\n return (1_000 * (1 - decay) * deltaPos) / deltaTime + d * decay;\n });\n\n // Clamp velocity axis.\n inertia.velocity = opt.axis([0, 0], inertia.velocity);\n\n inertia.time = time;\n inertia.position = position;\n opt.move && opt.move.call(this, position);\n },\n\n end: function (ev) {\n this.classList.remove('dragging', 'inertia');\n\n const v = inertia.velocity;\n if (v[0] * v[0] + v[1] * v[1] < 100) {\n inertia.timer.stop();\n return opt.stop && opt.stop();\n }\n\n const time = performance.now();\n const deltaTime = time - inertia.time;\n\n if (opt.hold === undefined) {\n opt.hold = 100;\n } // Default flick->drag threshold time (0 disables inertia).\n\n if (deltaTime >= opt.hold) {\n inertia.timer.stop();\n return opt.stop && opt.stop();\n }\n\n this.classList.add('inertia');\n opt.end && opt.end();\n\n const self = this;\n inertia.timer.restart((e) => {\n inertia.t = limit * (1 - Math.exp((-B * e) / A));\n opt.render && opt.render(inertia.t);\n if (inertia.t > 1) {\n inertia.timer.stop();\n self.classList.remove('inertia');\n inertia.velocity = [0, 0];\n inertia.t = 1;\n opt.finish && opt.finish();\n }\n });\n },\n };\n\n inertia.timer.stop();\n return inertia;\n}\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport * as d3 from 'd3';\nimport { type GeoGeometryObjects } from 'd3';\nimport { type Point, type Polygon, type Position } from 'geojson';\n\nimport type { Vector } from '../hooks';\n\nexport type LatLng = { lat: number; lng: number };\n\n// TODO(burdon): Clean-up.\n\nexport const positionToRotation = ([lng, lat]: [number, number], tilt = 0): Vector => [-lng, tilt - lat, 0];\n\nexport const geoToPosition = ({ lat, lng }: LatLng): [number, number] => [lng, lat];\n\nexport const geoPoint = (point: LatLng): Point => ({ type: 'Point', coordinates: geoToPosition(point) });\n\n// https://github.com/d3/d3-geo#geoCircle\nexport const geoCircle = ({ lat, lng }: LatLng, radius: number): Polygon =>\n d3.geoCircle().radius(radius).center([lng, lat])();\n\nexport const geoLine = (p1: LatLng, p2: LatLng): GeoGeometryObjects => ({\n type: 'LineString',\n coordinates: [\n [p1.lng, p1.lat],\n [p2.lng, p2.lat],\n ],\n});\n\nexport const closestPoint = (points: Position[], target: Position): Position | null => {\n if (points.length === 0) {\n return target;\n }\n\n let closestPoint = points[0];\n let minDistance = getDistance(points[0], target);\n\n for (const point of points) {\n const distance = getDistance(point, target);\n if (distance < minDistance) {\n minDistance = distance;\n closestPoint = point;\n }\n }\n\n return closestPoint;\n};\n\nexport const getDistance = (point1: Position, point2: Position): number => {\n const dx = point1[0] - point2[0];\n const dy = point1[1] - point2[1];\n return Math.sqrt(dx * dx + dy * dy);\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport * as d3 from 'd3';\nimport { type GeoPath, type GeoPermissibleObjects } from 'd3';\nimport * as topojson from 'topojson-client';\nimport { type Topology } from 'topojson-specification';\n\nimport { type LatLng, geoLine, geoPoint } from './path';\n\nexport type Styles = Record<string, any>;\n\nexport type Style =\n | 'background'\n | 'water'\n | 'graticule'\n | 'land'\n | 'border'\n | 'dots'\n | 'point'\n | 'line'\n | 'cursor'\n | 'arc';\n\nexport type StyleSet = Partial<Record<Style, Styles>>;\n\nexport type Features = {\n points?: LatLng[];\n lines?: { source: LatLng; target: LatLng }[];\n};\n\nexport type Layer = {\n styles: Styles;\n path: GeoPermissibleObjects;\n};\n\n/**\n * Create rendering layers.\n */\nexport const createLayers = (topology: Topology, features: Features, styles: StyleSet): Layer[] => {\n const layers: Layer[] = [];\n\n if (styles.water) {\n layers.push({\n styles: styles.water,\n path: {\n type: 'Sphere',\n },\n });\n }\n\n if (styles.graticule) {\n layers.push({\n styles: styles.graticule,\n path: d3.geoGraticule().step([6, 6])(),\n });\n }\n\n //\n // Topology.\n //\n\n if (topology) {\n if (topology.objects.land && styles.land) {\n layers.push({\n styles: styles.land,\n path: topojson.feature(topology, topology.objects.land),\n });\n }\n\n if (topology.objects.countries && styles.border) {\n layers.push({\n styles: styles.border,\n path: topojson.mesh(topology, topology.objects.countries, (a: any, b: any) => a !== b),\n });\n }\n\n if (topology.objects.dots && styles.dots) {\n layers.push({\n styles: styles.dots,\n path: topology.objects.dots as any, // TODO(burdon): Type.\n });\n }\n }\n\n //\n // Features.\n //\n\n if (features) {\n const { points, lines } = features;\n\n if (points && styles.point) {\n layers.push({\n styles: styles.point,\n path: {\n type: 'GeometryCollection',\n geometries: points.map((point) => geoPoint(point)),\n },\n });\n }\n\n if (lines && styles.line) {\n layers.push({\n styles: styles.line,\n path: {\n type: 'GeometryCollection',\n geometries: lines.map(({ source, target }) => geoLine(source, target)),\n },\n });\n }\n }\n\n return layers;\n};\n\n/**\n * Render layers created above.\n */\nexport const renderLayers = (generator: GeoPath, layers: Layer[] = [], scale: number, styles: StyleSet) => {\n const context: CanvasRenderingContext2D = generator.context();\n const {\n canvas: { width, height },\n } = context;\n context.reset();\n\n // Clear background.\n if (styles.background) {\n context.fillStyle = styles.background.fillStyle;\n context.fillRect(0, 0, width, height);\n } else {\n context.clearRect(0, 0, width, height);\n }\n\n // Render features.\n // https://github.com/d3/d3-geo#_path\n layers.forEach(({ path, styles }) => {\n context.save();\n let fill = false;\n let stroke = false;\n if (styles) {\n Object.entries(styles).forEach(([key, value]) => {\n if (key === 'pointRadius') {\n generator.pointRadius(value * scale);\n } else {\n context[key] = value;\n fill ||= key === 'fillStyle';\n stroke ||= key === 'strokeStyle';\n }\n });\n }\n\n context.beginPath();\n\n generator(path);\n fill && context.fill();\n stroke && context.stroke();\n context.restore();\n });\n\n return context;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useCallback } from 'react';\n\nimport { type GlobeController, type ControlProps } from '../components';\n\nexport const useGlobeZoomHandler = (controller: GlobeController | null | undefined): ControlProps['onAction'] => {\n return useCallback<ControlProps['onAction']>(\n (event) => {\n if (!controller) {\n return;\n }\n\n switch (event) {\n case 'zoom-in': {\n controller.setScale((scale) => scale * 1.1);\n break;\n }\n case 'zoom-out': {\n controller.setScale((scale) => scale * 0.9);\n break;\n }\n }\n },\n [controller],\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useCallback } from 'react';\n\nimport { type MapController, type ControlProps } from '../components';\n\nexport const useMapZoomHandler = (controller: MapController | null | undefined): ControlProps['onAction'] => {\n return useCallback<ControlProps['onAction']>(\n (event) => {\n if (!controller) {\n return;\n }\n\n switch (event) {\n case 'zoom-in': {\n controller.setZoom((scale) => scale + 1);\n break;\n }\n case 'zoom-out': {\n controller.setZoom((scale) => scale - 1);\n break;\n }\n }\n },\n [controller],\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as d3 from 'd3';\nimport { type Timer } from 'd3';\nimport { useEffect, useState } from 'react';\n\nimport { type Vector } from './context';\nimport { type GlobeController } from '../components';\n\nexport type SpinnerOptions = {\n disabled?: boolean;\n delta?: Vector;\n};\n\n/**\n * Rotates globe.\n */\nexport const useSpinner = (controller?: GlobeController | null, options: SpinnerOptions = {}) => {\n const [running, setRunning] = useState(false);\n useEffect(() => {\n let timer: Timer | undefined;\n\n const start = () => {\n const delta: Vector = options.delta ?? [0.001, 0, 0];\n\n let t = 0;\n let lastRotation = controller.projection.rotate();\n timer = d3.timer((elapsed) => {\n const dt = elapsed - t;\n t = elapsed;\n\n const rotation: Vector = [\n lastRotation[0] + delta[0] * dt,\n lastRotation[1] + delta[1] * dt,\n lastRotation[2] + delta[2] * dt,\n ];\n\n lastRotation = rotation;\n controller.setRotation(rotation);\n });\n };\n\n const stop = () => {\n if (timer) {\n timer.stop();\n timer = undefined;\n }\n };\n\n if (controller && running) {\n start();\n } else {\n stop();\n }\n\n return () => stop();\n }, [controller, running]);\n\n return [\n () => {\n if (!options.disabled) {\n setRunning(true);\n }\n },\n () => setRunning(false),\n ];\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as d3 from 'd3';\nimport { type Dispatch, type SetStateAction, useEffect, useState } from 'react';\nimport versor from 'versor';\n\nimport { log } from '@dxos/log';\n\nimport type { GlobeController } from '../components';\nimport { geoToPosition, type LatLng, positionToRotation, type StyleSet } from '../util';\n\nconst TRANSITION_NAME = 'globe-tour';\n\nconst defaultDuration = 1_500;\n\nexport type TourOptions = {\n running?: boolean;\n disabled?: boolean;\n duration?: number;\n loop?: boolean;\n tilt?: number;\n autoRotate?: boolean;\n styles?: StyleSet;\n};\n\n/**\n * Iterates between points.\n * Inspired by: https://observablehq.com/@mbostock/top-100-cities\n */\nexport const useTour = (\n controller?: GlobeController | null,\n points?: LatLng[],\n options: TourOptions = {},\n): [boolean, Dispatch<SetStateAction<boolean>>] => {\n const selection = d3.selection();\n const [running, setRunning] = useState(options.running ?? false);\n useEffect(() => {\n if (!running) {\n selection.interrupt(TRANSITION_NAME);\n return;\n }\n\n let t: ReturnType<typeof setTimeout>;\n if (controller && running) {\n t = setTimeout(async () => {\n const { canvas, projection, setRotation } = controller;\n const context = canvas.getContext('2d', { alpha: false });\n const path = d3.geoPath(projection, context).pointRadius(2);\n\n const tilt = options.tilt ?? 0;\n let last: LatLng;\n try {\n const p = [...points];\n if (options.loop) {\n p.push(p[0]);\n }\n\n for (const next of p) {\n if (!running) {\n break;\n }\n\n // Points.\n const p1 = last ? geoToPosition(last) : undefined;\n const p2 = geoToPosition(next);\n const ip = d3.geoInterpolate(p1 || p2, p2);\n const distance = d3.geoDistance(p1 || p2, p2);\n\n // Rotation.\n const r1 = p1 ? positionToRotation(p1, tilt) : controller.projection.rotate();\n const r2 = positionToRotation(p2, tilt);\n const iv = versor.interpolate(r1, r2);\n\n const transition = selection\n .transition(TRANSITION_NAME)\n .duration(Math.max(options.duration ?? defaultDuration, distance * 2_000))\n .tween('render', () => (t) => {\n const t1 = Math.max(0, Math.min(1, t * 2 - 1));\n const t2 = Math.min(1, t * 2);\n\n context.save();\n {\n context.beginPath();\n context.strokeStyle = options?.styles?.arc?.strokeStyle ?? 'yellow';\n context.lineWidth = (options?.styles?.arc?.lineWidth ?? 1.5) * (controller?.scale ?? 1);\n context.setLineDash(options?.styles?.arc?.lineDash ?? []);\n path({ type: 'LineString', coordinates: [ip(t1), ip(t2)] });\n context.stroke();\n\n context.beginPath();\n context.fillStyle = options?.styles?.cursor?.fillStyle ?? 'orange';\n path.pointRadius((options?.styles?.cursor?.pointRadius ?? 2) * (controller?.scale ?? 1));\n path({ type: 'Point', coordinates: ip(t2) });\n context.fill();\n }\n context.restore();\n\n // TODO(burdon): This has to come after rendering above. Add to features to correct order?\n if (options.autoRotate) {\n projection.rotate(iv(t));\n setRotation(projection.rotate());\n }\n });\n\n // Throws if interrupted.\n await transition.end();\n last = next;\n }\n } catch (err) {\n log.catch(err);\n } finally {\n setRunning(false);\n }\n });\n\n return () => {\n clearTimeout(t);\n selection.interrupt(TRANSITION_NAME);\n };\n }\n }, [controller, running, JSON.stringify(options)]);\n\n return [running, setRunning];\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ControlPosition } from 'leaflet';\nimport React from 'react';\n\nimport { IconButton, type ThemedClassName, Toolbar } from '@dxos/react-ui';\n\nexport type ControlAction = 'toggle' | 'start' | 'zoom-in' | 'zoom-out';\n\nexport type ControlProps = ThemedClassName<{\n onAction?: (action: ControlAction) => void;\n}>;\n\nexport const controlPositions: Record<ControlPosition, string> = {\n topleft: 'top-2 left-2',\n topright: 'top-2 right-2',\n bottomleft: 'bottom-2 left-2',\n bottomright: 'bottom-2 right-2',\n};\n\nexport const ZoomControls = ({ classNames, onAction }: ControlProps) => {\n return (\n <Toolbar.Root classNames={['gap-1', classNames]}>\n <IconButton\n //\n icon='ph--plus--regular'\n label='zoom in'\n iconOnly\n size={5}\n classNames='px-0 aspect-square'\n onClick={() => onAction?.('zoom-in')}\n />\n <IconButton\n //\n icon='ph--minus--regular'\n label='zoom out'\n iconOnly\n size={5}\n classNames='px-0 aspect-square'\n onClick={() => onAction?.('zoom-out')}\n />\n </Toolbar.Root>\n );\n};\n\nexport const ActionControls = ({ classNames, onAction }: ControlProps) => {\n return (\n <Toolbar.Root classNames={['gap-1', classNames]}>\n <IconButton\n //\n icon='ph--play--regular'\n label='start'\n iconOnly\n size={5}\n classNames='px-0 aspect-square'\n onClick={() => onAction?.('start')}\n />\n <IconButton\n //\n icon='ph--globe-hemisphere-west--regular'\n label='toggle'\n iconOnly\n size={5}\n classNames='px-0 aspect-square'\n onClick={() => onAction?.('toggle')}\n />\n </Toolbar.Root>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// eslint-disable-next-line no-restricted-imports\nimport 'leaflet/dist/leaflet.css';\n\nimport L, { Control, DomEvent, DomUtil, latLngBounds, type ControlPosition, type LatLngExpression } from 'leaflet';\nimport React, { forwardRef, useEffect, useImperativeHandle, type PropsWithChildren } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport type { MapContainerProps } from 'react-leaflet';\nimport { MapContainer, Marker, Popup, TileLayer, useMap } from 'react-leaflet';\nimport { useResizeDetector } from 'react-resize-detector';\n\nimport { debounce } from '@dxos/async';\nimport { ThemeProvider, Tooltip, type ThemedClassName } from '@dxos/react-ui';\nimport { defaultTx, mx } from '@dxos/react-ui-theme';\n\nimport { ActionControls, controlPositions, ZoomControls, type ControlProps } from '../Toolbar';\nimport { type MapCanvasProps } from '../types';\n\n// TODO(burdon): Explore plugins: https://www.npmjs.com/search?q=keywords%3Areact-leaflet-v4\n// TODO(burdon): react-leaflet v5 is not compatible with react 18.\n\nconst defaults = {\n // TODO(burdon): Guess location.\n center: { lat: 51, lng: 0 } as L.LatLngExpression,\n zoom: 4,\n};\n\n//\n// Root\n//\n\ntype MapRootProps = ThemedClassName<MapContainerProps>;\n\n// https://react-leaflet.js.org/docs/api-map\nconst MapRoot = ({ classNames, center = defaults.center, zoom = defaults.zoom, ...props }: MapRootProps) => {\n return (\n <MapContainer\n className={mx('relative flex w-full h-full grow bg-baseSurface', classNames)}\n attributionControl={false}\n // TODO(burdon): Only if attention.\n scrollWheelZoom={true}\n zoomControl={false}\n center={center}\n zoom={zoom}\n {...props}\n />\n );\n};\n\n//\n// Control\n//\n\n// TODO(burdon): Normalize with Globe.\ntype MapController = {\n setCenter: (center: LatLngExpression, zoom?: number) => void;\n setZoom: (cb: (zoom: number) => number) => void;\n};\n\nconst MapCanvas = forwardRef<MapController, MapCanvasProps>(({ markers, center, zoom, onChange }, forwardedRef) => {\n const { ref, width, height } = useResizeDetector({ refreshRate: 200 });\n const map = useMap();\n\n useImperativeHandle(\n forwardedRef,\n () => ({\n setCenter: (center: LatLngExpression, zoom?: number) => {\n map.setView(center, zoom);\n },\n setZoom: (cb) => {\n map.setZoom(cb(map.getZoom()));\n },\n }),\n [map],\n );\n\n // Resize.\n useEffect(() => {\n if (width && height) {\n map.invalidateSize();\n }\n }, [width, height]);\n\n // Position.\n useEffect(() => {\n if (center) {\n map.setView(center, zoom);\n } else if (zoom !== undefined) {\n map.setZoom(zoom);\n }\n }, [center, zoom]);\n\n // Events.\n useEffect(() => {\n const handler = debounce(() => {\n onChange?.({ center: map.getCenter(), zoom: map.getZoom() });\n }, 100);\n map.on('move', handler);\n map.on('zoom', handler);\n return () => {\n map.off('move', handler);\n map.off('zoom', handler);\n };\n }, [map, onChange]);\n\n // Set the viewport around the markers, or show the whole world map if `markers` is empty.\n useEffect(() => {\n if (markers.length > 0) {\n const bounds = latLngBounds(markers.map((marker) => marker.location));\n map.fitBounds(bounds);\n } else {\n map.setView(defaults.center, defaults.zoom);\n }\n }, [markers]);\n\n return (\n <div ref={ref} className='flex w-full h-full overflow-hidden bg-baseSurface'>\n {/* Map tiles. */}\n <TileLayer\n className='dark:filter dark:grayscale dark:invert'\n url='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'\n />\n\n {/* Markers. */}\n {markers?.map(({ id, title, location: { lat, lng } }) => {\n return (\n <Marker\n key={id}\n position={{ lat, lng }}\n icon={\n // TODO(burdon): Create custom icon from bundled assets.\n new L.Icon({\n iconUrl: 'https://dxos.network/marker-icon.png',\n iconRetinaUrl: 'https://dxos.network/marker-icon-2x.png',\n shadowUrl: 'https://dxos.network/marker-shadow.png',\n iconSize: [25, 41],\n iconAnchor: [12, 41],\n popupAnchor: [1, -34],\n shadowSize: [41, 41],\n })\n }\n >\n {title && <Popup>{title}</Popup>}\n </Marker>\n );\n })}\n </div>\n );\n});\n\n//\n// Controls\n// Integrates with Leaflet custom controls.\n//\n\nconst CustomControl = ({\n position,\n children,\n}: PropsWithChildren<{\n position: ControlPosition;\n}>) => {\n const map = useMap();\n\n useEffect(() => {\n const control = new Control({ position });\n control.onAdd = () => {\n const container = DomUtil.create('div', mx('!m-0', controlPositions[position]));\n DomEvent.disableClickPropagation(container);\n DomEvent.disableScrollPropagation(container);\n\n const root = createRoot(container);\n root.render(\n <ThemeProvider tx={defaultTx}>\n <Tooltip.Provider>{children}</Tooltip.Provider>\n </ThemeProvider>,\n );\n\n return container;\n };\n\n control.addTo(map);\n return () => {\n control.remove();\n };\n }, [map, position, children]);\n\n return null;\n};\n\ntype MapControlProps = { position?: ControlPosition } & Pick<ControlProps, 'onAction'>;\n\n//\n// Map\n//\n\nexport const Map = {\n Root: MapRoot,\n Canvas: MapCanvas,\n Zoom: ({ onAction, position = 'bottomleft', ...props }: MapControlProps) => (\n <CustomControl position={position} {...props}>\n <ZoomControls onAction={onAction} />\n </CustomControl>\n ),\n Action: ({ onAction, position = 'bottomright', ...props }: MapControlProps) => (\n <CustomControl position={position} {...props}>\n <ActionControls onAction={onAction} />\n </CustomControl>\n ),\n};\n\nexport { type MapCanvasProps, type MapController };\n"],
|
|
5
|
+
"mappings": ";;;;;AAIA,YAAYA,SAAQ;AAGpB,OAAOC,UAELC,YACAC,aAAAA,YACAC,qBACAC,SACAC,QACAC,YAAAA,iBACK;AACP,SAASC,yBAAyB;AAGlC,SAA+CC,eAAeC,uBAAuB;AACrF,SAASC,UAAU;;;AChBnB,OAAOC,SAASC,eAA2EC,kBAAkB;AAE7G,SAASC,aAAa;AACtB,SAASC,0BAA0B;AAqBnC,IAAMC,eAAeC,8BAAgCC,MAAAA;AAM9C,IAAMC,uBA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N,SAAAA;AAElC,YAAMO,OAAOC,WAAWR,SAAAA;AACxBO,WAAKE,OACH,gBAAAxE,OAAA,cAACyE,eAAAA;QAAcC,IAAIC;SACjB,gBAAA3E,OAAA,cAAC4E,QAAQC,UAAQ,MAAElB,QAAAA,CAAAA,CAAAA;AAIvB,aAAOI;IACT;AAEAH,YAAQkB,MAAM7D,GAAAA;AACd,WAAO,MAAA;AACL2C,cAAQmB,OAAM;IAChB;EACF,GAAG;IAAC9D;IAAK6B;IAAUa;GAAS;AAE5B,SAAO;AACT;AAQO,IAAMqB,MAAM;EACjBC,MAAMpF;EACNqF,QAAQ3E;EACR4E,MAAM,CAAC,EAAEC,UAAUtC,WAAW,cAAc,GAAG/C,MAAAA,MAC7C,gBAAAC,OAAA,cAAC0D,gBAAAA;IAAcZ;IAAqB,GAAG/C;KACrC,gBAAAC,OAAA,cAACqF,cAAAA;IAAaD;;EAGlBE,QAAQ,CAAC,EAAEF,UAAUtC,WAAW,eAAe,GAAG/C,MAAAA,MAChD,gBAAAC,OAAA,cAAC0D,gBAAAA;IAAcZ;IAAqB,GAAG/C;KACrC,gBAAAC,OAAA,cAACuF,gBAAAA;IAAeH;;AAGtB;",
|
|
6
|
+
"names": ["d3", "React", "forwardRef", "useEffect", "useImperativeHandle", "useMemo", "useRef", "useState", "useResizeDetector", "useDynamicRef", "useThemeContext", "mx", "React", "createContext", "useContext", "raise", "useControlledState", "GlobeContext", "createContext", "undefined", "GlobeContextProvider", "children", "size", "center", "_center", "scale", "_scale", "translation", "_translation", "rotation", "_rotation", "setCenter", "useControlledState", "setScale", "setTranslation", "setRotation", "Provider", "value", "useGlobeContext", "useContext", "raise", "Error", "d3", "useEffect", "debug", "timer", "cb", "start", "Date", "now", "data", "t", "console", "log", "d3", "versor", "restrictAxis", "axis", "original", "current", "map", "d", "i", "geoInertiaDrag", "target", "render", "projection", "options", "node", "select", "inertia", "geoInertiaDragHelper", "rotation", "rotate", "xAxis", "start", "move", "end", "stop", "finish", "time", "hold", "call", "drag", "on", "opt", "v0", "r0", "q0", "v10", "v11", "q10", "inertiaHelper", "versor", "cartesian", "invert", "position", "inv", "isNaN", "v1", "q1", "multiply", "delta", "r1", "r2", "velocity", "t", "A", "limit", "B", "Math", "log", "timer", "ev", "x", "y", "classList", "remove", "add", "performance", "now", "deltaTime", "decay", "exp", "deltaPos", "v", "undefined", "self", "restart", "e", "d3", "positionToRotation", "lng", "lat", "tilt", "geoToPosition", "geoPoint", "point", "type", "coordinates", "geoCircle", "radius", "center", "geoLine", "p1", "p2", "closestPoint", "points", "target", "length", "minDistance", "getDistance", "distance", "point1", "point2", "dx", "dy", "Math", "sqrt", "d3", "topojson", "createLayers", "topology", "features", "styles", "layers", "water", "push", "path", "type", "graticule", "geoGraticule", "step", "objects", "land", "feature", "countries", "border", "mesh", "a", "b", "dots", "points", "lines", "point", "geometries", "map", "geoPoint", "line", "source", "target", "geoLine", "renderLayers", "generator", "scale", "context", "canvas", "width", "height", "reset", "background", "fillStyle", "fillRect", "clearRect", "forEach", "save", "fill", "stroke", "Object", "entries", "key", "value", "pointRadius", "beginPath", "restore", "useDrag", "controller", "options", "useEffect", "canvas", "disabled", "geoInertiaDrag", "select", "setRotation", "projection", "rotate", "onUpdate", "type", "xAxis", "time", "start", "finish", "cancelDrag", "JSON", "stringify", "node", "on", "useCallback", "useGlobeZoomHandler", "controller", "useCallback", "event", "setScale", "scale", "useCallback", "useMapZoomHandler", "controller", "useCallback", "event", "setZoom", "scale", "d3", "useEffect", "useState", "useSpinner", "controller", "options", "running", "setRunning", "useState", "useEffect", "timer", "start", "delta", "t", "lastRotation", "projection", "rotate", "elapsed", "dt", "rotation", "setRotation", "stop", "undefined", "disabled", "d3", "useEffect", "useState", "versor", "log", "TRANSITION_NAME", "defaultDuration", "useTour", "controller", "points", "options", "selection", "running", "setRunning", "useState", "useEffect", "interrupt", "t", "setTimeout", "canvas", "projection", "setRotation", "context", "getContext", "alpha", "path", "geoPath", "pointRadius", "tilt", "last", "p", "loop", "push", "next", "p1", "geoToPosition", "undefined", "p2", "ip", "geoInterpolate", "distance", "geoDistance", "r1", "positionToRotation", "rotate", "r2", "iv", "versor", "interpolate", "transition", "duration", "Math", "max", "tween", "t1", "min", "t2", "save", "beginPath", "strokeStyle", "styles", "arc", "lineWidth", "scale", "setLineDash", "lineDash", "type", "coordinates", "stroke", "fillStyle", "cursor", "fill", "restore", "autoRotate", "end", "err", "log", "catch", "clearTimeout", "JSON", "stringify", "React", "IconButton", "Toolbar", "controlPositions", "topleft", "topright", "bottomleft", "bottomright", "ZoomControls", "classNames", "onAction", "React", "Toolbar", "Root", "IconButton", "icon", "label", "iconOnly", "size", "onClick", "ActionControls", "defaultStyles", "light", "background", "fillStyle", "water", "land", "line", "strokeStyle", "point", "strokeWidth", "pointRadius", "dark", "projectionMap", "orthographic", "geoOrthographic", "mercator", "geoMercator", "geoTransverseMercator", "getProjection", "type", "constructor", "GlobeRoot", "classNames", "children", "props", "ref", "width", "height", "useResizeDetector", "React", "div", "className", "mx", "GlobeContextProvider", "size", "GlobeCanvas", "forwardRef", "projection", "_projection", "topology", "features", "styles", "_styles", "themeMode", "useThemeContext", "useMemo", "canvas", "setCanvas", "useState", "canvasRef", "layers", "timer", "createLayers", "center", "scale", "translation", "rotation", "setCenter", "setScale", "setTranslation", "setRotation", "useGlobeContext", "scaleRef", "useDynamicRef", "useEffect", "positionToRotation", "geoToPosition", "zooming", "useRef", "useImperativeHandle", "current", "s", "is", "interpolateNumber", "d3", "transition", "ease", "easeLinear", "easeSinOut", "duration", "tween", "t", "on", "generator", "geoPath", "getContext", "alpha", "Math", "min", "translate", "x", "y", "rotate", "renderLayers", "GlobeDebug", "position", "controlPositions", "pre", "JSON", "stringify", "GlobePanel", "CustomControl", "Globe", "Root", "Canvas", "Zoom", "onAction", "ZoomControls", "Action", "ActionControls", "Debug", "Panel", "L", "Control", "DomEvent", "DomUtil", "latLngBounds", "React", "forwardRef", "useEffect", "useImperativeHandle", "createRoot", "MapContainer", "Marker", "Popup", "TileLayer", "useMap", "useResizeDetector", "debounce", "ThemeProvider", "Tooltip", "defaultTx", "mx", "defaults", "center", "lat", "lng", "zoom", "MapRoot", "classNames", "props", "React", "MapContainer", "className", "mx", "attributionControl", "scrollWheelZoom", "zoomControl", "MapCanvas", "forwardRef", "markers", "onChange", "forwardedRef", "ref", "width", "height", "useResizeDetector", "refreshRate", "map", "useMap", "useImperativeHandle", "setCenter", "setView", "setZoom", "cb", "getZoom", "useEffect", "invalidateSize", "undefined", "handler", "debounce", "getCenter", "on", "off", "length", "bounds", "latLngBounds", "marker", "location", "fitBounds", "div", "TileLayer", "url", "id", "title", "Marker", "key", "position", "icon", "L", "Icon", "iconUrl", "iconRetinaUrl", "shadowUrl", "iconSize", "iconAnchor", "popupAnchor", "shadowSize", "Popup", "CustomControl", "children", "control", "Control", "onAdd", "container", "DomUtil", "create", "controlPositions", "DomEvent", "disableClickPropagation", "disableScrollPropagation", "root", "createRoot", "render", "ThemeProvider", "tx", "defaultTx", "Tooltip", "Provider", "addTo", "remove", "Map", "Root", "Canvas", "Zoom", "onAction", "ZoomControls", "Action", "ActionControls"]
|
|
7
7
|
}
|