@hocuspocus/provider 4.0.0-rc.7 → 4.0.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 CHANGED
@@ -4,11 +4,68 @@
4
4
  [![License](https://img.shields.io/npm/l/@hocuspocus/provider.svg)](https://www.npmjs.com/package/@hocuspocus/provider)
5
5
  [![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/ueberdosis)
6
6
 
7
- ## Introduction
8
- The client-side provider for [Hocuspocus](https://github.com/ueberdosis/hocuspocus). It connects to a Hocuspocus server over WebSockets and syncs one or more [Y.js](https://github.com/yjs/yjs) documents, including awareness (presence), authentication, and stateless messaging.
7
+ The client-side provider for [Hocuspocus](https://github.com/ueberdosis/hocuspocus). Connects to a Hocuspocus server over WebSockets and syncs one or more [Y.js](https://github.com/yjs/yjs) documents — including awareness (presence), authentication, and stateless messaging.
9
8
 
10
- ## Official Documentation
11
- Documentation can be found in the [GitHub repository](https://github.com/ueberdosis/hocuspocus).
9
+ > **Building a React app?** Use [`@hocuspocus/provider-react`](../provider-react) instead — it wraps the provider in components and hooks so React handles the lifecycle for you (including StrictMode double-mounts).
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install @hocuspocus/provider yjs
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```js
20
+ import * as Y from "yjs"
21
+ import { HocuspocusProvider } from "@hocuspocus/provider"
22
+
23
+ const ydoc = new Y.Doc()
24
+
25
+ const provider = new HocuspocusProvider({
26
+ url: "ws://127.0.0.1:1234",
27
+ name: "example-document",
28
+ document: ydoc,
29
+ })
30
+ ```
31
+
32
+ Changes to `ydoc` are now synced to every other client connected to the same `name`.
33
+
34
+ ### Authenticating
35
+
36
+ Pass a `token` — it's forwarded to the server's `onAuthenticate` hook:
37
+
38
+ ```js
39
+ new HocuspocusProvider({
40
+ url: "wss://collab.example.com",
41
+ name: "example-document",
42
+ document: ydoc,
43
+ token: "super-secret-token",
44
+ })
45
+ ```
46
+
47
+ ### Sharing a socket across documents
48
+
49
+ Create a `HocuspocusProviderWebsocket` once, then reuse it for multiple documents:
50
+
51
+ ```js
52
+ import {
53
+ HocuspocusProvider,
54
+ HocuspocusProviderWebsocket,
55
+ } from "@hocuspocus/provider"
56
+
57
+ const socket = new HocuspocusProviderWebsocket({ url: "ws://127.0.0.1:1234" })
58
+
59
+ const doc1 = new HocuspocusProvider({ websocketProvider: socket, name: "doc-1" })
60
+ const doc2 = new HocuspocusProvider({ websocketProvider: socket, name: "doc-2" })
61
+ ```
62
+
63
+ Call `provider.destroy()` to disconnect a single document. Call `socket.destroy()` to tear down the shared connection.
64
+
65
+ ## Documentation
66
+
67
+ Full configuration, events, and awareness reference: [tiptap.dev/docs/hocuspocus/provider](https://tiptap.dev/docs/hocuspocus/provider/overview).
12
68
 
13
69
  ## License
14
- Hocuspocus is open-sourced software licensed under the [MIT license](https://github.com/ueberdosis/hocuspocus/blob/main/LICENSE.md).
70
+
71
+ MIT — see [LICENSE.md](https://github.com/ueberdosis/hocuspocus/blob/main/LICENSE.md).
@@ -538,7 +538,7 @@ var MessageSender = class {
538
538
 
539
539
  //#endregion
540
540
  //#region packages/provider/src/version.ts
541
- const version = "4.0.0-rc.7";
541
+ const version = "4.0.0";
542
542
 
543
543
  //#endregion
544
544
  //#region packages/provider/src/OutgoingMessages/AuthenticationMessage.ts
@@ -508,7 +508,7 @@ var MessageSender = class {
508
508
 
509
509
  //#endregion
510
510
  //#region packages/provider/src/version.ts
511
- const version = "4.0.0-rc.7";
511
+ const version = "4.0.0";
512
512
 
513
513
  //#endregion
514
514
  //#region packages/provider/src/OutgoingMessages/AuthenticationMessage.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hocuspocus/provider",
3
- "version": "4.0.0-rc.7",
3
+ "version": "4.0.0",
4
4
  "description": "hocuspocus provider",
5
5
  "homepage": "https://hocuspocus.dev",
6
6
  "keywords": [
@@ -29,7 +29,7 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@hocuspocus/common": "^4.0.0-rc.7",
32
+ "@hocuspocus/common": "^4.0.0",
33
33
  "@lifeomic/attempt": "^3.0.2",
34
34
  "lib0": "^0.2.87",
35
35
  "ws": "^8.17.1"
@@ -38,7 +38,7 @@
38
38
  "y-protocols": "^1.0.6",
39
39
  "yjs": "^13.6.8"
40
40
  },
41
- "gitHead": "d214278ee34bd1d776054cdc2a2227e3f05449d7",
41
+ "gitHead": "1c1b34800f702a06e1ce236e8a175c82876bff42",
42
42
  "repository": {
43
43
  "url": "https://github.com/ueberdosis/hocuspocus"
44
44
  },