Skip to content

Commit 248e458

Browse files
committed
Added README to all crates
1 parent 0ded7ec commit 248e458

21 files changed

Lines changed: 709 additions & 161 deletions

File tree

crates/gosub_config/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# gosub_config
2+
3+
The runtime settings store of the Gosub engine. Schema-agnostic by design: the caller
4+
supplies the schema (known keys, defaults, constraints) and only known keys can be read
5+
or written — this crate ships no settings of its own. The engine's schema lives in
6+
`gosub_engine` (`settings.json` / `useragent-settings.json`), which seeds a `Config` via
7+
`gosub_engine::default_settings()`.
8+
9+
Not to be confused with compile-time component selection (`ModuleConfiguration` /
10+
`DefaultRenderConfig`) — that is a different mechanism, documented in
11+
[docs/configuration.md](../../docs/configuration.md). This crate is for values that
12+
change at runtime.
13+
14+
## Entry points
15+
16+
- `Config` — cheap-to-clone handle (`Arc<RwLock<ConfigStore>>`); `Config::new(schema)`
17+
or `with_storage(schema, storage)`. Typed getters (`get_bool`, `get_uint`, ...),
18+
wildcard `find`, namespaced `merge`, and change **subscriptions**
19+
(`subscribe`/`unsubscribe` with wildcard patterns).
20+
- `StorageAdapter` — the pluggable persistence trait, with three implementations:
21+
`MemoryStorageAdapter` (default), `JsonStorageAdapter`, and `SqliteStorageAdapter`
22+
(not available on wasm32).
23+
- `settings::{Setting, SettingInfo, Constraint}` — the value model: typed settings with
24+
a wire format (`b:true`, `u:1000`, `s:...`) and constraints (enums, numeric ranges).
25+
- `HasConfig` — accessor bound so subsystems depend on `T: HasConfig` rather than a
26+
concrete context type.
27+
28+
## Trying it
29+
30+
The `config-store` example in the workspace root demonstrates the store:
31+
`cargo run --example config-store`.
32+
33+
## Further reading
34+
35+
- [docs/configuration.md](../../docs/configuration.md) — the two configuration layers
36+
and where this store fits

crates/gosub_css3/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# gosub_css3
2+
3+
The CSS3 system of the Gosub browser engine: tokenizer, parser, selector matcher, cascade,
4+
and property-value validation. Parsing follows the csstree (MIT) parser design. A stylesheet
5+
goes from text to a `CssStylesheet` (rules, selectors, declarations), and `Css3System`
6+
implements the `CssSystem` trait from `gosub_interface` — selector matching, cascade, and
7+
computed-value resolution for the rest of the engine.
8+
9+
## Entry points
10+
11+
- `Css3::parse_str(data, config, origin, source_url)` / `Css3::parse_stream(...)`
12+
stylesheet text → `CssStylesheet`.
13+
- `system::Css3System` — the `CssSystem` implementation; the main integration point
14+
(`Stylesheet = CssStylesheet`, `Property = CssProperty`, `Value = CssValue`).
15+
- `load_default_useragent_stylesheet()` — the embedded `resources/useragent.css`.
16+
- `matcher::syntax_matcher` — validates property values against their formal grammar
17+
(definitions embedded from `resources/definitions/*.json`).
18+
19+
## What lives here
20+
21+
| Module | Role |
22+
|--------|------|
23+
| `tokenizer`, `parser` | CSS text → AST, one parser module per construct (selectors, at-rules, calc, ...) |
24+
| `ast`, `node` | The AST and `convert_ast_to_stylesheet` |
25+
| `stylesheet` | The flattened `CssStylesheet` model and `CssValue` |
26+
| `matcher` | Selector matching, cascade, shorthand expansion, value-grammar validation |
27+
| `system` | `Css3System`, property computation, vendor-prefix normalization |
28+
| `functions` | `var()`, `attr()`, and the math functions (`calc`, `clamp`, `min`, `max`) |
29+
| `colors`, `walker` | Color parsing (named colors, hex, hsl, oklab/oklch) and an AST pretty-printer |
30+
31+
## Known limitations
32+
33+
- Most at-rules are dropped during AST → stylesheet conversion; only `@font-face` and
34+
`@layer` survive (the latter without layer-cascade semantics), and `@media` is not
35+
yet honored.
36+
- Not every longhand has a value-grammar definition, and the `background` shorthand is
37+
only partially recovered.
38+
39+
A recursion guard (`MAX_RECURSION_DEPTH = 64`) protects the parser against
40+
stack-overflowing input. The `unresolved_syntax` feature gates experimental
41+
syntax-matcher paths.
42+
43+
## Further reading
44+
45+
- [docs/css.md](../../docs/css.md) — the full parse → match → cascade → computed-value flow
46+
- [docs/interface.md](../../docs/interface.md) — the `CssSystem` trait contract
47+
- [docs/binaries.md](../../docs/binaries.md) — the `css3-parser` tool (run from the repo
48+
root: `cargo run --bin css3-parser`; note it parses without validating values)

crates/gosub_engine/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# gosub_engine
2+
3+
The primary public API of the Gosub browser engine — the crate you depend on to build a
4+
user agent or embed the engine. It ties the parser, CSS, layout, and rendering crates
5+
together behind an async, channel-driven surface: the engine emits `EngineEvent`s, and
6+
the embedder drives it with `EngineCommand` (engine/zone level) and `TabCommand` (per
7+
tab, via `TabHandle`). Work in progress; not yet production-ready.
8+
9+
## The model
10+
11+
- **`GosubEngine`** — create, `start()`/`run()`, `subscribe_events()`, `create_zone()`.
12+
- **Zones** — separate profiles. Each `Zone` owns its cookie jar and storage isolation;
13+
tabs live inside a zone.
14+
- **Tabs** — browsing contexts driven through `TabHandle`; per-tab runtime state
15+
(DOM, render pipeline caches) lives in a `BrowsingContext`.
16+
- **`EngineConfig`** — set-once engine configuration via `EngineConfig::builder()`;
17+
the dynamic settings store (`default_settings()`, backed by `gosub_config`) handles
18+
runtime-changeable values.
19+
- **`DefaultRenderConfig<Backend, FontSystem, Sink>`** — the zero-sized marker type that
20+
wires the standard `gosub_html5` + `gosub_css3` stack to your chosen render backend and
21+
font system. The default is headless (`NullBackend` + `ParleyFontSystem`).
22+
23+
## What lives here
24+
25+
| Area | Contents |
26+
|------|----------|
27+
| `engine/` | `GosubEngine`, zones, tabs, events, `BrowsingContext`, UA policy, settings store |
28+
| `net` | The engine side of networking: dedicated Tokio I/O thread, routing and content decisions, streaming bodies. The fetcher core is the external [gosub-sonar](https://github.com/gosub-io/gosub-sonar) crate |
29+
| `cookies` | `CookieJar` with in-memory, JSON, and SQLite stores (feature `sqlite_cookie_store`, on by default) |
30+
| `storage` | localStorage/sessionStorage services with partitioning policies |
31+
| `resource_pipeline` | Per-asset-kind fetch/parse pipelines (html, css, js, image, font) |
32+
| `html` | `DefaultRenderConfig`, `RenderConfiguration`, document parsing entry points |
33+
34+
Other features: `metrics` (engine metrics module), `ui_eframe` / `winit` / `wayland` /
35+
`x11` (GUI-toolkit integration glue).
36+
37+
## Getting started
38+
39+
Start from [`examples/hello-world.rs`](../../examples/hello-world.rs), then the
40+
[tutorial](../../docs/tutorial.md). The headless path is documented in
41+
[docs/headless.md](../../docs/headless.md) with `gosub-screenshot` as the reference.
42+
43+
## Further reading
44+
45+
- [docs/tutorial.md](../../docs/tutorial.md) — engine / zone / tab concepts, first integration
46+
- [docs/zones-and-tabs.md](../../docs/zones-and-tabs.md) — the runtime model
47+
- [docs/configuration.md](../../docs/configuration.md) — choosing backend and font system
48+
- [docs/cookies.md](../../docs/cookies.md), [docs/datastores.md](../../docs/datastores.md) — isolation and persistence
49+
- [docs/network/](../../docs/network/) — the networking architecture
50+
- [docs/resource-pipeline.md](../../docs/resource-pipeline.md) — async resource loading

crates/gosub_fontmanager/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# gosub_fontmanager
2+
3+
Concrete font-system implementations for the Gosub browser engine: font registration,
4+
CSS-query resolution (including raw font bytes), shaping into positioned glyph runs, and
5+
measurement. The `FontSystem` trait itself lives in `gosub_interface`; this crate only
6+
provides implementations. None of them draws glyphs — painting is each render backend's
7+
job.
8+
9+
## The implementations
10+
11+
| Type | Backing libraries | Availability | Typical pairing |
12+
|------|-------------------|--------------|-----------------|
13+
| `ParleyFontSystem` | Parley + Fontique | always | default; used with the Vello backend |
14+
| `CosmicFontSystem` | cosmic-text + rustybuzz + swash | always | pure-Rust alternative, not wired into any default config |
15+
| `PangoFontSystem` | fontconfig + Pango/HarfBuzz | feature `pango` | the Cairo configs |
16+
| `SkiaFontSystem` | Skia textlayout | feature `skia` | the Skia configs |
17+
18+
Each maps the shared `gosub_interface` value types (`TextStyle`, `FontQuery` /
19+
`ResolvedFont` / `FontBlob`, `ShapedText` / `ShapedRun` / `ShapedGlyph`) onto its backing
20+
library. Examples pick a font system in their `type AppConfig` alias via
21+
`DefaultRenderConfig<Backend, FontSystem>`.
22+
23+
## Notes
24+
25+
- No default features; only Parley and Cosmic compile without opting in. `pango` pulls in
26+
GTK4/pangocairo/fontconfig; `skia` pulls in `skia-safe`.
27+
- The Pango system uses raw fontconfig FFI serialized behind a global mutex (concurrent
28+
fontconfig configuration mutation can segfault) — this is why the crate relaxes the
29+
workspace `unsafe_code` lint from forbid to deny.
30+
31+
## Further reading
32+
33+
- [docs/fonts.md](../../docs/fonts.md) — the full picture: font systems vs text
34+
rasterizers, and the comparison table
35+
- [docs/configuration.md](../../docs/configuration.md) — how a config pairs a backend
36+
with a font system

crates/gosub_html5/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# gosub_html5
2+
3+
The HTML5 tokenizer and parser of the Gosub browser engine, plus the DOM it produces. The
4+
tokenizer implements the WHATWG state machine (74 states, character references, error
5+
recovery), the tree builder implements the 23 insertion modes, and the result is a
6+
`DocumentImpl` — an arena-backed DOM addressed by `NodeId` handles, implementing the
7+
`Document` trait from `gosub_interface`.
8+
9+
## Entry points
10+
11+
- `Html5Parser::parse_document(&mut stream, &mut doc, options)` — parse a full document
12+
from a `ByteStream`; `parse_fragment(...)` for the fragment case.
13+
- `html_compile::<C>(html)` — one-call convenience: string in, document out.
14+
- `DocumentBuilderImpl::new_document(url)` — create an empty document to parse into.
15+
- `writer` — serialize a document back to HTML.
16+
17+
## What lives here
18+
19+
| Module | Role |
20+
|--------|------|
21+
| `tokenizer` | WHATWG tokenizer state machine, tokens, named character references |
22+
| `parser` | Tree construction: insertion modes, quirks handling, foreign content |
23+
| `document` | `DocumentImpl` + `NodeArena` storage, builder, fragments, task queue |
24+
| `node` | `NodeImpl` node payloads, arena, element data, visitors |
25+
| `writer` | DOM → HTML serialization |
26+
| `testing` | Harness for the vendored WHATWG html5lib-tests suite |
27+
28+
## Features and testing
29+
30+
- Cargo features `debug_parser` / `debug_parser_verbose` gate extra parser tracing.
31+
- Conformance tests run against the vendored html5lib-tests suite in `tests/data/`;
32+
the `html5-parser-test` and `parser-test` binaries live in the root package, so run
33+
them from the repo root: `cargo run --bin html5-parser-test`.
34+
- Criterion benches: `tokenizer`, `tree_construction`, `html_parser` (the latter installs
35+
a counting allocator, which is why this crate relaxes the workspace `unsafe_code` lint).
36+
37+
## Further reading
38+
39+
- [docs/html5.md](../../docs/html5.md) — tokenizer/tree-builder structure and the
40+
html5lib test harness
41+
- [docs/binaries.md](../../docs/binaries.md) — the `gosub-parser`, `html5-parser-test`
42+
and `display-text-tree` component tools
43+
- [docs/interface.md](../../docs/interface.md) — the `Html5Parser` / `Document` trait
44+
contracts this crate implements

crates/gosub_jsapi/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# gosub_jsapi
2+
3+
Implementations of browser Web APIs for Gosub, written as plain Rust with no knowledge of
4+
any JavaScript engine — the `gosub_webinterop` macros are the intended path for exposing
5+
them into a script context.
6+
7+
Currently exactly one API exists: **`console`**, per the
8+
[WHATWG console spec](https://console.spec.whatwg.org/).
9+
10+
## Entry points
11+
12+
- `console::Console``new(Box<dyn Printer>)`; implements `log` / `info` / `warn` /
13+
`error` / `debug`, `assert`, `trace`, `dir`, counting (`count` / `count_reset`),
14+
grouping (`group` / `group_collapsed` / `group_end`), and timers (`time` / `time_log` /
15+
`time_end`).
16+
- `console::Printer` — the pluggable output sink; `WritablePrinter<W>` adapts any
17+
`std::io::Write`, and `Buffer` is an in-memory sink used by the tests.
18+
19+
## Further reading
20+
21+
- [docs/javascript.md](../../docs/javascript.md) — where the Web APIs sit in the
22+
scripting stack and the current integration status

crates/gosub_lattice/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# gosub_lattice
2+
3+
The CSS table layout engine of the Gosub workspace — the table algorithm (CSS 2.1 §17)
4+
that general-purpose flex/grid layouters don't cover. The crate is deliberately
5+
standalone: its only dependency is `anyhow`, and it talks to the host layout engine
6+
exclusively through the `TableTree` adapter trait.
7+
8+
## How it plugs in
9+
10+
The host implements `TableTree` (node traversal, `table_role`, CSS property access, a
11+
`layout_cell` callback for measuring cell content, and `set_layout` write-back), then
12+
calls `compute_table_layout` once per table. The live adapter is `PipelineTableTree` in
13+
`gosub_render_pipeline`; `mock::MockTable` provides a DOM-free implementation for tests
14+
and experiments.
15+
16+
## What lives here
17+
18+
| Module | Role |
19+
|--------|------|
20+
| `model` | Walks the subtree into a typed `TableModel`, with CSS 2.1 anonymous-box fixups |
21+
| `grid` | Grid placement: resolves cells to `(row, col)` honoring colspan/rowspan |
22+
| `sizing` | Column-width algorithm and row heights (via the `layout_cell` callback) |
23+
| `compute` | `compute_table_layout`: section ordering, placement, write-back |
24+
| `types` | The flat data types crossing the adapter boundary (`CellLayout`, `CssLength`, ...) |
25+
| `mock` | `MockTable` builder for standalone use |
26+
27+
## Trying it
28+
29+
`cargo run --bin table_console -p gosub_lattice` renders demo tables as ASCII grids.
30+
31+
## Known limitations
32+
33+
`rowspan > 1` heights are not distributed yet; `border-collapse`, `table-layout: fixed`,
34+
and captions are parsed into the model but not consumed (layout always uses
35+
separate-borders + auto sizing); column widths scan only the first non-empty row.
36+
37+
## Further reading
38+
39+
- [docs/lattice.md](../../docs/lattice.md) — the algorithm and the `TableTree` contract
40+
- [docs/render-pipeline/layout.md](../../docs/render-pipeline/layout.md) — the lattice
41+
write-back into the pipeline's layouter
42+
- [docs/two-worlds.md](../../docs/two-worlds.md) — why lattice cooperates with the
43+
general layouter instead of replacing it

0 commit comments

Comments
 (0)