feat: shared @spoolid/core package; refactor web + desktop onto it#28
Open
mateusdemboski wants to merge 1 commit into
Open
feat: shared @spoolid/core package; refactor web + desktop onto it#28mateusdemboski wants to merge 1 commit into
mateusdemboski wants to merge 1 commit into
Conversation
spec/ts becomes the shared client core: TS wire types generated from spec/v2 schemas (json2ts, git-ignored), deduplicated pure logic (material-DB parsing incl. the meterialType quirk, read-prefill, write status interpretation, color normalization, protocol/minor compat gate, OTA target detection), design tokens (tokens.css - single palette, both UIs; web adopts the desktop theme), and vitest coverage. Both frontends now import @spoolid/core via a root pnpm workspace (one lockfile; nested workspace files removed). The desktop serial layer types replies as a discriminated union (ok: true | ErrorReply) instead of Record<string, any>; the compat gate is shared and protocol-aware, fixing the documented-but-unimplemented dev-build skip. v2 fixtures for spec/status/config/read-error re-captured from a live v2 device; serial getspec verified byte-identical to HTTP /api/spec on hardware. CI: wails build -clean (spec/ts changes don't dirty the frontend hash cache); build_web.py installs the workspace root. Refs #18 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SBnenzHAV3VVAF8b8hpwkT
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.
Summary
PR3 of #18 — the deduplication payoff. Web and desktop now share one core package.
@spoolid/core(spec/ts) — root pnpm workspace member, imported by both frontends, zero runtime deps, exported as TS source (Vite inlines it; web pages stay single-file self-contained, ~5 KB gz total):generated/— wire types fromspec/v2/schemasvia json2ts (git-ignored,pnpm generate)db.ts—parseMaterialDb(single owner ofresult.list[].base+meterialTypemisspelling); kills the "mirrors the web client" copyread.ts/status.ts— shared read-prefill + write-status interpretation (both pollStatus loops now one function)compat.ts— protocol-first gate with major.minor fallback; fixes the dev-build skip that main.ts documented but never implemented (minorOf("0.0.0-dev")parsed as"0.0")color.ts/ota.ts— hex normalization, swatch names (desktop's re-hardcoded 15-hex map deleted), OTA filename regextokens.css— one palette, token names documented in PROTOCOL.md. Web UI visibly changes: adopts the desktop green theme (was blue)material_database.jsonClient refactors: desktop
Replyis now a discriminated union (ok: true|ErrorReply) instead ofRecord<string, any>;applyRead/pollStatus/checkCompat/cmpVer/COLOR_NAMESdeleted frommain.ts; webapp.ts/config.tsare DOM glue over core.Workspace: root
pnpm-workspace.yaml(web, desktop/frontend, spec/ts), one lockfile, nested workspace files removed.wails build -cleanin CI/release (spec/ts changes don't dirty the frontend hash cache).build_web.pyinstalls the workspace root.Hardware verification: flashed v2 firmware; captured v2 fixtures (spec/status/config/read-error) from the live device; serial
getspecverified byte-identical to HTTP/api/specon hardware — the unification is real on the wire.Verification
pnpm --dir spec/ts test→ 14/14;validate.mjsgreen (v1+v2+generated fixtures)pnpm --dir web build→ 5 fixed-name self-contained files;tools/build_web.py→ 5 .gz, ~5 KBwails build -clean→ SUCCESS;eslintclean;pio test -e nativestill greenNote:
read.reply/ok.json+dump.reply/ok.jsonv2 fixtures are still hand-authored (need a tag on the reader to capture; shapes already machine-proven by the contract test in CI).Closes #18.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SBnenzHAV3VVAF8b8hpwkT