Replace default export with named exports (#1998)

## Launch Checklist

See title,
Also removed some "_" from some file names.
This is a pure refactoring, no logic changes.


 - [x] Briefly describe the changes in this PR.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Harel M
2026-07-12 14:07:28 +03:00
committed by GitHub
parent 21e141542a
commit 9c1499b805
94 changed files with 319 additions and 402 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
*/
let REF = 0;
export default function generateUniqueId(prefix="") {
export function generateUniqueId(prefix="") {
REF++;
return prefix+REF;
}
+1 -3
View File
@@ -1,6 +1,6 @@
import { type TFunction } from "i18next";
const spec = (t: TFunction) => ({
export const spec = (t: TFunction) => ({
maputnik: {
maptiler_access_token: {
label: t("MapTiler Access Token"),
@@ -32,5 +32,3 @@ const spec = (t: TFunction) => ({
},
}
});
export default spec;
+1 -1
View File
@@ -1,6 +1,6 @@
import capitalize from "lodash.capitalize";
export default function labelFromFieldName(fieldName: string) {
export function labelFromFieldName(fieldName: string) {
let label;
const parts = fieldName.split("-");
if (parts.length > 1) {
+1 -1
View File
@@ -9,7 +9,7 @@ export type LayerWatcherOptions = {
/** Listens to map events to build up a store of available vector
* layers contained in the tiles */
export default class LayerWatcher {
export class LayerWatcher {
onSourcesChange: (sources: { [sourceId: string]: string[] }) => void;
onVectorLayersChange: (vectorLayers: { [vectorLayerId: string]: { [propertyName: string]: { [propertyValue: string]: {} } } }) => void;
throttledAnalyzeVectorLayerFields: (map: any) => void;
+1 -1
View File
@@ -1,4 +1,4 @@
export default function(num1: string | number, num2: string| number) {
export function sortNumerically(num1: string | number, num2: string| number) {
const a = +num1;
const b = +num2;
+6 -6
View File
@@ -1,4 +1,4 @@
import style from "../style";
import { emptyStyle, ensureStyleValidity, replaceAccessTokens, stripAccessTokens } from "../style";
import {format} from "@maplibre/maplibre-gl-style-spec";
import ReconnectingWebSocket from "reconnecting-websocket";
import type {IStyleStore, OnStyleChangedCallback, StyleSpecificationWithId} from "../definitions";
@@ -40,13 +40,13 @@ export class ApiStyleStore implements IStyleStore {
connection.onmessage = e => {
if(!e.data) return;
console.log("Received style update from API");
let parsedStyle = style.emptyStyle;
let parsedStyle = emptyStyle;
try {
parsedStyle = JSON.parse(e.data);
} catch(err) {
console.error(err);
}
const updatedStyle = style.ensureStyleValidity(parsedStyle);
const updatedStyle = ensureStyleValidity(parsedStyle);
this.onLocalStyleChange(updatedStyle);
};
}
@@ -57,7 +57,7 @@ export class ApiStyleStore implements IStyleStore {
mode: "cors",
});
const body = await response.json();
return style.ensureStyleValidity(body);
return ensureStyleValidity(body);
} else {
throw new Error("No latest style available. You need to init the api backend first.");
}
@@ -66,8 +66,8 @@ export class ApiStyleStore implements IStyleStore {
// Save current style replacing previous version
save(mapStyle: StyleSpecificationWithId) {
const styleJSON = format(
style.stripAccessTokens(
style.replaceAccessTokens(mapStyle)
stripAccessTokens(
replaceAccessTokens(mapStyle)
)
);
+2 -2
View File
@@ -1,4 +1,4 @@
import style from "../style";
import { ensureStyleValidity } from "../style";
import {loadStyleUrl} from "../urlopen";
import publicSources from "../../config/styles.json";
import type {IStyleStore, StyleSpecificationWithId} from "../definitions";
@@ -89,7 +89,7 @@ export class StyleStore implements IStyleStore {
// Save current style replacing previous version
save(mapStyle: StyleSpecificationWithId) {
mapStyle = style.ensureStyleValidity(mapStyle);
mapStyle = ensureStyleValidity(mapStyle);
const key = styleKey(mapStyle.id);
const saveFn = () => {
+1 -1
View File
@@ -148,7 +148,7 @@ function stripAccessTokens(mapStyle: StyleSpecification) {
};
}
export default {
export {
ensureStyleValidity,
emptyStyle,
indexOfLayer,
+3 -3
View File
@@ -1,4 +1,4 @@
import style from "./style";
import { emptyStyle, ensureStyleValidity } from "./style";
import { type StyleSpecificationWithId } from "./definitions";
export function getStyleUrlFromAddressbarAndRemoveItIfNeeded(): string | null {
@@ -19,10 +19,10 @@ export async function loadStyleUrl(styleUrl: string): Promise<StyleSpecification
credentials: "same-origin"
});
const body = await response.json();
return style.ensureStyleValidity(body);
return ensureStyleValidity(body);
} catch {
console.warn("Could not fetch default style: " + styleUrl);
return style.emptyStyle;
return emptyStyle;
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
import {type Map} from "maplibre-gl";
export default class ZoomControl {
export class ZoomControl {
_map: Map| undefined = undefined;
_container: HTMLDivElement | undefined = undefined;
_textEl: HTMLSpanElement | null = null;