@nika-js/onlymap 0.4.4 → 0.4.6
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 +6 -4
- package/bin/onlymapjs.mjs +14 -1
- package/dist/{LercDecode.es-CgN9Gb9e.js → LercDecode.es-B49qauXg.js} +1 -1
- package/dist/{basemap-Bfn5Z__c.js → basemap-nJ_ODY7r.js} +3 -3
- package/dist/elements/om-map.d.ts +40 -0
- package/dist/{index-CnitG1VX.js → index-CeOjfL2p.js} +2 -2
- package/dist/{index-KgO0MBqA.js → index-DSkgI4Oc.js} +7767 -7683
- package/dist/{index-C4cWRigY.js → index-DjlGZov2.js} +1 -1
- package/dist/{index-M8KfTTol.js → index-o_yRv2lD.js} +1 -1
- package/dist/{index-lXrP3rPo.js → index-uDJbHjA9.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/layer-registry.d.ts +8 -0
- package/dist/{lerc-l-QFh62d.js → lerc-CaQOmDCP.js} +2 -2
- package/dist/onlymap.standalone.js +12893 -12809
- package/dist/onlymapjs.js +67 -63
- package/dist/programmatic.d.ts +4 -0
- package/dist/{raster-BBA_oI-d.js → raster-DMq8FgiV.js} +2 -2
- package/dist/react.js +162 -161
- package/dist/runtime-core.d.ts +8 -0
- package/dist/testing.d.ts +6 -0
- package/dist/version.d.ts +1 -1
- package/dist/widget-layout.d.ts +20 -0
- package/docs/testing.md +4 -2
- package/llms.txt +1 -1
- package/package.json +2 -2
- package/skills/onlymapjs/SKILL.md +2 -2
- package/skills/onlymapjs/references/syntax.md +3 -3
- package/skills/onlymapjs/references/testing.md +1 -0
package/dist/react.js
CHANGED
|
@@ -1,193 +1,194 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { jsxs as
|
|
5
|
-
import { createContext as
|
|
6
|
-
import { MANAGED_SLOTS as
|
|
7
|
-
import { createPortal as
|
|
8
|
-
const ue =
|
|
9
|
-
function
|
|
10
|
-
const t =
|
|
1
|
+
var Ee = Object.defineProperty;
|
|
2
|
+
var Re = (e, t, s) => t in e ? Ee(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
|
3
|
+
var ne = (e, t, s) => Re(e, typeof t != "symbol" ? t + "" : t, s);
|
|
4
|
+
import { jsxs as J, jsx as E } from "react/jsx-runtime";
|
|
5
|
+
import { createContext as xe, useContext as Fe, forwardRef as Ce, useRef as h, useState as L, useId as le, useCallback as oe, useMemo as P, useLayoutEffect as se, useEffect as x, useImperativeHandle as Pe, useSyncExternalStore as ce } from "react";
|
|
6
|
+
import { MANAGED_SLOTS as Te, slotContainerStyle as ke, FOLD_SIDES as A, MapController as Me, parseWidgetStyle as Le, foldToggleSlot as $e, foldToggleStyle as je, foldPanelStyle as De, foldDrawerStyle as _e, resolveFoldBreakpointPx as Ae, shouldFoldAtWidth as Ie, DEFAULT_FOLD_BREAKPOINT_PX as ze, resolveSlot as Ke, foldSideForSlot as He, isStoreToken as Ne } from "@nika-js/onlymap";
|
|
7
|
+
import { createPortal as de } from "react-dom";
|
|
8
|
+
const ue = xe(null);
|
|
9
|
+
function W(e) {
|
|
10
|
+
const t = Fe(ue);
|
|
11
11
|
if (!t) throw new Error(`[onlymapjs] ${e} must be rendered inside <OmMap>.`);
|
|
12
12
|
return t;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function U(e, t) {
|
|
15
15
|
if (e === t) return !0;
|
|
16
16
|
const s = Object.keys(e ?? {}), o = Object.keys(t ?? {});
|
|
17
17
|
return s.length !== o.length ? !1 : s.every((i) => e[i] === t[i]);
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function We(e, t) {
|
|
20
20
|
const { props: s, updateTriggers: o, ...i } = e, { props: b, updateTriggers: m, ...a } = t;
|
|
21
|
-
return
|
|
21
|
+
return U(i, a) && U(s, b) && U(o, m);
|
|
22
22
|
}
|
|
23
|
-
class
|
|
23
|
+
class qe {
|
|
24
24
|
constructor(t) {
|
|
25
|
-
|
|
25
|
+
ne(this, "descriptors", /* @__PURE__ */ new Map());
|
|
26
26
|
this.controller = t;
|
|
27
27
|
}
|
|
28
28
|
upsert(t) {
|
|
29
29
|
const s = this.descriptors.get(t.id);
|
|
30
|
-
s &&
|
|
30
|
+
s && We(s, t) || (this.descriptors.set(t.id, t), this.controller.setLayers([...this.descriptors.values()]));
|
|
31
31
|
}
|
|
32
32
|
remove(t) {
|
|
33
33
|
this.descriptors.delete(t) && this.controller.setLayers([...this.descriptors.values()]);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
const
|
|
37
|
-
function
|
|
36
|
+
const N = Te, Ve = Object.fromEntries(N.map((e) => [e, ke(e)])), ie = { display: "flex", pointerEvents: "none", order: 2147483647 }, Be = Object.fromEntries(A.map((e) => [e, null]));
|
|
37
|
+
function Ye(e) {
|
|
38
38
|
const t = e.querySelector(
|
|
39
39
|
'button:not([disabled]),a[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])'
|
|
40
40
|
);
|
|
41
41
|
t ? t.focus() : (e.tabIndex = -1, e.focus());
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function Ge(e, t) {
|
|
44
44
|
return Object.entries(t).some(([s, o]) => o !== void 0 && e[s] !== o);
|
|
45
45
|
}
|
|
46
|
-
const
|
|
47
|
-
const { center: o, zoom: i, pitch: b, bearing: m, basemap: a, basemapKey: l, attribution: g, headless:
|
|
48
|
-
() => Object.fromEntries(
|
|
49
|
-
), [
|
|
50
|
-
() => Object.fromEntries(
|
|
51
|
-
), [
|
|
46
|
+
const rt = Ce(function(t, s) {
|
|
47
|
+
const { center: o, zoom: i, pitch: b, bearing: m, basemap: a, basemapKey: l, attribution: g, headless: d, widgetStyle: w, widgetsHidden: v, widgetsFold: p = !0, className: y, style: S, children: $ } = t, R = h(null), C = h(null), [c, T] = L(null), [F, D] = L(null), [j, I] = L(
|
|
48
|
+
() => Object.fromEntries(N.map((r) => [r, null]))
|
|
49
|
+
), [k, fe] = L(!1), [X, me] = L(Be), [ge, be] = L(
|
|
50
|
+
() => Object.fromEntries(A.map((r) => [r, 0]))
|
|
51
|
+
), [ye, q] = L(null), Q = `om-react-fold-${le().replaceAll(":", "")}`, pe = h(new Map(A.map((r) => [r, /* @__PURE__ */ new Set()]))), Z = d ? JSON.stringify(d) : "", z = h({
|
|
52
52
|
badge: null,
|
|
53
53
|
attribution: null
|
|
54
|
-
}),
|
|
54
|
+
}), he = oe((r) => {
|
|
55
55
|
D((n) => n === r ? n : r);
|
|
56
|
-
}, []),
|
|
56
|
+
}, []), ve = P(
|
|
57
57
|
() => Object.fromEntries(
|
|
58
|
-
|
|
58
|
+
N.map((r) => [
|
|
59
59
|
r,
|
|
60
60
|
(n) => {
|
|
61
|
-
|
|
61
|
+
I((u) => u[r] === n ? u : { ...u, [r]: n });
|
|
62
62
|
}
|
|
63
63
|
])
|
|
64
64
|
),
|
|
65
65
|
[]
|
|
66
|
-
),
|
|
66
|
+
), Se = P(
|
|
67
67
|
() => Object.fromEntries(
|
|
68
|
-
|
|
68
|
+
A.map((r) => [
|
|
69
69
|
r,
|
|
70
70
|
(n) => {
|
|
71
|
-
|
|
71
|
+
me((u) => u[r] === n ? u : { ...u, [r]: n });
|
|
72
72
|
}
|
|
73
73
|
])
|
|
74
74
|
),
|
|
75
75
|
[]
|
|
76
|
-
),
|
|
77
|
-
const f =
|
|
78
|
-
|
|
76
|
+
), ee = oe((r, n, u) => {
|
|
77
|
+
const f = pe.current.get(r), O = f.size;
|
|
78
|
+
u ? f.add(n) : f.delete(n), f.size !== O && be((_) => ({ ..._, [r]: f.size }));
|
|
79
79
|
}, []);
|
|
80
|
-
|
|
81
|
-
const r =
|
|
80
|
+
se(() => {
|
|
81
|
+
const r = R.current;
|
|
82
82
|
if (!r) return;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
let n, u = ze;
|
|
84
|
+
const f = (_) => {
|
|
85
|
+
const G = getComputedStyle(r).getPropertyValue("--om-widget-fold-breakpoint").trim();
|
|
86
|
+
G !== n && (n = G, u = Ae(G, r)), fe((we) => p && Ie(_, u, we));
|
|
86
87
|
};
|
|
87
|
-
if (
|
|
88
|
-
const
|
|
89
|
-
return
|
|
90
|
-
}, [p,
|
|
91
|
-
(!
|
|
92
|
-
}, [
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
|
|
88
|
+
if (f(r.getBoundingClientRect().width || (d ? d === !0 ? 800 : d.width ?? 800 : 0)), typeof ResizeObserver > "u") return;
|
|
89
|
+
const O = new ResizeObserver(([_]) => f(_.contentRect.width));
|
|
90
|
+
return O.observe(r), () => O.disconnect();
|
|
91
|
+
}, [p, Z]), x(() => {
|
|
92
|
+
(!k || v) && q(null);
|
|
93
|
+
}, [k, v]);
|
|
94
|
+
const te = h({ center: o, zoom: i, pitch: b, bearing: m });
|
|
95
|
+
te.current = { center: o, zoom: i, pitch: b, bearing: m };
|
|
96
|
+
const K = h(t.onReady);
|
|
97
|
+
K.current = t.onReady;
|
|
98
|
+
const M = h(t.onViewStateChange);
|
|
99
|
+
M.current = t.onViewStateChange;
|
|
100
|
+
const H = h(t.onRuntimeError);
|
|
101
|
+
H.current = t.onRuntimeError;
|
|
102
|
+
const V = h(a);
|
|
103
|
+
V.current = a;
|
|
104
|
+
const B = h(void 0);
|
|
105
|
+
se(() => {
|
|
105
106
|
if (!C.current) return;
|
|
106
|
-
const r =
|
|
107
|
-
|
|
108
|
-
const n = new
|
|
107
|
+
const r = te.current;
|
|
108
|
+
B.current = V.current;
|
|
109
|
+
const n = new Me(C.current, {
|
|
109
110
|
center: r.center,
|
|
110
111
|
zoom: r.zoom,
|
|
111
112
|
pitch: r.pitch,
|
|
112
113
|
bearing: r.bearing,
|
|
113
|
-
basemap:
|
|
114
|
+
basemap: V.current,
|
|
114
115
|
basemapKey: l,
|
|
115
116
|
attribution: g,
|
|
116
|
-
headless:
|
|
117
|
+
headless: d ? d === !0 ? {} : d : void 0,
|
|
117
118
|
chromeHosts: {
|
|
118
119
|
badge: z.current.badge ?? void 0,
|
|
119
120
|
attribution: z.current.attribution ?? void 0
|
|
120
121
|
},
|
|
121
122
|
onRuntimeError: (f) => {
|
|
122
|
-
var
|
|
123
|
-
return (
|
|
123
|
+
var O;
|
|
124
|
+
return (O = H.current) == null ? void 0 : O.call(H, f);
|
|
124
125
|
}
|
|
125
126
|
});
|
|
126
|
-
|
|
127
|
-
let
|
|
127
|
+
T(n);
|
|
128
|
+
let u = !0;
|
|
128
129
|
return n.ready.then(() => {
|
|
129
130
|
var f;
|
|
130
|
-
|
|
131
|
+
u && ((f = K.current) == null || f.call(K));
|
|
131
132
|
}), () => {
|
|
132
|
-
|
|
133
|
+
u = !1, T(null), n.destroy();
|
|
133
134
|
};
|
|
134
|
-
}, [
|
|
135
|
-
!c ||
|
|
136
|
-
}, [c, a]),
|
|
135
|
+
}, [Z]), x(() => {
|
|
136
|
+
!c || B.current === a || (B.current = a, c.setBasemap(a ?? null));
|
|
137
|
+
}, [c, a]), Pe(s, () => c, [c]), x(() => {
|
|
137
138
|
if (!c) return;
|
|
138
139
|
const r = { longitude: o == null ? void 0 : o[0], latitude: o == null ? void 0 : o[1], zoom: i, pitch: b, bearing: m };
|
|
139
|
-
|
|
140
|
-
}, [c, o == null ? void 0 : o[0], o == null ? void 0 : o[1], i, b, m]),
|
|
140
|
+
Ge(c.getViewState(), r) && c.setView(r);
|
|
141
|
+
}, [c, o == null ? void 0 : o[0], o == null ? void 0 : o[1], i, b, m]), x(() => {
|
|
141
142
|
var r;
|
|
142
143
|
if (c)
|
|
143
|
-
return (r =
|
|
144
|
+
return (r = M.current) == null || r.call(M, c.getViewState()), c.getStore("viewport").subscribe(() => {
|
|
144
145
|
var n;
|
|
145
|
-
return (n =
|
|
146
|
+
return (n = M.current) == null ? void 0 : n.call(M, c.getViewState());
|
|
146
147
|
});
|
|
147
148
|
}, [c]);
|
|
148
|
-
const
|
|
149
|
+
const Oe = P(
|
|
149
150
|
() => ({
|
|
150
151
|
position: "absolute",
|
|
151
152
|
inset: 0,
|
|
152
153
|
zIndex: 20,
|
|
153
154
|
pointerEvents: "none",
|
|
154
155
|
opacity: "var(--om-widget-opacity, 1)",
|
|
155
|
-
...w ?
|
|
156
|
+
...w ? Le(w).properties : void 0
|
|
156
157
|
}),
|
|
157
158
|
[w]
|
|
158
|
-
),
|
|
159
|
-
() => c &&
|
|
160
|
-
[c,
|
|
159
|
+
), Y = P(() => c ? new qe(c) : null, [c]), re = P(
|
|
160
|
+
() => c && Y && F ? { controller: c, layers: Y, overlayPane: F, corners: j, widgetsHidden: !!v, widgetsFolded: k, foldPanels: X, registerFoldedWidget: ee } : null,
|
|
161
|
+
[c, Y, F, j, v, k, X, ee]
|
|
161
162
|
);
|
|
162
|
-
return /* @__PURE__ */
|
|
163
|
+
return /* @__PURE__ */ J("div", { ref: R, className: y, style: { position: "relative", overflow: "hidden", ...S }, children: [
|
|
163
164
|
/* @__PURE__ */ E("div", { ref: C, style: { position: "absolute", inset: 0 } }),
|
|
164
165
|
/* @__PURE__ */ E(
|
|
165
166
|
"div",
|
|
166
167
|
{
|
|
167
|
-
ref:
|
|
168
|
+
ref: he,
|
|
168
169
|
style: { position: "absolute", top: 0, left: 0, zIndex: 10, pointerEvents: "none" }
|
|
169
170
|
}
|
|
170
171
|
),
|
|
171
|
-
/* @__PURE__ */ E("div", { "data-om-widget-layer": "", style:
|
|
172
|
+
/* @__PURE__ */ E("div", { "data-om-widget-layer": "", style: Oe, children: N.map((r) => /* @__PURE__ */ J(
|
|
172
173
|
"div",
|
|
173
174
|
{
|
|
174
175
|
"data-om-widget-slot": r,
|
|
175
|
-
ref:
|
|
176
|
+
ref: ve[r],
|
|
176
177
|
style: {
|
|
177
|
-
...
|
|
178
|
-
...
|
|
178
|
+
...Ve[r],
|
|
179
|
+
...k && r === "bottom-end" ? { bottom: "calc(var(--om-widget-inset-y, 12px) + 28px)" } : void 0
|
|
179
180
|
},
|
|
180
181
|
children: [
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
return /* @__PURE__ */
|
|
182
|
+
k && A.filter((n) => $e(n) === r && ge[n] > 0).map((n) => {
|
|
183
|
+
const u = ye === n;
|
|
184
|
+
return /* @__PURE__ */ J(
|
|
184
185
|
"div",
|
|
185
186
|
{
|
|
186
187
|
"data-om-fold-drawer": n,
|
|
187
|
-
style: { ...
|
|
188
|
+
style: { ..._e(n), display: v ? "none" : "flex" },
|
|
188
189
|
onKeyDown: (f) => {
|
|
189
|
-
var
|
|
190
|
-
f.key !== "Escape" || !
|
|
190
|
+
var O;
|
|
191
|
+
f.key !== "Escape" || !u || (q(null), (O = f.currentTarget.querySelector("[data-om-fold-toggle]")) == null || O.focus(), f.preventDefault(), f.stopPropagation());
|
|
191
192
|
},
|
|
192
193
|
children: [
|
|
193
194
|
/* @__PURE__ */ E(
|
|
@@ -195,15 +196,15 @@ const Ue = Re(function(t, s) {
|
|
|
195
196
|
{
|
|
196
197
|
type: "button",
|
|
197
198
|
"data-om-fold-toggle": n,
|
|
198
|
-
"aria-expanded":
|
|
199
|
-
"aria-controls": `${
|
|
200
|
-
"aria-label": `${
|
|
201
|
-
style:
|
|
199
|
+
"aria-expanded": u,
|
|
200
|
+
"aria-controls": `${Q}-${n}`,
|
|
201
|
+
"aria-label": `${u ? "Close" : "Open"} ${n} map controls`,
|
|
202
|
+
style: je(),
|
|
202
203
|
onClick: () => {
|
|
203
|
-
|
|
204
|
-
var
|
|
205
|
-
const f = (
|
|
206
|
-
f &&
|
|
204
|
+
q(u ? null : n), u || requestAnimationFrame(() => {
|
|
205
|
+
var O;
|
|
206
|
+
const f = (O = R.current) == null ? void 0 : O.querySelector(`[data-om-fold-panel="${n}"]`);
|
|
207
|
+
f && Ye(f);
|
|
207
208
|
});
|
|
208
209
|
},
|
|
209
210
|
children: "⋯"
|
|
@@ -212,13 +213,13 @@ const Ue = Re(function(t, s) {
|
|
|
212
213
|
/* @__PURE__ */ E(
|
|
213
214
|
"div",
|
|
214
215
|
{
|
|
215
|
-
id: `${
|
|
216
|
-
ref:
|
|
216
|
+
id: `${Q}-${n}`,
|
|
217
|
+
ref: Se[n],
|
|
217
218
|
"data-om-fold-panel": n,
|
|
218
219
|
role: "region",
|
|
219
220
|
"aria-label": `${n} map controls`,
|
|
220
|
-
hidden: !
|
|
221
|
-
style: { ...
|
|
221
|
+
hidden: !u,
|
|
222
|
+
style: { ...De(n), display: u ? "flex" : "none" }
|
|
222
223
|
}
|
|
223
224
|
)
|
|
224
225
|
]
|
|
@@ -233,7 +234,7 @@ const Ue = Re(function(t, s) {
|
|
|
233
234
|
ref: (n) => {
|
|
234
235
|
z.current.badge = n;
|
|
235
236
|
},
|
|
236
|
-
style:
|
|
237
|
+
style: ie
|
|
237
238
|
}
|
|
238
239
|
),
|
|
239
240
|
r === "bottom-end" && /* @__PURE__ */ E(
|
|
@@ -243,16 +244,16 @@ const Ue = Re(function(t, s) {
|
|
|
243
244
|
ref: (n) => {
|
|
244
245
|
z.current.attribution = n;
|
|
245
246
|
},
|
|
246
|
-
style:
|
|
247
|
+
style: ie
|
|
247
248
|
}
|
|
248
249
|
)
|
|
249
250
|
]
|
|
250
251
|
},
|
|
251
252
|
r
|
|
252
253
|
)) }),
|
|
253
|
-
|
|
254
|
+
re && /* @__PURE__ */ E(ue.Provider, { value: re, children: $ })
|
|
254
255
|
] });
|
|
255
|
-
}),
|
|
256
|
+
}), Je = /* @__PURE__ */ new Set([
|
|
256
257
|
"id",
|
|
257
258
|
"type",
|
|
258
259
|
"data",
|
|
@@ -272,10 +273,10 @@ const Ue = Re(function(t, s) {
|
|
|
272
273
|
"onClick",
|
|
273
274
|
"onHover"
|
|
274
275
|
]);
|
|
275
|
-
function
|
|
276
|
-
const { controller: t, layers: s } =
|
|
276
|
+
function nt(e) {
|
|
277
|
+
const { controller: t, layers: s } = W("OmLayer"), { id: o } = e, i = {};
|
|
277
278
|
for (const [l, g] of Object.entries(e))
|
|
278
|
-
!
|
|
279
|
+
!Je.has(l) && g !== void 0 && (i[l] = g);
|
|
279
280
|
const b = {
|
|
280
281
|
id: o,
|
|
281
282
|
type: e.type,
|
|
@@ -295,33 +296,33 @@ function Xe(e) {
|
|
|
295
296
|
updateTriggers: e.updateTriggers,
|
|
296
297
|
props: i
|
|
297
298
|
};
|
|
298
|
-
|
|
299
|
+
x(() => {
|
|
299
300
|
s.upsert(b);
|
|
300
|
-
}),
|
|
301
|
+
}), x(() => () => s.remove(o), [s, o]);
|
|
301
302
|
const m = h(e.onClick);
|
|
302
303
|
m.current = e.onClick;
|
|
303
304
|
const a = h(e.onHover);
|
|
304
|
-
return a.current = e.onHover,
|
|
305
|
+
return a.current = e.onHover, x(
|
|
305
306
|
() => t.watchPicks((l) => {
|
|
306
|
-
var g,
|
|
307
|
+
var g, d, w;
|
|
307
308
|
if (l === null) {
|
|
308
309
|
(g = a.current) == null || g.call(a, null);
|
|
309
310
|
return;
|
|
310
311
|
}
|
|
311
|
-
l.layerId === o && (l.type === "click" ? (
|
|
312
|
+
l.layerId === o && (l.type === "click" ? (d = m.current) == null || d.call(m, l) : (w = a.current) == null || w.call(a, l));
|
|
312
313
|
}),
|
|
313
314
|
[t, o]
|
|
314
315
|
), null;
|
|
315
316
|
}
|
|
316
|
-
function
|
|
317
|
-
const { corners: m, widgetsHidden: a, widgetsFolded: l, foldPanels: g, registerFoldedWidget:
|
|
318
|
-
if (
|
|
317
|
+
function ot({ position: e = "top-start", order: t, fold: s, className: o, style: i, children: b }) {
|
|
318
|
+
const { corners: m, widgetsHidden: a, widgetsFolded: l, foldPanels: g, registerFoldedWidget: d } = W("OmWidget"), w = le(), v = Ke(e) ?? "top-start", p = l && v !== "manual" && s !== "never", y = v === "manual" ? null : He(v);
|
|
319
|
+
if (x(() => {
|
|
319
320
|
if (y)
|
|
320
|
-
return
|
|
321
|
-
}, [y, w, p,
|
|
321
|
+
return d(y, w, p), () => d(y, w, !1);
|
|
322
|
+
}, [y, w, p, d]), v === "manual")
|
|
322
323
|
return /* @__PURE__ */ E("div", { className: o, style: { pointerEvents: "auto", ...i }, children: b });
|
|
323
|
-
const
|
|
324
|
-
return
|
|
324
|
+
const S = p && y ? g[y] : m[v];
|
|
325
|
+
return S ? de(
|
|
325
326
|
/* @__PURE__ */ E(
|
|
326
327
|
"div",
|
|
327
328
|
{
|
|
@@ -337,13 +338,13 @@ function Ze({ position: e = "top-start", order: t, fold: s, className: o, style:
|
|
|
337
338
|
children: b
|
|
338
339
|
}
|
|
339
340
|
),
|
|
340
|
-
|
|
341
|
+
S
|
|
341
342
|
) : null;
|
|
342
343
|
}
|
|
343
|
-
function
|
|
344
|
+
function ae(e, t) {
|
|
344
345
|
return !t || (e == null ? void 0 : e.layerId) === t;
|
|
345
346
|
}
|
|
346
|
-
const
|
|
347
|
+
const Ue = {
|
|
347
348
|
"top-left": "translate(0, 0)",
|
|
348
349
|
"top-center": "translate(-50%, 0)",
|
|
349
350
|
"top-right": "translate(-100%, 0)",
|
|
@@ -354,47 +355,47 @@ const Ve = {
|
|
|
354
355
|
"bottom-center": "translate(-50%, -100%)",
|
|
355
356
|
"bottom-right": "translate(-100%, -100%)"
|
|
356
357
|
};
|
|
357
|
-
function
|
|
358
|
-
const { controller: t, overlayPane: s } =
|
|
358
|
+
function st(e) {
|
|
359
|
+
const { controller: t, overlayPane: s } = W("OmOverlay"), o = h(null), i = h(void 0), b = h(e);
|
|
359
360
|
b.current = e;
|
|
360
|
-
const m =
|
|
361
|
+
const m = P(() => {
|
|
361
362
|
const p = t.getStore("selection");
|
|
362
|
-
let y,
|
|
363
|
+
let y, S, $ = null;
|
|
363
364
|
return {
|
|
364
365
|
subscribe: p.subscribe,
|
|
365
366
|
getSnapshot: () => {
|
|
366
|
-
const
|
|
367
|
-
return (
|
|
367
|
+
const R = p.getSnapshot(), { anchorFrom: C, layer: c } = b.current, T = `${C ?? ""}|${c ?? ""}`;
|
|
368
|
+
return (R !== y || T !== S) && (y = R, S = T, C === "selection" && ae(R, c) && ($ = R)), $;
|
|
368
369
|
}
|
|
369
370
|
};
|
|
370
|
-
}, [t]), a =
|
|
371
|
+
}, [t]), a = ce(
|
|
371
372
|
m.subscribe,
|
|
372
373
|
m.getSnapshot,
|
|
373
374
|
m.getSnapshot
|
|
374
375
|
);
|
|
375
|
-
|
|
376
|
+
x(
|
|
376
377
|
() => t.registerOverlay((p, y) => {
|
|
377
|
-
const
|
|
378
|
-
if (!
|
|
379
|
-
const { anchor:
|
|
378
|
+
const S = o.current;
|
|
379
|
+
if (!S) return;
|
|
380
|
+
const { anchor: $, anchorFrom: R, layer: C, visible: c = !0, anchorOffset: T } = b.current;
|
|
380
381
|
let F;
|
|
381
|
-
if (
|
|
382
|
-
|
|
382
|
+
if (R === "selection" ? (ae(y, C) && (i.current = (y == null ? void 0 : y.coordinate) ?? void 0), F = i.current) : F = $, !c || !F || !p) {
|
|
383
|
+
S.style.visibility = "hidden";
|
|
383
384
|
return;
|
|
384
385
|
}
|
|
385
|
-
const [D,
|
|
386
|
-
if (!(D >= 0 && D <= p.width &&
|
|
387
|
-
|
|
386
|
+
const [D, j, I] = p.project([F[0], F[1], 0]);
|
|
387
|
+
if (!(D >= 0 && D <= p.width && j >= 0 && j <= p.height) || I !== void 0 && I < 0) {
|
|
388
|
+
S.style.visibility = "hidden";
|
|
388
389
|
return;
|
|
389
390
|
}
|
|
390
|
-
|
|
391
|
+
S.style.visibility = "visible", S.style.transform = `translate(${D}px, ${j}px) ${Ue[T ?? "bottom-center"]}`;
|
|
391
392
|
}),
|
|
392
393
|
[t]
|
|
393
|
-
),
|
|
394
|
+
), x(() => {
|
|
394
395
|
t.refreshOverlays();
|
|
395
396
|
});
|
|
396
|
-
const { children: l, className: g, style:
|
|
397
|
-
return
|
|
397
|
+
const { children: l, className: g, style: d, interactive: w = !0 } = e, v = typeof l == "function" ? l(a) : l;
|
|
398
|
+
return de(
|
|
398
399
|
/* @__PURE__ */ E(
|
|
399
400
|
"div",
|
|
400
401
|
{
|
|
@@ -408,7 +409,7 @@ function et(e) {
|
|
|
408
409
|
// hidden until the first flush positions it — never flashes at the origin
|
|
409
410
|
willChange: "transform",
|
|
410
411
|
pointerEvents: w ? "auto" : "none",
|
|
411
|
-
...
|
|
412
|
+
...d
|
|
412
413
|
},
|
|
413
414
|
children: v
|
|
414
415
|
}
|
|
@@ -416,29 +417,29 @@ function et(e) {
|
|
|
416
417
|
s
|
|
417
418
|
);
|
|
418
419
|
}
|
|
419
|
-
function
|
|
420
|
-
const { controller: t } =
|
|
421
|
-
const m = (s ? s.split(" ") : []).flatMap((l) =>
|
|
420
|
+
function it(e = []) {
|
|
421
|
+
const { controller: t } = W("useOmMap"), s = e.join(" "), o = P(() => {
|
|
422
|
+
const m = (s ? s.split(" ") : []).flatMap((l) => Ne(l) ? [t.getStore(l)] : (console.warn(`[onlymapjs] useOmMap: "${l}" is not a watch token on the React front-end — expected viewport, selection, layers, or data:<layerId>.`), []));
|
|
422
423
|
let a;
|
|
423
424
|
return {
|
|
424
425
|
subscribe: (l) => {
|
|
425
|
-
const g = m.map((
|
|
426
|
+
const g = m.map((d) => d.subscribe(l));
|
|
426
427
|
return () => {
|
|
427
|
-
for (const
|
|
428
|
+
for (const d of g) d();
|
|
428
429
|
};
|
|
429
430
|
},
|
|
430
431
|
getSnapshot: () => {
|
|
431
432
|
const l = m.map((g) => g.getSnapshot());
|
|
432
|
-
return (!a || l.some((g,
|
|
433
|
+
return (!a || l.some((g, d) => g !== a[d])) && (a = l), a;
|
|
433
434
|
}
|
|
434
435
|
};
|
|
435
|
-
}, [t, s]), i =
|
|
436
|
-
return
|
|
436
|
+
}, [t, s]), i = ce(o.subscribe, o.getSnapshot, o.getSnapshot);
|
|
437
|
+
return P(() => t.buildCtx(), [t, i]);
|
|
437
438
|
}
|
|
438
439
|
export {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
440
|
+
nt as OmLayer,
|
|
441
|
+
rt as OmMap,
|
|
442
|
+
st as OmOverlay,
|
|
443
|
+
ot as OmWidget,
|
|
444
|
+
it as useOmMap
|
|
444
445
|
};
|
package/dist/runtime-core.d.ts
CHANGED
|
@@ -52,6 +52,14 @@ export interface RuntimeCoreCallbacks {
|
|
|
52
52
|
* deck reports none (e.g. off-globe).
|
|
53
53
|
*/
|
|
54
54
|
onMapPoint?: (coordinate: [number, number] | null, kind: "click" | "hover") => void;
|
|
55
|
+
/**
|
|
56
|
+
* A tileset-bearing layer (Tile3DLayer) finished loading its root tileset
|
|
57
|
+
* — the consumer hook for tools that must reach the LIVE deck tileset
|
|
58
|
+
* (region export, custom traversal) which the IR/metadata surface can't
|
|
59
|
+
* expose. `tileset` is deck's `Tileset3D` (typed `unknown` here to avoid a
|
|
60
|
+
* @loaders.gl/tiles type dependency in the core).
|
|
61
|
+
*/
|
|
62
|
+
onTilesetLoad?: (layerId: string, tileset: unknown) => void;
|
|
55
63
|
/**
|
|
56
64
|
* Runtime error boundary (spec: "Runtime error boundary") — deck.gl-level
|
|
57
65
|
* failures (a crashing accessor, an incompatible prop) formatted into the
|
package/dist/testing.d.ts
CHANGED
|
@@ -51,6 +51,12 @@ export interface TestHarness {
|
|
|
51
51
|
pick(opts: PickOptions): Promise<void>;
|
|
52
52
|
/** Ends the current selection (a hover-off) — the path that auto-hides tooltips. */
|
|
53
53
|
clearSelection(): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Feeds a map coordinate through the same path a real deck click/hover
|
|
56
|
+
* takes — drives the draw controller and fires the `om-map-point` event.
|
|
57
|
+
* For testing custom capture tools (sketch/AOI) without a GPU.
|
|
58
|
+
*/
|
|
59
|
+
mapPoint(coordinate: [number, number] | null, kind?: "click" | "hover"): Promise<void>;
|
|
54
60
|
/**
|
|
55
61
|
* Sets the camera directly (center/zoom/pitch/bearing) — everything
|
|
56
62
|
* viewport-derived reacts for real: `viewport`-watching widgets,
|
package/dist/version.d.ts
CHANGED
package/dist/widget-layout.d.ts
CHANGED
|
@@ -32,6 +32,26 @@ export declare function foldToggleSlot(side: FoldSide): ManagedSlot;
|
|
|
32
32
|
/** Shared drawer plumbing styles for the HTML and React front-ends. */
|
|
33
33
|
export declare function foldDrawerStyle(side?: FoldSide): Record<string, string | number>;
|
|
34
34
|
export declare function foldPanelStyle(side: FoldSide): Record<string, string | number>;
|
|
35
|
+
/** Default fold breakpoint (px) when `--om-widget-fold-breakpoint` is unset. */
|
|
36
|
+
export declare const DEFAULT_FOLD_BREAKPOINT_PX = 640;
|
|
37
|
+
/**
|
|
38
|
+
* Hysteresis band (px) so a map whose width oscillates around the breakpoint
|
|
39
|
+
* (drag-resize, flex, split-pane, a CSS transition) doesn't flap fold/unfold
|
|
40
|
+
* every ResizeObserver tick: fold at width ≤ breakpoint, unfold only once
|
|
41
|
+
* width ≥ breakpoint + this margin.
|
|
42
|
+
*/
|
|
43
|
+
export declare const FOLD_HYSTERESIS_PX = 40;
|
|
44
|
+
/**
|
|
45
|
+
* `--om-widget-fold-breakpoint` (already read to `raw`) → px — ONE resolver
|
|
46
|
+
* for both front-ends so they can't fold at different widths. Accepts px, a
|
|
47
|
+
* bare number, or author units (rem/em/vw…) resolved through a transient
|
|
48
|
+
* probe appended to `probeParent` (the browser is the unit converter — no
|
|
49
|
+
* second implementation). Takes the raw string (not the element) so callers
|
|
50
|
+
* can cache on it and skip the probe when unchanged.
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveFoldBreakpointPx(raw: string, probeParent: HTMLElement): number;
|
|
53
|
+
/** Fold decision with hysteresis — pure, shared by both lanes. `currentlyFolded` supplies the band's direction. */
|
|
54
|
+
export declare function shouldFoldAtWidth(width: number, breakpointPx: number, currentlyFolded: boolean): boolean;
|
|
35
55
|
export declare function foldToggleStyle(): Record<string, string | number>;
|
|
36
56
|
/** Legacy 4-corner vocabulary (pre-0.4.1) — accepted forever, mapped LOGICALLY. */
|
|
37
57
|
export declare const LEGACY_POSITION_ALIASES: Readonly<Record<string, ManagedSlot>>;
|
package/docs/testing.md
CHANGED
|
@@ -111,7 +111,7 @@ it("panning away empties viewport-scoped widgets", async () => {
|
|
|
111
111
|
});
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
-
The harness API: `pick` (synthetic picks fed through the exact code path real deck.gl picks take — columnar layers pick object-less by index, exactly like live), `clearSelection` (hover-off; runs the tooltip auto-hide path), `emit` (any action, same payload contract as `ctx.emit`/`data-emit`), `setView`, `layers()` (the live IR), `flush`, `unmount`. Every verb settles the library's internal batching before resolving — **you never write a sleep**.
|
|
114
|
+
The harness API: `pick` (synthetic picks fed through the exact code path real deck.gl picks take — columnar layers pick object-less by index, exactly like live), `clearSelection` (hover-off; runs the tooltip auto-hide path), `mapPoint` (a click/hover map coordinate through the real onMapPoint path — fires `om-map-point`, drives the draw controller), `emit` (any action, same payload contract as `ctx.emit`/`data-emit`), `setView`, `layers()` (the live IR), `flush`, `unmount`. Every verb settles the library's internal batching before resolving — **you never write a sleep**.
|
|
115
115
|
|
|
116
116
|
**Remote data:** mock `fetch` and the harness waits for it via the readiness signal:
|
|
117
117
|
|
|
@@ -137,7 +137,9 @@ npx playwright install chromium
|
|
|
137
137
|
npx onlymapjs check-layout public/dashboard.html
|
|
138
138
|
```
|
|
139
139
|
|
|
140
|
-
`check-layout` serves the manifest over loopback HTTP (so relative data URLs work), executes it in an isolated headless Chromium context, opens responsive drawers, and checks real geometry/hit-testing at 360, 640, 768, and 1024px. It prints one JSON diagnostic per problem and exits 0 when clean or 1 on layout errors. Because it executes the page, only run it on manifests you trust.
|
|
140
|
+
`check-layout` serves the manifest over loopback HTTP (so relative data URLs work), executes it in an isolated headless Chromium context, opens responsive drawers, and checks real geometry/hit-testing at 360, 640, 768, and 1024px. It prints one JSON diagnostic per problem and exits 0 when clean or 1 on layout errors. Because it executes the page, only run it on manifests you trust. Point it at a **browser-runnable** manifest — one that imports the built library (`@nika-js/onlymap`) — not a framework dev-server page that relies on on-the-fly transpilation (a page importing raw `.ts` will fail to render a canvas, and the tool reports exactly that).
|
|
141
|
+
|
|
142
|
+
To run the same audit inside your own Playwright suite instead of the CLI, import it: `auditLayout(page, { widths })` returns the `LayoutDiagnostic[]` (the CLI is a thin wrapper over it), and `settleLayout(page)` awaits the render/fonts/attribution settle contract. Both come from `@nika-js/onlymap`.
|
|
141
143
|
|
|
142
144
|
1. **`await mapEl.ready`** — resolves when the renderer initialized *and* the first reconcile ran *and* every declared `data` URL settled. Never `waitForTimeout`.
|
|
143
145
|
2. **`mapEl.projectInternal([lng, lat])`** — derive click/hover pixels from the map's own projection instead of hardcoding coordinates.
|