Skip to content

Commit

Permalink
build(deps): upgrade geostyler-sld-parser v5.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ocruze committed Jun 24, 2024
1 parent a1b0da2 commit 3adfe66
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ const getSld100 = async (originalFile: File): Promise<File> => {
const version = xmlDoc.getElementsByTagName("StyledLayerDescriptor")[0].attributes?.["version"]?.nodeValue ?? "";

if (version === "1.1.0") {
const sld110Parser = new SldStyleParser({ sldVersion: "1.1.0" });
const sld100Parser = new SldStyleParser({ sldVersion: "1.0.0" });
const sld110Parser = new SldStyleParser({ sldVersion: "1.1.0", locale: "fr" });
const sld100Parser = new SldStyleParser({ sldVersion: "1.0.0", locale: "fr" });

const result = await sld110Parser.readStyle(fileContent);

Expand Down
2 changes: 1 addition & 1 deletion assets/modules/Style/StyleHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class StyleHelper {
switch (extension) {
case "sld": {
const version = this.#getVersion(styleString);
parser = new SldStyleParser({ sldVersion: version });
parser = new SldStyleParser({ sldVersion: version, locale: "fr" });
break;
}
case "qml": {
Expand Down
2 changes: 1 addition & 1 deletion assets/modules/Style/TMSStyleFilesManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default class TMSStyleFilesManager implements BaseStyleFilesManager {
const styleString = await file.text();

const version = this.inputFormat === "sld" ? this.#getVersion(styleString) : null;
const parser = this.inputFormat === "sld" ? new SldStyleParser({ sldVersion: version }) : new QGISStyleParser();
const parser = this.inputFormat === "sld" ? new SldStyleParser({ sldVersion: version, locale: "fr" }) : new QGISStyleParser();

const { output } = await parser.readStyle(styleString);
if (output === undefined) throw Error(t("parsing_error"));
Expand Down
8 changes: 7 additions & 1 deletion assets/validations/SldStyleValidationErrorsTr.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const SldStyleValidationErrorsFrTranslations: Translations<"fr">["SldStyl
plural ? "n'ont" : "n'a"
} pas de symbolisation spécifiée.`;
},
geostyler_parse_error: ({ geostylerError }) => `Erreur de lecture : ${geostylerError}`,
geostyler_parse_error: ({ geostylerError }) => decodeHTMLEntities(geostylerError),
geostyler_unexpected_error: ({ geostylerError }) => `Une erreur inattendue est survenue : ${geostylerError}`,
};

Expand All @@ -53,3 +53,9 @@ export const SldStyleValidationErrorsEnTranslations: Translations<"en">["SldStyl
geostyler_parse_error: undefined,
geostyler_unexpected_error: undefined,
};

const decodeHTMLEntities = (text: string) => {
const textArea = document.createElement("textarea");
textArea.innerHTML = text;
return textArea.value;
};
2 changes: 1 addition & 1 deletion assets/validations/SldStyleValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class SldStyleValidator extends StyleValidator {
return ctx.createError({ message: tSld("sld_version_unaccepted", { version }) });
}

const sldParser = new SldStyleParser({ sldVersion: version });
const sldParser = new SldStyleParser({ sldVersion: version, locale: "fr" });
const result = await sldParser.readStyle(styleString);

const { output, warnings, errors, unsupportedProperties } = result;
Expand Down
2 changes: 1 addition & 1 deletion assets/validations/sldStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default class SldStyleWmsVectorValidator {
return ctx.createError({ message: tSld("sld_version_unaccepted", { version }) });
}

const sldParser = new SldStyleParser({ sldVersion: version });
const sldParser = new SldStyleParser({ sldVersion: version, locale: "fr" });
const result = await sldParser.readStyle(styleString);

const { output, warnings, errors, unsupportedProperties } = result;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"geostyler-mapbox-parser": "^5.0.1",
"geostyler-openlayers-parser": "^4.3.0",
"geostyler-qgis-parser": "^2.0.0",
"geostyler-sld-parser": "^5.1.0",
"geostyler-sld-parser": "^5.4.0",
"geostyler-style": "^8.0.0",
"i18nifty": "^3.0.0",
"ol": "6.9.0",
Expand Down Expand Up @@ -87,4 +87,4 @@
"browserslist": [
"defaults"
]
}
}
23 changes: 19 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,13 @@
dependencies:
regenerator-runtime "^0.14.0"

"@babel/runtime@^7.23.2":
version "7.24.7"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.24.7.tgz#f4f0d5530e8dbdf59b3451b9b3e594b6ba082e12"
integrity sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw==
dependencies:
regenerator-runtime "^0.14.0"

"@babel/template@^7.22.15", "@babel/template@^7.24.0":
version "7.24.0"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.24.0.tgz#c6a524aa93a4a05d66aaf31654258fae69d87d50"
Expand Down Expand Up @@ -4495,13 +4502,14 @@ geostyler-qgis-parser@^2.0.0:
xml2js "^0.4.23"
xmldom "^0.6.0"

geostyler-sld-parser@^5.1.0:
version "5.3.1"
resolved "https://registry.yarnpkg.com/geostyler-sld-parser/-/geostyler-sld-parser-5.3.1.tgz#f7033a1bbc7418f92de06555720c4879d5c33955"
integrity sha512-JwK1S+ZL5iHdXge96KrM468mOS2/MOH3+6L3RfoABrt+DF3SKSp1Yt94uzctswIHF4MUaamBtqJMIMWFVyk7tA==
geostyler-sld-parser@^5.4.0:
version "5.4.0"
resolved "https://registry.yarnpkg.com/geostyler-sld-parser/-/geostyler-sld-parser-5.4.0.tgz#01eba5df52c702ebbc3d71ac7d2efa76fa802408"
integrity sha512-TY/gwMoE/M8Xv8ykviC1NqygykrojvrFSCRIc/+CNww5VS0Qf9pu9JxiSQONGfR6QWDPtQrfFIoazyH67c0jTg==
dependencies:
fast-xml-parser "^4.2.2"
geostyler-style "^8.1.0"
i18next "^23.11.5"
lodash "^4.17.21"

geostyler-style@^7.2.0:
Expand Down Expand Up @@ -5051,6 +5059,13 @@ human-signals@^2.1.0:
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0"
integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==

i18next@^23.11.5:
version "23.11.5"
resolved "https://registry.yarnpkg.com/i18next/-/i18next-23.11.5.tgz#d71eb717a7e65498d87d0594f2664237f9e361ef"
integrity sha512-41pvpVbW9rhZPk5xjCX2TPJi2861LEig/YRhUkY+1FQ2IQPS0bKUDYnEqY8XPPbB48h1uIwLnP9iiEfuSl20CA==
dependencies:
"@babel/runtime" "^7.23.2"

i18nifty@^3.0.0:
version "3.2.1"
resolved "https://registry.yarnpkg.com/i18nifty/-/i18nifty-3.2.1.tgz#ee27e76cfdb8591d26ac980063567fac75a19c11"
Expand Down

0 comments on commit 3adfe66

Please sign in to comment.