doxa-maps/library/utils/README.md
swift-river542 a876e5e97b Host-agnostic share links, token-endpoint chain, dev playground as reusable modules, share/asset gates, validated profile-type vocabulary
- ShareButton resolves its link from where the bundle is hosted (profile-config.shareUrl ->
  embedBaseUrl -> window.MAP_EMBED_BASE_URL -> the bundle's own script URL); profiles pass
  tree-relative embed pages, so links work in the playground, on doxa.life and on any CDN
- Generated leaf pages try token endpoints in order (override -> configured absolute URL ->
  same-origin) and only then offer the paste-once box; build config points at the canonical
  https://doxa.life/api/maps/token
- Dev playground extracted from vite.config.js into internal/playground/{discover,render,dev-plugin}.mjs;
  serves /assets/* like the built site so data-driven maps initialise; passes assetsBase +
  shareUrl to every element; header ladder with a Start-here primer and the five kinds of
  mounting files (single-element, preset-element, multi-view-element, composite-element, app-shell)
- New gates: smoke:playground (every element boots, with status text + data diagnostics),
  smoke:share (Share URL resolves and reopens the same map), sync:dropin (mirror public/ into a
  host checkout, never credentials), deploy:dev (build + sync)
- MapToolbar + ShareButton on every map profile; UPG-100 composite (map + prayer lists) on the
  pane layout; shared --map-radius token consumed by the legend components
- docs/reference.md: profile types table, profile-config assetsBase/shareUrl/embedBaseUrl, gates
2026-09-16 12:10:38 -05:00

17 lines
1.1 KiB
Markdown

# library/utils/ — pure JS helpers
No Vue, no Pinia, no Mapbox. Anything reactive is a composable; anything stateful is a store.
| File | Purpose |
|---|---|
| `apiBaseUrl.js` | Resolves the API base URL at runtime (`window.MAP_APP_API_URL` / `VITE_API_BASE_URL`) |
| `embedBase.js` | Share/embed URL ladder — the built bundle derives its tree root from its own script url (`profileConfig.shareUrl` / `embedBaseUrl` / `window.MAP_EMBED_BASE_URL` override) so tree-relative `<bundle>/<profile>/index.html` links work on any host |
| `geoUtils.js` | Centroid, bounds, validation, GeoJSON helpers |
| `ClusterHelpers.js` | Shared helpers for the two clustering utilities below |
| `MSTClusteringUtil.js` | Minimum-spanning-tree clustering for affinity blocks |
| `NetworkClusteringUtil.js` | Network-line clustering — connect nearby pins with edges |
- No `import { ref } from 'vue'` and no `import mapboxgl` in this folder — operate on plain
`[lng, lat]` arrays.
- Named exports (for tree-shaking), JSDoc on every export.
- Writing reactive logic or needing Mapbox APIs? That's a composable — move it to `../composables/`.