@signalk/charts-plugin 3.7.0 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierignore +1 -0
- package/CHANGELOG.md +109 -0
- package/README.md +72 -0
- package/docs/screenshots/1_overview.png +0 -0
- package/docs/screenshots/2_region.png +0 -0
- package/docs/screenshots/3_jobs.png +0 -0
- package/package.json +13 -8
- package/plugin/cacheLayout.d.ts +72 -0
- package/plugin/cacheLayout.d.ts.map +1 -0
- package/plugin/cacheLayout.js +243 -0
- package/plugin/cacheLayout.js.map +1 -0
- package/plugin/chartDownloader.d.ts +122 -29
- package/plugin/chartDownloader.d.ts.map +1 -1
- package/plugin/chartDownloader.js +488 -313
- package/plugin/chartDownloader.js.map +1 -1
- package/plugin/chartDownloaderMBTilesHelpers.d.ts +10 -0
- package/plugin/chartDownloaderMBTilesHelpers.d.ts.map +1 -0
- package/plugin/chartDownloaderMBTilesHelpers.js +235 -0
- package/plugin/chartDownloaderMBTilesHelpers.js.map +1 -0
- package/plugin/chartDownloaderTileHelpers.d.ts +30 -0
- package/plugin/chartDownloaderTileHelpers.d.ts.map +1 -0
- package/plugin/chartDownloaderTileHelpers.js +277 -0
- package/plugin/chartDownloaderTileHelpers.js.map +1 -0
- package/plugin/charts.d.ts.map +1 -1
- package/plugin/charts.js +23 -5
- package/plugin/charts.js.map +1 -1
- package/plugin/constants.d.ts.map +1 -1
- package/plugin/index.d.ts.map +1 -1
- package/plugin/index.js +560 -47
- package/plugin/index.js.map +1 -1
- package/plugin/pluginStatus.js.map +1 -1
- package/plugin/projection.js.map +1 -1
- package/plugin/tileServer.d.ts +4 -2
- package/plugin/tileServer.d.ts.map +1 -1
- package/plugin/tileServer.js +37 -8
- package/plugin/tileServer.js.map +1 -1
- package/plugin/tokenProvider.d.ts +63 -0
- package/plugin/tokenProvider.d.ts.map +1 -0
- package/plugin/tokenProvider.js +258 -0
- package/plugin/tokenProvider.js.map +1 -0
- package/plugin/types.d.ts +37 -2
- package/plugin/types.d.ts.map +1 -1
- package/public/images/jobs.png +0 -0
- package/public/images/overview.png +0 -0
- package/public/images/region.png +0 -0
- package/public/index.html +392 -113
- package/public/js/index.js +620 -0
- package/public/leaflet/images/downloads.png +0 -0
- package/public/leaflet/images/layers-2x.png +0 -0
- package/public/leaflet/images/layers.png +0 -0
- package/public/leaflet/images/lifebuoy.png +0 -0
- package/public/leaflet/images/spritesheet-2x.png +0 -0
- package/public/leaflet/images/spritesheet.svg +156 -0
- package/public/leaflet/leaflet.css +677 -0
- package/public/leaflet/leaflet.draw.css +253 -0
- package/public/leaflet/leaflet.draw.js +2957 -0
- package/public/leaflet/leaflet.js +7467 -0
- package/public/style.css +351 -37
- package/docs/screenshots/1_placeholder.png +0 -0
- package/public/index.js +0 -349
|
@@ -1,73 +1,166 @@
|
|
|
1
|
-
import type { BBox
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
y: number;
|
|
7
|
-
z: number;
|
|
8
|
-
}
|
|
9
|
-
export declare enum Status {
|
|
1
|
+
import type { BBox } from 'geojson';
|
|
2
|
+
import { ChartProvider, MBTilesHandle } from './types';
|
|
3
|
+
import { Tile } from './chartDownloaderTileHelpers';
|
|
4
|
+
export type { Tile };
|
|
5
|
+
export declare enum State {
|
|
10
6
|
Stopped = 0,
|
|
11
7
|
Running = 1
|
|
12
8
|
}
|
|
9
|
+
interface CacheStatistic {
|
|
10
|
+
requests: number;
|
|
11
|
+
hits: number;
|
|
12
|
+
misses: number;
|
|
13
|
+
failures: number;
|
|
14
|
+
}
|
|
15
|
+
export interface JobOptions {
|
|
16
|
+
refetch: boolean;
|
|
17
|
+
mbtiles: boolean;
|
|
18
|
+
vacuum: boolean;
|
|
19
|
+
}
|
|
20
|
+
declare enum JobType {
|
|
21
|
+
None = 0,
|
|
22
|
+
Seed = 1,
|
|
23
|
+
Delete = 2
|
|
24
|
+
}
|
|
25
|
+
export declare enum TileSource {
|
|
26
|
+
None = 0,
|
|
27
|
+
FetchedFromCache = 1,
|
|
28
|
+
FetchedFromRemote = 2
|
|
29
|
+
}
|
|
30
|
+
export declare enum FailureKind {
|
|
31
|
+
None = "none",
|
|
32
|
+
Timeout = "timeout",
|
|
33
|
+
HttpClient = "http_4xx",
|
|
34
|
+
HttpServer = "http_5xx",
|
|
35
|
+
Network = "network",
|
|
36
|
+
NoRemoteUrl = "no_remote_url"
|
|
37
|
+
}
|
|
38
|
+
export interface TileFetchFailure {
|
|
39
|
+
kind: FailureKind;
|
|
40
|
+
status?: number;
|
|
41
|
+
}
|
|
42
|
+
export interface TileFetchResult {
|
|
43
|
+
buffer: Buffer | null;
|
|
44
|
+
source: TileSource;
|
|
45
|
+
failure?: TileFetchFailure;
|
|
46
|
+
}
|
|
47
|
+
export type FailureCounts = Partial<Record<FailureKind, number>>;
|
|
13
48
|
export declare class ChartSeedingManager {
|
|
14
49
|
static ActiveJobs: {
|
|
15
50
|
[key: number]: ChartDownloader;
|
|
16
51
|
};
|
|
17
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Reset all module-level static state owned by ChartSeedingManager and
|
|
54
|
+
* ChartDownloader so a test harness can run from a known baseline.
|
|
55
|
+
*
|
|
56
|
+
* The plugin's static fields outlive a `stop()` / `start()` cycle in
|
|
57
|
+
* production (which is intended — process-global gates and ID sequences),
|
|
58
|
+
* but in a test process running 200+ tests in sequence the residue
|
|
59
|
+
* shows up as cross-test interference: nextJobId drifts upward, an
|
|
60
|
+
* earlier low-disk-space probe leaves CachingEnabled=false for 2s,
|
|
61
|
+
* stale CacheStatistics from one provider get seen by an unrelated
|
|
62
|
+
* test asserting "stats are an object".
|
|
63
|
+
*
|
|
64
|
+
* Production code never calls this. The test app's beforeEach does.
|
|
65
|
+
*/
|
|
66
|
+
static resetForTests(): void;
|
|
67
|
+
static createJob(cachePath: string, provider: ChartProvider, options: JobOptions, minZoom: number, maxZoom: number, feature?: GeoJSON.Feature<GeoJSON.Geometry> | undefined, bbox?: BBox | undefined): Promise<ChartDownloader>;
|
|
18
68
|
static cancelAll(): void;
|
|
19
69
|
}
|
|
20
70
|
export declare class ChartDownloader {
|
|
21
|
-
private
|
|
22
|
-
private chartsPath;
|
|
71
|
+
private cachePath;
|
|
23
72
|
private provider;
|
|
73
|
+
private options;
|
|
24
74
|
private static MINIMUM_FREE_DISK_SPACE;
|
|
25
75
|
private static nextJobId;
|
|
76
|
+
private static CachingEnabled;
|
|
77
|
+
private static CacheStatistics;
|
|
78
|
+
private static TilesCached;
|
|
79
|
+
private static lastDiskSpaceCheck;
|
|
80
|
+
private static lastDiskSpaceResult;
|
|
81
|
+
static tileRetryBackoffMs: number;
|
|
26
82
|
private id;
|
|
83
|
+
private type;
|
|
84
|
+
private state;
|
|
27
85
|
private status;
|
|
28
86
|
private totalTiles;
|
|
29
87
|
private downloadedTiles;
|
|
30
88
|
private failedTiles;
|
|
31
89
|
private cachedTiles;
|
|
32
|
-
private
|
|
90
|
+
private deletedTiles;
|
|
91
|
+
private failureCounts;
|
|
92
|
+
private sampleLogged;
|
|
33
93
|
private areaDescription;
|
|
34
94
|
private cancelRequested;
|
|
95
|
+
private regionName;
|
|
35
96
|
private tiles;
|
|
36
|
-
private
|
|
37
|
-
constructor(
|
|
97
|
+
private tilesInDB;
|
|
98
|
+
constructor(cachePath: string, provider: ChartProvider, options: JobOptions);
|
|
38
99
|
get ID(): number;
|
|
39
|
-
|
|
40
|
-
initializeJobFromBBox(bbox: BBox, maxZoom: number): Promise<void>;
|
|
41
|
-
initializeJobFromTile(tile: Tile, maxZoom: number): Promise<void>;
|
|
42
|
-
private static DISK_CHECK_INTERVAL_MS;
|
|
100
|
+
initalizeJobFromFeature(feature: GeoJSON.Feature<GeoJSON.Geometry>, minZoom: number, maxZoom: number): Promise<void>;
|
|
101
|
+
initializeJobFromBBox(bbox: BBox, minZoom: number, maxZoom: number): Promise<void>;
|
|
43
102
|
/**
|
|
44
103
|
* Download map tiles for a specific area.
|
|
45
104
|
*/
|
|
46
105
|
seedCache(): Promise<void>;
|
|
47
106
|
deleteCache(): Promise<void>;
|
|
48
107
|
cancelJob(): void;
|
|
49
|
-
private filterCachedTiles;
|
|
50
108
|
info(): {
|
|
51
109
|
id: number;
|
|
110
|
+
type: JobType;
|
|
52
111
|
chartName: string;
|
|
53
112
|
regionName: string;
|
|
54
113
|
totalTiles: number;
|
|
55
114
|
downloadedTiles: number;
|
|
56
115
|
cachedTiles: number;
|
|
57
116
|
failedTiles: number;
|
|
117
|
+
failures: {
|
|
118
|
+
http_4xx?: number | undefined;
|
|
119
|
+
http_5xx?: number | undefined;
|
|
120
|
+
network?: number | undefined;
|
|
121
|
+
no_remote_url?: number | undefined;
|
|
122
|
+
none?: number | undefined;
|
|
123
|
+
timeout?: number | undefined;
|
|
124
|
+
};
|
|
125
|
+
deletedTiles: number;
|
|
58
126
|
progress: number;
|
|
59
|
-
status:
|
|
127
|
+
status: string;
|
|
128
|
+
state: State;
|
|
60
129
|
};
|
|
61
|
-
static getTileFromCacheOrRemote(chartsPath: string, provider: ChartProvider, tile: Tile): Promise<
|
|
130
|
+
static getTileFromCacheOrRemote(chartsPath: string, provider: ChartProvider, tile: Tile, overwrite?: boolean): Promise<TileFetchResult>;
|
|
131
|
+
static getTileFromMbTiles(mbtilesHandle: MBTilesHandle, tile: Tile): Promise<Buffer | null>;
|
|
132
|
+
static cacheTileToMbTiles(mbtilesHandle: MBTilesHandle, tile: Tile, buffer: Buffer | null): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Detailed-result variant of fetchTileFromRemote. Returns the buffer on
|
|
135
|
+
* success and a `failure` discriminator on every other path so the
|
|
136
|
+
* caller can attribute "failed" tiles to a specific cause (timeout vs
|
|
137
|
+
* 5xx vs network) for diagnostic logs and per-job counters.
|
|
138
|
+
*
|
|
139
|
+
* Retries once on 502/503 with TILE_RETRY_BACKOFF_MS backoff: those are
|
|
140
|
+
* the response codes that genuinely benefit from one more try (LB hiccup,
|
|
141
|
+
* backend cold-start). 504 is excluded because it means the upstream
|
|
142
|
+
* already waited; another wait makes the per-tile latency intolerable.
|
|
143
|
+
* 4xx are not retried (auth or "tile genuinely doesn't exist" — neither
|
|
144
|
+
* gets better by trying again).
|
|
145
|
+
*/
|
|
146
|
+
static fetchTileFromRemoteDetailed(provider: ChartProvider, tile: Tile, timeoutMs?: number): Promise<{
|
|
147
|
+
buffer: Buffer | null;
|
|
148
|
+
failure: TileFetchFailure;
|
|
149
|
+
}>;
|
|
150
|
+
/**
|
|
151
|
+
* Backwards-compatible wrapper for callers that only need the buffer.
|
|
152
|
+
* Internal callers should prefer fetchTileFromRemoteDetailed for the
|
|
153
|
+
* categorised failure information.
|
|
154
|
+
*/
|
|
62
155
|
static fetchTileFromRemote(provider: ChartProvider, tile: Tile, timeoutMs?: number): Promise<Buffer | null>;
|
|
63
|
-
|
|
156
|
+
static hasDiskSpace(path: string): Promise<boolean>;
|
|
157
|
+
static getStatistics(): {
|
|
158
|
+
[k: string]: CacheStatistic;
|
|
159
|
+
};
|
|
64
160
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
161
|
+
* Reset the static fields owned by ChartDownloader. See
|
|
162
|
+
* ChartSeedingManager.resetForTests for why this exists.
|
|
67
163
|
*/
|
|
68
|
-
|
|
69
|
-
getTilesForGeoJSON(geojson: FeatureCollection, zoomMin?: number, zoomMax?: number): Tile[];
|
|
70
|
-
private convertRegionToGeoJSON;
|
|
71
|
-
private bboxPolygon;
|
|
164
|
+
static resetForTests(): void;
|
|
72
165
|
}
|
|
73
166
|
//# sourceMappingURL=chartDownloader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chartDownloader.d.ts","sourceRoot":"","sources":["../src/chartDownloader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chartDownloader.d.ts","sourceRoot":"","sources":["../src/chartDownloader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SA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