@nika-js/onlymap 0.9.1 → 0.10.0

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 (79) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +26 -2
  3. package/dist/{basemap-DL0mk9Bf.js → basemap-9lXclX9H.js} +3882 -3980
  4. package/dist/cartograph/elements/om-frame.d.ts +67 -1
  5. package/dist/cartograph/georef.d.ts +18 -4
  6. package/dist/cartograph/schema.d.ts +11 -0
  7. package/dist/cartograph.js +1480 -1311
  8. package/dist/cartograph.standalone.js +1808 -1615
  9. package/dist/{cityjson-D_V5GY8b.js → cityjson-k-z1r6c0.js} +1 -1
  10. package/dist/{crs-DsDQ4Q4i.js → crs-BzE_KP4M.js} +25 -2
  11. package/dist/{crs-Ciu7Xs7a.js → crs-ChglCB3O.js} +39 -16
  12. package/dist/elements/om-map.d.ts +10 -0
  13. package/dist/{geoparquet-DJxZA0if.js → geoparquet-DFDZDBun.js} +10 -10
  14. package/dist/globe-view-D9wjfL0T.js +104 -0
  15. package/dist/hillshade-C2BQr6pd.js +298 -0
  16. package/dist/{hillshade-shader-n_zManfZ.js → hillshade-shader-DI2uLSNU.js} +15 -10
  17. package/dist/hillshade-shader.d.ts +18 -2
  18. package/dist/hillshade.d.ts +30 -0
  19. package/dist/{ifc-Dc-TdSJr.js → ifc-DXwePQRv.js} +131 -131
  20. package/dist/{index-CvuDsvnk.js → index-4Tvlt0iO.js} +47 -47
  21. package/dist/{index-BjcPjICh.js → index-Bn66l3KG.js} +59 -59
  22. package/dist/index-BuXrMq5D.js +322 -0
  23. package/dist/index-CNRbZHkK.js +459 -0
  24. package/dist/{index-DdTZSuAb.js → index-CkovmN47.js} +106 -106
  25. package/dist/index-CmuOizAF.js +641 -0
  26. package/dist/index-CvT5QHBS.js +65 -0
  27. package/dist/{index-vLXZuog4.js → index-DnVHKI61.js} +1 -1
  28. package/dist/{index-oY3XHIux.js → index-JjyDEqAS.js} +18178 -16943
  29. package/dist/index.d.ts +4 -0
  30. package/dist/layer-registry.d.ts +27 -0
  31. package/dist/{lerc-Bph62dCb.js → lerc-C1mQ_Kqq.js} +1 -1
  32. package/dist/onlymap.standalone.js +48211 -45574
  33. package/dist/onlymapjs.js +77 -74
  34. package/dist/parse-manifest.d.ts +6 -0
  35. package/dist/plane-camera.d.ts +59 -0
  36. package/dist/plane-layers.d.ts +56 -0
  37. package/dist/plane-tiles.d.ts +99 -0
  38. package/dist/plane-tileset.d.ts +31 -0
  39. package/dist/plane-warp.d.ts +91 -0
  40. package/dist/post-process-effect-DfslKPM6.js +197 -0
  41. package/dist/programmatic.d.ts +16 -1
  42. package/dist/projection.d.ts +118 -0
  43. package/dist/{raster-D-eTzCE3.js → raster-D2NzdjZE.js} +4 -4
  44. package/dist/{raster-pipeline-BlOnMPJe.js → raster-pipeline-qnD1icOv.js} +4 -3
  45. package/dist/runtime-core.d.ts +140 -1
  46. package/dist/serialize/clip.d.ts +50 -0
  47. package/dist/serialize/declutter.d.ts +44 -0
  48. package/dist/serialize/emit.d.ts +60 -0
  49. package/dist/serialize/index.d.ts +64 -0
  50. package/dist/serialize/strategy.d.ts +30 -0
  51. package/dist/serialize/style.d.ts +77 -0
  52. package/dist/snapshot.d.ts +46 -0
  53. package/dist/surface-anchor.d.ts +6 -0
  54. package/dist/text-on-path-Dm7vtNqt.js +146 -0
  55. package/dist/text-on-path.d.ts +157 -0
  56. package/dist/transform/buffer.d.ts +63 -0
  57. package/dist/transform/contour.d.ts +37 -0
  58. package/dist/transform/dot-density.d.ts +19 -0
  59. package/dist/transform/field.d.ts +80 -0
  60. package/dist/transform/geometry.d.ts +20 -0
  61. package/dist/transform/index.d.ts +29 -0
  62. package/dist/transform/simplify.d.ts +10 -0
  63. package/dist/transform/smooth.d.ts +12 -0
  64. package/dist/transform-stage.d.ts +92 -0
  65. package/dist/version.d.ts +1 -1
  66. package/dist/{zarr-BGDoEtFb.js → zarr-D5e5agMG.js} +2 -2
  67. package/docs/cartograph.md +12 -4
  68. package/docs/cartography.md +328 -0
  69. package/docs/design/arrows.md +182 -0
  70. package/docs/design/carto-substrate.md +1055 -0
  71. package/docs/design/extensions.md +250 -0
  72. package/llms.txt +2 -1
  73. package/onlymapjs.attributes.json +18 -0
  74. package/onlymapjs.html-data.json +169 -19
  75. package/package.json +1 -1
  76. package/skills/onlymapjs/SKILL.md +6 -2
  77. package/skills/onlymapjs/references/syntax.md +22 -2
  78. package/dist/hillshade-DR3TxO1a.js +0 -186
  79. package/dist/index-DO_w0tqR.js +0 -514
@@ -0,0 +1,322 @@
1
+ import { ac as j, ad as S, ae as A, af as M, ag as L } from "./index-JjyDEqAS.js";
2
+ import { ah as H, ai as V, aj as X, ak as K } from "./index-JjyDEqAS.js";
3
+ import { P as h } from "./post-process-effect-DfslKPM6.js";
4
+ const O = `
5
+ float omfx_lum(vec3 c) { return dot(c, vec3(0.299, 0.587, 0.114)); }
6
+ float omfx_hash(vec2 p) { return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453); }
7
+ `, w = {
8
+ tint: (o) => `
9
+ {
10
+ float L = omfx_lum(color.rgb);
11
+ float sat = max(max(color.r, color.g), color.b) - min(min(color.r, color.g), color.b);
12
+ vec3 duo = mix(${o("ink")}.rgb, ${o("paper")}.rgb, smoothstep(0.0, 1.0, L));
13
+ float keep = clamp(sat * 2.5, 0.0, 1.0) * ${o("keep-color")};
14
+ color.rgb = mix(color.rgb, mix(duo, color.rgb, keep), ${o("amount")});
15
+ }`,
16
+ levels: (o) => `
17
+ {
18
+ color.rgb = clamp((color.rgb - 0.5) * ${o("contrast")} + 0.5 + ${o("brightness")}, 0.0, 1.0);
19
+ color.rgb = pow(max(color.rgb, vec3(0.0)), vec3(1.0 / max(${o("gamma")}, 0.0001)));
20
+ }`,
21
+ saturation: (o) => `
22
+ {
23
+ color.rgb = mix(vec3(omfx_lum(color.rgb)), color.rgb, ${o("amount")});
24
+ }`,
25
+ posterize: (o) => `
26
+ {
27
+ float n = max(${o("levels")}, 2.0);
28
+ color.rgb = floor(color.rgb * n + 0.5) / n;
29
+ }`,
30
+ vignette: (o) => `
31
+ {
32
+ float r = length(coord - 0.5) * 1.41421356;
33
+ float v = smoothstep(${o("radius")}, ${o("radius")} + max(${o("softness")}, 0.0001), r);
34
+ color.rgb *= 1.0 - ${o("amount")} * v;
35
+ }`,
36
+ grain: (o, e) => `
37
+ {
38
+ float cell = max(${o("size")} * ${e}, 1.0);
39
+ vec2 g = floor(coord * texSize / cell) + ${o("seed")};
40
+ float n = omfx_hash(g) - 0.5;
41
+ vec3 nz = ${o("mono")} > 0.5
42
+ ? vec3(n)
43
+ : vec3(n, omfx_hash(g + 17.0) - 0.5, omfx_hash(g + 41.0) - 0.5);
44
+ color.rgb = clamp(color.rgb + nz * ${o("amount")}, 0.0, 1.0);
45
+ }`,
46
+ edges: (o, e) => `
47
+ {
48
+ vec2 o = max(${o("width")} * ${e}, 1.0) / texSize;
49
+ float tl = omfx_lum(texture(src, coord + o * vec2(-1.0, 1.0)).rgb);
50
+ float t = omfx_lum(texture(src, coord + o * vec2( 0.0, 1.0)).rgb);
51
+ float tr = omfx_lum(texture(src, coord + o * vec2( 1.0, 1.0)).rgb);
52
+ float l = omfx_lum(texture(src, coord + o * vec2(-1.0, 0.0)).rgb);
53
+ float r = omfx_lum(texture(src, coord + o * vec2( 1.0, 0.0)).rgb);
54
+ float bl = omfx_lum(texture(src, coord + o * vec2(-1.0, -1.0)).rgb);
55
+ float b = omfx_lum(texture(src, coord + o * vec2( 0.0, -1.0)).rgb);
56
+ float br = omfx_lum(texture(src, coord + o * vec2( 1.0, -1.0)).rgb);
57
+ float gx = (tr + 2.0 * r + br) - (tl + 2.0 * l + bl);
58
+ float gy = (bl + 2.0 * b + br) - (tl + 2.0 * t + tr);
59
+ float e = clamp(sqrt(gx * gx + gy * gy) * 2.0, 0.0, 1.0);
60
+ color.rgb = mix(color.rgb, ${o("color")}.rgb, e * ${o("amount")});
61
+ }`,
62
+ blur: (o, e) => `
63
+ {
64
+ vec2 o = max(${o("radius")} * ${e}, 0.5) / texSize;
65
+ vec4 sum = vec4(0.0);
66
+ float wsum = 0.0;
67
+ for (int i = -2; i <= 2; i++) {
68
+ for (int j = -2; j <= 2; j++) {
69
+ float w = exp(-float(i * i + j * j) / 4.0);
70
+ sum += texture(src, coord + o * vec2(float(i), float(j))) * w;
71
+ wsum += w;
72
+ }
73
+ }
74
+ color = sum / wsum;
75
+ }`,
76
+ sharpen: (o, e) => `
77
+ {
78
+ vec2 o = max(${o("radius")} * ${e}, 0.5) / texSize;
79
+ vec4 soft = vec4(0.0);
80
+ float wsum = 0.0;
81
+ for (int i = -1; i <= 1; i++) {
82
+ for (int j = -1; j <= 1; j++) {
83
+ float w = (i == 0 && j == 0) ? 4.0 : 1.0;
84
+ soft += texture(src, coord + o * vec2(float(i), float(j))) * w;
85
+ wsum += w;
86
+ }
87
+ }
88
+ soft /= wsum;
89
+ color.rgb = clamp(color.rgb + (color.rgb - soft.rgb) * ${o("amount")}, 0.0, 1.0);
90
+ }`,
91
+ halftone: (o, e) => `
92
+ {
93
+ float cell = max(${o("cell")} * ${e}, 2.0);
94
+ float a = radians(${o("angle")});
95
+ float ca = cos(a);
96
+ float sa = sin(a);
97
+ mat2 rot = mat2(ca, -sa, sa, ca);
98
+ mat2 inv = mat2(ca, sa, -sa, ca);
99
+ vec2 p = coord * texSize;
100
+ vec2 rp = rot * p;
101
+ vec2 centre = inv * ((floor(rp / cell) + 0.5) * cell);
102
+ vec4 c = texture(src, clamp(centre / texSize, vec2(0.0), vec2(1.0)));
103
+ float radius = sqrt(clamp(1.0 - omfx_lum(c.rgb), 0.0, 1.0)) * 0.5;
104
+ float d = length(fract(rp / cell) - 0.5);
105
+ float cov = 1.0 - smoothstep(radius - 0.08, radius + 0.08, d);
106
+ vec3 screened = mix(${o("paper")}.rgb, c.rgb, cov);
107
+ color.rgb = mix(color.rgb, screened, ${o("amount")});
108
+ }`
109
+ };
110
+ function b(o) {
111
+ const e = j(o), t = Object.prototype.hasOwnProperty.call(w, o) ? w[o] : void 0;
112
+ return e && t ? { ...e, glsl: t } : void 0;
113
+ }
114
+ const y = ` float omfxAlpha = inColor.a;
115
+ vec4 color = vec4(omfxAlpha > 0.0 ? inColor.rgb / omfxAlpha : vec3(0.0), omfxAlpha);`, _ = " return vec4(color.rgb * omfxAlpha, omfxAlpha);";
116
+ function z(o) {
117
+ const e = [];
118
+ let t = [];
119
+ const s = () => {
120
+ t.length > 0 && e.push({ kind: "pointwise", ops: t }), t = [];
121
+ };
122
+ return o.forEach((n, l) => {
123
+ if (n.def.kind === "pointwise") {
124
+ t.push(l);
125
+ return;
126
+ }
127
+ s(), e.push({ kind: "neighbourhood", op: l });
128
+ }), s(), e;
129
+ }
130
+ function T(o, e) {
131
+ if (o.length === 0) return null;
132
+ const t = [], s = [], n = /* @__PURE__ */ new Map();
133
+ o.forEach((a, u) => {
134
+ for (const g of a.def.params) {
135
+ const v = a.values[g.name];
136
+ let p;
137
+ g.kind === "color" ? (p = `c${t.length}`, t.push({ key: p, value: Array.isArray(v) ? v : [0, 0, 0, 1] })) : (p = `f${s.length}`, s.push({ key: p, value: typeof v == "number" ? v : 0 })), n.set(`${u}:${g.name}`, `${e}.${p}`);
138
+ }
139
+ });
140
+ const l = {}, c = {}, r = [];
141
+ for (const { key: a, value: u } of t)
142
+ l[a] = u, c[a] = "vec4<f32>", r.push(` vec4 ${a};`);
143
+ for (const { key: a, value: u } of s)
144
+ l[a] = u, c[a] = "f32", r.push(` float ${a};`);
145
+ l.pxPerMm = S, c.pxPerMm = "f32", r.push(" float pxPerMm;");
146
+ const i = `${e}.pxPerMm`, f = (a) => (u) => n.get(`${a}:${u}`) ?? "0.0", m = [], d = [];
147
+ z(o).forEach((a, u) => {
148
+ if (a.kind === "pointwise") {
149
+ const p = `${e}_p${u}`, E = a.ops.map(($) => o[$].def.glsl(f($), i)).join(`
150
+ `);
151
+ m.push(
152
+ `vec4 ${p}(vec4 inColor, vec2 texSize, vec2 coord) {
153
+ ${y}
154
+ ${E}
155
+ ${_}
156
+ }`
157
+ ), d.push({ filter: p });
158
+ return;
159
+ }
160
+ const g = `${e}_n${u}`, v = o[a.op].def.glsl(f(a.op), i);
161
+ m.push(
162
+ `vec4 ${g}(sampler2D src, vec2 texSize, vec2 coord) {
163
+ vec4 inColor = texture(src, coord);
164
+ ${y}
165
+ ${v}
166
+ ${_}
167
+ }`
168
+ ), d.push({ sampler: g });
169
+ });
170
+ const x = [
171
+ `layout(std140) uniform ${e}Uniforms {`,
172
+ ...r,
173
+ `} ${e};`,
174
+ O,
175
+ ...m
176
+ ].join(`
177
+ `);
178
+ return {
179
+ // A multi-pass module names the function each pass runs, which deck's
180
+ // runtime reads (`typeof pass.filter === 'string' ? pass.filter : …`) but
181
+ // its `ShaderSubPass` type declares as a boolean — a deck typing gap, not
182
+ // a runtime one, the same shape as `maxZoom` on the standalone controller.
183
+ module: { name: e, fs: x, uniformTypes: c, passes: d },
184
+ uniforms: l,
185
+ passCount: d.length
186
+ };
187
+ }
188
+ const C = /^\s*(-?[\d.]+)\s*(mm)?\s*$/i, N = /^\s*(-?[\d.]+)\s*(deg)?\s*$/i;
189
+ function k(o, e) {
190
+ if (o.kind === "color") {
191
+ const s = L(e);
192
+ if (!s) return;
193
+ const [n, l, c, r] = s;
194
+ return [n / 255, l / 255, c / 255, r === void 0 ? 1 : r > 1 ? r / 255 : r];
195
+ }
196
+ if (o.kind === "length" || o.kind === "angle") {
197
+ const s = (o.kind === "length" ? C : N).exec(e);
198
+ if (!s) return;
199
+ const n = Number(s[1]);
200
+ return Number.isFinite(n) ? n : void 0;
201
+ }
202
+ const t = Number(e);
203
+ return Number.isFinite(t) ? t : void 0;
204
+ }
205
+ function U(o) {
206
+ return k(o, String(o.default)) ?? 0;
207
+ }
208
+ function P(o, e) {
209
+ const t = b(o);
210
+ if (!t) return null;
211
+ const s = {};
212
+ for (const n of t.params) {
213
+ const l = e(n.name), c = l === null ? void 0 : k(n, l);
214
+ s[n.name] = c ?? U(n);
215
+ }
216
+ return { op: o, values: s };
217
+ }
218
+ function R(o) {
219
+ if (!o || typeof o != "object") return !1;
220
+ const e = o;
221
+ return typeof e.name == "string" && typeof e.fs == "string" && Array.isArray(e.passes) && e.passes.length > 0;
222
+ }
223
+ function J(o) {
224
+ const e = [];
225
+ for (const t of Array.from(o.querySelectorAll(":scope > om-effect"))) {
226
+ const s = t.getAttribute("preset"), n = t.getAttribute("op"), l = t.querySelector(":scope > script[type='application/json']");
227
+ if (s !== null && s !== "") {
228
+ if (!A(s)) {
229
+ console.warn(`[onlymapjs] <om-effect preset="${s}"> is not a known preset — skipped.`, t);
230
+ continue;
231
+ }
232
+ const c = M[s].map(({ op: r, params: i }) => b(r) ? P(r, (m) => {
233
+ const d = t.getAttribute(`${r}-${m}`);
234
+ if (d !== null) return d;
235
+ const x = i[m];
236
+ return x === void 0 ? null : String(x);
237
+ }) : null).filter((r) => r !== null);
238
+ e.push({ ops: c });
239
+ continue;
240
+ }
241
+ if (n !== null && n !== "") {
242
+ const c = P(n, (r) => t.getAttribute(r));
243
+ if (!c) {
244
+ console.warn(`[onlymapjs] <om-effect op="${n}"> is not a known op — skipped.`, t);
245
+ continue;
246
+ }
247
+ e.push({ ops: [c] });
248
+ continue;
249
+ }
250
+ if (l) {
251
+ let c;
252
+ try {
253
+ c = JSON.parse(l.textContent ?? "");
254
+ } catch (f) {
255
+ console.warn(`[onlymapjs] <om-effect>'s inline module is not valid JSON — skipped. ${String(f)}`, t);
256
+ continue;
257
+ }
258
+ if (!R(c)) {
259
+ console.warn(
260
+ "[onlymapjs] <om-effect>'s inline module needs `name`, `fs` and a non-empty `passes` — skipped.",
261
+ t
262
+ );
263
+ continue;
264
+ }
265
+ let r = {};
266
+ const i = t.getAttribute("uniforms");
267
+ if (i)
268
+ try {
269
+ r = JSON.parse(i);
270
+ } catch (f) {
271
+ console.warn(`[onlymapjs] <om-effect uniforms> is not valid JSON — ignored. ${String(f)}`, t);
272
+ }
273
+ e.push({ raw: { module: c, uniforms: r } });
274
+ continue;
275
+ }
276
+ console.warn("[onlymapjs] <om-effect> needs `preset`, `op`, or an inline module — skipped.", t);
277
+ }
278
+ return e;
279
+ }
280
+ let F = 0;
281
+ const q = () => F++;
282
+ function D(o, e = S) {
283
+ const t = [], s = [];
284
+ let n = [];
285
+ const l = q(), c = () => {
286
+ if (n.length === 0) return;
287
+ const r = T(n, `omfx${l}_${t.length}`);
288
+ if (n = [], !r) return;
289
+ const i = { ...r.uniforms, pxPerMm: e }, f = new h(r.module, i);
290
+ s.push({ effect: f, uniforms: r.uniforms }), t.push(f);
291
+ };
292
+ for (const r of o) {
293
+ if (r.ops) {
294
+ for (const { op: i, values: f } of r.ops) {
295
+ const m = b(i);
296
+ m && n.push({ def: m, values: f });
297
+ }
298
+ continue;
299
+ }
300
+ r.raw && (c(), t.push(new h(r.raw.module, r.raw.uniforms)));
301
+ }
302
+ return c(), {
303
+ effects: t,
304
+ setPixelsPerMm(r) {
305
+ for (const { effect: i, uniforms: f } of s) i.setProps({ ...f, pxPerMm: r });
306
+ }
307
+ };
308
+ }
309
+ export {
310
+ S as CSS_PX_PER_MM,
311
+ M as EFFECT_PRESETS,
312
+ H as EFFECT_PRESET_NAMES,
313
+ V as OP_META,
314
+ X as OP_NAMES,
315
+ D as buildPostProcessEffects,
316
+ k as coerceParam,
317
+ K as expandPreset,
318
+ A as isEffectPreset,
319
+ b as opDef,
320
+ j as opMeta,
321
+ J as parseEffectEls
322
+ };