@wtfalch/chat 0.1.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 (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +293 -0
  3. package/dist/chat/admin/admin.css +78 -0
  4. package/dist/chat/admin/index.d.ts +92 -0
  5. package/dist/chat/admin/index.js +124 -0
  6. package/dist/chat/admin/react.d.ts +40 -0
  7. package/dist/chat/admin/react.js +169 -0
  8. package/dist/chat/chat.css +1003 -0
  9. package/dist/chat/client.d.ts +30 -0
  10. package/dist/chat/client.js +1300 -0
  11. package/dist/chat/exchange.d.ts +9 -0
  12. package/dist/chat/exchange.js +31 -0
  13. package/dist/chat/fake/index.d.ts +27 -0
  14. package/dist/chat/fake/index.js +48 -0
  15. package/dist/chat/fake/intercept.d.ts +21 -0
  16. package/dist/chat/fake/intercept.js +57 -0
  17. package/dist/chat/fake/sample.d.ts +4 -0
  18. package/dist/chat/fake/sample.js +6 -0
  19. package/dist/chat/fake/server.d.ts +168 -0
  20. package/dist/chat/fake/server.js +811 -0
  21. package/dist/chat/fake/xhr.d.ts +3 -0
  22. package/dist/chat/fake/xhr.js +104 -0
  23. package/dist/chat/index.d.ts +10 -0
  24. package/dist/chat/index.js +9 -0
  25. package/dist/chat/markdown.d.ts +29 -0
  26. package/dist/chat/markdown.js +161 -0
  27. package/dist/chat/react/Attachment.d.ts +39 -0
  28. package/dist/chat/react/Attachment.js +113 -0
  29. package/dist/chat/react/Chat.d.ts +48 -0
  30. package/dist/chat/react/Chat.js +139 -0
  31. package/dist/chat/react/Composer.d.ts +25 -0
  32. package/dist/chat/react/Composer.js +157 -0
  33. package/dist/chat/react/MessageRow.d.ts +21 -0
  34. package/dist/chat/react/MessageRow.js +114 -0
  35. package/dist/chat/react/NewDirectMessage.d.ts +23 -0
  36. package/dist/chat/react/NewDirectMessage.js +47 -0
  37. package/dist/chat/react/ThreadPanel.d.ts +25 -0
  38. package/dist/chat/react/ThreadPanel.js +17 -0
  39. package/dist/chat/react/Timeline.d.ts +27 -0
  40. package/dist/chat/react/Timeline.js +120 -0
  41. package/dist/chat/react/index.d.ts +7 -0
  42. package/dist/chat/react/index.js +6 -0
  43. package/dist/chat/react/mentions.d.ts +34 -0
  44. package/dist/chat/react/mentions.js +70 -0
  45. package/dist/chat/react/scroll.d.ts +26 -0
  46. package/dist/chat/react/scroll.js +27 -0
  47. package/dist/chat/react/timelineLayout.d.ts +26 -0
  48. package/dist/chat/react/timelineLayout.js +47 -0
  49. package/dist/chat/sanitize.d.ts +49 -0
  50. package/dist/chat/sanitize.js +264 -0
  51. package/dist/chat/store.d.ts +16 -0
  52. package/dist/chat/store.js +25 -0
  53. package/dist/chat/types.d.ts +340 -0
  54. package/dist/chat/types.js +1 -0
  55. package/package.json +88 -0
@@ -0,0 +1,30 @@
1
+ import type { ChatClient, CreateChatClientOptions } from './types.ts';
2
+ /** What the bootstrap sets Synapse's `max_upload_size` to (chat plan
3
+ * section 8). Checked here so a person who picks a 200 MB video is told
4
+ * so at once, rather than after the whole thing has gone up and Synapse
5
+ * has refused it. */
6
+ export declare const MAX_UPLOAD_BYTES: number;
7
+ /**
8
+ * A chat session behind the exchange: a matrix-js-sdk `MatrixClient` the
9
+ * caller never sees, refreshed on its own, exposing only what a UI needs.
10
+ *
11
+ * **Crypto stays off.** Encryption is not in the first ship (chat plan
12
+ * section 6), so this never calls `initRustCrypto()`. matrix-js-sdk only
13
+ * imports its Rust crypto WASM when that is called (`client.js`: "importing
14
+ * rust-crypto will download the webassembly, so we delay it until we know
15
+ * it will be [needed]") -- so skipping it means the WASM module is never
16
+ * loaded, in the browser or under vitest. No shim or polyfill for it is
17
+ * needed either way.
18
+ *
19
+ * **Refresh, not a Matrix refresh token.** There is no such thing (section
20
+ * 4): a near-expiry timer and a `Session.logged_out` listener (fired by
21
+ * matrix-js-sdk's own HTTP layer on `M_UNKNOWN_TOKEN`, since no
22
+ * `refreshToken` is configured -- see `http-api/fetch.ts`) both call back
23
+ * into the exchange and swap the token in with `setAccessToken`. An
24
+ * unknown-token refresh also has to restart the client: matrix-js-sdk's
25
+ * sync loop treats `M_UNKNOWN_TOKEN` as "the logout already happened" and
26
+ * stops itself (`sync.ts`'s `shouldAbortSync`), and `startClient()` is a
27
+ * no-op while `clientRunning` is still true, so a plain retry would never
28
+ * resume syncing.
29
+ */
30
+ export declare function createChatClient(options: CreateChatClientOptions): ChatClient;