@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.
- package/README.md +5 -4
- package/dist/{LercDecode.es-C1xVetIa.js → LercDecode.es-B35eeLUh.js} +1 -1
- package/dist/{basemap-BkoYlZXu.js → basemap--znNIrJq.js} +8 -2
- package/dist/basemap.d.ts +8 -1
- package/dist/ctx.d.ts +4 -0
- package/dist/elements/om-map.d.ts +33 -3
- package/dist/elements/om-widget.d.ts +15 -0
- package/dist/external-store.d.ts +95 -0
- package/dist/{index-i_KAvtQZ.js → index-BKiyX-jQ.js} +10349 -10051
- package/dist/{index-CY7o8j7i.js → index-C8twrrDP.js} +2 -2
- package/dist/{index-Ck0N90Ri.js → index-CHmCCmPV.js} +1 -1
- package/dist/{index-BJvRiLIi.js → index-ClqgDar6.js} +1 -1
- package/dist/{index-DAx8ax6u.js → index-_K3U-Ww1.js} +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/{lerc-DWGhMWvo.js → lerc-filCwJiM.js} +2 -2
- package/dist/onlymap.standalone.js +14343 -14039
- package/dist/onlymapjs.js +57 -48
- package/dist/programmatic.d.ts +42 -5
- package/dist/{raster-Da1auFQH.js → raster-xUPg8Z-C.js} +2 -2
- package/dist/react/context.d.ts +5 -3
- package/dist/react/om-map.d.ts +2 -0
- package/dist/react/om-widget.d.ts +4 -1
- package/dist/react.js +216 -186
- package/dist/runtime-core.d.ts +9 -2
- package/dist/version.d.ts +1 -1
- package/dist/widget-layout.d.ts +62 -0
- package/docs/external-stores.md +135 -0
- package/docs/react.md +3 -1
- package/llms.txt +3 -3
- package/onlymapjs.html-data.json +36 -1
- package/package.json +11 -6
- package/skills/onlymapjs/SKILL.md +2 -2
- package/skills/onlymapjs/references/react.md +4 -3
- package/skills/onlymapjs/references/syntax.md +1 -1
package/dist/react.js
CHANGED
|
@@ -1,150 +1,143 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { jsxs as
|
|
5
|
-
import { createContext as
|
|
6
|
-
import { MapController as
|
|
7
|
-
import { createPortal as
|
|
8
|
-
const
|
|
9
|
-
function
|
|
10
|
-
const
|
|
11
|
-
if (!
|
|
12
|
-
return
|
|
1
|
+
var X = Object.defineProperty;
|
|
2
|
+
var Z = (t, e, n) => e in t ? X(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var B = (t, e, n) => Z(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { jsxs as ee, jsx as O } from "react/jsx-runtime";
|
|
5
|
+
import { createContext as te, useContext as re, forwardRef as ne, useRef as g, useState as N, useCallback as se, useMemo as x, useLayoutEffect as oe, useEffect as w, useImperativeHandle as ie, useSyncExternalStore as H } from "react";
|
|
6
|
+
import { MANAGED_SLOTS as ae, slotContainerStyle as ce, MapController as le, parseWidgetStyle as ue, resolveSlot as fe, isStoreToken as de } from "@nika-js/onlymap";
|
|
7
|
+
import { createPortal as J } from "react-dom";
|
|
8
|
+
const Y = te(null);
|
|
9
|
+
function $(t) {
|
|
10
|
+
const e = re(Y);
|
|
11
|
+
if (!e) throw new Error(`[onlymapjs] ${t} must be rendered inside <OmMap>.`);
|
|
12
|
+
return e;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
if (
|
|
16
|
-
const n = Object.keys(
|
|
17
|
-
return n.length !== r.length ? !1 : n.every((l) =>
|
|
14
|
+
function V(t, e) {
|
|
15
|
+
if (t === e) return !0;
|
|
16
|
+
const n = Object.keys(t ?? {}), r = Object.keys(e ?? {});
|
|
17
|
+
return n.length !== r.length ? !1 : n.every((l) => t[l] === e[l]);
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
const { props: n, updateTriggers: r, ...l } =
|
|
21
|
-
return
|
|
19
|
+
function ye(t, e) {
|
|
20
|
+
const { props: n, updateTriggers: r, ...l } = t, { props: f, updateTriggers: c, ...s } = e;
|
|
21
|
+
return V(l, s) && V(n, f) && V(r, c);
|
|
22
22
|
}
|
|
23
|
-
class
|
|
24
|
-
constructor(
|
|
25
|
-
|
|
26
|
-
this.controller =
|
|
23
|
+
class me {
|
|
24
|
+
constructor(e) {
|
|
25
|
+
B(this, "descriptors", /* @__PURE__ */ new Map());
|
|
26
|
+
this.controller = e;
|
|
27
27
|
}
|
|
28
|
-
upsert(
|
|
29
|
-
const n = this.descriptors.get(
|
|
30
|
-
n &&
|
|
28
|
+
upsert(e) {
|
|
29
|
+
const n = this.descriptors.get(e.id);
|
|
30
|
+
n && ye(n, e) || (this.descriptors.set(e.id, e), this.controller.setLayers([...this.descriptors.values()]));
|
|
31
31
|
}
|
|
32
|
-
remove(
|
|
33
|
-
this.descriptors.delete(
|
|
32
|
+
remove(e) {
|
|
33
|
+
this.descriptors.delete(e) && this.controller.setLayers([...this.descriptors.values()]);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
const
|
|
37
|
-
function
|
|
38
|
-
return
|
|
39
|
-
position: "absolute",
|
|
40
|
-
[e.startsWith("top") ? "top" : "bottom"]: 10,
|
|
41
|
-
[e.endsWith("left") ? "left" : "right"]: 10,
|
|
42
|
-
display: "flex",
|
|
43
|
-
flexDirection: "column",
|
|
44
|
-
gap: 8,
|
|
45
|
-
alignItems: e.endsWith("left") ? "flex-start" : "flex-end",
|
|
46
|
-
zIndex: 20,
|
|
47
|
-
// The container never intercepts the map's pointer events; each
|
|
48
|
-
// <OmWidget> shell re-enables its own.
|
|
49
|
-
pointerEvents: "none"
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
function ie(e, t) {
|
|
53
|
-
return Object.entries(t).some(([n, r]) => r !== void 0 && e[n] !== r);
|
|
36
|
+
const I = ae, ge = Object.fromEntries(I.map((t) => [t, ce(t)]));
|
|
37
|
+
function he(t, e) {
|
|
38
|
+
return Object.entries(e).some(([n, r]) => r !== void 0 && t[n] !== r);
|
|
54
39
|
}
|
|
55
|
-
const
|
|
56
|
-
const { center: r, zoom: l, pitch:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}), v = ee((s) => {
|
|
62
|
-
M((h) => h === s ? h : s);
|
|
63
|
-
}, []), w = I(
|
|
40
|
+
const Re = ne(function(e, n) {
|
|
41
|
+
const { center: r, zoom: l, pitch: f, bearing: c, basemap: s, basemapKey: a, attribution: d, headless: u, widgetStyle: p, className: z, style: h, children: b } = e, y = g(null), [o, v] = N(null), [S, T] = N(null), [E, R] = N(
|
|
42
|
+
() => Object.fromEntries(I.map((i) => [i, null]))
|
|
43
|
+
), k = se((i) => {
|
|
44
|
+
T((m) => m === i ? m : i);
|
|
45
|
+
}, []), j = x(
|
|
64
46
|
() => Object.fromEntries(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
(
|
|
68
|
-
|
|
47
|
+
I.map((i) => [
|
|
48
|
+
i,
|
|
49
|
+
(m) => {
|
|
50
|
+
R((M) => M[i] === m ? M : { ...M, [i]: m });
|
|
69
51
|
}
|
|
70
52
|
])
|
|
71
53
|
),
|
|
72
54
|
[]
|
|
73
|
-
),
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
if (!
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
center:
|
|
90
|
-
zoom:
|
|
91
|
-
pitch:
|
|
92
|
-
bearing:
|
|
93
|
-
basemap:
|
|
94
|
-
basemapKey:
|
|
95
|
-
attribution:
|
|
96
|
-
headless:
|
|
97
|
-
onRuntimeError: (
|
|
98
|
-
var
|
|
99
|
-
return (
|
|
55
|
+
), L = g({ center: r, zoom: l, pitch: f, bearing: c });
|
|
56
|
+
L.current = { center: r, zoom: l, pitch: f, bearing: c };
|
|
57
|
+
const P = g(e.onReady);
|
|
58
|
+
P.current = e.onReady;
|
|
59
|
+
const C = g(e.onViewStateChange);
|
|
60
|
+
C.current = e.onViewStateChange;
|
|
61
|
+
const F = g(e.onRuntimeError);
|
|
62
|
+
F.current = e.onRuntimeError;
|
|
63
|
+
const _ = g(s);
|
|
64
|
+
_.current = s;
|
|
65
|
+
const A = g(void 0), Q = u ? JSON.stringify(u) : "";
|
|
66
|
+
oe(() => {
|
|
67
|
+
if (!y.current) return;
|
|
68
|
+
const i = L.current;
|
|
69
|
+
A.current = _.current;
|
|
70
|
+
const m = new le(y.current, {
|
|
71
|
+
center: i.center,
|
|
72
|
+
zoom: i.zoom,
|
|
73
|
+
pitch: i.pitch,
|
|
74
|
+
bearing: i.bearing,
|
|
75
|
+
basemap: _.current,
|
|
76
|
+
basemapKey: a,
|
|
77
|
+
attribution: d,
|
|
78
|
+
headless: u ? u === !0 ? {} : u : void 0,
|
|
79
|
+
onRuntimeError: (K) => {
|
|
80
|
+
var q;
|
|
81
|
+
return (q = F.current) == null ? void 0 : q.call(F, K);
|
|
100
82
|
}
|
|
101
83
|
});
|
|
102
|
-
|
|
103
|
-
let
|
|
104
|
-
return
|
|
105
|
-
var
|
|
106
|
-
|
|
84
|
+
v(m);
|
|
85
|
+
let M = !0;
|
|
86
|
+
return m.ready.then(() => {
|
|
87
|
+
var K;
|
|
88
|
+
M && ((K = P.current) == null || K.call(P));
|
|
107
89
|
}), () => {
|
|
108
|
-
|
|
90
|
+
M = !1, v(null), m.destroy();
|
|
109
91
|
};
|
|
110
|
-
}, [
|
|
111
|
-
!o ||
|
|
112
|
-
}, [o,
|
|
92
|
+
}, [Q]), w(() => {
|
|
93
|
+
!o || A.current === s || (A.current = s, o.setBasemap(s ?? null));
|
|
94
|
+
}, [o, s]), ie(n, () => o, [o]), w(() => {
|
|
113
95
|
if (!o) return;
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
}, [o, r == null ? void 0 : r[0], r == null ? void 0 : r[1], l,
|
|
96
|
+
const i = { longitude: r == null ? void 0 : r[0], latitude: r == null ? void 0 : r[1], zoom: l, pitch: f, bearing: c };
|
|
97
|
+
he(o.getViewState(), i) && o.setView(i);
|
|
98
|
+
}, [o, r == null ? void 0 : r[0], r == null ? void 0 : r[1], l, f, c]), w(() => {
|
|
99
|
+
var i;
|
|
117
100
|
if (o)
|
|
118
|
-
return o.
|
|
119
|
-
var
|
|
120
|
-
return (
|
|
101
|
+
return (i = C.current) == null || i.call(C, o.getViewState()), o.getStore("viewport").subscribe(() => {
|
|
102
|
+
var m;
|
|
103
|
+
return (m = C.current) == null ? void 0 : m.call(C, o.getViewState());
|
|
121
104
|
});
|
|
122
105
|
}, [o]);
|
|
123
|
-
const
|
|
124
|
-
() =>
|
|
125
|
-
|
|
106
|
+
const U = x(
|
|
107
|
+
() => ({
|
|
108
|
+
position: "absolute",
|
|
109
|
+
inset: 0,
|
|
110
|
+
zIndex: 20,
|
|
111
|
+
pointerEvents: "none",
|
|
112
|
+
opacity: "var(--om-widget-opacity, 1)",
|
|
113
|
+
...p ? ue(p).properties : void 0
|
|
114
|
+
}),
|
|
115
|
+
[p]
|
|
116
|
+
), D = x(() => o ? new me(o) : null, [o]), W = x(
|
|
117
|
+
() => o && D && S ? { controller: o, layers: D, overlayPane: S, corners: E } : null,
|
|
118
|
+
[o, D, S, E]
|
|
126
119
|
);
|
|
127
|
-
return /* @__PURE__ */
|
|
128
|
-
/* @__PURE__ */
|
|
129
|
-
/* @__PURE__ */
|
|
120
|
+
return /* @__PURE__ */ ee("div", { className: z, style: { position: "relative", overflow: "hidden", ...h }, children: [
|
|
121
|
+
/* @__PURE__ */ O("div", { ref: y, style: { position: "absolute", inset: 0 } }),
|
|
122
|
+
/* @__PURE__ */ O(
|
|
130
123
|
"div",
|
|
131
124
|
{
|
|
132
|
-
ref:
|
|
125
|
+
ref: k,
|
|
133
126
|
style: { position: "absolute", top: 0, left: 0, zIndex: 10, pointerEvents: "none" }
|
|
134
127
|
}
|
|
135
128
|
),
|
|
136
|
-
|
|
129
|
+
/* @__PURE__ */ O("div", { "data-om-widget-layer": "", style: U, children: I.map((i) => /* @__PURE__ */ O(
|
|
137
130
|
"div",
|
|
138
131
|
{
|
|
139
|
-
"data-om-widget-
|
|
140
|
-
ref:
|
|
141
|
-
style:
|
|
132
|
+
"data-om-widget-slot": i,
|
|
133
|
+
ref: j[i],
|
|
134
|
+
style: ge[i]
|
|
142
135
|
},
|
|
143
|
-
|
|
144
|
-
)),
|
|
145
|
-
|
|
136
|
+
i
|
|
137
|
+
)) }),
|
|
138
|
+
W && /* @__PURE__ */ O(Y.Provider, { value: W, children: b })
|
|
146
139
|
] });
|
|
147
|
-
}),
|
|
140
|
+
}), be = /* @__PURE__ */ new Set([
|
|
148
141
|
"id",
|
|
149
142
|
"type",
|
|
150
143
|
"data",
|
|
@@ -164,55 +157,61 @@ const he = Z(function(t, n) {
|
|
|
164
157
|
"onClick",
|
|
165
158
|
"onHover"
|
|
166
159
|
]);
|
|
167
|
-
function
|
|
168
|
-
const { controller:
|
|
169
|
-
for (const [
|
|
170
|
-
!
|
|
171
|
-
const
|
|
160
|
+
function Ce(t) {
|
|
161
|
+
const { controller: e, layers: n } = $("OmLayer"), { id: r } = t, l = {};
|
|
162
|
+
for (const [a, d] of Object.entries(t))
|
|
163
|
+
!be.has(a) && d !== void 0 && (l[a] = d);
|
|
164
|
+
const f = {
|
|
172
165
|
id: r,
|
|
173
|
-
type:
|
|
174
|
-
data:
|
|
175
|
-
label:
|
|
176
|
-
color:
|
|
177
|
-
filterField:
|
|
178
|
-
filterRange:
|
|
179
|
-
filterSoftRange:
|
|
180
|
-
filterCategoryField:
|
|
181
|
-
filterCategories:
|
|
182
|
-
source:
|
|
183
|
-
key:
|
|
184
|
-
flush:
|
|
185
|
-
refresh:
|
|
186
|
-
terrain:
|
|
187
|
-
updateTriggers:
|
|
166
|
+
type: t.type,
|
|
167
|
+
data: t.data,
|
|
168
|
+
label: t.label,
|
|
169
|
+
color: t.color,
|
|
170
|
+
filterField: t.filterField,
|
|
171
|
+
filterRange: t.filterRange,
|
|
172
|
+
filterSoftRange: t.filterSoftRange,
|
|
173
|
+
filterCategoryField: t.filterCategoryField,
|
|
174
|
+
filterCategories: t.filterCategories,
|
|
175
|
+
source: t.source,
|
|
176
|
+
key: t.streamKey,
|
|
177
|
+
flush: t.flush,
|
|
178
|
+
refresh: t.refresh,
|
|
179
|
+
terrain: t.terrain,
|
|
180
|
+
updateTriggers: t.updateTriggers,
|
|
188
181
|
props: l
|
|
189
182
|
};
|
|
190
|
-
|
|
191
|
-
n.upsert(
|
|
192
|
-
}),
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
return
|
|
197
|
-
() =>
|
|
198
|
-
var
|
|
199
|
-
if (
|
|
200
|
-
(
|
|
183
|
+
w(() => {
|
|
184
|
+
n.upsert(f);
|
|
185
|
+
}), w(() => () => n.remove(r), [n, r]);
|
|
186
|
+
const c = g(t.onClick);
|
|
187
|
+
c.current = t.onClick;
|
|
188
|
+
const s = g(t.onHover);
|
|
189
|
+
return s.current = t.onHover, w(
|
|
190
|
+
() => e.watchPicks((a) => {
|
|
191
|
+
var d, u, p;
|
|
192
|
+
if (a === null) {
|
|
193
|
+
(d = s.current) == null || d.call(s, null);
|
|
201
194
|
return;
|
|
202
195
|
}
|
|
203
|
-
|
|
196
|
+
a.layerId === r && (a.type === "click" ? (u = c.current) == null || u.call(c, a) : (p = s.current) == null || p.call(s, a));
|
|
204
197
|
}),
|
|
205
|
-
[
|
|
198
|
+
[e, r]
|
|
206
199
|
), null;
|
|
207
200
|
}
|
|
208
|
-
function
|
|
209
|
-
const { corners:
|
|
210
|
-
|
|
211
|
-
/* @__PURE__ */
|
|
212
|
-
|
|
201
|
+
function xe({ position: t = "top-start", order: e, className: n, style: r, children: l }) {
|
|
202
|
+
const { corners: f } = $("OmWidget"), c = fe(t) ?? "top-start";
|
|
203
|
+
if (c === "manual")
|
|
204
|
+
return /* @__PURE__ */ O("div", { className: n, style: { pointerEvents: "auto", ...r }, children: l });
|
|
205
|
+
const s = f[c];
|
|
206
|
+
return s ? J(
|
|
207
|
+
/* @__PURE__ */ O("div", { className: n, style: { pointerEvents: "auto", ...e !== void 0 ? { order: e } : void 0, ...r }, children: l }),
|
|
208
|
+
s
|
|
213
209
|
) : null;
|
|
214
210
|
}
|
|
215
|
-
|
|
211
|
+
function G(t, e) {
|
|
212
|
+
return !e || (t == null ? void 0 : t.layerId) === e;
|
|
213
|
+
}
|
|
214
|
+
const ve = {
|
|
216
215
|
"top-left": "translate(0, 0)",
|
|
217
216
|
"top-center": "translate(-50%, 0)",
|
|
218
217
|
"top-right": "translate(-100%, 0)",
|
|
@@ -223,36 +222,52 @@ const ce = {
|
|
|
223
222
|
"bottom-center": "translate(-50%, -100%)",
|
|
224
223
|
"bottom-right": "translate(-100%, -100%)"
|
|
225
224
|
};
|
|
226
|
-
function
|
|
227
|
-
const { controller:
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
225
|
+
function Te(t) {
|
|
226
|
+
const { controller: e, overlayPane: n } = $("OmOverlay"), r = g(null), l = g(void 0), f = g(t);
|
|
227
|
+
f.current = t;
|
|
228
|
+
const c = x(() => {
|
|
229
|
+
const h = e.getStore("selection");
|
|
230
|
+
let b, y, o = null;
|
|
231
|
+
return {
|
|
232
|
+
subscribe: h.subscribe,
|
|
233
|
+
getSnapshot: () => {
|
|
234
|
+
const v = h.getSnapshot(), { anchorFrom: S, layer: T } = f.current, E = `${S ?? ""}|${T ?? ""}`;
|
|
235
|
+
return (v !== b || E !== y) && (b = v, y = E, S === "selection" && G(v, T) && (o = v)), o;
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
}, [e]), s = H(
|
|
239
|
+
c.subscribe,
|
|
240
|
+
c.getSnapshot,
|
|
241
|
+
c.getSnapshot
|
|
242
|
+
);
|
|
243
|
+
w(
|
|
244
|
+
() => e.registerOverlay((h, b) => {
|
|
245
|
+
const y = r.current;
|
|
246
|
+
if (!y) return;
|
|
247
|
+
const { anchor: o, anchorFrom: v, layer: S, visible: T = !0, anchorOffset: E } = f.current;
|
|
248
|
+
let R;
|
|
249
|
+
if (v === "selection" ? (G(b, S) && (l.current = (b == null ? void 0 : b.coordinate) ?? void 0), R = l.current) : R = o, !T || !R || !h) {
|
|
250
|
+
y.style.visibility = "hidden";
|
|
236
251
|
return;
|
|
237
252
|
}
|
|
238
|
-
const [
|
|
239
|
-
if (!(
|
|
240
|
-
|
|
253
|
+
const [k, j, L] = h.project([R[0], R[1], 0]);
|
|
254
|
+
if (!(k >= 0 && k <= h.width && j >= 0 && j <= h.height) || L !== void 0 && L < 0) {
|
|
255
|
+
y.style.visibility = "hidden";
|
|
241
256
|
return;
|
|
242
257
|
}
|
|
243
|
-
|
|
258
|
+
y.style.visibility = "visible", y.style.transform = `translate(${k}px, ${j}px) ${ve[E ?? "bottom-center"]}`;
|
|
244
259
|
}),
|
|
245
|
-
[
|
|
246
|
-
),
|
|
247
|
-
|
|
260
|
+
[e]
|
|
261
|
+
), w(() => {
|
|
262
|
+
e.refreshOverlays();
|
|
248
263
|
});
|
|
249
|
-
const { children:
|
|
250
|
-
return
|
|
251
|
-
/* @__PURE__ */
|
|
264
|
+
const { children: a, className: d, style: u, interactive: p = !0 } = t, z = typeof a == "function" ? a(s) : a;
|
|
265
|
+
return J(
|
|
266
|
+
/* @__PURE__ */ O(
|
|
252
267
|
"div",
|
|
253
268
|
{
|
|
254
269
|
ref: r,
|
|
255
|
-
className:
|
|
270
|
+
className: d,
|
|
256
271
|
style: {
|
|
257
272
|
position: "absolute",
|
|
258
273
|
top: 0,
|
|
@@ -260,8 +275,8 @@ function be(e) {
|
|
|
260
275
|
visibility: "hidden",
|
|
261
276
|
// hidden until the first flush positions it — never flashes at the origin
|
|
262
277
|
willChange: "transform",
|
|
263
|
-
pointerEvents:
|
|
264
|
-
...
|
|
278
|
+
pointerEvents: p ? "auto" : "none",
|
|
279
|
+
...u
|
|
265
280
|
},
|
|
266
281
|
children: z
|
|
267
282
|
}
|
|
@@ -269,14 +284,29 @@ function be(e) {
|
|
|
269
284
|
n
|
|
270
285
|
);
|
|
271
286
|
}
|
|
272
|
-
function
|
|
273
|
-
const { controller:
|
|
274
|
-
|
|
287
|
+
function Me(t = []) {
|
|
288
|
+
const { controller: e } = $("useOmMap"), n = t.join(" "), r = x(() => {
|
|
289
|
+
const c = (n ? n.split(" ") : []).flatMap((a) => de(a) ? [e.getStore(a)] : (console.warn(`[onlymapjs] useOmMap: "${a}" is not a watch token on the React front-end — expected viewport, selection, layers, or data:<layerId>.`), []));
|
|
290
|
+
let s;
|
|
291
|
+
return {
|
|
292
|
+
subscribe: (a) => {
|
|
293
|
+
const d = c.map((u) => u.subscribe(a));
|
|
294
|
+
return () => {
|
|
295
|
+
for (const u of d) u();
|
|
296
|
+
};
|
|
297
|
+
},
|
|
298
|
+
getSnapshot: () => {
|
|
299
|
+
const a = c.map((d) => d.getSnapshot());
|
|
300
|
+
return (!s || a.some((d, u) => d !== s[u])) && (s = a), s;
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
}, [e, n]), l = H(r.subscribe, r.getSnapshot, r.getSnapshot);
|
|
304
|
+
return x(() => e.buildCtx(), [e, l]);
|
|
275
305
|
}
|
|
276
306
|
export {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
307
|
+
Ce as OmLayer,
|
|
308
|
+
Re as OmMap,
|
|
309
|
+
Te as OmOverlay,
|
|
310
|
+
xe as OmWidget,
|
|
311
|
+
Me as useOmMap
|
|
282
312
|
};
|
package/dist/runtime-core.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type LightingIR } from "./scene-lighting";
|
|
2
2
|
import { type TerrainIR } from "./terrain";
|
|
3
|
+
import type { ViewOrigin } from "./external-store";
|
|
3
4
|
import type { LayerIR } from "./ir";
|
|
4
5
|
import { type Selection } from "./selection";
|
|
5
6
|
import type { ValidationEntry } from "./validation";
|
|
@@ -25,8 +26,14 @@ export interface CameraOptions {
|
|
|
25
26
|
curve?: boolean;
|
|
26
27
|
}
|
|
27
28
|
export interface RuntimeCoreCallbacks {
|
|
28
|
-
/**
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Fired whenever the view state changes (pan/zoom/pitch/bearing) — a
|
|
31
|
+
* notification, not a value. `origin` (spec: "External-Store Contract")
|
|
32
|
+
* distinguishes canvas gestures ("user") from camera APIs / actions /
|
|
33
|
+
* transition frames ("programmatic") — the mapbox `originalEvent`
|
|
34
|
+
* convention, the echo-loop half of two-way store binding.
|
|
35
|
+
*/
|
|
36
|
+
onViewportChange?: (origin: ViewOrigin) => void;
|
|
30
37
|
onSelectionChange?: (selection: Selection | null) => void;
|
|
31
38
|
/** Fired once the map (deck.gl standalone, or the basemap) has finished its async init (spec: Behavior Engine "load" event). */
|
|
32
39
|
onLoad?: () => void;
|
package/dist/version.d.ts
CHANGED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Widget layout vocabulary (spec: "Widget Layout Manager") — the shared,
|
|
3
|
+
* framework-free half of the slot system: slot names, legacy-corner
|
|
4
|
+
* aliasing, per-slot flex layout parameters, and the `widget-style` token
|
|
5
|
+
* sugar parser. Both front-ends derive their containers from THIS table
|
|
6
|
+
* (the HTML lane as cssText, the React lane as CSSProperties) so the two
|
|
7
|
+
* lanes cannot drift on placement semantics.
|
|
8
|
+
*
|
|
9
|
+
* Names are LOGICAL and RTL-aware: `-start`/`-end` map to CSS
|
|
10
|
+
* `inset-inline-*` and flex alignment, so an RTL document mirrors the
|
|
11
|
+
* whole chrome without any per-widget work. Legacy corner names stay as
|
|
12
|
+
* aliases mapped logically (`top-left` → `top-start`), which means legacy
|
|
13
|
+
* manifests mirror correctly under RTL too — physical-corner fidelity is
|
|
14
|
+
* deliberately NOT preserved there.
|
|
15
|
+
*/
|
|
16
|
+
export declare const MANAGED_SLOTS: readonly ["top-start", "top-center", "top-end", "center-start", "center-end", "bottom-start", "bottom-center", "bottom-end"];
|
|
17
|
+
export type ManagedSlot = (typeof MANAGED_SLOTS)[number];
|
|
18
|
+
/** A widget's resolved placement: a managed slot, or the author-styled manual tier. */
|
|
19
|
+
export type WidgetSlot = ManagedSlot | "manual";
|
|
20
|
+
/** Legacy 4-corner vocabulary (pre-0.4.1) — accepted forever, mapped LOGICALLY. */
|
|
21
|
+
export declare const LEGACY_POSITION_ALIASES: Readonly<Record<string, ManagedSlot>>;
|
|
22
|
+
/** Every accepted `position` value (validation + html-data). */
|
|
23
|
+
export declare const ALL_POSITION_VALUES: readonly string[];
|
|
24
|
+
/**
|
|
25
|
+
* `position` attribute/prop → slot. Absent/empty → the default `top-start`
|
|
26
|
+
* (today's `top-left` default, aliased). Unknown values → null; callers
|
|
27
|
+
* warn and fall back to the default (validation carries the loud version).
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveSlot(raw: string | null | undefined): WidgetSlot | null;
|
|
30
|
+
export interface SlotLayout {
|
|
31
|
+
/** Stack axis: edge-center slots run ALONG their edge (row); everything else stacks as a column. */
|
|
32
|
+
axis: "column" | "row";
|
|
33
|
+
block: "top" | "center" | "bottom";
|
|
34
|
+
inline: "start" | "center" | "end";
|
|
35
|
+
}
|
|
36
|
+
export declare function slotLayout(slot: ManagedSlot): SlotLayout;
|
|
37
|
+
/**
|
|
38
|
+
* The slot container's styles as a camelCase style object — ONE builder for
|
|
39
|
+
* both front-ends (the React lane spreads it as CSSProperties; the HTML
|
|
40
|
+
* lane serializes it to cssText), so the lanes cannot drift on placement.
|
|
41
|
+
* Insets/gaps read the layout tokens with the pre-0.4.1 constants as
|
|
42
|
+
* fallbacks (12px inset, 8px gap), so a single-widget legacy corner renders
|
|
43
|
+
* pixel-identically. Containers never intercept the map's pointer events;
|
|
44
|
+
* each widget re-enables its own.
|
|
45
|
+
*/
|
|
46
|
+
export declare function slotContainerStyle(slot: ManagedSlot): Record<string, string | number>;
|
|
47
|
+
/** The HTML lane's serialization of slotContainerStyle. */
|
|
48
|
+
export declare function slotContainerCssText(slot: ManagedSlot): string;
|
|
49
|
+
export declare const WIDGET_STYLE_KEY_NAMES: readonly string[];
|
|
50
|
+
export interface WidgetStyleParse {
|
|
51
|
+
/** Custom property → CSS value, ready for style.setProperty. */
|
|
52
|
+
properties: Record<string, string>;
|
|
53
|
+
/** Unparseable entries (unknown key / non-numeric value) — validation's loud half; the live path skips them. */
|
|
54
|
+
errors: string[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* `widget-style="gap:10 opacity:0.9 inset-x:16"` → custom properties — the
|
|
58
|
+
* no-CSS token surface for agents/authors. Space-separated `key:value`
|
|
59
|
+
* pairs; numbers get `px` except opacity. One parser serves the live path
|
|
60
|
+
* (om-map attr → host properties) and validation.
|
|
61
|
+
*/
|
|
62
|
+
export declare function parseWidgetStyle(raw: string): WidgetStyleParse;
|