tobogganSe connecter

library

Prebuilt pebble components: drop-in custom elements, no compiler needed

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

Dernier runAucun
0Étoiles
0Forks
2Issues

tablet's own engine: no CodeMirror, every line ours

The textarea stays the platform surface — IME, selection, a11y, mobile
keyboards come free — while the document becomes a pure-value model:
{ doc, selection }, actions as data, a step reducer, and the element's
own history. Native textarea undo dies at the first programmatic
value = write, and the mirror writes constantly, so history is ours;
that is the engine's reason to exist.

packages/tablet/engine/ is pure — state.ts (transactions as values),
commands.ts (insert/delete/word/line, surrogate-pair-safe), history.ts
(undo/redo as values, 500 ms run grouping, toki2-style), model.ts (the
action vocabulary + step). index.tsx rewires onto it per the paradigm:
beforeinput/paste/cut/keydown/selectionchange/compositionend are
streams mapped to actions; scan folds them; ONE toSignal crosses;
effects write outward (mirror to the field, caret via afterRender,
change via fromSignal → debounce → emit). Edits the engine handles are
canceled at beforeinput and applied exactly; anything it declines
reaches the field natively and reconciles by diff — preventDefault
decides which path runs, so they never double-apply. IME composition
is never canceled; it folds in as one undoable step at compositionend.

Public API unchanged: <pebble-tablet>, textarea PE/fallback as the form
field of record, change (300 ms, {value}), save (Mod+S via keys(),
IME-safe), part="editor field" (one element, two roles now), tablet.css
conventions, dist/tablet.{js,d.ts,css}. element.editor is repurposed to
the engine's read-only live view ({ doc, selection }).

Cues recorded in docs/tablet.md: toki2's web/editor (the paradigm
already applied to an editor; generalized from blocks/markdown to plain
text), CM6 (transactions/state/history as values; its view machinery is
for rendering, which tablet doesn't do), CodeJar/textarea-caret (their
machinery is re-render caret dances and caret coordinates — both
unneeded when the surface is never rewritten), ProseMirror/Lexical
(schema trees and DOM reconciliation are rich-text machinery; a
plain-text document is a string and the textarea is the platform's
editor for strings).

Size: 94,931 B gz → 7,928 B gz (Δ floor 3,908). Tests: 52 → 142
(77 engine unit tests, 21 element tests in happy-dom, 8 capability
probes). The smoke (examples/tablet-smoke.ts) drives the shipped bundle
in headless Chromium over CDP — Input.insertText is trusted input, so
the beforeinput cancellation is exercised for real; execCommand cannot
serve here: on a textarea it inserts without firing beforeinput.

Two environment notes for the repo: bun test elides a module import
whose bindings are only used in type positions, which silently skips
define() — test files need one value use of the import. And bun's
content-keyed transpile cache (~/.bun/install/cache/@t@) poisons across
worktrees: a sibling worktree's removed paths came back as ENOENT in
this one's CSS compiles until the stale .pile entries were deleted.

olivier · il y a 3 sem. · 6c3ab399ad48754298334f95a5efbdac14a8fec0

Parents 6246cc1

20 fichiers modifiés, 1779 ajouts, 246 suppressions

Apackages/tablet/engine/commands.test.ts+201−0
Apackages/tablet/engine/commands.ts+115−0
Apackages/tablet/engine/history.test.ts+152−0
Apackages/tablet/engine/history.ts+62−0
Apackages/tablet/engine/model.test.ts+176−0
Apackages/tablet/engine/model.ts+165−0
Apackages/tablet/engine/state.test.ts+43−0