@decentnetwork/beagle-ui 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.
- package/README.md +57 -0
- package/dist/beagle-ui.js +5073 -0
- package/package.json +24 -0
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @decentnetwork/beagle-ui
|
|
2
|
+
|
|
3
|
+
The Beagle chat UI, minus the machine it runs on.
|
|
4
|
+
|
|
5
|
+
Two clients render these components: the desktop install
|
|
6
|
+
([`@decentnetwork/beagle`](https://www.npmjs.com/package/@decentnetwork/beagle),
|
|
7
|
+
whose local server holds the identity as a file on disk) and the browser build
|
|
8
|
+
(`beagle-web`, where the peer runs inside the tab). They were two copies of the
|
|
9
|
+
same files, kept in sync by hand, until the drift was measured — 306 lines
|
|
10
|
+
across three files, none of it two implementations of the same thing. This
|
|
11
|
+
package is that measurement made permanent.
|
|
12
|
+
|
|
13
|
+
## Using it
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { mount, setUiHost } from "@decentnetwork/beagle-ui";
|
|
17
|
+
|
|
18
|
+
setUiHost({
|
|
19
|
+
fileUrl: (name) => "/api/file-download?name=" + encodeURIComponent(name),
|
|
20
|
+
fileDownloadUrl: (name) => "/api/file-download?name=" + encodeURIComponent(name) + "&dl=1",
|
|
21
|
+
});
|
|
22
|
+
mount(document.getElementById("root"));
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`setUiHost` must run before `mount` — the flags it sets are read during the
|
|
26
|
+
first render.
|
|
27
|
+
|
|
28
|
+
React, ReactDOM, `window.PeerWebRTC` (calls) and `window.ChatComponents` (form
|
|
29
|
+
messages) are expected as `<script>` globals. This bundle references them; it
|
|
30
|
+
does not import them, so a page never ends up with two copies of React.
|
|
31
|
+
|
|
32
|
+
## The host
|
|
33
|
+
|
|
34
|
+
Everything the two platforms cannot agree on. A host that supplies nothing gets
|
|
35
|
+
the simple case: a local server that answers plain URLs.
|
|
36
|
+
|
|
37
|
+
| key | what it is for |
|
|
38
|
+
|---|---|
|
|
39
|
+
| `fileUrl(name)` | a stored file as a URL an `<img>` can use |
|
|
40
|
+
| `fileDownloadUrl(name)` | the same, for `<a download>` |
|
|
41
|
+
| `prefetchThreadFiles(msgs)` | resolve a thread's files before it renders |
|
|
42
|
+
| `DkWelcome` | first-run flow |
|
|
43
|
+
| `DkLockedOut` | another tab owns the identity |
|
|
44
|
+
| `DkBrowserNotice` | standing caveat about running in a browser |
|
|
45
|
+
| `hostNeedsWelcome` | run the first-run flow, and refuse a nameless friend request |
|
|
46
|
+
| `hostPrefersRtcFile` | send files over a DataChannel when the peer can take one |
|
|
47
|
+
| `hostHasKeyBackup` | offer to export the keypair |
|
|
48
|
+
|
|
49
|
+
In a browser, `<img src>` and `<a download>` issue **native** requests that
|
|
50
|
+
bypass a patched `fetch`, so a plain `/api/...` URL reaches nobody when the peer
|
|
51
|
+
lives in the tab — which is why `fileUrl` exists rather than being hardcoded.
|
|
52
|
+
|
|
53
|
+
## Versioning
|
|
54
|
+
|
|
55
|
+
Consumers should pin an exact version. The release cadence is manual, and a UI
|
|
56
|
+
change that reaches an already-published client through a caret range is a
|
|
57
|
+
change nobody chose to ship.
|