@reearth/core 0.0.7-alpha.49 → 0.0.7-alpha.50
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/core.js +24053 -22620
- package/dist/core.umd.cjs +164 -161
- package/dist/index.d.ts +10 -10
- package/package.json +41 -45
- package/src/Map/ClusteredLayers/index.tsx +1 -1
- package/src/Map/Layer/hooks.ts +2 -2
- package/src/Map/Layer/index.tsx +1 -1
- package/src/Map/Layers/hooks.ts +2 -2
- package/src/Map/Layers/index.tsx +1 -1
- package/src/Map/Sketch/hooks.ts +4 -4
- package/src/Map/Sketch/index.tsx +2 -2
- package/src/Map/Sketch/usePluginSketchLayer.ts +1 -1
- package/src/Map/Sketch/useSketch.ts +1 -1
- package/src/Map/Sketch/useSketchFeature.ts +1 -1
- package/src/Map/SpatialId/hooks.ts +2 -2
- package/src/Map/SpatialId/index.tsx +2 -2
- package/src/Map/index.tsx +1 -1
- package/src/Map/ref.ts +5 -5
- package/src/Map/types/index.ts +2 -2
- package/src/Map/useTimelineManager.ts +1 -1
- package/src/Map/utils.ts +1 -1
- package/src/Visualizer/context.tsx +5 -5
- package/src/Visualizer/hooks.ts +8 -8
- package/src/Visualizer/useViewport.ts +1 -1
- package/src/engines/Cesium/Feature/Box/hooks/box.ts +4 -4
- package/src/engines/Cesium/Feature/HeatMap/HeatmapMesh.tsx +1 -1
- package/src/engines/Cesium/Feature/PhotoOverlay/hooks.ts +1 -1
- package/src/engines/Cesium/Feature/PhotoOverlay/index.tsx +3 -1
- package/src/engines/Cesium/Feature/Tileset/hooks.ts +2 -2
- package/src/engines/Cesium/Feature/Tileset/index.tsx +1 -1
- package/src/engines/Cesium/Feature/Tileset/useClippingBox.ts +2 -2
- package/src/engines/Cesium/Feature/index.tsx +1 -1
- package/src/engines/Cesium/core/Clock.tsx +1 -1
- package/src/engines/Cesium/core/Globe/index.tsx +1 -1
- package/src/engines/Cesium/core/Globe/useTerrainProviderPromise.ts +1 -1
- package/src/engines/Cesium/core/Indicator/Indicator.tsx +1 -1
- package/src/engines/Cesium/core/labels/JapanGSIOptimalBVmapVectorMapLabel/JapanGSIOptimalBVmapLabelImagery.tsx +1 -1
- package/src/engines/Cesium/hooks/useCamera.ts +1 -1
- package/src/engines/Cesium/hooks/useCameraLimiter.ts +1 -1
- package/src/engines/Cesium/hooks/useEngineRef.ts +2 -2
- package/src/engines/Cesium/hooks/useExplicitRender.ts +2 -2
- package/src/engines/Cesium/hooks/useInstance.ts +1 -1
- package/src/engines/Cesium/hooks/useLayerDragDrop.ts +2 -2
- package/src/engines/Cesium/hooks/useLayerSelectWithRect.ts +1 -1
- package/src/engines/Cesium/hooks/useOverrideGlobeShader/useOverrideGlobeShader.ts +2 -2
- package/src/engines/Cesium/hooks/useViewerProperty.ts +1 -1
- package/src/engines/Cesium/hooks.ts +7 -6
- package/src/mantle/atoms/compute.ts +3 -2
- package/src/mantle/data/shapefile/parseZip.ts +1 -0
- package/src/mantle/types/appearance.ts +8 -8
- package/src/test/utils.tsx +1 -1
- package/src/utils/image.ts +1 -1
- package/src/utils/use-delayed-count.ts +1 -1
- package/src/utils/use-dnd/drop.ts +1 -1
- package/src/utils/util.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6,11 +6,11 @@ import { CSSProperties } from 'react';
|
|
|
6
6
|
import { Feature as Feature_2 } from 'geojson';
|
|
7
7
|
import { ForwardRefExoticComponent } from 'react';
|
|
8
8
|
import { LineString } from 'geojson';
|
|
9
|
-
import { MemoExoticComponent } from 'react';
|
|
10
9
|
import { MultiLineString } from 'geojson';
|
|
11
10
|
import { MultiPoint } from 'geojson';
|
|
12
11
|
import { MultiPolygon } from 'geojson';
|
|
13
12
|
import { MutableRefObject } from 'react';
|
|
13
|
+
import { NamedExoticComponent } from 'react';
|
|
14
14
|
import { Point } from 'geojson';
|
|
15
15
|
import { Polygon as Polygon_2 } from 'geojson';
|
|
16
16
|
import { PropsWithoutRef } from 'react';
|
|
@@ -335,9 +335,9 @@ declare type CoreContext = {
|
|
|
335
335
|
|
|
336
336
|
export declare const coreContext: Context<CoreContext>;
|
|
337
337
|
|
|
338
|
-
export declare const CoreVisualizer:
|
|
338
|
+
export declare const CoreVisualizer: NamedExoticComponent<CoreVisualizerProps & {
|
|
339
339
|
children?: ReactNode;
|
|
340
|
-
} & RefAttributes<MapRef
|
|
340
|
+
} & RefAttributes<MapRef>>;
|
|
341
341
|
|
|
342
342
|
export declare type CoreVisualizerProps = {
|
|
343
343
|
engine?: EngineType;
|
|
@@ -512,7 +512,7 @@ export declare type EngineProps = {
|
|
|
512
512
|
shouldRender?: boolean;
|
|
513
513
|
meta?: Record<string, unknown>;
|
|
514
514
|
displayCredits?: boolean;
|
|
515
|
-
layersRef?: RefObject<LayersRef>;
|
|
515
|
+
layersRef?: RefObject<LayersRef | null>;
|
|
516
516
|
requestingRenderMode?: MutableRefObject<RequestingRenderMode>;
|
|
517
517
|
timelineManagerRef?: TimelineManagerRef;
|
|
518
518
|
onLayerSelect?: (layerId: string | undefined, featureId?: string, options?: LayerSelectionReason, info?: SelectedFeatureInfo) => void;
|
|
@@ -603,7 +603,7 @@ export declare type EngineRef = {
|
|
|
603
603
|
tick: () => Date | void;
|
|
604
604
|
inViewport: (location?: LatLng) => boolean;
|
|
605
605
|
onTick: TickEvent;
|
|
606
|
-
tickEventCallback?: RefObject<TickEventCallback[]>;
|
|
606
|
+
tickEventCallback?: RefObject<TickEventCallback[] | null>;
|
|
607
607
|
removeTickEventListener: TickEvent;
|
|
608
608
|
findFeatureById: (layerId: string, featureId: string) => Feature | undefined;
|
|
609
609
|
bringToFront: (layerId: string) => void;
|
|
@@ -1367,7 +1367,7 @@ declare type Props_2 = Omit<Props_3, "atomMap" | "isHidden" | "selectedLayerId">
|
|
|
1367
1367
|
hiddenLayers?: string[];
|
|
1368
1368
|
viewerProperty?: ViewerProperty;
|
|
1369
1369
|
requestingRenderMode?: MutableRefObject<RequestingRenderMode>;
|
|
1370
|
-
engineRef?: RefObject<EngineRef>;
|
|
1370
|
+
engineRef?: RefObject<EngineRef | null>;
|
|
1371
1371
|
onLayerSelect?: (layerId: string | undefined, featureId: string | undefined, layer: (() => Promise<ComputedLayer | undefined>) | undefined, reason: LayerSelectionReason | undefined, info: SelectedFeatureInfo | undefined) => void;
|
|
1372
1372
|
onMount?: () => void;
|
|
1373
1373
|
};
|
|
@@ -1551,8 +1551,8 @@ export declare type SketchOptions = {
|
|
|
1551
1551
|
};
|
|
1552
1552
|
|
|
1553
1553
|
export declare type SketchProps = {
|
|
1554
|
-
layersRef: RefObject<LayersRef>;
|
|
1555
|
-
engineRef: RefObject<EngineRef>;
|
|
1554
|
+
layersRef: RefObject<LayersRef | null>;
|
|
1555
|
+
engineRef: RefObject<EngineRef | null>;
|
|
1556
1556
|
SketchComponent?: SketchComponentType;
|
|
1557
1557
|
selectedFeature?: Feature;
|
|
1558
1558
|
interactionMode?: InteractionModeType;
|
|
@@ -1791,7 +1791,7 @@ export declare type Undefinable<T extends object> = {
|
|
|
1791
1791
|
|
|
1792
1792
|
export declare function useGet<T>(value: T): () => T;
|
|
1793
1793
|
|
|
1794
|
-
export declare const useVisualizer: () => RefObject<MapRef>;
|
|
1794
|
+
export declare const useVisualizer: () => RefObject<MapRef | null>;
|
|
1795
1795
|
|
|
1796
1796
|
export declare type ValueType = keyof ValueTypes;
|
|
1797
1797
|
|
|
@@ -1836,7 +1836,7 @@ export declare type Viewport = {
|
|
|
1836
1836
|
query: Record<string, string>;
|
|
1837
1837
|
};
|
|
1838
1838
|
|
|
1839
|
-
export declare type VisualizerContext = RefObject<MapRef>;
|
|
1839
|
+
export declare type VisualizerContext = RefObject<MapRef | null>;
|
|
1840
1840
|
|
|
1841
1841
|
export declare type WrappedRef<T> = {
|
|
1842
1842
|
[P in keyof T as T[P] extends (...args: any[]) => any ? P : never]: T[P] extends (...args: infer A) => infer R ? (...args: A) => R | undefined : never;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reearth/core",
|
|
3
|
-
"version": "0.0.7-alpha.
|
|
3
|
+
"version": "0.0.7-alpha.50",
|
|
4
4
|
"author": "Re:Earth contributors <community@reearth.io>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "A library that abstracts a map engine as one common API.",
|
|
@@ -29,26 +29,26 @@
|
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"cesium": "1.118.x",
|
|
32
|
-
"react": "^
|
|
33
|
-
"react-dom": "^
|
|
32
|
+
"react": "^19.0.0",
|
|
33
|
+
"react-dom": "^19.0.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@radix-ui/react-checkbox": "1.
|
|
37
|
-
"@radix-ui/react-dialog": "1.1.
|
|
38
|
-
"@radix-ui/react-icons": "1.3.
|
|
39
|
-
"@radix-ui/react-select": "2.
|
|
40
|
-
"@radix-ui/react-separator": "1.1.
|
|
41
|
-
"@radix-ui/react-slider": "1.
|
|
42
|
-
"@radix-ui/react-slot": "1.
|
|
43
|
-
"@radix-ui/react-switch": "1.
|
|
44
|
-
"@radix-ui/react-toggle": "1.1.
|
|
36
|
+
"@radix-ui/react-checkbox": "1.3.3",
|
|
37
|
+
"@radix-ui/react-dialog": "1.1.15",
|
|
38
|
+
"@radix-ui/react-icons": "1.3.2",
|
|
39
|
+
"@radix-ui/react-select": "2.2.6",
|
|
40
|
+
"@radix-ui/react-separator": "1.1.8",
|
|
41
|
+
"@radix-ui/react-slider": "1.3.6",
|
|
42
|
+
"@radix-ui/react-slot": "1.2.4",
|
|
43
|
+
"@radix-ui/react-switch": "1.2.6",
|
|
44
|
+
"@radix-ui/react-toggle": "1.1.10",
|
|
45
45
|
"@reearth/cesium-mvt-imagery-provider": "1.6.1",
|
|
46
46
|
"@reearth/spatial-id-sdk": "0.0.0",
|
|
47
47
|
"@rot1024/use-transition": "1.0.0",
|
|
48
48
|
"@seznam/compose-react-refs": "1.0.6",
|
|
49
49
|
"@turf/invariant": "6.5.0",
|
|
50
50
|
"@turf/turf": "6.5.0",
|
|
51
|
-
"@types/proj4": "2.5.
|
|
51
|
+
"@types/proj4": "2.5.6",
|
|
52
52
|
"@ungap/event-target": "0.2.4",
|
|
53
53
|
"@xstate/react": "3.2.1",
|
|
54
54
|
"cesium-dnd": "1.1.0",
|
|
@@ -59,27 +59,27 @@
|
|
|
59
59
|
"geojson": "0.5.0",
|
|
60
60
|
"jotai": "1.12.1",
|
|
61
61
|
"js-md5": "0.7.3",
|
|
62
|
-
"jsep": "1.
|
|
62
|
+
"jsep": "1.4.0",
|
|
63
63
|
"jsonpath-plus": "10.3.0",
|
|
64
64
|
"jszip": "3.10.1",
|
|
65
65
|
"lodash-es": "4.17.21",
|
|
66
66
|
"lru-cache": "8.0.4",
|
|
67
67
|
"pbf": "3.2.1",
|
|
68
|
-
"proj4": "2.
|
|
68
|
+
"proj4": "2.20.2",
|
|
69
69
|
"protomaps": "1.23.1",
|
|
70
70
|
"react-dnd": "16.0.1",
|
|
71
71
|
"react-dnd-html5-backend": "16.0.1",
|
|
72
72
|
"react-error-boundary": "4.0.11",
|
|
73
73
|
"react-nl2br": "1.0.4",
|
|
74
|
-
"react-use": "17.
|
|
75
|
-
"resium": "1.18.
|
|
74
|
+
"react-use": "17.6.0",
|
|
75
|
+
"resium": "1.18.4",
|
|
76
76
|
"suspend-react": "0.1.3",
|
|
77
77
|
"tailwind-merge": "2.5.2",
|
|
78
78
|
"tailwindcss": "3.4.10",
|
|
79
79
|
"tailwindcss-animate": "1.0.7",
|
|
80
80
|
"tiny-invariant": "1.3.3",
|
|
81
|
-
"use-callback-ref": "1.3.
|
|
82
|
-
"use-custom-compare": "1.
|
|
81
|
+
"use-callback-ref": "1.3.3",
|
|
82
|
+
"use-custom-compare": "1.5.0",
|
|
83
83
|
"uuid": "9.0.1",
|
|
84
84
|
"xstate": "4.38.2"
|
|
85
85
|
},
|
|
@@ -87,55 +87,51 @@
|
|
|
87
87
|
"@apollo/client": "3.8.1",
|
|
88
88
|
"@chromatic-com/storybook": "^1.3.3",
|
|
89
89
|
"@emotion/jest": "11.11.0",
|
|
90
|
-
"@storybook/addon-essentials": "8.
|
|
91
|
-
"@storybook/addon-interactions": "8.
|
|
92
|
-
"@storybook/addon-links": "8.
|
|
93
|
-
"@storybook/addon-onboarding": "8.
|
|
94
|
-
"@storybook/blocks": "8.
|
|
95
|
-
"@storybook/react": "8.
|
|
96
|
-
"@storybook/react-vite": "8.
|
|
97
|
-
"@storybook/test": "8.
|
|
90
|
+
"@storybook/addon-essentials": "8.4.7",
|
|
91
|
+
"@storybook/addon-interactions": "8.4.7",
|
|
92
|
+
"@storybook/addon-links": "8.4.7",
|
|
93
|
+
"@storybook/addon-onboarding": "8.4.7",
|
|
94
|
+
"@storybook/blocks": "8.4.7",
|
|
95
|
+
"@storybook/react": "8.4.7",
|
|
96
|
+
"@storybook/react-vite": "8.4.7",
|
|
97
|
+
"@storybook/test": "8.4.7",
|
|
98
98
|
"@testing-library/jest-dom": "6.1.4",
|
|
99
99
|
"@testing-library/react": "14.0.0",
|
|
100
100
|
"@types/d3": "7.4.3",
|
|
101
|
-
"@types/geojson": "7946.0.
|
|
102
|
-
"@types/js-md5": "0.
|
|
101
|
+
"@types/geojson": "7946.0.16",
|
|
102
|
+
"@types/js-md5": "0.8.0",
|
|
103
103
|
"@types/lodash-es": "4.17.12",
|
|
104
|
-
"@types/node": "20.
|
|
104
|
+
"@types/node": "20.17.15",
|
|
105
105
|
"@types/pbf": "3.0.5",
|
|
106
|
-
"@types/react": "
|
|
107
|
-
"@types/react-dom": "
|
|
106
|
+
"@types/react": "19.0.0",
|
|
107
|
+
"@types/react-dom": "19.0.0",
|
|
108
108
|
"@types/scheduler": "0.23.0",
|
|
109
109
|
"@types/uuid": "9.0.8",
|
|
110
|
-
"@typescript-eslint/eslint-plugin": "7.2.0",
|
|
111
|
-
"@typescript-eslint/parser": "7.2.0",
|
|
112
110
|
"@vitejs/plugin-react": "4.2.1",
|
|
113
111
|
"@xstate/cli": "0.5.17",
|
|
114
|
-
"autoprefixer": "10.4.
|
|
112
|
+
"autoprefixer": "10.4.22",
|
|
115
113
|
"cesium": "1.118.0",
|
|
116
|
-
"class-variance-authority": "0.7.
|
|
114
|
+
"class-variance-authority": "0.7.1",
|
|
117
115
|
"clsx": "2.1.1",
|
|
118
116
|
"eslint": "8.57.0",
|
|
119
117
|
"eslint-config-reearth": "0.3.0",
|
|
120
|
-
"eslint-plugin-react-hooks": "4.6.0",
|
|
121
|
-
"eslint-plugin-react-refresh": "0.4.6",
|
|
122
118
|
"eslint-plugin-storybook": "0.8.0",
|
|
123
119
|
"jsdom": "22.1.0",
|
|
124
|
-
"postcss": "8.
|
|
125
|
-
"prettier": "3.
|
|
126
|
-
"react": "
|
|
127
|
-
"react-dom": "
|
|
128
|
-
"storybook": "8.
|
|
120
|
+
"postcss": "8.5.6",
|
|
121
|
+
"prettier": "3.1.0",
|
|
122
|
+
"react": "19.0.0",
|
|
123
|
+
"react-dom": "19.0.0",
|
|
124
|
+
"storybook": "8.4.7",
|
|
129
125
|
"typescript": "5.2.2",
|
|
130
126
|
"vite": "5.0.8",
|
|
131
127
|
"vite-plugin-cesium": "1.2.23",
|
|
132
128
|
"vite-plugin-dts": "3.8.1",
|
|
133
|
-
"vite-plugin-svgr": "4.
|
|
129
|
+
"vite-plugin-svgr": "4.5.0",
|
|
134
130
|
"vite-tsconfig-paths": "^4.3.2",
|
|
135
131
|
"vitest": "1.0.4",
|
|
136
132
|
"web-streams-polyfill": "3.2.1"
|
|
137
133
|
},
|
|
138
134
|
"resolutions": {
|
|
139
|
-
"jackspeak": "
|
|
135
|
+
"jackspeak": "3.1.2"
|
|
140
136
|
}
|
|
141
137
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentType, useMemo, useCallback, ReactNode } from "react";
|
|
1
|
+
import { ComponentType, useMemo, useCallback, ReactNode, type JSX } from "react";
|
|
2
2
|
|
|
3
3
|
import LayerComponent, { type CommonProps, type Props as LayerProps } from "../Layer";
|
|
4
4
|
import type { Layer, Atom, Typography, DataType, ViewerProperty } from "../types";
|
package/src/Map/Layer/hooks.ts
CHANGED
|
@@ -90,7 +90,7 @@ export default function useHooks({
|
|
|
90
90
|
});
|
|
91
91
|
}, [layer, set]);
|
|
92
92
|
|
|
93
|
-
const intervalId = useRef<number>();
|
|
93
|
+
const intervalId = useRef<number>(undefined);
|
|
94
94
|
useLayoutEffect(() => {
|
|
95
95
|
const data = layer?.type === "simple" ? layer.data : undefined;
|
|
96
96
|
|
|
@@ -107,7 +107,7 @@ export default function useHooks({
|
|
|
107
107
|
};
|
|
108
108
|
}, [layer, forceUpdateFeatures]);
|
|
109
109
|
|
|
110
|
-
const prevForceUpdatableData = useRef<Pick<Data, "csv" | "jsonProperties" | "value">>();
|
|
110
|
+
const prevForceUpdatableData = useRef<Pick<Data, "csv" | "jsonProperties" | "value">>(undefined);
|
|
111
111
|
useLayoutEffect(() => {
|
|
112
112
|
const data = layer?.type === "simple" ? layer.data : undefined;
|
|
113
113
|
const forceUpdatableData = pick(data, "csv", "jsonProperties", "value");
|
package/src/Map/Layer/index.tsx
CHANGED
package/src/Map/Layers/hooks.ts
CHANGED
|
@@ -139,7 +139,7 @@ export default function useHooks({
|
|
|
139
139
|
reason: LayerSelectionReason | undefined,
|
|
140
140
|
info: SelectedFeatureInfo | undefined,
|
|
141
141
|
) => void;
|
|
142
|
-
engineRef?: RefObject<EngineRef>;
|
|
142
|
+
engineRef?: RefObject<EngineRef | null>;
|
|
143
143
|
onMount?: () => void;
|
|
144
144
|
}) {
|
|
145
145
|
const layerMap = useMemo(() => new Map<string, Layer>(), []);
|
|
@@ -751,7 +751,7 @@ function useSelection({
|
|
|
751
751
|
reason: LayerSelectionReason | undefined,
|
|
752
752
|
info: SelectedFeatureInfo | undefined,
|
|
753
753
|
) => void;
|
|
754
|
-
engineRef?: RefObject<EngineRef>;
|
|
754
|
+
engineRef?: RefObject<EngineRef | null>;
|
|
755
755
|
updateStyle: (layerId: string) => void;
|
|
756
756
|
}) {
|
|
757
757
|
const [selectedLayer, selectedComputedFeature]: SelectedLayer = useMemo(
|
package/src/Map/Layers/index.tsx
CHANGED
|
@@ -38,7 +38,7 @@ export type Props = Omit<ClusteredLayerProps, "atomMap" | "isHidden" | "selected
|
|
|
38
38
|
hiddenLayers?: string[];
|
|
39
39
|
viewerProperty?: ViewerProperty;
|
|
40
40
|
requestingRenderMode?: MutableRefObject<RequestingRenderMode>;
|
|
41
|
-
engineRef?: RefObject<EngineRef>;
|
|
41
|
+
engineRef?: RefObject<EngineRef | null>;
|
|
42
42
|
onLayerSelect?: (
|
|
43
43
|
layerId: string | undefined,
|
|
44
44
|
featureId: string | undefined,
|
package/src/Map/Sketch/hooks.ts
CHANGED
|
@@ -44,8 +44,8 @@ export type SketchFeatureCallback = (
|
|
|
44
44
|
|
|
45
45
|
type Props = {
|
|
46
46
|
ref: ForwardedRef<SketchRef>;
|
|
47
|
-
layersRef: RefObject<LayersRef>;
|
|
48
|
-
engineRef: RefObject<EngineRef>;
|
|
47
|
+
layersRef: RefObject<LayersRef | null>;
|
|
48
|
+
engineRef: RefObject<EngineRef | null>;
|
|
49
49
|
interactionMode: InteractionModeType;
|
|
50
50
|
selectedFeature?: Feature;
|
|
51
51
|
overrideInteractionMode?: (mode: InteractionModeType) => void;
|
|
@@ -131,7 +131,7 @@ export default function ({
|
|
|
131
131
|
|
|
132
132
|
const [selectedControlPointIndex, setSelectedControlPointIndex] = useState<number | undefined>();
|
|
133
133
|
const markerGeometryRef = useRef<GeometryOptionsXYZ | null>(null);
|
|
134
|
-
const pointerLocationRef = useRef<[lng: number, lat: number, height: number]>();
|
|
134
|
+
const pointerLocationRef = useRef<[lng: number, lat: number, height: number]>(undefined);
|
|
135
135
|
|
|
136
136
|
const isEditing = useMemo(() => state.matches("editing"), [state]);
|
|
137
137
|
|
|
@@ -643,7 +643,7 @@ export default function ({
|
|
|
643
643
|
|
|
644
644
|
async function getCentroid(
|
|
645
645
|
controlPoints: readonly Position3d[],
|
|
646
|
-
engineRef: RefObject<EngineRef>,
|
|
646
|
+
engineRef: RefObject<EngineRef | null>,
|
|
647
647
|
): Promise<Position3d | undefined> {
|
|
648
648
|
let totalLat = 0;
|
|
649
649
|
let totalLng = 0;
|
package/src/Map/Sketch/index.tsx
CHANGED
|
@@ -26,8 +26,8 @@ export type OnLayerSelectType = (
|
|
|
26
26
|
) => void;
|
|
27
27
|
|
|
28
28
|
export type SketchProps = {
|
|
29
|
-
layersRef: RefObject<LayersRef>;
|
|
30
|
-
engineRef: RefObject<EngineRef>;
|
|
29
|
+
layersRef: RefObject<LayersRef | null>;
|
|
30
|
+
engineRef: RefObject<EngineRef | null>;
|
|
31
31
|
SketchComponent?: SketchComponentType;
|
|
32
32
|
selectedFeature?: Feature;
|
|
33
33
|
interactionMode?: InteractionModeType;
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
type Props = {
|
|
20
20
|
state: sketchState;
|
|
21
21
|
send: SketchInterpreter["send"];
|
|
22
|
-
engineRef: RefObject<EngineRef>;
|
|
22
|
+
engineRef: RefObject<EngineRef | null>;
|
|
23
23
|
disableInteraction: boolean;
|
|
24
24
|
type: SketchType | undefined;
|
|
25
25
|
updateType: Dispatch<SetStateAction<SketchType | undefined>>;
|
|
@@ -11,7 +11,7 @@ type Props = {
|
|
|
11
11
|
sketchOptions: SketchOptions;
|
|
12
12
|
from: "editor" | "plugin";
|
|
13
13
|
updateType: Dispatch<SetStateAction<SketchType | undefined>>;
|
|
14
|
-
layersRef: RefObject<LayersRef>;
|
|
14
|
+
layersRef: RefObject<LayersRef | null>;
|
|
15
15
|
pluginSketchLayerCreate: (feature: SketchFeature) => {
|
|
16
16
|
layerId: string | undefined;
|
|
17
17
|
featureId: string;
|
|
@@ -29,8 +29,8 @@ import { createSpatialIdSpace, getSpaceData, getVerticalLimits } from "./utils";
|
|
|
29
29
|
|
|
30
30
|
type Props = {
|
|
31
31
|
ref: ForwardedRef<SpatialIdRef>;
|
|
32
|
-
engineRef: RefObject<EngineRef>;
|
|
33
|
-
geoidRef: RefObject<GeoidRef>;
|
|
32
|
+
engineRef: RefObject<EngineRef | null>;
|
|
33
|
+
geoidRef: RefObject<GeoidRef | null>;
|
|
34
34
|
terrainEnabled?: boolean;
|
|
35
35
|
interactionMode?: InteractionModeType;
|
|
36
36
|
overrideInteractionMode?: (mode: InteractionModeType) => void;
|
|
@@ -13,8 +13,8 @@ import useHooks from "./hooks";
|
|
|
13
13
|
import { SpatialIdRef } from "./types";
|
|
14
14
|
|
|
15
15
|
type SpatialIdProps = {
|
|
16
|
-
engineRef: RefObject<EngineRef>;
|
|
17
|
-
geoidRef: RefObject<GeoidRef>;
|
|
16
|
+
engineRef: RefObject<EngineRef | null>;
|
|
17
|
+
geoidRef: RefObject<GeoidRef | null>;
|
|
18
18
|
terrainEnabled?: boolean;
|
|
19
19
|
interactionMode?: InteractionModeType;
|
|
20
20
|
overrideInteractionMode?: (mode: InteractionModeType) => void;
|
package/src/Map/index.tsx
CHANGED
package/src/Map/ref.ts
CHANGED
|
@@ -155,11 +155,11 @@ export function mapRef({
|
|
|
155
155
|
geoidRef,
|
|
156
156
|
timelineManagerRef,
|
|
157
157
|
}: {
|
|
158
|
-
engineRef: RefObject<EngineRef>;
|
|
159
|
-
layersRef: RefObject<LayersRef>;
|
|
160
|
-
sketchRef: RefObject<SketchRef>;
|
|
161
|
-
spatialIdRef: RefObject<SpatialIdRef>;
|
|
162
|
-
geoidRef: RefObject<GeoidRef>;
|
|
158
|
+
engineRef: RefObject<EngineRef | null>;
|
|
159
|
+
layersRef: RefObject<LayersRef | null>;
|
|
160
|
+
sketchRef: RefObject<SketchRef | null>;
|
|
161
|
+
spatialIdRef: RefObject<SpatialIdRef | null>;
|
|
162
|
+
geoidRef: RefObject<GeoidRef | null>;
|
|
163
163
|
timelineManagerRef?: TimelineManagerRef;
|
|
164
164
|
}): MapRef {
|
|
165
165
|
return {
|
package/src/Map/types/index.ts
CHANGED
|
@@ -187,7 +187,7 @@ export type EngineRef = {
|
|
|
187
187
|
tick: () => Date | void;
|
|
188
188
|
inViewport: (location?: LatLng) => boolean;
|
|
189
189
|
onTick: TickEvent;
|
|
190
|
-
tickEventCallback?: RefObject<TickEventCallback[]>;
|
|
190
|
+
tickEventCallback?: RefObject<TickEventCallback[] | null>;
|
|
191
191
|
removeTickEventListener: TickEvent;
|
|
192
192
|
findFeatureById: (layerId: string, featureId: string) => Feature | undefined;
|
|
193
193
|
bringToFront: (layerId: string) => void;
|
|
@@ -238,7 +238,7 @@ export type EngineProps = {
|
|
|
238
238
|
shouldRender?: boolean;
|
|
239
239
|
meta?: Record<string, unknown>;
|
|
240
240
|
displayCredits?: boolean;
|
|
241
|
-
layersRef?: RefObject<LayersRef>;
|
|
241
|
+
layersRef?: RefObject<LayersRef | null>;
|
|
242
242
|
requestingRenderMode?: MutableRefObject<RequestingRenderMode>;
|
|
243
243
|
timelineManagerRef?: TimelineManagerRef;
|
|
244
244
|
onLayerSelect?: (
|
package/src/Map/utils.ts
CHANGED
|
@@ -6,7 +6,7 @@ export function useGet<T>(value: T): () => T {
|
|
|
6
6
|
return useCallback(() => ref.current, []);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export function wrapRef<T>(ref: RefObject<T>, keys: FunctionKeys<T>): WrappedRef<T> {
|
|
9
|
+
export function wrapRef<T>(ref: RefObject<T | null>, keys: FunctionKeys<T>): WrappedRef<T> {
|
|
10
10
|
return Object.fromEntries(
|
|
11
11
|
(Object.keys(keys) as (keyof T)[]).map(k => {
|
|
12
12
|
return [k, (...args: any[]) => (ref.current?.[k] as any)?.(...args)];
|
|
@@ -2,11 +2,11 @@ import { FC, PropsWithChildren, RefObject, createContext, useContext, useMemo }
|
|
|
2
2
|
|
|
3
3
|
import { MapRef } from "../Map";
|
|
4
4
|
|
|
5
|
-
const context = createContext<RefObject<MapRef> | undefined>(undefined);
|
|
5
|
+
const context = createContext<RefObject<MapRef | null> | undefined>(undefined);
|
|
6
6
|
|
|
7
|
-
export type Context = RefObject<MapRef>;
|
|
7
|
+
export type Context = RefObject<MapRef | null>;
|
|
8
8
|
|
|
9
|
-
export const useVisualizer = (): RefObject<MapRef> => {
|
|
9
|
+
export const useVisualizer = (): RefObject<MapRef | null> => {
|
|
10
10
|
const value = useContext(context);
|
|
11
11
|
if (!value) {
|
|
12
12
|
throw new Error("Visualizer is not declared. You have to use this hook inside of Visualizer");
|
|
@@ -14,11 +14,11 @@ export const useVisualizer = (): RefObject<MapRef> => {
|
|
|
14
14
|
return value;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
const filterMapRefToContext = (mapRef: RefObject<MapRef>): Context => {
|
|
17
|
+
const filterMapRefToContext = (mapRef: RefObject<MapRef | null>): Context => {
|
|
18
18
|
return mapRef as Context;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
export const VisualizerProvider: FC<PropsWithChildren<{ mapRef: RefObject<MapRef> }>> = ({
|
|
21
|
+
export const VisualizerProvider: FC<PropsWithChildren<{ mapRef: RefObject<MapRef | null> }>> = ({
|
|
22
22
|
mapRef,
|
|
23
23
|
children,
|
|
24
24
|
}) => {
|
package/src/Visualizer/hooks.ts
CHANGED
|
@@ -55,7 +55,7 @@ export default function useHooks(
|
|
|
55
55
|
) {
|
|
56
56
|
const mapRef = useRef<MapRef>(null);
|
|
57
57
|
|
|
58
|
-
useImperativeHandle(ref, () => mapRef.current, []);
|
|
58
|
+
useImperativeHandle(ref, () => mapRef.current as MapRef, []);
|
|
59
59
|
|
|
60
60
|
const wrapperRef = useRef<HTMLDivElement>(null);
|
|
61
61
|
|
|
@@ -119,7 +119,7 @@ export default function useHooks(
|
|
|
119
119
|
[selectedLayer, onLayerSelect],
|
|
120
120
|
);
|
|
121
121
|
|
|
122
|
-
const timelineManagerRef: TimelineManagerRef = useRef();
|
|
122
|
+
const timelineManagerRef: TimelineManagerRef = useRef(undefined);
|
|
123
123
|
|
|
124
124
|
// camera
|
|
125
125
|
const [camera, changeCamera] = useValue(initialCamera, onCameraChange);
|
|
@@ -145,7 +145,7 @@ export default function useHooks(
|
|
|
145
145
|
const featureFlags = INTERACTION_MODES[interactionMode ?? "default"];
|
|
146
146
|
|
|
147
147
|
// layer edit
|
|
148
|
-
const onLayerEditRef = useRef<(e: LayerEditEvent) => void>();
|
|
148
|
+
const onLayerEditRef = useRef<(e: LayerEditEvent) => void>(undefined);
|
|
149
149
|
const onLayerEdit = useCallback((cb: (e: LayerEditEvent) => void) => {
|
|
150
150
|
onLayerEditRef.current = cb;
|
|
151
151
|
}, []);
|
|
@@ -154,7 +154,7 @@ export default function useHooks(
|
|
|
154
154
|
}, []);
|
|
155
155
|
|
|
156
156
|
// layer visiblity
|
|
157
|
-
const onLayerVisibilityRef = useRef<(e: LayerVisibilityEvent) => void>();
|
|
157
|
+
const onLayerVisibilityRef = useRef<(e: LayerVisibilityEvent) => void>(undefined);
|
|
158
158
|
const onLayerVisibility = useCallback((cb: (e: LayerVisibilityEvent) => void) => {
|
|
159
159
|
onLayerVisibilityRef.current = cb;
|
|
160
160
|
}, []);
|
|
@@ -163,7 +163,7 @@ export default function useHooks(
|
|
|
163
163
|
}, []);
|
|
164
164
|
|
|
165
165
|
// layer load
|
|
166
|
-
const onLayerLoadRef = useRef<(e: LayerLoadEvent) => void>();
|
|
166
|
+
const onLayerLoadRef = useRef<(e: LayerLoadEvent) => void>(undefined);
|
|
167
167
|
const onLayerLoad = useCallback((cb: (e: LayerLoadEvent) => void) => {
|
|
168
168
|
onLayerLoadRef.current = cb;
|
|
169
169
|
}, []);
|
|
@@ -172,21 +172,21 @@ export default function useHooks(
|
|
|
172
172
|
}, []);
|
|
173
173
|
|
|
174
174
|
// multiple feature selection
|
|
175
|
-
const onLayerSelectWithRectStartRef = useRef<(e: LayerSelectWithRectStart) => void>();
|
|
175
|
+
const onLayerSelectWithRectStartRef = useRef<(e: LayerSelectWithRectStart) => void>(undefined);
|
|
176
176
|
const onLayerSelectWithRectStart = useCallback((cb: (e: LayerSelectWithRectStart) => void) => {
|
|
177
177
|
onLayerSelectWithRectStartRef.current = cb;
|
|
178
178
|
}, []);
|
|
179
179
|
const handleLayerSelectWithRectStart = useCallback((e: LayerSelectWithRectStart) => {
|
|
180
180
|
onLayerSelectWithRectStartRef.current?.(e);
|
|
181
181
|
}, []);
|
|
182
|
-
const onLayerSelectWithRectMoveRef = useRef<(e: LayerSelectWithRectMove) => void>();
|
|
182
|
+
const onLayerSelectWithRectMoveRef = useRef<(e: LayerSelectWithRectMove) => void>(undefined);
|
|
183
183
|
const onLayerSelectWithRectMove = useCallback((cb: (e: LayerSelectWithRectMove) => void) => {
|
|
184
184
|
onLayerSelectWithRectMoveRef.current = cb;
|
|
185
185
|
}, []);
|
|
186
186
|
const handleLayerSelectWithRectMove = useCallback((e: LayerSelectWithRectMove) => {
|
|
187
187
|
onLayerSelectWithRectMoveRef.current?.(e);
|
|
188
188
|
}, []);
|
|
189
|
-
const onLayerSelectWithRectEndRef = useRef<(e: LayerSelectWithRectEnd) => void>();
|
|
189
|
+
const onLayerSelectWithRectEndRef = useRef<(e: LayerSelectWithRectEnd) => void>(undefined);
|
|
190
190
|
const onLayerSelectWithRectEnd = useCallback((cb: (e: LayerSelectWithRectEnd) => void) => {
|
|
191
191
|
onLayerSelectWithRectEndRef.current = cb;
|
|
192
192
|
}, []);
|
|
@@ -127,7 +127,7 @@ export const useHooks = ({
|
|
|
127
127
|
);
|
|
128
128
|
|
|
129
129
|
// ScalePoint event handlers
|
|
130
|
-
const currentPointIndex = useRef<number>();
|
|
130
|
+
const currentPointIndex = useRef<number>(undefined);
|
|
131
131
|
const handlePointMouseDown: PointEventCallback = useCallback(
|
|
132
132
|
(_, { index }) => {
|
|
133
133
|
if (!viewer) {
|
|
@@ -138,7 +138,7 @@ export const useHooks = ({
|
|
|
138
138
|
},
|
|
139
139
|
[viewer],
|
|
140
140
|
);
|
|
141
|
-
const prevMousePosition2dForPoint = useRef<Cartesian2>();
|
|
141
|
+
const prevMousePosition2dForPoint = useRef<Cartesian2>(undefined);
|
|
142
142
|
const handlePointMouseMove: PointEventCallback = useCallback(
|
|
143
143
|
(e, { position, oppositePosition, pointLocal, index, layerId }) => {
|
|
144
144
|
if (
|
|
@@ -282,7 +282,7 @@ export const useHooks = ({
|
|
|
282
282
|
}, [viewer]);
|
|
283
283
|
|
|
284
284
|
// Edge event handlers
|
|
285
|
-
const currentEdgeIndex = useRef<number>();
|
|
285
|
+
const currentEdgeIndex = useRef<number>(undefined);
|
|
286
286
|
const handleEdgeMouseDown: EdgeEventCallback = useCallback(
|
|
287
287
|
(_, { index }) => {
|
|
288
288
|
if (!viewer) {
|
|
@@ -293,7 +293,7 @@ export const useHooks = ({
|
|
|
293
293
|
},
|
|
294
294
|
[viewer],
|
|
295
295
|
);
|
|
296
|
-
const prevMouseXAxisForEdge = useRef<number>();
|
|
296
|
+
const prevMouseXAxisForEdge = useRef<number>(undefined);
|
|
297
297
|
const handleEdgeMouseMove: EdgeEventCallback = useCallback(
|
|
298
298
|
(e, { index, layerId }) => {
|
|
299
299
|
if (currentEdgeIndex.current !== index) {
|
|
@@ -62,7 +62,7 @@ export const HeatmapMesh = memo(
|
|
|
62
62
|
) => {
|
|
63
63
|
const { scene } = useCesium();
|
|
64
64
|
const groundPrimitives = scene?.groundPrimitives;
|
|
65
|
-
const primitiveRef = useRef<GroundPrimitive>();
|
|
65
|
+
const primitiveRef = useRef<GroundPrimitive>(undefined);
|
|
66
66
|
|
|
67
67
|
const material = useConstant(() =>
|
|
68
68
|
createHeatmapMeshMaterial({
|
|
@@ -34,7 +34,7 @@ export default function ({ isSelected, camera }: { isSelected?: boolean; camera?
|
|
|
34
34
|
cameraRef.current = camera;
|
|
35
35
|
const storytelling = useRef(false);
|
|
36
36
|
storytelling.current = selectionReason?.reason === "storytelling";
|
|
37
|
-
const prevCamera = useRef<Camera>();
|
|
37
|
+
const prevCamera = useRef<Camera>(undefined);
|
|
38
38
|
|
|
39
39
|
// camera flight
|
|
40
40
|
useEffect(() => {
|
|
@@ -120,7 +120,9 @@ export default function PhotoOverlay({
|
|
|
120
120
|
alignItems: "center",
|
|
121
121
|
transition:
|
|
122
122
|
photoOverlayImageTransiton === "entering" || photoOverlayImageTransiton === "exiting"
|
|
123
|
-
? `all ${
|
|
123
|
+
? `all ${
|
|
124
|
+
photoOverlayImageTransiton === "exiting" ? photoExitDuration : photoDuration
|
|
125
|
+
}s ease`
|
|
124
126
|
: undefined,
|
|
125
127
|
opacity:
|
|
126
128
|
photoOverlayImageTransiton === "entering" || photoOverlayImageTransiton === "entered"
|