"http-proxy": "^1.18.1",
"mocha": "^10.0",
"puppeteer": "^19.0",
- "rollup": "^2.3.4",
+ "rollup": "^3.3.0",
"rollup-plugin-css-only": "^4.3.0",
"rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-svelte": "^7.0.0",
"leaflet": "1.9.2",
"leaflet-minimap": "^3.6.1",
"timeago.js": "^4.0.2"
- }
+ },
+ "type": "module"
}
import resolve from '@rollup/plugin-node-resolve';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
+import { spawn } from 'child_process';
import css from 'rollup-plugin-css-only';
import { readFileSync, writeFileSync } from 'fs';
-import { spawn } from 'child_process';
const production = !process.env.ROLLUP_WATCH;
-module.exports.formatOSMType = formatOSMType;
-module.exports.osmLink = osmLink;
-module.exports.formatLabel = formatLabel;
-module.exports.wikipediaLink = wikipediaLink;
-module.exports.coverageType = coverageType;
-module.exports.isAdminBoundary = isAdminBoundary;
-module.exports.formatAddressRank = formatAddressRank;
-module.exports.formatPlaceType = formatPlaceType;
-module.exports.formatAdminLevel = formatAdminLevel;
-module.exports.formatDistance = formatDistance;
-module.exports.formatKeywordToken = formatKeywordToken;
-module.exports.zoomLevels = zoomLevels;
-
-const escapeHtml = require('escape-html');
-
-function formatOSMType(sType, bExcludeExternal) {
+import escapeHtml from 'escape-html';
+
+export function formatOSMType(sType, bExcludeExternal) {
if (sType === 'N') return 'node';
if (sType === 'W') return 'way';
if (sType === 'R') return 'relation';
return '';
}
-function osmLink(aPlace) {
+export function osmLink(aPlace) {
if (!aPlace.osm_type) return '';
var sOSMType = formatOSMType(aPlace.osm_type, false);
if (!sOSMType) return '';
return '<a href="https://www.openstreetmap.org/' + sOSMType + '/' + aPlace.osm_id + '">' + sOSMType + ' ' + aPlace.osm_id + '</a>';
}
-function formatLabel(aPlace) {
+export function formatLabel(aPlace) {
if (aPlace.label) return aPlace.label;
function capitalize(s) {
}
/* en:London_Borough_of_Redbridge => https://en.wikipedia.org/wiki/London_Borough_of_Redbridge */
-function wikipediaLink(aPlace) {
+export function wikipediaLink(aPlace) {
if (!aPlace.calculated_wikipedia) return '';
var parts = aPlace.calculated_wikipedia.split(':', 2);
return '<a href="https://' + sLanguage + '.wikipedia.org/wiki/' + sArticle + '" target="_blank">' + sTitle + '</a>';
}
-function coverageType(aPlace) {
+export function coverageType(aPlace) {
return (aPlace.isarea ? 'Polygon' : 'Point');
}
-function isAdminBoundary(aPlace) {
+export function isAdminBoundary(aPlace) {
return aPlace.category === 'boundary' && aPlace.type === 'administrative';
}
-function formatAddressRank(iRank) {
+export function formatAddressRank(iRank) {
if (iRank < 4) return 'other';
if (iRank < 6) return 'country';
if (iRank < 8) return 'region';
return 'other';
}
-function formatPlaceType(aPlace) {
+export function formatPlaceType(aPlace) {
var sOut = aPlace.class + ':' + aPlace.type;
if (aPlace.type && aPlace.type === 'administrative' && aPlace.place_type) {
sOut = sOut + ' (' + aPlace.place_type + ')';
}
// Any over 15 are invalid data in OSM anyway
-function formatAdminLevel(iLevel) {
+export function formatAdminLevel(iLevel) {
return (iLevel && iLevel < 15 ? iLevel : '');
}
-function formatDistance(fDistance, bInMeters) {
+export function formatDistance(fDistance, bInMeters) {
if (bInMeters) {
if (fDistance < 1) return '0';
var sFormatted = (fDistance >= 1000)
}
// mark partial tokens (those starting with a space) with a star for readability
-function formatKeywordToken(sToken) {
+export function formatKeywordToken(sToken) {
return (sToken[0] === ' ' ? '*' : '') + escapeHtml(sToken);
}
-function zoomLevels() {
+export function zoomLevels() {
const aZoomLevels = [
/* 0 */ 'Continent / Sea',
/* 1 */ '',
-const static_server = require('static-server');
-const http = require('http');
-const httpProxy = require('http-proxy');
-const puppeteer = require('puppeteer');
-const fse = require('fs-extra');
+import static_server from 'static-server';
+import http from 'node:http';
+import httpProxy from 'http-proxy';
+import puppeteer from 'puppeteer';
+import fse from 'fs-extra';
const testing_port = 9999; // this is the port all tests expect nominatim-ui to listen to
// Methods to run at the start and end of the mocha testsuite run
// https://mochajs.org/#global-setup-fixtures
-exports.mochaGlobalSetup = async function () {
+export async function mochaGlobalSetup() {
const workdir = 'dist_for_testing';
// 1. Prepare build directory
'--user-agent=Nominatim UI test suite Mozilla/5.0 Gecko/20100101 HeadlessChrome/90.0'
]
});
-};
+}
-exports.mochaGlobalTeardown = async function () {
+export async function mochaGlobalTeardown() {
global.browser.close();
await this.static_http_server.stop();
this.proxy_server.close(() => console.log('proxy server stopped'));
}
-};
+}
-const assert = require('assert');
+import assert from 'assert';
describe('About Page', function () {
let page;
-const assert = require('assert');
+import assert from 'assert';
describe('Nominatim API errors', function () {
let page;
-const assert = require('assert');
+import assert from 'assert';
describe('Browser behaviour', function () {
-const assert = require('assert');
+import assert from 'assert';
describe('Reverse Only', function () {
let page;
-const assert = require('assert');
+import assert from 'assert';
const reverse_only = !!process.env.REVERSE_ONLY;
-const assert = require('assert');
+import assert from 'assert';
describe('Reverse Page', function () {
let page;
-const assert = require('assert');
+import assert from 'assert';
describe('Search Page', function () {
let page;
-const assert = require('assert');
+import assert from 'assert';
describe('Status Page', function () {
let page;
-const assert = require('assert');
-const helpers = require('../../src/lib/helpers');
+import assert from 'assert';
+import { formatLabel, wikipediaLink } from '../../src/lib/helpers.js';
describe('Helpers', function () {
it('.formatLabel', function () {
// not enough data
- assert.equal(helpers.formatLabel({}), '');
+ assert.equal(formatLabel({}), '');
// if label set, that becomes the label
- assert.equal(helpers.formatLabel({ label: 'A Label' }), 'A Label');
+ assert.equal(formatLabel({ label: 'A Label' }), 'A Label');
// type, but nicely formatted
- assert.equal(helpers.formatLabel({ category: 'highway', type: 'bus_stop' }), 'Bus stop');
+ assert.equal(formatLabel({ category: 'highway', type: 'bus_stop' }), 'Bus stop');
// type=yes, so we use the category
- assert.equal(helpers.formatLabel({ category: 'building', type: 'yes' }), 'Building');
+ assert.equal(formatLabel({ category: 'building', type: 'yes' }), 'Building');
});
it('.wikipediaLink', function () {
assert.equal(
- helpers.wikipediaLink({}),
+ wikipediaLink({}),
''
);
assert.equal(
- helpers.wikipediaLink({ calculated_wikipedia: 'de:Brandenburg Gate' }),
+ wikipediaLink({ calculated_wikipedia: 'de:Brandenburg Gate' }),
'<a href="https://de.wikipedia.org/wiki/Brandenburg Gate" target="_blank">de:Brandenburg Gate</a>'
);
// title includes HTML
assert.equal(
- helpers.wikipediaLink({ calculated_wikipedia: 'en:Slug & Lattuce' }),
+ wikipediaLink({ calculated_wikipedia: 'en:Slug & Lattuce' }),
'<a href="https://en.wikipedia.org/wiki/Slug & Lattuce" target="_blank">en:Slug & Lattuce</a>'
);
});
dependencies:
estree-walker "^0.6.1"
-rollup@^2.3.4:
- version "2.79.1"
- resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.79.1.tgz#bedee8faef7c9f93a2647ac0108748f497f081c7"
- integrity sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==
+rollup@^3.3.0:
+ version "3.3.0"
+ resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.3.0.tgz#ae8dc84808a9c75d775d8b2ed8db1adada31a581"
+ integrity sha512-wqOV/vUJCYEbWsXvwCkgGWvgaEnsbn4jxBQWKpN816CqsmCimDmCNJI83c6if7QVD4v/zlyRzxN7U2yDT5rfoA==
optionalDependencies:
fsevents "~2.3.2"