@liveblocks/client 0.18.0-beta2 → 0.18.0-beta3

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 +1 @@
1
- 18f6b3a6607e7c2a61feff9b9b677af5e9dd8797
1
+ b526e5e7b85bbb62bc81e1ed2fe6fb7e71aa7cc4
@@ -94,7 +94,7 @@ function assert(condition, errmsg) {
94
94
  }
95
95
  }
96
96
  function nn(value, errmsg = "Expected value to be non-nullable") {
97
- assert(value != null, errmsg);
97
+ assert(value !== null && value !== void 0, errmsg);
98
98
  return value;
99
99
  }
100
100
 
@@ -168,11 +168,11 @@ var WebsocketCloseCodes = /* @__PURE__ */ ((WebsocketCloseCodes2) => {
168
168
  var min = 32;
169
169
  var max = 126;
170
170
  function makePosition(before, after) {
171
- if (before != null && after != null) {
171
+ if (before !== void 0 && after !== void 0) {
172
172
  return pos(makePositionFromCodes(posCodes(before), posCodes(after)));
173
- } else if (before != null) {
173
+ } else if (before !== void 0) {
174
174
  return getNextPosition(before);
175
- } else if (after != null) {
175
+ } else if (after !== void 0) {
176
176
  return getPreviousPosition(after);
177
177
  }
178
178
  return pos([min + 1]);
@@ -255,8 +255,8 @@ function comparePosition(posA, posB) {
255
255
  const bCodes = posCodes(posB);
256
256
  const maxLength = Math.max(aCodes.length, bCodes.length);
257
257
  for (let i = 0; i < maxLength; i++) {
258
- const a = aCodes[i] == null ? min : aCodes[i];
259
- const b = bCodes[i] == null ? min : bCodes[i];
258
+ const a = aCodes[i] === void 0 ? min : aCodes[i];
259
+ const b = bCodes[i] === void 0 ? min : bCodes[i];
260
260
  if (a === b) {
261
261
  continue;
262
262
  } else {
@@ -421,7 +421,7 @@ var LiveRegister = class extends AbstractCrdt {
421
421
  return register;
422
422
  }
423
423
  _toOps(parentId, parentKey, pool) {
424
- if (this._id == null || parentId == null || parentKey == null) {
424
+ if (this._id === void 0) {
425
425
  throw new Error(
426
426
  "Cannot serialize register if parentId or parentKey is undefined"
427
427
  );
@@ -480,7 +480,7 @@ var LiveMap = class extends AbstractCrdt {
480
480
  }
481
481
  }
482
482
  _toOps(parentId, parentKey, pool) {
483
- if (this._id == null) {
483
+ if (this._id === void 0) {
484
484
  throw new Error("Cannot serialize item is not attached");
485
485
  }
486
486
  const ops = [];
@@ -501,7 +501,7 @@ var LiveMap = class extends AbstractCrdt {
501
501
  const map = new LiveMap();
502
502
  map._attach(id, pool);
503
503
  const children = parentToChildren.get(id);
504
- if (children == null) {
504
+ if (children === void 0) {
505
505
  return map;
506
506
  }
507
507
  for (const [id2, crdt] of children) {
@@ -521,7 +521,7 @@ var LiveMap = class extends AbstractCrdt {
521
521
  }
522
522
  }
523
523
  _attachChild(op, source) {
524
- if (this._pool == null) {
524
+ if (this._pool === void 0) {
525
525
  throw new Error("Can't attach child if managed pool is not present");
526
526
  }
527
527
  const { id, parentKey, opId } = op;
@@ -535,7 +535,7 @@ var LiveMap = class extends AbstractCrdt {
535
535
  if (lastUpdateOpId === opId) {
536
536
  this.unacknowledgedSet.delete(key);
537
537
  return { modified: false };
538
- } else if (lastUpdateOpId != null) {
538
+ } else if (lastUpdateOpId !== void 0) {
539
539
  return { modified: false };
540
540
  }
541
541
  } else if (source === 1 /* REMOTE */) {
@@ -599,7 +599,7 @@ var LiveMap = class extends AbstractCrdt {
599
599
  }
600
600
  get(key) {
601
601
  const value = this._map.get(key);
602
- if (value == void 0) {
602
+ if (value === void 0) {
603
603
  return void 0;
604
604
  }
605
605
  return liveNodeToLson(value);
@@ -639,7 +639,7 @@ var LiveMap = class extends AbstractCrdt {
639
639
  }
640
640
  delete(key) {
641
641
  const item = this._map.get(key);
642
- if (item == null) {
642
+ if (item === void 0) {
643
643
  return false;
644
644
  }
645
645
  item._detach();
@@ -748,7 +748,7 @@ var LiveObject = class extends AbstractCrdt {
748
748
  this._map = new Map(Object.entries(obj));
749
749
  }
750
750
  _toOps(parentId, parentKey, pool) {
751
- if (this._id == null) {
751
+ if (this._id === void 0) {
752
752
  throw new Error("Cannot serialize item is not attached");
753
753
  }
754
754
  const opId = pool == null ? void 0 : pool.generateOpId();
@@ -778,7 +778,7 @@ var LiveObject = class extends AbstractCrdt {
778
778
  }
779
779
  static _deserializeChildren(liveObj, parentToChildren, pool) {
780
780
  const children = parentToChildren.get(nn(liveObj._id));
781
- if (children == null) {
781
+ if (children === void 0) {
782
782
  return liveObj;
783
783
  }
784
784
  for (const [id, crdt] of children) {
@@ -800,7 +800,7 @@ var LiveObject = class extends AbstractCrdt {
800
800
  }
801
801
  }
802
802
  _attachChild(op, source) {
803
- if (this._pool == null) {
803
+ if (this._pool === void 0) {
804
804
  throw new Error("Can't attach child if managed pool is not present");
805
805
  }
806
806
  const { id, opId, parentKey: key } = op;
@@ -941,7 +941,7 @@ var LiveObject = class extends AbstractCrdt {
941
941
  }
942
942
  if (isLocal) {
943
943
  this._propToLastUpdate.set(key, nn(op.opId));
944
- } else if (this._propToLastUpdate.get(key) == null) {
944
+ } else if (this._propToLastUpdate.get(key) === void 0) {
945
945
  isModified = true;
946
946
  } else if (this._propToLastUpdate.get(key) === op.opId) {
947
947
  this._propToLastUpdate.delete(key);
@@ -1019,7 +1019,7 @@ var LiveObject = class extends AbstractCrdt {
1019
1019
  if (oldValue === void 0) {
1020
1020
  return;
1021
1021
  }
1022
- if (this._pool == null || this._id == null) {
1022
+ if (this._pool === void 0 || this._id === void 0) {
1023
1023
  if (isLiveNode(oldValue)) {
1024
1024
  oldValue._detach();
1025
1025
  }
@@ -1062,7 +1062,7 @@ var LiveObject = class extends AbstractCrdt {
1062
1062
  );
1063
1063
  }
1064
1064
  update(patch) {
1065
- if (this._pool == null || this._id == null) {
1065
+ if (this._pool === void 0 || this._id === void 0) {
1066
1066
  for (const key in patch) {
1067
1067
  const newValue = patch[key];
1068
1068
  if (newValue === void 0) {
@@ -1157,7 +1157,9 @@ var LiveObject = class extends AbstractCrdt {
1157
1157
  // src/utils.ts
1158
1158
  var freeze = process.env.NODE_ENV === "production" ? (x) => x : Object.freeze;
1159
1159
  function compact(items) {
1160
- return items.filter((item) => item != null);
1160
+ return items.filter(
1161
+ (item) => item !== null && item !== void 0
1162
+ );
1161
1163
  }
1162
1164
  function compactObject(obj) {
1163
1165
  const newObj = __spreadValues({}, obj);
@@ -1471,7 +1473,7 @@ var LiveList = class extends AbstractCrdt {
1471
1473
  const list = new LiveList();
1472
1474
  list._attach(id, pool);
1473
1475
  const children = parentToChildren.get(id);
1474
- if (children == null) {
1476
+ if (children === void 0) {
1475
1477
  return list;
1476
1478
  }
1477
1479
  for (const [id2, crdt] of children) {
@@ -1482,7 +1484,7 @@ var LiveList = class extends AbstractCrdt {
1482
1484
  return list;
1483
1485
  }
1484
1486
  _toOps(parentId, parentKey, pool) {
1485
- if (this._id == null) {
1487
+ if (this._id === void 0) {
1486
1488
  throw new Error("Cannot serialize item is not attached");
1487
1489
  }
1488
1490
  const ops = [];
@@ -1525,7 +1527,7 @@ var LiveList = class extends AbstractCrdt {
1525
1527
  }
1526
1528
  }
1527
1529
  _applySetRemote(op) {
1528
- if (this._pool == null) {
1530
+ if (this._pool === void 0) {
1529
1531
  throw new Error("Can't attach child if managed pool is not present");
1530
1532
  }
1531
1533
  const { id, parentKey: key } = op;
@@ -1579,7 +1581,7 @@ var LiveList = class extends AbstractCrdt {
1579
1581
  }
1580
1582
  }
1581
1583
  _applySetAck(op) {
1582
- if (this._pool == null) {
1584
+ if (this._pool === void 0) {
1583
1585
  throw new Error("Can't attach child if managed pool is not present");
1584
1586
  }
1585
1587
  const delta = [];
@@ -1588,7 +1590,7 @@ var LiveList = class extends AbstractCrdt {
1588
1590
  delta.push(deletedDelta);
1589
1591
  }
1590
1592
  const unacknowledgedOpId = this._unacknowledgedSets.get(op.parentKey);
1591
- if (unacknowledgedOpId != null) {
1593
+ if (unacknowledgedOpId !== void 0) {
1592
1594
  if (unacknowledgedOpId !== op.opId) {
1593
1595
  return delta.length === 0 ? { modified: false } : { modified: makeUpdate(this, delta), reverse: [] };
1594
1596
  } else {
@@ -1597,7 +1599,7 @@ var LiveList = class extends AbstractCrdt {
1597
1599
  }
1598
1600
  const indexOfItemWithSamePosition = this._indexOfPosition(op.parentKey);
1599
1601
  const existingItem = this._items.find((item) => item._id === op.id);
1600
- if (existingItem != null) {
1602
+ if (existingItem !== void 0) {
1601
1603
  if (existingItem._parentKey === op.parentKey) {
1602
1604
  return {
1603
1605
  modified: delta.length > 0 ? makeUpdate(this, delta) : false,
@@ -1655,11 +1657,11 @@ var LiveList = class extends AbstractCrdt {
1655
1657
  }
1656
1658
  }
1657
1659
  _detachItemAssociatedToSetOperation(deletedId) {
1658
- if (deletedId == null || this._pool == null) {
1660
+ if (deletedId === void 0 || this._pool === void 0) {
1659
1661
  return null;
1660
1662
  }
1661
1663
  const deletedItem = this._pool.getNode(deletedId);
1662
- if (deletedItem == null) {
1664
+ if (deletedItem === void 0) {
1663
1665
  return null;
1664
1666
  }
1665
1667
  const result = this._detachChild(deletedItem);
@@ -1669,7 +1671,7 @@ var LiveList = class extends AbstractCrdt {
1669
1671
  return result.modified.updates[0];
1670
1672
  }
1671
1673
  _applyRemoteInsert(op) {
1672
- if (this._pool == null) {
1674
+ if (this._pool === void 0) {
1673
1675
  throw new Error("Can't attach child if managed pool is not present");
1674
1676
  }
1675
1677
  const key = op.parentKey;
@@ -1797,7 +1799,7 @@ var LiveList = class extends AbstractCrdt {
1797
1799
  }
1798
1800
  }
1799
1801
  _attachChild(op, source) {
1800
- if (this._pool == null) {
1802
+ if (this._pool === void 0) {
1801
1803
  throw new Error("Can't attach child if managed pool is not present");
1802
1804
  }
1803
1805
  let result;
@@ -642,7 +642,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
642
642
  */
643
643
  isSelfAware(): boolean;
644
644
  getConnectionState(): ConnectionState;
645
- subscribe: {
645
+ readonly subscribe: {
646
646
  /**
647
647
  * Subscribe to the current user presence updates.
648
648
  *
@@ -746,7 +746,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
746
746
  /**
747
747
  * Room's history contains functions that let you undo and redo operation made on by the current client on the presence and storage.
748
748
  */
749
- history: History;
749
+ readonly history: History;
750
750
  /**
751
751
  * Gets the current user.
752
752
  * Returns null if not it is not yet connected to the room.
@@ -761,14 +761,14 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
761
761
  * @example
762
762
  * const presence = room.getPresence();
763
763
  */
764
- getPresence: () => TPresence;
764
+ getPresence(): TPresence;
765
765
  /**
766
766
  * Gets all the other users in the room.
767
767
  *
768
768
  * @example
769
769
  * const others = room.getOthers();
770
770
  */
771
- getOthers: () => Others<TPresence, TUserMeta>;
771
+ getOthers(): Others<TPresence, TUserMeta>;
772
772
  /**
773
773
  * Updates the presence of the current user. Only pass the properties you want to update. No need to send the full presence.
774
774
  * @param patch A partial object that contains the properties you want to update.
@@ -781,12 +781,12 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
781
781
  * const presence = room.getPresence();
782
782
  * // presence is equivalent to { x: 0, y: 0 }
783
783
  */
784
- updatePresence: (patch: Partial<TPresence>, options?: {
784
+ updatePresence(patch: Partial<TPresence>, options?: {
785
785
  /**
786
786
  * Whether or not the presence should have an impact on the undo/redo history.
787
787
  */
788
788
  addToHistory: boolean;
789
- }) => void;
789
+ }): void;
790
790
  /**
791
791
  * Broadcasts an event to other users in the room. Event broadcasted to the room can be listened with {@link Room.subscribe}("event").
792
792
  * @param {any} event the event to broadcast. Should be serializable to JSON
@@ -802,7 +802,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
802
802
  * }
803
803
  * });
804
804
  */
805
- broadcastEvent: (event: TRoomEvent, options?: BroadcastOptions) => void;
805
+ broadcastEvent(event: TRoomEvent, options?: BroadcastOptions): void;
806
806
  /**
807
807
  * Get the room's storage asynchronously.
808
808
  * The storage's root is a {@link LiveObject}.
@@ -810,7 +810,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
810
810
  * @example
811
811
  * const { root } = await room.getStorage();
812
812
  */
813
- getStorage: () => Promise<{
813
+ getStorage(): Promise<{
814
814
  root: LiveObject<TStorage>;
815
815
  }>;
816
816
  /**
@@ -821,7 +821,7 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
821
821
  * const root = room.getStorageSnapshot();
822
822
  */
823
823
  getStorageSnapshot(): LiveObject<TStorage> | null;
824
- events: {
824
+ readonly events: {
825
825
  customEvent: Observable<{
826
826
  connectionId: number;
827
827
  event: TRoomEvent;
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as ClientOptions, a as Client } from './index-60aa9677.js';
2
- export { B as BaseUserMeta, d as BroadcastOptions, a as Client, H as History, I as Immutable, e as ImmutableList, f as ImmutableMap, g as ImmutableObject, h as ImmutableRef, J as Json, i as JsonObject, L as LiveList, b as LiveMap, c as LiveObject, j as LiveStructure, k as Lson, l as LsonObject, O as Others, R as Room, S as StorageUpdate, U as User } from './index-60aa9677.js';
1
+ import { C as ClientOptions, a as Client } from './index-29762efc.js';
2
+ export { B as BaseUserMeta, d as BroadcastOptions, a as Client, H as History, I as Immutable, e as ImmutableList, f as ImmutableMap, g as ImmutableObject, h as ImmutableRef, J as Json, i as JsonObject, L as LiveList, b as LiveMap, c as LiveObject, j as LiveStructure, k as Lson, l as LsonObject, O as Others, R as Room, S as StorageUpdate, U as User } from './index-29762efc.js';
3
3
 
4
4
  /**
5
5
  * Create a client that will be responsible to communicate with liveblocks servers.
package/index.js CHANGED
@@ -25,7 +25,7 @@
25
25
 
26
26
 
27
27
 
28
- var _chunkRS4TQ2LTjs = require('./chunk-RS4TQ2LT.js');
28
+ var _chunkUV2F4F4Rjs = require('./chunk-UV2F4F4R.js');
29
29
 
30
30
  // src/EventSource.ts
31
31
  function makeEventSource() {
@@ -63,7 +63,7 @@ function makeEventSource() {
63
63
  // src/ImmutableRef.ts
64
64
  function merge(target, patch) {
65
65
  let updated = false;
66
- const newValue = _chunkRS4TQ2LTjs.__spreadValues.call(void 0, {}, target);
66
+ const newValue = _chunkUV2F4F4Rjs.__spreadValues.call(void 0, {}, target);
67
67
  Object.keys(patch).forEach((k) => {
68
68
  const key = k;
69
69
  const val = patch[key];
@@ -101,7 +101,7 @@ var ImmutableRef = class {
101
101
  var MeRef = class extends ImmutableRef {
102
102
  constructor(initialPresence) {
103
103
  super();
104
- this._me = _chunkRS4TQ2LTjs.freeze.call(void 0, _chunkRS4TQ2LTjs.compactObject.call(void 0, initialPresence));
104
+ this._me = _chunkUV2F4F4Rjs.freeze.call(void 0, _chunkUV2F4F4Rjs.compactObject.call(void 0, initialPresence));
105
105
  }
106
106
  _toImmutable() {
107
107
  return this._me;
@@ -110,7 +110,7 @@ var MeRef = class extends ImmutableRef {
110
110
  const oldMe = this._me;
111
111
  const newMe = merge(oldMe, patch);
112
112
  if (oldMe !== newMe) {
113
- this._me = _chunkRS4TQ2LTjs.freeze.call(void 0, newMe);
113
+ this._me = _chunkUV2F4F4Rjs.freeze.call(void 0, newMe);
114
114
  this.invalidate();
115
115
  }
116
116
  }
@@ -118,7 +118,7 @@ var MeRef = class extends ImmutableRef {
118
118
 
119
119
  // src/OthersRef.ts
120
120
  function makeUser(conn, presence) {
121
- return _chunkRS4TQ2LTjs.freeze.call(void 0, _chunkRS4TQ2LTjs.compactObject.call(void 0, _chunkRS4TQ2LTjs.__spreadProps.call(void 0, _chunkRS4TQ2LTjs.__spreadValues.call(void 0, {}, conn), { presence })));
121
+ return _chunkUV2F4F4Rjs.freeze.call(void 0, _chunkUV2F4F4Rjs.compactObject.call(void 0, _chunkUV2F4F4Rjs.__spreadProps.call(void 0, _chunkUV2F4F4Rjs.__spreadValues.call(void 0, {}, conn), { presence })));
122
122
  }
123
123
  var OthersRef = class extends ImmutableRef {
124
124
  constructor() {
@@ -128,12 +128,12 @@ var OthersRef = class extends ImmutableRef {
128
128
  this._users = {};
129
129
  }
130
130
  _toImmutable() {
131
- const users = _chunkRS4TQ2LTjs.compact.call(void 0,
131
+ const users = _chunkUV2F4F4Rjs.compact.call(void 0,
132
132
  Object.keys(this._presences).map(
133
133
  (connectionId) => this.getUser(Number(connectionId))
134
134
  )
135
135
  );
136
- return _chunkRS4TQ2LTjs.asArrayWithLegacyMethods.call(void 0, users);
136
+ return _chunkUV2F4F4Rjs.asArrayWithLegacyMethods.call(void 0, users);
137
137
  }
138
138
  clearOthers() {
139
139
  this._connections = {};
@@ -168,7 +168,7 @@ var OthersRef = class extends ImmutableRef {
168
168
  this.invalidate();
169
169
  }
170
170
  setConnection(connectionId, metaUserId, metaUserInfo) {
171
- this._connections[connectionId] = _chunkRS4TQ2LTjs.freeze.call(void 0, {
171
+ this._connections[connectionId] = _chunkUV2F4F4Rjs.freeze.call(void 0, {
172
172
  connectionId,
173
173
  id: metaUserId,
174
174
  info: metaUserInfo
@@ -183,7 +183,7 @@ var OthersRef = class extends ImmutableRef {
183
183
  this._invalidateUser(connectionId);
184
184
  }
185
185
  setOther(connectionId, presence) {
186
- this._presences[connectionId] = _chunkRS4TQ2LTjs.freeze.call(void 0, _chunkRS4TQ2LTjs.compactObject.call(void 0, presence));
186
+ this._presences[connectionId] = _chunkUV2F4F4Rjs.freeze.call(void 0, _chunkUV2F4F4Rjs.compactObject.call(void 0, presence));
187
187
  if (this._connections[connectionId] !== void 0) {
188
188
  this._invalidateUser(connectionId);
189
189
  }
@@ -195,7 +195,7 @@ var OthersRef = class extends ImmutableRef {
195
195
  }
196
196
  const newPresence = merge(oldPresence, patch);
197
197
  if (oldPresence !== newPresence) {
198
- this._presences[connectionId] = _chunkRS4TQ2LTjs.freeze.call(void 0, newPresence);
198
+ this._presences[connectionId] = _chunkUV2F4F4Rjs.freeze.call(void 0, newPresence);
199
199
  this._invalidateUser(connectionId);
200
200
  }
201
201
  }
@@ -205,13 +205,13 @@ var OthersRef = class extends ImmutableRef {
205
205
  var ValueRef = class extends ImmutableRef {
206
206
  constructor(initialValue) {
207
207
  super();
208
- this._value = _chunkRS4TQ2LTjs.freeze.call(void 0, _chunkRS4TQ2LTjs.compactObject.call(void 0, initialValue));
208
+ this._value = _chunkUV2F4F4Rjs.freeze.call(void 0, _chunkUV2F4F4Rjs.compactObject.call(void 0, initialValue));
209
209
  }
210
210
  _toImmutable() {
211
211
  return this._value;
212
212
  }
213
213
  set(newValue) {
214
- this._value = _chunkRS4TQ2LTjs.freeze.call(void 0, newValue);
214
+ this._value = _chunkUV2F4F4Rjs.freeze.call(void 0, newValue);
215
215
  this.invalidate();
216
216
  }
217
217
  };
@@ -259,7 +259,7 @@ function makeStateMachine(state, config, mockedEffects) {
259
259
  storageUpdates.forEach((value, key) => {
260
260
  activeBatch.updates.storageUpdates.set(
261
261
  key,
262
- _chunkRS4TQ2LTjs.mergeStorageUpdates.call(void 0,
262
+ _chunkUV2F4F4Rjs.mergeStorageUpdates.call(void 0,
263
263
  activeBatch.updates.storageUpdates.get(key),
264
264
  value
265
265
  )
@@ -287,8 +287,8 @@ function makeStateMachine(state, config, mockedEffects) {
287
287
  const effects = mockedEffects || {
288
288
  authenticate(auth, createWebSocket) {
289
289
  const rawToken = state.token;
290
- const parsedToken = rawToken !== null && _chunkRS4TQ2LTjs.parseRoomAuthToken.call(void 0, rawToken);
291
- if (parsedToken && !_chunkRS4TQ2LTjs.isTokenExpired.call(void 0, parsedToken)) {
290
+ const parsedToken = rawToken !== null && _chunkUV2F4F4Rjs.parseRoomAuthToken.call(void 0, rawToken);
291
+ if (parsedToken && !_chunkUV2F4F4Rjs.isTokenExpired.call(void 0, parsedToken)) {
292
292
  const socket = createWebSocket(rawToken);
293
293
  authenticationSuccess(parsedToken, socket);
294
294
  } else {
@@ -296,7 +296,7 @@ function makeStateMachine(state, config, mockedEffects) {
296
296
  if (state.connection.current.state !== "authenticating") {
297
297
  return;
298
298
  }
299
- const parsedToken2 = _chunkRS4TQ2LTjs.parseRoomAuthToken.call(void 0, token);
299
+ const parsedToken2 = _chunkUV2F4F4Rjs.parseRoomAuthToken.call(void 0, token);
300
300
  const socket = createWebSocket(token);
301
301
  authenticationSuccess(parsedToken2, socket);
302
302
  state.token = token;
@@ -308,7 +308,7 @@ function makeStateMachine(state, config, mockedEffects) {
308
308
  }
309
309
  },
310
310
  send(messageOrMessages) {
311
- if (state.socket == null) {
311
+ if (state.socket === null) {
312
312
  throw new Error("Can't send message if socket is null");
313
313
  }
314
314
  state.socket.send(JSON.stringify(messageOrMessages));
@@ -344,9 +344,9 @@ function makeStateMachine(state, config, mockedEffects) {
344
344
  } else {
345
345
  state.root = load(message.items);
346
346
  }
347
- for (const key in state.defaultStorageRoot) {
348
- if (state.root.get(key) == null) {
349
- state.root.set(key, state.defaultStorageRoot[key]);
347
+ for (const key in state.initialStorage) {
348
+ if (state.root.get(key) === void 0) {
349
+ state.root.set(key, state.initialStorage[key]);
350
350
  }
351
351
  }
352
352
  }
@@ -354,19 +354,19 @@ function makeStateMachine(state, config, mockedEffects) {
354
354
  const parentToChildren = /* @__PURE__ */ new Map();
355
355
  let root = null;
356
356
  for (const [id, crdt] of items) {
357
- if (_chunkRS4TQ2LTjs.isRootCrdt.call(void 0, crdt)) {
357
+ if (_chunkUV2F4F4Rjs.isRootCrdt.call(void 0, crdt)) {
358
358
  root = [id, crdt];
359
359
  } else {
360
360
  const tuple = [id, crdt];
361
361
  const children = parentToChildren.get(crdt.parentId);
362
- if (children != null) {
362
+ if (children !== void 0) {
363
363
  children.push(tuple);
364
364
  } else {
365
365
  parentToChildren.set(crdt.parentId, [tuple]);
366
366
  }
367
367
  }
368
368
  }
369
- if (root == null) {
369
+ if (root === null) {
370
370
  throw new Error("Root can't be null");
371
371
  }
372
372
  return [root, parentToChildren];
@@ -379,23 +379,26 @@ function makeStateMachine(state, config, mockedEffects) {
379
379
  state.nodes.forEach((node, id) => {
380
380
  currentItems.set(id, node._serialize());
381
381
  });
382
- const ops = _chunkRS4TQ2LTjs.getTreesDiffOperations.call(void 0, currentItems, new Map(items));
382
+ const ops = _chunkUV2F4F4Rjs.getTreesDiffOperations.call(void 0, currentItems, new Map(items));
383
383
  const result = apply(ops, false);
384
384
  notify(result.updates);
385
385
  }
386
386
  function load(items) {
387
387
  const [root, parentToChildren] = buildRootAndParentToChildren(items);
388
- return _chunkRS4TQ2LTjs.LiveObject._deserialize(root, parentToChildren, pool);
388
+ return _chunkUV2F4F4Rjs.LiveObject._deserialize(root, parentToChildren, pool);
389
389
  }
390
- function addToUndoStack(historyItem) {
390
+ function _addToRealUndoStack(historyOps) {
391
391
  if (state.undoStack.length >= 50) {
392
392
  state.undoStack.shift();
393
393
  }
394
- if (state.isHistoryPaused) {
395
- state.pausedHistory.unshift(...historyItem);
394
+ state.undoStack.push(historyOps);
395
+ onHistoryChange();
396
+ }
397
+ function addToUndoStack(historyOps) {
398
+ if (state.pausedHistory !== null) {
399
+ state.pausedHistory.unshift(...historyOps);
396
400
  } else {
397
- state.undoStack.push(historyItem);
398
- onHistoryChange();
401
+ _addToRealUndoStack(historyOps);
399
402
  }
400
403
  }
401
404
  function notify({
@@ -428,7 +431,7 @@ function makeStateMachine(state, config, mockedEffects) {
428
431
  "Internal. Tried to get connection id but connection was never open"
429
432
  );
430
433
  }
431
- function apply(item, isLocal) {
434
+ function apply(ops, isLocal) {
432
435
  const result = {
433
436
  reverse: [],
434
437
  updates: {
@@ -437,7 +440,7 @@ function makeStateMachine(state, config, mockedEffects) {
437
440
  }
438
441
  };
439
442
  const createdNodeIds = /* @__PURE__ */ new Set();
440
- for (const op of item) {
443
+ for (const op of ops) {
441
444
  if (op.type === "presence") {
442
445
  const reverse = {
443
446
  type: "presence",
@@ -447,7 +450,7 @@ function makeStateMachine(state, config, mockedEffects) {
447
450
  reverse.data[key] = state.me.current[key];
448
451
  }
449
452
  state.me.patch(op.data);
450
- if (state.buffer.me == null) {
453
+ if (state.buffer.me === null) {
451
454
  state.buffer.me = { type: "partial", data: op.data };
452
455
  } else {
453
456
  for (const key in op.data) {
@@ -464,21 +467,21 @@ function makeStateMachine(state, config, mockedEffects) {
464
467
  if (isLocal) {
465
468
  source = 0 /* UNDOREDO_RECONNECT */;
466
469
  } else {
467
- const deleted = state.offlineOperations.delete(_chunkRS4TQ2LTjs.nn.call(void 0, op.opId));
470
+ const deleted = state.offlineOperations.delete(_chunkUV2F4F4Rjs.nn.call(void 0, op.opId));
468
471
  source = deleted ? 2 /* ACK */ : 1 /* REMOTE */;
469
472
  }
470
473
  const applyOpResult = applyOp(op, source);
471
474
  if (applyOpResult.modified) {
472
- const parentId = applyOpResult.modified.node.parent.type === "HasParent" ? _chunkRS4TQ2LTjs.nn.call(void 0,
475
+ const parentId = applyOpResult.modified.node.parent.type === "HasParent" ? _chunkUV2F4F4Rjs.nn.call(void 0,
473
476
  applyOpResult.modified.node.parent.node._id,
474
477
  "Expected parent node to have an ID"
475
478
  ) : void 0;
476
479
  if (!parentId || !createdNodeIds.has(parentId)) {
477
480
  result.updates.storageUpdates.set(
478
- _chunkRS4TQ2LTjs.nn.call(void 0, applyOpResult.modified.node._id),
479
- _chunkRS4TQ2LTjs.mergeStorageUpdates.call(void 0,
481
+ _chunkUV2F4F4Rjs.nn.call(void 0, applyOpResult.modified.node._id),
482
+ _chunkUV2F4F4Rjs.mergeStorageUpdates.call(void 0,
480
483
  result.updates.storageUpdates.get(
481
- _chunkRS4TQ2LTjs.nn.call(void 0, applyOpResult.modified.node._id)
484
+ _chunkUV2F4F4Rjs.nn.call(void 0, applyOpResult.modified.node._id)
482
485
  ),
483
486
  applyOpResult.modified
484
487
  )
@@ -486,7 +489,7 @@ function makeStateMachine(state, config, mockedEffects) {
486
489
  result.reverse.unshift(...applyOpResult.reverse);
487
490
  }
488
491
  if (op.type === 2 /* CREATE_LIST */ || op.type === 7 /* CREATE_MAP */ || op.type === 4 /* CREATE_OBJECT */) {
489
- createdNodeIds.add(_chunkRS4TQ2LTjs.nn.call(void 0, applyOpResult.modified.node._id));
492
+ createdNodeIds.add(_chunkUV2F4F4Rjs.nn.call(void 0, applyOpResult.modified.node._id));
490
493
  }
491
494
  }
492
495
  }
@@ -499,17 +502,17 @@ function makeStateMachine(state, config, mockedEffects) {
499
502
  case 3 /* UPDATE_OBJECT */:
500
503
  case 5 /* DELETE_CRDT */: {
501
504
  const node = state.nodes.get(op.id);
502
- if (node == null) {
505
+ if (node === void 0) {
503
506
  return { modified: false };
504
507
  }
505
508
  return node._apply(op, source === 0 /* UNDOREDO_RECONNECT */);
506
509
  }
507
510
  case 1 /* SET_PARENT_KEY */: {
508
511
  const node = state.nodes.get(op.id);
509
- if (node == null) {
512
+ if (node === void 0) {
510
513
  return { modified: false };
511
514
  }
512
- if (node.parent.type === "HasParent" && _chunkRS4TQ2LTjs.isLiveList.call(void 0, node.parent.node)) {
515
+ if (node.parent.type === "HasParent" && _chunkUV2F4F4Rjs.isLiveList.call(void 0, node.parent.node)) {
513
516
  return node.parent.node._setChildKey(op.parentKey, node, source);
514
517
  }
515
518
  return { modified: false };
@@ -522,7 +525,7 @@ function makeStateMachine(state, config, mockedEffects) {
522
525
  return { modified: false };
523
526
  }
524
527
  const parentNode = state.nodes.get(op.parentId);
525
- if (parentNode == null) {
528
+ if (parentNode === void 0) {
526
529
  return { modified: false };
527
530
  }
528
531
  return parentNode._attachChild(op, source);
@@ -532,7 +535,7 @@ function makeStateMachine(state, config, mockedEffects) {
532
535
  function subscribeToLiveStructureDeeply(node, callback) {
533
536
  return eventHub.storage.subscribe((updates) => {
534
537
  const relatedUpdates = updates.filter(
535
- (update) => _chunkRS4TQ2LTjs.isSameNodeOrChildOf.call(void 0, update.node, node)
538
+ (update) => _chunkUV2F4F4Rjs.isSameNodeOrChildOf.call(void 0, update.node, node)
536
539
  );
537
540
  if (relatedUpdates.length > 0) {
538
541
  callback(relatedUpdates);
@@ -549,7 +552,7 @@ function makeStateMachine(state, config, mockedEffects) {
549
552
  });
550
553
  }
551
554
  function subscribe(first, second, options) {
552
- if (typeof first === "string" && _chunkRS4TQ2LTjs.isRoomEventName.call(void 0, first)) {
555
+ if (typeof first === "string" && _chunkUV2F4F4Rjs.isRoomEventName.call(void 0, first)) {
553
556
  if (typeof second !== "function") {
554
557
  throw new Error("Second argument must be a callback function");
555
558
  }
@@ -580,7 +583,7 @@ function makeStateMachine(state, config, mockedEffects) {
580
583
  case "history":
581
584
  return eventHub.history.subscribe(callback);
582
585
  default:
583
- return _chunkRS4TQ2LTjs.assertNever.call(void 0, first, "Unknown event");
586
+ return _chunkUV2F4F4Rjs.assertNever.call(void 0, first, "Unknown event");
584
587
  }
585
588
  }
586
589
  if (second === void 0 || typeof first === "function") {
@@ -591,7 +594,7 @@ function makeStateMachine(state, config, mockedEffects) {
591
594
  throw new Error("Please specify a listener callback");
592
595
  }
593
596
  }
594
- if (_chunkRS4TQ2LTjs.isLiveNode.call(void 0, first)) {
597
+ if (_chunkUV2F4F4Rjs.isLiveNode.call(void 0, first)) {
595
598
  const node = first;
596
599
  if (options == null ? void 0 : options.isDeep) {
597
600
  const storageCallback = second;
@@ -624,7 +627,7 @@ function makeStateMachine(state, config, mockedEffects) {
624
627
  }
625
628
  function updatePresence(patch, options) {
626
629
  const oldValues = {};
627
- if (state.buffer.me == null) {
630
+ if (state.buffer.me === null) {
628
631
  state.buffer.me = {
629
632
  type: "partial",
630
633
  data: {}
@@ -743,19 +746,19 @@ function makeStateMachine(state, config, mockedEffects) {
743
746
  return user ? { type: "enter", user } : void 0;
744
747
  }
745
748
  function parseServerMessage(data) {
746
- if (!_chunkRS4TQ2LTjs.isJsonObject.call(void 0, data)) {
749
+ if (!_chunkUV2F4F4Rjs.isJsonObject.call(void 0, data)) {
747
750
  return null;
748
751
  }
749
752
  return data;
750
753
  }
751
754
  function parseServerMessages(text) {
752
- const data = _chunkRS4TQ2LTjs.tryParseJson.call(void 0, text);
755
+ const data = _chunkUV2F4F4Rjs.tryParseJson.call(void 0, text);
753
756
  if (data === void 0) {
754
757
  return null;
755
- } else if (_chunkRS4TQ2LTjs.isJsonArray.call(void 0, data)) {
756
- return _chunkRS4TQ2LTjs.compact.call(void 0, data.map((item) => parseServerMessage(item)));
758
+ } else if (_chunkUV2F4F4Rjs.isJsonArray.call(void 0, data)) {
759
+ return _chunkUV2F4F4Rjs.compact.call(void 0, data.map((item) => parseServerMessage(item)));
757
760
  } else {
758
- return _chunkRS4TQ2LTjs.compact.call(void 0, [parseServerMessage(data)]);
761
+ return _chunkUV2F4F4Rjs.compact.call(void 0, [parseServerMessage(data)]);
759
762
  }
760
763
  }
761
764
  function onMessage(event) {
@@ -818,7 +821,7 @@ function makeStateMachine(state, config, mockedEffects) {
818
821
  applyResult.updates.storageUpdates.forEach((value, key) => {
819
822
  updates.storageUpdates.set(
820
823
  key,
821
- _chunkRS4TQ2LTjs.mergeStorageUpdates.call(void 0,
824
+ _chunkUV2F4F4Rjs.mergeStorageUpdates.call(void 0,
822
825
  updates.storageUpdates.get(key),
823
826
  value
824
827
  )
@@ -883,7 +886,7 @@ function makeStateMachine(state, config, mockedEffects) {
883
886
  clearInterval(state.intervalHandles.heartbeat);
884
887
  state.intervalHandles.heartbeat = effects.startHeartbeatInterval();
885
888
  if (state.connection.current.state === "connecting") {
886
- updateConnection(_chunkRS4TQ2LTjs.__spreadProps.call(void 0, _chunkRS4TQ2LTjs.__spreadValues.call(void 0, {}, state.connection.current), { state: "open" }));
889
+ updateConnection(_chunkUV2F4F4Rjs.__spreadProps.call(void 0, _chunkUV2F4F4Rjs.__spreadValues.call(void 0, {}, state.connection.current), { state: "open" }));
887
890
  state.numberOfRetry = 0;
888
891
  if (state.lastConnectionId !== void 0) {
889
892
  state.buffer.me = {
@@ -901,7 +904,7 @@ function makeStateMachine(state, config, mockedEffects) {
901
904
  }
902
905
  }
903
906
  function heartbeat() {
904
- if (state.socket == null) {
907
+ if (state.socket === null) {
905
908
  return;
906
909
  }
907
910
  clearTimeout(state.timeoutHandles.pongTimeout);
@@ -950,10 +953,10 @@ function makeStateMachine(state, config, mockedEffects) {
950
953
  const storageOps = state.buffer.storageOperations;
951
954
  if (storageOps.length > 0) {
952
955
  storageOps.forEach((op) => {
953
- state.offlineOperations.set(_chunkRS4TQ2LTjs.nn.call(void 0, op.opId), op);
956
+ state.offlineOperations.set(_chunkUV2F4F4Rjs.nn.call(void 0, op.opId), op);
954
957
  });
955
958
  }
956
- if (state.socket == null || state.socket.readyState !== state.socket.OPEN) {
959
+ if (state.socket === null || state.socket.readyState !== state.socket.OPEN) {
957
960
  state.buffer.storageOperations = [];
958
961
  return;
959
962
  }
@@ -972,7 +975,7 @@ function makeStateMachine(state, config, mockedEffects) {
972
975
  };
973
976
  state.lastFlushTime = now;
974
977
  } else {
975
- if (state.timeoutHandles.flush != null) {
978
+ if (state.timeoutHandles.flush !== null) {
976
979
  clearTimeout(state.timeoutHandles.flush);
977
980
  }
978
981
  state.timeoutHandles.flush = effects.delayFlush(
@@ -1034,7 +1037,7 @@ function makeStateMachine(state, config, mockedEffects) {
1034
1037
  function broadcastEvent(event, options = {
1035
1038
  shouldQueueEventIfNotReady: false
1036
1039
  }) {
1037
- if (state.socket == null && options.shouldQueueEventIfNotReady == false) {
1040
+ if (state.socket === null && !options.shouldQueueEventIfNotReady) {
1038
1041
  return;
1039
1042
  }
1040
1043
  state.buffer.messages.push({
@@ -1050,7 +1053,7 @@ function makeStateMachine(state, config, mockedEffects) {
1050
1053
  let _getInitialStatePromise = null;
1051
1054
  let _getInitialStateResolver = null;
1052
1055
  function startLoadingStorage() {
1053
- if (_getInitialStatePromise == null) {
1056
+ if (_getInitialStatePromise === null) {
1054
1057
  state.buffer.messages.push({ type: 200 /* FETCH_STORAGE */ });
1055
1058
  tryFlushing();
1056
1059
  _getInitialStatePromise = new Promise(
@@ -1069,7 +1072,7 @@ function makeStateMachine(state, config, mockedEffects) {
1069
1072
  }
1070
1073
  }
1071
1074
  function getStorage() {
1072
- return _chunkRS4TQ2LTjs.__async.call(void 0, this, null, function* () {
1075
+ return _chunkUV2F4F4Rjs.__async.call(void 0, this, null, function* () {
1073
1076
  if (state.root) {
1074
1077
  return Promise.resolve({
1075
1078
  root: state.root
@@ -1077,7 +1080,7 @@ function makeStateMachine(state, config, mockedEffects) {
1077
1080
  }
1078
1081
  yield startLoadingStorage();
1079
1082
  return {
1080
- root: _chunkRS4TQ2LTjs.nn.call(void 0, state.root)
1083
+ root: _chunkUV2F4F4Rjs.nn.call(void 0, state.root)
1081
1084
  };
1082
1085
  });
1083
1086
  }
@@ -1085,16 +1088,16 @@ function makeStateMachine(state, config, mockedEffects) {
1085
1088
  if (state.activeBatch) {
1086
1089
  throw new Error("undo is not allowed during a batch");
1087
1090
  }
1088
- const historyItem = state.undoStack.pop();
1089
- if (historyItem == null) {
1091
+ const historyOps = state.undoStack.pop();
1092
+ if (historyOps === void 0) {
1090
1093
  return;
1091
1094
  }
1092
- state.isHistoryPaused = false;
1093
- const result = apply(historyItem, true);
1095
+ state.pausedHistory = null;
1096
+ const result = apply(historyOps, true);
1094
1097
  notify(result.updates);
1095
1098
  state.redoStack.push(result.reverse);
1096
1099
  onHistoryChange();
1097
- for (const op of historyItem) {
1100
+ for (const op of historyOps) {
1098
1101
  if (op.type !== "presence") {
1099
1102
  state.buffer.storageOperations.push(op);
1100
1103
  }
@@ -1108,16 +1111,16 @@ function makeStateMachine(state, config, mockedEffects) {
1108
1111
  if (state.activeBatch) {
1109
1112
  throw new Error("redo is not allowed during a batch");
1110
1113
  }
1111
- const historyItem = state.redoStack.pop();
1112
- if (historyItem == null) {
1114
+ const historyOps = state.redoStack.pop();
1115
+ if (historyOps === void 0) {
1113
1116
  return;
1114
1117
  }
1115
- state.isHistoryPaused = false;
1116
- const result = apply(historyItem, true);
1118
+ state.pausedHistory = null;
1119
+ const result = apply(historyOps, true);
1117
1120
  notify(result.updates);
1118
1121
  state.undoStack.push(result.reverse);
1119
1122
  onHistoryChange();
1120
- for (const op of historyItem) {
1123
+ for (const op of historyOps) {
1121
1124
  if (op.type !== "presence") {
1122
1125
  state.buffer.storageOperations.push(op);
1123
1126
  }
@@ -1160,14 +1163,13 @@ function makeStateMachine(state, config, mockedEffects) {
1160
1163
  }
1161
1164
  function pauseHistory() {
1162
1165
  state.pausedHistory = [];
1163
- state.isHistoryPaused = true;
1164
1166
  }
1165
1167
  function resumeHistory() {
1166
- state.isHistoryPaused = false;
1167
- if (state.pausedHistory.length > 0) {
1168
- addToUndoStack(state.pausedHistory);
1168
+ const historyOps = state.pausedHistory;
1169
+ state.pausedHistory = null;
1170
+ if (historyOps !== null && historyOps.length > 0) {
1171
+ _addToRealUndoStack(historyOps);
1169
1172
  }
1170
- state.pausedHistory = [];
1171
1173
  }
1172
1174
  function simulateSocketClose() {
1173
1175
  if (state.socket) {
@@ -1247,7 +1249,7 @@ function defaultState(initialPresence, initialStorage) {
1247
1249
  connection,
1248
1250
  me: new MeRef(initialPresence),
1249
1251
  others,
1250
- defaultStorageRoot: initialStorage,
1252
+ initialStorage,
1251
1253
  idFactory: null,
1252
1254
  clock: 0,
1253
1255
  opClock: 0,
@@ -1255,8 +1257,7 @@ function defaultState(initialPresence, initialStorage) {
1255
1257
  root: void 0,
1256
1258
  undoStack: [],
1257
1259
  redoStack: [],
1258
- isHistoryPaused: false,
1259
- pausedHistory: [],
1260
+ pausedHistory: null,
1260
1261
  activeBatch: null,
1261
1262
  offlineOperations: /* @__PURE__ */ new Map()
1262
1263
  };
@@ -1313,7 +1314,7 @@ var LiveblocksError = class extends Error {
1313
1314
  }
1314
1315
  };
1315
1316
  function prepareCreateWebSocket(liveblocksServer, WebSocketPolyfill) {
1316
- if (typeof window === "undefined" && WebSocketPolyfill == null) {
1317
+ if (typeof window === "undefined" && WebSocketPolyfill === void 0) {
1317
1318
  throw new Error(
1318
1319
  "To use Liveblocks client in a non-dom environment, you need to provide a WebSocket polyfill."
1319
1320
  );
@@ -1321,13 +1322,13 @@ function prepareCreateWebSocket(liveblocksServer, WebSocketPolyfill) {
1321
1322
  const ws = WebSocketPolyfill || WebSocket;
1322
1323
  return (token) => {
1323
1324
  return new ws(
1324
- `${liveblocksServer}/?token=${token}&version=${true ? "0.18.0-beta2" : "dev"}`
1325
+ `${liveblocksServer}/?token=${token}&version=${true ? "0.18.0-beta3" : "dev"}`
1325
1326
  );
1326
1327
  };
1327
1328
  }
1328
1329
  function prepareAuthEndpoint(authentication, fetchPolyfill) {
1329
1330
  if (authentication.type === "public") {
1330
- if (typeof window === "undefined" && fetchPolyfill == null) {
1331
+ if (typeof window === "undefined" && fetchPolyfill === void 0) {
1331
1332
  throw new Error(
1332
1333
  "To use Liveblocks client in a non-dom environment with a publicApiKey, you need to provide a fetch polyfill."
1333
1334
  );
@@ -1338,7 +1339,7 @@ function prepareAuthEndpoint(authentication, fetchPolyfill) {
1338
1339
  });
1339
1340
  }
1340
1341
  if (authentication.type === "private") {
1341
- if (typeof window === "undefined" && fetchPolyfill == null) {
1342
+ if (typeof window === "undefined" && fetchPolyfill === void 0) {
1342
1343
  throw new Error(
1343
1344
  "To use Liveblocks client in a non-dom environment with a url as auth endpoint, you need to provide a fetch polyfill."
1344
1345
  );
@@ -1348,7 +1349,7 @@ function prepareAuthEndpoint(authentication, fetchPolyfill) {
1348
1349
  });
1349
1350
  }
1350
1351
  if (authentication.type === "custom") {
1351
- return (room) => _chunkRS4TQ2LTjs.__async.call(void 0, this, null, function* () {
1352
+ return (room) => _chunkUV2F4F4Rjs.__async.call(void 0, this, null, function* () {
1352
1353
  const response = yield authentication.callback(room);
1353
1354
  if (!response || !response.token) {
1354
1355
  throw new Error(
@@ -1361,7 +1362,7 @@ function prepareAuthEndpoint(authentication, fetchPolyfill) {
1361
1362
  throw new Error("Internal error. Unexpected authentication type");
1362
1363
  }
1363
1364
  function fetchAuthEndpoint(fetch2, endpoint, body) {
1364
- return _chunkRS4TQ2LTjs.__async.call(void 0, this, null, function* () {
1365
+ return _chunkUV2F4F4Rjs.__async.call(void 0, this, null, function* () {
1365
1366
  const res = yield fetch2(endpoint, {
1366
1367
  method: "POST",
1367
1368
  headers: {
@@ -1382,7 +1383,7 @@ function fetchAuthEndpoint(fetch2, endpoint, body) {
1382
1383
  `Expected a JSON response when doing a POST request on "${endpoint}". ${er}`
1383
1384
  );
1384
1385
  }
1385
- if (!_chunkRS4TQ2LTjs.isPlainObject.call(void 0, data) || typeof data.token !== "string") {
1386
+ if (!_chunkUV2F4F4Rjs.isPlainObject.call(void 0, data) || typeof data.token !== "string") {
1386
1387
  throw new AuthenticationError(
1387
1388
  `Expected a JSON response of the form \`{ token: "..." }\` when doing a POST request on "${endpoint}", but got ${JSON.stringify(
1388
1389
  data
@@ -1414,8 +1415,8 @@ function createClient(options) {
1414
1415
  if (internalRoom) {
1415
1416
  return internalRoom.room;
1416
1417
  }
1417
- _chunkRS4TQ2LTjs.deprecateIf.call(void 0,
1418
- options2.initialPresence == null,
1418
+ _chunkUV2F4F4Rjs.deprecateIf.call(void 0,
1419
+ options2.initialPresence === null || options2.initialPresence === void 0,
1419
1420
  "Please provide an initial presence value for the current user when entering the room."
1420
1421
  );
1421
1422
  internalRoom = createRoom(
@@ -1438,8 +1439,8 @@ function createClient(options) {
1438
1439
  internalRoom
1439
1440
  );
1440
1441
  if (!options2.DO_NOT_USE_withoutConnecting) {
1441
- if (typeof atob == "undefined") {
1442
- if (((_b = clientOptions.polyfills) == null ? void 0 : _b.atob) == void 0) {
1442
+ if (typeof atob === "undefined") {
1443
+ if (((_b = clientOptions.polyfills) == null ? void 0 : _b.atob) === void 0) {
1443
1444
  throw new Error(
1444
1445
  "You need to polyfill atob to use the client in your environment. Please follow the instructions at https://liveblocks.io/docs/errors/liveblocks-client/atob-polyfill"
1445
1446
  );
@@ -1581,4 +1582,4 @@ function shallow(a, b) {
1581
1582
 
1582
1583
 
1583
1584
 
1584
- exports.LiveList = _chunkRS4TQ2LTjs.LiveList; exports.LiveMap = _chunkRS4TQ2LTjs.LiveMap; exports.LiveObject = _chunkRS4TQ2LTjs.LiveObject; exports.createClient = createClient; exports.shallow = shallow;
1585
+ exports.LiveList = _chunkUV2F4F4Rjs.LiveList; exports.LiveMap = _chunkUV2F4F4Rjs.LiveMap; exports.LiveObject = _chunkUV2F4F4Rjs.LiveObject; exports.createClient = createClient; exports.shallow = shallow;
package/internal.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { i as JsonObject, J as Json, B as BaseUserMeta, k as Lson, l as LsonObject, c as LiveObject, S as StorageUpdate } from './index-60aa9677.js';
2
- export { n as LiveNode, o as Resolve, p as RoomInitializers, q as ToImmutable, T as ToJson, W as WebsocketCloseCodes, m as asArrayWithLegacyMethods, r as isJsonArray, s as isJsonObject, t as isJsonScalar } from './index-60aa9677.js';
1
+ import { i as JsonObject, J as Json, B as BaseUserMeta, k as Lson, l as LsonObject, c as LiveObject, S as StorageUpdate } from './index-29762efc.js';
2
+ export { n as LiveNode, o as Resolve, p as RoomInitializers, q as ToImmutable, T as ToJson, W as WebsocketCloseCodes, m as asArrayWithLegacyMethods, r as isJsonArray, s as isJsonObject, t as isJsonScalar } from './index-29762efc.js';
3
3
 
4
4
  declare enum OpCode {
5
5
  INIT = 0,
package/internal.js CHANGED
@@ -35,7 +35,7 @@
35
35
 
36
36
 
37
37
 
38
- var _chunkRS4TQ2LTjs = require('./chunk-RS4TQ2LT.js');
38
+ var _chunkUV2F4F4Rjs = require('./chunk-UV2F4F4R.js');
39
39
 
40
40
  // src/immutable.ts
41
41
  function lsonObjectToJson(obj) {
@@ -65,26 +65,26 @@ function liveListToJson(value) {
65
65
  return lsonListToJson(value.toArray());
66
66
  }
67
67
  function lsonToJson(value) {
68
- if (value instanceof _chunkRS4TQ2LTjs.LiveObject) {
68
+ if (value instanceof _chunkUV2F4F4Rjs.LiveObject) {
69
69
  return liveObjectToJson(value);
70
- } else if (value instanceof _chunkRS4TQ2LTjs.LiveList) {
70
+ } else if (value instanceof _chunkUV2F4F4Rjs.LiveList) {
71
71
  return liveListToJson(value);
72
- } else if (value instanceof _chunkRS4TQ2LTjs.LiveMap) {
72
+ } else if (value instanceof _chunkUV2F4F4Rjs.LiveMap) {
73
73
  return liveMapToJson(value);
74
- } else if (value instanceof _chunkRS4TQ2LTjs.LiveRegister) {
74
+ } else if (value instanceof _chunkUV2F4F4Rjs.LiveRegister) {
75
75
  return value.data;
76
76
  }
77
77
  if (Array.isArray(value)) {
78
78
  return lsonListToJson(value);
79
- } else if (_chunkRS4TQ2LTjs.isPlainObject.call(void 0, value)) {
79
+ } else if (_chunkUV2F4F4Rjs.isPlainObject.call(void 0, value)) {
80
80
  return lsonObjectToJson(value);
81
81
  }
82
82
  return value;
83
83
  }
84
84
  function deepLiveify(value) {
85
85
  if (Array.isArray(value)) {
86
- return new (0, _chunkRS4TQ2LTjs.LiveList)(value.map(deepLiveify));
87
- } else if (_chunkRS4TQ2LTjs.isPlainObject.call(void 0, value)) {
86
+ return new (0, _chunkUV2F4F4Rjs.LiveList)(value.map(deepLiveify));
87
+ } else if (_chunkUV2F4F4Rjs.isPlainObject.call(void 0, value)) {
88
88
  const init = {};
89
89
  for (const key in value) {
90
90
  const val = value[key];
@@ -93,7 +93,7 @@ function deepLiveify(value) {
93
93
  }
94
94
  init[key] = deepLiveify(val);
95
95
  }
96
- return new (0, _chunkRS4TQ2LTjs.LiveObject)(init);
96
+ return new (0, _chunkUV2F4F4Rjs.LiveObject)(init);
97
97
  } else {
98
98
  return value;
99
99
  }
@@ -143,7 +143,7 @@ function patchLiveList(liveList, prev, next) {
143
143
  prevNode = prev[i];
144
144
  nextNode = next[i];
145
145
  const liveListNode = liveList.get(i);
146
- if (_chunkRS4TQ2LTjs.isLiveObject.call(void 0, liveListNode) && _chunkRS4TQ2LTjs.isPlainObject.call(void 0, prevNode) && _chunkRS4TQ2LTjs.isPlainObject.call(void 0, nextNode)) {
146
+ if (_chunkUV2F4F4Rjs.isLiveObject.call(void 0, liveListNode) && _chunkUV2F4F4Rjs.isPlainObject.call(void 0, prevNode) && _chunkUV2F4F4Rjs.isPlainObject.call(void 0, nextNode)) {
147
147
  patchLiveObject(liveListNode, prevNode, nextNode);
148
148
  } else {
149
149
  liveList.set(i, deepLiveify(nextNode));
@@ -163,7 +163,7 @@ function patchLiveList(liveList, prev, next) {
163
163
  }
164
164
  function patchLiveObjectKey(liveObject, key, prev, next) {
165
165
  if (process.env.NODE_ENV !== "production") {
166
- const nonSerializableValue = _chunkRS4TQ2LTjs.findNonSerializableValue.call(void 0, next);
166
+ const nonSerializableValue = _chunkUV2F4F4Rjs.findNonSerializableValue.call(void 0, next);
167
167
  if (nonSerializableValue) {
168
168
  console.error(
169
169
  `New state path: '${nonSerializableValue.path}' value: '${nonSerializableValue.value}' is not serializable.
@@ -179,9 +179,9 @@ Only serializable value can be synced with Liveblocks.`
179
179
  liveObject.set(key, deepLiveify(next));
180
180
  } else if (prev === next) {
181
181
  return;
182
- } else if (_chunkRS4TQ2LTjs.isLiveList.call(void 0, value) && Array.isArray(prev) && Array.isArray(next)) {
182
+ } else if (_chunkUV2F4F4Rjs.isLiveList.call(void 0, value) && Array.isArray(prev) && Array.isArray(next)) {
183
183
  patchLiveList(value, prev, next);
184
- } else if (_chunkRS4TQ2LTjs.isLiveObject.call(void 0, value) && _chunkRS4TQ2LTjs.isPlainObject.call(void 0, prev) && _chunkRS4TQ2LTjs.isPlainObject.call(void 0, next)) {
184
+ } else if (_chunkUV2F4F4Rjs.isLiveObject.call(void 0, value) && _chunkUV2F4F4Rjs.isPlainObject.call(void 0, prev) && _chunkUV2F4F4Rjs.isPlainObject.call(void 0, next)) {
185
185
  patchLiveObject(value, prev, next);
186
186
  } else {
187
187
  liveObject.set(key, deepLiveify(next));
@@ -204,7 +204,7 @@ function patchLiveObject(root, prev, next) {
204
204
  function getParentsPath(node) {
205
205
  const path = [];
206
206
  while (node.parent.type === "HasParent") {
207
- if (_chunkRS4TQ2LTjs.isLiveList.call(void 0, node.parent.node)) {
207
+ if (_chunkUV2F4F4Rjs.isLiveList.call(void 0, node.parent.node)) {
208
208
  path.push(node.parent.node._indexOfPosition(node.parent.key));
209
209
  } else {
210
210
  path.push(node.parent.key);
@@ -328,7 +328,7 @@ function legacy_patchImmutableNode(state, path, update) {
328
328
  if (node === void 0) {
329
329
  return state;
330
330
  } else {
331
- return _chunkRS4TQ2LTjs.__spreadProps.call(void 0, _chunkRS4TQ2LTjs.__spreadValues.call(void 0, {}, state), {
331
+ return _chunkUV2F4F4Rjs.__spreadProps.call(void 0, _chunkUV2F4F4Rjs.__spreadValues.call(void 0, {}, state), {
332
332
  [pathItem]: legacy_patchImmutableNode(node, path, update)
333
333
  });
334
334
  }
@@ -367,4 +367,4 @@ function legacy_patchImmutableNode(state, path, update) {
367
367
 
368
368
 
369
369
 
370
- exports.ClientMsgCode = _chunkRS4TQ2LTjs.ClientMsgCode; exports.CrdtType = _chunkRS4TQ2LTjs.CrdtType; exports.OpCode = _chunkRS4TQ2LTjs.OpCode; exports.ServerMsgCode = _chunkRS4TQ2LTjs.ServerMsgCode; exports.WebsocketCloseCodes = _chunkRS4TQ2LTjs.WebsocketCloseCodes; exports.asArrayWithLegacyMethods = _chunkRS4TQ2LTjs.asArrayWithLegacyMethods; exports.assertNever = _chunkRS4TQ2LTjs.assertNever; exports.b64decode = _chunkRS4TQ2LTjs.b64decode; exports.comparePosition = _chunkRS4TQ2LTjs.comparePosition; exports.deprecate = _chunkRS4TQ2LTjs.deprecate; exports.deprecateIf = _chunkRS4TQ2LTjs.deprecateIf; exports.errorIf = _chunkRS4TQ2LTjs.errorIf; exports.freeze = _chunkRS4TQ2LTjs.freeze; exports.isAppOnlyAuthToken = _chunkRS4TQ2LTjs.isAppOnlyAuthToken; exports.isAuthToken = _chunkRS4TQ2LTjs.isAuthToken; exports.isChildCrdt = _chunkRS4TQ2LTjs.isChildCrdt; exports.isJsonArray = _chunkRS4TQ2LTjs.isJsonArray; exports.isJsonObject = _chunkRS4TQ2LTjs.isJsonObject; exports.isJsonScalar = _chunkRS4TQ2LTjs.isJsonScalar; exports.isPlainObject = _chunkRS4TQ2LTjs.isPlainObject; exports.isRoomAuthToken = _chunkRS4TQ2LTjs.isRoomAuthToken; exports.isRootCrdt = _chunkRS4TQ2LTjs.isRootCrdt; exports.isScope = _chunkRS4TQ2LTjs.isScope; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makePosition = _chunkRS4TQ2LTjs.makePosition; exports.nn = _chunkRS4TQ2LTjs.nn; exports.patchLiveObjectKey = patchLiveObjectKey; exports.throwUsageError = _chunkRS4TQ2LTjs.throwUsageError; exports.tryParseJson = _chunkRS4TQ2LTjs.tryParseJson;
370
+ exports.ClientMsgCode = _chunkUV2F4F4Rjs.ClientMsgCode; exports.CrdtType = _chunkUV2F4F4Rjs.CrdtType; exports.OpCode = _chunkUV2F4F4Rjs.OpCode; exports.ServerMsgCode = _chunkUV2F4F4Rjs.ServerMsgCode; exports.WebsocketCloseCodes = _chunkUV2F4F4Rjs.WebsocketCloseCodes; exports.asArrayWithLegacyMethods = _chunkUV2F4F4Rjs.asArrayWithLegacyMethods; exports.assertNever = _chunkUV2F4F4Rjs.assertNever; exports.b64decode = _chunkUV2F4F4Rjs.b64decode; exports.comparePosition = _chunkUV2F4F4Rjs.comparePosition; exports.deprecate = _chunkUV2F4F4Rjs.deprecate; exports.deprecateIf = _chunkUV2F4F4Rjs.deprecateIf; exports.errorIf = _chunkUV2F4F4Rjs.errorIf; exports.freeze = _chunkUV2F4F4Rjs.freeze; exports.isAppOnlyAuthToken = _chunkUV2F4F4Rjs.isAppOnlyAuthToken; exports.isAuthToken = _chunkUV2F4F4Rjs.isAuthToken; exports.isChildCrdt = _chunkUV2F4F4Rjs.isChildCrdt; exports.isJsonArray = _chunkUV2F4F4Rjs.isJsonArray; exports.isJsonObject = _chunkUV2F4F4Rjs.isJsonObject; exports.isJsonScalar = _chunkUV2F4F4Rjs.isJsonScalar; exports.isPlainObject = _chunkUV2F4F4Rjs.isPlainObject; exports.isRoomAuthToken = _chunkUV2F4F4Rjs.isRoomAuthToken; exports.isRootCrdt = _chunkUV2F4F4Rjs.isRootCrdt; exports.isScope = _chunkUV2F4F4Rjs.isScope; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makePosition = _chunkUV2F4F4Rjs.makePosition; exports.nn = _chunkUV2F4F4Rjs.nn; exports.patchLiveObjectKey = patchLiveObjectKey; exports.throwUsageError = _chunkUV2F4F4Rjs.throwUsageError; exports.tryParseJson = _chunkUV2F4F4Rjs.tryParseJson;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveblocks/client",
3
- "version": "0.18.0-beta2",
3
+ "version": "0.18.0-beta3",
4
4
  "description": "A client that lets you interact with Liveblocks servers.",
5
5
  "main": "./index.js",
6
6
  "module": "./index.mjs",