Skip to content

Commit 93f83be

Browse files
committed
Works reasonably well but for some typescript errors
1 parent 3087488 commit 93f83be

File tree

15 files changed

+78
-47
lines changed

15 files changed

+78
-47
lines changed

packages/api-types/src/lithologies.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ export interface Lithology extends LithologyCore {
1515
group: string | null; // Group classification (e.g., unconsolidated)
1616
color: string; // Color code for visualization (e.g., hex color)
1717
fill?: string | number; // Optional fill value for visualization
18+
prop?: number | null; // Proportion of the lithology, if applicable.
1819
}

packages/data-sheet/src/postgrest-table/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,21 @@ import {
1616
import { Spec } from "immutability-helper";
1717
import { DataSheetProviderProps } from "../provider";
1818
import { PostgrestFilterBuilder } from "@supabase/postgrest-js";
19-
import { GenericSchema } from "@supabase/postgrest-js";
19+
import type {
20+
GenericFunction,
21+
GenericTable,
22+
GenericView,
23+
} from "@supabase/postgrest-js/dist/cjs/types";
2024

2125
const h = hyper.styled(styles);
2226

23-
interface PostgRESTTableViewProps<T extends GenericSchema>
27+
export type GenericSchema = {
28+
Tables: Record<string, GenericTable>;
29+
Views: Record<string, GenericView>;
30+
Functions: Record<string, GenericFunction>;
31+
};
32+
33+
interface PostgRESTTableViewProps<T extends object>
2434
extends DataSheetProviderProps<T> {
2535
endpoint: string;
2636
table: string;

packages/feedback-components/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"@blueprintjs/core": "^5.10.2",
3737
"@blueprintjs/select": "^5.3.10",
3838
"@macrostrat/color-utils": "workspace:^",
39+
"@macrostrat/data-sheet": "workspace:^",
3940
"@macrostrat/hyper": "^3.0.6",
4041
"@macrostrat/ui-components": "workspace:^",
4142
"@xyflow/react": "^12.3.6",

packages/feedback-components/src/feedback/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import useElementDimensions from "use-element-dimensions";
3636
import { GraphView } from "./graph";
3737
import { useInDarkMode } from "@macrostrat/ui-components";
3838
import { asChromaColor } from "@macrostrat/color-utils";
39-
import { getIconImage } from "@macrostrat/map-styles";
4039
import { ColorPicker } from "@macrostrat/data-sheet";
4140

4241
export type { GraphData } from "./edit-state";

packages/feedback-components/src/feedback/text-visualizer.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import { AnnotateBlendTag, TextAnnotateBlend } from "react-text-annotate-blend";
1+
import { AnnotateBlendTag } from "react-text-annotate-blend";
22
import { InternalEntity } from "./types";
33
import { TreeDispatch } from "./edit-state";
44
import styles from "./feedback.module.sass";
55
import hyper from "@macrostrat/hyper";
66
import { buildHighlights, getTagStyle } from "../extractions";
77
import { Highlight } from "../extractions/types";
8-
import { useCallback, useEffect, useRef } from "react";
9-
import { Tag, TagField } from "@macrostrat/data-components";
10-
import { columnGeoJSONRecordToColumnIdentifier } from "packages/column-views/src/correlation-chart/prepare-data";
8+
import { useEffect, useRef } from "react";
119

1210
const h = hyper.styled(styles);
1311

packages/map-interface/src/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ export function MapMovedReporter({ onMapMoved = null }) {
115115

116116
interface MapLoadingReporterProps {
117117
ignoredSources?: string[];
118-
onMapLoading?: (evt: mapboxgl.EventData) => void;
119-
onMapIdle?: (evt: mapboxgl.EventData) => void;
118+
onMapLoading?: (evt: mapboxgl.MapEvent) => void;
119+
onMapIdle?: (evt: mapboxgl.MapEvent) => void;
120120
mapIsLoading?: boolean;
121121
}
122122

packages/map-interface/src/map-view.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ function defaultInitializeMap(container, args: MapboxOptionsExt = {}) {
7373
logoPosition: "bottom-left",
7474
trackResize: true,
7575
antialias: true,
76+
// This is a legacy option for Mapbox GL v2
77+
// @ts-ignore
7678
optimizeForTerrain: true,
7779
...rest,
7880
});

packages/map-styles/src/layer-helpers/cross-sections.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { getCSSVariable } from "@macrostrat/color-utils";
2-
import type { AnyLayer } from "mapbox-gl";
2+
import type { LayerSpecification, CircleLayerSpecification } from "mapbox-gl";
33

4-
export function buildCrossSectionLayers(): AnyLayer[] {
4+
export function buildCrossSectionLayers(): LayerSpecification[] {
55
/** Build standardized layers for cross-sections */
66
const ruleColor = getCSSVariable(
77
"--panel-background-color",
@@ -50,7 +50,9 @@ export function buildCrossSectionLayers(): AnyLayer[] {
5050
id: "crossSectionEndpoint",
5151
type: "circle",
5252
source: "crossSectionEndpoints",
53-
paint: crossSectionPointPaint,
53+
paint: crossSectionPointPaint as Partial<
54+
CircleLayerSpecification["paint"]
55+
>,
5456
},
5557
{
5658
id: "elevationMarker",
@@ -59,7 +61,7 @@ export function buildCrossSectionLayers(): AnyLayer[] {
5961
paint: {
6062
...crossSectionPointPaint,
6163
"circle-color": "#4bc0c0",
62-
},
64+
} as Partial<CircleLayerSpecification["paint"]>,
6365
},
6466
];
6567
}

packages/mapbox-react/src/controls.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import h from "@macrostrat/hyper";
22
import Base from "mapbox-gl-controls/lib/Base/Base";
33
import Button from "mapbox-gl-controls/lib/Button/Button";
4-
import {
5-
CompassControl as _CompassControl,
6-
ZoomControl as _ZoomControl,
7-
} from "mapbox-gl-controls";
4+
import { ZoomControl as _ZoomControl } from "mapbox-gl-controls";
85
import { Icon } from "@blueprintjs/core";
96
import { useRef, useEffect, useState } from "react";
107
import classNames from "classnames";
118
import { useMapElement, useMapRef } from "./context";
12-
import { NavigationControl, Control } from "mapbox-gl";
9+
import { NavigationControl } from "mapbox-gl";
1310

1411
export function MapControlWrapper({ className, control, options = {} }) {
1512
/** A wrapper for using Mapbox GL controls with a Mapbox GL map */

packages/mapbox-react/src/focus-state.ts

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
11
/* Reporters and buttons for evaluating a feature's focus on the map. */
22
import { Intent, Button } from "@blueprintjs/core";
3-
import { useMapInitialized, useMapRef, useMapStatus } from "./context";
3+
import { useMapInitialized, useMapRef } from "./context";
44
import classNames from "classnames";
55
import { useState, useRef, useEffect } from "react";
66
import bbox from "@turf/bbox";
77
import styles from "./main.module.scss";
88
import hyper from "@macrostrat/hyper";
99

10-
import mapboxgl, {
10+
import type GeoJSON from "geojson";
11+
import type {
1112
LngLatBoundsLike,
1213
LngLatLike,
1314
PaddingOptions,
14-
FlyToOptions,
15+
AnimationOptions,
16+
CameraOptions,
17+
Map,
1518
} from "mapbox-gl";
1619

20+
/**
21+
* FlyToOptions
22+
* For some reason, we have to shadow the mapboxgl.FlyToOptions type
23+
* */
24+
export interface FlyToOptions extends AnimationOptions, CameraOptions {
25+
curve?: number | undefined;
26+
minZoom?: number | undefined;
27+
speed?: number | undefined;
28+
screenSpeed?: number | undefined;
29+
maxDuration?: number | undefined;
30+
}
31+
1732
const h = hyper.styled(styles);
1833

1934
export enum PositionFocusState {
@@ -69,7 +84,7 @@ export function useMapEaseToCenter(position, padding) {
6984
);
7085
const map = mapRef.current;
7186
if (map == null) return;
72-
let opts: mapboxgl.FlyToOptions = null;
87+
let opts: FlyToOptions = null;
7388
if (position != prevPosition.current) {
7489
opts ??= {};
7590
opts.center = position;
@@ -117,7 +132,7 @@ export function useMapEaseToBounds(
117132
if (bounds == prevPosition.current || padding == prevPadding.current) {
118133
return;
119134
}
120-
let opts: mapboxgl.FlyToOptions = {
135+
let opts: FlyToOptions = {
121136
padding,
122137
duration: prevPadding.current == null ? 0 : 800,
123138
};
@@ -182,7 +197,7 @@ export function useMapEaseTo(props: MapEaseToProps) {
182197

183198
const positionChanges = filterChanges(state, prevState.current);
184199

185-
let opts: mapboxgl.FlyToOptions = {
200+
let opts: FlyToOptions = {
186201
padding,
187202
duration: initialized ? duration : 0,
188203
};
@@ -238,11 +253,7 @@ function stripNullKeys(obj: object) {
238253
return newObj;
239254
}
240255

241-
function moveMap(
242-
map: mapboxgl.Map,
243-
state: MapEaseToState,
244-
opts: mapboxgl.FlyToOptions,
245-
) {
256+
function moveMap(map: mapboxgl.Map, state: MapEaseToState, opts: FlyToOptions) {
246257
const { bounds, center, zoom, padding } = state;
247258
if (bounds != null) {
248259
map.fitBounds(bounds, opts);
@@ -279,8 +290,8 @@ function greatCircleDistance(
279290
}
280291

281292
export function getFocusState(
282-
map: mapboxgl.Map,
283-
location: mapboxgl.LngLatLike | GeoJSON.Geometry | null,
293+
map: Map,
294+
location: LngLatLike | GeoJSON.Geometry | null,
284295
): PositionFocusState | null {
285296
/** Determine whether the infomarker is positioned in the viewport */
286297
if (location == null) return null;
@@ -342,9 +353,7 @@ export function getFocusState(
342353
return PositionFocusState.OUT_OF_VIEW;
343354
}
344355

345-
export function useFocusState(
346-
position: mapboxgl.LngLatLike | GeoJSON.Geometry,
347-
) {
356+
export function useFocusState(position: LngLatLike | GeoJSON.Geometry) {
348357
const map = useMapRef();
349358
const [focusState, setFocusState] = useState<PositionFocusState | null>(null);
350359
const isInitialized = useMapInitialized();
@@ -373,11 +382,7 @@ export function isCentered(focusState: PositionFocusState) {
373382
}
374383

375384
function getCenterAndBestZoom(
376-
input:
377-
| [number, number]
378-
| GeoJSON.Geometry
379-
| GeoJSON.BBox
380-
| mapboxgl.LngLatLike,
385+
input: [number, number] | GeoJSON.Geometry | GeoJSON.BBox | LngLatLike,
381386
) {
382387
let box: GeoJSON.BBox;
383388
let center: [number, number] | null = null;

0 commit comments

Comments
 (0)