@liveblocks/client 0.16.12 → 0.16.13

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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { C as ClientOptions, a as Client } from './shared';
2
- export { B as BroadcastOptions, a as Client, H as History, J as Json, d as JsonObject, c as LiveList, b as LiveMap, L as LiveObject, e as Lson, f as LsonObject, O as Others, P as Presence, R as Room, S as StorageUpdate, U as User } from './shared';
2
+ export { B as BroadcastOptions, a as Client, H as History, J as Json, d as JsonObject, L as LiveList, b as LiveMap, c as LiveObject, e as LiveStructure, f as Lson, g as LsonObject, O as Others, P as Presence, R as Room, S as StorageUpdate, U as User } from './shared';
3
3
 
4
4
  /**
5
5
  * Create a client that will be responsible to communicate with liveblocks servers.
package/index.js CHANGED
@@ -6,10 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
 
7
7
  var LiveObject = require("./shared.js"), _excluded = [ "_hasReceivedInitialPresence" ], BACKOFF_RETRY_DELAYS = [ 250, 500, 1e3, 2e3, 4e3, 8e3, 1e4 ], BACKOFF_RETRY_DELAYS_SLOW = [ 2e3, 3e4, 6e4, 3e5 ];
8
8
 
9
- function isValidRoomEventType(value) {
10
- return "my-presence" === value || "others" === value || "event" === value || "error" === value || "connection" === value;
11
- }
12
-
13
9
  function makeOthers(userMap) {
14
10
  var _ref, users = Object.values(userMap).map((function(user) {
15
11
  return user._hasReceivedInitialPresence, LiveObject._objectWithoutPropertiesLoose(user, _excluded);
@@ -97,8 +93,8 @@ function makeStateMachine(state, context, mockedEffects) {
97
93
  roomId: context.roomId
98
94
  })), state.defaultStorageRoot) null == state.root.get(_key) && state.root.set(_key, state.defaultStorageRoot[_key]);
99
95
  }
100
- function addItem(id, item) {
101
- state.items.set(id, item);
96
+ function addItem(id, liveItem) {
97
+ state.items.set(id, liveItem);
102
98
  }
103
99
  function deleteItem(id) {
104
100
  state.items.delete(id);
@@ -164,40 +160,34 @@ function makeStateMachine(state, context, mockedEffects) {
164
160
  if (state.me = LiveObject._extends({}, state.me, op.data), null == state.buffer.presence) state.buffer.presence = op.data; else for (var _key3 in op.data) state.buffer.presence[_key3] = op.data[_key3];
165
161
  result.reverse.unshift(reverse), result.updates.presence = !0;
166
162
  } else {
167
- isLocal && !op.opId && (op.opId = generateOpId());
168
- var applyOpResult = applyOp(op, isLocal);
163
+ var source = void 0;
164
+ if (op.opId || (op.opId = generateOpId()), isLocal) source = LiveObject.OpSource.UNDOREDO_RECONNECT; else source = state.offlineOperations.delete(LiveObject.nn(op.opId)) ? LiveObject.OpSource.ACK : LiveObject.OpSource.REMOTE;
165
+ var applyOpResult = applyOp(op, source);
169
166
  if (applyOpResult.modified) {
170
- var _applyOpResult$modifi, _result$reverse, parentId = null == (_applyOpResult$modifi = applyOpResult.modified.node._parent) ? void 0 : _applyOpResult$modifi._id;
171
- if (!createdNodeIds.has(parentId)) result.updates.storageUpdates.set(applyOpResult.modified.node._id, LiveObject.mergeStorageUpdates(result.updates.storageUpdates.get(applyOpResult.modified.node._id), applyOpResult.modified)),
167
+ var _result$reverse, parentId = "HasParent" === applyOpResult.modified.node.parent.type ? LiveObject.nn(applyOpResult.modified.node.parent.node._id, "Expected parent node to have an ID") : void 0;
168
+ if (!parentId || !createdNodeIds.has(parentId)) result.updates.storageUpdates.set(LiveObject.nn(applyOpResult.modified.node._id), LiveObject.mergeStorageUpdates(result.updates.storageUpdates.get(LiveObject.nn(applyOpResult.modified.node._id)), applyOpResult.modified)),
172
169
  (_result$reverse = result.reverse).unshift.apply(_result$reverse, applyOpResult.reverse);
173
- op.type !== LiveObject.OpCode.CREATE_LIST && op.type !== LiveObject.OpCode.CREATE_MAP && op.type !== LiveObject.OpCode.CREATE_OBJECT || createdNodeIds.add(applyOpResult.modified.node._id);
170
+ op.type !== LiveObject.OpCode.CREATE_LIST && op.type !== LiveObject.OpCode.CREATE_MAP && op.type !== LiveObject.OpCode.CREATE_OBJECT || createdNodeIds.add(LiveObject.nn(applyOpResult.modified.node._id));
174
171
  }
175
172
  }
176
173
  }
177
174
  return result;
178
175
  }
179
- function applyOp(op, isLocal) {
180
- switch (op.opId && state.offlineOperations.delete(op.opId), op.type) {
176
+ function applyOp(op, source) {
177
+ switch (op.type) {
181
178
  case LiveObject.OpCode.DELETE_OBJECT_KEY:
182
179
  case LiveObject.OpCode.UPDATE_OBJECT:
183
180
  case LiveObject.OpCode.DELETE_CRDT:
184
181
  var item = state.items.get(op.id);
185
182
  return null == item ? {
186
183
  modified: !1
187
- } : item._apply(op, isLocal);
184
+ } : item._apply(op, source === LiveObject.OpSource.UNDOREDO_RECONNECT);
188
185
 
189
186
  case LiveObject.OpCode.SET_PARENT_KEY:
190
187
  var _item = state.items.get(op.id);
191
- if (null == _item) return {
188
+ return null == _item ? {
192
189
  modified: !1
193
- };
194
- if (_item._parent instanceof LiveObject.LiveList) {
195
- var previousKey = _item._parentKey;
196
- return previousKey === op.parentKey ? {
197
- modified: !1
198
- } : _item._parent._setChildKey(op.parentKey, _item, previousKey);
199
- }
200
- return {
190
+ } : "HasParent" === _item.parent.type && LiveObject.isLiveList(_item.parent.node) ? _item.parent.node._setChildKey(op.parentKey, _item, source) : {
201
191
  modified: !1
202
192
  };
203
193
 
@@ -205,10 +195,13 @@ function makeStateMachine(state, context, mockedEffects) {
205
195
  case LiveObject.OpCode.CREATE_LIST:
206
196
  case LiveObject.OpCode.CREATE_MAP:
207
197
  case LiveObject.OpCode.CREATE_REGISTER:
198
+ if (void 0 === op.parentId) return {
199
+ modified: !1
200
+ };
208
201
  var parent = state.items.get(op.parentId);
209
202
  return null == parent ? {
210
203
  modified: !1
211
- } : parent._attachChild(op, isLocal);
204
+ } : parent._attachChild(op, source);
212
205
  }
213
206
  }
214
207
  function connect() {
@@ -447,7 +440,7 @@ function makeStateMachine(state, context, mockedEffects) {
447
440
  function tryFlushing() {
448
441
  var storageOps = state.buffer.storageOperations;
449
442
  if (storageOps.length > 0 && storageOps.forEach((function(op) {
450
- state.offlineOperations.set(op.opId, op);
443
+ state.offlineOperations.set(LiveObject.nn(op.opId), op);
451
444
  })), null != state.socket && state.socket.readyState === state.socket.OPEN) {
452
445
  var now = Date.now();
453
446
  if (now - state.lastFlushTime > context.throttleDelay) {
@@ -495,10 +488,10 @@ function makeStateMachine(state, context, mockedEffects) {
495
488
  "unavailable" === state.connection.state && reconnect();
496
489
  },
497
490
  simulateSocketClose: function() {
498
- state.socket && state.socket.close();
491
+ state.socket && (state.socket = null);
499
492
  },
500
493
  simulateSendCloseEvent: function(event) {
501
- state.socket && onClose(event);
494
+ onClose(event);
502
495
  },
503
496
  onVisibilityChange: function(visibilityState) {
504
497
  "visible" === visibilityState && "open" === state.connection.state && heartbeat();
@@ -526,28 +519,23 @@ function makeStateMachine(state, context, mockedEffects) {
526
519
  }();
527
520
  },
528
521
  subscribe: function(firstParam, listener, options) {
529
- if (firstParam instanceof LiveObject.AbstractCrdt) return function(crdt, innerCallback, options) {
522
+ if (LiveObject.isLiveNode(firstParam)) return function(liveValue, innerCallback, options) {
530
523
  return genericSubscribe((function(updates) {
531
524
  for (var _step, relatedUpdates = [], _iterator = LiveObject._createForOfIteratorHelperLoose(updates); !(_step = _iterator()).done; ) {
532
525
  var update = _step.value;
533
- null != options && options.isDeep && LiveObject.isSameNodeOrChildOf(update.node, crdt) ? relatedUpdates.push(update) : update.node._id === crdt._id && innerCallback(update.node);
526
+ null != options && options.isDeep && LiveObject.isSameNodeOrChildOf(update.node, liveValue) ? relatedUpdates.push(update) : update.node._id === liveValue._id && innerCallback(update.node);
534
527
  }
535
528
  null != options && options.isDeep && relatedUpdates.length > 0 && innerCallback(relatedUpdates);
536
529
  }));
537
530
  }(firstParam, listener, options);
538
531
  if ("function" == typeof firstParam) return genericSubscribe(firstParam);
539
- if (!isValidRoomEventType(firstParam)) throw new Error('"' + firstParam + '" is not a valid event name');
532
+ if ("my-presence" !== (value = firstParam) && "others" !== value && "event" !== value && "error" !== value && "connection" !== value) throw new Error('"' + firstParam + '" is not a valid event name');
533
+ var value;
540
534
  return state.listeners[firstParam].push(listener), function() {
541
535
  var callbacks = state.listeners[firstParam];
542
536
  LiveObject.remove(callbacks, listener);
543
537
  };
544
538
  },
545
- unsubscribe: function(event, callback) {
546
- if (console.warn("unsubscribe is depreacted and will be removed in a future version.\nuse the callback returned by subscribe instead.\nSee v0.13 release notes for more information.\n"),
547
- !isValidRoomEventType(event)) throw new Error('"' + event + '" is not a valid event name');
548
- var callbacks = state.listeners[event];
549
- LiveObject.remove(callbacks, callback);
550
- },
551
539
  updatePresence: function(overrides, options) {
552
540
  var oldValues = {};
553
541
  for (var _key4 in null == state.buffer.presence && (state.buffer.presence = {}),
@@ -635,7 +623,7 @@ function makeStateMachine(state, context, mockedEffects) {
635
623
  return _getInitialStateResolver = resolve;
636
624
  }))), _getInitialStatePromise.then((function() {
637
625
  return {
638
- root: state.root
626
+ root: LiveObject.nn(state.root)
639
627
  };
640
628
  })));
641
629
  },
@@ -721,7 +709,6 @@ function createRoom(options, context) {
721
709
  getConnectionState: machine.selectors.getConnectionState,
722
710
  getSelf: machine.selectors.getSelf,
723
711
  subscribe: machine.subscribe,
724
- unsubscribe: machine.unsubscribe,
725
712
  getPresence: machine.selectors.getPresence,
726
713
  updatePresence: machine.updatePresence,
727
714
  getOthers: machine.selectors.getOthers,
@@ -734,9 +721,9 @@ function createRoom(options, context) {
734
721
  pause: machine.pauseHistory,
735
722
  resume: machine.resumeHistory
736
723
  },
737
- internalDevTools: {
738
- closeWebsocket: machine.simulateSocketClose,
739
- sendCloseEvent: machine.simulateSendCloseEvent
724
+ __INTERNAL_DO_NOT_USE: {
725
+ simulateCloseWebsocket: machine.simulateSocketClose,
726
+ simulateSendCloseEvent: machine.simulateSendCloseEvent
740
727
  }
741
728
  };
742
729
  return {
@@ -758,7 +745,7 @@ var LiveblocksError = function(_Error) {
758
745
  function parseToken(token) {
759
746
  var tokenParts = token.split(".");
760
747
  if (3 !== tokenParts.length) throw new Error("Authentication error. Liveblocks could not parse the response of your authentication endpoint");
761
- var data = LiveObject.tryParseJson(atob(tokenParts[1]));
748
+ var data = LiveObject.tryParseJson(LiveObject.b64decode(tokenParts[1]));
762
749
  if (void 0 !== data && LiveObject.isJsonObject(data) && "number" == typeof data.actor && (void 0 === data.id || "string" == typeof data.id)) return {
763
750
  actor: data.actor,
764
751
  id: data.id,
@@ -832,8 +819,8 @@ exports.createClient = function(options) {
832
819
  enter: function(roomId, options) {
833
820
  void 0 === options && (options = {});
834
821
  var internalRoom = rooms.get(roomId);
835
- return internalRoom || (LiveObject.deprecateIf(options.defaultPresence, "Argument `defaultPresence` will be removed in @liveblocks/client 0.18. Please use `initialPresence` instead. For more info, see https://bit.ly/3Niy5aP", "defaultPresence"),
836
- LiveObject.deprecateIf(options.defaultStorageRoot, "Argument `defaultStorageRoot` will be removed in @liveblocks/client 0.18. Please use `initialStorage` instead. For more info, see https://bit.ly/3Niy5aP", "defaultStorageRoot"),
822
+ return internalRoom || (LiveObject.errorIf(options.defaultPresence, "Argument `defaultPresence` will be removed in @liveblocks/client 0.18. Please use `initialPresence` instead. For more info, see https://bit.ly/3Niy5aP"),
823
+ LiveObject.errorIf(options.defaultStorageRoot, "Argument `defaultStorageRoot` will be removed in @liveblocks/client 0.18. Please use `initialStorage` instead. For more info, see https://bit.ly/3Niy5aP"),
837
824
  internalRoom = createRoom({
838
825
  initialPresence: options.initialPresence,
839
826
  initialStorage: options.initialStorage,
package/index.mjs CHANGED
@@ -1,13 +1,9 @@
1
- import { A as AbstractCrdt, r as remove, S as ServerMsgCode, m as mergeStorageUpdates, W as WebsocketCloseCodes, C as ClientMsgCode, i as isTokenValid, a as isSameNodeOrChildOf, L as LiveObject, g as getTreesDiffOperations, O as OpCode, b as LiveList, t as tryParseJson, c as isJsonArray, d as compact, e as isJsonObject, f as isRootCrdt, h as deprecateIf } from "./shared.mjs";
1
+ import { i as isLiveNode, r as remove, S as ServerMsgCode, m as mergeStorageUpdates, W as WebsocketCloseCodes, C as ClientMsgCode, n as nn, a as isTokenValid, b as isSameNodeOrChildOf, L as LiveObject, g as getTreesDiffOperations, O as OpSource, c as OpCode, d as isLiveList, t as tryParseJson, e as isJsonArray, f as compact, h as b64decode, j as isJsonObject, k as isRootCrdt, l as errorIf } from "./shared.mjs";
2
2
 
3
- export { b as LiveList, j as LiveMap, L as LiveObject } from "./shared.mjs";
3
+ export { o as LiveList, p as LiveMap, L as LiveObject } from "./shared.mjs";
4
4
 
5
5
  const BACKOFF_RETRY_DELAYS = [ 250, 500, 1e3, 2e3, 4e3, 8e3, 1e4 ], BACKOFF_RETRY_DELAYS_SLOW = [ 2e3, 3e4, 6e4, 3e5 ];
6
6
 
7
- function isValidRoomEventType(value) {
8
- return "my-presence" === value || "others" === value || "event" === value || "error" === value || "connection" === value;
9
- }
10
-
11
7
  function makeOthers(userMap) {
12
8
  const users = Object.values(userMap).map((user => function(s, e) {
13
9
  var t = {};
@@ -88,8 +84,8 @@ function makeStateMachine(state, context, mockedEffects) {
88
84
  }(message.items);
89
85
  for (const key in state.defaultStorageRoot) null == state.root.get(key) && state.root.set(key, state.defaultStorageRoot[key]);
90
86
  }
91
- function addItem(id, item) {
92
- state.items.set(id, item);
87
+ function addItem(id, liveItem) {
88
+ state.items.set(id, liveItem);
93
89
  }
94
90
  function deleteItem(id) {
95
91
  state.items.delete(id);
@@ -128,7 +124,6 @@ function makeStateMachine(state, context, mockedEffects) {
128
124
  return `${getConnectionId()}:${state.opClock++}`;
129
125
  }
130
126
  function apply(item, isLocal) {
131
- var _a;
132
127
  const result = {
133
128
  reverse: [],
134
129
  updates: {
@@ -145,18 +140,21 @@ function makeStateMachine(state, context, mockedEffects) {
145
140
  if (state.me = Object.assign(Object.assign({}, state.me), op.data), null == state.buffer.presence) state.buffer.presence = op.data; else for (const key in op.data) state.buffer.presence[key] = op.data[key];
146
141
  result.reverse.unshift(reverse), result.updates.presence = !0;
147
142
  } else {
148
- isLocal && !op.opId && (op.opId = generateOpId());
149
- const applyOpResult = applyOp(op, isLocal);
143
+ let source;
144
+ if (op.opId || (op.opId = generateOpId()), isLocal) source = OpSource.UNDOREDO_RECONNECT; else {
145
+ source = state.offlineOperations.delete(nn(op.opId)) ? OpSource.ACK : OpSource.REMOTE;
146
+ }
147
+ const applyOpResult = applyOp(op, source);
150
148
  if (applyOpResult.modified) {
151
- const parentId = null === (_a = applyOpResult.modified.node._parent) || void 0 === _a ? void 0 : _a._id;
152
- createdNodeIds.has(parentId) || (result.updates.storageUpdates.set(applyOpResult.modified.node._id, mergeStorageUpdates(result.updates.storageUpdates.get(applyOpResult.modified.node._id), applyOpResult.modified)),
153
- result.reverse.unshift(...applyOpResult.reverse)), op.type !== OpCode.CREATE_LIST && op.type !== OpCode.CREATE_MAP && op.type !== OpCode.CREATE_OBJECT || createdNodeIds.add(applyOpResult.modified.node._id);
149
+ const parentId = "HasParent" === applyOpResult.modified.node.parent.type ? nn(applyOpResult.modified.node.parent.node._id, "Expected parent node to have an ID") : void 0;
150
+ parentId && createdNodeIds.has(parentId) || (result.updates.storageUpdates.set(nn(applyOpResult.modified.node._id), mergeStorageUpdates(result.updates.storageUpdates.get(nn(applyOpResult.modified.node._id)), applyOpResult.modified)),
151
+ result.reverse.unshift(...applyOpResult.reverse)), op.type !== OpCode.CREATE_LIST && op.type !== OpCode.CREATE_MAP && op.type !== OpCode.CREATE_OBJECT || createdNodeIds.add(nn(applyOpResult.modified.node._id));
154
152
  }
155
153
  }
156
154
  return result;
157
155
  }
158
- function applyOp(op, isLocal) {
159
- switch (op.opId && state.offlineOperations.delete(op.opId), op.type) {
156
+ function applyOp(op, source) {
157
+ switch (op.type) {
160
158
  case OpCode.DELETE_OBJECT_KEY:
161
159
  case OpCode.UPDATE_OBJECT:
162
160
  case OpCode.DELETE_CRDT:
@@ -164,22 +162,15 @@ function makeStateMachine(state, context, mockedEffects) {
164
162
  const item = state.items.get(op.id);
165
163
  return null == item ? {
166
164
  modified: !1
167
- } : item._apply(op, isLocal);
165
+ } : item._apply(op, source === OpSource.UNDOREDO_RECONNECT);
168
166
  }
169
167
 
170
168
  case OpCode.SET_PARENT_KEY:
171
169
  {
172
170
  const item = state.items.get(op.id);
173
- if (null == item) return {
171
+ return null == item ? {
174
172
  modified: !1
175
- };
176
- if (item._parent instanceof LiveList) {
177
- const previousKey = item._parentKey;
178
- return previousKey === op.parentKey ? {
179
- modified: !1
180
- } : item._parent._setChildKey(op.parentKey, item, previousKey);
181
- }
182
- return {
173
+ } : "HasParent" === item.parent.type && isLiveList(item.parent.node) ? item.parent.node._setChildKey(op.parentKey, item, source) : {
183
174
  modified: !1
184
175
  };
185
176
  }
@@ -189,10 +180,13 @@ function makeStateMachine(state, context, mockedEffects) {
189
180
  case OpCode.CREATE_MAP:
190
181
  case OpCode.CREATE_REGISTER:
191
182
  {
183
+ if (void 0 === op.parentId) return {
184
+ modified: !1
185
+ };
192
186
  const parent = state.items.get(op.parentId);
193
187
  return null == parent ? {
194
188
  modified: !1
195
- } : parent._attachChild(op, isLocal);
189
+ } : parent._attachChild(op, source);
196
190
  }
197
191
  }
198
192
  }
@@ -424,7 +418,7 @@ function makeStateMachine(state, context, mockedEffects) {
424
418
  function tryFlushing() {
425
419
  const storageOps = state.buffer.storageOperations;
426
420
  if (storageOps.length > 0 && storageOps.forEach((op => {
427
- state.offlineOperations.set(op.opId, op);
421
+ state.offlineOperations.set(nn(op.opId), op);
428
422
  })), null == state.socket || state.socket.readyState !== state.socket.OPEN) return void (state.buffer.storageOperations = []);
429
423
  const now = Date.now();
430
424
  if (now - state.lastFlushTime > context.throttleDelay) {
@@ -466,10 +460,10 @@ function makeStateMachine(state, context, mockedEffects) {
466
460
  "unavailable" === state.connection.state && reconnect();
467
461
  },
468
462
  simulateSocketClose: function() {
469
- state.socket && state.socket.close();
463
+ state.socket && (state.socket = null);
470
464
  },
471
465
  simulateSendCloseEvent: function(event) {
472
- state.socket && onClose(event);
466
+ onClose(event);
473
467
  },
474
468
  onVisibilityChange: function(visibilityState) {
475
469
  "visible" === visibilityState && "open" === state.connection.state && heartbeat();
@@ -493,26 +487,21 @@ function makeStateMachine(state, context, mockedEffects) {
493
487
  }();
494
488
  },
495
489
  subscribe: function(firstParam, listener, options) {
496
- if (firstParam instanceof AbstractCrdt) return function(crdt, innerCallback, options) {
490
+ if (isLiveNode(firstParam)) return function(liveValue, innerCallback, options) {
497
491
  return genericSubscribe((updates => {
498
492
  const relatedUpdates = [];
499
- for (const update of updates) (null == options ? void 0 : options.isDeep) && isSameNodeOrChildOf(update.node, crdt) ? relatedUpdates.push(update) : update.node._id === crdt._id && innerCallback(update.node);
493
+ for (const update of updates) (null == options ? void 0 : options.isDeep) && isSameNodeOrChildOf(update.node, liveValue) ? relatedUpdates.push(update) : update.node._id === liveValue._id && innerCallback(update.node);
500
494
  (null == options ? void 0 : options.isDeep) && relatedUpdates.length > 0 && innerCallback(relatedUpdates);
501
495
  }));
502
496
  }(firstParam, listener, options);
503
497
  if ("function" == typeof firstParam) return genericSubscribe(firstParam);
504
- if (!isValidRoomEventType(firstParam)) throw new Error(`"${firstParam}" is not a valid event name`);
498
+ if ("my-presence" !== (value = firstParam) && "others" !== value && "event" !== value && "error" !== value && "connection" !== value) throw new Error(`"${firstParam}" is not a valid event name`);
499
+ var value;
505
500
  return state.listeners[firstParam].push(listener), () => {
506
501
  const callbacks = state.listeners[firstParam];
507
502
  remove(callbacks, listener);
508
503
  };
509
504
  },
510
- unsubscribe: function(event, callback) {
511
- if (console.warn("unsubscribe is depreacted and will be removed in a future version.\nuse the callback returned by subscribe instead.\nSee v0.13 release notes for more information.\n"),
512
- !isValidRoomEventType(event)) throw new Error(`"${event}" is not a valid event name`);
513
- const callbacks = state.listeners[event];
514
- remove(callbacks, callback);
515
- },
516
505
  updatePresence: function(overrides, options) {
517
506
  const oldValues = {};
518
507
  null == state.buffer.presence && (state.buffer.presence = {});
@@ -588,7 +577,7 @@ function makeStateMachine(state, context, mockedEffects) {
588
577
  type: ClientMsgCode.FETCH_STORAGE
589
578
  }), tryFlushing(), _getInitialStatePromise = new Promise((resolve => _getInitialStateResolver = resolve))),
590
579
  _getInitialStatePromise.then((() => ({
591
- root: state.root
580
+ root: nn(state.root)
592
581
  }))));
593
582
  },
594
583
  selectors: {
@@ -674,7 +663,6 @@ function createRoom(options, context) {
674
663
  getConnectionState: machine.selectors.getConnectionState,
675
664
  getSelf: machine.selectors.getSelf,
676
665
  subscribe: machine.subscribe,
677
- unsubscribe: machine.unsubscribe,
678
666
  getPresence: machine.selectors.getPresence,
679
667
  updatePresence: machine.updatePresence,
680
668
  getOthers: machine.selectors.getOthers,
@@ -687,9 +675,9 @@ function createRoom(options, context) {
687
675
  pause: machine.pauseHistory,
688
676
  resume: machine.resumeHistory
689
677
  },
690
- internalDevTools: {
691
- closeWebsocket: machine.simulateSocketClose,
692
- sendCloseEvent: machine.simulateSendCloseEvent
678
+ __INTERNAL_DO_NOT_USE: {
679
+ simulateCloseWebsocket: machine.simulateSocketClose,
680
+ simulateSendCloseEvent: machine.simulateSendCloseEvent
693
681
  }
694
682
  };
695
683
  return {
@@ -710,7 +698,7 @@ class LiveblocksError extends Error {
710
698
  function parseToken(token) {
711
699
  const tokenParts = token.split(".");
712
700
  if (3 !== tokenParts.length) throw new Error("Authentication error. Liveblocks could not parse the response of your authentication endpoint");
713
- const data = tryParseJson(atob(tokenParts[1]));
701
+ const data = tryParseJson(b64decode(tokenParts[1]));
714
702
  if (void 0 !== data && isJsonObject(data) && "number" == typeof data.actor && (void 0 === data.id || "string" == typeof data.id)) return {
715
703
  actor: data.actor,
716
704
  id: data.id,
@@ -760,8 +748,8 @@ function createClient(options) {
760
748
  },
761
749
  enter: function(roomId, options = {}) {
762
750
  let internalRoom = rooms.get(roomId);
763
- return internalRoom || (deprecateIf(options.defaultPresence, "Argument `defaultPresence` will be removed in @liveblocks/client 0.18. Please use `initialPresence` instead. For more info, see https://bit.ly/3Niy5aP", "defaultPresence"),
764
- deprecateIf(options.defaultStorageRoot, "Argument `defaultStorageRoot` will be removed in @liveblocks/client 0.18. Please use `initialStorage` instead. For more info, see https://bit.ly/3Niy5aP", "defaultStorageRoot"),
751
+ return internalRoom || (errorIf(options.defaultPresence, "Argument `defaultPresence` will be removed in @liveblocks/client 0.18. Please use `initialPresence` instead. For more info, see https://bit.ly/3Niy5aP"),
752
+ errorIf(options.defaultStorageRoot, "Argument `defaultStorageRoot` will be removed in @liveblocks/client 0.18. Please use `initialStorage` instead. For more info, see https://bit.ly/3Niy5aP"),
765
753
  internalRoom = createRoom({
766
754
  initialPresence: options.initialPresence,
767
755
  initialStorage: options.initialStorage,