@liveblocks/client 0.17.11 → 0.18.0-beta0

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.js CHANGED
@@ -49,6 +49,20 @@ function _construct(Parent, args, Class) {
49
49
  }
50
50
  return _construct.apply(null, arguments);
51
51
  }
52
+ function _defineProperties(target, props) {
53
+ for(var i = 0; i < props.length; i++){
54
+ var descriptor = props[i];
55
+ descriptor.enumerable = descriptor.enumerable || false;
56
+ descriptor.configurable = true;
57
+ if ("value" in descriptor) descriptor.writable = true;
58
+ Object.defineProperty(target, descriptor.key, descriptor);
59
+ }
60
+ }
61
+ function _createClass(Constructor, protoProps, staticProps) {
62
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
63
+ if (staticProps) _defineProperties(Constructor, staticProps);
64
+ return Constructor;
65
+ }
52
66
  function _defineProperty(obj, key, value) {
53
67
  if (key in obj) {
54
68
  Object.defineProperty(obj, key, {
@@ -163,33 +177,6 @@ function _objectSpreadProps(target, source) {
163
177
  }
164
178
  return target;
165
179
  }
166
- function _objectWithoutProperties(source, excluded) {
167
- if (source == null) return {};
168
- var target = _objectWithoutPropertiesLoose(source, excluded);
169
- var key, i;
170
- if (Object.getOwnPropertySymbols) {
171
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
172
- for(i = 0; i < sourceSymbolKeys.length; i++){
173
- key = sourceSymbolKeys[i];
174
- if (excluded.indexOf(key) >= 0) continue;
175
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
176
- target[key] = source[key];
177
- }
178
- }
179
- return target;
180
- }
181
- function _objectWithoutPropertiesLoose(source, excluded) {
182
- if (source == null) return {};
183
- var target = {};
184
- var sourceKeys = Object.keys(source);
185
- var key, i;
186
- for(i = 0; i < sourceKeys.length; i++){
187
- key = sourceKeys[i];
188
- if (excluded.indexOf(key) >= 0) continue;
189
- target[key] = source[key];
190
- }
191
- return target;
192
- }
193
180
  function _possibleConstructorReturn(self, call) {
194
181
  if (call && (_typeof(call) === "object" || typeof call === "function")) {
195
182
  return call;
@@ -310,7 +297,314 @@ function _optionalChain(ops) {
310
297
  }
311
298
  return value;
312
299
  }
313
- var _chunkQLMVHHAZjs = require("./chunk-QLMVHHAZ.js");
300
+ var _chunkZR7CHFN6js = require("./chunk-ZR7CHFN6.js");
301
+ // src/EventSource.ts
302
+ function makeEventSource() {
303
+ var subscribe = function subscribe(callback) {
304
+ _observers.add(callback);
305
+ return function() {
306
+ return _observers.delete(callback);
307
+ };
308
+ };
309
+ var subscribeOnce = function subscribeOnce(callback) {
310
+ _onetimeObservers.add(callback);
311
+ return function() {
312
+ return _onetimeObservers.delete(callback);
313
+ };
314
+ };
315
+ var notify = function notify(event) {
316
+ _onetimeObservers.forEach(function(callback) {
317
+ return callback(event);
318
+ });
319
+ _onetimeObservers.clear();
320
+ _observers.forEach(function(callback) {
321
+ return callback(event);
322
+ });
323
+ };
324
+ var clear = function clear() {
325
+ _onetimeObservers.clear();
326
+ _observers.clear();
327
+ };
328
+ var _onetimeObservers = /* @__PURE__ */ new Set();
329
+ var _observers = /* @__PURE__ */ new Set();
330
+ return {
331
+ notify: notify,
332
+ subscribe: subscribe,
333
+ subscribeOnce: subscribeOnce,
334
+ clear: clear,
335
+ observable: {
336
+ subscribe: subscribe,
337
+ subscribeOnce: subscribeOnce
338
+ }
339
+ };
340
+ }
341
+ // src/ImmutableRef.ts
342
+ function merge(target, patch) {
343
+ var updated = false;
344
+ var newValue = _objectSpread({}, target);
345
+ Object.keys(patch).forEach(function(k) {
346
+ var key = k;
347
+ var val = patch[key];
348
+ if (newValue[key] !== val) {
349
+ if (val === void 0) {
350
+ delete newValue[key];
351
+ } else {
352
+ newValue[key] = val;
353
+ }
354
+ updated = true;
355
+ }
356
+ });
357
+ return updated ? newValue : target;
358
+ }
359
+ var ImmutableRef = /*#__PURE__*/ function() {
360
+ function ImmutableRef() {
361
+ _classCallCheck(this, ImmutableRef);
362
+ this._ev = makeEventSource();
363
+ }
364
+ _createClass(ImmutableRef, [
365
+ {
366
+ key: "didInvalidate",
367
+ get: function get() {
368
+ return this._ev.observable;
369
+ }
370
+ },
371
+ {
372
+ key: "invalidate",
373
+ value: function invalidate() {
374
+ if (this._cache !== void 0) {
375
+ this._cache = void 0;
376
+ this._ev.notify();
377
+ }
378
+ }
379
+ },
380
+ {
381
+ key: "current",
382
+ get: function get() {
383
+ var _this = this;
384
+ return _nullishCoalesce(this._cache, function() {
385
+ return _this._cache = _this._toImmutable();
386
+ });
387
+ }
388
+ }
389
+ ]);
390
+ return ImmutableRef;
391
+ }();
392
+ // src/MeRef.ts
393
+ var MeRef = /*#__PURE__*/ function(ImmutableRef) {
394
+ _inherits(MeRef, ImmutableRef);
395
+ var _super = _createSuper(MeRef);
396
+ function MeRef(initialPresence) {
397
+ _classCallCheck(this, MeRef);
398
+ var _this;
399
+ _this = _super.call(this);
400
+ _this._me = _chunkZR7CHFN6js.freeze.call(void 0, _chunkZR7CHFN6js.compactObject.call(void 0, initialPresence));
401
+ return _this;
402
+ }
403
+ _createClass(MeRef, [
404
+ {
405
+ key: "_toImmutable",
406
+ value: function _toImmutable() {
407
+ return this._me;
408
+ }
409
+ },
410
+ {
411
+ key: "patch",
412
+ value: function patch(patch1) {
413
+ var oldMe = this._me;
414
+ var newMe = merge(oldMe, patch1);
415
+ if (oldMe !== newMe) {
416
+ this._me = _chunkZR7CHFN6js.freeze.call(void 0, newMe);
417
+ this.invalidate();
418
+ }
419
+ }
420
+ }
421
+ ]);
422
+ return MeRef;
423
+ }(ImmutableRef);
424
+ // src/OthersRef.ts
425
+ function makeUser(conn, presence) {
426
+ return _chunkZR7CHFN6js.freeze.call(void 0, _chunkZR7CHFN6js.compactObject.call(void 0, _objectSpreadProps(_objectSpread({}, conn), {
427
+ presence: presence
428
+ })));
429
+ }
430
+ var OthersRef = /*#__PURE__*/ function(ImmutableRef) {
431
+ _inherits(OthersRef, ImmutableRef);
432
+ var _super = _createSuper(OthersRef);
433
+ function OthersRef() {
434
+ _classCallCheck(this, OthersRef);
435
+ var _this;
436
+ _this = _super.call(this);
437
+ _this._connections = {};
438
+ _this._presences = {};
439
+ _this._users = {};
440
+ return _this;
441
+ }
442
+ _createClass(OthersRef, [
443
+ {
444
+ key: "_toImmutable",
445
+ value: function _toImmutable() {
446
+ var _this = this;
447
+ var users = _chunkZR7CHFN6js.compact.call(void 0, Object.keys(this._presences).map(function(connectionId) {
448
+ return _this.getUser(Number(connectionId));
449
+ }));
450
+ Object.defineProperty(users, "count", {
451
+ value: users.length,
452
+ enumerable: false
453
+ });
454
+ Object.defineProperty(users, "toArray", {
455
+ value: function() {
456
+ return users;
457
+ },
458
+ enumerable: false
459
+ });
460
+ return _chunkZR7CHFN6js.freeze.call(void 0, users);
461
+ }
462
+ },
463
+ {
464
+ key: "clearOthers",
465
+ value: function clearOthers() {
466
+ this._connections = {};
467
+ this._presences = {};
468
+ this._users = {};
469
+ this.invalidate();
470
+ }
471
+ },
472
+ {
473
+ key: "_getUser",
474
+ value: function _getUser(connectionId) {
475
+ var conn = this._connections[connectionId];
476
+ var presence = this._presences[connectionId];
477
+ if (conn !== void 0 && presence !== void 0) {
478
+ return makeUser(conn, presence);
479
+ }
480
+ return void 0;
481
+ }
482
+ },
483
+ {
484
+ key: "getUser",
485
+ value: function getUser(connectionId) {
486
+ var cachedUser = this._users[connectionId];
487
+ if (cachedUser) {
488
+ return cachedUser;
489
+ }
490
+ var computedUser = this._getUser(connectionId);
491
+ if (computedUser) {
492
+ this._users[connectionId] = computedUser;
493
+ return computedUser;
494
+ }
495
+ return void 0;
496
+ }
497
+ },
498
+ {
499
+ key: "_invalidateUser",
500
+ value: function _invalidateUser(connectionId) {
501
+ if (this._users[connectionId] !== void 0) {
502
+ delete this._users[connectionId];
503
+ }
504
+ this.invalidate();
505
+ }
506
+ },
507
+ {
508
+ key: "setConnection",
509
+ value: function setConnection(connectionId, metaUserId, metaUserInfo) {
510
+ this._connections[connectionId] = _chunkZR7CHFN6js.freeze.call(void 0, {
511
+ connectionId: connectionId,
512
+ id: metaUserId,
513
+ info: metaUserInfo
514
+ });
515
+ if (this._presences[connectionId] !== void 0) {
516
+ this._invalidateUser(connectionId);
517
+ }
518
+ }
519
+ },
520
+ {
521
+ key: "removeConnection",
522
+ value: function removeConnection(connectionId) {
523
+ delete this._connections[connectionId];
524
+ delete this._presences[connectionId];
525
+ this._invalidateUser(connectionId);
526
+ }
527
+ },
528
+ {
529
+ key: "setOther",
530
+ value: function setOther(connectionId, presence) {
531
+ this._presences[connectionId] = _chunkZR7CHFN6js.freeze.call(void 0, _chunkZR7CHFN6js.compactObject.call(void 0, presence));
532
+ if (this._connections[connectionId] !== void 0) {
533
+ this._invalidateUser(connectionId);
534
+ }
535
+ }
536
+ },
537
+ {
538
+ key: "patchOther",
539
+ value: function patchOther(connectionId, patch) {
540
+ var oldPresence = this._presences[connectionId];
541
+ if (oldPresence === void 0) {
542
+ return;
543
+ }
544
+ var newPresence = merge(oldPresence, patch);
545
+ if (oldPresence !== newPresence) {
546
+ this._presences[connectionId] = _chunkZR7CHFN6js.freeze.call(void 0, newPresence);
547
+ this._invalidateUser(connectionId);
548
+ }
549
+ }
550
+ }
551
+ ]);
552
+ return OthersRef;
553
+ }(ImmutableRef);
554
+ // src/ValueRef.ts
555
+ var ValueRef = /*#__PURE__*/ function(ImmutableRef) {
556
+ _inherits(ValueRef, ImmutableRef);
557
+ var _super = _createSuper(ValueRef);
558
+ function ValueRef(initialValue) {
559
+ _classCallCheck(this, ValueRef);
560
+ var _this;
561
+ _this = _super.call(this);
562
+ _this._value = _chunkZR7CHFN6js.freeze.call(void 0, _chunkZR7CHFN6js.compactObject.call(void 0, initialValue));
563
+ return _this;
564
+ }
565
+ _createClass(ValueRef, [
566
+ {
567
+ key: "_toImmutable",
568
+ value: function _toImmutable() {
569
+ return this._value;
570
+ }
571
+ },
572
+ {
573
+ key: "set",
574
+ value: function set(newValue) {
575
+ this._value = _chunkZR7CHFN6js.freeze.call(void 0, newValue);
576
+ this.invalidate();
577
+ }
578
+ }
579
+ ]);
580
+ return ValueRef;
581
+ }(ImmutableRef);
582
+ var DerivedRef = /*#__PURE__*/ function(ImmutableRef) {
583
+ _inherits(DerivedRef, ImmutableRef);
584
+ var _super = _createSuper(DerivedRef);
585
+ function DerivedRef(otherRefs, transformFn) {
586
+ _classCallCheck(this, DerivedRef);
587
+ var _this;
588
+ _this = _super.call(this);
589
+ _this._refs = otherRefs;
590
+ _this._refs.forEach(function(ref) {
591
+ ref.didInvalidate.subscribe(function() {
592
+ return _this.invalidate();
593
+ });
594
+ });
595
+ _this._transform = transformFn;
596
+ return _this;
597
+ }
598
+ _createClass(DerivedRef, [
599
+ {
600
+ key: "_toImmutable",
601
+ value: function _toImmutable() {
602
+ return this._transform(this._refs[0].current, this._refs[1].current);
603
+ }
604
+ }
605
+ ]);
606
+ return DerivedRef;
607
+ }(ImmutableRef);
314
608
  // src/room.ts
315
609
  var BACKOFF_RETRY_DELAYS = [
316
610
  250,
@@ -335,75 +629,16 @@ function makeIdFactory(connectionId) {
335
629
  return "".concat(connectionId, ":").concat(count++);
336
630
  };
337
631
  }
338
- function makeOthers(userMap) {
339
- var users = Object.values(userMap).map(function(user) {
340
- var _hasReceivedInitialPresence = user._hasReceivedInitialPresence, publicKeys = _objectWithoutProperties(user, [
341
- "_hasReceivedInitialPresence"
342
- ]);
343
- return publicKeys;
344
- });
345
- var _obj;
346
- return _obj = {
347
- get count () {
348
- return users.length;
349
- }
350
- }, _defineProperty(_obj, Symbol.iterator, function() {
351
- return users[Symbol.iterator]();
352
- }), _defineProperty(_obj, "map", function map(callback) {
353
- return users.map(callback);
354
- }), _defineProperty(_obj, "toArray", function toArray() {
355
- return users;
356
- }), _obj;
357
- }
358
632
  function log() {
359
633
  for(var _len = arguments.length, _params = new Array(_len), _key = 0; _key < _len; _key++){
360
634
  _params[_key] = arguments[_key];
361
635
  }
362
636
  return;
363
637
  }
364
- function makeStateMachine(state, context, mockedEffects) {
365
- var genericSubscribe = function genericSubscribe(callback) {
366
- state.listeners.storage.push(callback);
367
- return function() {
368
- return _chunkQLMVHHAZjs.remove.call(void 0, state.listeners.storage, callback);
369
- };
370
- };
371
- var subscribeToLiveStructureDeeply = function subscribeToLiveStructureDeeply(node, callback) {
372
- return genericSubscribe(function(updates) {
373
- var relatedUpdates = updates.filter(function(update) {
374
- return _chunkQLMVHHAZjs.isSameNodeOrChildOf.call(void 0, update.node, node);
375
- });
376
- if (relatedUpdates.length > 0) {
377
- callback(relatedUpdates);
378
- }
379
- });
380
- };
381
- var subscribeToLiveStructureShallowly = function subscribeToLiveStructureShallowly(node, callback) {
382
- return genericSubscribe(function(updates) {
383
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
384
- try {
385
- for(var _iterator = updates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
386
- var update = _step.value;
387
- if (update.node._id === node._id) {
388
- callback(update.node);
389
- }
390
- }
391
- } catch (err) {
392
- _didIteratorError = true;
393
- _iteratorError = err;
394
- } finally{
395
- try {
396
- if (!_iteratorNormalCompletion && _iterator.return != null) {
397
- _iterator.return();
398
- }
399
- } finally{
400
- if (_didIteratorError) {
401
- throw _iteratorError;
402
- }
403
- }
404
- }
405
- });
406
- };
638
+ function isConnectionSelfAware(connection) {
639
+ return connection.state === "open" || connection.state === "connecting";
640
+ }
641
+ function makeStateMachine(state, config, mockedEffects) {
407
642
  var createOrUpdateRootFromMessage = function createOrUpdateRootFromMessage(message) {
408
643
  if (message.items.length === 0) {
409
644
  throw new Error("Internal error: cannot load storage without items");
@@ -426,7 +661,7 @@ function makeStateMachine(state, context, mockedEffects) {
426
661
  try {
427
662
  for(var _iterator = items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
428
663
  var _value = _slicedToArray(_step.value, 2), id = _value[0], crdt = _value[1];
429
- if (_chunkQLMVHHAZjs.isRootCrdt.call(void 0, crdt)) {
664
+ if (_chunkZR7CHFN6js.isRootCrdt.call(void 0, crdt)) {
430
665
  root = [
431
666
  id,
432
667
  crdt
@@ -473,33 +708,16 @@ function makeStateMachine(state, context, mockedEffects) {
473
708
  return;
474
709
  }
475
710
  var currentItems = /* @__PURE__ */ new Map();
476
- state.items.forEach(function(liveCrdt, id) {
477
- currentItems.set(id, liveCrdt._toSerializedCrdt());
711
+ state.nodes.forEach(function(node, id) {
712
+ currentItems.set(id, node._serialize());
478
713
  });
479
- var ops = _chunkQLMVHHAZjs.getTreesDiffOperations.call(void 0, currentItems, new Map(items));
714
+ var ops = _chunkZR7CHFN6js.getTreesDiffOperations.call(void 0, currentItems, new Map(items));
480
715
  var result = apply(ops, false);
481
716
  notify(result.updates);
482
717
  };
483
718
  var load = function load(items) {
484
719
  var ref = _slicedToArray(buildRootAndParentToChildren(items), 2), root = ref[0], parentToChildren = ref[1];
485
- return _chunkQLMVHHAZjs.LiveObject._deserialize(root, parentToChildren, {
486
- getItem: getItem,
487
- addItem: addItem,
488
- deleteItem: deleteItem,
489
- generateId: generateId,
490
- generateOpId: generateOpId,
491
- dispatch: storageDispatch,
492
- roomId: context.roomId
493
- });
494
- };
495
- var addItem = function addItem(id, liveItem) {
496
- state.items.set(id, liveItem);
497
- };
498
- var deleteItem = function deleteItem(id) {
499
- state.items.delete(id);
500
- };
501
- var getItem = function getItem(id) {
502
- return state.items.get(id);
720
+ return _chunkZR7CHFN6js.LiveObject._deserialize(root, parentToChildren, pool);
503
721
  };
504
722
  var addToUndoStack = function addToUndoStack(historyItem) {
505
723
  if (state.undoStack.length >= 50) {
@@ -513,51 +731,18 @@ function makeStateMachine(state, context, mockedEffects) {
513
731
  onHistoryChange();
514
732
  }
515
733
  };
516
- var storageDispatch = function storageDispatch(ops, reverse, storageUpdates) {
517
- if (state.isBatching) {
518
- var _ops, _reverseOps;
519
- (_ops = state.batch.ops).push.apply(_ops, _toConsumableArray(ops));
520
- storageUpdates.forEach(function(value, key) {
521
- state.batch.updates.storageUpdates.set(key, _chunkQLMVHHAZjs.mergeStorageUpdates.call(void 0, state.batch.updates.storageUpdates.get(key), value));
522
- });
523
- (_reverseOps = state.batch.reverseOps).push.apply(_reverseOps, _toConsumableArray(reverse));
524
- } else {
525
- addToUndoStack(reverse);
526
- state.redoStack = [];
527
- dispatch(ops);
528
- notify({
529
- storageUpdates: storageUpdates
530
- });
531
- }
532
- };
533
734
  var notify = function notify(param) {
534
735
  var _storageUpdates = param.storageUpdates, storageUpdates = _storageUpdates === void 0 ? /* @__PURE__ */ new Map() : _storageUpdates, _presence = param.presence, presence = _presence === void 0 ? false : _presence, tmp = param.others, otherEvents = tmp === void 0 ? [] : tmp;
535
736
  if (otherEvents.length > 0) {
536
- state.others = makeOthers(state.users);
737
+ var others = state.others.current;
537
738
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
538
739
  try {
539
740
  for(var _iterator = otherEvents[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
540
741
  var event = _step.value;
541
- var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
542
- try {
543
- for(var _iterator1 = state.listeners.others[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
544
- var listener = _step1.value;
545
- listener(state.others, event);
546
- }
547
- } catch (err) {
548
- _didIteratorError1 = true;
549
- _iteratorError1 = err;
550
- } finally{
551
- try {
552
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
553
- _iterator1.return();
554
- }
555
- } finally{
556
- if (_didIteratorError1) {
557
- throw _iteratorError1;
558
- }
559
- }
560
- }
742
+ eventHub.others.notify({
743
+ others: others,
744
+ event: event
745
+ });
561
746
  }
562
747
  } catch (err) {
563
748
  _didIteratorError = true;
@@ -575,64 +760,22 @@ function makeStateMachine(state, context, mockedEffects) {
575
760
  }
576
761
  }
577
762
  if (presence) {
578
- var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined;
579
- try {
580
- for(var _iterator2 = state.listeners["my-presence"][Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true){
581
- var listener1 = _step2.value;
582
- listener1(state.me);
583
- }
584
- } catch (err) {
585
- _didIteratorError2 = true;
586
- _iteratorError2 = err;
587
- } finally{
588
- try {
589
- if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
590
- _iterator2.return();
591
- }
592
- } finally{
593
- if (_didIteratorError2) {
594
- throw _iteratorError2;
595
- }
596
- }
597
- }
763
+ eventHub.me.notify(state.me.current);
598
764
  }
599
765
  if (storageUpdates.size > 0) {
600
- var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = undefined;
601
- try {
602
- for(var _iterator3 = state.listeners.storage[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true){
603
- var subscriber = _step3.value;
604
- subscriber(Array.from(storageUpdates.values()));
605
- }
606
- } catch (err) {
607
- _didIteratorError3 = true;
608
- _iteratorError3 = err;
609
- } finally{
610
- try {
611
- if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
612
- _iterator3.return();
613
- }
614
- } finally{
615
- if (_didIteratorError3) {
616
- throw _iteratorError3;
617
- }
618
- }
619
- }
766
+ var updates = Array.from(storageUpdates.values());
767
+ eventHub.storage.notify(updates);
620
768
  }
621
769
  };
622
770
  var getConnectionId = function getConnectionId() {
623
- if (state.connection.state === "open" || state.connection.state === "connecting") {
624
- return state.connection.id;
771
+ var conn = state.connection.current;
772
+ if (isConnectionSelfAware(conn)) {
773
+ return conn.id;
625
774
  } else if (state.lastConnectionId !== null) {
626
775
  return state.lastConnectionId;
627
776
  }
628
777
  throw new Error("Internal. Tried to get connection id but connection was never open");
629
778
  };
630
- var generateId = function generateId() {
631
- return "".concat(getConnectionId(), ":").concat(state.clock++);
632
- };
633
- var generateOpId = function generateOpId() {
634
- return "".concat(getConnectionId(), ":").concat(state.opClock++);
635
- };
636
779
  var apply = function apply(item, isLocal) {
637
780
  var result = {
638
781
  reverse: [],
@@ -652,17 +795,17 @@ function makeStateMachine(state, context, mockedEffects) {
652
795
  data: {}
653
796
  };
654
797
  for(var key in op.data){
655
- reverse.data[key] = state.me[key];
798
+ reverse.data[key] = state.me.current[key];
656
799
  }
657
- state.me = _objectSpread({}, state.me, op.data);
658
- if (state.buffer.presence == null) {
659
- state.buffer.presence = {
800
+ state.me.patch(op.data);
801
+ if (state.buffer.me == null) {
802
+ state.buffer.me = {
660
803
  type: "partial",
661
804
  data: op.data
662
805
  };
663
806
  } else {
664
807
  for(var key1 in op.data){
665
- state.buffer.presence.data[key1] = op.data[key1];
808
+ state.buffer.me.data[key1] = op.data[key1];
666
809
  }
667
810
  }
668
811
  result.reverse.unshift(reverse);
@@ -670,24 +813,24 @@ function makeStateMachine(state, context, mockedEffects) {
670
813
  } else {
671
814
  var source = void 0;
672
815
  if (!op.opId) {
673
- op.opId = generateOpId();
816
+ op.opId = pool.generateOpId();
674
817
  }
675
818
  if (isLocal) {
676
819
  source = 0 /* UNDOREDO_RECONNECT */ ;
677
820
  } else {
678
- var deleted = state.offlineOperations.delete(_chunkQLMVHHAZjs.nn.call(void 0, op.opId));
821
+ var deleted = state.offlineOperations.delete(_chunkZR7CHFN6js.nn.call(void 0, op.opId));
679
822
  source = deleted ? 2 /* ACK */ : 1 /* REMOTE */ ;
680
823
  }
681
824
  var applyOpResult = applyOp(op, source);
682
825
  if (applyOpResult.modified) {
683
- var parentId = applyOpResult.modified.node.parent.type === "HasParent" ? _chunkQLMVHHAZjs.nn.call(void 0, applyOpResult.modified.node.parent.node._id, "Expected parent node to have an ID") : void 0;
826
+ var parentId = applyOpResult.modified.node.parent.type === "HasParent" ? _chunkZR7CHFN6js.nn.call(void 0, applyOpResult.modified.node.parent.node._id, "Expected parent node to have an ID") : void 0;
684
827
  if (!parentId || !createdNodeIds.has(parentId)) {
685
828
  var _reverse;
686
- result.updates.storageUpdates.set(_chunkQLMVHHAZjs.nn.call(void 0, applyOpResult.modified.node._id), _chunkQLMVHHAZjs.mergeStorageUpdates.call(void 0, result.updates.storageUpdates.get(_chunkQLMVHHAZjs.nn.call(void 0, applyOpResult.modified.node._id)), applyOpResult.modified));
829
+ result.updates.storageUpdates.set(_chunkZR7CHFN6js.nn.call(void 0, applyOpResult.modified.node._id), _chunkZR7CHFN6js.mergeStorageUpdates.call(void 0, result.updates.storageUpdates.get(_chunkZR7CHFN6js.nn.call(void 0, applyOpResult.modified.node._id)), applyOpResult.modified));
687
830
  (_reverse = result.reverse).unshift.apply(_reverse, _toConsumableArray(applyOpResult.reverse));
688
831
  }
689
832
  if (op.type === 2 /* CREATE_LIST */ || op.type === 7 /* CREATE_MAP */ || op.type === 4 /* CREATE_OBJECT */ ) {
690
- createdNodeIds.add(_chunkQLMVHHAZjs.nn.call(void 0, applyOpResult.modified.node._id));
833
+ createdNodeIds.add(_chunkZR7CHFN6js.nn.call(void 0, applyOpResult.modified.node._id));
691
834
  }
692
835
  }
693
836
  }
@@ -714,24 +857,24 @@ function makeStateMachine(state, context, mockedEffects) {
714
857
  case 3 /* UPDATE_OBJECT */ :
715
858
  case 5 /* DELETE_CRDT */ :
716
859
  {
717
- var item = state.items.get(op.id);
718
- if (item == null) {
860
+ var node = state.nodes.get(op.id);
861
+ if (node == null) {
719
862
  return {
720
863
  modified: false
721
864
  };
722
865
  }
723
- return item._apply(op, source === 0 /* UNDOREDO_RECONNECT */ );
866
+ return node._apply(op, source === 0 /* UNDOREDO_RECONNECT */ );
724
867
  }
725
868
  case 1 /* SET_PARENT_KEY */ :
726
869
  {
727
- var item1 = state.items.get(op.id);
728
- if (item1 == null) {
870
+ var node1 = state.nodes.get(op.id);
871
+ if (node1 == null) {
729
872
  return {
730
873
  modified: false
731
874
  };
732
875
  }
733
- if (item1.parent.type === "HasParent" && _chunkQLMVHHAZjs.isLiveList.call(void 0, item1.parent.node)) {
734
- return item1.parent.node._setChildKey(op.parentKey, item1, source);
876
+ if (node1.parent.type === "HasParent" && _chunkZR7CHFN6js.isLiveList.call(void 0, node1.parent.node)) {
877
+ return node1.parent.node._setChildKey(op.parentKey, node1, source);
735
878
  }
736
879
  return {
737
880
  modified: false
@@ -747,26 +890,92 @@ function makeStateMachine(state, context, mockedEffects) {
747
890
  modified: false
748
891
  };
749
892
  }
750
- var parent = state.items.get(op.parentId);
751
- if (parent == null) {
893
+ var parentNode = state.nodes.get(op.parentId);
894
+ if (parentNode == null) {
752
895
  return {
753
896
  modified: false
754
897
  };
755
898
  }
756
- return parent._attachChild(op, source);
899
+ return parentNode._attachChild(op, source);
757
900
  }
758
901
  }
759
902
  };
903
+ var subscribeToLiveStructureDeeply = function subscribeToLiveStructureDeeply(node, callback) {
904
+ return eventHub.storage.subscribe(function(updates) {
905
+ var relatedUpdates = updates.filter(function(update) {
906
+ return _chunkZR7CHFN6js.isSameNodeOrChildOf.call(void 0, update.node, node);
907
+ });
908
+ if (relatedUpdates.length > 0) {
909
+ callback(relatedUpdates);
910
+ }
911
+ });
912
+ };
913
+ var subscribeToLiveStructureShallowly = function subscribeToLiveStructureShallowly(node, callback) {
914
+ return eventHub.storage.subscribe(function(updates) {
915
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
916
+ try {
917
+ for(var _iterator = updates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
918
+ var update = _step.value;
919
+ if (update.node._id === node._id) {
920
+ callback(update.node);
921
+ }
922
+ }
923
+ } catch (err) {
924
+ _didIteratorError = true;
925
+ _iteratorError = err;
926
+ } finally{
927
+ try {
928
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
929
+ _iterator.return();
930
+ }
931
+ } finally{
932
+ if (_didIteratorError) {
933
+ throw _iteratorError;
934
+ }
935
+ }
936
+ }
937
+ });
938
+ };
760
939
  var subscribe = function subscribe(first, second, options) {
940
+ if (typeof first === "string" && _chunkZR7CHFN6js.isRoomEventName.call(void 0, first)) {
941
+ if (typeof second !== "function") {
942
+ throw new Error("Second argument must be a callback function");
943
+ }
944
+ var callback = second;
945
+ switch(first){
946
+ case "event":
947
+ return eventHub.customEvent.subscribe(callback);
948
+ case "my-presence":
949
+ return eventHub.me.subscribe(callback);
950
+ case "others":
951
+ {
952
+ var cb = callback;
953
+ return eventHub.others.subscribe(function(param) {
954
+ var others = param.others, event = param.event;
955
+ return cb(others, event);
956
+ });
957
+ }
958
+ case "error":
959
+ return eventHub.error.subscribe(callback);
960
+ case "connection":
961
+ return eventHub.connection.subscribe(callback);
962
+ case "storage":
963
+ return eventHub.storage.subscribe(callback);
964
+ case "history":
965
+ return eventHub.history.subscribe(callback);
966
+ default:
967
+ return _chunkZR7CHFN6js.assertNever.call(void 0, first, "Unknown event");
968
+ }
969
+ }
761
970
  if (second === void 0 || typeof first === "function") {
762
971
  if (typeof first === "function") {
763
972
  var storageCallback = first;
764
- return genericSubscribe(storageCallback);
973
+ return eventHub.storage.subscribe(storageCallback);
765
974
  } else {
766
975
  throw new Error("Please specify a listener callback");
767
976
  }
768
977
  }
769
- if (_chunkQLMVHHAZjs.isLiveNode.call(void 0, first)) {
978
+ if (_chunkZR7CHFN6js.isLiveNode.call(void 0, first)) {
770
979
  var node = first;
771
980
  if (_optionalChain([
772
981
  options,
@@ -782,34 +991,17 @@ function makeStateMachine(state, context, mockedEffects) {
782
991
  return subscribeToLiveStructureShallowly(node, nodeCallback);
783
992
  }
784
993
  }
785
- if (!_chunkQLMVHHAZjs.isRoomEventName.call(void 0, first)) {
786
- throw new Error('"'.concat(first, '" is not a valid event name'));
787
- }
788
- var eventName = first;
789
- var eventListener = second;
790
- state.listeners[eventName].push(eventListener);
791
- return function() {
792
- var callbacks = state.listeners[eventName];
793
- _chunkQLMVHHAZjs.remove.call(void 0, callbacks, eventListener);
794
- };
994
+ throw new Error('"'.concat(first, '" is not a valid event name'));
795
995
  };
796
996
  var getConnectionState = function getConnectionState() {
797
- return state.connection.state;
798
- };
799
- var getSelf = function getSelf() {
800
- return state.connection.state === "open" || state.connection.state === "connecting" ? {
801
- connectionId: state.connection.id,
802
- id: state.connection.userId,
803
- info: state.connection.userInfo,
804
- presence: getPresence()
805
- } : null;
997
+ return state.connection.current.state;
806
998
  };
807
999
  var connect = function connect() {
808
- if (state.connection.state !== "closed" && state.connection.state !== "unavailable") {
1000
+ if (state.connection.current.state !== "closed" && state.connection.current.state !== "unavailable") {
809
1001
  return null;
810
1002
  }
811
- var auth = prepareAuthEndpoint(context.authentication, _nullishCoalesce(_optionalChain([
812
- context,
1003
+ var auth = prepareAuthEndpoint(config.authentication, _nullishCoalesce(_optionalChain([
1004
+ config,
813
1005
  "access",
814
1006
  function(_2) {
815
1007
  return _2.polyfills;
@@ -819,10 +1011,10 @@ function makeStateMachine(state, context, mockedEffects) {
819
1011
  return _3.fetch;
820
1012
  }
821
1013
  ]), function() {
822
- return context.fetchPolyfill;
1014
+ return config.fetchPolyfill;
823
1015
  }));
824
- var createWebSocket = prepareCreateWebSocket(context.liveblocksServer, _nullishCoalesce(_optionalChain([
825
- context,
1016
+ var createWebSocket = prepareCreateWebSocket(config.liveblocksServer, _nullishCoalesce(_optionalChain([
1017
+ config,
826
1018
  "access",
827
1019
  function(_4) {
828
1020
  return _4.polyfills;
@@ -832,30 +1024,30 @@ function makeStateMachine(state, context, mockedEffects) {
832
1024
  return _5.WebSocket;
833
1025
  }
834
1026
  ]), function() {
835
- return context.WebSocketPolyfill;
1027
+ return config.WebSocketPolyfill;
836
1028
  }));
837
1029
  updateConnection({
838
1030
  state: "authenticating"
839
1031
  });
840
1032
  effects.authenticate(auth, createWebSocket);
841
1033
  };
842
- var updatePresence = function updatePresence(overrides, options) {
1034
+ var updatePresence = function updatePresence(patch, options) {
843
1035
  var oldValues = {};
844
- if (state.buffer.presence == null) {
845
- state.buffer.presence = {
1036
+ if (state.buffer.me == null) {
1037
+ state.buffer.me = {
846
1038
  type: "partial",
847
1039
  data: {}
848
1040
  };
849
1041
  }
850
- for(var key in overrides){
851
- var overrideValue = overrides[key];
1042
+ for(var key in patch){
1043
+ var overrideValue = patch[key];
852
1044
  if (overrideValue === void 0) {
853
1045
  continue;
854
1046
  }
855
- state.buffer.presence.data[key] = overrideValue;
856
- oldValues[key] = state.me[key];
1047
+ state.buffer.me.data[key] = overrideValue;
1048
+ oldValues[key] = state.me.current[key];
857
1049
  }
858
- state.me = _objectSpread({}, state.me, overrides);
1050
+ state.me.patch(patch);
859
1051
  if (state.isBatching) {
860
1052
  if (_optionalChain([
861
1053
  options,
@@ -917,44 +1109,40 @@ function makeStateMachine(state, context, mockedEffects) {
917
1109
  state.timeoutHandles.reconnect = effects.scheduleReconnect(getRetryDelay());
918
1110
  };
919
1111
  var onVisibilityChange = function onVisibilityChange(visibilityState) {
920
- if (visibilityState === "visible" && state.connection.state === "open") {
1112
+ if (visibilityState === "visible" && state.connection.current.state === "open") {
921
1113
  log("Heartbeat after visibility change");
922
1114
  heartbeat();
923
1115
  }
924
1116
  };
925
1117
  var onUpdatePresenceMessage = function onUpdatePresenceMessage(message) {
926
- var user = state.users[message.actor];
927
- if (message.targetActor === void 0 && user != null && !user._hasReceivedInitialPresence) {
928
- return void 0;
1118
+ if (message.targetActor !== void 0) {
1119
+ var oldUser = state.others.getUser(message.actor);
1120
+ state.others.setOther(message.actor, message.data);
1121
+ var newUser = state.others.getUser(message.actor);
1122
+ if (oldUser === void 0 && newUser !== void 0) {
1123
+ return {
1124
+ type: "enter",
1125
+ user: newUser
1126
+ };
1127
+ }
1128
+ } else {
1129
+ state.others.patchOther(message.actor, message.data), message;
929
1130
  }
930
- if (user == null) {
931
- state.users[message.actor] = {
932
- connectionId: message.actor,
933
- presence: message.data,
934
- id: void 0,
935
- info: void 0,
936
- _hasReceivedInitialPresence: true
1131
+ var user = state.others.getUser(message.actor);
1132
+ if (user) {
1133
+ return {
1134
+ type: "update",
1135
+ updates: message.data,
1136
+ user: user
937
1137
  };
938
1138
  } else {
939
- state.users[message.actor] = {
940
- id: user.id,
941
- info: user.info,
942
- connectionId: message.actor,
943
- presence: _objectSpread({}, user.presence, message.data),
944
- _hasReceivedInitialPresence: true
945
- };
1139
+ return void 0;
946
1140
  }
947
- return {
948
- type: "update",
949
- updates: message.data,
950
- user: state.users[message.actor]
951
- };
952
1141
  };
953
1142
  var onUserLeftMessage = function onUserLeftMessage(message) {
954
- var userLeftMessage = message;
955
- var user = state.users[userLeftMessage.actor];
1143
+ var user = state.others.getUser(message.actor);
956
1144
  if (user) {
957
- delete state.users[userLeftMessage.actor];
1145
+ state.others.removeConnection(message.actor);
958
1146
  return {
959
1147
  type: "leave",
960
1148
  user: user
@@ -963,113 +1151,57 @@ function makeStateMachine(state, context, mockedEffects) {
963
1151
  return null;
964
1152
  };
965
1153
  var onRoomStateMessage = function onRoomStateMessage(message) {
966
- var newUsers = {};
967
1154
  for(var key in message.users){
968
- var connectionId = Number.parseInt(key);
969
1155
  var user = message.users[key];
970
- newUsers[connectionId] = {
971
- connectionId: connectionId,
972
- info: user.info,
973
- id: user.id
974
- };
1156
+ var connectionId = Number(key);
1157
+ state.others.setConnection(connectionId, user.id, user.info);
975
1158
  }
976
- state.users = newUsers;
977
1159
  return {
978
1160
  type: "reset"
979
1161
  };
980
1162
  };
981
1163
  var onNavigatorOnline = function onNavigatorOnline() {
982
- if (state.connection.state === "unavailable") {
1164
+ if (state.connection.current.state === "unavailable") {
983
1165
  log("Try to reconnect after connectivity change");
984
1166
  reconnect();
985
1167
  }
986
1168
  };
987
- var onEvent = function onEvent(message) {
988
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
989
- try {
990
- for(var _iterator = state.listeners.event[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
991
- var listener = _step.value;
992
- listener({
993
- connectionId: message.actor,
994
- event: message.event
995
- });
996
- }
997
- } catch (err) {
998
- _didIteratorError = true;
999
- _iteratorError = err;
1000
- } finally{
1001
- try {
1002
- if (!_iteratorNormalCompletion && _iterator.return != null) {
1003
- _iterator.return();
1004
- }
1005
- } finally{
1006
- if (_didIteratorError) {
1007
- throw _iteratorError;
1008
- }
1009
- }
1010
- }
1011
- };
1012
1169
  var onHistoryChange = function onHistoryChange() {
1013
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1014
- try {
1015
- for(var _iterator = state.listeners.history[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1016
- var listener = _step.value;
1017
- listener({
1018
- canUndo: canUndo(),
1019
- canRedo: canRedo()
1020
- });
1021
- }
1022
- } catch (err) {
1023
- _didIteratorError = true;
1024
- _iteratorError = err;
1025
- } finally{
1026
- try {
1027
- if (!_iteratorNormalCompletion && _iterator.return != null) {
1028
- _iterator.return();
1029
- }
1030
- } finally{
1031
- if (_didIteratorError) {
1032
- throw _iteratorError;
1033
- }
1034
- }
1035
- }
1170
+ eventHub.history.notify({
1171
+ canUndo: canUndo(),
1172
+ canRedo: canRedo()
1173
+ });
1036
1174
  };
1037
1175
  var onUserJoinedMessage = function onUserJoinedMessage(message) {
1038
- state.users[message.actor] = {
1039
- connectionId: message.actor,
1040
- info: message.info,
1041
- id: message.id,
1042
- _hasReceivedInitialPresence: true
1043
- };
1044
- if (state.me) {
1045
- state.buffer.messages.push({
1046
- type: 100 /* UPDATE_PRESENCE */ ,
1047
- data: state.me,
1048
- targetActor: message.actor
1049
- });
1050
- tryFlushing();
1051
- }
1052
- return {
1176
+ state.others.setConnection(message.actor, message.id, message.info);
1177
+ state.buffer.messages.push({
1178
+ type: 100 /* UPDATE_PRESENCE */ ,
1179
+ data: state.me.current,
1180
+ targetActor: message.actor
1181
+ });
1182
+ tryFlushing();
1183
+ var user = state.others.getUser(message.actor);
1184
+ return user ? {
1053
1185
  type: "enter",
1054
- user: state.users[message.actor]
1055
- };
1186
+ user: user
1187
+ } : void 0;
1056
1188
  };
1057
1189
  var parseServerMessage = function parseServerMessage(data) {
1058
- if (!_chunkQLMVHHAZjs.isJsonObject.call(void 0, data)) {
1190
+ if (!_chunkZR7CHFN6js.isJsonObject.call(void 0, data)) {
1059
1191
  return null;
1060
1192
  }
1061
1193
  return data;
1062
1194
  };
1063
1195
  var parseServerMessages = function parseServerMessages(text) {
1064
- var data = _chunkQLMVHHAZjs.tryParseJson.call(void 0, text);
1196
+ var data = _chunkZR7CHFN6js.tryParseJson.call(void 0, text);
1065
1197
  if (data === void 0) {
1066
1198
  return null;
1067
- } else if (_chunkQLMVHHAZjs.isJsonArray.call(void 0, data)) {
1068
- return _chunkQLMVHHAZjs.compact.call(void 0, data.map(function(item) {
1199
+ } else if (_chunkZR7CHFN6js.isJsonArray.call(void 0, data)) {
1200
+ return _chunkZR7CHFN6js.compact.call(void 0, data.map(function(item) {
1069
1201
  return parseServerMessage(item);
1070
1202
  }));
1071
1203
  } else {
1072
- return _chunkQLMVHHAZjs.compact.call(void 0, [
1204
+ return _chunkZR7CHFN6js.compact.call(void 0, [
1073
1205
  parseServerMessage(data)
1074
1206
  ]);
1075
1207
  }
@@ -1094,7 +1226,10 @@ function makeStateMachine(state, context, mockedEffects) {
1094
1226
  switch(message.type){
1095
1227
  case 101 /* USER_JOINED */ :
1096
1228
  {
1097
- updates.others.push(onUserJoinedMessage(message));
1229
+ var userJoinedUpdate = onUserJoinedMessage(message);
1230
+ if (userJoinedUpdate) {
1231
+ updates.others.push(userJoinedUpdate);
1232
+ }
1098
1233
  break;
1099
1234
  }
1100
1235
  case 100 /* UPDATE_PRESENCE */ :
@@ -1107,7 +1242,10 @@ function makeStateMachine(state, context, mockedEffects) {
1107
1242
  }
1108
1243
  case 103 /* BROADCASTED_EVENT */ :
1109
1244
  {
1110
- onEvent(message);
1245
+ eventHub.customEvent.notify({
1246
+ connectionId: message.actor,
1247
+ event: message.event
1248
+ });
1111
1249
  break;
1112
1250
  }
1113
1251
  case 102 /* USER_LEFT */ :
@@ -1135,13 +1273,14 @@ function makeStateMachine(state, context, mockedEffects) {
1135
1273
  return _8();
1136
1274
  }
1137
1275
  ]);
1276
+ eventHub.storageDidLoad.notify();
1138
1277
  break;
1139
1278
  }
1140
1279
  case 201 /* UPDATE_STORAGE */ :
1141
1280
  {
1142
1281
  var applyResult = apply(message.ops, false);
1143
1282
  applyResult.updates.storageUpdates.forEach(function(value, key) {
1144
- updates.storageUpdates.set(key, _chunkQLMVHHAZjs.mergeStorageUpdates.call(void 0, updates.storageUpdates.get(key), value));
1283
+ updates.storageUpdates.set(key, _chunkZR7CHFN6js.mergeStorageUpdates.call(void 0, updates.storageUpdates.get(key), value));
1145
1284
  });
1146
1285
  break;
1147
1286
  }
@@ -1171,7 +1310,7 @@ function makeStateMachine(state, context, mockedEffects) {
1171
1310
  clearTimeout(state.timeoutHandles.flush);
1172
1311
  }
1173
1312
  clearTimeout(state.timeoutHandles.reconnect);
1174
- state.users = {};
1313
+ state.others.clearOthers();
1175
1314
  notify({
1176
1315
  others: [
1177
1316
  {
@@ -1184,26 +1323,7 @@ function makeStateMachine(state, context, mockedEffects) {
1184
1323
  state: "failed"
1185
1324
  });
1186
1325
  var error = new LiveblocksError(event.reason, event.code);
1187
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1188
- try {
1189
- for(var _iterator = state.listeners.error[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1190
- var listener = _step.value;
1191
- listener(error);
1192
- }
1193
- } catch (err) {
1194
- _didIteratorError = true;
1195
- _iteratorError = err;
1196
- } finally{
1197
- try {
1198
- if (!_iteratorNormalCompletion && _iterator.return != null) {
1199
- _iterator.return();
1200
- }
1201
- } finally{
1202
- if (_didIteratorError) {
1203
- throw _iteratorError;
1204
- }
1205
- }
1206
- }
1326
+ eventHub.error.notify(error);
1207
1327
  var delay = getRetryDelay(true);
1208
1328
  state.numberOfRetry++;
1209
1329
  if (process.env.NODE_ENV !== "production") {
@@ -1230,27 +1350,8 @@ function makeStateMachine(state, context, mockedEffects) {
1230
1350
  }
1231
1351
  };
1232
1352
  var updateConnection = function updateConnection(connection) {
1233
- state.connection = connection;
1234
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1235
- try {
1236
- for(var _iterator = state.listeners.connection[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1237
- var listener = _step.value;
1238
- listener(connection.state);
1239
- }
1240
- } catch (err) {
1241
- _didIteratorError = true;
1242
- _iteratorError = err;
1243
- } finally{
1244
- try {
1245
- if (!_iteratorNormalCompletion && _iterator.return != null) {
1246
- _iterator.return();
1247
- }
1248
- } finally{
1249
- if (_didIteratorError) {
1250
- throw _iteratorError;
1251
- }
1252
- }
1253
- }
1353
+ state.connection.set(connection);
1354
+ eventHub.connection.notify(connection.state);
1254
1355
  };
1255
1356
  var getRetryDelay = function getRetryDelay() {
1256
1357
  var slow = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
@@ -1263,19 +1364,19 @@ function makeStateMachine(state, context, mockedEffects) {
1263
1364
  var onOpen = function onOpen() {
1264
1365
  clearInterval(state.intervalHandles.heartbeat);
1265
1366
  state.intervalHandles.heartbeat = effects.startHeartbeatInterval();
1266
- if (state.connection.state === "connecting") {
1267
- updateConnection(_objectSpreadProps(_objectSpread({}, state.connection), {
1367
+ if (state.connection.current.state === "connecting") {
1368
+ updateConnection(_objectSpreadProps(_objectSpread({}, state.connection.current), {
1268
1369
  state: "open"
1269
1370
  }));
1270
1371
  state.numberOfRetry = 0;
1271
1372
  if (state.lastConnectionId !== void 0) {
1272
- state.buffer.presence = {
1373
+ state.buffer.me = {
1273
1374
  type: "full",
1274
- data: state.me
1375
+ data: state.me.current
1275
1376
  };
1276
1377
  tryFlushing();
1277
1378
  }
1278
- state.lastConnectionId = state.connection.id;
1379
+ state.lastConnectionId = state.connection.current.id;
1279
1380
  if (state.root) {
1280
1381
  state.buffer.messages.push({
1281
1382
  type: 200 /* FETCH_STORAGE */
@@ -1336,7 +1437,7 @@ function makeStateMachine(state, context, mockedEffects) {
1336
1437
  var storageOps = state.buffer.storageOperations;
1337
1438
  if (storageOps.length > 0) {
1338
1439
  storageOps.forEach(function(op) {
1339
- state.offlineOperations.set(_chunkQLMVHHAZjs.nn.call(void 0, op.opId), op);
1440
+ state.offlineOperations.set(_chunkZR7CHFN6js.nn.call(void 0, op.opId), op);
1340
1441
  });
1341
1442
  }
1342
1443
  if (state.socket == null || state.socket.readyState !== state.socket.OPEN) {
@@ -1345,7 +1446,7 @@ function makeStateMachine(state, context, mockedEffects) {
1345
1446
  }
1346
1447
  var now = Date.now();
1347
1448
  var elapsedTime = now - state.lastFlushTime;
1348
- if (elapsedTime > context.throttleDelay) {
1449
+ if (elapsedTime > config.throttleDelay) {
1349
1450
  var messages = flushDataToMessages(state);
1350
1451
  if (messages.length === 0) {
1351
1452
  return;
@@ -1354,26 +1455,26 @@ function makeStateMachine(state, context, mockedEffects) {
1354
1455
  state.buffer = {
1355
1456
  messages: [],
1356
1457
  storageOperations: [],
1357
- presence: null
1458
+ me: null
1358
1459
  };
1359
1460
  state.lastFlushTime = now;
1360
1461
  } else {
1361
1462
  if (state.timeoutHandles.flush != null) {
1362
1463
  clearTimeout(state.timeoutHandles.flush);
1363
1464
  }
1364
- state.timeoutHandles.flush = effects.delayFlush(context.throttleDelay - (now - state.lastFlushTime));
1465
+ state.timeoutHandles.flush = effects.delayFlush(config.throttleDelay - (now - state.lastFlushTime));
1365
1466
  }
1366
1467
  };
1367
1468
  var flushDataToMessages = function flushDataToMessages(state2) {
1368
1469
  var messages = [];
1369
- if (state2.buffer.presence) {
1370
- messages.push(state2.buffer.presence.type === "full" ? {
1470
+ if (state2.buffer.me) {
1471
+ messages.push(state2.buffer.me.type === "full" ? {
1371
1472
  type: 100 /* UPDATE_PRESENCE */ ,
1372
1473
  targetActor: -1,
1373
- data: state2.buffer.presence.data
1474
+ data: state2.buffer.me.data
1374
1475
  } : {
1375
1476
  type: 100 /* UPDATE_PRESENCE */ ,
1376
- data: state2.buffer.presence.data
1477
+ data: state2.buffer.me.data
1377
1478
  });
1378
1479
  }
1379
1480
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -1422,7 +1523,7 @@ function makeStateMachine(state, context, mockedEffects) {
1422
1523
  clearTimeout(state.timeoutHandles.reconnect);
1423
1524
  clearTimeout(state.timeoutHandles.pongTimeout);
1424
1525
  clearInterval(state.intervalHandles.heartbeat);
1425
- state.users = {};
1526
+ state.others.clearOthers();
1426
1527
  notify({
1427
1528
  others: [
1428
1529
  {
@@ -1430,18 +1531,15 @@ function makeStateMachine(state, context, mockedEffects) {
1430
1531
  }
1431
1532
  ]
1432
1533
  });
1433
- clearListeners();
1434
- };
1435
- var clearListeners = function clearListeners() {
1436
- for(var key in state.listeners){
1437
- state.listeners[key] = [];
1438
- }
1534
+ Object.values(eventHub).forEach(function(eventSource) {
1535
+ return eventSource.clear();
1536
+ });
1439
1537
  };
1440
1538
  var getPresence = function getPresence() {
1441
- return state.me;
1539
+ return state.me.current;
1442
1540
  };
1443
1541
  var getOthers = function getOthers() {
1444
- return state.others;
1542
+ return state.others.current;
1445
1543
  };
1446
1544
  var broadcastEvent = function broadcastEvent(event) {
1447
1545
  var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
@@ -1456,19 +1554,12 @@ function makeStateMachine(state, context, mockedEffects) {
1456
1554
  });
1457
1555
  tryFlushing();
1458
1556
  };
1459
- var dispatch = function dispatch(ops) {
1557
+ var dispatchOps = function dispatchOps(ops) {
1460
1558
  var _storageOperations;
1461
1559
  (_storageOperations = state.buffer.storageOperations).push.apply(_storageOperations, _toConsumableArray(ops));
1462
1560
  tryFlushing();
1463
1561
  };
1464
- var getStorage = function getStorage() {
1465
- if (state.root) {
1466
- return new Promise(function(resolve) {
1467
- return resolve({
1468
- root: state.root
1469
- });
1470
- });
1471
- }
1562
+ var startLoadingStorage = function startLoadingStorage() {
1472
1563
  if (_getInitialStatePromise == null) {
1473
1564
  state.buffer.messages.push({
1474
1565
  type: 200 /* FETCH_STORAGE */
@@ -1478,9 +1569,26 @@ function makeStateMachine(state, context, mockedEffects) {
1478
1569
  return _getInitialStateResolver = resolve;
1479
1570
  });
1480
1571
  }
1481
- return _getInitialStatePromise.then(function() {
1572
+ return _getInitialStatePromise;
1573
+ };
1574
+ var getStorageSnapshot = function getStorageSnapshot() {
1575
+ var root = state.root;
1576
+ if (root !== void 0) {
1577
+ return root;
1578
+ } else {
1579
+ startLoadingStorage();
1580
+ return null;
1581
+ }
1582
+ };
1583
+ var getStorage = function getStorage() {
1584
+ if (state.root) {
1585
+ return Promise.resolve({
1586
+ root: state.root
1587
+ });
1588
+ }
1589
+ return startLoadingStorage().then(function() {
1482
1590
  return {
1483
- root: _chunkQLMVHHAZjs.nn.call(void 0, state.root)
1591
+ root: _chunkZR7CHFN6js.nn.call(void 0, state.root)
1484
1592
  };
1485
1593
  });
1486
1594
  };
@@ -1580,7 +1688,7 @@ function makeStateMachine(state, context, mockedEffects) {
1580
1688
  state.redoStack = [];
1581
1689
  }
1582
1690
  if (state.batch.ops.length > 0) {
1583
- dispatch(state.batch.ops);
1691
+ dispatchOps(state.batch.ops);
1584
1692
  }
1585
1693
  notify(state.batch.updates);
1586
1694
  state.batch = {
@@ -1614,20 +1722,65 @@ function makeStateMachine(state, context, mockedEffects) {
1614
1722
  var simulateSendCloseEvent = function simulateSendCloseEvent(event) {
1615
1723
  onClose(event);
1616
1724
  };
1725
+ var pool = {
1726
+ roomId: config.roomId,
1727
+ getNode: function(id) {
1728
+ return state.nodes.get(id);
1729
+ },
1730
+ addNode: function(id, node) {
1731
+ return void state.nodes.set(id, node);
1732
+ },
1733
+ deleteNode: function(id) {
1734
+ return void state.nodes.delete(id);
1735
+ },
1736
+ generateId: function() {
1737
+ return "".concat(getConnectionId(), ":").concat(state.clock++);
1738
+ },
1739
+ generateOpId: function() {
1740
+ return "".concat(getConnectionId(), ":").concat(state.opClock++);
1741
+ },
1742
+ dispatch: function dispatch(ops, reverse, storageUpdates) {
1743
+ if (state.isBatching) {
1744
+ var _ops, _reverseOps;
1745
+ (_ops = state.batch.ops).push.apply(_ops, _toConsumableArray(ops));
1746
+ storageUpdates.forEach(function(value, key) {
1747
+ state.batch.updates.storageUpdates.set(key, _chunkZR7CHFN6js.mergeStorageUpdates.call(void 0, state.batch.updates.storageUpdates.get(key), value));
1748
+ });
1749
+ (_reverseOps = state.batch.reverseOps).push.apply(_reverseOps, _toConsumableArray(reverse));
1750
+ } else {
1751
+ addToUndoStack(reverse);
1752
+ state.redoStack = [];
1753
+ dispatchOps(ops);
1754
+ notify({
1755
+ storageUpdates: storageUpdates
1756
+ });
1757
+ }
1758
+ }
1759
+ };
1760
+ var eventHub = {
1761
+ customEvent: makeEventSource(),
1762
+ me: makeEventSource(),
1763
+ others: makeEventSource(),
1764
+ error: makeEventSource(),
1765
+ connection: makeEventSource(),
1766
+ storage: makeEventSource(),
1767
+ history: makeEventSource(),
1768
+ storageDidLoad: makeEventSource()
1769
+ };
1617
1770
  var effects = mockedEffects || {
1618
1771
  authenticate: function authenticate(auth, createWebSocket) {
1619
1772
  var rawToken = state.token;
1620
- var parsedToken = rawToken !== null && _chunkQLMVHHAZjs.parseRoomAuthToken.call(void 0, rawToken);
1621
- if (parsedToken && !_chunkQLMVHHAZjs.isTokenExpired.call(void 0, parsedToken)) {
1773
+ var parsedToken = rawToken !== null && _chunkZR7CHFN6js.parseRoomAuthToken.call(void 0, rawToken);
1774
+ if (parsedToken && !_chunkZR7CHFN6js.isTokenExpired.call(void 0, parsedToken)) {
1622
1775
  var socket = createWebSocket(rawToken);
1623
1776
  authenticationSuccess(parsedToken, socket);
1624
1777
  } else {
1625
- return auth(context.roomId).then(function(param) {
1778
+ return auth(config.roomId).then(function(param) {
1626
1779
  var token = param.token;
1627
- if (state.connection.state !== "authenticating") {
1780
+ if (state.connection.current.state !== "authenticating") {
1628
1781
  return;
1629
1782
  }
1630
- var parsedToken2 = _chunkQLMVHHAZjs.parseRoomAuthToken.call(void 0, token);
1783
+ var parsedToken2 = _chunkZR7CHFN6js.parseRoomAuthToken.call(void 0, token);
1631
1784
  var socket = createWebSocket(token);
1632
1785
  authenticationSuccess(parsedToken2, socket);
1633
1786
  state.token = token;
@@ -1655,6 +1808,17 @@ function makeStateMachine(state, context, mockedEffects) {
1655
1808
  return setTimeout(connect, delay);
1656
1809
  }
1657
1810
  };
1811
+ var self = new DerivedRef([
1812
+ state.connection,
1813
+ state.me
1814
+ ], function(conn, me) {
1815
+ return isConnectionSelfAware(conn) ? {
1816
+ connectionId: conn.id,
1817
+ id: conn.userId,
1818
+ info: conn.userInfo,
1819
+ presence: me
1820
+ } : null;
1821
+ });
1658
1822
  var _getInitialStatePromise = null;
1659
1823
  var _getInitialStateResolver = null;
1660
1824
  return {
@@ -1670,7 +1834,7 @@ function makeStateMachine(state, context, mockedEffects) {
1670
1834
  return state.undoStack;
1671
1835
  },
1672
1836
  getItemsCount: function() {
1673
- return state.items.size;
1837
+ return state.nodes.size;
1674
1838
  },
1675
1839
  connect: connect,
1676
1840
  disconnect: disconnect,
@@ -1685,31 +1849,37 @@ function makeStateMachine(state, context, mockedEffects) {
1685
1849
  pauseHistory: pauseHistory,
1686
1850
  resumeHistory: resumeHistory,
1687
1851
  getStorage: getStorage,
1688
- selectors: {
1689
- getConnectionState: getConnectionState,
1690
- getSelf: getSelf,
1691
- getPresence: getPresence,
1692
- getOthers: getOthers
1693
- }
1852
+ getStorageSnapshot: getStorageSnapshot,
1853
+ events: {
1854
+ customEvent: eventHub.customEvent.observable,
1855
+ others: eventHub.others.observable,
1856
+ me: eventHub.me.observable,
1857
+ error: eventHub.error.observable,
1858
+ connection: eventHub.connection.observable,
1859
+ storage: eventHub.storage.observable,
1860
+ history: eventHub.history.observable,
1861
+ storageDidLoad: eventHub.storageDidLoad.observable
1862
+ },
1863
+ getConnectionState: getConnectionState,
1864
+ isSelfAware: function() {
1865
+ return isConnectionSelfAware(state.connection.current);
1866
+ },
1867
+ getSelf: function() {
1868
+ return self.current;
1869
+ },
1870
+ getPresence: getPresence,
1871
+ getOthers: getOthers
1694
1872
  };
1695
1873
  }
1696
1874
  function defaultState(initialPresence, initialStorage) {
1875
+ var others = new OthersRef();
1876
+ var connection = new ValueRef({
1877
+ state: "closed"
1878
+ });
1697
1879
  return {
1698
- connection: {
1699
- state: "closed"
1700
- },
1701
1880
  token: null,
1702
1881
  lastConnectionId: null,
1703
1882
  socket: null,
1704
- listeners: {
1705
- event: [],
1706
- others: [],
1707
- "my-presence": [],
1708
- error: [],
1709
- connection: [],
1710
- storage: [],
1711
- history: []
1712
- },
1713
1883
  numberOfRetry: 0,
1714
1884
  lastFlushTime: 0,
1715
1885
  timeoutHandles: {
@@ -1718,9 +1888,9 @@ function defaultState(initialPresence, initialStorage) {
1718
1888
  pongTimeout: 0
1719
1889
  },
1720
1890
  buffer: {
1721
- presence: {
1891
+ me: {
1722
1892
  type: "full",
1723
- data: initialPresence == null ? {} : initialPresence
1893
+ data: initialPresence
1724
1894
  },
1725
1895
  messages: [],
1726
1896
  storageOperations: []
@@ -1728,14 +1898,14 @@ function defaultState(initialPresence, initialStorage) {
1728
1898
  intervalHandles: {
1729
1899
  heartbeat: 0
1730
1900
  },
1731
- me: initialPresence == null ? {} : initialPresence,
1732
- users: {},
1733
- others: makeOthers({}),
1901
+ connection: connection,
1902
+ me: new MeRef(initialPresence),
1903
+ others: others,
1734
1904
  defaultStorageRoot: initialStorage,
1735
1905
  idFactory: null,
1736
1906
  clock: 0,
1737
1907
  opClock: 0,
1738
- items: /* @__PURE__ */ new Map(),
1908
+ nodes: /* @__PURE__ */ new Map(),
1739
1909
  root: void 0,
1740
1910
  undoStack: [],
1741
1911
  redoStack: [],
@@ -1754,25 +1924,23 @@ function defaultState(initialPresence, initialStorage) {
1754
1924
  offlineOperations: /* @__PURE__ */ new Map()
1755
1925
  };
1756
1926
  }
1757
- function createRoom(options, context) {
1758
- var initialPresence = _nullishCoalesce(options.initialPresence, function() {
1759
- return options.defaultPresence;
1760
- });
1761
- var initialStorage = _nullishCoalesce(options.initialStorage, function() {
1762
- return options.defaultStorageRoot;
1763
- });
1764
- var state = defaultState(typeof initialPresence === "function" ? initialPresence(context.roomId) : initialPresence, typeof initialStorage === "function" ? initialStorage(context.roomId) : initialStorage);
1765
- var machine = makeStateMachine(state, context);
1927
+ function createRoom(options, config) {
1928
+ var initialPresence = options.initialPresence, initialStorage = options.initialStorage;
1929
+ var state = defaultState(typeof initialPresence === "function" ? initialPresence(config.roomId) : initialPresence, typeof initialStorage === "function" ? initialStorage(config.roomId) : initialStorage);
1930
+ var machine = makeStateMachine(state, config);
1766
1931
  var room = {
1767
- id: context.roomId,
1768
- getConnectionState: machine.selectors.getConnectionState,
1769
- getSelf: machine.selectors.getSelf,
1932
+ id: config.roomId,
1933
+ getConnectionState: machine.getConnectionState,
1934
+ isSelfAware: machine.isSelfAware,
1935
+ getSelf: machine.getSelf,
1770
1936
  subscribe: machine.subscribe,
1771
- getPresence: machine.selectors.getPresence,
1937
+ getPresence: machine.getPresence,
1772
1938
  updatePresence: machine.updatePresence,
1773
- getOthers: machine.selectors.getOthers,
1939
+ getOthers: machine.getOthers,
1774
1940
  broadcastEvent: machine.broadcastEvent,
1775
1941
  getStorage: machine.getStorage,
1942
+ getStorageSnapshot: machine.getStorageSnapshot,
1943
+ events: machine.events,
1776
1944
  batch: machine.batch,
1777
1945
  history: {
1778
1946
  undo: machine.undo,
@@ -1813,7 +1981,7 @@ function prepareCreateWebSocket(liveblocksServer, WebSocketPolyfill) {
1813
1981
  }
1814
1982
  var ws = WebSocketPolyfill || WebSocket;
1815
1983
  return function(token) {
1816
- return new ws("".concat(liveblocksServer, "/?token=").concat(token, "&version=").concat(true ? "0.17.11" : "dev"));
1984
+ return new ws("".concat(liveblocksServer, "/?token=").concat(token, "&version=").concat(true ? "0.18.0-beta0" : "dev"));
1817
1985
  };
1818
1986
  }
1819
1987
  function prepareAuthEndpoint(authentication, fetchPolyfill) {
@@ -1866,7 +2034,7 @@ function fetchAuthEndpoint(fetch2, endpoint, body) {
1866
2034
  throw new AuthenticationError('Expected a JSON response when doing a POST request on "'.concat(endpoint, '". ').concat(er));
1867
2035
  });
1868
2036
  }).then(function(data) {
1869
- if (!_chunkQLMVHHAZjs.isPlainObject.call(void 0, data) || typeof data.token !== "string") {
2037
+ if (!_chunkZR7CHFN6js.isPlainObject.call(void 0, data) || typeof data.token !== "string") {
1870
2038
  throw new AuthenticationError('Expected a JSON response of the form `{ token: "..." }` when doing a POST request on "'.concat(endpoint, '", but got ').concat(JSON.stringify(data)));
1871
2039
  }
1872
2040
  var token = data.token;
@@ -1890,19 +2058,17 @@ function createClient(options) {
1890
2058
  var internalRoom = rooms.get(roomId);
1891
2059
  return internalRoom ? internalRoom.room : null;
1892
2060
  };
1893
- var enter = function enter(roomId) {
1894
- var options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2061
+ var enter = function enter(roomId, options2) {
1895
2062
  var internalRoom = rooms.get(roomId);
1896
2063
  if (internalRoom) {
1897
2064
  return internalRoom.room;
1898
2065
  }
1899
- _chunkQLMVHHAZjs.errorIf.call(void 0, options2.defaultPresence, "Argument `defaultPresence` will be removed in @liveblocks/client 0.18. Please use `initialPresence` instead. For more info, see https://bit.ly/3Niy5aP");
1900
- _chunkQLMVHHAZjs.errorIf.call(void 0, options2.defaultStorageRoot, "Argument `defaultStorageRoot` will be removed in @liveblocks/client 0.18. Please use `initialStorage` instead. For more info, see https://bit.ly/3Niy5aP");
2066
+ _chunkZR7CHFN6js.deprecateIf.call(void 0, options2.initialPresence == null, "Please provide an initial presence value for the current user when entering the room.");
1901
2067
  internalRoom = createRoom({
1902
- initialPresence: options2.initialPresence,
1903
- initialStorage: options2.initialStorage,
1904
- defaultPresence: options2.defaultPresence,
1905
- defaultStorageRoot: options2.defaultStorageRoot
2068
+ initialPresence: _nullishCoalesce(options2.initialPresence, function() {
2069
+ return {};
2070
+ }),
2071
+ initialStorage: options2.initialStorage
1906
2072
  }, {
1907
2073
  roomId: roomId,
1908
2074
  throttleDelay: throttleDelay,
@@ -2051,7 +2217,46 @@ function buildLiveblocksPublicAuthorizeEndpoint(options, roomId) {
2051
2217
  }
2052
2218
  return "https://api.liveblocks.io/v2/rooms/".concat(encodeURIComponent(roomId), "/public/authorize");
2053
2219
  }
2054
- exports.LiveList = _chunkQLMVHHAZjs.LiveList;
2055
- exports.LiveMap = _chunkQLMVHHAZjs.LiveMap;
2056
- exports.LiveObject = _chunkQLMVHHAZjs.LiveObject;
2220
+ // src/shallow.ts
2221
+ function shallowArray(xs, ys) {
2222
+ if (xs.length !== ys.length) {
2223
+ return false;
2224
+ }
2225
+ for(var i = 0; i < xs.length; i++){
2226
+ if (!Object.is(xs[i], ys[i])) {
2227
+ return false;
2228
+ }
2229
+ }
2230
+ return true;
2231
+ }
2232
+ function shallowObj(objA, objB) {
2233
+ if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null || Object.prototype.toString.call(objA) !== "[object Object]" || Object.prototype.toString.call(objB) !== "[object Object]") {
2234
+ return false;
2235
+ }
2236
+ var keysA = Object.keys(objA);
2237
+ if (keysA.length !== Object.keys(objB).length) {
2238
+ return false;
2239
+ }
2240
+ return keysA.every(function(key) {
2241
+ return Object.prototype.hasOwnProperty.call(objB, key) && Object.is(objA[key], objB[key]);
2242
+ });
2243
+ }
2244
+ function shallow(a, b) {
2245
+ if (Object.is(a, b)) {
2246
+ return true;
2247
+ }
2248
+ var isArrayA = Array.isArray(a);
2249
+ var isArrayB = Array.isArray(b);
2250
+ if (isArrayA || isArrayB) {
2251
+ if (!isArrayA || !isArrayB) {
2252
+ return false;
2253
+ }
2254
+ return shallowArray(a, b);
2255
+ }
2256
+ return shallowObj(a, b);
2257
+ }
2258
+ exports.LiveList = _chunkZR7CHFN6js.LiveList;
2259
+ exports.LiveMap = _chunkZR7CHFN6js.LiveMap;
2260
+ exports.LiveObject = _chunkZR7CHFN6js.LiveObject;
2057
2261
  exports.createClient = createClient;
2262
+ exports.shallow = shallow;