@nika-js/onlymap 0.3.5 → 0.4.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.
Files changed (34) hide show
  1. package/README.md +5 -4
  2. package/dist/{LercDecode.es-C1xVetIa.js → LercDecode.es-B35eeLUh.js} +1 -1
  3. package/dist/{basemap-BkoYlZXu.js → basemap--znNIrJq.js} +8 -2
  4. package/dist/basemap.d.ts +8 -1
  5. package/dist/ctx.d.ts +4 -0
  6. package/dist/elements/om-map.d.ts +33 -3
  7. package/dist/elements/om-widget.d.ts +15 -0
  8. package/dist/external-store.d.ts +95 -0
  9. package/dist/{index-i_KAvtQZ.js → index-BKiyX-jQ.js} +10349 -10051
  10. package/dist/{index-CY7o8j7i.js → index-C8twrrDP.js} +2 -2
  11. package/dist/{index-Ck0N90Ri.js → index-CHmCCmPV.js} +1 -1
  12. package/dist/{index-BJvRiLIi.js → index-ClqgDar6.js} +1 -1
  13. package/dist/{index-DAx8ax6u.js → index-_K3U-Ww1.js} +1 -1
  14. package/dist/index.d.ts +5 -0
  15. package/dist/{lerc-DWGhMWvo.js → lerc-filCwJiM.js} +2 -2
  16. package/dist/onlymap.standalone.js +14343 -14039
  17. package/dist/onlymapjs.js +57 -48
  18. package/dist/programmatic.d.ts +42 -5
  19. package/dist/{raster-Da1auFQH.js → raster-xUPg8Z-C.js} +2 -2
  20. package/dist/react/context.d.ts +5 -3
  21. package/dist/react/om-map.d.ts +2 -0
  22. package/dist/react/om-widget.d.ts +4 -1
  23. package/dist/react.js +216 -186
  24. package/dist/runtime-core.d.ts +9 -2
  25. package/dist/version.d.ts +1 -1
  26. package/dist/widget-layout.d.ts +62 -0
  27. package/docs/external-stores.md +135 -0
  28. package/docs/react.md +3 -1
  29. package/llms.txt +3 -3
  30. package/onlymapjs.html-data.json +36 -1
  31. package/package.json +11 -6
  32. package/skills/onlymapjs/SKILL.md +2 -2
  33. package/skills/onlymapjs/references/react.md +4 -3
  34. package/skills/onlymapjs/references/syntax.md +1 -1
package/dist/onlymapjs.js CHANGED
@@ -1,58 +1,67 @@
1
- import { ay as e, az as r, aA as o, aB as t, aq as i, aC as n, aD as b, aE as l, aF as c, aG as g, aH as m, aI as p, aJ as L, aK as y, ap as T, aL as S, ax as u, W as d, aM as E, aN as M, aO as A, aP as I, aQ as f, aR as x, aS as C, aT as h, aU as B, aV as D, aW as R, aX as w, aY as v, aZ as F, a_ as G, a$ as N, b0 as O, b1 as W, b2 as _, b3 as z, b4 as H, b5 as J, b6 as k, b7 as P, b8 as V, b9 as Y, ba as j, bb as q, bc as K, bd as Q, be as U, bf as X, bg as Z, bh as $, bi as aa, bj as sa, bk as ea } from "./index-i_KAvtQZ.js";
1
+ import { ay as e, az as r, aA as o, aB as t, aC as i, aq as n, aD as b, aE as l, aF as S, aG as L, aH as p, aI as c, aJ as g, aK as m, aL as T, aM as y, aN as E, ap as A, aO as I, ax as u, aP as d, W as M, aQ as _, aR as C, aS as D, aT as O, aU as f, aV as x, aW as N, aX as h, aY as B, aZ as G, a_ as R, a$ as W, b0 as v, b1 as w, b2 as Y, b3 as F, b4 as P, b5 as k, b6 as z, b7 as H, b8 as J, b9 as V, ba as q, bb as K, bc as U, bd as j, be as Q, bf as X, bg as Z, bh as $, bi as aa, bj as sa, bk as ea, bl as ra, bm as oa, bn as ta, bo as ia, bp as na, bq as ba, br as la, bs as Sa, bt as La } from "./index-BKiyX-jQ.js";
2
2
  export {
3
- e as AccessorCache,
4
- r as BitmapLayer,
5
- o as COORDINATE_SYSTEM,
6
- t as CompileError,
7
- i as CompositeLayer,
8
- n as GeoJsonLayer,
9
- b as IconLayer,
10
- l as LIGHTING_PRESET_NAMES,
11
- c as Layer,
12
- g as LayerExtension,
3
+ e as ALL_POSITION_VALUES,
4
+ r as AccessorCache,
5
+ o as BitmapLayer,
6
+ t as COORDINATE_SYSTEM,
7
+ i as CompileError,
8
+ n as CompositeLayer,
9
+ b as GeoJsonLayer,
10
+ l as IconLayer,
11
+ S as LEGACY_POSITION_ALIASES,
12
+ L as LIGHTING_PRESET_NAMES,
13
+ p as Layer,
14
+ c as LayerExtension,
15
+ g as MANAGED_SLOTS,
13
16
  m as MapController,
14
- p as OmMap,
15
- L as ScatterplotLayer,
16
- y as ScenegraphLayer,
17
- T as SimpleMeshLayer,
18
- S as Tile3DLayer,
17
+ T as OmMap,
18
+ y as ScatterplotLayer,
19
+ E as ScenegraphLayer,
20
+ A as SimpleMeshLayer,
21
+ I as Tile3DLayer,
19
22
  u as TileLayer,
20
- d as WebMercatorViewport,
21
- E as arrowTableToColumnar,
22
- M as asRows,
23
- A as compileExpression,
24
- I as compileFullJsAccessorBlockInSandbox,
23
+ d as WIDGET_STYLE_KEY_NAMES,
24
+ M as WebMercatorViewport,
25
+ _ as arrowTableToColumnar,
26
+ C as asRows,
27
+ D as compileExpression,
28
+ O as compileFullJsAccessorBlockInSandbox,
25
29
  f as computeTimeline,
26
30
  x as configureBasemap,
27
- C as configureData,
31
+ N as configureData,
28
32
  h as configureLicense,
29
33
  B as configureTelemetry,
30
- D as descriptorToIR,
34
+ G as descriptorToIR,
31
35
  R as destroySandbox,
32
- w as evaluateInSandbox,
36
+ W as evaluateInSandbox,
33
37
  v as getBasemap,
34
- F as getEntitlements,
35
- G as getLayerSchema,
36
- N as getTerrain,
37
- O as isBrowser,
38
- W as isColumnar,
39
- _ as loadRasterModule,
40
- z as mountForTest,
41
- H as normalizeData,
42
- J as parseDurationMs,
43
- k as parseTerrainAttrs,
44
- P as registerAction,
45
- V as registerBasemap,
46
- Y as registerFormat,
47
- j as registerLayer,
48
- q as registerSource,
49
- K as registerTerrain,
50
- Q as registerWidget,
51
- U as resolveLighting,
52
- X as rowAt,
53
- Z as sandboxHtml,
54
- $ as snapshotIR,
55
- aa as solarAzElDegrees,
56
- sa as validateManifest,
57
- ea as validateManifestString
38
+ w as getEntitlements,
39
+ Y as getLayerSchema,
40
+ F as getTerrain,
41
+ P as isBrowser,
42
+ k as isColumnar,
43
+ z as isStoreToken,
44
+ H as loadRasterModule,
45
+ J as mountForTest,
46
+ V as normalizeData,
47
+ q as parseDurationMs,
48
+ K as parseTerrainAttrs,
49
+ U as parseWidgetStyle,
50
+ j as registerAction,
51
+ Q as registerBasemap,
52
+ X as registerFormat,
53
+ Z as registerLayer,
54
+ $ as registerSource,
55
+ aa as registerTerrain,
56
+ sa as registerWidget,
57
+ ea as resolveLighting,
58
+ ra as resolveSlot,
59
+ oa as rowAt,
60
+ ta as sandboxHtml,
61
+ ia as slotContainerStyle,
62
+ na as slotLayout,
63
+ ba as snapshotIR,
64
+ la as solarAzElDegrees,
65
+ Sa as validateManifest,
66
+ La as validateManifestString
58
67
  };
@@ -18,8 +18,10 @@ import { type CameraOptions } from "./runtime-core";
18
18
  import { type LightingIR, type LightingOptions } from "./scene-lighting";
19
19
  import type { TerrainIR } from "./terrain";
20
20
  import { type SnapshotOptions } from "./snapshot";
21
+ import { type TokenStore, type ViewOrigin, type ViewportSnapshot, type DataVersionSnapshot } from "./external-store";
21
22
  import type { LayerIR } from "./ir";
22
23
  import { type RuntimeContext } from "./ctx";
24
+ import type { LayerMetaSnapshot } from "./ctx";
23
25
  import type { Selection } from "./selection";
24
26
  import type { ValidationEntry } from "./validation";
25
27
  import type { MapViewport } from "./basemap";
@@ -96,9 +98,12 @@ export interface MapControllerOptions {
96
98
  /**
97
99
  * Camera settled (trailing-debounced, the `om-view-changed` twin) — for
98
100
  * camera persistence. Per-frame viewport churn goes to `watch(["viewport"])`;
99
- * this fires once with the destination.
101
+ * this fires once with the destination. `origin` is "user" when ANY change
102
+ * in the settled burst came from a canvas gesture (a drag's inertia tail
103
+ * alone must not relabel the gesture), "programmatic" for pure API/story
104
+ * moves — the echo-suppression signal for store bridges.
100
105
  */
101
- onViewChange?: (view: CameraState) => void;
106
+ onViewChange?: (view: CameraState, origin: ViewOrigin) => void;
102
107
  /** Scene lighting (spec: "Scene Lighting") — the lighting* attributes' programmatic twin; omit for deck's default lights. */
103
108
  lighting?: LightingOptions;
104
109
  }
@@ -131,7 +136,18 @@ export declare class MapController {
131
136
  private commitPending;
132
137
  private destroyed;
133
138
  private firstCommitDone;
134
- private viewChangeTimer;
139
+ private readonly stores;
140
+ /** Origin of the most recent viewport change FRAME — latched through the settle tracker for snapshot reads. */
141
+ private lastViewOrigin;
142
+ /**
143
+ * Shared settle/burst tracker (the `om-view-changed` twin) — ALWAYS armed,
144
+ * onViewChange or not: the burst latch also feeds the viewport snapshot's
145
+ * `origin`, so it must reset on settle even for store-only consumers.
146
+ */
147
+ private readonly viewSettle;
148
+ private onViewChange?;
149
+ /** Per-layer data version counters (`data:<id>` snapshots) — bumped on every data change, monotonic for the controller's lifetime. */
150
+ private readonly dataVersions;
135
151
  private readyFired;
136
152
  private resolveReady;
137
153
  readonly ready: Promise<void>;
@@ -153,6 +169,29 @@ export declare class MapController {
153
169
  */
154
170
  watch(tokens: readonly string[], notify: (ctx: RuntimeContext) => void): () => void;
155
171
  private notifyWatchers;
172
+ /**
173
+ * Per-token `{subscribe, getSnapshot}` store — the framework-free surface
174
+ * for `useSyncExternalStore`, MobX autoruns, Redux listeners, Zustand
175
+ * mirrors (recipes: docs/external-stores.md). Snapshots are cached
176
+ * immutable PLAIN DATA: `getSnapshot()` returns the SAME reference until
177
+ * this token's next change event, and never contains closures — rich
178
+ * reads (`project`, `data()`, `stats()`) stay on `ctx`. Tokens:
179
+ * - "viewport" → ViewportSnapshot (camera + bounds + origin)
180
+ * - "selection" → Selection | null
181
+ * - "layers" → LayerMetaSnapshot[] (what ctx.layers builds)
182
+ * - "data:<layerId>" → {version, rows} — a VERSION STAMP, not the rows
183
+ * (mirroring row arrays into a store per tick is the anti-pattern the
184
+ * Redux performance guidance warns about; fetch rows via ctx.data()).
185
+ * `history` is deliberately NOT a store here — the app owns state on the
186
+ * programmatic front-end. Calling twice for one token returns the
187
+ * identical store object.
188
+ */
189
+ getStore(token: "viewport"): TokenStore<ViewportSnapshot>;
190
+ getStore(token: "selection"): TokenStore<Selection | null>;
191
+ getStore(token: "layers"): TokenStore<LayerMetaSnapshot[]>;
192
+ getStore(token: `data:${string}`): TokenStore<DataVersionSnapshot>;
193
+ getStore(token: string): TokenStore<unknown>;
194
+ private buildViewportSnapshot;
156
195
  /** The RuntimeContext contract (HU5) — identical to what HTML widget scripts receive as `ctx`. */
157
196
  buildCtx(): RuntimeContext;
158
197
  /** Picked object, normalized to flat — same path as OmMapElement (GeoJSON properties lifted; columnar rows materialized). */
@@ -216,6 +255,4 @@ export declare class MapController {
216
255
  /** Projects a lng/lat through the current viewport — undefined before the viewport resolves. */
217
256
  project(lngLat: [number, number]): [number, number] | undefined;
218
257
  destroy(): void;
219
- /** Trailing-debounced onViewChange — see MapControllerOptions.onViewChange. */
220
- private scheduleViewChange;
221
258
  }
@@ -1,5 +1,5 @@
1
1
  import { w as kt, t as Ni, f as Oi, m as Ri } from "./mgrs-BY9bIvp4.js";
2
- import { an as Fi, ao as zi, ap as Ks, aq as Ws, ar as Di, b as Bi, as as Ui, l as es, at as ki, d as qi, au as Ki, av as Wi, aw as Xi, ax as Xs } from "./index-i_KAvtQZ.js";
2
+ import { an as Fi, ao as zi, ap as Ks, aq as Ws, ar as Di, b as Bi, as as Ui, l as es, at as ki, d as qi, au as Ki, av as Wi, aw as Xi, ax as Xs } from "./index-BKiyX-jQ.js";
3
3
  function Hi(t, e, s) {
4
4
  const { projectedCorners: i } = e, { topLeft: a, topRight: r, bottomRight: o, bottomLeft: n } = i, h = s(a[0], a[1]), l = s(r[0], r[1]), c = s(o[0], o[1]), u = s(n[0], n[1]), d = [
5
5
  h,
@@ -2377,7 +2377,7 @@ it.set(G.Zstd, () => import("./zstd-jXobGRcq.js").then((t) => t.decode));
2377
2377
  it.set(G.Jpeg, () => Promise.resolve(ke));
2378
2378
  it.set(G.Jpeg6, () => Promise.resolve(ke));
2379
2379
  it.set(G.Webp, () => Promise.resolve(ke));
2380
- it.set(G.Lerc, () => import("./lerc-DWGhMWvo.js").then((t) => t.l).then((t) => t.decode));
2380
+ it.set(G.Lerc, () => import("./lerc-filCwJiM.js").then((t) => t.l).then((t) => t.decode));
2381
2381
  async function qe(t, e, s) {
2382
2382
  const i = it.get(e);
2383
2383
  if (!i)
@@ -1,12 +1,14 @@
1
1
  import type { MapController, LayerDescriptor } from "@nika-js/onlymap";
2
- export type WidgetPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
2
+ import type { ManagedSlot } from "@nika-js/onlymap";
3
+ /** A managed slot (spec: "Widget Layout Manager"), a legacy corner alias, or the author-styled `manual` tier. */
4
+ export type WidgetPosition = ManagedSlot | "manual" | "top-left" | "top-right" | "bottom-left" | "bottom-right";
3
5
  export interface OmMapContextValue {
4
6
  controller: MapController;
5
7
  layers: LayerRegistry;
6
8
  /** The pane <OmOverlay> portals into — absolutely positioned above the canvas, pointer-events: none. */
7
9
  overlayPane: HTMLDivElement;
8
- /** Corner containers <OmWidget> portals into (filled as OmMap's own DOM mounts). */
9
- corners: Readonly<Record<WidgetPosition, HTMLDivElement | null>>;
10
+ /** Slot containers <OmWidget> portals into (filled as OmMap's own DOM mounts). */
11
+ corners: Readonly<Record<ManagedSlot, HTMLDivElement | null>>;
10
12
  }
11
13
  export declare const OmMapContext: import("react").Context<OmMapContextValue | null>;
12
14
  export declare function useOmMapContext(caller: string): OmMapContextValue;
@@ -18,6 +18,8 @@ export interface OmMapProps {
18
18
  width?: number;
19
19
  height?: number;
20
20
  };
21
+ /** Layout-token sugar, the `widget-style` attribute's twin: `"gap:10 opacity:0.9"` → `--om-widget-*` custom properties on the widget layer. */
22
+ widgetStyle?: string;
21
23
  className?: string;
22
24
  style?: CSSProperties;
23
25
  children?: ReactNode;
@@ -1,9 +1,12 @@
1
1
  import type { CSSProperties, ReactNode } from "react";
2
2
  import { type WidgetPosition } from "./context";
3
3
  export interface OmWidgetProps {
4
+ /** A managed slot (`top-start` … `bottom-end`), a legacy corner alias, or `manual`. Default `top-start`. */
4
5
  position?: WidgetPosition;
6
+ /** Deterministic in-slot ordering (flex `order`); default is mount order. */
7
+ order?: number;
5
8
  className?: string;
6
9
  style?: CSSProperties;
7
10
  children?: ReactNode;
8
11
  }
9
- export declare function OmWidget({ position, className, style, children }: OmWidgetProps): ReactNode;
12
+ export declare function OmWidget({ position, order, className, style, children }: OmWidgetProps): ReactNode;