From 2caf5a7dc10c3f121732e7f869566d868aed4595 Mon Sep 17 00:00:00 2001 From: Nanda Date: Fri, 26 Apr 2024 10:36:27 +1000 Subject: [PATCH 01/17] Provide ambient types or TSify some js/jsx files. --- buildprocess/configureWebpack.js | 9 ++ lib/Core/ConsoleAnalytics.d.ts | 17 +++ lib/Core/ConsoleAnalytics.js | 4 +- lib/Core/{DataUri.js => DataUri.ts} | 8 +- lib/Core/ServerConfig.d.ts | 6 + lib/Core/ServerConfig.js | 4 +- .../{arrayContains.js => arrayContains.ts} | 6 +- ...ropertyValue.js => formatPropertyValue.ts} | 8 +- .../{linkifyContent.js => linkifyContent.ts} | 12 +- lib/Core/loadText.js | 10 -- lib/Core/loadText.ts | 12 ++ lib/Core/loadWithXhr.d.ts | 13 ++ lib/Core/loadWithXhr.js | 2 +- lib/Core/markdownToHtml.ts | 10 +- .../{pollToPromise.js => pollToPromise.ts} | 17 ++- lib/Core/{readJson.js => readJson.ts} | 15 +- lib/Core/{readText.js => readText.ts} | 15 +- lib/Core/{readXml.js => readXml.ts} | 18 +-- .../{triggerResize.js => triggerResize.ts} | 6 +- lib/Map/DragPoints/DragPoints.d.ts | 17 +++ lib/Map/DragPoints/DragPoints.js | 4 +- .../{LeafletPatched.js => LeafletPatched.ts} | 3 +- lib/Map/Vector/EarthGravityModel1996.d.ts | 10 ++ .../Catalog/CatalogItems/KmlCatalogItem.ts | 38 ++--- lib/Models/LocationMarkerUtils.ts | 4 +- lib/Models/ShareDataService.ts | 2 +- lib/Models/markerIcon.js | 2 - lib/Models/sendFeedback.ts | 3 +- lib/ReactViewModels/DisclaimerHandler.js | 135 ------------------ lib/ReactViewModels/MouseCoords.ts | 11 +- lib/ReactViewModels/ViewState.ts | 5 - .../{DateFormats.js => DateFormats.ts} | 32 ++--- .../BottomDock/Timeline/Timeline.d.ts | 13 ++ lib/ReactViews/Custom/Chart/ChartPanel.d.ts | 12 ++ .../Custom/parseCustomHtmlToReact.ts | 11 +- lib/ReactViews/Disclaimer.d.ts | 5 + lib/ReactViews/DragDropNotification.d.ts | 5 + lib/ReactViews/DragDropNotification.jsx | 1 - lib/ReactViews/ExplorerWindow/Tabs.d.ts | 13 ++ lib/ReactViews/Generic/CloseButton.tsx | 34 +++++ lib/ReactViews/Generic/Prompt.d.ts | 20 +++ ...HelpPrompt.jsx => SatelliteHelpPrompt.tsx} | 0 .../Items/Compass/GyroscopeGuidance.d.ts | 9 ++ lib/ReactViews/Map/MenuBar/MenuBar.d.ts | 11 ++ .../Map/Panels/HelpPanel/HelpPanel.d.ts | 4 + .../Map/Panels/HelpPanel/VideoGuide.d.ts | 14 ++ lib/ReactViews/Mobile/MobileHeader.d.ts | 12 ++ lib/ReactViews/Preview/Description.d.ts | 11 ++ ...vateIndicator.jsx => PrivateIndicator.tsx} | 18 +-- .../Search/SearchBoxAndResults.d.ts | 22 +++ .../SidePanel/FullScreenButton.d.ts | 13 ++ .../StandardUserInterface/StandardTheme.jsx | 8 -- .../StandardUserInterface/StandardTheme.tsx | 9 ++ .../processCustomElements.d.ts | 15 ++ lib/ReactViews/Tour/TourPortal.d.ts | 6 + lib/ReactViews/Transitions/FadeIn/FadeIn.d.ts | 9 ++ .../SlideUpFadeIn/SlideUpFadeIn.d.ts | 9 ++ .../WelcomeMessage/WelcomeMessage.d.ts | 12 ++ .../Controls/ColorScaleRangeSection.d.ts | 11 ++ .../Workbench/Controls/FilterSection.d.ts | 9 ++ .../SatelliteImageryTimeFilterSection.d.ts | 9 ++ .../Workbench/Controls/TimerSection.d.ts | 5 + lib/Styled/{mixins.js => mixins.ts} | 26 ++-- package.json | 6 +- yarn.lock | 75 +++++----- 65 files changed, 547 insertions(+), 348 deletions(-) create mode 100644 lib/Core/ConsoleAnalytics.d.ts rename lib/Core/{DataUri.js => DataUri.ts} (85%) create mode 100644 lib/Core/ServerConfig.d.ts rename lib/Core/{arrayContains.js => arrayContains.ts} (57%) rename lib/Core/{formatPropertyValue.js => formatPropertyValue.ts} (84%) rename lib/Core/{linkifyContent.js => linkifyContent.ts} (75%) delete mode 100644 lib/Core/loadText.js create mode 100644 lib/Core/loadText.ts create mode 100644 lib/Core/loadWithXhr.d.ts rename lib/Core/{pollToPromise.js => pollToPromise.ts} (51%) rename lib/Core/{readJson.js => readJson.ts} (58%) rename lib/Core/{readText.js => readText.ts} (53%) rename lib/Core/{readXml.js => readXml.ts} (59%) rename lib/Core/{triggerResize.js => triggerResize.ts} (77%) create mode 100644 lib/Map/DragPoints/DragPoints.d.ts rename lib/Map/{LeafletPatched.js => LeafletPatched.ts} (90%) create mode 100644 lib/Map/Vector/EarthGravityModel1996.d.ts delete mode 100644 lib/Models/markerIcon.js delete mode 100644 lib/ReactViewModels/DisclaimerHandler.js rename lib/ReactViews/BottomDock/Timeline/{DateFormats.js => DateFormats.ts} (53%) create mode 100644 lib/ReactViews/BottomDock/Timeline/Timeline.d.ts create mode 100644 lib/ReactViews/Custom/Chart/ChartPanel.d.ts create mode 100644 lib/ReactViews/Disclaimer.d.ts create mode 100644 lib/ReactViews/DragDropNotification.d.ts create mode 100644 lib/ReactViews/ExplorerWindow/Tabs.d.ts create mode 100644 lib/ReactViews/Generic/CloseButton.tsx create mode 100644 lib/ReactViews/Generic/Prompt.d.ts rename lib/ReactViews/HelpScreens/{SatelliteHelpPrompt.jsx => SatelliteHelpPrompt.tsx} (100%) create mode 100644 lib/ReactViews/Map/MapNavigation/Items/Compass/GyroscopeGuidance.d.ts create mode 100644 lib/ReactViews/Map/MenuBar/MenuBar.d.ts create mode 100644 lib/ReactViews/Map/Panels/HelpPanel/HelpPanel.d.ts create mode 100644 lib/ReactViews/Map/Panels/HelpPanel/VideoGuide.d.ts create mode 100644 lib/ReactViews/Mobile/MobileHeader.d.ts create mode 100644 lib/ReactViews/Preview/Description.d.ts rename lib/ReactViews/PrivateIndicator/{PrivateIndicator.jsx => PrivateIndicator.tsx} (61%) create mode 100644 lib/ReactViews/Search/SearchBoxAndResults.d.ts create mode 100644 lib/ReactViews/SidePanel/FullScreenButton.d.ts delete mode 100644 lib/ReactViews/StandardUserInterface/StandardTheme.jsx create mode 100644 lib/ReactViews/StandardUserInterface/StandardTheme.tsx create mode 100644 lib/ReactViews/StandardUserInterface/processCustomElements.d.ts create mode 100644 lib/ReactViews/Tour/TourPortal.d.ts create mode 100644 lib/ReactViews/Transitions/FadeIn/FadeIn.d.ts create mode 100644 lib/ReactViews/Transitions/SlideUpFadeIn/SlideUpFadeIn.d.ts create mode 100644 lib/ReactViews/WelcomeMessage/WelcomeMessage.d.ts create mode 100644 lib/ReactViews/Workbench/Controls/ColorScaleRangeSection.d.ts create mode 100644 lib/ReactViews/Workbench/Controls/FilterSection.d.ts create mode 100644 lib/ReactViews/Workbench/Controls/SatelliteImageryTimeFilterSection.d.ts create mode 100644 lib/ReactViews/Workbench/Controls/TimerSection.d.ts rename lib/Styled/{mixins.js => mixins.ts} (81%) diff --git a/buildprocess/configureWebpack.js b/buildprocess/configureWebpack.js index 964deee41f0..57978564483 100644 --- a/buildprocess/configureWebpack.js +++ b/buildprocess/configureWebpack.js @@ -32,6 +32,7 @@ function configureWebpack( ".webpack.js", ".web.js", ".js", + ".mjs", ".ts", ".tsx" ]; @@ -111,6 +112,14 @@ function configureWebpack( }) }); + // Some packages exports an .mjs file for ESM imports. + // This rule instructs webpack to import mjs modules correctly. + config.module.rules.push({ + test: /\.mjs$/, + include: /node_modules/, + type: "javascript/auto" + }); + const zipJsDir = path.dirname(require.resolve("@zip.js/zip.js/package.json")); config.module.rules.push({ diff --git a/lib/Core/ConsoleAnalytics.d.ts b/lib/Core/ConsoleAnalytics.d.ts new file mode 100644 index 00000000000..d59edf93e53 --- /dev/null +++ b/lib/Core/ConsoleAnalytics.d.ts @@ -0,0 +1,17 @@ +declare class ConsoleAnalytics { + start: ( + configParameters: Partial<{ + enableConsoleAnalytics: boolean; + googleAnalyticsKey: any; + googleAnalyticsOptions: any; + }> + ) => void; + logEvent: ( + category: string, + action: string, + label?: string, + value?: number + ) => void; +} + +export default ConsoleAnalytics; diff --git a/lib/Core/ConsoleAnalytics.js b/lib/Core/ConsoleAnalytics.js index 2a6dc4e662a..ba57a641e37 100644 --- a/lib/Core/ConsoleAnalytics.js +++ b/lib/Core/ConsoleAnalytics.js @@ -1,5 +1,3 @@ -"use strict"; - var defined = require("terriajs-cesium/Source/Core/defined").default; const i18next = require("i18next").default; @@ -49,4 +47,4 @@ ConsoleAnalytics.prototype.logEvent = function ( } }; -module.exports = ConsoleAnalytics; +export default ConsoleAnalytics; diff --git a/lib/Core/DataUri.js b/lib/Core/DataUri.ts similarity index 85% rename from lib/Core/DataUri.js rename to lib/Core/DataUri.ts index 0518ed093e8..8b8097284d0 100644 --- a/lib/Core/DataUri.js +++ b/lib/Core/DataUri.ts @@ -1,18 +1,14 @@ -"use strict"; - -var DataUri = { +export default { /** * Turn a file with the supplied type and stringified data into a data uri that can be set as the href of an anchor tag. * @param {String} type Data type, eg. 'json' or 'csv'. * @param {String} dataString The data. * @return {String} A string that can be used to in an anchor tag's 'href' attribute to represent downloadable data. */ - make: function (type, dataString) { + make: function (type: string, dataString: string): string | undefined { if (dataString) { // Using attachment/* mime type makes safari download as attachment. text/* works on Chrome (as does attachment). return "data:attachment/" + type + "," + encodeURIComponent(dataString); } } }; - -module.exports = DataUri; diff --git a/lib/Core/ServerConfig.d.ts b/lib/Core/ServerConfig.d.ts new file mode 100644 index 00000000000..7195274ec41 --- /dev/null +++ b/lib/Core/ServerConfig.d.ts @@ -0,0 +1,6 @@ +declare class ServerConfig { + config: unknown; + init(serverConfigUrl: string): Promise; +} + +export default ServerConfig; diff --git a/lib/Core/ServerConfig.js b/lib/Core/ServerConfig.js index 766d0bb136e..0d9a3b45725 100644 --- a/lib/Core/ServerConfig.js +++ b/lib/Core/ServerConfig.js @@ -1,5 +1,3 @@ -"use strict"; - const i18next = require("i18next").default; var defaultValue = require("terriajs-cesium/Source/Core/defaultValue").default; var loadJson = require("./loadJson").default; @@ -49,4 +47,4 @@ ServerConfig.prototype.init = function (serverConfigUrl) { }); }; -module.exports = ServerConfig; +export default ServerConfig; diff --git a/lib/Core/arrayContains.js b/lib/Core/arrayContains.ts similarity index 57% rename from lib/Core/arrayContains.js rename to lib/Core/arrayContains.ts index 8930b8214ad..51998e73e70 100644 --- a/lib/Core/arrayContains.js +++ b/lib/Core/arrayContains.ts @@ -1,12 +1,8 @@ -"use strict"; - -function arrayContains(array, value) { +export default function arrayContains(array: readonly T[], value: T) { for (var i = 0; i < array.length; ++i) { if (array[i] === value) { return true; } } - return false; } -module.exports = arrayContains; diff --git a/lib/Core/formatPropertyValue.js b/lib/Core/formatPropertyValue.ts similarity index 84% rename from lib/Core/formatPropertyValue.js rename to lib/Core/formatPropertyValue.ts index ba83320aec4..31da5c7ebe1 100644 --- a/lib/Core/formatPropertyValue.js +++ b/lib/Core/formatPropertyValue.ts @@ -1,6 +1,4 @@ -"use strict"; - -var linkifyContent = require("./linkifyContent"); +import linkifyContent from "./linkifyContent"; /** * Format the value for the description, used by the Feature Info Panel. @@ -9,7 +7,7 @@ var linkifyContent = require("./linkifyContent"); * @param {} value The value to format. * @param {Object} [options] Number formatting options, passed to Number.toLocaleString(). */ -function formatPropertyValue(value, options) { +function formatPropertyValue(value: any, options?: Intl.NumberFormatOptions) { if (typeof value === "number") { // Note we default useGrouping to false (not true) and maximumFractionDigits to 20 (not 3). return value.toLocaleString(undefined, { @@ -27,4 +25,4 @@ function formatPropertyValue(value, options) { return value; } -module.exports = formatPropertyValue; +export default formatPropertyValue; diff --git a/lib/Core/linkifyContent.js b/lib/Core/linkifyContent.ts similarity index 75% rename from lib/Core/linkifyContent.js rename to lib/Core/linkifyContent.ts index c8063ae9b8e..d04f1667958 100644 --- a/lib/Core/linkifyContent.js +++ b/lib/Core/linkifyContent.ts @@ -1,11 +1,11 @@ -"use strict"; +import linkifyIt from "linkify-it"; -var linkify = require("linkify-it")(); +const linkify = linkifyIt(); -function linkifyContent(content) { - var matches = linkify.match(content), +function linkifyContent(content: string) { + let matches = linkify.match(content), result = [], - last; + last: number; if (matches) { last = 0; @@ -29,4 +29,4 @@ function linkifyContent(content) { return content; } -module.exports = linkifyContent; +export default linkifyContent; diff --git a/lib/Core/loadText.js b/lib/Core/loadText.js deleted file mode 100644 index 2c05abe1128..00000000000 --- a/lib/Core/loadText.js +++ /dev/null @@ -1,10 +0,0 @@ -const Resource = require("terriajs-cesium/Source/Core/Resource").default; - -function loadText(urlOrResource, headers) { - var resource = Resource.createIfNeeded(urlOrResource); - return resource.fetchText({ - headers: headers - }); -} - -module.exports = loadText; diff --git a/lib/Core/loadText.ts b/lib/Core/loadText.ts new file mode 100644 index 00000000000..60ac3bcd010 --- /dev/null +++ b/lib/Core/loadText.ts @@ -0,0 +1,12 @@ +import Resource from "terriajs-cesium/Source/Core/Resource"; + +async function loadText(urlOrResource: string | Resource): Promise { + var resource = (Resource as any).createIfNeeded(urlOrResource) as Resource; + const response = resource.fetchText(); + if (response === undefined) { + throw new Error("Request throttled"); + } + return response; +} + +export default loadText; diff --git a/lib/Core/loadWithXhr.d.ts b/lib/Core/loadWithXhr.d.ts new file mode 100644 index 00000000000..70f42f9119c --- /dev/null +++ b/lib/Core/loadWithXhr.d.ts @@ -0,0 +1,13 @@ +import Resource from "terriajs-cesium/Source/Core/Resource"; + +interface Options extends Resource.ConstructorOptions { + responseType?: string; + headers?: any; + overrideMimeType?: string; + method?: "GET" | "POST" | "PUT"; + data?: any; +} + +declare function loadWithXhr(options: Options): Promise; + +export default loadWithXhr; diff --git a/lib/Core/loadWithXhr.js b/lib/Core/loadWithXhr.js index 668a6bab9b4..d656fe46f32 100644 --- a/lib/Core/loadWithXhr.js +++ b/lib/Core/loadWithXhr.js @@ -31,4 +31,4 @@ Object.defineProperties(loadWithXhr, { } }); -module.exports = loadWithXhr; +export default loadWithXhr; diff --git a/lib/Core/markdownToHtml.ts b/lib/Core/markdownToHtml.ts index 63e5231c452..fafb1df3a20 100644 --- a/lib/Core/markdownToHtml.ts +++ b/lib/Core/markdownToHtml.ts @@ -1,10 +1,8 @@ -"use strict"; - -const defined = require("terriajs-cesium/Source/Core/defined").default; -const MarkdownIt = require("markdown-it"); -const DOMPurify = require("dompurify/dist/purify"); -import injectTerms from "./injectTerms"; +import DOMPurify from "dompurify"; +import MarkdownIt from "markdown-it"; +import defined from "terriajs-cesium/Source/Core/defined"; import { Term } from "../ReactViewModels/defaultTerms"; +import injectTerms from "./injectTerms"; const md = new MarkdownIt({ html: true, diff --git a/lib/Core/pollToPromise.js b/lib/Core/pollToPromise.ts similarity index 51% rename from lib/Core/pollToPromise.js rename to lib/Core/pollToPromise.ts index d66d1a41558..f1012902caf 100644 --- a/lib/Core/pollToPromise.js +++ b/lib/Core/pollToPromise.ts @@ -1,15 +1,18 @@ -"use strict"; +import defaultValue from "terriajs-cesium/Source/Core/defaultValue"; +import getTimestamp from "terriajs-cesium/Source/Core/getTimestamp"; -var defaultValue = require("terriajs-cesium/Source/Core/defaultValue").default; -var getTimestamp = require("terriajs-cesium/Source/Core/getTimestamp").default; +interface Options { + pollInterval?: number; + timeout?: number; +} -var pollToPromise = function (f, options) { - options = defaultValue(options, defaultValue.EMPTY_OBJECT); +const pollToPromise = function (f: () => boolean, options: Options) { + options = defaultValue(options, (defaultValue as any).EMPTY_OBJECT); var pollInterval = defaultValue(options.pollInterval, 1); var timeout = defaultValue(options.timeout, 5000); - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { var startTimestamp = getTimestamp(); var endTimestamp = startTimestamp + timeout; @@ -29,4 +32,4 @@ var pollToPromise = function (f, options) { }); }; -module.exports = pollToPromise; +export default pollToPromise; diff --git a/lib/Core/readJson.js b/lib/Core/readJson.ts similarity index 58% rename from lib/Core/readJson.js rename to lib/Core/readJson.ts index da1a98c7d10..672d804f268 100644 --- a/lib/Core/readJson.js +++ b/lib/Core/readJson.ts @@ -1,20 +1,19 @@ -"use strict"; - -const json5 = require("json5"); -const readText = require("./readText"); +import json5 from "json5"; +import { JsonObject } from "./Json"; +import readText from "./readText"; /** * Try to read the file as JSON. If that fails, try JSON5. * @param {File} file The file. * @return {Promise} The JSON or json5 object described by the file. */ -function readJson(file) { +function readJson(file: Blob): Promise { return readText(file).then((s) => { try { - return JSON.parse(s); + return JSON.parse(s!); } catch (e) { if (e instanceof SyntaxError) { - return json5.parse(s); + return json5.parse(s!); } else { throw e; } @@ -22,4 +21,4 @@ function readJson(file) { }); } -module.exports = readJson; +export default readJson; diff --git a/lib/Core/readText.js b/lib/Core/readText.ts similarity index 53% rename from lib/Core/readText.js rename to lib/Core/readText.ts index fc85b495436..622362de8f0 100644 --- a/lib/Core/readText.js +++ b/lib/Core/readText.ts @@ -1,10 +1,7 @@ -"use strict"; -const i18next = require("i18next").default; +import i18next from "i18next"; +import DeveloperError from "terriajs-cesium/Source/Core/DeveloperError"; -const DeveloperError = - require("terriajs-cesium/Source/Core/DeveloperError").default; - -function readText(file) { +function readText(file: Blob): Promise { return new Promise((resolve, reject) => { if (typeof file === "undefined") { throw new DeveloperError(i18next.t("core.readText.fileRequired")); @@ -14,8 +11,8 @@ function readText(file) { reader.readAsText(file); reader.onload = function (event) { - const allText = event.target.result; - resolve(allText); + const allText = event.target?.result; + resolve((allText ?? undefined) as string | undefined); }; reader.onerror = function (e) { reject(e); @@ -23,4 +20,4 @@ function readText(file) { }); } -module.exports = readText; +export default readText; diff --git a/lib/Core/readXml.js b/lib/Core/readXml.ts similarity index 59% rename from lib/Core/readXml.js rename to lib/Core/readXml.ts index c21fb7264be..0d0833a57ab 100644 --- a/lib/Core/readXml.js +++ b/lib/Core/readXml.ts @@ -1,18 +1,18 @@ -"use strict"; +import i18next from "i18next"; +import readText from "./readText"; +import RuntimeError from "terriajs-cesium/Source/Core/RuntimeError"; -const i18next = require("i18next").default; -var readText = require("./readText"); +let parser: DOMParser; -var RuntimeError = require("terriajs-cesium/Source/Core/RuntimeError").default; - -var parser; - -function readXml(file) { +function readXml(file: Blob) { return readText(file).then(function (result) { if (!parser) { parser = new DOMParser(); } + if (!result) { + return undefined; + } var xml = parser.parseFromString(result, "application/xml"); if ( !xml || @@ -25,4 +25,4 @@ function readXml(file) { }); } -module.exports = readXml; +export default readXml; diff --git a/lib/Core/triggerResize.js b/lib/Core/triggerResize.ts similarity index 77% rename from lib/Core/triggerResize.js rename to lib/Core/triggerResize.ts index 664226ddf15..004d0c36b3c 100644 --- a/lib/Core/triggerResize.js +++ b/lib/Core/triggerResize.ts @@ -1,9 +1,7 @@ -"use strict"; - /** * Trigger a window resize event. */ -function triggerResize() { +export default function triggerResize() { try { window.dispatchEvent(new Event("resize")); } catch (e) { @@ -12,5 +10,3 @@ function triggerResize() { window.dispatchEvent(evt); } } - -module.exports = triggerResize; diff --git a/lib/Map/DragPoints/DragPoints.d.ts b/lib/Map/DragPoints/DragPoints.d.ts new file mode 100644 index 00000000000..a450bdb86c1 --- /dev/null +++ b/lib/Map/DragPoints/DragPoints.d.ts @@ -0,0 +1,17 @@ +import CustomDataSource from "terriajs-cesium/Source/DataSources/CustomDataSource"; +import Terria from "../../Models/Terria"; + +declare class DragPoints { + constructor( + terria: Terria, + pointMovedCallback: (draggableObjects: CustomDataSource) => void + ); + + setUp(): void; + updateDraggableObjects(draggableObjects: CustomDataSource): void; + getDragCount(): number; + resetDragCount(): void; + destroy(): void; +} + +export default DragPoints; diff --git a/lib/Map/DragPoints/DragPoints.js b/lib/Map/DragPoints/DragPoints.js index fc50c39646b..0062d4b6c97 100644 --- a/lib/Map/DragPoints/DragPoints.js +++ b/lib/Map/DragPoints/DragPoints.js @@ -1,5 +1,3 @@ -"use strict"; - var defined = require("terriajs-cesium/Source/Core/defined").default; var CesiumDragPoints = require("./CesiumDragPoints"); var LeafletDragPoints = require("./LeafletDragPoints"); @@ -99,4 +97,4 @@ DragPoints.prototype._createDragPointsHelper = function (pointMovedCallback) { } }; -module.exports = DragPoints; +export default DragPoints; diff --git a/lib/Map/LeafletPatched.js b/lib/Map/LeafletPatched.ts similarity index 90% rename from lib/Map/LeafletPatched.js rename to lib/Map/LeafletPatched.ts index 4583f16674e..55062c0e9d0 100644 --- a/lib/Map/LeafletPatched.js +++ b/lib/Map/LeafletPatched.ts @@ -3,7 +3,8 @@ import L from "leaflet"; // Function taken from Leaflet 1.0.1 (https://github.com/Leaflet/Leaflet/blob/v1.0.1/src/layer/vector/Canvas.js#L254-L267) // Leaflet 1.0.2 and later don't trigger click events for every Path, so feature selection only gives 1 result. // Updated to incorporate function changes up to v1.7.1 -L.Canvas.prototype._onClick = function (e) { +const Canvas = L.Canvas as any; +Canvas.prototype._onClick = function (e: any) { const point = this._map.mouseEventToLayerPoint(e); const layers = []; for (let order = this._drawFirst; order; order = order.next) { diff --git a/lib/Map/Vector/EarthGravityModel1996.d.ts b/lib/Map/Vector/EarthGravityModel1996.d.ts new file mode 100644 index 00000000000..d894292d80c --- /dev/null +++ b/lib/Map/Vector/EarthGravityModel1996.d.ts @@ -0,0 +1,10 @@ +declare class EarthGravityModel1996 { + readonly minimumHeight: number; + readonly maximumHeight: number; + + constructor(gridFileUrl: string); + + getHeight(longitude: number, latitude: number): Promise; +} + +export default EarthGravityModel1996; diff --git a/lib/Models/Catalog/CatalogItems/KmlCatalogItem.ts b/lib/Models/Catalog/CatalogItems/KmlCatalogItem.ts index 8d7cc0e0e30..170bf30c9fe 100644 --- a/lib/Models/Catalog/CatalogItems/KmlCatalogItem.ts +++ b/lib/Models/Catalog/CatalogItems/KmlCatalogItem.ts @@ -63,28 +63,30 @@ class KmlCatalogItem } protected forceLoadMapItems(): Promise { - return new Promise((resolve) => { - if (isDefined(this.kmlString)) { - const parser = new DOMParser(); - resolve(parser.parseFromString(this.kmlString, "text/xml")); - } else if (isDefined(this._kmlFile)) { - if (this._kmlFile.name && this._kmlFile.name.match(kmzRegex)) { - resolve(this._kmlFile); + return new Promise( + (resolve) => { + if (isDefined(this.kmlString)) { + const parser = new DOMParser(); + resolve(parser.parseFromString(this.kmlString, "text/xml")); + } else if (isDefined(this._kmlFile)) { + if (this._kmlFile.name && this._kmlFile.name.match(kmzRegex)) { + resolve(this._kmlFile); + } else { + resolve(readXml(this._kmlFile)); + } + } else if (isDefined(this.url)) { + resolve(proxyCatalogItemUrl(this, this.url)); } else { - resolve(readXml(this._kmlFile)); + throw networkRequestError({ + sender: this, + title: i18next.t("models.kml.unableToLoadItemTitle"), + message: i18next.t("models.kml.unableToLoadItemMessage") + }); } - } else if (isDefined(this.url)) { - resolve(proxyCatalogItemUrl(this, this.url)); - } else { - throw networkRequestError({ - sender: this, - title: i18next.t("models.kml.unableToLoadItemTitle"), - message: i18next.t("models.kml.unableToLoadItemMessage") - }); } - }) + ) .then((kmlLoadInput) => { - return KmlDataSource.load(kmlLoadInput); + return KmlDataSource.load(kmlLoadInput!); }) .then((dataSource) => { this._dataSource = dataSource; diff --git a/lib/Models/LocationMarkerUtils.ts b/lib/Models/LocationMarkerUtils.ts index d6c93ba9df4..b16977b7ded 100644 --- a/lib/Models/LocationMarkerUtils.ts +++ b/lib/Models/LocationMarkerUtils.ts @@ -1,5 +1,4 @@ import i18next from "i18next"; -import markerIcon from "./markerIcon"; import prettifyCoordinates from "../Map/Vector/prettifyCoordinates"; import CommonStrata from "./Definition/CommonStrata"; import CzmlCatalogItem from "./Catalog/CatalogItems/CzmlCatalogItem"; @@ -7,6 +6,9 @@ import Terria from "./Terria"; import LatLonHeight from "../Core/LatLonHeight"; import { toJS } from "mobx"; +//@ts-ignore +import markerIcon from "../../wwwroot/images/map-pin.png"; + export const LOCATION_MARKER_DATA_SOURCE_NAME = "TerriaJS Location Marker Points"; export const MARKER_UNIQUE_ID = "__TERRRIAJS-LOCATIONMARKER__"; diff --git a/lib/Models/ShareDataService.ts b/lib/Models/ShareDataService.ts index 6162148eb40..eae9fb1e3fc 100644 --- a/lib/Models/ShareDataService.ts +++ b/lib/Models/ShareDataService.ts @@ -58,7 +58,7 @@ export default class ShareDataService { try { const result = await loadWithXhr({ - url: this.url, + url: this.url!, method: "POST", data: JSON.stringify(shareData), headers: { "Content-Type": "application/json" }, diff --git a/lib/Models/markerIcon.js b/lib/Models/markerIcon.js deleted file mode 100644 index 34a51c1c210..00000000000 --- a/lib/Models/markerIcon.js +++ /dev/null @@ -1,2 +0,0 @@ -import markerIcon from "../../wwwroot/images/map-pin.png"; -export default markerIcon; diff --git a/lib/Models/sendFeedback.ts b/lib/Models/sendFeedback.ts index 60bbf6016f7..3338a5522b3 100644 --- a/lib/Models/sendFeedback.ts +++ b/lib/Models/sendFeedback.ts @@ -28,6 +28,7 @@ export default function sendFeedback(options: { raiseError(terria, "`terria.configParameters.feedbackUrl` is not defined"); return; } + const feedbackUrl = terria.configParameters.feedbackUrl; const shareLinkPromise = options.sendShareURL ? canShorten(terria) @@ -56,7 +57,7 @@ export default function sendFeedback(options: { ); } return loadWithXhr({ - url: terria.configParameters.feedbackUrl, + url: feedbackUrl, responseType: "json", method: "POST", data: JSON.stringify(feedbackData), diff --git a/lib/ReactViewModels/DisclaimerHandler.js b/lib/ReactViewModels/DisclaimerHandler.js deleted file mode 100644 index 1ce8eec8111..00000000000 --- a/lib/ReactViewModels/DisclaimerHandler.js +++ /dev/null @@ -1,135 +0,0 @@ -"use strict"; - -import defined from "terriajs-cesium/Source/Core/defined"; -import combine from "terriajs-cesium/Source/Core/combine"; - -/** - * Shows disclaimers for {@link CatalogItem}s that are dispatched through {@link Terria#disclaimerEvent} - ensures that - * disclaimers that share the same key (as specified in {@link CatalogItem#initialMessage#key}) are only ever displayed - * once per key - if a single disclaimer is triggered 3 different times, for instance, one disclaimer popup will be - * displayed, and then once that disclaimer is accepted, the callbacks for all three {@Terria#disclaimerEvent} will be - * executed. This response will be persisted in localStorage so that subsequent calls to {@Terria#disclaimerEvent} do - * not display any disclaimer and have their successCallback executed immediately. - * - * Also accepts disclaimers with no key, which will always be displayed, and disclaimers with no need for confirmation - * (as specified by {@link CatalogItem#initialMessage#confirmation}), which will have their successCallback executed - * immediately as the message is shown. - * - * Note that this is not for displaying a general disclaimer on startup. - * - * @param terria The {@link Terria} instance to use. - * @param viewState the viewstate to manipulate in order to display notifications. - * @constructor - */ -export default class DisclaimerHandler { - constructor(terria, viewState) { - this.terria = terria; - this.viewState = viewState; - this._pending = {}; - - this.terria.disclaimerListener = this._handleInitialMessage.bind(this); - } - - dispose() { - this.terria.disclaimerListener = undefined; - } - - /** - * Handles the {@Terria#disclaimerEvent} being raised. Only one disclaimer will be shown for each catalogItem with the - * same {@link CatalogItem#initialMessage#key}, but all calls will have their successCallback executed when it's - * accepted. - * - * @param catalogItem The catalog item to display a disclaimer for. - * @param successCallback A callback to execute once the disclaimer is accepted. - * @private - */ - _handleInitialMessage(catalogItem, successCallback) { - var keySpecified = defined(catalogItem.initialMessage.key); - if ( - keySpecified && - this.terria.getLocalProperty(catalogItem.initialMessage.key) - ) { - successCallback(); - return; - } - - if (catalogItem.initialMessage.confirmation) { - if (keySpecified) { - var key = catalogItem.initialMessage.key; - - if (defined(this._pending[key])) { - this._pending[key].push(successCallback); - } else { - this._pending[key] = [successCallback]; - this._openConfirmationModal( - catalogItem, - this._executeCallbacksForKey.bind(this, key) - ); - } - } else { - this._openConfirmationModal(catalogItem, successCallback); - } - } else { - if (keySpecified) { - this.terria.setLocalProperty(catalogItem.initialMessage.key, true); - } - this._openNotificationModel(catalogItem); - successCallback(); - } - } - - /** - * Opens a confirmation modal for the specified {@link CatalogItem}. - * - * @param catalogItem The catalog item to get disclaimer details from. - * @param callback The callback to execute when the modal is dismissed. - * @private - */ - _openConfirmationModal(catalogItem, callback) { - this.viewState.terria.notificationState.addNotificationToQueue( - combine( - { - confirmAction: callback - }, - DisclaimerHandler._generateOptions(catalogItem) - ) - ); - } - - _openNotificationModel(catalogItem) { - this.viewState.terria.notificationState.addNotificationToQueue( - DisclaimerHandler._generateOptions(catalogItem) - ); - } - - /** - * Executes all the callbacks stored in {@link DisclaimerHandler#pending} for the specified key, and clears that key - * in pending. - * - * @param key The key to get callbacks from. - * @private - */ - _executeCallbacksForKey(key) { - (this._pending[key] || []).forEach(function (cb) { - cb(); - }); - this._pending[key] = undefined; - this.terria.setLocalProperty(key, true); - } - - /** - * Generates options for {@link PopupMessageConfirmationViewModel} and {@link PopupMessageViewModel} for a - * {@link CatalogItem} - * @returns {{title: string, message: string, width: number, height: number, confirmText: string}} - * @private - */ - static _generateOptions(catalogItem) { - return { - title: catalogItem.initialMessage.title, - message: catalogItem.initialMessage.content, - confirmText: catalogItem.initialMessage.confirmText, - width: catalogItem.initialMessage.width, - height: catalogItem.initialMessage.height - }; - } -} diff --git a/lib/ReactViewModels/MouseCoords.ts b/lib/ReactViewModels/MouseCoords.ts index 86e2fcf52ca..3142d87e713 100644 --- a/lib/ReactViewModels/MouseCoords.ts +++ b/lib/ReactViewModels/MouseCoords.ts @@ -9,21 +9,14 @@ import Intersections2D from "terriajs-cesium/Source/Core/Intersections2D"; import CesiumMath from "terriajs-cesium/Source/Core/Math"; import Ray from "terriajs-cesium/Source/Core/Ray"; import TerrainProvider from "terriajs-cesium/Source/Core/TerrainProvider"; +import sampleTerrainMostDetailed from "terriajs-cesium/Source/Core/sampleTerrainMostDetailed"; import isDefined from "../Core/isDefined"; -import JSEarthGravityModel1996 from "../Map/Vector/EarthGravityModel1996"; import pickTriangle, { PickTriangleResult } from "../Map/Cesium/pickTriangle"; +import EarthGravityModel1996 from "../Map/Vector/EarthGravityModel1996"; import prettifyCoordinates from "../Map/Vector/prettifyCoordinates"; import prettifyProjection from "../Map/Vector/prettifyProjection"; import Terria from "../Models/Terria"; -// TypeScript 3.6.3 can't tell JSEarthGravityModel1996 is a class and reports -// Cannot use namespace 'JSEarthGravityModel1996' as a type.ts(2709) -// This is a dodgy workaround. -class EarthGravityModel1996 extends JSEarthGravityModel1996 {} - -const sampleTerrainMostDetailed = - require("terriajs-cesium/Source/Core/sampleTerrainMostDetailed").default; - interface Cancelable { cancel: () => void; } diff --git a/lib/ReactViewModels/ViewState.ts b/lib/ReactViewModels/ViewState.ts index 77a1975d62c..eb36fd265a0 100644 --- a/lib/ReactViewModels/ViewState.ts +++ b/lib/ReactViewModels/ViewState.ts @@ -36,7 +36,6 @@ import { RelativePosition, TourPoint } from "./defaultTourPoints"; -import DisclaimerHandler from "./DisclaimerHandler"; import SearchState from "./SearchState"; import CatalogSearchProviderMixin from "../ModelMixins/SearchProviders/CatalogSearchProviderMixin"; import { getMarkerCatalogItem } from "../Models/LocationMarkerUtils"; @@ -373,7 +372,6 @@ export default class ViewState { private _locationMarkerSubscription: IReactionDisposer; private _workbenchHasTimeWMSSubscription: IReactionDisposer; private _storyBeforeUnloadSubscription: IReactionDisposer; - private _disclaimerHandler: DisclaimerHandler; constructor(options: ViewStateOptions) { makeObservable(this); @@ -449,8 +447,6 @@ export default class ViewState { } ); - this._disclaimerHandler = new DisclaimerHandler(terria, this); - this._workbenchHasTimeWMSSubscription = reaction( () => this.terria.workbench.hasTimeWMS, (hasTimeWMS: boolean) => { @@ -540,7 +536,6 @@ export default class ViewState { this._previewedItemIdSubscription(); this._workbenchHasTimeWMSSubscription(); this._locationMarkerSubscription(); - this._disclaimerHandler.dispose(); this.searchState.dispose(); } diff --git a/lib/ReactViews/BottomDock/Timeline/DateFormats.js b/lib/ReactViews/BottomDock/Timeline/DateFormats.ts similarity index 53% rename from lib/ReactViews/BottomDock/Timeline/DateFormats.js rename to lib/ReactViews/BottomDock/Timeline/DateFormats.ts index a8558cf95d4..0026ddc799d 100644 --- a/lib/ReactViews/BottomDock/Timeline/DateFormats.js +++ b/lib/ReactViews/BottomDock/Timeline/DateFormats.ts @@ -1,15 +1,13 @@ -"use strict"; - import defined from "terriajs-cesium/Source/Core/defined"; /** * Formats a date according to the locale if provided, otherwise in a dd/mm/yyyy format. * - * @param {Date} d the date to format - * @param {Locale} [locale] the locale to use for formatting - * @returns {string} A formatted date. + * @param d the date to format + * @param locale the locale to use for formatting + * @returns A formatted date. */ -export function formatDate(d, locale) { +export function formatDate(d: Date, locale?: string): string { if (defined(locale)) { return d.toLocaleDateString(locale); } @@ -19,11 +17,11 @@ export function formatDate(d, locale) { /** * Formats the time according to the locale if provided, otherwise in a hh:mm:ss format. * - * @param {Date} d the date to format - * @param {Locale} [locale] the locale to use for formatting - * @returns {string} A formatted time. + * @param d the date to format + * @param locale the locale to use for formatting + * @returns A formatted time. */ -export function formatTime(d, locale) { +export function formatTime(d: Date, locale?: string): string { if (defined(locale)) { return d.toLocaleTimeString(locale); } @@ -35,20 +33,20 @@ export function formatTime(d, locale) { /** * Combines {@link #formatDate} and {@link #formatTime}. * - * @param {Date} d the date to format - * @param {Locale} [locale] the locale to use for formatting - * @returns {string} A formatted date and time with a comma separating them. + * @param d the date to format + * @param locale the locale to use for formatting + * @returns A formatted date and time with a comma separating them. */ -export function formatDateTime(d, locale) { +export function formatDateTime(d: Date, locale?: string): string { return formatDate(d, locale) + ", " + formatTime(d, locale); } /** * Puts a leading 0 in front of a number of it's less than 10. * - * @param {number} s A number to pad - * @returns {string} A string representing a two-digit number. + * @param s A number to pad + * @returns A string representing a two-digit number. */ -function pad(s) { +function pad(s: number): string { return s < 10 ? "0" + s : `${s}`; } diff --git a/lib/ReactViews/BottomDock/Timeline/Timeline.d.ts b/lib/ReactViews/BottomDock/Timeline/Timeline.d.ts new file mode 100644 index 00000000000..8cd8b6c80c0 --- /dev/null +++ b/lib/ReactViews/BottomDock/Timeline/Timeline.d.ts @@ -0,0 +1,13 @@ +import React from "react"; +import IElementConfig from "../../../Models/IElementConfig"; +import Terria from "../../../Models/Terria"; + +interface PropsType { + terria: Terria; + locale?: unknown; + elementConfig?: IElementConfig; +} + +declare class Timeline extends React.Component {} + +export default Timeline; diff --git a/lib/ReactViews/Custom/Chart/ChartPanel.d.ts b/lib/ReactViews/Custom/Chart/ChartPanel.d.ts new file mode 100644 index 00000000000..b09e524ae99 --- /dev/null +++ b/lib/ReactViews/Custom/Chart/ChartPanel.d.ts @@ -0,0 +1,12 @@ +import React from "react"; +import Terria from "../../../Models/Terria"; +import { ViewState } from "terriajs-plugin-api"; + +interface PropsType { + viewState: ViewState; + terria: Terria; +} + +declare class ChartPanel extends React.Component {} + +export default ChartPanel; diff --git a/lib/ReactViews/Custom/parseCustomHtmlToReact.ts b/lib/ReactViews/Custom/parseCustomHtmlToReact.ts index 3d89d755817..7d83108bca0 100644 --- a/lib/ReactViews/Custom/parseCustomHtmlToReact.ts +++ b/lib/ReactViews/Custom/parseCustomHtmlToReact.ts @@ -1,22 +1,19 @@ -"use strict"; - +import DOMPurify from "dompurify"; import React, { AnchorHTMLAttributes, createElement, DetailedReactHTMLElement, ReactElement } from "react"; -import styled from "styled-components"; +import combine from "terriajs-cesium/Source/Core/combine"; +import defined from "terriajs-cesium/Source/Core/defined"; import CustomComponent, { DomElement, ProcessNodeContext } from "./CustomComponent"; -import { ExternalLinkWithWarning, ExternalLinkIcon } from "./ExternalLink"; +import { ExternalLinkIcon, ExternalLinkWithWarning } from "./ExternalLink"; -const DOMPurify = require("dompurify/dist/purify"); const HtmlToReact = require("html-to-react"); -const combine = require("terriajs-cesium/Source/Core/combine").default; -const defined = require("terriajs-cesium/Source/Core/defined").default; const utils = require("html-to-react/lib/utils"); const htmlToReactParser = new HtmlToReact.Parser({ diff --git a/lib/ReactViews/Disclaimer.d.ts b/lib/ReactViews/Disclaimer.d.ts new file mode 100644 index 00000000000..7c6ae10693c --- /dev/null +++ b/lib/ReactViews/Disclaimer.d.ts @@ -0,0 +1,5 @@ +import React from "react"; + +declare class Disclaimer extends React.Component<{}> {} + +export default Disclaimer; diff --git a/lib/ReactViews/DragDropNotification.d.ts b/lib/ReactViews/DragDropNotification.d.ts new file mode 100644 index 00000000000..33b2a353455 --- /dev/null +++ b/lib/ReactViews/DragDropNotification.d.ts @@ -0,0 +1,5 @@ +import React from "react"; + +declare class DragDropNotification extends React.Component<{}> {} + +export default DragDropNotification; diff --git a/lib/ReactViews/DragDropNotification.jsx b/lib/ReactViews/DragDropNotification.jsx index 63bf30c8c7d..5edcf1a9cfb 100644 --- a/lib/ReactViews/DragDropNotification.jsx +++ b/lib/ReactViews/DragDropNotification.jsx @@ -1,4 +1,3 @@ -"use strict"; import classNames from "classnames"; import { reaction } from "mobx"; import { observer } from "mobx-react"; diff --git a/lib/ReactViews/ExplorerWindow/Tabs.d.ts b/lib/ReactViews/ExplorerWindow/Tabs.d.ts new file mode 100644 index 00000000000..8714b383e1c --- /dev/null +++ b/lib/ReactViews/ExplorerWindow/Tabs.d.ts @@ -0,0 +1,13 @@ +import React from "react"; +import Terria from "../../Models/Terria"; +import ViewState from "../../ReactViewModels/ViewState"; + +interface PropsType { + terria: Terria; + viewState: ViewState; + tabs?: unknown[]; +} + +declare class Tabs extends React.Component {} + +export default Tabs; diff --git a/lib/ReactViews/Generic/CloseButton.tsx b/lib/ReactViews/Generic/CloseButton.tsx new file mode 100644 index 00000000000..f38f209e7bf --- /dev/null +++ b/lib/ReactViews/Generic/CloseButton.tsx @@ -0,0 +1,34 @@ +// for all the panels and modals we will eventually normalise +import React from "react"; +import styled from "styled-components"; +// import Box from "../../Styled/Box"; +import Icon from "../../Styled/Icon"; +import { ButtonProps, RawButton } from "../../Styled/Button"; + +const StyledCloseButton = styled(RawButton)` + ${(p: any) => !p.noAbsolute && `position: absolute;`} + // width: 20px; + // height: 20px; + width: 14px; + height: 14px; + ${(p: any) => + p.topRight && + ` + top: 15px; + right:15px; + `} + svg { + // fill: ${(p) => p.color || p.theme.darkWithOverlay}; + fill: ${(p) => p.color}; + } +`; + +const CloseButton = (props: ButtonProps) => { + return ( + + + + ); +}; + +export default CloseButton; diff --git a/lib/ReactViews/Generic/Prompt.d.ts b/lib/ReactViews/Generic/Prompt.d.ts new file mode 100644 index 00000000000..29a61a8cca6 --- /dev/null +++ b/lib/ReactViews/Generic/Prompt.d.ts @@ -0,0 +1,20 @@ +import React from "react"; + +interface PropsType { + content: React.ReactNode; + isVisible: boolean; + displayDelay: number; + dismissText: string; + dismissAction: () => void; + centered?: boolean; + caretTopOffset?: number; + caretLeftOffset?: number; + caretSize?: number; + promptWidth?: number; + promptTopOffset?: number; + promptLeftOffset?: number; +} + +declare class Prompt extends React.PureComponent {} + +export default Prompt; diff --git a/lib/ReactViews/HelpScreens/SatelliteHelpPrompt.jsx b/lib/ReactViews/HelpScreens/SatelliteHelpPrompt.tsx similarity index 100% rename from lib/ReactViews/HelpScreens/SatelliteHelpPrompt.jsx rename to lib/ReactViews/HelpScreens/SatelliteHelpPrompt.tsx diff --git a/lib/ReactViews/Map/MapNavigation/Items/Compass/GyroscopeGuidance.d.ts b/lib/ReactViews/Map/MapNavigation/Items/Compass/GyroscopeGuidance.d.ts new file mode 100644 index 00000000000..2cc84af1144 --- /dev/null +++ b/lib/ReactViews/Map/MapNavigation/Items/Compass/GyroscopeGuidance.d.ts @@ -0,0 +1,9 @@ +import { ViewState } from "terriajs-plugin-api"; + +interface PropsType { + viewState: ViewState; + handleHelp?: () => void; + onClose: () => void; +} + +export declare const GyroscopeGuidance: React.FC; diff --git a/lib/ReactViews/Map/MenuBar/MenuBar.d.ts b/lib/ReactViews/Map/MenuBar/MenuBar.d.ts new file mode 100644 index 00000000000..a1d8f37a149 --- /dev/null +++ b/lib/ReactViews/Map/MenuBar/MenuBar.d.ts @@ -0,0 +1,11 @@ +import IElementConfig from "../../../Models/IElementConfig"; + +interface PropsType { + animationDuration?: number; + menuItems: React.ReactElement[]; + menuLeftItems: React.ReactElement[]; + elementConfig?: IElementConfig; +} + +declare const MenuBar: React.FC; +export default MenuBar; diff --git a/lib/ReactViews/Map/Panels/HelpPanel/HelpPanel.d.ts b/lib/ReactViews/Map/Panels/HelpPanel/HelpPanel.d.ts new file mode 100644 index 00000000000..807fe6c1d6c --- /dev/null +++ b/lib/ReactViews/Map/Panels/HelpPanel/HelpPanel.d.ts @@ -0,0 +1,4 @@ +import React from "react"; + +declare class HelpPanel extends React.Component<{}> {} +export default HelpPanel; diff --git a/lib/ReactViews/Map/Panels/HelpPanel/VideoGuide.d.ts b/lib/ReactViews/Map/Panels/HelpPanel/VideoGuide.d.ts new file mode 100644 index 00000000000..de29f4976d5 --- /dev/null +++ b/lib/ReactViews/Map/Panels/HelpPanel/VideoGuide.d.ts @@ -0,0 +1,14 @@ +import React from "react"; +import ViewState from "../../../../ReactViewModels/ViewState"; + +interface PropsType { + viewState: ViewState; + videoName: string; + videoLink: string; + background: string; + // A number between 0 and 1.0 + backgroundOpacity?: number; +} + +declare class VideoGuide extends React.Component {} +export default VideoGuide; diff --git a/lib/ReactViews/Mobile/MobileHeader.d.ts b/lib/ReactViews/Mobile/MobileHeader.d.ts new file mode 100644 index 00000000000..68eb64b1f86 --- /dev/null +++ b/lib/ReactViews/Mobile/MobileHeader.d.ts @@ -0,0 +1,12 @@ +import { i18n } from "i18next"; +import React from "react"; + +interface PropsType { + version?: string; + menuLeftItems: React.ReactNode[]; + menuItems: React.ReactNode[]; + i18n?: i18n; +} + +declare class MobileHeader extends React.Component {} +export default MobileHeader; diff --git a/lib/ReactViews/Preview/Description.d.ts b/lib/ReactViews/Preview/Description.d.ts new file mode 100644 index 00000000000..08b8b869484 --- /dev/null +++ b/lib/ReactViews/Preview/Description.d.ts @@ -0,0 +1,11 @@ +import React from "react"; +import { BaseModel } from "terriajs-plugin-api"; + +interface PropsType { + item: BaseModel; + printView?: boolean; +} + +declare class Description extends React.Component {} + +export default Description; diff --git a/lib/ReactViews/PrivateIndicator/PrivateIndicator.jsx b/lib/ReactViews/PrivateIndicator/PrivateIndicator.tsx similarity index 61% rename from lib/ReactViews/PrivateIndicator/PrivateIndicator.jsx rename to lib/ReactViews/PrivateIndicator/PrivateIndicator.tsx index 06c2cce9781..edb7f388baa 100644 --- a/lib/ReactViews/PrivateIndicator/PrivateIndicator.jsx +++ b/lib/ReactViews/PrivateIndicator/PrivateIndicator.tsx @@ -1,28 +1,24 @@ import React from "react"; -import PropTypes from "prop-types"; import { useTranslation } from "react-i18next"; +import Icon from "terriajs/lib/Styled/Icon"; +import IconWrapper from "terriajs/lib/Styled/IconWrapper"; -import Icon from "../../Styled/Icon"; -import IconWrapper from "../../Styled/IconWrapper"; - -PrivateIndicator.propTypes = { - inWorkbench: PropTypes.bool -}; +interface PropsType { + inWorkbench?: boolean; +} -export default function PrivateIndicator(props) { +export default function PrivateIndicator(props: PropsType) { const { t } = useTranslation(); - return ( + fill: ${(p: any) => p.inWorkbench ? p.theme.textLight : p.theme.charcoalGrey}; } `} diff --git a/lib/ReactViews/Search/SearchBoxAndResults.d.ts b/lib/ReactViews/Search/SearchBoxAndResults.d.ts new file mode 100644 index 00000000000..989a5db1fa6 --- /dev/null +++ b/lib/ReactViews/Search/SearchBoxAndResults.d.ts @@ -0,0 +1,22 @@ +import { TFunction } from "i18next"; +import React from "react"; +import { ViewState } from "terriajs-plugin-api"; +import Terria from "../../Models/Terria"; + +interface SearchInDataCatalogPropsType { + viewState: ViewState; + handleClick: () => void; +} + +export declare const SearchInDataCatalog: React.FC; + +interface PropsType { + viewState: ViewState; + terria: Terria; + t?: TFunction; + placeholder?: string; +} + +declare class SearchBoxAndResults extends React.Component {} + +export default SearchBoxAndResults; diff --git a/lib/ReactViews/SidePanel/FullScreenButton.d.ts b/lib/ReactViews/SidePanel/FullScreenButton.d.ts new file mode 100644 index 00000000000..0498ca74692 --- /dev/null +++ b/lib/ReactViews/SidePanel/FullScreenButton.d.ts @@ -0,0 +1,13 @@ +import React from "react"; +import IElementConfig from "../../Models/IElementConfig"; + +interface PropsType { + btnText: string; + minified: boolean; + animationDuration?: number; + elementConfig?: IElementConfig; +} + +declare class FullScreenButton extends React.Component {} + +export default FullScreenButton; diff --git a/lib/ReactViews/StandardUserInterface/StandardTheme.jsx b/lib/ReactViews/StandardUserInterface/StandardTheme.jsx deleted file mode 100644 index dca182dfab1..00000000000 --- a/lib/ReactViews/StandardUserInterface/StandardTheme.jsx +++ /dev/null @@ -1,8 +0,0 @@ -import Variables from "../../Sass/exports/_variables-export.scss"; - -import Mixins from "../../Styled/mixins"; - -export const terriaTheme = { - ...Variables, - ...Mixins -}; diff --git a/lib/ReactViews/StandardUserInterface/StandardTheme.tsx b/lib/ReactViews/StandardUserInterface/StandardTheme.tsx new file mode 100644 index 00000000000..5eca616ff28 --- /dev/null +++ b/lib/ReactViews/StandardUserInterface/StandardTheme.tsx @@ -0,0 +1,9 @@ +import Variables from "terriajs/lib/Sass/exports/_variables-export.scss"; +import Mixins from "terriajs/lib/Styled/mixins"; + +export const terriaTheme = { + ...Variables, + ...Mixins +}; + +export type TerriaTheme = typeof terriaTheme; diff --git a/lib/ReactViews/StandardUserInterface/processCustomElements.d.ts b/lib/ReactViews/StandardUserInterface/processCustomElements.d.ts new file mode 100644 index 00000000000..24f4b3d9edb --- /dev/null +++ b/lib/ReactViews/StandardUserInterface/processCustomElements.d.ts @@ -0,0 +1,15 @@ +import React from "react"; + +type GroupElementKeys = + | "menu" + | "menuLeft" + | "nav" + | "experimentalMenu" + | "feedback"; + +declare function processCustomElements( + isSmallScreen: boolean, + customUI: React.ReactNode +): Record; + +export default processCustomElements; diff --git a/lib/ReactViews/Tour/TourPortal.d.ts b/lib/ReactViews/Tour/TourPortal.d.ts new file mode 100644 index 00000000000..d7392d851bc --- /dev/null +++ b/lib/ReactViews/Tour/TourPortal.d.ts @@ -0,0 +1,6 @@ +export declare const TourExplanation: React.FC; +export declare const TourPreface: React.FC; + +declare const TourPortal: React.FC<{}>; + +export default TourPortal; diff --git a/lib/ReactViews/Transitions/FadeIn/FadeIn.d.ts b/lib/ReactViews/Transitions/FadeIn/FadeIn.d.ts new file mode 100644 index 00000000000..17057b1b305 --- /dev/null +++ b/lib/ReactViews/Transitions/FadeIn/FadeIn.d.ts @@ -0,0 +1,9 @@ +interface PropsType { + isVisible: boolean; + onEnter?: () => void; + onExited?: () => void; + transitionProps?: any; +} + +declare const FadeIn: React.FC; +export default FadeIn; diff --git a/lib/ReactViews/Transitions/SlideUpFadeIn/SlideUpFadeIn.d.ts b/lib/ReactViews/Transitions/SlideUpFadeIn/SlideUpFadeIn.d.ts new file mode 100644 index 00000000000..60f9e2e91c1 --- /dev/null +++ b/lib/ReactViews/Transitions/SlideUpFadeIn/SlideUpFadeIn.d.ts @@ -0,0 +1,9 @@ +interface PropsType { + isVisible: boolean; + onEnter?: () => void; + onExited?: () => void; + transitionProps?: any; +} + +declare const SlideUpFadeIn: React.FC; +export default SlideUpFadeIn; diff --git a/lib/ReactViews/WelcomeMessage/WelcomeMessage.d.ts b/lib/ReactViews/WelcomeMessage/WelcomeMessage.d.ts new file mode 100644 index 00000000000..858b3816356 --- /dev/null +++ b/lib/ReactViews/WelcomeMessage/WelcomeMessage.d.ts @@ -0,0 +1,12 @@ +import React from "react"; + +interface WelcomeMessagePurePropsType { + showWelcomeMessage: boolean; + setShowWelcomeMessage: (show: boolean) => void; + isTopElement: boolean; +} + +export declare const WelcomeMessagePure: React.FC; + +declare class WelcomeMessage extends React.Component<{}> {} +export default WelcomeMessage; diff --git a/lib/ReactViews/Workbench/Controls/ColorScaleRangeSection.d.ts b/lib/ReactViews/Workbench/Controls/ColorScaleRangeSection.d.ts new file mode 100644 index 00000000000..e9192db03ab --- /dev/null +++ b/lib/ReactViews/Workbench/Controls/ColorScaleRangeSection.d.ts @@ -0,0 +1,11 @@ +import React from "react"; +import { BaseModel } from "../../../Models/Definition/Model"; + +interface PropsType { + item: BaseModel; + minValue: number; + maxValue: number; +} + +declare class ColorScaleRangeSection extends React.Component {} +export default ColorScaleRangeSection; diff --git a/lib/ReactViews/Workbench/Controls/FilterSection.d.ts b/lib/ReactViews/Workbench/Controls/FilterSection.d.ts new file mode 100644 index 00000000000..b599403cb16 --- /dev/null +++ b/lib/ReactViews/Workbench/Controls/FilterSection.d.ts @@ -0,0 +1,9 @@ +import React from "react"; +import { BaseModel } from "../../../Models/Definition/Model"; + +interface PropsType { + item: BaseModel; +} + +declare class FilterSection extends React.Component {} +export default FilterSection; diff --git a/lib/ReactViews/Workbench/Controls/SatelliteImageryTimeFilterSection.d.ts b/lib/ReactViews/Workbench/Controls/SatelliteImageryTimeFilterSection.d.ts new file mode 100644 index 00000000000..35be383dbda --- /dev/null +++ b/lib/ReactViews/Workbench/Controls/SatelliteImageryTimeFilterSection.d.ts @@ -0,0 +1,9 @@ +import React from "react"; +import { BaseModel } from "../../../Models/Definition/Model"; + +interface PropsType { + item: BaseModel; +} + +declare class SatelliteImageryTimeFilterSection extends React.Component {} +export default SatelliteImageryTimeFilterSection; diff --git a/lib/ReactViews/Workbench/Controls/TimerSection.d.ts b/lib/ReactViews/Workbench/Controls/TimerSection.d.ts new file mode 100644 index 00000000000..1ae97eb7525 --- /dev/null +++ b/lib/ReactViews/Workbench/Controls/TimerSection.d.ts @@ -0,0 +1,5 @@ +import React from "react"; +import { BaseModel } from "../../../Models/Definition/Model"; + +declare class TimerSection extends React.Component<{ item: BaseModel }> {} +export default TimerSection; diff --git a/lib/Styled/mixins.js b/lib/Styled/mixins.ts similarity index 81% rename from lib/Styled/mixins.js rename to lib/Styled/mixins.ts index ec3e61403f9..32af1855cc3 100644 --- a/lib/Styled/mixins.js +++ b/lib/Styled/mixins.ts @@ -1,5 +1,11 @@ // Doesn't result in composed classes that reuse these, but to save some typing +import cssExports from "terriajs/lib/Sass/exports/_variables-export.scss"; + +interface MixinProps { + theme: typeof cssExports; +} + export const scrollBars = () => ` -webkit-overflow-scrolling: touch; @@ -41,16 +47,16 @@ export const removeListStyles = () => ` margin: 0; `; -export const borderRadiusTop = (radius) => ` +export const borderRadiusTop = (radius: number | string) => ` border-radius: ${radius}px ${radius}px 0 0; `; -export const borderRadiusRight = (radius) => ` +export const borderRadiusRight = (radius: number | string) => ` border-radius: 0 ${radius}px ${radius}px 0; `; -export const borderRadiusBottom = (radius) => ` +export const borderRadiusBottom = (radius: number | string) => ` border-radius: 0 0 ${radius}px ${radius}px; `; -export const borderRadiusLeft = (radius) => ` +export const borderRadiusLeft = (radius: number | string) => ` border-radius: ${radius}px 0 0 ${radius}px; `; @@ -65,7 +71,7 @@ export const addBasicHoverStyles = () => ` * unfortunately this means more classnames outputted, but gives us consistency * in the meantime. * */ -export const addTerriaPrimaryBtnStyles = (props) => ` +export const addTerriaPrimaryBtnStyles = (props: MixinProps) => ` background: ${props.theme.colorPrimary}; color: ${props.theme.textLight}; svg { @@ -79,7 +85,7 @@ export const addTerriaPrimaryBtnStyles = (props) => ` } `; -export const addTerriaSecondaryBtnStyles = (props) => ` +export const addTerriaSecondaryBtnStyles = (props: MixinProps) => ` color: ${props.theme.colorPrimary}; // Don't override border here on secondary, as it's set specifically on certain buttons e.g. story cancel button @@ -91,7 +97,7 @@ export const addTerriaSecondaryBtnStyles = (props) => ` ${addBasicHoverStyles()} `; -export const addTerriaTertiaryBtnStyles = (props) => ` +export const addTerriaTertiaryBtnStyles = (props: MixinProps) => ` color: ${props.theme.modalText}; background: ${props.theme.modalBg}; border: 2px solid ${props.theme.modalText}; @@ -103,7 +109,7 @@ export const addTerriaTertiaryBtnStyles = (props) => ` } `; -export const addTerriaMapBtnStyles = (props) => ` +export const addTerriaMapBtnStyles = (props: MixinProps) => ` color: ${props.theme.textLight}; background-color: ${props.theme.dark}; &:hover, @@ -123,7 +129,7 @@ export const addTerriaMapBtnStyles = (props) => ` } `; -export const addTerriaLightBtnStyles = (props) => ` +export const addTerriaLightBtnStyles = (props: MixinProps) => ` color: ${props.theme.textLight}; svg { fill: ${props.theme.textLight}; @@ -135,7 +141,7 @@ export const addTerriaLightBtnStyles = (props) => ` } `; -export const addTerriaScrollbarStyles = (props) => ` +export const addTerriaScrollbarStyles = () => ` -webkit-overflow-scrolling: touch; &::-webkit-scrollbar { diff --git a/package.json b/package.json index a552f3033fa..e5c3d88dac9 100644 --- a/package.json +++ b/package.json @@ -132,9 +132,9 @@ "javascript-natural-sort": "^0.7.1", "json5": "^2.1.0", "leaflet": "^1.8.0", - "linkify-it": "^2.0.0", + "linkify-it": "^5.0.0", "lodash-es": "^4.17.11", - "markdown-it": "^11.0.0", + "markdown-it": "^14.1.0", "math-expression-evaluator": "^1.3.7", "mini-css-extract-plugin": "^0.5.0", "minisearch": "^3.0.2", @@ -196,6 +196,8 @@ "@babel/eslint-parser": "^7.23.3", "@babel/plugin-syntax-dynamic-import": "^7.8.3", "@types/dateformat": "^3.0.1", + "@types/linkify-it": "^3.0.5", + "@types/markdown-it": "^14.0.1", "@types/node": "^18.15.11", "@types/webpack": "4.41.33", "@typescript-eslint/eslint-plugin": "^6.12.0", diff --git a/yarn.lock b/yarn.lock index ce0acca487b..d69661004f2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1787,6 +1787,11 @@ dependencies: "@types/geojson" "*" +"@types/linkify-it@^3.0.5": + version "3.0.5" + resolved "https://registry.yarnpkg.com/@types/linkify-it/-/linkify-it-3.0.5.tgz#1e78a3ac2428e6d7e6c05c1665c242023a4601d8" + integrity sha512-yg6E+u0/+Zjva+buc3EIb+29XEg4wltq7cSmd4Uc2EE/1nUVmxyzpX6gUXD0V8jIrG0r7YeOGVIbYRkxeooCtw== + "@types/lodash-es@^4.17.3": version "4.17.5" resolved "https://registry.yarnpkg.com/@types/lodash-es/-/lodash-es-4.17.5.tgz#1c3fdd16849d84aea43890b1c60da379fb501353" @@ -2664,6 +2669,11 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== + arity-n@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/arity-n/-/arity-n-1.0.4.tgz#d9e76b11733e08569c0847ae7b39b2860b30b745" @@ -5062,10 +5072,10 @@ entities@^3.0.1: resolved "https://registry.yarnpkg.com/entities/-/entities-3.0.1.tgz#2b887ca62585e96db3903482d336c1006c3001d4" integrity sha512-WiyBqoomrwMdFG1e0kqvASYfnlb0lp8M5o5Fw2OFq1hNZxxcNk8Ik0Xm7LxzBhuidnZB/UtBqVCgUz3kBOP51Q== -entities@~2.0.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/entities/-/entities-2.0.3.tgz#5c487e5742ab93c15abb5da22759b8590ec03b7f" - integrity sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ== +entities@^4.4.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/entities/-/entities-4.5.0.tgz#5d268ea5e7113ec74c4d033b79ea5a35a488fb48" + integrity sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw== errno@^0.1.3: version "0.1.8" @@ -7924,19 +7934,12 @@ lines-and-columns@^1.1.6: resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== -linkify-it@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-2.2.0.tgz#e3b54697e78bf915c70a38acd78fd09e0058b1cf" - integrity sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw== - dependencies: - uc.micro "^1.0.1" - -linkify-it@^3.0.1: - version "3.0.3" - resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-3.0.3.tgz#a98baf44ce45a550efb4d49c769d07524cc2fa2e" - integrity sha512-ynTsyrFSdE5oZ/O9GEf00kPngmOfVwazR5GKDq6EYfhlpFug3J2zybX56a2PRRpc9P+FuSoGNAwjlbDs9jJBPQ== +linkify-it@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-5.0.0.tgz#9ef238bfa6dc70bd8e7f9572b52d369af569b421" + integrity sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ== dependencies: - uc.micro "^1.0.1" + uc.micro "^2.0.0" load-json-file@^1.0.0: version "1.1.0" @@ -8168,16 +8171,17 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" -markdown-it@^11.0.0: - version "11.0.1" - resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-11.0.1.tgz#b54f15ec2a2193efa66dda1eb4173baea08993d6" - integrity sha512-aU1TzmBKcWNNYvH9pjq6u92BML+Hz3h5S/QpfTFwiQF852pLT+9qHsrhM9JYipkOXZxGn+sGH8oyJE9FD9WezQ== +markdown-it@^14.1.0: + version "14.1.0" + resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-14.1.0.tgz#3c3c5992883c633db4714ccb4d7b5935d98b7d45" + integrity sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg== dependencies: - argparse "^1.0.7" - entities "~2.0.0" - linkify-it "^3.0.1" - mdurl "^1.0.1" - uc.micro "^1.0.5" + argparse "^2.0.1" + entities "^4.4.0" + linkify-it "^5.0.0" + mdurl "^2.0.0" + punycode.js "^2.3.1" + uc.micro "^2.1.0" matchdep@^2.0.0: version "2.0.0" @@ -8215,10 +8219,10 @@ md5.js@^1.3.4: inherits "^2.0.1" safe-buffer "^5.1.2" -mdurl@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e" - integrity sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4= +mdurl@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-2.0.0.tgz#80676ec0433025dd3e17ee983d0fe8de5a2237e0" + integrity sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w== media-typer@0.3.0: version "0.3.0" @@ -9696,6 +9700,11 @@ pumpify@^1.3.5: inherits "^2.0.3" pump "^2.0.0" +punycode.js@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/punycode.js/-/punycode.js-2.3.1.tgz#6b53e56ad75588234e79f4affa90972c7dd8cdb7" + integrity sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA== + punycode@1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" @@ -11973,10 +11982,10 @@ ua-parser-js@^0.7.30: resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.37.tgz#e464e66dac2d33a7a1251d7d7a99d6157ec27832" integrity sha512-xV8kqRKM+jhMvcHWUKthV9fNebIzrNy//2O9ZwWcfiBFR5f25XVZPLlEajk/sf3Ra15V92isyQqnIEXRDaZWEA== -uc.micro@^1.0.1, uc.micro@^1.0.5: - version "1.0.6" - resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac" - integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA== +uc.micro@^2.0.0, uc.micro@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-2.1.0.tgz#f8d3f7d0ec4c3dea35a7e3c8efa4cb8b45c9e7ee" + integrity sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A== uglify-js@3.4.x: version "3.4.10" From 8b5cbc47fdca0b0982bb2cca6cb4cbe596375156 Mon Sep 17 00:00:00 2001 From: Nanda Date: Fri, 26 Apr 2024 11:05:47 +1000 Subject: [PATCH 02/17] Fix imports. --- lib/ReactViews/Custom/Chart/ChartPanel.d.ts | 2 +- .../Map/MapNavigation/Items/Compass/GyroscopeGuidance.d.ts | 2 +- lib/ReactViews/Preview/Description.d.ts | 2 +- lib/ReactViews/Search/SearchBoxAndResults.d.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ReactViews/Custom/Chart/ChartPanel.d.ts b/lib/ReactViews/Custom/Chart/ChartPanel.d.ts index b09e524ae99..0a109cc8c95 100644 --- a/lib/ReactViews/Custom/Chart/ChartPanel.d.ts +++ b/lib/ReactViews/Custom/Chart/ChartPanel.d.ts @@ -1,6 +1,6 @@ import React from "react"; import Terria from "../../../Models/Terria"; -import { ViewState } from "terriajs-plugin-api"; +import ViewState from "../../../ReactViewModels/ViewState"; interface PropsType { viewState: ViewState; diff --git a/lib/ReactViews/Map/MapNavigation/Items/Compass/GyroscopeGuidance.d.ts b/lib/ReactViews/Map/MapNavigation/Items/Compass/GyroscopeGuidance.d.ts index 2cc84af1144..51dc182af2d 100644 --- a/lib/ReactViews/Map/MapNavigation/Items/Compass/GyroscopeGuidance.d.ts +++ b/lib/ReactViews/Map/MapNavigation/Items/Compass/GyroscopeGuidance.d.ts @@ -1,4 +1,4 @@ -import { ViewState } from "terriajs-plugin-api"; +import ViewState from "../../../../../ReactViewModels/ViewState"; interface PropsType { viewState: ViewState; diff --git a/lib/ReactViews/Preview/Description.d.ts b/lib/ReactViews/Preview/Description.d.ts index 08b8b869484..0ada6130fcb 100644 --- a/lib/ReactViews/Preview/Description.d.ts +++ b/lib/ReactViews/Preview/Description.d.ts @@ -1,5 +1,5 @@ import React from "react"; -import { BaseModel } from "terriajs-plugin-api"; +import { BaseModel } from "../../Models/Definition/Model"; interface PropsType { item: BaseModel; diff --git a/lib/ReactViews/Search/SearchBoxAndResults.d.ts b/lib/ReactViews/Search/SearchBoxAndResults.d.ts index 989a5db1fa6..361eb03867c 100644 --- a/lib/ReactViews/Search/SearchBoxAndResults.d.ts +++ b/lib/ReactViews/Search/SearchBoxAndResults.d.ts @@ -1,7 +1,7 @@ import { TFunction } from "i18next"; import React from "react"; -import { ViewState } from "terriajs-plugin-api"; import Terria from "../../Models/Terria"; +import ViewState from "../../ReactViewModels/ViewState"; interface SearchInDataCatalogPropsType { viewState: ViewState; From c8036ebc198e9426898f5c5cce2656a9b9e59955 Mon Sep 17 00:00:00 2001 From: Nanda Date: Fri, 26 Apr 2024 11:20:32 +1000 Subject: [PATCH 03/17] Inlcude Sass & Styled modules to tsconfig-node.json for passing typecheck. --- tsconfig-node.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tsconfig-node.json b/tsconfig-node.json index 37123944db3..dbf8c3262e7 100644 --- a/tsconfig-node.json +++ b/tsconfig-node.json @@ -24,6 +24,9 @@ "./lib/Traits/**/*", "./lib/Language/**/*", "./lib/ReactViews/**/*", - "./lib/ThirdParty/**/*" + "./lib/ThirdParty/**/*", + // These Sass and Styled modules are required for their typings + "./lib/Sass/exports/**/*", + "./lib/Styled/Icon*" ] } From 479d23cddf99ba99c0c659f0bdb16523a6fb0152 Mon Sep 17 00:00:00 2001 From: Nanda Date: Fri, 26 Apr 2024 11:42:22 +1000 Subject: [PATCH 04/17] Try explicit paths. --- tsconfig-node.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tsconfig-node.json b/tsconfig-node.json index dbf8c3262e7..5f07bcbabdb 100644 --- a/tsconfig-node.json +++ b/tsconfig-node.json @@ -26,7 +26,8 @@ "./lib/ReactViews/**/*", "./lib/ThirdParty/**/*", // These Sass and Styled modules are required for their typings - "./lib/Sass/exports/**/*", - "./lib/Styled/Icon*" + "./lib/Sass/exports/*", + "./lib/Styled/Icon.tsx", + "./lib/Styled/IconWrapper.tsx" ] } From 48edd99047b69e1502256cf9a0cee43b3724f1a2 Mon Sep 17 00:00:00 2001 From: Nanda Date: Fri, 26 Apr 2024 12:18:32 +1000 Subject: [PATCH 05/17] Fix import paths. --- .../PrivateIndicator/PrivateIndicator.tsx | 4 ++-- .../StandardUserInterface/StandardTheme.tsx | 4 ++-- lib/Styled/mixins.ts | 2 +- tsconfig-node.json | 6 +----- yarn.lock | 15 ++++++++++++++- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/lib/ReactViews/PrivateIndicator/PrivateIndicator.tsx b/lib/ReactViews/PrivateIndicator/PrivateIndicator.tsx index edb7f388baa..bb5295f34b2 100644 --- a/lib/ReactViews/PrivateIndicator/PrivateIndicator.tsx +++ b/lib/ReactViews/PrivateIndicator/PrivateIndicator.tsx @@ -1,7 +1,7 @@ import React from "react"; import { useTranslation } from "react-i18next"; -import Icon from "terriajs/lib/Styled/Icon"; -import IconWrapper from "terriajs/lib/Styled/IconWrapper"; +import Icon from "../../Styled/Icon"; +import IconWrapper from "../../Styled/IconWrapper"; interface PropsType { inWorkbench?: boolean; diff --git a/lib/ReactViews/StandardUserInterface/StandardTheme.tsx b/lib/ReactViews/StandardUserInterface/StandardTheme.tsx index 5eca616ff28..a065688d20e 100644 --- a/lib/ReactViews/StandardUserInterface/StandardTheme.tsx +++ b/lib/ReactViews/StandardUserInterface/StandardTheme.tsx @@ -1,5 +1,5 @@ -import Variables from "terriajs/lib/Sass/exports/_variables-export.scss"; -import Mixins from "terriajs/lib/Styled/mixins"; +import Variables from "../../Sass/exports/_variables-export.scss"; +import Mixins from "../../Styled/mixins"; export const terriaTheme = { ...Variables, diff --git a/lib/Styled/mixins.ts b/lib/Styled/mixins.ts index 32af1855cc3..359691550c6 100644 --- a/lib/Styled/mixins.ts +++ b/lib/Styled/mixins.ts @@ -1,6 +1,6 @@ // Doesn't result in composed classes that reuse these, but to save some typing -import cssExports from "terriajs/lib/Sass/exports/_variables-export.scss"; +import cssExports from "../Sass/exports/_variables-export.scss"; interface MixinProps { theme: typeof cssExports; diff --git a/tsconfig-node.json b/tsconfig-node.json index 5f07bcbabdb..37123944db3 100644 --- a/tsconfig-node.json +++ b/tsconfig-node.json @@ -24,10 +24,6 @@ "./lib/Traits/**/*", "./lib/Language/**/*", "./lib/ReactViews/**/*", - "./lib/ThirdParty/**/*", - // These Sass and Styled modules are required for their typings - "./lib/Sass/exports/*", - "./lib/Styled/Icon.tsx", - "./lib/Styled/IconWrapper.tsx" + "./lib/ThirdParty/**/*" ] } diff --git a/yarn.lock b/yarn.lock index d69661004f2..4a85f68382b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1787,7 +1787,7 @@ dependencies: "@types/geojson" "*" -"@types/linkify-it@^3.0.5": +"@types/linkify-it@*", "@types/linkify-it@^3.0.5": version "3.0.5" resolved "https://registry.yarnpkg.com/@types/linkify-it/-/linkify-it-3.0.5.tgz#1e78a3ac2428e6d7e6c05c1665c242023a4601d8" integrity sha512-yg6E+u0/+Zjva+buc3EIb+29XEg4wltq7cSmd4Uc2EE/1nUVmxyzpX6gUXD0V8jIrG0r7YeOGVIbYRkxeooCtw== @@ -1804,11 +1804,24 @@ resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.178.tgz#341f6d2247db528d4a13ddbb374bcdc80406f4f8" integrity sha512-0d5Wd09ItQWH1qFbEyQ7oTQ3GZrMfth5JkbN3EvTKLXcHLRDSXeLnlvlOn0wvxVIwK5o2M8JzP/OWz7T3NRsbw== +"@types/markdown-it@^14.0.1": + version "14.0.1" + resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-14.0.1.tgz#3d3fdf9dba83b69edececc070d39ec72b84270a7" + integrity sha512-6WfOG3jXR78DW8L5cTYCVVGAsIFZskRHCDo5tbqa+qtKVt4oDRVH7hyIWu1SpDQJlmIoEivNQZ5h+AGAOrgOtQ== + dependencies: + "@types/linkify-it" "*" + "@types/mdurl" "*" + "@types/math-expression-evaluator@^1.2.0": version "1.2.2" resolved "https://registry.yarnpkg.com/@types/math-expression-evaluator/-/math-expression-evaluator-1.2.2.tgz#05970d669d8c27c43f97d1557fa2a67e79698100" integrity sha512-eHy3f0C2mfFdHbK2zoKRXaM830dm2pSTUBWZ3aJCWxFsOxErWsXNPziFLliqBddGYreCM4Nyl1IZwFCt0jwRNg== +"@types/mdurl@*": + version "1.0.5" + resolved "https://registry.yarnpkg.com/@types/mdurl/-/mdurl-1.0.5.tgz#3e0d2db570e9fb6ccb2dc8fde0be1d79ac810d39" + integrity sha512-6L6VymKTzYSrEf4Nev4Xa1LCHKrlTlYCBMTlQKFuddo1CvQcE52I0mwfOJayueUC7MJuXOeHTcIU683lzd0cUA== + "@types/minimatch@*": version "3.0.5" resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40" From a9094e8dcca7ce1428c75d0f0cd40f689ff72613 Mon Sep 17 00:00:00 2001 From: Nanda Date: Fri, 26 Apr 2024 13:29:07 +1000 Subject: [PATCH 06/17] More type changes. --- lib/Core/loadArrayBuffer.ts | 2 -- lib/Core/{loadXML.js => loadXML.ts} | 20 ++++++++++--------- lib/Map/Vector/EarthGravityModel1996.js | 2 +- lib/Map/Vector/Reproject.ts | 20 +++++++++++-------- lib/ModelMixins/XmlRequestMixin.ts | 5 ++--- .../Esri/ArcGisMapServerCatalogItem.ts | 2 +- .../Catalog/Ows/WebMapServiceCapabilities.ts | 2 +- .../Ows/WebMapTileServiceCapabilities.ts | 2 +- .../Ows/WebProcessingServiceCapabilities.ts | 4 ++-- ...tureInfo.js => ImageryLayerFeatureInfo.ts} | 14 +++++-------- lib/Models/GlobeOrMap.ts | 2 +- lib/Models/ItemSearchProviders/TextIndex.ts | 5 ++--- lib/Models/{getToken.js => getToken.ts} | 15 +++++++------- package.json | 1 + yarn.lock | 5 +++++ 15 files changed, 53 insertions(+), 48 deletions(-) rename lib/Core/{loadXML.js => loadXML.ts} (51%) rename lib/Models/Feature/{ImageryLayerFeatureInfo.js => ImageryLayerFeatureInfo.ts} (75%) rename lib/Models/{getToken.js => getToken.ts} (75%) diff --git a/lib/Core/loadArrayBuffer.ts b/lib/Core/loadArrayBuffer.ts index 575ef970e8f..b1ca292fffa 100644 --- a/lib/Core/loadArrayBuffer.ts +++ b/lib/Core/loadArrayBuffer.ts @@ -6,5 +6,3 @@ export default function loadArrayBuffer( ): Promise { return Resource.fetchArrayBuffer({ url: urlOrResource, headers: headers })!; } - -module.exports = loadArrayBuffer; diff --git a/lib/Core/loadXML.js b/lib/Core/loadXML.ts similarity index 51% rename from lib/Core/loadXML.js rename to lib/Core/loadXML.ts index 6987ba8f0d5..69a2e8f4383 100644 --- a/lib/Core/loadXML.js +++ b/lib/Core/loadXML.ts @@ -1,8 +1,10 @@ -const Resource = require("terriajs-cesium/Source/Core/Resource").default; +import Resource from "terriajs-cesium/Source/Core/Resource"; -async function loadXML(urlOrResource) { - var resource = Resource.createIfNeeded(urlOrResource); - const respone = await resource.fetchXML(); +async function loadXML( + urlOrResource: string | Resource +): Promise { + var resource = (Resource as any).createIfNeeded(urlOrResource) as Resource; + const response = await resource.fetchXML(); /** * Sometimes Cesium's Resource.fetchXML will return an Array Buffer (usually in Node.js env) @@ -13,17 +15,17 @@ async function loadXML(urlOrResource) { * See full license here https://github.com/fengyuanchen/is-array-buffer/blob/main/LICENSE */ if ( - respone instanceof ArrayBuffer || - toString.call(respone) === "[object ArrayBuffer]" + response instanceof ArrayBuffer || + toString.call(response) === "[object ArrayBuffer]" ) { const enc = new TextDecoder("utf-8"); - const xmlString = enc.decode(respone); + const xmlString = enc.decode(response as any); const parser = new DOMParser(); return parser.parseFromString(xmlString, "text/xml"); } - return respone; + return response; } -module.exports = loadXML; +export default loadXML; diff --git a/lib/Map/Vector/EarthGravityModel1996.js b/lib/Map/Vector/EarthGravityModel1996.js index 01d75defd56..cd301cff88b 100644 --- a/lib/Map/Vector/EarthGravityModel1996.js +++ b/lib/Map/Vector/EarthGravityModel1996.js @@ -2,7 +2,7 @@ var CesiumMath = require("terriajs-cesium/Source/Core/Math").default; var defined = require("terriajs-cesium/Source/Core/defined").default; -var loadArrayBuffer = require("../../Core/loadArrayBuffer"); +var loadArrayBuffer = require("../../Core/loadArrayBuffer").default; /** * The Earth Gravity Model 1996 (EGM96) geoid. diff --git a/lib/Map/Vector/Reproject.ts b/lib/Map/Vector/Reproject.ts index b883042f591..51e505fd528 100644 --- a/lib/Map/Vector/Reproject.ts +++ b/lib/Map/Vector/Reproject.ts @@ -1,9 +1,8 @@ +import proj4 from "proj4"; import defined from "terriajs-cesium/Source/Core/defined"; -import Proj4Definitions from "./Proj4Definitions"; import urijs from "urijs"; - -const proj4 = require("proj4").default; -const loadText = require("../../Core/loadText"); +import loadText from "../../Core/loadText"; +import Proj4Definitions from "./Proj4Definitions"; export default { TERRIA_CRS: "EPSG:4326", @@ -60,16 +59,21 @@ export default { ): [number, number] | undefined { const source = sourceCode in Proj4Definitions - ? new proj4.Proj(Proj4Definitions[sourceCode]) + ? proj4.Proj(Proj4Definitions[sourceCode]) : undefined; const dest = destCode in Proj4Definitions - ? new proj4.Proj(Proj4Definitions[destCode]) + ? proj4.Proj(Proj4Definitions[destCode]) : undefined; - if (!sourceCode || !destCode) { + if (!source || !dest) { return; } - return proj4(source, dest, coordinates); + const result = proj4.transform(source, dest, coordinates) ?? {}; + if (result) { + const { x, y } = result; + return [x, y]; + } + return undefined; }, /** diff --git a/lib/ModelMixins/XmlRequestMixin.ts b/lib/ModelMixins/XmlRequestMixin.ts index 6bd29d3c32a..5f64e01a919 100644 --- a/lib/ModelMixins/XmlRequestMixin.ts +++ b/lib/ModelMixins/XmlRequestMixin.ts @@ -1,9 +1,8 @@ import URI from "urijs"; import AbstractConstructor from "../Core/AbstractConstructor"; import isDefined from "../Core/isDefined"; - -const loadXML = require("../Core/loadXML"); -const loadWithXhr = require("../Core/loadWithXhr"); +import loadWithXhr from "../Core/loadWithXhr"; +import loadXML from "../Core/loadXML"; export default function XmlRequestMixin>( Base: T diff --git a/lib/Models/Catalog/Esri/ArcGisMapServerCatalogItem.ts b/lib/Models/Catalog/Esri/ArcGisMapServerCatalogItem.ts index b91a6c9003f..ff0e1880a8b 100644 --- a/lib/Models/Catalog/Esri/ArcGisMapServerCatalogItem.ts +++ b/lib/Models/Catalog/Esri/ArcGisMapServerCatalogItem.ts @@ -88,7 +88,7 @@ class MapServerStratum extends LoadableStratum( } static async load(item: ArcGisMapServerCatalogItem) { - if (!isDefined(item.uri)) { + if (!isDefined(item.uri) || !isDefined(item.url)) { throw new TerriaError({ title: i18next.t("models.arcGisMapServerCatalogItem.invalidUrlTitle"), message: i18next.t( diff --git a/lib/Models/Catalog/Ows/WebMapServiceCapabilities.ts b/lib/Models/Catalog/Ows/WebMapServiceCapabilities.ts index 205245d6d2e..6ed4896837e 100644 --- a/lib/Models/Catalog/Ows/WebMapServiceCapabilities.ts +++ b/lib/Models/Catalog/Ows/WebMapServiceCapabilities.ts @@ -163,7 +163,7 @@ export default class WebMapServiceCapabilities { createTransformer((url: string) => { return Promise.resolve(loadXML(url)).then(function (capabilitiesXml) { const json = xml2json(capabilitiesXml); - if (!defined(json.Capability)) { + if (!capabilitiesXml || !defined(json.Capability)) { throw networkRequestError({ title: "Invalid GetCapabilities", message: diff --git a/lib/Models/Catalog/Ows/WebMapTileServiceCapabilities.ts b/lib/Models/Catalog/Ows/WebMapTileServiceCapabilities.ts index 4c494292f84..18cb04ff5aa 100644 --- a/lib/Models/Catalog/Ows/WebMapTileServiceCapabilities.ts +++ b/lib/Models/Catalog/Ows/WebMapTileServiceCapabilities.ts @@ -131,7 +131,7 @@ export default class WebMapTileServiceCapabilities { createTransformer((url: string) => { return Promise.resolve(loadXML(url)).then(function (capabilitiesXml) { const json = xml2json(capabilitiesXml); - if (!defined(json.ServiceIdentification)) { + if (!capabilitiesXml || !defined(json.ServiceIdentification)) { throw networkRequestError({ title: i18next.t( "models.webMapTileServiceCatalogGroup.invalidCapabilitiesTitle" diff --git a/lib/Models/Catalog/Ows/WebProcessingServiceCapabilities.ts b/lib/Models/Catalog/Ows/WebProcessingServiceCapabilities.ts index f3c3e3d6d78..bdd8a5fdd05 100644 --- a/lib/Models/Catalog/Ows/WebProcessingServiceCapabilities.ts +++ b/lib/Models/Catalog/Ows/WebProcessingServiceCapabilities.ts @@ -54,7 +54,7 @@ export interface ServiceProvider { export default class WebProcessingServiceCapabilities { constructor( - readonly capabilitiesXml: string, + readonly capabilitiesXml: XMLDocument, readonly capabilities: Capabilities ) {} @@ -62,7 +62,7 @@ export default class WebProcessingServiceCapabilities { return Promise.resolve(loadXML(url)).then(function (capabilitiesXml) { const capabilities = parseCapabilities(xml2json(capabilitiesXml)); - if (capabilities === undefined) { + if (capabilitiesXml === undefined || capabilities === undefined) { throw networkRequestError({ title: i18next.t( "models.webProcessingServiceCatalogGroup.invalidCapabilitiesTitle" diff --git a/lib/Models/Feature/ImageryLayerFeatureInfo.js b/lib/Models/Feature/ImageryLayerFeatureInfo.ts similarity index 75% rename from lib/Models/Feature/ImageryLayerFeatureInfo.js rename to lib/Models/Feature/ImageryLayerFeatureInfo.ts index e9a9b84d4fe..31f6da877bb 100644 --- a/lib/Models/Feature/ImageryLayerFeatureInfo.js +++ b/lib/Models/Feature/ImageryLayerFeatureInfo.ts @@ -1,10 +1,6 @@ -"use strict"; - -var ImageryLayerFeatureInfo = - require("terriajs-cesium/Source/Scene/ImageryLayerFeatureInfo").default; -var defined = require("terriajs-cesium/Source/Core/defined").default; - -var formatPropertyValue = require("../../Core/formatPropertyValue"); +import defined from "terriajs-cesium/Source/Core/defined"; +import ImageryLayerFeatureInfo from "terriajs-cesium/Source/Scene/ImageryLayerFeatureInfo"; +import formatPropertyValue from "../../Core/formatPropertyValue"; /** * Configures the description of this feature by creating an HTML table of properties and their values. @@ -12,8 +8,8 @@ var formatPropertyValue = require("../../Core/formatPropertyValue"); * @param {Object} properties An object literal containing the properties of the feature. */ ImageryLayerFeatureInfo.prototype.configureDescriptionFromProperties = - function (properties) { - function describe(properties) { + function (properties: any) { + function describe(properties: any) { var html = ''; for (var key in properties) { if (Object.prototype.hasOwnProperty.call(properties, key)) { diff --git a/lib/Models/GlobeOrMap.ts b/lib/Models/GlobeOrMap.ts index a50b43e2874..0cf40450d13 100644 --- a/lib/Models/GlobeOrMap.ts +++ b/lib/Models/GlobeOrMap.ts @@ -33,7 +33,7 @@ import createStratumInstance from "./Definition/createStratumInstance"; import TerriaFeature from "./Feature/Feature"; import Terria from "./Terria"; -require("./Feature/ImageryLayerFeatureInfo"); // overrides Cesium's prototype.configureDescriptionFromProperties +import "./Feature/ImageryLayerFeatureInfo"; // overrides Cesium's prototype.configureDescriptionFromProperties export default abstract class GlobeOrMap { abstract readonly type: string; diff --git a/lib/Models/ItemSearchProviders/TextIndex.ts b/lib/Models/ItemSearchProviders/TextIndex.ts index 39dead55b13..88895e3c317 100644 --- a/lib/Models/ItemSearchProviders/TextIndex.ts +++ b/lib/Models/ItemSearchProviders/TextIndex.ts @@ -1,8 +1,7 @@ import MiniSearch, { Options as MiniSearchOptions } from "minisearch"; -import joinUrl from "./joinUrl"; +import loadText from "../../Core/loadText"; import { IndexBase, IndexType } from "./Types"; - -const loadText = require("../../Core/loadText"); +import joinUrl from "./joinUrl"; // Text search query type TextSearchQuery = string; diff --git a/lib/Models/getToken.js b/lib/Models/getToken.ts similarity index 75% rename from lib/Models/getToken.js rename to lib/Models/getToken.ts index 41c0539cf55..7f792bb51a7 100644 --- a/lib/Models/getToken.js +++ b/lib/Models/getToken.ts @@ -1,12 +1,13 @@ -const defined = require("terriajs-cesium/Source/Core/defined").default; -const loadWithXhr = require("../Core/loadWithXhr"); -const TerriaError = require("../Core/TerriaError").default; -var i18next = require("i18next").default; +import defined from "terriajs-cesium/Source/Core/defined"; +import loadWithXhr from "../Core/loadWithXhr"; +import TerriaError from "../Core/TerriaError"; +import i18next from "i18next"; +import Terria from "./Terria"; -function getToken(terria, tokenUrl, url) { +function getToken(terria: Terria, tokenUrl: string, url: string) { const options = { url: tokenUrl, - method: "POST", + method: "POST" as const, headers: { "Content-Type": "application/json" }, data: JSON.stringify({ url: url @@ -48,4 +49,4 @@ function getToken(terria, tokenUrl, url) { }); } -module.exports = getToken; +export default getToken; diff --git a/package.json b/package.json index e5c3d88dac9..9357b0e5570 100644 --- a/package.json +++ b/package.json @@ -199,6 +199,7 @@ "@types/linkify-it": "^3.0.5", "@types/markdown-it": "^14.0.1", "@types/node": "^18.15.11", + "@types/proj4": "^2.5.5", "@types/webpack": "4.41.33", "@typescript-eslint/eslint-plugin": "^6.12.0", "@typescript-eslint/parser": "^6.12.0", diff --git a/yarn.lock b/yarn.lock index 4a85f68382b..6b84bf7eaf5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1867,6 +1867,11 @@ resolved "https://registry.yarnpkg.com/@types/pbf/-/pbf-3.0.2.tgz#8d291ad68b4b8c533e96c174a2e3e6399a59ed61" integrity sha512-EDrLIPaPXOZqDjrkzxxbX7UlJSeQVgah3i0aA4pOSzmK9zq3BIh7/MZIQxED7slJByvKM4Gc6Hypyu2lJzh3SQ== +"@types/proj4@^2.5.5": + version "2.5.5" + resolved "https://registry.yarnpkg.com/@types/proj4/-/proj4-2.5.5.tgz#044d53782dc75f20335577ca3af2643962a56980" + integrity sha512-y4tHUVVoMEOm2nxRLQ2/ET8upj/pBmoutGxFw2LZJTQWPgWXI+cbxVEUFFmIzr/bpFR83hGDOTSXX6HBeObvZA== + "@types/prop-types@*": version "15.7.4" resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.4.tgz#fcf7205c25dff795ee79af1e30da2c9790808f11" From c699f46a5a0423a134a4d945a779223bc861cf1f Mon Sep 17 00:00:00 2001 From: Nanda Date: Fri, 26 Apr 2024 13:43:46 +1000 Subject: [PATCH 07/17] Lint fixes. --- lib/Core/arrayContains.ts | 2 +- lib/Core/linkifyContent.ts | 6 +++--- lib/Core/loadText.ts | 2 +- lib/Core/loadXML.ts | 2 +- lib/Core/pollToPromise.ts | 8 ++++---- lib/Core/readXml.ts | 2 +- lib/Core/triggerResize.ts | 2 +- lib/Models/Feature/ImageryLayerFeatureInfo.ts | 6 +++--- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/Core/arrayContains.ts b/lib/Core/arrayContains.ts index 51998e73e70..ae37169bd6b 100644 --- a/lib/Core/arrayContains.ts +++ b/lib/Core/arrayContains.ts @@ -1,5 +1,5 @@ export default function arrayContains(array: readonly T[], value: T) { - for (var i = 0; i < array.length; ++i) { + for (let i = 0; i < array.length; ++i) { if (array[i] === value) { return true; } diff --git a/lib/Core/linkifyContent.ts b/lib/Core/linkifyContent.ts index d04f1667958..af31b3cccd0 100644 --- a/lib/Core/linkifyContent.ts +++ b/lib/Core/linkifyContent.ts @@ -3,9 +3,9 @@ import linkifyIt from "linkify-it"; const linkify = linkifyIt(); function linkifyContent(content: string) { - let matches = linkify.match(content), - result = [], - last: number; + const matches = linkify.match(content), + result = []; + let last: number; if (matches) { last = 0; diff --git a/lib/Core/loadText.ts b/lib/Core/loadText.ts index 60ac3bcd010..dcf4af63aac 100644 --- a/lib/Core/loadText.ts +++ b/lib/Core/loadText.ts @@ -1,7 +1,7 @@ import Resource from "terriajs-cesium/Source/Core/Resource"; async function loadText(urlOrResource: string | Resource): Promise { - var resource = (Resource as any).createIfNeeded(urlOrResource) as Resource; + const resource = (Resource as any).createIfNeeded(urlOrResource) as Resource; const response = resource.fetchText(); if (response === undefined) { throw new Error("Request throttled"); diff --git a/lib/Core/loadXML.ts b/lib/Core/loadXML.ts index 69a2e8f4383..863f2ab3dd0 100644 --- a/lib/Core/loadXML.ts +++ b/lib/Core/loadXML.ts @@ -3,7 +3,7 @@ import Resource from "terriajs-cesium/Source/Core/Resource"; async function loadXML( urlOrResource: string | Resource ): Promise { - var resource = (Resource as any).createIfNeeded(urlOrResource) as Resource; + const resource = (Resource as any).createIfNeeded(urlOrResource) as Resource; const response = await resource.fetchXML(); /** diff --git a/lib/Core/pollToPromise.ts b/lib/Core/pollToPromise.ts index f1012902caf..57efa3c01c6 100644 --- a/lib/Core/pollToPromise.ts +++ b/lib/Core/pollToPromise.ts @@ -9,12 +9,12 @@ interface Options { const pollToPromise = function (f: () => boolean, options: Options) { options = defaultValue(options, (defaultValue as any).EMPTY_OBJECT); - var pollInterval = defaultValue(options.pollInterval, 1); - var timeout = defaultValue(options.timeout, 5000); + const pollInterval = defaultValue(options.pollInterval, 1); + const timeout = defaultValue(options.timeout, 5000); return new Promise((resolve, reject) => { - var startTimestamp = getTimestamp(); - var endTimestamp = startTimestamp + timeout; + const startTimestamp = getTimestamp(); + const endTimestamp = startTimestamp + timeout; function poller() { if (f()) { diff --git a/lib/Core/readXml.ts b/lib/Core/readXml.ts index 0d0833a57ab..c2816aeeaa2 100644 --- a/lib/Core/readXml.ts +++ b/lib/Core/readXml.ts @@ -13,7 +13,7 @@ function readXml(file: Blob) { if (!result) { return undefined; } - var xml = parser.parseFromString(result, "application/xml"); + const xml = parser.parseFromString(result, "application/xml"); if ( !xml || !xml.documentElement || diff --git a/lib/Core/triggerResize.ts b/lib/Core/triggerResize.ts index 004d0c36b3c..017b57f0399 100644 --- a/lib/Core/triggerResize.ts +++ b/lib/Core/triggerResize.ts @@ -5,7 +5,7 @@ export default function triggerResize() { try { window.dispatchEvent(new Event("resize")); } catch (e) { - var evt = window.document.createEvent("UIEvents"); + const evt = window.document.createEvent("UIEvents"); evt.initUIEvent("resize", true, false, window, 0); window.dispatchEvent(evt); } diff --git a/lib/Models/Feature/ImageryLayerFeatureInfo.ts b/lib/Models/Feature/ImageryLayerFeatureInfo.ts index 31f6da877bb..eb42f051eff 100644 --- a/lib/Models/Feature/ImageryLayerFeatureInfo.ts +++ b/lib/Models/Feature/ImageryLayerFeatureInfo.ts @@ -10,10 +10,10 @@ import formatPropertyValue from "../../Core/formatPropertyValue"; ImageryLayerFeatureInfo.prototype.configureDescriptionFromProperties = function (properties: any) { function describe(properties: any) { - var html = '
'; - for (var key in properties) { + let html = '
'; + for (const key in properties) { if (Object.prototype.hasOwnProperty.call(properties, key)) { - var value = properties[key]; + const value = properties[key]; if (defined(value)) { if (typeof value === "object") { html += From d3083faa6938a92ec0db1e7e8a66b24a3664b919 Mon Sep 17 00:00:00 2001 From: Nanda Date: Fri, 26 Apr 2024 14:32:36 +1000 Subject: [PATCH 08/17] Move some of the @types/* to dependencies. This is needed when building terriajs from outside, like from terriamap. --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 9357b0e5570..615508672c4 100644 --- a/package.json +++ b/package.json @@ -56,13 +56,16 @@ "@types/jasmine-ajax": "^3.3.0", "@types/json5": "^0.0.30", "@types/leaflet": "^1.7.10", + "@types/linkify-it": "^3.0.5", "@types/lodash-es": "^4.17.3", + "@types/markdown-it": "^14.0.1", "@types/math-expression-evaluator": "^1.2.0", "@types/ms": "^0.7.31", "@types/mustache": "^0.8.32", "@types/node-fetch": "^2.6.2", "@types/papaparse": "^4.5.9", "@types/pbf": "^3.0.1", + "@types/proj4": "^2.5.5", "@types/rbush": "^3.0.0", "@types/rc-slider": "^8.6.6", "@types/react": "^17.0.3", @@ -196,10 +199,7 @@ "@babel/eslint-parser": "^7.23.3", "@babel/plugin-syntax-dynamic-import": "^7.8.3", "@types/dateformat": "^3.0.1", - "@types/linkify-it": "^3.0.5", - "@types/markdown-it": "^14.0.1", "@types/node": "^18.15.11", - "@types/proj4": "^2.5.5", "@types/webpack": "4.41.33", "@typescript-eslint/eslint-plugin": "^6.12.0", "@typescript-eslint/parser": "^6.12.0", From 75c1b089c17d42f3ac8ea8ec1a4107e7d7652219 Mon Sep 17 00:00:00 2001 From: Nanda Date: Fri, 26 Apr 2024 15:05:45 +1000 Subject: [PATCH 09/17] Typeify more files. --- lib/Core/containsAny.js | 25 ------------------- lib/Core/containsAny.ts | 23 +++++++++++++++++ lib/Core/replaceUnderscores.js | 15 ----------- lib/Core/replaceUnderscores.ts | 10 ++++++++ .../WebProcessingServiceCatalogFunctionJob.ts | 15 ++++++----- lib/ReactViews/Story/StoryBuilder.tsx | 6 ++--- lib/ReactViews/Story/StoryEditor.d.ts | 15 +++++++++++ lib/ThirdParty/xml2json.d.ts | 4 +++ lib/ThirdParty/xml2json.js | 2 +- 9 files changed, 63 insertions(+), 52 deletions(-) delete mode 100644 lib/Core/containsAny.js create mode 100644 lib/Core/containsAny.ts delete mode 100644 lib/Core/replaceUnderscores.js create mode 100644 lib/Core/replaceUnderscores.ts create mode 100644 lib/ReactViews/Story/StoryEditor.d.ts create mode 100644 lib/ThirdParty/xml2json.d.ts diff --git a/lib/Core/containsAny.js b/lib/Core/containsAny.js deleted file mode 100644 index dac94168d30..00000000000 --- a/lib/Core/containsAny.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; - -var defined = require("terriajs-cesium/Source/Core/defined").default; - -/** - * Determins is a given string contains any of a number of possible strings. - * - * @param {String} s The string to test. - * @param {String[]} possibleStrings The possible strings to test `s` for. - * @return {Boolean} true if `s` contains any of the strings in `possibleStrings`; otherwise, false. - */ -var containsAny = function (s, possibleStrings) { - if (!defined(s)) { - return false; - } - - for (var i = 0; i < possibleStrings.length; ++i) { - if (s.indexOf(possibleStrings[i]) >= 0) { - return true; - } - } - return false; -}; - -module.exports = containsAny; diff --git a/lib/Core/containsAny.ts b/lib/Core/containsAny.ts new file mode 100644 index 00000000000..480d9ce127a --- /dev/null +++ b/lib/Core/containsAny.ts @@ -0,0 +1,23 @@ +import defined from "terriajs-cesium/Source/Core/defined"; + +/** + * Determins is a given string contains any of a number of possible strings. + * + * @param s The string to test. + * @param possibleStrings The possible strings to test `s` for. + * @return true if `s` contains any of the strings in `possibleStrings`; otherwise, false. + */ +const containsAny = function (s: string, possibleStrings: string[]) { + if (!defined(s)) { + return false; + } + + for (var i = 0; i < possibleStrings.length; ++i) { + if (s.indexOf(possibleStrings[i]) >= 0) { + return true; + } + } + return false; +}; + +export default containsAny; diff --git a/lib/Core/replaceUnderscores.js b/lib/Core/replaceUnderscores.js deleted file mode 100644 index e6e500ff6fd..00000000000 --- a/lib/Core/replaceUnderscores.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -/** - * Replace all underscores in the string with spaces. If the argument is not a string, return it unchanged. - * @param {} string The string to replace. If the argument is not a string, does nothing. - * @return {} The argument with all underscores replaced with spaces. If the argument is not a string, returns the argument unchanged. - */ -function replaceUnderscores(string) { - if (typeof string === "string" || string instanceof String) { - return string.replace(/_/g, " "); - } - return string; -} - -module.exports = replaceUnderscores; diff --git a/lib/Core/replaceUnderscores.ts b/lib/Core/replaceUnderscores.ts new file mode 100644 index 00000000000..693deb23882 --- /dev/null +++ b/lib/Core/replaceUnderscores.ts @@ -0,0 +1,10 @@ +/** + * Replace all underscores in the string with spaces. If the argument is not a string, return it unchanged. + * @param string The string to replace. If the argument is not a string, does nothing. + * @return The argument with all underscores replaced with spaces. If the argument is not a string, returns the argument unchanged. + */ +function replaceUnderscores(str: string | undefined): typeof str { + return typeof str === "string" ? str.replace(/_/g, " ") : str; +} + +export default replaceUnderscores; diff --git a/lib/Models/Catalog/Ows/WebProcessingServiceCatalogFunctionJob.ts b/lib/Models/Catalog/Ows/WebProcessingServiceCatalogFunctionJob.ts index 95a7aab7e0e..ed9ae07b63e 100644 --- a/lib/Models/Catalog/Ows/WebProcessingServiceCatalogFunctionJob.ts +++ b/lib/Models/Catalog/Ows/WebProcessingServiceCatalogFunctionJob.ts @@ -3,17 +3,17 @@ import { action, computed, isObservableArray, + makeObservable, observable, + override, runInAction, - toJS, - makeObservable, - override + toJS } from "mobx"; import Mustache from "mustache"; import URI from "urijs"; -import isDefined from "../../../Core/isDefined"; -import { JsonObject, isJsonObject } from "../../../Core/Json"; +import { JsonObject } from "../../../Core/Json"; import TerriaError from "../../../Core/TerriaError"; +import isDefined from "../../../Core/isDefined"; import CatalogFunctionJobMixin from "../../../ModelMixins/CatalogFunctionJobMixin"; import CatalogMemberMixin from "../../../ModelMixins/CatalogMemberMixin"; import XmlRequestMixin from "../../../ModelMixins/XmlRequestMixin"; @@ -23,16 +23,15 @@ import { FeatureInfoTemplateTraits } from "../../../Traits/TraitsClasses/Feature import WebProcessingServiceCatalogFunctionJobTraits from "../../../Traits/TraitsClasses/WebProcessingServiceCatalogFunctionJobTraits"; import CommonStrata from "../../Definition/CommonStrata"; import CreateModel from "../../Definition/CreateModel"; -import createStratumInstance from "../../Definition/createStratumInstance"; import LoadableStratum from "../../Definition/LoadableStratum"; -import { BaseModel } from "../../Definition/Model"; +import { BaseModel, ModelConstructorParameters } from "../../Definition/Model"; import StratumFromTraits from "../../Definition/StratumFromTraits"; import StratumOrder from "../../Definition/StratumOrder"; +import createStratumInstance from "../../Definition/createStratumInstance"; import updateModelFromJson from "../../Definition/updateModelFromJson"; import upsertModelFromJson from "../../Definition/upsertModelFromJson"; import GeoJsonCatalogItem from "../CatalogItems/GeoJsonCatalogItem"; import CatalogMemberFactory from "../CatalogMemberFactory"; -import { ModelConstructorParameters } from "../../Definition/Model"; import proxyCatalogItemUrl from "../proxyCatalogItemUrl"; const executeWpsTemplate = require("./ExecuteWpsTemplate.xml"); diff --git a/lib/ReactViews/Story/StoryBuilder.tsx b/lib/ReactViews/Story/StoryBuilder.tsx index 733b90537ab..3b2bfa4a6f8 100644 --- a/lib/ReactViews/Story/StoryBuilder.tsx +++ b/lib/ReactViews/Story/StoryBuilder.tsx @@ -30,12 +30,12 @@ import SharePanel from "../Map/Panels/SharePanel/SharePanel"; import { WithViewState, withViewState } from "../Context"; import Story from "./Story"; import Styles from "./story-builder.scss"; -import StoryEditor from "./StoryEditor.jsx"; +import StoryEditor from "./StoryEditor"; const dataStoriesImg = require("../../../wwwroot/images/data-stories-getting-started.jpg"); const STORY_VIDEO = "storyVideo"; -type StoryData = ViewState["terria"]["stories"][number]; +export type StoryData = ViewState["terria"]["stories"][number]; interface IProps { isVisible?: boolean; @@ -85,7 +85,7 @@ class StoryBuilder extends React.Component< storyWithOpenMenuId: undefined }; } - removeStory = (index: number, story: StoryData) => { + removeStory = (index: number, story?: StoryData) => { this.setState({ isSharing: false, isRemoving: true, diff --git a/lib/ReactViews/Story/StoryEditor.d.ts b/lib/ReactViews/Story/StoryEditor.d.ts new file mode 100644 index 00000000000..3bf04fdcc2a --- /dev/null +++ b/lib/ReactViews/Story/StoryEditor.d.ts @@ -0,0 +1,15 @@ +import React from "react"; +import Terria from "../../Models/Terria"; +import { StoryData } from "./StoryBuilder"; + +interface PropsType { + story?: StoryData; + removeStory: (id: number) => void; + saveStory: (story: StoryData) => void; + exitEditingMode: () => void; + terria: Terria; +} + +declare class StoryEditor extends React.Component {} + +export default StoryEditor; diff --git a/lib/ThirdParty/xml2json.d.ts b/lib/ThirdParty/xml2json.d.ts new file mode 100644 index 00000000000..7e663dfa272 --- /dev/null +++ b/lib/ThirdParty/xml2json.d.ts @@ -0,0 +1,4 @@ +export default function xml2json( + xml: XMLDocument | string | undefined, + extended?: boolean +): any; diff --git a/lib/ThirdParty/xml2json.js b/lib/ThirdParty/xml2json.js index fcd396f09c4..61ae6d160cd 100644 --- a/lib/ThirdParty/xml2json.js +++ b/lib/ThirdParty/xml2json.js @@ -180,4 +180,4 @@ function text2xml(str) { return parser.parseFromString(str, "text/xml"); } -module.exports = xml2json; +export default xml2json; From b066468ad9c842f49a104c1803fe1edc8b921bc9 Mon Sep 17 00:00:00 2001 From: Nanda Date: Fri, 26 Apr 2024 15:08:29 +1000 Subject: [PATCH 10/17] Fix lint. --- lib/Core/containsAny.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Core/containsAny.ts b/lib/Core/containsAny.ts index 480d9ce127a..9c16a415932 100644 --- a/lib/Core/containsAny.ts +++ b/lib/Core/containsAny.ts @@ -12,7 +12,7 @@ const containsAny = function (s: string, possibleStrings: string[]) { return false; } - for (var i = 0; i < possibleStrings.length; ++i) { + for (let i = 0; i < possibleStrings.length; ++i) { if (s.indexOf(possibleStrings[i]) >= 0) { return true; } From c2e4d9a6ad396a560a76e857fe058377e76d4f3c Mon Sep 17 00:00:00 2001 From: Nanda Date: Fri, 26 Apr 2024 15:24:51 +1000 Subject: [PATCH 11/17] Fix replaceUnderscores to handle String type. --- lib/Core/replaceUnderscores.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Core/replaceUnderscores.ts b/lib/Core/replaceUnderscores.ts index 693deb23882..c8772e389fa 100644 --- a/lib/Core/replaceUnderscores.ts +++ b/lib/Core/replaceUnderscores.ts @@ -3,8 +3,10 @@ * @param string The string to replace. If the argument is not a string, does nothing. * @return The argument with all underscores replaced with spaces. If the argument is not a string, returns the argument unchanged. */ -function replaceUnderscores(str: string | undefined): typeof str { - return typeof str === "string" ? str.replace(/_/g, " ") : str; +function replaceUnderscores(str: any): typeof str { + return typeof str === "string" || str instanceof String + ? str.replace(/_/g, " ") + : str; } export default replaceUnderscores; From 54dc6d674e9d55ad349e155243ff2bda51b97c56 Mon Sep 17 00:00:00 2001 From: Nanda Date: Sat, 27 Apr 2024 17:31:02 +1000 Subject: [PATCH 12/17] Remove CJS style exports. --- lib/Models/Feature/Feature.ts | 2 -- lib/ReactViews/Workbench/Controls/ShortReport.tsx | 4 ---- 2 files changed, 6 deletions(-) diff --git a/lib/Models/Feature/Feature.ts b/lib/Models/Feature/Feature.ts index a149bf0c1ff..fceaf85c047 100644 --- a/lib/Models/Feature/Feature.ts +++ b/lib/Models/Feature/Feature.ts @@ -108,5 +108,3 @@ function addCustomFeatureProperties(entity: Entity) { } } } - -module.exports = TerriaFeature; diff --git a/lib/ReactViews/Workbench/Controls/ShortReport.tsx b/lib/ReactViews/Workbench/Controls/ShortReport.tsx index 7143a9eac89..de5dac79e52 100644 --- a/lib/ReactViews/Workbench/Controls/ShortReport.tsx +++ b/lib/ReactViews/Workbench/Controls/ShortReport.tsx @@ -1,5 +1,3 @@ -"use strict"; - import { runInAction } from "mobx"; import { observer } from "mobx-react"; import React from "react"; @@ -103,5 +101,3 @@ export default class ShortReport extends React.Component<{ ); } } - -module.exports = ShortReport; From 8f3fd7cbf9082b242fb179d3b79a8636eafa0eaa Mon Sep 17 00:00:00 2001 From: Nanda Date: Tue, 30 Apr 2024 13:53:27 +1000 Subject: [PATCH 13/17] Update CHANGES.md. --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 9d0d1f50712..c8a93e8f9a2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,7 @@ #### next release (8.7.2) - Add NumberParameterEditor to enable WPS AllowedValues Ranges to be set and use DefaultValue +- TSify some `js` and `jsx` files and provide `.d.ts` ambient type files for a few others. This is so that running `tsc` on an external project that imports Terria code will typecheck successfully. #### 8.7.1 - 2024-04-16 From bf079e8d1afed2b664cf0ce002289d58ac18cec0 Mon Sep 17 00:00:00 2001 From: Stephen Davies Date: Thu, 2 May 2024 16:37:31 +1000 Subject: [PATCH 14/17] Remove old utility now included in ES2016 --- lib/Core/arrayContains.ts | 8 -------- .../StandardUserInterface/StandardUserInterface.tsx | 6 +----- 2 files changed, 1 insertion(+), 13 deletions(-) delete mode 100644 lib/Core/arrayContains.ts diff --git a/lib/Core/arrayContains.ts b/lib/Core/arrayContains.ts deleted file mode 100644 index ae37169bd6b..00000000000 --- a/lib/Core/arrayContains.ts +++ /dev/null @@ -1,8 +0,0 @@ -export default function arrayContains(array: readonly T[], value: T) { - for (let i = 0; i < array.length; ++i) { - if (array[i] === value) { - return true; - } - } - return false; -} diff --git a/lib/ReactViews/StandardUserInterface/StandardUserInterface.tsx b/lib/ReactViews/StandardUserInterface/StandardUserInterface.tsx index 495587487f5..5fcececb343 100644 --- a/lib/ReactViews/StandardUserInterface/StandardUserInterface.tsx +++ b/lib/ReactViews/StandardUserInterface/StandardUserInterface.tsx @@ -6,7 +6,6 @@ import React, { ReactNode, useEffect } from "react"; import { useTranslation } from "react-i18next"; import { DefaultTheme } from "styled-components"; import combine from "terriajs-cesium/Source/Core/combine"; -import arrayContains from "../../Core/arrayContains"; import ViewState from "../../ReactViewModels/ViewState"; import Disclaimer from "../Disclaimer"; import DragDropFile from "../DragDropFile"; @@ -68,10 +67,7 @@ const StandardUserInterfaceBase: React.FC = }); const handleDragOver = (e: React.DragEvent) => { - if ( - !e.dataTransfer.types || - !arrayContains(e.dataTransfer.types, "Files") - ) { + if (!e.dataTransfer.types || !e.dataTransfer.types.includes("Files")) { return; } e.preventDefault(); From b4cbe7547b1a9fd30cf4a3f4a6bf0758b2dae48b Mon Sep 17 00:00:00 2001 From: Nanda Date: Thu, 23 May 2024 11:52:33 +1000 Subject: [PATCH 15/17] Remove ts-expect-error. --- lib/ReactViews/Map/MapColumn.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/ReactViews/Map/MapColumn.tsx b/lib/ReactViews/Map/MapColumn.tsx index 0135fb2a5da..2701e89cc85 100644 --- a/lib/ReactViews/Map/MapColumn.tsx +++ b/lib/ReactViews/Map/MapColumn.tsx @@ -60,7 +60,6 @@ export const MapColumn: FC = observer( `} > Date: Mon, 17 Jun 2024 15:14:53 +1000 Subject: [PATCH 16/17] Use ts-expect-error. --- lib/Models/LocationMarkerUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Models/LocationMarkerUtils.ts b/lib/Models/LocationMarkerUtils.ts index b16977b7ded..d7eee1871ca 100644 --- a/lib/Models/LocationMarkerUtils.ts +++ b/lib/Models/LocationMarkerUtils.ts @@ -6,7 +6,7 @@ import Terria from "./Terria"; import LatLonHeight from "../Core/LatLonHeight"; import { toJS } from "mobx"; -//@ts-ignore +// @ts-expect-error import markerIcon from "../../wwwroot/images/map-pin.png"; export const LOCATION_MARKER_DATA_SOURCE_NAME = From cb7ec0f8ab37e0fc37d722faf27f7acfea61cdfc Mon Sep 17 00:00:00 2001 From: Nanda Date: Mon, 17 Jun 2024 15:20:17 +1000 Subject: [PATCH 17/17] Update CHANGES.md. --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 5ad2875fd76..345758a0b6c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ #### next release (8.7.5) +- TSify some `js` and `jsx` files and provide `.d.ts` ambient type files for a few others. This is so that running `tsc` on an external project that imports Terria code will typecheck successfully. - [The next improvement] #### 8.7.4 - 2024-06-07 @@ -24,7 +25,6 @@ #### 8.7.2 - 2024-05-14 - Add NumberParameterEditor to enable WPS AllowedValues Ranges to be set and use DefaultValue -- TSify some `js` and `jsx` files and provide `.d.ts` ambient type files for a few others. This is so that running `tsc` on an external project that imports Terria code will typecheck successfully. - Feature info template has access to activeStyle of item having TableTraits. - Updated a few dependencies to fix security warnings: `underscore`, `visx`, `shpjs`, `resolve-uri-loader`, `svg-sprite-loader` - Allow related maps UI strings to be translated. Translation support for related maps content is not included.