@rhizomatics/signalk-einklabel-plugin 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.6.3
2
+
3
+ - Improve logging if an image cannot be found in an `assets` directory to match a SignalK path value
4
+ - Expose `plugin_version` as a path for the `einklabel` source
5
+
1
6
  # 0.6.2
2
7
 
3
8
  - Auto default SignalK URL if `-u` or `-e` not passed as CLI arguments
package/README.md CHANGED
@@ -95,6 +95,7 @@ The source can be overridden to use the SignalK server's Resources API instead.
95
95
 
96
96
  - `path=repainted` - the timestamp of the current repaint - for example `source=einklabel,path=repainted,format=local_datetime_short` to show when the label was last updated.
97
97
  - `path=local_zone` - a short zone name (e.g. `BST`) for the same timezone used for `local_time`/`day_mon`/`local_datetime_short` (see above) - a fallback for `environment.time.timezoneRegion,format=utc_offset` on installs that never publish that path, since it needs no SignalK metadata of its own. Falls back to a plain UTC offset like `GMT+1` where the host's locale has no real abbreviation for the zone.
98
+ - `path=plugin_version` - expose the version of the eInk Label plugin itself.
98
99
 
99
100
  #### Customizing Output
100
101
 
@@ -11,6 +11,7 @@ const formatters_1 = require("../render/formatters");
11
11
  const httpJson_1 = require("../httpJson");
12
12
  const unitCategories_1 = require("../unitCategories");
13
13
  const pathMeta_1 = require("../pathMeta");
14
+ const pluginVersion_1 = require("../pluginVersion");
14
15
  const log_1 = require("./log");
15
16
  const RESOURCES_API_PATH = '/signalk/v2/api/resources';
16
17
  /** `context=self` -> `vessels/self`, `context=vessels.urn:mrn:imo:mmsi:1` -> `vessels/urn:mrn:imo:mmsi:1` - matches the REST path for that context's full-data-model subtree. */
@@ -78,7 +79,11 @@ async function assembleLiveContext(signalkUrl, bindings) {
78
79
  const categories = await (0, unitCategories_1.fetchCategoryDisplayUnits)(signalkUrl, categoryNames);
79
80
  // Matches `considerRepaint` in repaintScheduler.ts - the CLI has no real device repaint to time, so
80
81
  // a `source=einklabel,path=repainted` binding just resolves to "now", same as a live render would.
81
- const meta = { repainted: new Date().toISOString(), local_zone: (0, formatters_1.resolveLocalZoneAbbreviation)({ signalk }) };
82
+ const meta = {
83
+ repainted: new Date().toISOString(),
84
+ local_zone: (0, formatters_1.resolveLocalZoneAbbreviation)({ signalk }),
85
+ plugin_version: pluginVersion_1.PLUGIN_VERSION,
86
+ };
82
87
  return { signalk, resources, pathMeta, categories, meta };
83
88
  }
84
89
  async function readJsonFile(filePath) {
@@ -147,6 +152,10 @@ async function assembleExampleContext(examplesDir, bindings) {
147
152
  }
148
153
  }
149
154
  }
150
- const meta = { repainted: new Date().toISOString(), local_zone: (0, formatters_1.resolveLocalZoneAbbreviation)({ signalk }) };
155
+ const meta = {
156
+ repainted: new Date().toISOString(),
157
+ local_zone: (0, formatters_1.resolveLocalZoneAbbreviation)({ signalk }),
158
+ plugin_version: pluginVersion_1.PLUGIN_VERSION,
159
+ };
151
160
  return { signalk, resources, pathMeta: {}, categories, meta };
152
161
  }
package/dist/plugin.js CHANGED
@@ -29,7 +29,8 @@ async function runStartupScan(app, discovered, durationSeconds) {
29
29
  }
30
30
  discovered.push(found);
31
31
  const pid = found.pid !== undefined ? `0x${found.pid.toString(16).padStart(4, '0')}` : 'unknown';
32
- app.debug(`discovered ${driver.vendor} device "${found.name ?? ''}" [${found.address}] pid=${pid}`);
32
+ const hwid = found.hwVersion ?? 'unknown';
33
+ app.debug(`discovered ${driver.vendor} device "${found.name ?? ''}" [${found.address}] pid=${pid} hwid=${hwid}`);
33
34
  });
34
35
  });
35
36
  }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The installed plugin's own version, read from `package.json` once at module load - exposed to
3
+ * templates as `source=einklabel,path=plugin_version` (see `meta` in repaintScheduler.ts and
4
+ * `cli/liveContext.ts`), e.g. to show a build/version marker on a label for support purposes.
5
+ */
6
+ export declare const PLUGIN_VERSION: string;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PLUGIN_VERSION = void 0;
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
6
+ /**
7
+ * The installed plugin's own version, read from `package.json` once at module load - exposed to
8
+ * templates as `source=einklabel,path=plugin_version` (see `meta` in repaintScheduler.ts and
9
+ * `cli/liveContext.ts`), e.g. to show a build/version marker on a label for support purposes.
10
+ */
11
+ exports.PLUGIN_VERSION = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '..', 'package.json'), 'utf-8')).version;
@@ -128,6 +128,9 @@ class SvgRenderer {
128
128
  const key = (0, assets_1.normalizeAssetKey)((0, binding_1.resolveBinding)(binding, context));
129
129
  const assetPath = key && (0, assets_1.resolveAssetPath)(svgTemplatePath, binding.assets, key);
130
130
  if (!assetPath) {
131
+ console.error(key
132
+ ? `image "${descElement.textContent}" has no asset file for value "${key}" in "${binding.assets}"`
133
+ : `image "${descElement.textContent}" resolved to no usable value to pick an asset file with`);
131
134
  element.parentNode?.removeChild(element);
132
135
  continue;
133
136
  }
@@ -13,6 +13,7 @@ const formatters_1 = require("./render/formatters");
13
13
  const unitCategories_1 = require("./unitCategories");
14
14
  const pathMeta_1 = require("./pathMeta");
15
15
  const resolveApiUrl_1 = require("./resolveApiUrl");
16
+ const pluginVersion_1 = require("./pluginVersion");
16
17
  const INTERVAL_POLL_MS = 60000;
17
18
  const SUBSCRIPTION_DEBOUNCE_MS = 2000;
18
19
  function statePath(app) {
@@ -139,7 +140,11 @@ async function considerRepaint(app, config, device, state, getApiUrl) {
139
140
  }
140
141
  const renderContext = {
141
142
  ...rawContext,
142
- meta: { repainted: new Date().toISOString(), local_zone: (0, formatters_1.resolveLocalZoneAbbreviation)(rawContext) },
143
+ meta: {
144
+ repainted: new Date().toISOString(),
145
+ local_zone: (0, formatters_1.resolveLocalZoneAbbreviation)(rawContext),
146
+ plugin_version: pluginVersion_1.PLUGIN_VERSION,
147
+ },
143
148
  };
144
149
  const renderer = new svgRenderer_1.SvgRenderer();
145
150
  const bitmap = await renderer.render(templatePath, renderContext, metadata.width, metadata.height - metadata.voffset);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhizomatics/signalk-einklabel-plugin",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "Display SignalK data on eInk Electronic Shelf Labels",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,8 +23,8 @@
23
23
  inkscape:pagecheckerboard="0"
24
24
  inkscape:deskcolor="#d1d1d1"
25
25
  inkscape:zoom="1.3906433"
26
- inkscape:cx="249.88435"
27
- inkscape:cy="101.03238"
26
+ inkscape:cx="144.89697"
27
+ inkscape:cy="197.39066"
28
28
  inkscape:window-width="1488"
29
29
  inkscape:window-height="674"
30
30
  inkscape:window-x="24"
@@ -71,19 +71,19 @@
71
71
  transform="scale(0.89274878,1.1201359)">Tidal Station Name<desc
72
72
  id="desc1">source=resources,resource=tides,path=station.name</desc></text><text
73
73
  id="source"
74
- x="347.95166"
74
+ x="367.44577"
75
75
  y="226.1548"
76
76
  font-size="18"
77
77
  font-family="serif"
78
78
  fill="black"
79
- style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;font-family:sans-serif;-inkscape-font-specification:'Roboto',sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#ff0000;stroke-width:3.80045"
80
- transform="scale(0.95907863,1.0426674)"><desc
79
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;font-family:sans-serif;-inkscape-font-specification:'\'Roboto\', sans-serif';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#ff0000;stroke-width:3.80045"
80
+ transform="scale(0.95907862,1.0426674)"><desc
81
81
  id="desc21">source=resources,resource=tides,path=station.source.name</desc><tspan
82
82
  sodipodi:role="line"
83
83
  id="tspan20"
84
- x="347.95166"
84
+ x="367.44577"
85
85
  y="226.1548"
86
- style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3332995px;font-family:sans-serif;-inkscape-font-specification:'Roboto',sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke-width:3.80045">SOURCE</tspan></text><text
86
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;font-family:sans-serif;-inkscape-font-specification:'\'Roboto\', sans-serif';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke-width:3.80045">SOURCE</tspan></text><text
87
87
  id="last_repaint"
88
88
  x="4.3477793"
89
89
  y="201.9895"
@@ -119,8 +119,8 @@
119
119
  fill="red"
120
120
  style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:22.6667px;font-family:sans-serif;-inkscape-font-specification:'Roboto, Normal',sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#ff0000"><desc
121
121
  id="desc15">source=resources,resource=tides,path=extremes[2].label</desc>High or Low</text><text
122
- id="environment.time.timezoneRegion"
123
- x="239.09819"
122
+ id="timezone"
123
+ x="330.60489"
124
124
  y="204.67754"
125
125
  font-size="10.373px"
126
126
  font-family="sans-serif"
@@ -128,7 +128,20 @@
128
128
  style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;font-family:sans-serif;-inkscape-font-specification:'Roboto, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;direction:rtl;fill:#000000;stroke-width:0.864419"
129
129
  transform="scale(0.86441854,1.156847)">UTC+01:00<desc
130
130
  id="desc11">source=einklabel,path=local_zone</desc></text><text
131
- id="lat"
131
+ id="plugin_version"
132
+ x="194.07487"
133
+ y="204.51942"
134
+ font-size="10.373px"
135
+ font-family="sans-serif"
136
+ fill="#ffff00"
137
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;font-family:Roboto;-inkscape-font-specification:'Roboto, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;direction:rtl;fill:#000000;stroke-width:0.864419"
138
+ transform="scale(0.86441854,1.156847)"><desc
139
+ id="desc16">source=einklabel,path=plugin_version</desc><tspan
140
+ sodipodi:role="line"
141
+ id="tspan1"
142
+ x="194.07487"
143
+ y="204.51942">v0.0.1</tspan></text><text
144
+ id="min_tide"
132
145
  x="282.65424"
133
146
  y="24.967674"
134
147
  font-size="12px"
@@ -140,7 +153,7 @@
140
153
  id="tspan17"
141
154
  x="282.65424"
142
155
  y="24.967674">0.0m</tspan></text><text
143
- id="hat"
156
+ id="max_tide"
144
157
  x="360.77148"
145
158
  y="24.967674"
146
159
  font-size="12px"
@@ -211,7 +224,7 @@
211
224
  style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:37.3333px;font-family:monospace;-inkscape-font-specification:'Roboto Mono, Bold',monospace;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000;stroke-width:1.55397"
212
225
  transform="scale(0.74654856,1.3394976)">03:27<desc
213
226
  id="desc3">source=resources,resource=tides,path=extremes[0].time,format=local_time</desc></text><text
214
- id="extremes.0.time-8"
227
+ id="extremes.0.date"
215
228
  x="10.326324"
216
229
  y="74.630478"
217
230
  font-size="14"
@@ -220,7 +233,7 @@
220
233
  style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:22.6667px;font-family:sans-serif;-inkscape-font-specification:'Roboto, Normal',sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#666666;stroke-width:1.32646"
221
234
  transform="scale(0.82428216,1.2131768)"><desc
222
235
  id="desc2">source=resources,resource=tides,path=extremes[0].time,format=day_mon</desc>27 Jun</text><text
223
- id="extremes.0.time-8-5"
236
+ id="extremes.1.date"
224
237
  x="9.9649849"
225
238
  y="123.34451"
226
239
  font-size="14"
@@ -229,7 +242,7 @@
229
242
  style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:22.6667px;font-family:sans-serif;-inkscape-font-specification:'Roboto, Normal',sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#666666;stroke-width:1.32646"
230
243
  transform="scale(0.82428216,1.2131768)"><desc
231
244
  id="desc7">source=resources,resource=tides,path=extremes[1].time,format=day_mon</desc>27 Jun</text><text
232
- id="extremes.0.time-8-9"
245
+ id="extremes.2.date"
233
246
  x="12.934491"
234
247
  y="156.77794"
235
248
  font-size="14"