mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-22 19:14:52 +01:00
rename morpheus to brawl
This commit is contained in:
parent
83613f49c9
commit
db376d3ac6
@ -1,11 +1,11 @@
|
|||||||
# morpheusjs
|
# Brawl
|
||||||
A javascript matrix client prototype, trying to minize RAM usage by offloading as much as possible to IndexedDB
|
A javascript matrix client prototype, trying to minize RAM usage by offloading as much as possible to IndexedDB
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
|
|
||||||
Syncing & storing rooms with state and timeline, with a minimal UI syncing room list and timeline on screen. Filling gaps supported, detecting overlapping events. The `[0/1]` in the gif below is the local event key, consisting of a fragment id and event index. No sending yet. Using Fractal here to update the room name and send messages:
|
Syncing & storing rooms with state and timeline, with a minimal UI syncing room list and timeline on screen. Filling gaps supported, detecting overlapping events. The `[0/1]` in the gif below is the local event key, consisting of a fragment id and event index. No sending yet. Using Fractal here to update the room name and send messages:
|
||||||
|
|
||||||
![Rooms and timeline syncing on-screen, gaps filling](https://bwindels.github.io/morpheusjs/images/morpheus-gaps.gif)
|
![Rooms and timeline syncing on-screen, gaps filling](https://bwindels.github.io/brawl-chat/images/morpheus-gaps.gif)
|
||||||
|
|
||||||
## Features that this approach would be well suited for
|
## Features that this approach would be well suited for
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ For this reason a `Room` processes a sync response in two phases: `persistSync`
|
|||||||
|
|
||||||
## Timeline, fragments & event indices.
|
## Timeline, fragments & event indices.
|
||||||
|
|
||||||
A room in matrix is a DAG (directed, acyclic graph) of events, also known as the timeline. Morpheus is only aware of fragments of this graph, and can be unaware how these fragments relate to each other until a common event is found while paginating a fragment. After doing an initial sync, you start with one fragment. When looking up an event with the `/context` endpoint (for fetching a replied to message, or navigating to a given event id, e.g. through a permalink), a new, unconnected, fragment is created. Also, when receiving a limited sync response during incremental sync, a new fragment is created. Here, the relationship is clear, so they are immediately linked up at creation. Events in morpheus are identified within a room by `[fragment_id, event_index]`. The `event_index` is an unique number within a fragment to sort events in chronological order in the timeline. `fragment_id` cannot be directly compared for sorting (as the relationship may be unknown), but with help of the `FragmentIndex`, one can attempt to sort events by their `FragmentIndex([fragment_id, event_index])`.
|
A room in matrix is a DAG (directed, acyclic graph) of events, also known as the timeline. brawl is only aware of fragments of this graph, and can be unaware how these fragments relate to each other until a common event is found while paginating a fragment. After doing an initial sync, you start with one fragment. When looking up an event with the `/context` endpoint (for fetching a replied to message, or navigating to a given event id, e.g. through a permalink), a new, unconnected, fragment is created. Also, when receiving a limited sync response during incremental sync, a new fragment is created. Here, the relationship is clear, so they are immediately linked up at creation. Events in brawl are identified within a room by `[fragment_id, event_index]`. The `event_index` is an unique number within a fragment to sort events in chronological order in the timeline. `fragment_id` cannot be directly compared for sorting (as the relationship may be unknown), but with help of the `FragmentIndex`, one can attempt to sort events by their `FragmentIndex([fragment_id, event_index])`.
|
||||||
|
|
||||||
A fragment is the following data structure:
|
A fragment is the following data structure:
|
||||||
```
|
```
|
||||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "morpheusjs",
|
"name": "brawl-chat",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "morpheusjs",
|
"name": "brawl-chat",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "A javascript matrix client prototype, trying to minize RAM usage by offloading as much as possible to IndexedDB",
|
"description": "A javascript matrix client prototype, trying to minize RAM usage by offloading as much as possible to IndexedDB",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
@ -12,14 +12,14 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/bwindels/morpheusjs.git"
|
"url": "git+https://github.com/bwindels/brawl-chat.git"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/bwindels/morpheusjs/issues"
|
"url": "https://github.com/bwindels/brawl-chat/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/bwindels/morpheusjs#readme",
|
"homepage": "https://github.com/bwindels/brawl-chat#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"finalhandler": "^1.1.1",
|
"finalhandler": "^1.1.1",
|
||||||
"impunity": "^0.0.7",
|
"impunity": "^0.0.7",
|
||||||
|
@ -12,7 +12,7 @@ const USER_ID = `@${USERNAME}:${HOST}`;
|
|||||||
const PASSWORD = "testtest";
|
const PASSWORD = "testtest";
|
||||||
|
|
||||||
function getSessionInfo(userId) {
|
function getSessionInfo(userId) {
|
||||||
const sessionsJson = localStorage.getItem("morpheus_sessions_v1");
|
const sessionsJson = localStorage.getItem("brawl_sessions_v1");
|
||||||
if (sessionsJson) {
|
if (sessionsJson) {
|
||||||
const sessions = JSON.parse(sessionsJson);
|
const sessions = JSON.parse(sessionsJson);
|
||||||
const session = sessions.find(session => session.userId === userId);
|
const session = sessions.find(session => session.userId === userId);
|
||||||
@ -23,7 +23,7 @@ function getSessionInfo(userId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function storeSessionInfo(loginData) {
|
function storeSessionInfo(loginData) {
|
||||||
const sessionsJson = localStorage.getItem("morpheus_sessions_v1");
|
const sessionsJson = localStorage.getItem("brawl_sessions_v1");
|
||||||
const sessions = sessionsJson ? JSON.parse(sessionsJson) : [];
|
const sessions = sessionsJson ? JSON.parse(sessionsJson) : [];
|
||||||
const sessionId = (Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)).toString();
|
const sessionId = (Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)).toString();
|
||||||
const sessionInfo = {
|
const sessionInfo = {
|
||||||
@ -34,7 +34,7 @@ function storeSessionInfo(loginData) {
|
|||||||
accessToken: loginData.access_token,
|
accessToken: loginData.access_token,
|
||||||
};
|
};
|
||||||
sessions.push(sessionInfo);
|
sessions.push(sessionInfo);
|
||||||
localStorage.setItem("morpheus_sessions_v1", JSON.stringify(sessions));
|
localStorage.setItem("brawl_sessions_v1", JSON.stringify(sessions));
|
||||||
return sessionInfo;
|
return sessionInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ export default async function main(label, button, container) {
|
|||||||
if (!sessionInfo) {
|
if (!sessionInfo) {
|
||||||
sessionInfo = await login(USERNAME, PASSWORD, HOMESERVER);
|
sessionInfo = await login(USERNAME, PASSWORD, HOMESERVER);
|
||||||
}
|
}
|
||||||
const storage = await createIdbStorage(`morpheus_session_${sessionInfo.id}`);
|
const storage = await createIdbStorage(`brawl_session_${sessionInfo.id}`);
|
||||||
const hsApi = new HomeServerApi(HOMESERVER, sessionInfo.accessToken);
|
const hsApi = new HomeServerApi(HOMESERVER, sessionInfo.accessToken);
|
||||||
const session = new Session({storage, hsApi, sessionInfo: {
|
const session = new Session({storage, hsApi, sessionInfo: {
|
||||||
deviceId: sessionInfo.deviceId,
|
deviceId: sessionInfo.deviceId,
|
||||||
|
Loading…
Reference in New Issue
Block a user