@vielzeug/codex 26.11.13 → 26.11.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  # Vielzeug: Full Documentation
2
2
 
3
- > Complete documentation for 46 packages. Version: 26.11.12
3
+ > Complete documentation for 46 packages. Version: 26.11.13
4
4
 
5
5
  ---
6
6
 
@@ -4621,6 +4621,7 @@ await createMcpServer(catalog, { version: snapshot.manifest.version }).connect(n
4621
4621
 
4622
4622
  - Use `search-packages` for capability discovery before loading broad source.
4623
4623
  - Use `get-type-signature` before loading full source.
4624
+ - Call `check-install` when working inside a project that depends on `@vielzeug/*`: it compares the served snapshot with the versions that project declares and its lockfile resolves, so agents can tell whether snapshot docs may lag the install.
4624
4625
  - Every snapshot is one flat directory (manifest, catalog, content chunks, optional Refine metadata); `--snapshot` points at it directly.
4625
4626
  - Pass `validateContents: true` to `loadSnapshot()` for artifact verification; normal startup keeps package chunks lazy.
4626
4627
  - Return a fresh configured server from `startHttpHost`'s `createServer` factory.
@@ -13967,6 +13968,7 @@ Use Keymap to route keyboard shortcuts into `undo()` and `redo()`. Project `ledg
13967
13968
  ## Examples
13968
13969
 
13969
13970
  - [Text Editor History](./examples/text-editor.md)
13971
+ - [JSON Delta History](./examples/json-delta-history.md)
13970
13972
  - [Form History](./examples/form-history.md)
13971
13973
 
13972
13974
  ### REPL Examples
@@ -14122,10 +14124,11 @@ const translator = createTranslator({ save: 'Enregistrer' }, { locale: 'fr' });
14122
14124
  translator.translate('save');
14123
14125
  ```
14124
14126
 
14125
- | Method | Signature | Returns |
14126
- | ----------- | -------------------------------------------------------------------- | ---------------------- |
14127
- | `translate` | `(textKey, options?)` or `(pluralKey, { count, ordinal?, values? })` | Rendered string |
14128
- | `locale` | `Locale` | Resolved active locale |
14127
+ | Method | Signature | Returns |
14128
+ | ------------------ | -------------------------------------------------------------------- | ---------------------- |
14129
+ | `translate` | `(textKey, options?)` or `(pluralKey, { count, ordinal?, values? })` | Rendered string |
14130
+ | `translateUnkeyed` | `(key: string, options?)` | Rendered string |
14131
+ | `locale` | `Locale` | Resolved active locale |
14129
14132
 
14130
14133
  ---
14131
14134
 
@@ -14164,6 +14167,7 @@ i18n.translate('title');
14164
14167
  | Method or property | Signature | Returns |
14165
14168
  | ------------------ | ------------------------------------- | -------------------------------------------------------------- |
14166
14169
  | `translate` | Translator method | Rendered string |
14170
+ | `translateUnkeyed` | Translator method | Rendered string for a runtime key outside the typed key set |
14167
14171
  | `load` | `({ locale? })` | `Promise` after the locale and configured fallbacks load |
14168
14172
  | `setLocale` | `(locale)` | `Promise` after an atomic loaded-locale commit |
14169
14173
  | `isLoaded` | `({ locale? })` | `boolean` |
@@ -14186,7 +14190,7 @@ i18n.translate('title');
14186
14190
  function createReactiveI18n(i18n: I18n): ReactiveI18n;
14187
14191
  ```
14188
14192
 
14189
- Bridges a lingua instance into `@vielzeug/ripple` so translated strings are reactive. `i18n.translate()` is not ripple-reactive on its own: reading it inside a `computed()` computes once and never re-runs, since it registers no tracked dependency. The bridge's `translate` first reads the reactive `locale` readable, so any binding built on it re-evaluates the instant `setLocale()` resolves.
14193
+ Bridges a lingua instance into `@vielzeug/ripple` so translated strings are reactive. `i18n.translate()` is not ripple-reactive on its own: reading it inside a `computed()` computes once and never re-runs, since it registers no tracked dependency. The bridge's `translate` and `translateUnkeyed` first read the reactive `locale` readable, so any binding built on them re-evaluates the instant `setLocale()` resolves. For runtime-assembled keys inside reactive bindings use the bridge's `translateUnkeyed`: calling `i18n.translateUnkeyed` directly skips the reactive locale and caches the first result.
14190
14194
 
14191
14195
  `@vielzeug/ripple` is an optional peer dependency: install it only when you use this subpath.
14192
14196
 
@@ -14206,6 +14210,7 @@ await reactive.i18n.setLocale('fr');
14206
14210
  | `i18n` | `I18n` | The underlying instance for imperative work (`setLocale`, `load`, disposal) |
14207
14211
  | `locale` | `Readable` | Reactive locale: reading it inside a computed/template registers the dependency |
14208
14212
  | `translate` | `(key, options?)` | Rendered string; re-evaluates whenever the locale changes |
14213
+ | `translateUnkeyed` | `(key, options?)` | Rendered string for a runtime key; re-evaluates whenever the locale changes |
14209
14214
 
14210
14215
  ---
14211
14216
 
@@ -14353,6 +14358,7 @@ type Translator = {
14353
14358
  readonly locale: Locale;
14354
14359
  translate(key: TextKey, options?: TranslateOptions): string;
14355
14360
  translate(key: PluralKey, options: PluralOptions): string;
14361
+ translateUnkeyed(key: string, options?: TranslateOptions | PluralOptions): string;
14356
14362
  };
14357
14363
  ```
14358
14364
 
@@ -17972,7 +17978,7 @@ clobber concurrent edits. JSON Patch is the wire format for the honest answer, a
17972
17978
  implements it with the two properties sync code actually needs: `apply` is **immutable with
17973
17979
  structural sharing** (untouched subtrees keep their object identity, so React and every memo
17974
17980
  layer work for free), and `diff` is **structural** (objects diff field-by-field, append-only
17975
- arrays stay one operation).
17981
+ arrays stay one operation, and inserts land at exactly the right index).
17976
17982
 
17977
17983
  ```ts
17978
17984
  import { apply, diff } from '@vielzeug/patchwork';
@@ -18019,11 +18025,12 @@ tryApply(doc, [{ op: 'test', path: '/title', value: 'Other' }, ...patch]);
18019
18025
 
18020
18026
  - **`apply`**: immutable RFC 6902 — all six operations, copy-on-write with structural sharing.
18021
18027
  - **`tryApply`**: the same engine as data; a failed `test` or bad pointer returns a structured rejection with the failing operation index.
18022
- - **`diff`**: per-field object patches, suffix-trimmed arrays (appends cost a single `add`), pointer-escaped keys.
18028
+ - **`diff`**: per-field object patches, prefix/suffix-aligned arrays (appends, prepends, and middle inserts cost a single `add`), pointer-escaped keys.
18023
18029
  - **Pointer API**: `parsePointer`/`formatPointer` with `~0`/`~1` escaping and `getIn` for reads.
18024
18030
  - **Spec-exact edges**: `null` is a value not an absence, `replace` requires an existing target, array `add` inserts, `-` appends.
18025
18031
  - **Input isolation**: `add`/`copy` values are cloned in, so the caller's objects can never mutate a document afterwards.
18026
18032
  - **Hard JSON domain**: numbers, strings, booleans, null, arrays, objects — no functions, no prototypes, nothing to inherit.
18033
+ - **`@vielzeug/patchwork/merge`**: opt-in three-way merge — field-level reconciliation of diverged copies with `conflicts` as data.
18027
18034
 
18028
18035
  ## Documentation
18029
18036
 
@@ -18054,6 +18061,7 @@ tryApply(doc, [{ op: 'test', path: '/title', value: 'Other' }, ...patch]);
18054
18061
 
18055
18062
  ```ts
18056
18063
  import { apply, diff, getIn, parsePointer, tryApply } from '@vielzeug/patchwork';
18064
+ import { merge } from '@vielzeug/patchwork/merge'; // three-way merge subpath
18057
18065
  ```
18058
18066
 
18059
18067
  ## Functions
@@ -18081,8 +18089,8 @@ function tryApply(doc: JsonValue, patch: JsonPatch): ApplyResult;
18081
18089
  ```
18082
18090
 
18083
18091
  Never throws for patch failures: returns `{ ok: true, doc }` or
18084
- `{ ok: false, error: { index, path, reason: 'path' | 'test', message } }`, where `path` is
18085
- the failing operation's `path` (or `from` for `move`/`copy`).
18092
+ `{ ok: false, error: { index, path, reason: 'path' | 'test', message } }`, where `path` is the
18093
+ exact pointer that failed — for `move`/`copy`, whichever side (source or target) was bad.
18086
18094
 
18087
18095
  ### diff
18088
18096
 
@@ -18090,10 +18098,11 @@ the failing operation's `path` (or `from` for `move`/`copy`).
18090
18098
  function diff(from: JsonValue, to: JsonValue): JsonPatch;
18091
18099
  ```
18092
18100
 
18093
- Computes a patch that turns `from` into `to`. Objects diff per key; arrays trim their common
18094
- suffix, recurse positionally over the shared head, and emit tail removals followed by `-`
18095
- appends; anything else becomes one `replace` at the deepest shared pointer. The result always
18096
- applies via `apply` (`apply(from, diff(from, to))` deep-equals `to`).
18101
+ Computes a patch that turns `from` into `to`. Objects diff per key; arrays align on their
18102
+ common prefix and suffix, recurse positionally through the middle, and emit ordered removals
18103
+ and indexed inserts around it (`-` only for true appends); anything else becomes one
18104
+ `replace` at the deepest shared pointer. The result always round-trips
18105
+ (`apply(from, diff(from, to))` deep-equals `to`) — verified by a seeded round-trip test.
18097
18106
 
18098
18107
  ### getIn / parsePointer / formatPointer
18099
18108
 
@@ -18106,6 +18115,21 @@ function formatPointer(tokens: readonly string[]): JsonPointer;
18106
18115
  RFC 6901 throughout: `~1` decodes to `/`, `~0` to `~`; the empty pointer is the whole
18107
18116
  document. `parsePointer('x')` throws — pointers start with `/` or are empty.
18108
18117
 
18118
+ ### merge (subpath `@vielzeug/patchwork/merge`)
18119
+
18120
+ ```ts
18121
+ function merge(base: JsonValue, local: JsonValue, remote: JsonValue, options?: MergeOptions): MergeResult;
18122
+ ```
18123
+
18124
+ Reconciles two diverged copies of `base` field-by-field. Returns `{ doc, conflicts }`:
18125
+ `doc` applies both sides where they do not collide, and `conflicts` lists every location
18126
+ where both sides changed the base differently (`{ base, local, path, remote }`, with
18127
+ `undefined` marking a deleted or never-present side). `options.resolution` picks the winner
18128
+ (`'remote'` default; `'local'` available) — conflicts are reported either way. Arrays: pure
18129
+ appends concatenate (local first), pure truncations take the shorter, anything else
18130
+ conflicts as a whole array. Types `MergeConflict`, `MergeOptions`, and `MergeResult` are
18131
+ exported from the subpath.
18132
+
18109
18133
  ## Types
18110
18134
 
18111
18135
  | Type | Purpose |
@@ -18124,11 +18148,11 @@ builders.
18124
18148
 
18125
18149
  ## Errors
18126
18150
 
18127
- | Error | Thrown when |
18128
- | ---------------- | -------------------------------------------------------------------------------- |
18129
- | `PatchError` | Base class for every patchwork error |
18130
- | `PatchPathError` | A pointer does not resolve, an index is out of bounds, or a pointer is malformed |
18131
- | `PatchTestError` | A `test` operation did not match the document |
18151
+ | Error | Thrown when |
18152
+ | ---------------- | ----------------------------------------------------------------------------------------------------------------------------- |
18153
+ | `PatchError` | Base class for every patchwork error |
18154
+ | `PatchPathError` | A pointer does not resolve, an index is out of bounds, or a pointer is malformed; `error.pointer` names the offending pointer |
18155
+ | `PatchTestError` | A `test` operation did not match the document |
18132
18156
 
18133
18157
  ### Usage Guide
18134
18158
 
@@ -18194,7 +18218,7 @@ server `tryApply`s, and a failed test means someone else moved first.
18194
18218
  ## What diff Emits
18195
18219
 
18196
18220
  - **Objects**: per-key `remove`s, `add`s, and recursive descent — changed fields cost one small operation each, regardless of document size.
18197
- - **Arrays**: the common suffix is trimmed and the head walked positionally; appends become a single `{ op: 'add', path: '/x/-' }`, tail removals become ordered index removes.
18221
+ - **Arrays**: the common prefix and suffix are aligned and the middle walked positionally; appends become a single `{ op: 'add', path: '/x/-' }`, prepends and middle inserts a single indexed `add`, and surplus entries become ordered index removes.
18198
18222
  - **Different types or root changes**: one `replace` at the shared ancestor — patches stay short and always apply cleanly.
18199
18223
 
18200
18224
  `diff` optimizes for apply-safety and small steady-state payloads (edit-one-field,
@@ -18202,6 +18226,33 @@ append-one-row), which is exactly the traffic of form autosaves, live documents,
18202
18226
  trails. It is not an attempt at minimal-edit-count: reordering an array yields positional
18203
18227
  replaces, which are correct, just not clever.
18204
18228
 
18229
+ ## Three-Way Merge (Subpath)
18230
+
18231
+ When two copies of a document diverge from a common ancestor, `@vielzeug/patchwork/merge`
18232
+ reconciles them field-by-field instead of one side overwriting the other:
18233
+
18234
+ ```ts
18235
+ import { merge } from '@vielzeug/patchwork/merge';
18236
+
18237
+ const base = { price: 10, title: 'Doc', tags: ['a'] };
18238
+ const local = { price: 10, title: 'My edit', tags: ['a', 'mine'] };
18239
+ const remote = { price: 12, title: 'Doc', tags: ['a', 'theirs'] };
18240
+
18241
+ const { doc, conflicts } = merge(base, local, remote);
18242
+ // doc: { price: 12, title: 'My edit', tags: ['a', 'mine', 'theirs'] }
18243
+ // conflicts: [] — only same-field collisions conflict
18244
+ ```
18245
+
18246
+ The policy is deliberately conservative: objects merge key-by-key to any depth, a delete
18247
+ beats an untouched copy, both sides only appending an array concatenates (local first), and
18248
+ both sides only truncating takes the shorter result. Anything else — a mid-list array edit,
18249
+ an append versus a truncate, different additions to the same key — is reported in
18250
+ `conflicts` and resolved by `options.resolution` (`'remote'` default, `'local'` opt-in),
18251
+ never guessed. Ship the merged doc back to either side as an ordinary patch with
18252
+ `diff(side, doc)`.
18253
+
18254
+ This module is policy, not RFC 6902: the core entry point stays spec-only on purpose.
18255
+
18205
18256
  ## The JSON Domain
18206
18257
 
18207
18258
  Documents are JSON: `null`, booleans, numbers, strings, arrays, and plain objects. `apply`
@@ -18223,6 +18274,7 @@ that is the `from` location when the source was missing.
18223
18274
  - Prefix state-changing patches with a `{ op: 'test', path: '/rev', … }` operation instead of shipping whole documents; the patch is the lock.
18224
18275
  - Keep patches in your logs as data (they are JSON): replaying `apply` over an old snapshot reconstructs exactly what was sent.
18225
18276
  - Do not feed non-JSON values (functions, `undefined`, `Date`) through `apply`; validate documents with [Vault](/vault/) schemas at the edge and the domain stays clean.
18277
+ - In a sync engine, merge on the server with `{ resolution: 'remote' }` and show the `conflicts` array to the user — silent wins are how sync tools lose trust.
18226
18278
 
18227
18279
  ### Examples
18228
18280
 
@@ -18235,6 +18287,7 @@ that is the `from` location when the source was missing.
18235
18287
 
18236
18288
  - Apply - Immutable patches and guarded test (id: `apply-basic`)
18237
18289
  - Diff - Structural patches (id: `diff-basic`)
18290
+ - Merge - Three-way field-level reconciliation (id: `merge-basic`)
18238
18291
 
18239
18292
  ---
18240
18293
 
@@ -26787,16 +26840,16 @@ proseOutline(doc); // [{ level: 1, text: 'Hello', id: 'hello' }]
26787
26840
  Scribe implements a fixed CommonMark + GFM subset — the same on every platform and every
26788
26841
  release:
26789
26842
 
26790
- | Feature | Notes |
26791
- | ------------ | ---------------------------------------------------------------------------------------------------------- |
26792
- | Headings | ATX (`#`–`######`) only; setext underlines render literally |
26793
- | Emphasis | `*`, `**`, `***`, `_`, `__` with CommonMark flanking rules (`snake_case` is safe); `~~strikethrough~~` |
26794
- | Code | Fenced (``` / `~~~`, info string preserved as `lang`), indented (4 spaces), backtick spans |
26795
- | Blocks | Paragraphs, blockquotes, thematic breaks, hard breaks (`two spaces` or `\`) |
26796
- | Lists | `-`/`+`/`*` bullets and `1.` ordered; strict last-marker nesting; simplified tight/loose rule |
26797
- | Tables | GFM pipes with alignment row; a table must start on its own line |
26798
- | Links/images | Inline links with optional titles, images with alt text; autolinks and bare www URLs; GFM autoliteral URLs |
26799
- | Task lists | `[ ]`/`[x]` items render a **disabled** checkbox (never interactive) |
26843
+ | Feature | Notes |
26844
+ | ------------ | ------------------------------------------------------------------------------------------------------------------------------- |
26845
+ | Headings | ATX (`#`–`######`) only; setext underlines render literally |
26846
+ | Emphasis | `*`, `**`, `***`, `_`, `__` with CommonMark flanking rules (`snake_case` is safe); `~~strikethrough~~` |
26847
+ | Code | Fenced (``` / `~~~`, info string preserved as `lang`), indented (4 spaces), backtick spans |
26848
+ | Blocks | Paragraphs, blockquotes, thematic breaks, hard breaks (`two spaces` or `\`) |
26849
+ | Lists | `-`/`+`/`*` bullets and `1.` ordered; strict last-marker nesting; simplified tight/loose rule |
26850
+ | Tables | GFM pipes with alignment row; a table must start on its own line |
26851
+ | Links/images | Inline links with optional titles, images with alt text; angle-bracket URI and email (`mailto:`) autolinks; bare `http(s)` URLs |
26852
+ | Task lists | `[ ]`/`[x]` items render a **disabled** checkbox (never interactive) |
26800
26853
 
26801
26854
  Deliberately absent: raw HTML and entities (rendered as inert text), reference link
26802
26855
  definitions, setext headings, lazy list continuation, definition lists, footnotes, math.
@@ -32659,7 +32712,7 @@ console.log(recordsToCsv([{ a: 1, b: 'x,y' }]));
32659
32712
 
32660
32713
  - **`parseGrid`**: RFC 4180 scanner into a string grid — BOM stripped, CRLF/CR/LF endings, `""` escapes, configurable delimiter.
32661
32714
  - **`parseRecords`**: first row as keys (or your own `headers`), short rows omit keys instead of inventing `undefined`.
32662
- - **`detectDelimiter`**: counts `,` `;` and tabs outside quotes on the first line — auto-detect with no content sniffing.
32715
+ - **Delimiter auto-detection**: `,`, `;`, and tab are counted outside quotes on the first line — no content sniffing, and pinning `delimiter` skips it.
32663
32716
  - **`toCsv` / `recordsToCsv`**: quotes only when needed, `quoteAll` for spreadsheet paranoia, CRLF by default.
32664
32717
  - **`createCsvGridStream`**: a `TransformStream` of rows for uploads and Node streams; even delimiter auto-detection buffers at most one line.
32665
32718
  - **`parseTypedRecords`**: rows through any Spell/standard-schema validator — one `TabulaValidationError` with every row's line number and issues.
@@ -32685,12 +32738,11 @@ console.log(recordsToCsv([{ a: 1, b: 'x,y' }]));
32685
32738
  | --------------------- | ---------------------------------------------------- | --------- | -------------------------------------------------------------------- |
32686
32739
  | `parseGrid` | RFC 4180 text → string grid | Sync | Blank lines skipped unless `skipEmptyLines: false` |
32687
32740
  | `parseRecords` | First row (or `headers`) as keys | Sync | Short rows omit keys; extra cells are dropped |
32688
- | `detectDelimiter` | Count `,` `;` tab outside quotes on the first line | Sync | Ties resolve to `,`; pin `delimiter` when the source is known |
32689
32741
  | `toCsv` | Grid → CSV text | Sync | CRLF by default; pass `newline: '\n'` for LF output |
32690
32742
  | `recordsToCsv` | Records → CSV text with column union | Sync | Without `columns`, order comes from first-seen keys |
32691
32743
  | `createCsvGridStream` | `TransformStream` for chunked text | Async | The header row is emitted like any other row |
32692
32744
  | `parseTypedRecords` | Records through a standard schema | Sync | Async schemas throw; failures aggregate into `TabulaValidationError` |
32693
- | `CsvScanner` | Push-based state machine behind every parser | Sync | Call `finish()` after the last `push()` |
32745
+ | `CsvScanner` | Push-based state machine behind every parser | Sync | Call `finish()` after the last `push()`; auto-detects when unpinned |
32694
32746
 
32695
32747
  ## Package Entry Point
32696
32748
 
@@ -32708,8 +32760,9 @@ function parseGrid(text: string, options?: TabulaParseOptions): string[][];
32708
32760
 
32709
32761
  Parses CSV text into rows of cells. A leading BOM is stripped; `\r\n`, `\r`, and `\n` all
32710
32762
  terminate records; `""` inside quoted fields is an escaped quote; quotes inside unquoted
32711
- fields are literal (spreadsheet producers emit them constantly). `delimiter` defaults to
32712
- `detectDelimiter(text)`.
32763
+ fields are literal (spreadsheet producers emit them constantly). `delimiter` must be a single
32764
+ character and defaults to auto-detection: the scanner counts `,`, `;`, and tab outside quotes on
32765
+ the first line and takes the winner (ties go to `,`).
32713
32766
 
32714
32767
  ### parseRecords
32715
32768
 
@@ -32721,15 +32774,6 @@ Reads the first row as headers unless `headers` is supplied (then the first row
32721
32774
  Extra cells beyond the header are dropped; missing cells leave the key off the record.
32722
32775
  Empty `headers` throws `TabulaParseError`.
32723
32776
 
32724
- ### detectDelimiter
32725
-
32726
- ```ts
32727
- function detectDelimiter(text: string): string;
32728
- ```
32729
-
32730
- Counts `,`, `;`, and tab outside quoted regions of the first line and returns the most
32731
- frequent; ties go to `,`.
32732
-
32733
32777
  ### toCsv
32734
32778
 
32735
32779
  ```ts
@@ -32757,8 +32801,8 @@ function createCsvGridStream(options?: TabulaParseOptions): TransformStream;
32757
32801
  ```
32758
32802
 
32759
32803
  Transforms streamed text into completed rows. Until the first newline arrives (needed for
32760
- delimiter auto-detection unless `delimiter` is pinned) input is buffered; after that rows are
32761
- emitted as they complete.
32804
+ delimiter auto-detection unless `delimiter` is pinned) input is buffered by the scanner; after
32805
+ that rows are emitted as they complete.
32762
32806
 
32763
32807
  ### parseTypedRecords
32764
32808
 
@@ -32778,14 +32822,16 @@ as a spreadsheet would show it. All rows are attempted, then failures throw as o
32778
32822
 
32779
32823
  ```ts
32780
32824
  class CsvScanner {
32781
- constructor(delimiter?: string, skipEmptyLines?: boolean);
32825
+ constructor(options?: TabulaParseOptions);
32782
32826
  push(text: string, onRow: (row: string[], line: number) => void): void;
32783
32827
  finish(onRow: (row: string[], line: number) => void): void;
32784
32828
  }
32785
32829
  ```
32786
32830
 
32787
32831
  The push-based state machine every parser shares — split a fetch body however you like and
32788
- semantics stay identical. `push` may be called with any chunk boundary, mid-quote included.
32832
+ semantics stay identical. Without a pinned `delimiter` it holds input until the first line
32833
+ completes, auto-detects, and starts emitting. `push` may be called with any chunk boundary,
32834
+ mid-quote included.
32789
32835
  Each row arrives with the 1-based physical line it started on (quoted newlines and blank
32790
32836
  lines included), which is what `TabulaRowError.line` reports.
32791
32837
 
@@ -32801,12 +32847,12 @@ lines included), which is what `TabulaRowError.line` reports.
32801
32847
 
32802
32848
  ## Errors
32803
32849
 
32804
- | Error | Thrown when |
32805
- | ----------------------- | ----------------------------------------------------------------------- |
32806
- | `TabulaError` | Base class for every tabula error |
32807
- | `TabulaParseError` | A request cannot be honored (e.g. `headers: []`) |
32808
- | `TabulaRowError` | One row failed schema validation (`line`, `issues`) |
32809
- | `TabulaValidationError` | Typed parse finished with any invalid rows (`errors: TabulaRowError[]`) |
32850
+ | Error | Thrown when |
32851
+ | ----------------------- | --------------------------------------------------------------------------------- |
32852
+ | `TabulaError` | Base class for every tabula error |
32853
+ | `TabulaParseError` | A request cannot be honored (`headers: []`, multi-char `delimiter`, async schema) |
32854
+ | `TabulaRowError` | One row failed schema validation (`line`, `issues`) |
32855
+ | `TabulaValidationError` | Typed parse finished with any invalid rows (`errors: TabulaRowError[]`) |
32810
32856
 
32811
32857
  ### Usage Guide
32812
32858
 
@@ -32836,9 +32882,9 @@ A few parser behaviors worth knowing because every hand-rolled parser gets them
32836
32882
 
32837
32883
  ## Delimiter Detection
32838
32884
 
32839
- `detectDelimiter` counts `,`, `;`, and tab occurrences outside quotes on the first line and
32840
- returns the winner (ties go to `,`). Every parse entry point defaults to it, so a paste box
32841
- and an uploaded `.csv` both just work:
32885
+ Every parse entry point auto-detects the delimiter unless you pin one: the scanner counts `,`,
32886
+ `;`, and tab occurrences outside quotes on the first line and takes the winner (ties go to `,`).
32887
+ A paste box and an uploaded `.csv` both just work:
32842
32888
 
32843
32889
  ```ts
32844
32890
  import { parseGrid } from '@vielzeug/tabula';
@@ -32927,7 +32973,7 @@ per line, not as one opaque message.
32927
32973
  ### REPL Examples
32928
32974
 
32929
32975
  - Parse - Delimiters, quoting, records (id: `parse-basic`)
32930
- - Serialize - Safe quoting and detection (id: `serialize-basic`)
32976
+ - Serialize - Safe quoting and delimiters (id: `serialize-basic`)
32931
32977
 
32932
32978
  ---
32933
32979
 
@@ -33611,15 +33657,16 @@ guest.dispose();
33611
33657
 
33612
33658
  ## Package Entry Point
33613
33659
 
33614
- | Import | Purpose |
33615
- | ------------------ | -------------------------- |
33616
- | `@vielzeug/tavern` | Complete public Tavern API |
33660
+ | Import | Purpose |
33661
+ | -------------------------- | ----------------------------------------------- |
33662
+ | `@vielzeug/tavern` | Complete public Tavern API |
33663
+ | `@vielzeug/tavern/testing` | Test seam: the fake WebRTC factory for sessions |
33617
33664
 
33618
33665
  The `MeshPeer` type carried by host events and the `peers` getter is re-exported here, so a single import types everything.
33619
33666
 
33620
33667
  ## `hostTavern(options)`
33621
33668
 
33622
- Creates a mesh host for one subject. Guest commands are validated against the wire shape (Tavern's own protocol) and checked against `commands`: a name the table does not hold rejects without applying, and a handler that throws rejects the guest with the error's message. Local changes (via `subject.onChanged`) re-broadcast `subject.snapshot()`: coalesced on a microtask; `subject.onRemoved` ends hosting. Presence and transport warnings are reported through `tap()` as `TavernHostEvent`s, and the live peer list is the `peers` getter; hosting ending: from removal or `dispose()`: fires `onEnded` exactly once. `relayNotice` serializes through `serializeNotice` and broadcasts to every guest.
33669
+ Creates a mesh host for one subject. Guest commands are validated against the wire shape (Tavern's own protocol) and checked against `commands`: a name the table does not hold rejects without applying, and a handler that throws rejects the guest with the error's message. Declaring `subject.id` makes the session _named_: every guest command must name that id as `sendCommand`'s `target`, and a command that omits or misses it rejects before the table runs. Local changes (via `subject.onChanged`) re-broadcast `subject.snapshot()`: coalesced on a microtask; `subject.onRemoved` ends hosting. Presence and transport warnings are reported through `tap()` as `TavernHostEvent`s, and the live peer list is the `peers` getter; hosting ending: from removal or `dispose()`: fires `onEnded` exactly once. `relayNotice` serializes through `serializeNotice` and broadcasts to every guest.
33623
33670
 
33624
33671
  **Returns:** `TavernHost`: the host handle.
33625
33672
 
@@ -33704,14 +33751,14 @@ await ready; // the mirror is live
33704
33751
 
33705
33752
  ### `TavernGuest` members
33706
33753
 
33707
- | Member | Type | Behavior |
33708
- | -------------------- | -------------------------------- | -------------------------------------------------------------------------------------------- |
33709
- | `disposalSignal` | `AbortSignal` | Aborted when the session ends |
33710
- | `dispose()` | `() => void` | Leaves the session; `onEnded` fires exactly once |
33711
- | `disposed` | `boolean` | Whether the session has ended |
33712
- | `sendCommand()` | `(name, args?) => void` | Forwards a command to the host's table; throws `TavernDisposedError` after the session ended |
33713
- | `tap()` | `(handler, opts?) => () => void` | Subscribes to `TavernGuestEvent`s; handler errors are swallowed; detaches on abort or end |
33714
- | `[Symbol.dispose]()` | `() => void` | Delegates to `dispose()`; enables `using` declarations |
33754
+ | Member | Type | Behavior |
33755
+ | -------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
33756
+ | `disposalSignal` | `AbortSignal` | Aborted when the session ends |
33757
+ | `dispose()` | `() => void` | Leaves the session; `onEnded` fires exactly once |
33758
+ | `disposed` | `boolean` | Whether the session has ended |
33759
+ | `sendCommand()` | `(name, args?, target?) => void` | Forwards a command to the host's table; `target` is required on a named session; throws `TavernDisposedError` after the session ended |
33760
+ | `tap()` | `(handler, opts?) => () => void` | Subscribes to `TavernGuestEvent`s; handler errors are swallowed; detaches on abort or end |
33761
+ | `[Symbol.dispose]()` | `() => void` | Delegates to `dispose()`; enables `using` declarations |
33715
33762
 
33716
33763
  ## Types
33717
33764
 
@@ -33728,13 +33775,14 @@ The host's command table, keyed by name: the same functions the host's own UI ca
33728
33775
 
33729
33776
  ```ts
33730
33777
  interface TavernSubject {
33778
+ readonly id?: string;
33731
33779
  onChanged(listener: () => void): () => void;
33732
33780
  onRemoved(listener: () => void): () => void;
33733
33781
  snapshot(): unknown;
33734
33782
  }
33735
33783
  ```
33736
33784
 
33737
- How the host reads and watches the single subject it shares. `onChanged` is the re-broadcast trigger; `onRemoved` ends hosting; `snapshot()` returns the JSON-serializable state to broadcast, or `null` while the subject is missing (the broadcast skips). A throwing `snapshot` is reported as a `warning` tap event instead of crashing the host.
33785
+ How the host reads and watches the single subject it shares. `onChanged` is the re-broadcast trigger; `onRemoved` ends hosting; `snapshot()` returns the JSON-serializable state to broadcast, or `null` while the subject is missing (the broadcast skips). A throwing `snapshot` is reported as a `warning` tap event instead of crashing the host. `id` is the subject's stable identity: declaring it puts every command under target verification: guests must pass the id as `sendCommand`'s `target`, and a missing or mismatched target rejects with `That command does not target the hosted subject.` before the command table runs. The target is a guest claim, not a proof: the guard catches misrouted commands, while handlers and the command table stay the authorization boundary. Omit `id` for anonymous sessions, where targets carry no meaning.
33738
33786
 
33739
33787
  ### `TavernHostEvent`
33740
33788
 
@@ -33767,6 +33815,19 @@ The code the consumer pasted could not be used: garbage, the wrong kind, an expi
33767
33815
 
33768
33816
  A stopped host or ended guest was used again: control-plane calls throw it so leaked handles surface, and it rejects `ready` when the guest leaves before the first snapshot.
33769
33817
 
33818
+ ## Testing
33819
+
33820
+ `@vielzeug/tavern/testing` re-exports `createFakeRtc()` (and the `FakeRtc` type): an in-process fake WebRTC factory you pass as the `rtc` option of `hostTavern` and `joinTavern` to drive a real host/guest pair inside one test process, with no browser or network. Consuming this subpath keeps mesh, tavern's transport, out of your dev dependencies.
33821
+
33822
+ ```ts
33823
+ import { hostTavern, joinTavern } from '@vielzeug/tavern';
33824
+ import { createFakeRtc } from '@vielzeug/tavern/testing';
33825
+
33826
+ const { rtc } = createFakeRtc();
33827
+ const host = hostTavern({ rtc, subject });
33828
+ const guest = await joinTavern({ invitationCode: await host.createInvitationCode(), mount, name, rtc });
33829
+ ```
33830
+
33770
33831
  ### Usage Guide
33771
33832
 
33772
33833
  ## Basic Usage
@@ -33837,6 +33898,27 @@ host.dispose(); // stop hosting: every guest disconnects
33837
33898
 
33838
33899
  Omit `commands` for a read-only session: guests mirror the subject, and every command rejects with `The host has no command named "..."`.
33839
33900
 
33901
+ ## Name the Subject to Guard Command Targets
33902
+
33903
+ A guest tab can mirror more than one subject, so a command alone does not say enough: it must name what it acts on. Declaring `subject.id` makes tavern verify that: every command needs the hosted subject's id as `sendCommand`'s third argument, and a missing or mismatched `target` rejects with a `rejected` tap event before the command table ever runs. Without `id`, the session stays anonymous and targets carry no meaning.
33904
+
33905
+ ```ts
33906
+ const host = hostTavern({
33907
+ commands: { rename: (args) => myStore.rename(docId, args[0] as string) },
33908
+ subject: {
33909
+ id: docId, // named session: guests must target this id
33910
+ onChanged: (listener) => myStore.onUpdated(docId, listener),
33911
+ onRemoved: (listener) => myStore.onRemoved(docId, listener),
33912
+ snapshot: () => myStore.read(docId),
33913
+ },
33914
+ });
33915
+
33916
+ // Guest side: the mirror knows which subject it is mirroring.
33917
+ guest.sendCommand('rename', ['Quarterly report'], docId);
33918
+ ```
33919
+
33920
+ The guard stops honest misrouting: a stray command meant for another subject in a guest tab fails loudly instead of silently mutating the hosted one. It cannot make a paired guest honest: the target is a claim, not a proof, so handlers must keep acting on their own subject and the command table remains the authorization boundary for what guests may do.
33921
+
33840
33922
  ## Join as a Guest
33841
33923
 
33842
33924
  Joining consumes the invitation code and produces the answer code to show back. The session goes live once the host accepts the answer and the first snapshot mounts: that transition settles the `ready` promise, so there is no race between the handshake and your code attaching handlers.
@@ -35952,6 +36034,8 @@ router.dispose();
35952
36034
  - `createHashHistory()`: Runs browser routes on static hosts that cannot rewrite deep links.
35953
36035
  - `createMemoryHistory()`: Runs routers in tests and non-browser environments.
35954
36036
  - `subscribe()`: Reactive subscription to navigation state changes.
36037
+ - `createRouteSignals()`: Mirrors navigation into ripple readables.
36038
+ - `createQueryState()`: Typed reactive URL query params with merged, deduplicated writes.
35955
36039
 
35956
36040
  ## Documentation
35957
36041
 
@@ -35974,6 +36058,8 @@ router.dispose();
35974
36058
  | -------------------------------------------- | --------------------------------------------------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------ |
35975
36059
  | `createRouter(options)` | Create a router from a route table | Sync | Initial navigation starts asynchronously in the constructor |
35976
36060
  | `createRouteSignals(router)` | Mirror a router into ripple readables (name/params/query/state) | Sync | `router.getSnapshot()` alone is not ripple-reactive: use this bridge |
36061
+ | `createQueryState(router, spec, options?)` | Bind typed reactive URL query params (read + merged writes) | Sync (writes async) | A codec's default must be its param-absent state |
36062
+ | `param.string/number/boolean/pick/list` | Built-in query-param codecs | Sync (returns codec) | Unknown URL values decode to the default, never throw |
35977
36063
  | `createBrowserHistory()` | Create the default browser history driver | Sync | Requires server-side SPA rewrites |
35978
36064
  | `createHashHistory(options?)` | Create a static-host-safe hash history driver | Sync | Pass the same `base` to the history and router |
35979
36065
  | `createHistoryForBase(base)` | Pick browser vs hash history for a deploy base | Sync | Returns the hash driver for any base other than `'/'` |
@@ -36369,6 +36455,49 @@ Mirrors a router into ripple readables so templates and computeds react to navig
36369
36455
 
36370
36456
  **Returns:** `RouteSignals`: `name` (deepest matched route name, `null` while nothing matches), `params` (its path params), `query` (raw string-valued query params of the current location), and `state` (the full `RouteState`, for deriving further computeds).
36371
36457
 
36458
+ ## `createQueryState(router, spec, options?)`
36459
+
36460
+ ```ts
36461
+ import { createQueryState, param } from '@vielzeug/wayfinder';
36462
+
36463
+ const filters = createQueryState(router, {
36464
+ q: param.string(),
36465
+ page: param.number(1),
36466
+ sort: param.pick(['price', 'name'] as const, 'price'),
36467
+ inStock: param.boolean(),
36468
+ tags: param.list(),
36469
+ });
36470
+
36471
+ filters.params.page.value; // 1 when ?page is absent or malformed
36472
+ filters.query.value; // the whole typed view as one computed
36473
+ await filters.set({ page: 2 }); // merged write; default values are omitted from the URL
36474
+ await filters.reset(); // clear every declared param
36475
+ ```
36476
+
36477
+ Binds a declared param schema to a router as reactive readables: reads recompute on every navigation, and writes merge into the current URL — params you did not declare, the hash, and the path are preserved. Each write issues one `router.navigate()` with `replace: true` by default (flip globally via `options.replace` or per write via `set(patch, { replace: false })`), so same-URL deduplication, back/forward, and leave guards keep working. Both option objects carry the router's full `NavigateOptions` and forward them untouched, so `viewTransition`, `force`, and `state` can be set for every write or overridden per write — for example `createQueryState(router, spec, { viewTransition: false })` keeps filter edits from animating on a router that transitions route changes. Setting a key outside the schema throws `WayfinderConfigError`.
36478
+
36479
+ The codec contract is one invariant: **the default is the param-absent state**. `param.number(1)` writes `?page=2` but clears the param at `1`, keeping URLs canonical and round-trips stable. Decoding is lenient on purpose: a malformed URL value falls back to the default instead of throwing, because URLs carry untrusted input.
36480
+
36481
+ Create query states once beside the router: their route signals live for the app lifetime, not the element's (same rule as `createRouteSignals`).
36482
+
36483
+ **Returns:** `QueryState`: `params` (per-key ripple `Readable`s), `query` (the full schema as one computed), `set(patch, options?)`, and `reset(options?)`.
36484
+
36485
+ ---
36486
+
36487
+ ## `param` codecs
36488
+
36489
+ | Codec | Absent or unknown decodes to | Wire format |
36490
+ | ------------------------------ | --------------------------------- | --------------------------------- |
36491
+ | `param.string(default?)` | `default` (`''` when omitted) | plain value |
36492
+ | `param.number(default?)` | `default` (`0` when omitted) | finite numeric string |
36493
+ | `param.boolean(default?)` | `default` (`false` when omitted) | `1`/`true` and `0`/`false` |
36494
+ | `param.pick(values, default?)` | `default`, or `undefined` if none | one of `values` |
36495
+ | `param.list()` | `[]` | repeated params (`tags=a&tags=b`) |
36496
+
36497
+ For anything else, supply a custom `ParamSpec` (`decode`, optional `default`, `encode`). Return `undefined` from `encode` to omit the param from the URL.
36498
+
36499
+ ---
36500
+
36372
36501
  ## `redirectTo(target, options?)`
36373
36502
 
36374
36503
  ```ts
@@ -37308,6 +37437,39 @@ const user = state.matches.at(-1)?.data;
37308
37437
 
37309
37438
  `waitFor` rejects immediately if the router is already in `status: 'error'`, and also rejects if `router.dispose()` is called while the promise is pending. Resolves immediately if the named route is already active and idle.
37310
37439
 
37440
+ ## URL Query State
37441
+
37442
+ Filter controls need a two-way binding with the URL. `createQueryState` declares the schema once; reads are ripple readables and writes merge into the current URL without disturbing params it does not declare:
37443
+
37444
+ ```ts
37445
+ import { computed } from '@vielzeug/ripple';
37446
+ import { createQueryState, param } from '@vielzeug/wayfinder';
37447
+
37448
+ const queryState = createQueryState(router, {
37449
+ q: param.string(),
37450
+ sort: param.pick(['newest', 'price'] as const, 'newest'),
37451
+ page: param.number(1),
37452
+ });
37453
+
37454
+ // reads react to every navigation (back/forward included)
37455
+ const visibleItems = computed(() => {
37456
+ const start = (queryState.params.page.value - 1) * pageSize;
37457
+ return sortedItems.value.slice(start, start + pageSize);
37458
+ });
37459
+
37460
+ // writes merge, replace the current entry by default, and dedupe same-URL navigations
37461
+ await queryState.set({ page: 1, q: term.value });
37462
+ ```
37463
+
37464
+ Create the state once beside the router (its route signals live for the app lifetime). For a control the user is actively editing, keep a local signal for the keystroke and persist through an effect: the URL stays the persistence layer while same-URL deduplication keeps the echo silent:
37465
+
37466
+ ```ts
37467
+ const search = signal(queryState.params.q.value); // initial value comes from the URL
37468
+ effect(() => void queryState.set({ q: search.value })); // persistence on every change
37469
+ ```
37470
+
37471
+ A codec's default is its param-absent state, so `?page=1` never appears in a clean URL, and malformed values decode back to the default instead of breaking the view.
37472
+
37311
37473
  ## Testing
37312
37474
 
37313
37475
  Use `createMemoryHistory` to test routers without a browser:
package/data/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # Vielzeug
2
2
 
3
- > 46 focused TypeScript packages. Version: 26.11.12
3
+ > 46 focused TypeScript packages. Version: 26.11.13
4
4
 
5
5
  Install any package independently: `pnpm add @vielzeug/<name>`
6
6
 
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "schemaVersion": 2,
3
- "version": "26.11.12"
3
+ "version": "26.11.13"
4
4
  }