@botiverse/porthole 0.14.8 → 0.14.10

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/annotate/types.d.ts +33 -2
  3. package/dist/annotate/validate.d.ts +6 -1
  4. package/dist/annotate/validate.js +31 -3
  5. package/dist/bridge/bridge.d.ts +6 -0
  6. package/dist/bridge/bridge.js +5 -0
  7. package/dist/check/page-source.js +1 -1
  8. package/dist/config/capabilities.d.ts +16 -2
  9. package/dist/config/capabilities.js +8 -0
  10. package/dist/conformance/harness-source.js +1 -1
  11. package/dist/find/types.d.ts +83 -0
  12. package/dist/find/types.js +29 -0
  13. package/dist/find/validate.d.ts +17 -0
  14. package/dist/find/validate.js +82 -0
  15. package/dist/guide/guide.js +2 -1
  16. package/dist/host/create-host.js +219 -3
  17. package/dist/host/pass-on.js +3 -2
  18. package/dist/host/types.d.ts +54 -1
  19. package/dist/index.d.ts +5 -3
  20. package/dist/index.js +4 -1
  21. package/dist/react/frame.d.ts +45 -1
  22. package/dist/react/frame.js +107 -3
  23. package/dist/react/view.js +2 -0
  24. package/dist/runtime/contract.d.ts +1 -1
  25. package/dist/runtime/contract.js +1 -1
  26. package/dist/shell/annotate.d.ts +5 -1
  27. package/dist/shell/annotate.js +41 -107
  28. package/dist/shell/document.d.ts +3 -3
  29. package/dist/shell/document.js +5 -3
  30. package/dist/shell/find.d.ts +82 -0
  31. package/dist/shell/find.js +725 -0
  32. package/dist/shell/runtime.js +4 -1
  33. package/dist/shell/text.d.ts +17 -0
  34. package/dist/shell/text.js +140 -0
  35. package/docs/ADOPTING.md +112 -0
  36. package/docs/ARCHITECTURE.md +10 -3
  37. package/docs/DECISIONS.md +284 -1
  38. package/docs/DESIGN.md +48 -2
  39. package/docs/THREAT_MODEL.md +61 -5
  40. package/docs/insertion-entry-points.md +17 -0
  41. package/package.json +1 -1
  42. package/src/annotate/types.ts +43 -4
  43. package/src/annotate/validate.ts +34 -3
  44. package/src/bridge/bridge.ts +7 -0
  45. package/src/config/capabilities.ts +13 -1
  46. package/src/find/types.ts +86 -0
  47. package/src/find/validate.ts +101 -0
  48. package/src/guide/guide.ts +3 -1
  49. package/src/host/create-host.ts +235 -3
  50. package/src/host/pass-on.ts +3 -2
  51. package/src/host/types.ts +55 -1
  52. package/src/index.ts +14 -1
  53. package/src/react/frame.tsx +162 -2
  54. package/src/react/view.tsx +3 -0
  55. package/src/runtime/contract.ts +1 -1
  56. package/src/shell/annotate.ts +42 -107
  57. package/src/shell/document.ts +5 -3
  58. package/src/shell/find.ts +731 -0
  59. package/src/shell/runtime.ts +4 -1
  60. package/src/shell/text.ts +140 -0
@@ -0,0 +1,82 @@
1
+ /**
2
+ * The matches of a query in the document's text (P131), spliced into the find runtime: `text` is
3
+ * the text index's (`textIndex().text`), `query` the person's words. Case-insensitive unless
4
+ * `caseSensitive` (Unicode simple case folding, `u` and `i`, so a match keeps the text's own
5
+ * offsets), and loose about spacing as annotations' `squash` is: the query is trimmed, and each
6
+ * run of white space in it matches any run of white space in the text. Everything else is
7
+ * literal (no pattern syntax reaches the expression). Matches don't overlap, in document order.
8
+ *
9
+ * `keep(start, end)` says whether a match counts (the runtime: whether it has a box on screen,
10
+ * and its range), null if not; at most `most` are kept, and at most ten times that many are
11
+ * looked at (`capped`: it stopped there, and there may be more). The platform's own `RegExp`,
12
+ * its `exec` and `Reflect.apply` come in as taken before content ran, and so do the list the
13
+ * spans go in and how one is added (`list`, `push`: the shell's prototype-less `listOf` and
14
+ * `pushTo`); nothing else is called on a prototype content could replace (only indexing,
15
+ * comparisons and `length`).
16
+ */
17
+ export declare const FIND_MATCH: string;
18
+ /**
19
+ * Whether a key is the find shortcut (P131), spliced into the find runtime: Cmd+F on Apple's
20
+ * platforms (`apple`), Ctrl+F elsewhere, with no Alt, no Shift and not the other of the two. The
21
+ * letter is `key`'s; on a layout whose letters aren't Latin (Cyrillic, Greek), the key in F's
22
+ * place (`code`), as browsers find there too. Comparisons only.
23
+ */
24
+ export declare const FIND_SHORTCUT: string;
25
+ /**
26
+ * Only the latest query (P131), spliced into the find runtime: what the shell does with each
27
+ * query the host asks. A search is synchronous and, on a large page, long (hundreds of ms), so a
28
+ * bar that asks at every key builds a queue of messages behind it. A query that comes while none
29
+ * waits, and not within `quiet` ms of the end of the last one run, is run at once (answered
30
+ * before any content's listener could answer it). Otherwise it waits for the next task, after the
31
+ * messages already queued: a later query (or a clear, `drop`) supersedes it, and the one it
32
+ * superseded is answered `superseded(id)` at once (an error; the host makes it `"unsupported"`).
33
+ * So a burst is at most the query running and the latest, never each in turn.
34
+ *
35
+ * `later(run, wait)` and `time()` are the shell's kept timers and clock, `run(id, request)` runs
36
+ * and answers a query; `request` is what the runtime read from the host's message when it came
37
+ * (read once, never again). Comparisons and its own closures only.
38
+ */
39
+ export declare const FIND_LATEST: string;
40
+ /**
41
+ * The style of the shell's layers over the content (annotations' and find's): inline and
42
+ * important, so the content's own style sheets can't hide, shrink or move it by accident (its
43
+ * scripts can, P104). The annotation runtime carries the same text (a test holds them equal).
44
+ */
45
+ export declare const LAYER_STYLE = "position:fixed!important;inset:0!important;width:auto!important;height:auto!important;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;display:block!important;visibility:visible!important;opacity:1!important;pointer-events:none!important;z-index:2147483647!important;overflow:hidden!important;margin:0!important;padding:0!important;border:0!important;background:none!important;transform:none!important;scale:none!important;translate:none!important;rotate:none!important;zoom:1!important;clip-path:none!important;mask:none!important;filter:none!important;content-visibility:visible!important;contain:none!important";
46
+ /**
47
+ * The shell's find in page (P131), spliced into the shell's runtime (`__FIND__`) when the config
48
+ * declares `find`, so it runs before any content does, with the DOM's own functions as they were.
49
+ * Plain ES2020 like the rest of the shell; no template literals (it sits in one).
50
+ *
51
+ * The host drives it (`porthole/find.query`, a request; `porthole/find.clear|handled`) and it
52
+ * says (`porthole/find.requested|updated`):
53
+ * - a query: its matches in the document's text (annotations' text index: the body's text nodes,
54
+ * without scripts, styles, noscript, templates), case-insensitive and loose about spacing,
55
+ * those with a box on screen, at most 1,000; each is drawn in a layer of the shell's own (a
56
+ * closed shadow root, over the content, as annotations' marks are; never the CSS Custom
57
+ * Highlight API, which content can read and rewrite: P053, P104), the current one apart, again
58
+ * at each scroll, resize and change of the content; the answer is how many and which, and the
59
+ * current one's box once it was scrolled into view (its scrolling ancestors first, then the
60
+ * window, centred); only the latest of a burst is searched, the ones it superseded answered
61
+ * with an error (`FIND_LATEST`);
62
+ * - a change of the content while a query is shown: found again once it settles (at most a
63
+ * second late), the current match kept by its place, and the host told when the count or the
64
+ * current one changed, at most once a second;
65
+ * - the shortcut: while the host says it draws its own find bar (`handled`), Cmd+F (Apple) or
66
+ * Ctrl+F (elsewhere) in the frame that the page didn't take itself (it called preventDefault)
67
+ * stops the browser's own find and is told (`requested`); otherwise the key is left alone.
68
+ *
69
+ * Every built-in it calls once content may have run is one it took before (the DOM's methods and
70
+ * getters, the timers, `postMessage`, `Map`, `RegExp`), called through the shell's `callOf`
71
+ * (P129); its lists are the shell's prototype-less ones, and what it reads from the host's message
72
+ * (the event's fields, the request's own properties) is read once and only as a string, a number
73
+ * or a boolean. The nodes of its layer go in only through the shell's guarded insertion methods
74
+ * (P130: `createElement`, `attachShadow`, `appendChild`, `replaceChildren`, the `textContent`
75
+ * setter, taken after the shell wrapped them), and it inserts nothing into the content's own
76
+ * trees.
77
+ *
78
+ * It shares the realm with the content, which can read the query, change what matches, hide the
79
+ * layer, keep the key from it or say `requested` itself: the host takes what it says as a find
80
+ * bar's numbers, never as facts.
81
+ */
82
+ export declare const FIND_RUNTIME: string;