@brass-build/client 0.4.1 → 0.5.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 (323) hide show
  1. package/AGENTS.md +124 -45
  2. package/CHANGELOG.md +80 -4
  3. package/README.md +666 -179
  4. package/dist/api-fetch.d.ts +8 -0
  5. package/dist/api-fetch.d.ts.map +1 -1
  6. package/dist/api-fetch.js +35 -8
  7. package/dist/api-fetch.js.map +1 -1
  8. package/dist/batched-get.d.ts +11 -0
  9. package/dist/batched-get.d.ts.map +1 -0
  10. package/dist/batched-get.js +92 -0
  11. package/dist/batched-get.js.map +1 -0
  12. package/dist/call-service.d.ts +4 -0
  13. package/dist/call-service.d.ts.map +1 -1
  14. package/dist/call-service.js +66 -3
  15. package/dist/call-service.js.map +1 -1
  16. package/dist/client.d.ts +48 -2
  17. package/dist/client.d.ts.map +1 -1
  18. package/dist/client.js +918 -115
  19. package/dist/client.js.map +1 -1
  20. package/dist/document-checkpoints.d.ts +25 -2
  21. package/dist/document-checkpoints.d.ts.map +1 -1
  22. package/dist/document-checkpoints.js +258 -61
  23. package/dist/document-checkpoints.js.map +1 -1
  24. package/dist/document-commands.d.ts.map +1 -1
  25. package/dist/document-commands.js +5 -3
  26. package/dist/document-commands.js.map +1 -1
  27. package/dist/document-contents.d.ts +10 -0
  28. package/dist/document-contents.d.ts.map +1 -1
  29. package/dist/document-contents.js +23 -1
  30. package/dist/document-contents.js.map +1 -1
  31. package/dist/document-set-subscription.d.ts +56 -0
  32. package/dist/document-set-subscription.d.ts.map +1 -0
  33. package/dist/document-set-subscription.js +240 -0
  34. package/dist/document-set-subscription.js.map +1 -0
  35. package/dist/document-signals.d.ts +6 -0
  36. package/dist/document-signals.d.ts.map +1 -1
  37. package/dist/document-signals.js +31 -1
  38. package/dist/document-signals.js.map +1 -1
  39. package/dist/document-streams.d.ts +36 -2
  40. package/dist/document-streams.d.ts.map +1 -1
  41. package/dist/document-streams.js +69 -18
  42. package/dist/document-streams.js.map +1 -1
  43. package/dist/document-thumbnail-capture.d.ts +12 -2
  44. package/dist/document-thumbnail-capture.d.ts.map +1 -1
  45. package/dist/document-thumbnail-capture.js +103 -27
  46. package/dist/document-thumbnail-capture.js.map +1 -1
  47. package/dist/documents-namespace.d.ts +92 -10
  48. package/dist/documents-namespace.d.ts.map +1 -1
  49. package/dist/documents-namespace.js +285 -39
  50. package/dist/documents-namespace.js.map +1 -1
  51. package/dist/documents.d.ts +173 -8
  52. package/dist/documents.d.ts.map +1 -1
  53. package/dist/documents.js +1778 -310
  54. package/dist/documents.js.map +1 -1
  55. package/dist/errors.d.ts +3 -3
  56. package/dist/errors.d.ts.map +1 -1
  57. package/dist/errors.js.map +1 -1
  58. package/dist/fetch-retry.d.ts +1 -0
  59. package/dist/fetch-retry.d.ts.map +1 -1
  60. package/dist/fetch-retry.js +2 -0
  61. package/dist/fetch-retry.js.map +1 -1
  62. package/dist/file-choice.d.ts +2 -0
  63. package/dist/file-choice.d.ts.map +1 -0
  64. package/dist/file-choice.js +27 -0
  65. package/dist/file-choice.js.map +1 -0
  66. package/dist/guest-link.d.ts +18 -1
  67. package/dist/guest-link.d.ts.map +1 -1
  68. package/dist/guest-link.js +329 -1
  69. package/dist/guest-link.js.map +1 -1
  70. package/dist/handle-types.d.ts +67 -5
  71. package/dist/handle-types.d.ts.map +1 -1
  72. package/dist/handles.d.ts +15 -19
  73. package/dist/handles.d.ts.map +1 -1
  74. package/dist/handles.js +231 -76
  75. package/dist/handles.js.map +1 -1
  76. package/dist/hosted-ui.d.ts +61 -0
  77. package/dist/hosted-ui.d.ts.map +1 -1
  78. package/dist/hosted-ui.js +94 -42
  79. package/dist/hosted-ui.js.map +1 -1
  80. package/dist/import-contract.d.ts +74 -0
  81. package/dist/import-contract.d.ts.map +1 -0
  82. package/dist/import-contract.js +163 -0
  83. package/dist/import-contract.js.map +1 -0
  84. package/dist/import-guest.d.ts +9 -0
  85. package/dist/import-guest.d.ts.map +1 -0
  86. package/dist/import-guest.js +155 -0
  87. package/dist/import-guest.js.map +1 -0
  88. package/dist/import-report.d.ts +17 -0
  89. package/dist/import-report.d.ts.map +1 -0
  90. package/dist/import-report.js +7 -0
  91. package/dist/import-report.js.map +1 -0
  92. package/dist/importer-wait.d.ts +2 -0
  93. package/dist/importer-wait.d.ts.map +1 -0
  94. package/dist/importer-wait.js +5 -0
  95. package/dist/importer-wait.js.map +1 -0
  96. package/dist/importer.d.ts +18 -4
  97. package/dist/importer.d.ts.map +1 -1
  98. package/dist/importer.js +322 -105
  99. package/dist/importer.js.map +1 -1
  100. package/dist/in-development.d.ts +2 -0
  101. package/dist/in-development.d.ts.map +1 -0
  102. package/dist/in-development.js +10 -0
  103. package/dist/in-development.js.map +1 -0
  104. package/dist/index.d.ts +16 -8
  105. package/dist/index.d.ts.map +1 -1
  106. package/dist/index.js +24 -8
  107. package/dist/index.js.map +1 -1
  108. package/dist/init-keys.d.ts +1 -1
  109. package/dist/init-keys.d.ts.map +1 -1
  110. package/dist/init-keys.js +6 -1
  111. package/dist/init-keys.js.map +1 -1
  112. package/dist/input-documents.d.ts +67 -0
  113. package/dist/input-documents.d.ts.map +1 -0
  114. package/dist/input-documents.js +693 -0
  115. package/dist/input-documents.js.map +1 -0
  116. package/dist/inputs-status.d.ts +80 -0
  117. package/dist/inputs-status.d.ts.map +1 -0
  118. package/dist/inputs-status.js +460 -0
  119. package/dist/inputs-status.js.map +1 -0
  120. package/dist/inputs.d.ts +2 -0
  121. package/dist/inputs.d.ts.map +1 -0
  122. package/dist/inputs.js +793 -0
  123. package/dist/inputs.js.map +1 -0
  124. package/dist/internal.d.ts +6 -1
  125. package/dist/internal.d.ts.map +1 -1
  126. package/dist/internal.js +4 -1
  127. package/dist/internal.js.map +1 -1
  128. package/dist/join-content.d.ts +33 -0
  129. package/dist/join-content.d.ts.map +1 -0
  130. package/dist/join-content.js +114 -0
  131. package/dist/join-content.js.map +1 -0
  132. package/dist/join-stamp.d.ts +3 -0
  133. package/dist/join-stamp.d.ts.map +1 -0
  134. package/dist/join-stamp.js +12 -0
  135. package/dist/join-stamp.js.map +1 -0
  136. package/dist/manifest-drift.d.ts +9 -0
  137. package/dist/manifest-drift.d.ts.map +1 -0
  138. package/dist/manifest-drift.js +46 -0
  139. package/dist/manifest-drift.js.map +1 -0
  140. package/dist/open-document.d.ts +109 -2
  141. package/dist/open-document.d.ts.map +1 -1
  142. package/dist/open-document.js +1822 -811
  143. package/dist/open-document.js.map +1 -1
  144. package/dist/page-restore.d.ts +12 -0
  145. package/dist/page-restore.d.ts.map +1 -0
  146. package/dist/page-restore.js +23 -0
  147. package/dist/page-restore.js.map +1 -0
  148. package/dist/placement.d.ts +13 -0
  149. package/dist/placement.d.ts.map +1 -0
  150. package/dist/placement.js +34 -0
  151. package/dist/placement.js.map +1 -0
  152. package/dist/presence.d.ts +1 -0
  153. package/dist/presence.d.ts.map +1 -1
  154. package/dist/presence.js +16 -4
  155. package/dist/presence.js.map +1 -1
  156. package/dist/read-only-document.d.ts +87 -0
  157. package/dist/read-only-document.d.ts.map +1 -0
  158. package/dist/read-only-document.js +4 -0
  159. package/dist/read-only-document.js.map +1 -0
  160. package/dist/record-paging.d.ts +63 -6
  161. package/dist/record-paging.d.ts.map +1 -1
  162. package/dist/record-paging.js +122 -29
  163. package/dist/record-paging.js.map +1 -1
  164. package/dist/references.d.ts +40 -0
  165. package/dist/references.d.ts.map +1 -0
  166. package/dist/references.js +135 -0
  167. package/dist/references.js.map +1 -0
  168. package/dist/request-lane.d.ts +5 -0
  169. package/dist/request-lane.d.ts.map +1 -0
  170. package/dist/request-lane.js +48 -0
  171. package/dist/request-lane.js.map +1 -0
  172. package/dist/sealed-arrow.d.ts +170 -0
  173. package/dist/sealed-arrow.d.ts.map +1 -0
  174. package/dist/sealed-arrow.js +769 -0
  175. package/dist/sealed-arrow.js.map +1 -0
  176. package/dist/sealed-cache.d.ts +21 -0
  177. package/dist/sealed-cache.d.ts.map +1 -0
  178. package/dist/sealed-cache.js +247 -0
  179. package/dist/sealed-cache.js.map +1 -0
  180. package/dist/sealed-encode.d.ts +87 -0
  181. package/dist/sealed-encode.d.ts.map +1 -0
  182. package/dist/sealed-encode.js +876 -0
  183. package/dist/sealed-encode.js.map +1 -0
  184. package/dist/sealed-handles.d.ts +45 -0
  185. package/dist/sealed-handles.d.ts.map +1 -0
  186. package/dist/sealed-handles.js +408 -0
  187. package/dist/sealed-handles.js.map +1 -0
  188. package/dist/sealed-store.d.ts +242 -0
  189. package/dist/sealed-store.d.ts.map +1 -0
  190. package/dist/sealed-store.js +1155 -0
  191. package/dist/sealed-store.js.map +1 -0
  192. package/dist/serializer.d.ts +6 -15
  193. package/dist/serializer.d.ts.map +1 -1
  194. package/dist/session-toolbar.d.ts +20 -5
  195. package/dist/session-toolbar.d.ts.map +1 -1
  196. package/dist/session-toolbar.js +419 -67
  197. package/dist/session-toolbar.js.map +1 -1
  198. package/dist/session.d.ts +38 -1
  199. package/dist/session.d.ts.map +1 -1
  200. package/dist/session.js +562 -79
  201. package/dist/session.js.map +1 -1
  202. package/dist/sha256.d.ts +3 -0
  203. package/dist/sha256.d.ts.map +1 -0
  204. package/dist/sha256.js +74 -0
  205. package/dist/sha256.js.map +1 -0
  206. package/dist/stable-handles.d.ts +19 -0
  207. package/dist/stable-handles.d.ts.map +1 -0
  208. package/dist/stable-handles.js +193 -0
  209. package/dist/stable-handles.js.map +1 -0
  210. package/dist/staged-seal.d.ts +2 -0
  211. package/dist/staged-seal.d.ts.map +1 -0
  212. package/dist/staged-seal.js +76 -0
  213. package/dist/staged-seal.js.map +1 -0
  214. package/dist/subscriber-delivery.d.ts +8 -0
  215. package/dist/subscriber-delivery.d.ts.map +1 -0
  216. package/dist/subscriber-delivery.js +31 -0
  217. package/dist/subscriber-delivery.js.map +1 -0
  218. package/dist/tail-op-import.d.ts +10 -0
  219. package/dist/tail-op-import.d.ts.map +1 -0
  220. package/dist/tail-op-import.js +33 -0
  221. package/dist/tail-op-import.js.map +1 -0
  222. package/dist/topic-lifecycle.d.ts +6 -0
  223. package/dist/topic-lifecycle.d.ts.map +1 -1
  224. package/dist/topic-lifecycle.js +32 -2
  225. package/dist/topic-lifecycle.js.map +1 -1
  226. package/dist/trial-replace-dialog.d.ts +10 -0
  227. package/dist/trial-replace-dialog.d.ts.map +1 -0
  228. package/dist/trial-replace-dialog.js +153 -0
  229. package/dist/trial-replace-dialog.js.map +1 -0
  230. package/dist/types.d.ts +8 -1
  231. package/dist/types.d.ts.map +1 -1
  232. package/dist/undo.d.ts +60 -5
  233. package/dist/undo.d.ts.map +1 -1
  234. package/dist/undo.js +344 -75
  235. package/dist/undo.js.map +1 -1
  236. package/dist/version-bar.d.ts +1 -0
  237. package/dist/version-bar.d.ts.map +1 -1
  238. package/dist/version-bar.js +2 -1
  239. package/dist/version-bar.js.map +1 -1
  240. package/dist/version.d.ts +2 -2
  241. package/dist/version.js +1 -1
  242. package/dist/ws-client.d.ts +21 -0
  243. package/dist/ws-client.d.ts.map +1 -1
  244. package/dist/ws-client.js +192 -8
  245. package/dist/ws-client.js.map +1 -1
  246. package/dist/ws-frame-limit.d.ts +1 -0
  247. package/dist/ws-frame-limit.d.ts.map +1 -1
  248. package/dist/ws-frame-limit.js.map +1 -1
  249. package/docs/app-manifest.md +121 -17
  250. package/docs/custom-chrome.md +24 -16
  251. package/docs/hosted-ui-advanced.md +38 -6
  252. package/docs/imported-documents.md +104 -51
  253. package/docs/presence.md +16 -4
  254. package/docs/schemas.md +8 -5
  255. package/docs/services.md +6 -6
  256. package/docs/streams.md +139 -150
  257. package/docs/text-fields.md +26 -19
  258. package/package.json +5 -2
  259. package/src/api-fetch.ts +53 -3
  260. package/src/auth-flow.ts +1 -1
  261. package/src/batched-get.ts +117 -0
  262. package/src/call-service.ts +78 -3
  263. package/src/client.ts +1022 -112
  264. package/src/document-checkpoints.ts +307 -65
  265. package/src/document-commands.ts +5 -5
  266. package/src/document-contents.ts +27 -1
  267. package/src/document-set-subscription.ts +274 -0
  268. package/src/document-signals.ts +47 -5
  269. package/src/document-streams.ts +85 -16
  270. package/src/document-thumbnail-capture.ts +118 -32
  271. package/src/documents-namespace.ts +539 -84
  272. package/src/documents.ts +2017 -348
  273. package/src/errors.ts +17 -6
  274. package/src/fetch-retry.ts +5 -0
  275. package/src/file-choice.ts +26 -0
  276. package/src/guest-link.ts +362 -1
  277. package/src/handle-types.ts +73 -47
  278. package/src/handles.ts +253 -83
  279. package/src/hosted-ui.ts +211 -50
  280. package/src/import-contract.ts +227 -0
  281. package/src/import-guest.ts +193 -0
  282. package/src/import-report.ts +24 -0
  283. package/src/importer-wait.ts +4 -0
  284. package/src/importer.ts +386 -131
  285. package/src/in-development.ts +10 -0
  286. package/src/index.ts +76 -16
  287. package/src/init-keys.ts +6 -1
  288. package/src/input-documents.ts +819 -0
  289. package/src/inputs-status.ts +598 -0
  290. package/src/inputs.ts +1090 -0
  291. package/src/internal.ts +7 -0
  292. package/src/join-content.ts +135 -0
  293. package/src/join-stamp.ts +12 -0
  294. package/src/manifest-drift.ts +54 -0
  295. package/src/open-document.ts +2346 -930
  296. package/src/page-restore.ts +38 -0
  297. package/src/placement.ts +54 -0
  298. package/src/presence.ts +21 -5
  299. package/src/read-only-document.ts +133 -0
  300. package/src/record-paging.ts +147 -25
  301. package/src/references.ts +207 -0
  302. package/src/request-lane.ts +59 -0
  303. package/src/sealed-arrow.ts +843 -0
  304. package/src/sealed-cache.ts +267 -0
  305. package/src/sealed-encode.ts +1015 -0
  306. package/src/sealed-handles.ts +486 -0
  307. package/src/sealed-store.ts +1330 -0
  308. package/src/serializer.ts +8 -20
  309. package/src/session-toolbar.ts +463 -72
  310. package/src/session.ts +740 -99
  311. package/src/sha256.ts +65 -0
  312. package/src/stable-handles.ts +235 -0
  313. package/src/staged-seal.ts +90 -0
  314. package/src/subscriber-delivery.ts +37 -0
  315. package/src/tail-op-import.ts +30 -0
  316. package/src/topic-lifecycle.ts +38 -2
  317. package/src/trial-replace-dialog.ts +163 -0
  318. package/src/types.ts +6 -6
  319. package/src/undo.ts +386 -73
  320. package/src/version-bar.ts +5 -1
  321. package/src/version.ts +1 -1
  322. package/src/ws-client.ts +208 -16
  323. package/src/ws-frame-limit.ts +1 -0
package/dist/importer.js CHANGED
@@ -1,5 +1,7 @@
1
+ import { SealRefusedError } from './staged-seal.js';
2
+ import { ImportResultError, encodeImportStreams, encodeStreamBundle, readImportResult, } from './import-contract.js';
1
3
  import { BrassError } from './errors.js';
2
- import { whenSaved } from './when-saved.js';
4
+ import { claimHolderOf } from './api-fetch.js';
3
5
  // The claim holder can close its tab mid-import and let its claim expire, so
4
6
  // a client that lost the race asks again instead of spending this document's
5
7
  // one attempt on it.
@@ -16,12 +18,27 @@ const PENDING_RETRY_INTERVAL_MS = 120_000;
16
18
  // Enough tail attempts to outlast a holder refreshing to its own bound, and
17
19
  // far inside the per-caller claim budget.
18
20
  const PENDING_RETRY_TAIL = 18;
21
+ // The whole wait on another client's claim, which is what the schedule above
22
+ // spans; a holder that keeps refreshing is waited for this long.
23
+ const PENDING_WAIT_MAX_MS = PENDING_RETRY_DELAYS_MS.reduce((a, b) => a + b, 0) +
24
+ PENDING_RETRY_TAIL * PENDING_RETRY_INTERVAL_MS;
25
+ // A holder refreshes its claim every `CLAIM_REFRESH_MS`, so one that has not
26
+ // for this long has missed a refresh and is taken to have stopped. The reader
27
+ // asks again the moment the stopped holder's claim lapses, which is when the
28
+ // platform lets it take the claim over.
29
+ export const STALLED_HOLDER_MS = 2 * 60_000;
30
+ const LAPSE_MARGIN_MS = 2_000;
19
31
  // A claim expires while a long import is still parsing or still waiting for
20
32
  // its writes to be acked, and the completion needs it, so the runner
21
33
  // re-claims on this interval while its own import runs. Bounded so a
22
34
  // document whose writes never drain stops re-claiming.
23
35
  const CLAIM_REFRESH_MS = 60_000;
24
36
  const CLAIM_REFRESH_MAX = 30;
37
+ // How long an importer may run before its import is recorded as failed, as a
38
+ // thrown importer's is. Inside the claim's refreshed lifetime, so the failure
39
+ // is recorded while this client still holds the claim, and far past what a
40
+ // file at the platform's upload cap takes to parse.
41
+ export const IMPORTER_RUN_CEILING_MS = 20 * 60_000;
25
42
  // The status the platform refuses an import the app cannot run with: its
26
43
  // `imports` do not claim the file, it declares no schema, or the document
27
44
  // holds a half-written import.
@@ -53,13 +70,59 @@ export function createImportRunner(deps) {
53
70
  // still say "someone is watching this" when nothing is, and the reopened
54
71
  // document would never attempt its import again for the life of the page.
55
72
  const waiting = new WeakMap();
56
- // Retries already scheduled against another client's live claim.
73
+ // Retries already scheduled against another client's live claim, and when
74
+ // the wait on it began.
57
75
  const pendingRetries = new WeakMap();
76
+ const pendingSince = new WeakMap();
77
+ // Documents whose last answer named a holder that had stopped refreshing.
78
+ const stalledBefore = new WeakSet();
79
+ // Documents this runner is holding read-only while an import is in flight
80
+ // on them, in this client or in another. The import becomes the document's
81
+ // content only while nothing else has been written to it, so an edit made
82
+ // first would leave the file unimportable.
83
+ const importLocks = new WeakSet();
84
+ const reloadsInPlace = new WeakSet();
85
+ // The import attempt in flight for each document id, from its claim to its
86
+ // outcome, across every Document this client holds for that id.
87
+ const inFlight = new Map();
88
+ // Frozen copies that reload when their hold is released, because what they
89
+ // loaded is no longer what the document holds: a copy taken before its file
90
+ // was stored learns what that work left, and a copy of a file another
91
+ // client imported takes that import.
92
+ const reloadOnRelease = new WeakSet();
93
+ function lock(doc, message) {
94
+ importLocks.add(doc);
95
+ doc._importHold = { message, pending: true, blocking: true };
96
+ doc._emitStatus(doc._importHold);
97
+ }
98
+ // Release the hold onto a failed import rather than onto "Ready": the
99
+ // document holds nothing the file had in it.
100
+ function settleFailed(doc, message) {
101
+ reloadOnRelease.delete(doc);
102
+ importLocks.delete(doc);
103
+ doc._importHold = null;
104
+ doc._emitStatus({ message, pending: false, blocking: true });
105
+ }
106
+ function unlock(doc) {
107
+ if (reloadOnRelease.delete(doc)) {
108
+ importLocks.delete(doc);
109
+ doc._awaitsImport = false;
110
+ doc._importHold = null;
111
+ doc.reload().catch((err) => deps.reportError(asError(err)));
112
+ return;
113
+ }
114
+ if (!importLocks.delete(doc))
115
+ return;
116
+ doc._importHold = null;
117
+ doc._emitStatus({ message: 'Ready', pending: false, blocking: false }, { contentLoaded: true });
118
+ }
58
119
  const runner = {
59
120
  setImporter(fn) {
60
121
  importer = fn;
61
122
  },
62
- async attempt(doc) {
123
+ async attempt(doc, options) {
124
+ if (options?.reloadInPlace === true)
125
+ reloadsInPlace.add(doc);
63
126
  if (importer === null || doc.id === null)
64
127
  return;
65
128
  if (attempted.has(doc) && attempted.get(doc) === doc._openGeneration) {
@@ -76,22 +139,38 @@ export function createImportRunner(deps) {
76
139
  if (!doc._isLive)
77
140
  return;
78
141
  // A document with server-side work in flight has no source file to
79
- // read yet. A drive-linked file is fetched from the drive and stored
80
- // by a worker AFTER the open returns, so claiming now asks to import
81
- // bytes that have not arrived: the platform refuses, and this
82
- // document's one attempt is spent on a document that was never
83
- // eligible. Wait for the work the server reports, then attempt.
84
- if (doc.status?.pending === true) {
142
+ // read yet (a trial document opened through its link while the
143
+ // visitor's file is stored), so claiming now asks to import bytes that
144
+ // have not arrived: the platform refuses, and this document's one
145
+ // attempt is spent on a document that was never eligible. Wait for the
146
+ // work the server reports, then attempt.
147
+ if (doc._workStatusNow?.pending === true && !importLocks.has(doc)) {
85
148
  // Any listener from an earlier attempt goes first, so the document is
86
149
  // watched exactly once whether or not the previous one survived.
87
150
  waiting.get(doc)?.();
88
151
  waiting.delete(doc);
152
+ // A frozen copy holds through the end of that work: the copy is still
153
+ // the empty one it loaded, so the settled status the work reports
154
+ // would read as an empty file until the claim answers. The hold is
155
+ // what the document emits in place of that status, which is how the
156
+ // listener tells the work ending from its progress.
157
+ const hold = reloadsInPlace.has(doc)
158
+ ? { message: 'Importing...', pending: true, blocking: true }
159
+ : null;
160
+ if (hold !== null) {
161
+ doc._importHold = hold;
162
+ doc._awaitsImport = true;
163
+ }
89
164
  try {
90
165
  const off = doc.onStatus((status) => {
91
- if (status.pending)
166
+ if (status.pending && status !== hold)
92
167
  return;
93
168
  waiting.get(doc)?.();
94
169
  waiting.delete(doc);
170
+ if (hold !== null) {
171
+ importLocks.add(doc);
172
+ reloadOnRelease.add(doc);
173
+ }
95
174
  void runner.attempt(doc);
96
175
  });
97
176
  waiting.set(doc, off);
@@ -106,103 +185,213 @@ export function createImportRunner(deps) {
106
185
  // rather than leave it to fire against a document already past it.
107
186
  waiting.get(doc)?.();
108
187
  waiting.delete(doc);
188
+ // Another Document for this id is already importing it in this client.
189
+ // Every claim this client makes carries one client id, so the platform
190
+ // would hand this one the same claim and the file would be imported
191
+ // twice. It waits for that attempt to settle and then asks for itself,
192
+ // which answers from whatever that attempt left.
193
+ const running = inFlight.get(doc.id);
194
+ if (running !== undefined) {
195
+ if (doc._awaitsImport)
196
+ lock(doc, 'Importing...');
197
+ await running;
198
+ return runner.attempt(doc);
199
+ }
109
200
  attempted.set(doc, doc._openGeneration);
110
201
  const run = importer;
111
202
  const docId = doc.id;
112
- let claim;
203
+ let settle = () => undefined;
204
+ const work = new Promise((resolve) => (settle = resolve));
205
+ inFlight.set(docId, work);
113
206
  try {
114
- claim = await deps.claimImport(docId);
115
- }
116
- catch (err) {
117
- const status = err instanceof BrassError ? err.status : undefined;
118
- if (status === 409) {
119
- schedulePendingRetry(doc);
207
+ // Held before the claim goes out, and synchronously, so the app never
208
+ // sees the empty document as editable while the answer is in flight.
209
+ if (doc._awaitsImport)
210
+ lock(doc, 'Importing...');
211
+ doc._importAbandoned = null;
212
+ let claim;
213
+ try {
214
+ claim = await deps.claimImport(docId);
215
+ }
216
+ catch (err) {
217
+ const status = err instanceof BrassError ? err.status : undefined;
218
+ if (status === 409) {
219
+ const holder = claimHolderOf(err);
220
+ // A holder that stopped refreshing and still held the claim after
221
+ // it should have lapsed is not coming back for it.
222
+ if (holder !== null && stalled(holder) && stalledBefore.has(doc)) {
223
+ stalledBefore.delete(doc);
224
+ giveUp(doc, STALLED_HOLDER_MESSAGE);
225
+ return;
226
+ }
227
+ lock(doc, 'Importing...');
228
+ schedulePendingRetry(doc, holder);
229
+ return;
230
+ }
231
+ // Refused for rate, not eligibility: the file is still waiting, so
232
+ // the document stays held and the claim is asked again.
233
+ if (status === 429 && doc._awaitsImport) {
234
+ deps.reportError(asError(err));
235
+ lock(doc, 'Importing...');
236
+ schedulePendingRetry(doc);
237
+ return;
238
+ }
239
+ unlock(doc);
240
+ // A refusal names what the developer has to change, so it reaches
241
+ // the app's error handler; the rest of the 4xx surface (nothing
242
+ // stored to import, read-only access) is a no-op.
243
+ if (status !== undefined &&
244
+ status < 500 &&
245
+ status !== CLAIM_REFUSED_STATUS) {
246
+ return;
247
+ }
248
+ deps.reportError(asError(err));
120
249
  return;
121
250
  }
122
- // A refusal names what the developer has to change, so it reaches
123
- // the app's error handler; the rest of the 4xx surface (nothing
124
- // stored to import, read-only access) is a no-op.
125
- if (status !== undefined &&
126
- status < 500 &&
127
- status !== CLAIM_REFUSED_STATUS) {
251
+ if (claim.import_failed === true) {
252
+ settleFailed(doc, claim.message ?? 'This file could not be imported.');
128
253
  return;
129
254
  }
130
- deps.reportError(asError(err));
131
- return;
132
- }
133
- if (claim.claimed !== true)
134
- return;
135
- // This client won the claim: run the importer, then report
136
- // completion so the platform stamps the document with the app's
137
- // schema. A throw skips the completion and leaves the claim to
138
- // expire; the platform decides what a later claim may do with a
139
- // document the failed run already wrote records into.
140
- try {
141
- const source = await doc.sourceBlob();
142
- const stopRefresh = startClaimRefresh(docId, doc);
143
- // Whether the importer put anything on the wire. A commit fires the
144
- // document's subscribers synchronously and raises `savingCount` as it
145
- // does, so a run that wrote is seen here even when its ops ack before
146
- // it returns.
147
- let wroteRecords = false;
148
- const stopWatchingWrites = doc.subscribe(() => {
149
- if (doc.savingCount > 0)
150
- wroteRecords = true;
151
- });
152
- let saved = false;
153
- try {
154
- await run(source, doc);
155
- // The importer's ops are still in flight when it returns, and
156
- // the completion stamps the version the import produced from
157
- // the head it lands on. Completing before they are acked stamps
158
- // a version below the records' own, which reads as a document
159
- // edited since it was uploaded from then on.
160
- saved = await whenSaved(doc);
255
+ if (claim.claimed !== true) {
256
+ // Imported elsewhere, or nothing to import: either way the lock has
257
+ // nothing left to hold, since the reload an import's completion sent
258
+ // carries its content. A frozen copy hears that reload as a change
259
+ // notice only, so it loads the content itself.
260
+ if (reloadsInPlace.has(doc) && claim.already_imported === true)
261
+ reloadOnRelease.add(doc);
262
+ unlock(doc);
263
+ return;
161
264
  }
162
- finally {
163
- stopRefresh();
164
- stopWatchingWrites();
265
+ // This client won the claim: run the importer over the stored files,
266
+ // encode what it returns, and hand the platform the encoded streams to
267
+ // seal as the document's content. An importer that cannot read the
268
+ // file is recorded on the document, so later opens show the failure
269
+ // instead of running it again, and so is a seal refused for what the
270
+ // importer produced. Any other throw (the file unreachable, the
271
+ // document changed under the seal) leaves the file for a later open
272
+ // to import.
273
+ lock(doc, 'Importing...');
274
+ let failure = null;
275
+ try {
276
+ const source = await doc.sourceBlob();
277
+ lock(doc, `Importing ${source.filename}...`);
278
+ const stopRefresh = startClaimRefresh(docId, doc);
279
+ try {
280
+ let result = null;
281
+ try {
282
+ result = readImportResult(await withinCeiling(run(importFileOf(source))));
283
+ }
284
+ catch (err) {
285
+ if (unreadSources.has(err))
286
+ throw err;
287
+ failure = asError(err);
288
+ }
289
+ if (failure === null && result === null) {
290
+ failure = new Error('The importer returned no content, so this file was not ' +
291
+ 'imported. Return { streams } from the importer.');
292
+ }
293
+ if (failure === null && result !== null) {
294
+ failure = await seal(doc, docId, result);
295
+ }
296
+ }
297
+ finally {
298
+ stopRefresh();
299
+ }
165
300
  }
166
- // The wait ends on the document going, and on the acks stopping, as
167
- // well as on the writes draining, and only the last of those means
168
- // the records are stored. The completion stamps the document with the
169
- // app's schema at the version it lands on, so running it over writes
170
- // that never reached the server records an import of records the
171
- // document does not hold. Abandoning instead leaves the claim to
172
- // expire, and a client that is still open imports the file properly.
173
- if (!saved)
301
+ catch (err) {
302
+ deps.reportError(asError(err));
303
+ // A seal the platform refused for the file's content was recorded
304
+ // on the document as a failed import, as the importer's own
305
+ // failure is.
306
+ if (err instanceof SealRefusedError && err.importFailed !== undefined) {
307
+ settleFailed(doc, err.importFailed);
308
+ return;
309
+ }
310
+ unlock(doc);
174
311
  return;
175
- // An importer that returns without writing anything must not stamp the
176
- // document imported: the stamp is permanent, a later open reads
177
- // `already_imported`, and the file's records then have no path into a
178
- // document that holds none. `try { parse() } catch { return }` is an
179
- // ordinary shape, so this is reachable from app code that looks
180
- // correct. Both signals are required before skipping, so an import
181
- // that DID write is completed either way and never runs twice.
182
- if (!wroteRecords && isEmptyDocument(doc)) {
183
- deps.reportError(new Error('The importer wrote no records, so this file was not imported. ' +
184
- 'Reload to try again.'));
312
+ }
313
+ if (failure === null) {
314
+ unlock(doc);
185
315
  return;
186
316
  }
187
- await deps.completeImport(docId);
317
+ deps.reportError(failure);
318
+ try {
319
+ const recorded = await deps.failImport(docId, failure.message);
320
+ settleFailed(doc, recorded.message);
321
+ }
322
+ catch (err) {
323
+ deps.reportError(asError(err));
324
+ unlock(doc);
325
+ }
188
326
  }
189
- catch (err) {
190
- deps.reportError(asError(err));
327
+ finally {
328
+ if (inFlight.get(docId) === work)
329
+ inFlight.delete(docId);
330
+ settle();
191
331
  }
192
332
  },
193
333
  };
194
- function schedulePendingRetry(doc) {
334
+ // Seal the streams as the document's first content, answering the failure
335
+ // to record when the result holds nothing. The platform refuses a document
336
+ // something was already written to, and that refusal reaches the app's
337
+ // error handler like any other failed import.
338
+ async function seal(doc, docId, result) {
339
+ const streams = await encodeImportStreams(result);
340
+ // An import that holds nothing must not stamp the document imported: the
341
+ // stamp is permanent, and the file's content would then have no path
342
+ // into a document that holds none.
343
+ if (streams.length === 0) {
344
+ return new Error('The importer returned no records, so this file was not imported.');
345
+ }
346
+ if (!doc._isLive)
347
+ return null;
348
+ const key = await deps.stageImport(docId, encodeStreamBundle(streams));
349
+ await deps.completeImport(docId, result.report, key);
350
+ // Every open client reloads onto the sealed content, this one included;
351
+ // reloading here shows it without waiting for that frame. The copy stays
352
+ // held as importing until the reloaded one replaces it: released first,
353
+ // it would report Ready on a document that holds none of the file.
354
+ doc._awaitsImport = false;
355
+ if (reloadsInPlace.has(doc)) {
356
+ reloadOnRelease.delete(doc);
357
+ await doc.reload();
358
+ unlock(doc);
359
+ return null;
360
+ }
361
+ importLocks.delete(doc);
362
+ doc._reopen();
363
+ return null;
364
+ }
365
+ // Release a document whose import this client stopped waiting for, saying
366
+ // why: the reader is looking at an empty document, so the reason is what
367
+ // keeps them from concluding the file was empty.
368
+ function giveUp(doc, message) {
369
+ unlock(doc);
370
+ doc._importAbandoned = message;
371
+ deps.reportError(new Error(message));
372
+ }
373
+ function schedulePendingRetry(doc, holder = null) {
195
374
  const taken = pendingRetries.get(doc) ?? 0;
196
- const delay = PENDING_RETRY_DELAYS_MS[taken] ??
197
- (taken < PENDING_RETRY_DELAYS_MS.length + PENDING_RETRY_TAIL
198
- ? PENDING_RETRY_INTERVAL_MS
199
- : undefined);
200
- if (delay === undefined) {
201
- // Out of attempts with the file still unimported. The reader is looking
202
- // at an empty document, so say so rather than leaving them to conclude
203
- // the file was empty.
204
- deps.reportError(new Error('Could not import this file: another window has been importing it ' +
205
- 'for longer than expected. Reload to try again.'));
375
+ const now = Date.now();
376
+ const since = pendingSince.get(doc) ?? now;
377
+ pendingSince.set(doc, since);
378
+ let delay = PENDING_RETRY_DELAYS_MS[taken] ?? PENDING_RETRY_INTERVAL_MS;
379
+ if (holder !== null && !holder.sealing) {
380
+ // Ask again as soon as a holder that stops now would read as stopped,
381
+ // or the moment a stopped one's claim lapses.
382
+ if (stalled(holder)) {
383
+ stalledBefore.add(doc);
384
+ delay = holder.expiresInMs + LAPSE_MARGIN_MS;
385
+ }
386
+ else {
387
+ stalledBefore.delete(doc);
388
+ delay = Math.min(delay, STALLED_HOLDER_MS - holder.refreshedMsAgo + LAPSE_MARGIN_MS);
389
+ }
390
+ }
391
+ if (now + delay - since > PENDING_WAIT_MAX_MS) {
392
+ // Out of time with the file still unimported.
393
+ giveUp(doc, 'Could not import this file: another window has been importing it ' +
394
+ 'for longer than expected. Reload to try again.');
206
395
  return;
207
396
  }
208
397
  pendingRetries.set(doc, taken + 1);
@@ -238,24 +427,52 @@ export function createImportRunner(deps) {
238
427
  }
239
428
  return runner;
240
429
  }
430
+ // An importer's run, rejected once it passes `IMPORTER_RUN_CEILING_MS`.
431
+ function withinCeiling(run) {
432
+ let timer;
433
+ const ceiling = new Promise((_, reject) => {
434
+ timer = setTimeout(() => reject(new Error(`The importer did not finish within ${IMPORTER_RUN_CEILING_MS / 60_000} minutes, ` +
435
+ 'so this file was not imported.')), IMPORTER_RUN_CEILING_MS);
436
+ });
437
+ return Promise.race([Promise.resolve(run), ceiling]).finally(() => clearTimeout(timer));
438
+ }
439
+ const STALLED_HOLDER_MESSAGE = 'Could not import this file: the window that was importing it stopped ' +
440
+ 'responding. Reload to try again.';
441
+ function stalled(holder) {
442
+ return !holder.sealing && holder.refreshedMsAgo >= STALLED_HOLDER_MS;
443
+ }
444
+ // Errors thrown reading the stored file. They say the file could not be
445
+ // reached, not that the importer could not read it, so they are not recorded
446
+ // as a failed import.
447
+ const unreadSources = new WeakSet();
241
448
  function asError(err) {
242
449
  return err instanceof Error ? err : new Error(String(err));
243
450
  }
244
- // Whether the document holds nothing at all, read only when no write was
245
- // observed, so the walk is over an empty or near-empty document.
246
- //
247
- // A document reports its ROOTS whatever it holds (a fresh one reads
248
- // `{ entities: {} }`), so emptiness is every root being empty rather than
249
- // there being no roots.
250
- function isEmptyDocument(doc) {
251
- try {
252
- return Object.values(doc.toJSON()).every((root) => root === null ||
253
- typeof root !== 'object' ||
254
- Object.keys(root).length === 0);
255
- }
256
- catch {
257
- // A document that cannot be read is not one to declare empty.
258
- return false;
259
- }
451
+ // The file an importer is given, fetched when the importer asks for its
452
+ // bytes.
453
+ function importFileOf(source) {
454
+ return {
455
+ name: source.filename,
456
+ content_type: source.content_type,
457
+ byte_size: source.byte_size,
458
+ url: source.url,
459
+ async bytes() {
460
+ try {
461
+ const response = await fetch(source.url);
462
+ if (!response.ok) {
463
+ throw new BrassError(`Reading ${source.filename} failed`, {
464
+ status: response.status,
465
+ });
466
+ }
467
+ return new Uint8Array(await response.arrayBuffer());
468
+ }
469
+ catch (err) {
470
+ if (err !== null && typeof err === 'object')
471
+ unreadSources.add(err);
472
+ throw err;
473
+ }
474
+ },
475
+ };
260
476
  }
477
+ export { ImportResultError };
261
478
  //# sourceMappingURL=importer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"importer.js","sourceRoot":"","sources":["../src/importer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAsC5C,6EAA6E;AAC7E,6EAA6E;AAC7E,qBAAqB;AACrB,EAAE;AACF,yEAAyE;AACzE,mEAAmE;AACnE,6EAA6E;AAC7E,yEAAyE;AACzE,2EAA2E;AAC3E,6EAA6E;AAC7E,qDAAqD;AACrD,MAAM,uBAAuB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAC1D,MAAM,yBAAyB,GAAG,OAAO,CAAC;AAC1C,4EAA4E;AAC5E,0CAA0C;AAC1C,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,4EAA4E;AAC5E,qEAAqE;AACrE,qEAAqE;AACrE,uDAAuD;AACvD,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAChC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,yEAAyE;AACzE,0EAA0E;AAC1E,+BAA+B;AAC/B,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAEjC,sEAAsE;AACtE,iEAAiE;AACjE,iDAAiD;AACjD,MAAM,UAAU,kBAAkB,CAAC,IAAsB;IACvD,IAAI,QAAQ,GAA4B,IAAI,CAAC;IAC7C,wEAAwE;IACxE,yEAAyE;IACzE,2EAA2E;IAC3E,6EAA6E;I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OAAO,GAAG,KAAK,QAAQ;oBAAE,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACpE,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const inDevelopment: () => boolean;
2
+ //# sourceMappingURL=in-development.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-development.d.ts","sourceRoot":"","sources":["../src/in-development.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,QAAO,OAMhC,CAAC"}
@@ -0,0 +1,10 @@
1
+ // Bundlers replace `process.env.NODE_ENV`; with none, nothing is reported.
2
+ export const inDevelopment = () => {
3
+ try {
4
+ return process.env.NODE_ENV !== 'production';
5
+ }
6
+ catch {
7
+ return false;
8
+ }
9
+ };
10
+ //# sourceMappingURL=in-development.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"in-development.js","sourceRoot":"","sources":["../src/in-development.ts"],"names":[],"mappings":"AAEA,2EAA2E;AAC3E,MAAM,CAAC,MAAM,aAAa,GAAG,GAAY,EAAE;IACzC,IAAI,CAAC;QACH,OAAO,OAAQ,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,23 +1,28 @@
1
- import type { CreateDocumentOptions, OpenDocumentByIdOptions, OpenedDocument } from './open-document.js';
2
- import type { SelectDocumentResult } from './hosted-ui.js';
1
+ import type { CreateDocumentOptions, OpenedDocument } from './open-document.js';
2
+ import type { ChooseInputOptions, ChooseInputsOptions, DocumentFamilies, InputReference, SelectDocumentResult } from './hosted-ui.js';
3
3
  import type { AppServiceState, CallServiceOptions } from './call-service.js';
4
4
  import type { DocumentsNamespace } from './documents-namespace.js';
5
- import type { DocumentImporter } from './importer.js';
5
+ import type { OpenDocumentById } from './read-only-document.js';
6
+ import type { DocumentImporter } from './import-contract.js';
6
7
  import type { DocumentSerializer } from './serializer.js';
7
8
  import type { DocumentSession } from './session.js';
8
9
  import type { AuthStatus, ErrorListener, BrassInitOptions, BrassUser, UndoControllerOptions, UserChangeListener } from './types.js';
9
10
  export type { AuthStatus, ErrorListener, BrassInitOptions, BrassUser, UndoControllerOptions, UserChangeListener, };
10
11
  export { BrassError, type BrassErrorCode } from './errors.js';
11
12
  export type { AppServiceState, CallServiceBody, CallServiceOptions, } from './call-service.js';
12
- export { type HostedUiTheme, type SelectDocumentResult, } from './hosted-ui.js';
13
- export { type DocumentMember, type DocumentRecord, type DocumentRole, type DocumentCheckpoint, type DocumentSourceBlob, type DocumentSourceStream, type DocumentStreamInfo, type DocumentSummary, type DocumentThumbnail, type DocumentsNamespace, type GetThumbnailOptions, type SetThumbnailInput, } from './documents-namespace.js';
13
+ export { type HostedUiTheme, type ChooseInputOptions, type ChooseInputsOptions, type DocumentFamilies, type SelectDocumentResult, type SelectionAccept, type SelectionNarrowing, } from './hosted-ui.js';
14
+ export { type DocumentMember, type DocumentRecord, type DocumentRole, type DocumentSourceBlob, type DocumentStreamInfo, type DocumentSummary, type DocumentThumbnail, type DocumentsNamespace, type GetThumbnailOptions, type SetThumbnailInput, } from './documents-namespace.js';
15
+ export { type ReadOnlyDocument, type ReadOnlyStream, type ReadOnlyListHandle, type ReadOnlyMapHandle, type ReadOnlyOrderedMapHandle, type ReadOnlyTextHandle, type OpenModeOptions, } from './read-only-document.js';
14
16
  export { type CanvasSource, type Command, type CommandGroup, type CommandSurface, type DocumentSession, type SessionOpenOptions, type SessionStatus, } from './session.js';
15
17
  export type { SessionToolbarHandle, SessionHeaderHandle, SessionToolbarOptions, MountedPiece, } from './session-toolbar.js';
16
18
  import type { SessionToolbarHandle, SessionHeaderHandle, SessionToolbarOptions, MountedPiece } from './session-toolbar.js';
17
19
  export { Document, type DocumentMutator, type DocumentOptions, type DocumentSubscriber, type SyntheticSubscribeEvent, type DocumentUnsubscribe, type DocumentGoneListener, type DocumentGoneReason, type DocumentGoneUnsubscribe, type DocumentWorkStatus, type DocumentStatusListener, type DocumentStatusUnsubscribe, type DocumentDriveStatus, type DocumentDriveStatusListener, type DocumentDriveStatusUnsubscribe, type DocumentDriveTrackingState, type DriveMirrorDirection, type EntityProxy, type RootKind, type UndoState, type UndoStateSubscriber, } from './documents.js';
18
- export type { Change, ChangeOrigin, ChangeSource, HandleUnsubscribe, ListHandle, ListChange, ListSubscriber, Splice, MapHandle, MapSubscriber, OrderedMapHandle, OrderedMapPosition, TextHandle, TextSubscriber, } from './handle-types.js';
20
+ export type { Change, ChangeOrigin, ChangeSource, HandleUnsubscribe, ListHandle, ListChange, ListSubscriber, Splice, MapHandle, MapSubscriber, MutateOptions, OrderedMapHandle, OrderedMapPosition, TextHandle, TextSubscriber, } from './handle-types.js';
21
+ export type { InputDocument, InputDocumentHandlers, InputDocumentOpen, InputDocumentOptions, } from './input-documents.js';
19
22
  export type { DocumentSerializer, StoredDocument, StoredList, StoredMap, } from './serializer.js';
20
- export type { DocumentImporter } from './importer.js';
23
+ export type { DocumentImporter, ImportContent, ImportFile, ImportResult, } from './import-contract.js';
24
+ export type { ImportFinding, ImportFindingKind, ImportReport, } from './import-report.js';
25
+ export type { InputReference, InputStatus, InputStatusDocument, } from './inputs-status.js';
21
26
  export { DocumentStream } from './document-streams.js';
22
27
  export { type CreateDocumentOptions, type OpenDocumentByIdOptions, type OpenedDocument, } from './open-document.js';
23
28
  export { PRESENCE_LAYER_MAX_BYTES } from './presence.js';
@@ -47,9 +52,12 @@ export declare const Brass: {
47
52
  mountDriveSync(container: HTMLElement): MountedPiece;
48
53
  mountAccountMenu(container: HTMLElement): MountedPiece;
49
54
  mountVersionPreview(container: HTMLElement): MountedPiece;
55
+ /** @deprecated Use `Brass.session.open()` with no id. */
50
56
  selectDocument(): Promise<SelectDocumentResult | null>;
57
+ chooseInputs(families: DocumentFamilies, options?: ChooseInputsOptions): Promise<InputReference[] | null>;
58
+ chooseInput(families: DocumentFamilies, options?: ChooseInputOptions): Promise<InputReference | null>;
51
59
  shareDocument(docId: string): Promise<void>;
52
- openDocumentById(docId: string, options?: OpenDocumentByIdOptions): Promise<OpenedDocument>;
60
+ openDocumentById: OpenDocumentById;
53
61
  readonly isGuest: boolean;
54
62
  createDocument(options?: CreateDocumentOptions): Promise<OpenedDocument>;
55
63
  registerSerializer(serializer: DocumentSerializer): void;