@pluv/react 0.12.0 → 0.12.2

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,18 +1,18 @@
1
1
 
2
- > @pluv/react@0.12.0 build /home/runner/work/pluv/pluv/packages/react
2
+ > @pluv/react@0.12.2 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
6
6
  CLI Using tsconfig: tsconfig.json
7
- CLI tsup v7.2.0
7
+ CLI tsup v8.0.1
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- ESM dist/index.mjs 9.97 KB
12
- ESM ⚡️ Build success in 82ms
13
- CJS dist/index.js 12.55 KB
14
- CJS ⚡️ Build success in 94ms
11
+ CJS dist/index.js 12.46 KB
12
+ CJS ⚡️ Build success in 90ms
13
+ ESM dist/index.mjs 9.88 KB
14
+ ESM ⚡️ Build success in 112ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 7801ms
17
- DTS dist/index.d.mts 4.73 KB
18
- DTS dist/index.d.ts 4.73 KB
16
+ DTS ⚡️ Build success in 4361ms
17
+ DTS dist/index.d.mts 4.74 KB
18
+ DTS dist/index.d.ts 4.74 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @pluv/react
2
2
 
3
+ ## 0.12.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 259a7da: Bumped dependencies
8
+
9
+ ## 0.12.1
10
+
11
+ ### Patch Changes
12
+
13
+ - cae08aa: Updated storage from `getStorage` to never return null
14
+ - Updated dependencies [cae08aa]
15
+ - @pluv/client@0.12.1
16
+ - @pluv/types@0.12.1
17
+
3
18
  ## 0.12.0
4
19
 
5
20
  ### Minor Changes
@@ -217,12 +232,12 @@
217
232
  const transact = usePluvTransact();
218
233
 
219
234
  transact(() => {
220
- sharedType?.push(["hello world!"]);
235
+ sharedType.push(["hello world!"]);
221
236
  });
222
237
 
223
238
  // This will also be undoable because `"user-123"` is a tracked origin.
224
239
  transact(() => {
225
- sharedType?.push(["hello world!"]);
240
+ sharedType.push(["hello world!"]);
226
241
  }, "user-123");
227
242
 
228
243
  /**
package/dist/index.d.mts CHANGED
@@ -48,7 +48,7 @@ interface CreateRoomBundle<TIO extends IOLike, TPresence extends JsonObject, TSt
48
48
  usePluvOthers: <T extends unknown = UserInfo<TIO, TPresence>>(selector?: (other: readonly Id<UserInfo<TIO, TPresence>>[]) => T[], options?: SubscriptionHookOptions<readonly Id<T>[]>) => readonly Id<T>[];
49
49
  usePluvRedo: () => () => void;
50
50
  usePluvRoom: () => AbstractRoom<TIO, TPresence, TStorage>;
51
- usePluvStorage: <TKey extends keyof TStorage, TData extends unknown = InferYjsSharedTypeJson<TStorage[TKey]>>(key: TKey, selector?: (data: InferYjsSharedTypeJson<TStorage[TKey]>) => TData, options?: SubscriptionHookOptions<TData | null>) => [data: TData | null, sharedType: TStorage[TKey] | null];
51
+ usePluvStorage: <TKey extends keyof TStorage, TData extends unknown = InferYjsSharedTypeJson<TStorage[TKey]>>(key: TKey, selector?: (data: InferYjsSharedTypeJson<TStorage[TKey]>) => TData, options?: SubscriptionHookOptions<TData>) => [data: TData, sharedType: TStorage[TKey]];
52
52
  usePluvTransact: () => (fn: (storage: TStorage) => void, origin?: string) => void;
53
53
  usePluvUndo: () => () => void;
54
54
  }
@@ -63,4 +63,4 @@ interface CreateBundle<TIO extends IOLike> {
63
63
  }
64
64
  declare const createBundle: <TIO extends IOLike<_pluv_types.IOAuthorize<any, any>, {}, {}, {}, {}>>(client: PluvClient<TIO>) => CreateBundle<TIO>;
65
65
 
66
- export { CreateBundle, CreateRoomBundle, CreateRoomBundleOptions, PluvProviderProps, PluvRoomProviderProps, SubscriptionHookOptions, createBundle };
66
+ export { type CreateBundle, type CreateRoomBundle, type CreateRoomBundleOptions, type PluvProviderProps, type PluvRoomProviderProps, type SubscriptionHookOptions, createBundle };
package/dist/index.d.ts CHANGED
@@ -48,7 +48,7 @@ interface CreateRoomBundle<TIO extends IOLike, TPresence extends JsonObject, TSt
48
48
  usePluvOthers: <T extends unknown = UserInfo<TIO, TPresence>>(selector?: (other: readonly Id<UserInfo<TIO, TPresence>>[]) => T[], options?: SubscriptionHookOptions<readonly Id<T>[]>) => readonly Id<T>[];
49
49
  usePluvRedo: () => () => void;
50
50
  usePluvRoom: () => AbstractRoom<TIO, TPresence, TStorage>;
51
- usePluvStorage: <TKey extends keyof TStorage, TData extends unknown = InferYjsSharedTypeJson<TStorage[TKey]>>(key: TKey, selector?: (data: InferYjsSharedTypeJson<TStorage[TKey]>) => TData, options?: SubscriptionHookOptions<TData | null>) => [data: TData | null, sharedType: TStorage[TKey] | null];
51
+ usePluvStorage: <TKey extends keyof TStorage, TData extends unknown = InferYjsSharedTypeJson<TStorage[TKey]>>(key: TKey, selector?: (data: InferYjsSharedTypeJson<TStorage[TKey]>) => TData, options?: SubscriptionHookOptions<TData>) => [data: TData, sharedType: TStorage[TKey]];
52
52
  usePluvTransact: () => (fn: (storage: TStorage) => void, origin?: string) => void;
53
53
  usePluvUndo: () => () => void;
54
54
  }
@@ -63,4 +63,4 @@ interface CreateBundle<TIO extends IOLike> {
63
63
  }
64
64
  declare const createBundle: <TIO extends IOLike<_pluv_types.IOAuthorize<any, any>, {}, {}, {}, {}>>(client: PluvClient<TIO>) => CreateBundle<TIO>;
65
65
 
66
- export { CreateBundle, CreateRoomBundle, CreateRoomBundleOptions, PluvProviderProps, PluvRoomProviderProps, SubscriptionHookOptions, createBundle };
66
+ export { type CreateBundle, type CreateRoomBundle, type CreateRoomBundleOptions, type PluvProviderProps, type PluvRoomProviderProps, type SubscriptionHookOptions, createBundle };
package/dist/index.js CHANGED
@@ -315,12 +315,11 @@ var createRoomBundle = (client, options = {}) => {
315
315
  [key, room]
316
316
  );
317
317
  const getSnapshot = (0, import_react2.useCallback)(() => {
318
- var _a2, _b;
319
- return (_b = (_a2 = room.getStorage(key)) == null ? void 0 : _a2.toJSON()) != null ? _b : null;
318
+ return room.getStorage(key).toJSON();
320
319
  }, [key, room]);
321
320
  const _selector = (0, import_react2.useCallback)(
322
321
  (snapshot) => {
323
- return !snapshot ? null : selector(snapshot);
322
+ return selector(snapshot);
324
323
  },
325
324
  [selector]
326
325
  );
package/dist/index.mjs CHANGED
@@ -285,12 +285,11 @@ var createRoomBundle = (client, options = {}) => {
285
285
  [key, room]
286
286
  );
287
287
  const getSnapshot = useCallback2(() => {
288
- var _a2, _b;
289
- return (_b = (_a2 = room.getStorage(key)) == null ? void 0 : _a2.toJSON()) != null ? _b : null;
288
+ return room.getStorage(key).toJSON();
290
289
  }, [key, room]);
291
290
  const _selector = useCallback2(
292
291
  (snapshot) => {
293
- return !snapshot ? null : selector(snapshot);
292
+ return selector(snapshot);
294
293
  },
295
294
  [selector]
296
295
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/react",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "description": "@pluv/client React.js bindings",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -17,25 +17,25 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@types/react": "18.2.22",
21
- "@types/use-sync-external-store": "^0.0.4",
20
+ "@types/react": "^18.2.38",
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.0",
25
- "@pluv/types": "^0.12.0"
24
+ "@pluv/client": "^0.12.2",
25
+ "@pluv/types": "^0.12.2"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "react": "^17.0.0 || ^18.0.0",
29
29
  "yjs": "^13.0.0"
30
30
  },
31
31
  "devDependencies": {
32
- "eslint": "^8.50.0",
33
- "react": "18.2.0",
34
- "tsup": "^7.2.0",
32
+ "eslint": "^8.54.0",
33
+ "react": "^18.2.0",
34
+ "tsup": "^8.0.1",
35
35
  "typescript": "^5.2.2",
36
- "yjs": "^13.6.8",
37
- "@pluv/tsconfig": "^0.12.0",
38
- "eslint-config-pluv": "^0.12.0"
36
+ "yjs": "^13.6.10",
37
+ "@pluv/tsconfig": "^0.12.2",
38
+ "eslint-config-pluv": "^0.12.2"
39
39
  },
40
40
  "scripts": {
41
41
  "build": "tsup src/index.ts --format esm,cjs --dts --external react",
@@ -136,8 +136,8 @@ export interface CreateRoomBundle<
136
136
  >(
137
137
  key: TKey,
138
138
  selector?: (data: InferYjsSharedTypeJson<TStorage[TKey]>) => TData,
139
- options?: SubscriptionHookOptions<TData | null>,
140
- ) => [data: TData | null, sharedType: TStorage[TKey] | null];
139
+ options?: SubscriptionHookOptions<TData>,
140
+ ) => [data: TData, sharedType: TStorage[TKey]];
141
141
  usePluvTransact: () => (
142
142
  fn: (storage: TStorage) => void,
143
143
  origin?: string,
@@ -517,8 +517,8 @@ export const createRoomBundle = <
517
517
  selector = identity as (
518
518
  data: InferYjsSharedTypeJson<TStorage[TKey]>,
519
519
  ) => TData,
520
- options?: SubscriptionHookOptions<TData | null>,
521
- ): [data: TData | null, sharedType: TStorage[TKey] | null] => {
520
+ options?: SubscriptionHookOptions<TData>,
521
+ ): [data: TData, sharedType: TStorage[TKey]] => {
522
522
  const room = usePluvRoom();
523
523
 
524
524
  const subscribe = useCallback(
@@ -528,13 +528,13 @@ export const createRoomBundle = <
528
528
 
529
529
  const getSnapshot = useCallback((): InferYjsSharedTypeJson<
530
530
  TStorage[TKey]
531
- > | null => {
532
- return room.getStorage(key)?.toJSON() ?? null;
531
+ > => {
532
+ return room.getStorage(key).toJSON();
533
533
  }, [key, room]);
534
534
 
535
535
  const _selector = useCallback(
536
- (snapshot: InferYjsSharedTypeJson<TStorage[TKey]> | null) => {
537
- return !snapshot ? null : selector(snapshot);
536
+ (snapshot: InferYjsSharedTypeJson<TStorage[TKey]>) => {
537
+ return selector(snapshot);
538
538
  },
539
539
  [selector],
540
540
  );