@arenarium/maps 1.0.175 → 1.0.177

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.
@@ -0,0 +1 @@
1
+ "use strict";var E=Object.defineProperty;var v=(l,o,n)=>o in l?E(l,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):l[o]=n;var h=(l,o,n)=>v(l,typeof o!="symbol"?o+"":o,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./states-O4d3qSXC.cjs");class B{constructor(o,n,i){h(this,"x");h(this,"y");h(this,"width");h(this,"height");h(this,"zoom");h(this,"angles");h(this,"expanded");h(this,"angle");h(this,"bounds");const c=f.Mercator.project(n.lat,n.lng,o.mapSize);this.x=c.x,this.y=c.y,this.width=n.width+2*n.margin,this.height=n.height+2*n.margin,this.zoom=i[0],this.angles=i[1].map(g=>[g[0],f.Angles.DEGREES[g[1]]]),this.expanded=!1,this.angle=0,this.bounds=void 0}getBounds(o,n){let{offsetX:i,offsetY:c}=f.Rectangle.getOffsets(this.width,this.height,n),g=-i,u=this.width-g,b=-c,e=this.height-b;return{x:this.x,y:this.y,left:g/o,right:u/o,top:b/o,bottom:e/o}}}function M(l,o,n){var b;if(o.length!=n.length)throw new Error("Data and states length must be the same");const i=new Array(o.length);for(let e=0;e<o.length;e++){const a=n[e];if(isNaN(a[0]))throw new Error("State zoom is not a number");if(a[1]==null||a[1].length==0)throw new Error("State angles is empty");if(a[0]!=a[1][0][0])throw new Error("State expand zoom and start angles zoom are not the same");const d=new B(l,o[e],n[e]);i[e]=d}const c=l.zoomMin,g=l.zoomMax,u=1/l.zoomScale;for(let e=c;e<=g;e+=u){const a=Math.pow(2,e);for(let d=0;d<i.length;d++){const t=i[d];if(t.expanded=t.zoom<e,t.expanded==!1)continue;const r=(b=t.angles.findLast(s=>s[0]<e))==null?void 0:b[1];if(r==null)throw new Error("Angle not found");t.angle=r,t.bounds=t.getBounds(a,r)}for(let d=0;d<i.length;d++){const t=i[d];if(t.bounds!=null)for(let r=d+1;r<i.length;r++){const s=i[r];if(s.bounds!=null&&f.Bounds.areOverlaping(t.bounds,s.bounds)){console.log("OVERLAP",e,o[d],o[r],t.angle,s.angle);const m=t.bounds.x-t.bounds.left,w=t.bounds.y-t.bounds.top,x=t.bounds.x+t.bounds.right,y=t.bounds.y+t.bounds.bottom;console.log(`B1: (${m}, ${w}), (${m}, ${y}), (${x}, ${w}), (${x}, ${y})`);const z=s.bounds.x-s.bounds.left,S=s.bounds.y-s.bounds.top,$=s.bounds.x+s.bounds.right,p=s.bounds.y+s.bounds.bottom;throw console.log(`B2: (${z}, ${S}), (${z}, ${p}), (${$}, ${S}), (${$}, ${p})`),new Error("Bounds overlaping")}}}}}exports.getStates=f.getStates;exports.testStates=M;
package/dist/api.d.ts ADDED
@@ -0,0 +1,139 @@
1
+ import { z } from 'zod';
2
+
3
+ export declare function getStates(parameters: MapProviderParameters, data: Array<MapTooltipStateInput>): MapTooltipState[];
4
+
5
+ declare type MapProviderParameters = z.infer<typeof mapProviderParametersSchema>;
6
+
7
+ declare const mapProviderParametersSchema: z.ZodObject<{
8
+ mapSize: z.ZodNumber;
9
+ zoomMin: z.ZodNumber;
10
+ zoomMax: z.ZodNumber;
11
+ zoomScale: z.ZodNumber;
12
+ }, "strip", z.ZodTypeAny, {
13
+ mapSize: number;
14
+ zoomMin: number;
15
+ zoomMax: number;
16
+ zoomScale: number;
17
+ }, {
18
+ mapSize: number;
19
+ zoomMin: number;
20
+ zoomMax: number;
21
+ zoomScale: number;
22
+ }>;
23
+
24
+ export declare type MapTooltipState = z.infer<typeof mapTooltipStateSchema>;
25
+
26
+ export declare type MapTooltipStateInput = z.infer<typeof mapTooltipStateInputSchema>;
27
+
28
+ declare const mapTooltipStateInputSchema: z.ZodObject<{
29
+ id: z.ZodString;
30
+ rank: z.ZodNumber;
31
+ lat: z.ZodNumber;
32
+ lng: z.ZodNumber;
33
+ width: z.ZodNumber;
34
+ height: z.ZodNumber;
35
+ margin: z.ZodNumber;
36
+ }, "strip", z.ZodTypeAny, {
37
+ lat: number;
38
+ lng: number;
39
+ id: string;
40
+ rank: number;
41
+ width: number;
42
+ height: number;
43
+ margin: number;
44
+ }, {
45
+ lat: number;
46
+ lng: number;
47
+ id: string;
48
+ rank: number;
49
+ width: number;
50
+ height: number;
51
+ margin: number;
52
+ }>;
53
+
54
+ declare const mapTooltipStateSchema: z.ZodTuple<[z.ZodNumber, z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, "many">], null>;
55
+
56
+ export declare type MapTooltipStatesRequest = z.infer<typeof mapTooltipStatesRequestSchema>;
57
+
58
+ declare const mapTooltipStatesRequestSchema: z.ZodObject<{
59
+ key: z.ZodString;
60
+ parameters: z.ZodObject<{
61
+ mapSize: z.ZodNumber;
62
+ zoomMin: z.ZodNumber;
63
+ zoomMax: z.ZodNumber;
64
+ zoomScale: z.ZodNumber;
65
+ }, "strip", z.ZodTypeAny, {
66
+ mapSize: number;
67
+ zoomMin: number;
68
+ zoomMax: number;
69
+ zoomScale: number;
70
+ }, {
71
+ mapSize: number;
72
+ zoomMin: number;
73
+ zoomMax: number;
74
+ zoomScale: number;
75
+ }>;
76
+ input: z.ZodArray<z.ZodObject<{
77
+ id: z.ZodString;
78
+ rank: z.ZodNumber;
79
+ lat: z.ZodNumber;
80
+ lng: z.ZodNumber;
81
+ width: z.ZodNumber;
82
+ height: z.ZodNumber;
83
+ margin: z.ZodNumber;
84
+ }, "strip", z.ZodTypeAny, {
85
+ lat: number;
86
+ lng: number;
87
+ id: string;
88
+ rank: number;
89
+ width: number;
90
+ height: number;
91
+ margin: number;
92
+ }, {
93
+ lat: number;
94
+ lng: number;
95
+ id: string;
96
+ rank: number;
97
+ width: number;
98
+ height: number;
99
+ margin: number;
100
+ }>, "many">;
101
+ }, "strip", z.ZodTypeAny, {
102
+ key: string;
103
+ parameters: {
104
+ mapSize: number;
105
+ zoomMin: number;
106
+ zoomMax: number;
107
+ zoomScale: number;
108
+ };
109
+ input: {
110
+ lat: number;
111
+ lng: number;
112
+ id: string;
113
+ rank: number;
114
+ width: number;
115
+ height: number;
116
+ margin: number;
117
+ }[];
118
+ }, {
119
+ key: string;
120
+ parameters: {
121
+ mapSize: number;
122
+ zoomMin: number;
123
+ zoomMax: number;
124
+ zoomScale: number;
125
+ };
126
+ input: {
127
+ lat: number;
128
+ lng: number;
129
+ id: string;
130
+ rank: number;
131
+ width: number;
132
+ height: number;
133
+ margin: number;
134
+ }[];
135
+ }>;
136
+
137
+ export declare function testStates(parameters: MapProviderParameters, inputs: MapTooltipStateInput[], states: MapTooltipState[]): void;
138
+
139
+ export { }
package/dist/api.es.js ADDED
@@ -0,0 +1,73 @@
1
+ var E = Object.defineProperty;
2
+ var S = (l, o, n) => o in l ? E(l, o, { enumerable: !0, configurable: !0, writable: !0, value: n }) : l[o] = n;
3
+ var d = (l, o, n) => S(l, typeof o != "symbol" ? o + "" : o, n);
4
+ import { B as v, M as B, A, R as M } from "./states-CxxqUf8M.js";
5
+ import { g as G } from "./states-CxxqUf8M.js";
6
+ class R {
7
+ constructor(o, n, i) {
8
+ d(this, "x");
9
+ d(this, "y");
10
+ d(this, "width");
11
+ d(this, "height");
12
+ d(this, "zoom");
13
+ d(this, "angles");
14
+ d(this, "expanded");
15
+ d(this, "angle");
16
+ d(this, "bounds");
17
+ const c = B.project(n.lat, n.lng, o.mapSize);
18
+ this.x = c.x, this.y = c.y, this.width = n.width + 2 * n.margin, this.height = n.height + 2 * n.margin, this.zoom = i[0], this.angles = i[1].map((a) => [a[0], A.DEGREES[a[1]]]), this.expanded = !1, this.angle = 0, this.bounds = void 0;
19
+ }
20
+ getBounds(o, n) {
21
+ let { offsetX: i, offsetY: c } = M.getOffsets(this.width, this.height, n), a = -i, b = this.width - a, f = -c, e = this.height - f;
22
+ return {
23
+ x: this.x,
24
+ y: this.y,
25
+ left: a / o,
26
+ right: b / o,
27
+ top: f / o,
28
+ bottom: e / o
29
+ };
30
+ }
31
+ }
32
+ function D(l, o, n) {
33
+ var f;
34
+ if (o.length != n.length) throw new Error("Data and states length must be the same");
35
+ const i = new Array(o.length);
36
+ for (let e = 0; e < o.length; e++) {
37
+ const g = n[e];
38
+ if (isNaN(g[0])) throw new Error("State zoom is not a number");
39
+ if (g[1] == null || g[1].length == 0) throw new Error("State angles is empty");
40
+ if (g[0] != g[1][0][0]) throw new Error("State expand zoom and start angles zoom are not the same");
41
+ const h = new R(l, o[e], n[e]);
42
+ i[e] = h;
43
+ }
44
+ const c = l.zoomMin, a = l.zoomMax, b = 1 / l.zoomScale;
45
+ for (let e = c; e <= a; e += b) {
46
+ const g = Math.pow(2, e);
47
+ for (let h = 0; h < i.length; h++) {
48
+ const t = i[h];
49
+ if (t.expanded = t.zoom < e, t.expanded == !1) continue;
50
+ const r = (f = t.angles.findLast((s) => s[0] < e)) == null ? void 0 : f[1];
51
+ if (r == null) throw new Error("Angle not found");
52
+ t.angle = r, t.bounds = t.getBounds(g, r);
53
+ }
54
+ for (let h = 0; h < i.length; h++) {
55
+ const t = i[h];
56
+ if (t.bounds != null)
57
+ for (let r = h + 1; r < i.length; r++) {
58
+ const s = i[r];
59
+ if (s.bounds != null && v.areOverlaping(t.bounds, s.bounds)) {
60
+ console.log("OVERLAP", e, o[h], o[r], t.angle, s.angle);
61
+ const m = t.bounds.x - t.bounds.left, u = t.bounds.y - t.bounds.top, x = t.bounds.x + t.bounds.right, w = t.bounds.y + t.bounds.bottom;
62
+ console.log(`B1: (${m}, ${u}), (${m}, ${w}), (${x}, ${u}), (${x}, ${w})`);
63
+ const $ = s.bounds.x - s.bounds.left, y = s.bounds.y - s.bounds.top, p = s.bounds.x + s.bounds.right, z = s.bounds.y + s.bounds.bottom;
64
+ throw console.log(`B2: (${$}, ${y}), (${$}, ${z}), (${p}, ${y}), (${p}, ${z})`), new Error("Bounds overlaping");
65
+ }
66
+ }
67
+ }
68
+ }
69
+ }
70
+ export {
71
+ G as getStates,
72
+ D as testStates
73
+ };
package/dist/index.d.ts CHANGED
@@ -34,17 +34,51 @@ declare const mapConfigurationSchema: z.ZodObject<{
34
34
  limit?: number | undefined;
35
35
  } | undefined;
36
36
  }>>;
37
- states: z.ZodOptional<z.ZodObject<{
38
- url: z.ZodString;
39
- key: z.ZodString;
37
+ api: z.ZodObject<{
38
+ states: z.ZodOptional<z.ZodObject<{
39
+ url: z.ZodString;
40
+ key: z.ZodString;
41
+ }, "strip", z.ZodTypeAny, {
42
+ url: string;
43
+ key: string;
44
+ }, {
45
+ url: string;
46
+ key: string;
47
+ }>>;
48
+ log: z.ZodOptional<z.ZodObject<{
49
+ enabled: z.ZodBoolean;
50
+ }, "strip", z.ZodTypeAny, {
51
+ enabled: boolean;
52
+ }, {
53
+ enabled: boolean;
54
+ }>>;
40
55
  }, "strip", z.ZodTypeAny, {
41
- url: string;
42
- key: string;
56
+ states?: {
57
+ url: string;
58
+ key: string;
59
+ } | undefined;
60
+ log?: {
61
+ enabled: boolean;
62
+ } | undefined;
43
63
  }, {
44
- url: string;
45
- key: string;
46
- }>>;
64
+ states?: {
65
+ url: string;
66
+ key: string;
67
+ } | undefined;
68
+ log?: {
69
+ enabled: boolean;
70
+ } | undefined;
71
+ }>;
47
72
  }, "strip", z.ZodTypeAny, {
73
+ api: {
74
+ states?: {
75
+ url: string;
76
+ key: string;
77
+ } | undefined;
78
+ log?: {
79
+ enabled: boolean;
80
+ } | undefined;
81
+ };
48
82
  pin?: {
49
83
  fade?: boolean | undefined;
50
84
  maxCount?: number | undefined;
@@ -55,11 +89,16 @@ declare const mapConfigurationSchema: z.ZodObject<{
55
89
  limit?: number | undefined;
56
90
  } | undefined;
57
91
  } | undefined;
58
- states?: {
59
- url: string;
60
- key: string;
61
- } | undefined;
62
92
  }, {
93
+ api: {
94
+ states?: {
95
+ url: string;
96
+ key: string;
97
+ } | undefined;
98
+ log?: {
99
+ enabled: boolean;
100
+ } | undefined;
101
+ };
63
102
  pin?: {
64
103
  fade?: boolean | undefined;
65
104
  maxCount?: number | undefined;
@@ -70,10 +109,6 @@ declare const mapConfigurationSchema: z.ZodObject<{
70
109
  limit?: number | undefined;
71
110
  } | undefined;
72
111
  } | undefined;
73
- states?: {
74
- url: string;
75
- key: string;
76
- } | undefined;
77
112
  }>;
78
113
  export type MapConfiguration = z.infer<typeof mapConfigurationSchema>;
79
114
  declare const mapBoundsSchema: z.ZodObject<{
@@ -495,10 +530,124 @@ declare const mapMarkerSchema: z.ZodObject<{
495
530
  } | undefined;
496
531
  }>;
497
532
  export type MapMarker = z.infer<typeof mapMarkerSchema>;
533
+ declare const mapTooltipStateSchema: z.ZodTuple<[
534
+ z.ZodNumber,
535
+ z.ZodArray<z.ZodTuple<[
536
+ z.ZodNumber,
537
+ z.ZodNumber
538
+ ], null>, "many">
539
+ ], null>;
540
+ declare const mapTooltipStateInputSchema: z.ZodObject<{
541
+ id: z.ZodString;
542
+ rank: z.ZodNumber;
543
+ lat: z.ZodNumber;
544
+ lng: z.ZodNumber;
545
+ width: z.ZodNumber;
546
+ height: z.ZodNumber;
547
+ margin: z.ZodNumber;
548
+ }, "strip", z.ZodTypeAny, {
549
+ lat: number;
550
+ lng: number;
551
+ id: string;
552
+ rank: number;
553
+ width: number;
554
+ height: number;
555
+ margin: number;
556
+ }, {
557
+ lat: number;
558
+ lng: number;
559
+ id: string;
560
+ rank: number;
561
+ width: number;
562
+ height: number;
563
+ margin: number;
564
+ }>;
565
+ declare const mapTooltipStatesRequestSchema: z.ZodObject<{
566
+ key: z.ZodString;
567
+ parameters: z.ZodObject<{
568
+ mapSize: z.ZodNumber;
569
+ zoomMin: z.ZodNumber;
570
+ zoomMax: z.ZodNumber;
571
+ zoomScale: z.ZodNumber;
572
+ }, "strip", z.ZodTypeAny, {
573
+ mapSize: number;
574
+ zoomMin: number;
575
+ zoomMax: number;
576
+ zoomScale: number;
577
+ }, {
578
+ mapSize: number;
579
+ zoomMin: number;
580
+ zoomMax: number;
581
+ zoomScale: number;
582
+ }>;
583
+ input: z.ZodArray<z.ZodObject<{
584
+ id: z.ZodString;
585
+ rank: z.ZodNumber;
586
+ lat: z.ZodNumber;
587
+ lng: z.ZodNumber;
588
+ width: z.ZodNumber;
589
+ height: z.ZodNumber;
590
+ margin: z.ZodNumber;
591
+ }, "strip", z.ZodTypeAny, {
592
+ lat: number;
593
+ lng: number;
594
+ id: string;
595
+ rank: number;
596
+ width: number;
597
+ height: number;
598
+ margin: number;
599
+ }, {
600
+ lat: number;
601
+ lng: number;
602
+ id: string;
603
+ rank: number;
604
+ width: number;
605
+ height: number;
606
+ margin: number;
607
+ }>, "many">;
608
+ }, "strip", z.ZodTypeAny, {
609
+ key: string;
610
+ parameters: {
611
+ mapSize: number;
612
+ zoomMin: number;
613
+ zoomMax: number;
614
+ zoomScale: number;
615
+ };
616
+ input: {
617
+ lat: number;
618
+ lng: number;
619
+ id: string;
620
+ rank: number;
621
+ width: number;
622
+ height: number;
623
+ margin: number;
624
+ }[];
625
+ }, {
626
+ key: string;
627
+ parameters: {
628
+ mapSize: number;
629
+ zoomMin: number;
630
+ zoomMax: number;
631
+ zoomScale: number;
632
+ };
633
+ input: {
634
+ lat: number;
635
+ lng: number;
636
+ id: string;
637
+ rank: number;
638
+ width: number;
639
+ height: number;
640
+ margin: number;
641
+ }[];
642
+ }>;
643
+ export type MapTooltipState = z.infer<typeof mapTooltipStateSchema>;
644
+ export type MapTooltipStateInput = z.infer<typeof mapTooltipStateInputSchema>;
645
+ export type MapTooltipStatesRequest = z.infer<typeof mapTooltipStatesRequestSchema>;
498
646
  export declare class MapManager {
499
647
  private provider;
500
- private statesApiUrl;
501
- private statesApiKey;
648
+ private apiStatesUrl;
649
+ private apiStatesKey;
650
+ private apiLogEnabled;
502
651
  private markerDataArray;
503
652
  private markerDataMap;
504
653
  private markerDataUpdating;
@@ -515,6 +664,7 @@ export declare class MapManager {
515
664
  private removeMarkerData;
516
665
  private processMarkerDataCallback;
517
666
  private processMarkerData;
667
+ private log;
518
668
  }
519
669
  export interface MaplibreMapClass {
520
670
  new (options: maplibregl.MapOptions): maplibregl.Map;
@@ -632,6 +782,8 @@ export declare const GoogleMapDarkStyle: ({
632
782
  lightness: number;
633
783
  }[];
634
784
  })[];
785
+ export declare function getStates(parameters: MapProviderParameters, data: Array<MapTooltipStateInput>): MapTooltipState[];
786
+ export declare function testStates(parameters: MapProviderParameters, inputs: MapTooltipStateInput[], states: MapTooltipState[]): void;
635
787
 
636
788
  export as namespace arenarium;
637
789