@nika-js/onlymap 0.13.4 → 0.13.5

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 (50) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +2 -2
  3. package/dist/actions.d.ts +12 -6
  4. package/dist/attribute-resolution.d.ts +32 -4
  5. package/dist/{basemap-BiC_RwbV.js → basemap-CErNEhX6.js} +2 -2
  6. package/dist/{build-DQCmcQE1.js → build-ByNIb4VX.js} +1 -1
  7. package/dist/{client-C0CgEs_P.js → client-xe2E4jg4.js} +2 -2
  8. package/dist/ctx.d.ts +2 -0
  9. package/dist/{geoparquet-DbVJrJYG.js → geoparquet-DOhMQl-X.js} +1 -1
  10. package/dist/{globe-view-CrGbvqqZ.js → globe-view-84s_uNZX.js} +1 -1
  11. package/dist/{hillshade-CGY_OBaG.js → hillshade-D8h8CRQq.js} +2 -2
  12. package/dist/{hillshade-shader-w8tmFgaV.js → hillshade-shader-Bm1O0P76.js} +1 -1
  13. package/dist/{index-QrGqSW_H.js → index-4Y4Q7RP4.js} +3 -3
  14. package/dist/{index-DrCMvhhr.js → index-BG_49YHy.js} +19732 -19592
  15. package/dist/{index-GfvWJDX0.js → index-DTN2CcOQ.js} +11 -11
  16. package/dist/{index-ChoEWeXU.js → index-DXxQu9Xi.js} +1 -1
  17. package/dist/{index-Cm2sfhw7.js → index-D_EiGesl.js} +1 -1
  18. package/dist/{index-Dtsf-TPD.js → index-DrSCLk9i.js} +12 -12
  19. package/dist/{index-2lD29y87.js → index-J_Sj6T0S.js} +25 -25
  20. package/dist/index-bpdGuZR6.js +478 -0
  21. package/dist/{index-xF9sKoMB.js → index-phbljJTZ.js} +3 -3
  22. package/dist/ir-snapshot.d.ts +2 -0
  23. package/dist/ir.d.ts +18 -0
  24. package/dist/{lerc-DxujwTm7.js → lerc-DLWS3sYw.js} +1 -1
  25. package/dist/onlymap.standalone.js +35477 -35321
  26. package/dist/onlymapjs.js +13 -13
  27. package/dist/plane-gpu/plane-basemap.d.ts +79 -79
  28. package/dist/plane-vector/plane-mvt-layer.d.ts +79 -79
  29. package/dist/{post-process-effect-BL9rBDEh.js → post-process-effect-CHsD0-oP.js} +1 -1
  30. package/dist/programmatic.d.ts +4 -0
  31. package/dist/{raster-Bq768NZr.js → raster-B7ILGg0X.js} +4 -4
  32. package/dist/{raster-pipeline-C898iYqw.js → raster-pipeline-avMAbONM.js} +2 -2
  33. package/dist/react/om-layer.d.ts +4 -0
  34. package/dist/react.js +67 -65
  35. package/dist/serialize/emit.d.ts +2 -0
  36. package/dist/serialize/index.d.ts +2 -0
  37. package/dist/{terrain-inspect-DNZO8z6S.js → terrain-inspect-FKTVm7nv.js} +1 -1
  38. package/dist/{text-on-path-owfh8Ac6.js → text-on-path-CpHM02Fs.js} +19 -18
  39. package/dist/{vector-style-BlnKzVND.js → vector-style-CPvUSy2F.js} +1 -1
  40. package/dist/version.d.ts +1 -1
  41. package/dist/{zarr-CMWiR63-.js → zarr-DpbT4eyF.js} +2 -2
  42. package/dist/zoom-gates.d.ts +60 -0
  43. package/docs/cartograph.md +2 -2
  44. package/llms.txt +1 -0
  45. package/onlymapjs.attributes.json +2 -0
  46. package/onlymapjs.html-data.json +16 -0
  47. package/package.json +1 -1
  48. package/skills/onlymapjs/SKILL.md +2 -1
  49. package/skills/onlymapjs/references/syntax.md +30 -3
  50. package/dist/index-Bdltig68.js +0 -459
@@ -996,6 +996,22 @@
996
996
  "name": "visible-zoom-range",
997
997
  "description": "Per-layer zoom visibility \"[minZoom, maxZoom]\" — hidden outside min ≤ zoom < max (minzoom/maxzoom convention), any layer type. Composes with visible; the layer stays in the legend/switcher while zoom-hidden."
998
998
  },
999
+ {
1000
+ "name": "min-zoom-field",
1001
+ "description": "Per-FEATURE minimum zoom: the property holding each feature's min zoom — a feature draws only while zoom ≥ its value (fractional, inclusive), smoothly during a zoom, never written to the document. Missing/non-numeric values always draw. Layers that draw one mark per row (not tiled, aggregation or clustered layers); uses one GPU filter slot (at most 3 filter-fields alongside). Not a data filter — ctx filter state and stats ignore it."
1002
+ },
1003
+ {
1004
+ "name": "listed",
1005
+ "description": "listed=\"false\" keeps a helper layer out of the legend and layer-switcher widgets. It stays in ctx.layers and toggle/filter actions still reach it.",
1006
+ "values": [
1007
+ {
1008
+ "name": "false"
1009
+ },
1010
+ {
1011
+ "name": "true"
1012
+ }
1013
+ ]
1014
+ },
999
1015
  {
1000
1016
  "name": "get-position",
1001
1017
  "description": "Accessor for deck.gl getPosition — expression language: $field, scale(), formatDate(), arithmetic. Valid on: ColumnLayer, ContourLayer, GridCellLayer, GridLayer, HeatmapLayer, HexagonLayer, IconLayer, PointCloudLayer, PopupLayer, ScatterplotLayer, ScenegraphLayer, ScreenGridLayer, SimpleMeshLayer, TextLayer, Tracking."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nika-js/onlymap",
3
- "version": "0.13.4",
3
+ "version": "0.13.5",
4
4
  "description": "Declarative deck.gl maps for HTML and React — interactive WebGL mapping with GeoJSON/CSV/Arrow data, MapLibre basemaps, widgets, popups, and live streams from a custom-element manifest or typed React components. TypeScript, no build step.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "publishConfig": {
@@ -23,7 +23,7 @@ Use OnlyMapJS as a declarative HTML map library. Write custom elements such as `
23
23
  </script>
24
24
  ```
25
25
 
26
- For no-build CDN pages, use the single-file standalone bundle from a raw-file CDN — `https://unpkg.com/@nika-js/onlymap@0.13.4` (the bare package URL serves `dist/onlymap.standalone.js`) — plus `<link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.13.4/dist/onlymapjs.css">`. Never a rebundling CDN (esm.sh, skypack): re-bundling duplicates the deck.gl/luma.gl runtime and every layer fails shader compilation.
26
+ For no-build CDN pages, use the single-file standalone bundle from a raw-file CDN — `https://unpkg.com/@nika-js/onlymap@0.13.5` (the bare package URL serves `dist/onlymap.standalone.js`) — plus `<link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.13.5/dist/onlymapjs.css">`. Never a rebundling CDN (esm.sh, skypack): re-bundling duplicates the deck.gl/luma.gl runtime and every layer fails shader compilation.
27
27
 
28
28
  ## React Projects
29
29
 
@@ -72,6 +72,7 @@ Load the smallest reference needed for the task:
72
72
  - Sparse rich HTML at one geographic location -> `<om-overlay>`.
73
73
  - Many labels/badges -> `<om-layer type="PopupLayer">`.
74
74
  - Many overlapping POINTS ("marker clusters", "group the pins", "thousands of points that pile up when zoomed out") -> `cluster="true"` on the existing `ScatterplotLayer`/`GeoJsonLayer`/`IconLayer` — a toggle, never a new layer type or a `HexagonLayer`. Add `cluster-properties="sum:field,mode:field"` when a bubble should say more than a count, and style bubbles with `get-cluster-radius`/`get-cluster-fill-color` over `$count`, `$count_max` and the aggregates (syntax.md "Clustering"). Do NOT confuse with `cluster="false"` on `<om-widget>`, which is button grouping.
75
+ - Labels or features that should appear from DIFFERENT zooms one by one ("show each label once it has room", per-feature minzoom from an exporter) -> `min-zoom-field="<property>"` on the layer — GPU-side against the live camera, never a script rewriting `filter-range` on `om-view-changed`. A whole layer by zoom is `visible-zoom-range`. Keep a helper layer (e.g. hidden-label dots) out of the legend/switcher with `listed="false"`. See references/syntax.md.
75
76
  - A styled look for the whole map (vintage / printed / risograph / newsprint / night plate, film grain, halftone, duotone) -> `<om-effect>` children of `<om-map>`: `preset="vintage|engraved|night|blueprint|riso|newsprint|muted"`, or `op=` with knobs, in document order. Spatial knobs are MILLIMETRES, never px. See references/syntax.md.
76
77
  - Guided tour or narrative sequence -> `<om-story>` with `<om-step>` siblings that reference existing layers/overlays by id.
77
78
  - Basemap choice or user-switchable basemaps -> `basemap` presets (`positron`, `liberty`, `dark-matter`, `osm`, `satellite` for keyless imagery — soft past ~z14, so a street-level imagery request wants keyed `maptiler-satellite`, ...) + `<om-widget type="basemap-switcher">`; MapTiler custom styles via a style URL or `basemap-key`.
@@ -16,8 +16,8 @@ Vite/npm project:
16
16
  Static CDN page (raw-file CDNs only — unpkg/jsDelivr; never esm.sh or another rebundling CDN, which duplicates the WebGL runtime and breaks layer shaders):
17
17
 
18
18
  ```html
19
- <link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.13.4/dist/onlymapjs.css">
20
- <script type="module" src="https://unpkg.com/@nika-js/onlymap@0.13.4"></script>
19
+ <link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.13.5/dist/onlymapjs.css">
20
+ <script type="module" src="https://unpkg.com/@nika-js/onlymap@0.13.5"></script>
21
21
  ```
22
22
 
23
23
  Always include `onlymapjs.css` — it carries the MapLibre basemap styles and the no-JS fallback rules (`<om-fallback>` / default banner). For the fallback to work in script-disabled previews it must load without JavaScript: a real `<link rel="stylesheet">` or inlined `<style>` on no-build pages (a bundler-emitted stylesheet is fine in npm projects).
@@ -175,6 +175,33 @@ One `<om-widget type="filter">` per dimension — each moves its own field's ran
175
175
 
176
176
  `visible-zoom-range="[8, 14]"` — scale-dependent visibility, the QGIS/ArcGIS/Mapbox everyday pattern: the layer renders only at min ≤ zoom < max (min inclusive, max exclusive — the minzoom/maxzoom convention). Universal: valid on every layer type, unlike the tile-only `visible-min-zoom`/`visible-max-zoom` deck props. Composes with `visible` (both must allow); a zoom-hidden layer stays a full scene member — legend, layer-switcher, and `ctx` still list it. Malformed values are ignored with a warning (`validate` reports them structurally).
177
177
 
178
+ ## Per-feature minimum zoom (any layer type)
179
+
180
+ `min-zoom-field="minzoom"` — each FEATURE draws only while the camera zoom is ≥ the value in that property (inclusive, against the exact fractional zoom: `12.8` appears at 12.8, not 13). The per-feature twin of `visible-zoom-range`: label staging ("show each label from the zoom where it has room"), detail that fills in as the reader zooms. Evaluated on the GPU against the live camera, so features appear smoothly DURING a zoom; nothing is written to the document, the undo history or a save.
181
+
182
+ ```html
183
+ <om-layer id="parcel-labels" type="TextLayer" min-zoom-field="minzoom"
184
+ get-position="$geometry.coordinates" get-text="$properties.name">
185
+ <script type="application/json">{"type":"FeatureCollection","features":[
186
+ {"type":"Feature","geometry":{"type":"Point","coordinates":[0,0]},"properties":{"name":"A","minzoom":0}},
187
+ {"type":"Feature","geometry":{"type":"Point","coordinates":[0.001,0]},"properties":{"name":"B","minzoom":12.8}}
188
+ ]}</script>
189
+ </om-layer>
190
+ ```
191
+
192
+ - A missing, null or non-numeric value means "always drawn" (numeric strings like `"12"` count as numbers).
193
+ - Composes (AND) with `visible`, `visible-zoom-range` and every `filter-*`. A hidden feature is not pickable.
194
+ - It is presentation, NOT a data filter: `ctx.layers[].filter`, the `filter` widget and `ctx.stats` see only the authored filter and count every row.
195
+ - It takes one of the layer's 4 GPU filter slots: at most 3 `filter-fields` alongside it (`validate` errors at 4; the runtime then ignores `min-zoom-field` with a warning — never the authored filter).
196
+ - `snapshot({ format: "svg" })` leaves out features below their min zoom at the capture zoom.
197
+ - Descriptor (`MapController`) and React: `minZoomField: "minzoom"`.
198
+ - Not on tiled layers (`MVTLayer`, `TileLayer`, …), aggregation layers (`HexagonLayer`, `HeatmapLayer`, …) or with `cluster="true"` — there are no per-row marks to gate there (a cluster bubble would count the hidden rows); the runtime ignores it with a warning and `validate` says so.
199
+ - Never script this with an `om-view-changed` listener rewriting `filter-range` — that writes view state into the document on every zoom step and only updates after the camera settles.
200
+
201
+ ## Keeping a helper layer out of the legend (`listed="false"`)
202
+
203
+ `listed="false"` on an `<om-layer>` keeps it out of the `legend` and `layer-switcher` widgets — for a helper layer that would read as a duplicate (dots marking where a label is still hidden, a halo under the real layer). It stays a full scene member: in `ctx.layers` (with `listed: false`), toggleable and filterable by actions. Descriptor (`MapController`): `listed: false`; React: `listed={false}`.
204
+
178
205
  ## Clustering (`ScatterplotLayer`, `GeoJsonLayer` with Point features, `IconLayer`)
179
206
 
180
207
  `cluster="true"` merges points that would overlap on screen into count bubbles that split apart as the reader zooms in. A TOGGLE on the point layer, never a separate layer type: the layer keeps its id, data, its own `get-*` symbology for the points that stand alone at the current zoom, its picks, behaviors and actions.
@@ -580,7 +607,7 @@ Do not use full-JS blocks on columnar/Arrow layers.
580
607
  Built-ins:
581
608
 
582
609
  - `legend` — symbology-aware by default: it parses each layer's `get-fill-color`. A `sequential`/`diverging` `scale()` renders as a gradient ramp with the domain ends labeled; a `threshold` scale as discrete class ranges (`< b1`, `b1 – b2`, `≥ bN`); an equality ternary chain (`$f == 'a' ? '#c1' : $f == 'b' ? '#c2' : '#fallback'`) as a category palette with an "other" row. Any other expression falls back to the single `color` swatch — so writing the canonical shapes buys a self-describing legend for free.
583
- - `layer-switcher`
610
+ - `layer-switcher` — one visibility checkbox per layer. Both it and `legend` skip layers marked `listed="false"`.
584
611
  - `zoom-controls`
585
612
  - `scale-bar` — `units="metric|imperial|nautical"` (default metric) picks the length system; snaps to a nice round distance.
586
613
  - `attribution`
@@ -1,459 +0,0 @@
1
- import { aU as B } from "./index-DrCMvhhr.js";
2
- const V = /* @__PURE__ */ new Set([
3
- "GeoJsonLayer",
4
- "PolygonLayer",
5
- "SolidPolygonLayer",
6
- "PathLayer",
7
- "LineLayer",
8
- "ScatterplotLayer",
9
- "PointCloudLayer",
10
- "ArcLayer",
11
- "TripsLayer",
12
- "Route",
13
- "Tracking"
14
- ]), Z = /* @__PURE__ */ new Set(["TextLayer"]), q = /* @__PURE__ */ new Set(["TextOnPathLayer"]), J = /* @__PURE__ */ new Set([
15
- "COGLayer",
16
- "ZarrLayer",
17
- "BitmapLayer",
18
- "ImageOverlay",
19
- "TileLayer",
20
- "MVTLayer",
21
- "HillshadeLayer",
22
- "Tile3DLayer",
23
- "BIMLayer",
24
- "ScenegraphLayer",
25
- "SimpleMeshLayer",
26
- "TerrainLayer",
27
- "HeatmapLayer",
28
- "HexagonLayer",
29
- "GridLayer",
30
- "ContourLayer",
31
- "ScreenGridLayer"
32
- ]);
33
- function ot(t) {
34
- return q.has(t) ? "path-text" : Z.has(t) ? "text" : V.has(t) ? "vector" : (J.has(t), "raster");
35
- }
36
- function rt(t) {
37
- return V.has(t) || Z.has(t) || q.has(t) || J.has(t);
38
- }
39
- function it(t) {
40
- const e = [];
41
- for (const o of t) {
42
- const r = ot(o.type), n = e[e.length - 1];
43
- n && n.strategy === "raster" && r === "raster" ? n.ids.push(o.id) : e.push({ strategy: r, ids: [o.id] });
44
- }
45
- return e;
46
- }
47
- function W(t, e) {
48
- return e[0] >= t.left && e[0] <= t.right && e[1] >= t.top && e[1] <= t.bottom;
49
- }
50
- function Q(t, e) {
51
- let o = 1 / 0, r = 1 / 0, n = -1 / 0, i = -1 / 0;
52
- for (const [s, c] of t)
53
- s < o && (o = s), s > n && (n = s), c < r && (r = c), c > i && (i = c);
54
- return n < e.left || o > e.right || i < e.top || r > e.bottom;
55
- }
56
- function st(t, e, o) {
57
- const r = e[0] - t[0], n = e[1] - t[1];
58
- let i = 0, s = 1;
59
- const c = (f, u) => {
60
- if (f === 0) return u >= 0;
61
- const p = u / f;
62
- if (f < 0) {
63
- if (p > s) return !1;
64
- p > i && (i = p);
65
- } else {
66
- if (p < i) return !1;
67
- p < s && (s = p);
68
- }
69
- return !0;
70
- };
71
- return !c(-r, t[0] - o.left) || !c(r, o.right - t[0]) || !c(-n, t[1] - o.top) || !c(n, o.bottom - t[1]) ? null : [
72
- [t[0] + i * r, t[1] + i * n],
73
- [t[0] + s * r, t[1] + s * n]
74
- ];
75
- }
76
- function tt(t, e) {
77
- if (t.length < 2) return W(e, t[0] ?? [NaN, NaN]) ? [[...t]] : [];
78
- if (Q(t, e)) return [];
79
- const o = [];
80
- let r = null;
81
- for (let n = 0; n + 1 < t.length; n++) {
82
- const i = st(t[n], t[n + 1], e);
83
- if (!i) {
84
- r = null;
85
- continue;
86
- }
87
- const [s, c] = i;
88
- r && r[r.length - 1][0] === s[0] && r[r.length - 1][1] === s[1] ? r.push(c) : (r = [s, c], o.push(r));
89
- }
90
- return o;
91
- }
92
- function H(t, e, o) {
93
- switch (o) {
94
- case "left":
95
- return t[0] >= e.left;
96
- case "right":
97
- return t[0] <= e.right;
98
- case "top":
99
- return t[1] >= e.top;
100
- case "bottom":
101
- return t[1] <= e.bottom;
102
- }
103
- }
104
- function X(t, e, o, r) {
105
- const n = e[0] - t[0], i = e[1] - t[1];
106
- switch (r) {
107
- case "left":
108
- return [o.left, t[1] + i * (o.left - t[0]) / n];
109
- case "right":
110
- return [o.right, t[1] + i * (o.right - t[0]) / n];
111
- case "top":
112
- return [t[0] + n * (o.top - t[1]) / i, o.top];
113
- case "bottom":
114
- return [t[0] + n * (o.bottom - t[1]) / i, o.bottom];
115
- }
116
- }
117
- function at(t, e) {
118
- if (t.length < 3) return [];
119
- if (Q(t, e)) return [];
120
- let o = t;
121
- for (const r of ["left", "right", "top", "bottom"]) {
122
- const n = o;
123
- if (o = [], n.length === 0) return [];
124
- let i = n[n.length - 1];
125
- for (let s = 0; s < n.length; s++) {
126
- const c = n[s], f = H(c, e, r), u = H(i, e, r);
127
- f ? (u || o.push(X(i, c, e, r)), o.push(c)) : u && o.push(X(i, c, e, r)), i = c;
128
- }
129
- }
130
- return o;
131
- }
132
- const Y = (t) => Math.max(0, Math.min(255, Math.round(t)));
133
- function E(t) {
134
- if (!Array.isArray(t) || t.length < 3) return { color: "#000000", opacity: 1 };
135
- const [e, o, r, n] = t, i = (s) => Y(s).toString(16).padStart(2, "0");
136
- return {
137
- color: `#${i(e)}${i(o)}${i(r)}`,
138
- // deck's alpha DEFAULT is 255, not 0 — an absent fourth component means
139
- // opaque. Reading it as zero would emit a whole invisible sheet.
140
- opacity: n === void 0 ? 1 : Y(n) / 255
141
- };
142
- }
143
- function D(t, e, o, r, n) {
144
- if (typeof t == "function")
145
- try {
146
- return t(e, { index: o, data: r });
147
- } catch {
148
- return n;
149
- }
150
- return t === void 0 ? n : t;
151
- }
152
- const L = (t, e) => typeof t == "number" && Number.isFinite(t) ? t : e, ct = ["getLineColor", "getColor", "getSourceColor"], lt = ["getLineWidth", "getWidth"], ut = ["lineWidthScale", "widthScale"], ft = ["lineWidthUnits", "widthUnits"], dt = ["lineWidthMinPixels", "widthMinPixels"], ht = ["lineWidthMaxPixels", "widthMaxPixels"], pt = ["getRadius", "getPointRadius"], gt = ["radiusScale", "pointRadiusScale"], mt = ["radiusUnits", "pointRadiusUnits"], yt = ["radiusMinPixels", "pointRadiusMinPixels"], xt = ["radiusMaxPixels", "pointRadiusMaxPixels"];
153
- function $(t, e) {
154
- for (const o of e) if (t[o] !== void 0) return t[o];
155
- }
156
- function $t(t, e, o, r) {
157
- const n = t.props, i = L(D($(n, lt), e, o, t.data, 1), 1), s = L($(n, ut), 1);
158
- let u = ($(n, ft) === "meters" ? "meters" : "pixels") === "meters" ? i * s / Math.max(r, 1e-9) : i * s;
159
- u = Math.max(u, L($(n, dt), 0));
160
- const p = $(n, ht);
161
- return typeof p == "number" && Number.isFinite(p) && (u = Math.min(u, p)), u;
162
- }
163
- function Pt(t, e, o, r) {
164
- const n = t.props, i = L(D($(n, pt), e, o, t.data, 1), 1), s = L($(n, gt), 1);
165
- let f = ($(n, mt) === "pixels" ? "pixels" : "meters") === "pixels" ? i * s : i * s / Math.max(r, 1e-9);
166
- f = Math.max(f, L($(n, yt), 0));
167
- const u = $(n, xt);
168
- return typeof u == "number" && Number.isFinite(u) && (f = Math.min(f, u)), f;
169
- }
170
- function bt(t, e) {
171
- const o = t.props.getDashArray ?? t.props.dashArray, r = typeof o == "function" ? void 0 : o;
172
- if (!Array.isArray(r) || r.length < 2) return;
173
- const [n, i] = r;
174
- if (!Number.isFinite(n) || !Number.isFinite(i) || n <= 0 && i <= 0) return;
175
- const s = Math.max(e, 1e-6);
176
- return `${(n * s).toFixed(3)} ${(i * s).toFixed(3)}`;
177
- }
178
- function St(t, e, o, r) {
179
- const n = t.props, i = L(n.opacity, 1), s = E(D(n.getFillColor, e, o, t.data, [0, 0, 0, 255])), c = E(D($(n, ct), e, o, t.data, [0, 0, 0, 255])), f = $t(t, e, o, r);
180
- return {
181
- fill: n.filled === !1 ? "none" : s.color,
182
- fillOpacity: s.opacity * i,
183
- // `stroked: false` is a POLYGON prop. A PathLayer has no such prop and is
184
- // nothing but stroke, so an absent `stroked` must read as "yes", not as
185
- // deck's polygon default.
186
- stroke: n.stroked === !1 ? "none" : c.color,
187
- strokeOpacity: c.opacity * i,
188
- strokeWidth: f,
189
- dashArray: bt(t, f),
190
- radius: Pt(t, e, o, r)
191
- };
192
- }
193
- function N(t, e) {
194
- const o = [];
195
- return e === "area" ? (o.push(`fill="${t.fill}"`), t.fill !== "none" && t.fillOpacity < 1 && o.push(`fill-opacity="${t.fillOpacity.toFixed(4)}"`)) : o.push('fill="none"'), t.stroke !== "none" && t.strokeWidth > 0 && (o.push(`stroke="${t.stroke}"`), o.push(`stroke-width="${t.strokeWidth.toFixed(3)}"`), t.strokeOpacity < 1 && o.push(`stroke-opacity="${t.strokeOpacity.toFixed(4)}"`), t.dashArray && o.push(`stroke-dasharray="${t.dashArray}"`), o.push('stroke-linejoin="round"', 'stroke-linecap="round"')), o.join(" ");
196
- }
197
- function wt(t, e, o) {
198
- return !(t.right + o < e.left || e.right + o < t.left || t.bottom + o < e.top || e.bottom + o < t.top);
199
- }
200
- function At(t, e = 2) {
201
- const o = t.map((i, s) => ({ box: i, index: s })).sort((i, s) => s.box.priority - i.box.priority || i.index - s.index), r = [], n = [];
202
- for (const { box: i, index: s } of o) {
203
- let c = !1;
204
- for (const f of r)
205
- if (wt(i, f, e)) {
206
- c = !0;
207
- break;
208
- }
209
- c || (r.push(i), n.push(s));
210
- }
211
- return n.sort((i, s) => i - s);
212
- }
213
- function Tt(t, e, o, r, n = "middle", i = "center") {
214
- const s = t.length * r * 0.6, c = r * 1.2, f = n === "start" ? e : n === "end" ? e - s : e - s / 2, u = i === "top" ? o : i === "bottom" ? o - c : o - c / 2;
215
- return { left: f, top: u, right: f + s, bottom: u + c };
216
- }
217
- const G = 32, z = (t) => t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), S = (t) => z(t).replace(/"/g, "&quot;"), y = (t) => (Math.round(t * 100) / 100).toString();
218
- function j(t, e) {
219
- const o = [];
220
- for (const r of t)
221
- if (!(r.length < 2)) {
222
- o.push(`M${y(r[0][0])} ${y(r[0][1])}`);
223
- for (let n = 1; n < r.length; n++) o.push(`L${y(r[n][0])} ${y(r[n][1])}`);
224
- e && o.push("Z");
225
- }
226
- return o.join("");
227
- }
228
- const et = { rings: [], kind: "line" };
229
- function Lt(t) {
230
- const e = t, o = e?.type ?? "", r = e?.coordinates;
231
- switch (o) {
232
- case "Polygon":
233
- return { rings: r, kind: "area" };
234
- case "MultiPolygon":
235
- return { rings: r.flat(), kind: "area" };
236
- case "LineString":
237
- return { rings: [r], kind: "line" };
238
- case "MultiLineString":
239
- return { rings: r, kind: "line" };
240
- case "Point":
241
- return { rings: [[r]], kind: "point" };
242
- case "MultiPoint":
243
- return { rings: [r], kind: "point" };
244
- default:
245
- return et;
246
- }
247
- }
248
- const C = (t) => Array.isArray(t) && typeof t[0] == "number" && typeof t[1] == "number", U = (t) => Array.isArray(t) && C(t[0]);
249
- function kt(t, e, o, r) {
250
- const n = (p) => {
251
- const d = t[p];
252
- if (d !== void 0) {
253
- if (typeof d != "function") return d;
254
- try {
255
- return d(e, { index: o, data: r });
256
- } catch {
257
- return;
258
- }
259
- }
260
- }, i = n("getPolygon");
261
- if (U(i)) return { rings: [i], kind: "area" };
262
- if (Array.isArray(i) && U(i[0])) return { rings: i, kind: "area" };
263
- const s = n("getPath");
264
- if (U(s)) return { rings: [s], kind: "line" };
265
- const c = n("getSourcePosition"), f = n("getTargetPosition");
266
- if (C(c) && C(f)) return { rings: [[c, f]], kind: "line" };
267
- const u = n("getPosition");
268
- return C(u) ? { rings: [[u]], kind: "point" } : et;
269
- }
270
- function vt(t, e) {
271
- const o = B(t.data);
272
- if (o.length === 0) return { markup: "", elementCount: 0 };
273
- const r = [];
274
- let n = 0;
275
- for (let i = 0; i < o.length; i++) {
276
- const s = o[i], c = s.geometry ?? s;
277
- let { rings: f, kind: u } = Lt(c);
278
- if (f.length === 0 && ({ rings: f, kind: u } = kt(t.props, s, i, t.data)), f.length === 0) continue;
279
- const p = St(t, s, i, e.metresPerPixel);
280
- if (u === "point") {
281
- for (const l of f)
282
- for (const a of l) {
283
- const h = e.project([a[0], a[1]]);
284
- if (!W(e.frame, h)) continue;
285
- const m = Math.max(p.radius ?? 1, 0.1);
286
- r.push(
287
- `<circle cx="${y(h[0])}" cy="${y(h[1])}" r="${y(m)}" ${N(p, "area")}/>`
288
- ), n++;
289
- }
290
- continue;
291
- }
292
- const d = f.map((l) => l.map((a) => e.project([a[0], a[1]])));
293
- if (u === "area") {
294
- const l = d.map((a) => at(a, e.frame)).filter((a) => a.length >= 3);
295
- if (l.length === 0) continue;
296
- r.push(
297
- `<path d="${j(l, !0)}" fill-rule="evenodd" ${N(p, "area")}/>`
298
- ), n++;
299
- } else {
300
- const l = d.flatMap((a) => tt(a, e.frame));
301
- if (l.length === 0) continue;
302
- r.push(`<path d="${j(l, !1)}" ${N(p, "line")}/>`), n++;
303
- }
304
- }
305
- return {
306
- markup: r.length ? `<g id="${S(t.id)}">${r.join("")}</g>` : "",
307
- elementCount: n
308
- };
309
- }
310
- function Mt(t, e, o) {
311
- const r = B(t.data);
312
- if (r.length === 0) return { markup: "", elementCount: 0 };
313
- const n = t.props, i = (l, a, h, m) => {
314
- if (typeof l != "function") return l ?? m;
315
- try {
316
- return l(a, { index: h, data: t.data });
317
- } catch {
318
- return m;
319
- }
320
- }, s = String(n.fontFamily ?? "sans-serif"), c = typeof n.getTextAnchor == "string" ? n.getTextAnchor : "middle", f = typeof n.getAlignmentBaseline == "string" ? n.getAlignmentBaseline : "center", u = [];
321
- for (let l = 0; l < r.length; l++) {
322
- const a = r[l], h = String(i(n.getText, a, l, "") ?? "");
323
- if (!h) continue;
324
- const m = i(n.getPosition, a, l, void 0);
325
- if (!Array.isArray(m)) continue;
326
- const g = e.project([m[0], m[1]]);
327
- if (!W(e.frame, g)) continue;
328
- const w = Number(i(n.getSize, a, l, G)), v = Number(n.sizeScale ?? 1), M = (Number.isFinite(w) && w > 0 ? w : G) * (Number.isFinite(v) && v > 0 ? v : 1), k = E(i(n.getColor, a, l, [0, 0, 0, 255])), R = Number(i(n.getCollisionPriority, a, l, 0)) || 0, A = i(n.getPixelOffset, a, l, void 0), _ = Array.isArray(A) && typeof A[0] == "number" ? A[0] : 0, F = Array.isArray(A) && typeof A[1] == "number" ? A[1] : 0;
329
- g[0] += _, g[1] += F;
330
- const O = String(i(n.getTextAnchor, a, l, c) ?? c), T = O === "start" || O === "end" ? O : "middle", I = String(i(n.getAlignmentBaseline, a, l, f) ?? f), x = I === "top" || I === "bottom" ? I : "center", P = o ? o(h, M, s) : void 0, b = Tt(h, g[0], g[1], M, T, x), nt = P === void 0 ? { id: `${t.id}:${l}`, priority: R, ...b } : {
331
- id: `${t.id}:${l}`,
332
- priority: R,
333
- left: T === "start" ? g[0] : T === "end" ? g[0] - P : g[0] - P / 2,
334
- top: b.top,
335
- right: (T === "start" ? g[0] : T === "end" ? g[0] - P : g[0] - P / 2) + P,
336
- bottom: b.bottom
337
- };
338
- u.push({ text: h, p: g, size: M, colour: k, anchor: T, baseline: x, box: nt });
339
- }
340
- const d = (n.collisionEnabled === !1 ? u.map((l, a) => a) : At(u.map((l) => l.box))).map((l) => {
341
- const a = u[l], h = a.baseline === "top" ? "hanging" : a.baseline === "bottom" ? "alphabetic" : "central", m = a.colour.opacity < 1 ? ` fill-opacity="${a.colour.opacity.toFixed(4)}"` : "";
342
- return `<text x="${y(a.p[0])}" y="${y(a.p[1])}" font-family="${S(s)}" font-size="${y(a.size)}" text-anchor="${a.anchor}" dominant-baseline="${h}" fill="${a.colour.color}"${m}>${z(a.text)}</text>`;
343
- });
344
- return {
345
- markup: d.length ? `<g id="${S(t.id)}">${d.join("")}</g>` : "",
346
- elementCount: d.length
347
- };
348
- }
349
- function Rt(t, e) {
350
- const o = B(t.data);
351
- if (o.length === 0) return { markup: "", elementCount: 0 };
352
- const r = t.props, n = (h, m, g, w) => {
353
- if (typeof h != "function") return h ?? w;
354
- try {
355
- return h(m, { index: g, data: t.data });
356
- } catch {
357
- return w;
358
- }
359
- }, i = String(r.fontFamily ?? "sans-serif"), s = String(r.fontWeight ?? "normal"), c = Number(r.letterSpacing ?? 0) || 0, f = Number(r.offset ?? 0) || 0, u = String(r.placement ?? "middle"), p = u === "start" ? "0%" : u === "end" ? "100%" : "50%", d = u === "start" ? "start" : u === "end" ? "end" : "middle", l = [], a = [];
360
- for (let h = 0; h < o.length; h++) {
361
- const m = o[h], g = n(r.getPath, m, h, void 0), w = String(n(r.getText, m, h, "") ?? "");
362
- if (!Array.isArray(g) || g.length < 2 || !w) continue;
363
- const v = g.map((x) => e.project([x[0], x[1]])), M = tt(v, e.frame);
364
- let k = null, R = 0;
365
- for (const x of M) {
366
- let P = 0;
367
- for (let b = 1; b < x.length; b++) P += Math.hypot(x[b][0] - x[b - 1][0], x[b][1] - x[b - 1][1]);
368
- P > R && (R = P, k = x);
369
- }
370
- if (!k || k.length < 2) continue;
371
- const A = Number(n(r.getSize, m, h, 14)) || 14, _ = E(n(r.getColor, m, h, [30, 30, 30, 255])), F = `${t.id}-path-${h}`;
372
- l.push(`<path id="${S(F)}" d="${j([k], !1)}" fill="none"/>`);
373
- const O = _.opacity < 1 ? ` fill-opacity="${_.opacity.toFixed(4)}"` : "", T = c !== 0 ? ` letter-spacing="${y(c)}"` : "", I = f !== 0 ? ` dy="${y(-f)}"` : "";
374
- a.push(
375
- `<text font-family="${S(i)}" font-weight="${S(s)}" font-size="${y(A)}" fill="${_.color}"${O}${T}><textPath href="#${S(F)}" startOffset="${p}" text-anchor="${d}"${I}>${z(w)}</textPath></text>`
376
- );
377
- }
378
- return a.length === 0 ? { markup: "", elementCount: 0 } : {
379
- markup: `<defs>${l.join("")}</defs><g id="${S(t.id)}">${a.join("")}</g>`,
380
- elementCount: a.length
381
- };
382
- }
383
- function K(t, e, o) {
384
- return `<image id="${S(`band:${o.join("+")}`)}" x="${y(e.left)}" y="${y(e.top)}" width="${y(e.right - e.left)}" height="${y(e.bottom - e.top)}" preserveAspectRatio="none" href="${S(t)}"/>`;
385
- }
386
- const _t = 600, Ot = 5e4;
387
- function Ft(t) {
388
- return Math.max(1, t / 96);
389
- }
390
- async function Ct(t, e) {
391
- const o = [], r = { left: 0, top: 0, right: e.width, bottom: e.height }, n = e.effectDpi ?? _t, i = {
392
- project: e.project,
393
- frame: r,
394
- metresPerPixel: e.metresPerPixel,
395
- featureBudget: e.featureBudget ?? Ot
396
- }, s = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${e.width}" height="${e.height}" viewBox="0 0 ${e.width} ${e.height}">`;
397
- if (e.hasPostProcessPass) {
398
- const d = await e.captureBand(null, n);
399
- return o.push({
400
- code: "rasterised-by-effect",
401
- message: `The map frame was rasterised at ${n} dpi because a post-process pass${e.postProcessLabel ? ` (${e.postProcessLabel})` : ""} treats the finished frame, and there is no vector equivalent.`,
402
- fix: "Remove the finish for fully editable linework, or raise effect-dpi if the type needs to be sharper."
403
- }), {
404
- svg: `${s}${K(d, r, ["frame"])}</svg>`,
405
- notices: o,
406
- elementCount: 1
407
- };
408
- }
409
- const c = it(t.map((d) => ({ id: d.id, type: d.type }))), f = new Map(t.map((d) => [d.id, d])), u = [];
410
- let p = 0;
411
- for (const d of c) {
412
- if (d.strategy === "raster") {
413
- for (const l of d.ids) {
414
- const a = f.get(l);
415
- a && !rt(a.type) && o.push({
416
- code: "unknown-layer-type",
417
- message: `Layer "${l}" has type "${a.type}", which the serializer does not recognise — it was drawn into a raster band.`,
418
- fix: "It renders correctly but is not editable. If it should be vector, register its type with the serializer."
419
- });
420
- }
421
- u.push(K(await e.captureBand(d.ids, n), r, d.ids)), p++;
422
- continue;
423
- }
424
- for (const l of d.ids) {
425
- const a = f.get(l);
426
- if (!a || a.props.visible === !1) continue;
427
- const h = d.strategy === "path-text" ? Rt(a, i) : d.strategy === "text" ? Mt(a, i, e.measureText) : vt(a, i);
428
- h.markup && u.push(h.markup), p += h.elementCount;
429
- }
430
- }
431
- return p > i.featureBudget && o.push({
432
- code: "feature-budget",
433
- message: `The sheet emitted ${p} elements, past the ${i.featureBudget} budget — editors slow to a crawl well before this.`,
434
- fix: 'Add <om-transform type="simplify" tolerance="0.15mm"> to the densest layer, or raise the budget deliberately.'
435
- }), { svg: `${s}${u.join("")}</svg>`, notices: o, elementCount: p };
436
- }
437
- export {
438
- _t as DEFAULT_EFFECT_DPI,
439
- Ot as DEFAULT_FEATURE_BUDGET,
440
- Ft as bandScaleFor,
441
- tt as clipPolyline,
442
- at as clipRing,
443
- st as clipSegment,
444
- E as deckColorToSvg,
445
- At as declutter,
446
- K as emitRasterBand,
447
- Mt as emitTextLayer,
448
- Rt as emitTextOnPathLayer,
449
- vt as emitVectorLayer,
450
- Tt as estimateLabelBox,
451
- it as groupIntoRuns,
452
- rt as isKnownType,
453
- bt as resolveDashArray,
454
- St as resolveFeatureStyle,
455
- $t as resolveLineWidth,
456
- Pt as resolveRadius,
457
- Ct as serializeToSvg,
458
- ot as strategyFor
459
- };