@liveblocks/react 1.0.2-test5 → 1.0.6-test1

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.
Files changed (3) hide show
  1. package/README.md +3 -2
  2. package/dist/index.js +25 -21
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -32,8 +32,9 @@ npm install @liveblocks/client @liveblocks/react
32
32
 
33
33
  ## Documentation
34
34
 
35
- Read the [documentation](https://liveblocks.io/docs) for guides and API
36
- references.
35
+ Read the
36
+ [documentation](https://liveblocks.io/docs/api-reference/liveblocks-react) for
37
+ guides and API references.
37
38
 
38
39
  ## Examples
39
40
 
package/dist/index.js CHANGED
@@ -5,9 +5,7 @@ function ClientSideSuspense(props) {
5
5
  React.useEffect(() => {
6
6
  setMounted(true);
7
7
  }, []);
8
- return /* @__PURE__ */ React.createElement(React.Suspense, {
9
- fallback: props.fallback
10
- }, mounted ? props.children() : props.fallback);
8
+ return /* @__PURE__ */ React.createElement(React.Suspense, { fallback: props.fallback }, mounted ? props.children() : props.fallback);
11
9
  }
12
10
 
13
11
  // src/factory.tsx
@@ -24,6 +22,9 @@ var _withselector = require('use-sync-external-store/shim/with-selector');
24
22
 
25
23
  function useRerender() {
26
24
  const [, update] = _react.useReducer.call(void 0,
25
+ // This implementation works by incrementing a hidden counter value that is
26
+ // never consumed. Simply incrementing the counter changes the component's
27
+ // state and, thus, trigger a re-render.
27
28
  (x) => x + 1,
28
29
  0
29
30
  );
@@ -52,7 +53,10 @@ var superfluous_unstable_batchedUpdates = "You don\u2019t need to pass unstable_
52
53
  function useSyncExternalStore(s, gs, gss) {
53
54
  return _withselector.useSyncExternalStoreWithSelector.call(void 0, s, gs, gss, identity);
54
55
  }
55
- var EMPTY_OTHERS = _core.asArrayWithLegacyMethods.call(void 0, []);
56
+ var EMPTY_OTHERS = (
57
+ // NOTE: asArrayWithLegacyMethods() wrapping should no longer be necessary in 0.19
58
+ _core.asArrayWithLegacyMethods.call(void 0, [])
59
+ );
56
60
  function getEmptyOthers() {
57
61
  return EMPTY_OTHERS;
58
62
  }
@@ -123,30 +127,24 @@ function createRoomContext(client) {
123
127
  () => client.enter(roomId, {
124
128
  initialPresence: frozen.initialPresence,
125
129
  initialStorage: frozen.initialStorage,
126
- unstable_batchedUpdates: frozen.unstable_batchedUpdates,
127
- shouldInitiallyConnect: frozen.shouldInitiallyConnect
130
+ shouldInitiallyConnect: frozen.shouldInitiallyConnect,
131
+ unstable_batchedUpdates: frozen.unstable_batchedUpdates
128
132
  })
129
133
  );
130
- const isFirstRender = React2.useRef(true);
131
134
  React2.useEffect(() => {
132
- if (!isFirstRender.current) {
133
- setRoom(
134
- client.enter(roomId, {
135
- initialPresence: frozen.initialPresence,
136
- initialStorage: frozen.initialStorage,
137
- unstable_batchedUpdates: frozen.unstable_batchedUpdates,
138
- withoutConnecting: frozen.shouldInitiallyConnect
139
- })
140
- );
141
- }
142
- isFirstRender.current = false;
135
+ setRoom(
136
+ client.enter(roomId, {
137
+ initialPresence: frozen.initialPresence,
138
+ initialStorage: frozen.initialStorage,
139
+ shouldInitiallyConnect: frozen.shouldInitiallyConnect,
140
+ unstable_batchedUpdates: frozen.unstable_batchedUpdates
141
+ })
142
+ );
143
143
  return () => {
144
144
  client.leave(roomId);
145
145
  };
146
146
  }, [roomId, frozen]);
147
- return /* @__PURE__ */ React2.createElement(RoomContext.Provider, {
148
- value: room
149
- }, props.children);
147
+ return /* @__PURE__ */ React2.createElement(RoomContext.Provider, { value: room }, props.children);
150
148
  }
151
149
  function connectionIdSelector(others) {
152
150
  return others.map((user) => user.connectionId);
@@ -344,6 +342,7 @@ function createRoomContext(client) {
344
342
  liveValue = newCrdt;
345
343
  unsubscribeCrdt = room.subscribe(
346
344
  liveValue,
345
+ // TODO: This is hiding a bug! If `liveValue` happens to be the string `"event"` this actually subscribes an event handler!
347
346
  rerender
348
347
  );
349
348
  rerender();
@@ -351,10 +350,12 @@ function createRoomContext(client) {
351
350
  }
352
351
  let unsubscribeCrdt = room.subscribe(
353
352
  liveValue,
353
+ // TODO: This is hiding a bug! If `liveValue` happens to be the string `"event"` this actually subscribes an event handler!
354
354
  rerender
355
355
  );
356
356
  const unsubscribeRoot = room.subscribe(
357
357
  root,
358
+ // TODO: This is hiding a bug! If `liveValue` happens to be the string `"event"` this actually subscribes an event handler!
358
359
  onRootChange
359
360
  );
360
361
  rerender();
@@ -433,6 +434,7 @@ function createRoomContext(client) {
433
434
  () => callback(makeMutationContext(room), ...args)
434
435
  );
435
436
  },
437
+ // eslint-disable-next-line react-hooks/exhaustive-deps
436
438
  [room, ...deps]
437
439
  );
438
440
  }
@@ -486,6 +488,7 @@ function createRoomContext(client) {
486
488
  useRedo,
487
489
  useCanRedo,
488
490
  useCanUndo,
491
+ // These are just aliases. The passed-in key will define their return values.
489
492
  useList: useLegacyKey,
490
493
  useMap: useLegacyKey,
491
494
  useObject: useLegacyKey,
@@ -512,6 +515,7 @@ function createRoomContext(client) {
512
515
  useRedo,
513
516
  useCanRedo,
514
517
  useCanUndo,
518
+ // Legacy hooks
515
519
  useList: useLegacyKeySuspense,
516
520
  useMap: useLegacyKeySuspense,
517
521
  useObject: useLegacyKeySuspense,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveblocks/react",
3
- "version": "1.0.2-test5",
3
+ "version": "1.0.6-test1",
4
4
  "description": "A set of React hooks and providers to use Liveblocks declaratively. Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -20,8 +20,8 @@
20
20
  "test:watch": "jest --silent --verbose --color=always --watch"
21
21
  },
22
22
  "dependencies": {
23
- "@liveblocks/client": "1.0.2-test5",
24
- "@liveblocks/core": "1.0.2-test5",
23
+ "@liveblocks/client": "1.0.6-test1",
24
+ "@liveblocks/core": "1.0.6-test1",
25
25
  "use-sync-external-store": "^1.2.0"
26
26
  },
27
27
  "peerDependencies": {