@liveblocks/redux 0.16.4-beta2 → 0.16.4

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/index.js +31 -34
  2. package/index.mjs +1 -2
  3. package/package.json +2 -2
package/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var client = require('@liveblocks/client');
5
+ var internal = require('@liveblocks/client/internal');
6
6
 
7
7
  function _extends() {
8
8
  _extends = Object.assign || function (target) {
@@ -77,9 +77,6 @@ function mappingToFunctionIsNotAllowed(key) {
77
77
  return new Error(ERROR_PREFIX + " mapping." + key + " is invalid. Mapping to a function is not allowed.");
78
78
  }
79
79
 
80
- var patchImmutableObject = client.internals.patchImmutableObject,
81
- patchLiveObjectKey = client.internals.patchLiveObjectKey,
82
- lsonToJson = client.internals.lsonToJson;
83
80
  var ACTION_TYPES = {
84
81
  ENTER: "@@LIVEBLOCKS/ENTER",
85
82
  LEAVE: "@@LIVEBLOCKS/LEAVE",
@@ -217,14 +214,14 @@ var internalEnhancer = function internalEnhancer(options) {
217
214
  var root = _ref.root;
218
215
  var updates = {};
219
216
  room.batch(function () {
220
- for (var _key in mapping) {
221
- var liveblocksStatePart = root.get(_key);
217
+ for (var key in mapping) {
218
+ var liveblocksStatePart = root.get(key);
222
219
 
223
220
  if (liveblocksStatePart == null) {
224
- updates[_key] = storageInitialState[_key];
225
- patchLiveObjectKey(root, _key, undefined, storageInitialState[_key]);
221
+ updates[key] = storageInitialState[key];
222
+ internal.patchLiveObjectKey(root, key, undefined, storageInitialState[key]);
226
223
  } else {
227
- updates[_key] = lsonToJson(liveblocksStatePart);
224
+ updates[key] = internal.lsonToJson(liveblocksStatePart);
228
225
  }
229
226
  }
230
227
  });
@@ -299,35 +296,35 @@ function leaveRoom(roomId) {
299
296
  var enhancer = internalEnhancer;
300
297
 
301
298
  function patchLiveblocksStorage(root, oldState, newState, mapping) {
302
- for (var _key2 in mapping) {
303
- if (process.env.NODE_ENV !== "production" && typeof newState[_key2] === "function") {
299
+ for (var key in mapping) {
300
+ if (process.env.NODE_ENV !== "production" && typeof newState[key] === "function") {
304
301
  throw mappingToFunctionIsNotAllowed("value");
305
302
  }
306
303
 
307
- if (oldState[_key2] !== newState[_key2]) {
308
- patchLiveObjectKey(root, _key2, oldState[_key2], newState[_key2]);
304
+ if (oldState[key] !== newState[key]) {
305
+ internal.patchLiveObjectKey(root, key, oldState[key], newState[key]);
309
306
  }
310
307
  }
311
308
  }
312
309
 
313
310
  function broadcastInitialPresence(room, state, mapping) {
314
- for (var _key3 in mapping) {
311
+ for (var key in mapping) {
315
312
  var _room$updatePresence;
316
313
 
317
- room == null ? void 0 : room.updatePresence((_room$updatePresence = {}, _room$updatePresence[_key3] = state[_key3], _room$updatePresence));
314
+ room == null ? void 0 : room.updatePresence((_room$updatePresence = {}, _room$updatePresence[key] = state[key], _room$updatePresence));
318
315
  }
319
316
  }
320
317
 
321
318
  function updatePresence(room, oldState, newState, presenceMapping) {
322
- for (var _key4 in presenceMapping) {
323
- if (typeof newState[_key4] === "function") {
319
+ for (var key in presenceMapping) {
320
+ if (typeof newState[key] === "function") {
324
321
  throw mappingToFunctionIsNotAllowed("value");
325
322
  }
326
323
 
327
- if (oldState[_key4] !== newState[_key4]) {
324
+ if (oldState[key] !== newState[key]) {
328
325
  var _room$updatePresence2;
329
326
 
330
- room.updatePresence((_room$updatePresence2 = {}, _room$updatePresence2[_key4] = newState[_key4], _room$updatePresence2));
327
+ room.updatePresence((_room$updatePresence2 = {}, _room$updatePresence2[key] = newState[key], _room$updatePresence2));
331
328
  }
332
329
  }
333
330
  }
@@ -337,9 +334,9 @@ function isObject(value) {
337
334
  }
338
335
 
339
336
  function validateNoDuplicateKeys(storageMapping, presenceMapping) {
340
- for (var _key5 in storageMapping) {
341
- if (presenceMapping[_key5] !== undefined) {
342
- throw mappingShouldNotHaveTheSameKeys(_key5);
337
+ for (var key in storageMapping) {
338
+ if (presenceMapping[key] !== undefined) {
339
+ throw mappingShouldNotHaveTheSameKeys(key);
343
340
  }
344
341
  }
345
342
  }
@@ -347,8 +344,8 @@ function validateNoDuplicateKeys(storageMapping, presenceMapping) {
347
344
  function patchPresenceState(presence, mapping) {
348
345
  var partialState = {};
349
346
 
350
- for (var _key6 in mapping) {
351
- partialState[_key6] = presence[_key6];
347
+ for (var key in mapping) {
348
+ partialState[key] = presence[key];
352
349
  }
353
350
 
354
351
  return partialState;
@@ -357,15 +354,15 @@ function patchPresenceState(presence, mapping) {
357
354
  function patchState(state, updates, mapping) {
358
355
  var partialState = {};
359
356
 
360
- for (var _key7 in mapping) {
361
- partialState[_key7] = state[_key7];
357
+ for (var key in mapping) {
358
+ partialState[key] = state[key];
362
359
  }
363
360
 
364
- var patched = patchImmutableObject(partialState, updates);
361
+ var patched = internal.patchImmutableObject(partialState, updates);
365
362
  var result = {};
366
363
 
367
- for (var _key8 in mapping) {
368
- result[_key8] = patched[_key8];
364
+ for (var _key in mapping) {
365
+ result[_key] = patched[_key];
369
366
  }
370
367
 
371
368
  return result;
@@ -380,13 +377,13 @@ function validateMapping(mapping, mappingType) {
380
377
 
381
378
  var result = {};
382
379
 
383
- for (var _key9 in mapping) {
384
- if (process.env.NODE_ENV !== "production" && typeof mapping[_key9] !== "boolean") {
385
- throw mappingValueShouldBeABoolean(mappingType, _key9);
380
+ for (var key in mapping) {
381
+ if (process.env.NODE_ENV !== "production" && typeof mapping[key] !== "boolean") {
382
+ throw mappingValueShouldBeABoolean(mappingType, key);
386
383
  }
387
384
 
388
- if (mapping[_key9] === true) {
389
- result[_key9] = true;
385
+ if (mapping[key] === true) {
386
+ result[key] = true;
390
387
  }
391
388
  }
392
389
 
package/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { internals } from '@liveblocks/client';
1
+ import { patchLiveObjectKey, lsonToJson, patchImmutableObject } from '@liveblocks/client/internal';
2
2
 
3
3
  const ERROR_PREFIX = "Invalid @liveblocks/redux middleware config.";
4
4
  function missingClient() {
@@ -17,7 +17,6 @@ function mappingToFunctionIsNotAllowed(key) {
17
17
  return new Error(`${ERROR_PREFIX} mapping.${key} is invalid. Mapping to a function is not allowed.`);
18
18
  }
19
19
 
20
- const { patchImmutableObject, patchLiveObjectKey, lsonToJson } = internals;
21
20
  const ACTION_TYPES = {
22
21
  ENTER: "@@LIVEBLOCKS/ENTER",
23
22
  LEAVE: "@@LIVEBLOCKS/LEAVE",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveblocks/redux",
3
- "version": "0.16.4-beta2",
3
+ "version": "0.16.4",
4
4
  "description": "A store enhancer to integrate Liveblocks into Redux stores.",
5
5
  "main": "./index.js",
6
6
  "module": "./index.mjs",
@@ -30,7 +30,7 @@
30
30
  "directory": "packages/liveblocks-redux"
31
31
  },
32
32
  "peerDependencies": {
33
- "@liveblocks/client": "0.16.4-beta2",
33
+ "@liveblocks/client": "0.16.4",
34
34
  "redux": "^4"
35
35
  },
36
36
  "devDependencies": {