Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
474 changes: 311 additions & 163 deletions README.md

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@ okf_version: '0.2'
- [Project README](../README.md) — product overview, API preview, implementation order, and local setup.
- [Project brief](planning/project-brief.md) — product outcome, scope, non-goals, and success criteria.
- [Canonical roadmap](roadmap/roadmap.md) — implementation sequence, issue-sized milestones, dependencies, and exit gates.
- [Runtime and bake API V0](planning/api-shapes.md) — accepted V1 public API, package boundaries, and explicitly deferred additions.
- [Raster and baker plugin guide](planning/raster-baker-plugin.md) — build an external technique through the public runtime, baker, artifact, discovery, and lifecycle contracts.
- [Merged v0 runtime and bake API](planning/api-shapes.md) — migration fixture for the implemented, unreleased package boundaries and explicitly deferred additions.
- [Three.js text API](planning/three-api.md) — authoritative Three-native loader, explicit `TextGroup` batching, reusable text across group disposal, retained non-throwing errors, ordering, and lifecycle contract.
- [Core text API](planning/core-api.md) — authoritative API for ordered font stacks, batch-owned paragraph handles, identity-preserving capacity changes, fixed-capacity failure, synchronized updates, and renderer-ready glyph batches.
- [Engine integration contract](planning/engine-integration-contract.md) — exact storage, batching, submission, ownership, staging, and frame-publication boundary for custom renderers.
- [Raster technique and engine resource API](planning/raster-technique-api.md) — portable artifact loading, CPU raster data, glyph-resource binding, reusable shader-backend programs, and engine target ownership.
- [TypeGPU-first shader authority](planning/typegpu-first-shader-authority.md) — exploratory TypeGPU-first shader/program architecture, Three and gpucat bridge limits, fallback authority models, and proof gates.
- [Merged v0 raster and baker plugin guide](planning/raster-baker-plugin.md) — build against the implemented combined runtime/renderer module before the target v1 extraction replaces it.
- [External gpucat integration fitness plan](planning/gpucat-integration.md) — source-validated proof plan for consuming the target v1 core without private imports or core changes.

## Architecture and data contracts

- [Architecture](planning/architecture.md) — ownership, loading, shaping, paragraph, and raster boundaries.
- [Renderer-neutral core and engine plan](planning/engine-integration-boundary.md) — WIP extraction sequence and proof gates for Three.js and Wayfare.
- [Shaping data contract V0](planning/shaping-data-contract.md) — retained SFNT profile, Wasm ABI, validation, and conformance.
- [Raster data contract V0](planning/raster-data-contract.md) — bitmap, MSDF, and Slug records and resources.
- [glTF extension drafts](planning/extensions/index.md) — `PMNDRS_font` and raster companion schemas.
Expand Down
27 changes: 23 additions & 4 deletions docs/log.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/packages/text.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ sources:
title: Unicode analysis implementation
generated:
by: openai-codex/gpt-5.6
at: '2026-08-04T19:04:36Z'
at: '2026-08-07T01:16:02Z'
---

# Package reference: `@pmndrs/text`
Expand Down Expand Up @@ -192,7 +192,7 @@ The geometry core is independent of its host boundary. A sibling `mtsdf-baker` c

Milestone 8.2 composed that kernel into the original fixed `@pmndrs/text/bakers/msdf` artifact path. One shared Fontations adapter supplies maintained unscaled line, quadratic, and cubic outlines to both admission evidence and the baker; no second parser or outline bridge exists. Its 64 px/em, full-eight-pixel-range descriptor hashes to `e944ba8d…fe93`. Item 8.6 now exposes `emSize` and full `pixelRange` as authenticated integer bake options in `1..=1022` and `1..=1020`. Omitted or partial options resolve against 64/8; explicit effective 64/8 canonicalizes to the legacy fieldless descriptor and raster key, while every non-default descriptor carries both effective values. `planeUnitsPerEm` equals `emSize`, and each glyph is evaluated only over its tight source-outline rectangle plus `ceil(pixelRange / 2)` field-padding texels on that global plane grid. Correction operates over the same glyph-local rectangle before copying into a 1024-pixel atlas page. Real 155-glyph subset bakes at 32/4 and 32/6 pass artifact validation, establishing the control path without changing the recommended default before quality and payload benchmarking. Bitmap and MTSDF descriptors may additionally authenticate bounded raster coverage while retaining the full source-local glyph namespace and dense record table. Standalone validation derives the expected coverage only from that authenticated descriptor; its public context has no second coverage field that could silently disagree. Degenerate non-rendering selected glyphs become exact absent records, while malformed command streams remain typed failures. The shared TypeScript direct-memory host owns allocation, response framing, nested metadata validation, copying, and transactional cleanup for both bitmap and MTSDF bakers.

Direct raster-baker ABI V1 keeps ordinary responses contiguous and moves oversized results through bounded borrowed windows: the host reads metadata once, copies each window while Wasm owns it, and explicitly releases that ownership before the Worker transfers exact result buffers. Every Wasm pointer, status, length, and count is normalized as unsigned at the JavaScript boundary. The generator-only no-default-feature MTSDF module remains valid because artifact-baker fields are optional to the generator host, while the published baker requires and validates them. MTSDF quality options travel in the authenticated descriptor and do not change the low-level Wasm ABI. Build output removes obsolete ABI V0 files before packing.
Direct raster-baker ABI revision 1 keeps ordinary responses contiguous and moves oversized results through bounded borrowed windows: the host reads metadata once, copies each window while Wasm owns it, and explicitly releases that ownership before the Worker transfers exact result buffers. Every Wasm pointer, status, length, and count is normalized as unsigned at the JavaScript boundary. The generator-only no-default-feature MTSDF module remains valid because artifact-baker fields are optional to the generator host, while the packaged baker requires and validates them. MTSDF quality options travel in the authenticated descriptor and do not change the low-level Wasm ABI. Build output removes obsolete ABI revision 0 files before packing.

Bitmap and MTSDF runtime fallback share one serial ESM module-Worker host. The same normalized descriptor options drive deliberate Node baking and missing-artifact fallback; Bitmap's Worker normalizer retains both strikes and coverage instead of projecting coverage away. Each dynamically imported baker receives an owned source copy, one active job uses the reusable Worker, queued jobs remain FIFO, cancellation replaces active ownership safely, and an idle Worker terminates. Preparation failures reject through the promised asynchronous API rather than escaping synchronously. Core provenance now retains the authenticated collection-face index; legacy artifacts may default only when their descriptor hash proves face zero, and runtime raster baking always reuses that selected face. Registry subscriptions are released when their final tracked font is disposed.

Expand Down
29 changes: 20 additions & 9 deletions docs/planning/api-shapes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
type: API Reference
title: Runtime and bake API fixture V0
description: Defines the canonical accepted V1 package, loader, baker, shaper, paragraph, raster, and cache interfaces plus explicitly deferred additions.
title: Merged v0 runtime and bake API fixture
description: Records the merged v0 package, loader, baker, shaper, paragraph, raster, and cache interfaces for migration and regression comparison while the target v1 API is built.
tags: [api, loader, baker, shaping, paragraph, raster]
sources:
- id: 'citation-1'
Expand All @@ -22,17 +22,28 @@ sources:
- id: 'raster-technique-comparison'
resource: '../../apps/benchmarks/src/surfaces/conformance/scenes/raster-technique-comparison.ts'
title: 'Retained MSDF and Slug comparison scene'
- id: 'core-api'
resource: 'core-api.md'
title: 'Core text API'
- id: 'engine-integration-contract'
resource: 'engine-integration-contract.md'
title: 'Proposed engine integration data contract'

generated:
by: openai-codex/gpt-5.6
at: '2026-08-03T15:29:54Z'
at: '2026-08-07T01:16:02Z'
---

# Runtime and bake API fixture V0
# Merged v0 runtime and bake API fixture

Status: accepted V1 surfaces are implemented; sections labeled deferred remain proposals
Status: merged v0 surfaces are implemented but unreleased; sections labeled deferred remain proposals
Scope: baked-first loading, lazy Worker baking, HarfRust Wasm shaping, JavaScript paragraph layout, and explicit raster loading

> [!NOTE]
> This page is retained for migration and regression comparison. The root [README](../../README.md),
> [core text API](core-api.md), and [engine integration contract](engine-integration-contract.md) define the
> authoritative extraction API.

## Milestone 0.1 acceptance evidence

This table reports contract evidence; it does not turn implementation or prose into maintainer acceptance. The [canonical roadmap checklist](../roadmap/roadmap.md#milestone-0--accept-contracts-and-versions) is the only closure gate, and the [decision register](decision-register.md#product-and-public-api) records approval state.
Expand All @@ -48,7 +59,7 @@ This table reports contract evidence; it does not turn implementation or prose i
## Benchmark consumer API discovery

The Milestone-10 benchmark cleanup treats every live workload as executable consumer evidence. A public API candidate is
admitted here only when the desired consumer snippet cannot be expressed through the shipped package, the missing
admitted here only when the desired consumer snippet cannot be expressed through the merged v0 package, the missing
constraint has a distinguishing test, and runtime-size, Worker, renderer, and type consequences are stated. Benchmark
telemetry, fixture authentication, renderer ownership, and direct-ABI measurement do not become product APIs merely
because the harness needs them.
Expand All @@ -68,7 +79,7 @@ because the harness needs them.
| Direct baker/shaper ABI targets | Published Wasm/package entry points behind one lazily selected target adapter | Exact ABI timing and byte-level conformance | Keep isolated under benchmark conformance/measurement targets |
| Retained MSDF / Slug comparison | Two independently transactional public `Text` objects coordinated by the scene | Paired offscreen-target publication and rollback after a delayed peer | Keep coordination local; no ordinary consumer proves a grouped public transaction |

The workload pass also tested three plausible additions and found no consumer failure that would justify shipping them:
The workload pass also tested three plausible additions and found no consumer failure that would justify merging them:

| Candidate | Evidence | Decision |
| ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
Expand All @@ -77,7 +88,7 @@ The workload pass also tested three plausible additions and found no consumer fa
| Public retained-update diagnostics | Reuse, ranged upload, overflow, and replacement are covered by raster tests and benchmark-only telemetry; applications do not need those classifications to render correctly | Keep investigation/profiling signals outside the thin runtime so production builds retain zero diagnostic cost |

This audit rejects new loader telemetry, generic raster-statistics, Three-specific, and React-specific APIs: each would add
coupling or shipped code without a demonstrated consumer failure. It also rejects exporting the first-party capacity and dirty-
coupling or merged code without a demonstrated consumer failure. It also rejects exporting the first-party capacity and dirty-
range helpers: the portable `stageBatch` contract already lets an external raster own an equivalent policy without inheriting
Three-specific storage. The delayed-peer failure is real, but its required atomicity belongs to one comparison product over
two independent render targets. The private retained-target solution closes that consumer failure without adding renderer-
Expand Down Expand Up @@ -1148,7 +1159,7 @@ Coverage seeds are normalized, bounded, and authenticated in the raster descript

The optional bitmap presentation helpers snapshot copied font handles, glyph IDs, UTF-16 clusters, exact font-size bits, occurrence ordinals, and currently displayed instance origins without retaining a `Text`, batch, texture, or geometry. A transition matches only the same complete glyph identity and updates the target batch's existing origin arrays. New or reshaped glyphs remain at their authoritative target positions; sizes, UVs, paint, shaping, line breaks, and `ParagraphLayout` never interpolate. Progress is finite and bounded to `[0, 1]`, stale or disposed batches reject mutation, and `finish`/`dispose` are idempotent. Target-origin storage is allocated only when a consumer creates a transition. The existing TSL graph still performs the final physical-pixel snap.

The resource and draw-batch types are owned by their optional raster packages. `defineRaster` captures the literal `kind` and associated types from the module value; consumers do not supply generic arguments. Core has no closed raster-kind union and does not assume which raster packages are installed or shipped. Each optional package owns its literal kind and companion data contract. Adding a first-party or external raster requires no change to the core type declarations. The shared package depends only on `RasterModule` and never imports concrete engines.
The resource and draw-batch types are owned by their optional raster packages. `defineRaster` captures the literal `kind` and associated types from the module value; consumers do not supply generic arguments. Core has no closed raster-kind union and does not assume which raster packages are installed or present. Each optional package owns its literal kind and companion data contract. Adding a first-party or external raster requires no change to the core type declarations. The shared package depends only on `RasterModule` and never imports concrete engines.

`RasterDrawBatch` is the portable disposal contract. Renderer adapters refine it without changing that core boundary:
`RasterObjectDrawBatch<Object>` adds one host scene object, and the public `ThreeRasterDrawBatch` alias binds that object to
Expand Down
Loading