Skip to content

feat: add first-party map package - #457

Merged
bambamboole merged 11 commits into
mainfrom
agent/map-package
Aug 14, 2026
Merged

feat: add first-party map package#457
bambamboole merged 11 commits into
mainfrom
agent/map-package

Conversation

@bambamboole

@bambamboole bambamboole commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add the provider-neutral lattice-php/map package with an OpenStreetMap/Leaflet provider: server-driven markers, automatic or click-opened popups, and complete Lattice component schemas inside popup content
  • keep Leaflet out of the initial bundle: the Composer plugin entry is a small lazy shell — the map component and the precompiled renderer (Leaflet bundled inside, React and the Lattice runtime shared with the host) load on the first map render, so pages without a map never pay for Leaflet (workbench app chunk 1.16 MB → 400 KB, renderer in its own 160 KB lazy chunk)
  • no-build apps publish the same self-contained dist/plugin.js via php artisan lattice:assets
  • wire the package into generated TypeScript types, standalone assets, release CI, the Workbench, and the documentation

Visual

Before: Lattice had no first-party map renderer or map demo.

After: /components/map in the Workbench renders Berlin and Potsdam markers on themed Leaflet tiles, opens the Berlin popup from the server configuration, and switches to the Potsdam server-provided schema when its marker is clicked.

Validation

  • composer check and npm run check green, CI 27/27
  • Pest feature tests: wire serialization, application-registered providers, marker/coordinate/zoom validation, both bundled locales
  • Chromium browser tests: real marker clicks, popup switching, viewport behavior, provider error states, and the Composer entry serving popups through the prebuilt renderer
  • standalone artifact built and verified (single module, host externals only)

Release prerequisite

  • create the lattice-php/map split repository before this package is released

@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 196.03kB (4.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
lattice-map-esm 196.03kB 196.03kB (100%) ⬆️

@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

@bambamboole
bambamboole changed the base branch from feat/wire-schema-artifacts to main August 14, 2026 07:49
@bambamboole bambamboole reopened this Aug 14, 2026
The Composer plugin entry is now a small source shell: the map component
loads lazily from source and the OpenStreetMap renderer loads Leaflet
through the self-contained dist artifact on first map render. Pages
without a map no longer pay for Leaflet; the workbench app chunk drops
from 1.16MB to 400KB with the renderer in its own 160KB lazy chunk.
No-build apps keep using dist/plugin.js via the standalone key.
…llback

The height maximum was policy without a need — full-bleed maps are now
possible; the 160px minimum matching the CSS min-height stays. The
'openstreetmap' fallback in prepareMap was unreachable because
mergeConfigFrom always supplies the key. Also merges the duplicated
.leaflet-control rule blocks in map.css.
The standalone build redirects every @lattice-php/* import in a dist
plugin to the runtime barrel, but useExtensionRegistry was never
re-exported there — rendering the map through dist/plugin.js (no-build
apps, stale-discovery dev servers) crashed with 'useExtensionRegistry
is not a function'. A browser test now renders the artifact's own map
component against the barrel so a missing re-export fails the suite.
Namespace JSON nests each PHP lang file under its basename, so client
keys must be 'map.loading', not 'loading' — the bare keys missed on
every lookup, rendered only the English defaults, and fired an i18next
saveMissing POST per key, which queued up on the single-worker
Testbench server and froze the workbench UI. The dist artifact is
rebuilt with the prefixed keys.
The root vite config maintains its /css aliases by hand and had none
for map, so '@lattice-php/map/css' fell through to the broader package
alias and the import was silently dropped — Leaflet's structural CSS
never loaded and tiles scattered across the page. Adds the alias, the
workbench app.css import, and documents the css import for build-step
consumers.
- Marker::icon() (BackedEnum|string via Wire::scalar) and Marker::color()
  (Color|ColorName|string via Color::from), rendered through an
  IconRenderer portal into the pin and the lt-tone class/vars, so custom
  icon renderers keep working in source, Composer, and dist builds.
- Pins point down again: the teardrop needs rotate -45deg, not 45deg.
- The view is set before markers are added — Leaflet only creates layer
  elements once the map has a view, so pin styling and the aria-label
  actually apply now.
- Cmd/Ctrl+wheel (and trackpad pinch) zooms while plain scrolling keeps
  scrolling the page; scrollZoom() still enables the bare wheel.
- coerceColor/toneProps join the runtime barrel for the dist build; the
  workbench demo grows to 600px with an iconed, colored Potsdam marker.
@bambamboole
bambamboole marked this pull request as ready for review August 14, 2026 12:58
@bambamboole
bambamboole enabled auto-merge (squash) August 14, 2026 12:58
@bambamboole
bambamboole merged commit b3deda6 into main Aug 14, 2026
28 checks passed
@bambamboole
bambamboole deleted the agent/map-package branch August 14, 2026 13:03
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.

1 participant