From 1b64eeb6b1021be9e2fb5bb15b39f5bc9ee42823 Mon Sep 17 00:00:00 2001 From: 098714 Date: Mon, 12 Jun 2023 13:23:10 +0200 Subject: [PATCH 1/7] togeojson 5.6.0 -> 5.6.2 to fix black hotline bug --- package.json | 2 +- src/control.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bfa491b..5e7ab85 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "uvu": "^0.5.6" }, "peerDependencies": { - "@tmcw/togeojson": "5.6.0", + "@tmcw/togeojson": "5.6.2", "d3": "7.8.4", "leaflet": "^1.7.0", "leaflet-i18n": "^0.3.1" diff --git a/src/control.js b/src/control.js index 636c809..6388aaf 100644 --- a/src/control.js +++ b/src/control.js @@ -14,7 +14,7 @@ export const Elevation = L.Control.Elevation = L.Control.extend({ __mileFactor: 0.621371, // 1 km = (0.621371 mi) __footFactor: 3.28084, // 1 m = (3.28084 ft) __D3: 'https://unpkg.com/d3@7.8.4/dist/d3.min.js', - __TOGEOJSON: 'https://unpkg.com/@tmcw/togeojson@5.6.0/dist/togeojson.umd.js', + __TOGEOJSON: 'https://unpkg.com/@tmcw/togeojson@5.6.2/dist/togeojson.umd.js', __LGEOMUTIL: 'https://unpkg.com/leaflet-geometryutil@0.10.1/src/leaflet.geometryutil.js', __LALMOSTOVER: 'https://unpkg.com/leaflet-almostover@1.0.1/src/leaflet.almostover.js', __LHOTLINE: '../libs/leaflet-hotline.min.js', From aff372e9356b50c0cfa7cba65de0e898917c6ff0 Mon Sep 17 00:00:00 2001 From: Raruto Date: Tue, 13 Jun 2023 19:35:48 +0200 Subject: [PATCH 2/7] Update http_server.js --- test/setup/http_server.js | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/test/setup/http_server.js b/test/setup/http_server.js index 92a0f1d..f0d6aa9 100644 --- a/test/setup/http_server.js +++ b/test/setup/http_server.js @@ -2,16 +2,31 @@ import { suite as uvu_suite } from 'uvu'; import { exec } from 'child_process'; import { chromium } from 'playwright'; +process.on('exit', async () => { + await globalThis.server.kill('SIGTERM'); +}) + /** * Start HTTP server */ export async function setup(ctx) { - ctx.server = new AbortController(); - exec('http-server', { signal: ctx.server.signal }); + if (!globalThis.server) { + await new Promise((resolve) => { + globalThis.server = exec('http-server'); + globalThis.server.stdout.on('data', (msg) => { + // console.log(msg); + // if (msg.toString().match(/Starting up/)) { + if (msg.toString().indexOf('Hit CTRL-C to stop the server')) { + resolve(); + // setTimeout(resolve, 1500); + } + }); + }); + } ctx.localhost = 'http://localhost:8080'; ctx.browser = await chromium.launch(); ctx.context = await ctx.browser.newContext(); - ctx.context.route(/.html$/, mock_cdn_urls); + ctx.context.route(/.html$/, await mock_cdn_urls); ctx.page = await ctx.context.newPage(); } @@ -21,7 +36,6 @@ export async function setup(ctx) { export async function reset(ctx) { await ctx.context.close(); await ctx.browser.close(); - try { ctx.server.abort(); } catch(e) { } } /** @@ -47,8 +61,10 @@ export function suite() { test.before(setup); test.after(reset); test.before.each(async ({ localhost, page }) => { - page.on('console', msg => console.log(msg.text())) + page.on('requestfailed', request => { console.log(request.failure().errorText, request.url()); }); + page.on('pageerror', exception => { console.log(exception); }); await page.goto((new URL(arguments[0], localhost)).toString()); + await page.waitForLoadState('domcontentloaded'); }); // augment uvu `test` function with a third parameter `timeout` return new Proxy(test, { @@ -63,13 +79,13 @@ export function suite() { * * @see https://github.com/lukeed/uvu/issues/33#issuecomment-879870292 */ -function timeout(handler, ms=10000) { +function timeout(handler, ms = 10000) { return (ctx) => { - let timer - return Promise.race([ - handler(ctx), - new Promise((_, reject) => { timer = setTimeout(() => reject(new Error('[TIMEOUT] Maximum execution time exceeded: ' + ms + 'ms')), ms) }) - ]).finally(() => { clearTimeout(timer) }) + let timer + return Promise.race([ + handler(ctx), + new Promise((_, reject) => { timer = setTimeout(() => reject(new Error('[TIMEOUT] Maximum execution time exceeded: ' + ms + 'ms')), ms) }) + ]).finally(() => { clearTimeout(timer) }) } } From aa65ddfe5623cea42e559cf411d153a4b1218531 Mon Sep 17 00:00:00 2001 From: Raruto Date: Tue, 13 Jun 2023 20:48:25 +0200 Subject: [PATCH 3/7] Update http_server.js --- test/setup/http_server.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/setup/http_server.js b/test/setup/http_server.js index f0d6aa9..1b04d63 100644 --- a/test/setup/http_server.js +++ b/test/setup/http_server.js @@ -61,6 +61,7 @@ export function suite() { test.before(setup); test.after(reset); test.before.each(async ({ localhost, page }) => { + page.on('console', msg => console.log(msg.text())); page.on('requestfailed', request => { console.log(request.failure().errorText, request.url()); }); page.on('pageerror', exception => { console.log(exception); }); await page.goto((new URL(arguments[0], localhost)).toString()); From 8daf696c015a62553a95189aa4fc30ed82863db6 Mon Sep 17 00:00:00 2001 From: Raruto Date: Tue, 13 Jun 2023 20:56:45 +0200 Subject: [PATCH 4/7] update examples --- README.md | 4 ++-- examples/leaflet-elevation_hoverable-tracks.html | 4 ++-- examples/leaflet-elevation_toggable-charts.html | 4 ++-- examples/leaflet-elevation_upload-gpx.html | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4504f2a..80a63d3 100644 --- a/README.md +++ b/README.md @@ -311,8 +311,8 @@ All notable changes to this project are documented in the [releases](https://git **Compatibile with:** [![Leaflet 1.x compatible!](https://img.shields.io/badge/Leaflet-1.7.0-1EB300.svg?style=flat)](http://leafletjs.com/reference.html) -[![d3.js v6 compatibile!](https://img.shields.io/badge/d3.js-6.5-1EB300.svg?style=flat)](https://www.npmjs.com/package/d3) -[![@tmcw/togeojson v4.6.0 compatibile!](https://img.shields.io/badge/@tmcw/togeojson-4.6-1EB300.svg?style=flat)](https://www.npmjs.com/package/@tmcw/togeojson) +[![d3.js v7 compatibile!](https://img.shields.io/badge/d3.js-7.8-1EB300.svg?style=flat)](https://www.npmjs.com/package/d3) +[![@tmcw/togeojson v5 compatibile!](https://img.shields.io/badge/@tmcw/togeojson-5.6-1EB300.svg?style=flat)](https://www.npmjs.com/package/@tmcw/togeojson) --- diff --git a/examples/leaflet-elevation_hoverable-tracks.html b/examples/leaflet-elevation_hoverable-tracks.html index d7685b5..01a6261 100644 --- a/examples/leaflet-elevation_hoverable-tracks.html +++ b/examples/leaflet-elevation_hoverable-tracks.html @@ -53,8 +53,8 @@ searchControl: false, loadingControl: false, plugins: [ - "d3@6.5.0/dist/d3.min.js", - "@tmcw/togeojson@4.5.0/dist/togeojson.umd.js", + "d3@7.8.4/dist/d3.min.js", + "@tmcw/togeojson@5.6.2/dist/togeojson.umd.js", "leaflet-geometryutil@0.9.3/src/leaflet.geometryutil.js", "leaflet-almostover@1.0.1/src/leaflet.almostover.js", "@raruto/leaflet-elevation@2.4.0/libs/leaflet-distance-marker.css", diff --git a/examples/leaflet-elevation_toggable-charts.html b/examples/leaflet-elevation_toggable-charts.html index 177bda3..d191f1d 100644 --- a/examples/leaflet-elevation_toggable-charts.html +++ b/examples/leaflet-elevation_toggable-charts.html @@ -38,8 +38,8 @@ searchControl: false, loadingControl: false, plugins: [ - "d3@6.5.0/dist/d3.min.js", - "@tmcw/togeojson@4.5.0/dist/togeojson.umd.js", + "d3@7.8.4/dist/d3.min.js", + "@tmcw/togeojson@5.6.2/dist/togeojson.umd.js", "leaflet-geometryutil@0.9.3/src/leaflet.geometryutil.js", "leaflet-almostover@1.0.1/src/leaflet.almostover.js", "@raruto/leaflet-elevation@2.4.0/libs/leaflet-distance-marker.css", diff --git a/examples/leaflet-elevation_upload-gpx.html b/examples/leaflet-elevation_upload-gpx.html index e0e7305..a3cf1be 100644 --- a/examples/leaflet-elevation_upload-gpx.html +++ b/examples/leaflet-elevation_upload-gpx.html @@ -21,7 +21,7 @@ - +