@botiverse/porthole 0.14.0 → 0.14.2

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 (46) hide show
  1. package/CHANGELOG.md +782 -0
  2. package/dist/annotate/types.d.ts +4 -1
  3. package/dist/annotate/types.js +2 -0
  4. package/dist/annotate/validate.d.ts +2 -1
  5. package/dist/annotate/validate.js +11 -4
  6. package/dist/check/page-source.js +1 -1
  7. package/dist/compile/policy.js +2 -2
  8. package/dist/conformance/harness-source.js +1 -1
  9. package/dist/host/create-host.js +5 -0
  10. package/dist/host/types.d.ts +7 -0
  11. package/dist/react/frame.d.ts +30 -4
  12. package/dist/react/frame.js +69 -5
  13. package/dist/react/index.d.ts +1 -1
  14. package/dist/react/view.js +10 -4
  15. package/dist/server/index.d.ts +1 -1
  16. package/dist/server/index.js +4 -3
  17. package/dist/server/naming.js +4 -0
  18. package/dist/server/nested.d.ts +24 -2
  19. package/dist/server/nested.js +28 -2
  20. package/dist/server/server.js +145 -25
  21. package/dist/server/types.d.ts +5 -0
  22. package/dist/shell/annotate.d.ts +3 -2
  23. package/dist/shell/annotate.js +22 -2
  24. package/dist/shell/runtime.d.ts +6 -0
  25. package/dist/shell/runtime.js +11 -1
  26. package/docs/ADOPTING.md +55 -7
  27. package/docs/ARCHITECTURE.md +10 -5
  28. package/docs/DECISIONS.md +248 -1
  29. package/docs/DESIGN.md +18 -7
  30. package/docs/THREAT_MODEL.md +30 -3
  31. package/package.json +6 -5
  32. package/src/annotate/types.ts +4 -1
  33. package/src/annotate/validate.ts +11 -6
  34. package/src/compile/policy.ts +2 -2
  35. package/src/host/create-host.ts +5 -0
  36. package/src/host/types.ts +7 -0
  37. package/src/react/frame.tsx +114 -6
  38. package/src/react/index.ts +1 -0
  39. package/src/react/view.tsx +20 -2
  40. package/src/server/index.ts +6 -2
  41. package/src/server/naming.ts +4 -0
  42. package/src/server/nested.ts +32 -2
  43. package/src/server/server.ts +168 -24
  44. package/src/server/types.ts +5 -0
  45. package/src/shell/annotate.ts +22 -2
  46. package/src/shell/runtime.ts +12 -1
@@ -76,7 +76,8 @@ export interface AnnotationMark {
76
76
  readonly anchor: AnnotationAnchor;
77
77
  /**
78
78
  * A marker (P104): with a count, the shell also draws a small bubble with this number (0 to
79
- * `ANNOTATION_LIMITS.count`; above 99 it reads "99+", 0 draws the bubble alone) at the end of a
79
+ * `ANNOTATION_LIMITS.count`, a larger one clamped to it (P116); above 99 it reads "99+", 0 draws
80
+ * the bubble alone) at the end of a
80
81
  * text anchor and the top right of an element. The person can click it: the frame reports
81
82
  * `activated`. The content can read the number; give one only where the page may know it. A
82
83
  * draft's is dropped (P107): its marker has no number.
@@ -182,6 +183,8 @@ export declare const ANNOTATE_METHODS: {
182
183
  readonly track: "porthole/annotate.track";
183
184
  /** Frame → host: the followed mark's box, as it moves (P112). */
184
185
  readonly tracked: "porthole/annotate.tracked";
186
+ /** Host → frame: take the page's text selection away, telling nothing back (P115). */
187
+ readonly clearSelection: "porthole/annotate.clearSelection";
185
188
  };
186
189
  /** The most of each part of an anchor or report the host takes. */
187
190
  export declare const ANNOTATION_LIMITS: {
@@ -34,6 +34,8 @@ export const ANNOTATE_METHODS = {
34
34
  track: "porthole/annotate.track",
35
35
  /** Frame → host: the followed mark's box, as it moves (P112). */
36
36
  tracked: "porthole/annotate.tracked",
37
+ /** Host → frame: take the page's text selection away, telling nothing back (P115). */
38
+ clearSelection: "porthole/annotate.clearSelection",
37
39
  };
38
40
  /** The most of each part of an anchor or report the host takes. */
39
41
  export const ANNOTATION_LIMITS = {
@@ -28,7 +28,8 @@ export declare function annotateMode(mode: AnnotateMode | undefined): Required<A
28
28
  */
29
29
  export declare const hasMarker: (mark: AnnotationMark) => boolean;
30
30
  /**
31
- * The host's marks, checked before they go to the frame; throws on the first bad one. Each is
31
+ * The host's marks, checked before they go to the frame; throws on the first bad one (a count above
32
+ * `ANNOTATION_LIMITS.count` isn't bad: it is clamped to it, P116). Each is
32
33
  * rebuilt as the frame gets it: a posted mark as 0.10.0 sent it (no `kind`), a draft with
33
34
  * `kind: "draft"` and without its count (P107: a draft's marker shows no number, so the page isn't
34
35
  * told one).
@@ -189,7 +189,8 @@ export function annotateMode(mode) {
189
189
  */
190
190
  export const hasMarker = (mark) => mark.count !== undefined || mark.kind === "draft";
191
191
  /**
192
- * The host's marks, checked before they go to the frame; throws on the first bad one. Each is
192
+ * The host's marks, checked before they go to the frame; throws on the first bad one (a count above
193
+ * `ANNOTATION_LIMITS.count` isn't bad: it is clamped to it, P116). Each is
193
194
  * rebuilt as the frame gets it: a posted mark as 0.10.0 sent it (no `kind`), a draft with
194
195
  * `kind: "draft"` and without its count (P107: a draft's marker shows no number, so the page isn't
195
196
  * told one).
@@ -204,8 +205,10 @@ export function checkMarks(marks) {
204
205
  if (!markId(mark?.id) || seen.has(mark.id) || anchor === null) {
205
206
  throw new TypeError(`annotations.show: mark ${index} needs a unique id (1 to ${LIMITS.id} characters) and a valid anchor`);
206
207
  }
207
- if (mark.count !== undefined && !count(mark.count, LIMITS.count)) {
208
- throw new TypeError(`annotations.show: mark ${index}'s count is a whole number from 0 to ${LIMITS.count}`);
208
+ // A count above the limit is clamped to it (P116): the marker reads "99+" either way, and a
209
+ // count is data anyone can grow (a thread's replies), so it mustn't reject the whole list.
210
+ if (mark.count !== undefined && !count(mark.count, Infinity)) {
211
+ throw new TypeError(`annotations.show: mark ${index}'s count is a whole number, 0 or more`);
209
212
  }
210
213
  const kind = mark.kind;
211
214
  if (kind !== undefined && kind !== "posted" && kind !== "draft") {
@@ -215,6 +218,10 @@ export function checkMarks(marks) {
215
218
  if (kind === "draft") {
216
219
  return { id: mark.id, anchor, kind };
217
220
  }
218
- return { id: mark.id, anchor, ...(mark.count === undefined ? {} : { count: mark.count }) };
221
+ return {
222
+ id: mark.id,
223
+ anchor,
224
+ ...(mark.count === undefined ? {} : { count: Math.min(mark.count, LIMITS.count) }),
225
+ };
219
226
  });
220
227
  }