signalk-history-widgets 0.4.0 → 0.6.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/README.md +63 -12
- package/docs/screenshots/depth.png +0 -0
- package/docs/screenshots/system-health.png +0 -0
- package/package.json +4 -3
- package/plugin/index.js +35 -1
- package/plugin/index.js.map +1 -1
- package/public/assets/{battery-BP5w2HNc.js → battery-DIdhsP3c.js} +1 -1
- package/public/assets/{battery-config-DYeoAWMp.js → battery-config-DjFsEE6z.js} +1 -1
- package/public/assets/{clock-DGa0UjBJ.js → clock-BM6oWw1K.js} +1 -1
- package/public/assets/{clock-config-DBFHzMXm.js → clock-config-CEXnt2BC.js} +1 -1
- package/public/assets/{config-4Cx9vP2h.js → config-CGQo6w5J.js} +1 -1
- package/public/assets/depth-BRzrsqnk.js +1 -0
- package/public/assets/depth-config-CXV_1Ma9.js +9 -0
- package/public/assets/depth-model-DGmfV7Y9.js +1 -0
- package/public/assets/level-DvwXfEQD.js +1 -0
- package/public/assets/{level-config-COx4EZHZ.js → level-config-BUp6HxOr.js} +1 -1
- package/public/assets/level-render-70t5D0u5.js +1 -0
- package/public/assets/pi-CnIcVauf.js +1 -0
- package/public/assets/pi-config-Bv1JcQ9H.js +15 -0
- package/public/assets/pi-model-DtR5ejzZ.js +1 -0
- package/public/assets/series-DIfvccHD.js +1 -0
- package/public/assets/{signalk-NgaYaNkQ.js → signalk-BOmj4E6B.js} +1 -1
- package/public/assets/{steer-DVXoKR46.js → steer-DVy1Yeda.js} +1 -1
- package/public/assets/{tank-B7og9w7x.js → tank-DoTwuOR1.js} +1 -1
- package/public/assets/{tank-config-BUfMKMvt.js → tank-config-CQ5sfnUH.js} +1 -1
- package/public/assets/widget-BZqPEWQ6.js +1 -0
- package/public/battery-config.html +3 -3
- package/public/battery.html +4 -3
- package/public/clock-config.html +2 -2
- package/public/clock.html +2 -2
- package/public/config.html +2 -2
- package/public/depth-config.html +17 -0
- package/public/depth.html +19 -0
- package/public/pi-config.html +16 -0
- package/public/pi.html +21 -0
- package/public/steer.html +2 -2
- package/public/tank-config.html +3 -3
- package/public/tank.html +4 -3
- package/public/widget.html +3 -2
- package/public/assets/level-wmEozZnD.js +0 -1
- package/public/assets/widget-VvPC6-2G.js +0 -1
package/README.md
CHANGED
|
@@ -10,31 +10,48 @@ moves.
|
|
|
10
10
|
|
|
11
11
|

|
|
12
12
|
|
|
13
|
-
The package
|
|
14
|
-
|
|
13
|
+
The package brings these widgets, each in the size it is placed at (columns x
|
|
14
|
+
rows of the widget area):
|
|
15
|
+
|
|
16
|
+
| Widget | Size | Shows |
|
|
17
|
+
| ------------------------------------------------------------ | -------------- | ----------------------------------------------------------------- |
|
|
18
|
+
| [History strip](#use) | 1x2, wide 2x2 | one value over 5 minutes to 24 hours |
|
|
19
|
+
| [Wind steering](#wind-steering) | 2x2 | apparent and true wind, close-hauled lines, wind shift |
|
|
20
|
+
| [Tank level, Battery charge](#tank-level-and-battery-charge) | 1x2, small 1x1 | a tank's level or a bank's state of charge, coloured by its zones |
|
|
21
|
+
| [Clock](#clock) | 2x1 | local, UTC or boat time, corrected to GPS |
|
|
22
|
+
| [Depth profile](#depth-profile) | 2x1, large 2x2 | the depth over time like an echo sounder |
|
|
23
|
+
| [System health](#system-health) | 1x1 | CPU temperature, load and memory of the computer Signal K runs on |
|
|
15
24
|
|
|
16
25
|
## Use
|
|
17
26
|
|
|
18
27
|
1. Install **History Widgets** from the App Store and restart the server. The
|
|
19
28
|
plugin is enabled on install.
|
|
20
29
|
2. In Freeboard-SK, press and hold an empty spot in a widget area (a corner or
|
|
21
|
-
the bottom centre) and pick **History strip** (tall)
|
|
22
|
-
(wide)**.
|
|
23
|
-
3.
|
|
24
|
-
HDG, depth, air pressure, air and water temperature) or any
|
|
25
|
-
path. Tap the time span, from 5 minutes to 24 hours.
|
|
30
|
+
the bottom centre) and pick a widget, for example **History strip** (tall)
|
|
31
|
+
or **History strip (wide)**.
|
|
32
|
+
3. For a strip, pick the value: a quick button (TWD, TWS, TWA, AWA, AWS, SOG,
|
|
33
|
+
STW, COG, HDG, depth, air pressure, air and water temperature) or any
|
|
34
|
+
numeric Signal K path. Tap the time span, from 5 minutes to 24 hours.
|
|
26
35
|
|
|
27
36
|
For several values, place several strips next to each other. Press and hold a
|
|
28
|
-
placed
|
|
37
|
+
placed widget to change it or remove it.
|
|
29
38
|
|
|
30
39
|

|
|
31
40
|
|
|
32
41
|
## History
|
|
33
42
|
|
|
34
|
-
With a History API provider on the server (for example
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
43
|
+
With a History API provider on the server (for example signalk-questdb, which
|
|
44
|
+
the App Store suggests alongside this plugin, the KIP plugin, signalk-parquet
|
|
45
|
+
or signalk-to-influxdb2) a new strip shows as much of the window as the
|
|
46
|
+
provider has recorded for that path; a provider that was installed recently
|
|
47
|
+
fills only the time since then. Without one the strip starts empty and fills
|
|
48
|
+
from live data. The configuration panel says which case applies.
|
|
49
|
+
|
|
50
|
+
After a server restart the history provider can take a while to come up. A
|
|
51
|
+
strip or depth profile that loads meanwhile shows live data and keeps asking
|
|
52
|
+
for its history for up to ten minutes; once the provider answers, the earlier
|
|
53
|
+
part of the window fills in without losing what was collected in between. A
|
|
54
|
+
screen that was asleep fills the gap from history when it wakes up.
|
|
38
55
|
|
|
39
56
|
Directions such as true wind direction or heading read 0 to 360 and stay one
|
|
40
57
|
band when they swing across north. Other angles, such as the apparent wind
|
|
@@ -117,6 +134,40 @@ without a network right.
|
|
|
117
134
|
Press and hold the clock to choose the zone, 24 or 12 hours, and whether to
|
|
118
135
|
show seconds and the date, all with buttons.
|
|
119
136
|
|
|
137
|
+
## Depth profile
|
|
138
|
+
|
|
139
|
+
The depth over the last minutes or hours like an echo sounder: time runs
|
|
140
|
+
left to right with now at the right edge, depth runs down from the selected
|
|
141
|
+
reference, and the seabed is filled in below each moment's shallowest reading
|
|
142
|
+
(for history, the provider's minimum; a provider that gives only averages
|
|
143
|
+
shows the average, so the seabed can look deeper than the shallowest depth
|
|
144
|
+
recorded). The current depth sits top left in the unit set in the server's Unit
|
|
145
|
+
Preferences. Like the strip, it is seeded from the History API: with a
|
|
146
|
+
history provider on the server it is full as soon as it opens, without one
|
|
147
|
+
it fills from live data as the window passes.
|
|
148
|
+
|
|
149
|
+

|
|
150
|
+
|
|
151
|
+
It follows the depth below the surface when the server has it, else below
|
|
152
|
+
the transducer or the keel. Press and hold it to pick one of those yourself
|
|
153
|
+
or another window, from 5 minutes to 24 hours, all with buttons.
|
|
154
|
+
|
|
155
|
+
## System health
|
|
156
|
+
|
|
157
|
+
A small tile (1x1) for the computer Signal K runs on: the CPU temperature in
|
|
158
|
+
large type, and bars for CPU load and memory in use, with storage as an
|
|
159
|
+
option. It reads what signalk-rpi-stats publishes under `environment.rpi`,
|
|
160
|
+
which the Universal Installer sets up with RPI Manager. A reading turns
|
|
161
|
+
yellow from 70 °C, 80 % CPU or memory and 85 % storage, and red from 80 °C
|
|
162
|
+
(where a Raspberry Pi starts slowing down), 95 % CPU, 90 % memory and 95 %
|
|
163
|
+
storage; zones set in the path's metadata take their place. When the Pi
|
|
164
|
+
reports low voltage or throttling, that replaces the title in red. A reading
|
|
165
|
+
older than two minutes shows `--`.
|
|
166
|
+
|
|
167
|
+

|
|
168
|
+
|
|
169
|
+
Press and hold the tile to show or hide storage and to give it a label.
|
|
170
|
+
|
|
120
171
|
## Requirements
|
|
121
172
|
|
|
122
173
|
- Signal K server 2.22.1 or newer (History API v2) on Node 24 or newer
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "signalk-history-widgets",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "History strip, wind steering, tank level and
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "History strip, wind steering, tank level, clock, depth profile and system health widgets for Signal K chartplotters: any value over the last minutes or hours as a vertical strip with min, average and max, a wind steering dial with close-hauled lines and the recent wind shift, tank levels and battery charge coloured by their zones, a clock in local, UTC or boat time, the depth over time like an echo sounder, and the temperature, CPU load and memory of the computer Signal K runs on",
|
|
5
5
|
"author": "Dirk Wahrheit",
|
|
6
6
|
"main": "plugin/index.js",
|
|
7
7
|
"type": "module",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"displayName": "History Widgets",
|
|
30
30
|
"appIcon": "./icon.svg",
|
|
31
31
|
"recommends": [
|
|
32
|
-
"@signalk/freeboard-sk"
|
|
32
|
+
"@signalk/freeboard-sk",
|
|
33
|
+
"signalk-questdb"
|
|
33
34
|
],
|
|
34
35
|
"screenshots": [
|
|
35
36
|
"./docs/screenshots/wind-strips.png",
|
package/plugin/index.js
CHANGED
|
@@ -39,6 +39,15 @@ var PLUGIN_ID = "signalk-history-widgets";
|
|
|
39
39
|
* admins only: every user of the chartplotter loads these.
|
|
40
40
|
*/
|
|
41
41
|
var ASSET_BASE = `/plotterext/${PLUGIN_ID}`;
|
|
42
|
+
var depth = (id, title, size) => ({
|
|
43
|
+
id,
|
|
44
|
+
title,
|
|
45
|
+
type: "iframe",
|
|
46
|
+
url: `${ASSET_BASE}/depth.html`,
|
|
47
|
+
size,
|
|
48
|
+
configPanel: "depth-config",
|
|
49
|
+
lifecycle: "whileEnabled"
|
|
50
|
+
});
|
|
42
51
|
var strip = (id, title, size) => ({
|
|
43
52
|
id,
|
|
44
53
|
title,
|
|
@@ -69,7 +78,7 @@ var levelPanel = (id, title) => ({
|
|
|
69
78
|
function buildManifest(version) {
|
|
70
79
|
return {
|
|
71
80
|
name: "History Widgets",
|
|
72
|
-
description: "Any value over the last minutes or hours as a vertical strip with its minimum, average and maximum, a wind steering dial with the wind shift of the last minutes, tank levels and battery charge coloured by their zones,
|
|
81
|
+
description: "Any value over the last minutes or hours as a vertical strip with its minimum, average and maximum, a wind steering dial with the wind shift of the last minutes, tank levels and battery charge coloured by their zones, a clock in local, UTC or boat time, the depth over time like an echo sounder, and the temperature, CPU load and memory of the computer Signal K runs on.",
|
|
73
82
|
version,
|
|
74
83
|
apiVersion: "1",
|
|
75
84
|
requires: [
|
|
@@ -102,6 +111,17 @@ function buildManifest(version) {
|
|
|
102
111
|
size: "2x1",
|
|
103
112
|
configPanel: "clock-config",
|
|
104
113
|
lifecycle: "whileEnabled"
|
|
114
|
+
},
|
|
115
|
+
depth("depth", "Depth profile", "2x1"),
|
|
116
|
+
depth("depth-large", "Depth profile (large)", "2x2"),
|
|
117
|
+
{
|
|
118
|
+
id: "system-health",
|
|
119
|
+
title: "System health",
|
|
120
|
+
type: "iframe",
|
|
121
|
+
url: `${ASSET_BASE}/pi.html`,
|
|
122
|
+
size: "1x1",
|
|
123
|
+
configPanel: "system-health-config",
|
|
124
|
+
lifecycle: "whileEnabled"
|
|
105
125
|
}
|
|
106
126
|
],
|
|
107
127
|
panels: [
|
|
@@ -127,6 +147,20 @@ function buildManifest(version) {
|
|
|
127
147
|
type: "iframe",
|
|
128
148
|
url: `${ASSET_BASE}/clock-config.html`,
|
|
129
149
|
lifecycle: "onOpen"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
id: "depth-config",
|
|
153
|
+
title: "Depth profile",
|
|
154
|
+
type: "iframe",
|
|
155
|
+
url: `${ASSET_BASE}/depth-config.html`,
|
|
156
|
+
lifecycle: "onOpen"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
id: "system-health-config",
|
|
160
|
+
title: "System health",
|
|
161
|
+
type: "iframe",
|
|
162
|
+
url: `${ASSET_BASE}/pi-config.html`,
|
|
163
|
+
lifecycle: "onOpen"
|
|
130
164
|
}
|
|
131
165
|
]
|
|
132
166
|
};
|
package/plugin/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/assets.ts","../src/manifest.ts","../src/index.ts"],"sourcesContent":["import { readdir, readFile } from 'node:fs/promises'\nimport { extname, join, relative, sep } from 'node:path'\n\nconst TYPES: Record<string, string> = {\n '.html': 'text/html; charset=utf-8',\n '.js': 'text/javascript; charset=utf-8',\n '.css': 'text/css; charset=utf-8',\n '.svg': 'image/svg+xml',\n '.map': 'application/json'\n}\n\nexport interface Asset {\n type: string\n body: Buffer\n}\n\n/**\n * Every file of the built web pages, keyed by its URL path. Serving from this\n * list rather than from the file system keeps requests out of everything\n * else on disk.\n */\nexport async function loadAssets(dir: string): Promise<Map<string, Asset>> {\n const assets = new Map<string, Asset>()\n const entries = await readdir(dir, { recursive: true, withFileTypes: true })\n for (const entry of entries) {\n if (!entry.isFile()) continue\n const file = join(entry.parentPath, entry.name)\n const url = '/' + relative(dir, file).split(sep).join('/')\n assets.set(url, {\n type: TYPES[extname(file)] ?? 'application/octet-stream',\n body: await readFile(file)\n })\n }\n return assets\n}\n","export const PLUGIN_ID = 'signalk-history-widgets'\n\n/**\n * Where the widget pages are served. Not under /plugins/<id>, which is for\n * admins only: every user of the chartplotter loads these.\n */\nexport const ASSET_BASE = `/plotterext/${PLUGIN_ID}`\n\nconst strip = (id: string, title: string, size: string) => ({\n id,\n title,\n type: 'iframe',\n url: `${ASSET_BASE}/widget.html`,\n size,\n configPanel: 'strip-config',\n lifecycle: 'whileEnabled'\n})\n\n/** A level widget; the small one shares its page and panel. */\nconst level = (id: string, title: string, size = '1x2', page = id) => ({\n id,\n title,\n type: 'iframe',\n url: `${ASSET_BASE}/${page}.html`,\n size,\n configPanel: `${page}-config`,\n lifecycle: 'whileEnabled'\n})\n\nconst levelPanel = (id: string, title: string) => ({\n id: `${id}-config`,\n title,\n type: 'iframe',\n url: `${ASSET_BASE}/${id}-config.html`,\n lifecycle: 'onOpen'\n})\n\n/** The Plotter Extensions manifest (apiVersion 1). */\nexport function buildManifest(version: string) {\n return {\n name: 'History Widgets',\n description:\n 'Any value over the last minutes or hours as a vertical strip with its minimum, average and maximum, a wind steering dial with the wind shift of the last minutes, tank levels and battery charge coloured by their zones, and a clock in local, UTC or boat time.',\n version,\n apiVersion: '1',\n requires: ['widgets', 'panels.iframe', 'signalk.stream'],\n optional: ['nightMode'],\n widgets: [\n strip('strip', 'History strip', '1x2'),\n strip('strip-wide', 'History strip (wide)', '2x2'),\n {\n id: 'wind-steering',\n title: 'Wind steering',\n type: 'iframe',\n url: `${ASSET_BASE}/steer.html`,\n size: '2x2',\n configPanel: 'wind-steering-config',\n lifecycle: 'whileEnabled'\n },\n level('tank', 'Tank level'),\n level('tank-small', 'Tank level (small)', '1x1', 'tank'),\n level('battery', 'Battery charge'),\n level('battery-small', 'Battery charge (small)', '1x1', 'battery'),\n {\n id: 'clock',\n title: 'Clock',\n type: 'iframe',\n url: `${ASSET_BASE}/clock.html`,\n size: '2x1',\n configPanel: 'clock-config',\n lifecycle: 'whileEnabled'\n }\n ],\n panels: [\n {\n id: 'strip-config',\n title: 'History strip',\n type: 'iframe',\n url: `${ASSET_BASE}/config.html`,\n lifecycle: 'onOpen'\n },\n {\n id: 'wind-steering-config',\n title: 'Wind steering',\n type: 'iframe',\n url: `${ASSET_BASE}/steer-config.html`,\n lifecycle: 'onOpen'\n },\n levelPanel('tank', 'Tank level'),\n levelPanel('battery', 'Battery charge'),\n {\n id: 'clock-config',\n title: 'Clock',\n type: 'iframe',\n url: `${ASSET_BASE}/clock-config.html`,\n lifecycle: 'onOpen'\n }\n ]\n }\n}\n","import { readFileSync } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\nimport type { Request, Response, NextFunction } from 'express'\nimport type { Plugin, ServerAPI } from '@signalk/server-api'\nimport { loadAssets, type Asset } from './assets.js'\nimport { ASSET_BASE, PLUGIN_ID, buildManifest } from './manifest.js'\n\nconst PUBLIC_DIR = fileURLToPath(new URL('../public', import.meta.url))\nconst PACKAGE_JSON = fileURLToPath(new URL('../package.json', import.meta.url))\n\n/** The express app the server hands plugins; ServerAPI leaves `use` out. */\ntype App = ServerAPI & {\n use?: (path: string, handler: (req: Request, res: Response, next: NextFunction) => void) => void\n}\n\nfunction packageVersion(): string {\n const pkg: unknown = JSON.parse(readFileSync(PACKAGE_JSON, 'utf8'))\n const version = (pkg as { version?: unknown }).version\n return typeof version === 'string' ? version : '0.0.0'\n}\n\nexport default function historyWidgets(app: App): Plugin {\n let running = false\n let assets = new Map<string, Asset>()\n let mounted = false\n let registered = false\n const manifest = buildManifest(packageVersion())\n\n const mount = () => {\n if (mounted || !app.use) return\n mounted = true\n // express cannot unmount a route, so a stopped plugin answers 404.\n app.use(ASSET_BASE, (req, res, next) => {\n const asset = running ? assets.get(req.path) : undefined\n if (!asset || (req.method !== 'GET' && req.method !== 'HEAD')) {\n next()\n return\n }\n res.type(asset.type).send(asset.body)\n })\n }\n\n const register = () => {\n if (registered) return\n registered = true\n app.registerResourceProvider({\n type: 'plotterExtensions',\n methods: {\n listResources: () => Promise.resolve(running ? { [PLUGIN_ID]: manifest } : {}),\n getResource: (id: string) =>\n running && id === PLUGIN_ID\n ? Promise.resolve(manifest)\n : Promise.reject(new Error(`No such plotterExtensions resource: ${id}`)),\n setResource: () => Promise.reject(new Error(`${PLUGIN_ID} is read-only`)),\n deleteResource: () => Promise.reject(new Error(`${PLUGIN_ID} is read-only`))\n }\n })\n }\n\n return {\n id: PLUGIN_ID,\n name: 'History Widgets',\n description:\n 'History strip and wind steering widgets for Freeboard-SK and other Plotter Extensions hosts',\n schema: () => ({ type: 'object', properties: {} }),\n\n start() {\n running = true\n mount()\n register()\n loadAssets(PUBLIC_DIR)\n .then((loaded) => {\n assets = loaded\n app.setPluginStatus(`Serving ${manifest.widgets.length} widgets`)\n })\n .catch((err: unknown) => {\n app.setPluginError(\n `Web pages missing: ${err instanceof Error ? err.message : String(err)}`\n )\n })\n },\n\n stop() {\n running = false\n }\n }\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/assets.ts","../src/manifest.ts","../src/index.ts"],"sourcesContent":["import { readdir, readFile } from 'node:fs/promises'\nimport { extname, join, relative, sep } from 'node:path'\n\nconst TYPES: Record<string, string> = {\n '.html': 'text/html; charset=utf-8',\n '.js': 'text/javascript; charset=utf-8',\n '.css': 'text/css; charset=utf-8',\n '.svg': 'image/svg+xml',\n '.map': 'application/json'\n}\n\nexport interface Asset {\n type: string\n body: Buffer\n}\n\n/**\n * Every file of the built web pages, keyed by its URL path. Serving from this\n * list rather than from the file system keeps requests out of everything\n * else on disk.\n */\nexport async function loadAssets(dir: string): Promise<Map<string, Asset>> {\n const assets = new Map<string, Asset>()\n const entries = await readdir(dir, { recursive: true, withFileTypes: true })\n for (const entry of entries) {\n if (!entry.isFile()) continue\n const file = join(entry.parentPath, entry.name)\n const url = '/' + relative(dir, file).split(sep).join('/')\n assets.set(url, {\n type: TYPES[extname(file)] ?? 'application/octet-stream',\n body: await readFile(file)\n })\n }\n return assets\n}\n","export const PLUGIN_ID = 'signalk-history-widgets'\n\n/**\n * Where the widget pages are served. Not under /plugins/<id>, which is for\n * admins only: every user of the chartplotter loads these.\n */\nexport const ASSET_BASE = `/plotterext/${PLUGIN_ID}`\n\nconst depth = (id: string, title: string, size: string) => ({\n id,\n title,\n type: 'iframe',\n url: `${ASSET_BASE}/depth.html`,\n size,\n configPanel: 'depth-config',\n lifecycle: 'whileEnabled'\n})\n\nconst strip = (id: string, title: string, size: string) => ({\n id,\n title,\n type: 'iframe',\n url: `${ASSET_BASE}/widget.html`,\n size,\n configPanel: 'strip-config',\n lifecycle: 'whileEnabled'\n})\n\n/** A level widget; the small one shares its page and panel. */\nconst level = (id: string, title: string, size = '1x2', page = id) => ({\n id,\n title,\n type: 'iframe',\n url: `${ASSET_BASE}/${page}.html`,\n size,\n configPanel: `${page}-config`,\n lifecycle: 'whileEnabled'\n})\n\nconst levelPanel = (id: string, title: string) => ({\n id: `${id}-config`,\n title,\n type: 'iframe',\n url: `${ASSET_BASE}/${id}-config.html`,\n lifecycle: 'onOpen'\n})\n\n/** The Plotter Extensions manifest (apiVersion 1). */\nexport function buildManifest(version: string) {\n return {\n name: 'History Widgets',\n description:\n 'Any value over the last minutes or hours as a vertical strip with its minimum, average and maximum, a wind steering dial with the wind shift of the last minutes, tank levels and battery charge coloured by their zones, a clock in local, UTC or boat time, the depth over time like an echo sounder, and the temperature, CPU load and memory of the computer Signal K runs on.',\n version,\n apiVersion: '1',\n requires: ['widgets', 'panels.iframe', 'signalk.stream'],\n optional: ['nightMode'],\n widgets: [\n strip('strip', 'History strip', '1x2'),\n strip('strip-wide', 'History strip (wide)', '2x2'),\n {\n id: 'wind-steering',\n title: 'Wind steering',\n type: 'iframe',\n url: `${ASSET_BASE}/steer.html`,\n size: '2x2',\n configPanel: 'wind-steering-config',\n lifecycle: 'whileEnabled'\n },\n level('tank', 'Tank level'),\n level('tank-small', 'Tank level (small)', '1x1', 'tank'),\n level('battery', 'Battery charge'),\n level('battery-small', 'Battery charge (small)', '1x1', 'battery'),\n {\n id: 'clock',\n title: 'Clock',\n type: 'iframe',\n url: `${ASSET_BASE}/clock.html`,\n size: '2x1',\n configPanel: 'clock-config',\n lifecycle: 'whileEnabled'\n },\n depth('depth', 'Depth profile', '2x1'),\n depth('depth-large', 'Depth profile (large)', '2x2'),\n {\n id: 'system-health',\n title: 'System health',\n type: 'iframe',\n url: `${ASSET_BASE}/pi.html`,\n size: '1x1',\n configPanel: 'system-health-config',\n lifecycle: 'whileEnabled'\n }\n ],\n panels: [\n {\n id: 'strip-config',\n title: 'History strip',\n type: 'iframe',\n url: `${ASSET_BASE}/config.html`,\n lifecycle: 'onOpen'\n },\n {\n id: 'wind-steering-config',\n title: 'Wind steering',\n type: 'iframe',\n url: `${ASSET_BASE}/steer-config.html`,\n lifecycle: 'onOpen'\n },\n levelPanel('tank', 'Tank level'),\n levelPanel('battery', 'Battery charge'),\n {\n id: 'clock-config',\n title: 'Clock',\n type: 'iframe',\n url: `${ASSET_BASE}/clock-config.html`,\n lifecycle: 'onOpen'\n },\n {\n id: 'depth-config',\n title: 'Depth profile',\n type: 'iframe',\n url: `${ASSET_BASE}/depth-config.html`,\n lifecycle: 'onOpen'\n },\n {\n id: 'system-health-config',\n title: 'System health',\n type: 'iframe',\n url: `${ASSET_BASE}/pi-config.html`,\n lifecycle: 'onOpen'\n }\n ]\n }\n}\n","import { readFileSync } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\nimport type { Request, Response, NextFunction } from 'express'\nimport type { Plugin, ServerAPI } from '@signalk/server-api'\nimport { loadAssets, type Asset } from './assets.js'\nimport { ASSET_BASE, PLUGIN_ID, buildManifest } from './manifest.js'\n\nconst PUBLIC_DIR = fileURLToPath(new URL('../public', import.meta.url))\nconst PACKAGE_JSON = fileURLToPath(new URL('../package.json', import.meta.url))\n\n/** The express app the server hands plugins; ServerAPI leaves `use` out. */\ntype App = ServerAPI & {\n use?: (path: string, handler: (req: Request, res: Response, next: NextFunction) => void) => void\n}\n\nfunction packageVersion(): string {\n const pkg: unknown = JSON.parse(readFileSync(PACKAGE_JSON, 'utf8'))\n const version = (pkg as { version?: unknown }).version\n return typeof version === 'string' ? version : '0.0.0'\n}\n\nexport default function historyWidgets(app: App): Plugin {\n let running = false\n let assets = new Map<string, Asset>()\n let mounted = false\n let registered = false\n const manifest = buildManifest(packageVersion())\n\n const mount = () => {\n if (mounted || !app.use) return\n mounted = true\n // express cannot unmount a route, so a stopped plugin answers 404.\n app.use(ASSET_BASE, (req, res, next) => {\n const asset = running ? assets.get(req.path) : undefined\n if (!asset || (req.method !== 'GET' && req.method !== 'HEAD')) {\n next()\n return\n }\n res.type(asset.type).send(asset.body)\n })\n }\n\n const register = () => {\n if (registered) return\n registered = true\n app.registerResourceProvider({\n type: 'plotterExtensions',\n methods: {\n listResources: () => Promise.resolve(running ? { [PLUGIN_ID]: manifest } : {}),\n getResource: (id: string) =>\n running && id === PLUGIN_ID\n ? Promise.resolve(manifest)\n : Promise.reject(new Error(`No such plotterExtensions resource: ${id}`)),\n setResource: () => Promise.reject(new Error(`${PLUGIN_ID} is read-only`)),\n deleteResource: () => Promise.reject(new Error(`${PLUGIN_ID} is read-only`))\n }\n })\n }\n\n return {\n id: PLUGIN_ID,\n name: 'History Widgets',\n description:\n 'History strip and wind steering widgets for Freeboard-SK and other Plotter Extensions hosts',\n schema: () => ({ type: 'object', properties: {} }),\n\n start() {\n running = true\n mount()\n register()\n loadAssets(PUBLIC_DIR)\n .then((loaded) => {\n assets = loaded\n app.setPluginStatus(`Serving ${manifest.widgets.length} widgets`)\n })\n .catch((err: unknown) => {\n app.setPluginError(\n `Web pages missing: ${err instanceof Error ? err.message : String(err)}`\n )\n })\n },\n\n stop() {\n running = false\n }\n }\n}\n"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-U7YORXZ7-BLTBSYrv.js";import{t as e}from"./level-
|
|
1
|
+
import"./chunk-U7YORXZ7-BLTBSYrv.js";import{t as e}from"./level-DvwXfEQD.js";e(`battery`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-U7YORXZ7-BLTBSYrv.js";import{t as e}from"./level-config-
|
|
1
|
+
import"./chunk-U7YORXZ7-BLTBSYrv.js";import{t as e}from"./level-config-BUp6HxOr.js";e(`battery`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./chunk-U7YORXZ7-BLTBSYrv.js";import{n as t,t as n}from"./styles-CjtPzFRR.js";import{a as r,i,n as a,o,r as s,s as c,t as l}from"./clock-model-D8TrsRP6.js";import{i as u}from"./signalk-
|
|
1
|
+
import{t as e}from"./chunk-U7YORXZ7-BLTBSYrv.js";import{n as t,t as n}from"./styles-CjtPzFRR.js";import{a as r,i,n as a,o,r as s,s as c,t as l}from"./clock-model-D8TrsRP6.js";import{i as u}from"./signalk-BOmj4E6B.js";var d={card:`rgba(20, 26, 32, 0.78)`,text:`#e8edf2`,muted:`#9fb3c4`},f={card:`rgba(8, 0, 0, 0.85)`,text:`#d32f2f`,muted:`#8e2424`},p=`'Helvetica Neue', Arial, sans-serif`;function m(e,t,n){let r=Math.floor(n);for(;r>7&&e(r)>t;)r--;return r}function h(e,t,n){if(n(e))return e;let r=t&&e.endsWith(t)?t:``,i=e.slice(0,e.length-r.length);for(let e=i.length-1;e>0;e--){let t=`${i.slice(0,e).trimEnd()}…${r?` ${r}`:``}`;if(n(t))return t}for(let e=(r||i).length-1;e>0;e--){let t=`${(r||i).slice(0,e).trimEnd()}…`;if(n(t))return t}return`…`}function g(e,t,n,r,i=``){let a=m(n=>(e.font=`${i} ${n}px ${p}`,e.measureText(t).width),n,r);return e.font=`${i} ${a}px ${p}`,a}function _(e,t,n,r){let i=r.palette;e.clearRect(0,0,t,n),e.fillStyle=i.card,e.beginPath(),e.roundRect(0,0,t,n,8),e.fill();let a=Math.max(4,Math.min(t,n)*.06),o=t-2*a,s=Math.max(9,Math.min(n*.14,t*.08));e.textAlign=`center`,e.textBaseline=`alphabetic`;let c=g(e,r.title,o,s),l=h(r.title,r.keep??``,t=>e.measureText(t).width<=o);e.fillStyle=i.muted,e.fillText(l,t/2,a+c);let u=r.date?s:0,d=a+c,f=n-a-(r.date?u*1.3:0),p=g(e,r.time,o,(f-d)*.9,`600`);e.fillStyle=i.text,e.fillText(r.time,t/2,(d+f)/2+p*.36),r.date&&(g(e,r.date,o,u),e.fillStyle=i.muted,e.fillText(r.date,t/2,n-a))}var v=document.createElement(`canvas`);document.getElementById(`root`)?.append(v);var y=o({}),b=!1,x=new s,S=new l,C=!1;function w(){C=!1;let e=v.getBoundingClientRect(),t=window.devicePixelRatio||1,n=Math.max(1,Math.round(e.width*t)),a=Math.max(1,Math.round(e.height*t));(v.width!==n||v.height!==a)&&(v.width=n,v.height=a);let o=v.getContext(`2d`);if(!o)return;o.setTransform(t,0,0,t,0,0);let s=i(Date.now()+x.correction,y,S.zone());_(o,e.width,e.height,{title:r(y,s),keep:s.fallback?s.zoneName:void 0,time:s.time,date:y.showDate?s.date:``,palette:b?f:d})}function T(){C||(C=!0,requestAnimationFrame(w))}function E(){T();let e=Date.now()+x.correction;setTimeout(E,1e3-e%1e3+20)}async function D(e){t(e),new ResizeObserver(T).observe(v);let r=c(()=>e.state.get().then(e=>{y=o(e),T()}).catch(e=>{console.warn(`clock: settings unavailable`,e)}));await e.subscribe([`state.changed`],r),await n(e,e=>{b=e,T()}).catch(e=>{console.warn(`clock: night mode unavailable`,e)}),E(),r();for(let e of[a.region,a.offset])u(e).then(t=>{S.stored(e,t),T()});await e.signalk.subscribe(Object.values(a),e=>{e.path===a.gpsTime?x.read(Date.now(),e.value):S.live(e.path,e.value),T()})}e().then(D).catch(e=>{console.warn(`clock: host connection failed`,e)});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./chunk-U7YORXZ7-BLTBSYrv.js";import{a as t,i as n,n as r,o as i,t as a}from"./clock-model-D8TrsRP6.js";import{i as o}from"./signalk-
|
|
1
|
+
import{t as e}from"./chunk-U7YORXZ7-BLTBSYrv.js";import{a as t,i as n,n as r,o as i,t as a}from"./clock-model-D8TrsRP6.js";import{i as o}from"./signalk-BOmj4E6B.js";/* empty css */var s=[{key:`zone`,title:`Time zone`,options:[[`local`,`This screen`],[`utc`,`UTC`],[`boat`,`Boat`]]},{key:`hours`,title:`Hours`,options:[[`24`,`24 h`],[`12`,`12 h`]]},{key:`seconds`,title:`Seconds`,options:[[!0,`Show`],[!1,`Hide`]]},{key:`showDate`,title:`Date`,options:[[!0,`Show`],[!1,`Hide`]]}];function c(e){let t=document.getElementById(e);if(!t)throw Error(`missing #${e}`);return t}function l(){let e=c(`label`);return e instanceof HTMLInputElement?e.value.trim():``}function u(e){return e.replace(/[&<>"]/g,e=>`&#${e.charCodeAt(0)};`)}async function d(){let d=c(`root`),f=await e();d.innerHTML=`<p class="status">Loading…</p>`;let p=i(await f.state.get()),m=new a,h=()=>{let e={...p,label:l()},r=n(Date.now(),e,m.zone()),i=p.showDate?`, ${u(r.date)}`:``;return`${u(t(e,r))}: ${u(r.time)}${i}`},g=()=>{c(`preview`).innerHTML=h()},_=()=>{d.innerHTML=`
|
|
2
2
|
${s.map(e=>`
|
|
3
3
|
<div class="row"><span>${e.title}</span><div class="chips">${e.options.map(([t,n],r)=>`<button type="button" class="chip${p[e.key]===t?` on`:``}" data-key="${e.key}" data-index="${r}">${n}</button>`).join(``)}</div></div>`).join(``)}
|
|
4
4
|
<label class="row"><span>Label</span>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./chunk-U7YORXZ7-BLTBSYrv.js";import{a as t,i as n,o as r,t as i}from"./config-model-BkGUzGeC.js";import{r as a,t as o}from"./signalk-
|
|
1
|
+
import{t as e}from"./chunk-U7YORXZ7-BLTBSYrv.js";import{a as t,i as n,o as r,t as i}from"./config-model-BkGUzGeC.js";import{r as a,t as o}from"./signalk-BOmj4E6B.js";import{t as s}from"./units-nn6bpgTR.js";/* empty css */function c(e){return e.replace(/[&<>"]/g,e=>`&#${e.charCodeAt(0)};`)}function l(e){let t=document.getElementById(e);if(!t)throw Error(`missing #${e}`);return t}function u(e){let t=l(e);if(t instanceof HTMLInputElement||t instanceof HTMLSelectElement)return t;throw Error(`#${e} is not a form field`)}function d(e,n,a){let o=i.map(t=>`<button type="button" class="chip${t.path===e.path?` on`:``}" data-path="${t.path}" title="${c(t.title)}">${t.label}</button>`).join(``),s=a.length>0?`History from ${c(a.join(`, `))}: the strip fills at once.`:`No history provider on the server: the strip fills from live data. Install one (for example KIP, signalk-parquet or signalk-to-influxdb2) to see the past window at once.`;return`
|
|
2
2
|
<div class="chips">${o}</div>
|
|
3
3
|
<label class="row"><span>Signal K path</span>
|
|
4
4
|
<input id="path" list="paths" value="${c(e.path)}" placeholder="Type to search…">
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./chunk-U7YORXZ7-BLTBSYrv.js";import{a as t,i as n,o as r,r as i,t as a}from"./depth-model-DGmfV7Y9.js";import{c as o,l as s,o as c,t as l}from"./series-DIfvccHD.js";import{n as u,t as d}from"./styles-CjtPzFRR.js";import{a as f,n as p}from"./signalk-BOmj4E6B.js";import{n as m,r as h}from"./units-nn6bpgTR.js";var g={card:`rgba(20, 26, 32, 0.78)`,waterTop:`rgba(41, 182, 246, 0.30)`,waterBottom:`rgba(13, 71, 161, 0.55)`,seabed:`#8d6e63`,seabedEdge:`#d7ccc8`,text:`#e8edf2`,muted:`#9fb3c4`,grid:`rgba(255, 255, 255, 0.22)`},_={card:`rgba(8, 0, 0, 0.85)`,waterTop:`rgba(40, 0, 0, 0.4)`,waterBottom:`rgba(60, 0, 0, 0.6)`,seabed:`#4a0c0c`,seabedEdge:`#b71c1c`,text:`#d32f2f`,muted:`#8e2424`,grid:`rgba(211, 47, 47, 0.3)`},v=`'Helvetica Neue', Arial, sans-serif`;function y(e,t){let n=Number.isInteger(t)?0:t*10===Math.round(t*10)?1:2;return e.toFixed(n)}function b(e,t,n,r){let a=r.palette;e.clearRect(0,0,t,n),e.fillStyle=a.card,e.beginPath(),e.roundRect(0,0,t,n,10),e.fill();let o=Math.max(4,Math.round(Math.min(t,n)*.05)),s=Math.max(8,Math.round(Math.min(t/18,n/9))),l=r.bands.reduce((e,t)=>Math.max(e,t.hi),0),u=i(l),d=[];for(let e=0;e<=u.max+u.step/1e3;e+=u.step)d.push(e);e.font=`${s}px ${v}`;let f=Math.ceil(Math.max(...d.map(t=>e.measureText(y(t,u.step)).width)))+4,p=o,m=t-o-f,h=o,g=n-o-s-2,_=m-p,b=g-h;if(_<10||b<10)return;let x=e=>m-e/r.windowMs*_,S=e=>h+Math.max(0,e)/u.max*b,C=e.createLinearGradient(0,h,0,g);C.addColorStop(0,a.waterTop),C.addColorStop(1,a.waterBottom),e.fillStyle=C,e.fillRect(p,h,_,b),e.fillStyle=a.seabed;for(let t of r.bands){let n=Math.max(p,x(t.ageEnd)),r=Math.min(m,x(t.ageStart));r<=p||e.fillRect(n,S(t.lo),r-n+.5,g-S(t.lo))}e.fillStyle=a.seabedEdge;for(let t of r.bands){let n=Math.max(p,x(t.ageEnd)),r=Math.min(m,x(t.ageStart));r<=p||e.fillRect(n,S(t.lo)-1,r-n+.5,2)}e.strokeStyle=a.grid,e.lineWidth=1,e.fillStyle=a.muted,e.textAlign=`left`,e.textBaseline=`middle`;let w=Math.ceil(s*1.3/(b/(d.length-1)));d.forEach((t,n)=>{let r=Math.round(S(t))+.5;t>0&&t<u.max&&(e.beginPath(),e.moveTo(p,r),e.lineTo(m,r),e.stroke()),n%w===0&&e.fillText(y(t,u.step),m+4,Math.min(Math.max(r,h+s/2),g))}),e.textAlign=`center`,e.textBaseline=`alphabetic`;for(let t of c(r.windowMs)){let i=Math.round(x(t.age))+.5;t.age<r.windowMs&&(e.beginPath(),e.moveTo(i,h),e.lineTo(i,g),e.stroke()),e.fillText(/h$/.test(t.label)?t.label:`${t.label} min`,Math.max(i,p+2*s),n-o)}e.strokeRect(p+.5,h+.5,_-1,b-1),e.save(),e.shadowColor=`rgba(0, 0, 0, 0.8)`,e.shadowBlur=4,e.textAlign=`left`,e.fillStyle=a.muted,e.font=`600 ${s}px ${v}`,e.fillText(r.title,p+o,h+o+s,_-2*o);let T=Math.round(Math.min(b*.38,_/4));e.font=`600 ${T}px ${v}`,e.fillStyle=a.text;let E=h+o+s+T;e.fillText(r.value,p+o,E);let D=e.measureText(r.value).width;e.font=`${s}px ${v}`,e.fillStyle=a.muted,e.fillText(r.symbol,p+o+D+4,E),e.restore(),r.bands.length===0&&(e.textAlign=`center`,e.fillText(r.message,p+_/2,h+b*.75,_-4))}var x=6e4,S=1e4,C=document.createElement(`canvas`);document.getElementById(`root`)?.append(C);var w,T=!1,E=0,D,O,k=!1;function A(e){let n=T?_:g,r=w;if(!r)return{title:`Depth`,value:`--`,symbol:``,windowMs:1,bands:[],message:``,palette:n};let i=r.display.conversion,a=(r.series.stats(e)?.bands??[]).map(e=>({...e,lo:m(e.lo,i),hi:m(e.hi,i)})),o=r.last&&e-r.last.time<x?r.last.value:void 0;return{title:t(r.path),value:o===void 0?`--`:m(o,i).toFixed(r.display.decimals),symbol:r.display.symbol,windowMs:r.series.windowMs,bands:a,message:r.loading?`Loading…`:`No depth yet`,palette:n}}function j(){k=!1;let e=C.getBoundingClientRect(),t=window.devicePixelRatio||1,n=Math.max(1,Math.round(e.width*t)),r=Math.max(1,Math.round(e.height*t));(C.width!==n||C.height!==r)&&(C.width=n,C.height=r);let i=C.getContext(`2d`);i&&(i.setTransform(t,0,0,t,0,0),b(i,e.width,e.height,A(Date.now())))}function M(){k||(k=!0,requestAnimationFrame(j))}async function N(e,t){let n=async t=>{let n=await o(e.path,e.series.windowMs,e.series.bucketMs,t);return e.loading=!1,n},r=t?await s(n,()=>w===e):await n(2e4)??[];if(w===e){for(let t of r)e.series.merge(t.time,t.min,t.max,t.avg);M()}}async function P(){let e=await Promise.all(a.map(e=>f(e.path)));return new Set(a.filter((t,n)=>typeof e[n]==`number`).map(e=>e.path))}async function F(e){let t=++E,i=r(await e.state.get()),a=n(i,i.path?new Set:await P()),o=await p(a);if(t!==E)return;let s={path:a,display:h({...o,units:o?.units??`m`},void 0,-1),series:new l(i.minutes*6e4,!1),loading:!0},c=await e.signalk.subscribe([a],e=>{if(typeof e.value!=`number`||!Number.isFinite(e.value))return;let t=Date.now();s.last={time:t,value:e.value},s.series.add(t,e.value),M()});if(t!==E){await c().catch(()=>void 0);return}let u=D;clearInterval(O),D=c,w=s,M(),O=setInterval(M,Math.max(1e3,s.series.bucketMs));let d=N(s,!0);u?.().catch(()=>void 0),await d}function I(e){F(e).catch(t=>{console.warn(`depth profile: loading settings failed, retrying`,t);let n=E;setTimeout(()=>{E===n&&I(e)},S)})}async function L(){let t=await e();u(t),new ResizeObserver(M).observe(C),await t.subscribe([`state.changed`],()=>{I(t)}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&w&&N(w,!1)}),await d(t,e=>{T=e,M()}).catch(e=>{console.warn(`depth profile: night mode unavailable`,e)}),I(t)}L().catch(e=>{console.warn(`depth profile: host connection failed`,e)});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{t as e}from"./chunk-U7YORXZ7-BLTBSYrv.js";import{i as t,n,o as r,s as i,t as a}from"./depth-model-DGmfV7Y9.js";import{i as o,n as s}from"./signalk-BOmj4E6B.js";import{n as c,r as l}from"./units-nn6bpgTR.js";/* empty css */function u(e){return e.replace(/[&<>"]/g,e=>`&#${e.charCodeAt(0)};`)}function d(e){let t=document.getElementById(e);if(!t)throw Error(`missing #${e}`);return t}async function f(){let e=new Map;return await Promise.all(a.map(async t=>{let[n,r]=await Promise.all([o(t.path),s(t.path)]);if(typeof n!=`number`||!Number.isFinite(n))return;let i=l({...r,units:r?.units??`m`},void 0,-1);e.set(t.path,`${c(n,i.conversion).toFixed(i.decimals)} ${i.symbol}`)})),e}async function p(){let o=d(`root`),s=await e();o.innerHTML=`<p class="status">Loading…</p>`;let[c,l]=await Promise.all([s.state.get(),f()]),p=r(c),m=t({...p,path:``},new Set(l.keys())),h=a.find(e=>e.path===m)?.label.toLowerCase()??``,g=()=>{let e=[{path:``,label:`Automatic (${h})`},...a.map(e=>({path:e.path,label:`${e.label} ${l.get(e.path)??`(none)`}`}))];o.innerHTML=`
|
|
2
|
+
<div class="row"><span>Depth</span><div class="chips">${e.map((e,t)=>`<button type="button" class="chip${e.path===p.path?` on`:``}" data-depth="${t}">${u(e.label)}</button>`).join(``)}</div></div>
|
|
3
|
+
<div class="row"><span>Window</span><div class="chips">${n.map(e=>`<button type="button" class="chip${e===p.minutes?` on`:``}" data-minutes="${e}">${i(e)}</button>`).join(``)}</div></div>
|
|
4
|
+
<p class="status">Automatic follows the depth below the surface when the server has it, else below the transducer or the keel.</p>
|
|
5
|
+
<p class="status" id="status"></p>
|
|
6
|
+
<div class="actions">
|
|
7
|
+
<button type="button" id="cancel">Cancel</button>
|
|
8
|
+
<button type="button" id="save" class="primary">Save</button>
|
|
9
|
+
</div>`;for(let t of o.querySelectorAll(`[data-depth]`))t.addEventListener(`click`,()=>{p.path=e[Number(t.dataset.depth)]?.path??``,g()});for(let e of o.querySelectorAll(`[data-minutes]`))e.addEventListener(`click`,()=>{p.minutes=Number(e.dataset.minutes),g()});d(`save`).addEventListener(`click`,()=>{s.state.set({...p}).then(()=>s.call(`ui.closePanel`)).catch(e=>{d(`status`).textContent=`Save failed: ${e instanceof Error?e.message:String(e)}`})}),d(`cancel`).addEventListener(`click`,()=>{s.call(`ui.closePanel`).catch(()=>void 0)})};g()}p().catch(e=>{let t=document.getElementById(`root`);t&&(t.textContent=`Host connection failed: ${e instanceof Error?e.message:String(e)}`)});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=[{path:`environment.depth.belowSurface`,label:`Below surface`},{path:`environment.depth.belowTransducer`,label:`Below transducer`},{path:`environment.depth.belowKeel`,label:`Below keel`}],t=[5,15,30,60,180,360,720,1440],n={path:``,minutes:30};function r(r){return{path:e.some(e=>e.path===r.path)?String(r.path):``,minutes:t.find(e=>e===r.minutes)??n.minutes}}function i(t,n){return t.path?t.path:e.find(e=>n.has(e.path))?.path??e[1].path}function a(t){let n=e.find(e=>e.path===t);return n?`Depth ${n.label.toLowerCase()}`:`Depth`}function o(e){return e<60?`${e} min`:`${e/60} h`}var s=4;function c(e){let t=Math.max(e*1.15,1),n=t/s,r=10**Math.floor(Math.log10(n)),i=[1,2,2.5,5,10].map(e=>e*r).find(e=>e>=n)??10*r;return{max:Math.ceil(t/i)*i,step:i}}export{a,i,t as n,r as o,c as r,o as s,e as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./chunk-U7YORXZ7-BLTBSYrv.js";import{n as t,t as n}from"./styles-CjtPzFRR.js";import{i as r,n as i}from"./signalk-BOmj4E6B.js";import{r as a}from"./steer-model-DA5-9SMr.js";import{a as o,i as s,n as c,o as l,r as u,s as d,t as f}from"./level-model-CINplXoI.js";import{n as p,r as m,t as h}from"./level-render-70t5D0u5.js";import{n as g,r as _}from"./units-nn6bpgTR.js";var v=12e4,y=5e3;function b(b){let x=f[b],S=document.createElement(`canvas`);document.getElementById(`root`)?.append(S);let C,w=!1,T=0,E,D=!1,O=(e,t,n=!0)=>e&&(!n||t-e.time<v)?e.value:void 0;function k(e){let t=w?p:h,n=C;if(!n?.config.path)return{title:x.noun,fraction:void 0,level:`ok`,valueText:`Not set up`,detailText:``,marks:[],kind:b,style:n?.config.style??`3d`,palette:t};let r=O(n.levelReading,e),i=O(n.detailReading,e,x.detailAges),a=n.config.showDetail&&r!==void 0&&i!==void 0?`${g(x.detail(r,i),n.detail.conversion).toFixed(n.detail.decimals)} ${n.detail.symbol}`.trim():``,o=n.config.showDetail?O(n.flowReading,e):void 0,s=o===void 0?void 0:{text:`${g(Math.abs(o),n.flow.conversion).toFixed(n.flow.decimals)} ${n.flow.symbol}`.trim(),direction:c(o)};return{title:n.title,fraction:r,level:r===void 0?`ok`:u(d(r,n.zones)),valueText:r===void 0?`--`:`${g(r,n.level.conversion).toFixed(n.level.decimals)} ${n.level.symbol}`.trim(),detailText:a,flow:s,marks:l(n.zones),kind:b,style:n.config.style,palette:t}}function A(){D=!1;let e=S.getBoundingClientRect(),t=window.devicePixelRatio||1,n=Math.max(1,Math.round(e.width*t)),r=Math.max(1,Math.round(e.height*t));(S.width!==n||S.height!==r)&&(S.width=n,S.height=r);let i=S.getContext(`2d`);i&&(i.setTransform(t,0,0,t,0,0),m(i,e.width,e.height,k(Date.now())))}function j(){D||(D=!0,requestAnimationFrame(A))}async function M(e){let t=++T,n=s(await e.state.get()),c=x.matches(n.path),l=c?x.detailPath(n.path):void 0,u=c?x.flowPath?.(n.path):void 0,[d,f,p,m]=n.path?await Promise.all([i(n.path),l?i(l):void 0,l&&!x.detailAges?r(l):void 0,u?i(u):void 0]):[void 0,void 0,void 0,void 0];if(t!==T)return;let h={config:n,title:n.label||d?.displayName||x.name(n.path),zones:o(d?.zones),level:_({...d,units:d?.units??`ratio`},`percent`,0),detail:_({...f,units:f?.units??x.detailUnits},void 0,x.detailDecimals),flow:_({...m,units:m?.units??`A`},void 0,1)};typeof p==`number`&&Number.isFinite(p)&&(h.detailReading={time:Date.now(),value:p});let g;if(n.path){let r=[n.path,l,u].filter(e=>e!==void 0),i=new a;if(g=await e.signalk.subscribe(r,e=>{if(typeof e.value!=`number`||!Number.isFinite(e.value))return;let t={time:i.local(Date.now(),e.timestamp),value:e.value};e.path===n.path?h.levelReading=t:e.path===u?h.flowReading=t:h.detailReading=t,j()}),t!==T){await g().catch(()=>void 0);return}}let v=E;E=g,C=h,j(),await v?.().catch(()=>void 0)}async function N(){let r=await e();t(r),new ResizeObserver(j).observe(S),setInterval(j,y),await r.subscribe([`state.changed`],()=>{M(r).catch(e=>{console.warn(`${b}: settings reload failed`,e)})}),await n(r,e=>{w=e,j()}).catch(e=>{console.warn(`${b}: night mode unavailable`,e)}),await M(r)}N().catch(e=>{console.warn(`${b}: host connection failed`,e)})}export{b as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./chunk-U7YORXZ7-BLTBSYrv.js";import{r as t}from"./signalk-
|
|
1
|
+
import{t as e}from"./chunk-U7YORXZ7-BLTBSYrv.js";import{r as t}from"./signalk-BOmj4E6B.js";import{i as n,t as r}from"./level-model-CINplXoI.js";import{n as i,r as a}from"./units-nn6bpgTR.js";/* empty css */function o(e){return e.replace(/[&<>"]/g,e=>`&#${e.charCodeAt(0)};`)}function s(e){let t=document.getElementById(e);if(!t)throw Error(`missing #${e}`);return t}function c(e){let t=s(e);if(t instanceof HTMLInputElement)return t;throw Error(`#${e} is not an input`)}var l=a({units:`ratio`},`percent`,0);function u(e,t,n){let r=e.matches(t.path)?t.displayName||e.name(t.path):t.path;return`<button type="button" class="pick${t.path===n?` on`:``}" aria-pressed="${t.path===n}" data-path="${o(t.path)}" title="${o(t.path)}">
|
|
2
2
|
<span class="name">${o(r)}</span>
|
|
3
3
|
<span class="reading">${i(t.value,l.conversion).toFixed(l.decimals)} ${l.symbol}</span>
|
|
4
4
|
</button>`}function d(e,t,n,r){return n.length===0?``:`<div class="section-title">${t}</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={card:`rgba(20, 26, 32, 0.78)`,text:`#e8edf2`,muted:`#9fb3c4`,glass:`rgba(255, 255, 255, 0.07)`,glassEdge:`rgba(207, 216, 220, 0.75)`,glint:`rgba(255, 255, 255, 0.28)`,liquid:{ok:{edge:`#1b5e20`,middle:`#66bb6a`,surface:`#a5d6a7`},warn:{edge:`#e65100`,middle:`#fdd835`,surface:`#fff59d`},alarm:{edge:`#7f0000`,middle:`#e53935`,surface:`#ef9a9a`}},mark:{ok:`#66bb6a`,warn:`#fdd835`,alarm:`#e53935`}},t={card:`rgba(8, 0, 0, 0.85)`,text:`#d32f2f`,muted:`#8e2424`,glass:`rgba(120, 20, 20, 0.08)`,glassEdge:`rgba(110, 24, 24, 0.9)`,glint:`rgba(160, 40, 40, 0.18)`,liquid:{ok:{edge:`#0b2a0d`,middle:`#2e5d31`,surface:`#3d7340`},warn:{edge:`#3d2600`,middle:`#7a6a10`,surface:`#8f7d1c`},alarm:{edge:`#3a0000`,middle:`#8e1b1b`,surface:`#b02a2a`}},mark:{ok:`#2e5d31`,warn:`#7a6a10`,alarm:`#b02a2a`}};function n(e,t,n,r,i,a){e.beginPath(),e.moveTo(t+a,n),e.arcTo(t+r,n,t+r,n+i,a),e.arcTo(t+r,n+i,t,n+i,a),e.arcTo(t,n+i,t,n,a),e.arcTo(t,n,t+r,n,a),e.closePath()}function r(e,t,n,r,i=``){let a=n;for(e.font=`${i} ${a}px 'Helvetica Neue', Arial, sans-serif`;a>8&&e.measureText(t).width>r;)--a,e.font=`${i} ${a}px 'Helvetica Neue', Arial, sans-serif`}function i(e,t,n,r,i,a){e.beginPath(),e.moveTo(t-n,i),e.lineTo(t-n,a),e.ellipse(t,a,n,r,0,Math.PI,0,!0),e.lineTo(t+n,i),e.ellipse(t,i,n,r,0,0,Math.PI,!1),e.closePath()}function a(e,t,n,r,i){let a=e.createLinearGradient(t-n,0,t+n,0);return a.addColorStop(0,r),a.addColorStop(.35,i),a.addColorStop(.55,i),a.addColorStop(1,r),a}function o(e,t){return e.bottom-Math.min(1,Math.max(0,t))*(e.bottom-e.top)}function s(e,t,n){let r=n.palette,{cx:s,rx:c,top:l,bottom:u}=t,d=c*.22;if(i(e,s,c,d,l,u),e.fillStyle=r.glass,e.fill(),n.fraction!==void 0){let l=r.liquid[n.level],f=o(t,n.fraction);i(e,s,c,d,f,u),e.fillStyle=a(e,s,c,l.edge,l.middle),e.fill(),e.beginPath(),e.ellipse(s,f,c,d,0,0,Math.PI*2),e.fillStyle=l.surface,e.fill()}let f=e.createLinearGradient(s-c*.7,0,s-c*.35,0);if(f.addColorStop(0,`rgba(255, 255, 255, 0)`),f.addColorStop(.5,r.glint),f.addColorStop(1,`rgba(255, 255, 255, 0)`),e.fillStyle=f,e.fillRect(s-c*.7,l+d,c*.35,u-l-d),e.lineWidth=Math.max(1,c*.04),e.strokeStyle=r.glassEdge,i(e,s,c,d,l,u),e.stroke(),e.beginPath(),e.ellipse(s,l,c,d,0,0,Math.PI*2),e.stroke(),n.kind===`battery`){let t=c*.32,n=t*.22,o=c*.22;i(e,s,t,n,l-o,l),e.fillStyle=a(e,s,t,r.glassEdge,r.text),e.fill(),e.beginPath(),e.ellipse(s,l-o,t,n,0,0,Math.PI*2),e.fillStyle=r.text,e.fill()}}function c(e,t,r){let i=r.palette,{cx:a,rx:s,top:c,bottom:l}=t,u=Math.min(s*.25,8),d=Math.max(1,s*.04);if(n(e,a-s,c,2*s,l-c,u),e.fillStyle=i.glass,e.fill(),r.fraction!==void 0){let d=o(t,r.fraction);e.save(),n(e,a-s,c,2*s,l-c,u),e.clip(),e.fillStyle=i.liquid[r.level].middle,e.fillRect(a-s,d,2*s,l-d),e.restore()}if(e.lineWidth=d,e.strokeStyle=i.glassEdge,n(e,a-s,c,2*s,l-c,u),e.stroke(),r.kind===`battery`){let t=s*.6,r=s*.18;n(e,a-t/2,c-r,t,r,Math.min(r/2,3)),e.fillStyle=i.glassEdge,e.fill()}}function l(e,t,n,i,a,o,s){let c=t.direction===`idle`?0:a*.7,l=c?a*.3:0;r(e,t.text,a,o-c-l,`bold`);let u=n-(c+l+e.measureText(t.text).width)/2;if(e.fillStyle=t.direction===`charging`?s.mark.ok:t.direction===`discharging`?s.mark.alarm:s.muted,c){let n=i-a*.8,r=t.direction===`charging`?n:i,o=t.direction===`charging`?i:n;e.beginPath(),e.moveTo(u+c/2,r),e.lineTo(u+c,o),e.lineTo(u,o),e.closePath(),e.fill()}e.textAlign=`left`,e.fillText(t.text,u+c+l,i),e.textAlign=`center`}function u(e,t,i,a){let u=a.palette;e.clearRect(0,0,t,i),n(e,0,0,t,i,Math.min(10,t/10)),e.fillStyle=u.card,e.fill();let d=Math.max(6,Math.min(t,i)*.06),f=t>=i*.8,p=Math.max(10,Math.min(t*.11,i*(f?.1:.06))),m=Math.max(14,f?Math.min(t*.17,i*.2):Math.min(t*.2,i*.11)),h=Math.max(9,m*.5);e.textAlign=`center`,e.textBaseline=`top`,e.fillStyle=u.muted,r(e,a.title,p,t-2*d),e.fillText(a.title,t/2,d);let g=h*1.2,_=(+!!a.detailText+ +!!a.flow)*g,v=f?0:m+_+d,y=d+p*1.5,b=i-v-d*.5,x=Math.min(f?t*.15:t*.27,(b-y)*.4),S=x*(a.style===`3d`?.22:0)+(a.kind===`battery`?x*.22:0),C={cx:f?d+x:t/2-x*.15,rx:x,top:y+S,bottom:b-(a.style===`3d`?x*.22:0)};if(C.bottom-C.top<4)return;a.style===`flat`?c(e,C,a):s(e,C,a);let w=C.cx+x+Math.max(3,x*.12),T=e=>o(C,e);e.lineCap=`round`,e.strokeStyle=u.muted,e.lineWidth=Math.max(1,x*.03);for(let t of[.25,.5,.75])e.beginPath(),e.moveTo(w,T(t)),e.lineTo(w+x*.18,T(t)),e.stroke();e.lineWidth=Math.max(2,x*.09);for(let t of a.marks)e.strokeStyle=u.mark[t.level],e.beginPath(),e.moveTo(w,T(t.at)),e.lineTo(w+x*.32,T(t.at)),e.stroke();let E=f?w+x*.32+d*.5:d,D=t-d-E,O=E+D/2,k=m+_,A=f?(y+b+k)/2:i-d;e.textBaseline=`alphabetic`,e.fillStyle=a.fraction===void 0?u.muted:u.text,r(e,a.valueText,m,D,`bold`);let j=A-_;e.fillText(a.valueText,O,j),a.detailText&&(j+=g,e.fillStyle=u.muted,r(e,a.detailText,h,D),e.fillText(a.detailText,O,j)),a.flow&&l(e,a.flow,O,j+g,h,D,u)}export{t as n,u as r,e as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./chunk-U7YORXZ7-BLTBSYrv.js";import{n as t,t as n}from"./styles-CjtPzFRR.js";import{n as r}from"./signalk-BOmj4E6B.js";import{r as i}from"./steer-model-DA5-9SMr.js";import{n as a,t as o}from"./level-render-70t5D0u5.js";import{a as s,c,i as l,n as u,o as d,r as f,s as p,t as m}from"./pi-model-DtR5ejzZ.js";import{n as h,r as g}from"./units-nn6bpgTR.js";var _=`'Helvetica Neue', Arial, sans-serif`;function v(e,t,n,r,i=``){let a=Math.floor(n);for(e.font=`${i} ${a}px ${_}`;a>7&&e.measureText(t).width>r;)--a,e.font=`${i} ${a}px ${_}`}function y(e,t,n){return n?t===`ok`?e.text:e.mark[t]:e.muted}function b(e,t,n,r){let i=r.palette;e.clearRect(0,0,t,n),e.fillStyle=i.card,e.beginPath(),e.roundRect(0,0,t,n,Math.min(10,t/10)),e.fill();let a=Math.max(5,Math.min(t,n)*.07),o=t-2*a,s=Math.max(9,n*.12),c=(n-2*a)*(r.bars.length>2?.17:.2),l=n-a-c*r.bars.length;e.textAlign=`center`,e.textBaseline=`top`,e.fillStyle=r.warning?i.mark.alarm:i.muted;let u=r.warning??r.title;v(e,u,s,o,r.warning?`bold`:``),e.fillText(u,t/2,a);let d=a+s*1.15,f=(l-d)*.9;e.textBaseline=`middle`,e.fillStyle=y(i,r.temperature.level,r.temperature.known),v(e,r.temperature.text,f,o,`bold`),e.fillText(r.temperature.text,t/2,(d+l)/2+f*.04);let p=c*.5;e.font=`${p}px ${_}`;let m=Math.max(...r.bars.map(t=>e.measureText(t.label).width),0);e.font=`bold ${p}px ${_}`;let h=e.measureText(`100 %`).width,g=a*.4,b=a+m+g,x=Math.max(4,o-m-h-2*g),S=Math.max(3,c*.42);for(let[n,o]of r.bars.entries()){let r=l+c*(n+.5);if(e.textAlign=`left`,e.fillStyle=i.muted,e.font=`${p}px ${_}`,e.fillText(o.label,a,r),e.fillStyle=i.glass,e.beginPath(),e.roundRect(b,r-S/2,x,S,S/2),e.fill(),o.fraction!==void 0){let t=Math.max(S,x*Math.min(1,Math.max(0,o.fraction)));e.fillStyle=i.liquid[o.level].middle,e.beginPath(),e.roundRect(b,r-S/2,t,S,S/2),e.fill()}e.textAlign=`right`,e.fillStyle=y(i,o.level,o.fraction!==void 0),v(e,o.text,p,h,`bold`),e.fillText(o.text,t-a,r)}}var x=12e4,S=5e3,C=Object.keys(u),w=g({units:`ratio`},`percent`,0),T=document.createElement(`canvas`);document.getElementById(`root`)?.append(T);var E=d({}),D=!1,O=g({units:`K`},void 0,0),k=Object.fromEntries(C.map(e=>[e,c(e,void 0)])),A=new Map,j=new Map,M=!1;function N(e,t){let n=A.get(e);return n&&t-n.time<x?n.value:void 0}function P(e){let t=N(u.temperature,e),n=l(E).map(t=>{let n=N(u[t],e);return{label:m[t],fraction:n,text:n===void 0?`--`:`${h(n,w.conversion).toFixed(w.decimals)} ${w.symbol}`,level:n===void 0?`ok`:s(n,k[t])}}),r=t=>{let n=j.get(t);return n!==void 0&&e-n.time<x&&n.on};return{title:E.label||`System`,warning:p({underVoltage:r(f.underVoltage),throttled:r(f.throttled)}),temperature:{text:t===void 0?`--`:`${h(t,O.conversion).toFixed(O.decimals)}${O.symbol}`,level:t===void 0?`ok`:s(t,k.temperature),known:t!==void 0},bars:n,palette:D?a:o}}function F(){M=!1;let e=T.getBoundingClientRect(),t=window.devicePixelRatio||1,n=Math.max(1,Math.round(e.width*t)),r=Math.max(1,Math.round(e.height*t));(T.width!==n||T.height!==r)&&(T.width=n,T.height=r);let i=T.getContext(`2d`);i&&(i.setTransform(t,0,0,t,0,0),b(i,e.width,e.height,P(Date.now())))}function I(){M||(M=!0,requestAnimationFrame(F))}async function L(){let e=await Promise.all(C.map(e=>r(u[e])));for(let[t,n]of C.entries())k[n]=c(n,e[t]?.zones);let t=e[C.indexOf(`temperature`)];O=g({...t,units:`K`},void 0,0),I()}async function R(e){t(e),new ResizeObserver(I).observe(T),setInterval(I,S);let r=()=>e.state.get().then(e=>{E=d(e),I()}).catch(e=>{console.warn(`system: settings unavailable`,e)});await e.subscribe([`state.changed`],()=>{r()}),await n(e,e=>{D=e,I()}).catch(e=>{console.warn(`system: night mode unavailable`,e)}),await r(),L();let a=new i,o=Object.values(f);await e.signalk.subscribe([...Object.values(u),...o],e=>{let t=a.local(Date.now(),e.timestamp);o.includes(e.path)?typeof e.value==`boolean`&&j.set(e.path,{time:t,on:e.value}):typeof e.value==`number`&&Number.isFinite(e.value)?A.set(e.path,{time:t,value:e.value}):A.delete(e.path),I()})}e().then(R).catch(e=>{console.warn(`system: host connection failed`,e)});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import{t as e}from"./chunk-U7YORXZ7-BLTBSYrv.js";import{o as t}from"./pi-model-DtR5ejzZ.js";/* empty css */function n(e){let t=document.getElementById(e);if(!t)throw Error(`missing #${e}`);return t}function r(e){return e.replace(/[&<>"]/g,e=>`&#${e.charCodeAt(0)};`)}async function i(){let i=n(`root`),a=await e();i.innerHTML=`<p class="status">Loading…</p>`;let o=t(await a.state.get()),{showStorage:s}=o;i.innerHTML=`
|
|
2
|
+
<div class="section-title">Storage</div>
|
|
3
|
+
<div class="chips">
|
|
4
|
+
<button type="button" class="chip" data-storage="true">Show</button>
|
|
5
|
+
<button type="button" class="chip" data-storage="false">Hide</button>
|
|
6
|
+
</div>
|
|
7
|
+
<label class="row"><span>Label</span>
|
|
8
|
+
<input id="label" value="${r(o.label)}" placeholder="System">
|
|
9
|
+
</label>
|
|
10
|
+
<p class="status">Readings come from signalk-rpi-stats. They turn yellow from 70 °C, 80 % CPU or RAM and 85 % storage, and red from 80 °C, 95 % CPU, 90 % RAM and 95 % storage, unless the path's metadata sets its own zones.</p>
|
|
11
|
+
<p class="status" id="status"></p>
|
|
12
|
+
<div class="actions">
|
|
13
|
+
<button type="button" id="cancel">Cancel</button>
|
|
14
|
+
<button type="button" id="save" class="primary">Save</button>
|
|
15
|
+
</div>`;let c=i.querySelectorAll(`[data-storage]`),l=()=>{for(let e of c){let t=e.dataset.storage===String(s);e.classList.toggle(`on`,t),e.setAttribute(`aria-pressed`,String(t))}};for(let e of c)e.addEventListener(`click`,()=>{s=e.dataset.storage===`true`,l()});l(),n(`save`).addEventListener(`click`,()=>{let e=n(`label`),t=e instanceof HTMLInputElement?e.value.trim():``;a.state.set({label:t,showStorage:s}).then(()=>a.call(`ui.closePanel`)).catch(e=>{n(`status`).textContent=`Save failed: ${e instanceof Error?e.message:String(e)}`})}),n(`cancel`).addEventListener(`click`,()=>{a.call(`ui.closePanel`).catch(()=>void 0)})}i().catch(e=>{let t=document.getElementById(`root`);t&&(t.textContent=`Host connection failed: ${e instanceof Error?e.message:String(e)}`)});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,r as t,s as n}from"./level-model-CINplXoI.js";var r=`environment.rpi`,i={temperature:`${r}.cpu.temperature`,cpu:`${r}.cpu.utilisation`,memory:`${r}.memory.utilisation`,storage:`${r}.storage.utilisation`},a={underVoltage:`${r}.throttling.underVoltage`,throttled:`${r}.throttling.throttled`},o={temperature:[{lower:343.15,upper:353.15,state:`warn`},{lower:353.15,state:`alarm`}],cpu:[{lower:.8,upper:.95,state:`warn`},{lower:.95,state:`alarm`}],memory:[{lower:.8,upper:.9,state:`warn`},{lower:.9,state:`alarm`}],storage:[{lower:.85,upper:.95,state:`warn`},{lower:.95,state:`alarm`}]};function s(t,n){let r=e(n);return r.length>0?r:o[t]}function c(e,r){return t(n(e,r))}var l={label:``,showStorage:!1};function u(e){let t=typeof e==`object`&&e?e:{};return{label:typeof t.label==`string`?t.label:l.label,showStorage:typeof t.showStorage==`boolean`?t.showStorage:l.showStorage}}function d(e){return e.showStorage?[`cpu`,`memory`,`storage`]:[`cpu`,`memory`]}var f={cpu:`CPU`,memory:`RAM`,storage:`Disk`};function p(e){if(e.underVoltage)return`Low voltage`;if(e.throttled)return`Throttled`}export{c as a,s as c,d as i,i as n,u as o,a as r,p as s,f as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,t,n,r){return`/signalk/v2/api/history/values?${new URLSearchParams({paths:(r?[`min`,`max`,`average`]:[`average`]).map(t=>`${e}:${t}`).join(`,`),duration:String(Math.ceil(t/1e3)),resolution:String(Math.max(1,Math.round(n/1e3)))}).toString()}`}function t(e,t){let n=n=>e.values.findIndex(e=>e.path===t&&e.method===n),r=n(`average`);if(r<0)return[];let i=n(`min`),a=n(`max`),o=[];for(let t of e.data){let e=Date.parse(t[0]),n=t[r+1];if(Number.isNaN(e)||typeof n!=`number`)continue;let s=i<0?n:t[i+1],c=a<0?n:t[a+1];o.push({time:e,avg:n,min:typeof s==`number`?s:n,max:typeof c==`number`?c:n})}return o}var n=2e4;function r(e){if(typeof e!=`object`||!e)return!1;let t=e;return Array.isArray(t.values)&&Array.isArray(t.data)}async function i(i,a,o,s=n,c=fetch){let l=AbortSignal.timeout(s);for(let n of[!0,!1])try{let s=await c(e(i,a,o,n),{credentials:`include`,signal:l});if(s.status===404)return[];if(s.status>=500)return;if(!s.ok){if(n&&s.status===400)continue;return[]}let u=await s.json();if(r(u))return t(u,i)}catch(e){return console.warn(`history query failed`,e),e instanceof SyntaxError?[]:void 0}return[]}var a=e=>new Promise(t=>setTimeout(t,e));async function o(e,t,r=a,i=Date.now){let o=i()+6e5,s=1e4;for(;;){let a=await e(Math.max(1,Math.min(n,o-i())));if(a)return a;let c=o-i();if(c<=0||!t()||(await r(Math.min(s,c)),!t()||o-i()<=0))return[];s=Math.min(6e4,s*2)}}var s={card:`rgba(20, 26, 32, 0.78)`,text:`#e8edf2`,muted:`#9fb3c4`,bar:`#29b6f6`,avg:`#ef5350`,grid:`rgba(255, 255, 255, 0.22)`},c={card:`rgba(8, 0, 0, 0.85)`,text:`#d32f2f`,muted:`#8e2424`,bar:`#7f1212`,avg:`#ff5252`,grid:`rgba(211, 47, 47, 0.3)`},l=[1,2,5,10,15,20,30,60,120,180,240,360,720,1440],u=4;function d(e){let t=e/6e4,n=l.find(e=>t/e<=u)??Math.ceil(t/u/1440)*1440,r=t>120,i=[];for(let e=n;e<=t+1e-9;e+=n)i.push({age:e*6e4,label:r?`${+(e/60).toFixed(1)}h`:`${e}`});return i}function f(e,t){let n=e.min,r=e.max;if(r-n<t){let e=(r+n)/2;n=e-t/2,r=e+t/2}let i=(r-n)*.05;return{lo:n-i,hi:r+i}}function p(e,t,n,r,i=``){let a=r;for(e.font=`${i} ${a}px 'Helvetica Neue', Arial, sans-serif`;a>7&&e.measureText(t).width>n;)a--,e.font=`${i} ${a}px 'Helvetica Neue', Arial, sans-serif`;return a}function m(e,t,n,r){let i=r.palette,a=Math.max(4,Math.round(t*.05));e.clearRect(0,0,t,n),e.fillStyle=i.card,e.beginPath(),e.roundRect(0,0,t,n,10),e.fill(),e.textBaseline=`alphabetic`;let o=t-2*a,s=Math.max(8,Math.round(Math.min(t/9,n/18)));e.fillStyle=i.muted,e.font=`600 ${s}px 'Helvetica Neue', Arial, sans-serif`,e.textAlign=`left`;let c=a+s;e.fillText(r.label,a,c,o*.7),e.textAlign=`right`,e.fillText(r.symbol,t-a,c,o*.3);let l=p(e,r.value,o,Math.round(Math.min(t/3.2,n/7)),`600`);e.fillStyle=i.text,e.textAlign=`center`,c+=l+2,e.fillText(r.value,t/2,c);let u=p(e,`${r.min} ${r.avg} ${r.max}`,o,s);e.font=`${u}px 'Helvetica Neue', Arial, sans-serif`,c+=u+4,e.textAlign=`left`,e.fillStyle=i.muted,e.fillText(r.min,a,c),e.textAlign=`right`,e.fillText(r.max,t-a,c),e.textAlign=`center`,e.fillStyle=i.avg,e.fillText(r.avg,t/2,c);let m=Math.max(7,s-2);e.font=`${m}px 'Helvetica Neue', Arial, sans-serif`;let h=d(r.windowMs),g=Math.ceil(Math.max(...h.map(t=>e.measureText(t.label).width),0))+3,_=c+4,v=a,y=t-a-g,b=n-a,x=b-_,S=y-v;if(x<10||S<10)return;e.strokeStyle=i.grid,e.lineWidth=1,e.strokeRect(v+.5,_+.5,S-1,x-1);let C=e=>_+e/r.windowMs*x;e.fillStyle=i.muted,e.textAlign=`left`,e.textBaseline=`middle`;for(let t of h){let n=Math.round(C(t.age))+.5;t.age<r.windowMs&&(e.beginPath(),e.moveTo(v,n),e.lineTo(y,n),e.stroke()),e.fillText(t.label,y+3,Math.min(n,b-m/2))}if(!r.stats){r.message&&(e.textAlign=`center`,e.fillStyle=i.muted,e.fillText(r.message,v+S/2,_+x/2,S-4));return}let w=f(r.stats,r.minSpan),T=e=>v+(e-w.lo)/(w.hi-w.lo)*S;e.fillStyle=i.bar;for(let t of r.stats.bands){let n=C(t.ageStart),r=Math.min(b,C(t.ageEnd));if(r<=_)continue;let i=T(t.lo),a=Math.max(i+2,T(t.hi)),o=Math.max(_,n);e.fillRect(i,o,a-i,Math.max(1,r-o)+.5)}let E=Math.round(T(r.stats.avg))+.5;e.strokeStyle=i.avg,e.beginPath(),e.moveTo(E,_),e.lineTo(E,b),e.stroke()}var h=2*Math.PI;function g(e){let t=((e+Math.PI)%h+h)%h;return t===0?Math.PI:t-Math.PI}var _=class{windowMs;bucketMs;angular;buckets=new Map;constructor(e,t,n=240){this.windowMs=e,this.bucketMs=e/n,this.angular=t}get size(){return this.buckets.size}add(e,t){this.merge(e,t,t,t)}merge(e,t,n,r){if(![e,t,n,r].every(Number.isFinite))return;let i=Math.floor(e/this.bucketMs),a=this.buckets.get(i);if(a||(a={index:i,ref:this.angular?r:0,lo:1/0,hi:-1/0,sum:0,sin:0,cos:0,n:0},this.buckets.set(i,a)),this.angular){let e=g(r-a.ref),i=g(t-r),o=g(n-r);a.lo=Math.min(a.lo,e+Math.min(0,i,o)),a.hi=Math.max(a.hi,e+Math.max(0,i,o)),a.sin+=Math.sin(r),a.cos+=Math.cos(r)}else a.lo=Math.min(a.lo,t,r),a.hi=Math.max(a.hi,n,r),a.sum+=r;a.n++}prune(e){let t=Math.floor((e-this.windowMs)/this.bucketMs);for(let e of this.buckets.keys())e<t&&this.buckets.delete(e)}clear(){this.buckets.clear()}stats(e){this.prune(e);let t=[...this.buckets.values()].filter(e=>e.n>0);if(t.length===0)return;let n=0;if(this.angular){let e=0,r=0;for(let n of t){let t=Math.atan2(n.sin,n.cos);e+=Math.sin(t),r+=Math.cos(t)}n=Math.atan2(e,r)}let r=1/0,i=-1/0,a=0,o=[];for(let s of t){let t=this.angular?g(s.ref-n):0,c=s.lo+t,l=s.hi+t;r=Math.min(r,c),i=Math.max(i,l),this.angular||(a+=s.sum/s.n);let u=s.index*this.bucketMs;o.push({ageStart:Math.max(0,e-(u+this.bucketMs)),ageEnd:Math.max(0,e-u),lo:c,hi:l})}return{centre:n,min:r,max:i,avg:this.angular?0:a/t.length,bands:o}}};export{m as a,i as c,c as i,o as l,g as n,d as o,s as r,n as s,_ as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){return typeof e==`object`&&!!e}async function t(t){try{let n=await fetch(`/signalk/v1/api/vessels/self/${t.replace(/\./g,`/`)}/meta`,{credentials:`include`});if(!n.ok)return;let r=await n.json();if(!e(r))return;let i={};typeof r.units==`string`&&(i.units=r.units),typeof r.displayName==`string`&&(i.displayName=r.displayName),Array.isArray(r.zones)&&(i.zones=r.zones);let a=r.displayUnits;return e(a)&&(i.displayUnits={},typeof a.targetUnit==`string`&&(i.displayUnits.targetUnit=a.targetUnit),typeof a.displayFormat==`string`&&(i.displayUnits.displayFormat=a.displayFormat)),i}catch{return}}function n(t,r=``,i=[]){if(!e(t))return i;if(`value`in t){if(typeof t.value==`number`){let n=t.meta;i.push({path:r,units:e(n)&&typeof n.units==`string`?n.units:void 0,value:t.value,displayName:e(n)&&typeof n.displayName==`string`?n.displayName:void 0})}return i}for(let[e,a]of Object.entries(t))e!==`meta`&&e!==`$source`&&e!==`timestamp`&&e!==`values`&&n(a,r?`${r}.${e}`:e,i);return i}async function r(){try{let e=await fetch(`/signalk/v1/api/vessels/self`,{credentials:`include`});return e.ok?n(await e.json()).sort((e,t)=>e.path.localeCompare(t.path)):[]}catch{return[]}}async function i(){try{let t=await fetch(`/signalk/v2/api/history/_providers`,{credentials:`include`});if(!t.ok)return[];let n=await t.json();return e(n)?Object.keys(n):[]}catch{return[]}}async function a(e){
|
|
1
|
+
function e(e){return typeof e==`object`&&!!e}async function t(t){try{let n=await fetch(`/signalk/v1/api/vessels/self/${t.replace(/\./g,`/`)}/meta`,{credentials:`include`});if(!n.ok)return;let r=await n.json();if(!e(r))return;let i={};typeof r.units==`string`&&(i.units=r.units),typeof r.displayName==`string`&&(i.displayName=r.displayName),Array.isArray(r.zones)&&(i.zones=r.zones);let a=r.displayUnits;return e(a)&&(i.displayUnits={},typeof a.targetUnit==`string`&&(i.displayUnits.targetUnit=a.targetUnit),typeof a.displayFormat==`string`&&(i.displayUnits.displayFormat=a.displayFormat)),i}catch{return}}function n(t,r=``,i=[]){if(!e(t))return i;if(`value`in t){if(typeof t.value==`number`){let n=t.meta;i.push({path:r,units:e(n)&&typeof n.units==`string`?n.units:void 0,value:t.value,displayName:e(n)&&typeof n.displayName==`string`?n.displayName:void 0})}return i}for(let[e,a]of Object.entries(t))e!==`meta`&&e!==`$source`&&e!==`timestamp`&&e!==`values`&&n(a,r?`${r}.${e}`:e,i);return i}async function r(){try{let e=await fetch(`/signalk/v1/api/vessels/self`,{credentials:`include`});return e.ok?n(await e.json()).sort((e,t)=>e.path.localeCompare(t.path)):[]}catch{return[]}}async function i(){try{let t=await fetch(`/signalk/v2/api/history/_providers`,{credentials:`include`});if(!t.ok)return[];let n=await t.json();return e(n)?Object.keys(n):[]}catch{return[]}}async function a(e){let t=await fetch(`/signalk/v1/api/vessels/self/${e.replace(/\./g,`/`)}/value`,{credentials:`include`});if(t.status>=500)throw Error(`${e}: HTTP ${t.status}`);if(t.ok)return await t.json()}async function o(e){try{return await a(e)}catch{return}}export{a,o as i,t as n,r,i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./chunk-U7YORXZ7-BLTBSYrv.js";import{n as t,t as n}from"./styles-CjtPzFRR.js";import{n as r}from"./signalk-
|
|
1
|
+
import{t as e}from"./chunk-U7YORXZ7-BLTBSYrv.js";import{n as t,t as n}from"./styles-CjtPzFRR.js";import{n as r}from"./signalk-BOmj4E6B.js";import{a as i,c as a,d as o,i as s,l as c,n as l,o as u,r as d,s as f,u as p}from"./steer-model-DA5-9SMr.js";import{n as m,r as h}from"./units-nn6bpgTR.js";var g={card:`rgba(20, 26, 32, 0.78)`,ring:`#cfd8dc`,ringText:`#1d2329`,text:`#e8edf2`,muted:`#9fb3c4`,port:`#e53935`,starboard:`#43a047`,apparent:`#29b6f6`,trueWind:`#ffa726`,shift:`rgba(255, 167, 38, 0.28)`,waypoint:`#ab47bc`,course:`#ec407a`,current:`#26c6da`},_={card:`rgba(8, 0, 0, 0.85)`,ring:`#4a0c0c`,ringText:`#d32f2f`,text:`#d32f2f`,muted:`#8e2424`,port:`#b71c1c`,starboard:`#7f1212`,apparent:`#ff5252`,trueWind:`#d32f2f`,shift:`rgba(211, 47, 47, 0.22)`,waypoint:`#c62828`,course:`#e57373`,current:`#ef9a9a`},v=Math.PI/180,y=35*v,b=`'Helvetica Neue', Arial, sans-serif`;function x(e,t,n){return[e.cx+n*Math.sin(t),e.cy-n*Math.cos(t)]}function S(e){return e-Math.PI/2}function C(e,t){return o(t-e)}function ee(e,t,n){let r=n.palette,i=t.r-t.band/2;e.lineWidth=t.band,e.strokeStyle=r.ring,e.beginPath(),e.arc(t.cx,t.cy,i,0,2*Math.PI),e.stroke(),e.lineWidth=t.band*.2;for(let[n,i,a]of[[r.port,-60*v,-20*v],[r.starboard,20*v,60*v]])e.strokeStyle=n,e.beginPath(),e.arc(t.cx,t.cy,t.r-t.band*.9,S(i),S(a)),e.stroke();let a=n.dial===`compass`?n.heading:0;if(e.strokeStyle=r.ringText,e.fillStyle=r.ringText,e.textAlign=`center`,e.textBaseline=`middle`,e.font=`600 ${Math.max(8,t.band*.5)}px ${b}`,a!==void 0)for(let r=0;r<360;r+=10){let i=r*v-a,o=r%30==0;e.lineWidth=o?2:1;let[s,c]=x(t,i,t.r),[l,u]=x(t,i,t.r-t.band*(o?.28:.18));if(e.beginPath(),e.moveTo(s,c),e.lineTo(l,u),e.stroke(),!o)continue;let d=n.dial===`compass`?w(r):String(r>180?360-r:r),[f,p]=x(t,i,t.r-t.band*.62);e.save(),e.translate(f,p),e.rotate(i),e.fillText(d,0,0),e.restore()}}function w(e){return{0:`N`,90:`E`,180:`S`,270:`W`}[e]??String(e)}function T(e,t,n,r,i){let[a,o]=x(t,n,t.r-t.band);e.strokeStyle=r,e.lineWidth=Math.max(1.5,t.r*.012),e.setLineDash(i?[t.r*.05,t.r*.04]:[]),e.beginPath(),e.moveTo(t.cx,t.cy),e.lineTo(a,o),e.stroke(),e.setLineDash([])}function E(e,t,n){if(!n.shift)return;e.fillStyle=n.palette.shift,e.beginPath(),e.moveTo(t.cx,t.cy);let r=S(n.shift.from);e.arc(t.cx,t.cy,t.r-t.band,r,r+C(n.shift.from,n.shift.to)),e.closePath(),e.fill()}function D(e,t,n,r,i,a){let o=t.r-t.band,s=x(t,n,o*(1-a)),c=t.r*.07,l=x(t,n,o),u=[l[0]-c*Math.cos(n),l[1]-c*Math.sin(n)],d=[l[0]+c*Math.cos(n),l[1]+c*Math.sin(n)];e.fillStyle=r,e.beginPath(),e.moveTo(s[0],s[1]),e.lineTo(u[0],u[1]),e.lineTo(d[0],d[1]),e.closePath(),e.fill();let[f,p]=x(t,n,o-t.r*.07);e.fillStyle=`#10161b`,e.font=`700 ${Math.max(8,t.r*.075)}px ${b}`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(i,f,p)}function O(e,t,n,r,i){let[a,o]=x(t,n,t.r-t.band/2),s=t.band*.32;e.fillStyle=r,e.strokeStyle=`#10161b`,e.lineWidth=1.5,e.beginPath(),i===`dot`?e.arc(a,o,s,0,2*Math.PI):(e.moveTo(a+s*Math.sin(n),o-s*Math.cos(n)),e.lineTo(a+s*Math.cos(n),o+s*Math.sin(n)),e.lineTo(a-s*Math.sin(n),o+s*Math.cos(n)),e.lineTo(a-s*Math.cos(n),o-s*Math.sin(n)),e.closePath()),e.fill(),e.stroke()}function k(e,t,n){let r=n.current;if(!r)return;let i=(t.r-t.band)*(.25+.45*Math.min(1,r.fraction)),[a,o]=x(t,r.angle,i),s=t.r*.06;e.strokeStyle=n.palette.current,e.fillStyle=n.palette.current,e.lineWidth=Math.max(2,t.r*.02),e.beginPath(),e.moveTo(t.cx,t.cy),e.lineTo(a,o),e.stroke();let[c,l]=x(t,r.angle,i-s*1.6);e.beginPath(),e.moveTo(a,o),e.lineTo(c+s*Math.cos(r.angle),l+s*Math.sin(r.angle)),e.lineTo(c-s*Math.cos(r.angle),l-s*Math.sin(r.angle)),e.closePath(),e.fill();let[u,d]=x(t,r.angle,i+t.r*.09);e.font=`600 ${Math.max(8,t.r*.075)}px ${b}`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(r.text,u,d)}function A(e,t,n){let r=t.r*.38,i=r*.34;e.strokeStyle=n.palette.muted,e.lineWidth=1.5,e.beginPath(),e.moveTo(t.cx,t.cy-r),e.bezierCurveTo(t.cx+i*1.1,t.cy-r*.45,t.cx+i,t.cy+r*.5,t.cx+i*.7,t.cy+r*.8),e.lineTo(t.cx-i*.7,t.cy+r*.8),e.bezierCurveTo(t.cx-i,t.cy+r*.5,t.cx-i*1.1,t.cy-r*.45,t.cx,t.cy-r),e.stroke()}function j(e,t,n){let r=t.band*.45,i=t.cy-t.r;e.fillStyle=n.palette.text,e.beginPath(),e.moveTo(t.cx,i+r),e.lineTo(t.cx-r*.7,i-r*.25),e.lineTo(t.cx+r*.7,i-r*.25),e.closePath(),e.fill()}function M(e,t,n,r,i,a,o,s){e.textAlign=i,e.textBaseline=`top`;let c=a*.5,l=s?r-a-c-2:r,u=s?r-a:r+c+2;e.fillStyle=o.muted,e.font=`600 ${c}px ${b}`,e.fillText(t.unit?`${t.label} ${t.unit}`:t.label,n,l),e.fillStyle=o.text,e.font=`700 ${a}px ${b}`,e.fillText(t.value,n,u)}function N(e,t,n,r){if(n.rudder===void 0)return;let i=t.r*.55,a=Math.max(4,t.r*.05);e.fillStyle=n.palette.ring,e.globalAlpha=.35,e.fillRect(t.cx-i,r,i*2,a),e.globalAlpha=1;let o=Math.max(-1,Math.min(1,n.rudder/y));e.fillStyle=o<0?n.palette.port:n.palette.starboard,e.fillRect(Math.min(t.cx,t.cx+o*i),r,Math.abs(o)*i,a),e.fillStyle=n.palette.text,e.fillRect(t.cx-1,r-2,2,a+4)}function te(e,t,n,r){let i=r.palette;e.clearRect(0,0,t,n),e.fillStyle=i.card,e.beginPath(),e.roundRect(0,0,t,n,8),e.fill();let a=Math.max(4,Math.min(t,n)*.03),o=r.rudder===void 0?0:Math.min(t,n)*.06,c=Math.max(10,Math.min(t,n-o)/2-a),l={cx:t/2,cy:(n-o)/2,r:c,band:c*.16};E(e,l,r),ee(e,l,r),A(e,l,r),r.trueWind!==void 0&&r.closeHauled!==void 0&&(T(e,l,r.trueWind+r.closeHauled,i.port,!0),T(e,l,r.trueWind-r.closeHauled,i.starboard,!0)),r.waypoint!==void 0&&O(e,l,r.waypoint,i.waypoint,`dot`),r.course!==void 0&&O(e,l,r.course,i.course,`diamond`),k(e,l,r),r.trueWind!==void 0&&D(e,l,r.trueWind,i.trueWind,`T`,.22),r.apparent!==void 0&&D(e,l,r.apparent,i.apparent,`A`,.5),j(e,l,r),e.fillStyle=i.text,e.textAlign=`center`,e.textBaseline=`middle`,e.font=`700 ${Math.max(10,c*.2)}px ${b}`,e.fillText(r.heading===void 0?`---`:`${s(r.heading)}°`,l.cx,l.cy);let u=Math.max(10,Math.min(t,n)*.075);M(e,r.topLeft,a,a,`left`,u,i,!1),M(e,r.topRight,t-a,a,`right`,u,i,!1),M(e,r.bottomLeft,a,n-a,`left`,u,i,!0),M(e,r.bottomRight,t-a,n-a,`right`,u,i,!0),N(e,l,r,l.cy+c+a*.6)}var P=1e4,F=Math.PI/180,I=.1,L=.05,R=1,z=1e3,B=new Set([`angleTrueWater`,`angleTrueGround`,`directionTrue`]),V=document.createElement(`canvas`);document.getElementById(`root`)?.append(V);var H,U=!1,W=0,G,K=!1;function q(e,t){return n=>{let r=e.values.get(n);return r&&t-r.time<P?r.value:void 0}}function J(e,t,n){return{label:e,value:t===void 0?`--`:m(t,n.conversion).toFixed(n.decimals),unit:n.symbol}}function Y(e,t){return{label:e,value:t===void 0?`--`:f(t),unit:``}}function X(e){let t=U?_:g,n={label:``,value:``,unit:``},r=H;if(!r)return{dial:`compass`,topLeft:n,topRight:n,bottomLeft:n,bottomRight:n,palette:t};let a=r.config,o=q(r,e),s=o(`heading`),l=o(`angleApparent`),u=c(o,a.trueWind),d=o(`speedOverGround`),f=o(`drift`),h=i(o(`set`),s),v=a.showShift&&s!==void 0?r.shift.range(e):void 0;return{dial:a.dial,heading:s,apparent:l,trueWind:u,shift:v&&s!==void 0?{from:v.from-s,to:v.to-s}:void 0,closeHauled:a.showTackLines?a.closeHauled*F:void 0,waypoint:a.showWaypoint?i(o(`waypoint`),s):void 0,course:a.showCourse&&d!==void 0&&d>=I?i(o(`course`),s):void 0,current:a.showCurrent&&h!==void 0&&f!==void 0&&f>=L?{angle:h,fraction:f/R,text:`${m(f,r.speed.conversion).toFixed(1)} ${r.speed.symbol}`}:void 0,rudder:a.showRudder?o(`rudder`):void 0,topLeft:J(`AWS`,o(`speedApparent`),r.speed),topRight:J(`TWS`,p(o,a.trueWind),r.speed),bottomLeft:Y(`AWA`,l),bottomRight:Y(`TWA`,u),palette:t}}function Z(){K=!1;let e=V.getBoundingClientRect(),t=window.devicePixelRatio||1,n=Math.max(1,Math.round(e.width*t)),r=Math.max(1,Math.round(e.height*t));(V.width!==n||V.height!==r)&&(V.width=n,V.height=r);let i=V.getContext(`2d`);i&&(i.setTransform(t,0,0,t,0,0),te(i,e.width,e.height,X(Date.now())))}function Q(){K||(K=!0,requestAnimationFrame(Z))}function ne(e,t){let n=q(e,t),r=n(`heading`),i=c(n,e.config.trueWind);r!==void 0&&i!==void 0&&e.shift.add(t,o(r+i))}async function $(e){let t=++W,n=u(await e.state.get()),i=a(n.north),o=await r(i.speedApparent);if(t!==W)return;let s={config:n,values:new Map,shift:new l(n.shiftSeconds*1e3),clock:new d,speed:h({...o,units:o?.units??`m/s`},void 0,1)},c=new Map;for(let[e,t]of Object.entries(i))c.set(t,[...c.get(t)??[],e]);let f=await e.signalk.subscribe([...c.keys()],e=>{let t=c.get(e.path);if(!t||typeof e.value!=`number`||!Number.isFinite(e.value))return;let n=Date.now(),r=s.clock.local(n,e.timestamp);for(let n of t)s.values.set(n,{time:r,value:e.value});t.some(e=>B.has(e))&&ne(s,n),Q()});if(t!==W){await f().catch(()=>void 0);return}let p=G;G=f,H=s,Q(),await p?.().catch(()=>void 0)}async function re(){let r=await e();t(r),new ResizeObserver(Q).observe(V),setInterval(Q,z),await r.subscribe([`state.changed`],()=>{$(r).catch(e=>{console.warn(`wind steering: settings reload failed`,e)})}),await n(r,e=>{U=e,Q()}).catch(e=>{console.warn(`wind steering: night mode unavailable`,e)}),await $(r)}re().catch(e=>{console.warn(`wind steering: host connection failed`,e)});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-U7YORXZ7-BLTBSYrv.js";import{t as e}from"./level-
|
|
1
|
+
import"./chunk-U7YORXZ7-BLTBSYrv.js";import{t as e}from"./level-DvwXfEQD.js";e(`tank`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-U7YORXZ7-BLTBSYrv.js";import{t as e}from"./level-config-
|
|
1
|
+
import"./chunk-U7YORXZ7-BLTBSYrv.js";import{t as e}from"./level-config-BUp6HxOr.js";e(`tank`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./chunk-U7YORXZ7-BLTBSYrv.js";import{i as t,n,o as r,r as i}from"./config-model-BkGUzGeC.js";import{a,c as o,i as s,l as c,n as l,r as u,t as d}from"./series-DIfvccHD.js";import{n as f,t as p}from"./styles-CjtPzFRR.js";import{n as m}from"./signalk-BOmj4E6B.js";import{n as h,r as g}from"./units-nn6bpgTR.js";var _=6e4,v=2*Math.PI,y=2,b=document.createElement(`canvas`);document.getElementById(`root`)?.append(b);var x,S=!1,C=0,w,T,E=!1;function D(e,t){if(e===void 0||!Number.isFinite(e))return`--`;let n=e;t.display.angular&&(n=t.signed?l(e):(e%v+v)%v);let r=h(n,t.display.conversion).toFixed(t.display.decimals);return t.display.angular&&!t.signed&&Number(r)>=360?0 .toFixed(t.display.decimals):r}function O(e){let t=S?s:u,n=x;if(!n)return{label:``,value:`--`,symbol:``,min:``,avg:``,max:``,windowMs:1,stats:void 0,minSpan:1,palette:t};let r=n.series.stats(e),a=e=>e===void 0?void 0:(r?.centre??0)+e,o=n.last&&e-n.last.time<_?n.last.value:void 0,c=n.display.conversion?1/Math.abs(n.display.conversion.factor):1;return{label:i(n.config),value:D(o,n),symbol:n.display.symbol,min:r?D(a(r.min),n):``,avg:r?D(a(r.avg),n):``,max:r?D(a(r.max),n):``,windowMs:n.series.windowMs,stats:r,minSpan:y*c,message:n.loading?`Loading…`:`No data`,palette:t}}function k(){E=!1;let e=b.getBoundingClientRect(),t=window.devicePixelRatio||1,n=Math.max(1,Math.round(e.width*t)),r=Math.max(1,Math.round(e.height*t));(b.width!==n||b.height!==r)&&(b.width=n,b.height=r);let i=b.getContext(`2d`);i&&(i.setTransform(t,0,0,t,0,0),a(i,e.width,e.height,O(Date.now())))}function A(){E||(E=!0,requestAnimationFrame(k))}async function j(e,t,n){let r=async t=>{let n=await o(e.config.path,e.series.windowMs,e.series.bucketMs,t);return e.loading=!1,n},i=n?await c(r,()=>t===C):await r(2e4)??[];if(t===C){for(let t of i)e.series.merge(t.time,t.min,t.max,t.avg);A()}}async function M(e){let i=++C;if(w){let e=w;w=void 0,await e().catch(()=>void 0)}T&&clearInterval(T);let a=t(await e.state.get()),o=await m(a.path);if(i!==C)return;let s=g(o,a.unit||void 0,a.decimals),c=r(a),l={config:a,display:s,series:new d(c,s.angular),signed:n(a.path),loading:!0};x=l,A(),w=await e.signalk.subscribe([a.path],e=>{if(typeof e.value!=`number`||!Number.isFinite(e.value))return;let t=Date.now();l.last={time:t,value:e.value},l.series.add(t,e.value),A()}),T=setInterval(A,Math.max(1e3,l.series.bucketMs)),await j(l,i,!0)}async function N(){let t=await e();f(t),new ResizeObserver(A).observe(b),await t.subscribe([`state.changed`],()=>{M(t).catch(e=>{console.warn(`history strip: settings reload failed`,e)})}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&x&&j(x,C,!1)}),await p(t,e=>{S=e,A()}).catch(e=>{console.warn(`history strip: night mode unavailable`,e)}),await M(t)}N().catch(e=>{console.warn(`history strip: host connection failed`,e)});
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>Battery setup</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/battery-config-
|
|
7
|
+
<script type="module" crossorigin src="./assets/battery-config-DjFsEE6z.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="./assets/chunk-U7YORXZ7-BLTBSYrv.js">
|
|
9
|
-
<link rel="modulepreload" crossorigin href="./assets/signalk-
|
|
9
|
+
<link rel="modulepreload" crossorigin href="./assets/signalk-BOmj4E6B.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="./assets/level-model-CINplXoI.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="./assets/units-nn6bpgTR.js">
|
|
12
|
-
<link rel="modulepreload" crossorigin href="./assets/level-config-
|
|
12
|
+
<link rel="modulepreload" crossorigin href="./assets/level-config-BUp6HxOr.js">
|
|
13
13
|
<link rel="stylesheet" crossorigin href="./assets/config-DBAHPNIf.css">
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
package/public/battery.html
CHANGED
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>Battery</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/battery-
|
|
7
|
+
<script type="module" crossorigin src="./assets/battery-DIdhsP3c.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="./assets/chunk-U7YORXZ7-BLTBSYrv.js">
|
|
9
9
|
<link rel="modulepreload" crossorigin href="./assets/styles-CjtPzFRR.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="./assets/signalk-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="./assets/signalk-BOmj4E6B.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="./assets/steer-model-DA5-9SMr.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="./assets/level-model-CINplXoI.js">
|
|
13
|
+
<link rel="modulepreload" crossorigin href="./assets/level-render-70t5D0u5.js">
|
|
13
14
|
<link rel="modulepreload" crossorigin href="./assets/units-nn6bpgTR.js">
|
|
14
|
-
<link rel="modulepreload" crossorigin href="./assets/level-
|
|
15
|
+
<link rel="modulepreload" crossorigin href="./assets/level-DvwXfEQD.js">
|
|
15
16
|
<link rel="stylesheet" crossorigin href="./assets/styles-D6wkrAFq.css">
|
|
16
17
|
</head>
|
|
17
18
|
<body>
|
package/public/clock-config.html
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>Clock setup</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/clock-config-
|
|
7
|
+
<script type="module" crossorigin src="./assets/clock-config-CEXnt2BC.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="./assets/chunk-U7YORXZ7-BLTBSYrv.js">
|
|
9
9
|
<link rel="modulepreload" crossorigin href="./assets/clock-model-D8TrsRP6.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="./assets/signalk-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="./assets/signalk-BOmj4E6B.js">
|
|
11
11
|
<link rel="stylesheet" crossorigin href="./assets/config-DBAHPNIf.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
package/public/clock.html
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>Clock</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/clock-
|
|
7
|
+
<script type="module" crossorigin src="./assets/clock-BM6oWw1K.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="./assets/chunk-U7YORXZ7-BLTBSYrv.js">
|
|
9
9
|
<link rel="modulepreload" crossorigin href="./assets/styles-CjtPzFRR.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="./assets/clock-model-D8TrsRP6.js">
|
|
11
|
-
<link rel="modulepreload" crossorigin href="./assets/signalk-
|
|
11
|
+
<link rel="modulepreload" crossorigin href="./assets/signalk-BOmj4E6B.js">
|
|
12
12
|
<link rel="stylesheet" crossorigin href="./assets/styles-D6wkrAFq.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
package/public/config.html
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>History strip setup</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/config-
|
|
7
|
+
<script type="module" crossorigin src="./assets/config-CGQo6w5J.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="./assets/chunk-U7YORXZ7-BLTBSYrv.js">
|
|
9
9
|
<link rel="modulepreload" crossorigin href="./assets/config-model-BkGUzGeC.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="./assets/signalk-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="./assets/signalk-BOmj4E6B.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="./assets/units-nn6bpgTR.js">
|
|
12
12
|
<link rel="stylesheet" crossorigin href="./assets/config-DBAHPNIf.css">
|
|
13
13
|
</head>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>Depth profile setup</title>
|
|
7
|
+
<script type="module" crossorigin src="./assets/depth-config-CXV_1Ma9.js"></script>
|
|
8
|
+
<link rel="modulepreload" crossorigin href="./assets/chunk-U7YORXZ7-BLTBSYrv.js">
|
|
9
|
+
<link rel="modulepreload" crossorigin href="./assets/depth-model-DGmfV7Y9.js">
|
|
10
|
+
<link rel="modulepreload" crossorigin href="./assets/signalk-BOmj4E6B.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="./assets/units-nn6bpgTR.js">
|
|
12
|
+
<link rel="stylesheet" crossorigin href="./assets/config-DBAHPNIf.css">
|
|
13
|
+
</head>
|
|
14
|
+
<body>
|
|
15
|
+
<div id="root"></div>
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>Depth profile</title>
|
|
7
|
+
<script type="module" crossorigin src="./assets/depth-BRzrsqnk.js"></script>
|
|
8
|
+
<link rel="modulepreload" crossorigin href="./assets/chunk-U7YORXZ7-BLTBSYrv.js">
|
|
9
|
+
<link rel="modulepreload" crossorigin href="./assets/depth-model-DGmfV7Y9.js">
|
|
10
|
+
<link rel="modulepreload" crossorigin href="./assets/series-DIfvccHD.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="./assets/styles-CjtPzFRR.js">
|
|
12
|
+
<link rel="modulepreload" crossorigin href="./assets/signalk-BOmj4E6B.js">
|
|
13
|
+
<link rel="modulepreload" crossorigin href="./assets/units-nn6bpgTR.js">
|
|
14
|
+
<link rel="stylesheet" crossorigin href="./assets/styles-D6wkrAFq.css">
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
<div id="root"></div>
|
|
18
|
+
</body>
|
|
19
|
+
</html>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>System health setup</title>
|
|
7
|
+
<script type="module" crossorigin src="./assets/pi-config-Bv1JcQ9H.js"></script>
|
|
8
|
+
<link rel="modulepreload" crossorigin href="./assets/chunk-U7YORXZ7-BLTBSYrv.js">
|
|
9
|
+
<link rel="modulepreload" crossorigin href="./assets/level-model-CINplXoI.js">
|
|
10
|
+
<link rel="modulepreload" crossorigin href="./assets/pi-model-DtR5ejzZ.js">
|
|
11
|
+
<link rel="stylesheet" crossorigin href="./assets/config-DBAHPNIf.css">
|
|
12
|
+
</head>
|
|
13
|
+
<body>
|
|
14
|
+
<div id="root"></div>
|
|
15
|
+
</body>
|
|
16
|
+
</html>
|
package/public/pi.html
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>System health</title>
|
|
7
|
+
<script type="module" crossorigin src="./assets/pi-CnIcVauf.js"></script>
|
|
8
|
+
<link rel="modulepreload" crossorigin href="./assets/chunk-U7YORXZ7-BLTBSYrv.js">
|
|
9
|
+
<link rel="modulepreload" crossorigin href="./assets/styles-CjtPzFRR.js">
|
|
10
|
+
<link rel="modulepreload" crossorigin href="./assets/signalk-BOmj4E6B.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="./assets/steer-model-DA5-9SMr.js">
|
|
12
|
+
<link rel="modulepreload" crossorigin href="./assets/level-render-70t5D0u5.js">
|
|
13
|
+
<link rel="modulepreload" crossorigin href="./assets/level-model-CINplXoI.js">
|
|
14
|
+
<link rel="modulepreload" crossorigin href="./assets/pi-model-DtR5ejzZ.js">
|
|
15
|
+
<link rel="modulepreload" crossorigin href="./assets/units-nn6bpgTR.js">
|
|
16
|
+
<link rel="stylesheet" crossorigin href="./assets/styles-D6wkrAFq.css">
|
|
17
|
+
</head>
|
|
18
|
+
<body>
|
|
19
|
+
<div id="root"></div>
|
|
20
|
+
</body>
|
|
21
|
+
</html>
|
package/public/steer.html
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>Wind steering</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/steer-
|
|
7
|
+
<script type="module" crossorigin src="./assets/steer-DVy1Yeda.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="./assets/chunk-U7YORXZ7-BLTBSYrv.js">
|
|
9
9
|
<link rel="modulepreload" crossorigin href="./assets/styles-CjtPzFRR.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="./assets/signalk-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="./assets/signalk-BOmj4E6B.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="./assets/steer-model-DA5-9SMr.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="./assets/units-nn6bpgTR.js">
|
|
13
13
|
<link rel="stylesheet" crossorigin href="./assets/styles-D6wkrAFq.css">
|
package/public/tank-config.html
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>Tank setup</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/tank-config-
|
|
7
|
+
<script type="module" crossorigin src="./assets/tank-config-CQ5sfnUH.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="./assets/chunk-U7YORXZ7-BLTBSYrv.js">
|
|
9
|
-
<link rel="modulepreload" crossorigin href="./assets/signalk-
|
|
9
|
+
<link rel="modulepreload" crossorigin href="./assets/signalk-BOmj4E6B.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="./assets/level-model-CINplXoI.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="./assets/units-nn6bpgTR.js">
|
|
12
|
-
<link rel="modulepreload" crossorigin href="./assets/level-config-
|
|
12
|
+
<link rel="modulepreload" crossorigin href="./assets/level-config-BUp6HxOr.js">
|
|
13
13
|
<link rel="stylesheet" crossorigin href="./assets/config-DBAHPNIf.css">
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
package/public/tank.html
CHANGED
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>Tank</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/tank-
|
|
7
|
+
<script type="module" crossorigin src="./assets/tank-DoTwuOR1.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="./assets/chunk-U7YORXZ7-BLTBSYrv.js">
|
|
9
9
|
<link rel="modulepreload" crossorigin href="./assets/styles-CjtPzFRR.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="./assets/signalk-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="./assets/signalk-BOmj4E6B.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="./assets/steer-model-DA5-9SMr.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="./assets/level-model-CINplXoI.js">
|
|
13
|
+
<link rel="modulepreload" crossorigin href="./assets/level-render-70t5D0u5.js">
|
|
13
14
|
<link rel="modulepreload" crossorigin href="./assets/units-nn6bpgTR.js">
|
|
14
|
-
<link rel="modulepreload" crossorigin href="./assets/level-
|
|
15
|
+
<link rel="modulepreload" crossorigin href="./assets/level-DvwXfEQD.js">
|
|
15
16
|
<link rel="stylesheet" crossorigin href="./assets/styles-D6wkrAFq.css">
|
|
16
17
|
</head>
|
|
17
18
|
<body>
|
package/public/widget.html
CHANGED
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>History strip</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/widget-
|
|
7
|
+
<script type="module" crossorigin src="./assets/widget-BZqPEWQ6.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="./assets/chunk-U7YORXZ7-BLTBSYrv.js">
|
|
9
9
|
<link rel="modulepreload" crossorigin href="./assets/config-model-BkGUzGeC.js">
|
|
10
|
+
<link rel="modulepreload" crossorigin href="./assets/series-DIfvccHD.js">
|
|
10
11
|
<link rel="modulepreload" crossorigin href="./assets/styles-CjtPzFRR.js">
|
|
11
|
-
<link rel="modulepreload" crossorigin href="./assets/signalk-
|
|
12
|
+
<link rel="modulepreload" crossorigin href="./assets/signalk-BOmj4E6B.js">
|
|
12
13
|
<link rel="modulepreload" crossorigin href="./assets/units-nn6bpgTR.js">
|
|
13
14
|
<link rel="stylesheet" crossorigin href="./assets/styles-D6wkrAFq.css">
|
|
14
15
|
</head>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./chunk-U7YORXZ7-BLTBSYrv.js";import{n as t,t as n}from"./styles-CjtPzFRR.js";import{i as r,n as i}from"./signalk-NgaYaNkQ.js";import{r as a}from"./steer-model-DA5-9SMr.js";import{a as o,i as s,n as c,o as l,r as u,s as d,t as f}from"./level-model-CINplXoI.js";import{n as p,r as m}from"./units-nn6bpgTR.js";var h={card:`rgba(20, 26, 32, 0.78)`,text:`#e8edf2`,muted:`#9fb3c4`,glass:`rgba(255, 255, 255, 0.07)`,glassEdge:`rgba(207, 216, 220, 0.75)`,glint:`rgba(255, 255, 255, 0.28)`,liquid:{ok:{edge:`#1b5e20`,middle:`#66bb6a`,surface:`#a5d6a7`},warn:{edge:`#e65100`,middle:`#fdd835`,surface:`#fff59d`},alarm:{edge:`#7f0000`,middle:`#e53935`,surface:`#ef9a9a`}},mark:{ok:`#66bb6a`,warn:`#fdd835`,alarm:`#e53935`}},g={card:`rgba(8, 0, 0, 0.85)`,text:`#d32f2f`,muted:`#8e2424`,glass:`rgba(120, 20, 20, 0.08)`,glassEdge:`rgba(110, 24, 24, 0.9)`,glint:`rgba(160, 40, 40, 0.18)`,liquid:{ok:{edge:`#0b2a0d`,middle:`#2e5d31`,surface:`#3d7340`},warn:{edge:`#3d2600`,middle:`#7a6a10`,surface:`#8f7d1c`},alarm:{edge:`#3a0000`,middle:`#8e1b1b`,surface:`#b02a2a`}},mark:{ok:`#2e5d31`,warn:`#7a6a10`,alarm:`#b02a2a`}};function _(e,t,n,r,i,a){e.beginPath(),e.moveTo(t+a,n),e.arcTo(t+r,n,t+r,n+i,a),e.arcTo(t+r,n+i,t,n+i,a),e.arcTo(t,n+i,t,n,a),e.arcTo(t,n,t+r,n,a),e.closePath()}function v(e,t,n,r,i=``){let a=n;for(e.font=`${i} ${a}px 'Helvetica Neue', Arial, sans-serif`;a>8&&e.measureText(t).width>r;)--a,e.font=`${i} ${a}px 'Helvetica Neue', Arial, sans-serif`}function y(e,t,n,r,i,a){e.beginPath(),e.moveTo(t-n,i),e.lineTo(t-n,a),e.ellipse(t,a,n,r,0,Math.PI,0,!0),e.lineTo(t+n,i),e.ellipse(t,i,n,r,0,0,Math.PI,!1),e.closePath()}function b(e,t,n,r,i){let a=e.createLinearGradient(t-n,0,t+n,0);return a.addColorStop(0,r),a.addColorStop(.35,i),a.addColorStop(.55,i),a.addColorStop(1,r),a}function x(e,t){return e.bottom-Math.min(1,Math.max(0,t))*(e.bottom-e.top)}function S(e,t,n){let r=n.palette,{cx:i,rx:a,top:o,bottom:s}=t,c=a*.22;if(y(e,i,a,c,o,s),e.fillStyle=r.glass,e.fill(),n.fraction!==void 0){let o=r.liquid[n.level],l=x(t,n.fraction);y(e,i,a,c,l,s),e.fillStyle=b(e,i,a,o.edge,o.middle),e.fill(),e.beginPath(),e.ellipse(i,l,a,c,0,0,Math.PI*2),e.fillStyle=o.surface,e.fill()}let l=e.createLinearGradient(i-a*.7,0,i-a*.35,0);if(l.addColorStop(0,`rgba(255, 255, 255, 0)`),l.addColorStop(.5,r.glint),l.addColorStop(1,`rgba(255, 255, 255, 0)`),e.fillStyle=l,e.fillRect(i-a*.7,o+c,a*.35,s-o-c),e.lineWidth=Math.max(1,a*.04),e.strokeStyle=r.glassEdge,y(e,i,a,c,o,s),e.stroke(),e.beginPath(),e.ellipse(i,o,a,c,0,0,Math.PI*2),e.stroke(),n.kind===`battery`){let t=a*.32,n=t*.22,s=a*.22;y(e,i,t,n,o-s,o),e.fillStyle=b(e,i,t,r.glassEdge,r.text),e.fill(),e.beginPath(),e.ellipse(i,o-s,t,n,0,0,Math.PI*2),e.fillStyle=r.text,e.fill()}}function C(e,t,n){let r=n.palette,{cx:i,rx:a,top:o,bottom:s}=t,c=Math.min(a*.25,8),l=Math.max(1,a*.04);if(_(e,i-a,o,2*a,s-o,c),e.fillStyle=r.glass,e.fill(),n.fraction!==void 0){let l=x(t,n.fraction);e.save(),_(e,i-a,o,2*a,s-o,c),e.clip(),e.fillStyle=r.liquid[n.level].middle,e.fillRect(i-a,l,2*a,s-l),e.restore()}if(e.lineWidth=l,e.strokeStyle=r.glassEdge,_(e,i-a,o,2*a,s-o,c),e.stroke(),n.kind===`battery`){let t=a*.6,n=a*.18;_(e,i-t/2,o-n,t,n,Math.min(n/2,3)),e.fillStyle=r.glassEdge,e.fill()}}function w(e,t,n,r,i,a,o){let s=t.direction===`idle`?0:i*.7,c=s?i*.3:0;v(e,t.text,i,a-s-c,`bold`);let l=n-(s+c+e.measureText(t.text).width)/2;if(e.fillStyle=t.direction===`charging`?o.mark.ok:t.direction===`discharging`?o.mark.alarm:o.muted,s){let n=r-i*.8,a=t.direction===`charging`?n:r,o=t.direction===`charging`?r:n;e.beginPath(),e.moveTo(l+s/2,a),e.lineTo(l+s,o),e.lineTo(l,o),e.closePath(),e.fill()}e.textAlign=`left`,e.fillText(t.text,l+s+c,r),e.textAlign=`center`}function T(e,t,n,r){let i=r.palette;e.clearRect(0,0,t,n),_(e,0,0,t,n,Math.min(10,t/10)),e.fillStyle=i.card,e.fill();let a=Math.max(6,Math.min(t,n)*.06),o=t>=n*.8,s=Math.max(10,Math.min(t*.11,n*(o?.1:.06))),c=Math.max(14,o?Math.min(t*.17,n*.2):Math.min(t*.2,n*.11)),l=Math.max(9,c*.5);e.textAlign=`center`,e.textBaseline=`top`,e.fillStyle=i.muted,v(e,r.title,s,t-2*a),e.fillText(r.title,t/2,a);let u=l*1.2,d=(+!!r.detailText+ +!!r.flow)*u,f=o?0:c+d+a,p=a+s*1.5,m=n-f-a*.5,h=Math.min(o?t*.15:t*.27,(m-p)*.4),g=h*(r.style===`3d`?.22:0)+(r.kind===`battery`?h*.22:0),y={cx:o?a+h:t/2-h*.15,rx:h,top:p+g,bottom:m-(r.style===`3d`?h*.22:0)};if(y.bottom-y.top<4)return;r.style===`flat`?C(e,y,r):S(e,y,r);let b=y.cx+h+Math.max(3,h*.12),T=e=>x(y,e);e.lineCap=`round`,e.strokeStyle=i.muted,e.lineWidth=Math.max(1,h*.03);for(let t of[.25,.5,.75])e.beginPath(),e.moveTo(b,T(t)),e.lineTo(b+h*.18,T(t)),e.stroke();e.lineWidth=Math.max(2,h*.09);for(let t of r.marks)e.strokeStyle=i.mark[t.level],e.beginPath(),e.moveTo(b,T(t.at)),e.lineTo(b+h*.32,T(t.at)),e.stroke();let E=o?b+h*.32+a*.5:a,D=t-a-E,O=E+D/2,k=c+d,A=o?(p+m+k)/2:n-a;e.textBaseline=`alphabetic`,e.fillStyle=r.fraction===void 0?i.muted:i.text,v(e,r.valueText,c,D,`bold`);let j=A-d;e.fillText(r.valueText,O,j),r.detailText&&(j+=u,e.fillStyle=i.muted,v(e,r.detailText,l,D),e.fillText(r.detailText,O,j)),r.flow&&w(e,r.flow,O,j+u,l,D,i)}var E=12e4,D=5e3;function O(_){let v=f[_],y=document.createElement(`canvas`);document.getElementById(`root`)?.append(y);let b,x=!1,S=0,C,w=!1,O=(e,t,n=!0)=>e&&(!n||t-e.time<E)?e.value:void 0;function k(e){let t=x?g:h,n=b;if(!n?.config.path)return{title:v.noun,fraction:void 0,level:`ok`,valueText:`Not set up`,detailText:``,marks:[],kind:_,style:n?.config.style??`3d`,palette:t};let r=O(n.levelReading,e),i=O(n.detailReading,e,v.detailAges),a=n.config.showDetail&&r!==void 0&&i!==void 0?`${p(v.detail(r,i),n.detail.conversion).toFixed(n.detail.decimals)} ${n.detail.symbol}`.trim():``,o=n.config.showDetail?O(n.flowReading,e):void 0,s=o===void 0?void 0:{text:`${p(Math.abs(o),n.flow.conversion).toFixed(n.flow.decimals)} ${n.flow.symbol}`.trim(),direction:c(o)};return{title:n.title,fraction:r,level:r===void 0?`ok`:u(d(r,n.zones)),valueText:r===void 0?`--`:`${p(r,n.level.conversion).toFixed(n.level.decimals)} ${n.level.symbol}`.trim(),detailText:a,flow:s,marks:l(n.zones),kind:_,style:n.config.style,palette:t}}function A(){w=!1;let e=y.getBoundingClientRect(),t=window.devicePixelRatio||1,n=Math.max(1,Math.round(e.width*t)),r=Math.max(1,Math.round(e.height*t));(y.width!==n||y.height!==r)&&(y.width=n,y.height=r);let i=y.getContext(`2d`);i&&(i.setTransform(t,0,0,t,0,0),T(i,e.width,e.height,k(Date.now())))}function j(){w||(w=!0,requestAnimationFrame(A))}async function M(e){let t=++S,n=s(await e.state.get()),c=v.matches(n.path),l=c?v.detailPath(n.path):void 0,u=c?v.flowPath?.(n.path):void 0,[d,f,p,h]=n.path?await Promise.all([i(n.path),l?i(l):void 0,l&&!v.detailAges?r(l):void 0,u?i(u):void 0]):[void 0,void 0,void 0,void 0];if(t!==S)return;let g={config:n,title:n.label||d?.displayName||v.name(n.path),zones:o(d?.zones),level:m({...d,units:d?.units??`ratio`},`percent`,0),detail:m({...f,units:f?.units??v.detailUnits},void 0,v.detailDecimals),flow:m({...h,units:h?.units??`A`},void 0,1)};typeof p==`number`&&Number.isFinite(p)&&(g.detailReading={time:Date.now(),value:p});let _;if(n.path){let r=[n.path,l,u].filter(e=>e!==void 0),i=new a;if(_=await e.signalk.subscribe(r,e=>{if(typeof e.value!=`number`||!Number.isFinite(e.value))return;let t={time:i.local(Date.now(),e.timestamp),value:e.value};e.path===n.path?g.levelReading=t:e.path===u?g.flowReading=t:g.detailReading=t,j()}),t!==S){await _().catch(()=>void 0);return}}let y=C;C=_,b=g,j(),await y?.().catch(()=>void 0)}async function N(){let r=await e();t(r),new ResizeObserver(j).observe(y),setInterval(j,D),await r.subscribe([`state.changed`],()=>{M(r).catch(e=>{console.warn(`${_}: settings reload failed`,e)})}),await n(r,e=>{x=e,j()}).catch(e=>{console.warn(`${_}: night mode unavailable`,e)}),await M(r)}N().catch(e=>{console.warn(`${_}: host connection failed`,e)})}export{O as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./chunk-U7YORXZ7-BLTBSYrv.js";import{i as t,n,o as r,r as i}from"./config-model-BkGUzGeC.js";import{n as a,t as o}from"./styles-CjtPzFRR.js";import{n as s}from"./signalk-NgaYaNkQ.js";import{n as c,r as l}from"./units-nn6bpgTR.js";var u=`/signalk/v2/api/history/values`;function d(e,t,n,r){return`${u}?${new URLSearchParams({paths:(r?[`min`,`max`,`average`]:[`average`]).map(t=>`${e}:${t}`).join(`,`),duration:String(Math.ceil(t/1e3)),resolution:String(Math.max(1,Math.round(n/1e3)))}).toString()}`}function f(e,t){let n=n=>e.values.findIndex(e=>e.path===t&&e.method===n),r=n(`average`);if(r<0)return[];let i=n(`min`),a=n(`max`),o=[];for(let t of e.data){let e=Date.parse(t[0]),n=t[r+1];if(Number.isNaN(e)||typeof n!=`number`)continue;let s=i<0?n:t[i+1],c=a<0?n:t[a+1];o.push({time:e,avg:n,min:typeof s==`number`?s:n,max:typeof c==`number`?c:n})}return o}function p(e){if(typeof e!=`object`||!e)return!1;let t=e;return Array.isArray(t.values)&&Array.isArray(t.data)}async function m(e,t,n,r=fetch){for(let i of[!0,!1])try{let a=await r(d(e,t,n,i),{credentials:`include`});if(a.status===404||a.status===501)return[];if(!a.ok)continue;let o=await a.json();if(p(o))return f(o,e)}catch(e){return console.warn(`history query failed`,e),[]}return[]}var h={card:`rgba(20, 26, 32, 0.78)`,text:`#e8edf2`,muted:`#9fb3c4`,bar:`#29b6f6`,avg:`#ef5350`,grid:`rgba(255, 255, 255, 0.22)`},g={card:`rgba(8, 0, 0, 0.85)`,text:`#d32f2f`,muted:`#8e2424`,bar:`#7f1212`,avg:`#ff5252`,grid:`rgba(211, 47, 47, 0.3)`},_=[1,2,5,10,15,20,30,60,120,180,240,360,720,1440],v=4;function y(e){let t=e/6e4,n=_.find(e=>t/e<=v)??Math.ceil(t/v/1440)*1440,r=t>120,i=[];for(let e=n;e<=t+1e-9;e+=n)i.push({age:e*6e4,label:r?`${+(e/60).toFixed(1)}h`:`${e}`});return i}function b(e,t){let n=e.min,r=e.max;if(r-n<t){let e=(r+n)/2;n=e-t/2,r=e+t/2}let i=(r-n)*.05;return{lo:n-i,hi:r+i}}function x(e,t,n,r,i=``){let a=r;for(e.font=`${i} ${a}px 'Helvetica Neue', Arial, sans-serif`;a>7&&e.measureText(t).width>n;)a--,e.font=`${i} ${a}px 'Helvetica Neue', Arial, sans-serif`;return a}function S(e,t,n,r){let i=r.palette,a=Math.max(4,Math.round(t*.05));e.clearRect(0,0,t,n),e.fillStyle=i.card,e.beginPath(),e.roundRect(0,0,t,n,10),e.fill(),e.textBaseline=`alphabetic`;let o=t-2*a,s=Math.max(8,Math.round(Math.min(t/9,n/18)));e.fillStyle=i.muted,e.font=`600 ${s}px 'Helvetica Neue', Arial, sans-serif`,e.textAlign=`left`;let c=a+s;e.fillText(r.label,a,c,o*.7),e.textAlign=`right`,e.fillText(r.symbol,t-a,c,o*.3);let l=x(e,r.value,o,Math.round(Math.min(t/3.2,n/7)),`600`);e.fillStyle=i.text,e.textAlign=`center`,c+=l+2,e.fillText(r.value,t/2,c);let u=x(e,`${r.min} ${r.avg} ${r.max}`,o,s);e.font=`${u}px 'Helvetica Neue', Arial, sans-serif`,c+=u+4,e.textAlign=`left`,e.fillStyle=i.muted,e.fillText(r.min,a,c),e.textAlign=`right`,e.fillText(r.max,t-a,c),e.textAlign=`center`,e.fillStyle=i.avg,e.fillText(r.avg,t/2,c);let d=Math.max(7,s-2);e.font=`${d}px 'Helvetica Neue', Arial, sans-serif`;let f=y(r.windowMs),p=Math.ceil(Math.max(...f.map(t=>e.measureText(t.label).width),0))+3,m=c+4,h=a,g=t-a-p,_=n-a,v=_-m,S=g-h;if(v<10||S<10)return;e.strokeStyle=i.grid,e.lineWidth=1,e.strokeRect(h+.5,m+.5,S-1,v-1);let C=e=>m+e/r.windowMs*v;e.fillStyle=i.muted,e.textAlign=`left`,e.textBaseline=`middle`;for(let t of f){let n=Math.round(C(t.age))+.5;t.age<r.windowMs&&(e.beginPath(),e.moveTo(h,n),e.lineTo(g,n),e.stroke()),e.fillText(t.label,g+3,Math.min(n,_-d/2))}if(!r.stats){r.message&&(e.textAlign=`center`,e.fillStyle=i.muted,e.fillText(r.message,h+S/2,m+v/2,S-4));return}let w=b(r.stats,r.minSpan),T=e=>h+(e-w.lo)/(w.hi-w.lo)*S;e.fillStyle=i.bar;for(let t of r.stats.bands){let n=C(t.ageStart),r=Math.min(_,C(t.ageEnd));if(r<=m)continue;let i=T(t.lo),a=Math.max(i+2,T(t.hi)),o=Math.max(m,n);e.fillRect(i,o,a-i,Math.max(1,r-o)+.5)}let E=Math.round(T(r.stats.avg))+.5;e.strokeStyle=i.avg,e.beginPath(),e.moveTo(E,m),e.lineTo(E,_),e.stroke()}var C=2*Math.PI;function w(e){let t=((e+Math.PI)%C+C)%C;return t===0?Math.PI:t-Math.PI}var T=class{windowMs;bucketMs;angular;buckets=new Map;constructor(e,t,n=240){this.windowMs=e,this.bucketMs=e/n,this.angular=t}get size(){return this.buckets.size}add(e,t){this.merge(e,t,t,t)}merge(e,t,n,r){if(![e,t,n,r].every(Number.isFinite))return;let i=Math.floor(e/this.bucketMs),a=this.buckets.get(i);if(a||(a={index:i,ref:this.angular?r:0,lo:1/0,hi:-1/0,sum:0,sin:0,cos:0,n:0},this.buckets.set(i,a)),this.angular){let e=w(r-a.ref),i=w(t-r),o=w(n-r);a.lo=Math.min(a.lo,e+Math.min(0,i,o)),a.hi=Math.max(a.hi,e+Math.max(0,i,o)),a.sin+=Math.sin(r),a.cos+=Math.cos(r)}else a.lo=Math.min(a.lo,t,r),a.hi=Math.max(a.hi,n,r),a.sum+=r;a.n++}prune(e){let t=Math.floor((e-this.windowMs)/this.bucketMs);for(let e of this.buckets.keys())e<t&&this.buckets.delete(e)}clear(){this.buckets.clear()}stats(e){this.prune(e);let t=[...this.buckets.values()].filter(e=>e.n>0);if(t.length===0)return;let n=0;if(this.angular){let e=0,r=0;for(let n of t){let t=Math.atan2(n.sin,n.cos);e+=Math.sin(t),r+=Math.cos(t)}n=Math.atan2(e,r)}let r=1/0,i=-1/0,a=0,o=[];for(let s of t){let t=this.angular?w(s.ref-n):0,c=s.lo+t,l=s.hi+t;r=Math.min(r,c),i=Math.max(i,l),this.angular||(a+=s.sum/s.n);let u=s.index*this.bucketMs;o.push({ageStart:Math.max(0,e-(u+this.bucketMs)),ageEnd:Math.max(0,e-u),lo:c,hi:l})}return{centre:n,min:r,max:i,avg:this.angular?0:a/t.length,bands:o}}},E=6e4,D=2*Math.PI,O=2,k=document.createElement(`canvas`);document.getElementById(`root`)?.append(k);var A,j=!1,M=0,N,P,F=!1;function I(e,t){if(e===void 0||!Number.isFinite(e))return`--`;let n=e;t.display.angular&&(n=t.signed?w(e):(e%D+D)%D);let r=c(n,t.display.conversion).toFixed(t.display.decimals);return t.display.angular&&!t.signed&&Number(r)>=360?0 .toFixed(t.display.decimals):r}function L(e){let t=j?g:h,n=A;if(!n)return{label:``,value:`--`,symbol:``,min:``,avg:``,max:``,windowMs:1,stats:void 0,minSpan:1,palette:t};let r=n.series.stats(e),a=e=>e===void 0?void 0:(r?.centre??0)+e,o=n.last&&e-n.last.time<E?n.last.value:void 0,s=n.display.conversion?1/Math.abs(n.display.conversion.factor):1;return{label:i(n.config),value:I(o,n),symbol:n.display.symbol,min:r?I(a(r.min),n):``,avg:r?I(a(r.avg),n):``,max:r?I(a(r.max),n):``,windowMs:n.series.windowMs,stats:r,minSpan:O*s,message:n.loading?`Loading…`:`No data`,palette:t}}function R(){F=!1;let e=k.getBoundingClientRect(),t=window.devicePixelRatio||1,n=Math.max(1,Math.round(e.width*t)),r=Math.max(1,Math.round(e.height*t));(k.width!==n||k.height!==r)&&(k.width=n,k.height=r);let i=k.getContext(`2d`);i&&(i.setTransform(t,0,0,t,0,0),S(i,e.width,e.height,L(Date.now())))}function z(){F||(F=!0,requestAnimationFrame(R))}async function B(e,t){let n=await m(e.config.path,e.series.windowMs,e.series.bucketMs);if(t===M){if(n.length>0){e.series.clear();for(let t of n)e.series.merge(t.time,t.min,t.max,t.avg);e.last&&e.series.add(e.last.time,e.last.value)}e.loading=!1,z()}}async function V(e){let i=++M;if(N){let e=N;N=void 0,await e().catch(()=>void 0)}P&&clearInterval(P);let a=t(await e.state.get()),o=await s(a.path);if(i!==M)return;let c=l(o,a.unit||void 0,a.decimals),u={config:a,display:c,series:new T(r(a),c.angular),signed:n(a.path),loading:!0};A=u,z(),N=await e.signalk.subscribe([a.path],e=>{if(typeof e.value!=`number`||!Number.isFinite(e.value))return;let t=Date.now();u.last={time:t,value:e.value},u.series.add(t,e.value),z()}),P=setInterval(z,Math.max(1e3,u.series.bucketMs)),await B(u,i)}async function H(){let t=await e();a(t),new ResizeObserver(z).observe(k),await t.subscribe([`state.changed`],()=>{V(t).catch(e=>{console.warn(`history strip: settings reload failed`,e)})}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&A&&B(A,M)}),await o(t,e=>{j=e,z()}).catch(e=>{console.warn(`history strip: night mode unavailable`,e)}),await V(t)}H().catch(e=>{console.warn(`history strip: host connection failed`,e)});
|