@signalk/tracks-plugin 3.0.1 → 3.0.3
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/README.md +7 -4
- package/dist/asyncTrackStore.d.ts +62 -0
- package/dist/asyncTrackStore.test.d.ts +1 -0
- package/dist/harness.test-utils.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +464 -12157
- package/dist/index.js.map +1 -1
- package/dist/sqliteStore.d.ts +11 -1
- package/dist/store.d.ts +1 -1
- package/dist/timeWindow.d.ts +27 -3
- package/dist/trackStoreProtocol.d.ts +38 -0
- package/dist/trackStoreWorker.d.ts +1 -0
- package/dist/trackStoreWorker.js +11717 -0
- package/dist/trackStoreWorker.js.map +1 -0
- package/dist/types.d.ts +12 -0
- package/dist/utils-DOEyuPRy.js +525 -0
- package/dist/utils-DOEyuPRy.js.map +1 -0
- package/dist/workerTestSetup.d.ts +2 -0
- package/docs/history-and-storage.md +56 -3
- package/package.json +1 -1
package/dist/sqliteStore.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { TrackQuery } from './timeWindow.js';
|
|
2
2
|
import { TrackStore } from './store.js';
|
|
3
3
|
import { Context, Debug, LatLngTuple, TimedPosition, TimedTrackCollection, TimeWindow, TrackCollection, TrackParams } from './types.js';
|
|
4
|
+
export declare class TransactionStateError extends Error {
|
|
5
|
+
}
|
|
4
6
|
export interface SqliteStoreConfig {
|
|
5
7
|
/** Absolute path to the database file, or ':memory:'. */
|
|
6
8
|
file: string;
|
|
@@ -102,7 +104,15 @@ export declare class SqliteTrackStore implements TrackStore {
|
|
|
102
104
|
segments(context: Context, window?: TimeWindow): LatLngTuple[][];
|
|
103
105
|
recordName(context: Context, name: string, timestamp?: number): void;
|
|
104
106
|
nameFor(context: Context): string | undefined;
|
|
105
|
-
prune(maxAge: number, keep?: Context): void;
|
|
107
|
+
prune(maxAge: number, keep?: Context, now?: number): void;
|
|
108
|
+
/** Worker startup snapshot; queries and name lookups must not open a second database. */
|
|
109
|
+
storedNames(): {
|
|
110
|
+
context: string;
|
|
111
|
+
name: string;
|
|
112
|
+
timestamp: number;
|
|
113
|
+
}[];
|
|
114
|
+
/** A failed batch stops writes in its worker; reads remain available. */
|
|
115
|
+
transaction(write: () => void): void;
|
|
106
116
|
close(): void;
|
|
107
117
|
/** Unsigned round-trip check, used by the tests. */
|
|
108
118
|
cellIdsFor(context: Context): bigint[];
|
package/dist/store.d.ts
CHANGED
package/dist/timeWindow.d.ts
CHANGED
|
@@ -25,9 +25,32 @@ export interface TrackQuery {
|
|
|
25
25
|
* and the whole retained track is returned, as before.
|
|
26
26
|
*/
|
|
27
27
|
export declare function parseTrackQuery(query: Record<string, unknown>, now?: number, alsoAllowed?: readonly string[]): TrackQuery;
|
|
28
|
+
/**
|
|
29
|
+
* The time between two points that no history bucket either side can account
|
|
30
|
+
* for.
|
|
31
|
+
*
|
|
32
|
+
* Providers disagree on whether a bucket's timestamp marks its start or its
|
|
33
|
+
* end, so a bucket may cover up to its width on either side of it. Two
|
|
34
|
+
* buckets, however, cover the time between their timestamps once between
|
|
35
|
+
* them, so one width is taken off, the wider of the two: exact between
|
|
36
|
+
* buckets under either convention, and between a fix and a bucket never more
|
|
37
|
+
* than the pause could be.
|
|
38
|
+
*/
|
|
39
|
+
export declare function uncoveredBetween(previous: TimedPosition, point: TimedPosition): number;
|
|
40
|
+
/**
|
|
41
|
+
* The pause in the recording between two consecutive points: where thinning
|
|
42
|
+
* dropped the points between them, the longest pause among those it recorded,
|
|
43
|
+
* and otherwise whatever of the time between them no bucket accounts for.
|
|
44
|
+
*/
|
|
45
|
+
export declare function pauseBetween(previous: TimedPosition, point: TimedPosition): number;
|
|
28
46
|
/**
|
|
29
47
|
* Drop points closer together than `resolution` milliseconds, always keeping
|
|
30
48
|
* the first and last so the track keeps its extent.
|
|
49
|
+
*
|
|
50
|
+
* A point kept after dropped ones records the longest pause among them as
|
|
51
|
+
* `pauseBefore`: the kept points are further apart than anything recorded
|
|
52
|
+
* between them, so without it `segment()` would read the spacing thinning
|
|
53
|
+
* made as a stop in the recording.
|
|
31
54
|
*/
|
|
32
55
|
export declare function thin(points: TimedPosition[], resolution: number | undefined): TimedPosition[];
|
|
33
56
|
/**
|
|
@@ -57,9 +80,10 @@ export declare function thinToBudget(points: TimedPosition[], maxPoints: number,
|
|
|
57
80
|
* over an anchorage it actually sat still in.
|
|
58
81
|
*
|
|
59
82
|
* Operates on timestamped points rather than inside a store, so both the
|
|
60
|
-
* in-memory and sqlite stores segment identically
|
|
61
|
-
*
|
|
62
|
-
*
|
|
83
|
+
* in-memory and sqlite stores segment identically. A gap is a pause in the
|
|
84
|
+
* recording, not in the points given: see `pauseBetween`, which lets a
|
|
85
|
+
* thinned track, or one reconciled with history buckets, segment exactly as
|
|
86
|
+
* the recording would.
|
|
63
87
|
*
|
|
64
88
|
* `gap` of 0 or undefined returns a single segment, preserving the old shape.
|
|
65
89
|
* An empty input returns no segments rather than one empty one, so a caller can
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SqliteTrackStore } from './sqliteStore.js';
|
|
2
|
+
export type StoreMethod = 'newPosition' | 'recordName' | 'initialTrack' | 'prune' | 'get' | 'getTimed' | 'getAllTracks' | 'getFilteredTracks' | 'getFilteredTimedTracks' | 'close';
|
|
3
|
+
export type Operation = {
|
|
4
|
+
[K in StoreMethod]: {
|
|
5
|
+
id: number;
|
|
6
|
+
method: K;
|
|
7
|
+
args: Parameters<SqliteTrackStore[K]>;
|
|
8
|
+
};
|
|
9
|
+
}[StoreMethod];
|
|
10
|
+
export interface StoredName {
|
|
11
|
+
context: string;
|
|
12
|
+
name: string;
|
|
13
|
+
timestamp: number;
|
|
14
|
+
}
|
|
15
|
+
export type WorkerMessage = {
|
|
16
|
+
kind: 'ready';
|
|
17
|
+
names: StoredName[];
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'debug';
|
|
20
|
+
text: string;
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'fatal';
|
|
23
|
+
error: string;
|
|
24
|
+
} | {
|
|
25
|
+
kind: 'result';
|
|
26
|
+
results: {
|
|
27
|
+
id: number;
|
|
28
|
+
value?: unknown;
|
|
29
|
+
error?: string;
|
|
30
|
+
writeFailed?: boolean;
|
|
31
|
+
selfPositionUnavailable?: boolean;
|
|
32
|
+
name?: {
|
|
33
|
+
context: string;
|
|
34
|
+
value: string | undefined;
|
|
35
|
+
};
|
|
36
|
+
names?: string[];
|
|
37
|
+
}[];
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|