trmnl_preview 0.12.0 → 0.13.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e476239f7e0c53801c4a3100d40640de825bda5ad90174893caf919d26c7a8c4
4
- data.tar.gz: 66552a72bd4a6e761090064712f8bc01cb84c5cbff4a8a166b14020f6fcf8f79
3
+ metadata.gz: ecba4b3a3029f83fccf8ec4efd0215f8a83a8d0d12f2bdaaeef01ee4647b7f8a
4
+ data.tar.gz: bdbca95517982906657d3b568446c8c525976d9cd0a128e2a96d7c923ff8b59b
5
5
  SHA512:
6
- metadata.gz: 54e5c7f1044484fb55f26881a8c853455fdf0a3149ad9567633dec55fc2004c36645ab84c00589984cb82192298fd0a8ab40040ed5c57442058595d532102508
7
- data.tar.gz: dea4cfcecfeb3fabf9f0df522cc23bffbf90dc1638f03406d17d1022ae777f2846fe9fd7acd1ced2b7c379c2bd6e3d79d665e7b94e80864a64698c3c617ea4ef
6
+ metadata.gz: 7e599a894d8ef1fc3c3f89f22293284e188d26a563cc063bba5dbdee35865da6eac91ef64c27d1684f91e160e946433b52cf438ecd8f6c02f6cff5ccccbaba0e
7
+ data.tar.gz: aeb473789628ed40f5a68b14978dddb6ac1fbc49d32828a69c1a4de68abca941ba3288f6d5fac2be66f0c9f0ed4869389b5be8cf6c9d3ecb59db4a3dd0257ef0
data/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
 
2
2
  # Changelog
3
3
 
4
+ ## 0.13.1
5
+
6
+ - `lat_lon` is a known form field type, so `trmnlp lint`, `build` and `serve` no longer warn "unknown field_type: lat_lon" for a location field. The vendored list in `db/data/form_fields.yml` predated the hosted service adding it. (#129)
7
+
8
+ ## 0.13.0
9
+
10
+ - `trmnlp login` now accepts the scoped API keys trmnl.com issues with a `trmnl_` prefix, as well as `user_` account keys. It used to refuse them with "Invalid API key; did you copy it from the right place?" before checking them with the server. A scoped key needs the profile capability to log in, read to list and pull, and content to push. With delete as well, a failed first push removes the plugin it created. (#132)
11
+ - The local preview now fills the `trmnl` fields the hosted service added: `trmnl.device.model`, `bit_depth`, `firmware_version`, `refresh_interval_seconds`, `sleep_mode_enabled`, `sleep_start_time` and `sleep_end_time`, and `trmnl.plugin_settings.refresh_interval_minutes`. The model and bit depth follow the device picker, with `og_plus` and 2 when nothing is picked. (#131)
12
+
4
13
  ## 0.12.0
5
14
 
6
15
  - `required_ruby_version` is now `>= 4.0`, matching the Ruby version trmnlp actually needs. It has understated the real floor since 0.4.0: both `xdg` (Ruby 4.0 in the 10.x series pinned since 0.8.0) and `trmnl-liquid` (Ruby 4.0 since 0.5.0) require more than the gemspec claimed. RubyGems resolves against the declared value, so `gem install trmnl_preview` on an older Ruby did not fail. It quietly walked backwards to the newest version whose dependency tree resolved, reporting "Successfully installed" for a build up to twenty months old. On Ruby 3.4 that was 0.7.1, and on Ruby 3.3 and below it was 0.3.2, which predates the Thor CLI and offers only `serve`, `build` and `version`. Asking for the current version explicitly (`gem install trmnl_preview -v 0.11.0`) crashed RubyGems inside its own conflict reporting rather than explaining the problem. Installing on an unsupported Ruby now stops with "requires Ruby version >= 4.0".
@@ -18,6 +18,7 @@ field_types:
18
18
  - copyable
19
19
  - copyable_webhook_url
20
20
  - date
21
+ - lat_lon
21
22
  - multi_string
22
23
  - number
23
24
  - password
@@ -17,8 +17,8 @@ module TRMNLP
17
17
  api_key = prompt('API Key: ')
18
18
  raise InvalidApiKey, 'API key cannot be empty' if api_key.empty?
19
19
 
20
- # Only trmnl.com issues user_-prefixed keys; BYOS servers use their own token formats (e.g. Sanctum).
21
- if config.app.trmnl_host? && !api_key.start_with?('user_')
20
+ # Only trmnl.com issues user_ and trmnl_ prefixed keys; BYOS servers use their own token formats (e.g. Sanctum).
21
+ if config.app.trmnl_host? && !api_key.start_with?('user_', 'trmnl_')
22
22
  raise InvalidApiKey,
23
23
  'Invalid API key; did you copy it from the right place?'
24
24
  end
@@ -26,6 +26,7 @@ module TRMNLP
26
26
  end
27
27
 
28
28
  def strategy = @config['strategy']
29
+ def refresh_interval = @config['refresh_interval']
29
30
  def polling? = strategy == 'polling'
30
31
  def webhook? = strategy == 'webhook'
31
32
  def static? = strategy == 'static'
@@ -29,7 +29,8 @@ module TRMNLP
29
29
  end
30
30
 
31
31
  def device_from_params(params)
32
- { 'width' => params[:width]&.to_i, 'height' => params[:height]&.to_i }.compact
32
+ { 'width' => params[:width]&.to_i, 'height' => params[:height]&.to_i,
33
+ 'model' => params[:model], 'bit_depth' => params[:bit_depth]&.to_i }.compact
33
34
  end
34
35
 
35
36
  private
@@ -86,13 +87,17 @@ module TRMNLP
86
87
  {
87
88
  'friendly_id' => 'ABC123', 'percent_charged' => 85.0, 'wifi_strength' => 90,
88
89
  'height' => device['height'] || DEFAULT_DEVICE_HEIGHT,
89
- 'width' => device['width'] || DEFAULT_DEVICE_WIDTH
90
+ 'width' => device['width'] || DEFAULT_DEVICE_WIDTH,
91
+ 'model' => device['model'] || 'og_plus', 'bit_depth' => device['bit_depth'] || 2,
92
+ 'firmware_version' => '1.6.3', 'refresh_interval_seconds' => 900,
93
+ 'sleep_mode_enabled' => false, 'sleep_start_time' => 1320, 'sleep_end_time' => 480
90
94
  }
91
95
  end
92
96
 
93
97
  def plugin_settings_namespace
94
98
  {
95
99
  'instance_name' => 'instance_name',
100
+ 'refresh_interval_minutes' => config.plugin.refresh_interval,
96
101
  'strategy' => config.plugin.strategy,
97
102
  'dark_mode' => config.plugin.dark_mode,
98
103
  'polling_headers' => config.plugin.polling_headers_encoded,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TRMNLP
4
- VERSION = '0.12.0'
4
+ VERSION = '0.13.1'
5
5
  end
data/web/public/index.js CHANGED
@@ -20,18 +20,22 @@ trmnlp.connectLiveRender = function () {
20
20
  };
21
21
 
22
22
 
23
+ // trmnl.device values the picked model and palette decide.
24
+ trmnlp.deviceParams = function (state) {
25
+ const bitDepth = Math.ceil(Math.log2(state.palette?.grays || 2));
26
+ return new URLSearchParams({ width: state.width, height: state.height, model: state.model.name, bit_depth: bitDepth });
27
+ };
28
+
23
29
  trmnlp.fetchPreview = function (pickerState) {
24
30
  const state = pickerState || trmnlp.picker?.state;
25
31
  const screenClasses = (state?.screenClasses || []).join(" ");
26
32
  const encodedScreenClasses = encodeURIComponent(screenClasses);
27
33
  let src = `/render/${trmnlp.view}.${trmnlp.formatSelect.value}?screen_classes=${encodedScreenClasses}`;
28
34
 
29
- // Pass dimensions for both HTML and PNG renders so trmnl.device.{width,height}
35
+ // Pass the device for both HTML and PNG renders so trmnl.device.{width,height,model,bit_depth}
30
36
  // in the Liquid context tracks the picker model selection.
31
37
  if (state) {
32
- const width = encodeURIComponent(state.width);
33
- const height = encodeURIComponent(state.height);
34
- src += `&width=${width}&height=${height}`;
38
+ src += `&${trmnlp.deviceParams(state)}`;
35
39
  }
36
40
 
37
41
  // PNG-only: dark mode + color depth from palette
@@ -48,7 +52,7 @@ trmnlp.fetchPreview = function (pickerState) {
48
52
 
49
53
  trmnlp.refreshUserData = async function (state) {
50
54
  if (!state) return;
51
- const params = new URLSearchParams({ width: state.width, height: state.height });
55
+ const params = trmnlp.deviceParams(state);
52
56
  try {
53
57
  const response = await fetch(`/data?${params}`);
54
58
  if (!response.ok) return;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trmnl_preview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rockwell Schrock