Skip to content

Commit f533298

Browse files
committed
0.0.16 - removes braid-text dependence
1 parent 428550c commit f533298

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# DOM Diffing and Synchronization over Braid-HTTP
22

3-
Efficiently diff and synchronization a DOM, either locally or over the network via [Braid-HTTP](https://datatracker.ietf.org/doc/html/draft-toomim-httpbis-braid-http). Sync multiple browser & server DOMs over the network, via Dom Diffs. Collaboratively edit live HTML. Create mashups of UIs, interoperating via Dom Diffs.
3+
Efficiently diff and synchronize a DOM, either locally or over the network via [Braid-HTTP](https://datatracker.ietf.org/doc/html/draft-toomim-httpbis-braid-http). Sync multiple browser & server DOMs over the network, via Dom Diffs. Collaboratively edit live HTML. Create mashups of UIs, interoperating via Dom Diffs.
44

55
- Supports [Braid-HTTP 04](https://github.com/braid-org/braid-spec/blob/master/draft-toomim-httpbis-braid-http-04.txt) protocol
66
- Uses Tree-sitter for robust, incremental HTML parsing
@@ -34,16 +34,16 @@ http_server.on("request", (req, res) => {
3434
})
3535
```
3636

37-
The first thing `serve_dom_diff` does is subscribe to an underlying textual resource using the suplied callback with the `subscribe` function. Then, it responds to the request with a braid subscription using the `simpleton` merge type for html, which consists of sending replacement html for a given `xpath`. Whenever changes are made to the underlying textual resource, `serve_dom_diff` will figure out the relevant changes to the DOM, and send these patches to all subscribed clients.
37+
`serve_dom_diff` first subscribes to an underlying textual resource using the provided callback. It then responds to the request with a Braid subscription using the `simpleton` merge type for HTML, which sends replacement HTML for a given `xpath`. When changes occur in the underlying textual resource, `serve_dom_diff` calculates the relevant DOM changes and sends these patches to all subscribed clients.
3838

3939
## Server API
4040

41-
`serve_dom_diff(req, res, options)`
41+
`serve_dom_diff(req, res, braid_text_cb, options)`
4242
- `req`: Incoming HTTP request object.
4343
- `res`: Outgoing HTTP response object.
44-
- `braid_text_cb`:
45-
- `options`: <small style="color:lightgrey">[optional]</small> An object containing additional options:
46-
- `key`: <small style="color:lightgrey">[optional]</small> ID of HTML resource to sync with. Defaults to `req.url`.
44+
- `braid_text_cb`: Function called by `serve_dom_diff` to subscribe to the underlying textual resource. It receives a callback function with parameters like `({ version, parents, body, patches })` to be called for each new Braid version.
45+
- `options`: (optional) An object containing additional options:
46+
- `key`: (optional) ID of HTML resource to sync with. Defaults to `req.url`.
4747
- This method handles Braid-HTTP requests for collaborative DOM editing.
4848

4949
## Client-side Usage
@@ -58,7 +58,7 @@ let dd = create_dom_diff(initialHtml)
5858
// Get current HTML
5959
let currentHtml = dd.get()
6060

61-
// Apply a patch
61+
// Apply a patch and get the diff
6262
let diff = dd.patch(newHtml)
6363

6464
// Apply DOM diff to actual DOM
@@ -67,14 +67,16 @@ apply_dom_diff(domElement, diff)
6767

6868
## Client API
6969

70-
`init_dom_diff()`
70+
`async init_dom_diff()`
7171
- Initializes the DOM diffing system, loading necessary dependencies.
7272

7373
`create_dom_diff(html)`
74-
- Creates a new DOM diff object for the given HTML.
74+
- Creates a new DOM diff object for the given `html`.
7575
- Returns an object with methods:
7676
- `get()`: Returns the current HTML.
77-
- `patch(newHtml)`: Applies a patch and returns the diff.
77+
- `patch(newHtml)`: Updates to the `newHtml` and returns the DOM diff to get there.
7878

7979
`apply_dom_diff(dom, diff)`
8080
- Applies a diff to the given DOM element.
81+
- `dom`: The target DOM element to update.
82+
- `diff`: The diff object generated by `patch()`.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
{
22
"name": "@braidjs/dom-diff",
3-
"version": "0.0.15",
3+
"version": "0.0.16",
44
"description": "utilities for diffing html doms",
55
"author": "Braid Working Group",
66
"repository": "braid-org/dom-diff",
77
"homepage": "https://braid.org",
88
"dependencies": {
99
"braid-http": "^0.3.20",
10-
"braid-text": "^0.0.15",
1110
"web-tree-sitter": "^0.22.6"
1211
}
1312
}

0 commit comments

Comments
 (0)