fix build

This commit is contained in:
HarelM
2026-07-12 09:15:23 +03:00
parent a5c47437ee
commit ca66f47be0
3 changed files with 11 additions and 11 deletions
+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 {format} from "@maplibre/maplibre-gl-style-spec";
import ReconnectingWebSocket from "reconnecting-websocket"; import ReconnectingWebSocket from "reconnecting-websocket";
import type {IStyleStore, OnStyleChangedCallback, StyleSpecificationWithId} from "../definitions"; import type {IStyleStore, OnStyleChangedCallback, StyleSpecificationWithId} from "../definitions";
@@ -40,13 +40,13 @@ export class ApiStyleStore implements IStyleStore {
connection.onmessage = e => { connection.onmessage = e => {
if(!e.data) return; if(!e.data) return;
console.log("Received style update from API"); console.log("Received style update from API");
let parsedStyle = style.emptyStyle; let parsedStyle = emptyStyle;
try { try {
parsedStyle = JSON.parse(e.data); parsedStyle = JSON.parse(e.data);
} catch(err) { } catch(err) {
console.error(err); console.error(err);
} }
const updatedStyle = style.ensureStyleValidity(parsedStyle); const updatedStyle = ensureStyleValidity(parsedStyle);
this.onLocalStyleChange(updatedStyle); this.onLocalStyleChange(updatedStyle);
}; };
} }
@@ -57,7 +57,7 @@ export class ApiStyleStore implements IStyleStore {
mode: "cors", mode: "cors",
}); });
const body = await response.json(); const body = await response.json();
return style.ensureStyleValidity(body); return ensureStyleValidity(body);
} else { } else {
throw new Error("No latest style available. You need to init the api backend first."); 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 current style replacing previous version
save(mapStyle: StyleSpecificationWithId) { save(mapStyle: StyleSpecificationWithId) {
const styleJSON = format( const styleJSON = format(
style.stripAccessTokens( stripAccessTokens(
style.replaceAccessTokens(mapStyle) replaceAccessTokens(mapStyle)
) )
); );
+2 -2
View File
@@ -1,4 +1,4 @@
import style from "../style"; import { ensureStyleValidity } from "../style";
import {loadStyleUrl} from "../urlopen"; import {loadStyleUrl} from "../urlopen";
import publicSources from "../../config/styles.json"; import publicSources from "../../config/styles.json";
import type {IStyleStore, StyleSpecificationWithId} from "../definitions"; import type {IStyleStore, StyleSpecificationWithId} from "../definitions";
@@ -89,7 +89,7 @@ export class StyleStore implements IStyleStore {
// Save current style replacing previous version // Save current style replacing previous version
save(mapStyle: StyleSpecificationWithId) { save(mapStyle: StyleSpecificationWithId) {
mapStyle = style.ensureStyleValidity(mapStyle); mapStyle = ensureStyleValidity(mapStyle);
const key = styleKey(mapStyle.id); const key = styleKey(mapStyle.id);
const saveFn = () => { const saveFn = () => {
+3 -3
View File
@@ -1,4 +1,4 @@
import style from "./style"; import { emptyStyle, ensureStyleValidity } from "./style";
import { type StyleSpecificationWithId } from "./definitions"; import { type StyleSpecificationWithId } from "./definitions";
export function getStyleUrlFromAddressbarAndRemoveItIfNeeded(): string | null { export function getStyleUrlFromAddressbarAndRemoveItIfNeeded(): string | null {
@@ -19,10 +19,10 @@ export async function loadStyleUrl(styleUrl: string): Promise<StyleSpecification
credentials: "same-origin" credentials: "same-origin"
}); });
const body = await response.json(); const body = await response.json();
return style.ensureStyleValidity(body); return ensureStyleValidity(body);
} catch { } catch {
console.warn("Could not fetch default style: " + styleUrl); console.warn("Could not fetch default style: " + styleUrl);
return style.emptyStyle; return emptyStyle;
} }
} }