feat(cli): live preview in the browser with gram view --serve #255
No reviewers
Labels
No labels
bug
discussion
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
research
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gram-lang/gram!255
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/view-serve"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Step C of the 1.6 plan (
.notes/v1.6/plan-etape-c.md):gram view <file> --serveserves a live preview of the recipe on127.0.0.1, for any editor.PipelineResult.dependencies(every file the recipe was read from, or tried to be, missing@usetargets included),ExportOptions.onPipeline,NothingToShowError.services/preview-server.ts, genericnode:httpserver with SSE: one page with a tab per view that has anhtmlformat, a print button loading/print(theprintformat, same asgram print) in a hidden iframe,/client.js= the renderer'sTOOLTIP_SCRIPT. Host check against DNS rebinding, per-route CSP, a directory watcher robust to atomic saves, renders serialized with a generation counter, last valid page kept under a banner on error.services/view-serve.ts(flags, validation, render reading config/DB/scale/kitchen on every render) and--serve,--port,--no-open,--viewingram view, which now takes the run sheet settings too and refuses an extra positional (--serve "<date>"written thegram planway).renderer.print,renderer.disconnectedinenandfr.@gram-lang/cli.Deviations from the plan, forced by the code:
/allowsstyle-src 'unsafe-inline': the renderer's HTML has inlinestyleattributes (copy button). Scripts stay'self'only.MODULE_PARSE_ERRORon the entry) to show the banner.loadDb/resolveScaleFactorinstead of their*Safevariants in the render, so a broken config mid-session shows the banner instead of exiting.settings-parity.test.ts:gram viewnow exposes--clock.The last commit aligns
openInBrowser()with #254 (fix onmain, without its changeset), so mergingmainintodev/1.6brings no conflict.Tests:
preview-server.test.ts(real HTTP on port 0: routes, Host, CSP, live updates incl. rename saves,@usewritten before its file, errors, concurrency, shutdown),view-serve-args.test.ts, exporter tests. Not done: a manual run in Neovim/Helix and in a real browser.