@nika-js/onlymap 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -5
- package/dist/{basemap-C0RKcLaL.js → basemap-COurZNDH.js} +2126 -2105
- package/dist/basemap-registry.d.ts +49 -0
- package/dist/basemap.d.ts +22 -2
- package/dist/html-data.d.ts +2 -2
- package/dist/{index-CZf9WlZe.js → index-COu-3-gN.js} +1 -1
- package/dist/{index-DeEur5Xk.js → index-CgyAD98B.js} +1 -1
- package/dist/{index-DnvxPnDF.js → index-CvfuISOc.js} +11661 -11466
- package/dist/{index-BDJ9hHXv.js → index-D-X8KPA1.js} +1 -1
- package/dist/{index-GTGi85ZO.js → index-DuvXK95V.js} +2 -2
- package/dist/index.d.ts +5 -0
- package/dist/onlymapjs.js +20 -17
- package/dist/onlymapjs.umd.cjs +277 -271
- package/dist/programmatic.d.ts +11 -1
- package/dist/react/om-map.d.ts +5 -1
- package/dist/react.js +136 -128
- package/dist/runtime-core.d.ts +34 -1
- package/dist/widget-registry.d.ts +2 -0
- package/docs/basemaps.md +89 -0
- package/docs/react.md +1 -1
- package/llms.txt +3 -3
- package/onlymapjs.html-data.json +57 -1
- package/package.json +1 -1
- package/skills/onlymapjs/SKILL.md +14 -2
- package/skills/onlymapjs/references/react.md +68 -0
- package/skills/onlymapjs/references/syntax.md +5 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Basemap preset registry (spec: "Basemap presets & switching") — the sixth
|
|
3
|
+
* plugin surface, alongside registerLayer/Widget/Action/Source/Format.
|
|
4
|
+
* Deliberately maplibre-free: validation, html-data generation, and om-map
|
|
5
|
+
* all consult it without pulling the ~326 KB gz maplibre chunk; only
|
|
6
|
+
* basemap.ts (already inside that chunk) consumes the resolved style.
|
|
7
|
+
*
|
|
8
|
+
* A MapTiler key is a PUBLISHABLE, origin-restricted client key — it ships
|
|
9
|
+
* in page source by design, so unlike data credentials (configureData) it
|
|
10
|
+
* may appear in markup (`basemap-key`) or be configured once
|
|
11
|
+
* (`OmMap.configureBasemap({ maptilerKey })`).
|
|
12
|
+
*/
|
|
13
|
+
/** A MapLibre style: a URL string (possibly with a `{key}` placeholder) or an inline style-spec object. */
|
|
14
|
+
export type BasemapStyle = string | Record<string, unknown>;
|
|
15
|
+
export interface BasemapPreset {
|
|
16
|
+
style: BasemapStyle;
|
|
17
|
+
/** Extra attribution line beyond what the style's tile sources declare (MapLibre renders source attributions automatically). */
|
|
18
|
+
attribution?: string;
|
|
19
|
+
/** Display name for the basemap-switcher widget (falls back to the preset name). */
|
|
20
|
+
label?: string;
|
|
21
|
+
/** Which key `{key}` substitutes — currently only "maptiler". */
|
|
22
|
+
requiresKey?: "maptiler";
|
|
23
|
+
}
|
|
24
|
+
/** MapLibre's own official, freely-hosted demo style — the zero-config `basemap="maplibre"` default (back-compat). */
|
|
25
|
+
export declare const MAPLIBRE_DEMO_STYLE = "https://demotiles.maplibre.org/style.json";
|
|
26
|
+
export declare function registerBasemap(name: string, preset: BasemapPreset): void;
|
|
27
|
+
export declare function getBasemap(name: string): BasemapPreset | undefined;
|
|
28
|
+
export declare function getAllBasemaps(): ReadonlyMap<string, BasemapPreset>;
|
|
29
|
+
/** Provider keys for keyed presets — one call covers every layer of the app. */
|
|
30
|
+
export declare function configureBasemap(config: {
|
|
31
|
+
maptilerKey?: string;
|
|
32
|
+
}): void;
|
|
33
|
+
/** Static-validation support: is a key available for this provider (from configureBasemap)? */
|
|
34
|
+
export declare function hasConfiguredKey(provider: "maptiler"): boolean;
|
|
35
|
+
export interface ResolvedBasemap {
|
|
36
|
+
style: BasemapStyle;
|
|
37
|
+
attribution?: string;
|
|
38
|
+
/** Resolution problem (unknown name / missing key) — the caller decides how loudly to fail; `style` is always usable (demo fallback). */
|
|
39
|
+
error?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* `basemap` attribute value → concrete style. Precedence: explicit URL /
|
|
43
|
+
* `.json` path passes through untouched (bring-your-own, keys inline);
|
|
44
|
+
* `maplibre` / `maplibre-*` → the demo style (back-compat); anything else
|
|
45
|
+
* is a registry lookup. Unknown names and keyless keyed presets resolve to
|
|
46
|
+
* the demo style WITH an `error` — the live path logs it, validation turns
|
|
47
|
+
* it into a structured entry, and the map still renders something.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveBasemapStyle(raw: string, keyAttr?: string): ResolvedBasemap;
|
package/dist/basemap.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "maplibre-gl/dist/maplibre-gl.css";
|
|
2
2
|
import type { DeckProps, Viewport } from "@deck.gl/core";
|
|
3
|
+
import type { ResolvedBasemap } from "./basemap-registry";
|
|
3
4
|
export interface ViewportLike {
|
|
4
5
|
project(xyz: number[]): number[];
|
|
5
6
|
getBounds(): [number, number, number, number];
|
|
@@ -18,6 +19,10 @@ export interface BasemapViewState {
|
|
|
18
19
|
export declare class MapLibreBasemapAdapter {
|
|
19
20
|
private map;
|
|
20
21
|
private overlay;
|
|
22
|
+
/** Our own compact attribution control (spec: "attribution becomes correct, not optional") — undefined when the author opted out. */
|
|
23
|
+
private attribution?;
|
|
24
|
+
private attributionText?;
|
|
25
|
+
private showAttribution;
|
|
21
26
|
/**
|
|
22
27
|
* One-time "has the map initialized at least once" flag, set by the first
|
|
23
28
|
* `load` event. Deliberately NOT `this.map.loaded()` — that method means
|
|
@@ -34,18 +39,33 @@ export declare class MapLibreBasemapAdapter {
|
|
|
34
39
|
*/
|
|
35
40
|
private initialized;
|
|
36
41
|
private loadCallbacks;
|
|
37
|
-
constructor(container: HTMLElement,
|
|
42
|
+
constructor(container: HTMLElement, resolved: ResolvedBasemap, initialView: {
|
|
38
43
|
longitude: number;
|
|
39
44
|
latitude: number;
|
|
40
45
|
zoom: number;
|
|
41
46
|
pitch?: number;
|
|
42
47
|
bearing?: number;
|
|
43
|
-
}, deckProps: DeckProps);
|
|
48
|
+
}, deckProps: DeckProps, showAttribution?: boolean);
|
|
44
49
|
private markInitialized;
|
|
45
50
|
onLoad(cb: () => void): void;
|
|
46
51
|
/** Fires continuously during pan/zoom/rotate — MapLibre's own camera-change event, standing in for deck's onViewStateChange (which doesn't apply — deck isn't driving the camera). */
|
|
47
52
|
onMove(cb: () => void): void;
|
|
48
53
|
setLayers(layers: DeckProps["layers"]): void;
|
|
54
|
+
/**
|
|
55
|
+
* Live basemap switch (spec: "Basemap presets & switching"). Deck layers
|
|
56
|
+
* survive BY CONSTRUCTION: the MapboxOverlay is a map control, not style
|
|
57
|
+
* layers, and controls persist across `setStyle` — as does the camera.
|
|
58
|
+
* MapLibre diffs same-source styles and falls back to a full style reload
|
|
59
|
+
* internally when the diff fails (the cross-provider case).
|
|
60
|
+
*/
|
|
61
|
+
setStyle(resolved: ResolvedBasemap): void;
|
|
62
|
+
/**
|
|
63
|
+
* (Re)mounts the compact attribution control. Source-declared attributions
|
|
64
|
+
* (what OpenFreeMap/CARTO/OSM styles carry) are read live by the control on
|
|
65
|
+
* every style change; only the PRESET-level `attribution` override needs a
|
|
66
|
+
* remount, since `customAttribution` is fixed at construction.
|
|
67
|
+
*/
|
|
68
|
+
private mountAttribution;
|
|
49
69
|
/** Toggle map interactions (spec: "Manual Drawing", D4) — used to suspend double-click-zoom while a draw tool is active. */
|
|
50
70
|
setInteractive(opts: {
|
|
51
71
|
doubleClickZoom?: boolean;
|
package/dist/html-data.d.ts
CHANGED
|
@@ -15,9 +15,9 @@ interface TagData {
|
|
|
15
15
|
}[];
|
|
16
16
|
}
|
|
17
17
|
/** Hand-authored action list — validated against hasAction() in html-data.test.ts. */
|
|
18
|
-
export declare const BUILTIN_ACTIONS: readonly ["toggle-layer", "zoom-in", "zoom-out", "filter-layer", "highlight-feature", "fade", "pulse", "populate", "trace", "story-play", "story-pause", "story-seek", "fly-to", "zoom-to-feature", "show-overlay", "hide-overlay", "show-tooltip", "hide-tooltip", "draw-mode", "draw-commit", "draw-cancel", "draw-delete", "draw-clear", "draw-config", "draw-save"];
|
|
18
|
+
export declare const BUILTIN_ACTIONS: readonly ["toggle-layer", "zoom-in", "zoom-out", "filter-layer", "highlight-feature", "fade", "pulse", "populate", "trace", "story-play", "story-pause", "story-seek", "fly-to", "zoom-to-feature", "show-overlay", "hide-overlay", "show-tooltip", "hide-tooltip", "draw-mode", "draw-commit", "draw-cancel", "draw-delete", "draw-clear", "draw-config", "draw-save", "set-basemap"];
|
|
19
19
|
/** Hand-authored widget types — validated against the widget registry in html-data.test.ts. */
|
|
20
|
-
export declare const BUILTIN_WIDGETS: readonly ["legend", "layer-switcher", "zoom-controls", "scale-bar", "attribution", "filter", "vega-lite", "player", "draw"];
|
|
20
|
+
export declare const BUILTIN_WIDGETS: readonly ["legend", "layer-switcher", "zoom-controls", "scale-bar", "attribution", "filter", "vega-lite", "player", "draw", "basemap-switcher"];
|
|
21
21
|
export declare function buildHtmlCustomData(): {
|
|
22
22
|
version: number;
|
|
23
23
|
tags: TagData[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Oe = Object.defineProperty;
|
|
2
2
|
var ke = (r, e, t) => e in r ? Oe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
3
|
var l = (r, e, t) => ke(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { g as ve, a as ce, b as he, i as Fe, t as je, l as xe } from "./index-
|
|
4
|
+
import { g as ve, a as ce, b as he, i as Fe, t as je, l as xe } from "./index-CvfuISOc.js";
|
|
5
5
|
import { ai as Ie, h as ue, au as X, a2 as W, af as fe, Y as Ne, F as Le, aR as Ue, S as Me, bP as qe } from "./recordbatch-HRu0SMKp.js";
|
|
6
6
|
import { g as $, a as de, b as Ve, c as $e, d as Pe, e as He, m as ze } from "./table-accessors-DBjWgN0C.js";
|
|
7
7
|
import { c as Qe } from "./convert-arrow-schema-CvZ3cT5m.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Ri = Object.defineProperty;
|
|
2
2
|
var Ii = (t, a, i) => a in t ? Ri(t, a, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[a] = i;
|
|
3
3
|
var N = (t, a, i) => Ii(t, typeof a != "symbol" ? a + "" : a, i);
|
|
4
|
-
import { t as zt, $ as ca, a0 as ua, a1 as wi } from "./index-
|
|
4
|
+
import { t as zt, $ as ca, a0 as ua, a1 as wi } from "./index-CvfuISOc.js";
|
|
5
5
|
import { c as Si } from "./convert-arrow-schema-CvZ3cT5m.js";
|
|
6
6
|
import { ai as Ni, af as Nt, h as Ci, au as Pi, a2 as Oi } from "./recordbatch-HRu0SMKp.js";
|
|
7
7
|
class Ti {
|