Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[Chore]: Technical: Translate utils (color and data) (#1732)
Maksim Suslovd8abca9d2ee1
diff --git a/src/reducers/combined-updaters.ts b/src/reducers/combined-updaters.tsindex e116cf03a..893e9d1bf 100644--- a/src/reducers/combined-updaters.ts+++ b/src/reducers/combined-updaters.ts@@ -40,6 +40,7 @@ import {ProviderState} from './provider-state-updaters';import {AddDataToMapPayload} from 'actions/actions';import {loadFilesSuccessUpdaterAction} from 'actions/vis-state-actions';import {ParsedConfig} from 'schemas';+import {Layer} from 'layers';export type KeplerGlState = {visState: VisState;@@ -152,10 +153,11 @@ export const addDataToMapUpdater = (parsedConfig = state.visState.schema.parseSavedConfig(config);}const oldLayers = state.visState.layers;- const filterNewlyAddedLayers = layers => layers.filter(nl => !oldLayers.find(ol => ol === nl));+ const filterNewlyAddedLayers = (layers: Layer[]) =>+ layers.filter(nl => !oldLayers.find(ol => ol === nl));// Returns undefined if not found, to make typescript happy- const findMapBoundsIfCentered = layers => {+ const findMapBoundsIfCentered = (layers: Layer[]) => {const bounds = options.centerMap && findMapBounds(layers);return bounds ? bounds : undefined;};diff --git a/src/reducers/map-style-updaters.ts b/src/reducers/map-style-updaters.tsindex 76aed0e6a..cd6f6c43a 100644--- a/src/reducers/map-style-updaters.ts+++ b/src/reducers/map-style-updaters.ts@@ -560,8 +560,8 @@ export const inputMapStyleUpdater = (const icon = isValid? getStyleImageIcon({mapState,- styleUrl: updated.url,- mapboxApiAccessToken: updated.accessToken || state.mapboxApiAccessToken,+ styleUrl: updated.url || '',+ mapboxApiAccessToken: updated.accessToken || state.mapboxApiAccessToken || '',mapboxApiUrl: state.mapboxApiUrl || DEFAULT_MAPBOX_API_URL}): state.inputStyle.icon;diff --git a/src/utils/color-utils.d.ts b/src/utils/color-utils.d.tsdeleted file mode 100644index 1d13a8a33..000000000--- a/src/utils/color-utils.d.ts+++ /dev/null@@ -1,9 +0,0 @@-import {ColorRange} from '../layers/layer-factory';--export const hexToRgb: (hex: string) => [number, number, number];-export const createLinearGradient: (string: direction, colors: number[]) => string;-export const reverseColorRange: (reversed: boolean, colorRange: ColorRange) => object;-export const rgbToHex: (colors: [number, number, number]) => string;--export const getColorGroupByName: (ColorRange) => ColorRange;-export function isRgbColor(color: unknown): color is RGBColor;diff --git a/src/utils/color-utils.js b/src/utils/color-utils.tssimilarity index 79%rename from src/utils/color-utils.jsrename to src/utils/color-utils.tsindex 5e1938858..df0bf4cf8 100644--- a/src/utils/color-utils.js+++ b/src/utils/color-utils.ts@@ -18,13 +18,16 @@// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN// THE SOFTWARE.+import {ColorRange} from 'layers/layer-factory';+import {HexColor, RGBColor} from 'reducers';+/*** get r g b from hex code*- * @param {string} hex- * @returns {import('reducers/types').RGBColor} array of r g bs+ * @param hex+ * @returns array of r g bs*/-export function hexToRgb(hex) {+export function hexToRgb(hex: string): RGBColor {const result = isHexColor(hex);if (!result) {@@ -38,7 +41,7 @@ export function hexToRgb(hex) {return [r, g, b];}-export function isHexColor(hex) {+export function isHexColor(hex: string): RegExpExecArray | null {const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);return result;@@ -52,10 +55,10 @@ function PadNum(c) {/*** get hex from r g b*- * @param {array} rgb- * @returns {string} hex string+ * @param rgb+ * @returns hex string*/-export function rgbToHex([r, g, b]) {+export function rgbToHex([r, g, b]: RGBColor): HexColor {return `#${[r, g, b].map(n => PadNum(n)).join('')}`.toUpperCase();}@@ -66,7 +69,7 @@ export function rgbToHex([r, g, b]) {* @param {Object} colorRange* @return {string | null}*/-export function getColorGroupByName(colorRange) {+export function getColorGroupByName(colorRange: ColorRange): string | null {if (!colorRange || typeof colorRange.name !== 'string') {return null;}@@ -76,10 +79,10 @@ export function getColorGroupByName(colorRange) {/*** Get a reversed colorRange- * @param {Boolean} reversed- * @param {Object} colorRange+ * @param reversed+ * @param colorRange*/-export function reverseColorRange(reversed, colorRange) {+export function reverseColorRange(reversed: boolean, colorRange: ColorRange): ColorRange | null {if (!colorRange) return null;// if (colorRange.reversed) return colorRange;return {@@ -92,10 +95,10 @@ export function reverseColorRange(reversed, colorRange) {/*** given a list of rgb arrays it will generate a linear gradient css rule* @param direction- * @param {Array} colors- * @return {string}+ * @param colors+ * @return*/-export function createLinearGradient(direction, colors) {+export function createLinearGradient(direction: string, colors: RGBColor[]) {const step = parseFloat((100.0 / colors.length).toFixed(2));const bands = colors.map((rgb, index) => {return `rgba(${rgb.join(',')}, 1) ${step * index}%, rgba(${rgb.join(',')}, 1) ${step *@@ -107,10 +110,9 @@ export function createLinearGradient(direction, colors) {/*** Whether color is rgb- * @type {typeof import('./color-utils').isRgbColor}* @returns*/-export function isRgbColor(color) {+export function isRgbColor(color: unknown): color is RGBColor {if (color &&Array.isArray(color) &&diff --git a/src/utils/data-scale-utils.d.ts b/src/utils/data-scale-utils.d.tsdeleted file mode 100644index 15a2b20e3..000000000--- a/src/utils/data-scale-utils.d.ts+++ /dev/null@@ -1,26 +0,0 @@-import {DataContainerInterface} from './table-utils/data-container-interface';--function dataValueAccessor(any): any;-function sort(a: any, b: any): any;-function dataContainerValueAccessor(d: {index: number}, dc: DataContainerInterface): any;--export function getQuantileDomain(- data: any[],- valueAccessor?: typeof dataValueAccessor,- sortFunc?: typeof sort-): number[];--export function getOrdinalDomain(- dataContainer: DataContainerInterface,- valueAccessor: typeof dataContainerValueAccessor-): string[];--export function getLinearDomain(- data: any[],- valueAccessor?: typeof dataValueAccessor-): [number, number];--export function getLogDomain(- data: any[],- valueAccessor?: typeof dataValueAccessor-): [number, number];diff --git a/src/utils/data-scale-utils.js b/src/utils/data-scale-utils.tssimilarity index 70%rename from src/utils/data-scale-utils.jsrename to src/utils/data-scale-utils.tsindex 717ef977f..29070f66a 100644--- a/src/utils/data-scale-utils.js+++ b/src/utils/data-scale-utils.ts@@ -20,12 +20,19 @@import {notNullorUndefined, unique} from './data-utils';import {extent} from 'd3-array';+import {DataContainerInterface} from './table-utils/data-container-interface';+type dataValueAccessor = <T>(param: T) => T;+type dataContainerValueAccessor = (d: {index: number}, dc: DataContainerInterface) => any;+type sort = (a: any, b: any) => any;/*** return quantile domain for an array of data- * @type {typeof import('./data-scale-utils').getQuantileDomain}*/-export function getQuantileDomain(data, valueAccessor, sortFunc) {+export function getQuantileDomain(+ data: any[],+ valueAccessor?: dataValueAccessor,+ sortFunc?: sort+): number[] {const values = typeof valueAccessor === 'function' ? data.map(valueAccessor) : data;return values.filter(notNullorUndefined).sort(sortFunc);@@ -33,9 +40,11 @@ export function getQuantileDomain(data, valueAccessor, sortFunc) {/*** return ordinal domain for a data container- * @type {typeof import('./data-scale-utils').getOrdinalDomain}*/-export function getOrdinalDomain(dataContainer, valueAccessor) {+export function getOrdinalDomain(+ dataContainer: DataContainerInterface,+ valueAccessor: dataContainerValueAccessor+): string[] {const values = dataContainer.mapIndex(valueAccessor);return unique(values)@@ -45,19 +54,22 @@ export function getOrdinalDomain(dataContainer, valueAccessor) {/*** return linear domain for an array of data- * @type {typeof import('./data-scale-utils').getLinearDomain}*/-export function getLinearDomain(data, valueAccessor) {+export function getLinearDomain(+ data: number[],+ valueAccessor?: dataValueAccessor+): [number, number] {const range = typeof valueAccessor === 'function' ? extent(data, valueAccessor) : extent(data);- // @ts-ignore- return range.map((d, i) => (d === undefined ? i : d));+ return range.map((d: undefined | number, i: number) => (d === undefined ? i : d)) as [+ number,+ number+ ];}/*** return linear domain for an array of data. A log scale domain cannot contain 0- * @type {typeof import('./data-scale-utils').getLogDomain}*/-export function getLogDomain(data, valueAccessor) {+export function getLogDomain(data: any[], valueAccessor: dataValueAccessor): [number, number] {const [d0, d1] = getLinearDomain(data, valueAccessor);return [d0 === 0 ? 1e-5 : d0, d1];}diff --git a/src/utils/data-utils.d.ts b/src/utils/data-utils.d.tsdeleted file mode 100644index 3a84dd5c5..000000000--- a/src/utils/data-utils.d.ts+++ /dev/null@@ -1,44 +0,0 @@-import {Millisecond} from 'reducers/types';-import {Layer, Field} from 'reducers/vis-state-updaters';-import {Bounds} from 'reducers/map-state-updaters';-import {DataRow} from './table-utils/data-row';-import {DataContainerInterface} from './table-utils/data-container-interface';--export function maybeToDate(isTime: boolean, fieldIdx: number, format: string, dc: DataContainerInterface, d: {index: number}): any;--export function timeToUnixMilli(value: any, format: string): Millisecond | null;-export function notNullorUndefined<T extends NonNullable<any>>(d: T | null | undefined): d is T;-export function isNumber(d: any): boolean;-export function isPlainObject(d: any): boolean;-export function numberSort(a: any, b: any): any;-export function unique(values: any[]): any[];-export function arrayMove(array: any[], from: number, to: number);-export function getSortingFunction(fieldType: string): numberSort | undefined;-export function preciseRound(num: number, decimals: number): string;-export function parseFieldValue(value: any, type: string): string;-export function getLatLngBounds(- points: number[][],- idx: number,- limit: [number, number]-): [number, number] | null;-export function getSampleData(data: any[], sampleSize?: number, getValue?: any): any[];-export function findMapBounds(layers: Layer[]): Bounds | null;-function formatter(v: any): any;-export function getFormatter(format: any, field?: Field): formatter;-export function defaultFormatter(v: any): string;-export function snapToMarks(value: number, marks: number[]): number;-export function normalizeSliderValue(- val: number,- minValue: number,- step: number,- marks?: number[]-): number;-export function roundValToStep(minValue: number, step: number, val: number): number;-export function clamp([min, max], val);--export type FieldFormatter = (value: any) => string;-export declare const FIELD_DISPLAY_FORMAT: {- [key: string]: FieldFormatter;-};--export declare function datetimeFormatter(timezone?: string | null): (format: string) => (ts: number) => string;diff --git a/src/utils/data-utils.js b/src/utils/data-utils.tssimilarity index 74%rename from src/utils/data-utils.jsrename to src/utils/data-utils.tsindex f9c897c21..acbc4a156 100644--- a/src/utils/data-utils.js+++ b/src/utils/data-utils.ts@@ -25,6 +25,14 @@ import {format as d3Format} from 'd3-format';import {bisectLeft} from 'd3-array';import moment from 'moment-timezone';+import {Millisecond} from 'reducers/types';+import {Layer} from 'layers';+import {Bounds} from 'reducers/map-state-updaters';+import {DataContainerInterface} from './table-utils/data-container-interface';+import {Field} from './table-utils/kepler-table';++export type FieldFormatter = (value: any) => string;+const MAX_LATITUDE = 90;const MIN_LATITUDE = -90;const MAX_LONGITUDE = 180;@@ -33,11 +41,11 @@ const MIN_LONGITUDE = -180;/*** simple getting unique values of an array*- * @param {array} values- * @returns {array} unique values+ * @param values+ * @returns unique values*/-export function unique(values) {- const results = [];+export function unique<T>(values: T[]) {+ const results: T[] = [];const uniqueSet = new Set(values);uniqueSet.forEach(v => {if (notNullorUndefined(v)) {@@ -47,17 +55,18 @@ export function unique(values) {return results;}-/* eslint-disable max-statements *//*** return center of map from given points- * @param {array} layers- * @returns {object} coordinates of map center, empty if not found+ * @param layers+ * @returns coordinates of map center, empty if not found*/-export function findMapBounds(layers) {+export function findMapBounds(layers: Layer[]): Bounds | null {// find bounds in formatted layerData// take ALL layers into account when finding map bounds- const availableLayerBounds = layers.reduce((res, l) => {+ const availableLayerBounds: Bounds | [] = layers.reduce((res, l) => {+ // @ts-expect-errorif (l.meta && l.meta.bounds) {+ // @ts-expect-errorres.push(l.meta.bounds);}return res;@@ -67,7 +76,7 @@ export function findMapBounds(layers) {return null;}// merge bounds in each layer- const newBounds = availableLayerBounds.reduce(+ const newBounds = (availableLayerBounds as Bounds).reduce((res, b) => {return [Math.min(res[0], b[0]),@@ -78,13 +87,17 @@ export function findMapBounds(layers) {},[MAX_LONGITUDE, MAX_LATITUDE, MIN_LONGITUDE, MIN_LATITUDE]);+ // @ts-expect-errorreturn newBounds;}-/* eslint-enable max-statements */-export function getLatLngBounds(points, idx, limit) {+export function getLatLngBounds(+ points: number[][],+ idx: number,+ limit: [number, number]+): [number, number] | null {const lats = points- .map(d => Array.isArray(d) && d[idx])+ .map(d => Number(Array.isArray(d)) && d[idx]).filter(Number.isFinite).sort(numberSort);@@ -96,13 +109,13 @@ export function getLatLngBounds(points, idx, limit) {return [Math.max(lats[0], limit[0]), Math.min(lats[lats.length - 1], limit[1])];}-export function clamp([min, max], val) {+export function clamp([min, max]: [number, number], val: number): number {return val <= min ? min : val >= max ? max : val;}export function getSampleData(data, sampleSize = 500, getValue = d => d) {const sampleStep = Math.max(Math.floor(data.length / sampleSize), 1);- const output = [];+ const output: any[] = [];for (let i = 0; i < data.length; i += sampleStep) {output.push(getValue(data[i]));}@@ -112,9 +125,8 @@ export function getSampleData(data, sampleSize = 500, getValue = d => d) {/*** Convert different time format to unix milliseconds- * @type {typeof import('./data-utils').timeToUnixMilli}*/-export function timeToUnixMilli(value, format) {+export function timeToUnixMilli(value: string | number, format: string): Millisecond | null {if (notNullorUndefined(value)) {return typeof value === 'string'? moment.utc(value, format).valueOf()@@ -125,11 +137,13 @@ export function timeToUnixMilli(value, format) {return null;}-/**- *- * @type {typeof import('./data-utils').maybeToDate}- */-export function maybeToDate(isTime, fieldIdx, format, dc, d) {+export function maybeToDate(+ isTime: boolean,+ fieldIdx: number,+ format: string,+ dc: DataContainerInterface,+ d: {index: number}+) {if (isTime) {return timeToUnixMilli(dc.valueAt(d.index, fieldIdx), format);}@@ -139,37 +153,29 @@ export function maybeToDate(isTime, fieldIdx, format, dc, d) {/*** whether null or undefined- * @type {typeof import('./data-utils').notNullorUndefined}*/-export function notNullorUndefined(d) {+export function notNullorUndefined<T extends NonNullable<any>>(d: T | null | undefined): d is T {return d !== undefined && d !== null;}/*** Whether d is a number, this filtered out NaN as well- * @type {typeof import('./data-utils').notNullorUndefined}*/-export function isNumber(d) {+export function isNumber(d: any): boolean {return Number.isFinite(d);}/*** whether null or undefined*/-export function isPlainObject(obj) {+export function isPlainObject(obj: any): boolean {return obj === Object(obj) && typeof obj !== 'function' && !Array.isArray(obj);}-/**- * @type {typeof import('./data-utils').numberSort}- */-export function numberSort(a, b) {+export function numberSort(a: number, b: number): number {return a - b;}-/**- * @type {typeof import('./data-utils').getSortingFunction}- */-export function getSortingFunction(fieldType) {+export function getSortingFunction(fieldType: string): typeof numberSort | undefined {switch (fieldType) {case ALL_FIELD_TYPES.real:case ALL_FIELD_TYPES.integer:@@ -183,9 +189,8 @@ export function getSortingFunction(fieldType) {/*** round number with exact number of decimals* return as a string- * @type {typeof import('./data-utils').preciseRound}*/-export function preciseRound(num, decimals) {+export function preciseRound(num: number, decimals: number): string {const t = Math.pow(10, decimals);return (Math.round(@@ -196,10 +201,10 @@ export function preciseRound(num, decimals) {/*** get number of decimals to round to for slider from step- * @param {number} step- * @returns {number} - number of decimal+ * @param step+ * @returns- number of decimal*/-export function getRoundingDecimalFromStep(step) {+export function getRoundingDecimalFromStep(step: number): number {if (isNaN(step)) {assert('step is not a number');assert(step);@@ -214,11 +219,10 @@ export function getRoundingDecimalFromStep(step) {/*** Use in slider, given a number and an array of numbers, return the nears number from the array- * @type {typeof import('./data-utils').snapToMarks}* @param value* @param marks*/-export function snapToMarks(value, marks) {+export function snapToMarks(value: number, marks: number[]): number {// always use bin x0const i = bisectLeft(marks, value);if (i === 0) {@@ -232,13 +236,17 @@ export function snapToMarks(value, marks) {/*** If marks is provided, snap to marks, if not normalize to step- * @type {typeof import('./data-utils').normalizeSliderValue}* @param val* @param minValue* @param step* @param marks*/-export function normalizeSliderValue(val, minValue, step, marks) {+export function normalizeSliderValue(+ val: number,+ minValue: number,+ step: number,+ marks?: number[]+): number {if (marks && marks.length) {return snapToMarks(val, marks);}@@ -248,13 +256,12 @@ export function normalizeSliderValue(val, minValue, step, marks) {/*** round the value to step for the slider- * @type {typeof import('./data-utils').roundValToStep}* @param minValue* @param step* @param val* @returns - rounded number*/-export function roundValToStep(minValue, step, val) {+export function roundValToStep(minValue: number, step: number, val: number): number {if (!isNumber(step) || !isNumber(minValue)) {return val;}@@ -266,7 +273,7 @@ export function roundValToStep(minValue, step, val) {// has to round because javascript turns 0.1 into 0.9999999999999987remain = Number(preciseRound(remain, 8));- let closest;+ let closest: number;if (remain === 0) {closest = val;} else if (remain < step / 2) {@@ -284,11 +291,12 @@ export function roundValToStep(minValue, step, val) {/*** Get the value format based on field and format options* Used in render tooltip value- * @type {typeof import('./data-utils').defaultFormatter}*/-export const defaultFormatter = v => (notNullorUndefined(v) ? String(v) : '');+export const defaultFormatter: FieldFormatter = v => (notNullorUndefined(v) ? String(v) : '');-export const FIELD_DISPLAY_FORMAT = {+export const FIELD_DISPLAY_FORMAT: {+ [key: string]: FieldFormatter;+} = {[ALL_FIELD_TYPES.string]: defaultFormatter,[ALL_FIELD_TYPES.timestamp]: defaultFormatter,[ALL_FIELD_TYPES.integer]: defaultFormatter,@@ -307,9 +315,8 @@ export const FIELD_DISPLAY_FORMAT = {/*** Parse field value and type and return a string representation- * @type {typeof import('./data-utils').parseFieldValue}*/-export const parseFieldValue = (value, type) => {+export const parseFieldValue = (value: any, type: string): string => {if (!notNullorUndefined(value)) {return '';}@@ -317,17 +324,17 @@ export const parseFieldValue = (value, type) => {return FIELD_DISPLAY_FORMAT[type] ? FIELD_DISPLAY_FORMAT[type](value) : String(value);};-const arrayMoveMutate = (array, from, to) => {+const arrayMoveMutate = <T>(array: T[], from: number, to: number) => {array.splice(to < 0 ? array.length + to : to, 0, array.splice(from, 1)[0]);};/***- * @param {*} array- * @param {*} from- * @param {*} to+ * @param array+ * @param from+ * @param to*/-export const arrayMove = (array, from, to) => {+export const arrayMove = <T>(array: T[], from: number, to: number) => {array = array.slice();arrayMoveMutate(array, from, to);return array;@@ -336,11 +343,13 @@ export const arrayMove = (array, from, to) => {/*** Get the value format based on field and format options* Used in render tooltip value- * @type {typeof import('./data-utils').getFormatter}* @param format* @param field*/-export function getFormatter(format, field) {+export function getFormatter(+ format: string | Record<string, string>,+ field?: Field+): FieldFormatter {if (!format) {return defaultFormatter;}@@ -375,18 +384,18 @@ export function applyDefaultFormat(tooltipFormat) {}}-export function getBooleanFormatter(format) {+export function getBooleanFormatter(format: string): FieldFormatter {switch (format) {case '01':- return v => (v ? '1' : '0');+ return (v: Boolean) => (v ? '1' : '0');case 'yn':- return v => (v ? 'yes' : 'no');+ return (v: Boolean) => (v ? 'yes' : 'no');default:return defaultFormatter;}}// Allow user to specify custom tooltip format via config-export function applyCustomFormat(format, field) {+export function applyCustomFormat(format, field): FieldFormatter {switch (field.type) {case ALL_FIELD_TYPES.real:case ALL_FIELD_TYPES.integer:@@ -401,9 +410,11 @@ export function applyCustomFormat(format, field) {/*** Format epoch milliseconds with a format string- * @type {typeof import('./data-utils').datetimeFormatter} timezone+ * @type timezone*/-export function datetimeFormatter(timezone) {+export function datetimeFormatter(+ timezone?: string | null+): (format: string) => (ts: number) => string {return timezone? format => ts =>momentdiff --git a/src/utils/map-style-utils/mapbox-gl-style-editor.ts b/src/utils/map-style-utils/mapbox-gl-style-editor.tsindex 8ff851c89..7deef4672 100644--- a/src/utils/map-style-utils/mapbox-gl-style-editor.ts+++ b/src/utils/map-style-utils/mapbox-gl-style-editor.ts@@ -21,7 +21,7 @@import memoize from 'lodash.memoize';import clondDeep from 'lodash.clonedeep';import {DEFAULT_LAYER_GROUPS, DEFAULT_MAPBOX_API_URL} from 'constants/default-settings';-import {LayerGroup} from 'reducers';+import {BaseMapStyle, LayerGroup, MapState} from 'reducers';const mapUrlRg = /^mapbox:\/\/styles\/[-a-z0-9]{2,256}\/[-a-z0-9]{2,256}/;const httpRg = /^(?=(http:|https:))/;@@ -45,26 +45,30 @@ const resolver = ({id, mapStyle, visibleLayerGroups = {}}) =>/*** Edit preset map style to keep only visible layers*- * @param {Object} mapStyle - preset map style- * @param {Object} visibleLayerGroups - visible layers of top map- * @returns {Object} top map style+ * @param mapStyle - preset map style+ * @param visibleLayerGroups - visible layers of top map+ * @returns top map style*/-export const editTopMapStyle = memoize(({id, mapStyle, visibleLayerGroups}) => {- const visibleFilters = (mapStyle.layerGroups || [])- .filter(lg => visibleLayerGroups[lg.slug])- .map(lg => lg.filter);-- // if top map- // keep only visible layers- const filteredLayers = mapStyle.style.layers.filter(layer =>- visibleFilters.some(match => match(layer))- );-- return {- ...mapStyle.style,- layers: filteredLayers- };-}, resolver);+export const editTopMapStyle = memoize(+ ({mapStyle, visibleLayerGroups}: {mapStyle: BaseMapStyle; visibleLayerGroups: LayerGroup[]}) => {+ const visibleFilters = (mapStyle.layerGroups || [])+ .filter(lg => visibleLayerGroups[lg.slug])+ .map(lg => lg.filter);++ // if top map+ // keep only visible layers+ // @ts-expect-error+ const filteredLayers = mapStyle.style.layers.filter(layer =>+ visibleFilters.some(match => match(layer))+ );++ return {+ ...mapStyle.style,+ layers: filteredLayers+ };+ },+ resolver+);/*** Edit preset map style to filter out invisible layers@@ -117,13 +121,13 @@ export function getStyleDownloadUrl(styleUrl, accessToken, mapboxApiUrl) {/*** Generate static map image from style Url to be used as icon- * @param {Object} param- * @param {string} param.styleUrl- * @param {string} param.mapboxApiAccessToken- * @param {string} param.mapboxApiUrl- * @param {Object} param.mapState- * @param {number} param.mapW- * @param {number} param.mapH+ * @param param+ * @param param.styleUrl+ * @param param.mapboxApiAccessToken+ * @param param.mapboxApiUrl+ * @param param.mapState+ * @param param.mapW+ * @param param.mapH*/export function getStyleImageIcon({styleUrl,@@ -136,6 +140,13 @@ export function getStyleImageIcon({},mapW = 400,mapH = 300+}: {+ styleUrl: string;+ mapboxApiAccessToken: string;+ mapboxApiUrl?: string;+ mapState?: Partial<MapState>;+ mapW?: number;+ mapH?: number;}) {const styleId = styleUrl.replace('mapbox://styles/', '');diff --git a/src/utils/notifications-utils.ts b/src/utils/notifications-utils.tsindex e0904aed9..17ddef38b 100644--- a/src/utils/notifications-utils.ts+++ b/src/utils/notifications-utils.ts@@ -31,13 +31,13 @@ import {BUG_REPORT_LINK} from 'constants/user-guides';/*** Creates a notification- * @param {object} opt- * @param {string} opt.message - Message to display during the notification- * @param {string} opt.type - The type of message. One of DEFAULT_NOTIFICATION_TYPES- * @param {string} opt.topic - The topic the notification belongs to. One of DEFAULT_NOTIFICATION_TOPICS- * @param {string} opt.id optional id for notification. If not provided it will be generated by the method- * @param {object} opt.options - Extra parameters to store as part of hte notification- * @returns {object}+ * @param opt+ * @param opt.message - Message to display during the notification+ * @param opt.type - The type of message. One of DEFAULT_NOTIFICATION_TYPES+ * @param opt.topic - The topic the notification belongs to. One of DEFAULT_NOTIFICATION_TOPICS+ * @param opt.id optional id for notification. If not provided it will be generated by the method+ * @param opt.options - Extra parameters to store as part of hte notification+ * @returns*/export function createNotification({message = DEFAULT_NOTIFICATION_MESSAGE,@@ -45,6 +45,12 @@ export function createNotification({topic = DEFAULT_NOTIFICATION_TOPICS.global,id = generateHashId(DEFAULT_UUID_COUNT),...options+}: {+ message?: string;+ type?: string;+ topic?: string;+ id?: string;+ options?: any;}) {return {...options,