import { Cheerio } from 'cheerio'; import { CRU } from 'facilmap-types'; import { CustomPluginOptions } from 'i18next'; import { Field } from 'facilmap-types'; import { FieldOption } from 'facilmap-types'; import { i18n } from 'i18next'; import { ID } from 'facilmap-types'; import { Line } from 'facilmap-types'; import { LineTemplate } from 'facilmap-types'; import { Marker } from 'facilmap-types'; import { Module } from 'i18next'; import { Newable } from 'i18next'; import { Node as Node_2 } from 'domhandler'; import { ParentNode as ParentNode_2 } from 'domhandler'; import { Point } from 'facilmap-types'; import { RouteMode } from 'facilmap-types'; import { SearchResult } from 'facilmap-types'; import { Type } from 'facilmap-types'; import { Units } from 'facilmap-types'; import { View } from 'facilmap-types'; import { ZoomLevel } from 'facilmap-types'; export declare function applyLineStyles(line: Line, type: Type): Line; export declare function applyMarkerStyles(marker: Marker, type: Type): Marker; declare interface AscentDescent { ascent: number | undefined; descent: number | undefined; } export declare function calculateDistance(posList: Array<{ lat: number; lon: number; }>): number; export declare function canControl(type: Type, ignoreField?: Field | null): Array; export declare function compileExpression(expr?: string): FilterFunc; export declare interface Config { openElevationApiUrl: string; openElevationThrottleMs: number; openElevationMaxBatchSize: number; nominatimUrl: string; } declare let currentUnitsGetter: (() => Units | undefined) | undefined; declare type DecodedGeoQuery = Point & { zoom: number; }; export declare interface DecodedRouteMode { mode: "" | "car" | "bicycle" | "pedestrian" | "track"; type: "" | "hgv" | "road" | "mountain" | "electric" | "hiking" | "wheelchair"; preference: "fastest" | "shortest"; details: boolean; avoid: Array<"highways" | "tollways" | "ferries" | "fords" | "steps">; } /** * Checks whether the given query string is a representation of coordinates, such an OSM permalink. */ export declare function decodeLonLatUrl(query: string): DecodedGeoQuery | undefined; export declare function decodeQueryString(str: string): Record; export declare function decodeRouteMode(encodedMode: RouteMode | undefined): DecodedRouteMode; /** * Decodes a route query as encoded into English by encodeRouteQuery(). */ export declare function decodeRouteQuery(query: string): RouteQuery; /** * Decodes a string from FacilMap.Util.encodeShortLink(). */ export declare function decodeShortLink(encoded: string): DecodedGeoQuery | undefined; export declare const DEFAULT_LANGUAGE = "en"; export declare const defaultI18nGetter: () => i18n; /** * Iterates through the descendant nodes of the given cheerio element, yielding each node when it is opened and when it is * closed. For childless nodes (such as text nodes), an open and close object are emitted right after each other. */ export declare function domTreeIterator(el: Cheerio): Generator<{ type: "open" | "close"; node: Node_2; }, void, void>; export declare function encodeQueryString(obj: Record): string; export declare function encodeRouteMode(decodedMode: DecodedRouteMode): string; export declare function encodeRouteQuery(query: RouteQuery): string; export declare let fetchAdapter: typeof fetch; export declare type FilterFunc = (obj: Marker | Line, type: Type) => boolean; export declare function filterHasError(expr: string): Error | undefined; export declare function find(query: string, options?: FindOptions): Promise>; declare type FindOptions = { lang?: string; }; /** * Converts an object { entry: { subentry: "value" } } into { "entry.subentry": "value" } * @param obj {Object} * @return {Object} */ export declare function flattenObject(obj: Record, _prefix?: string): Record; export declare function formatAscentDescent(ascentDescent: number): string; export declare function formatCheckboxValue(value: string): string; export declare function formatCoordinates(point: Point): string; export declare function formatDistance(distance: number, decimals?: number): string; export declare function formatElevation(elevation: number): string; export declare function formatFieldName(name: string): string; export declare function formatFieldValue(field: Field, value: string | undefined, html: boolean): string; export declare function formatPOIName(name: string): string; export declare function formatRouteMode(encodedMode: RouteMode): string; export declare function formatRouteTime(time: number, encodedMode: RouteMode): string; export declare function formatTime(seconds: number): string; export declare function formatTypeName(name: string): string; export declare function generateRandomPadId(length?: number): string; export declare function getAcceptHotI18n(lang: string, namespace: string): (mod: any) => void; export declare function getAscentDescent(elevations: Array): AscentDescent; export declare function getBrightness(colour: string): number; export declare function getConfig(): Config; export declare function getCurrentLanguage(): string; export declare function getCurrentUnits(): Units; export declare const getElevationForPoint: (args_0: { lat: number; lon: number; }) => Promise; export declare function getFallbackLonLatResult(pointWithZoom: PointWithZoom): SearchResult; export declare function getI18n(): Pick; export declare function getLineTemplate(type: Type): LineTemplate; /** * Returns a map of each existing language key to its language name in the language itself. */ export declare function getLocalizedLanguageList(): Record; export declare function _getMatchesWithBrackets(str: string, regexp: string): string[]; export declare function getObjectDiff(obj1: Record, obj2: Record): Array; export declare function getOrderedTypes(types: Type[] | Record): Type[]; export declare function getOrderedViews(views: View[] | Record): View[]; export declare function getProperty>(obj: T, key: K): V; export declare function getProperty(obj: T, key: K): T[K]; /** * Returns the i18n object returned by the i18nGetter, with any onI18nReady() callbacks applied. * This should not be called by translated components directly. Instead, each package should provide its own wrapper for this function * in a module that loads the necessary i18n resources as a side effect. */ export declare function getRawI18n(): i18n; export declare function getSafeFilename(fname: string): string; export declare function getSelectedOption(field: Field, value: string | undefined, ignoreDefault?: boolean): FieldOption | undefined; /** * Returns the text content of the given cheerio element, making a best attempt to represent line breaks caused by * block elements and paragraphs in the given data. */ export declare function getTextContent(el: Cheerio): string; /** * The config that the backend injects into the EJS template to be read by the frontend. */ export declare interface InjectedConfig { appName: string; openElevationApiUrl: string; openElevationThrottleMs: number; openElevationMaxBatchSize: number; nominatimUrl: string; limaLabsToken?: string; hideCommercialMapLinks?: boolean; supportsRoutes: boolean; supportsAdvancedRoutes: boolean; } /** * Given a list of objects whose order is defined by an index field, returns how the index field of each object needs to be updated * in order to create a new item at the given index (id === undefined) or move an existing item to the new index (id !== undefined). */ export declare function insertIdx(objects: Array<{ id: IDType; idx: number; }>, id: IDType | undefined, insertAtIdx: number): Array<{ id: IDType; oldIdx: number; newIdx: number; }>; export declare function isBright(colour: string): boolean; export declare let isCustomI18nGetter: boolean; export declare let isCustomLanguageDetector: boolean; export declare function isLine(object: Marker | Line): object is Line; export declare function isMarker(object: Marker | Line): object is Marker; export declare function isPromise(object: any): object is Promise; export declare function isSearchId(string: string | undefined): boolean; /** * If true, this route can be handled by OSRM, ORS is not needed. */ export declare function isSimpleRoute(decodedMode: DecodedRouteMode): boolean; export declare function kmToMi(km: number): number; export declare const LANG_COOKIE = "lang"; export declare const LANG_QUERY = "lang"; export declare const LANGUAGES: string[]; export declare function makeTextColour(backgroundColour: string, threshold?: number): string; export declare function makeTypeFilter(previousFilter: string | undefined, typeId: ID, filteredData: boolean | Record>): string; export declare function markdownBlock(string: string, html: boolean): string; export declare function markdownInline(string: string, html: boolean): string; export declare function matchLonLat(query: string): (Point & { zoom?: number; }) | undefined; /** * Performs a 3-way merge. Takes the difference between oldObject and newObject and applies it to targetObject. * @param oldObject {Object} * @param newObject {Object} * @param targetObject {Object} */ export declare function mergeObject>(oldObject: T | undefined, newObject: T, targetObject: T): void; export declare function mToFt(m: number): number; export declare function normalizeFieldValue(field: Field, value: string | undefined, ignoreDefault?: boolean): string; export declare function normalizeLineName(name: string | undefined): string; export declare function normalizeMarkerName(name: string | undefined): string; export declare function normalizePadName(name: string | undefined): string; export declare function normalizePageDescription(padDescription: string | undefined): string; export declare function normalizePageTitle(padName: string | undefined, appName: string): string; export declare function numberKeys(obj: Record): Generator; export declare interface ObjectDiffItem { index: string; before: any; after: any; } /** * Calls the given callback the first time getI18n() is called. If getI18n() has already been called, calls the callback immediately. */ export declare function onI18nReady(callback: (i18n: i18n) => void): void; export declare type Optional = Omit & Partial>; export declare function overwriteObject(from: Record, to: Record): void; export declare function parsePadUrl(url: string, baseUrl: string): { padId: string; hash: string; } | undefined; /** * Attempts to interpret a route query as specified by the user in the current language. */ export declare function parseRouteQuery(query: string): RouteQuery; export declare function parseUrlQuery(query: string): string | undefined; declare interface PointWithZoom extends Point { zoom?: ZoomLevel; } export declare function prepareObject | Line>(obj: T, type: Type): T & { type?: Type["type"]; }; export declare function quote(str: string): string; export declare function quoteHtml(str: string | number): string; export declare function quoteRegExp(str: string): string; export declare const R = 6371; export declare function renderOsmTag(key: string, value: string): string; export declare function resolveCreateLine(line: Line, type: Type): Line; export declare function resolveCreateMarker(marker: Marker, type: Type): Marker; export declare function resolveUpdateLine(line: Line, update: Line, newType: Type): Line; export declare function resolveUpdateMarker(marker: Marker, update: Marker, newType: Type): Marker; export declare class RetryError extends Error { cause: Error; constructor(cause: Error); } export declare function round(number: number, digits: number): number; export declare type RouteQuery = { queries: string[]; mode: string | null; }; export declare function setConfig(newConfig: Config): void; export declare function setCurrentUnitsGetter(getter: typeof currentUnitsGetter): void; export declare function setFetchAdapter(newFetchAdapter: typeof fetchAdapter): void; export declare function setI18nGetter(getter: () => i18n): void; export declare function setLanguageDetector(detector: Module | Newable | undefined, options?: CustomPluginOptions["detection"]): void; export declare function sleep(ms: number): Promise; export declare function throttledBatch(getBatch: (batch: Args[]) => Promise, { delayMs, maxSize, maxRetries, noParallel }: { delayMs: number | (() => number); maxSize: number | (() => number); maxRetries?: number; noParallel?: boolean; }): ((...args: Args) => Promise); export { }