@pluv/react 0.12.3 → 0.13.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @pluv/react@0.12.3 build /home/runner/work/pluv/pluv/packages/react
2
+ > @pluv/react@0.13.0 build /home/runner/work/pluv/pluv/packages/react
3
3
  > tsup src/index.ts --format esm,cjs --dts --external react
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,11 +8,11 @@
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- CJS dist/index.js 12.46 KB
12
- CJS ⚡️ Build success in 96ms
13
- ESM dist/index.mjs 9.88 KB
14
- ESM ⚡️ Build success in 108ms
11
+ ESM dist/index.mjs 9.98 KB
12
+ ESM ⚡️ Build success in 144ms
13
+ CJS dist/index.js 12.57 KB
14
+ CJS ⚡️ Build success in 143ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 4516ms
17
- DTS dist/index.d.mts 4.74 KB
18
- DTS dist/index.d.ts 4.74 KB
16
+ DTS ⚡️ Build success in 4008ms
17
+ DTS dist/index.d.mts 4.77 KB
18
+ DTS dist/index.d.ts 4.77 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @pluv/react
2
2
 
3
+ ## 0.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 4c4b47f: Added `usePluvDoc` to access the root Yjs doc.
8
+
9
+ ```ts
10
+ import type { Doc } from "yjs";
11
+
12
+ const doc: Doc = usePluvDoc();
13
+ ```
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [1126215]
18
+ - @pluv/client@0.13.0
19
+ - @pluv/types@0.13.0
20
+
3
21
  ## 0.12.3
4
22
 
5
23
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -4,7 +4,7 @@ import * as _pluv_types from '@pluv/types';
4
4
  import { IOLike, JsonObject, InputZodLike, InferIOInput, Id, InferIOOutput, IOEventMessage } from '@pluv/types';
5
5
  export { BaseUser, EventMessage, EventRecord, IOEventMessage } from '@pluv/types';
6
6
  import { FC, Dispatch, ReactNode } from 'react';
7
- import { AbstractType } from 'yjs';
7
+ import { AbstractType, Doc } from 'yjs';
8
8
 
9
9
  type CreateRoomBundleOptions<TIO extends IOLike, TPresence extends JsonObject = {}, TStorage extends Record<string, AbstractType<any>> = {}> = {
10
10
  addons?: readonly PluvRoomAddon<TIO, TPresence, TStorage>[];
@@ -38,6 +38,7 @@ interface CreateRoomBundle<TIO extends IOLike, TPresence extends JsonObject, TSt
38
38
  usePluvCanRedo: () => boolean;
39
39
  usePluvCanUndo: () => boolean;
40
40
  usePluvConnection: <T extends unknown = WebSocketConnection>(selector: (connection: WebSocketConnection) => T, options?: SubscriptionHookOptions<Id<T>>) => Id<T>;
41
+ usePluvDoc: () => Doc;
41
42
  usePluvEvent: <TType extends keyof InferIOOutput<TIO>>(type: TType, callback: (data: Id<IOEventMessage<TIO, TType>>) => void) => void;
42
43
  usePluvMyPresence: <T extends unknown = TPresence>(selector?: (myPresence: TPresence) => T, options?: SubscriptionHookOptions<Id<T> | null>) => [
43
44
  myPresence: Id<T>,
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as _pluv_types from '@pluv/types';
4
4
  import { IOLike, JsonObject, InputZodLike, InferIOInput, Id, InferIOOutput, IOEventMessage } from '@pluv/types';
5
5
  export { BaseUser, EventMessage, EventRecord, IOEventMessage } from '@pluv/types';
6
6
  import { FC, Dispatch, ReactNode } from 'react';
7
- import { AbstractType } from 'yjs';
7
+ import { AbstractType, Doc } from 'yjs';
8
8
 
9
9
  type CreateRoomBundleOptions<TIO extends IOLike, TPresence extends JsonObject = {}, TStorage extends Record<string, AbstractType<any>> = {}> = {
10
10
  addons?: readonly PluvRoomAddon<TIO, TPresence, TStorage>[];
@@ -38,6 +38,7 @@ interface CreateRoomBundle<TIO extends IOLike, TPresence extends JsonObject, TSt
38
38
  usePluvCanRedo: () => boolean;
39
39
  usePluvCanUndo: () => boolean;
40
40
  usePluvConnection: <T extends unknown = WebSocketConnection>(selector: (connection: WebSocketConnection) => T, options?: SubscriptionHookOptions<Id<T>>) => Id<T>;
41
+ usePluvDoc: () => Doc;
41
42
  usePluvEvent: <TType extends keyof InferIOOutput<TIO>>(type: TType, callback: (data: Id<IOEventMessage<TIO, TType>>) => void) => void;
42
43
  usePluvMyPresence: <T extends unknown = TPresence>(selector?: (myPresence: TPresence) => T, options?: SubscriptionHookOptions<Id<T> | null>) => [
43
44
  myPresence: Id<T>,
package/dist/index.js CHANGED
@@ -195,6 +195,10 @@ var createRoomBundle = (client, options = {}) => {
195
195
  (_a = options2 == null ? void 0 : options2.isEqual) != null ? _a : import_fast_deep_equal.default
196
196
  );
197
197
  };
198
+ const usePluvDoc = () => {
199
+ const room = usePluvRoom();
200
+ return room.getDoc();
201
+ };
198
202
  const usePluvEvent = (type, callback) => {
199
203
  const room = usePluvRoom();
200
204
  (0, import_react2.useEffect)(() => {
@@ -350,6 +354,7 @@ var createRoomBundle = (client, options = {}) => {
350
354
  usePluvCanRedo,
351
355
  usePluvCanUndo,
352
356
  usePluvConnection,
357
+ usePluvDoc,
353
358
  usePluvEvent,
354
359
  usePluvMyPresence,
355
360
  usePluvMyself,
package/dist/index.mjs CHANGED
@@ -165,6 +165,10 @@ var createRoomBundle = (client, options = {}) => {
165
165
  (_a = options2 == null ? void 0 : options2.isEqual) != null ? _a : fastDeepEqual
166
166
  );
167
167
  };
168
+ const usePluvDoc = () => {
169
+ const room = usePluvRoom();
170
+ return room.getDoc();
171
+ };
168
172
  const usePluvEvent = (type, callback) => {
169
173
  const room = usePluvRoom();
170
174
  useEffect(() => {
@@ -320,6 +324,7 @@ var createRoomBundle = (client, options = {}) => {
320
324
  usePluvCanRedo,
321
325
  usePluvCanUndo,
322
326
  usePluvConnection,
327
+ usePluvDoc,
323
328
  usePluvEvent,
324
329
  usePluvMyPresence,
325
330
  usePluvMyself,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/react",
3
- "version": "0.12.3",
3
+ "version": "0.13.0",
4
4
  "description": "@pluv/client React.js bindings",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -21,8 +21,8 @@
21
21
  "@types/use-sync-external-store": "^0.0.6",
22
22
  "fast-deep-equal": "^3.1.3",
23
23
  "use-sync-external-store": "^1.2.0",
24
- "@pluv/client": "^0.12.3",
25
- "@pluv/types": "^0.12.3"
24
+ "@pluv/client": "^0.13.0",
25
+ "@pluv/types": "^0.13.0"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "react": "^17.0.0 || ^18.0.0",
@@ -34,8 +34,8 @@
34
34
  "tsup": "^8.0.1",
35
35
  "typescript": "^5.2.2",
36
36
  "yjs": "^13.6.10",
37
- "@pluv/tsconfig": "^0.12.3",
38
- "eslint-config-pluv": "^0.12.3"
37
+ "@pluv/tsconfig": "^0.13.0",
38
+ "eslint-config-pluv": "^0.13.0"
39
39
  },
40
40
  "scripts": {
41
41
  "build": "tsup src/index.ts --format esm,cjs --dts --external react",
@@ -30,7 +30,7 @@ import {
30
30
  useEffect,
31
31
  useState,
32
32
  } from "react";
33
- import type { AbstractType } from "yjs";
33
+ import type { AbstractType, Doc } from "yjs";
34
34
  import {
35
35
  identity,
36
36
  shallowArrayEqual,
@@ -104,6 +104,7 @@ export interface CreateRoomBundle<
104
104
  selector: (connection: WebSocketConnection) => T,
105
105
  options?: SubscriptionHookOptions<Id<T>>,
106
106
  ) => Id<T>;
107
+ usePluvDoc: () => Doc;
107
108
  usePluvEvent: <TType extends keyof InferIOOutput<TIO>>(
108
109
  type: TType,
109
110
  callback: (data: Id<IOEventMessage<TIO, TType>>) => void,
@@ -350,6 +351,12 @@ export const createRoomBundle = <
350
351
  );
351
352
  };
352
353
 
354
+ const usePluvDoc = () => {
355
+ const room = usePluvRoom();
356
+
357
+ return room.getDoc();
358
+ };
359
+
353
360
  const usePluvEvent = <TType extends keyof InferIOOutput<TIO>>(
354
361
  type: TType,
355
362
  callback: (data: Id<IOEventMessage<TIO, TType>>) => void,
@@ -574,6 +581,7 @@ export const createRoomBundle = <
574
581
  usePluvCanRedo,
575
582
  usePluvCanUndo,
576
583
  usePluvConnection,
584
+ usePluvDoc,
577
585
  usePluvEvent,
578
586
  usePluvMyPresence,
579
587
  usePluvMyself,