Contracts & Invariants
Public, user-visible guarantees that Webstir preserves across releases. These are validated by end-to-end tests and serve as the stable contract between the CLI and projects.
Source Layout
- Frontend:
src/frontend/** - Pages:
src/frontend/pages/<page>/index.html|css|ts - App assets:
src/frontend/app/** - Static assets:
src/frontend/{images|fonts|media}/** - Backend:
src/backend/**(entry:src/backend/index.ts) - Shared:
src/shared/** - Types:
types/**
Dev Outputs
build/frontend/**(includespages,images,fonts,media)build/backend/**
Publish Outputs
- Per page under
dist/frontend/pages/<page>/:index.htmlindex.<timestamp>.cssindex.<timestamp>.jsmanifest.json(lists fingerprinted asset names)
- Static assets under
dist/frontend/{images|fonts|media}/** - App assets under
dist/frontend/app/**
HTML Composition
- Base HTML at
src/frontend/app/app.htmlmust contain a<main>where page HTML is merged. - Clean URLs in dev:
/aboutserves/pages/about/index.html.
JavaScript/TypeScript
- ESM-only module graph; CommonJS is not supported.
- Compiled via
tsc --buildusing the embedded basetsconfig.
CSS
- Resolves
@importand asset URLs in dev. - Publish minification/prefixing (modern-only): preserves strings/urls and license comments; trims whitespace and trailing
;; normalizes numbers/zeros; collapses zero shorthands; shortens hex (#rrggbb→#rgb,#rrggbbaa→#rgba); strips legacy prefixes/values (-ms-*,-o-*,-khtml-*, legacy flexbox); adds minimal-webkit-where needed.
Dev Server
- Serves
build/frontend/**with SSE reload and an/api/*proxy to the Node server. - No-cache headers for HTML; short/no-cache for static assets in dev.
- Accepts client error reports at
POST /client-errors:- Requires
Content-Type: application/jsonand body up to 32KB. - Returns
204on success;415for unsupported media type;413if payload too large. - Forwards to the error tracking hook with correlation id support (
X-Correlation-IDor payloadcorrelationId).
- Requires
Error Handling
- Missing required inputs (base HTML, server entry) fails fast with clear messages.
- Publish removes comments and source maps from outputs.
- Template includes a client error handler (
/app/error.js) that throttles to 1/sec (max 20/session) and deduplicates repeats for 60s.
CLI Guarantees
- Commands:
init,build,watch,test,publish,add-page,add-test,help. - Default command:
watchwhen no command is provided.