Skip to content

fix: install MapLibre transform compat on the headless entry - #2088

Merged
giswqs merged 2 commits into
opengeos:mainfrom
kongdd:fix/headless-map-transform-compat
Aug 24, 2026
Merged

fix: install MapLibre transform compat on the headless entry#2088
giswqs merged 2 commits into
opengeos:mainfrom
kongdd:fix/headless-map-transform-compat

Conversation

@kongdd

@kongdd kongdd commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

installMapTransformCompat() already runs from map-controller.ts for the desktop app. @geolibre/map/headless did not call it.

After MapLibre 6, map.transform moved to map._camera.transform. @deck.gl/mapbox still reads map.transform.height on every frame. Independent apps that only import the headless entry therefore throw Cannot read properties of undefined (reading 'height') and COG / maplibre-gl-raster overlays draw nothing.

This installs the existing shim when the headless module loads, and re-exports it for apps that construct Map first.

Test plan

  • import { createLayerSync } from "@geolibre/map/headless" then new Map(...)map.transform.height is defined
  • Add a COG via maplibre-gl-raster — overlay draws, no per-frame height error
  • Desktop app still starts (idempotent; no-op if Map#transform already exists)

Summary by CodeRabbit

  • New Features
    • Added compatibility support for map transformations when the headless map module loads.
    • Exposed the map transformation compatibility installer for advanced integrations.

map-controller already installs the MapLibre 6 map.transform shim so
@deck.gl/mapbox can read transform.height. @geolibre/map/headless skipped
that, so COG/raster overlays throw every frame and draw nothing.

Install the same shim on headless module load and re-export it.
Copilot AI lite review requested due to automatic review settings August 24, 2026 12:44
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 398f4e67-9237-428f-9d1a-87a52411e40e

📥 Commits

Reviewing files that changed from the base of the PR and between 95ea999 and 151643c.

📒 Files selected for processing (1)
  • packages/map/src/headless.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


Important

Approval pending

CodeRabbit has no unresolved comments, but it has not reviewed the latest commit.

Use the checkbox below to review the latest commit. CodeRabbit will approve the changes if it finds no blocking issues.

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The headless map entry point now installs map transform compatibility during module initialization and re-exports installMapTransformCompat.

Changes

Map transform compatibility

Layer / File(s) Summary
Headless compatibility initialization
packages/map/src/headless.ts
The entry point imports and invokes installMapTransformCompat() during module initialization. It also re-exports the installer.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 15164

This PR enables the existing MapLibre compatibility shim for the headless entry and re-exports it for callers that construct maps separately. No actionable merge-blocking risk remains beyond normal checks and review.

Poem

A rabbit hops through maps so bright,
Compatibility wakes at module light.
The installer joins the public trail,
Headless transforms now prevail.
“Hop!” says the rabbit. “The exports are set!”

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes installing MapLibre transform compatibility in the headless entry.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR ensures the MapLibre v6 map.transform compatibility shim is installed when consumers import the @geolibre/map/headless entrypoint, preventing deck.gl / raster overlays from failing in apps that don’t use the full desktop map controller.

Changes:

  • Import and run installMapTransformCompat() at module load in the headless entry.
  • Re-export installMapTransformCompat so external apps can call it explicitly when needed.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/map/src/headless.ts Outdated
Comment thread packages/map/src/headless.ts Outdated
Comment on lines +13 to +15
import { installMapTransformCompat } from "./map-transform-compat";

installMapTransformCompat();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor/low-confidence: the underlying installMapTransformCompat behavior is already covered by tests/map-transform-compat.test.ts, but nothing currently regression-tests that @geolibre/map/headless actually wires it up at import time (the exact bug this PR fixes). A one-line addition to tests/headless-layer-sync.test.ts — importing the module and asserting MapLibreMap.prototype has a transform getter (or that installMapTransformCompat() now returns false since it's already installed) — would catch a future accidental removal of this side-effect call.

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

🔍 Cloudflare PR preview

Item Value
Site https://5cdc80ed.geolibre-preview.pages.dev
Demo app https://5cdc80ed.geolibre-preview.pages.dev/demo/
Commit 9dcde0d

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs: None found. The change simply calls the existing, well-tested installMapTransformCompat() at headless.ts module load and re-exports it — mirroring the identical pattern already used in map-controller.ts. The function is idempotent (guarded by "transform" in prototype), so calling it from both entry points in the same process is safe.

Security: None found. No user input, no new external dependency, no secrets involved.

Performance: None found. headless.ts already pulls in the real maplibre-gl runtime module transitively via layer-sync.ts (addProtocol, config), so this adds no new module-load cost; referencing MapLibreMap.prototype at import time does not touch DOM/WebGL APIs.

Quality: Low confidence — no regression test exercises the new wiring itself (only the underlying installMapTransformCompat function, via tests/map-transform-compat.test.ts). Posted as an inline suggestion on packages/map/src/headless.ts:13-15 to add a one-line assertion so a future accidental removal of this side-effect call would be caught by CI.

CLAUDE.md: No violations. This isn't a dist/publishConfig entry-point change (no new export paths, no tsdown entry changes), and doesn't touch any of the documented "mirrored constant" call sites.

Overall: a minimal, correct, low-risk fix that follows the exact precedent already established in map-controller.ts.

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

🔍 GitHub Pages PR preview

Item Value
Site https://opengeos.org/pages-preview/GeoLibre/pr-2088/
Demo app https://opengeos.org/pages-preview/GeoLibre/pr-2088/demo/
Commit 9dcde0d

Note

GitHub Pages built this preview successfully, but its serving edge returned HTTP 403 when checked. The links may still be propagating.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@@ -10,6 +10,12 @@
import type { GeoLibreLayer } from "@geolibre/core";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor style nit: importing the symbol under an alias (line 9) just to call it, and separately re-exporting it from the same module (line 10), is a bit more indirection than needed — a single import used for both the call and the export would read the same with one less binding:

import { installMapTransformCompat } from "./map-transform-compat";
export { installMapTransformCompat };

Purely stylistic; the code as written is correct. Confidence: low.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs: None found. The fix correctly mirrors the already-tested installMapTransformCompat() call pattern from map-controller.ts:69-74, calling it at headless-module load time (before Map construction, as required — see map-transform-compat.ts's own docstring). The underlying shim is idempotent and self-disabling on MapLibre versions that still ship Map#transform, so double-installation (e.g. an app that loads both index.ts and headless.ts) is safe. (Confidence: high)

Security: None found — no new input handling, no injection surface.

Performance: None found. Module-load-time side effect is a one-time, cheap prototype-property definition; no per-frame cost beyond what already existed for the non-headless path.

Quality:

  • Minor: the aliased import (installMapTransformCompat as _installMapTransformCompat) plus a separate export { installMapTransformCompat } from ... re-export creates two bindings for the same function where a single import + export {} would do (posted inline). Purely stylistic. Confidence: low.
  • Minor/optional: no automated test asserts that importing @geolibre/map/headless itself triggers the shim installation — map-transform-compat.test.ts only exercises the underlying function directly (already true before this PR, via map-controller.ts's import). Since the new code is a single trivial call, this is a small coverage gap rather than a real risk. Confidence: low.

CLAUDE.md: No violations. packages/map is a published package (main/types/exports point at src, publishConfig at dist), and this change doesn't touch that split. No i18n, Tauri CSP, or other documented mirror/convention is implicated by this file.

Overall: a small, well-scoped, correct fix consistent with the codebase's existing pattern for this shim.

@giswqs giswqs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for your contribution.

@giswqs
giswqs merged commit 0b6a405 into opengeos:main Aug 24, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants