mirror of
https://github.com/maputnik/editor.git
synced 2026-07-27 16:27:26 +00:00
fix build
This commit is contained in:
@@ -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)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -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 = () => {
|
||||
|
||||
+3
-3
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user