@botiverse/porthole 0.14.10 → 0.14.11

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.
package/docs/DECISIONS.md CHANGED
@@ -4595,7 +4595,7 @@ second wall on a tab); a host needs a served page to open windows from a tab (th
4595
4595
  `'self'` default (it joins `FRAME_DENIED_FEATURES`); or WebKit and Firefox apply
4596
4596
  `Permissions-Policy` to these features (the shell's device locks become the second wall there too).
4597
4597
 
4598
- ## P104 · 2026-10-20 · Annotation markers: a number at an anchor, a click the host hears, marks that follow a scroll · Accepted; amended by P105, P107, P116
4598
+ ## P104 · 2026-10-20 · Annotation markers: a number at an anchor, a click the host hears, marks that follow a scroll · Accepted; amended by P105, P107, P116, P133
4599
4599
 
4600
4600
  A host that shows its comments beside an artifact page wants, at each comment's anchor in the page,
4601
4601
  a small marker (a bubble and how many comments are there) that scrolls with the content; a click on
@@ -4873,7 +4873,7 @@ when someone remembered, and what DESIGN.md said they fail had drifted from what
4873
4873
  a control's run makes a CI job too long (shard the controls across jobs), or the kit's app gains
4874
4874
  a weakening seam (then its controls join the registry).
4875
4875
 
4876
- ## P105 · 2026-10-20 · After the review of P104: a marker's click within a gesture and the host's view guarded, one clock for follow-ups, text markers beside their line · Accepted
4876
+ ## P105 · 2026-10-20 · After the review of P104: a marker's click within a gesture and the host's view guarded, one clock for follow-ups, text markers beside their line · Accepted; amended by P133
4877
4877
 
4878
4878
  Amends P104 (its points 1, 3, 5 and 7, and its Trust) and P053's Trust. From the independent
4879
4879
  review of P104 and 0.9.0 (botiverse/porthole#37: no P0 or P1, two P2s, six P3s) and from #36
@@ -7596,3 +7596,140 @@ control: nothing here is a defense; the bound is `parseRect`'s, which existing p
7596
7596
  **Revisit when** a host needs places within a page's own scrolling box (a place relative to that
7597
7597
  box, and its scroll), the scroll without following a mark (a page with no marks the host follows),
7598
7598
  or a host draws from `documentRect` inside the frame's own area and wants Porthole to clip for it.
7599
+
7600
+ ## P133 · 2026-11-06 · Markers are labelled buttons, a posted comment's sits at its paragraph's end, and reports say where the last line is · Accepted
7601
+
7602
+ Amends P104 (its point 6, and its "Revisit when" on a keyboard inside the frame) and P105 (its
7603
+ point 3, for posted text marks, and P2-B's click listener on each marker). Three follow-ups for
7604
+ comment markers, from a host (Raft web):
7605
+
7606
+ - A marker can't be reached from the keyboard or named by assistive technology (P104 point 6
7607
+ chose that, and named this as what would reopen it).
7608
+ - A marker beside the anchor's last line, in the gutter, sits between the lines of a paragraph
7609
+ someone is reading, up to the column's width from its words (P105 point 3 said so); the host
7610
+ wants it where the paragraph ends.
7611
+ - A host that puts its own UI after a selection's last line has only the selection's whole box:
7612
+ `rect` ends at the widest line's right, not where the words end, and it is clamped.
7613
+
7614
+ **Decision.**
7615
+
7616
+ 1. **A marker is a real button.** A `<button type="button">` with an explicit tab stop (`tabindex`:
7617
+ Safari's Tab otherwise skips one) and a name that says what it is: `aria-label` "3 comments on
7618
+ …", "1 comment on …", "Comment on …" for a count of 0, "Draft comment on …", with the mark's
7619
+ `anchor.label`. The layer is no longer `aria-hidden`: its marks and its outline are, so the
7620
+ markers are all assistive technology finds in it. A marker's styles take off what a browser
7621
+ gives a button, and it has a focus ring of its own. Markers go in the page's reading order
7622
+ (each finding reads where each mark starts, as `order` does), which is the Tab key's: after the
7623
+ page's own stops, since the layer is the document's last child. A marker that stays in its
7624
+ place isn't touched, and none moves while one has the focus.
7625
+ 2. **The existing path, from the keyboard.** Enter and Space make the button's own trusted click,
7626
+ which reaches the shell's first window listener as a pointer's does, retargeted to the layer. It
7627
+ has no click count and no point (0, 0, or the like), so the hit test can't place it: a trusted
7628
+ click with `detail` 0 is the focused marker's, read through the closed shadow root's
7629
+ `activeElement` by the platform's getter, kept before content runs, and otherwise goes on to the
7630
+ hit test as ever (assistive technology that clicks an element without focusing it is missed:
7631
+ see Revisit). `activated`, its `rect` (the marker's box), the
7632
+ host's id check and its gesture check are unchanged: a real key gives the host's page transient
7633
+ activation as a click does (as the HTML standard says for a key but Escape; unmeasured here, see
7634
+ Tested). While elements are picked a marker takes itself out of the Tab order (`tabindex` -1) and
7635
+ a click on one reports nothing, as the pointer's goes past it.
7636
+ 3. **Enter and Space are stopped as a press is**, in the window's first listener, read through
7637
+ kept getters, on all of keydown, keypress and keyup while their target is the layer: the content
7638
+ neither hears them nor cancels the click. Every other key stays the page's, as on a button of its
7639
+ own: Tab, Escape (which the shell's own picking and selecting hear after this), and the host's
7640
+ find shortcut. A repeat of either is cancelled: a key held down clicks once, where 30 clicks a
7641
+ second would spend the bridge's 120 a minute on one press.
7642
+ 4. **The focus stays while the page redraws.** A draw hit-tests places with the markers out of the
7643
+ display (P105), which loses a focused one, on every scroll. While one has the focus they only
7644
+ take no pointer (`pointer-events`, so the tests skip them): dearer for that time, as P105 measured
7645
+ (0.13 ms a marker per test), and only then. Nothing else in a draw touches a kept node.
7646
+ 5. **The focus brings a marker into view.** One out of view is outside the layer's box. A focused
7647
+ element scrolls its scrolling ancestors into view, and `overflow: hidden` is one, so the layer
7648
+ would have scrolled away from everything it draws: it clips now (`overflow: clip`, `hidden`
7649
+ where an engine lacks it, Safari before 16; the shared `LAYER_STYLE`, find's layer too). The
7650
+ shell scrolls the document instead, to centre the marker, with the `scrollBy` kept before content
7651
+ runs, as `focus(id)` does for a mark. The focus on a marker lights its words as the pointer does.
7652
+ Focus events between two markers don't leave the shadow root, so these listen there.
7653
+ 6. **A posted comment's marker sits at its paragraph's end.** A text anchor's, not a draft's: on
7654
+ the last line of the block its words end in, read from the anchor's end as far as a block inside
7655
+ it (a nested list's words are their own paragraph) and over only what is drawn, at most 256 text
7656
+ nodes, once for each finding (a range kept on the mark, so a draw reads one box). It takes P105's
7657
+ places on that line, after a new first one: just past the last word, where nothing follows that a
7658
+ marker could cover, which is what P105's gutter gave up for. Where the line leaves no room, the
7659
+ gutter, the frame's edge, compact and over the line's end as before. Those at one paragraph's end
7660
+ go together, in the order their words end.
7661
+ 7. **A draft's stays by its words**, as P105 places it: it is the person's comment being written on
7662
+ those words, beside a composer near them, and nothing else says which words those are. **An
7663
+ element's stays on its corner** (P104): it may have no text and no lines, and a pinned paragraph's
7664
+ marker is P119's. The light on the words, on hover and on focus, still ties a marker at a
7665
+ paragraph's end to the words it is for.
7666
+ 8. **`lastLineDocumentRect`** on `selected`, on each attached result of `anchored` and on `tracked`:
7667
+ the last line with words on it (the last client rect with a width: a triple click's empty box on
7668
+ the next block doesn't count), or an element's whole box, in the coordinates of `documentRect`:
7669
+ the box as the shell read it plus the `scroll` it was read at. **`selected` takes `scroll` too**,
7670
+ so it is `rect`'s equal: its viewport place is one less the other. `createHost` checks each as a
7671
+ box, clamps none (a clamp erases an offscreen line, and `rect` is P104's). No other field, method,
7672
+ option or rate. Follow-ups still go by `rect` and `order`: a line that moves inside an unmoved box
7673
+ isn't told, and comparing in document coordinates would tell a fixed mark at every scroll.
7674
+ 9. **The marker's own click listener goes**, and with it the control `marker-tap`. It was there
7675
+ only so WebKit would make a tap a click on a `div`: P105's P2-B measured that it did so for a
7676
+ button all along. The tap probes stay, under `marker-click`.
7677
+
7678
+ **Compatibility.** Every field is optional and only added. An older shell sends none, and a host
7679
+ tests for `lastLineDocumentRect`; an older host drops them (each report is rebuilt from known
7680
+ fields, P053). A malformed one drops the whole report, as any malformed part does. Markers change in
7681
+ place for a host doing nothing: they move, and take the keyboard. `show`, `activated` and every
7682
+ existing field are as they were. The shell is the content server's: upgrade that for all of it.
7683
+
7684
+ **Threat.** P104 refused the tab stop because the content controls that focus order. That stands,
7685
+ and is accepted (THREAT_MODEL §7): the content can take the focus from a marker, keep a person from
7686
+ one, draw a look-alike with a tab stop of its own, and tell that the person is on one. It gains no
7687
+ power from that: a marker's press has no effect but `activated`, which it can fake within the host's
7688
+ checks anyway; a made-up key or `click()` is no trusted click; and keys reach a marker only while
7689
+ the frame has the focus, so P109's keyboard is untouched. The focus model P104 hoped for, one the
7690
+ content can't steal, is rejected below: only the host's own UI can be that, and the host's list of
7691
+ marks stays the way a keyboard can rely on. `activated` by keyboard is as fakeable and as guarded
7692
+ as by pointer; ADOPTING's guard already takes no key. The name carries the page's own words
7693
+ (`anchor.label`) to assistive technology, after the shell's own: a page can't change what kind of
7694
+ thing it says this is, and those words reach the frame in `show` already. `lastLineDocumentRect`
7695
+ re-opens what `documentRect` re-opened, no more: a host that draws from it without clipping lets the
7696
+ page choose where (P132's duty, THREAT_MODEL §6). `rect` stays clamped. The page learns nothing new
7697
+ from it (it goes from the frame to the host).
7698
+
7699
+ **Tested.** `test/annotate.test.ts` "the last line (P133)": kept in all three reports, rebuilt from
7700
+ known fields; an older shell's selection exactly as before; a malformed one or a selection's
7701
+ malformed scroll dropping the report; through `createHost`, `rect` clamped, the last line and the
7702
+ scroll as the shell said. `leak/annotate.spec.ts` (three engines), written and not yet run (test runs
7703
+ were paused where this was written, so everything measured above is reasoned from the standards and
7704
+ the engines' sources and awaits CI): "a marker is a button the keyboard reaches…" (`marker-key`,
7705
+ `marker-click`); "a marker out of view brings itself into view…"; "a posted comment's marker sits at
7706
+ its paragraph's end…"; "a selection's and a mark's last line…" (`annotation-rect-clamp`, as P132's).
7707
+ "text markers cover no word" now puts a draft in a line's middle: posted ones have no next word to
7708
+ cover, so that is what control `marker-place` shows. Tests that clicked a posted marker on its
7709
+ anchor's line now look on its paragraph's last line. New control `marker-key`.
7710
+
7711
+ **Rejected.**
7712
+ - A focus model the content can't steal, inside the frame (P104's hope): the shell shares the realm,
7713
+ so nothing in the frame is out of a page's reach. Only the host's overlay could be, a tab stop per
7714
+ mark outside the frame, kept level with content it can't see into: that is the host's list again.
7715
+ - `role="button"` on the `div`: every activation by hand (Enter on keydown, Space on keyup,
7716
+ nothing for assistive technology's own click), for nothing; "works with the existing path" is what
7717
+ a real button's trusted click gives.
7718
+ - A click listener on the marker itself, to know the target without the focus: the window's first
7719
+ listener has to stop the click before it gets there, or the content hears it.
7720
+ - Stopping every key on a marker: it would take Escape and Tab from a page's own handling, and the
7721
+ host's find shortcut, for no secret; what's stopped is what acts on a marker.
7722
+ - A host's `label` on a mark for the name in the person's language: a new field in `show` and in
7723
+ what the page reads, not asked for yet (see Revisit).
7724
+ - Moving the marker to the paragraph's end in the gutter always (P105's place on that line): it
7725
+ keeps the distance from the words that this is here to end.
7726
+ - A marker at a picked paragraph's end too: an element anchor isn't always text, and P119 pins that
7727
+ marker on purpose.
7728
+ - `documentRect` on `selected` as well: not asked for; `rect` and the last line place a host's UI.
7729
+
7730
+ **Revisit when** a host's UI isn't in English and its marker names should be (a host's `label` on a
7731
+ mark, sent into the frame, the page reading it); an engine's or a screen reader's click on a marker
7732
+ it didn't focus is missed, or reported as the marker that has the focus, so the wrong comment opens
7733
+ (give the layer a way to learn its target); a right-to-left paragraph's
7734
+ end should be on its left (P105's places aren't direction-aware either); paragraphs split by `<br>`
7735
+ should count as many; or a host wants a picked paragraph's marker at its end.
package/docs/DESIGN.md CHANGED
@@ -1047,13 +1047,13 @@ chooses), and the annotation runtime is in the shell only then.
1047
1047
  | host → frame | `porthole/annotate.focus` | `{ id }`: scrolled into view inside the frame, made the active mark, flashed |
1048
1048
  | host → frame | `porthole/annotate.clear` | — |
1049
1049
  | host → frame | `porthole/annotate.clearSelection` | —: the page's text selection is taken away (the DOM's own `removeAllRanges`, taken before content runs) with what the shell held of it, and nothing is reported back; marks, drafts and the mode stay (P115) |
1050
- | frame → host | `porthole/annotate.selected` | `{ anchor, rect }`; after a scroll, the same selection again only if its box moved more than 0.5 px, on the follow-ups' clock (P105) |
1050
+ | frame → host | `porthole/annotate.selected` | `{ anchor, rect, lastLineDocumentRect?, scroll? }` (a newer shell's last two: P133, below); after a scroll, the same selection again only if its box moved more than 0.5 px, on the follow-ups' clock (P105) |
1051
1051
  | frame → host | `porthole/annotate.unselected` | — (the text selection went away) |
1052
1052
  | frame → host | `porthole/annotate.cancelled` | — (Escape) |
1053
- | frame → host | `porthole/annotate.anchored` | `{ results: [{ id, state: "attached" \| "orphaned", rect?, documentRect?, order? }], scroll? }` (a newer shell's `documentRect` and `scroll`: P132, below): every mark after `show`, the one after `focus`, every mark when the content changed a state, and, while any mark has a marker (a `count` or a draft, P107), once a scroll, a resize or a run of content changes has settled (150 ms quiet), only the marks that moved more than 0.5 px since the host was last told, at most one a second together with the selection's (P104, P105) |
1053
+ | frame → host | `porthole/annotate.anchored` | `{ results: [{ id, state: "attached" \| "orphaned", rect?, documentRect?, lastLineDocumentRect?, order? }], scroll? }` (a newer shell's `documentRect` and `scroll`: P132, below; `lastLineDocumentRect`: P133): every mark after `show`, the one after `focus`, every mark when the content changed a state, and, while any mark has a marker (a `count` or a draft, P107), once a scroll, a resize or a run of content changes has settled (150 ms quiet), only the marks that moved more than 0.5 px since the host was last told, at most one a second together with the selection's (P104, P105) |
1054
1054
  | host → frame | `porthole/annotate.track` | `{ id }` or `{ id: null }`: follow one shown mark, or none (P112) |
1055
- | frame → host | `porthole/annotate.tracked` | `{ id, rect, documentRect?, scroll? }`: the followed mark's box at an animation frame where it moved, at most one every 16 ms; the host takes 60 a second, for that mark only (P112); a newer shell adds its place in the document and the document's scroll (P132) |
1056
- | frame → host | `porthole/annotate.activated` | `{ id, rect }`: the person clicked a mark's marker; `rect` is the marker's (P104); taken only while the host's page has transient activation (P105) |
1055
+ | frame → host | `porthole/annotate.tracked` | `{ id, rect, documentRect?, lastLineDocumentRect?, scroll? }`: the followed mark's box at an animation frame where it moved, at most one every 16 ms; the host takes 60 a second, for that mark only (P112); a newer shell adds its place in the document and the document's scroll (P132), and its last line's (P133) |
1056
+ | frame → host | `porthole/annotate.activated` | `{ id, rect }`: the person clicked a mark's marker, or pressed Enter or Space on it (P133); `rect` is the marker's (P104); taken only while the host's page has transient activation (P105) |
1057
1057
 
1058
1058
  - **Anchors** are W3C Web Annotation selectors, at most one of each:
1059
1059
  `CssSelector` (unique: the nearest id, else a path of `nth-of-type` steps),
@@ -1083,10 +1083,20 @@ chooses), and the annotation runtime is in the shell only then.
1083
1083
  negative; a malformed one drops the report) and clamps neither: the host clips what it
1084
1084
  draws from them. A page that scrolls a box of its own rather than its document moves
1085
1085
  its marks' places with it, as their `rect` does; those are told as before.
1086
+ - **The last line** (P133). A newer shell says where a selection or a mark ends, for a
1087
+ host's UI after it: `lastLineDocumentRect`, on `selected` (with `scroll`, read with
1088
+ it), on each attached result of `anchored` and on `tracked`, in the coordinates of
1089
+ `documentRect`, checked and left unclamped as it is. It is the last box with a width
1090
+ of the words' client rects, the box a text marker's place starts from; an element,
1091
+ which has no lines of its own, gives its whole box. Its place in the frame's viewport
1092
+ is it less `scroll`. Absent from an older shell, and where nothing of it is drawn.
1086
1093
  - **Markers** (P104). A mark with a `count` gets a bubble glyph and its number ("99+"
1087
- above 99; 0 the bubble alone) on an element's top right corner, inside the frame's
1088
- width, and beside a text anchor's last line, centred on it (P105, #36): in the
1089
- line's gutter, just past the right edge of the anchor's block; at the frame's right
1094
+ above 99; 0 the bubble alone), a real button (P133, below), on an element's top right
1095
+ corner, inside the frame's width, and at the end of a text anchor's paragraph (P133):
1096
+ on the last line of the block its words end in, read as far as a block inside it,
1097
+ just past that line's last word, or where that doesn't fit at the places a draft's
1098
+ takes. A draft's goes beside its anchor's own last line, centred on it (P105, #36): in
1099
+ the line's gutter, just past the right edge of the anchor's block; at the frame's right
1090
1100
  edge where the frame is too narrow for that; just past the line's last word where
1091
1101
  something else is beside the block (a table's next cell, a card in a row). Each
1092
1102
  place must be clear of that line's words and of anything of the content's but a box
@@ -1101,8 +1111,8 @@ chooses), and the annotation runtime is in the shell only then.
1101
1111
  is a thin line. The layer takes no pointer but on markers: a press on one, and the pointer's
1102
1112
  moves over it, are stopped in the shell's first window listener, read through the
1103
1113
  platform's own functions kept before content runs (P105), and a trusted click is
1104
- reported `activated`; a tap too, on WebKit as well, since each marker has a click
1105
- listener of its own (WebKit makes a tap a click only on such an element, P105). On
1114
+ reported `activated`; a tap too, on WebKit as well, since a button is an element it
1115
+ makes a tap a click on (P105). On
1106
1116
  touch (P119), while the last pointer down or moved was a finger or a pen (before any,
1107
1117
  where `(any-pointer: coarse)` matches), each marker also takes the pointer in a box of
1108
1118
  at least 44 by 44 px centred on its bubble (an invisible `::before` in the layer), the
@@ -1113,10 +1123,26 @@ chooses), and the annotation runtime is in the shell only then.
1113
1123
  its handlers, nor what is under the marker, gets them; content that patches others
1114
1124
  can reach the layer's nodes (P105). Either way the content can tell a press
1115
1125
  happened, by `:active`, `relatedTarget` and user activation. Markers step aside
1116
- while elements are picked. No tab stop, and the layer stays `aria-hidden`: the
1117
- host's own list of marks is the keyboard path.
1126
+ while elements are picked, the keyboard's Tab too.
1127
+ - **Markers from the keyboard** (P133). Each marker is a `<button>` with a tab stop,
1128
+ in the page's reading order after the page's own stops (the layer is the document's
1129
+ last child), named for what it is (`aria-label`: "3 comments on …", "Draft comment on
1130
+ …", with the mark's `anchor.label`, in English); only the markers are exposed to
1131
+ assistive technology, the layer no longer `aria-hidden`, its marks and outline are.
1132
+ A press of a pointer still moves no focus. Enter and Space make the button's own
1133
+ trusted click, which goes the way a pointer's does, but has no count and no place, so
1134
+ it is the focused marker's (read through the shadow root's `activeElement`, kept
1135
+ before content runs); those two keys are stopped at the window as a press is, a
1136
+ repeat of them cancelled (a key held down clicks once), and every other key stays the
1137
+ page's. A real key gives the host's page transient activation as a click does. The
1138
+ focus on a marker lights its words and, out of view, scrolls the document to it: the
1139
+ layer clips rather than hides, so it never scrolls itself. While one has the focus a
1140
+ draw takes the markers out of hit tests by `pointer-events`, not `display` (which
1141
+ would lose it), and moves none. The page shares the focus order: the host's own list
1142
+ of marks stays the keyboard path it can rely on.
1118
1143
  - **Drafts** (P107). A mark with `kind: "draft"` (a comment not yet posted) has a
1119
- marker whether or not it has a count, placed as a posted one's, and drawn apart: a
1144
+ marker whether or not it has a count, placed by its own words (not at its paragraph's
1145
+ end, P133), and drawn apart: a
1120
1146
  dashed underline (a dashed outline on an element), a lighter fill, and a hollow
1121
1147
  marker (a light bubble with a dashed edge and the glyph's outline) with no number.
1122
1148
  `checkMarks` sends a posted mark as before (no `kind`), a draft without its count,
@@ -1160,7 +1186,12 @@ they change; an MCP Apps view; and a hostile page faking every report (not asked
1160
1186
  malformed, too large, the wrong kind, no such mark, a flood), whose negative
1161
1187
  control is `annotation-checks`. Markers (P104): drawn with their numbers, a click
1162
1188
  reported with its id and box and heard by none of the content's listeners, nor a
1163
- double, right or middle click (`marker-click` → those two cases), focus and
1189
+ double, right or middle click (`marker-click` → those two cases), by the keyboard
1190
+ too (P133: a button in reading order and named for what it is, Enter and Space
1191
+ reported once, a key held down once, none of it heard, nothing while elements are
1192
+ picked; `marker-key`, `marker-click` too), brought into view by the focus and keeping
1193
+ it through redraws, at its paragraph's end past the last word, a nested block's
1194
+ words not its own, a draft's by its words; focus and
1164
1195
  selection kept, a drag from a marker too (`marker-prevent` → the press case), none
1165
1196
  without a count, stepping aside while picking, drawn whole at the frame's top; a
1166
1197
  run of scrolls reported with only the marks that moved, a fixed one never; marks
@@ -1177,9 +1208,9 @@ the layer itself (`annotation-activated`, `annotation-activated-count`,
1177
1208
  `MouseEvent`'s prototypes neither hearing a marker's press nor stopping its report
1178
1209
  (`marker-originals`; `marker-click` too); a tap on a marker reported on each
1179
1210
  engine, a touch screen and a phone's emulation (iPhone 13, Pixel 5), content hearing
1180
- none of it (`marker-tap` → WebKit; `marker-click` too); on a 640 px column and a phone page's lines
1211
+ none of it (`marker-click`); on a 640 px column and a phone page's lines
1181
1212
  with one marker each, no marker covering a word (`marker-place`, the marker just
1182
- past its words as 0.9.0 had it); drafts (P107) drawn apart from posted marks on the
1213
+ past its words as 0.9.0 had it, which a draft's in a line's middle shows); drafts (P107) drawn apart from posted marks on the
1183
1214
  same anchors (the frame's pixels and the words' own differ; on Chromium every draft's
1184
1215
  marker and line drawn as a draft's, no number though given a count), a draft's and a
1185
1216
  posted marker's clicks reported beside each other, none reaching the content
@@ -1497,10 +1528,10 @@ control the tables above name to the registry):
1497
1528
  | `annotation-activated` | `annotate.spec.ts` | `a hostile page fakes a marker's click: the host takes it only for a mark it shows with a marker` | — | — |
1498
1529
  | `annotation-activated-count` | `annotate.spec.ts` | `a hostile page fakes a marker's click: the host takes it only for a mark it shows with a marker` | — | — |
1499
1530
  | `marker-trusted` | `annotate.spec.ts` | `a hostile page fakes a marker's click: the host takes it only for a mark it shows with a marker` | — | — |
1500
- | `marker-click` | `annotate.spec.ts` | `markers: a mark with a count gets a numbered bubble; its click is reported and never reaches the content`, `a marker's press, of any kind, moves nothing of the content's: no handler, no focus, no selection`, `a page that patches the event's built-ins neither hears a marker's press nor stops its report (P105)`, `a tap on a marker is reported on every engine, and the content hears none of it (P105)`, `drafts (P107): a dashed line and a hollow marker with no number, apart from posted marks; their clicks are reported the same`, `on touch, a marker takes a tap a few px off its bubble (44 by 44), after the page scrolled itself; a tap past that is the page's (P119)`, `on touch, where two markers' 44 px boxes overlap, a tap is the nearest bubble's (P119)`, `a paragraph's marker pinned at the frame's top once its start scrolled away takes a mouse click and a tap where it is drawn (P119, porthole#42)` | — | — |
1531
+ | `marker-click` | `annotate.spec.ts` | `markers: a mark with a count gets a numbered bubble; its click is reported and never reaches the content`, `a marker's press, of any kind, moves nothing of the content's: no handler, no focus, no selection`, `a page that patches the event's built-ins neither hears a marker's press nor stops its report (P105)`, `a tap on a marker is reported on every engine, and the content hears none of it (P105)`, `a marker is a button the keyboard reaches: Tab in reading order, Enter and Space report it once, the content hears neither, and it steps aside while elements are picked (P133)`, `drafts (P107): a dashed line and a hollow marker with no number, apart from posted marks; their clicks are reported the same`, `on touch, a marker takes a tap a few px off its bubble (44 by 44), after the page scrolled itself; a tap past that is the page's (P119)`, `on touch, where two markers' 44 px boxes overlap, a tap is the nearest bubble's (P119)`, `a paragraph's marker pinned at the frame's top once its start scrolled away takes a mouse click and a tap where it is drawn (P119, porthole#42)` | — | — |
1501
1532
  | `marker-prevent` | `annotate.spec.ts` | `a marker's press, of any kind, moves nothing of the content's: no handler, no focus, no selection` | — | — |
1502
1533
  | `marker-place` | `annotate.spec.ts` | `text markers cover no word: on a column page, and on a phone's lines with one marker each (P105, #36)` | — | — |
1503
- | `marker-tap` | `annotate.spec.ts` | nothing | WebKit: `a tap on a marker is reported on every engine, and the content hears none of it (P105)`, `on touch, a marker takes a tap a few px off its bubble (44 by 44), after the page scrolled itself; a tap past that is the page's (P119)`, `on touch, where two markers' 44 px boxes overlap, a tap is the nearest bubble's (P119)`, `a paragraph's marker pinned at the frame's top once its start scrolled away takes a mouse click and a tap where it is drawn (P119, porthole#42)` | no probe can see it on Chromium and Firefox: they make a tap a click on the marker without a listener of its own (measured, P105) |
1534
+ | `marker-key` | `annotate.spec.ts` | `a marker is a button the keyboard reaches: Tab in reading order, Enter and Space report it once, the content hears neither, and it steps aside while elements are picked (P133)` | — | — |
1504
1535
  | `marker-originals` | `annotate.spec.ts` | `a page that patches the event's built-ins neither hears a marker's press nor stops its report (P105)` | — | — |
1505
1536
  | `follow-throttle` | `annotate.spec.ts` | `an honest scroll session, long, in comment mode, leaves room for a marker's click: follow-ups, the selection's too, at most one a second` | — | — |
1506
1537
  | `selection-follow` | `annotate.spec.ts` | `an honest scroll session, long, in comment mode, leaves room for a marker's click: follow-ups, the selection's too, at most one a second` | — | — |
@@ -1508,7 +1539,7 @@ control the tables above name to the registry):
1508
1539
  | `draft-count` | `annotate.spec.ts` | `what the page reads of a draft (P107): that it is one, never its count; a posted mark as before` | — | — |
1509
1540
  | `draft-shell-checks` | `annotate.spec.ts` | `the shell's own checks on a raw show (P107): a draft draws no number, a kind it doesn't know is no mark` | — | — |
1510
1541
  | `annotation-activated-gesture` | `annotate.spec.ts` | `a hostile page's marker click with no gesture is dropped; one on the person's own press is the host's view to guard (P105)` | — | — |
1511
- | `annotation-rect-clamp` | `annotate.spec.ts` | `a hostile page reports a box outside its frame: the host gets it clamped to the frame's viewport`, `marks: drawn over their anchors, one brought into view, an unfound one orphaned, all cleared`, `following: once a scroll settles, one report with only the marks that moved`, `every attached mark's place in the document comes with the scroll it was read at, offscreen ones too, and the followed mark's as the document scrolls (P132)` | — | — |
1542
+ | `annotation-rect-clamp` | `annotate.spec.ts` | `a hostile page reports a box outside its frame: the host gets it clamped to the frame's viewport`, `marks: drawn over their anchors, one brought into view, an unfound one orphaned, all cleared`, `following: once a scroll settles, one report with only the marks that moved`, `every attached mark's place in the document comes with the scroll it was read at, offscreen ones too, and the followed mark's as the document scrolls (P132)`, `a selection's and a mark's last line come in the document's coordinates with the scroll, offscreen ones too; rect stays clamped (P133)` | — | — |
1512
1543
  | `authorize` | `served/authorize.spec.ts` | `a revoked subject's ticket opens nothing: a page and an app are denied, and the host is told`, `in a tab of its own, a revoked app and page are denied from the next request on`, `a framed page mid-session: its next load after revocation is denied where the engine keeps its cookie` | Chromium, Firefox: `a framed app mid-session: its next request after revocation is denied, and its next load tells the host` | — |
1513
1544
  | `url-permissions` | `served/permissions.spec.ts` | `a url-mode frame gets no clipboard writes or full screen unless the host delegates them` | — | — |
1514
1545
  | `navigate-guard` | `served/live.spec.ts`, `served/files.spec.ts`, `served/served.spec.ts`, `served/tab.spec.ts` | `served.domain.self-navigation`, `served.domain.tab-navigation`, `served.domain.tab-links`, `can't navigate itself away (location): to a site, or to another content origin`, `can't navigate itself away (replace): to a site, or to another content origin`, `can't navigate itself away (open-self): to a site, or to another content origin`, `can't navigate itself away (navigation-api): to a site, or to another content origin`, `a link to another page of the set opens it in the frame; the display goes on`, `a link to another page of the set opens it in the frame when the leaving page's notice is dropped (P098)`, `a link to another page of the set opens it in the frame when the leaving page's notice is late (P098)`, `a page opens nothing else: not a file that isn't a page, not another path of its origin`, `no report, content error or blocked navigation names the frame's sealed address (P083)` | — | — |
@@ -5,7 +5,7 @@ What Porthole protects, from whom, and where that protection ends. For each way
5
5
  guaranteed. [ADOPTING.md](ADOPTING.md) says how to set each one up, and
6
6
  [DESIGN.md](DESIGN.md) lists every defense with the test that proves it.
7
7
 
8
- **Status.** This describes Porthole 0.14.10 (2026-11-05). A review on 2026-10-19 found gaps, and every decision it led to
8
+ **Status.** This describes Porthole 0.14.11 (2026-11-06). A review on 2026-10-19 found gaps, and every decision it led to
9
9
  has merged ([§8](#8-fixes-in-flight) lists them). P096 changed the negative-control runner and CI,
10
10
  and the shipped conformance probes' messages and timing, not what they check. P104 (0.9.0's
11
11
  annotation markers) had a review of its own, and P105, in 0.10.0, is what it led to. 0.11.0 was
@@ -30,7 +30,11 @@ in page (`find`, off unless a config declares it): the host's find bar sends the
30
30
  into the frame, where the content can read it, and takes counts, a box and the find shortcut back
31
31
  as the content's word (§6, §7 "Find in page"); no wall moves. 0.14.10: P132 adds a mark's place in
32
32
  the document and the document's scroll to annotation reports, unclamped, so a host must clip what it
33
- draws from them to its own region (§6, §7); `rect` stays clamped and no wall moves.
33
+ draws from them to its own region (§6, §7); `rect` stays clamped and no wall moves. 0.14.11: P133
34
+ makes markers buttons in the frame's Tab order, reversing P104's "no tab stop": the page shares that
35
+ order, so it can steer or spoil the focus, and a host keeps its own list of marks (§7). A press only
36
+ reports `activated`, which the page could already fake; `lastLineDocumentRect` is unclamped, for a
37
+ host to clip as P132's are; no wall moves.
34
38
 
35
39
  ## 1. Two layers
36
40
 
@@ -196,8 +200,9 @@ Whatever the use:
196
200
  log them, show nothing for them. A url-mode app can still say any outcome (S6).
197
201
  - Take what the frame reports about annotations as UI hints (where to draw, what to open), never
198
202
  as permissions, and put nothing in a mark the page may not know (§7). A mark's place in the
199
- document (`documentRect`, with the report's `scroll`, P132) isn't clamped to the frame: clip
200
- whatever you draw from it to the frame's box, or to your own region beside the frame.
203
+ document (`documentRect`, with the report's `scroll`, P132) and its last line's
204
+ (`lastLineDocumentRect`, P133) aren't clamped to the frame: clip whatever you draw from them to
205
+ the frame's box, or to your own region beside the frame.
201
206
  - Under `find` (P131), know that the page reads every query your find bar sends it, and declare
202
207
  `find` only for displays whose pages may learn what the person searches for (not a third-party
203
208
  app with egress, S5, unless you accept it). Take its counts as the bar's numbers, and open your
@@ -824,7 +829,9 @@ own frame, below the shell, P111), so:
824
829
  what they are for: a host that maps a `documentRect` onto its own page without clipping to the
825
830
  frame's box (or to its own region beside it) lets the page choose where that UI goes, outside
826
831
  the frame as well (accepted, P132; the host's duty in §6). They say nothing else: the page knows
827
- where its words are anyway.
832
+ where its words are anyway. Where a selection or a mark's words end (`lastLineDocumentRect` in
833
+ `selected`, `anchored` and `tracked`, P133) is one more such box, read, checked and left unclamped
834
+ the same way, with the same duty; `selected` also carries `scroll` now.
828
835
  - *What holds, against content that patches none of the DOM's or JavaScript's built-ins.* A real
829
836
  press or click on a marker reaches none of the content's handlers (the shell's first listener
830
837
  stops it; control `marker-click`) and moves neither focus nor a selection (control
@@ -837,6 +844,21 @@ own frame, below the shell, P111), so:
837
844
  loses a tap within 13 px of a bubble (a few px of its words above and below it), as it loses
838
845
  one on the bubble. Which pointer is used is read from trusted pointer events only; a page that
839
846
  makes its own up changes nothing, and a real `activated` still needs a real click.
847
+ - *The keyboard on a marker* (P133, reversing P104's point 6). A marker is a button with a tab
848
+ stop. Enter and Space on it are stopped in the shell's first listener, as a press is (control
849
+ `marker-key`), and the click they make is a trusted one the content doesn't get (`marker-click`):
850
+ it can neither hear nor cancel them. Every other key on a marker is the page's, as on a button of
851
+ its own, Tab too. So what P104 feared stands, and is accepted: the markers join a focus order the
852
+ content controls. It can take the focus from a marker (`focus()` from any handler or timer), keep
853
+ the person from reaching one (a trap on Tab in its own elements), draw its own look-alike with
854
+ its own tab stop, and tell that the person is on one (`document.activeElement` is the layer, its
855
+ own element's `focusout` names it). None of that gives it what it lacks: a marker's press has no
856
+ power but `activated`, which it can fake anyway within the host's checks, keys go to a marker only
857
+ while the frame has the focus, so nothing typed in the host passes through it (P109 is unchanged),
858
+ and a page's made-up key or `click()` is no trusted click. Assistive technology now reads the
859
+ marker's name, the page's own words (`anchor.label`, the host's copy with what can't be seen taken
860
+ out) after the shell's. A host can't rely on a marker being reached, as it can't on one being
861
+ seen: its own list of marks is the keyboard way that holds.
840
862
  - *What doesn't hold against content that does.* The shell shares the content's realm. It reads
841
863
  and stops a marker's press through the platform's own functions and getters, kept before
842
864
  content runs (P105, control `marker-originals`), so patching `Event`'s or `MouseEvent`'s
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botiverse/porthole",
3
- "version": "0.14.10",
3
+ "version": "0.14.11",
4
4
  "description": "A host-side sandbox for agent-made HTML: isolation, egress hardening, a themed shell, gated host functions, and the agent manual, from one config.",
5
5
  "homepage": "https://github.com/botiverse/porthole#readme",
6
6
  "bugs": {
@@ -52,8 +52,8 @@ export interface AnnotationAnchor {
52
52
  * The page's word: the host clamps each it reports to the frame's viewport (P104), so one wholly
53
53
  * outside is a box of no size on the nearest edge. A positioning hint only. It is in the frame's
54
54
  * own layout px: a host that scales or transforms the frame maps it through that transform too
55
- * (P105). A result's `documentRect` (P132) is the same shape in the document's coordinates, and
56
- * isn't clamped.
55
+ * (P105). A result's `documentRect` (P132) and a report's `lastLineDocumentRect` (P133) are the
56
+ * same shape in the document's coordinates, and aren't clamped.
57
57
  */
58
58
  export interface AnnotationRect {
59
59
  readonly x: number;
@@ -95,20 +95,21 @@ export interface AnnotationMark {
95
95
  readonly id: string;
96
96
  readonly anchor: AnnotationAnchor;
97
97
  /**
98
- * A marker (P104): with a count, the shell also draws a small bubble with this number (0 to
99
- * `ANNOTATION_LIMITS.count`, a larger one clamped to it (P116); above 99 it reads "99+", 0 draws
100
- * the bubble alone) at the end of a
101
- * text anchor and the top right of an element. The person can click it: the frame reports
102
- * `activated`. The content can read the number; give one only where the page may know it. A
98
+ * A marker (P104): with a count, the shell also draws a small button, a bubble with this number
99
+ * (0 to `ANNOTATION_LIMITS.count`, a larger one clamped to it (P116); above 99 it reads "99+", 0
100
+ * draws the bubble alone) at the end of a text anchor's paragraph (P133) and the top right of an
101
+ * element. The person can click it, or reach it with the keyboard and press Enter or Space
102
+ * (P133): the frame reports `activated`. Its accessible name says what it is, with the count and
103
+ * `anchor.label`. The content can read the number; give one only where the page may know it. A
103
104
  * draft's is dropped (P107): its marker has no number.
104
105
  */
105
106
  readonly count?: number;
106
107
  /**
107
108
  * What the mark is (P107): `"posted"` (the default, as absent) or `"draft"`, a comment its
108
109
  * author hasn't submitted yet. A draft is drawn apart (a dashed line and a hollow marker with no
109
- * number) and has a marker whether or not it has a count; its count is dropped before the mark
110
- * goes to the frame. The content can read that a mark is a draft: send drafts only to their
111
- * author's own frame.
110
+ * number, beside its anchor's own last line, not at its paragraph's end: P133) and has a marker
111
+ * whether or not it has a count; its count is dropped before the mark goes to the frame. The
112
+ * content can read that a mark is a draft: send drafts only to their author's own frame.
112
113
  */
113
114
  readonly kind?: AnnotationMarkKind;
114
115
  }
@@ -132,6 +133,13 @@ export interface AnchorResult {
132
133
  * box, or to its own region beside the frame. Absent from an older shell. The page's word.
133
134
  */
134
135
  readonly documentRect?: AnnotationRect;
136
+ /**
137
+ * Where its last line is in the document (P133), in the coordinates of `documentRect` and as
138
+ * unclamped: its last line with words on it for text, its whole box for an element, which has no
139
+ * lines of its own. For a host's UI after the last line (its right, or its bottom). Absent from
140
+ * an older shell, and where nothing of the mark is drawn. The page's word.
141
+ */
142
+ readonly lastLineDocumentRect?: AnnotationRect;
135
143
  /**
136
144
  * Its place in the document among the found marks, from 0 (P112): where it starts, offscreen
137
145
  * marks included, for a host that lists marks in reading order. The content's word: an order to
@@ -142,11 +150,18 @@ export interface AnchorResult {
142
150
 
143
151
  /** What the frame reports, once the host has checked it. */
144
152
  export type AnnotationReport =
145
- /** The person pointed at an element or settled a text selection. */
153
+ /**
154
+ * The person pointed at an element or settled a text selection. A newer shell (P133) adds where
155
+ * it ends, for a host's UI after its last line: `lastLineDocumentRect` as a result's is, with
156
+ * how far the document was scrolled as it was read (so its place in the frame's viewport is the
157
+ * one less the other, unclamped). Both absent from an older shell.
158
+ */
146
159
  | {
147
160
  readonly type: "selected";
148
161
  readonly anchor: AnnotationAnchor;
149
162
  readonly rect: AnnotationRect;
163
+ readonly lastLineDocumentRect?: AnnotationRect;
164
+ readonly scroll?: AnnotationScroll;
150
165
  }
151
166
  /** The text selection went away. */
152
167
  | { readonly type: "unselected" }
@@ -180,18 +195,21 @@ export type AnnotationReport =
180
195
  * adds the mark's `documentRect` and the document's `scroll`: the mark's box moves as the
181
196
  * document scrolls, so a host following one mark hears the scroll at every animation frame where
182
197
  * it changed, whether that mark is in the frame or not, and places every mark it holds a
183
- * `documentRect` for (an `anchored` report's) without asking again.
198
+ * `documentRect` for (an `anchored` report's) without asking again. A newer one still (P133) adds
199
+ * its `lastLineDocumentRect`.
184
200
  */
185
201
  | {
186
202
  readonly type: "tracked";
187
203
  readonly id: string;
188
204
  readonly rect: AnnotationRect;
189
205
  readonly documentRect?: AnnotationRect;
206
+ readonly lastLineDocumentRect?: AnnotationRect;
190
207
  readonly scroll?: AnnotationScroll;
191
208
  }
192
209
  /**
193
210
  * The person clicked the marker of a mark the host shows with a `count` (P104), or of a draft
194
- * (P107); `rect` is the marker's box, to open the host's own UI beside it. The content can fake
211
+ * (P107), or pressed Enter or Space on it (P133); `rect` is the marker's box, to open the host's
212
+ * own UI beside it. The content can fake
195
213
  * it for any mark the host shows with a marker, and can tell a real one happened: open the
196
214
  * host's own view of that mark, never act on it.
197
215
  */
@@ -214,7 +232,7 @@ export const ANNOTATE_METHODS = {
214
232
  unselected: "porthole/annotate.unselected",
215
233
  cancelled: "porthole/annotate.cancelled",
216
234
  anchored: "porthole/annotate.anchored",
217
- /** Frame → host: a mark's marker was clicked (P104). */
235
+ /** Frame → host: a mark's marker was clicked, or pressed from the keyboard (P104, P133). */
218
236
  activated: "porthole/annotate.activated",
219
237
  /** Host → frame: follow one mark's box (`{ id }`), or none (`{ id: null }`) (P112). */
220
238
  track: "porthole/annotate.track",
@@ -166,7 +166,10 @@ function results(value: unknown): AnchorResult[] | null {
166
166
  const rect = each.rect === undefined ? undefined : parseRect(each.rect);
167
167
  // Where it is in the document (P132): a box as `rect` is, never clamped.
168
168
  const documentRect = each.documentRect === undefined ? undefined : parseRect(each.documentRect);
169
- if (rect === null || documentRect === null) {
169
+ // Where its last line is in the document (P133), as `documentRect` is.
170
+ const lastLineDocumentRect =
171
+ each.lastLineDocumentRect === undefined ? undefined : parseRect(each.lastLineDocumentRect);
172
+ if (rect === null || documentRect === null || lastLineDocumentRect === null) {
170
173
  return null;
171
174
  }
172
175
  // A place among the marks (P112): a whole number below the most marks a show carries.
@@ -182,6 +185,7 @@ function results(value: unknown): AnchorResult[] | null {
182
185
  state: "attached",
183
186
  ...(rect === undefined ? {} : { rect }),
184
187
  ...(documentRect === undefined ? {} : { documentRect }),
188
+ ...(lastLineDocumentRect === undefined ? {} : { lastLineDocumentRect }),
185
189
  ...(order === undefined ? {} : { order }),
186
190
  });
187
191
  }
@@ -197,7 +201,22 @@ export function parseReport(value: unknown): AnnotationReport | null {
197
201
  case "selected": {
198
202
  const anchor = parseAnchor(value.anchor);
199
203
  const rect = parseRect(value.rect);
200
- return anchor === null || rect === null ? null : { type: "selected", anchor, rect };
204
+ // A newer shell's (P133): where its last line is in the document, and how far it is scrolled.
205
+ const lastLineDocumentRect =
206
+ value.lastLineDocumentRect === undefined
207
+ ? undefined
208
+ : parseRect(value.lastLineDocumentRect);
209
+ const scroll = value.scroll === undefined ? undefined : parseScroll(value.scroll);
210
+ if (anchor === null || rect === null || lastLineDocumentRect === null || scroll === null) {
211
+ return null;
212
+ }
213
+ return {
214
+ type: "selected",
215
+ anchor,
216
+ rect,
217
+ ...(lastLineDocumentRect === undefined ? {} : { lastLineDocumentRect }),
218
+ ...(scroll === undefined ? {} : { scroll }),
219
+ };
201
220
  }
202
221
  case "unselected":
203
222
  return { type: "unselected" };
@@ -219,8 +238,18 @@ export function parseReport(value: unknown): AnnotationReport | null {
219
238
  // A newer shell's (P132): where the mark is in the document, and how far it is scrolled.
220
239
  const documentRect =
221
240
  value.documentRect === undefined ? undefined : parseRect(value.documentRect);
241
+ const lastLineDocumentRect =
242
+ value.lastLineDocumentRect === undefined
243
+ ? undefined
244
+ : parseRect(value.lastLineDocumentRect);
222
245
  const scroll = value.scroll === undefined ? undefined : parseScroll(value.scroll);
223
- if (!markId(value.id) || rect === null || documentRect === null || scroll === null) {
246
+ if (
247
+ !markId(value.id) ||
248
+ rect === null ||
249
+ documentRect === null ||
250
+ lastLineDocumentRect === null ||
251
+ scroll === null
252
+ ) {
224
253
  return null;
225
254
  }
226
255
  return {
@@ -228,6 +257,7 @@ export function parseReport(value: unknown): AnnotationReport | null {
228
257
  id: value.id,
229
258
  rect,
230
259
  ...(documentRect === undefined ? {} : { documentRect }),
260
+ ...(lastLineDocumentRect === undefined ? {} : { lastLineDocumentRect }),
231
261
  ...(scroll === undefined ? {} : { scroll }),
232
262
  };
233
263
  }