mirror of
https://github.com/maputnik/editor.git
synced 2026-02-05 12:10:03 +00:00
Bumps [maplibre-gl](https://github.com/maplibre/maplibre-gl-js) from 5.10.0 to 5.11.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/maplibre/maplibre-gl-js/releases">maplibre-gl's releases</a>.</em></p> <blockquote> <h2>v5.11.0</h2> <p><a href="https://github.com/maplibre/maplibre-gl-js">https://github.com/maplibre/maplibre-gl-js</a> <a href="https://github.com/maplibre/maplibre-gl-js/compare/v5.10.0...v5.11.0">Changes</a> since <a href="https://github.com/maplibre/maplibre-gl-js/releases/tag/v5.10.0">MapLibre GL JS v5.10.0</a>:</p> <h3>✨ Features and improvements</h3> <ul> <li>Improve performance of <code>GeoJSONSource#updateData</code> when called on small diffs (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/pull/6562">#6562</a>) (by <a href="https://github.com/lucaswoj"><code>@lucaswoj</code></a>)</li> <li>If the stylesheet lacks a <code>glyphs</code> property at the root level, interpret the <code>text-font</code> property as a cascading fallback list of font names and render all text using local or system fonts. (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/pull/4564">#4564</a>) (by <a href="https://github.com/1ec5"><code>@1ec5</code></a>)</li> <li>⚠️ Refactor SourceCache to TileManager (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/pull/6635">#6635</a>) - this is not a breaking change since SourceCache is not part of the public API, but if you have a plugin that uses internal stuff, it might break... (by <a href="https://github.com/wayofthefuture"><code>@wayofthefuture</code></a>)</li> </ul> <h3>🐞 Bug fixes</h3> <ul> <li>If a required glyph PBF is unavailable or it lacks a glyph for a character in a <code>text-field</code>, try to render it locally instead of crashing. (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/pull/4564">#4564</a>) (by <a href="https://github.com/1ec5"><code>@1ec5</code></a>)</li> <li>Export <code>now()</code> function in timeControl API to complete the API and enable external code to read controlled time (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/pull/6644">#6644</a>) (by <a href="https://github.com/bjperson"><code>@bjperson</code></a>)</li> <li>ScaleControl CSS styling contains <code>white-space: nowrap</code> to prevent wrapping (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/pull/6647">#6647</a>) (by <a href="https://github.com/stroebjo"><code>@stroebjo</code></a>)</li> <li>Fix edge fading for unloaded tiles (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/pull/6650">#6650</a>) (by <a href="https://github.com/wayofthefuture"><code>@wayofthefuture</code></a>)</li> </ul> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/maplibre/maplibre-gl-js/blob/main/CHANGELOG.md">maplibre-gl's changelog</a>.</em></p> <blockquote> <h2>5.11.0</h2> <h3>✨ Features and improvements</h3> <ul> <li>Improve performance of <code>GeoJSONSource#updateData</code> when called on small diffs (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/pull/6562">#6562</a>) (by <a href="https://github.com/lucaswoj"><code>@lucaswoj</code></a>)</li> <li>If the stylesheet lacks a <code>glyphs</code> property at the root level, interpret the <code>text-font</code> property as a cascading fallback list of font names and render all text using local or system fonts. (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/pull/4564">#4564</a>) (by <a href="https://github.com/1ec5"><code>@1ec5</code></a>)</li> <li>⚠️ Refactor SourceCache to TileManager (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/pull/6635">#6635</a>) - this is not a breaking change since SourceCache is not part of the public API, but if you have a plugin that uses internal stuff, it might break... (by <a href="https://github.com/wayofthefuture"><code>@wayofthefuture</code></a>)</li> </ul> <h3>🐞 Bug fixes</h3> <ul> <li>If a required glyph PBF is unavailable or it lacks a glyph for a character in a <code>text-field</code>, try to render it locally instead of crashing. (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/pull/4564">#4564</a>) (by <a href="https://github.com/1ec5"><code>@1ec5</code></a>)</li> <li>Export <code>now()</code> function in timeControl API to complete the API and enable external code to read controlled time (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/pull/6644">#6644</a>) (by <a href="https://github.com/bjperson"><code>@bjperson</code></a>)</li> <li>ScaleControl CSS styling contains <code>white-space: nowrap</code> to prevent wrapping (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/pull/6647">#6647</a>) (by <a href="https://github.com/stroebjo"><code>@stroebjo</code></a>)</li> <li>Fix edge fading for unloaded tiles (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/pull/6650">#6650</a>) (by <a href="https://github.com/wayofthefuture"><code>@wayofthefuture</code></a>)</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="25d189b0b1"><code>25d189b</code></a> Bump version to 5.11.0 (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/issues/6660">#6660</a>)</li> <li><a href="2ceb99058d"><code>2ceb990</code></a> Fix edge fading for unloaded tiles (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/issues/6650">#6650</a>)</li> <li><a href="5e525bb049"><code>5e525bb</code></a> chore(deps-dev): bump cssnano from 7.1.1 to 7.1.2 (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/issues/6657">#6657</a>)</li> <li><a href="96fa4d88f5"><code>96fa4d8</code></a> chore(deps-dev): bump jsdom from 27.0.1 to 27.1.0 (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/issues/6654">#6654</a>)</li> <li><a href="3602bb8e4a"><code>3602bb8</code></a> chore(deps-dev): bump <code>@types/node</code> from 24.9.1 to 24.9.2 (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/issues/6656">#6656</a>)</li> <li><a href="dcaf719e21"><code>dcaf719</code></a> chore(deps-dev): bump devtools-protocol from 0.0.1534754 to 0.0.1537100 (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/issues/6658">#6658</a>)</li> <li><a href="695d00b267"><code>695d00b</code></a> chore(deps-dev): bump <code>@rollup/plugin-replace</code> from 6.0.2 to 6.0.3 (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/issues/6655">#6655</a>)</li> <li><a href="ab75910b09"><code>ab75910</code></a> chore(deps): bump github/codeql-action from 4.31.0 to 4.31.2 (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/issues/6651">#6651</a>)</li> <li><a href="7877effef6"><code>7877eff</code></a> chore(deps-dev): bump puppeteer from 24.26.1 to 24.27.0 (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/issues/6653">#6653</a>)</li> <li><a href="38f6c930fb"><code>38f6c93</code></a> chore(deps-dev): bump the vitest group with 4 updates (<a href="https://redirect.github.com/maplibre/maplibre-gl-js/issues/6652">#6652</a>)</li> <li>Additional commits viewable in <a href="https://github.com/maplibre/maplibre-gl-js/compare/v5.10.0...v5.11.0">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: HarelM <harel.mazor@gmail.com>
82 lines
3.1 KiB
TypeScript
82 lines
3.1 KiB
TypeScript
import throttle from "lodash.throttle";
|
|
import isEqual from "lodash.isequal";
|
|
import { type Map } from "maplibre-gl";
|
|
|
|
export type LayerWatcherOptions = {
|
|
onSourcesChange?: (sources: { [sourceId: string]: string[] }) => void;
|
|
onVectorLayersChange?: (vectorLayers: { [vectorLayerId: string]: { [propertyName: string]: { [propertyValue: string]: {} } } }) => void;
|
|
};
|
|
|
|
/** Listens to map events to build up a store of available vector
|
|
* layers contained in the tiles */
|
|
export default class LayerWatcher {
|
|
onSourcesChange: (sources: { [sourceId: string]: string[] }) => void;
|
|
onVectorLayersChange: (vectorLayers: { [vectorLayerId: string]: { [propertyName: string]: { [propertyValue: string]: {} } } }) => void;
|
|
throttledAnalyzeVectorLayerFields: (map: any) => void;
|
|
_sources: { [sourceId: string]: string[] };
|
|
_vectorLayers: { [vectorLayerId: string]: { [propertyName: string]: { [propertyValue: string]: {} } } };
|
|
|
|
constructor(opts: LayerWatcherOptions = {}) {
|
|
this.onSourcesChange = opts.onSourcesChange || (() => {});
|
|
this.onVectorLayersChange = opts.onVectorLayersChange || (() => {});
|
|
|
|
this._sources = {};
|
|
this._vectorLayers = {};
|
|
|
|
// Since we scan over all features we want to avoid this as much as
|
|
// possible and only do it after a batch of data has loaded because
|
|
// we only care eventuall about knowing the fields in the vector layers
|
|
this.throttledAnalyzeVectorLayerFields = throttle(this.analyzeVectorLayerFields, 5000);
|
|
}
|
|
|
|
analyzeMap(map: Map) {
|
|
const previousSources = { ...this._sources };
|
|
|
|
for (const sourceId of Object.keys(map.style.tileManagers)) {
|
|
//NOTE: This heavily depends on the internal API of Maplibre GL
|
|
//so this breaks between Maplibre GL JS releases
|
|
this._sources[sourceId] = map.style.tileManagers[sourceId]._source.vectorLayerIds as string[];
|
|
};
|
|
|
|
if(!isEqual(previousSources, this._sources)) {
|
|
this.onSourcesChange(this._sources);
|
|
}
|
|
|
|
this.throttledAnalyzeVectorLayerFields(map);
|
|
}
|
|
|
|
analyzeVectorLayerFields(map: Map) {
|
|
const previousVectorLayers = { ...this._vectorLayers };
|
|
|
|
Object.keys(this._sources).forEach(sourceId => {
|
|
(this._sources[sourceId] || []).forEach(vectorLayerId => {
|
|
const knownProperties = this._vectorLayers[vectorLayerId] || {};
|
|
const params = { sourceLayer: vectorLayerId };
|
|
map.querySourceFeatures(sourceId, params as any).forEach(feature => {
|
|
Object.keys(feature.properties).forEach(propertyName => {
|
|
const knownPropertyValues = knownProperties[propertyName] || {};
|
|
knownPropertyValues[feature.properties[propertyName]] = {};
|
|
knownProperties[propertyName] = knownPropertyValues;
|
|
});
|
|
});
|
|
|
|
this._vectorLayers[vectorLayerId] = knownProperties;
|
|
});
|
|
});
|
|
|
|
if(!isEqual(previousVectorLayers, this._vectorLayers)) {
|
|
this.onVectorLayersChange(this._vectorLayers);
|
|
}
|
|
|
|
}
|
|
|
|
/** Access all known sources and their vector tile ids */
|
|
get sources() {
|
|
return this._sources;
|
|
}
|
|
|
|
get vectorLayers() {
|
|
return this._vectorLayers;
|
|
}
|
|
}
|