diff --git a/bun.lockb b/bun.lockb index 29b270a..2a4543e 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 4df69ce..3fa12f3 100644 --- a/package.json +++ b/package.json @@ -21,10 +21,8 @@ "test": "vitest run", "test:watch": "vitest", "test:cov": "vitest run --coverage", - "dev": "run-p -rl vite:watch serve:firefox", - "vite:site": "vite", - "vite:watch": "vite build --watch --mode development --minify false", - "build": "tsc && vite build", + "dev": "run-p -rl 'vite build --watch --mode development --minify false' serve:firefox", + "build": "vite build", "serve:firefox": "web-ext run -s dist", "serve:chromium": "web-ext run -t chromium -s dist", "bundle": "web-ext build -s dist -a out --overwrite-dest -n replace_maps.zip", @@ -39,7 +37,6 @@ "prettier": "^3.3.2", "release-it": "^17.4.0", "release-it-changelogen": "^0.1.0", - "typescript": "^5.5.2", "vite": "^5.3.2", "vite-plugin-static-copy": "^1.0.5", "vitest": "^1.6.0", diff --git a/src/bg.html b/src/bg.html index 33b9947..3c545d4 100644 --- a/src/bg.html +++ b/src/bg.html @@ -1,6 +1,6 @@ - - + + diff --git a/src/bg/action.ts b/src/bg/action.js similarity index 84% rename from src/bg/action.ts rename to src/bg/action.js index 15251ce..f8295ef 100644 --- a/src/bg/action.ts +++ b/src/bg/action.js @@ -1,4 +1,4 @@ -import { browserAction, /*webNavigation,*/ type Tabs, tabs } from 'webextension-polyfill' +import { browserAction, /*webNavigation,*/ Tabs, tabs } from 'webextension-polyfill' import { getHostname, invertHostState } from './utils/storage' //import { matcher as mapsUrlMatcher, runtimeMapUrl } from './bg'; @@ -10,9 +10,9 @@ import { getHostname, invertHostState } from './utils/storage' * * Requests all frames from the current tab, filters them for extension Leaflet frames and Maps frames. * Reloads the full tab on extension Leaflet or Maps frame match. - * @param tab Currently active tab + * @param {Tabs.Tab} tab Currently active tab */ -async function actionClick(tab: Tabs.Tab): Promise { +async function actionClick(tab) { if (!tab.url || !tab.id) return let hostname = getHostname(tab.url) diff --git a/src/bg/bg.ts b/src/bg/bg.js similarity index 77% rename from src/bg/bg.ts rename to src/bg/bg.js index 7df1b44..1e14453 100644 --- a/src/bg/bg.ts +++ b/src/bg/bg.js @@ -1,10 +1,10 @@ -import { runtime, tabs, windows, webRequest, type WebRequest } from 'webextension-polyfill' +import { runtime, tabs, windows, webRequest, WebRequest } from 'webextension-polyfill' import { disabledHosts, getHostname } from './utils/storage' import { updateActiveTabIcon } from './utils/actionIcon' import { domainEnds } from './utils/domainEnds' -const gLocales: string = domainEnds.join('|') // TODO: collect more locales -export const matcher: RegExp = new RegExp( +const gLocales = domainEnds.join('|') // TODO: collect more locales +export const matcher = new RegExp( // TODO: fix regex to fit more patterns `^(https?:\/\/)?(maps\.google\.(${gLocales})\/maps.*\?.*output=embed|(www\.)?google\.(${gLocales})\/maps\/embed.*\?)` ) @@ -14,10 +14,10 @@ export const runtimeMapUrl = runtime.getURL('map.html') * Checks if `frames` send a request to Maps. * If they do and the extension isn't disabled for the current site, then the request is redirected to the extension leaflet map with all URL search params. * Else the request is'nt blocked. - * @param req Web Request from frame - * @returns Redirect to extension map or pass through if extension disabled for website + * @param {WebRequest.OnBeforeRequestDetailsType} req Web Request from frame + * @returns {WebRequest.BlockingResponse} Redirect to extension map or pass through if extension disabled for website */ -function redirect(req: WebRequest.OnBeforeRequestDetailsType): WebRequest.BlockingResponse { +function redirect(req) { // TODO: check if originUrl always matches current tab url -> e.g. in frames with subframes if (req.originUrl && req.url.match(matcher)) { if (!disabledHosts.includes(getHostname(req.originUrl))) { diff --git a/src/bg/utils/actionIcon.ts b/src/bg/utils/actionIcon.js similarity index 83% rename from src/bg/utils/actionIcon.ts rename to src/bg/utils/actionIcon.js index 542518e..e400188 100644 --- a/src/bg/utils/actionIcon.ts +++ b/src/bg/utils/actionIcon.js @@ -3,9 +3,9 @@ import { disabledHosts, getHostname } from './storage' /** * Updates the action icon - * @param hostname Hostname + * @param {string} hostname Hostname */ -export function updateIcon(hostname: string): void { +export function updateIcon(hostname) { let disabled = disabledHosts.includes(hostname) browserAction.setIcon({ @@ -24,7 +24,7 @@ export function updateIcon(hostname: string): void { /** * Async function to update the icon of the currently active tab. Uses `updateIcon` internally */ -export async function updateActiveTabIcon(): Promise { +export async function updateActiveTabIcon() { let browserTabs = await tabs.query({ active: true, currentWindow: true }) let tab = browserTabs[0] diff --git a/src/bg/utils/domainEnds.ts b/src/bg/utils/domainEnds.js similarity index 98% rename from src/bg/utils/domainEnds.ts rename to src/bg/utils/domainEnds.js index 6eba323..3903313 100644 --- a/src/bg/utils/domainEnds.ts +++ b/src/bg/utils/domainEnds.js @@ -1,5 +1,5 @@ // Domain ends of google -export const domainEnds: string[] = [ +export const domainEnds = [ 'com', 'ac', 'ad', diff --git a/src/bg/utils/storage.ts b/src/bg/utils/storage.js similarity index 72% rename from src/bg/utils/storage.ts rename to src/bg/utils/storage.js index c9eeaf9..2613880 100644 --- a/src/bg/utils/storage.ts +++ b/src/bg/utils/storage.js @@ -4,7 +4,8 @@ import { updateIcon } from './actionIcon' export const KEY_DISABLED_HOSTS = 'disabled_hosts' // Listens to changes on the storage. Updates disabled hosts list, if stored list changes -export let disabledHosts: string[] = await getDisabledHosts() +/** @type {string[]} */ +export let disabledHosts = await getDisabledHosts() storage.local.onChanged.addListener((changes) => { if (KEY_DISABLED_HOSTS in changes) { disabledHosts = changes[KEY_DISABLED_HOSTS].newValue ?? [] @@ -13,18 +14,18 @@ storage.local.onChanged.addListener((changes) => { /** * Async function to get the list of disabled hostnames - * @returns List of disabled hostnames + * @returns {Promise} List of disabled hostnames */ -async function getDisabledHosts(): Promise { +async function getDisabledHosts() { return (await storage.local.get(KEY_DISABLED_HOSTS))[KEY_DISABLED_HOSTS] ?? [] } /** * Async function to invert the state of a hostname. * Adds new entry if not disabled, removes entry, if already disabled - * @param hostname Hostname to invert the state of + * @param {string} hostname Hostname to invert the state of */ -export async function invertHostState(hostname: string): Promise { +export async function invertHostState(hostname) { if (disabledHosts.includes(hostname)) { disabledHosts.splice(disabledHosts.indexOf(hostname), 1) } else { @@ -40,10 +41,10 @@ export async function invertHostState(hostname: string): Promise { /** * Retrieves the hostname from a URL - * @param url Full URL string - * @returns Hostname string + * @param {string} url Full URL string + * @returns {string} Hostname string */ -export function getHostname(url: string): string { +export function getHostname(url) { url = url.replace(/^\w+:\/\//, '') url = url.split(/[\/#\?]/, 1)[0] return url diff --git a/src/map.html b/src/map.html index 1f49292..7ac0c16 100644 --- a/src/map.html +++ b/src/map.html @@ -12,6 +12,6 @@
- + diff --git a/src/map/map.ts b/src/map/map.js similarity index 80% rename from src/map/map.ts rename to src/map/map.js index 3c9fd81..5c90a8a 100644 --- a/src/map/map.ts +++ b/src/map/map.js @@ -1,18 +1,18 @@ import L from 'leaflet' import 'leaflet-fullscreen' -import { readPB, readQ, type MapData } from './utils/read' -import { type TileType, tileTypes } from './utils/parsePB' +import { readPB, readQ, MapData } from './utils/read' +import { tileTypes } from './utils/parsePB' -type Tiles = { - [K in TileType]: { - layer: string - attr: string - } -} +/** + * @typedef {object} Tile + * @property {string} layer + * @property {string} attr + */ // https://leaflet-extras.github.io/leaflet-providers/preview/ -const tileProviders: Tiles = { +/** @type {{TileTypes: Tile}} */ +const tileProviders = { roadmap: { layer: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', // OpenStreetMap.Mapnik attr: '© OpenStreetMap', @@ -24,12 +24,13 @@ const tileProviders: Tiles = { }, // TODO: add street layer etc to satellite } -const gPos: string = 'pb' -const gQuery: string = 'q' -const gZoom: string = 'z' -const params: URLSearchParams = new URLSearchParams(document.location.search) +const gPos = 'pb' +const gQuery = 'q' +const gZoom = 'z' +const params = new URLSearchParams(document.location.search) -let mapData: MapData = {} +/** @type {MapData} */ +const mapData = {} if (params.has(gPos)) { mapData = await readPB(params.get(gPos) as string) @@ -45,7 +46,8 @@ if (params.has(gZoom)) { mapData.zoom = parseInt(params.get(gZoom) as string) } -const map: L.Map = L.map('map', { +/** @type {L.Map} */ +const map = L.map('map', { fullscreenControl: true, scrollWheelZoom: true, // TODO: on pc allow ctrl + scroll zoom: mapData.zoom ?? 17, diff --git a/src/map/utils/parseDMS.js b/src/map/utils/parseDMS.js new file mode 100644 index 0000000..080f658 --- /dev/null +++ b/src/map/utils/parseDMS.js @@ -0,0 +1,27 @@ +/** + * Converts DMS coordinates to Lat and Lon + * @param {string} input String containing DMS coordinates + * @returns {[number, number]} Array containing Latitude and Longitude + */ +export function parseDMS(input) { + /** @type {string[]} */ + const parts = input.split(/[^\d\w\.]+/) + const lat = convertDMSToDD(parts.slice(0, 4)) + const lon = convertDMSToDD(parts.slice(4)) + + return [lat, lon] +} +/** + * Converts DMS part to Lat/Lon + * @param {string[]} dms Array of four strings representing: Degree Minutes Seconds Direction + * @returns {number} DMS part converted to Latitude / Longitude + */ +function convertDMSToDD(dms) { + const [degrees, minutes, seconds, direction] = dms + let dd = Number(degrees) + Number(minutes) / 60 + Number(seconds) / (60 * 60) + + if (direction === 'S' || direction === 'W') { + dd = dd * -1 + } // Don't do anything for N or E + return dd +} diff --git a/src/map/utils/parseDMS.ts b/src/map/utils/parseDMS.ts deleted file mode 100644 index 8f75b43..0000000 --- a/src/map/utils/parseDMS.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Converts DMS coordinates to Lat and Lon - * @param input String containing DMS coordinates - * @returns Array containing Latitude and Longitude - */ -export function parseDMS(input: string): [number, number] { - let parts: string[] = input.split(/[^\d\w\.]+/) - let lat = convertDMSToDD(parts.slice(0, 4)) - let lon = convertDMSToDD(parts.slice(4)) - - return [lat, lon] -} -/** - * Converts DMS part to Lat/Lon - * @param dms Array of four strings representing: Degree Minutes Seconds Direction - * @returns DMS part converted to Latitude / Longitude - */ -function convertDMSToDD(dms: string[]): number { - const [degrees, minutes, seconds, direction] = dms - let dd = Number(degrees) + Number(minutes) / 60 + Number(seconds) / (60 * 60) - - if (direction === 'S' || direction === 'W') { - dd = dd * -1 - } // Don't do anything for N or E - return dd -} diff --git a/src/map/utils/parsePB.ts b/src/map/utils/parsePB.js similarity index 65% rename from src/map/utils/parsePB.ts rename to src/map/utils/parsePB.js index 9ea13f6..89d6b49 100644 --- a/src/map/utils/parsePB.ts +++ b/src/map/utils/parsePB.js @@ -1,5 +1,9 @@ -export type TileType = 'roadmap' | 'satellite' -export const tileTypes: TileType[] = ['roadmap', 'satellite'] + +/** + * @typedef {'roadmap' | 'satellite'} TileType + * @type {TileType[]} + */ +export const tileTypes = ['roadmap', 'satellite'] /** * Takes one bang operator and decodes it. @@ -17,16 +21,18 @@ export const tileTypes: TileType[] = ['roadmap', 'satellite'] * * Unknown types are kept as string. * - * @param item One bang operator with the structure: position, one character (data type), encoded data - * @returns Array of two items. First is the decoded result. Second describes if the result is a new matrix. + * @param {string} item One bang operator with the structure: position, one character (data type), encoded data + * @returns {[string | TileType | number, boolean]} Array of two items. First is the decoded result. Second describes if the result is a new matrix. */ -function convertType(item: string): [string | TileType | number, boolean] { +function convertType(item) { item = item.replace(/^\d+/, '') - const type: string = item.charAt(0) + /** @type {string} */ + const type = item.charAt(0) item = item.substring(1) // s: string || v: timestamp || b: boolean?/byte? - let val: string | TileType | number = item + /** @type {string | TileType | number} */ + let val = item switch (type) { case 'f': @@ -66,11 +72,11 @@ function convertType(item: string): [string | TileType | number, boolean] { * - https://andrewwhitby.com/2014/09/09/google-maps-new-embed-format/ * - https://blog.themillhousegroup.com/2016/08/deep-diving-into-google-pb-embedded-map.html * - https://stackoverflow.com/a/47042514 - * @param items Bang operators (e.g. `!1m13`) split into pieces at `!` - * @param out Array for top and recursion levels to save results and return - * @returns Filled `out` array with bang operators converted into readable format + * @param {string[]} items Bang operators (e.g. `!1m13`) split into pieces at `!` + * @param {any[]} out Array for top and recursion levels to save results and return + * @returns {any[]} Filled `out` array with bang operators converted into readable format */ -export function parsePB(items: string[], out: any[] = []): any[] { +export function parsePB(items, out = []) { let i = 0 while (i < items.length) { let [val, isNew] = convertType(items[i]) @@ -78,9 +84,9 @@ export function parsePB(items: string[], out: any[] = []): any[] { if (!isNew) { out.push(val) } else { - let itemsPart = items.slice(i + 1, i + (val as number) + 1) + let itemsPart = items.slice(i + 1, i + val + 1) out.push(parsePB(itemsPart)) - i += val as number + i += val } i++ } diff --git a/src/map/utils/read.js b/src/map/utils/read.js new file mode 100644 index 0000000..8ad6d18 --- /dev/null +++ b/src/map/utils/read.js @@ -0,0 +1,112 @@ +import { TileType, parsePB, tileTypes } from './parsePB' +import { parseDMS } from './parseDMS' +import { getMapZoom } from './zoom' + +export const nominatimQ = 'https://nominatim.openstreetmap.org/search?limit=1&format=json&q=' +const cidMatch = /^0x[\da-f]+:0x[\da-f]+$/i +const dmsMatch = /^\d{1,2}°\d{1,2}'\d{1,2}\.\d"(N|S) \d{1,2}°\d{1,2}'\d{1,2}\.\d"(E|W)$/i + +/** + * @typedef {object} LatLon + * @property {number} lat + * @property {number} lon + */ + +/** + * @typedef {object} Marker + * @property {number} lat + * @property {number} lon + * @property {string} label + */ + +/** + * @typedef {object} MapData + * @property {LatLon?} area + * @property {number?} zoom + * @property {TileType?} tile + * @property {Marker[]?} markers + */ + +/** + * Decodes the `pb` parameter with the help of `parsePB` and `readQ` + * @param {string} param Content of the `pb` parameter as a string + * @returns {Promise} MapData with area, zoom, tile type and markers + */ +export async function readPB(param) { + /** @type {MapData} */ + const mapData = { + markers: [], + } + + let data = parsePB(param.split('!').slice(1))[0] + + /** @type {number[]} */ + let mapArea = data[0][0] + mapData.area = { + lat: mapArea[2], + lon: mapArea[1], + } + + mapData.zoom = getMapZoom(mapArea[0]) + + /** @type {any[] | string} */ + let currMarkers = data[1] + if (typeof currMarkers !== 'string') { + for (let markers of currMarkers[0]) { + if (markers.match(cidMatch)) { + // TODO: understand CID + console.log(markers) + } else if (markers.match(dmsMatch)) { + let [lat, lon] = parseDMS(markers) + if (lat && lon) { + mapData.markers?.push({ + lat: lat, + lon: lon, + label: `${lat} ${lon}`, + }) + } + } else { + let marker = await readQ(markers) + if (marker) { + mapData.markers?.push(marker) + } + } + } + } + + if (tileTypes.includes(data[data.length - 1])) { + mapData.tile = data[data.length - 1] + } + + return mapData +} + +/** + * Makes a request to the Nominatim API to get the coordinates of an address + * + * Reference: https://medium.com/@sowmyaaji/how-to-build-a-backend-with-jquery-and-add-a-leaflet-js-frontend-e77f2079c852 + * @param {string} addr An address or place + * @returns {Promise} The Latitude and Logitude of the address or place + */ +export async function readQ(addr) { + const uri = encodeURI(nominatimQ + addr) + const res = await fetch(uri) + + if (!res.ok) { + return null + } + + /** @type {LatLon[]} */ + const json = await res.json() + /** @type {LatLon} */ + const body = json[0] + + /** @type {Marker} */ + const marker = { + lat: parseFloat(body.lat), + lon: parseFloat(body.lon), + label: addr, + } + + return marker +} diff --git a/src/map/utils/read.ts b/src/map/utils/read.ts deleted file mode 100644 index 1b38f3a..0000000 --- a/src/map/utils/read.ts +++ /dev/null @@ -1,104 +0,0 @@ -import { parsePB, tileTypes, type TileType } from './parsePB' -import { parseDMS } from './parseDMS' -import { getMapZoom } from './zoom' - -export const nominatimQ: string = - 'https://nominatim.openstreetmap.org/search?limit=1&format=json&q=' -const cidMatch: RegExp = /^0x[\da-f]+:0x[\da-f]+$/i -const dmsMatch: RegExp = /^\d{1,2}°\d{1,2}'\d{1,2}\.\d"(N|S) \d{1,2}°\d{1,2}'\d{1,2}\.\d"(E|W)$/i - -export type Marker = { - lat: number - lon: number - label: string -} - -export type MapData = { - area?: { - lat: number - lon: number - } - zoom?: number - tile?: TileType - - markers?: Marker[] -} - -/** - * Decodes the `pb` parameter with the help of `parsePB` and `readQ` - * @param param Content of the `pb` parameter as a string - * @returns MapData with area, zoom, tile type and markers - */ -export async function readPB(param: string): Promise { - let mapData: MapData = { - markers: [], - } - - let data = parsePB(param.split('!').slice(1))[0] - - let mapArea: number[] = data[0][0] - mapData.area = { - lat: mapArea[2], - lon: mapArea[1], - } - - mapData.zoom = getMapZoom(mapArea[0]) - - let currMarkers: any[] | string = data[1] - if (typeof currMarkers !== 'string') { - for (let markers of currMarkers[0] as string[]) { - if (markers.match(cidMatch)) { - // TODO: understand CID - console.log(markers) - } else if (markers.match(dmsMatch)) { - let [lat, lon] = parseDMS(markers) - if (lat && lon) { - mapData.markers?.push({ - lat: lat, - lon: lon, - label: `${lat} ${lon}`, - }) - } - } else { - let marker = await readQ(markers) - if (marker) { - mapData.markers?.push(marker) - } - } - } - } - - if (tileTypes.includes(data[data.length - 1])) { - mapData.tile = data[data.length - 1] - } - - return mapData -} - -/** - * Makes a request to the Nominatim API to get the coordinates of an address - * - * Reference: https://medium.com/@sowmyaaji/how-to-build-a-backend-with-jquery-and-add-a-leaflet-js-frontend-e77f2079c852 - * @param addr An address or place - * @returns The Latitude and Logitude of the address or place - */ -export async function readQ(addr: string): Promise { - let uri = encodeURI(nominatimQ + addr) - let res = await fetch(uri) - - if (!res.ok) { - return null - } - - let json: { lat: string; lon: string }[] = await res.json() - - let body: { lat: string; lon: string } = json[0] - - let marker: Marker = { - lat: parseFloat(body.lat), - lon: parseFloat(body.lon), - label: addr, - } - - return marker -} diff --git a/src/map/utils/zoom.ts b/src/map/utils/zoom.js similarity index 69% rename from src/map/utils/zoom.ts rename to src/map/utils/zoom.js index c226e3b..045bd3f 100644 --- a/src/map/utils/zoom.ts +++ b/src/map/utils/zoom.js @@ -1,15 +1,15 @@ -const factor: number = 35200000 -const precision: number = 10 +const factor = 35200000 +const precision = 10 /** * Converts *altitude over the map* to *zoom level of the map* * TODO: Should be rewritten!!! * * Reference: https://groups.google.com/g/google-earth-browser-plugin/c/eSL9GlAkWBk/m/T4mdToJz_FgJ - * @param alt Altitude as number - * @returns Zoom level between 0 and 19 + * @param {number} alt Altitude as number + * @returns {number} Zoom level between 0 and 19 */ -export function getMapZoom(alt: number): number { +export function getMapZoom(alt) { let zoom = Math.log2(factor / alt) * 1.225 zoom = Math.round((zoom + Number.EPSILON) * precision) / precision diff --git a/src/options.html b/src/options.html index cf89db0..e7ceb59 100644 --- a/src/options.html +++ b/src/options.html @@ -6,7 +6,7 @@ - + Replace Maps Options diff --git a/src/options/options.ts b/src/options/options.js similarity index 73% rename from src/options/options.ts rename to src/options/options.js index 5840048..77da5ab 100644 --- a/src/options/options.ts +++ b/src/options/options.js @@ -6,12 +6,12 @@ import { invertHostState, } from '../bg/utils/storage' -const table = document.querySelector('.table')! +const table = document.querySelector('.table') /** * (Re)Builds the list of diasabled hostnames */ -function buildEntries(): void { +function buildEntries() { table.innerHTML = '' disabledHosts.forEach(createEntry) } @@ -20,7 +20,7 @@ function buildEntries(): void { * Async function to add a hostname (from the form / URL Search Params) to the displayed list and the storage list of disabled hosts * If the entry is already present in the stored hosts, no entry is added to the display list */ -async function addEntry(): Promise { +async function addEntry() { const search = new URLSearchParams(document.location.search) let hostname = search.get('hostname') if (hostname === null) return @@ -34,9 +34,9 @@ async function addEntry(): Promise { /** * Creates a new entry for the displayed list of disabled hostnames and appends it to the view - * @param hostname Hostname to add to the list + * @param {string} hostname Hostname to add to the list */ -function createEntry(hostname: string): void { +function createEntry(hostname) { const div = document.createElement('div') let span = document.createElement('span') @@ -52,13 +52,13 @@ function createEntry(hostname: string): void { /** * Async funtion to remove an entry at click of its button. * Takes the index in the table to remove it from the list of stored hostnames - * @param click Button click + * @param {MouseEvent} click Button click */ -async function removeEntry(click: MouseEvent): Promise { - let target: EventTarget | null = click.target +async function removeEntry(click) { + const target = click.target if (target === null) return - let index = getIndex(target as HTMLButtonElement) + let index = getIndex(target) if (index === -1) return await invertHostState(disabledHosts[index]) @@ -66,11 +66,11 @@ async function removeEntry(click: MouseEvent): Promise { /** * Gets the index of a list entry using its clicked button - * @param button Button that was clicked to remove an entry - * @returns Index of the list entry + * @param {HTMLButtonElement} button Button that was clicked to remove an entry + * @returns {number} Index of the list entry */ -function getIndex(button: HTMLButtonElement): number { - let div: HTMLDivElement = button.parentElement as HTMLDivElement +function getIndex(button) { + let div = button.parentElement if (div === null) return -1 let index = Array.from(table.children).indexOf(div) diff --git a/test/map/utils/parseDMS.test.ts b/test/map/utils/parseDMS.test.js similarity index 100% rename from test/map/utils/parseDMS.test.ts rename to test/map/utils/parseDMS.test.js diff --git a/test/map/utils/parsePB.test.ts b/test/map/utils/parsePB.test.js similarity index 100% rename from test/map/utils/parsePB.test.ts rename to test/map/utils/parsePB.test.js diff --git a/test/map/utils/read.test.ts b/test/map/utils/read.test.js similarity index 94% rename from test/map/utils/read.test.ts rename to test/map/utils/read.test.js index 4470915..c549fc3 100644 --- a/test/map/utils/read.test.ts +++ b/test/map/utils/read.test.js @@ -6,7 +6,13 @@ globalThis.fetch = vitest.fn() const input = 'test position' const result = [{ lat: '1.1', lon: '1.1' }] -function mockNominatimResponse(data: { lat: string; lon: string }[], status: boolean) { +/** + * + * @param {{lat: string; lon: string}} data + * @param {boolean} status + * @returns {Response} + */ +function mockNominatimResponse(data, status) { return { ok: status, json: () => new Promise((resolve) => resolve(data)) } } diff --git a/test/map/utils/zoom.test.ts b/test/map/utils/zoom.test.js similarity index 100% rename from test/map/utils/zoom.test.ts rename to test/map/utils/zoom.test.js diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index 74b53de..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "baseUrl": ".", - "paths": { - "~/*": ["src/*"] - }, - "target": "ESNext", - "useDefineForClassFields": true, - "module": "ESNext", - "lib": ["ESNext", "DOM"], - "moduleResolution": "Node", - "strict": true, - "sourceMap": true, - "resolveJsonModule": true, - "esModuleInterop": true, - "noEmit": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noImplicitReturns": true, - "declaration": false - }, - "include": ["src"], - "exclude": ["node_modules"] -} diff --git a/vite.config.ts b/vite.config.js similarity index 100% rename from vite.config.ts rename to vite.config.js