@dxos/react-ui-geo 0.8.1 → 0.8.2-main.2f9c567
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 +45 -55
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +40 -50
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +45 -55
- 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.map +1 -1
- package/dist/types/src/components/Map/Map.stories.d.ts +5 -4
- package/dist/types/src/components/Map/Map.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/useTour.d.ts +1 -1
- package/dist/types/src/hooks/useTour.d.ts.map +1 -1
- package/dist/types/src/util/inertia.d.ts +1 -2
- package/dist/types/src/util/inertia.d.ts.map +1 -1
- package/dist/types/src/util/path.d.ts.map +1 -1
- package/dist/types/src/util/render.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/components/Globe/Globe.tsx +20 -11
- package/src/components/Map/Map.stories.tsx +4 -4
- package/src/hooks/useDrag.ts +3 -3
- package/src/hooks/useSpinner.ts +2 -2
- package/src/hooks/useTour.ts +9 -13
- package/src/util/inertia.ts +4 -5
- package/src/util/path.ts +2 -5
- package/src/util/render.ts +5 -6
package/dist/lib/node/index.cjs
CHANGED
|
@@ -35,7 +35,7 @@ __export(node_exports, {
|
|
|
35
35
|
closestPoint: () => closestPoint,
|
|
36
36
|
controlPositions: () => controlPositions,
|
|
37
37
|
createLayers: () => createLayers,
|
|
38
|
-
geoCircle: () =>
|
|
38
|
+
geoCircle: () => geoCircle,
|
|
39
39
|
geoInertiaDrag: () => geoInertiaDrag,
|
|
40
40
|
geoLine: () => geoLine,
|
|
41
41
|
geoPoint: () => geoPoint,
|
|
@@ -55,7 +55,7 @@ __export(node_exports, {
|
|
|
55
55
|
});
|
|
56
56
|
module.exports = __toCommonJS(node_exports);
|
|
57
57
|
var import_chunk_LAICG6L2 = require("./chunk-LAICG6L2.cjs");
|
|
58
|
-
var
|
|
58
|
+
var import_d3 = require("d3");
|
|
59
59
|
var import_react = __toESM(require("react"));
|
|
60
60
|
var import_react_resize_detector = require("react-resize-detector");
|
|
61
61
|
var import_react_ui = require("@dxos/react-ui");
|
|
@@ -63,21 +63,20 @@ var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
|
63
63
|
var import_react2 = __toESM(require("react"));
|
|
64
64
|
var import_debug = require("@dxos/debug");
|
|
65
65
|
var import_react_ui2 = require("@dxos/react-ui");
|
|
66
|
-
var
|
|
66
|
+
var import_d32 = require("d3");
|
|
67
67
|
var import_react3 = require("react");
|
|
68
|
-
var
|
|
68
|
+
var import_d33 = require("d3");
|
|
69
69
|
var import_versor = __toESM(require("versor"));
|
|
70
|
-
var
|
|
71
|
-
var
|
|
72
|
-
var
|
|
70
|
+
var import_d34 = require("d3");
|
|
71
|
+
var import_d35 = require("d3");
|
|
72
|
+
var import_topojson_client = require("topojson-client");
|
|
73
73
|
var import_react4 = require("react");
|
|
74
74
|
var import_react5 = require("react");
|
|
75
|
-
var
|
|
75
|
+
var import_d36 = require("d3");
|
|
76
76
|
var import_react6 = require("react");
|
|
77
|
-
var
|
|
77
|
+
var import_d37 = require("d3");
|
|
78
78
|
var import_react7 = require("react");
|
|
79
79
|
var import_versor2 = __toESM(require("versor"));
|
|
80
|
-
var import_log = require("@dxos/log");
|
|
81
80
|
var import_react8 = __toESM(require("react"));
|
|
82
81
|
var import_react_ui3 = require("@dxos/react-ui");
|
|
83
82
|
var import_leaflet = require("leaflet/dist/leaflet.css");
|
|
@@ -133,7 +132,7 @@ var geoInertiaDrag = (target, render, projection, options) => {
|
|
|
133
132
|
if (target.node) {
|
|
134
133
|
target = target.node();
|
|
135
134
|
}
|
|
136
|
-
target =
|
|
135
|
+
target = (0, import_d33.select)(target);
|
|
137
136
|
const inertia = geoInertiaDragHelper({
|
|
138
137
|
projection,
|
|
139
138
|
render: (rotation) => {
|
|
@@ -157,7 +156,7 @@ var geoInertiaDrag = (target, render, projection, options) => {
|
|
|
157
156
|
time: options.time,
|
|
158
157
|
hold: options.hold
|
|
159
158
|
});
|
|
160
|
-
target.call(
|
|
159
|
+
target.call((0, import_d33.drag)().on("start", inertia.start).on("drag", inertia.move).on("end", inertia.end));
|
|
161
160
|
return inertia;
|
|
162
161
|
};
|
|
163
162
|
var geoInertiaDragHelper = (opt) => {
|
|
@@ -218,7 +217,7 @@ function inertiaHelper(opt) {
|
|
|
218
217
|
0,
|
|
219
218
|
0
|
|
220
219
|
],
|
|
221
|
-
timer:
|
|
220
|
+
timer: (0, import_d33.timer)(() => {
|
|
222
221
|
}),
|
|
223
222
|
time: 0,
|
|
224
223
|
t: 0,
|
|
@@ -309,7 +308,7 @@ var geoPoint = (point) => ({
|
|
|
309
308
|
type: "Point",
|
|
310
309
|
coordinates: geoToPosition(point)
|
|
311
310
|
});
|
|
312
|
-
var
|
|
311
|
+
var geoCircle = ({ lat, lng }, radius) => (0, import_d34.geoCircle)().radius(radius).center([
|
|
313
312
|
lng,
|
|
314
313
|
lat
|
|
315
314
|
])();
|
|
@@ -359,7 +358,7 @@ var createLayers = (topology, features, styles) => {
|
|
|
359
358
|
if (styles.graticule) {
|
|
360
359
|
layers.push({
|
|
361
360
|
styles: styles.graticule,
|
|
362
|
-
path:
|
|
361
|
+
path: (0, import_d35.geoGraticule)().step([
|
|
363
362
|
6,
|
|
364
363
|
6
|
|
365
364
|
])()
|
|
@@ -369,13 +368,13 @@ var createLayers = (topology, features, styles) => {
|
|
|
369
368
|
if (topology.objects.land && styles.land) {
|
|
370
369
|
layers.push({
|
|
371
370
|
styles: styles.land,
|
|
372
|
-
path:
|
|
371
|
+
path: (0, import_topojson_client.feature)(topology, topology.objects.land)
|
|
373
372
|
});
|
|
374
373
|
}
|
|
375
374
|
if (topology.objects.countries && styles.border) {
|
|
376
375
|
layers.push({
|
|
377
376
|
styles: styles.border,
|
|
378
|
-
path:
|
|
377
|
+
path: (0, import_topojson_client.mesh)(topology, topology.objects.countries, (a, b) => a !== b)
|
|
379
378
|
});
|
|
380
379
|
}
|
|
381
380
|
if (topology.objects.dots && styles.dots) {
|
|
@@ -447,7 +446,7 @@ var useDrag = (controller, options = {}) => {
|
|
|
447
446
|
if (!canvas || options.disabled) {
|
|
448
447
|
return;
|
|
449
448
|
}
|
|
450
|
-
geoInertiaDrag(
|
|
449
|
+
geoInertiaDrag((0, import_d32.select)(canvas), () => {
|
|
451
450
|
controller.setRotation(controller.projection.rotate());
|
|
452
451
|
options.onUpdate?.({
|
|
453
452
|
type: "move",
|
|
@@ -466,7 +465,7 @@ var useDrag = (controller, options = {}) => {
|
|
|
466
465
|
})
|
|
467
466
|
});
|
|
468
467
|
return () => {
|
|
469
|
-
cancelDrag(
|
|
468
|
+
cancelDrag((0, import_d32.select)(canvas));
|
|
470
469
|
};
|
|
471
470
|
}, [
|
|
472
471
|
controller,
|
|
@@ -515,7 +514,7 @@ var useMapZoomHandler = (controller) => {
|
|
|
515
514
|
var useSpinner = (controller, options = {}) => {
|
|
516
515
|
const [running, setRunning] = (0, import_react6.useState)(false);
|
|
517
516
|
(0, import_react6.useEffect)(() => {
|
|
518
|
-
let
|
|
517
|
+
let timer3;
|
|
519
518
|
const start = () => {
|
|
520
519
|
const delta = options.delta ?? [
|
|
521
520
|
1e-3,
|
|
@@ -524,7 +523,7 @@ var useSpinner = (controller, options = {}) => {
|
|
|
524
523
|
];
|
|
525
524
|
let t = 0;
|
|
526
525
|
let lastRotation = controller.projection.rotate();
|
|
527
|
-
|
|
526
|
+
timer3 = (0, import_d36.timer)((elapsed) => {
|
|
528
527
|
const dt = elapsed - t;
|
|
529
528
|
t = elapsed;
|
|
530
529
|
const rotation = [
|
|
@@ -537,9 +536,9 @@ var useSpinner = (controller, options = {}) => {
|
|
|
537
536
|
});
|
|
538
537
|
};
|
|
539
538
|
const stop = () => {
|
|
540
|
-
if (
|
|
541
|
-
|
|
542
|
-
|
|
539
|
+
if (timer3) {
|
|
540
|
+
timer3.stop();
|
|
541
|
+
timer3 = void 0;
|
|
543
542
|
}
|
|
544
543
|
};
|
|
545
544
|
if (controller && running) {
|
|
@@ -561,15 +560,14 @@ var useSpinner = (controller, options = {}) => {
|
|
|
561
560
|
() => setRunning(false)
|
|
562
561
|
];
|
|
563
562
|
};
|
|
564
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-geo/src/hooks/useTour.ts";
|
|
565
563
|
var TRANSITION_NAME = "globe-tour";
|
|
566
564
|
var defaultDuration = 1500;
|
|
567
565
|
var useTour = (controller, points, options = {}) => {
|
|
568
|
-
const
|
|
566
|
+
const selection = (0, import_react7.useMemo)(() => (0, import_d37.selection)(), []);
|
|
569
567
|
const [running, setRunning] = (0, import_react7.useState)(options.running ?? false);
|
|
570
568
|
(0, import_react7.useEffect)(() => {
|
|
571
569
|
if (!running) {
|
|
572
|
-
|
|
570
|
+
selection.interrupt(TRANSITION_NAME);
|
|
573
571
|
return;
|
|
574
572
|
}
|
|
575
573
|
let t;
|
|
@@ -579,7 +577,7 @@ var useTour = (controller, points, options = {}) => {
|
|
|
579
577
|
const context = canvas.getContext("2d", {
|
|
580
578
|
alpha: false
|
|
581
579
|
});
|
|
582
|
-
const path =
|
|
580
|
+
const path = (0, import_d37.geoPath)(projection, context).pointRadius(2);
|
|
583
581
|
const tilt = options.tilt ?? 0;
|
|
584
582
|
let last;
|
|
585
583
|
try {
|
|
@@ -595,12 +593,12 @@ var useTour = (controller, points, options = {}) => {
|
|
|
595
593
|
}
|
|
596
594
|
const p1 = last ? geoToPosition(last) : void 0;
|
|
597
595
|
const p2 = geoToPosition(next);
|
|
598
|
-
const ip =
|
|
599
|
-
const distance =
|
|
596
|
+
const ip = (0, import_d37.geoInterpolate)(p1 || p2, p2);
|
|
597
|
+
const distance = (0, import_d37.geoDistance)(p1 || p2, p2);
|
|
600
598
|
const r1 = p1 ? positionToRotation(p1, tilt) : controller.projection.rotate();
|
|
601
599
|
const r2 = positionToRotation(p2, tilt);
|
|
602
600
|
const iv = import_versor2.default.interpolate(r1, r2);
|
|
603
|
-
const transition2 =
|
|
601
|
+
const transition2 = selection.transition(TRANSITION_NAME).duration(Math.max(options.duration ?? defaultDuration, distance * 2e3)).tween("render", () => (t2) => {
|
|
604
602
|
const t1 = Math.max(0, Math.min(1, t2 * 2 - 1));
|
|
605
603
|
const t22 = Math.min(1, t2 * 2);
|
|
606
604
|
context.save();
|
|
@@ -627,28 +625,20 @@ var useTour = (controller, points, options = {}) => {
|
|
|
627
625
|
context.fill();
|
|
628
626
|
}
|
|
629
627
|
context.restore();
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
setRotation(projection.rotate());
|
|
633
|
-
}
|
|
628
|
+
projection.rotate(iv(t2));
|
|
629
|
+
setRotation(projection.rotate());
|
|
634
630
|
});
|
|
635
631
|
await transition2.end();
|
|
636
632
|
last = next;
|
|
637
633
|
}
|
|
638
634
|
} catch (err) {
|
|
639
|
-
import_log.log.catch(err, void 0, {
|
|
640
|
-
F: __dxlog_file,
|
|
641
|
-
L: 112,
|
|
642
|
-
S: void 0,
|
|
643
|
-
C: (f, a) => f(...a)
|
|
644
|
-
});
|
|
645
635
|
} finally {
|
|
646
636
|
setRunning(false);
|
|
647
637
|
}
|
|
648
638
|
});
|
|
649
639
|
return () => {
|
|
650
640
|
clearTimeout(t);
|
|
651
|
-
|
|
641
|
+
selection.interrupt(TRANSITION_NAME);
|
|
652
642
|
};
|
|
653
643
|
}
|
|
654
644
|
}, [
|
|
@@ -758,16 +748,16 @@ var defaultStyles = {
|
|
|
758
748
|
}
|
|
759
749
|
};
|
|
760
750
|
var projectionMap = {
|
|
761
|
-
orthographic:
|
|
762
|
-
mercator:
|
|
763
|
-
"transverse-mercator":
|
|
751
|
+
orthographic: import_d3.geoOrthographic,
|
|
752
|
+
mercator: import_d3.geoMercator,
|
|
753
|
+
"transverse-mercator": import_d3.geoTransverseMercator
|
|
764
754
|
};
|
|
765
755
|
var getProjection = (type = "orthographic") => {
|
|
766
756
|
if (typeof type === "string") {
|
|
767
|
-
const constructor = projectionMap[type] ??
|
|
757
|
+
const constructor = projectionMap[type] ?? import_d3.geoOrthographic;
|
|
768
758
|
return constructor();
|
|
769
759
|
}
|
|
770
|
-
return type ??
|
|
760
|
+
return type ?? (0, import_d3.geoOrthographic)();
|
|
771
761
|
};
|
|
772
762
|
var GlobeRoot = ({ classNames, children, ...props }) => {
|
|
773
763
|
const { ref, width, height } = (0, import_react_resize_detector.useResizeDetector)();
|
|
@@ -824,8 +814,8 @@ var GlobeCanvas = /* @__PURE__ */ (0, import_react.forwardRef)(({ projection: _p
|
|
|
824
814
|
setCenter,
|
|
825
815
|
setScale: (s) => {
|
|
826
816
|
if (typeof s === "function") {
|
|
827
|
-
const is =
|
|
828
|
-
|
|
817
|
+
const is = (0, import_d3.interpolateNumber)(scaleRef.current, s(scaleRef.current));
|
|
818
|
+
(0, import_d3.transition)().ease(zooming.current ? import_d3.easeLinear : import_d3.easeSinOut).duration(200).tween("scale", () => (t) => setScale(is(t))).on("end", () => {
|
|
829
819
|
zooming.current = false;
|
|
830
820
|
});
|
|
831
821
|
} else {
|
|
@@ -838,7 +828,7 @@ var GlobeCanvas = /* @__PURE__ */ (0, import_react.forwardRef)(({ projection: _p
|
|
|
838
828
|
}, [
|
|
839
829
|
canvas
|
|
840
830
|
]);
|
|
841
|
-
const generator = (0, import_react.useMemo)(() => canvas && projection &&
|
|
831
|
+
const generator = (0, import_react.useMemo)(() => canvas && projection && (0, import_d3.geoPath)(projection, canvas.getContext("2d", {
|
|
842
832
|
alpha: false
|
|
843
833
|
})), [
|
|
844
834
|
canvas,
|
|
@@ -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, 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,UAAoB;AAGpB,mBAQO;AACP,mCAAkC;AAGlC,sBAAqF;AACrF,4BAAmB;AChBnB,IAAAA,gBAA6G;AAE7G,mBAAsB;AACtB,IAAAC,mBAAmC;ACHnC,UAAoB;AACpB,IAAAD,gBAA0B;AEC1B,SAAoB;AACpB,oBAAmB;ACHnB,UAAoB;ACApB,UAAoB;AAEpB,eAA0B;ACF1B,IAAAA,gBAA4B;ACA5B,IAAAA,gBAA4B;ACA5B,UAAoB;AAEpB,IAAAA,gBAAoC;ACFpC,UAAoB;AACpB,IAAAA,gBAAwE;AACxE,IAAAE,iBAAmB;AAEnB,iBAAoB;ACHpB,IA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_leaflet", "import_react_resize_detector", "import_react_ui_theme", "GlobeContext", "createContext", "undefined", "GlobeContextProvider", "children", "size", "center", "_center", "scale", "_scale", "translation", "_translation", "rotation", "_rotation", "setCenter", "useControlledState", "setScale", "setTranslation", "setRotation", "React", "Provider", "value", "useGlobeContext", "useContext", "raise", "Error", "debug", "timer", "cb", "start", "Date", "now", "data", "t", "console", "log", "restrictAxis", "axis", "original", "current", "map", "d", "i", "geoInertiaDrag", "target", "render", "projection", "options", "node", "select", "inertia", "geoInertiaDragHelper", "rotate", "xAxis", "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", "A", "limit", "B", "Math", "ev", "x", "y", "classList", "remove", "add", "performance", "deltaTime", "decay", "exp", "deltaPos", "v", "self", "restart", "e", "positionToRotation", "lng", "lat", "tilt", "geoToPosition", "geoPoint", "point", "type", "coordinates", "geoCircle", "radius", "geoLine", "p1", "p2", "closestPoint", "points", "length", "minDistance", "getDistance", "distance", "point1", "point2", "dx", "dy", "sqrt", "createLayers", "topology", "features", "styles", "layers", "water", "push", "path", "graticule", "geoGraticule", "step", "objects", "land", "feature", "countries", "border", "mesh", "a", "b", "dots", "lines", "geometries", "line", "source", "renderLayers", "generator", "context", "canvas", "width", "height", "reset", "background", "fillStyle", "fillRect", "clearRect", "forEach", "save", "fill", "stroke", "Object", "entries", "key", "pointRadius", "beginPath", "restore", "useDrag", "controller", "useEffect", "disabled", "onUpdate", "cancelDrag", "JSON", "stringify", "useGlobeZoomHandler", "useCallback", "event", "useMapZoomHandler", "setZoom", "useSpinner", "running", "setRunning", "useState", "lastRotation", "elapsed", "dt", "TRANSITION_NAME", "defaultDuration", "useTour", "selection", "interrupt", "setTimeout", "getContext", "alpha", "geoPath", "last", "p", "loop", "next", "ip", "geoInterpolate", "geoDistance", "iv", "interpolate", "transition", "duration", "max", "tween", "t1", "min", "t2", "strokeStyle", "arc", "lineWidth", "setLineDash", "lineDash", "cursor", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2018 DXOS.org\n//\n\nimport {\n type GeoProjection,\n geoMercator,\n geoOrthographic,\n geoPath,\n geoTransverseMercator,\n interpolateNumber,\n transition,\n easeLinear,\n easeSinOut,\n} 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: geoOrthographic,\n mercator: geoMercator,\n 'transverse-mercator': geoTransverseMercator,\n};\n\nconst getProjection = (type: GlobeCanvasProps['projection'] = 'orthographic'): GeoProjection => {\n if (typeof type === 'string') {\n const constructor = projectionMap[type] ?? geoOrthographic;\n return constructor();\n }\n\n return type ?? 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 = interpolateNumber(scaleRef.current, s(scaleRef.current));\n // Stop easing if already zooming.\n transition()\n .ease(zooming.current ? easeLinear : 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 && 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 { select } 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 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(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 { select, drag, timer } 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 = 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(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: 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 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 { type GeoGeometryObjects, geoCircle as d3GeoCircle } 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\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 d3GeoCircle().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 { type GeoPath, type GeoPermissibleObjects, geoGraticule } from 'd3';\nimport { feature, mesh } 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: 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: feature(topology, topology.objects.land),\n });\n }\n\n if (topology.objects.countries && styles.border) {\n layers.push({\n styles: styles.border,\n path: 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 { timer as d3Timer } 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 = d3Timer((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 { geoPath, geoInterpolate, geoDistance, selection as d3Selection } from 'd3';\nimport { type SetStateAction, type Dispatch, useEffect, useState, useMemo } from 'react';\nimport versor from 'versor';\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 = useMemo(() => d3Selection(), []);\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 = 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 = geoInterpolate(p1 || p2, p2);\n const distance = 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 // Ignore.\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,gBAUO;AAEP,mBAQO;AACP,mCAAkC;AAGlC,sBAAqF;AACrF,4BAAmB;ACzBnB,IAAAA,gBAA6G;AAE7G,mBAAsB;AACtB,IAAAC,mBAAmC;ACHnC,IAAAC,aAAuB;AACvB,IAAAF,gBAA0B;AEC1B,IAAAE,aAAoC;AACpC,oBAAmB;ACHnB,IAAAA,aAAkE;ACAlE,IAAAA,aAAuE;AACvE,6BAA8B;ACD9B,IAAAF,gBAA4B;ACA5B,IAAAA,gBAA4B;ACA5B,IAAAE,aAAiC;AAEjC,IAAAF,gBAAoC;ACFpC,IAAAE,aAA+E;AAC/E,IAAAF,gBAAiF;AACjF,IAAAG,iBAAmB;ACDnB,IAAAH,gBAAkB;AAElB,IAAAC,mBAA0D;ACF1D,qBAAO;AAEP,IAAAG,kBAAyG;AACzG,IAAAJ,gBAA0F;AAC1F,oBAA2B;AAE3B,2BAA+D;AAC/D,IAAAK,gCAAkC;AAElC,mBAAyB;AACzB,IA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AMC,YAAYC,wBAAQC,OAAO,WAAO5E,uBAAAA,IAAG,QAAQlC,iBAAiB5J,QAAAA,CAAS,CAAA;AAC7E2Q,+BAASC,wBAAwBJ,SAAAA;AACjCG,+BAASE,yBAAyBL,SAAAA;AAElC,YAAMM,WAAOC,0BAAWP,SAAAA;AACxBM,WAAK3S,OACH1B,8BAAAA,QAAA,cAACuU,gCAAAA;QAAcC,IAAIC;SACjBzU,8BAAAA,QAAA,cAAC0U,yBAAQzU,UAAQ,MAAEhB,QAAAA,CAAAA,CAAAA;AAIvB,aAAO8U;IACT;AAEAH,YAAQe,MAAMtT,GAAAA;AACd,WAAO,MAAA;AACLuS,cAAQnP,OAAM;IAChB;EACF,GAAG;IAACpD;IAAKkC;IAAUtE;GAAS;AAE5B,SAAO;AACT;AAQO,IAAM2V,MAAM;EACjBhH,MAAM0D;EACNP,QAAQY;EACRX,MAAM,CAAC,EAAEtD,UAAUnK,WAAW,cAAc,GAAGyL,MAAAA,MAC7ChP,8BAAAA,QAAA,cAAC6Q,gBAAAA;IAActN;IAAqB,GAAGyL;KACrChP,8BAAAA,QAAA,cAACwN,cAAAA;IAAaE;;EAGlBuD,QAAQ,CAAC,EAAEvD,UAAUnK,WAAW,eAAe,GAAGyL,MAAAA,MAChDhP,8BAAAA,QAAA,cAAC6Q,gBAAAA;IAActN;IAAqB,GAAGyL;KACrChP,8BAAAA,QAAA,cAACkO,gBAAAA;IAAeR;;AAGtB;",
|
|
6
|
+
"names": ["import_react", "import_react_ui", "import_d3", "import_versor", "import_leaflet", "import_react_resize_detector", "import_react_ui_theme", "GlobeContext", "createContext", "undefined", "GlobeContextProvider", "children", "size", "center", "_center", "scale", "_scale", "translation", "_translation", "rotation", "_rotation", "setCenter", "useControlledState", "setScale", "setTranslation", "setRotation", "React", "Provider", "value", "useGlobeContext", "useContext", "raise", "Error", "debug", "timer", "cb", "start", "Date", "now", "data", "t", "console", "log", "restrictAxis", "axis", "original", "current", "map", "d", "i", "geoInertiaDrag", "target", "render", "projection", "options", "node", "select", "inertia", "geoInertiaDragHelper", "rotate", "xAxis", "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", "A", "limit", "B", "Math", "ev", "x", "y", "classList", "remove", "add", "performance", "deltaTime", "decay", "exp", "deltaPos", "v", "self", "restart", "e", "positionToRotation", "lng", "lat", "tilt", "geoToPosition", "geoPoint", "point", "type", "coordinates", "geoCircle", "radius", "d3GeoCircle", "geoLine", "p1", "p2", "closestPoint", "points", "length", "minDistance", "getDistance", "distance", "point1", "point2", "dx", "dy", "sqrt", "createLayers", "topology", "features", "styles", "layers", "water", "push", "path", "graticule", "geoGraticule", "step", "objects", "land", "feature", "countries", "border", "mesh", "a", "b", "dots", "lines", "geometries", "line", "source", "renderLayers", "generator", "context", "canvas", "width", "height", "reset", "background", "fillStyle", "fillRect", "clearRect", "forEach", "save", "fill", "stroke", "Object", "entries", "key", "pointRadius", "beginPath", "restore", "useDrag", "controller", "useEffect", "disabled", "onUpdate", "cancelDrag", "JSON", "stringify", "useGlobeZoomHandler", "useCallback", "event", "useMapZoomHandler", "setZoom", "useSpinner", "running", "setRunning", "useState", "lastRotation", "d3Timer", "elapsed", "dt", "TRANSITION_NAME", "defaultDuration", "useTour", "selection", "useMemo", "d3Selection", "interrupt", "setTimeout", "getContext", "alpha", "geoPath", "last", "p", "loop", "next", "ip", "geoInterpolate", "geoDistance", "iv", "interpolate", "transition", "duration", "max", "tween", "t1", "min", "t2", "strokeStyle", "arc", "lineWidth", "setLineDash", "lineDash", "cursor", "err", "clearTimeout", "controlPositions", "topleft", "topright", "bottomleft", "bottomright", "ZoomControls", "classNames", "onAction", "Toolbar", "Root", "IconButton", "icon", "label", "iconOnly", "onClick", "ActionControls", "defaultStyles", "light", "strokeWidth", "dark", "projectionMap", "orthographic", "geoOrthographic", "mercator", "geoMercator", "geoTransverseMercator", "getProjection", "constructor", "GlobeRoot", "props", "ref", "useResizeDetector", "div", "className", "mx", "GlobeCanvas", "forwardRef", "_projection", "_styles", "themeMode", "useThemeContext", "setCanvas", "canvasRef", "scaleRef", "useDynamicRef", "zooming", "useRef", "useImperativeHandle", "s", "is", "interpolateNumber", "ease", "easeLinear", "easeSinOut", "translate", "GlobeDebug", "pre", "GlobePanel", "CustomControl", "Globe", "Canvas", "Zoom", "Action", "Debug", "Panel", "defaults", "zoom", "MapRoot", "MapContainer", "attributionControl", "scrollWheelZoom", "zoomControl", "MapCanvas", "markers", "onChange", "forwardedRef", "refreshRate", "useMap", "setView", "getZoom", "invalidateSize", "handler", "debounce", "getCenter", "off", "bounds", "latLngBounds", "marker", "location", "fitBounds", "TileLayer", "url", "id", "title", "Marker", "L", "Icon", "iconUrl", "iconRetinaUrl", "shadowUrl", "iconSize", "iconAnchor", "popupAnchor", "shadowSize", "Popup", "control", "Control", "onAdd", "container", "DomUtil", "create", "DomEvent", "disableClickPropagation", "disableScrollPropagation", "root", "createRoot", "ThemeProvider", "tx", "defaultTx", "Tooltip", "addTo", "Map"]
|
|
7
7
|
}
|