@nika-js/onlymap 0.10.4 → 0.10.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +1 -1
  3. package/dist/{basemap-CEk-fwwQ.js → basemap-Do1r50ff.js} +2 -2
  4. package/dist/cartograph/elements/om-frame.d.ts +55 -2
  5. package/dist/cartograph/elements/om-source.d.ts +23 -0
  6. package/dist/cartograph/frame-sources.d.ts +64 -0
  7. package/dist/cartograph/live-frame.d.ts +8 -2
  8. package/dist/cartograph.js +1324 -1126
  9. package/dist/cartograph.standalone.js +1804 -1606
  10. package/dist/elements/om-map.d.ts +11 -0
  11. package/dist/{geoparquet-aBafoHei.js → geoparquet-CfnIgWoq.js} +1 -1
  12. package/dist/{globe-view-CPzn74yH.js → globe-view-CKrjE2_P.js} +1 -1
  13. package/dist/{hillshade-fonIyeOe.js → hillshade-DYX4HiM6.js} +1 -1
  14. package/dist/{index-6uyOjvvx.js → index-CLwi0tl1.js} +1 -1
  15. package/dist/{index-XlX-ORox.js → index-Cr2lpzhG.js} +9673 -9611
  16. package/dist/{index-CW9LiA0Z.js → index-D7pGwN4r.js} +2 -2
  17. package/dist/{index-CIiSsOZG.js → index-DfH_mTX9.js} +1 -1
  18. package/dist/{index-BOXzqzVq.js → index-DwX39Hco.js} +1 -1
  19. package/dist/{index-BYOHopZU.js → index-jOAZ7MGr.js} +1 -1
  20. package/dist/{index-irwJUTjX.js → index-pNSDUva1.js} +1 -1
  21. package/dist/{index-BlwNB2Fo.js → index-q_KoQjsU.js} +3 -3
  22. package/dist/{index-FP1-ImsV.js → index-xTIB8sjz.js} +3 -3
  23. package/dist/legend-spec.d.ts +18 -0
  24. package/dist/{lerc-B_m7L7RH.js → lerc-DIXeSlBh.js} +1 -1
  25. package/dist/onlymap.standalone.js +18707 -18590
  26. package/dist/onlymapjs.js +1 -1
  27. package/dist/{post-process-effect-D-uTiLdK.js → post-process-effect-BSBhBXeu.js} +1 -1
  28. package/dist/{raster-D3o26cuQ.js → raster-mlOu3P2H.js} +3 -3
  29. package/dist/{raster-pipeline-1u0HyuNs.js → raster-pipeline-ByRr7hBG.js} +1 -1
  30. package/dist/runtime-core.d.ts +19 -0
  31. package/dist/text-on-path-Q0dF8039.js +201 -0
  32. package/dist/text-on-path.d.ts +51 -11
  33. package/dist/version.d.ts +1 -1
  34. package/dist/{zarr-CVVmWsbf.js → zarr-D6-cCHW4.js} +2 -2
  35. package/docs/cartograph.md +49 -3
  36. package/docs/design/carto-substrate.md +12 -0
  37. package/docs/design/frame-sources.md +229 -0
  38. package/llms.txt +2 -2
  39. package/onlymapjs.attributes.json +2 -0
  40. package/onlymapjs.html-data.json +36 -0
  41. package/package.json +1 -1
  42. package/skills/onlymapjs/SKILL.md +3 -2
  43. package/skills/onlymapjs/references/syntax.md +16 -2
  44. package/dist/text-on-path-DCS_Eg0_.js +0 -146
package/dist/onlymapjs.js CHANGED
@@ -1,4 +1,4 @@
1
- import { bP as e, bQ as r, bR as t, as as c, C as o, bS as i, c as n, bT as d, bU as l, bV as S, bW as E, ah as g, bX as L, bY as T, bZ as _, b_ as A, b$ as p, c0 as m, c1 as I, c2 as D, L as M, g as u, c3 as b, c4 as y, c5 as f, c6 as O, c7 as P, bE as R, c8 as C, ap as N, c9 as F, aB as h, ca as B, W as v, cb as x, aA as G, cc as U, cd as W, ce as w, cf as Y, cg as k, ch as X, ci as H, cj as K, ck as V, cl as j, cm as z, cn as J, co as q, cp as Q, cq as Z, cr as $, ak as aa, cs as sa, ct as ea, cu as ra, cv as ta, cw as ca, cx as oa, cy as ia, cz as na, cA as da, cB as la, cC as Sa, cD as Ea, aq as ga, cE as La, cF as Ta, ae as _a, cG as Aa, cH as pa, cI as ma, cJ as Ia, cK as Da, cL as Ma, cM as ua, cN as ba, cO as ya, cP as fa, cQ as Oa, cR as Pa, cS as Ra, cT as Ca, cU as Na, cV as Fa, cW as ha, cX as Ba, cY as va, cZ as xa, c_ as Ga, c$ as Ua, d0 as Wa, d1 as wa, d2 as Ya, d3 as ka, d4 as Xa, d5 as Ha, d6 as Ka, aC as Va, d7 as ja, d8 as za, d9 as Ja, da as qa, db as Qa, dc as Za, dd as $a, de as as, df as ss, dg as es, dh as rs, di as ts, dj as cs, dk as os, dl as is, dm as ns, dn as ds } from "./index-XlX-ORox.js";
1
+ import { bP as e, bQ as r, bR as t, as as c, C as o, bS as i, c as n, bT as d, bU as l, bV as S, bW as E, ah as g, bX as L, bY as T, bZ as _, b_ as A, b$ as p, c0 as m, c1 as I, c2 as D, L as M, g as u, c3 as b, c4 as y, c5 as f, c6 as O, c7 as P, bE as R, c8 as C, ap as N, c9 as F, aB as h, ca as B, W as v, cb as x, aA as G, cc as U, cd as W, ce as w, cf as Y, cg as k, ch as X, ci as H, cj as K, ck as V, cl as j, cm as z, cn as J, co as q, cp as Q, cq as Z, cr as $, ak as aa, cs as sa, ct as ea, cu as ra, cv as ta, cw as ca, cx as oa, cy as ia, cz as na, cA as da, cB as la, cC as Sa, cD as Ea, aq as ga, cE as La, cF as Ta, ae as _a, cG as Aa, cH as pa, cI as ma, cJ as Ia, cK as Da, cL as Ma, cM as ua, cN as ba, cO as ya, cP as fa, cQ as Oa, cR as Pa, cS as Ra, cT as Ca, cU as Na, cV as Fa, cW as ha, cX as Ba, cY as va, cZ as xa, c_ as Ga, c$ as Ua, d0 as Wa, d1 as wa, d2 as Ya, d3 as ka, d4 as Xa, d5 as Ha, d6 as Ka, aC as Va, d7 as ja, d8 as za, d9 as Ja, da as qa, db as Qa, dc as Za, dd as $a, de as as, df as ss, dg as es, dh as rs, di as ts, dj as cs, dk as os, dl as is, dm as ns, dn as ds } from "./index-Cr2lpzhG.js";
2
2
  export {
3
3
  e as ALL_POSITION_VALUES,
4
4
  r as AUDIT_EXEMPTIONS,
@@ -1,4 +1,4 @@
1
- import { av as m, aw as h, ax as P, ay as S, az as C } from "./index-XlX-ORox.js";
1
+ import { av as m, aw as h, ax as P, ay as S, az as C } from "./index-Cr2lpzhG.js";
2
2
  const x = (
3
3
  /* wgsl */
4
4
  `struct VertexInputs {
@@ -1,7 +1,7 @@
1
- import { c as se, t as $e, i as Ct, a as ke, s as Lt, C as It, b as Gt, F as vt, A as Et, d as Ft, R as ye, e as At, p as jt, m as Rt, f as Mt, g as We, h as Ut, r as le, j as Ot, k as xt, l as Kt, n as Dt } from "./raster-pipeline-1u0HyuNs.js";
1
+ import { c as se, t as $e, i as Ct, a as ke, s as Lt, C as It, b as Gt, F as vt, A as Et, d as Ft, R as ye, e as At, p as jt, m as Rt, f as Mt, g as We, h as Ut, r as le, j as Ot, k as xt, l as Kt, n as Dt } from "./raster-pipeline-ByRr7hBG.js";
2
2
  import { N as Nt, c as zt } from "./hillshade-apron-Bem3DWyJ.js";
3
3
  import { r as Bt } from "./hillshade-shader-DI2uLSNU.js";
4
- import { bK as _t, bL as $t } from "./index-XlX-ORox.js";
4
+ import { bK as _t, bL as $t } from "./index-Cr2lpzhG.js";
5
5
  import we from "./index-CW1n5LdO.js";
6
6
  function kt(e, t) {
7
7
  const n = e.length / 3, r = new Uint8ClampedArray(n * 4), o = 0, i = n, a = n * 2;
@@ -1072,7 +1072,7 @@ j.set(f.Zstd, () => import("./zstd-jXobGRcq.js").then((e) => e.decode));
1072
1072
  j.set(f.Jpeg, () => Promise.resolve(ce));
1073
1073
  j.set(f.Jpeg6, () => Promise.resolve(ce));
1074
1074
  j.set(f.Webp, () => Promise.resolve(ce));
1075
- j.set(f.Lerc, () => import("./lerc-B_m7L7RH.js").then((e) => e.decode));
1075
+ j.set(f.Lerc, () => import("./lerc-DIXeSlBh.js").then((e) => e.decode));
1076
1076
  async function ue(e, t, n) {
1077
1077
  const r = j.get(t);
1078
1078
  if (!r)
@@ -1,5 +1,5 @@
1
1
  import { w as he } from "./mgrs-BY9bIvp4.js";
2
- import { a3 as de, bD as fe, bE as re, c as oe, bF as me, G as pe, bG as ge, aK as Z, bH as ve, N as be, bI as xe, bJ as Pe, al as Te, ap as ie } from "./index-XlX-ORox.js";
2
+ import { a3 as de, bD as fe, bE as re, c as oe, bF as me, G as pe, bG as ge, aK as Z, bH as ve, N as be, bI as xe, bJ as Pe, al as Te, ap as ie } from "./index-Cr2lpzhG.js";
3
3
  import { p as ye, a as Le, h as we } from "./hillshade-shader-DI2uLSNU.js";
4
4
  function Oe(n, e, t) {
5
5
  const { projectedCorners: s } = e, { topLeft: r, topRight: o, bottomRight: i, bottomLeft: a } = s, c = t(r[0], r[1]), u = t(o[0], o[1]), l = t(i[0], i[1]), d = t(a[0], a[1]), f = [
@@ -685,6 +685,25 @@ export declare class RuntimeCore {
685
685
  */
686
686
  /** The basemap's own settle state (style + tiles for the current view) — true when standalone/headless. NOT vacuously true while a basemap-mode adapter is absent (initial chunk load, a determinism-flip remount): a settle or paced gate polling that window must hold until the mount lands, not capture a frame with no basemap canvas. */
687
687
  basemapIdle(): boolean;
688
+ /**
689
+ * Does this map put ANYTHING on screen?
690
+ *
691
+ * Not a quality judgement and deliberately not "every layer loaded": one
692
+ * drawable thing is the whole bar. A sheet whose fifth layer 404s is
693
+ * degraded, not failed, and a caller that treated it as failed would be
694
+ * adjudicating cartography, which this cannot do.
695
+ *
696
+ * It exists for a caller that must distinguish "loaded and drew nothing"
697
+ * from "drew" — `<om-frame>`'s ordered sources, where a map document whose
698
+ * every layer failed to fetch settles successfully with an empty canvas.
699
+ * `layersReady()` says true there (nothing is still pending) and deck still
700
+ * lists the layers, each holding `data: []`, so neither answers the
701
+ * question. The IRs do: an empty `data` is "no rows", by its own contract.
702
+ *
703
+ * Counted as drawable: a basemap; rows on any layer; a tile template or an
704
+ * image overlay, which draw from the network rather than from `data`.
705
+ */
706
+ hasDrawableContent(): boolean;
688
707
  /** deck's own per-layer readiness (async layer/pipeline init) — whenSettled gates on this too; a capture before it is stably missing content (issue #37's flaky first frame). Headless/basemap-pending count as ready. */
689
708
  layersReady(): boolean;
690
709
  /**
@@ -0,0 +1,201 @@
1
+ import { c as E, a3 as N } from "./index-Cr2lpzhG.js";
2
+ const z = Math.PI / 180, O = 45, W = 24, T = /* @__PURE__ */ new Map();
3
+ let b = null;
4
+ function I(e) {
5
+ if (typeof document > "u") return null;
6
+ if (!b) {
7
+ const o = document.createElement("canvas");
8
+ o.width = 8, o.height = 8, b = o.getContext("2d");
9
+ }
10
+ return b && (b.font = e), b;
11
+ }
12
+ function k(e, o, t) {
13
+ const n = `${t} 100px ${o}`;
14
+ let i = T.get(n);
15
+ i || (i = /* @__PURE__ */ new Map(), T.set(n, i));
16
+ const f = i.get(e);
17
+ if (f !== void 0) return f;
18
+ const u = I(n), s = u ? u.measureText(e).width / 100 : 0.6;
19
+ return i.set(e, s), s;
20
+ }
21
+ function D(e) {
22
+ const o = [0];
23
+ let t = 0;
24
+ for (let n = 1; n < e.length; n++)
25
+ t += Math.hypot(e[n][0] - e[n - 1][0], e[n][1] - e[n - 1][1]), o.push(t);
26
+ return { cumulative: o, total: t };
27
+ }
28
+ function M(e, o, t) {
29
+ const { cumulative: n } = o;
30
+ if (e.length < 2) return null;
31
+ let i = 1;
32
+ for (; i < n.length - 1 && n[i] < t; ) i++;
33
+ const f = n[i] - n[i - 1], u = f > 0 ? (t - n[i - 1]) / f : 0, s = e[i - 1], l = e[i];
34
+ return {
35
+ position: [s[0] + (l[0] - s[0]) * u, s[1] + (l[1] - s[1]) * u],
36
+ angle: Math.atan2(-(l[1] - s[1]), l[0] - s[0]) * 180 / Math.PI
37
+ };
38
+ }
39
+ function C(e, o, t) {
40
+ if (t === 0) return e;
41
+ const n = (o + 90) * z;
42
+ return [e[0] + Math.cos(n) * t, e[1] - Math.sin(n) * t];
43
+ }
44
+ function G(e) {
45
+ return e === "auto" ? "auto" : e === "start" ? "end" : e === "end" ? "start" : "middle";
46
+ }
47
+ function L(e) {
48
+ let o = 0;
49
+ for (let t = 1; t < e.length; t++) {
50
+ let n = e[t].angle - e[t - 1].angle;
51
+ for (; n > 180; ) n -= 360;
52
+ for (; n < -180; ) n += 360;
53
+ o = Math.max(o, Math.abs(n));
54
+ }
55
+ return o;
56
+ }
57
+ function U(e, o, t, n, i, f, u) {
58
+ let s = i;
59
+ const l = [];
60
+ for (let g = 0; g < t.length; g++) {
61
+ const c = M(e, o, s + (n[g] - u) / 2);
62
+ if (!c) break;
63
+ l.push({ position: C(c.position, c.angle, f), angle: c.angle, char: t[g] }), s += n[g];
64
+ }
65
+ return l;
66
+ }
67
+ function w(e, o, t, n, i, f, u, s) {
68
+ const l = M(e, o, i), g = M(e, o, i + f);
69
+ if (!l || !g) return [];
70
+ const c = g.position[0] - l.position[0], a = g.position[1] - l.position[1], h = Math.hypot(c, a);
71
+ if (!(h > 0)) return [];
72
+ const m = Math.atan2(-a, c) * 180 / Math.PI, v = c / h, y = a / h;
73
+ let d = 0;
74
+ const x = [];
75
+ for (let r = 0; r < t.length; r++) {
76
+ const p = d + (n[r] - s) / 2, P = Math.min(p, h), A = [l.position[0] + v * P, l.position[1] + y * P];
77
+ x.push({ position: C(A, m, u), angle: m, char: t[r] }), d += n[r];
78
+ }
79
+ return x;
80
+ }
81
+ function F(e, o, t) {
82
+ if (e.length < 2 || !o) return [];
83
+ const n = D(e);
84
+ if (!(n.total > 0)) return [];
85
+ const i = [...o], f = i.map((r) => k(r, t.fontFamily, t.fontWeight) * t.sizePx + t.letterSpacing), u = f.reduce((r, p) => r + p, 0) - t.letterSpacing;
86
+ if (u > n.total) return [];
87
+ const s = n.total - u, l = Number.isFinite(t.maxAngle) ? Math.max(0, t.maxAngle) : O, g = t.orientation === "chord" ? "chord" : "curve", c = (r) => r === "start" ? 0 : r === "end" ? s : s / 2, a = c(t.placement === "auto" ? "middle" : t.placement), h = M(e, n, a), m = M(e, n, a + u);
88
+ if (h && m && m.position[0] < h.position[0]) {
89
+ const r = [...e].reverse();
90
+ return F(r, o, { ...t, placement: G(t.placement), offsetPx: -t.offsetPx });
91
+ }
92
+ const v = (r) => g === "chord" ? w(e, n, i, f, r, u, t.offsetPx, t.letterSpacing) : U(e, n, i, f, r, t.offsetPx, t.letterSpacing);
93
+ if (t.placement !== "auto") {
94
+ const r = v(c(t.placement));
95
+ if (g === "curve" && L(r) > l) {
96
+ const p = w(e, n, i, f, c(t.placement), u, t.offsetPx, t.letterSpacing);
97
+ if (p.length) return p;
98
+ }
99
+ return r;
100
+ }
101
+ let y = [], d = 1 / 0;
102
+ const x = s > 0 ? W : 1;
103
+ for (let r = 0; r < x; r++) {
104
+ const p = x === 1 ? 0 : s * r / (x - 1), P = v(p);
105
+ if (!P.length) continue;
106
+ const A = L(P);
107
+ if (A < d && (d = A, y = P, A <= l))
108
+ break;
109
+ }
110
+ if (!y.length) return [];
111
+ if (g === "curve" && d > l) {
112
+ const r = w(e, n, i, f, c("middle"), u, t.offsetPx, t.letterSpacing);
113
+ if (r.length) return r;
114
+ }
115
+ return y;
116
+ }
117
+ function S(e, o, t, n, i) {
118
+ if (typeof e != "function") return e ?? i;
119
+ try {
120
+ return e(o, { index: t, data: n });
121
+ } catch {
122
+ return i;
123
+ }
124
+ }
125
+ class j extends E {
126
+ static layerName = "OmTextOnPathLayer";
127
+ static defaultProps = {
128
+ getPath: { type: "accessor", value: (o) => o.path },
129
+ getText: { type: "accessor", value: (o) => o.text },
130
+ getSize: { type: "accessor", value: 14 },
131
+ getColor: { type: "accessor", value: [30, 30, 30, 255] },
132
+ fontFamily: { type: "string", value: "sans-serif" },
133
+ fontWeight: { type: "string", value: "normal" },
134
+ letterSpacing: { type: "number", value: 0 },
135
+ offset: { type: "number", value: 0 },
136
+ placement: { type: "string", value: "auto" },
137
+ maxAngle: { type: "number", value: 45 },
138
+ orientation: { type: "string", value: "curve" },
139
+ maxLabels: { type: "number", value: 2e3 }
140
+ };
141
+ /** Recompute on a viewport change: a glyph advance is pixels and a path is world distance. */
142
+ shouldUpdateState({ changeFlags: o }) {
143
+ return !!o.somethingChanged;
144
+ }
145
+ renderLayers() {
146
+ const o = this.context.viewport;
147
+ if (!o || !o.width) return null;
148
+ const t = Array.isArray(this.props.data) ? this.props.data : [], i = ["auto", "start", "middle", "end"].includes(this.props.placement) ? this.props.placement : "auto", f = this.props.orientation === "chord" ? "chord" : "curve", u = Number(this.props.maxAngle), s = this.props.fontFamily ?? "sans-serif", l = this.props.fontWeight ?? "normal", g = this.props.maxLabels ?? 2e3, c = [];
149
+ for (let a = 0; a < t.length && c.length < g; a++) {
150
+ const h = t[a], m = S(this.props.getPath, h, a, t, void 0), v = String(S(this.props.getText, h, a, t, "") ?? "");
151
+ if (!Array.isArray(m) || m.length < 2 || !v) continue;
152
+ const y = Number(S(this.props.getSize, h, a, t, 14)) || 14, d = S(this.props.getColor, h, a, t, [30, 30, 30, 255]), x = m.map((r) => o.project([r[0], r[1]]).slice(0, 2));
153
+ for (const r of F(x, v, {
154
+ fontFamily: s,
155
+ fontWeight: l,
156
+ sizePx: y,
157
+ letterSpacing: this.props.letterSpacing ?? 0,
158
+ maxAngle: Number.isFinite(u) ? u : void 0,
159
+ orientation: f,
160
+ offsetPx: this.props.offset ?? 0,
161
+ placement: i
162
+ })) {
163
+ const p = o.unproject([r.position[0], r.position[1]]);
164
+ if (c.push({
165
+ char: r.char,
166
+ position: [p[0], p[1]],
167
+ angle: r.angle,
168
+ size: y,
169
+ color: Array.isArray(d) ? d : [30, 30, 30, 255]
170
+ }), c.length >= g) break;
171
+ }
172
+ }
173
+ return c.length === 0 ? null : new N(
174
+ this.getSubLayerProps({ id: "glyphs" }),
175
+ {
176
+ data: c,
177
+ getText: (a) => a.char,
178
+ getPosition: (a) => a.position,
179
+ getAngle: (a) => a.angle,
180
+ getSize: (a) => a.size,
181
+ getColor: (a) => a.color,
182
+ fontFamily: s,
183
+ fontWeight: l,
184
+ getTextAnchor: "middle",
185
+ getAlignmentBaseline: "center",
186
+ characterSet: "auto",
187
+ // Every glyph is its own instance, so deck's own collision would fight
188
+ // the word it belongs to. The whole label is placed or dropped.
189
+ updateTriggers: { getText: c.length, getPosition: c.length }
190
+ }
191
+ );
192
+ }
193
+ }
194
+ export {
195
+ j as OmTextOnPathLayer,
196
+ k as charAdvance,
197
+ L as maxGlyphTurn,
198
+ D as pathMetrics,
199
+ F as placeTextOnPath,
200
+ M as pointAtDistance
201
+ };
@@ -23,7 +23,15 @@
23
23
  * `<textPath>` is exactly the right primitive.
24
24
  */
25
25
  import { CompositeLayer, type Layer } from "@deck.gl/core";
26
- export type PathPlacement = "start" | "middle" | "end";
26
+ export type PathPlacement = "auto" | "start" | "middle" | "end";
27
+ /** How a label sits on its line: following every bend, or straight along the chord across its span. */
28
+ export type PathOrientation = "curve" | "chord";
29
+ /** A glyph as PLACEMENT produces it — the layer adds size and colour. */
30
+ export type PlacedGlyph = {
31
+ position: ScreenPoint;
32
+ angle: number;
33
+ char: string;
34
+ };
27
35
  export interface OmTextOnPathLayerProps {
28
36
  data?: unknown;
29
37
  getPath?: unknown;
@@ -34,6 +42,10 @@ export interface OmTextOnPathLayerProps {
34
42
  fontWeight?: string | number;
35
43
  /** Extra tracking between glyphs, in pixels. Letter-spaced names are a cartographic convention, not a flourish. */
36
44
  letterSpacing?: number;
45
+ /** Largest turn between adjacent glyphs, in degrees. Default 45, matching MapLibre's `text-max-angle`. */
46
+ maxAngle?: number;
47
+ /** `curve` follows every bend; `chord` lays the name straight along its span. */
48
+ orientation?: PathOrientation;
37
49
  /** Perpendicular offset in pixels — positive is to the LEFT of the path's direction. */
38
50
  offset?: number;
39
51
  placement?: PathPlacement;
@@ -62,10 +74,11 @@ export declare function charAdvance(char: string, fontFamily: string, fontWeight
62
74
  */
63
75
  export type ScreenPoint = [number, number];
64
76
  /** Cumulative pixel length along a projected path. */
65
- export declare function pathMetrics(path: readonly ScreenPoint[]): {
77
+ export type PathMetrics = {
66
78
  cumulative: number[];
67
79
  total: number;
68
80
  };
81
+ export declare function pathMetrics(path: readonly ScreenPoint[]): PathMetrics;
69
82
  /**
70
83
  * The screen point and tangent angle at a pixel distance along the path.
71
84
  *
@@ -87,18 +100,37 @@ export interface PlaceOptions {
87
100
  letterSpacing: number;
88
101
  offsetPx: number;
89
102
  placement: PathPlacement;
103
+ /** Largest turn allowed BETWEEN ADJACENT GLYPHS, in degrees. */
104
+ maxAngle?: number;
105
+ orientation?: PathOrientation;
90
106
  }
107
+ /** Largest turn between adjacent glyphs, in degrees — the legibility score. */
108
+ export declare function maxGlyphTurn(glyphs: readonly {
109
+ angle: number;
110
+ }[]): number;
91
111
  /**
92
- * Lay one string along one projected path. Returns nothing when the label is
93
- * longer than the path — a name that does not fit is DROPPED rather than
94
- * compressed or run off the end, which is what a cartographer would do and the
95
- * only option that never leaves a label pointing at nothing.
112
+ * Lay one string along one projected path.
113
+ *
114
+ * Returns nothing when the label is longer than the path — a name that does not
115
+ * fit is DROPPED rather than compressed or run off the end, which is what a
116
+ * cartographer would do and the only option that never leaves a label pointing
117
+ * at nothing.
118
+ *
119
+ * WHERE the label sits is a search, not a constant. Pinning it to the midpoint
120
+ * put names on whatever the line happened to be doing there, and on real
121
+ * hydrography that is usually a bend: measured on Natural Earth's rivers at a
122
+ * continental scale, the Colorado turned 151 degrees between adjacent glyphs
123
+ * and the Columbia spread 292 degrees — a name wrapped most of a circle.
124
+ * Scanning for the straightest reach that still fits brought 9 of 11 rivers
125
+ * under 45 degrees, the Colorado to 34 and the Ohio to 33. Smoothing the path
126
+ * instead was tried and is weaker: it topped out around a 95 degree improvement
127
+ * and made two rivers worse, because simplifying several gentle bends can
128
+ * produce one sharp corner exactly where the label sits.
129
+ *
130
+ * So: slide, then straighten, then drop. `start`/`middle`/`end` opt out of the
131
+ * search when a label belongs at a particular place, such as a river's mouth.
96
132
  */
97
- export declare function placeTextOnPath(path: readonly ScreenPoint[], text: string, opts: PlaceOptions): {
98
- position: ScreenPoint;
99
- angle: number;
100
- char: string;
101
- }[];
133
+ export declare function placeTextOnPath(path: readonly ScreenPoint[], text: string, opts: PlaceOptions): PlacedGlyph[];
102
134
  export declare class OmTextOnPathLayer extends CompositeLayer<OmTextOnPathLayerProps> {
103
135
  static layerName: string;
104
136
  static defaultProps: {
@@ -142,6 +174,14 @@ export declare class OmTextOnPathLayer extends CompositeLayer<OmTextOnPathLayerP
142
174
  type: string;
143
175
  value: string;
144
176
  };
177
+ maxAngle: {
178
+ type: string;
179
+ value: number;
180
+ };
181
+ orientation: {
182
+ type: string;
183
+ value: string;
184
+ };
145
185
  maxLabels: {
146
186
  type: string;
147
187
  value: number;
package/dist/version.d.ts CHANGED
@@ -5,4 +5,4 @@
5
5
  * the build rootDir, and a `define` would need repeating across vite/vitest/
6
6
  * vite-node configs.
7
7
  */
8
- export declare const LIBRARY_VERSION = "0.10.4";
8
+ export declare const LIBRARY_VERSION = "0.10.6";
@@ -1,5 +1,5 @@
1
- import { A as ur, d as lr, R as zt, e as fr, m as dr, p as St, f as hr, k as pr, l as mr } from "./raster-pipeline-1u0HyuNs.js";
2
- import { c as gr } from "./index-XlX-ORox.js";
1
+ import { A as ur, d as lr, R as zt, e as fr, m as dr, p as St, f as hr, k as pr, l as mr } from "./raster-pipeline-ByRr7hBG.js";
2
+ import { c as gr } from "./index-Cr2lpzhG.js";
3
3
  import $t from "./index-CW1n5LdO.js";
4
4
  var Et;
5
5
  function h(e, t, n) {
@@ -22,8 +22,8 @@ to PDF at true page size via CSS `@page` and exports PNG/JPEG at print DPI throu
22
22
  <html>
23
23
  <head>
24
24
  <meta charset="utf-8">
25
- <script type="module" src="https://unpkg.com/@nika-js/onlymap@0.10.4/dist/cartograph.standalone.js"></script>
26
- <link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.10.4/dist/cartograph.css">
25
+ <script type="module" src="https://unpkg.com/@nika-js/onlymap@0.10.6/dist/cartograph.standalone.js"></script>
26
+ <link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.10.6/dist/cartograph.css">
27
27
  </head>
28
28
  <body>
29
29
  <om-cartograph cartograph-id="cg-lot-12" format="cartograph/2" size="A4" theme="minimal"
@@ -78,7 +78,8 @@ The authoritative attribute lists (with editor IntelliSense) are generated from
78
78
  | Element | Purpose | Status |
79
79
  |---|---|---|
80
80
  | `<om-cartograph>` | Page root: `cartograph-id`, `format="cartograph/2"`, `size` (A5–A0/Letter/Legal) or `width`/`height` (mm), `orientation`, `theme`, `title`, `attribution`; print controls `bleed`, `crop-marks`, `safe-zone`, `dpi`, `flatten`, `color-profile`; `cvd`; `allow-url-actions` | implemented |
81
- | `<om-frame>` | A placed map. `mode="static"`: a georeferenced `<img>` child placed by `crs` + `corners`. `mode="live"` (the default): mounts `<om-map>` from `src=` or an inline child with the frame's own `center/zoom/bearing/pitch`; `overview-of` draws another frame's footprint | implemented |
81
+ | `<om-frame>` | A placed map. `mode="static"`: a georeferenced `<img>` child placed by `crs` + `corners`. `mode="live"` (the default): mounts `<om-map>` from `src=`, an `<om-source>` child or an inline child with the frame's own `center/zoom/bearing/pitch`; `overview-of` draws another frame's footprint | implemented |
82
+ | `<om-source>` | One place a frame's picture may come from — `src` (a map document `.html`, or a capture image), plus `corners`/`crs`/`crs-def` for a capture. A frame tries its sources in document order and shows the first that renders | implemented |
82
83
  | `<om-text>` | Text block — `kind` (title/text/attribution), `font-size` (pt), `weight`, `align`, `font`, `color`, `bg`; body may use `{{tokens}}` | implemented |
83
84
  | `<om-scalebar>` | Scale bar — `for`, `units` (metric/imperial/nautical), `segments`, `segment-length`, `kind` (single/double/line/ticks) | implemented |
84
85
  | `<om-north>` | North indicator — `for`, `kind` (arrow/rose). Direction is derived from the frame's georeference | implemented |
@@ -158,6 +159,51 @@ A live frame mounts the real map runtime with the FRAME's own camera:
158
159
  `om-frame-error`; a failed frame shows a visible inline placeholder rather than an empty
159
160
  box, which on a printed page is indistinguishable from a design choice.
160
161
 
162
+ ## Ordered sources
163
+
164
+ `src=` names one place the picture comes from and assumes it works. That holds in the app
165
+ that wrote the sheet and essentially nowhere else: a relative path into a host's storage
166
+ and a host-local protocol for the layer data are both app-local, so the same file opened
167
+ elsewhere mounts a map with zero drawable layers and *reports success*. The frame looks
168
+ like a blank box surrounded by correct furniture.
169
+
170
+ A frame can therefore declare several sources and show the first that **renders**:
171
+
172
+ ```html
173
+ <om-frame id="main" x="15" y="41" w="255" h="155" center="[-96, 38]" zoom="3.25">
174
+ <om-source src="../maps/map-abc.html"></om-source>
175
+ <om-source src="captures/main@2x.png"
176
+ corners="[[-126,50],[-66,50],[-66,23],[-126,23]]" crs="EPSG:5070"></om-source>
177
+ </om-frame>
178
+ ```
179
+
180
+ - **`src=` on the frame is shorthand** for the first `<om-source src=>`, so every existing
181
+ document keeps working and the common case stays one line. Writing both is fine: the
182
+ frame's `src=` is tried first, then each `<om-source>` in document order. An inline
183
+ `<om-map>` child always outranks both — the author put the map *in* the frame.
184
+ - **One attribute, `src`, for both kinds.** The kind is read from the extension (`.html`
185
+ is a map document; `.png`/`.jpg`/`.jpeg`/`.webp`/`.avif`/`.gif`/`.svg` is a capture).
186
+ An unrecognised extension is a validation error naming both, never a silent guess.
187
+ - **"Rendered" means one drawable thing**, checked after the map settles: a basemap, or
188
+ rows on any layer, or a tile template. Deliberately not "every layer loaded" — a sheet
189
+ whose fifth layer 404s is degraded, not failed, and swapping it for a stale capture
190
+ would be worse than showing it.
191
+ - **A capture carries its own `corners` (and `crs`)**, because when the capture is what
192
+ gets shown the live map did not load and its projection is unknowable. The corners are
193
+ required on a capture source and are what furniture is placed against.
194
+ - **The frame says which source it settled on** — `data-om-carto-source="<index>"` plus an
195
+ `om-frame-source` event (`{ id, index, kind, src }`). A capture shown silently is its own
196
+ trap: an editor should be able to report "showing a capture". `om-frame-view` fires too,
197
+ so the graticule, scale bar and north arrow re-place against the new georeference.
198
+ - A source that fails by drawing nothing costs a full settle before the next is tried (up
199
+ to the existing 20 s timeout). That is paid once, on a stored file; in the app the first
200
+ source succeeds and the mechanism costs nothing.
201
+
202
+ **A stored sheet is renderable in place, not portable.** Capture paths are relative, so
203
+ moving the file alone breaks them exactly as it already breaks a relative `src=`. Export is
204
+ what produces a file that survives being sent to someone — it inlines the map and embeds
205
+ the rasters.
206
+
161
207
  ### Export and print resolution
162
208
 
163
209
  `renderCartograph()` and `print()` capture each live frame through the core's
@@ -949,6 +949,18 @@ Two other designs are in flight against this codebase — **layer extensions**
949
949
  They were written independently and they touch this one in six places. Recording the
950
950
  interactions here so none of them is discovered by a failing gate.
951
951
 
952
+ ### 13.0 Frame sources — `frame-sources.md`
953
+
954
+ Written later, and it touches §7 in one place. `freeze()` converts a live frame to a
955
+ static one and stamps `corners` + `crs`; that georef contract is reused there for a
956
+ RASTER SOURCE on a frame that is still live, rather than a second contract being
957
+ invented. Freeze remains the only way a frame stops being live.
958
+
959
+ The motivating failure is worth recording here because it is invisible from this
960
+ document: a sheet's live `src` resolves outside the host app and the map it names then
961
+ draws nothing, because its layers are on a host-local protocol. The failure is silent,
962
+ so anything hung off an error path never fires.
963
+
952
964
  ### 13.1 The rasterise trigger is a post-process pass, by type
953
965
 
954
966
  The sharpest one, and it has a wrong answer on each side.