@mappedin/marker-cluster 6.0.1-beta.46 → 6.0.1-beta.47
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.
- package/lib/esm/index.js +1 -1
- package/package.json +6 -6
package/lib/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ie=Object.defineProperty,pe=Object.defineProperties;var ge=Object.getOwnPropertyDescriptors;var ne=Object.getOwnPropertySymbols;var Me=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var oe=n=>{throw TypeError(n)};var W=(n,e,t)=>e in n?ie(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,b=(n,e)=>{for(var t in e||(e={}))Me.call(e,t)&&W(n,t,e[t]);if(ne)for(var t of ne(e))ye.call(e,t)&&W(n,t,e[t]);return n},L=(n,e)=>pe(n,ge(e)),i=(n,e)=>ie(n,"name",{value:e,configurable:!0});var c=(n,e,t)=>W(n,typeof e!="symbol"?e+"":e,t),ae=(n,e,t)=>e.has(n)||oe("Cannot "+t);var r=(n,e,t)=>(ae(n,e,"read from private field"),t?t.call(n):e.get(n)),a=(n,e,t)=>e.has(n)?oe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),f=(n,e,t,s)=>(ae(n,e,"write to private field"),s?s.call(n,t):e.set(n,t),t);var h={env:{NODE_ENV:"production",npm_package_version:"6.0.1-beta.47"}};var X="[MappedinJS]";var xe={logState:h.env.NODE_ENV==="test"?3:0,log(...n){this.logState<=0&&console.log(X,...n)},warn(...n){this.logState<=1&&console.warn(X,...n)},error(...n){this.logState<=2&&console.error(X,...n)},assert(...n){console.assert(...n)},time(n){console.time(n)},timeEnd(n){console.timeEnd(n)}},_=xe;var Z=class Z extends Error{};i(Z,"InvalidTokenError");var H=Z;H.prototype.name="InvalidTokenError";function ue(n,e,t=!1){let s=null,o=0;return function(...l){o++,o===1&&t===!0&&n(...l);let m=i(()=>{(!t||o>1)&&n(...l),s=null,o=0},"later");clearTimeout(s),s=setTimeout(m,e)}}i(ue,"debounce");var Q=[0,4,6,8,10],j=i(()=>{let n=new Array(16).fill(0),e=Math.random()*4294967296;for(let s=0;s<n.length;s++)s>0&&(s&3)===0&&(e=Math.random()*4294967296),n[s]=e>>>((s&3)<<3)&255;let t=n.map(s=>s.toString(16).padStart(2,"0"));return t[6]="4"+t[6][1],t[8]=["8","9","a","b"].includes(t[7][0])?t[7]:"a"+t[7][1],Q.map((s,o)=>t.slice(s,o===Q.length-1?void 0:Q[o+1]).join("")).join("-")},"randomId");var B=["red","blue","green","purple","orange","pink","brown","gray","black","magenta","cyan","silver","maroon","teal","aqua"],le=i((n,e,t)=>'<div style="background-color:'.concat(e,";color:white;width:").concat(t,"px;height:").concat(t,"px;border-radius:50%;text-align:center;line-height:").concat(t,"px;border:1px solid white;font-size:").concat(Math.floor(t*.7),'px;">').concat(n,"</div>"),"debugMarkerFn");import{Coordinate as ce}from"@mappedin/mappedin-js";var V=i(n=>parseFloat(n.toFixed(8)),"trimCoordValue"),de=i((n,e)=>{if(n.length===0)return new ce({latitude:0,longitude:0});let t=n.reduce((o,l)=>o+l.latitude,0)/n.length,s=n.reduce((o,l)=>o+l.longitude,0)/n.length;return new ce({latitude:V(t),longitude:V(s),floorId:e!=null?e:n[0].floorId})},"averageCoords"),he=i((n,e)=>n.length===0?"":[...n.map(t=>t.id).sort(),V(e.latitude),V(e.longitude),e.floorId].filter(t=>t!=null).join("-"),"getClusterId"),me=i((n,e)=>{if(e<=0)throw new Error("Buffer must be greater than 0");return{minX:n.x-e/2,minY:n.y-e/2,maxX:n.x+e/2,maxY:n.y+e/2}},"bufferPoint");import Ee from"rbush";var R=i(n=>"".concat(n.x,",").concat(n.y),"serializePoint"),g,ee=class ee extends Ee{constructor(){super(...arguments);a(this,g,new Map);c(this,"load",i(t=>{for(let s of t)r(this,g).set(R(s),s);return super.load(t)},"load"));c(this,"insert",i(t=>(r(this,g).set(R(t),t),super.insert(t)),"insert"));c(this,"remove",i(t=>(r(this,g).delete(R(t)),super.remove(t)),"remove"));c(this,"clear",i(()=>(r(this,g).clear(),super.clear()),"clear"));c(this,"peek",i(()=>r(this,g).values().next().value,"peek"));c(this,"has",i(t=>r(this,g).has(R(t)),"has"));c(this,"find",i(t=>{for(let s of r(this,g).values())if(t(s))return s},"find"));c(this,"toBBox",i(t=>({minX:t.x,minY:t.y,maxX:t.x,maxY:t.y}),"toBBox"));c(this,"compareMinX",i((t,s)=>t.x-s.x,"compareMinX"));c(this,"compareMinY",i((t,s)=>t.y-s.y,"compareMinY"));c(this,"equals",i((t,s)=>t.x===s.x&&t.y===s.y,"equals"))}get size(){return r(this,g).size}};g=new WeakMap,i(ee,"PointRBush");var C=ee;var A,x,M,y,E,F,$,te=class te{constructor(e){a(this,A);a(this,x,{threshold:100});a(this,M,new C);a(this,y,new Map);a(this,E,[]);a(this,F,i(()=>[...r(this,y).values()].map(e=>L(b({},r(this,A).getScreenCoordinateFromCoordinate(e.target.anchorTarget)),{markerId:e.id})),"#getScreenCoordinates"));a(this,$,i(e=>{let t=[e];r(this,M).remove(e);let s=r(this,M).search(me(e,r(this,x).threshold));if(s.length===0)return t;t.push(...s);for(let o of s)r(this,M).remove(o);return t},"#resolveNeighbours"));f(this,A,e)}setOptions(e){if(e.threshold!=null&&e.threshold<=0)throw new Error("Cluster threshold must be greater than 0");f(this,x,b(b({},r(this,x)),e))}load(e){r(this,y).clear();for(let t of e)r(this,y).set(t.id,t)}getClusters(){var l;let e=r(this,F).call(this);r(this,M).clear(),r(this,M).load(e);let t=r(this,M),s=[],o=[];for(;t.size>0;){let m=(l=t.find(w=>r(this,E).includes(w)))!=null?l:t.peek();if(m==null)break;o.push(m);let fe=r(this,$).call(this,m).map(w=>r(this,y).get(w.markerId)).filter(w=>w!=null);s.push(fe)}return f(this,E,o),s}destroy(){r(this,y).clear(),r(this,M).clear(),f(this,E,[])}};A=new WeakMap,x=new WeakMap,M=new WeakMap,y=new WeakMap,E=new WeakMap,F=new WeakMap,$=new WeakMap,i(te,"ScreenDistanceClustering");var N=te;var T,p,d,u,D,v,Y,J,U,K,q,z,P,k,I,S,O,se=class se{constructor(e,t,s){c(this,"id",j());a(this,T);a(this,p);a(this,d);a(this,u,{singleMarkersById:new Map,clustersById:new Map,clusterMarkersByClusterId:new Map,debugMarkersByClusterId:new Map,debugColorsByClusterId:new Map});a(this,D);a(this,v);a(this,Y,i(()=>[...r(this,u).singleMarkersById.values()],"#getMarkers"));a(this,J,i(e=>{r(this,p).updateState(e,{enabled:!1})},"#hideMarker"));a(this,U,i(e=>{r(this,p).updateState(e,{enabled:!0})},"#showMarker"));a(this,K,i(()=>{let e=r(this,d).algorithm;return e.load(r(this,Y).call(this)),e.getClusters()},"#getClusteredMarkers"));a(this,q,i(e=>{var s;let t=de(e.map(o=>o.target.anchorTarget),(s=r(this,d).floor)==null?void 0:s.id);return{id:he(e,t),markers:e,center:t}},"#createCluster"));a(this,z,i(e=>{var o;let t=(o=r(this,u).debugColorsByClusterId.get(e.id))!=null?o:B[0],s=r(this,D).call(this,e);s!=null&&r(this,u).clusterMarkersByClusterId.set(e.id,s);for(let l of e.markers)r(this,d).debug&&(l.contentEl.style.outline="2px solid ".concat(t)),r(this,d).hideClusteredMarkers&&r(this,J).call(this,l);if(r(this,d).debug){(s==null?void 0:s.contentEl.firstChild)instanceof HTMLElement&&(s.contentEl.firstChild.style.opacity="0.25");let l=r(this,p).Markers.add(e.center,le(e.markers.length.toString(),t,20),{rank:"always-visible",zIndex:99});r(this,u).debugMarkersByClusterId.set(e.id,l)}},"#addClusterMarkers"));a(this,P,i(e=>{let t=r(this,u).clusterMarkersByClusterId.get(e.id);if(t!=null&&(r(this,p).Markers.remove(t),r(this,u).clusterMarkersByClusterId.delete(e.id)),r(this,d).debug){let s=r(this,u).debugMarkersByClusterId.get(e.id);s!=null&&(r(this,p).Markers.remove(s),r(this,u).debugMarkersByClusterId.delete(e.id))}for(let s of e.markers)r(this,U).call(this,s)},"#removeClusterMarkers"));a(this,k,i(()=>{let e=new Map(r(this,u).clustersById),t=[],s=r(this,K).call(this);for(let o=0;o<s.length;o++){let l=s[o];if(l.length<r(this,d).minSize)continue;let m=r(this,q).call(this,l);r(this,u).clustersById.has(m.id)?e.delete(m.id):t.push(m)}for(let o of e.values())r(this,P).call(this,o),r(this,u).clustersById.delete(o.id),r(this,d).debug&&r(this,u).debugColorsByClusterId.delete(o.id);for(let o of t){if(r(this,d).debug){let l=B[Math.floor(Math.random()*B.length)];r(this,u).debugColorsByClusterId.set(o.id,l)}r(this,z).call(this,o),r(this,u).clustersById.set(o.id,o)}},"#updateImmediately"));a(this,I,i(()=>{r(this,d).debounce===0?r(this,k).call(this):r(this,v).call(this)},"#update"));a(this,S,i(()=>{r(this,I).call(this)},"#handleCameraChange"));a(this,O,i(()=>{r(this,k).call(this)},"#handleFocus"));c(this,"add",i(e=>{var t,s;if(r(this,d).floor==null)r(this,d).floor=(s=r(this,T).getById("floor",(t=e.target.anchorTarget.floorId)!=null?t:""))!=null?s:null;else if(r(this,d).floor.id!==e.target.anchorTarget.floorId)throw new Error("Cannot cluster markers on different floors!");r(this,u).singleMarkersById.set(e.id,e),r(this,I).call(this)},"add"));c(this,"remove",i(e=>{if(!r(this,u).singleMarkersById.has(e.id)){_.log("Cannot remove marker ".concat(e.id," because it is not in the cluster!"));return}r(this,u).singleMarkersById.delete(e.id),r(this,I).call(this)},"remove"));c(this,"has",i(e=>r(this,u).singleMarkersById.has(e.id),"has"));c(this,"destroy",i(()=>{r(this,d).algorithm.destroy(),r(this,p).off("camera-change",r(this,S)),window.removeEventListener("focus",r(this,O));for(let[,e]of r(this,u).clustersById)r(this,P).call(this,e);for(let e of Object.values(r(this,u)))if(e instanceof Map)e.clear();else throw new Error("Encountered unexpected data type in cache! Potentially failed to clean up MarkerCluster.")},"destroy"));var l,m;let o;if((s==null?void 0:s.algorithm)==null){let G=new N(e);G.setOptions((l=s==null?void 0:s.algorithmOptions)!=null?l:{}),o=G}else o=s.algorithm,o.setOptions((m=s==null?void 0:s.algorithmOptions)!=null?m:{});if(f(this,d,L(b({floor:null,minSize:2,debounce:50,debug:!1,hideClusteredMarkers:!0},s),{algorithm:o})),f(this,p,e),f(this,T,Object.values(r(this,p).getMapData())[0]),r(this,T)==null)throw new Error("No map data found in MapView!");f(this,D,t),f(this,v,ue(r(this,k),r(this,d).debounce)),r(this,p).on("camera-change",r(this,S)),window.addEventListener("focus",r(this,O))}get clusters(){return[...r(this,u).clustersById.values()]}};T=new WeakMap,p=new WeakMap,d=new WeakMap,u=new WeakMap,D=new WeakMap,v=new WeakMap,Y=new WeakMap,J=new WeakMap,U=new WeakMap,K=new WeakMap,q=new WeakMap,z=new WeakMap,P=new WeakMap,k=new WeakMap,I=new WeakMap,S=new WeakMap,O=new WeakMap,i(se,"MarkerCluster");var re=se;export{re as MarkerCluster,C as PointRBush,N as ScreenDistanceClustering};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mappedin/marker-cluster",
|
|
3
|
-
"version": "6.0.1-beta.
|
|
3
|
+
"version": "6.0.1-beta.47",
|
|
4
4
|
"homepage": "https://developer.mappedin.com/",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "lib/esm/index.js",
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
],
|
|
16
16
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
17
17
|
"scripts": {
|
|
18
|
-
"start": "
|
|
19
|
-
"build": "
|
|
20
|
-
"build:prod": "cross-env NODE_ENV=production
|
|
18
|
+
"start": "pnpm build && concurrently \"node scripts/build.mjs --watchChanges\" \"node scripts/start.mjs\"",
|
|
19
|
+
"build": "pnpm clean && tsc -b && node scripts/build.mjs",
|
|
20
|
+
"build:prod": "cross-env NODE_ENV=production pnpm build",
|
|
21
21
|
"types": "tsc -b",
|
|
22
22
|
"test": "NODE_ENV=test jest",
|
|
23
23
|
"test:cov": "NODE_ENV=test jest --coverage",
|
|
24
24
|
"clean": "rm -rf lib/** && rm -rf examples/dist/**",
|
|
25
|
-
"docs": "
|
|
25
|
+
"docs": "pnpm build && typedoc"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@mappedin/mappedin-js": "^6.0.1-beta.37"
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"volta": {
|
|
31
31
|
"extends": "../../package.json"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "a26145ebd6397dbdcbe07726be9b6c230d881360"
|
|
34
34
|
}
|