trmnl_preview 0.30.1 → 0.30.2
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/trmnlp/app.rb +1 -1
- data/lib/trmnlp/screenshot.rb +25 -0
- data/lib/trmnlp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 685a69fdb40d83171f2f8cb17d89b6954fae9c97f9f551d4210d228acbdb0690
|
|
4
|
+
data.tar.gz: e666f0a63344dc33447eb70cabf3202bab6c6030f967716e3b50954583e222e7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a53e8130820062a99d94d25b2a140506baefccb9e2747c30c46d2cc7795a96c423c4c537c520514c3706a9aafacd1cb215957fdd3af6048b5145632ddb24058a
|
|
7
|
+
data.tar.gz: ebbaa2038fb76c066394dd98218a5305741d2b274763ddc2d41ad4151fc096763ec4593338f364d71807f032687264341e0585f17cf630684276101d757c6f78
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
# Changelog
|
|
3
3
|
|
|
4
|
+
## 0.30.2
|
|
5
|
+
|
|
6
|
+
- `trmnlp serve`'s HTML preview of a device TRMNL scales runs the page's scripts at the CSS size too, then shows the page at the device's size and stops its timers, as the PNG and the device do. Before, a table showed 8 of 20 rows on a TRMNL X where the device shows 15.
|
|
7
|
+
|
|
4
8
|
## 0.30.1
|
|
5
9
|
|
|
6
10
|
- A screen on a device TRMNL scales, as the TRMNL X or a Kobo, runs its scripts at the CSS size and is scaled only for the picture, as TRMNL does. Before, the scripts measured the scaled page, so a table cut rows the device shows (7 of 14 on a TRMNL X) and clamped text kept lines the device cuts.
|
data/lib/trmnlp/app.rb
CHANGED
data/lib/trmnlp/screenshot.rb
CHANGED
|
@@ -49,6 +49,31 @@ module TRMNLP
|
|
|
49
49
|
Promise.race([window.TRMNLMaps.refresh(), timeout]).then(() => done(true), () => done(false));
|
|
50
50
|
JS
|
|
51
51
|
|
|
52
|
+
# The live preview settles in the page as a capture does, then stays still, as the device shows it.
|
|
53
|
+
SETTLE_LIVE_PREVIEW = <<~JS.freeze
|
|
54
|
+
(async () => {
|
|
55
|
+
const wait = window.setTimeout.bind(window);
|
|
56
|
+
const sleep = (ms) => new Promise((resolve) => wait(resolve, ms));
|
|
57
|
+
const ready = () => { #{READINESS_CHECK_SCRIPT} };
|
|
58
|
+
const readyBy = Date.now() + 1000 * %d;
|
|
59
|
+
while (!ready() && Date.now() < readyBy) await sleep(50);
|
|
60
|
+
if (document.fonts) await Promise.race([document.fonts.ready, sleep(#{FONTS_TIMEOUT_SECONDS * 1000})]);
|
|
61
|
+
if (typeof window.TRMNLMaps?.refresh !== 'function') {
|
|
62
|
+
#{FREEZE_TIMERS}
|
|
63
|
+
#{APPLY_CAPTURE_SCALE}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
#{APPLY_CAPTURE_SCALE}
|
|
67
|
+
await Promise.race([window.TRMNLMaps.refresh(), sleep(8000)]).catch(() => {});
|
|
68
|
+
#{FREEZE_TIMERS}
|
|
69
|
+
})();
|
|
70
|
+
JS
|
|
71
|
+
|
|
72
|
+
def self.live_preview(html)
|
|
73
|
+
timeout = html.match?(MAPS_DOCUMENT_PATTERN) ? READINESS_TIMEOUT_WITH_MAPS_SECONDS : READINESS_TIMEOUT_SECONDS
|
|
74
|
+
html.sub('</head>', "#{LAYOUT_PASS_STYLE}<script>#{format(SETTLE_LIVE_PREVIEW, timeout)}</script></head>")
|
|
75
|
+
end
|
|
76
|
+
|
|
52
77
|
def initialize(pool:, viewport_timeout: 5, fonts_timeout: FONTS_TIMEOUT_SECONDS)
|
|
53
78
|
@pool = pool
|
|
54
79
|
@viewport_timeout = viewport_timeout
|
data/lib/trmnlp/version.rb
CHANGED