@botiverse/porthole 0.9.0 → 0.12.0

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 (65) hide show
  1. package/dist/annotate/types.d.ts +21 -7
  2. package/dist/annotate/validate.d.ts +18 -3
  3. package/dist/annotate/validate.js +29 -5
  4. package/dist/bridge/bridge.js +1 -51
  5. package/dist/bridge/unseen.d.ts +18 -0
  6. package/dist/bridge/unseen.js +71 -0
  7. package/dist/check/files.d.ts +2 -0
  8. package/dist/check/files.js +67 -50
  9. package/dist/check/lint.d.ts +8 -1
  10. package/dist/check/lint.js +18 -0
  11. package/dist/check/markup.d.ts +7 -0
  12. package/dist/check/markup.js +49 -0
  13. package/dist/check/page-source.js +1 -1
  14. package/dist/check/scroll.d.ts +100 -0
  15. package/dist/check/scroll.js +1429 -0
  16. package/dist/conformance/behavior.js +107 -68
  17. package/dist/conformance/clipboard.js +16 -14
  18. package/dist/conformance/harness-source.js +1 -1
  19. package/dist/conformance/limits.js +117 -64
  20. package/dist/conformance/probes.js +66 -49
  21. package/dist/conformance/runtime.js +6 -0
  22. package/dist/conformance/served.js +66 -63
  23. package/dist/guide/guide.js +1 -1
  24. package/dist/guide/runtime.js +2 -2
  25. package/dist/host/create-host.js +46 -4
  26. package/dist/index.d.ts +1 -1
  27. package/dist/platform/types.d.ts +4 -2
  28. package/dist/react/frame.d.ts +2 -1
  29. package/dist/runtime/requests.d.ts +5 -0
  30. package/dist/runtime/requests.js +16 -1
  31. package/dist/runtime/types.generated.js +1 -1
  32. package/dist/shell/annotate.d.ts +6 -3
  33. package/dist/shell/annotate.js +474 -104
  34. package/dist/shell/use.js +9 -1
  35. package/docs/ADOPTING.md +99 -1
  36. package/docs/ARCHITECTURE.md +2 -1
  37. package/docs/DECISIONS.md +764 -14
  38. package/docs/DESIGN.md +192 -42
  39. package/docs/THREAT_MODEL.md +109 -27
  40. package/package.json +1 -1
  41. package/src/annotate/types.ts +22 -7
  42. package/src/annotate/validate.ts +32 -6
  43. package/src/bridge/bridge.ts +1 -60
  44. package/src/bridge/unseen.ts +82 -0
  45. package/src/check/files.ts +68 -54
  46. package/src/check/lint.ts +24 -0
  47. package/src/check/markup.ts +53 -0
  48. package/src/check/scroll.ts +1757 -0
  49. package/src/conformance/behavior.ts +221 -69
  50. package/src/conformance/clipboard.ts +44 -14
  51. package/src/conformance/limits.ts +169 -76
  52. package/src/conformance/probes.ts +97 -49
  53. package/src/conformance/runtime.ts +9 -0
  54. package/src/conformance/served.ts +112 -63
  55. package/src/guide/guide.ts +1 -0
  56. package/src/guide/runtime.ts +2 -2
  57. package/src/host/create-host.ts +50 -4
  58. package/src/index.ts +1 -0
  59. package/src/platform/types.ts +4 -2
  60. package/src/react/frame.tsx +2 -1
  61. package/src/runtime/requests.ts +23 -1
  62. package/src/runtime/types.generated.ts +1 -1
  63. package/src/shell/annotate.ts +474 -104
  64. package/src/shell/use.ts +9 -1
  65. package/types/runtime/v1/comments.d.ts +14 -4
package/src/shell/use.ts CHANGED
@@ -131,7 +131,15 @@ export const USE_RUNTIME = String.raw`
131
131
  const METHODS = {
132
132
  user: { get: () => call("user", "get", {}) },
133
133
  comments: {
134
- open: (anchor) => clicked("comments", "comments.open") || call("comments", "open", { anchor: typeof anchor === "string" ? { name: anchor } : record(anchor) }),
134
+ // The draft goes as the page gave it, for the host to refuse what isn't text (P108): read
135
+ // after the click's check, so a getter that throws is a rejection; options that aren't an
136
+ // object send a null draft, refused.
137
+ open: (anchor, options) =>
138
+ clicked("comments", "comments.open") ||
139
+ Promise.resolve().then(() => {
140
+ const draft = options === undefined || options === null ? undefined : typeof options === "object" ? options.draft : null;
141
+ return call("comments", "open", { anchor: typeof anchor === "string" ? { name: anchor } : record(anchor), ...(draft === undefined ? {} : { draft }) });
142
+ }),
135
143
  },
136
144
  clipboard: { copy: (text) => clicked("copyText", "clipboard.copy") || call("clipboard", "copy", { text: String(text) }) },
137
145
  links: { open: (url) => clicked("openLink", "links.open") || call("links", "open", { url: String(url) }) },
@@ -10,13 +10,23 @@ interface PortholeCommentAnchor {
10
10
  readonly quote?: string;
11
11
  }
12
12
 
13
+ /** How the composer opens. */
14
+ interface PortholeCommentOptions {
15
+ /**
16
+ * Text the composer starts with (at most 2,000 characters): a draft the person edits, posts
17
+ * or discards in the app. It is never posted without them. Visible text only: new lines and
18
+ * tabs are fine; a draft with zero-width, bidi or tag characters is refused.
19
+ */
20
+ readonly draft?: string;
21
+ }
22
+
13
23
  interface PortholeComments {
14
24
  /**
15
- * Opens the app's comment composer at the anchor (a name alone is { name }). The person writes
16
- * and posts it in the app. Resolves true if the composer opened. Write-only: a page never reads
17
- * comments. Call it from a click. Level: view.
25
+ * Opens the app's comment composer at the anchor (a name alone is { name }), starting with
26
+ * `options.draft` if given. The person writes and posts it in the app. Resolves true if the
27
+ * composer opened. Write-only: a page never reads comments. Call it from a click. Level: view.
18
28
  */
19
- open(anchor: PortholeCommentAnchor | string): Promise<boolean>;
29
+ open(anchor: PortholeCommentAnchor | string, options?: PortholeCommentOptions): Promise<boolean>;
20
30
  }
21
31
 
22
32
  interface PortholeCapabilities {