maplibre-gl 6.3.0 → 6.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/maplibre-gl-dev.mjs +590 -208
- package/dist/maplibre-gl-dev.mjs.map +1 -1
- package/dist/maplibre-gl-shared-dev.mjs +258 -235
- package/dist/maplibre-gl-shared-dev.mjs.map +1 -1
- package/dist/maplibre-gl-shared.mjs +2 -2
- package/dist/maplibre-gl-shared.mjs.map +1 -1
- package/dist/maplibre-gl-worker-dev.mjs +2 -2
- package/dist/maplibre-gl-worker.mjs +2 -2
- package/dist/maplibre-gl-worker.mjs.map +1 -1
- package/dist/maplibre-gl.d.ts +258 -97
- package/dist/maplibre-gl.mjs +18 -18
- package/dist/maplibre-gl.mjs.map +1 -1
- package/package.json +7 -7
- package/src/data/bucket/fill_extrusion_bucket.ts +1 -13
- package/src/data/bucket/round_polygon_corners.test.ts +84 -36
- package/src/data/bucket/round_polygon_corners.ts +90 -39
- package/src/data/extent_bounds.ts +28 -1
- package/src/geo/projection/globe_transform.test.ts +129 -1
- package/src/geo/projection/globe_utils.ts +189 -2
- package/src/geo/projection/vertical_perspective_camera_helper.test.ts +24 -0
- package/src/geo/projection/vertical_perspective_camera_helper.ts +11 -10
- package/src/render/image_atlas.test.ts +110 -2
- package/src/render/image_atlas.ts +35 -4
- package/src/render/image_manager.test.ts +66 -1
- package/src/render/image_manager.ts +136 -144
- package/src/render/painter.ts +5 -2
- package/src/render/pattern_atlas.test.ts +131 -0
- package/src/render/pattern_atlas.ts +144 -0
- package/src/shaders/glsl/_prelude.vertex.glsl +8 -8
- package/src/shaders/glsl/_prelude.vertex.glsl.g.ts +1 -1
- package/src/shaders/glsl/color_relief.fragment.glsl +1 -2
- package/src/shaders/glsl/color_relief.fragment.glsl.g.ts +1 -1
- package/src/shaders/glsl/hillshade_prepare.fragment.glsl +12 -12
- package/src/shaders/glsl/hillshade_prepare.fragment.glsl.g.ts +1 -1
- package/src/source/image_source.test.ts +41 -31
- package/src/source/image_source.ts +14 -15
- package/src/source/raster_dem_tile_source.test.ts +37 -3
- package/src/source/raster_dem_tile_source.ts +1 -2
- package/src/source/raster_tile_source.test.ts +5 -26
- package/src/source/raster_tile_source.ts +4 -3
- package/src/style/style.test.ts +64 -0
- package/src/style/style.ts +37 -64
- package/src/symbol/cross_tile_symbol_index.test.ts +31 -0
- package/src/symbol/cross_tile_symbol_index.ts +67 -37
- package/src/tile/tile_manager.test.ts +69 -1
- package/src/tile/tile_manager.ts +14 -9
- package/src/ui/handler/two_fingers_touch.test.ts +14 -3
- package/src/ui/handler_inertia.test.ts +91 -0
- package/src/ui/handler_inertia.ts +65 -14
- package/src/ui/map_tests/map_images.test.ts +26 -0
- package/src/ui/map_tests/map_webgl.test.ts +2 -1
- package/src/ui/marker.test.ts +151 -0
- package/src/ui/marker.ts +120 -10
- package/src/util/image_request.ts +31 -1
- package/src/webgl/draw/draw_background.ts +1 -1
- package/src/webgl/program/pattern.ts +3 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MapLibre GL JS
|
|
3
|
-
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.
|
|
3
|
+
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.4.0/LICENSE.txt
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { B as PbfReader, Bn as JSON_PREFIX, D as SymbolBucket, Dn as getArrayBuffer, Dt as RGBAImage, Et as AlphaImage, Fn as removeProtocol, I as potpack, K as FillExtrusionBucket, Nn as addProtocol, On as getJSON, P as ImageAtlas, Rn as isAbortError, S as createStyleLayer, U as LineBucket, Ur as EXTENT, Vt as CollisionBoxArray, W as GeoJSONVT, Wi as Point, an as register, bt as DEMData, c as FeatureIndex, d as DictionaryCoder, fr as getImageData, g as OverscaledTileID, i as clipGeometry, ir as ensureError, jn as makeRequest, l as MLTVectorTile, m as fromVectorTileJs, mn as createExpression, mr as isImageBitmap, mt as FillBucket, n as performSymbolLayout, nn as rtlWorkerPlugin, o as BoundedLRUCache, or as extend, p as GeoJSONWrapper, tn as EvaluationParameters, ut as VectorTile, vn as featureFilter, x as Actor, xr as mapObject, yn as groupByLayout, yr as isWorker, zr as warnOnce } from "./maplibre-gl-shared-dev.mjs";
|
|
6
6
|
//#region src/style/style_layer_index.ts
|
|
7
7
|
var StyleLayerIndex = class {
|
|
8
8
|
constructor(layerConfigs, globalState) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MapLibre GL JS
|
|
3
|
-
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.
|
|
3
|
+
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.4.0/LICENSE.txt
|
|
4
4
|
*/
|
|
5
|
-
import{An as e,Bt as t,C as n,Dn as r,En as i,Et as a,F as o,G as s,Hr as c,L as l,Ln as u,Mn as d,O as f,Pn as p,Ri as m,Rr as h,S as g,Tt as _,V as v,W as y,_ as b,_n as x,ar as S,br as C,c as w,d as T,dr as E,dt as D,en as O,i as k,in as A,l as j,m as M,n as N,o as P,p as F,pn as I,pr as ee,pt as te,q as ne,rr as re,tn as L,vn as R,vr as z,yt as B,zn as V}from"./maplibre-gl-shared.mjs";var H=class{constructor(e,t){this.keyCache={},e&&this.replace(e,t)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(e,t,r){for(let t of e){this._layerConfigs[t.id]=t;let e=this._layers[t.id]=n(t,r);e._featureFilter=x(e.filter,`layers[${t.id}].filter`,r),this.keyCache[t.id]&&delete this.keyCache[t.id]}for(let e of t)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};let i=R(Object.values(this._layerConfigs),this.keyCache);for(let e of i){let t=e.map(e=>this._layers[e.id]),n=t[0];if(n.isHidden())continue;let r=n.source||``,i=this.familiesBySource[r];i||=this.familiesBySource[r]={};let a=n.sourceLayer||`_geojsonTileLayer`,o=i[a];o||=i[a]=[],o.push(t)}}},U=class{constructor(e){let t={},n=[];for(let r in e){let i=e[r],a=t[r]={};for(let e in i){let t=i[+e];if(!t||t.bitmap.width===0||t.bitmap.height===0)continue;let r={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};n.push(r),a[e]={rect:r,metrics:t.metrics}}}let{w:r,h:i}=l(n),a=new _({width:r||1,height:i||1});for(let n in e){let r=e[n];for(let e in r){let i=r[+e];if(!i||i.bitmap.width===0||i.bitmap.height===0)continue;let o=t[n][e].rect;_.copy(i.bitmap,a,{x:0,y:0},{x:o.x+1,y:o.y+1},i.bitmap)}}this.image=a,this.positions=t}};A(`GlyphAtlas`,U);var W=class{constructor(e){this.tileID=new b(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.uid=e.uid,this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId,this.inFlightDependencies=[]}async parse(e,n,r,i,a){this.data=e,this.collisionBoxArray=new t;let s=new T(Object.keys(e.layers).sort()),c=new w(this.tileID,this.promoteId);c.bucketLayerIDs=[];let l={},u={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:r,subdivisionGranularity:a},d=n.familiesBySource[this.source];for(let t in d){let n=e.layers[t];if(!n)continue;n.version===1&&h(`Vector tile source "${this.source}" layer "${t}" does not use vector tile spec v2 and therefore may have some rendering errors.`);let i=s.encode(t),a=[];for(let e=0;e<n.length;e++){let r=n.feature(e),o=c.getId(r,t);a.push({feature:r,id:o,index:e,sourceLayerIndex:i})}for(let e of d[t]){let t=e[0];t.source!==this.source&&h(`layer.source = ${t.source} does not equal this.source = ${this.source}`),!t.isHidden(this.zoom,!0)&&(G(e,this.zoom,r),(l[t.id]=t.createBucket({index:c.bucketLayerIDs.length,layers:e,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:i,sourceID:this.source})).populate(a,u,this.tileID.canonical),c.bucketLayerIDs.push(e.map(e=>e.id)))}}let p=C(u.glyphDependencies,e=>Object.keys(e).map(Number));for(let e of this.inFlightDependencies)e?.abort();this.inFlightDependencies=[];let m=Promise.resolve({});if(Object.keys(p).length){let e=new AbortController;this.inFlightDependencies.push(e),m=i.sendAsync({type:`GG`,data:{stacks:p,source:this.source,tileID:this.tileID,type:`glyphs`}},e)}let g=Object.keys(u.iconDependencies),_=Promise.resolve({});if(g.length){let e=new AbortController;this.inFlightDependencies.push(e),_=i.sendAsync({type:`GI`,data:{icons:g,source:this.source,tileID:this.tileID,type:`icons`}},e)}let v=Object.keys(u.patternDependencies),b=Promise.resolve({});if(v.length){let e=new AbortController;this.inFlightDependencies.push(e),b=i.sendAsync({type:`GI`,data:{icons:v,source:this.source,tileID:this.tileID,type:`patterns`}},e)}let x=u.dashDependencies,S=Promise.resolve({});if(Object.keys(x).length){let e=new AbortController;this.inFlightDependencies.push(e),S=i.sendAsync({type:`GDA`,data:{dashes:x}},e)}let[E,D,O,k]=await Promise.all([m,_,b,S]),A=new U(E),j=new o(D,O);for(let e in l){let t=l[e];t instanceof f?(G(t.layers,this.zoom,r),N({bucket:t,glyphMap:E,glyphPositions:A.positions,imageMap:D,imagePositions:j.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:u.subdivisionGranularity})):t.hasDependencies&&(t instanceof te||t instanceof ne||t instanceof y)&&(G(t.layers,this.zoom,r),t.addFeatures(u,this.tileID.canonical,j.patternPositions,k))}return{buckets:Object.values(l).filter(e=>!e.isEmpty()),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:A.image,imageAtlas:j,dashPositions:k,glyphMap:this.returnDependencies?E:null,iconMap:this.returnDependencies?D:null,glyphPositions:this.returnDependencies?A.positions:null}}};function G(e,t,n){let r=new O(t);for(let t of e)t.recalculate(r,n)}var K=class{constructor(){this.loading={},this.loaded={},this.parsing={}}startLoading(e,t){this.loading[e]=t}finishLoading(e){delete this.loading[e]}abort(e){let t=this.loading[e];t?.abort&&(t.abort.abort(),delete this.loading[e])}getParsing(e){return this.parsing[e]}setParsing(e,t){this.parsing[e]=t}removeParsing(e){delete this.parsing[e]}markLoaded(e,t){this.loaded[e]=t}getLoaded(e){let t=this.loaded[e];if(t)return t}removeLoaded(e){delete this.loaded[e]}clearLoaded(){this.loaded={}}},q=class{constructor(e){this.start=`${e}#start`,this.end=`${e}#end`,this.measure=e,performance.mark(this.start)}finish(){performance.mark(this.end);let e=performance.getEntriesByName(this.measure);return e.length===0&&(performance.measure(this.measure,this.start,this.end),e=performance.getEntriesByName(this.measure),performance.clearMarks(this.start),performance.clearMarks(this.end),performance.clearMeasures(this.measure)),e}},J=class{constructor(e,t,n,r,i){this.type=e,this.properties=n||{},this.extent=i,this.pointsArray=t,this.id=r}loadGeometry(){return this.pointsArray.map(e=>e.map(e=>new m(e.x,e.y)))}},Y=class{constructor(e,t,n){this.version=2,this._myFeatures=e,this.name=t,this.length=e.length,this.extent=n}feature(e){return this._myFeatures[e]}},ie=class{constructor(){this.layers={}}addLayer(e){this.layers[e.name]=e}};function ae(e,t,n){let{extent:r}=e,i=2**(n.z-t.z),a=(n.x-t.x*i)*r,o=(n.y-t.y*i)*r,s=[];for(let t=0;t<e.length;t++){let n=e.feature(t),c=n.loadGeometry();for(let e of c)for(let t of e)t.x=t.x*i-a,t.y=t.y*i-o;c=k(c,n.type,-128,-128,r+128,r+128),c.length!==0&&s.push(new J(n.type,c,n.properties,n.id,r))}return new Y(s,e.name,r)}var oe=class{constructor(e,t,n){this.actor=e,this.layerIndex=t,this.availableImages=n,this.tileState=new K,this.overzoomedTileResultCache=new P(1e3)}loadVectorTile(e,t){try{return{vectorTile:e.encoding===`mlt`?new j(t):new D(new v(t)),rawData:t}}catch(n){let r=new Uint8Array(t),i=r[0]===31&&r[1]===139,a=`Unable to parse the tile at ${e.request.url}, `;throw a+=i?`please make sure the data is not gzipped and that you have configured the relevant header in the server`:`got error: ${re(n).message}`,Error(a)}}async loadTile(e){let{uid:t,overzoomParameters:n}=e;n&&(e.request=n.overzoomRequest);let r=this._startRequestTiming(e),a=new W(e);this.tileState.startLoading(t,a);let o=new AbortController;a.abort=o;try{let s=await i(e.request,o);if(e.etag&&e.etag===s.etag)return this.tileState.finishLoading(t),this._getEtagUnmodifiedResult(s,r);let c=this.loadVectorTile(e,s.data);if(this.tileState.finishLoading(t),!c)return null;let{vectorTile:l,rawData:u}=c;n&&({vectorTile:l,rawData:u}=this._getOverzoomTile(e,l));let d=this._getExpiryData(s),f=this._finishRequestTiming(r);a.vectorTile=l,this.tileState.markLoaded(t,a);let p={rawData:u,cacheControl:d,resourceTiming:f};return this.tileState.setParsing(t,p),await this._parseWorkerTile(a,e)}catch(e){throw this.tileState.finishLoading(t),this.tileState.markLoaded(t,a),e}}_getEtagUnmodifiedResult(e,t){let n=this._getExpiryData(e),r=this._finishRequestTiming(t);return S({etagUnmodified:!0},n,r)}async _parseWorkerTile(e,t){let n=this.tileState.getParsing(e.uid),r=await e.parse(e.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);if(n){let{rawData:i,cacheControl:a,resourceTiming:o}=n,s=t.overzoomParameters?`mvt`:t.encoding;r=S({rawTileData:i.slice(0),encoding:s},r,a,o),this.tileState.removeParsing(e.uid)}return r}_getExpiryData({expires:e,cacheControl:t,etag:n}){let r={};return e&&(r.expires=e),t&&(r.cacheControl=t),n&&(r.etag=n),r}_startRequestTiming(e){if(e.request?.collectResourceTiming)return new q(e.request.url)}_finishRequestTiming(e){let t=e?.finish();return t?{resourceTiming:JSON.parse(JSON.stringify(t))}:{}}_getOverzoomTile(e,t){let{tileID:n,source:r,overzoomParameters:i}=e,{maxZoomTileID:a}=i,o=`${a.key}_${n.key}_${e.request?.url}`,s=this.overzoomedTileResultCache.get(o);if(s)return s;let c=new ie,l=this.layerIndex.familiesBySource[r];for(let e in l){let r=t.layers[e];if(!r)continue;let i=ae(r,a,n.canonical);i.length>0&&c.addLayer(i)}let u={vectorTile:c,rawData:M(c).buffer};return this.overzoomedTileResultCache.set(o,u),u}async reloadTile(e){let t=e.uid,n=this.tileState.getLoaded(t);if(!n)throw Error(`Should not be trying to reload a tile that was never loaded or has been removed`);if(n.vectorTile)return n.showCollisionBoxes=e.showCollisionBoxes,await this._parseWorkerTile(n,e)}async abortTile(e){this.tileState.abort(e.uid)}async removeTile(e){this.tileState.removeLoaded(e.uid)}},X=class{constructor(){this.loaded={}}async loadTile(e){let{uid:t,encoding:n,rawImageData:r,redFactor:i,greenFactor:o,blueFactor:s,baseShift:c}=e,l=r.width+2,u=r.height+2,d=ee(r)?new a({width:l,height:u},await E(r,-1,-1,l,u)):r,f=new B(t,d,n,i,o,s,c);return this.loaded||={},this.loaded[t]=f,f}removeTile(e){let t=this.loaded,n=e.uid;t?.[n]&&delete t[n]}},se=class{constructor(e,t,n,r=ce){this.actor=e,this.layerIndex=t,this.availableImages=n,this.tileState=new K,this._createGeoJSONIndex=r}loadVectorTile(e){if(!this._geoJSONIndex)throw Error(`Unable to parse the data into a cluster or geojson`);let{z:t,x:n,y:r}=e.tileID.canonical,i=this._geoJSONIndex.getTile(t,n,r);if(!i)return null;let a=new F(i.features,{version:2,extent:c});return{vectorTile:a,rawData:M(a,V).buffer}}async loadTile(e){let{uid:t}=e,n=new W(e);n.abort=new AbortController;try{let r=this.loadVectorTile(e);if(!r)return null;let{vectorTile:i,rawData:a}=r;n.vectorTile=i,this.tileState.markLoaded(t,n);let o={rawData:a};return this.tileState.setParsing(t,o),await this._parseWorkerTile(n,e)}catch(e){throw this.tileState.markLoaded(t,n),e}}async _parseWorkerTile(e,t){let n=this.tileState.getParsing(e.uid),r=await e.parse(e.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);if(n){let{rawData:t}=n;r=S({rawTileData:t.slice(0),encoding:`mvt`},r),this.tileState.removeParsing(e.uid)}return r}async abortTile(e){this.tileState.abort(e.uid)}async removeTile(e){this.tileState.removeLoaded(e.uid)}async loadData(e){this._pendingRequest?.abort();let t=this._startRequestTiming(e);this._pendingRequest=new AbortController;try{await this.loadAndProcessGeoJSON(e,this._pendingRequest),delete this._pendingRequest,this.tileState.clearLoaded();let n={};return e.request&&(n.data=e.data),this._finishRequestTiming(t,e,n),n}catch(e){if(delete this._pendingRequest,!u(e))throw e;return{abandoned:!0}}}_startRequestTiming(e){if(e.request?.collectResourceTiming)return new q(e.request.url)}_finishRequestTiming(e,t,n){let r=e?.finish();r&&(n.resourceTiming={[t.source]:JSON.parse(JSON.stringify(r))})}async reloadTile(e){let t=e.uid,n=this.tileState.getLoaded(t);if(!n)return await this.loadTile(e);if(n.vectorTile)return n.showCollisionBoxes=e.showCollisionBoxes,await this._parseWorkerTile(n,e)}async loadAndProcessGeoJSON(e,t){if(e.request&&(e.data=(await r(e.request,t)).data),e.data){e.data=this._filterGeoJSON(e.data,e.filter,e.source),this._geoJSONIndex=this._createGeoJSONIndex(e.data,e);return}if(e.dataDiff){this._geoJSONIndex??=this._createGeoJSONIndex({type:`FeatureCollection`,features:[]},e),this._geoJSONIndex.updateData(e.dataDiff,this._getFilterPredicate(e.filter,e.source));return}if(e.updateCluster&&this._geoJSONIndex.updateClusterOptions(e.geojsonVtOptions.cluster,Z(e)),this._geoJSONIndex==null)throw Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`)}_filterGeoJSON(e,t,n){if(e.type!==`FeatureCollection`)return e;let r=this._getFilterPredicate(t,n);return r?{type:`FeatureCollection`,features:e.features.filter(e=>r(e))}:e}_getFilterPredicate(e,t){if(typeof e!=`boolean`&&!e?.length)return;let n=I(e,`sources.${t}.filter`,{type:`boolean`,"property-type":`data-driven`,overridable:!1,transition:!1});if(n.result===`error`)throw Error(n.value.map(e=>`${e.key}: ${e.message}`).join(`, `));return e=>n.value.evaluate({zoom:0},e)}async removeSource(e){this._pendingRequest?.abort()}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getClusterChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getClusterLeaves(e.clusterId,e.limit,e.offset)}};function ce(e,t){let n=S(t.geojsonVtOptions||{},{updateable:!0,clusterOptions:Z(t)});return new s(e,n)}function Z({geojsonVtOptions:e,clusterProperties:t,source:n}){if(!t||!e.clusterOptions)return e.clusterOptions;let r={},i={},a={accumulated:null,zoom:0},o={properties:null},s=Object.keys(t);for(let e of s){let[a,o]=t[e],s=I(o,`sources.${n}.clusterProperties.${e}[1]`),c=I(typeof a==`string`?[a,[`accumulated`],[`get`,e]]:a,`sources.${n}.clusterProperties.${e}[0]`);r[e]=s.value,i[e]=c.value}return e.clusterOptions.map=e=>{o.properties=e;let t={};for(let e of s)t[e]=r[e].evaluate(a,o);return t},e.clusterOptions.reduce=(e,t)=>{o.properties=t;for(let t of s)a.accumulated=e[t],e[t]=i[t].evaluate(a,o)},e.clusterOptions}async function Q(e){if(e.endsWith(`.mjs`)){await import(e);return}let t=await fetch(e,{credentials:`same-origin`});if(!t.ok)throw Error(`Failed to load ${e}: ${t.status}`);let n=await t.text();if(/^[ \t]*(import|export)\s/m.test(n)){let e=URL.createObjectURL(new Blob([n],{type:`text/javascript`}));try{await import(e)}finally{URL.revokeObjectURL(e)}return}globalThis.eval(n)}var $=class{constructor(t){this.self=t,this.actor=new g(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t},this.self.addProtocol=d,this.self.removeProtocol=p,this.self.registerRTLTextPlugin=e=>{L.setMethods(e)},this.self.makeRequest=e,this.actor.registerMessageHandler(`LDT`,(e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t)),this.actor.registerMessageHandler(`RDT`,async(e,t)=>{this._getDEMWorkerSource(e,t.source).removeTile(t)}),this.actor.registerMessageHandler(`GCEZ`,async(e,t)=>this._getWorkerSource(e,t.type,t.source).getClusterExpansionZoom(t)),this.actor.registerMessageHandler(`GCC`,async(e,t)=>this._getWorkerSource(e,t.type,t.source).getClusterChildren(t)),this.actor.registerMessageHandler(`GCL`,async(e,t)=>this._getWorkerSource(e,t.type,t.source).getClusterLeaves(t)),this.actor.registerMessageHandler(`LD`,(e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t)),this.actor.registerMessageHandler(`LT`,(e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t)),this.actor.registerMessageHandler(`RT`,(e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t)),this.actor.registerMessageHandler(`AT`,(e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t)),this.actor.registerMessageHandler(`RMT`,(e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t)),this.actor.registerMessageHandler(`RS`,async(e,t)=>{if(!this.workerSources[e]?.[t.type]?.[t.source])return;let n=this.workerSources[e][t.type][t.source];delete this.workerSources[e][t.type][t.source],n.removeSource!==void 0&&n.removeSource(t)}),this.actor.registerMessageHandler(`RM`,async e=>{delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],this.globalStates.delete(e)}),this.actor.registerMessageHandler(`SR`,async(e,t)=>{this.referrer=t}),this.actor.registerMessageHandler(`SRPS`,(e,t)=>this._syncRTLPluginState(e,t)),this.actor.registerMessageHandler(`IS`,async(e,t)=>{await Q(t)}),this.actor.registerMessageHandler(`SI`,(e,t)=>this._setImages(e,t)),this.actor.registerMessageHandler(`UL`,async(e,t)=>{this._getLayerIndex(e).update(t.layers,t.removedIds,this._getGlobalState(e))}),this.actor.registerMessageHandler(`UGS`,async(e,t)=>{let n=this._getGlobalState(e);for(let e in t)n[e]=t[e]}),this.actor.registerMessageHandler(`SL`,async(e,t)=>{this._getLayerIndex(e).replace(t,this._getGlobalState(e))})}_getGlobalState(e){let t=this.globalStates.get(e);return t||(t={},this.globalStates.set(e,t)),t}async _setImages(e,t){this.availableImages[e]=t;for(let n in this.workerSources[e]){let r=this.workerSources[e][n];for(let e in r)r[e].availableImages=t}}async _syncRTLPluginState(e,t){return await L.syncState(t,Q)}_getAvailableImages(e){let t=this.availableImages[e];return t||=[],t}_getLayerIndex(e){let t=this.layerIndexes[e];return t||=this.layerIndexes[e]=new H,t}_getWorkerSource(e,t,n){if(this.workerSources[e]||={},this.workerSources[e][t]||={},!this.workerSources[e][t][n]){let r={sendAsync:(t,n)=>(t.targetMapId=e,this.actor.sendAsync(t,n))};switch(t){case`vector`:this.workerSources[e][t][n]=new oe(r,this._getLayerIndex(e),this._getAvailableImages(e));break;case`geojson`:this.workerSources[e][t][n]=new se(r,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][n]=new this.externalWorkerSourceTypes[t](r,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][t][n]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||={},this.demWorkerSources[e][t]||=new X,this.demWorkerSources[e][t]}};z(self)&&(self.worker=new $(self));export{$ as default};
|
|
5
|
+
import{B as e,Bn as t,D as n,Dn as r,Dt as i,Et as a,Fn as o,I as s,K as c,Nn as l,On as u,P as d,Rn as f,S as p,U as m,Ur as h,Vi as g,Vt as ee,W as _,an as v,bt as y,c as b,d as x,fr as S,g as C,i as w,ir as T,jn as E,l as D,m as O,mn as k,mr as A,mt as j,n as M,nn as N,o as te,or as P,p as ne,tn as re,ut as F,vn as I,x as L,xr as R,yn as z,yr as B,zr as V}from"./maplibre-gl-shared.mjs";var H=class{constructor(e,t){this.keyCache={},e&&this.replace(e,t)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(e,t,n){for(let t of e){this._layerConfigs[t.id]=t;let e=this._layers[t.id]=p(t,n);e._featureFilter=I(e.filter,`layers[${t.id}].filter`,n),this.keyCache[t.id]&&delete this.keyCache[t.id]}for(let e of t)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};let r=z(Object.values(this._layerConfigs),this.keyCache);for(let e of r){let t=e.map(e=>this._layers[e.id]),n=t[0];if(n.isHidden())continue;let r=n.source||``,i=this.familiesBySource[r];i||=this.familiesBySource[r]={};let a=n.sourceLayer||`_geojsonTileLayer`,o=i[a];o||=i[a]=[],o.push(t)}}},U=class{constructor(e){let t={},n=[];for(let r in e){let i=e[r],a=t[r]={};for(let e in i){let t=i[+e];if(!t||t.bitmap.width===0||t.bitmap.height===0)continue;let r={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};n.push(r),a[e]={rect:r,metrics:t.metrics}}}let{w:r,h:i}=s(n),o=new a({width:r||1,height:i||1});for(let n in e){let r=e[n];for(let e in r){let i=r[+e];if(!i||i.bitmap.width===0||i.bitmap.height===0)continue;let s=t[n][e].rect;a.copy(i.bitmap,o,{x:0,y:0},{x:s.x+1,y:s.y+1},i.bitmap)}}this.image=o,this.positions=t}};v(`GlyphAtlas`,U);var W=class{constructor(e){this.tileID=new C(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.uid=e.uid,this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId,this.inFlightDependencies=[]}async parse(e,t,r,i,a){this.data=e,this.collisionBoxArray=new ee;let o=new x(Object.keys(e.layers).sort()),s=new b(this.tileID,this.promoteId);s.bucketLayerIDs=[];let l={},u={featureIndex:s,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:r,subdivisionGranularity:a},f=t.familiesBySource[this.source];for(let t in f){let n=e.layers[t];if(!n)continue;n.version===1&&V(`Vector tile source "${this.source}" layer "${t}" does not use vector tile spec v2 and therefore may have some rendering errors.`);let i=o.encode(t),a=[];for(let e=0;e<n.length;e++){let r=n.feature(e),o=s.getId(r,t);a.push({feature:r,id:o,index:e,sourceLayerIndex:i})}for(let e of f[t]){let t=e[0];t.source!==this.source&&V(`layer.source = ${t.source} does not equal this.source = ${this.source}`),!t.isHidden(this.zoom,!0)&&(G(e,this.zoom,r),(l[t.id]=t.createBucket({index:s.bucketLayerIDs.length,layers:e,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:i,sourceID:this.source})).populate(a,u,this.tileID.canonical),s.bucketLayerIDs.push(e.map(e=>e.id)))}}let p=R(u.glyphDependencies,e=>Object.keys(e).map(Number));for(let e of this.inFlightDependencies)e?.abort();this.inFlightDependencies=[];let h=Promise.resolve({});if(Object.keys(p).length){let e=new AbortController;this.inFlightDependencies.push(e),h=i.sendAsync({type:`GG`,data:{stacks:p,source:this.source,tileID:this.tileID,type:`glyphs`}},e)}let g=Object.keys(u.iconDependencies),_=Promise.resolve({});if(g.length){let e=new AbortController;this.inFlightDependencies.push(e),_=i.sendAsync({type:`GI`,data:{icons:g,source:this.source,tileID:this.tileID,type:`icons`}},e)}let v=Object.keys(u.patternDependencies),y=Promise.resolve({});if(v.length){let e=new AbortController;this.inFlightDependencies.push(e),y=i.sendAsync({type:`GI`,data:{icons:v,source:this.source,tileID:this.tileID,type:`patterns`}},e)}let S=u.dashDependencies,C=Promise.resolve({});if(Object.keys(S).length){let e=new AbortController;this.inFlightDependencies.push(e),C=i.sendAsync({type:`GDA`,data:{dashes:S}},e)}let[w,T,E,D]=await Promise.all([h,_,y,C]),O=new U(w),k=new d(T,E);for(let e in l){let t=l[e];t instanceof n?(G(t.layers,this.zoom,r),M({bucket:t,glyphMap:w,glyphPositions:O.positions,imageMap:T,imagePositions:k.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:u.subdivisionGranularity})):t.hasDependencies&&(t instanceof j||t instanceof c||t instanceof m)&&(G(t.layers,this.zoom,r),t.addFeatures(u,this.tileID.canonical,k.patternPositions,D))}return{buckets:Object.values(l).filter(e=>!e.isEmpty()),featureIndex:s,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:O.image,imageAtlas:k,dashPositions:D,glyphMap:this.returnDependencies?w:null,iconMap:this.returnDependencies?T:null,glyphPositions:this.returnDependencies?O.positions:null}}};function G(e,t,n){let r=new re(t);for(let t of e)t.recalculate(r,n)}var K=class{constructor(){this.loading={},this.loaded={},this.parsing={}}startLoading(e,t){this.loading[e]=t}finishLoading(e){delete this.loading[e]}abort(e){let t=this.loading[e];t?.abort&&(t.abort.abort(),delete this.loading[e])}getParsing(e){return this.parsing[e]}setParsing(e,t){this.parsing[e]=t}removeParsing(e){delete this.parsing[e]}markLoaded(e,t){this.loaded[e]=t}getLoaded(e){let t=this.loaded[e];if(t)return t}removeLoaded(e){delete this.loaded[e]}clearLoaded(){this.loaded={}}},q=class{constructor(e){this.start=`${e}#start`,this.end=`${e}#end`,this.measure=e,performance.mark(this.start)}finish(){performance.mark(this.end);let e=performance.getEntriesByName(this.measure);return e.length===0&&(performance.measure(this.measure,this.start,this.end),e=performance.getEntriesByName(this.measure),performance.clearMarks(this.start),performance.clearMarks(this.end),performance.clearMeasures(this.measure)),e}},J=class{constructor(e,t,n,r,i){this.type=e,this.properties=n||{},this.extent=i,this.pointsArray=t,this.id=r}loadGeometry(){return this.pointsArray.map(e=>e.map(e=>new g(e.x,e.y)))}},Y=class{constructor(e,t,n){this.version=2,this._myFeatures=e,this.name=t,this.length=e.length,this.extent=n}feature(e){return this._myFeatures[e]}},X=class{constructor(){this.layers={}}addLayer(e){this.layers[e.name]=e}};function ie(e,t,n){let{extent:r}=e,i=2**(n.z-t.z),a=(n.x-t.x*i)*r,o=(n.y-t.y*i)*r,s=[];for(let t=0;t<e.length;t++){let n=e.feature(t),c=n.loadGeometry();for(let e of c)for(let t of e)t.x=t.x*i-a,t.y=t.y*i-o;c=w(c,n.type,-128,-128,r+128,r+128),c.length!==0&&s.push(new J(n.type,c,n.properties,n.id,r))}return new Y(s,e.name,r)}var ae=class{constructor(e,t,n){this.actor=e,this.layerIndex=t,this.availableImages=n,this.tileState=new K,this.overzoomedTileResultCache=new te(1e3)}loadVectorTile(t,n){try{return{vectorTile:t.encoding===`mlt`?new D(n):new F(new e(n)),rawData:n}}catch(e){let r=new Uint8Array(n),i=r[0]===31&&r[1]===139,a=`Unable to parse the tile at ${t.request.url}, `;throw a+=i?`please make sure the data is not gzipped and that you have configured the relevant header in the server`:`got error: ${T(e).message}`,Error(a)}}async loadTile(e){let{uid:t,overzoomParameters:n}=e;n&&(e.request=n.overzoomRequest);let i=this._startRequestTiming(e),a=new W(e);this.tileState.startLoading(t,a);let o=new AbortController;a.abort=o;try{let s=await r(e.request,o);if(e.etag&&e.etag===s.etag)return this.tileState.finishLoading(t),this._getEtagUnmodifiedResult(s,i);let c=this.loadVectorTile(e,s.data);if(this.tileState.finishLoading(t),!c)return null;let{vectorTile:l,rawData:u}=c;n&&({vectorTile:l,rawData:u}=this._getOverzoomTile(e,l));let d=this._getExpiryData(s),f=this._finishRequestTiming(i);a.vectorTile=l,this.tileState.markLoaded(t,a);let p={rawData:u,cacheControl:d,resourceTiming:f};return this.tileState.setParsing(t,p),await this._parseWorkerTile(a,e)}catch(e){throw this.tileState.finishLoading(t),this.tileState.markLoaded(t,a),e}}_getEtagUnmodifiedResult(e,t){let n=this._getExpiryData(e),r=this._finishRequestTiming(t);return P({etagUnmodified:!0},n,r)}async _parseWorkerTile(e,t){let n=this.tileState.getParsing(e.uid),r=await e.parse(e.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);if(n){let{rawData:i,cacheControl:a,resourceTiming:o}=n,s=t.overzoomParameters?`mvt`:t.encoding;r=P({rawTileData:i.slice(0),encoding:s},r,a,o),this.tileState.removeParsing(e.uid)}return r}_getExpiryData({expires:e,cacheControl:t,etag:n}){let r={};return e&&(r.expires=e),t&&(r.cacheControl=t),n&&(r.etag=n),r}_startRequestTiming(e){if(e.request?.collectResourceTiming)return new q(e.request.url)}_finishRequestTiming(e){let t=e?.finish();return t?{resourceTiming:JSON.parse(JSON.stringify(t))}:{}}_getOverzoomTile(e,t){let{tileID:n,source:r,overzoomParameters:i}=e,{maxZoomTileID:a}=i,o=`${a.key}_${n.key}_${e.request?.url}`,s=this.overzoomedTileResultCache.get(o);if(s)return s;let c=new X,l=this.layerIndex.familiesBySource[r];for(let e in l){let r=t.layers[e];if(!r)continue;let i=ie(r,a,n.canonical);i.length>0&&c.addLayer(i)}let u={vectorTile:c,rawData:O(c).buffer};return this.overzoomedTileResultCache.set(o,u),u}async reloadTile(e){let t=e.uid,n=this.tileState.getLoaded(t);if(!n)throw Error(`Should not be trying to reload a tile that was never loaded or has been removed`);if(n.vectorTile)return n.showCollisionBoxes=e.showCollisionBoxes,await this._parseWorkerTile(n,e)}async abortTile(e){this.tileState.abort(e.uid)}async removeTile(e){this.tileState.removeLoaded(e.uid)}},oe=class{constructor(){this.loaded={}}async loadTile(e){let{uid:t,encoding:n,rawImageData:r,redFactor:a,greenFactor:o,blueFactor:s,baseShift:c}=e,l=r.width+2,u=r.height+2,d=A(r)?new i({width:l,height:u},await S(r,-1,-1,l,u)):r,f=new y(t,d,n,a,o,s,c);return this.loaded||={},this.loaded[t]=f,f}removeTile(e){let t=this.loaded,n=e.uid;t?.[n]&&delete t[n]}},se=class{constructor(e,t,n,r=ce){this.actor=e,this.layerIndex=t,this.availableImages=n,this.tileState=new K,this._createGeoJSONIndex=r}loadVectorTile(e){if(!this._geoJSONIndex)throw Error(`Unable to parse the data into a cluster or geojson`);let{z:n,x:r,y:i}=e.tileID.canonical,a=this._geoJSONIndex.getTile(n,r,i);if(!a)return null;let o=new ne(a.features,{version:2,extent:h});return{vectorTile:o,rawData:O(o,t).buffer}}async loadTile(e){let{uid:t}=e,n=new W(e);n.abort=new AbortController;try{let r=this.loadVectorTile(e);if(!r)return null;let{vectorTile:i,rawData:a}=r;n.vectorTile=i,this.tileState.markLoaded(t,n);let o={rawData:a};return this.tileState.setParsing(t,o),await this._parseWorkerTile(n,e)}catch(e){throw this.tileState.markLoaded(t,n),e}}async _parseWorkerTile(e,t){let n=this.tileState.getParsing(e.uid),r=await e.parse(e.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);if(n){let{rawData:t}=n;r=P({rawTileData:t.slice(0),encoding:`mvt`},r),this.tileState.removeParsing(e.uid)}return r}async abortTile(e){this.tileState.abort(e.uid)}async removeTile(e){this.tileState.removeLoaded(e.uid)}async loadData(e){this._pendingRequest?.abort();let t=this._startRequestTiming(e);this._pendingRequest=new AbortController;try{await this.loadAndProcessGeoJSON(e,this._pendingRequest),delete this._pendingRequest,this.tileState.clearLoaded();let n={};return e.request&&(n.data=e.data),this._finishRequestTiming(t,e,n),n}catch(e){if(delete this._pendingRequest,!f(e))throw e;return{abandoned:!0}}}_startRequestTiming(e){if(e.request?.collectResourceTiming)return new q(e.request.url)}_finishRequestTiming(e,t,n){let r=e?.finish();r&&(n.resourceTiming={[t.source]:JSON.parse(JSON.stringify(r))})}async reloadTile(e){let t=e.uid,n=this.tileState.getLoaded(t);if(!n)return await this.loadTile(e);if(n.vectorTile)return n.showCollisionBoxes=e.showCollisionBoxes,await this._parseWorkerTile(n,e)}async loadAndProcessGeoJSON(e,t){if(e.request&&(e.data=(await u(e.request,t)).data),e.data){e.data=this._filterGeoJSON(e.data,e.filter,e.source),this._geoJSONIndex=this._createGeoJSONIndex(e.data,e);return}if(e.dataDiff){this._geoJSONIndex??=this._createGeoJSONIndex({type:`FeatureCollection`,features:[]},e),this._geoJSONIndex.updateData(e.dataDiff,this._getFilterPredicate(e.filter,e.source));return}if(e.updateCluster&&this._geoJSONIndex.updateClusterOptions(e.geojsonVtOptions.cluster,Z(e)),this._geoJSONIndex==null)throw Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`)}_filterGeoJSON(e,t,n){if(e.type!==`FeatureCollection`)return e;let r=this._getFilterPredicate(t,n);return r?{type:`FeatureCollection`,features:e.features.filter(e=>r(e))}:e}_getFilterPredicate(e,t){if(typeof e!=`boolean`&&!e?.length)return;let n=k(e,`sources.${t}.filter`,{type:`boolean`,"property-type":`data-driven`,overridable:!1,transition:!1});if(n.result===`error`)throw Error(n.value.map(e=>`${e.key}: ${e.message}`).join(`, `));return e=>n.value.evaluate({zoom:0},e)}async removeSource(e){this._pendingRequest?.abort()}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getClusterChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getClusterLeaves(e.clusterId,e.limit,e.offset)}};function ce(e,t){let n=P(t.geojsonVtOptions||{},{updateable:!0,clusterOptions:Z(t)});return new _(e,n)}function Z({geojsonVtOptions:e,clusterProperties:t,source:n}){if(!t||!e.clusterOptions)return e.clusterOptions;let r={},i={},a={accumulated:null,zoom:0},o={properties:null},s=Object.keys(t);for(let e of s){let[a,o]=t[e],s=k(o,`sources.${n}.clusterProperties.${e}[1]`),c=k(typeof a==`string`?[a,[`accumulated`],[`get`,e]]:a,`sources.${n}.clusterProperties.${e}[0]`);r[e]=s.value,i[e]=c.value}return e.clusterOptions.map=e=>{o.properties=e;let t={};for(let e of s)t[e]=r[e].evaluate(a,o);return t},e.clusterOptions.reduce=(e,t)=>{o.properties=t;for(let t of s)a.accumulated=e[t],e[t]=i[t].evaluate(a,o)},e.clusterOptions}async function Q(e){if(e.endsWith(`.mjs`)){await import(e);return}let t=await fetch(e,{credentials:`same-origin`});if(!t.ok)throw Error(`Failed to load ${e}: ${t.status}`);let n=await t.text();if(/^[ \t]*(import|export)\s/m.test(n)){let e=URL.createObjectURL(new Blob([n],{type:`text/javascript`}));try{await import(e)}finally{URL.revokeObjectURL(e)}return}globalThis.eval(n)}var $=class{constructor(e){this.self=e,this.actor=new L(e),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t},this.self.addProtocol=l,this.self.removeProtocol=o,this.self.registerRTLTextPlugin=e=>{N.setMethods(e)},this.self.makeRequest=E,this.actor.registerMessageHandler(`LDT`,(e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t)),this.actor.registerMessageHandler(`RDT`,async(e,t)=>{this._getDEMWorkerSource(e,t.source).removeTile(t)}),this.actor.registerMessageHandler(`GCEZ`,async(e,t)=>this._getWorkerSource(e,t.type,t.source).getClusterExpansionZoom(t)),this.actor.registerMessageHandler(`GCC`,async(e,t)=>this._getWorkerSource(e,t.type,t.source).getClusterChildren(t)),this.actor.registerMessageHandler(`GCL`,async(e,t)=>this._getWorkerSource(e,t.type,t.source).getClusterLeaves(t)),this.actor.registerMessageHandler(`LD`,(e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t)),this.actor.registerMessageHandler(`LT`,(e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t)),this.actor.registerMessageHandler(`RT`,(e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t)),this.actor.registerMessageHandler(`AT`,(e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t)),this.actor.registerMessageHandler(`RMT`,(e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t)),this.actor.registerMessageHandler(`RS`,async(e,t)=>{if(!this.workerSources[e]?.[t.type]?.[t.source])return;let n=this.workerSources[e][t.type][t.source];delete this.workerSources[e][t.type][t.source],n.removeSource!==void 0&&n.removeSource(t)}),this.actor.registerMessageHandler(`RM`,async e=>{delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],this.globalStates.delete(e)}),this.actor.registerMessageHandler(`SR`,async(e,t)=>{this.referrer=t}),this.actor.registerMessageHandler(`SRPS`,(e,t)=>this._syncRTLPluginState(e,t)),this.actor.registerMessageHandler(`IS`,async(e,t)=>{await Q(t)}),this.actor.registerMessageHandler(`SI`,(e,t)=>this._setImages(e,t)),this.actor.registerMessageHandler(`UL`,async(e,t)=>{this._getLayerIndex(e).update(t.layers,t.removedIds,this._getGlobalState(e))}),this.actor.registerMessageHandler(`UGS`,async(e,t)=>{let n=this._getGlobalState(e);for(let e in t)n[e]=t[e]}),this.actor.registerMessageHandler(`SL`,async(e,t)=>{this._getLayerIndex(e).replace(t,this._getGlobalState(e))})}_getGlobalState(e){let t=this.globalStates.get(e);return t||(t={},this.globalStates.set(e,t)),t}async _setImages(e,t){this.availableImages[e]=t;for(let n in this.workerSources[e]){let r=this.workerSources[e][n];for(let e in r)r[e].availableImages=t}}async _syncRTLPluginState(e,t){return await N.syncState(t,Q)}_getAvailableImages(e){let t=this.availableImages[e];return t||=[],t}_getLayerIndex(e){let t=this.layerIndexes[e];return t||=this.layerIndexes[e]=new H,t}_getWorkerSource(e,t,n){if(this.workerSources[e]||={},this.workerSources[e][t]||={},!this.workerSources[e][t][n]){let r={sendAsync:(t,n)=>(t.targetMapId=e,this.actor.sendAsync(t,n))};switch(t){case`vector`:this.workerSources[e][t][n]=new ae(r,this._getLayerIndex(e),this._getAvailableImages(e));break;case`geojson`:this.workerSources[e][t][n]=new se(r,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][n]=new this.externalWorkerSourceTypes[t](r,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][t][n]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||={},this.demWorkerSources[e][t]||=new oe,this.demWorkerSources[e][t]}};B(self)&&(self.worker=new $(self));export{$ as default};
|
|
6
6
|
//# sourceMappingURL=maplibre-gl-worker.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maplibre-gl-worker.mjs","names":[],"sources":["../src/style/style_layer_index.ts","../src/render/glyph_atlas.ts","../src/source/worker_tile.ts","../src/source/worker_tile_state.ts","../src/util/request_performance.ts","../src/source/vector_tile_overzoomed.ts","../src/source/vector_tile_worker_source.ts","../src/source/raster_dem_tile_worker_source.ts","../src/source/geojson_worker_source.ts","../src/source/worker.ts"],"sourcesContent":["import {createStyleLayer} from './create_style_layer.ts';\nimport {featureFilter, groupByLayout} from '@maplibre/maplibre-gl-style-spec';\nimport {GEOJSON_TILE_LAYER_NAME} from '../data/feature_index.ts';\nimport type {StyleLayer} from './style_layer.ts';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type LayerConfigs = {[_: string]: LayerSpecification};\n\nexport class StyleLayerIndex {\n familiesBySource: {\n [source: string]: {\n [sourceLayer: string]: StyleLayer[][];\n };\n };\n keyCache: {[source: string]: string};\n\n _layerConfigs: LayerConfigs;\n _layers: {[_: string]: StyleLayer};\n\n constructor(layerConfigs?: LayerSpecification[] | null, globalState?: Record<string, any>) {\n this.keyCache = {};\n if (layerConfigs) {\n this.replace(layerConfigs, globalState);\n }\n }\n\n replace(layerConfigs: LayerSpecification[], globalState?: Record<string, any>): void {\n this._layerConfigs = {};\n this._layers = {};\n this.update(layerConfigs, [], globalState);\n }\n\n update(layerConfigs: LayerSpecification[], removedIds: string[], globalState?: Record<string, any>): void {\n for (const layerConfig of layerConfigs) {\n this._layerConfigs[layerConfig.id] = layerConfig;\n\n const layer = this._layers[layerConfig.id] = createStyleLayer(layerConfig, globalState);\n layer._featureFilter = featureFilter(layer.filter, `layers[${layerConfig.id}].filter`, globalState);\n if (this.keyCache[layerConfig.id])\n delete this.keyCache[layerConfig.id];\n }\n for (const id of removedIds) {\n delete this.keyCache[id];\n delete this._layerConfigs[id];\n delete this._layers[id];\n }\n\n this.familiesBySource = {};\n\n const groups = groupByLayout(Object.values(this._layerConfigs), this.keyCache);\n\n for (const layerConfigs of groups) {\n const layers = layerConfigs.map((layerConfig) => this._layers[layerConfig.id]);\n\n const layer = layers[0];\n if (layer.isHidden()) {\n continue;\n }\n\n const sourceId = layer.source || '';\n let sourceGroup = this.familiesBySource[sourceId];\n sourceGroup ||= this.familiesBySource[sourceId] = {};\n\n const sourceLayerId = layer.sourceLayer || GEOJSON_TILE_LAYER_NAME;\n let sourceLayerFamilies = sourceGroup[sourceLayerId];\n sourceLayerFamilies ||= sourceGroup[sourceLayerId] = [];\n\n sourceLayerFamilies.push(layers);\n }\n }\n}\n","import {AlphaImage} from '../util/image.ts';\nimport {register} from '../util/web_worker_transfer.ts';\nimport potpack from 'potpack';\n\nimport type {GlyphMetrics} from '../style/style_glyph.ts';\nimport type {GetGlyphsResponse} from '../util/actor_messages.ts';\n\nconst padding = 1;\n\n/**\n * A rectangle type with position, width and height.\n */\nexport type Rect = {\n x: number;\n y: number;\n w: number;\n h: number;\n};\n\n/**\n * The glyph's position\n */\nexport type GlyphPosition = {\n rect: Rect;\n metrics: GlyphMetrics;\n};\n\n/**\n * The glyphs' positions\n */\nexport type GlyphPositions = {\n [_: string]: {\n [_: number]: GlyphPosition;\n };\n};\n\nexport class GlyphAtlas {\n image: AlphaImage;\n positions: GlyphPositions;\n\n constructor(stacks: GetGlyphsResponse) {\n const positions = {};\n const bins = [];\n\n for (const stack in stacks) {\n const glyphs = stacks[stack];\n const stackPositions = positions[stack] = {};\n\n for (const id in glyphs) {\n const src = glyphs[+id];\n if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue;\n\n const bin = {\n x: 0,\n y: 0,\n w: src.bitmap.width + 2 * padding,\n h: src.bitmap.height + 2 * padding\n };\n bins.push(bin);\n stackPositions[id] = {rect: bin, metrics: src.metrics};\n }\n }\n\n const {w, h} = potpack(bins);\n const image = new AlphaImage({width: w || 1, height: h || 1});\n\n for (const stack in stacks) {\n const glyphs = stacks[stack];\n\n for (const id in glyphs) {\n const src = glyphs[+id];\n if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue;\n const bin = positions[stack][id].rect;\n AlphaImage.copy(src.bitmap, image, {x: 0, y: 0}, {x: bin.x + padding, y: bin.y + padding}, src.bitmap);\n }\n }\n\n this.image = image;\n this.positions = positions;\n }\n}\n\nregister('GlyphAtlas', GlyphAtlas);\n","import {FeatureIndex} from '../data/feature_index.ts';\nimport {performSymbolLayout} from '../symbol/symbol_layout.ts';\nimport {CollisionBoxArray} from '../data/array_types.g.ts';\nimport {DictionaryCoder} from '../util/dictionary_coder.ts';\nimport {SymbolBucket} from '../data/bucket/symbol_bucket.ts';\nimport {LineBucket} from '../data/bucket/line_bucket.ts';\nimport {FillBucket} from '../data/bucket/fill_bucket.ts';\nimport {FillExtrusionBucket} from '../data/bucket/fill_extrusion_bucket.ts';\nimport {warnOnce, mapObject} from '../util/util.ts';\nimport {ImageAtlas} from '../render/image_atlas.ts';\nimport {GlyphAtlas} from '../render/glyph_atlas.ts';\nimport {EvaluationParameters} from '../style/evaluation_parameters.ts';\nimport {OverscaledTileID} from '../tile/tile_id.ts';\n\nimport type {Bucket} from '../data/bucket.ts';\nimport type {IActor} from '../util/actor.ts';\nimport type {StyleLayer} from '../style/style_layer.ts';\nimport type {StyleLayerIndex} from '../style/style_layer_index.ts';\nimport type {\n WorkerTileParameters,\n WorkerTileResult,\n} from './worker_source.ts';\nimport type {PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {VectorTileLike} from '@maplibre/vt-pbf';\nimport {type GetDashesResponse, MessageType, type GetGlyphsResponse, type GetImagesResponse} from '../util/actor_messages.ts';\nimport type {SubdivisionGranularitySetting} from '../render/subdivision_granularity_settings.ts';\nexport class WorkerTile {\n tileID: OverscaledTileID;\n uid: string | number;\n zoom: number;\n pixelRatio: number;\n tileSize: number;\n source: string;\n promoteId: PromoteIdSpecification;\n overscaling: number;\n showCollisionBoxes: boolean;\n collectResourceTiming: boolean;\n returnDependencies: boolean;\n\n data: VectorTileLike;\n collisionBoxArray: CollisionBoxArray;\n\n abort: AbortController;\n vectorTile: VectorTileLike;\n inFlightDependencies: AbortController[];\n\n constructor(params: WorkerTileParameters) {\n this.tileID = new OverscaledTileID(params.tileID.overscaledZ, params.tileID.wrap, params.tileID.canonical.z, params.tileID.canonical.x, params.tileID.canonical.y);\n this.uid = params.uid;\n this.zoom = params.zoom;\n this.pixelRatio = params.pixelRatio;\n this.tileSize = params.tileSize;\n this.source = params.source;\n this.overscaling = this.tileID.overscaleFactor();\n this.showCollisionBoxes = params.showCollisionBoxes;\n this.collectResourceTiming = !!params.collectResourceTiming;\n this.returnDependencies = !!params.returnDependencies;\n this.promoteId = params.promoteId;\n this.inFlightDependencies = [];\n }\n\n async parse(data: VectorTileLike, layerIndex: StyleLayerIndex, availableImages: string[], actor: IActor, subdivisionGranularity: SubdivisionGranularitySetting): Promise<WorkerTileResult> {\n this.data = data;\n\n this.collisionBoxArray = new CollisionBoxArray();\n const sourceLayerCoder = new DictionaryCoder(Object.keys(data.layers).sort());\n\n const featureIndex = new FeatureIndex(this.tileID, this.promoteId);\n featureIndex.bucketLayerIDs = [];\n\n const buckets: {[_: string]: Bucket} = {};\n\n const options = {\n featureIndex,\n iconDependencies: {},\n patternDependencies: {},\n glyphDependencies: {},\n dashDependencies: {},\n availableImages,\n subdivisionGranularity\n };\n\n const layerFamilies = layerIndex.familiesBySource[this.source];\n for (const sourceLayerId in layerFamilies) {\n const sourceLayer = data.layers[sourceLayerId];\n if (!sourceLayer) {\n continue;\n }\n\n if (sourceLayer.version === 1) {\n warnOnce(`Vector tile source \"${this.source}\" layer \"${sourceLayerId}\" ` +\n 'does not use vector tile spec v2 and therefore may have some rendering errors.');\n }\n\n const sourceLayerIndex = sourceLayerCoder.encode(sourceLayerId);\n const features = [];\n for (let index = 0; index < sourceLayer.length; index++) {\n const feature = sourceLayer.feature(index);\n const id = featureIndex.getId(feature, sourceLayerId);\n features.push({feature, id, index, sourceLayerIndex});\n }\n\n for (const family of layerFamilies[sourceLayerId]) {\n const layer = family[0];\n\n if (layer.source !== this.source) {\n warnOnce(`layer.source = ${layer.source} does not equal this.source = ${this.source}`);\n }\n if (layer.isHidden(this.zoom, true)) continue;\n recalculateLayers(family, this.zoom, availableImages);\n\n const bucket = buckets[layer.id] = layer.createBucket({\n index: featureIndex.bucketLayerIDs.length,\n layers: family,\n zoom: this.zoom,\n pixelRatio: this.pixelRatio,\n overscaling: this.overscaling,\n collisionBoxArray: this.collisionBoxArray,\n sourceLayerIndex,\n sourceID: this.source\n });\n\n bucket.populate(features, options, this.tileID.canonical);\n featureIndex.bucketLayerIDs.push(family.map((l) => l.id));\n }\n }\n\n // options.glyphDependencies looks like: {\"SomeFontName\":{\"10\":true,\"32\":true}}\n // this line makes an object like: {\"SomeFontName\":[10,32]}\n const stacks: {[_: string]: number[]} = mapObject(options.glyphDependencies, (glyphs) => Object.keys(glyphs).map(Number));\n\n for (const request of this.inFlightDependencies) {\n request?.abort();\n }\n this.inFlightDependencies = [];\n\n let getGlyphsPromise = Promise.resolve<GetGlyphsResponse>({});\n if (Object.keys(stacks).length) {\n const abortController = new AbortController();\n this.inFlightDependencies.push(abortController);\n getGlyphsPromise = actor.sendAsync({type: MessageType.getGlyphs, data: {stacks, source: this.source, tileID: this.tileID, type: 'glyphs'}}, abortController);\n }\n\n const icons = Object.keys(options.iconDependencies);\n let getIconsPromise = Promise.resolve<GetImagesResponse>({});\n if (icons.length) {\n const abortController = new AbortController();\n this.inFlightDependencies.push(abortController);\n getIconsPromise = actor.sendAsync({type: MessageType.getImages, data: {icons, source: this.source, tileID: this.tileID, type: 'icons'}}, abortController);\n }\n\n const patterns = Object.keys(options.patternDependencies);\n let getPatternsPromise = Promise.resolve<GetImagesResponse>({});\n if (patterns.length) {\n const abortController = new AbortController();\n this.inFlightDependencies.push(abortController);\n getPatternsPromise = actor.sendAsync({type: MessageType.getImages, data: {icons: patterns, source: this.source, tileID: this.tileID, type: 'patterns'}}, abortController);\n }\n\n const dashes = options.dashDependencies;\n let getDashesPromise = Promise.resolve<GetDashesResponse>({} as GetDashesResponse);\n if (Object.keys(dashes).length) {\n const abortController = new AbortController();\n this.inFlightDependencies.push(abortController);\n getDashesPromise = actor.sendAsync({type: MessageType.getDashes, data: {dashes}}, abortController);\n }\n\n const [glyphMap, iconMap, patternMap, dashPositions] = await Promise.all([getGlyphsPromise, getIconsPromise, getPatternsPromise, getDashesPromise]);\n\n const glyphAtlas = new GlyphAtlas(glyphMap);\n const imageAtlas = new ImageAtlas(iconMap, patternMap);\n\n for (const key in buckets) {\n const bucket = buckets[key];\n if (bucket instanceof SymbolBucket) {\n recalculateLayers(bucket.layers, this.zoom, availableImages);\n performSymbolLayout({\n bucket,\n glyphMap,\n glyphPositions: glyphAtlas.positions,\n imageMap: iconMap,\n imagePositions: imageAtlas.iconPositions,\n showCollisionBoxes: this.showCollisionBoxes,\n canonical: this.tileID.canonical,\n subdivisionGranularity: options.subdivisionGranularity\n });\n } else if (bucket.hasDependencies && (bucket instanceof FillBucket || bucket instanceof FillExtrusionBucket || bucket instanceof LineBucket)) {\n recalculateLayers(bucket.layers, this.zoom, availableImages);\n bucket.addFeatures(options, this.tileID.canonical, imageAtlas.patternPositions, dashPositions);\n }\n }\n\n return {\n buckets: Object.values(buckets).filter(b => !b.isEmpty()),\n featureIndex,\n collisionBoxArray: this.collisionBoxArray,\n glyphAtlasImage: glyphAtlas.image,\n imageAtlas,\n dashPositions,\n // Only used for benchmarking:\n glyphMap: this.returnDependencies ? glyphMap : null,\n iconMap: this.returnDependencies ? iconMap : null,\n glyphPositions: this.returnDependencies ? glyphAtlas.positions : null\n };\n }\n}\n\nfunction recalculateLayers(layers: readonly StyleLayer[], zoom: number, availableImages: string[]) {\n // Layers are shared and may have been used by a WorkerTile with a different zoom.\n const parameters = new EvaluationParameters(zoom);\n for (const layer of layers) {\n layer.recalculate(parameters, availableImages);\n }\n}\n","import type {WorkerTile} from './worker_tile.ts';\nimport {type ExpiryData} from '../util/ajax.ts';\n\nexport type ParsingState = {\n rawData: ArrayBufferLike;\n cacheControl?: ExpiryData;\n resourceTiming?: any;\n};\n\nexport class WorkerTileState {\n loading: Record<string, WorkerTile> = {};\n loaded: Record<string, WorkerTile> = {};\n parsing: Record<string, ParsingState> = {};\n\n startLoading(uid: string | number, tile: WorkerTile): void {\n this.loading[uid] = tile;\n }\n\n finishLoading(uid: string | number): void {\n delete this.loading[uid];\n }\n\n abort(uid: string | number): void {\n const tile = this.loading[uid];\n if (!tile?.abort) return;\n tile.abort.abort();\n delete this.loading[uid];\n }\n\n getParsing(uid: string | number): ParsingState | undefined {\n return this.parsing[uid];\n }\n\n setParsing(uid: string | number, state: ParsingState): void {\n this.parsing[uid] = state;\n }\n\n removeParsing(uid: string | number): void {\n delete this.parsing[uid];\n }\n\n markLoaded(uid: string | number, tile: WorkerTile): void {\n this.loaded[uid] = tile;\n }\n\n getLoaded(uid: string | number): WorkerTile | undefined {\n const tile = this.loaded[uid];\n if (!tile) return undefined;\n return tile;\n }\n\n removeLoaded(uid: string | number): void {\n delete this.loaded[uid];\n }\n\n clearLoaded(): void {\n this.loaded = {};\n }\n}\n","/**\n * @internal\n * Safe wrapper for the performance resource timing API in web workers with graceful degradation\n */\nexport class RequestPerformance {\n private start: string;\n private end: string;\n private measure: string;\n\n constructor (url: string) {\n this.start = `${url}#start`;\n this.end = `${url}#end`;\n this.measure = url;\n\n performance.mark(this.start);\n }\n\n finish(): PerformanceEntryList {\n performance.mark(this.end);\n let resourceTimingData = performance.getEntriesByName(this.measure);\n\n // fallback if web worker implementation of perf.getEntriesByName returns empty\n if (resourceTimingData.length === 0) {\n performance.measure(this.measure, this.start, this.end);\n resourceTimingData = performance.getEntriesByName(this.measure);\n\n // cleanup\n performance.clearMarks(this.start);\n performance.clearMarks(this.end);\n performance.clearMeasures(this.measure);\n }\n\n return resourceTimingData;\n }\n}\n","import Point from '@mapbox/point-geometry';\nimport {clipGeometry} from '../symbol/clip_line.ts';\nimport type {CanonicalTileID} from '../tile/tile_id.ts';\nimport type {VectorTileFeatureLike, VectorTileLayerLike, VectorTileLike} from '@maplibre/vt-pbf';\n\nclass VectorTileFeatureOverzoomed implements VectorTileFeatureLike {\n pointsArray: Point[][];\n type: VectorTileFeatureLike['type'];\n properties: VectorTileFeatureLike['properties'];\n id: VectorTileFeatureLike['id'];\n extent: VectorTileFeatureLike['extent'];\n\n constructor(\n type: VectorTileFeatureLike['type'],\n geometry: Point[][],\n properties: VectorTileFeatureLike['properties'],\n id: VectorTileFeatureLike['id'],\n extent: VectorTileFeatureLike['extent']\n ) {\n this.type = type;\n this.properties = properties ? properties : {};\n this.extent = extent;\n this.pointsArray = geometry;\n this.id = id;\n }\n\n loadGeometry(): Point[][] {\n // Clone the geometry and ensure all points are Point instances\n return this.pointsArray.map(ring =>\n ring.map(point => new Point(point.x, point.y))\n );\n }\n}\n\nclass VectorTileLayerOverzoomed implements VectorTileLayerLike {\n private _myFeatures: VectorTileFeatureOverzoomed[];\n name: string;\n extent: number;\n version: number = 2;\n length: number;\n\n constructor(features: VectorTileFeatureOverzoomed[], layerName: string, extent: number) {\n this._myFeatures = features;\n this.name = layerName;\n this.length = features.length;\n this.extent = extent;\n }\n\n feature(i: number): VectorTileFeatureLike {\n return this._myFeatures[i];\n }\n}\n\nexport class VectorTileOverzoomed implements VectorTileLike {\n layers: Record<string, VectorTileLayerLike> = {};\n\n addLayer(layer: VectorTileLayerOverzoomed): void {\n this.layers[layer.name] = layer;\n }\n}\n\n/**\n * This function slices a source tile layer into an overzoomed tile layer for a target tile ID.\n * @param sourceLayer - the source tile layer to slice\n * @param maxZoomTileID - the maximum zoom tile ID\n * @param targetTileID - the target tile ID\n * @returns - the overzoomed tile layer\n */\nexport function sliceVectorTileLayer(sourceLayer: VectorTileLayerLike, maxZoomTileID: CanonicalTileID, targetTileID: CanonicalTileID): VectorTileLayerOverzoomed {\n const {extent} = sourceLayer;\n const dz = targetTileID.z - maxZoomTileID.z;\n const scale = Math.pow(2, dz);\n \n // Calculate the target tile's position within the source tile in target coordinate space\n // This ensures all tiles share the same coordinate system\n const offsetX = (targetTileID.x - maxZoomTileID.x * scale) * extent;\n const offsetY = (targetTileID.y - maxZoomTileID.y * scale) * extent;\n\n const featureWrappers: VectorTileFeatureOverzoomed[] = [];\n for (let index = 0; index < sourceLayer.length; index++) {\n const feature: VectorTileFeatureLike = sourceLayer.feature(index);\n let geometry = feature.loadGeometry();\n \n // Transform all coordinates to target tile space\n for (const ring of geometry) {\n for (const point of ring) {\n point.x = point.x * scale - offsetX;\n point.y = point.y * scale - offsetY;\n }\n }\n \n const buffer = 128;\n geometry = clipGeometry(geometry, feature.type, -buffer, -buffer, extent + buffer, extent + buffer);\n if (geometry.length === 0) {\n continue;\n }\n \n featureWrappers.push(new VectorTileFeatureOverzoomed(\n feature.type,\n geometry,\n feature.properties,\n feature.id,\n extent\n ));\n }\n return new VectorTileLayerOverzoomed(featureWrappers, sourceLayer.name, extent);\n}","import {PbfReader} from 'pbf';\nimport {VectorTile} from '@mapbox/vector-tile';\nimport {fromVectorTileJs, type VectorTileLayerLike, type VectorTileLike} from '@maplibre/vt-pbf';\nimport {type ExpiryData, getArrayBuffer} from '../util/ajax.ts';\nimport {WorkerTile} from './worker_tile.ts';\nimport {WorkerTileState} from './worker_tile_state.ts';\nimport {BoundedLRUCache} from '../tile/tile_cache.ts';\nimport {ensureError, extend} from '../util/util.ts';\nimport {RequestPerformance} from '../util/request_performance.ts';\nimport {VectorTileOverzoomed, sliceVectorTileLayer} from './vector_tile_overzoomed.ts';\nimport {MLTVectorTile} from './vector_tile_mlt.ts';\nimport type {\n WorkerSource,\n WorkerTileParameters,\n TileParameters,\n WorkerTileResult\n} from '../source/worker_source.ts';\nimport type {IActor} from '../util/actor.ts';\nimport type {StyleLayer} from '../style/style_layer.ts';\nimport type {StyleLayerIndex} from '../style/style_layer_index.ts';\n\nexport type LoadVectorTileResult = {\n vectorTile: VectorTileLike;\n rawData: ArrayBufferLike;\n};\n\n/**\n * The {@link WorkerSource} implementation that supports {@link VectorTileSource}. This class is\n * used by vector tile sources to perform tile processing operations in a separate worker thread.\n */\nexport class VectorTileWorkerSource implements WorkerSource {\n actor: IActor;\n layerIndex: StyleLayerIndex;\n availableImages: string[];\n tileState: WorkerTileState;\n overzoomedTileResultCache: BoundedLRUCache<string, LoadVectorTileResult>;\n\n constructor(actor: IActor, layerIndex: StyleLayerIndex, availableImages: string[]) {\n this.actor = actor;\n this.layerIndex = layerIndex;\n this.availableImages = availableImages;\n this.tileState = new WorkerTileState();\n this.overzoomedTileResultCache = new BoundedLRUCache<string, LoadVectorTileResult>(1000);\n }\n\n /**\n * Loads a vector tile\n */\n loadVectorTile(params: WorkerTileParameters, rawData: ArrayBuffer): LoadVectorTileResult {\n try {\n const vectorTile = params.encoding !== 'mlt'\n ? new VectorTile(new PbfReader(rawData))\n : new MLTVectorTile(rawData);\n\n return {vectorTile, rawData};\n } catch (ex) {\n const bytes = new Uint8Array(rawData);\n const isGzipped = bytes[0] === 0x1f && bytes[1] === 0x8b;\n let errorMessage = `Unable to parse the tile at ${params.request.url}, `;\n if (isGzipped) {\n errorMessage += 'please make sure the data is not gzipped and that you have configured the relevant header in the server';\n } else {\n errorMessage += `got error: ${ensureError(ex).message}`;\n }\n throw new Error(errorMessage);\n }\n }\n\n /**\n * Implements {@link WorkerSource.loadTile}.\n */\n async loadTile(params: WorkerTileParameters): Promise<WorkerTileResult | null> {\n const {uid, overzoomParameters} = params;\n\n if (overzoomParameters) {\n params.request = overzoomParameters.overzoomRequest;\n }\n\n const timing = this._startRequestTiming(params);\n const workerTile = new WorkerTile(params);\n\n this.tileState.startLoading(uid, workerTile);\n const abortController = new AbortController();\n workerTile.abort = abortController;\n try {\n // Download the tile data from the network.\n const tileResponse = await getArrayBuffer(params.request, abortController);\n\n // Tile data hasn't changed (etag support) - return an unmodified result\n if (params.etag && params.etag === tileResponse.etag) {\n this.tileState.finishLoading(uid);\n return this._getEtagUnmodifiedResult(tileResponse, timing);\n }\n\n const tileResult = this.loadVectorTile(params, tileResponse.data);\n this.tileState.finishLoading(uid);\n if (!tileResult) return null;\n\n let {vectorTile, rawData} = tileResult;\n if (overzoomParameters) {\n ({vectorTile, rawData} = this._getOverzoomTile(params, vectorTile));\n }\n\n const cacheControl = this._getExpiryData(tileResponse);\n const resourceTiming = this._finishRequestTiming(timing);\n\n workerTile.vectorTile = vectorTile;\n this.tileState.markLoaded(uid, workerTile);\n const parsingState = {rawData, cacheControl, resourceTiming};\n this.tileState.setParsing(uid, parsingState);\n\n return await this._parseWorkerTile(workerTile, params);\n } catch (err) {\n this.tileState.finishLoading(uid);\n this.tileState.markLoaded(uid, workerTile);\n throw err;\n }\n }\n\n _getEtagUnmodifiedResult(response: ExpiryData, timing: RequestPerformance): WorkerTileResult {\n const cacheControl = this._getExpiryData(response);\n const resourceTiming = this._finishRequestTiming(timing);\n return extend({etagUnmodified: true as const}, cacheControl, resourceTiming);\n }\n\n async _parseWorkerTile(workerTile: WorkerTile, params: WorkerTileParameters): Promise<WorkerTileResult> {\n const parseState = this.tileState.getParsing(workerTile.uid);\n\n let result = await workerTile.parse(workerTile.vectorTile, this.layerIndex, this.availableImages, this.actor, params.subdivisionGranularity);\n\n // We need to pass rawTileData back to the main thread so that it can be stored in the Tile and FeatureIndex.\n // After the main thread has successfully received and stored rawTileData,\n // we no longer need to store it in the worker or transfer additional copies of it.\n if (parseState) {\n const {rawData, cacheControl, resourceTiming} = parseState;\n // Overzoomed tiles are always re-encoded to MVT protobuf by _getOverzoomTile\n const encoding = params.overzoomParameters ? 'mvt' : params.encoding;\n // Return a copy of rawData to the main thread to avoid clearing the worker's buffer\n result = extend({rawTileData: rawData.slice(0), encoding}, result, cacheControl, resourceTiming);\n this.tileState.removeParsing(workerTile.uid);\n }\n // else: this seems like a missing case where cache control is lost? see #3309\n\n return result;\n }\n\n _getExpiryData({expires, cacheControl, etag}: ExpiryData): ExpiryData {\n const data: ExpiryData = {};\n if (expires) data.expires = expires;\n if (cacheControl) data.cacheControl = cacheControl;\n if (etag) data.etag = etag;\n return data;\n }\n\n _startRequestTiming(params: WorkerTileParameters): RequestPerformance | undefined {\n if (!params.request?.collectResourceTiming) return;\n return new RequestPerformance(params.request.url);\n }\n\n _finishRequestTiming(timing: RequestPerformance): {resourceTiming?: any} {\n const timingData = timing?.finish();\n if (!timingData) return {};\n\n // it's necessary to eval the result of getEntriesByName() here via parse/stringify\n // late evaluation in the main thread causes TypeError: illegal invocation\n return {resourceTiming: JSON.parse(JSON.stringify(timingData))};\n }\n\n /**\n * If we are seeking a tile deeper than the source's max available canonical tile, get the overzoomed tile\n * @param params - the worker tile parameters\n * @param maxZoomVectorTile - the original vector tile at the source's max available canonical zoom\n * @returns the overzoomed tile and its raw data\n */\n private _getOverzoomTile(params: WorkerTileParameters, maxZoomVectorTile: VectorTileLike): LoadVectorTileResult {\n const {tileID, source, overzoomParameters} = params;\n const {maxZoomTileID} = overzoomParameters;\n\n const cacheKey = `${maxZoomTileID.key}_${tileID.key}_${params.request?.url}`;\n const cachedOverzoomTile = this.overzoomedTileResultCache.get(cacheKey);\n\n if (cachedOverzoomTile) {\n return cachedOverzoomTile;\n }\n\n const overzoomedVectorTile = new VectorTileOverzoomed();\n const layerFamilies: Record<string, StyleLayer[][]> = this.layerIndex.familiesBySource[source];\n\n for (const sourceLayerId in layerFamilies) {\n const sourceLayer: VectorTileLayerLike = maxZoomVectorTile.layers[sourceLayerId];\n if (!sourceLayer) {\n continue;\n }\n\n const slicedTileLayer = sliceVectorTileLayer(sourceLayer, maxZoomTileID, tileID.canonical);\n if (slicedTileLayer.length > 0) {\n overzoomedVectorTile.addLayer(slicedTileLayer);\n }\n }\n const overzoomedVectorTileResult = {\n vectorTile: overzoomedVectorTile,\n rawData: fromVectorTileJs(overzoomedVectorTile).buffer\n };\n this.overzoomedTileResultCache.set(cacheKey, overzoomedVectorTileResult);\n\n return overzoomedVectorTileResult;\n }\n\n /**\n * Implements {@link WorkerSource.reloadTile}.\n */\n async reloadTile(params: WorkerTileParameters): Promise<WorkerTileResult> {\n const uid = params.uid;\n const workerTile = this.tileState.getLoaded(uid);\n if (!workerTile) throw new Error('Should not be trying to reload a tile that was never loaded or has been removed');\n\n // If there was no vector tile data on the initial load, don't try to reparse the tile.\n if (!workerTile.vectorTile) {\n return;\n }\n\n workerTile.showCollisionBoxes = params.showCollisionBoxes;\n return await this._parseWorkerTile(workerTile, params);\n }\n\n /**\n * Implements {@link WorkerSource.abortTile}.\n */\n async abortTile(params: TileParameters): Promise<void> {\n this.tileState.abort(params.uid);\n }\n\n /**\n * Implements {@link WorkerSource.removeTile}.\n */\n async removeTile(params: TileParameters): Promise<void> {\n this.tileState.removeLoaded(params.uid);\n }\n}\n","import {DEMData} from '../data/dem_data.ts';\nimport {RGBAImage} from '../util/image.ts';\nimport type {Actor} from '../util/actor.ts';\nimport type {\n WorkerDEMTileParameters,\n TileParameters\n} from './worker_source.ts';\nimport {getImageData, isImageBitmap} from '../util/util.ts';\n\nexport class RasterDEMTileWorkerSource {\n actor: Actor;\n loaded: {[_: string]: DEMData};\n\n constructor() {\n this.loaded = {};\n }\n\n async loadTile(params: WorkerDEMTileParameters): Promise<DEMData | null> {\n const {uid, encoding, rawImageData, redFactor, greenFactor, blueFactor, baseShift} = params;\n const width = rawImageData.width + 2;\n const height = rawImageData.height + 2;\n const imagePixels: RGBAImage | ImageData = isImageBitmap(rawImageData) ?\n new RGBAImage({width, height}, await getImageData(rawImageData, -1, -1, width, height)) :\n rawImageData;\n const dem = new DEMData(uid, imagePixels, encoding, redFactor, greenFactor, blueFactor, baseShift);\n this.loaded ||= {};\n this.loaded[uid] = dem;\n return dem;\n }\n\n removeTile(params: TileParameters): void {\n const loaded = this.loaded,\n uid = params.uid;\n if (loaded?.[uid]) {\n delete loaded[uid];\n }\n }\n}\n","import {getJSON} from '../util/ajax.ts';\nimport {RequestPerformance} from '../util/request_performance.ts';\nimport {fromVectorTileJs, GeoJSONWrapper} from '@maplibre/vt-pbf';\nimport {EXTENT} from '../data/extent.ts';\nimport {GeoJSONVT, type GeoJSONVTOptions} from '@maplibre/geojson-vt';\nimport {createExpression, type FilterSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport {isAbortError} from '../util/abort_error.ts';\nimport {WorkerTile} from './worker_tile.ts';\nimport {WorkerTileState} from './worker_tile_state.ts';\nimport {extend, JSON_PREFIX} from '../util/util.ts';\n\nimport type {GeoJSONSourceDiff} from './geojson_source_diff.ts';\nimport type {WorkerSource, WorkerTileParameters, TileParameters, WorkerTileResult} from './worker_source.ts';\nimport type {LoadVectorTileResult} from './vector_tile_worker_source.ts';\nimport type {RequestParameters} from '../util/ajax.ts';\nimport type {ClusterIDAndSource, GeoJSONWorkerSourceLoadDataResult, RemoveSourceParams} from '../util/actor_messages.ts';\nimport type {IActor} from '../util/actor.ts';\nimport type {StyleLayerIndex} from '../style/style_layer_index.ts';\n\n/**\n * The geojson worker options that can be passed to the worker\n */\nexport type GeoJSONWorkerOptions = {\n source?: string;\n geojsonVtOptions?: GeoJSONVTOptions;\n clusterProperties?: Record<string, [unknown, unknown]>;\n filter?: FilterSpecification;\n collectResourceTiming?: boolean;\n};\n\n/**\n * Parameters needed to load GeoJSON to the worker - must specify either a `request`, `data` or `dataDiff`.\n */\nexport type LoadGeoJSONParameters = GeoJSONWorkerOptions & {\n type: 'geojson';\n /** The geojson source ID. */\n source: string;\n /**\n * Request parameters including a URL to fetch GeoJSON data.\n */\n request?: RequestParameters;\n /**\n * GeoJSON data to set as the source's data.\n */\n data?: GeoJSON.GeoJSON;\n /**\n * GeoJSONSourceDiff to apply to the existing GeoJSON source data.\n */\n dataDiff?: GeoJSONSourceDiff;\n /**\n * Update the supercluster using the latest worker cluster options.\n */\n updateCluster?: boolean;\n};\n\n/**\n * The {@link WorkerSource} implementation that supports {@link GeoJSONSource}.\n * This class is designed to be easily reused to support custom source types\n * for data formats that can be parsed/converted into an in-memory GeoJSON\n * representation. To do so, create it with\n * `new GeoJSONWorkerSource(actor, layerIndex, customLoadGeoJSONFunction)`.\n * For a full example, see [mapbox-gl-topojson](https://github.com/developmentseed/mapbox-gl-topojson).\n */\nexport class GeoJSONWorkerSource implements WorkerSource {\n actor: IActor;\n layerIndex: StyleLayerIndex;\n availableImages: string[];\n tileState: WorkerTileState;\n\n _pendingRequest: AbortController;\n _geoJSONIndex: GeoJSONVT;\n _createGeoJSONIndex: typeof createGeoJSONIndex;\n\n constructor(actor: IActor, layerIndex: StyleLayerIndex, availableImages: string[], createGeoJSONIndexFunc: typeof createGeoJSONIndex = createGeoJSONIndex) {\n this.actor = actor;\n this.layerIndex = layerIndex;\n this.availableImages = availableImages;\n this.tileState = new WorkerTileState();\n this._createGeoJSONIndex = createGeoJSONIndexFunc;\n }\n\n /**\n * Retrieves and sends loaded vector tiles to the main thread.\n */\n loadVectorTile(params: WorkerTileParameters): LoadVectorTileResult | null {\n if (!this._geoJSONIndex) throw new Error('Unable to parse the data into a cluster or geojson');\n\n const {z, x, y} = params.tileID.canonical;\n const geoJSONTile = this._geoJSONIndex.getTile(z, x, y);\n if (!geoJSONTile) return null;\n\n const geojsonWrapper = new GeoJSONWrapper(geoJSONTile.features, {version: 2, extent: EXTENT});\n return {\n vectorTile: geojsonWrapper,\n rawData: fromVectorTileJs(geojsonWrapper, JSON_PREFIX).buffer\n };\n\n }\n\n /**\n * Implements {@link WorkerSource.loadTile}.\n */\n async loadTile(params: WorkerTileParameters): Promise<WorkerTileResult | null> {\n const {uid} = params;\n\n const workerTile = new WorkerTile(params);\n workerTile.abort = new AbortController();\n try {\n const loadResult = this.loadVectorTile(params);\n if (!loadResult) return null;\n\n const {vectorTile, rawData} = loadResult;\n\n workerTile.vectorTile = vectorTile;\n this.tileState.markLoaded(uid, workerTile);\n const parsingState = {rawData};\n this.tileState.setParsing(uid, parsingState);\n\n return await this._parseWorkerTile(workerTile, params);\n } catch (err) {\n this.tileState.markLoaded(uid, workerTile);\n throw err;\n }\n }\n\n async _parseWorkerTile(workerTile: WorkerTile, params: WorkerTileParameters): Promise<WorkerTileResult> {\n const parseState = this.tileState.getParsing(workerTile.uid);\n\n let result = await workerTile.parse(workerTile.vectorTile, this.layerIndex, this.availableImages, this.actor, params.subdivisionGranularity);\n\n // We need to pass rawTileData back to the main thread so that it can be stored in the Tile and FeatureIndex.\n // After the main thread has successfully received and stored rawTileData,\n // we no longer need to store it in the worker or transfer additional copies of it.\n if (parseState) {\n const {rawData} = parseState;\n // Return a copy of rawData to the main thread to avoid clearing the worker's buffer\n result = extend({rawTileData: rawData.slice(0), encoding: 'mvt'}, result);\n this.tileState.removeParsing(workerTile.uid);\n }\n\n return result;\n }\n\n /**\n * Implements {@link WorkerSource.abortTile}.\n */\n async abortTile(params: TileParameters): Promise<void> {\n this.tileState.abort(params.uid);\n }\n\n /**\n * Implements {@link WorkerSource.removeTile}.\n */\n async removeTile(params: TileParameters): Promise<void> {\n this.tileState.removeLoaded(params.uid);\n }\n\n /**\n * Fetches (if appropriate), parses and indexes geojson data into tiles. This\n * preparatory method must be called before {@link GeoJSONWorkerSource.loadTile}\n * can correctly serve up tiles. The first call to this method must contain a valid\n * {@link params.data}, {@link params.request} or {@link params.dataDiff}. Subsequent\n * calls may omit these parameters to reprocess the existing data (such as to update\n * clustering options).\n *\n * Defers to {@link GeoJSONWorkerSource.loadAndProcessGeoJSON} for the pre-processing.\n *\n * When a `loadData` request comes in while a previous one is being processed,\n * the previous one is aborted.\n *\n * @param params - the parameters\n * @returns a promise that resolves when the data is loaded and parsed into a GeoJSON object\n */\n async loadData(params: LoadGeoJSONParameters): Promise<GeoJSONWorkerSourceLoadDataResult> {\n this._pendingRequest?.abort();\n\n const timing = this._startRequestTiming(params);\n this._pendingRequest = new AbortController();\n try {\n await this.loadAndProcessGeoJSON(params, this._pendingRequest);\n delete this._pendingRequest;\n this.tileState.clearLoaded();\n\n // Sending a large GeoJSON payload from the worker to the main thread is slow so only do if necessary.\n // Send data only if it was loaded from a URL, otherwise the main thread already has a copy of this data.\n const result: GeoJSONWorkerSourceLoadDataResult = {};\n if (params.request) result.data = params.data;\n\n this._finishRequestTiming(timing, params, result);\n return result;\n } catch (err) {\n delete this._pendingRequest;\n if (!isAbortError(err)) throw err;\n return {abandoned: true};\n }\n }\n\n _startRequestTiming(params: LoadGeoJSONParameters): RequestPerformance | undefined {\n if (!params.request?.collectResourceTiming) return;\n return new RequestPerformance(params.request.url);\n }\n\n _finishRequestTiming(timing: RequestPerformance, params: LoadGeoJSONParameters, result: GeoJSONWorkerSourceLoadDataResult): void {\n const timingData = timing?.finish();\n if (!timingData) return;\n\n // it's necessary to eval the result of getEntriesByName() here via parse/stringify\n // late evaluation in the main thread causes TypeError: illegal invocation\n result.resourceTiming = {[params.source]: JSON.parse(JSON.stringify(timingData))};\n }\n\n /**\n * Implements {@link WorkerSource.reloadTile}.\n *\n * If the tile is loaded, reload by re-parsing the already available tile data.\n * Otherwise, such as after a setData() call, we load the tile fresh.\n *\n * @param params - the parameters\n * @returns A promise that resolves when the tile is reloaded\n */\n async reloadTile(params: WorkerTileParameters): Promise<WorkerTileResult> {\n const uid = params.uid;\n const workerTile = this.tileState.getLoaded(uid);\n if (!workerTile) {\n return await this.loadTile(params);\n }\n\n // If there was no vector tile data on the initial load, don't try to reparse the tile.\n if (!workerTile.vectorTile) {\n return;\n }\n\n workerTile.showCollisionBoxes = params.showCollisionBoxes;\n return await this._parseWorkerTile(workerTile, params);\n }\n\n /**\n * Fetch, parse and process GeoJSON according to the given parameters.\n * Defers to {@link GeoJSONWorkerSource._loadGeoJSONFromString} for the fetching and parsing.\n *\n * @param params - the parameters\n * @param abortController - the abort controller that allows aborting this operation\n * @returns a promise that is resolved with the processes GeoJSON\n */\n async loadAndProcessGeoJSON(params: LoadGeoJSONParameters, abortController: AbortController): Promise<GeoJSON.GeoJSON> {\n if (params.request) {\n params.data = (await getJSON<GeoJSON.GeoJSON>(params.request, abortController)).data;\n }\n\n if (params.data) {\n params.data = this._filterGeoJSON(params.data, params.filter, params.source);\n this._geoJSONIndex = this._createGeoJSONIndex(params.data, params);\n return;\n }\n\n if (params.dataDiff) {\n this._geoJSONIndex ??= this._createGeoJSONIndex({type: 'FeatureCollection', features: []}, params);\n this._geoJSONIndex.updateData(params.dataDiff, this._getFilterPredicate(params.filter, params.source));\n return;\n }\n\n if (params.updateCluster) {\n this._geoJSONIndex.updateClusterOptions(params.geojsonVtOptions.cluster, getSuperclusterOptions(params));\n }\n\n if (this._geoJSONIndex == null) {\n throw new Error(`Input data given to '${params.source}' is not a valid GeoJSON object.`);\n }\n }\n\n /**\n * Applies a filter to a GeoJSON object.\n */\n _filterGeoJSON(data: GeoJSON.GeoJSON, filter: FilterSpecification, source: string): GeoJSON.GeoJSON {\n if (data.type !== 'FeatureCollection') return data;\n\n const predicate = this._getFilterPredicate(filter, source);\n if (!predicate) return data;\n\n return {type: 'FeatureCollection', features: data.features.filter(feature => predicate(feature))};\n }\n\n /**\n * Gets a predicate function that can be used to filter GeoJSON features.\n */\n _getFilterPredicate(filter: FilterSpecification, source: string): (feature: GeoJSON.Feature) => boolean {\n if (typeof filter !== 'boolean' && !filter?.length) return undefined;\n\n const compiled = createExpression(filter, `sources.${source}.filter`, {type: 'boolean', 'property-type': 'data-driven', overridable: false, transition: false} as any);\n if (compiled.result === 'error') {\n throw new Error(compiled.value.map(err => `${err.key}: ${err.message}`).join(', '));\n }\n\n return (feature: GeoJSON.Feature) => compiled.value.evaluate({zoom: 0}, feature as any);\n }\n\n async removeSource(_params: RemoveSourceParams): Promise<void> {\n this._pendingRequest?.abort();\n }\n\n getClusterExpansionZoom(params: ClusterIDAndSource): number {\n return this._geoJSONIndex.getClusterExpansionZoom(params.clusterId);\n }\n\n getClusterChildren(params: ClusterIDAndSource): GeoJSON.Feature[] {\n return this._geoJSONIndex.getClusterChildren(params.clusterId);\n }\n\n getClusterLeaves(params: {\n clusterId: number;\n limit: number;\n offset: number;\n }): GeoJSON.Feature[] {\n return this._geoJSONIndex.getClusterLeaves(params.clusterId, params.limit, params.offset);\n }\n}\n\nexport function createGeoJSONIndex(data: GeoJSON.GeoJSON, params: LoadGeoJSONParameters): GeoJSONVT {\n const options = extend(params.geojsonVtOptions || {}, {\n updateable: true,\n clusterOptions: getSuperclusterOptions(params),\n });\n\n return new GeoJSONVT(data, options);\n}\n\nfunction getSuperclusterOptions({geojsonVtOptions, clusterProperties, source}: LoadGeoJSONParameters) {\n if (!clusterProperties || !geojsonVtOptions.clusterOptions) return geojsonVtOptions.clusterOptions;\n\n const mapExpressions = {};\n const reduceExpressions = {};\n const globals = {accumulated: null, zoom: 0};\n const feature = {properties: null};\n const propertyNames = Object.keys(clusterProperties);\n\n for (const key of propertyNames) {\n const [operator, mapExpression] = clusterProperties[key];\n\n const mapExpressionParsed = createExpression(mapExpression, `sources.${source}.clusterProperties.${key}[1]`);\n const reduceExpressionParsed = createExpression(\n typeof operator === 'string' ? [operator, ['accumulated'], ['get', key]] : operator, `sources.${source}.clusterProperties.${key}[0]`);\n\n mapExpressions[key] = mapExpressionParsed.value;\n reduceExpressions[key] = reduceExpressionParsed.value;\n }\n\n geojsonVtOptions.clusterOptions.map = (pointProperties) => {\n feature.properties = pointProperties;\n const properties = {};\n for (const key of propertyNames) {\n properties[key] = mapExpressions[key].evaluate(globals, feature);\n }\n return properties;\n };\n geojsonVtOptions.clusterOptions.reduce = (accumulated, clusterProperties) => {\n feature.properties = clusterProperties;\n for (const key of propertyNames) {\n globals.accumulated = accumulated[key];\n accumulated[key] = reduceExpressions[key].evaluate(globals, feature);\n }\n };\n return geojsonVtOptions.clusterOptions;\n}\n","import {Actor, type ActorTarget, type IActor} from '../util/actor.ts';\nimport {StyleLayerIndex} from '../style/style_layer_index.ts';\nimport {VectorTileWorkerSource} from './vector_tile_worker_source.ts';\nimport {RasterDEMTileWorkerSource} from './raster_dem_tile_worker_source.ts';\nimport {rtlWorkerPlugin, type RTLTextPlugin} from './rtl_text_plugin_worker.ts';\nimport {GeoJSONWorkerSource, type LoadGeoJSONParameters} from './geojson_worker_source.ts';\nimport {isWorker} from '../util/util.ts';\nimport {addProtocol, removeProtocol} from './protocol_crud.ts';\nimport {makeRequest} from '../util/ajax.ts';\n\nimport {type PluginState} from './rtl_text_plugin_status.ts';\nimport type {\n WorkerSource,\n WorkerSourceConstructor,\n WorkerTileParameters,\n WorkerDEMTileParameters,\n TileParameters\n} from '../source/worker_source.ts';\nimport type {WorkerGlobalScopeInterface} from '../util/web_worker.ts';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport {\n MessageType,\n type ClusterIDAndSource,\n type GetClusterLeavesParams,\n type RemoveSourceParams,\n type UpdateLayersParameters\n} from '../util/actor_messages.ts';\n\n/**\n * Loads an external script into worker (global) scope. The loader picks a\n * strategy based on what the script actually is:\n *\n * - `.mjs` URLs: dynamic `import()` directly, no fetch/sniff overhead. Worker\n * CSP needs `script-src` to permit the URL.\n *\n * - Other URLs: fetch the source and sniff for ESM syntax (top-level `import`\n * or `export`). If ESM is detected, run it through a blob-URL dynamic\n * `import()` so the browser parses it as a module; this requires\n * `script-src blob:` in the worker CSP. Otherwise treat it as UMD/IIFE and\n * run it via `globalThis.eval`, which requires `script-src 'unsafe-eval'`.\n */\nasync function loadScript(url: string): Promise<void> {\n if (url.endsWith('.mjs')) {\n await import(/* @vite-ignore */ url);\n return;\n }\n const response = await fetch(url, {credentials: 'same-origin'});\n if (!response.ok) {\n throw new Error(`Failed to load ${url}: ${response.status}`);\n }\n const code = await response.text();\n // Top-level `import`/`export` keywords are unique to ESM. UMD scripts\n // assign to `module.exports` / `exports.foo` — those don't match.\n if (/^[ \\t]*(import|export)\\s/m.test(code)) {\n const blobUrl = URL.createObjectURL(new Blob([code], {type: 'text/javascript'}));\n try {\n await import(/* @vite-ignore */ blobUrl);\n } finally {\n URL.revokeObjectURL(blobUrl);\n }\n return;\n }\n // Run the code in the worker's global scope (not inside this function),\n // so UMD/IIFE plugin scripts can assign to globals like\n // `self.registerRTLTextPlugin`. Calling eval as a property access\n // (rather than the bare `eval` identifier) is what makes it global-scope.\n globalThis.eval(code);\n}\n\n/**\n * The Worker class responsible for background thread related execution\n */\nexport default class Worker {\n self: WorkerGlobalScopeInterface & ActorTarget;\n actor: Actor;\n layerIndexes: {[_: string]: StyleLayerIndex};\n availableImages: {[_: string]: string[]};\n externalWorkerSourceTypes: { [_: string]: WorkerSourceConstructor };\n /**\n * This holds a cache for the already created worker source instances.\n * The cache is build with the following hierarchy:\n * [mapId][sourceType][sourceName]: worker source instance\n * sourceType can be 'vector' for example\n */\n workerSources: {\n [_: string]: {\n [_: string]: {\n [_: string]: WorkerSource;\n };\n };\n };\n /**\n * This holds a cache for the already created DEM worker source instances.\n * The cache is build with the following hierarchy:\n * [mapId][sourceType]: DEM worker source instance\n * sourceType can be 'raster-dem' for example\n */\n demWorkerSources: {\n [_: string]: {\n [_: string]: RasterDEMTileWorkerSource;\n };\n };\n referrer: string;\n globalStates: Map<string, Record<string, any>>;\n\n constructor(self: WorkerGlobalScopeInterface & ActorTarget) {\n this.self = self;\n this.actor = new Actor(self);\n\n this.layerIndexes = {};\n this.availableImages = {};\n\n this.workerSources = {};\n this.demWorkerSources = {};\n this.externalWorkerSourceTypes = {};\n\n this.globalStates = new Map<string, Record<string, any>>();\n\n this.self.registerWorkerSource = (name: string, WorkerSource: WorkerSourceConstructor) => {\n if (this.externalWorkerSourceTypes[name]) {\n throw new Error(`Worker source with name \"${name}\" already registered.`);\n }\n this.externalWorkerSourceTypes[name] = WorkerSource;\n };\n\n this.self.addProtocol = addProtocol;\n this.self.removeProtocol = removeProtocol;\n\n // Invoked by the RTL text plugin once it has fetched and parsed.\n this.self.registerRTLTextPlugin = (rtlTextPlugin: RTLTextPlugin) => {\n rtlWorkerPlugin.setMethods(rtlTextPlugin);\n };\n\n this.self.makeRequest = makeRequest;\n\n this.actor.registerMessageHandler(MessageType.loadDEMTile, (mapId: string, params: WorkerDEMTileParameters) => {\n return this._getDEMWorkerSource(mapId, params.source).loadTile(params);\n });\n\n this.actor.registerMessageHandler(MessageType.removeDEMTile, async (mapId: string, params: TileParameters) => {\n this._getDEMWorkerSource(mapId, params.source).removeTile(params);\n });\n\n this.actor.registerMessageHandler(MessageType.getClusterExpansionZoom, async (mapId: string, params: ClusterIDAndSource) => {\n return (this._getWorkerSource(mapId, params.type, params.source) as GeoJSONWorkerSource).getClusterExpansionZoom(params);\n });\n\n this.actor.registerMessageHandler(MessageType.getClusterChildren, async (mapId: string, params: ClusterIDAndSource) => {\n return (this._getWorkerSource(mapId, params.type, params.source) as GeoJSONWorkerSource).getClusterChildren(params);\n });\n\n this.actor.registerMessageHandler(MessageType.getClusterLeaves, async (mapId: string, params: GetClusterLeavesParams) => {\n return (this._getWorkerSource(mapId, params.type, params.source) as GeoJSONWorkerSource).getClusterLeaves(params);\n });\n\n this.actor.registerMessageHandler(MessageType.loadData, (mapId: string, params: LoadGeoJSONParameters) => {\n return (this._getWorkerSource(mapId, params.type, params.source) as GeoJSONWorkerSource).loadData(params);\n });\n\n this.actor.registerMessageHandler(MessageType.loadTile, (mapId: string, params: WorkerTileParameters) => {\n return this._getWorkerSource(mapId, params.type, params.source).loadTile(params);\n });\n\n this.actor.registerMessageHandler(MessageType.reloadTile, (mapId: string, params: WorkerTileParameters) => {\n return this._getWorkerSource(mapId, params.type, params.source).reloadTile(params);\n });\n\n this.actor.registerMessageHandler(MessageType.abortTile, (mapId: string, params: TileParameters) => {\n return this._getWorkerSource(mapId, params.type, params.source).abortTile(params);\n });\n\n this.actor.registerMessageHandler(MessageType.removeTile, (mapId: string, params: TileParameters) => {\n return this._getWorkerSource(mapId, params.type, params.source).removeTile(params);\n });\n\n this.actor.registerMessageHandler(MessageType.removeSource, async (mapId: string, params: RemoveSourceParams) => {\n if (!this.workerSources[mapId]?.[params.type]?.[params.source]) {\n return;\n }\n\n const worker = this.workerSources[mapId][params.type][params.source];\n delete this.workerSources[mapId][params.type][params.source];\n\n if (worker.removeSource !== undefined) {\n worker.removeSource(params);\n }\n });\n\n this.actor.registerMessageHandler(MessageType.removeMap, async (mapId: string) => {\n delete this.layerIndexes[mapId];\n delete this.availableImages[mapId];\n delete this.workerSources[mapId];\n delete this.demWorkerSources[mapId];\n this.globalStates.delete(mapId);\n });\n\n this.actor.registerMessageHandler(MessageType.setReferrer, async (_mapId: string, params: string) => {\n this.referrer = params;\n });\n\n this.actor.registerMessageHandler(MessageType.syncRTLPluginState, (mapId: string, params: PluginState) => {\n return this._syncRTLPluginState(mapId, params);\n });\n\n this.actor.registerMessageHandler(MessageType.importScript, async (_mapId: string, params: string) => {\n await loadScript(params);\n });\n\n this.actor.registerMessageHandler(MessageType.setImages, (mapId: string, params: string[]) => {\n return this._setImages(mapId, params);\n });\n\n this.actor.registerMessageHandler(MessageType.updateLayers, async (mapId: string, params: UpdateLayersParameters) => {\n this._getLayerIndex(mapId).update(params.layers, params.removedIds, this._getGlobalState(mapId));\n });\n\n this.actor.registerMessageHandler(MessageType.updateGlobalState, async (mapId: string, params: Record<string, any>) => {\n const globalState = this._getGlobalState(mapId);\n for (const key in params) {\n globalState[key] = params[key];\n }\n });\n\n this.actor.registerMessageHandler(MessageType.setLayers, async (mapId: string, params: LayerSpecification[]) => {\n this._getLayerIndex(mapId).replace(params, this._getGlobalState(mapId));\n });\n }\n\n private _getGlobalState(mapId: string): Record<string, any> {\n let state = this.globalStates.get(mapId);\n if (!state) {\n state = {};\n this.globalStates.set(mapId, state);\n }\n return state;\n }\n\n private async _setImages(mapId: string, images: string[]): Promise<void> {\n this.availableImages[mapId] = images;\n for (const workerSource in this.workerSources[mapId]) {\n const ws = this.workerSources[mapId][workerSource];\n for (const source in ws) {\n ws[source].availableImages = images;\n }\n }\n }\n\n private async _syncRTLPluginState(mapId: string, incomingState: PluginState): Promise<PluginState> {\n return await rtlWorkerPlugin.syncState(incomingState, loadScript);\n }\n\n private _getAvailableImages(mapId: string) {\n let availableImages = this.availableImages[mapId];\n\n availableImages ||= [];\n\n return availableImages;\n }\n\n private _getLayerIndex(mapId: string) {\n let layerIndexes = this.layerIndexes[mapId];\n layerIndexes ||= this.layerIndexes[mapId] = new StyleLayerIndex();\n return layerIndexes;\n }\n\n /**\n * This is basically a lazy initialization of a worker per mapId and sourceType and sourceName\n * @param mapId - the mapId\n * @param sourceType - the source type - 'vector' for example\n * @param sourceName - the source name - 'osm' for example\n * @returns a new instance or a cached one\n */\n private _getWorkerSource(mapId: string, sourceType: string, sourceName: string): WorkerSource {\n this.workerSources[mapId] ||= {};\n this.workerSources[mapId][sourceType] ||= {};\n\n if (!this.workerSources[mapId][sourceType][sourceName]) {\n // use a wrapped actor so that we can attach a target mapId param\n // to any messages invoked by the WorkerSource, this is very important when there are multiple maps\n const actor: IActor = {\n sendAsync: (message, abortController) => {\n message.targetMapId = mapId;\n return this.actor.sendAsync(message, abortController);\n }\n };\n switch (sourceType) {\n case 'vector':\n this.workerSources[mapId][sourceType][sourceName] = new VectorTileWorkerSource(actor, this._getLayerIndex(mapId), this._getAvailableImages(mapId));\n break;\n case 'geojson':\n this.workerSources[mapId][sourceType][sourceName] = new GeoJSONWorkerSource(actor, this._getLayerIndex(mapId), this._getAvailableImages(mapId));\n break;\n default:\n this.workerSources[mapId][sourceType][sourceName] = new (this.externalWorkerSourceTypes[sourceType])(actor, this._getLayerIndex(mapId), this._getAvailableImages(mapId));\n break;\n }\n }\n\n return this.workerSources[mapId][sourceType][sourceName];\n }\n\n /**\n * This is basically a lazy initialization of a worker per mapId and source\n * @param mapId - the mapId\n * @param sourceType - the source type - 'raster-dem' for example\n * @returns a new instance or a cached one\n */\n private _getDEMWorkerSource(mapId: string, sourceType: string) {\n this.demWorkerSources[mapId] ||= {};\n this.demWorkerSources[mapId][sourceType] ||= new RasterDEMTileWorkerSource();\n\n return this.demWorkerSources[mapId][sourceType];\n }\n}\n\nif (isWorker(self)) {\n self.worker = new Worker(self);\n}\n"],"mappings":";;;;wYAQA,IAAa,EAAb,K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/worker_tile.ts","../src/source/worker_tile_state.ts","../src/util/request_performance.ts","../src/source/vector_tile_overzoomed.ts","../src/source/vector_tile_worker_source.ts","../src/source/raster_dem_tile_worker_source.ts","../src/source/geojson_worker_source.ts","../src/source/worker.ts"],"sourcesContent":["import {createStyleLayer} from './create_style_layer.ts';\nimport {featureFilter, groupByLayout} from '@maplibre/maplibre-gl-style-spec';\nimport {GEOJSON_TILE_LAYER_NAME} from '../data/feature_index.ts';\nimport type {StyleLayer} from './style_layer.ts';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\n\nexport type LayerConfigs = {[_: string]: LayerSpecification};\n\nexport class StyleLayerIndex {\n familiesBySource: {\n [source: string]: {\n [sourceLayer: string]: StyleLayer[][];\n };\n };\n keyCache: {[source: string]: string};\n\n _layerConfigs: LayerConfigs;\n _layers: {[_: string]: StyleLayer};\n\n constructor(layerConfigs?: LayerSpecification[] | null, globalState?: Record<string, any>) {\n this.keyCache = {};\n if (layerConfigs) {\n this.replace(layerConfigs, globalState);\n }\n }\n\n replace(layerConfigs: LayerSpecification[], globalState?: Record<string, any>): void {\n this._layerConfigs = {};\n this._layers = {};\n this.update(layerConfigs, [], globalState);\n }\n\n update(layerConfigs: LayerSpecification[], removedIds: string[], globalState?: Record<string, any>): void {\n for (const layerConfig of layerConfigs) {\n this._layerConfigs[layerConfig.id] = layerConfig;\n\n const layer = this._layers[layerConfig.id] = createStyleLayer(layerConfig, globalState);\n layer._featureFilter = featureFilter(layer.filter, `layers[${layerConfig.id}].filter`, globalState);\n if (this.keyCache[layerConfig.id])\n delete this.keyCache[layerConfig.id];\n }\n for (const id of removedIds) {\n delete this.keyCache[id];\n delete this._layerConfigs[id];\n delete this._layers[id];\n }\n\n this.familiesBySource = {};\n\n const groups = groupByLayout(Object.values(this._layerConfigs), this.keyCache);\n\n for (const layerConfigs of groups) {\n const layers = layerConfigs.map((layerConfig) => this._layers[layerConfig.id]);\n\n const layer = layers[0];\n if (layer.isHidden()) {\n continue;\n }\n\n const sourceId = layer.source || '';\n let sourceGroup = this.familiesBySource[sourceId];\n sourceGroup ||= this.familiesBySource[sourceId] = {};\n\n const sourceLayerId = layer.sourceLayer || GEOJSON_TILE_LAYER_NAME;\n let sourceLayerFamilies = sourceGroup[sourceLayerId];\n sourceLayerFamilies ||= sourceGroup[sourceLayerId] = [];\n\n sourceLayerFamilies.push(layers);\n }\n }\n}\n","import {AlphaImage} from '../util/image.ts';\nimport {register} from '../util/web_worker_transfer.ts';\nimport potpack from 'potpack';\n\nimport type {GlyphMetrics} from '../style/style_glyph.ts';\nimport type {GetGlyphsResponse} from '../util/actor_messages.ts';\n\nconst padding = 1;\n\n/**\n * A rectangle type with position, width and height.\n */\nexport type Rect = {\n x: number;\n y: number;\n w: number;\n h: number;\n};\n\n/**\n * The glyph's position\n */\nexport type GlyphPosition = {\n rect: Rect;\n metrics: GlyphMetrics;\n};\n\n/**\n * The glyphs' positions\n */\nexport type GlyphPositions = {\n [_: string]: {\n [_: number]: GlyphPosition;\n };\n};\n\nexport class GlyphAtlas {\n image: AlphaImage;\n positions: GlyphPositions;\n\n constructor(stacks: GetGlyphsResponse) {\n const positions = {};\n const bins = [];\n\n for (const stack in stacks) {\n const glyphs = stacks[stack];\n const stackPositions = positions[stack] = {};\n\n for (const id in glyphs) {\n const src = glyphs[+id];\n if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue;\n\n const bin = {\n x: 0,\n y: 0,\n w: src.bitmap.width + 2 * padding,\n h: src.bitmap.height + 2 * padding\n };\n bins.push(bin);\n stackPositions[id] = {rect: bin, metrics: src.metrics};\n }\n }\n\n const {w, h} = potpack(bins);\n const image = new AlphaImage({width: w || 1, height: h || 1});\n\n for (const stack in stacks) {\n const glyphs = stacks[stack];\n\n for (const id in glyphs) {\n const src = glyphs[+id];\n if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue;\n const bin = positions[stack][id].rect;\n AlphaImage.copy(src.bitmap, image, {x: 0, y: 0}, {x: bin.x + padding, y: bin.y + padding}, src.bitmap);\n }\n }\n\n this.image = image;\n this.positions = positions;\n }\n}\n\nregister('GlyphAtlas', GlyphAtlas);\n","import {FeatureIndex} from '../data/feature_index.ts';\nimport {performSymbolLayout} from '../symbol/symbol_layout.ts';\nimport {CollisionBoxArray} from '../data/array_types.g.ts';\nimport {DictionaryCoder} from '../util/dictionary_coder.ts';\nimport {SymbolBucket} from '../data/bucket/symbol_bucket.ts';\nimport {LineBucket} from '../data/bucket/line_bucket.ts';\nimport {FillBucket} from '../data/bucket/fill_bucket.ts';\nimport {FillExtrusionBucket} from '../data/bucket/fill_extrusion_bucket.ts';\nimport {warnOnce, mapObject} from '../util/util.ts';\nimport {ImageAtlas} from '../render/image_atlas.ts';\nimport {GlyphAtlas} from '../render/glyph_atlas.ts';\nimport {EvaluationParameters} from '../style/evaluation_parameters.ts';\nimport {OverscaledTileID} from '../tile/tile_id.ts';\n\nimport type {Bucket} from '../data/bucket.ts';\nimport type {IActor} from '../util/actor.ts';\nimport type {StyleLayer} from '../style/style_layer.ts';\nimport type {StyleLayerIndex} from '../style/style_layer_index.ts';\nimport type {\n WorkerTileParameters,\n WorkerTileResult,\n} from './worker_source.ts';\nimport type {PromoteIdSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport type {VectorTileLike} from '@maplibre/vt-pbf';\nimport {type GetDashesResponse, MessageType, type GetGlyphsResponse, type GetImagesResponse} from '../util/actor_messages.ts';\nimport type {SubdivisionGranularitySetting} from '../render/subdivision_granularity_settings.ts';\nexport class WorkerTile {\n tileID: OverscaledTileID;\n uid: string | number;\n zoom: number;\n pixelRatio: number;\n tileSize: number;\n source: string;\n promoteId: PromoteIdSpecification;\n overscaling: number;\n showCollisionBoxes: boolean;\n collectResourceTiming: boolean;\n returnDependencies: boolean;\n\n data: VectorTileLike;\n collisionBoxArray: CollisionBoxArray;\n\n abort: AbortController;\n vectorTile: VectorTileLike;\n inFlightDependencies: AbortController[];\n\n constructor(params: WorkerTileParameters) {\n this.tileID = new OverscaledTileID(params.tileID.overscaledZ, params.tileID.wrap, params.tileID.canonical.z, params.tileID.canonical.x, params.tileID.canonical.y);\n this.uid = params.uid;\n this.zoom = params.zoom;\n this.pixelRatio = params.pixelRatio;\n this.tileSize = params.tileSize;\n this.source = params.source;\n this.overscaling = this.tileID.overscaleFactor();\n this.showCollisionBoxes = params.showCollisionBoxes;\n this.collectResourceTiming = !!params.collectResourceTiming;\n this.returnDependencies = !!params.returnDependencies;\n this.promoteId = params.promoteId;\n this.inFlightDependencies = [];\n }\n\n async parse(data: VectorTileLike, layerIndex: StyleLayerIndex, availableImages: string[], actor: IActor, subdivisionGranularity: SubdivisionGranularitySetting): Promise<WorkerTileResult> {\n this.data = data;\n\n this.collisionBoxArray = new CollisionBoxArray();\n const sourceLayerCoder = new DictionaryCoder(Object.keys(data.layers).sort());\n\n const featureIndex = new FeatureIndex(this.tileID, this.promoteId);\n featureIndex.bucketLayerIDs = [];\n\n const buckets: {[_: string]: Bucket} = {};\n\n const options = {\n featureIndex,\n iconDependencies: {},\n patternDependencies: {},\n glyphDependencies: {},\n dashDependencies: {},\n availableImages,\n subdivisionGranularity\n };\n\n const layerFamilies = layerIndex.familiesBySource[this.source];\n for (const sourceLayerId in layerFamilies) {\n const sourceLayer = data.layers[sourceLayerId];\n if (!sourceLayer) {\n continue;\n }\n\n if (sourceLayer.version === 1) {\n warnOnce(`Vector tile source \"${this.source}\" layer \"${sourceLayerId}\" ` +\n 'does not use vector tile spec v2 and therefore may have some rendering errors.');\n }\n\n const sourceLayerIndex = sourceLayerCoder.encode(sourceLayerId);\n const features = [];\n for (let index = 0; index < sourceLayer.length; index++) {\n const feature = sourceLayer.feature(index);\n const id = featureIndex.getId(feature, sourceLayerId);\n features.push({feature, id, index, sourceLayerIndex});\n }\n\n for (const family of layerFamilies[sourceLayerId]) {\n const layer = family[0];\n\n if (layer.source !== this.source) {\n warnOnce(`layer.source = ${layer.source} does not equal this.source = ${this.source}`);\n }\n if (layer.isHidden(this.zoom, true)) continue;\n recalculateLayers(family, this.zoom, availableImages);\n\n const bucket = buckets[layer.id] = layer.createBucket({\n index: featureIndex.bucketLayerIDs.length,\n layers: family,\n zoom: this.zoom,\n pixelRatio: this.pixelRatio,\n overscaling: this.overscaling,\n collisionBoxArray: this.collisionBoxArray,\n sourceLayerIndex,\n sourceID: this.source\n });\n\n bucket.populate(features, options, this.tileID.canonical);\n featureIndex.bucketLayerIDs.push(family.map((l) => l.id));\n }\n }\n\n // options.glyphDependencies looks like: {\"SomeFontName\":{\"10\":true,\"32\":true}}\n // this line makes an object like: {\"SomeFontName\":[10,32]}\n const stacks: {[_: string]: number[]} = mapObject(options.glyphDependencies, (glyphs) => Object.keys(glyphs).map(Number));\n\n for (const request of this.inFlightDependencies) {\n request?.abort();\n }\n this.inFlightDependencies = [];\n\n let getGlyphsPromise = Promise.resolve<GetGlyphsResponse>({});\n if (Object.keys(stacks).length) {\n const abortController = new AbortController();\n this.inFlightDependencies.push(abortController);\n getGlyphsPromise = actor.sendAsync({type: MessageType.getGlyphs, data: {stacks, source: this.source, tileID: this.tileID, type: 'glyphs'}}, abortController);\n }\n\n const icons = Object.keys(options.iconDependencies);\n let getIconsPromise = Promise.resolve<GetImagesResponse>({});\n if (icons.length) {\n const abortController = new AbortController();\n this.inFlightDependencies.push(abortController);\n getIconsPromise = actor.sendAsync({type: MessageType.getImages, data: {icons, source: this.source, tileID: this.tileID, type: 'icons'}}, abortController);\n }\n\n const patterns = Object.keys(options.patternDependencies);\n let getPatternsPromise = Promise.resolve<GetImagesResponse>({});\n if (patterns.length) {\n const abortController = new AbortController();\n this.inFlightDependencies.push(abortController);\n getPatternsPromise = actor.sendAsync({type: MessageType.getImages, data: {icons: patterns, source: this.source, tileID: this.tileID, type: 'patterns'}}, abortController);\n }\n\n const dashes = options.dashDependencies;\n let getDashesPromise = Promise.resolve<GetDashesResponse>({} as GetDashesResponse);\n if (Object.keys(dashes).length) {\n const abortController = new AbortController();\n this.inFlightDependencies.push(abortController);\n getDashesPromise = actor.sendAsync({type: MessageType.getDashes, data: {dashes}}, abortController);\n }\n\n const [glyphMap, iconMap, patternMap, dashPositions] = await Promise.all([getGlyphsPromise, getIconsPromise, getPatternsPromise, getDashesPromise]);\n\n const glyphAtlas = new GlyphAtlas(glyphMap);\n const imageAtlas = new ImageAtlas(iconMap, patternMap);\n\n for (const key in buckets) {\n const bucket = buckets[key];\n if (bucket instanceof SymbolBucket) {\n recalculateLayers(bucket.layers, this.zoom, availableImages);\n performSymbolLayout({\n bucket,\n glyphMap,\n glyphPositions: glyphAtlas.positions,\n imageMap: iconMap,\n imagePositions: imageAtlas.iconPositions,\n showCollisionBoxes: this.showCollisionBoxes,\n canonical: this.tileID.canonical,\n subdivisionGranularity: options.subdivisionGranularity\n });\n } else if (bucket.hasDependencies && (bucket instanceof FillBucket || bucket instanceof FillExtrusionBucket || bucket instanceof LineBucket)) {\n recalculateLayers(bucket.layers, this.zoom, availableImages);\n bucket.addFeatures(options, this.tileID.canonical, imageAtlas.patternPositions, dashPositions);\n }\n }\n\n return {\n buckets: Object.values(buckets).filter(b => !b.isEmpty()),\n featureIndex,\n collisionBoxArray: this.collisionBoxArray,\n glyphAtlasImage: glyphAtlas.image,\n imageAtlas,\n dashPositions,\n // Only used for benchmarking:\n glyphMap: this.returnDependencies ? glyphMap : null,\n iconMap: this.returnDependencies ? iconMap : null,\n glyphPositions: this.returnDependencies ? glyphAtlas.positions : null\n };\n }\n}\n\nfunction recalculateLayers(layers: readonly StyleLayer[], zoom: number, availableImages: string[]) {\n // Layers are shared and may have been used by a WorkerTile with a different zoom.\n const parameters = new EvaluationParameters(zoom);\n for (const layer of layers) {\n layer.recalculate(parameters, availableImages);\n }\n}\n","import type {WorkerTile} from './worker_tile.ts';\nimport {type ExpiryData} from '../util/ajax.ts';\n\nexport type ParsingState = {\n rawData: ArrayBufferLike;\n cacheControl?: ExpiryData;\n resourceTiming?: any;\n};\n\nexport class WorkerTileState {\n loading: Record<string, WorkerTile> = {};\n loaded: Record<string, WorkerTile> = {};\n parsing: Record<string, ParsingState> = {};\n\n startLoading(uid: string | number, tile: WorkerTile): void {\n this.loading[uid] = tile;\n }\n\n finishLoading(uid: string | number): void {\n delete this.loading[uid];\n }\n\n abort(uid: string | number): void {\n const tile = this.loading[uid];\n if (!tile?.abort) return;\n tile.abort.abort();\n delete this.loading[uid];\n }\n\n getParsing(uid: string | number): ParsingState | undefined {\n return this.parsing[uid];\n }\n\n setParsing(uid: string | number, state: ParsingState): void {\n this.parsing[uid] = state;\n }\n\n removeParsing(uid: string | number): void {\n delete this.parsing[uid];\n }\n\n markLoaded(uid: string | number, tile: WorkerTile): void {\n this.loaded[uid] = tile;\n }\n\n getLoaded(uid: string | number): WorkerTile | undefined {\n const tile = this.loaded[uid];\n if (!tile) return undefined;\n return tile;\n }\n\n removeLoaded(uid: string | number): void {\n delete this.loaded[uid];\n }\n\n clearLoaded(): void {\n this.loaded = {};\n }\n}\n","/**\n * @internal\n * Safe wrapper for the performance resource timing API in web workers with graceful degradation\n */\nexport class RequestPerformance {\n private start: string;\n private end: string;\n private measure: string;\n\n constructor (url: string) {\n this.start = `${url}#start`;\n this.end = `${url}#end`;\n this.measure = url;\n\n performance.mark(this.start);\n }\n\n finish(): PerformanceEntryList {\n performance.mark(this.end);\n let resourceTimingData = performance.getEntriesByName(this.measure);\n\n // fallback if web worker implementation of perf.getEntriesByName returns empty\n if (resourceTimingData.length === 0) {\n performance.measure(this.measure, this.start, this.end);\n resourceTimingData = performance.getEntriesByName(this.measure);\n\n // cleanup\n performance.clearMarks(this.start);\n performance.clearMarks(this.end);\n performance.clearMeasures(this.measure);\n }\n\n return resourceTimingData;\n }\n}\n","import Point from '@mapbox/point-geometry';\nimport {clipGeometry} from '../symbol/clip_line.ts';\nimport type {CanonicalTileID} from '../tile/tile_id.ts';\nimport type {VectorTileFeatureLike, VectorTileLayerLike, VectorTileLike} from '@maplibre/vt-pbf';\n\nclass VectorTileFeatureOverzoomed implements VectorTileFeatureLike {\n pointsArray: Point[][];\n type: VectorTileFeatureLike['type'];\n properties: VectorTileFeatureLike['properties'];\n id: VectorTileFeatureLike['id'];\n extent: VectorTileFeatureLike['extent'];\n\n constructor(\n type: VectorTileFeatureLike['type'],\n geometry: Point[][],\n properties: VectorTileFeatureLike['properties'],\n id: VectorTileFeatureLike['id'],\n extent: VectorTileFeatureLike['extent']\n ) {\n this.type = type;\n this.properties = properties ? properties : {};\n this.extent = extent;\n this.pointsArray = geometry;\n this.id = id;\n }\n\n loadGeometry(): Point[][] {\n // Clone the geometry and ensure all points are Point instances\n return this.pointsArray.map(ring =>\n ring.map(point => new Point(point.x, point.y))\n );\n }\n}\n\nclass VectorTileLayerOverzoomed implements VectorTileLayerLike {\n private _myFeatures: VectorTileFeatureOverzoomed[];\n name: string;\n extent: number;\n version: number = 2;\n length: number;\n\n constructor(features: VectorTileFeatureOverzoomed[], layerName: string, extent: number) {\n this._myFeatures = features;\n this.name = layerName;\n this.length = features.length;\n this.extent = extent;\n }\n\n feature(i: number): VectorTileFeatureLike {\n return this._myFeatures[i];\n }\n}\n\nexport class VectorTileOverzoomed implements VectorTileLike {\n layers: Record<string, VectorTileLayerLike> = {};\n\n addLayer(layer: VectorTileLayerOverzoomed): void {\n this.layers[layer.name] = layer;\n }\n}\n\n/**\n * This function slices a source tile layer into an overzoomed tile layer for a target tile ID.\n * @param sourceLayer - the source tile layer to slice\n * @param maxZoomTileID - the maximum zoom tile ID\n * @param targetTileID - the target tile ID\n * @returns - the overzoomed tile layer\n */\nexport function sliceVectorTileLayer(sourceLayer: VectorTileLayerLike, maxZoomTileID: CanonicalTileID, targetTileID: CanonicalTileID): VectorTileLayerOverzoomed {\n const {extent} = sourceLayer;\n const dz = targetTileID.z - maxZoomTileID.z;\n const scale = Math.pow(2, dz);\n \n // Calculate the target tile's position within the source tile in target coordinate space\n // This ensures all tiles share the same coordinate system\n const offsetX = (targetTileID.x - maxZoomTileID.x * scale) * extent;\n const offsetY = (targetTileID.y - maxZoomTileID.y * scale) * extent;\n\n const featureWrappers: VectorTileFeatureOverzoomed[] = [];\n for (let index = 0; index < sourceLayer.length; index++) {\n const feature: VectorTileFeatureLike = sourceLayer.feature(index);\n let geometry = feature.loadGeometry();\n \n // Transform all coordinates to target tile space\n for (const ring of geometry) {\n for (const point of ring) {\n point.x = point.x * scale - offsetX;\n point.y = point.y * scale - offsetY;\n }\n }\n \n const buffer = 128;\n geometry = clipGeometry(geometry, feature.type, -buffer, -buffer, extent + buffer, extent + buffer);\n if (geometry.length === 0) {\n continue;\n }\n \n featureWrappers.push(new VectorTileFeatureOverzoomed(\n feature.type,\n geometry,\n feature.properties,\n feature.id,\n extent\n ));\n }\n return new VectorTileLayerOverzoomed(featureWrappers, sourceLayer.name, extent);\n}","import {PbfReader} from 'pbf';\nimport {VectorTile} from '@mapbox/vector-tile';\nimport {fromVectorTileJs, type VectorTileLayerLike, type VectorTileLike} from '@maplibre/vt-pbf';\nimport {type ExpiryData, getArrayBuffer} from '../util/ajax.ts';\nimport {WorkerTile} from './worker_tile.ts';\nimport {WorkerTileState} from './worker_tile_state.ts';\nimport {BoundedLRUCache} from '../tile/tile_cache.ts';\nimport {ensureError, extend} from '../util/util.ts';\nimport {RequestPerformance} from '../util/request_performance.ts';\nimport {VectorTileOverzoomed, sliceVectorTileLayer} from './vector_tile_overzoomed.ts';\nimport {MLTVectorTile} from './vector_tile_mlt.ts';\nimport type {\n WorkerSource,\n WorkerTileParameters,\n TileParameters,\n WorkerTileResult\n} from '../source/worker_source.ts';\nimport type {IActor} from '../util/actor.ts';\nimport type {StyleLayer} from '../style/style_layer.ts';\nimport type {StyleLayerIndex} from '../style/style_layer_index.ts';\n\nexport type LoadVectorTileResult = {\n vectorTile: VectorTileLike;\n rawData: ArrayBufferLike;\n};\n\n/**\n * The {@link WorkerSource} implementation that supports {@link VectorTileSource}. This class is\n * used by vector tile sources to perform tile processing operations in a separate worker thread.\n */\nexport class VectorTileWorkerSource implements WorkerSource {\n actor: IActor;\n layerIndex: StyleLayerIndex;\n availableImages: string[];\n tileState: WorkerTileState;\n overzoomedTileResultCache: BoundedLRUCache<string, LoadVectorTileResult>;\n\n constructor(actor: IActor, layerIndex: StyleLayerIndex, availableImages: string[]) {\n this.actor = actor;\n this.layerIndex = layerIndex;\n this.availableImages = availableImages;\n this.tileState = new WorkerTileState();\n this.overzoomedTileResultCache = new BoundedLRUCache<string, LoadVectorTileResult>(1000);\n }\n\n /**\n * Loads a vector tile\n */\n loadVectorTile(params: WorkerTileParameters, rawData: ArrayBuffer): LoadVectorTileResult {\n try {\n const vectorTile = params.encoding !== 'mlt'\n ? new VectorTile(new PbfReader(rawData))\n : new MLTVectorTile(rawData);\n\n return {vectorTile, rawData};\n } catch (ex) {\n const bytes = new Uint8Array(rawData);\n const isGzipped = bytes[0] === 0x1f && bytes[1] === 0x8b;\n let errorMessage = `Unable to parse the tile at ${params.request.url}, `;\n if (isGzipped) {\n errorMessage += 'please make sure the data is not gzipped and that you have configured the relevant header in the server';\n } else {\n errorMessage += `got error: ${ensureError(ex).message}`;\n }\n throw new Error(errorMessage);\n }\n }\n\n /**\n * Implements {@link WorkerSource.loadTile}.\n */\n async loadTile(params: WorkerTileParameters): Promise<WorkerTileResult | null> {\n const {uid, overzoomParameters} = params;\n\n if (overzoomParameters) {\n params.request = overzoomParameters.overzoomRequest;\n }\n\n const timing = this._startRequestTiming(params);\n const workerTile = new WorkerTile(params);\n\n this.tileState.startLoading(uid, workerTile);\n const abortController = new AbortController();\n workerTile.abort = abortController;\n try {\n // Download the tile data from the network.\n const tileResponse = await getArrayBuffer(params.request, abortController);\n\n // Tile data hasn't changed (etag support) - return an unmodified result\n if (params.etag && params.etag === tileResponse.etag) {\n this.tileState.finishLoading(uid);\n return this._getEtagUnmodifiedResult(tileResponse, timing);\n }\n\n const tileResult = this.loadVectorTile(params, tileResponse.data);\n this.tileState.finishLoading(uid);\n if (!tileResult) return null;\n\n let {vectorTile, rawData} = tileResult;\n if (overzoomParameters) {\n ({vectorTile, rawData} = this._getOverzoomTile(params, vectorTile));\n }\n\n const cacheControl = this._getExpiryData(tileResponse);\n const resourceTiming = this._finishRequestTiming(timing);\n\n workerTile.vectorTile = vectorTile;\n this.tileState.markLoaded(uid, workerTile);\n const parsingState = {rawData, cacheControl, resourceTiming};\n this.tileState.setParsing(uid, parsingState);\n\n return await this._parseWorkerTile(workerTile, params);\n } catch (err) {\n this.tileState.finishLoading(uid);\n this.tileState.markLoaded(uid, workerTile);\n throw err;\n }\n }\n\n _getEtagUnmodifiedResult(response: ExpiryData, timing: RequestPerformance): WorkerTileResult {\n const cacheControl = this._getExpiryData(response);\n const resourceTiming = this._finishRequestTiming(timing);\n return extend({etagUnmodified: true as const}, cacheControl, resourceTiming);\n }\n\n async _parseWorkerTile(workerTile: WorkerTile, params: WorkerTileParameters): Promise<WorkerTileResult> {\n const parseState = this.tileState.getParsing(workerTile.uid);\n\n let result = await workerTile.parse(workerTile.vectorTile, this.layerIndex, this.availableImages, this.actor, params.subdivisionGranularity);\n\n // We need to pass rawTileData back to the main thread so that it can be stored in the Tile and FeatureIndex.\n // After the main thread has successfully received and stored rawTileData,\n // we no longer need to store it in the worker or transfer additional copies of it.\n if (parseState) {\n const {rawData, cacheControl, resourceTiming} = parseState;\n // Overzoomed tiles are always re-encoded to MVT protobuf by _getOverzoomTile\n const encoding = params.overzoomParameters ? 'mvt' : params.encoding;\n // Return a copy of rawData to the main thread to avoid clearing the worker's buffer\n result = extend({rawTileData: rawData.slice(0), encoding}, result, cacheControl, resourceTiming);\n this.tileState.removeParsing(workerTile.uid);\n }\n // else: this seems like a missing case where cache control is lost? see #3309\n\n return result;\n }\n\n _getExpiryData({expires, cacheControl, etag}: ExpiryData): ExpiryData {\n const data: ExpiryData = {};\n if (expires) data.expires = expires;\n if (cacheControl) data.cacheControl = cacheControl;\n if (etag) data.etag = etag;\n return data;\n }\n\n _startRequestTiming(params: WorkerTileParameters): RequestPerformance | undefined {\n if (!params.request?.collectResourceTiming) return;\n return new RequestPerformance(params.request.url);\n }\n\n _finishRequestTiming(timing: RequestPerformance): {resourceTiming?: any} {\n const timingData = timing?.finish();\n if (!timingData) return {};\n\n // it's necessary to eval the result of getEntriesByName() here via parse/stringify\n // late evaluation in the main thread causes TypeError: illegal invocation\n return {resourceTiming: JSON.parse(JSON.stringify(timingData))};\n }\n\n /**\n * If we are seeking a tile deeper than the source's max available canonical tile, get the overzoomed tile\n * @param params - the worker tile parameters\n * @param maxZoomVectorTile - the original vector tile at the source's max available canonical zoom\n * @returns the overzoomed tile and its raw data\n */\n private _getOverzoomTile(params: WorkerTileParameters, maxZoomVectorTile: VectorTileLike): LoadVectorTileResult {\n const {tileID, source, overzoomParameters} = params;\n const {maxZoomTileID} = overzoomParameters;\n\n const cacheKey = `${maxZoomTileID.key}_${tileID.key}_${params.request?.url}`;\n const cachedOverzoomTile = this.overzoomedTileResultCache.get(cacheKey);\n\n if (cachedOverzoomTile) {\n return cachedOverzoomTile;\n }\n\n const overzoomedVectorTile = new VectorTileOverzoomed();\n const layerFamilies: Record<string, StyleLayer[][]> = this.layerIndex.familiesBySource[source];\n\n for (const sourceLayerId in layerFamilies) {\n const sourceLayer: VectorTileLayerLike = maxZoomVectorTile.layers[sourceLayerId];\n if (!sourceLayer) {\n continue;\n }\n\n const slicedTileLayer = sliceVectorTileLayer(sourceLayer, maxZoomTileID, tileID.canonical);\n if (slicedTileLayer.length > 0) {\n overzoomedVectorTile.addLayer(slicedTileLayer);\n }\n }\n const overzoomedVectorTileResult = {\n vectorTile: overzoomedVectorTile,\n rawData: fromVectorTileJs(overzoomedVectorTile).buffer\n };\n this.overzoomedTileResultCache.set(cacheKey, overzoomedVectorTileResult);\n\n return overzoomedVectorTileResult;\n }\n\n /**\n * Implements {@link WorkerSource.reloadTile}.\n */\n async reloadTile(params: WorkerTileParameters): Promise<WorkerTileResult> {\n const uid = params.uid;\n const workerTile = this.tileState.getLoaded(uid);\n if (!workerTile) throw new Error('Should not be trying to reload a tile that was never loaded or has been removed');\n\n // If there was no vector tile data on the initial load, don't try to reparse the tile.\n if (!workerTile.vectorTile) {\n return;\n }\n\n workerTile.showCollisionBoxes = params.showCollisionBoxes;\n return await this._parseWorkerTile(workerTile, params);\n }\n\n /**\n * Implements {@link WorkerSource.abortTile}.\n */\n async abortTile(params: TileParameters): Promise<void> {\n this.tileState.abort(params.uid);\n }\n\n /**\n * Implements {@link WorkerSource.removeTile}.\n */\n async removeTile(params: TileParameters): Promise<void> {\n this.tileState.removeLoaded(params.uid);\n }\n}\n","import {DEMData} from '../data/dem_data.ts';\nimport {RGBAImage} from '../util/image.ts';\nimport type {Actor} from '../util/actor.ts';\nimport type {\n WorkerDEMTileParameters,\n TileParameters\n} from './worker_source.ts';\nimport {getImageData, isImageBitmap} from '../util/util.ts';\n\nexport class RasterDEMTileWorkerSource {\n actor: Actor;\n loaded: {[_: string]: DEMData};\n\n constructor() {\n this.loaded = {};\n }\n\n async loadTile(params: WorkerDEMTileParameters): Promise<DEMData | null> {\n const {uid, encoding, rawImageData, redFactor, greenFactor, blueFactor, baseShift} = params;\n const width = rawImageData.width + 2;\n const height = rawImageData.height + 2;\n const imagePixels: RGBAImage | ImageData = isImageBitmap(rawImageData) ?\n new RGBAImage({width, height}, await getImageData(rawImageData, -1, -1, width, height)) :\n rawImageData;\n const dem = new DEMData(uid, imagePixels, encoding, redFactor, greenFactor, blueFactor, baseShift);\n this.loaded ||= {};\n this.loaded[uid] = dem;\n return dem;\n }\n\n removeTile(params: TileParameters): void {\n const loaded = this.loaded,\n uid = params.uid;\n if (loaded?.[uid]) {\n delete loaded[uid];\n }\n }\n}\n","import {getJSON} from '../util/ajax.ts';\nimport {RequestPerformance} from '../util/request_performance.ts';\nimport {fromVectorTileJs, GeoJSONWrapper} from '@maplibre/vt-pbf';\nimport {EXTENT} from '../data/extent.ts';\nimport {GeoJSONVT, type GeoJSONVTOptions} from '@maplibre/geojson-vt';\nimport {createExpression, type FilterSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport {isAbortError} from '../util/abort_error.ts';\nimport {WorkerTile} from './worker_tile.ts';\nimport {WorkerTileState} from './worker_tile_state.ts';\nimport {extend, JSON_PREFIX} from '../util/util.ts';\n\nimport type {GeoJSONSourceDiff} from './geojson_source_diff.ts';\nimport type {WorkerSource, WorkerTileParameters, TileParameters, WorkerTileResult} from './worker_source.ts';\nimport type {LoadVectorTileResult} from './vector_tile_worker_source.ts';\nimport type {RequestParameters} from '../util/ajax.ts';\nimport type {ClusterIDAndSource, GeoJSONWorkerSourceLoadDataResult, RemoveSourceParams} from '../util/actor_messages.ts';\nimport type {IActor} from '../util/actor.ts';\nimport type {StyleLayerIndex} from '../style/style_layer_index.ts';\n\n/**\n * The geojson worker options that can be passed to the worker\n */\nexport type GeoJSONWorkerOptions = {\n source?: string;\n geojsonVtOptions?: GeoJSONVTOptions;\n clusterProperties?: Record<string, [unknown, unknown]>;\n filter?: FilterSpecification;\n collectResourceTiming?: boolean;\n};\n\n/**\n * Parameters needed to load GeoJSON to the worker - must specify either a `request`, `data` or `dataDiff`.\n */\nexport type LoadGeoJSONParameters = GeoJSONWorkerOptions & {\n type: 'geojson';\n /** The geojson source ID. */\n source: string;\n /**\n * Request parameters including a URL to fetch GeoJSON data.\n */\n request?: RequestParameters;\n /**\n * GeoJSON data to set as the source's data.\n */\n data?: GeoJSON.GeoJSON;\n /**\n * GeoJSONSourceDiff to apply to the existing GeoJSON source data.\n */\n dataDiff?: GeoJSONSourceDiff;\n /**\n * Update the supercluster using the latest worker cluster options.\n */\n updateCluster?: boolean;\n};\n\n/**\n * The {@link WorkerSource} implementation that supports {@link GeoJSONSource}.\n * This class is designed to be easily reused to support custom source types\n * for data formats that can be parsed/converted into an in-memory GeoJSON\n * representation. To do so, create it with\n * `new GeoJSONWorkerSource(actor, layerIndex, customLoadGeoJSONFunction)`.\n * For a full example, see [mapbox-gl-topojson](https://github.com/developmentseed/mapbox-gl-topojson).\n */\nexport class GeoJSONWorkerSource implements WorkerSource {\n actor: IActor;\n layerIndex: StyleLayerIndex;\n availableImages: string[];\n tileState: WorkerTileState;\n\n _pendingRequest: AbortController;\n _geoJSONIndex: GeoJSONVT;\n _createGeoJSONIndex: typeof createGeoJSONIndex;\n\n constructor(actor: IActor, layerIndex: StyleLayerIndex, availableImages: string[], createGeoJSONIndexFunc: typeof createGeoJSONIndex = createGeoJSONIndex) {\n this.actor = actor;\n this.layerIndex = layerIndex;\n this.availableImages = availableImages;\n this.tileState = new WorkerTileState();\n this._createGeoJSONIndex = createGeoJSONIndexFunc;\n }\n\n /**\n * Retrieves and sends loaded vector tiles to the main thread.\n */\n loadVectorTile(params: WorkerTileParameters): LoadVectorTileResult | null {\n if (!this._geoJSONIndex) throw new Error('Unable to parse the data into a cluster or geojson');\n\n const {z, x, y} = params.tileID.canonical;\n const geoJSONTile = this._geoJSONIndex.getTile(z, x, y);\n if (!geoJSONTile) return null;\n\n const geojsonWrapper = new GeoJSONWrapper(geoJSONTile.features, {version: 2, extent: EXTENT});\n return {\n vectorTile: geojsonWrapper,\n rawData: fromVectorTileJs(geojsonWrapper, JSON_PREFIX).buffer\n };\n\n }\n\n /**\n * Implements {@link WorkerSource.loadTile}.\n */\n async loadTile(params: WorkerTileParameters): Promise<WorkerTileResult | null> {\n const {uid} = params;\n\n const workerTile = new WorkerTile(params);\n workerTile.abort = new AbortController();\n try {\n const loadResult = this.loadVectorTile(params);\n if (!loadResult) return null;\n\n const {vectorTile, rawData} = loadResult;\n\n workerTile.vectorTile = vectorTile;\n this.tileState.markLoaded(uid, workerTile);\n const parsingState = {rawData};\n this.tileState.setParsing(uid, parsingState);\n\n return await this._parseWorkerTile(workerTile, params);\n } catch (err) {\n this.tileState.markLoaded(uid, workerTile);\n throw err;\n }\n }\n\n async _parseWorkerTile(workerTile: WorkerTile, params: WorkerTileParameters): Promise<WorkerTileResult> {\n const parseState = this.tileState.getParsing(workerTile.uid);\n\n let result = await workerTile.parse(workerTile.vectorTile, this.layerIndex, this.availableImages, this.actor, params.subdivisionGranularity);\n\n // We need to pass rawTileData back to the main thread so that it can be stored in the Tile and FeatureIndex.\n // After the main thread has successfully received and stored rawTileData,\n // we no longer need to store it in the worker or transfer additional copies of it.\n if (parseState) {\n const {rawData} = parseState;\n // Return a copy of rawData to the main thread to avoid clearing the worker's buffer\n result = extend({rawTileData: rawData.slice(0), encoding: 'mvt'}, result);\n this.tileState.removeParsing(workerTile.uid);\n }\n\n return result;\n }\n\n /**\n * Implements {@link WorkerSource.abortTile}.\n */\n async abortTile(params: TileParameters): Promise<void> {\n this.tileState.abort(params.uid);\n }\n\n /**\n * Implements {@link WorkerSource.removeTile}.\n */\n async removeTile(params: TileParameters): Promise<void> {\n this.tileState.removeLoaded(params.uid);\n }\n\n /**\n * Fetches (if appropriate), parses and indexes geojson data into tiles. This\n * preparatory method must be called before {@link GeoJSONWorkerSource.loadTile}\n * can correctly serve up tiles. The first call to this method must contain a valid\n * {@link params.data}, {@link params.request} or {@link params.dataDiff}. Subsequent\n * calls may omit these parameters to reprocess the existing data (such as to update\n * clustering options).\n *\n * Defers to {@link GeoJSONWorkerSource.loadAndProcessGeoJSON} for the pre-processing.\n *\n * When a `loadData` request comes in while a previous one is being processed,\n * the previous one is aborted.\n *\n * @param params - the parameters\n * @returns a promise that resolves when the data is loaded and parsed into a GeoJSON object\n */\n async loadData(params: LoadGeoJSONParameters): Promise<GeoJSONWorkerSourceLoadDataResult> {\n this._pendingRequest?.abort();\n\n const timing = this._startRequestTiming(params);\n this._pendingRequest = new AbortController();\n try {\n await this.loadAndProcessGeoJSON(params, this._pendingRequest);\n delete this._pendingRequest;\n this.tileState.clearLoaded();\n\n // Sending a large GeoJSON payload from the worker to the main thread is slow so only do if necessary.\n // Send data only if it was loaded from a URL, otherwise the main thread already has a copy of this data.\n const result: GeoJSONWorkerSourceLoadDataResult = {};\n if (params.request) result.data = params.data;\n\n this._finishRequestTiming(timing, params, result);\n return result;\n } catch (err) {\n delete this._pendingRequest;\n if (!isAbortError(err)) throw err;\n return {abandoned: true};\n }\n }\n\n _startRequestTiming(params: LoadGeoJSONParameters): RequestPerformance | undefined {\n if (!params.request?.collectResourceTiming) return;\n return new RequestPerformance(params.request.url);\n }\n\n _finishRequestTiming(timing: RequestPerformance, params: LoadGeoJSONParameters, result: GeoJSONWorkerSourceLoadDataResult): void {\n const timingData = timing?.finish();\n if (!timingData) return;\n\n // it's necessary to eval the result of getEntriesByName() here via parse/stringify\n // late evaluation in the main thread causes TypeError: illegal invocation\n result.resourceTiming = {[params.source]: JSON.parse(JSON.stringify(timingData))};\n }\n\n /**\n * Implements {@link WorkerSource.reloadTile}.\n *\n * If the tile is loaded, reload by re-parsing the already available tile data.\n * Otherwise, such as after a setData() call, we load the tile fresh.\n *\n * @param params - the parameters\n * @returns A promise that resolves when the tile is reloaded\n */\n async reloadTile(params: WorkerTileParameters): Promise<WorkerTileResult> {\n const uid = params.uid;\n const workerTile = this.tileState.getLoaded(uid);\n if (!workerTile) {\n return await this.loadTile(params);\n }\n\n // If there was no vector tile data on the initial load, don't try to reparse the tile.\n if (!workerTile.vectorTile) {\n return;\n }\n\n workerTile.showCollisionBoxes = params.showCollisionBoxes;\n return await this._parseWorkerTile(workerTile, params);\n }\n\n /**\n * Fetch, parse and process GeoJSON according to the given parameters.\n * Defers to {@link GeoJSONWorkerSource._loadGeoJSONFromString} for the fetching and parsing.\n *\n * @param params - the parameters\n * @param abortController - the abort controller that allows aborting this operation\n * @returns a promise that is resolved with the processes GeoJSON\n */\n async loadAndProcessGeoJSON(params: LoadGeoJSONParameters, abortController: AbortController): Promise<GeoJSON.GeoJSON> {\n if (params.request) {\n params.data = (await getJSON<GeoJSON.GeoJSON>(params.request, abortController)).data;\n }\n\n if (params.data) {\n params.data = this._filterGeoJSON(params.data, params.filter, params.source);\n this._geoJSONIndex = this._createGeoJSONIndex(params.data, params);\n return;\n }\n\n if (params.dataDiff) {\n this._geoJSONIndex ??= this._createGeoJSONIndex({type: 'FeatureCollection', features: []}, params);\n this._geoJSONIndex.updateData(params.dataDiff, this._getFilterPredicate(params.filter, params.source));\n return;\n }\n\n if (params.updateCluster) {\n this._geoJSONIndex.updateClusterOptions(params.geojsonVtOptions.cluster, getSuperclusterOptions(params));\n }\n\n if (this._geoJSONIndex == null) {\n throw new Error(`Input data given to '${params.source}' is not a valid GeoJSON object.`);\n }\n }\n\n /**\n * Applies a filter to a GeoJSON object.\n */\n _filterGeoJSON(data: GeoJSON.GeoJSON, filter: FilterSpecification, source: string): GeoJSON.GeoJSON {\n if (data.type !== 'FeatureCollection') return data;\n\n const predicate = this._getFilterPredicate(filter, source);\n if (!predicate) return data;\n\n return {type: 'FeatureCollection', features: data.features.filter(feature => predicate(feature))};\n }\n\n /**\n * Gets a predicate function that can be used to filter GeoJSON features.\n */\n _getFilterPredicate(filter: FilterSpecification, source: string): (feature: GeoJSON.Feature) => boolean {\n if (typeof filter !== 'boolean' && !filter?.length) return undefined;\n\n const compiled = createExpression(filter, `sources.${source}.filter`, {type: 'boolean', 'property-type': 'data-driven', overridable: false, transition: false} as any);\n if (compiled.result === 'error') {\n throw new Error(compiled.value.map(err => `${err.key}: ${err.message}`).join(', '));\n }\n\n return (feature: GeoJSON.Feature) => compiled.value.evaluate({zoom: 0}, feature as any);\n }\n\n async removeSource(_params: RemoveSourceParams): Promise<void> {\n this._pendingRequest?.abort();\n }\n\n getClusterExpansionZoom(params: ClusterIDAndSource): number {\n return this._geoJSONIndex.getClusterExpansionZoom(params.clusterId);\n }\n\n getClusterChildren(params: ClusterIDAndSource): GeoJSON.Feature[] {\n return this._geoJSONIndex.getClusterChildren(params.clusterId);\n }\n\n getClusterLeaves(params: {\n clusterId: number;\n limit: number;\n offset: number;\n }): GeoJSON.Feature[] {\n return this._geoJSONIndex.getClusterLeaves(params.clusterId, params.limit, params.offset);\n }\n}\n\nexport function createGeoJSONIndex(data: GeoJSON.GeoJSON, params: LoadGeoJSONParameters): GeoJSONVT {\n const options = extend(params.geojsonVtOptions || {}, {\n updateable: true,\n clusterOptions: getSuperclusterOptions(params),\n });\n\n return new GeoJSONVT(data, options);\n}\n\nfunction getSuperclusterOptions({geojsonVtOptions, clusterProperties, source}: LoadGeoJSONParameters) {\n if (!clusterProperties || !geojsonVtOptions.clusterOptions) return geojsonVtOptions.clusterOptions;\n\n const mapExpressions = {};\n const reduceExpressions = {};\n const globals = {accumulated: null, zoom: 0};\n const feature = {properties: null};\n const propertyNames = Object.keys(clusterProperties);\n\n for (const key of propertyNames) {\n const [operator, mapExpression] = clusterProperties[key];\n\n const mapExpressionParsed = createExpression(mapExpression, `sources.${source}.clusterProperties.${key}[1]`);\n const reduceExpressionParsed = createExpression(\n typeof operator === 'string' ? [operator, ['accumulated'], ['get', key]] : operator, `sources.${source}.clusterProperties.${key}[0]`);\n\n mapExpressions[key] = mapExpressionParsed.value;\n reduceExpressions[key] = reduceExpressionParsed.value;\n }\n\n geojsonVtOptions.clusterOptions.map = (pointProperties) => {\n feature.properties = pointProperties;\n const properties = {};\n for (const key of propertyNames) {\n properties[key] = mapExpressions[key].evaluate(globals, feature);\n }\n return properties;\n };\n geojsonVtOptions.clusterOptions.reduce = (accumulated, clusterProperties) => {\n feature.properties = clusterProperties;\n for (const key of propertyNames) {\n globals.accumulated = accumulated[key];\n accumulated[key] = reduceExpressions[key].evaluate(globals, feature);\n }\n };\n return geojsonVtOptions.clusterOptions;\n}\n","import {Actor, type ActorTarget, type IActor} from '../util/actor.ts';\nimport {StyleLayerIndex} from '../style/style_layer_index.ts';\nimport {VectorTileWorkerSource} from './vector_tile_worker_source.ts';\nimport {RasterDEMTileWorkerSource} from './raster_dem_tile_worker_source.ts';\nimport {rtlWorkerPlugin, type RTLTextPlugin} from './rtl_text_plugin_worker.ts';\nimport {GeoJSONWorkerSource, type LoadGeoJSONParameters} from './geojson_worker_source.ts';\nimport {isWorker} from '../util/util.ts';\nimport {addProtocol, removeProtocol} from './protocol_crud.ts';\nimport {makeRequest} from '../util/ajax.ts';\n\nimport {type PluginState} from './rtl_text_plugin_status.ts';\nimport type {\n WorkerSource,\n WorkerSourceConstructor,\n WorkerTileParameters,\n WorkerDEMTileParameters,\n TileParameters\n} from '../source/worker_source.ts';\nimport type {WorkerGlobalScopeInterface} from '../util/web_worker.ts';\nimport type {LayerSpecification} from '@maplibre/maplibre-gl-style-spec';\nimport {\n MessageType,\n type ClusterIDAndSource,\n type GetClusterLeavesParams,\n type RemoveSourceParams,\n type UpdateLayersParameters\n} from '../util/actor_messages.ts';\n\n/**\n * Loads an external script into worker (global) scope. The loader picks a\n * strategy based on what the script actually is:\n *\n * - `.mjs` URLs: dynamic `import()` directly, no fetch/sniff overhead. Worker\n * CSP needs `script-src` to permit the URL.\n *\n * - Other URLs: fetch the source and sniff for ESM syntax (top-level `import`\n * or `export`). If ESM is detected, run it through a blob-URL dynamic\n * `import()` so the browser parses it as a module; this requires\n * `script-src blob:` in the worker CSP. Otherwise treat it as UMD/IIFE and\n * run it via `globalThis.eval`, which requires `script-src 'unsafe-eval'`.\n */\nasync function loadScript(url: string): Promise<void> {\n if (url.endsWith('.mjs')) {\n await import(/* @vite-ignore */ url);\n return;\n }\n const response = await fetch(url, {credentials: 'same-origin'});\n if (!response.ok) {\n throw new Error(`Failed to load ${url}: ${response.status}`);\n }\n const code = await response.text();\n // Top-level `import`/`export` keywords are unique to ESM. UMD scripts\n // assign to `module.exports` / `exports.foo` — those don't match.\n if (/^[ \\t]*(import|export)\\s/m.test(code)) {\n const blobUrl = URL.createObjectURL(new Blob([code], {type: 'text/javascript'}));\n try {\n await import(/* @vite-ignore */ blobUrl);\n } finally {\n URL.revokeObjectURL(blobUrl);\n }\n return;\n }\n // Run the code in the worker's global scope (not inside this function),\n // so UMD/IIFE plugin scripts can assign to globals like\n // `self.registerRTLTextPlugin`. Calling eval as a property access\n // (rather than the bare `eval` identifier) is what makes it global-scope.\n globalThis.eval(code);\n}\n\n/**\n * The Worker class responsible for background thread related execution\n */\nexport default class Worker {\n self: WorkerGlobalScopeInterface & ActorTarget;\n actor: Actor;\n layerIndexes: {[_: string]: StyleLayerIndex};\n availableImages: {[_: string]: string[]};\n externalWorkerSourceTypes: { [_: string]: WorkerSourceConstructor };\n /**\n * This holds a cache for the already created worker source instances.\n * The cache is build with the following hierarchy:\n * [mapId][sourceType][sourceName]: worker source instance\n * sourceType can be 'vector' for example\n */\n workerSources: {\n [_: string]: {\n [_: string]: {\n [_: string]: WorkerSource;\n };\n };\n };\n /**\n * This holds a cache for the already created DEM worker source instances.\n * The cache is build with the following hierarchy:\n * [mapId][sourceType]: DEM worker source instance\n * sourceType can be 'raster-dem' for example\n */\n demWorkerSources: {\n [_: string]: {\n [_: string]: RasterDEMTileWorkerSource;\n };\n };\n referrer: string;\n globalStates: Map<string, Record<string, any>>;\n\n constructor(self: WorkerGlobalScopeInterface & ActorTarget) {\n this.self = self;\n this.actor = new Actor(self);\n\n this.layerIndexes = {};\n this.availableImages = {};\n\n this.workerSources = {};\n this.demWorkerSources = {};\n this.externalWorkerSourceTypes = {};\n\n this.globalStates = new Map<string, Record<string, any>>();\n\n this.self.registerWorkerSource = (name: string, WorkerSource: WorkerSourceConstructor) => {\n if (this.externalWorkerSourceTypes[name]) {\n throw new Error(`Worker source with name \"${name}\" already registered.`);\n }\n this.externalWorkerSourceTypes[name] = WorkerSource;\n };\n\n this.self.addProtocol = addProtocol;\n this.self.removeProtocol = removeProtocol;\n\n // Invoked by the RTL text plugin once it has fetched and parsed.\n this.self.registerRTLTextPlugin = (rtlTextPlugin: RTLTextPlugin) => {\n rtlWorkerPlugin.setMethods(rtlTextPlugin);\n };\n\n this.self.makeRequest = makeRequest;\n\n this.actor.registerMessageHandler(MessageType.loadDEMTile, (mapId: string, params: WorkerDEMTileParameters) => {\n return this._getDEMWorkerSource(mapId, params.source).loadTile(params);\n });\n\n this.actor.registerMessageHandler(MessageType.removeDEMTile, async (mapId: string, params: TileParameters) => {\n this._getDEMWorkerSource(mapId, params.source).removeTile(params);\n });\n\n this.actor.registerMessageHandler(MessageType.getClusterExpansionZoom, async (mapId: string, params: ClusterIDAndSource) => {\n return (this._getWorkerSource(mapId, params.type, params.source) as GeoJSONWorkerSource).getClusterExpansionZoom(params);\n });\n\n this.actor.registerMessageHandler(MessageType.getClusterChildren, async (mapId: string, params: ClusterIDAndSource) => {\n return (this._getWorkerSource(mapId, params.type, params.source) as GeoJSONWorkerSource).getClusterChildren(params);\n });\n\n this.actor.registerMessageHandler(MessageType.getClusterLeaves, async (mapId: string, params: GetClusterLeavesParams) => {\n return (this._getWorkerSource(mapId, params.type, params.source) as GeoJSONWorkerSource).getClusterLeaves(params);\n });\n\n this.actor.registerMessageHandler(MessageType.loadData, (mapId: string, params: LoadGeoJSONParameters) => {\n return (this._getWorkerSource(mapId, params.type, params.source) as GeoJSONWorkerSource).loadData(params);\n });\n\n this.actor.registerMessageHandler(MessageType.loadTile, (mapId: string, params: WorkerTileParameters) => {\n return this._getWorkerSource(mapId, params.type, params.source).loadTile(params);\n });\n\n this.actor.registerMessageHandler(MessageType.reloadTile, (mapId: string, params: WorkerTileParameters) => {\n return this._getWorkerSource(mapId, params.type, params.source).reloadTile(params);\n });\n\n this.actor.registerMessageHandler(MessageType.abortTile, (mapId: string, params: TileParameters) => {\n return this._getWorkerSource(mapId, params.type, params.source).abortTile(params);\n });\n\n this.actor.registerMessageHandler(MessageType.removeTile, (mapId: string, params: TileParameters) => {\n return this._getWorkerSource(mapId, params.type, params.source).removeTile(params);\n });\n\n this.actor.registerMessageHandler(MessageType.removeSource, async (mapId: string, params: RemoveSourceParams) => {\n if (!this.workerSources[mapId]?.[params.type]?.[params.source]) {\n return;\n }\n\n const worker = this.workerSources[mapId][params.type][params.source];\n delete this.workerSources[mapId][params.type][params.source];\n\n if (worker.removeSource !== undefined) {\n worker.removeSource(params);\n }\n });\n\n this.actor.registerMessageHandler(MessageType.removeMap, async (mapId: string) => {\n delete this.layerIndexes[mapId];\n delete this.availableImages[mapId];\n delete this.workerSources[mapId];\n delete this.demWorkerSources[mapId];\n this.globalStates.delete(mapId);\n });\n\n this.actor.registerMessageHandler(MessageType.setReferrer, async (_mapId: string, params: string) => {\n this.referrer = params;\n });\n\n this.actor.registerMessageHandler(MessageType.syncRTLPluginState, (mapId: string, params: PluginState) => {\n return this._syncRTLPluginState(mapId, params);\n });\n\n this.actor.registerMessageHandler(MessageType.importScript, async (_mapId: string, params: string) => {\n await loadScript(params);\n });\n\n this.actor.registerMessageHandler(MessageType.setImages, (mapId: string, params: string[]) => {\n return this._setImages(mapId, params);\n });\n\n this.actor.registerMessageHandler(MessageType.updateLayers, async (mapId: string, params: UpdateLayersParameters) => {\n this._getLayerIndex(mapId).update(params.layers, params.removedIds, this._getGlobalState(mapId));\n });\n\n this.actor.registerMessageHandler(MessageType.updateGlobalState, async (mapId: string, params: Record<string, any>) => {\n const globalState = this._getGlobalState(mapId);\n for (const key in params) {\n globalState[key] = params[key];\n }\n });\n\n this.actor.registerMessageHandler(MessageType.setLayers, async (mapId: string, params: LayerSpecification[]) => {\n this._getLayerIndex(mapId).replace(params, this._getGlobalState(mapId));\n });\n }\n\n private _getGlobalState(mapId: string): Record<string, any> {\n let state = this.globalStates.get(mapId);\n if (!state) {\n state = {};\n this.globalStates.set(mapId, state);\n }\n return state;\n }\n\n private async _setImages(mapId: string, images: string[]): Promise<void> {\n this.availableImages[mapId] = images;\n for (const workerSource in this.workerSources[mapId]) {\n const ws = this.workerSources[mapId][workerSource];\n for (const source in ws) {\n ws[source].availableImages = images;\n }\n }\n }\n\n private async _syncRTLPluginState(mapId: string, incomingState: PluginState): Promise<PluginState> {\n return await rtlWorkerPlugin.syncState(incomingState, loadScript);\n }\n\n private _getAvailableImages(mapId: string) {\n let availableImages = this.availableImages[mapId];\n\n availableImages ||= [];\n\n return availableImages;\n }\n\n private _getLayerIndex(mapId: string) {\n let layerIndexes = this.layerIndexes[mapId];\n layerIndexes ||= this.layerIndexes[mapId] = new StyleLayerIndex();\n return layerIndexes;\n }\n\n /**\n * This is basically a lazy initialization of a worker per mapId and sourceType and sourceName\n * @param mapId - the mapId\n * @param sourceType - the source type - 'vector' for example\n * @param sourceName - the source name - 'osm' for example\n * @returns a new instance or a cached one\n */\n private _getWorkerSource(mapId: string, sourceType: string, sourceName: string): WorkerSource {\n this.workerSources[mapId] ||= {};\n this.workerSources[mapId][sourceType] ||= {};\n\n if (!this.workerSources[mapId][sourceType][sourceName]) {\n // use a wrapped actor so that we can attach a target mapId param\n // to any messages invoked by the WorkerSource, this is very important when there are multiple maps\n const actor: IActor = {\n sendAsync: (message, abortController) => {\n message.targetMapId = mapId;\n return this.actor.sendAsync(message, abortController);\n }\n };\n switch (sourceType) {\n case 'vector':\n this.workerSources[mapId][sourceType][sourceName] = new VectorTileWorkerSource(actor, this._getLayerIndex(mapId), this._getAvailableImages(mapId));\n break;\n case 'geojson':\n this.workerSources[mapId][sourceType][sourceName] = new GeoJSONWorkerSource(actor, this._getLayerIndex(mapId), this._getAvailableImages(mapId));\n break;\n default:\n this.workerSources[mapId][sourceType][sourceName] = new (this.externalWorkerSourceTypes[sourceType])(actor, this._getLayerIndex(mapId), this._getAvailableImages(mapId));\n break;\n }\n }\n\n return this.workerSources[mapId][sourceType][sourceName];\n }\n\n /**\n * This is basically a lazy initialization of a worker per mapId and source\n * @param mapId - the mapId\n * @param sourceType - the source type - 'raster-dem' for example\n * @returns a new instance or a cached one\n */\n private _getDEMWorkerSource(mapId: string, sourceType: string) {\n this.demWorkerSources[mapId] ||= {};\n this.demWorkerSources[mapId][sourceType] ||= new RasterDEMTileWorkerSource();\n\n return this.demWorkerSources[mapId][sourceType];\n }\n}\n\nif (isWorker(self)) {\n self.worker = new Worker(self);\n}\n"],"mappings":";;;;wYAQA,IAAa,EAAb,KAA6B,CAWzB,YAAY,EAA4C,EAAmC,CACvF,KAAK,SAAW,CAAC,EACb,GACA,KAAK,QAAQ,EAAc,CAAW,CAE9C,CAEA,QAAQ,EAAoC,EAAyC,CACjF,KAAK,cAAgB,CAAC,EACtB,KAAK,QAAU,CAAC,EAChB,KAAK,OAAO,EAAc,CAAC,EAAG,CAAW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