Update to name-suggestion-index v5

Merge in NSI presets after UI has initialized
This commit is contained in:
Bryan Housel
2021-01-05 10:32:01 -05:00
parent 2c2eabb145
commit b0800c10ed
3 changed files with 33 additions and 8 deletions
+21 -7
View File
@@ -6,7 +6,7 @@ import { select as d3_select } from 'd3-selection';
import { t } from '../core/localizer';
import { fileFetcher as data } from './file_fetcher';
import { fileFetcher } from './file_fetcher';
import { localizer } from './localizer';
import { prefs } from './preferences';
import { coreHistory } from './history';
@@ -447,7 +447,7 @@ export function coreContext() {
context.assetPath = function(val) {
if (!arguments.length) return _assetPath;
_assetPath = val;
data.assetPath(val);
fileFetcher.assetPath(val);
return context;
};
@@ -455,7 +455,7 @@ export function coreContext() {
context.assetMap = function(val) {
if (!arguments.length) return _assetMap;
_assetMap = val;
data.assetMap(val);
fileFetcher.assetMap(val);
return context;
};
@@ -576,13 +576,27 @@ export function coreContext() {
// if the container isn't available, e.g. when testing, don't load the UI
if (!context.container().empty()) {
_ui.ensureLoaded().then(function() {
_photos.init();
});
_ui.ensureLoaded()
.then(() => {
_photos.init();
loadNSIPresets();
});
}
}
};
function loadNSIPresets() {
return fileFetcher.get('nsi_presets')
.then(d => {
// Add `suggestion=true` to all the nsi presets
// The preset json schema doesn't include it, but the iD code still uses it
Object.values(d.presets).forEach(preset => preset.suggestion = true);
presetManager.merge({ presets: d.presets });
})
.catch(() => { /* ignore */ });
}
};
return context;
}
+11
View File
@@ -19,8 +19,19 @@ export function coreFileFetcher() {
'keepRight': 'data/keepRight.min.json',
'languages': 'data/languages.min.json',
'locales': 'locales/index.min.json',
// old
'nsi_brands': 'https://cdn.jsdelivr.net/npm/name-suggestion-index@4/dist/brands.min.json',
'nsi_filters': 'https://cdn.jsdelivr.net/npm/name-suggestion-index@4/dist/filters.min.json',
// new
'nsi_presets': 'https://raw.githubusercontent.com/osmlab/name-suggestion-index/main/dist/presets/nsi-id-presets.min.json',
'nsi_data': 'https://raw.githubusercontent.com/osmlab/name-suggestion-index/main/dist/nsi.min.json',
'nsi_features': 'https://raw.githubusercontent.com/osmlab/name-suggestion-index/main/dist/featureCollection.min.json',
'nsi_generics': 'https://raw.githubusercontent.com/osmlab/name-suggestion-index/main/dist/genericWords.min.json',
'nsi_replacements': 'https://raw.githubusercontent.com/osmlab/name-suggestion-index/main/dist/replacements.min.json',
'nsi_trees': 'https://raw.githubusercontent.com/osmlab/name-suggestion-index/main/dist/trees.min.json',
'oci_features': 'https://cdn.jsdelivr.net/npm/osm-community-index@3/dist/featureCollection.min.json',
'oci_resources': 'https://cdn.jsdelivr.net/npm/osm-community-index@3/dist/resources.min.json',
'preset_categories': 'https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@3/dist/preset_categories.min.json',
+1 -1
View File
@@ -99,7 +99,7 @@
"minimist": "^1.2.3",
"mocha": "^7.0.1",
"mocha-phantomjs-core": "^2.1.0",
"name-suggestion-index": "4.0.2",
"name-suggestion-index": "^5.0.0",
"node-fetch": "^2.6.1",
"npm-run-all": "^4.0.0",
"object-inspect": "1.9.0",