Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ The format is based on Keep a Changelog and the project follows Semantic Version

### Changed

- Upgrade the location map to MapLibre GL JS 6 while keeping its worker bundled
locally for Chromium and Firefox extension pages. Maps now require WebGL2.

- The interface language can be chosen in Settings. Automatic still follows the
browser language. Popup, sidebar, and Settings update without a reload.
- Language choices show the English name and the name from the active translation.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cmdk": "^1.1.1",
"maplibre-gl": "^5.24.0",
"maplibre-gl": "^6.4.1",
"react": "^19.2.7",
"react-dom": "^19.2.7",
"sonner": "^2.0.8",
Expand Down
145 changes: 54 additions & 91 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/ui/options/components/map/ProfileDraftMap.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "maplibre-gl/dist/maplibre-gl.css";

import type maplibreglType from "maplibre-gl";
import type * as maplibreglType from "maplibre-gl";
import type { AddLayerObject, GeoJSONSource } from "maplibre-gl";
import type { MutableRefObject, ReactNode } from "react";
import { useEffect, useRef } from "react";
Expand Down
32 changes: 15 additions & 17 deletions src/ui/options/components/map/maplibre-csp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ const { setWorkerUrl } = vi.hoisted(() => ({
setWorkerUrl: vi.fn(),
}));

vi.mock("maplibre-gl/dist/maplibre-gl-csp.js", () => ({
default: {
setWorkerUrl,
},
vi.mock("maplibre-gl", () => ({
setWorkerUrl,
}));

vi.mock("maplibre-gl/dist/maplibre-gl-csp-worker.js?url", () => ({
default: "/assets/maplibre-gl-csp-worker.js",
vi.mock("maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url", () => ({
default: "/assets/maplibre-gl-worker.js",
}));

describe("maplibre-csp", () => {
Expand All @@ -21,17 +19,17 @@ describe("maplibre-csp", () => {
vi.unstubAllGlobals();
});

it("configures the CSP worker against the current extension page origin", async () => {
vi.stubGlobal(
"location",
new URL("chrome-extension://test/src/ui/options/index.html"),
);
it.each(["chrome-extension://test", "moz-extension://test"])(
"configures the bundled worker against the %s page origin",
async (origin) => {
vi.stubGlobal("location", new URL(`${origin}/src/ui/options/index.html`));

const module = await import("@/ui/options/components/map/maplibre-csp");
const module = await import("@/ui/options/components/map/maplibre-csp");

expect(setWorkerUrl).toHaveBeenCalledWith(
"chrome-extension://test/assets/maplibre-gl-csp-worker.js",
);
expect(module.default).toHaveProperty("setWorkerUrl", setWorkerUrl);
});
expect(setWorkerUrl).toHaveBeenCalledWith(
`${origin}/assets/maplibre-gl-worker.js`,
);
expect(module.default).toHaveProperty("setWorkerUrl", setWorkerUrl);
},
);
});
8 changes: 3 additions & 5 deletions src/ui/options/components/map/maplibre-csp.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import type maplibreglType from "maplibre-gl";
import maplibreWorkerUrl from "maplibre-gl/dist/maplibre-gl-csp-worker.js?url";
import maplibreglRuntime from "maplibre-gl/dist/maplibre-gl-csp.js";

const maplibregl = maplibreglRuntime as typeof maplibreglType;
import * as maplibregl from "maplibre-gl";
// Bundle the worker's shared ESM imports too; a plain ?url would leave them missing.
import maplibreWorkerUrl from "maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url";

const resolvedWorkerUrl =
typeof globalThis.location?.href === "string"
Expand Down
Loading