mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-13 04:44:50 +02:00
synchronize fetching presets from cdn
by first fetching `package.json` and loading the exact version from that for further presets requests
This commit is contained in:
@@ -47,6 +47,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
|
||||
* add support for tagging schema v5 ([#9320])
|
||||
* Render `natural=strait` features in blue color ([#9294])
|
||||
#### :hammer: Development
|
||||
* Synchronize fetching of released presets
|
||||
|
||||
[#9294]: https://github.com/openstreetmap/iD/issues/9294
|
||||
[#9320]: https://github.com/openstreetmap/iD/pull/9320
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
const presetsCdnUrl = 'https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@{presets_version}/';
|
||||
const presetsCdnVersion = '3';
|
||||
|
||||
export {
|
||||
presetsCdnUrl,
|
||||
presetsCdnVersion
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
import parseVersion from 'vparse';
|
||||
import { presetsCdnUrl, presetsCdnVersion } from '../../config/cdn.js';
|
||||
// Double check this resolves to iD's `package.json`
|
||||
import packageJSON from '../../package.json';
|
||||
|
||||
@@ -18,8 +19,6 @@ export function coreFileFetcher() {
|
||||
let _inflight = {};
|
||||
let _fileMap = {
|
||||
'address_formats': 'data/address_formats.min.json',
|
||||
'deprecated': 'https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@3/dist/deprecated.min.json',
|
||||
'discarded': 'https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@3/dist/discarded.min.json',
|
||||
'imagery': 'data/imagery.min.json',
|
||||
'intro_graph': 'data/intro_graph.min.json',
|
||||
'keepRight': 'data/keepRight.min.json',
|
||||
@@ -28,10 +27,13 @@ export function coreFileFetcher() {
|
||||
'oci_defaults': `https://cdn.jsdelivr.net/npm/osm-community-index@${vMinor}/dist/defaults.min.json`,
|
||||
'oci_features': `https://cdn.jsdelivr.net/npm/osm-community-index@${vMinor}/dist/featureCollection.min.json`,
|
||||
'oci_resources': `https://cdn.jsdelivr.net/npm/osm-community-index@${vMinor}/dist/resources.min.json`,
|
||||
'preset_categories': 'https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@3/dist/preset_categories.min.json',
|
||||
'preset_defaults': 'https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@3/dist/preset_defaults.min.json',
|
||||
'preset_fields': 'https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@3/dist/fields.min.json',
|
||||
'preset_presets': 'https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@3/dist/presets.min.json',
|
||||
'presets_package': presetsCdnUrl.replace('{presets_version}', presetsCdnVersion) + 'package.json',
|
||||
'deprecated': presetsCdnUrl + 'dist/deprecated.min.json',
|
||||
'discarded': presetsCdnUrl + 'dist/discarded.min.json',
|
||||
'preset_categories': presetsCdnUrl + 'dist/preset_categories.min.json',
|
||||
'preset_defaults': presetsCdnUrl + 'dist/preset_defaults.min.json',
|
||||
'preset_fields': presetsCdnUrl + 'dist/fields.min.json',
|
||||
'preset_presets': presetsCdnUrl + 'dist/presets.min.json',
|
||||
'phone_formats': 'data/phone_formats.min.json',
|
||||
'qa_data': 'data/qa_data.min.json',
|
||||
'shortcuts': 'data/shortcuts.min.json',
|
||||
@@ -57,6 +59,18 @@ export function coreFileFetcher() {
|
||||
return Promise.reject(`Unknown data file for "${which}"`);
|
||||
}
|
||||
|
||||
if (url.includes('{presets_version}')) {
|
||||
return _this.get('presets_package')
|
||||
.then(result => {
|
||||
const presetsVersion = result.version;
|
||||
return getUrl(url.replace('{presets_version}', presetsVersion), which);
|
||||
});
|
||||
} else {
|
||||
return getUrl(url);
|
||||
}
|
||||
};
|
||||
|
||||
function getUrl(url, which) {
|
||||
let prom = _inflight[url];
|
||||
if (!prom) {
|
||||
_inflight[url] = prom = fetch(url)
|
||||
@@ -82,7 +96,7 @@ export function coreFileFetcher() {
|
||||
}
|
||||
|
||||
return prom;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Accessor for the file map
|
||||
|
||||
Reference in New Issue
Block a user