deckgl-expansion 1.0.3 → 1.0.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.
@@ -1,17 +1,17 @@
1
1
  var W = Object.defineProperty;
2
2
  var E = (n, t, e) => t in n ? W(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var b = (n, t, e) => E(n, typeof t != "symbol" ? t + "" : t, e);
3
+ var j = (n, t, e) => E(n, typeof t != "symbol" ? t + "" : t, e);
4
4
  import { Layer as $ } from "@deck.gl/core";
5
5
  function G() {
6
6
  }
7
- function N(n) {
7
+ function D(n) {
8
8
  return Object.getOwnPropertySymbols(n).filter((t) => Object.prototype.propertyIsEnumerable.call(n, t));
9
9
  }
10
- function P(n) {
10
+ function V(n) {
11
11
  return n == null ? n === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(n);
12
12
  }
13
- const K = "[object RegExp]", k = "[object String]", q = "[object Number]", Z = "[object Boolean]", z = "[object Arguments]", _ = "[object Symbol]", H = "[object Date]", J = "[object Map]", Q = "[object Set]", tt = "[object Array]", et = "[object Function]", it = "[object ArrayBuffer]", j = "[object Object]", nt = "[object Error]", st = "[object DataView]", ot = "[object Uint8Array]", rt = "[object Uint8ClampedArray]", ct = "[object Uint16Array]", at = "[object Uint32Array]", lt = "[object BigUint64Array]", ht = "[object Int8Array]", ut = "[object Int16Array]", ft = "[object Int32Array]", dt = "[object BigInt64Array]", gt = "[object Float32Array]", xt = "[object Float64Array]";
14
- function V(n) {
13
+ const q = "[object RegExp]", K = "[object String]", k = "[object Number]", Z = "[object Boolean]", N = "[object Arguments]", _ = "[object Symbol]", H = "[object Date]", J = "[object Map]", Q = "[object Set]", tt = "[object Array]", et = "[object Function]", it = "[object ArrayBuffer]", v = "[object Object]", nt = "[object Error]", st = "[object DataView]", ot = "[object Uint8Array]", rt = "[object Uint8ClampedArray]", at = "[object Uint16Array]", ct = "[object Uint32Array]", lt = "[object BigUint64Array]", ht = "[object Int8Array]", ut = "[object Int16Array]", dt = "[object Int32Array]", ft = "[object BigInt64Array]", gt = "[object Float32Array]", pt = "[object Float64Array]";
14
+ function Y(n) {
15
15
  if (!n || typeof n != "object")
16
16
  return !1;
17
17
  const t = Object.getPrototypeOf(n);
@@ -20,13 +20,13 @@ function V(n) {
20
20
  function yt(n, t) {
21
21
  return n === t || Number.isNaN(n) && Number.isNaN(t);
22
22
  }
23
- function pt(n, t, e) {
23
+ function xt(n, t, e) {
24
24
  return m(n, t, void 0, void 0, void 0, void 0, e);
25
25
  }
26
- function m(n, t, e, i, s, o, c) {
27
- const a = c(n, t, e, i, s, o);
28
- if (a !== void 0)
29
- return a;
26
+ function m(n, t, e, i, s, o, a) {
27
+ const c = a(n, t, e, i, s, o);
28
+ if (c !== void 0)
29
+ return c;
30
30
  if (typeof n == typeof t)
31
31
  switch (typeof n) {
32
32
  case "bigint":
@@ -40,20 +40,20 @@ function m(n, t, e, i, s, o, c) {
40
40
  case "function":
41
41
  return n === t;
42
42
  case "object":
43
- return w(n, t, o, c);
43
+ return w(n, t, o, a);
44
44
  }
45
- return w(n, t, o, c);
45
+ return w(n, t, o, a);
46
46
  }
47
47
  function w(n, t, e, i) {
48
48
  if (Object.is(n, t))
49
49
  return !0;
50
- let s = P(n), o = P(t);
51
- if (s === z && (s = j), o === z && (o = j), s !== o)
50
+ let s = V(n), o = V(t);
51
+ if (s === N && (s = v), o === N && (o = v), s !== o)
52
52
  return !1;
53
53
  switch (s) {
54
- case k:
54
+ case K:
55
55
  return n.toString() === t.toString();
56
- case q: {
56
+ case k: {
57
57
  const r = n.valueOf(), l = t.valueOf();
58
58
  return yt(r, l);
59
59
  }
@@ -61,15 +61,15 @@ function w(n, t, e, i) {
61
61
  case H:
62
62
  case _:
63
63
  return Object.is(n.valueOf(), t.valueOf());
64
- case K:
64
+ case q:
65
65
  return n.source === t.source && n.flags === t.flags;
66
66
  case et:
67
67
  return n === t;
68
68
  }
69
69
  e = e ?? /* @__PURE__ */ new Map();
70
- const c = e.get(n), a = e.get(t);
71
- if (c != null && a != null)
72
- return c === t;
70
+ const a = e.get(n), c = e.get(t);
71
+ if (a != null && c != null)
72
+ return a === t;
73
73
  e.set(n, t), e.set(t, n);
74
74
  try {
75
75
  switch (s) {
@@ -85,8 +85,8 @@ function w(n, t, e, i) {
85
85
  if (n.size !== t.size)
86
86
  return !1;
87
87
  const r = Array.from(n.values()), l = Array.from(t.values());
88
- for (let f = 0; f < r.length; f++) {
89
- const h = r[f], u = l.findIndex((d) => m(h, d, void 0, n, t, e, i));
88
+ for (let d = 0; d < r.length; d++) {
89
+ const h = r[d], u = l.findIndex((f) => m(h, f, void 0, n, t, e, i));
90
90
  if (u === -1)
91
91
  return !1;
92
92
  l.splice(u, 1);
@@ -96,15 +96,15 @@ function w(n, t, e, i) {
96
96
  case tt:
97
97
  case ot:
98
98
  case rt:
99
- case ct:
100
99
  case at:
100
+ case ct:
101
101
  case lt:
102
102
  case ht:
103
103
  case ut:
104
- case ft:
105
104
  case dt:
105
+ case ft:
106
106
  case gt:
107
- case xt: {
107
+ case pt: {
108
108
  if (typeof Buffer < "u" && Buffer.isBuffer(n) !== Buffer.isBuffer(t) || n.length !== t.length)
109
109
  return !1;
110
110
  for (let r = 0; r < n.length; r++)
@@ -118,18 +118,18 @@ function w(n, t, e, i) {
118
118
  return n.byteLength !== t.byteLength || n.byteOffset !== t.byteOffset ? !1 : w(new Uint8Array(n), new Uint8Array(t), e, i);
119
119
  case nt:
120
120
  return n.name === t.name && n.message === t.message;
121
- case j: {
122
- if (!(w(n.constructor, t.constructor, e, i) || V(n) && V(t)))
121
+ case v: {
122
+ if (!(w(n.constructor, t.constructor, e, i) || Y(n) && Y(t)))
123
123
  return !1;
124
- const l = [...Object.keys(n), ...N(n)], f = [...Object.keys(t), ...N(t)];
125
- if (l.length !== f.length)
124
+ const l = [...Object.keys(n), ...D(n)], d = [...Object.keys(t), ...D(t)];
125
+ if (l.length !== d.length)
126
126
  return !1;
127
127
  for (let h = 0; h < l.length; h++) {
128
- const u = l[h], d = n[u];
128
+ const u = l[h], f = n[u];
129
129
  if (!Object.hasOwn(t, u))
130
130
  return !1;
131
- const x = t[u];
132
- if (!m(d, x, u, n, t, e, i))
131
+ const p = t[u];
132
+ if (!m(f, p, u, n, t, e, i))
133
133
  return !1;
134
134
  }
135
135
  return !0;
@@ -142,7 +142,7 @@ function w(n, t, e, i) {
142
142
  }
143
143
  }
144
144
  function mt(n, t) {
145
- return pt(n, t, G);
145
+ return xt(n, t, G);
146
146
  }
147
147
  const wt = Object.prototype.hasOwnProperty, y = typeof Symbol < "u" ? Symbol.toStringTag : void 0;
148
148
  function bt(n) {
@@ -159,7 +159,7 @@ function bt(n) {
159
159
  const s = Object.prototype.toString.call(n);
160
160
  return i && (t ? n[y] = e : delete n[y]), s;
161
161
  }
162
- function p(n) {
162
+ function x(n) {
163
163
  if (!jt(n))
164
164
  return !1;
165
165
  const t = bt(n);
@@ -169,21 +169,21 @@ function jt(n) {
169
169
  const t = typeof n;
170
170
  return n !== null && (t === "object" || t === "function");
171
171
  }
172
- function At(n) {
172
+ function vt(n) {
173
173
  return n == null ? !1 : typeof n == "string" || n.constructor !== null && n.constructor === String;
174
174
  }
175
175
  function A(n) {
176
176
  return Object.prototype.toString.call(n) === "[object Number]" && !isNaN(n);
177
177
  }
178
- function vt(n) {
178
+ function At(n) {
179
179
  return Array.isArray(n);
180
180
  }
181
181
  function St(n, t) {
182
182
  console.warn(`${t}: ${n}`);
183
183
  }
184
- const Y = {};
184
+ const z = {};
185
185
  function Ot(n, t) {
186
- Y[t] || (St(t, n), Y[t] = !0);
186
+ z[t] || (St(t, n), z[t] = !0);
187
187
  }
188
188
  function It(n, t) {
189
189
  return n - t * Math.floor(n / t);
@@ -193,15 +193,15 @@ function g(n) {
193
193
  }
194
194
  function Tt(n, t = {}) {
195
195
  let e, i;
196
- if (n.forEach(function(c) {
197
- switch (c.header.parameterCategory + "," + c.header.parameterNumber) {
196
+ if (n.forEach(function(a) {
197
+ switch (a.header.parameterCategory + "," + a.header.parameterNumber) {
198
198
  case "1,2":
199
199
  case "2,2":
200
- e = c;
200
+ e = a;
201
201
  break;
202
202
  case "1,3":
203
203
  case "2,3":
204
- i = c;
204
+ i = a;
205
205
  break;
206
206
  }
207
207
  }), !i || !e)
@@ -235,9 +235,6 @@ function Ct(n, t, e, i) {
235
235
  } else
236
236
  return new i(n * e, t * e);
237
237
  }
238
- function Mt(n) {
239
- return n ? (n.parentNode && n.parentNode.removeChild(n), n) : null;
240
- }
241
238
  class L {
242
239
  constructor(t, e) {
243
240
  this.u = t, this.v = e, this.m = this.magnitude();
@@ -277,14 +274,14 @@ class B {
277
274
  buildGrid() {
278
275
  const t = [];
279
276
  let e = 0;
280
- const { rows: i, cols: s, us: o, vs: c } = this;
281
- for (let a = 0; a < i; a++) {
277
+ const { rows: i, cols: s, us: o, vs: a } = this;
278
+ for (let c = 0; c < i; c++) {
282
279
  const r = [];
283
280
  for (let l = 0; l < s; l++, e++) {
284
- const f = o[e], h = c[e], u = this.isValid(f) && this.isValid(h);
285
- r[l] = u ? new L(f, h) : null;
281
+ const d = o[e], h = a[e], u = this.isValid(d) && this.isValid(h);
282
+ r[l] = u ? new L(d, h) : null;
286
283
  }
287
- this.isContinuous && r.push(r[0]), t[a] = r;
284
+ this.isContinuous && r.push(r[0]), t[c] = r;
288
285
  }
289
286
  return t;
290
287
  }
@@ -313,9 +310,9 @@ class B {
313
310
  * @param {Number[]} g11
314
311
  * @returns {Vector}
315
312
  */
316
- bilinearInterpolateVector(t, e, i, s, o, c) {
317
- const a = 1 - t, r = 1 - e, l = a * r, f = t * r, h = a * e, u = t * e, d = i.u * l + s.u * f + o.u * h + c.u * u, x = i.v * l + s.v * f + o.v * h + c.v * u;
318
- return new L(d, x);
313
+ bilinearInterpolateVector(t, e, i, s, o, a) {
314
+ const c = 1 - t, r = 1 - e, l = c * r, d = t * r, h = c * e, u = t * e, f = i.u * l + s.u * d + o.u * h + a.u * u, p = i.v * l + s.v * d + o.v * h + a.v * u;
315
+ return new L(f, p);
319
316
  }
320
317
  /**
321
318
  * calculate vector value range
@@ -326,10 +323,10 @@ class B {
326
323
  const t = this.grid.length, e = this.grid[0].length;
327
324
  let i, s;
328
325
  for (let o = 0; o < t; o++)
329
- for (let c = 0; c < e; c++) {
330
- const a = this.grid[o][c];
331
- if (a !== null) {
332
- const r = a.m || a.magnitude();
326
+ for (let a = 0; a < e; a++) {
327
+ const c = this.grid[o][a];
328
+ if (c !== null) {
329
+ const r = c.m || c.magnitude();
333
330
  i === void 0 ? i = r : s === void 0 ? (s = r, i = Math.min(i, s), s = Math.max(i, s)) : (i = Math.min(r, i), s = Math.max(r, s));
334
331
  }
335
332
  }
@@ -351,8 +348,8 @@ class B {
351
348
  const [i, s] = this.getWrappedLongitudes();
352
349
  s > 180 && t >= -180 && t <= s - 360 ? t += 360 : i < -180 && t <= 180 && t >= i + 360 && (t -= 360);
353
350
  const o = t >= i && t <= s;
354
- let c;
355
- return this.deltaY >= 0 ? c = e >= this.ymin && e <= this.ymax : c = e >= this.ymax && e <= this.ymin, o && c;
351
+ let a;
352
+ return this.deltaY >= 0 ? a = e >= this.ymin && e <= this.ymax : a = e >= this.ymax && e <= this.ymin, o && a;
356
353
  }
357
354
  /**
358
355
  * 获取经纬度所在的位置索引
@@ -379,8 +376,8 @@ class B {
379
376
  let i = !1;
380
377
  if ((this.wrapX || this.contains(t, e)) && (i = !0), !i)
381
378
  return null;
382
- const s = this.getDecimalIndexes(t, e), o = Math.floor(s[0]), c = Math.floor(s[1]), a = this.clampColumnIndex(o), r = this.clampRowIndex(c);
383
- return this.valueAtIndexes(a, r);
379
+ const s = this.getDecimalIndexes(t, e), o = Math.floor(s[0]), a = Math.floor(s[1]), c = this.clampColumnIndex(o), r = this.clampRowIndex(a);
380
+ return this.valueAtIndexes(c, r);
384
381
  }
385
382
  /**
386
383
  * Get interpolated grid value lon-lat coordinates
@@ -404,10 +401,10 @@ class B {
404
401
  * @param j
405
402
  */
406
403
  interpolatePoint(t, e) {
407
- const i = this.getFourSurroundingIndexes(t, e), [s, o, c, a] = i, r = this.getFourSurroundingValues(s, o, c, a);
404
+ const i = this.getFourSurroundingIndexes(t, e), [s, o, a, c] = i, r = this.getFourSurroundingValues(s, o, a, c);
408
405
  if (r) {
409
- const [l, f, h, u] = r;
410
- return this.bilinearInterpolateVector(t - s, e - c, l, f, h, u);
406
+ const [l, d, h, u] = r;
407
+ return this.bilinearInterpolateVector(t - s, e - a, l, d, h, u);
411
408
  }
412
409
  return null;
413
410
  }
@@ -448,8 +445,8 @@ class B {
448
445
  const i = Math.floor(t);
449
446
  let s = i + 1;
450
447
  this.isContinuous && s >= this.cols && (s = 0), s = this.clampColumnIndex(s);
451
- const o = this.clampRowIndex(Math.floor(e)), c = this.clampRowIndex(o + 1);
452
- return [i, s, o, c];
448
+ const o = this.clampRowIndex(Math.floor(e)), a = this.clampRowIndex(o + 1);
449
+ return [i, s, o, a];
453
450
  }
454
451
  /**
455
452
  * Get four surrounding values or null if not available,
@@ -464,11 +461,11 @@ class B {
464
461
  getFourSurroundingValues(t, e, i, s) {
465
462
  let o;
466
463
  if (o = this.grid[i]) {
467
- const c = o[t], a = o[e];
468
- if (this.isValid(c) && this.isValid(a) && (o = this.grid[s])) {
464
+ const a = o[t], c = o[e];
465
+ if (this.isValid(a) && this.isValid(c) && (o = this.grid[s])) {
469
466
  const r = o[t], l = o[e];
470
467
  if (this.isValid(r) && this.isValid(l))
471
- return [c, a, r, l];
468
+ return [a, c, r, l];
472
469
  }
473
470
  }
474
471
  return null;
@@ -520,8 +517,8 @@ class B {
520
517
  * @return IPosition
521
518
  */
522
519
  randomize(t = {}, e, i, s) {
523
- const o = Math.random() * (e || this.cols) | 0, c = Math.random() * (i || this.rows) | 0, a = s([o, c]);
524
- return a !== null ? (t.x = a[0], t.y = a[1]) : (t.x = this.longitudeAtX(o), t.y = this.latitudeAtY(c)), t;
520
+ const o = Math.random() * (e || this.cols) | 0, a = Math.random() * (i || this.rows) | 0, c = s([o, a]);
521
+ return c !== null ? (t.x = c[0], t.y = c[1]) : (t.x = this.longitudeAtX(o), t.y = this.latitudeAtY(a)), t;
525
522
  }
526
523
  /**
527
524
  * 判断是否是 `Field` 的实例
@@ -549,7 +546,7 @@ const U = {
549
546
  function R(n, t, e, i) {
550
547
  return Math.max(0, Math.min(i.length - 1, Math.round((n - t) / (e - t) * (i.length - 1))));
551
548
  }
552
- const S = class S {
549
+ const O = class O {
553
550
  constructor(t, e, i) {
554
551
  if (this.particles = [], this.generated = !1, this.ctx = t, !this.ctx)
555
552
  throw new Error("ctx error");
@@ -636,18 +633,18 @@ const S = class S {
636
633
  postrender() {
637
634
  }
638
635
  moveParticles() {
639
- const { width: t, height: e } = this.ctx.canvas, i = this.particles, s = this.options.maxAge, o = p(this.options.velocityScale) ? this.options.velocityScale() : this.options.velocityScale;
640
- let c = 0;
641
- const a = i.length;
642
- for (; c < a; c++) {
643
- const r = i[c];
636
+ const { width: t, height: e } = this.ctx.canvas, i = this.particles, s = this.options.maxAge, o = x(this.options.velocityScale) ? this.options.velocityScale() : this.options.velocityScale;
637
+ let a = 0;
638
+ const c = i.length;
639
+ for (; a < c; a++) {
640
+ const r = i[a];
644
641
  r.age > s && (r.age = 0, this.field.randomize(r, t, e, this.unproject));
645
- const l = r.x, f = r.y, h = this.field.interpolatedValueAt(l, f);
642
+ const l = r.x, d = r.y, h = this.field.interpolatedValueAt(l, d);
646
643
  if (h === null)
647
644
  r.age = s;
648
645
  else {
649
- const u = l + h.u * o, d = f + h.v * o;
650
- this.field.hasValueAt(u, d) ? (r.xt = u, r.yt = d, r.m = h.m) : (r.x = u, r.y = d, r.age = s);
646
+ const u = l + h.u * o, f = d + h.v * o;
647
+ this.field.hasValueAt(u, f) ? (r.xt = u, r.yt = f, r.m = h.m) : (r.x = u, r.y = f, r.age = s);
651
648
  }
652
649
  r.age++;
653
650
  }
@@ -658,7 +655,7 @@ const S = class S {
658
655
  }
659
656
  drawParticles() {
660
657
  const t = this.particles;
661
- this.fadeIn(), this.ctx.globalAlpha = this.options.globalAlpha, this.ctx.fillStyle = `rgba(0, 0, 0, ${this.options.globalAlpha})`, this.ctx.lineWidth = A(this.options.lineWidth) ? this.options.lineWidth : 1, this.ctx.strokeStyle = At(this.options.colorScale) ? this.options.colorScale : "#fff";
658
+ this.fadeIn(), this.ctx.globalAlpha = this.options.globalAlpha, this.ctx.fillStyle = `rgba(0, 0, 0, ${this.options.globalAlpha})`, this.ctx.lineWidth = A(this.options.lineWidth) ? this.options.lineWidth : 1, this.ctx.strokeStyle = vt(this.options.colorScale) ? this.options.colorScale : "#fff";
662
659
  let e = 0;
663
660
  const i = t.length;
664
661
  if (this.field && i > 0) {
@@ -676,13 +673,13 @@ const S = class S {
676
673
  drawPixelParticle(t, e, i) {
677
674
  const s = [t.x, t.y], o = [t.xt, t.yt];
678
675
  if (o && s && g(o[0]) && g(o[1]) && g(s[0]) && g(s[1]) && t.age <= this.options.maxAge) {
679
- if (this.ctx.beginPath(), this.ctx.moveTo(s[0], s[1]), this.ctx.lineTo(o[0], o[1]), p(this.options.colorScale))
676
+ if (this.ctx.beginPath(), this.ctx.moveTo(s[0], s[1]), this.ctx.lineTo(o[0], o[1]), x(this.options.colorScale))
680
677
  this.ctx.strokeStyle = this.options.colorScale(t.m);
681
678
  else if (Array.isArray(this.options.colorScale)) {
682
- const c = R(t.m, e, i, this.options.colorScale);
683
- this.ctx.strokeStyle = this.options.colorScale[c];
679
+ const a = R(t.m, e, i, this.options.colorScale);
680
+ this.ctx.strokeStyle = this.options.colorScale[a];
684
681
  }
685
- p(this.options.lineWidth) && (this.ctx.lineWidth = this.options.lineWidth(t.m)), t.x = t.xt, t.y = t.yt, this.ctx.stroke();
682
+ x(this.options.lineWidth) && (this.ctx.lineWidth = this.options.lineWidth(t.m)), t.x = t.xt, t.y = t.yt, this.ctx.stroke();
686
683
  }
687
684
  }
688
685
  /**
@@ -694,15 +691,15 @@ const S = class S {
694
691
  drawCoordsParticle(t, e, i) {
695
692
  const s = [t.x, t.y], o = [t.xt, t.yt];
696
693
  if (o && s && g(o[0]) && g(o[1]) && g(s[0]) && g(s[1]) && this.intersectsCoordinate(o) && t.age <= this.options.maxAge) {
697
- const c = this.project(s), a = this.project(o);
698
- if (c && a) {
699
- if (this.ctx.beginPath(), this.ctx.moveTo(c[0], c[1]), this.ctx.lineTo(a[0], a[1]), t.x = t.xt, t.y = t.yt, p(this.options.colorScale))
694
+ const a = this.project(s), c = this.project(o);
695
+ if (a && c) {
696
+ if (this.ctx.beginPath(), this.ctx.moveTo(a[0], a[1]), this.ctx.lineTo(c[0], c[1]), t.x = t.xt, t.y = t.yt, x(this.options.colorScale))
700
697
  this.ctx.strokeStyle = this.options.colorScale(t.m);
701
698
  else if (Array.isArray(this.options.colorScale)) {
702
699
  const r = R(t.m, e, i, this.options.colorScale);
703
700
  this.ctx.strokeStyle = this.options.colorScale[r];
704
701
  }
705
- p(this.options.lineWidth) && (this.ctx.lineWidth = this.options.lineWidth(t.m)), this.ctx.stroke();
702
+ x(this.options.lineWidth) && (this.ctx.lineWidth = this.options.lineWidth(t.m)), this.ctx.stroke();
706
703
  }
707
704
  }
708
705
  }
@@ -728,15 +725,14 @@ const S = class S {
728
725
  return Math.floor(Math.random() * this.options.maxAge);
729
726
  }
730
727
  };
731
- S.Field = B;
732
- let v = S;
733
- class Ft extends $ {
734
- constructor(e) {
735
- super(e);
736
- b(this, "_defaultOptions", {
728
+ O.Field = B;
729
+ let S = O;
730
+ class Mt extends $ {
731
+ constructor() {
732
+ super(...arguments);
733
+ j(this, "_defaultOptions", {
737
734
  ...U
738
735
  });
739
- this.props.zIndex = this.props.zIndex || "unset";
740
736
  }
741
737
  initializeState() {
742
738
  this.init();
@@ -745,32 +741,33 @@ class Ft extends $ {
745
741
  return e.somethingChanged;
746
742
  }
747
743
  updateState({ props: e, oldProps: i, context: s }) {
748
- var f;
749
- const { bounds: o, wind: c, windOptions: a } = this.state, r = (o == null ? void 0 : o.reduce((h, u) => h + u, 0)) || 0, l = ((f = s.viewport.getBounds()) == null ? void 0 : f.reduce((h, u) => h + u, 0)) || 0;
744
+ var d;
745
+ const { bounds: o, wind: a, windOptions: c } = this.state, r = (o == null ? void 0 : o.reduce((h, u) => h + u, 0)) || 0, l = ((d = s.viewport.getBounds()) == null ? void 0 : d.reduce((h, u) => h + u, 0)) || 0;
750
746
  if (r !== l && this.setState({
751
747
  bounds: s.viewport.getBounds()
752
- }), (i == null ? void 0 : i.data) !== (e == null ? void 0 : e.data) && this.setData(e.data, (e == null ? void 0 : e.fieldOptions) || {}), (i == null ? void 0 : i.windOptions) !== (e == null ? void 0 : e.windOptions) && this.init(), (i == null ? void 0 : i.visible) !== e.visible && this.setVisible(e.visible), (i == null ? void 0 : i.zIndex) !== e.zIndex && this.setzIndex(String(e.zIndex) || "unset"), !mt(a, e == null ? void 0 : e.windOptions)) {
753
- const h = Object.assign({}, a, e.windOptions);
754
- c.setOptions(h), this.setState({
748
+ }), (i == null ? void 0 : i.data) !== (e == null ? void 0 : e.data) && this.setData(e.data, (e == null ? void 0 : e.fieldOptions) || {}), (i == null ? void 0 : i.visible) !== e.visible && this.setVisible(e.visible), (i == null ? void 0 : i.zIndex) !== e.zIndex && this.setzIndex(String(e.zIndex) || "unset"), !mt(c, e == null ? void 0 : e.windOptions)) {
749
+ const h = Object.assign({}, c, e.windOptions);
750
+ a.setOptions(h), this.setState({
755
751
  windOptions: h
756
752
  });
757
753
  }
758
754
  }
759
755
  intersectsCoordinate([e, i]) {
760
- const [s, o, c, a] = this.state.bounds;
761
- return e >= s && e <= c && i >= o && i <= a;
756
+ const [s, o, a, c] = this.state.bounds;
757
+ return e >= s && e <= a && i >= o && i <= c;
762
758
  }
763
759
  init() {
764
- var I, T, C, M, F, D, X;
765
- const { viewport: e, deck: i } = this.context, s = i == null ? void 0 : i.width, o = i == null ? void 0 : i.height, c = this.getDevicePixelRatio(), a = Ct(s, o, c);
766
- a.style.position = "absolute", a.style.top = "0px", a.style.left = "0px", a.style.right = "0px", a.style.bottom = "0px", a.style.width = `${s}px`, a.style.height = `${o}px`, a.style.display = (I = this.props) != null && I.visible ? "block" : "none", a.style.zIndex = ((C = (T = this.props) == null ? void 0 : T.zIndex) == null ? void 0 : C.toString()) || "unset";
767
- const r = a.getContext("2d"), l = e.getBounds(), f = (M = this.props) == null ? void 0 : M.data, h = Object.assign(this._defaultOptions, ((F = this.props) == null ? void 0 : F.windOptions) || {}), u = ((D = this.props) == null ? void 0 : D.fieldOptions) || null, d = this.checkData(f, u), x = new v(r, h, d);
768
- x.postrender = this.postrender.bind(this), x.project = this.cproject.bind(this), x.unproject = this.cunproject.bind(this), x.intersectsCoordinate = this.intersectsCoordinate.bind(this);
769
- const O = (X = i == null ? void 0 : i.getCanvas()) == null ? void 0 : X.parentNode;
770
- O && O.appendChild(a), this.setState({
760
+ var I, T, C, M, F, P, X;
761
+ const { viewport: e, deck: i } = this.context, s = i == null ? void 0 : i.width, o = i == null ? void 0 : i.height, a = this.getDevicePixelRatio(), c = this.state.canvas ?? Ct(s, o, a);
762
+ c.style.position = "absolute", c.style.top = "0px", c.style.left = "0px", c.style.right = "0px", c.style.bottom = "0px", c.style.width = `${s}px`, c.style.height = `${o}px`, c.style.display = (I = this.props) != null && I.visible ? "block" : "none", c.style.zIndex = ((C = (T = this.props) == null ? void 0 : T.zIndex) == null ? void 0 : C.toString()) || "unset", c.id = "windy-layer-canvas";
763
+ const r = c.getContext("2d"), l = e.getBounds(), d = (M = this.props) == null ? void 0 : M.data, h = Object.assign(this._defaultOptions, ((F = this.props) == null ? void 0 : F.windOptions) || {}), u = ((P = this.props) == null ? void 0 : P.fieldOptions) || null, f = this.checkData(d, u), p = new S(r, h, f);
764
+ p.postrender = this.postrender.bind(this), p.project = this.cproject.bind(this), p.unproject = this.cunproject.bind(this), p.intersectsCoordinate = this.intersectsCoordinate.bind(this);
765
+ const b = (X = i == null ? void 0 : i.getCanvas()) == null ? void 0 : X.parentNode;
766
+ b && !b.querySelector("#windy-layer-canvas") && b.appendChild(c), this.setState({
771
767
  bounds: l,
772
- canvas: a,
773
- wind: x,
768
+ canvas: c,
769
+ wind: p,
770
+ container: b,
774
771
  windOpitons: h
775
772
  });
776
773
  }
@@ -788,15 +785,15 @@ class Ft extends $ {
788
785
  (i = (e = this.props) == null ? void 0 : e.onPostRender) == null || i.call(e, this);
789
786
  }
790
787
  cproject([e, i]) {
791
- const s = this.getDevicePixelRatio(), [o, c] = this.context.viewport.project([e, i, 0]);
792
- return [o * s, c * s];
788
+ const s = this.getDevicePixelRatio(), [o, a] = this.context.viewport.project([e, i, 0]);
789
+ return [o * s, a * s];
793
790
  }
794
791
  cunproject([e, i]) {
795
792
  const s = this.context.viewport.unproject([e, i]);
796
793
  return s ? [s[0], s[1]] : null;
797
794
  }
798
795
  checkData(e, i) {
799
- return typeof e == "string" ? null : e && e.checkFields && e.checkFields() ? e : vt(e) ? Tt(e, i) : (console.error("Illegal data"), null);
796
+ return typeof e == "string" ? null : e && e.checkFields && e.checkFields() ? e : At(e) ? Tt(e, i) : (console.error("Illegal data"), null);
800
797
  }
801
798
  setData(e, i) {
802
799
  const s = this.checkData(e, i);
@@ -805,8 +802,8 @@ class Ft extends $ {
805
802
  }), this.state.wind.updateData(s), this.state.wind.prerender();
806
803
  }
807
804
  destory() {
808
- const { wind: e } = this.state;
809
- e == null || e.stop(), e == null || e.clearCanvas(), Mt(this.state.canvas), this.setState({
805
+ const { wind: e, container: i } = this.state;
806
+ e == null || e.stop(), e == null || e.clearCanvas(), i && i.removeChild(this.state.canvas), this.setState({
810
807
  canvas: null,
811
808
  wind: null,
812
809
  bounds: null,
@@ -818,7 +815,7 @@ class Ft extends $ {
818
815
  this.destory();
819
816
  }
820
817
  }
821
- b(Ft, "layerName", "WindLayer");
818
+ j(Mt, "layerName", "WindLayer");
822
819
  export {
823
- Ft as WindyLayer
820
+ Mt as WindyLayer
824
821
  };
@@ -1 +1 @@
1
- (function(d,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("@deck.gl/core")):typeof define=="function"&&define.amd?define(["exports","@deck.gl/core"],g):(d=typeof globalThis<"u"?globalThis:d||self,g(d["deckgl-expansion"]={},d.Deck["gl/core"]))})(this,function(d,g){"use strict";var Ft=Object.defineProperty;var Dt=(d,g,w)=>g in d?Ft(d,g,{enumerable:!0,configurable:!0,writable:!0,value:w}):d[g]=w;var T=(d,g,w)=>Dt(d,typeof g!="symbol"?g+"":g,w);function w(){}function C(n){return Object.getOwnPropertySymbols(n).filter(t=>Object.prototype.propertyIsEnumerable.call(n,t))}function M(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}const G="[object RegExp]",q="[object String]",K="[object Number]",Z="[object Boolean]",F="[object Arguments]",_="[object Symbol]",H="[object Date]",J="[object Map]",Q="[object Set]",tt="[object Array]",et="[object Function]",it="[object ArrayBuffer]",A="[object Object]",nt="[object Error]",st="[object DataView]",ot="[object Uint8Array]",rt="[object Uint8ClampedArray]",ct="[object Uint16Array]",at="[object Uint32Array]",lt="[object BigUint64Array]",ht="[object Int8Array]",ut="[object Int16Array]",ft="[object Int32Array]",dt="[object BigInt64Array]",gt="[object Float32Array]",xt="[object Float64Array]";function D(n){if(!n||typeof n!="object")return!1;const t=Object.getPrototypeOf(n);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null?Object.prototype.toString.call(n)==="[object Object]":!1}function yt(n,t){return n===t||Number.isNaN(n)&&Number.isNaN(t)}function pt(n,t,e){return b(n,t,void 0,void 0,void 0,void 0,e)}function b(n,t,e,i,s,o,c){const a=c(n,t,e,i,s,o);if(a!==void 0)return a;if(typeof n==typeof t)switch(typeof n){case"bigint":case"string":case"boolean":case"symbol":case"undefined":return n===t;case"number":return n===t||Object.is(n,t);case"function":return n===t;case"object":return j(n,t,o,c)}return j(n,t,o,c)}function j(n,t,e,i){if(Object.is(n,t))return!0;let s=M(n),o=M(t);if(s===F&&(s=A),o===F&&(o=A),s!==o)return!1;switch(s){case q:return n.toString()===t.toString();case K:{const r=n.valueOf(),l=t.valueOf();return yt(r,l)}case Z:case H:case _:return Object.is(n.valueOf(),t.valueOf());case G:return n.source===t.source&&n.flags===t.flags;case et:return n===t}e=e??new Map;const c=e.get(n),a=e.get(t);if(c!=null&&a!=null)return c===t;e.set(n,t),e.set(t,n);try{switch(s){case J:{if(n.size!==t.size)return!1;for(const[r,l]of n.entries())if(!t.has(r)||!b(l,t.get(r),r,n,t,e,i))return!1;return!0}case Q:{if(n.size!==t.size)return!1;const r=Array.from(n.values()),l=Array.from(t.values());for(let f=0;f<r.length;f++){const h=r[f],u=l.findIndex(x=>b(h,x,void 0,n,t,e,i));if(u===-1)return!1;l.splice(u,1)}return!0}case tt:case ot:case rt:case ct:case at:case lt:case ht:case ut:case ft:case dt:case gt:case xt:{if(typeof Buffer<"u"&&Buffer.isBuffer(n)!==Buffer.isBuffer(t)||n.length!==t.length)return!1;for(let r=0;r<n.length;r++)if(!b(n[r],t[r],r,n,t,e,i))return!1;return!0}case it:return n.byteLength!==t.byteLength?!1:j(new Uint8Array(n),new Uint8Array(t),e,i);case st:return n.byteLength!==t.byteLength||n.byteOffset!==t.byteOffset?!1:j(new Uint8Array(n),new Uint8Array(t),e,i);case nt:return n.name===t.name&&n.message===t.message;case A:{if(!(j(n.constructor,t.constructor,e,i)||D(n)&&D(t)))return!1;const l=[...Object.keys(n),...C(n)],f=[...Object.keys(t),...C(t)];if(l.length!==f.length)return!1;for(let h=0;h<l.length;h++){const u=l[h],x=n[u];if(!Object.hasOwn(t,u))return!1;const p=t[u];if(!b(x,p,u,n,t,e,i))return!1}return!0}default:return!1}}finally{e.delete(n),e.delete(t)}}function mt(n,t){return pt(n,t,w)}const wt=Object.prototype.hasOwnProperty,m=typeof Symbol<"u"?Symbol.toStringTag:void 0;function bt(n){if(n===null)return n===void 0?"[object Undefined]":"[object Null]";if(!(m&&m in Object(n)))return toString.call(n);const t=wt.call(n,m),e=n[m];let i=!1;try{n[m]=void 0,i=!0}catch{}const s=Object.prototype.toString.call(n);return i&&(t?n[m]=e:delete n[m]),s}function v(n){if(!jt(n))return!1;const t=bt(n);return t==="[object Function]"||t==="[object AsyncFunction]"||t==="[object GeneratorFunction]"||t==="[object Proxy]"}function jt(n){const t=typeof n;return n!==null&&(t==="object"||t==="function")}function vt(n){return n==null?!1:typeof n=="string"||n.constructor!==null&&n.constructor===String}function S(n){return Object.prototype.toString.call(n)==="[object Number]"&&!isNaN(n)}function At(n){return Array.isArray(n)}function St(n,t){console.warn(`${t}: ${n}`)}const X={};function Ot(n,t){X[t]||(St(t,n),X[t]=!0)}function It(n,t){return n-t*Math.floor(n/t)}function y(n){return n!=null&&!isNaN(n)}function Tt(n,t={}){let e,i;if(n.forEach(function(c){switch(c.header.parameterCategory+","+c.header.parameterNumber){case"1,2":case"2,2":e=c;break;case"1,3":case"2,3":i=c;break}}),!i||!e)return;const s=e.header;return new P({xmin:s.lo1,ymin:s.la1,xmax:s.lo2,ymax:s.la2,deltaX:s.dx,deltaY:s.dy,cols:s.nx,rows:s.ny,us:e.data,vs:i.data,...t})}function Ct(n,t,e,i){if(typeof document<"u"){const s=document.createElement("canvas");return s.width=n*e,s.height=t*e,s}else return new i(n*e,t*e)}function Mt(n){return n?(n.parentNode&&n.parentNode.removeChild(n),n):null}class N{constructor(t,e){this.u=t,this.v=e,this.m=this.magnitude()}magnitude(){return Math.sqrt(this.u**2+this.v**2)}directionTo(){let e=Math.atan2(this.u,this.v)*(180/Math.PI);return e<0&&(e+=360),e}directionFrom(){return(this.directionTo()+180)%360}}class P{constructor(t){this.grid=[],this.xmin=t.xmin,this.xmax=t.xmax,this.ymin=t.ymin,this.ymax=t.ymax,this.cols=t.cols,this.rows=t.rows,this.us=t.us,this.vs=t.vs,this.deltaX=t.deltaX,this.deltaY=t.deltaY,this.flipY=!!t.flipY,this.ymin=Math.min(t.ymax,t.ymin),this.ymax=Math.max(t.ymax,t.ymin),this.deltaY<0&&this.ymin<this.ymax||(t.flipY===void 0&&(this.flipY=!0),console.warn("[wind-core]: The data is flipY")),this.isFields=!0;const e=Math.ceil((this.xmax-this.xmin)/t.deltaX),i=Math.ceil((this.ymax-this.ymin)/t.deltaY);(e!==this.cols||i!==this.rows)&&console.warn("[wind-core]: The data grid not equal"),this.isContinuous=Math.floor(this.cols*t.deltaX)>=360,this.translateX="translateX"in t?t.translateX:this.xmax>180,"wrappedX"in t&&Ot("[wind-core]: ","`wrappedX` namespace will deprecated please use `translateX` instead!"),this.wrapX=!!t.wrapX,this.grid=this.buildGrid(),this.range=this.calculateRange()}buildGrid(){const t=[];let e=0;const{rows:i,cols:s,us:o,vs:c}=this;for(let a=0;a<i;a++){const r=[];for(let l=0;l<s;l++,e++){const f=o[e],h=c[e],u=this.isValid(f)&&this.isValid(h);r[l]=u?new N(f,h):null}this.isContinuous&&r.push(r[0]),t[a]=r}return t}release(){this.grid=[]}extent(){return[this.xmin,this.ymin,this.xmax,this.ymax]}bilinearInterpolateVector(t,e,i,s,o,c){const a=1-t,r=1-e,l=a*r,f=t*r,h=a*e,u=t*e,x=i.u*l+s.u*f+o.u*h+c.u*u,p=i.v*l+s.v*f+o.v*h+c.v*u;return new N(x,p)}calculateRange(){if(!this.grid||!this.grid[0])return;const t=this.grid.length,e=this.grid[0].length;let i,s;for(let o=0;o<t;o++)for(let c=0;c<e;c++){const a=this.grid[o][c];if(a!==null){const r=a.m||a.magnitude();i===void 0?i=r:s===void 0?(s=r,i=Math.min(i,s),s=Math.max(i,s)):(i=Math.min(r,i),s=Math.max(r,s))}}return[i,s]}isValid(t){return t!=null}getWrappedLongitudes(){let t=this.xmin,e=this.xmax;return this.translateX&&(this.isContinuous?(t=-180,e=180):(e=this.xmax-360,t=this.xmin-360)),[t,e]}contains(t,e){const[i,s]=this.getWrappedLongitudes();s>180&&t>=-180&&t<=s-360?t+=360:i<-180&&t<=180&&t>=i+360&&(t-=360);const o=t>=i&&t<=s;let c;return this.deltaY>=0?c=e>=this.ymin&&e<=this.ymax:c=e>=this.ymax&&e<=this.ymin,o&&c}getDecimalIndexes(t,e){const i=It(t-this.xmin,360)/this.deltaX;if(this.flipY){const s=(this.ymax-e)/this.deltaY;return[i,s]}else{const s=(this.ymin+e)/this.deltaY;return[i,s]}}valueAt(t,e){let i=!1;if((this.wrapX||this.contains(t,e))&&(i=!0),!i)return null;const s=this.getDecimalIndexes(t,e),o=Math.floor(s[0]),c=Math.floor(s[1]),a=this.clampColumnIndex(o),r=this.clampRowIndex(c);return this.valueAtIndexes(a,r)}interpolatedValueAt(t,e){let i=!1;if((this.wrapX||this.contains(t,e))&&(i=!0),!i)return null;const[s,o]=this.getDecimalIndexes(t,e);return this.interpolatePoint(s,o)}hasValueAt(t,e){return this.valueAt(t,e)!==null}interpolatePoint(t,e){const i=this.getFourSurroundingIndexes(t,e),[s,o,c,a]=i,r=this.getFourSurroundingValues(s,o,c,a);if(r){const[l,f,h,u]=r;return this.bilinearInterpolateVector(t-s,e-c,l,f,h,u)}return null}clampColumnIndex(t){let e=t;t<0&&(e=0);const i=this.cols-1;return t>i&&(e=i),e}clampRowIndex(t){let e=t;t<0&&(e=0);const i=this.rows-1;return t>i&&(e=i),e}getFourSurroundingIndexes(t,e){const i=Math.floor(t);let s=i+1;this.isContinuous&&s>=this.cols&&(s=0),s=this.clampColumnIndex(s);const o=this.clampRowIndex(Math.floor(e)),c=this.clampRowIndex(o+1);return[i,s,o,c]}getFourSurroundingValues(t,e,i,s){let o;if(o=this.grid[i]){const c=o[t],a=o[e];if(this.isValid(c)&&this.isValid(a)&&(o=this.grid[s])){const r=o[t],l=o[e];if(this.isValid(r)&&this.isValid(l))return[c,a,r,l]}}return null}valueAtIndexes(t,e){return this.grid[e][t]}lonLatAtIndexes(t,e){const i=this.longitudeAtX(t),s=this.latitudeAtY(e);return[i,s]}longitudeAtX(t){const e=this.deltaX/2;let i=this.xmin+e+t*this.deltaX;return this.translateX&&(i=i>180?i-360:i),i}latitudeAtY(t){const e=this.deltaY/2;return this.ymax-e-t*this.deltaY}randomize(t={},e,i,s){const o=Math.random()*(e||this.cols)|0,c=Math.random()*(i||this.rows)|0,a=s([o,c]);return a!==null?(t.x=a[0],t.y=a[1]):(t.x=this.longitudeAtX(o),t.y=this.latitudeAtY(c)),t}checkFields(){return this.isFields}}const z={globalAlpha:.9,lineWidth:1,colorScale:"#fff",velocityScale:1/25,maxAge:90,paths:800,frameRate:20,useCoordsDraw:!0};function V(n,t,e,i){return Math.max(0,Math.min(i.length-1,Math.round((n-t)/(e-t)*(i.length-1))))}const I=class I{constructor(t,e,i){if(this.particles=[],this.generated=!1,this.ctx=t,!this.ctx)throw new Error("ctx error");this.animate=this.animate.bind(this),this.setOptions(e),i&&this.updateData(i)}setOptions(t){this.options={...z,...t};const{width:e,height:i}=this.ctx.canvas;"particleAge"in t&&!("maxAge"in t)&&S(this.options.particleAge)&&(this.options.maxAge=this.options.particleAge),"particleMultiplier"in t&&!("paths"in t)&&S(this.options.particleMultiplier)&&(this.options.paths=Math.round(e*i*this.options.particleMultiplier)),this.prerender()}getOptions(){return this.options}updateData(t){this.field=t,this.generated&&(this.particles=this.prepareParticlePaths())}project(...t){throw new Error("project must be overriden")}unproject(...t){throw new Error("unproject must be overriden")}intersectsCoordinate(t){throw new Error("must be overriden")}clearCanvas(){this.stop(),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.forceStop=!1}isStop(){return!this.starting}start(){this.starting=!0,this.forceStop=!1,this.then=Date.now(),this.animate()}stop(){cancelAnimationFrame(this.animationLoop),this.starting=!1,this.forceStop=!0}animate(){this.animationLoop&&cancelAnimationFrame(this.animationLoop),this.animationLoop=requestAnimationFrame(this.animate);const t=Date.now(),e=t-this.then;e>this.options.frameRate&&(this.then=t-e%this.options.frameRate,this.render())}prerender(){this.generated=!1,this.field&&(this.particles=this.prepareParticlePaths(),this.generated=!0,!this.starting&&!this.forceStop&&(this.starting=!0,this.then=Date.now(),this.animate()))}render(){this.moveParticles(),this.drawParticles(),this.postrender()}postrender(){}moveParticles(){const{width:t,height:e}=this.ctx.canvas,i=this.particles,s=this.options.maxAge,o=v(this.options.velocityScale)?this.options.velocityScale():this.options.velocityScale;let c=0;const a=i.length;for(;c<a;c++){const r=i[c];r.age>s&&(r.age=0,this.field.randomize(r,t,e,this.unproject));const l=r.x,f=r.y,h=this.field.interpolatedValueAt(l,f);if(h===null)r.age=s;else{const u=l+h.u*o,x=f+h.v*o;this.field.hasValueAt(u,x)?(r.xt=u,r.yt=x,r.m=h.m):(r.x=u,r.y=x,r.age=s)}r.age++}}fadeIn(){const t=this.ctx.globalCompositeOperation;this.ctx.globalCompositeOperation="destination-in",this.ctx.fillRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.globalCompositeOperation=t}drawParticles(){const t=this.particles;this.fadeIn(),this.ctx.globalAlpha=this.options.globalAlpha,this.ctx.fillStyle=`rgba(0, 0, 0, ${this.options.globalAlpha})`,this.ctx.lineWidth=S(this.options.lineWidth)?this.options.lineWidth:1,this.ctx.strokeStyle=vt(this.options.colorScale)?this.options.colorScale:"#fff";let e=0;const i=t.length;if(this.field&&i>0){let s,o;for(y(this.options.minVelocity)&&y(this.options.maxVelocity)?(s=this.options.minVelocity,o=this.options.maxVelocity):[s,o]=this.field.range;e<i;e++)this[this.options.useCoordsDraw?"drawCoordsParticle":"drawPixelParticle"](t[e],s,o)}}drawPixelParticle(t,e,i){const s=[t.x,t.y],o=[t.xt,t.yt];if(o&&s&&y(o[0])&&y(o[1])&&y(s[0])&&y(s[1])&&t.age<=this.options.maxAge){if(this.ctx.beginPath(),this.ctx.moveTo(s[0],s[1]),this.ctx.lineTo(o[0],o[1]),v(this.options.colorScale))this.ctx.strokeStyle=this.options.colorScale(t.m);else if(Array.isArray(this.options.colorScale)){const c=V(t.m,e,i,this.options.colorScale);this.ctx.strokeStyle=this.options.colorScale[c]}v(this.options.lineWidth)&&(this.ctx.lineWidth=this.options.lineWidth(t.m)),t.x=t.xt,t.y=t.yt,this.ctx.stroke()}}drawCoordsParticle(t,e,i){const s=[t.x,t.y],o=[t.xt,t.yt];if(o&&s&&y(o[0])&&y(o[1])&&y(s[0])&&y(s[1])&&this.intersectsCoordinate(o)&&t.age<=this.options.maxAge){const c=this.project(s),a=this.project(o);if(c&&a){if(this.ctx.beginPath(),this.ctx.moveTo(c[0],c[1]),this.ctx.lineTo(a[0],a[1]),t.x=t.xt,t.y=t.yt,v(this.options.colorScale))this.ctx.strokeStyle=this.options.colorScale(t.m);else if(Array.isArray(this.options.colorScale)){const r=V(t.m,e,i,this.options.colorScale);this.ctx.strokeStyle=this.options.colorScale[r]}v(this.options.lineWidth)&&(this.ctx.lineWidth=this.options.lineWidth(t.m)),this.ctx.stroke()}}}prepareParticlePaths(){const{width:t,height:e}=this.ctx.canvas,i=typeof this.options.paths=="function"?this.options.paths(this):this.options.paths,s=[];if(!this.field)return[];let o=0;for(;o<i;o++)s.push(this.field.randomize({age:this.randomize()},t,e,this.unproject));return s}randomize(){return Math.floor(Math.random()*this.options.maxAge)}};I.Field=P;let O=I;class Y extends g.Layer{constructor(e){super(e);T(this,"_defaultOptions",{...z});this.props.zIndex=this.props.zIndex||"unset"}initializeState(){this.init()}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({props:e,oldProps:i,context:s}){var f;const{bounds:o,wind:c,windOptions:a}=this.state,r=(o==null?void 0:o.reduce((h,u)=>h+u,0))||0,l=((f=s.viewport.getBounds())==null?void 0:f.reduce((h,u)=>h+u,0))||0;if(r!==l&&this.setState({bounds:s.viewport.getBounds()}),(i==null?void 0:i.data)!==(e==null?void 0:e.data)&&this.setData(e.data,(e==null?void 0:e.fieldOptions)||{}),(i==null?void 0:i.windOptions)!==(e==null?void 0:e.windOptions)&&this.init(),(i==null?void 0:i.visible)!==e.visible&&this.setVisible(e.visible),(i==null?void 0:i.zIndex)!==e.zIndex&&this.setzIndex(String(e.zIndex)||"unset"),!mt(a,e==null?void 0:e.windOptions)){const h=Object.assign({},a,e.windOptions);c.setOptions(h),this.setState({windOptions:h})}}intersectsCoordinate([e,i]){const[s,o,c,a]=this.state.bounds;return e>=s&&e<=c&&i>=o&&i<=a}init(){var R,B,W,U,E,k,$;const{viewport:e,deck:i}=this.context,s=i==null?void 0:i.width,o=i==null?void 0:i.height,c=this.getDevicePixelRatio(),a=Ct(s,o,c);a.style.position="absolute",a.style.top="0px",a.style.left="0px",a.style.right="0px",a.style.bottom="0px",a.style.width=`${s}px`,a.style.height=`${o}px`,a.style.display=(R=this.props)!=null&&R.visible?"block":"none",a.style.zIndex=((W=(B=this.props)==null?void 0:B.zIndex)==null?void 0:W.toString())||"unset";const r=a.getContext("2d"),l=e.getBounds(),f=(U=this.props)==null?void 0:U.data,h=Object.assign(this._defaultOptions,((E=this.props)==null?void 0:E.windOptions)||{}),u=((k=this.props)==null?void 0:k.fieldOptions)||null,x=this.checkData(f,u),p=new O(r,h,x);p.postrender=this.postrender.bind(this),p.project=this.cproject.bind(this),p.unproject=this.cunproject.bind(this),p.intersectsCoordinate=this.intersectsCoordinate.bind(this);const L=($=i==null?void 0:i.getCanvas())==null?void 0:$.parentNode;L&&L.appendChild(a),this.setState({bounds:l,canvas:a,wind:p,windOpitons:h})}setVisible(e){this.state.canvas.style.display=e?"block":"none"}setzIndex(e){this.state.canvas.style.zIndex=String(e)||"unset"}getDevicePixelRatio(){return(window==null?void 0:window.devicePixelRatio)||1}postrender(){var e,i;(i=(e=this.props)==null?void 0:e.onPostRender)==null||i.call(e,this)}cproject([e,i]){const s=this.getDevicePixelRatio(),[o,c]=this.context.viewport.project([e,i,0]);return[o*s,c*s]}cunproject([e,i]){const s=this.context.viewport.unproject([e,i]);return s?[s[0],s[1]]:null}checkData(e,i){return typeof e=="string"?null:e&&e.checkFields&&e.checkFields()?e:At(e)?Tt(e,i):(console.error("Illegal data"),null)}setData(e,i){const s=this.checkData(e,i);this.setState({data:s}),this.state.wind.updateData(s),this.state.wind.prerender()}destory(){const{wind:e}=this.state;e==null||e.stop(),e==null||e.clearCanvas(),Mt(this.state.canvas),this.setState({canvas:null,wind:null,bounds:null,windOptions:null,fieldOptions:null})}finalizeState(){this.destory()}}T(Y,"layerName","WindLayer"),d.WindyLayer=Y,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
1
+ (function(f,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("@deck.gl/core")):typeof define=="function"&&define.amd?define(["exports","@deck.gl/core"],g):(f=typeof globalThis<"u"?globalThis:f||self,g(f["deckgl-expansion"]={},f.Deck["gl/core"]))})(this,function(f,g){"use strict";var Mt=Object.defineProperty;var Pt=(f,g,w)=>g in f?Mt(f,g,{enumerable:!0,configurable:!0,writable:!0,value:w}):f[g]=w;var C=(f,g,w)=>Pt(f,typeof g!="symbol"?g+"":g,w);function w(){}function M(n){return Object.getOwnPropertySymbols(n).filter(t=>Object.prototype.propertyIsEnumerable.call(n,t))}function P(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}const q="[object RegExp]",G="[object String]",K="[object Number]",Z="[object Boolean]",F="[object Arguments]",_="[object Symbol]",H="[object Date]",J="[object Map]",Q="[object Set]",tt="[object Array]",et="[object Function]",it="[object ArrayBuffer]",S="[object Object]",nt="[object Error]",st="[object DataView]",ot="[object Uint8Array]",rt="[object Uint8ClampedArray]",ct="[object Uint16Array]",at="[object Uint32Array]",lt="[object BigUint64Array]",ht="[object Int8Array]",ut="[object Int16Array]",dt="[object Int32Array]",ft="[object BigInt64Array]",gt="[object Float32Array]",pt="[object Float64Array]";function D(n){if(!n||typeof n!="object")return!1;const t=Object.getPrototypeOf(n);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null?Object.prototype.toString.call(n)==="[object Object]":!1}function yt(n,t){return n===t||Number.isNaN(n)&&Number.isNaN(t)}function xt(n,t,e){return b(n,t,void 0,void 0,void 0,void 0,e)}function b(n,t,e,i,s,o,c){const a=c(n,t,e,i,s,o);if(a!==void 0)return a;if(typeof n==typeof t)switch(typeof n){case"bigint":case"string":case"boolean":case"symbol":case"undefined":return n===t;case"number":return n===t||Object.is(n,t);case"function":return n===t;case"object":return j(n,t,o,c)}return j(n,t,o,c)}function j(n,t,e,i){if(Object.is(n,t))return!0;let s=P(n),o=P(t);if(s===F&&(s=S),o===F&&(o=S),s!==o)return!1;switch(s){case G:return n.toString()===t.toString();case K:{const r=n.valueOf(),l=t.valueOf();return yt(r,l)}case Z:case H:case _:return Object.is(n.valueOf(),t.valueOf());case q:return n.source===t.source&&n.flags===t.flags;case et:return n===t}e=e??new Map;const c=e.get(n),a=e.get(t);if(c!=null&&a!=null)return c===t;e.set(n,t),e.set(t,n);try{switch(s){case J:{if(n.size!==t.size)return!1;for(const[r,l]of n.entries())if(!t.has(r)||!b(l,t.get(r),r,n,t,e,i))return!1;return!0}case Q:{if(n.size!==t.size)return!1;const r=Array.from(n.values()),l=Array.from(t.values());for(let d=0;d<r.length;d++){const h=r[d],u=l.findIndex(p=>b(h,p,void 0,n,t,e,i));if(u===-1)return!1;l.splice(u,1)}return!0}case tt:case ot:case rt:case ct:case at:case lt:case ht:case ut:case dt:case ft:case gt:case pt:{if(typeof Buffer<"u"&&Buffer.isBuffer(n)!==Buffer.isBuffer(t)||n.length!==t.length)return!1;for(let r=0;r<n.length;r++)if(!b(n[r],t[r],r,n,t,e,i))return!1;return!0}case it:return n.byteLength!==t.byteLength?!1:j(new Uint8Array(n),new Uint8Array(t),e,i);case st:return n.byteLength!==t.byteLength||n.byteOffset!==t.byteOffset?!1:j(new Uint8Array(n),new Uint8Array(t),e,i);case nt:return n.name===t.name&&n.message===t.message;case S:{if(!(j(n.constructor,t.constructor,e,i)||D(n)&&D(t)))return!1;const l=[...Object.keys(n),...M(n)],d=[...Object.keys(t),...M(t)];if(l.length!==d.length)return!1;for(let h=0;h<l.length;h++){const u=l[h],p=n[u];if(!Object.hasOwn(t,u))return!1;const x=t[u];if(!b(p,x,u,n,t,e,i))return!1}return!0}default:return!1}}finally{e.delete(n),e.delete(t)}}function mt(n,t){return xt(n,t,w)}const wt=Object.prototype.hasOwnProperty,m=typeof Symbol<"u"?Symbol.toStringTag:void 0;function bt(n){if(n===null)return n===void 0?"[object Undefined]":"[object Null]";if(!(m&&m in Object(n)))return toString.call(n);const t=wt.call(n,m),e=n[m];let i=!1;try{n[m]=void 0,i=!0}catch{}const s=Object.prototype.toString.call(n);return i&&(t?n[m]=e:delete n[m]),s}function v(n){if(!jt(n))return!1;const t=bt(n);return t==="[object Function]"||t==="[object AsyncFunction]"||t==="[object GeneratorFunction]"||t==="[object Proxy]"}function jt(n){const t=typeof n;return n!==null&&(t==="object"||t==="function")}function vt(n){return n==null?!1:typeof n=="string"||n.constructor!==null&&n.constructor===String}function O(n){return Object.prototype.toString.call(n)==="[object Number]"&&!isNaN(n)}function At(n){return Array.isArray(n)}function St(n,t){console.warn(`${t}: ${n}`)}const X={};function Ot(n,t){X[t]||(St(t,n),X[t]=!0)}function Tt(n,t){return n-t*Math.floor(n/t)}function y(n){return n!=null&&!isNaN(n)}function It(n,t={}){let e,i;if(n.forEach(function(c){switch(c.header.parameterCategory+","+c.header.parameterNumber){case"1,2":case"2,2":e=c;break;case"1,3":case"2,3":i=c;break}}),!i||!e)return;const s=e.header;return new N({xmin:s.lo1,ymin:s.la1,xmax:s.lo2,ymax:s.la2,deltaX:s.dx,deltaY:s.dy,cols:s.nx,rows:s.ny,us:e.data,vs:i.data,...t})}function Ct(n,t,e,i){if(typeof document<"u"){const s=document.createElement("canvas");return s.width=n*e,s.height=t*e,s}else return new i(n*e,t*e)}class V{constructor(t,e){this.u=t,this.v=e,this.m=this.magnitude()}magnitude(){return Math.sqrt(this.u**2+this.v**2)}directionTo(){let e=Math.atan2(this.u,this.v)*(180/Math.PI);return e<0&&(e+=360),e}directionFrom(){return(this.directionTo()+180)%360}}class N{constructor(t){this.grid=[],this.xmin=t.xmin,this.xmax=t.xmax,this.ymin=t.ymin,this.ymax=t.ymax,this.cols=t.cols,this.rows=t.rows,this.us=t.us,this.vs=t.vs,this.deltaX=t.deltaX,this.deltaY=t.deltaY,this.flipY=!!t.flipY,this.ymin=Math.min(t.ymax,t.ymin),this.ymax=Math.max(t.ymax,t.ymin),this.deltaY<0&&this.ymin<this.ymax||(t.flipY===void 0&&(this.flipY=!0),console.warn("[wind-core]: The data is flipY")),this.isFields=!0;const e=Math.ceil((this.xmax-this.xmin)/t.deltaX),i=Math.ceil((this.ymax-this.ymin)/t.deltaY);(e!==this.cols||i!==this.rows)&&console.warn("[wind-core]: The data grid not equal"),this.isContinuous=Math.floor(this.cols*t.deltaX)>=360,this.translateX="translateX"in t?t.translateX:this.xmax>180,"wrappedX"in t&&Ot("[wind-core]: ","`wrappedX` namespace will deprecated please use `translateX` instead!"),this.wrapX=!!t.wrapX,this.grid=this.buildGrid(),this.range=this.calculateRange()}buildGrid(){const t=[];let e=0;const{rows:i,cols:s,us:o,vs:c}=this;for(let a=0;a<i;a++){const r=[];for(let l=0;l<s;l++,e++){const d=o[e],h=c[e],u=this.isValid(d)&&this.isValid(h);r[l]=u?new V(d,h):null}this.isContinuous&&r.push(r[0]),t[a]=r}return t}release(){this.grid=[]}extent(){return[this.xmin,this.ymin,this.xmax,this.ymax]}bilinearInterpolateVector(t,e,i,s,o,c){const a=1-t,r=1-e,l=a*r,d=t*r,h=a*e,u=t*e,p=i.u*l+s.u*d+o.u*h+c.u*u,x=i.v*l+s.v*d+o.v*h+c.v*u;return new V(p,x)}calculateRange(){if(!this.grid||!this.grid[0])return;const t=this.grid.length,e=this.grid[0].length;let i,s;for(let o=0;o<t;o++)for(let c=0;c<e;c++){const a=this.grid[o][c];if(a!==null){const r=a.m||a.magnitude();i===void 0?i=r:s===void 0?(s=r,i=Math.min(i,s),s=Math.max(i,s)):(i=Math.min(r,i),s=Math.max(r,s))}}return[i,s]}isValid(t){return t!=null}getWrappedLongitudes(){let t=this.xmin,e=this.xmax;return this.translateX&&(this.isContinuous?(t=-180,e=180):(e=this.xmax-360,t=this.xmin-360)),[t,e]}contains(t,e){const[i,s]=this.getWrappedLongitudes();s>180&&t>=-180&&t<=s-360?t+=360:i<-180&&t<=180&&t>=i+360&&(t-=360);const o=t>=i&&t<=s;let c;return this.deltaY>=0?c=e>=this.ymin&&e<=this.ymax:c=e>=this.ymax&&e<=this.ymin,o&&c}getDecimalIndexes(t,e){const i=Tt(t-this.xmin,360)/this.deltaX;if(this.flipY){const s=(this.ymax-e)/this.deltaY;return[i,s]}else{const s=(this.ymin+e)/this.deltaY;return[i,s]}}valueAt(t,e){let i=!1;if((this.wrapX||this.contains(t,e))&&(i=!0),!i)return null;const s=this.getDecimalIndexes(t,e),o=Math.floor(s[0]),c=Math.floor(s[1]),a=this.clampColumnIndex(o),r=this.clampRowIndex(c);return this.valueAtIndexes(a,r)}interpolatedValueAt(t,e){let i=!1;if((this.wrapX||this.contains(t,e))&&(i=!0),!i)return null;const[s,o]=this.getDecimalIndexes(t,e);return this.interpolatePoint(s,o)}hasValueAt(t,e){return this.valueAt(t,e)!==null}interpolatePoint(t,e){const i=this.getFourSurroundingIndexes(t,e),[s,o,c,a]=i,r=this.getFourSurroundingValues(s,o,c,a);if(r){const[l,d,h,u]=r;return this.bilinearInterpolateVector(t-s,e-c,l,d,h,u)}return null}clampColumnIndex(t){let e=t;t<0&&(e=0);const i=this.cols-1;return t>i&&(e=i),e}clampRowIndex(t){let e=t;t<0&&(e=0);const i=this.rows-1;return t>i&&(e=i),e}getFourSurroundingIndexes(t,e){const i=Math.floor(t);let s=i+1;this.isContinuous&&s>=this.cols&&(s=0),s=this.clampColumnIndex(s);const o=this.clampRowIndex(Math.floor(e)),c=this.clampRowIndex(o+1);return[i,s,o,c]}getFourSurroundingValues(t,e,i,s){let o;if(o=this.grid[i]){const c=o[t],a=o[e];if(this.isValid(c)&&this.isValid(a)&&(o=this.grid[s])){const r=o[t],l=o[e];if(this.isValid(r)&&this.isValid(l))return[c,a,r,l]}}return null}valueAtIndexes(t,e){return this.grid[e][t]}lonLatAtIndexes(t,e){const i=this.longitudeAtX(t),s=this.latitudeAtY(e);return[i,s]}longitudeAtX(t){const e=this.deltaX/2;let i=this.xmin+e+t*this.deltaX;return this.translateX&&(i=i>180?i-360:i),i}latitudeAtY(t){const e=this.deltaY/2;return this.ymax-e-t*this.deltaY}randomize(t={},e,i,s){const o=Math.random()*(e||this.cols)|0,c=Math.random()*(i||this.rows)|0,a=s([o,c]);return a!==null?(t.x=a[0],t.y=a[1]):(t.x=this.longitudeAtX(o),t.y=this.latitudeAtY(c)),t}checkFields(){return this.isFields}}const Y={globalAlpha:.9,lineWidth:1,colorScale:"#fff",velocityScale:1/25,maxAge:90,paths:800,frameRate:20,useCoordsDraw:!0};function z(n,t,e,i){return Math.max(0,Math.min(i.length-1,Math.round((n-t)/(e-t)*(i.length-1))))}const I=class I{constructor(t,e,i){if(this.particles=[],this.generated=!1,this.ctx=t,!this.ctx)throw new Error("ctx error");this.animate=this.animate.bind(this),this.setOptions(e),i&&this.updateData(i)}setOptions(t){this.options={...Y,...t};const{width:e,height:i}=this.ctx.canvas;"particleAge"in t&&!("maxAge"in t)&&O(this.options.particleAge)&&(this.options.maxAge=this.options.particleAge),"particleMultiplier"in t&&!("paths"in t)&&O(this.options.particleMultiplier)&&(this.options.paths=Math.round(e*i*this.options.particleMultiplier)),this.prerender()}getOptions(){return this.options}updateData(t){this.field=t,this.generated&&(this.particles=this.prepareParticlePaths())}project(...t){throw new Error("project must be overriden")}unproject(...t){throw new Error("unproject must be overriden")}intersectsCoordinate(t){throw new Error("must be overriden")}clearCanvas(){this.stop(),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.forceStop=!1}isStop(){return!this.starting}start(){this.starting=!0,this.forceStop=!1,this.then=Date.now(),this.animate()}stop(){cancelAnimationFrame(this.animationLoop),this.starting=!1,this.forceStop=!0}animate(){this.animationLoop&&cancelAnimationFrame(this.animationLoop),this.animationLoop=requestAnimationFrame(this.animate);const t=Date.now(),e=t-this.then;e>this.options.frameRate&&(this.then=t-e%this.options.frameRate,this.render())}prerender(){this.generated=!1,this.field&&(this.particles=this.prepareParticlePaths(),this.generated=!0,!this.starting&&!this.forceStop&&(this.starting=!0,this.then=Date.now(),this.animate()))}render(){this.moveParticles(),this.drawParticles(),this.postrender()}postrender(){}moveParticles(){const{width:t,height:e}=this.ctx.canvas,i=this.particles,s=this.options.maxAge,o=v(this.options.velocityScale)?this.options.velocityScale():this.options.velocityScale;let c=0;const a=i.length;for(;c<a;c++){const r=i[c];r.age>s&&(r.age=0,this.field.randomize(r,t,e,this.unproject));const l=r.x,d=r.y,h=this.field.interpolatedValueAt(l,d);if(h===null)r.age=s;else{const u=l+h.u*o,p=d+h.v*o;this.field.hasValueAt(u,p)?(r.xt=u,r.yt=p,r.m=h.m):(r.x=u,r.y=p,r.age=s)}r.age++}}fadeIn(){const t=this.ctx.globalCompositeOperation;this.ctx.globalCompositeOperation="destination-in",this.ctx.fillRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.globalCompositeOperation=t}drawParticles(){const t=this.particles;this.fadeIn(),this.ctx.globalAlpha=this.options.globalAlpha,this.ctx.fillStyle=`rgba(0, 0, 0, ${this.options.globalAlpha})`,this.ctx.lineWidth=O(this.options.lineWidth)?this.options.lineWidth:1,this.ctx.strokeStyle=vt(this.options.colorScale)?this.options.colorScale:"#fff";let e=0;const i=t.length;if(this.field&&i>0){let s,o;for(y(this.options.minVelocity)&&y(this.options.maxVelocity)?(s=this.options.minVelocity,o=this.options.maxVelocity):[s,o]=this.field.range;e<i;e++)this[this.options.useCoordsDraw?"drawCoordsParticle":"drawPixelParticle"](t[e],s,o)}}drawPixelParticle(t,e,i){const s=[t.x,t.y],o=[t.xt,t.yt];if(o&&s&&y(o[0])&&y(o[1])&&y(s[0])&&y(s[1])&&t.age<=this.options.maxAge){if(this.ctx.beginPath(),this.ctx.moveTo(s[0],s[1]),this.ctx.lineTo(o[0],o[1]),v(this.options.colorScale))this.ctx.strokeStyle=this.options.colorScale(t.m);else if(Array.isArray(this.options.colorScale)){const c=z(t.m,e,i,this.options.colorScale);this.ctx.strokeStyle=this.options.colorScale[c]}v(this.options.lineWidth)&&(this.ctx.lineWidth=this.options.lineWidth(t.m)),t.x=t.xt,t.y=t.yt,this.ctx.stroke()}}drawCoordsParticle(t,e,i){const s=[t.x,t.y],o=[t.xt,t.yt];if(o&&s&&y(o[0])&&y(o[1])&&y(s[0])&&y(s[1])&&this.intersectsCoordinate(o)&&t.age<=this.options.maxAge){const c=this.project(s),a=this.project(o);if(c&&a){if(this.ctx.beginPath(),this.ctx.moveTo(c[0],c[1]),this.ctx.lineTo(a[0],a[1]),t.x=t.xt,t.y=t.yt,v(this.options.colorScale))this.ctx.strokeStyle=this.options.colorScale(t.m);else if(Array.isArray(this.options.colorScale)){const r=z(t.m,e,i,this.options.colorScale);this.ctx.strokeStyle=this.options.colorScale[r]}v(this.options.lineWidth)&&(this.ctx.lineWidth=this.options.lineWidth(t.m)),this.ctx.stroke()}}}prepareParticlePaths(){const{width:t,height:e}=this.ctx.canvas,i=typeof this.options.paths=="function"?this.options.paths(this):this.options.paths,s=[];if(!this.field)return[];let o=0;for(;o<i;o++)s.push(this.field.randomize({age:this.randomize()},t,e,this.unproject));return s}randomize(){return Math.floor(Math.random()*this.options.maxAge)}};I.Field=N;let T=I;class L extends g.Layer{constructor(){super(...arguments);C(this,"_defaultOptions",{...Y})}initializeState(){this.init()}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({props:e,oldProps:i,context:s}){var d;const{bounds:o,wind:c,windOptions:a}=this.state,r=(o==null?void 0:o.reduce((h,u)=>h+u,0))||0,l=((d=s.viewport.getBounds())==null?void 0:d.reduce((h,u)=>h+u,0))||0;if(r!==l&&this.setState({bounds:s.viewport.getBounds()}),(i==null?void 0:i.data)!==(e==null?void 0:e.data)&&this.setData(e.data,(e==null?void 0:e.fieldOptions)||{}),(i==null?void 0:i.visible)!==e.visible&&this.setVisible(e.visible),(i==null?void 0:i.zIndex)!==e.zIndex&&this.setzIndex(String(e.zIndex)||"unset"),!mt(a,e==null?void 0:e.windOptions)){const h=Object.assign({},a,e.windOptions);c.setOptions(h),this.setState({windOptions:h})}}intersectsCoordinate([e,i]){const[s,o,c,a]=this.state.bounds;return e>=s&&e<=c&&i>=o&&i<=a}init(){var R,B,W,U,E,k,$;const{viewport:e,deck:i}=this.context,s=i==null?void 0:i.width,o=i==null?void 0:i.height,c=this.getDevicePixelRatio(),a=this.state.canvas??Ct(s,o,c);a.style.position="absolute",a.style.top="0px",a.style.left="0px",a.style.right="0px",a.style.bottom="0px",a.style.width=`${s}px`,a.style.height=`${o}px`,a.style.display=(R=this.props)!=null&&R.visible?"block":"none",a.style.zIndex=((W=(B=this.props)==null?void 0:B.zIndex)==null?void 0:W.toString())||"unset",a.id="windy-layer-canvas";const r=a.getContext("2d"),l=e.getBounds(),d=(U=this.props)==null?void 0:U.data,h=Object.assign(this._defaultOptions,((E=this.props)==null?void 0:E.windOptions)||{}),u=((k=this.props)==null?void 0:k.fieldOptions)||null,p=this.checkData(d,u),x=new T(r,h,p);x.postrender=this.postrender.bind(this),x.project=this.cproject.bind(this),x.unproject=this.cunproject.bind(this),x.intersectsCoordinate=this.intersectsCoordinate.bind(this);const A=($=i==null?void 0:i.getCanvas())==null?void 0:$.parentNode;A&&!A.querySelector("#windy-layer-canvas")&&A.appendChild(a),this.setState({bounds:l,canvas:a,wind:x,container:A,windOpitons:h})}setVisible(e){this.state.canvas.style.display=e?"block":"none"}setzIndex(e){this.state.canvas.style.zIndex=String(e)||"unset"}getDevicePixelRatio(){return(window==null?void 0:window.devicePixelRatio)||1}postrender(){var e,i;(i=(e=this.props)==null?void 0:e.onPostRender)==null||i.call(e,this)}cproject([e,i]){const s=this.getDevicePixelRatio(),[o,c]=this.context.viewport.project([e,i,0]);return[o*s,c*s]}cunproject([e,i]){const s=this.context.viewport.unproject([e,i]);return s?[s[0],s[1]]:null}checkData(e,i){return typeof e=="string"?null:e&&e.checkFields&&e.checkFields()?e:At(e)?It(e,i):(console.error("Illegal data"),null)}setData(e,i){const s=this.checkData(e,i);this.setState({data:s}),this.state.wind.updateData(s),this.state.wind.prerender()}destory(){const{wind:e,container:i}=this.state;e==null||e.stop(),e==null||e.clearCanvas(),i&&i.removeChild(this.state.canvas),this.setState({canvas:null,wind:null,bounds:null,windOptions:null,fieldOptions:null})}finalizeState(){this.destory()}}C(L,"layerName","WindLayer"),f.WindyLayer=L,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
@@ -10,13 +10,13 @@ export interface WindyLayerProps extends LayerProps {
10
10
  export default class WindyLayer extends Layer<WindyLayerProps> {
11
11
  static layerName: string;
12
12
  private _defaultOptions;
13
- constructor(props: WindyLayerProps);
14
13
  state: {
15
14
  canvas: HTMLCanvasElement;
16
15
  wind: WindCore;
17
16
  bounds: [number, number, number, number];
18
17
  windOptions: Partial<IOptions> | undefined;
19
18
  fieldOptions: Partial<IField> | undefined;
19
+ container: HTMLElement | null;
20
20
  };
21
21
  initializeState(): void;
22
22
  shouldUpdateState({ changeFlags }: UpdateParameters<this>): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deckgl-expansion",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "private": false,
6
6
  "types": "dist/types/index.d.ts",