Skip to content

Commit

Permalink
switch from build-metadata to npm-style.protomaps.dev for dynamically… (
Browse files Browse the repository at this point in the history
#359)

* switch from build-metadata to npm-style.protomaps.dev for dynamically fetching NPM versions.

this will let us deprecate the pre-generated styles on NPM.
  • Loading branch information
bdon authored Jan 15, 2025
1 parent a7190fa commit 74837c6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
4 changes: 2 additions & 2 deletions app/src/Builds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ function Builds() {
type: "maplibre-gl",
renderer: "maplibre-gl",
index: 0,
url: `https://build-metadata.protomaps.dev/style@${latestStyle()}+theme@${theme}+tiles@${leftKey}.json`,
url: `https://npm-style.protomaps.dev/style.json?version=${latestStyle()}&theme=${theme}&tiles=${leftKey}`,
};
const right: MaperturePayload = {
name: `${rightKey} ${latestStyle()} ${theme}`,
type: "maplibre-gl",
renderer: "maplibre-gl",
index: 0,
url: `https://build-metadata.protomaps.dev/style@${latestStyle()}+theme@${theme}+tiles@${rightKey}.json`,
url: `https://npm-style.protomaps.dev/style.json?version=${latestStyle()}&theme=${theme}&tiles=${rightKey}`,
};
const payload = JSON.stringify([left, right]);
open(
Expand Down
12 changes: 1 addition & 11 deletions app/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,8 @@ export function createHash(
}

export async function layersForVersion(version: string, theme?: string) {
if (version >= "4.0.0") {
const resp = await fetch(
`https://unpkg.com/protomaps-themes-base@${version}/dist/styles/${
theme || "light"
}/en.json`,
);
return (await resp.json()).layers;
}
const resp = await fetch(
`https://unpkg.com/protomaps-themes-base@${version}/dist/layers/${
theme || "light"
}.json`,
`https://npm-style.protomaps.dev/layers.json?version=${version}&theme=${theme || "light"}&lang=en`,
);
return await resp.json();
}
Expand Down

0 comments on commit 74837c6

Please sign in to comment.