@nika-js/onlymap 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +25 -2
  3. package/dist/{LercDecode.es-BMcxSLhD.js → LercDecode.es-IEPCRZOv.js} +1 -1
  4. package/dist/{basemap-m98j2wxG.js → basemap-DL0mk9Bf.js} +1 -1
  5. package/dist/dem-decode.d.ts +58 -0
  6. package/dist/elements/om-map.d.ts +2 -0
  7. package/dist/{geoparquet-XOwOmChh.js → geoparquet-DJxZA0if.js} +1 -1
  8. package/dist/hillshade-DR3TxO1a.js +186 -0
  9. package/dist/hillshade-apron-Bem3DWyJ.js +40 -0
  10. package/dist/hillshade-apron.d.ts +54 -0
  11. package/dist/hillshade-shader-n_zManfZ.js +160 -0
  12. package/dist/hillshade-shader.d.ts +152 -0
  13. package/dist/hillshade.d.ts +133 -0
  14. package/dist/html-data.d.ts +1 -1
  15. package/dist/{index-HZWdgtm4.js → index-BjcPjICh.js} +59 -59
  16. package/dist/{index-DzOvV-O7.js → index-CvuDsvnk.js} +22 -22
  17. package/dist/{index-CfPbQUqO.js → index-DO_w0tqR.js} +86 -83
  18. package/dist/{index-DDNElBTs.js → index-DdTZSuAb.js} +106 -106
  19. package/dist/{index-BSAY6CWm.js → index-oY3XHIux.js} +9843 -9623
  20. package/dist/{index-BMbpftvm.js → index-vLXZuog4.js} +1 -1
  21. package/dist/lerc-Bph62dCb.js +22 -0
  22. package/dist/onlymap.standalone.js +21279 -20558
  23. package/dist/onlymapjs.js +37 -37
  24. package/dist/{raster-Dg5p_99H.js → raster-D-eTzCE3.js} +609 -499
  25. package/dist/raster-hillshade.d.ts +119 -0
  26. package/dist/{raster-pipeline-DhjkqDYd.js → raster-pipeline-BlOnMPJe.js} +510 -484
  27. package/dist/raster-pipeline.d.ts +10 -0
  28. package/dist/raster.d.ts +5 -0
  29. package/dist/terrain-heightfield.d.ts +0 -16
  30. package/dist/terrain-sample.d.ts +0 -13
  31. package/dist/version.d.ts +1 -1
  32. package/dist/volumetrics.d.ts +7 -0
  33. package/dist/{zarr-D3CzK1Zm.js → zarr-BGDoEtFb.js} +2 -2
  34. package/docs/cartograph.md +2 -2
  35. package/docs/design/hillshade.md +290 -0
  36. package/docs/effects.md +11 -0
  37. package/docs/hillshade.md +203 -0
  38. package/llms.txt +2 -1
  39. package/onlymapjs.attributes.json +27 -2
  40. package/onlymapjs.html-data.json +44 -6
  41. package/package.json +13 -9
  42. package/skills/onlymapjs/SKILL.md +3 -2
  43. package/skills/onlymapjs/references/syntax.md +11 -3
  44. package/dist/lerc-qK-nhCaB.js +0 -30
@@ -1,6 +1,6 @@
1
- import { M as A, G as k, u as T, P as M, i as j, o as F, C as w, a as z, E as O, c as L } from "./index-BSAY6CWm.js";
2
- import { b as io, O as lo, d as ao, e as fo } from "./index-BSAY6CWm.js";
3
- const R = (
1
+ import { M as k, G as M, u as j, P as L, i as F, o as z, a as E, b as O, E as R, c as I } from "./index-oY3XHIux.js";
2
+ import { e as ao, O as fo, h as uo, j as po } from "./index-oY3XHIux.js";
3
+ const B = (
4
4
  /* wgsl */
5
5
  `struct VertexInputs {
6
6
  @location(0) clipSpacePositions: vec2<f32>,
@@ -25,7 +25,7 @@ fn vertexMain(inputs: VertexInputs) -> FragmentInputs {
25
25
  return outputs;
26
26
  }
27
27
  `
28
- ), I = (
28
+ ), N = (
29
29
  /* glsl */
30
30
  `#version 300 es
31
31
  in vec2 clipSpacePositions;
@@ -44,16 +44,16 @@ void main(void) {
44
44
  }
45
45
  `
46
46
  ), $ = [-1, -1, 1, -1, -1, 1, 1, 1];
47
- class B extends A {
47
+ class U extends k {
48
48
  constructor(e, t) {
49
49
  const n = $.map((r) => r === -1 ? 0 : r);
50
- t.source && (t = { ...t, source: `${R}
50
+ t.source && (t = { ...t, source: `${B}
51
51
  ${t.source}` }), super(e, {
52
- id: t.id || T("clip-space"),
52
+ id: t.id || j("clip-space"),
53
53
  ...t,
54
- vs: I,
54
+ vs: N,
55
55
  vertexCount: 4,
56
- geometry: new k({
56
+ geometry: new M({
57
57
  topology: "triangle-strip",
58
58
  vertexCount: 4,
59
59
  attributes: {
@@ -68,14 +68,14 @@ ${t.source}` }), super(e, {
68
68
  const D = `layout(std140) uniform screenUniforms {
69
69
  vec2 texSize;
70
70
  } screen;
71
- `, N = {
71
+ `, G = {
72
72
  name: "screen",
73
73
  fs: D,
74
74
  uniformTypes: {
75
75
  texSize: "vec2<f32>"
76
76
  }
77
77
  };
78
- class U extends M {
78
+ class V extends L {
79
79
  constructor(e, t) {
80
80
  super(e, t);
81
81
  const { module: n, fs: r, id: i } = t, c = {
@@ -90,7 +90,7 @@ class U extends M {
90
90
  blendColorOperation: "add",
91
91
  blendAlphaOperation: "add"
92
92
  };
93
- this.model = new B(e, { id: i, fs: r, modules: [n, N], parameters: c });
93
+ this.model = new U(e, { id: i, fs: r, modules: [n, G], parameters: c });
94
94
  }
95
95
  render(e) {
96
96
  this._renderPass(this.device, e);
@@ -124,12 +124,12 @@ class U extends M {
124
124
  this.model.draw(l), l.end();
125
125
  }
126
126
  }
127
- class S {
127
+ class P {
128
128
  constructor(e, t) {
129
- this.id = `${e.name}-pass`, this.props = t, j(e), this.module = e;
129
+ this.id = `${e.name}-pass`, this.props = t, F(e), this.module = e;
130
130
  }
131
131
  setup({ device: e }) {
132
- this.passes = G(e, this.module, this.id);
132
+ this.passes = q(e, this.module, this.id);
133
133
  }
134
134
  setProps(e) {
135
135
  this.props = e;
@@ -143,8 +143,8 @@ class S {
143
143
  for (let c = 0; c < t.length; c++) {
144
144
  const s = c === t.length - 1, l = n !== void 0 && s;
145
145
  l && (i = n);
146
- const f = !l || !!e.clearCanvas, u = {}, d = this.module.passes[c].uniforms;
147
- u[this.module.name] = { ...this.props, ...d }, t[c].render({ clearCanvas: f, inputBuffer: r, outputBuffer: i, moduleProps: u });
146
+ const f = !l || !!e.clearCanvas, u = {}, m = this.module.passes[c].uniforms;
147
+ u[this.module.name] = { ...this.props, ...m }, t[c].render({ clearCanvas: f, inputBuffer: r, outputBuffer: i, moduleProps: u });
148
148
  const v = i;
149
149
  i = r, r = v;
150
150
  }
@@ -158,13 +158,13 @@ class S {
158
158
  }
159
159
  }
160
160
  }
161
- function G(o, e, t) {
161
+ function q(o, e, t) {
162
162
  return e.passes.map((n, r) => {
163
- const i = J(e, n), c = `${t}-${r}`;
164
- return new U(o, { id: c, module: e, fs: i });
163
+ const i = H(e, n), c = `${t}-${r}`;
164
+ return new V(o, { id: c, module: e, fs: i });
165
165
  });
166
166
  }
167
- const y = `#version 300 es
167
+ const C = `#version 300 es
168
168
  uniform sampler2D texSrc;
169
169
 
170
170
  in vec2 position;
@@ -172,31 +172,31 @@ in vec2 coordinate;
172
172
  in vec2 uv;
173
173
 
174
174
  out vec4 fragColor;
175
- `, V = (o) => `${y}
175
+ `, J = (o) => `${C}
176
176
  void main() {
177
177
  fragColor = texture(texSrc, coordinate);
178
178
  fragColor = ${o}(fragColor, screen.texSize, coordinate);
179
179
  }
180
- `, q = (o) => `${y}
180
+ `, X = (o) => `${C}
181
181
  void main() {
182
182
  fragColor = ${o}(texSrc, screen.texSize, coordinate);
183
183
  }
184
184
  `;
185
- function J(o, e) {
185
+ function H(o, e) {
186
186
  if (e.filter) {
187
187
  const t = typeof e.filter == "string" ? e.filter : `${o.name}_filterColor_ext`;
188
- return V(t);
188
+ return J(t);
189
189
  }
190
190
  if (e.sampler) {
191
191
  const t = typeof e.sampler == "string" ? e.sampler : `${o.name}_sampleColor`;
192
- return q(t);
192
+ return X(t);
193
193
  }
194
194
  return "";
195
195
  }
196
- const X = `
196
+ const W = `
197
197
  float omfx_lum(vec3 c) { return dot(c, vec3(0.299, 0.587, 0.114)); }
198
198
  float omfx_hash(vec2 p) { return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453); }
199
- `, P = {
199
+ `, S = {
200
200
  tint: (o) => `
201
201
  {
202
202
  float L = omfx_lum(color.rgb);
@@ -300,10 +300,12 @@ float omfx_hash(vec2 p) { return fract(sin(dot(p, vec2(12.9898, 78.233))) * 4375
300
300
  }`
301
301
  };
302
302
  function x(o) {
303
- const e = F(o), t = Object.prototype.hasOwnProperty.call(P, o) ? P[o] : void 0;
303
+ const e = z(o), t = Object.prototype.hasOwnProperty.call(S, o) ? S[o] : void 0;
304
304
  return e && t ? { ...e, glsl: t } : void 0;
305
305
  }
306
- function H(o) {
306
+ const _ = ` float omfxAlpha = inColor.a;
307
+ vec4 color = vec4(omfxAlpha > 0.0 ? inColor.rgb / omfxAlpha : vec3(0.0), omfxAlpha);`, w = " return vec4(color.rgb * omfxAlpha, omfxAlpha);";
308
+ function Y(o) {
307
309
  const e = [];
308
310
  let t = [];
309
311
  const n = () => {
@@ -317,14 +319,14 @@ function H(o) {
317
319
  n(), e.push({ kind: "neighbourhood", op: i });
318
320
  }), n(), e;
319
321
  }
320
- function W(o, e) {
322
+ function K(o, e) {
321
323
  if (o.length === 0) return null;
322
324
  const t = [], n = [], r = /* @__PURE__ */ new Map();
323
325
  o.forEach((a, p) => {
324
326
  for (const g of a.def.params) {
325
327
  const h = a.values[g.name];
326
- let m;
327
- g.kind === "color" ? (m = `c${t.length}`, t.push({ key: m, value: Array.isArray(h) ? h : [0, 0, 0, 1] })) : (m = `f${n.length}`, n.push({ key: m, value: typeof h == "number" ? h : 0 })), r.set(`${p}:${g.name}`, `${e}.${m}`);
328
+ let d;
329
+ g.kind === "color" ? (d = `c${t.length}`, t.push({ key: d, value: Array.isArray(h) ? h : [0, 0, 0, 1] })) : (d = `f${n.length}`, n.push({ key: d, value: typeof h == "number" ? h : 0 })), r.set(`${p}:${g.name}`, `${e}.${d}`);
328
330
  }
329
331
  });
330
332
  const i = {}, c = {}, s = [];
@@ -332,35 +334,36 @@ function W(o, e) {
332
334
  i[a] = p, c[a] = "vec4<f32>", s.push(` vec4 ${a};`);
333
335
  for (const { key: a, value: p } of n)
334
336
  i[a] = p, c[a] = "f32", s.push(` float ${a};`);
335
- i.pxPerMm = w, c.pxPerMm = "f32", s.push(" float pxPerMm;");
336
- const l = `${e}.pxPerMm`, f = (a) => (p) => r.get(`${a}:${p}`) ?? "0.0", u = [], d = [];
337
- H(o).forEach((a, p) => {
337
+ i.pxPerMm = E, c.pxPerMm = "f32", s.push(" float pxPerMm;");
338
+ const l = `${e}.pxPerMm`, f = (a) => (p) => r.get(`${a}:${p}`) ?? "0.0", u = [], m = [];
339
+ Y(o).forEach((a, p) => {
338
340
  if (a.kind === "pointwise") {
339
- const m = `${e}_p${p}`, C = a.ops.map((b) => o[b].def.glsl(f(b), l)).join(`
341
+ const d = `${e}_p${p}`, T = a.ops.map((b) => o[b].def.glsl(f(b), l)).join(`
340
342
  `);
341
343
  u.push(
342
- `vec4 ${m}(vec4 inColor, vec2 texSize, vec2 coord) {
343
- vec4 color = inColor;
344
- ${C}
345
- return color;
344
+ `vec4 ${d}(vec4 inColor, vec2 texSize, vec2 coord) {
345
+ ${_}
346
+ ${T}
347
+ ${w}
346
348
  }`
347
- ), d.push({ filter: m });
349
+ ), m.push({ filter: d });
348
350
  return;
349
351
  }
350
352
  const g = `${e}_n${p}`, h = o[a.op].def.glsl(f(a.op), l);
351
353
  u.push(
352
354
  `vec4 ${g}(sampler2D src, vec2 texSize, vec2 coord) {
353
- vec4 color = texture(src, coord);
355
+ vec4 inColor = texture(src, coord);
356
+ ${_}
354
357
  ${h}
355
- return color;
358
+ ${w}
356
359
  }`
357
- ), d.push({ sampler: g });
360
+ ), m.push({ sampler: g });
358
361
  });
359
362
  const v = [
360
363
  `layout(std140) uniform ${e}Uniforms {`,
361
364
  ...s,
362
365
  `} ${e};`,
363
- X,
366
+ W,
364
367
  ...u
365
368
  ].join(`
366
369
  `);
@@ -369,21 +372,21 @@ ${h}
369
372
  // runtime reads (`typeof pass.filter === 'string' ? pass.filter : …`) but
370
373
  // its `ShaderSubPass` type declares as a boolean — a deck typing gap, not
371
374
  // a runtime one, the same shape as `maxZoom` on the standalone controller.
372
- module: { name: e, fs: v, uniformTypes: c, passes: d },
375
+ module: { name: e, fs: v, uniformTypes: c, passes: m },
373
376
  uniforms: i,
374
- passCount: d.length
377
+ passCount: m.length
375
378
  };
376
379
  }
377
- const K = /^\s*(-?[\d.]+)\s*(mm)?\s*$/i, Q = /^\s*(-?[\d.]+)\s*(deg)?\s*$/i;
378
- function E(o, e) {
380
+ const Q = /^\s*(-?[\d.]+)\s*(mm)?\s*$/i, Z = /^\s*(-?[\d.]+)\s*(deg)?\s*$/i;
381
+ function A(o, e) {
379
382
  if (o.kind === "color") {
380
- const n = L(e);
383
+ const n = I(e);
381
384
  if (!n) return;
382
385
  const [r, i, c, s] = n;
383
386
  return [r / 255, i / 255, c / 255, s === void 0 ? 1 : s > 1 ? s / 255 : s];
384
387
  }
385
388
  if (o.kind === "length" || o.kind === "angle") {
386
- const n = (o.kind === "length" ? K : Q).exec(e);
389
+ const n = (o.kind === "length" ? Q : Z).exec(e);
387
390
  if (!n) return;
388
391
  const r = Number(n[1]);
389
392
  return Number.isFinite(r) ? r : void 0;
@@ -391,36 +394,36 @@ function E(o, e) {
391
394
  const t = Number(e);
392
395
  return Number.isFinite(t) ? t : void 0;
393
396
  }
394
- function Y(o) {
395
- return E(o, String(o.default)) ?? 0;
397
+ function oo(o) {
398
+ return A(o, String(o.default)) ?? 0;
396
399
  }
397
- function _(o, e) {
400
+ function y(o, e) {
398
401
  const t = x(o);
399
402
  if (!t) return null;
400
403
  const n = {};
401
404
  for (const r of t.params) {
402
- const i = e(r.name), c = i === null ? void 0 : E(r, i);
403
- n[r.name] = c ?? Y(r);
405
+ const i = e(r.name), c = i === null ? void 0 : A(r, i);
406
+ n[r.name] = c ?? oo(r);
404
407
  }
405
408
  return { op: o, values: n };
406
409
  }
407
- function Z(o) {
410
+ function eo(o) {
408
411
  if (!o || typeof o != "object") return !1;
409
412
  const e = o;
410
413
  return typeof e.name == "string" && typeof e.fs == "string" && Array.isArray(e.passes) && e.passes.length > 0;
411
414
  }
412
- function ro(o) {
415
+ function no(o) {
413
416
  const e = [];
414
417
  for (const t of Array.from(o.querySelectorAll(":scope > om-effect"))) {
415
418
  const n = t.getAttribute("preset"), r = t.getAttribute("op"), i = t.querySelector(":scope > script[type='application/json']");
416
419
  if (n !== null && n !== "") {
417
- if (!z(n)) {
420
+ if (!O(n)) {
418
421
  console.warn(`[onlymapjs] <om-effect preset="${n}"> is not a known preset — skipped.`, t);
419
422
  continue;
420
423
  }
421
- const c = O[n].map(({ op: s, params: l }) => x(s) ? _(s, (u) => {
422
- const d = t.getAttribute(`${s}-${u}`);
423
- if (d !== null) return d;
424
+ const c = R[n].map(({ op: s, params: l }) => x(s) ? y(s, (u) => {
425
+ const m = t.getAttribute(`${s}-${u}`);
426
+ if (m !== null) return m;
424
427
  const v = l[u];
425
428
  return v === void 0 ? null : String(v);
426
429
  }) : null).filter((s) => s !== null);
@@ -428,7 +431,7 @@ function ro(o) {
428
431
  continue;
429
432
  }
430
433
  if (r !== null && r !== "") {
431
- const c = _(r, (s) => t.getAttribute(s));
434
+ const c = y(r, (s) => t.getAttribute(s));
432
435
  if (!c) {
433
436
  console.warn(`[onlymapjs] <om-effect op="${r}"> is not a known op — skipped.`, t);
434
437
  continue;
@@ -444,7 +447,7 @@ function ro(o) {
444
447
  console.warn(`[onlymapjs] <om-effect>'s inline module is not valid JSON — skipped. ${String(f)}`, t);
445
448
  continue;
446
449
  }
447
- if (!Z(c)) {
450
+ if (!eo(c)) {
448
451
  console.warn(
449
452
  "[onlymapjs] <om-effect>'s inline module needs `name`, `fs` and a non-empty `passes` — skipped.",
450
453
  t
@@ -466,16 +469,16 @@ function ro(o) {
466
469
  }
467
470
  return e;
468
471
  }
469
- let oo = 0;
470
- const eo = () => oo++;
471
- function so(o, e = w) {
472
+ let to = 0;
473
+ const ro = () => to++;
474
+ function co(o, e = E) {
472
475
  const t = [], n = [];
473
476
  let r = [];
474
- const i = eo(), c = () => {
477
+ const i = ro(), c = () => {
475
478
  if (r.length === 0) return;
476
- const s = W(r, `omfx${i}_${t.length}`);
479
+ const s = K(r, `omfx${i}_${t.length}`);
477
480
  if (r = [], !s) return;
478
- const l = { ...s.uniforms, pxPerMm: e }, f = new S(s.module, l);
481
+ const l = { ...s.uniforms, pxPerMm: e }, f = new P(s.module, l);
479
482
  n.push({ effect: f, uniforms: s.uniforms }), t.push(f);
480
483
  };
481
484
  for (const s of o) {
@@ -486,7 +489,7 @@ function so(o, e = w) {
486
489
  }
487
490
  continue;
488
491
  }
489
- s.raw && (c(), t.push(new S(s.raw.module, s.raw.uniforms)));
492
+ s.raw && (c(), t.push(new P(s.raw.module, s.raw.uniforms)));
490
493
  }
491
494
  return c(), {
492
495
  effects: t,
@@ -496,16 +499,16 @@ function so(o, e = w) {
496
499
  };
497
500
  }
498
501
  export {
499
- w as CSS_PX_PER_MM,
500
- O as EFFECT_PRESETS,
501
- io as EFFECT_PRESET_NAMES,
502
- lo as OP_META,
503
- ao as OP_NAMES,
504
- so as buildPostProcessEffects,
505
- E as coerceParam,
506
- fo as expandPreset,
507
- z as isEffectPreset,
502
+ E as CSS_PX_PER_MM,
503
+ R as EFFECT_PRESETS,
504
+ ao as EFFECT_PRESET_NAMES,
505
+ fo as OP_META,
506
+ uo as OP_NAMES,
507
+ co as buildPostProcessEffects,
508
+ A as coerceParam,
509
+ po as expandPreset,
510
+ O as isEffectPreset,
508
511
  x as opDef,
509
- F as opMeta,
510
- ro as parseEffectEls
512
+ z as opMeta,
513
+ no as parseEffectEls
511
514
  };