diff --git a/README.md b/README.md index 8fae3b677..8ae27c60c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ implemented as a single page application (SPA) for ease of development and to limit the overall number of catalog reads necessary when browsing (as catalogs may be nested and do not necessarily contain references to their parents). -Version: **3.0.0-beta.9** (supports all STAC versions between 0.6.0 and 1.0.0) +Version: **3.0.0-rc.1** (supports all STAC versions between 0.6.0 and 1.0.0) This package has also been published to npm as [`@radiantearth/stac-browser`](https://www.npmjs.com/package/@radiantearth/stac-browser). diff --git a/package.json b/package.json index c48497888..218066f6d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@radiantearth/stac-browser", - "version": "3.0.0-beta.9", + "version": "3.0.0-rc.1", "description": "A full-fledged UI in Vue for browsing and searching static STAC catalogs and STAC APIs.", "main": "src/main.js", "scripts": { diff --git a/src/locales/de-CH/default.js b/src/locales/de-CH/default.js index b0c24f981..267f6a275 100644 --- a/src/locales/de-CH/default.js +++ b/src/locales/de-CH/default.js @@ -1,4 +1,5 @@ -export default Object.assign( +import Utils from '../../utils'; +export default Utils.mergeDeep( { fields: require('../de/fields.json'), }, diff --git a/src/locales/de/default.js b/src/locales/de/default.js index 1853921fe..485258b64 100644 --- a/src/locales/de/default.js +++ b/src/locales/de/default.js @@ -1,4 +1,5 @@ -export default Object.assign( +import Utils from '../../utils'; +export default Utils.mergeDeep( { fields: require('./fields.json'), }, diff --git a/src/locales/en/default.js b/src/locales/en/default.js index 376314241..7dfdeb8ee 100644 --- a/src/locales/en/default.js +++ b/src/locales/en/default.js @@ -1,4 +1,5 @@ -export default Object.assign( +import Utils from '../../utils'; +export default Utils.mergeDeep( // Don't import the fields as it's a 1:1 mapping anyway // { fields: require('./fields.json') }, require('./texts.json'), diff --git a/src/locales/es/default.js b/src/locales/es/default.js index 1853921fe..485258b64 100644 --- a/src/locales/es/default.js +++ b/src/locales/es/default.js @@ -1,4 +1,5 @@ -export default Object.assign( +import Utils from '../../utils'; +export default Utils.mergeDeep( { fields: require('./fields.json'), }, diff --git a/src/locales/fr-CA/default.js b/src/locales/fr-CA/default.js index 1da4afb03..b8c426bf0 100644 --- a/src/locales/fr-CA/default.js +++ b/src/locales/fr-CA/default.js @@ -1,4 +1,5 @@ -export default Object.assign( +import Utils from '../../utils'; +export default Utils.mergeDeep( { fields: require('../fr/fields.json'), }, diff --git a/src/locales/fr-CH/default.js b/src/locales/fr-CH/default.js index 1da4afb03..b8c426bf0 100644 --- a/src/locales/fr-CH/default.js +++ b/src/locales/fr-CH/default.js @@ -1,4 +1,5 @@ -export default Object.assign( +import Utils from '../../utils'; +export default Utils.mergeDeep( { fields: require('../fr/fields.json'), }, diff --git a/src/locales/fr/default.js b/src/locales/fr/default.js index 1853921fe..485258b64 100644 --- a/src/locales/fr/default.js +++ b/src/locales/fr/default.js @@ -1,4 +1,5 @@ -export default Object.assign( +import Utils from '../../utils'; +export default Utils.mergeDeep( { fields: require('./fields.json'), }, diff --git a/src/locales/it-CH/default.js b/src/locales/it-CH/default.js index 793fdee34..246a85553 100644 --- a/src/locales/it-CH/default.js +++ b/src/locales/it-CH/default.js @@ -1,4 +1,5 @@ -export default Object.assign( +import Utils from '../../utils'; +export default Utils.mergeDeep( { fields: require('../it/fields.json'), }, diff --git a/src/locales/it/default.js b/src/locales/it/default.js index 1853921fe..485258b64 100644 --- a/src/locales/it/default.js +++ b/src/locales/it/default.js @@ -1,4 +1,5 @@ -export default Object.assign( +import Utils from '../../utils'; +export default Utils.mergeDeep( { fields: require('./fields.json'), }, diff --git a/src/locales/ro/default.js b/src/locales/ro/default.js index 1853921fe..485258b64 100644 --- a/src/locales/ro/default.js +++ b/src/locales/ro/default.js @@ -1,4 +1,5 @@ -export default Object.assign( +import Utils from '../../utils'; +export default Utils.mergeDeep( { fields: require('./fields.json'), }, diff --git a/src/utils.js b/src/utils.js index 31bf85456..c08334eed 100644 --- a/src/utils.js +++ b/src/utils.js @@ -398,4 +398,31 @@ export default class Utils { return Boolean(data['stac_extensions'].find(uri => regexp.test(uri))); } + /** + * Deep merge two objects. + * @param target + * @param ...sources + */ + static mergeDeep(target, ...sources) { + if (!sources.length) { + return target; + } + const source = sources.shift(); + + if (Utils.isObject(target) && Utils.isObject(source)) { + for (const key in source) { + if (Utils.isObject(source[key])) { + if (!target[key]) { + Object.assign(target, { [key]: {} }); + } + Utils.mergeDeep(target[key], source[key]); + } else { + Object.assign(target, { [key]: source[key] }); + } + } + } + + return Utils.mergeDeep(target, ...sources); + } + } \ No newline at end of file