Rebuild @screenly/edge-apps with failure-mode algorithm and single-file deploy - #5
Open
Sir-Monke wants to merge 3 commits into
Open
Rebuild @screenly/edge-apps with failure-mode algorithm and single-file deploy#5Sir-Monke wants to merge 3 commits into
Sir-Monke wants to merge 3 commits into
Conversation
- Scaffolded with the official create command: TypeScript in src/, Bun and Vite building to dist/, so a deploy uploads three files and nothing else. - Implements the approved failure-mode diagram. There are no credentials here, the USGS feed is public, so only the data half applies: cache on success, display_errors on failure, last-known-good otherwise, and an explicit unavailable state when there is no cache. - display_errors follows the library: same key, same false default, same panic-overlay, and the same signal-on-error so a crash cannot stall a playlist. - 8s fetch timeout to fit the screenshotter budget. Measured: signals at 8.1s on a hung feed, inside the 10s ready-signal window. - Single-use values moved into the functions that use them. - Release plumbing: CHANGELOG.md, CI and deploy workflows, user_version. - Drops .ignore, since deploying from dist/ makes it unnecessary, and five workflows for languages this repo has never contained. The library stylesheet and auto-scaler are deliberately not used. Both are commented in place with the reason. 24 failure-mode checks in e2e/failure-modes.mjs, all passing.
Deploying index.html plus ./js and ./css subdirectories does not work: the player sat in a downloading-content loop and the screenshotter returned 500 on the asset capture. The same app as one file renders on both. Measured against revisions 49, 50 and 51. - scripts/inline-bundle.mjs folds the CSS and JS back into index.html after Vite runs, wired as postbuild. It also drops type=module and crossorigin, which the IIFE bundle does not need, so there is no subresource fetch and no CORS for a player to get wrong. - stage, map and world were resolved at module top level. As a deferred module that happened after parsing and worked by accident; inlined as a classic script it runs before <body> exists and all three were null. They are resolved in start() instead. Verified: revision 51 deploys at 1/1 file and renders through Screenly's own capture endpoint. 24/24 failure-mode checks still pass.
…heir functions - jsdom, @types/jsdom, bun-types and @types/bun are scaffold defaults that nothing imports. tsconfig's types list is [vite/client, node], so the bun types were never loaded either. - playwright is now an explicit devDependency. e2e/failure-modes.mjs imports it by name and was resolving it transitively through @playwright/test, which works until that tree changes. - FETCH_TIMEOUT_MS, REFRESH_MS and KEPT had one use each. Moved into load(), start() and nearestKept(), same as compass and the map clamps. build:prod, build:dev and test:unit are duplicate aliases with no caller here, but the Edge Apps doc calls for a shared workflow template across repos and it may invoke them. Left in place deliberately.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Changes
Rebuilt on
@screenly/edge-apps, scaffolded with the officialcreatecommand. TypeScript insrc/, Bun and Vite, release plumbing per the Edge Apps development doc.index.htmlis now generated rather than hand-written; the design is unchanged, pixel for pixel.The failure-mode algorithm. There are no credentials here — the USGS feed is public — so the credential half of the diagram does not apply. What is left:
display_errorsdisplay_errorsfollows the library exactly: same key, samefalsedefault, samepanic-overlay, and the same signal-on-error, so a crash cannot stall a playlist. The last row is the diagram's Abort terminal —screenly.signalAbort()does not exist yet (T10903), so for now it states the problem and signals ready anyway, because an app that never signals holds the playlist for sixty seconds and is then dropped withPlaybackReason::LoadTimeout.Only the ten nearest quakes are cached, trimmed to the five fields drawn — 491 bytes rather than the feed's few megabytes, and a cached render is identical to a live one.
Timings. One clock: an 8s feed timeout. The screenshotter allows 10s for the page to go quiet and 10s more for the ready signal, so timing out early leaves room to fall back to cache, draw and signal. Measured at 8,089 ms to signal on a hung feed.
Single-use values moved into the functions that use them —
compassintoheading(), the 1500/12000 clamps intowidthToFitKept(), the feed URL intoload(),unitsintoaway().Release plumbing.
CHANGELOG.md, CI and deploy workflows,user_versionin the manifest. Drops.ignore— deploying fromdist/makes it unnecessary — and five workflows for Rust, Python and SQL, none of which this repo has ever contained.e2e/failure-modes.mjs, 24 checks, one per branch of the diagram.bun run verify.Checklist
Additional Notes/Comments
Two library bugs found on the way, both worth their own issues.
The default build output does not deploy.
edge-apps-scripts buildemitsindex.htmlplusjs/andcss/subdirectories. Deployed as-is, the player sticks in a "downloading content" loop andapi/v3/assets/<id>/capture/returns 500 — with a completely clean browser console, because nothing of the app ever executes. The same app as one file renders on both. Proven across three revisions: 49 (three files) broken, 50 (old single file) fine, 51 (rebuilt, inlined) fine. Root cause not isolated — either the player cannot serve nested asset paths, ortype="module" crossoriginfails on it.scripts/inline-bundle.mjssidesteps both by folding the CSS and JS back intoindex.htmlafter Vite runs. If this reproduces generally, every app scaffolded today has it.edge-apps-scriptsdoes not run on Windows.lint,type-check,build,devandbuild:devall fail with "The system cannot find the path specified".resolveBin()returnsnode_modules/.bin/<tool>with no.cmdor.exe, andexecSync/execFileSyncroute that throughcmd.exe, which cannot execute it. CI is unaffected. The README documents the direct-invocation workaround.Three things must be in place before either workflow can fire, none of which I can do:
masterrenamed tomain— both workflows trigger onmainanddevelopmentper the doc, so while this PR targetsmasterno checks will run on it.developmentbranch, for the stage environment.SCREENLY_API_TOKENrepo secret.Two conventions deliberately not adopted, both commented in place with the reason:
system-uion purpose. Skipping it takes the CSS from 458 KB to 3.4 KB.<auto-scaler>is not used. It scales a fixed 1920x1080 design, which would letterbox a portrait screen; the map window is fitted to the screen's real aspect ratio instead.Happy to change either if you would rather have consistency than the behaviour.