@liveblocks/client 0.17.11-debug2 → 0.18.0-beta1

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,304 @@ function _optionalChain(ops) {
310
297
  }
311
298
  return value;
312
299
  }
313
- var _chunkQLMVHHAZjs = require("./chunk-QLMVHHAZ.js");
300
+ var _chunkZNCSOBAXjs = require("./chunk-ZNCSOBAX.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 = _chunkZNCSOBAXjs.freeze.call(void 0, _chunkZNCSOBAXjs.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 = _chunkZNCSOBAXjs.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 _chunkZNCSOBAXjs.freeze.call(void 0, _chunkZNCSOBAXjs.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 = _chunkZNCSOBAXjs.compact.call(void 0, Object.keys(this._presences).map(function(connectionId) {
448
+ return _this.getUser(Number(connectionId));
449
+ }));
450
+ return _chunkZNCSOBAXjs.asArrayWithLegacyMethods.call(void 0, users);
451
+ }
452
+ },
453
+ {
454
+ key: "clearOthers",
455
+ value: function clearOthers() {
456
+ this._connections = {};
457
+ this._presences = {};
458
+ this._users = {};
459
+ this.invalidate();
460
+ }
461
+ },
462
+ {
463
+ key: "_getUser",
464
+ value: function _getUser(connectionId) {
465
+ var conn = this._connections[connectionId];
466
+ var presence = this._presences[connectionId];
467
+ if (conn !== void 0 && presence !== void 0) {
468
+ return makeUser(conn, presence);
469
+ }
470
+ return void 0;
471
+ }
472
+ },
473
+ {
474
+ key: "getUser",
475
+ value: function getUser(connectionId) {
476
+ var cachedUser = this._users[connectionId];
477
+ if (cachedUser) {
478
+ return cachedUser;
479
+ }
480
+ var computedUser = this._getUser(connectionId);
481
+ if (computedUser) {
482
+ this._users[connectionId] = computedUser;
483
+ return computedUser;
484
+ }
485
+ return void 0;
486
+ }
487
+ },
488
+ {
489
+ key: "_invalidateUser",
490
+ value: function _invalidateUser(connectionId) {
491
+ if (this._users[connectionId] !== void 0) {
492
+ delete this._users[connectionId];
493
+ }
494
+ this.invalidate();
495
+ }
496
+ },
497
+ {
498
+ key: "setConnection",
499
+ value: function setConnection(connectionId, metaUserId, metaUserInfo) {
500
+ this._connections[connectionId] = _chunkZNCSOBAXjs.freeze.call(void 0, {
501
+ connectionId: connectionId,
502
+ id: metaUserId,
503
+ info: metaUserInfo
504
+ });
505
+ if (this._presences[connectionId] !== void 0) {
506
+ this._invalidateUser(connectionId);
507
+ }
508
+ }
509
+ },
510
+ {
511
+ key: "removeConnection",
512
+ value: function removeConnection(connectionId) {
513
+ delete this._connections[connectionId];
514
+ delete this._presences[connectionId];
515
+ this._invalidateUser(connectionId);
516
+ }
517
+ },
518
+ {
519
+ key: "setOther",
520
+ value: function setOther(connectionId, presence) {
521
+ this._presences[connectionId] = _chunkZNCSOBAXjs.freeze.call(void 0, _chunkZNCSOBAXjs.compactObject.call(void 0, presence));
522
+ if (this._connections[connectionId] !== void 0) {
523
+ this._invalidateUser(connectionId);
524
+ }
525
+ }
526
+ },
527
+ {
528
+ key: "patchOther",
529
+ value: function patchOther(connectionId, patch) {
530
+ var oldPresence = this._presences[connectionId];
531
+ if (oldPresence === void 0) {
532
+ return;
533
+ }
534
+ var newPresence = merge(oldPresence, patch);
535
+ if (oldPresence !== newPresence) {
536
+ this._presences[connectionId] = _chunkZNCSOBAXjs.freeze.call(void 0, newPresence);
537
+ this._invalidateUser(connectionId);
538
+ }
539
+ }
540
+ }
541
+ ]);
542
+ return OthersRef;
543
+ }(ImmutableRef);
544
+ // src/ValueRef.ts
545
+ var ValueRef = /*#__PURE__*/ function(ImmutableRef) {
546
+ _inherits(ValueRef, ImmutableRef);
547
+ var _super = _createSuper(ValueRef);
548
+ function ValueRef(initialValue) {
549
+ _classCallCheck(this, ValueRef);
550
+ var _this;
551
+ _this = _super.call(this);
552
+ _this._value = _chunkZNCSOBAXjs.freeze.call(void 0, _chunkZNCSOBAXjs.compactObject.call(void 0, initialValue));
553
+ return _this;
554
+ }
555
+ _createClass(ValueRef, [
556
+ {
557
+ key: "_toImmutable",
558
+ value: function _toImmutable() {
559
+ return this._value;
560
+ }
561
+ },
562
+ {
563
+ key: "set",
564
+ value: function set(newValue) {
565
+ this._value = _chunkZNCSOBAXjs.freeze.call(void 0, newValue);
566
+ this.invalidate();
567
+ }
568
+ }
569
+ ]);
570
+ return ValueRef;
571
+ }(ImmutableRef);
572
+ var DerivedRef = /*#__PURE__*/ function(ImmutableRef) {
573
+ _inherits(DerivedRef, ImmutableRef);
574
+ var _super = _createSuper(DerivedRef);
575
+ function DerivedRef(otherRefs, transformFn) {
576
+ _classCallCheck(this, DerivedRef);
577
+ var _this;
578
+ _this = _super.call(this);
579
+ _this._refs = otherRefs;
580
+ _this._refs.forEach(function(ref) {
581
+ ref.didInvalidate.subscribe(function() {
582
+ return _this.invalidate();
583
+ });
584
+ });
585
+ _this._transform = transformFn;
586
+ return _this;
587
+ }
588
+ _createClass(DerivedRef, [
589
+ {
590
+ key: "_toImmutable",
591
+ value: function _toImmutable() {
592
+ return this._transform(this._refs[0].current, this._refs[1].current);
593
+ }
594
+ }
595
+ ]);
596
+ return DerivedRef;
597
+ }(ImmutableRef);
314
598
  // src/room.ts
315
599
  var BACKOFF_RETRY_DELAYS = [
316
600
  250,
@@ -335,75 +619,16 @@ function makeIdFactory(connectionId) {
335
619
  return "".concat(connectionId, ":").concat(count++);
336
620
  };
337
621
  }
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
622
  function log() {
359
623
  for(var _len = arguments.length, _params = new Array(_len), _key = 0; _key < _len; _key++){
360
624
  _params[_key] = arguments[_key];
361
625
  }
362
626
  return;
363
627
  }
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
- };
628
+ function isConnectionSelfAware(connection) {
629
+ return connection.state === "open" || connection.state === "connecting";
630
+ }
631
+ function makeStateMachine(state, config, mockedEffects) {
407
632
  var createOrUpdateRootFromMessage = function createOrUpdateRootFromMessage(message) {
408
633
  if (message.items.length === 0) {
409
634
  throw new Error("Internal error: cannot load storage without items");
@@ -426,7 +651,7 @@ function makeStateMachine(state, context, mockedEffects) {
426
651
  try {
427
652
  for(var _iterator = items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
428
653
  var _value = _slicedToArray(_step.value, 2), id = _value[0], crdt = _value[1];
429
- if (_chunkQLMVHHAZjs.isRootCrdt.call(void 0, crdt)) {
654
+ if (_chunkZNCSOBAXjs.isRootCrdt.call(void 0, crdt)) {
430
655
  root = [
431
656
  id,
432
657
  crdt
@@ -473,33 +698,16 @@ function makeStateMachine(state, context, mockedEffects) {
473
698
  return;
474
699
  }
475
700
  var currentItems = /* @__PURE__ */ new Map();
476
- state.items.forEach(function(liveCrdt, id) {
477
- currentItems.set(id, liveCrdt._toSerializedCrdt());
701
+ state.nodes.forEach(function(node, id) {
702
+ currentItems.set(id, node._serialize());
478
703
  });
479
- var ops = _chunkQLMVHHAZjs.getTreesDiffOperations.call(void 0, currentItems, new Map(items));
704
+ var ops = _chunkZNCSOBAXjs.getTreesDiffOperations.call(void 0, currentItems, new Map(items));
480
705
  var result = apply(ops, false);
481
706
  notify(result.updates);
482
707
  };
483
708
  var load = function load(items) {
484
709
  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);
710
+ return _chunkZNCSOBAXjs.LiveObject._deserialize(root, parentToChildren, pool);
503
711
  };
504
712
  var addToUndoStack = function addToUndoStack(historyItem) {
505
713
  if (state.undoStack.length >= 50) {
@@ -513,51 +721,18 @@ function makeStateMachine(state, context, mockedEffects) {
513
721
  onHistoryChange();
514
722
  }
515
723
  };
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
724
  var notify = function notify(param) {
534
725
  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
726
  if (otherEvents.length > 0) {
536
- state.others = makeOthers(state.users);
727
+ var others = state.others.current;
537
728
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
538
729
  try {
539
730
  for(var _iterator = otherEvents[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
540
731
  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
- }
732
+ eventHub.others.notify({
733
+ others: others,
734
+ event: event
735
+ });
561
736
  }
562
737
  } catch (err) {
563
738
  _didIteratorError = true;
@@ -575,64 +750,22 @@ function makeStateMachine(state, context, mockedEffects) {
575
750
  }
576
751
  }
577
752
  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
- }
753
+ eventHub.me.notify(state.me.current);
598
754
  }
599
755
  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
- }
756
+ var updates = Array.from(storageUpdates.values());
757
+ eventHub.storage.notify(updates);
620
758
  }
621
759
  };
622
760
  var getConnectionId = function getConnectionId() {
623
- if (state.connection.state === "open" || state.connection.state === "connecting") {
624
- return state.connection.id;
761
+ var conn = state.connection.current;
762
+ if (isConnectionSelfAware(conn)) {
763
+ return conn.id;
625
764
  } else if (state.lastConnectionId !== null) {
626
765
  return state.lastConnectionId;
627
766
  }
628
767
  throw new Error("Internal. Tried to get connection id but connection was never open");
629
768
  };
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
769
  var apply = function apply(item, isLocal) {
637
770
  var result = {
638
771
  reverse: [],
@@ -652,17 +785,17 @@ function makeStateMachine(state, context, mockedEffects) {
652
785
  data: {}
653
786
  };
654
787
  for(var key in op.data){
655
- reverse.data[key] = state.me[key];
788
+ reverse.data[key] = state.me.current[key];
656
789
  }
657
- state.me = _objectSpread({}, state.me, op.data);
658
- if (state.buffer.presence == null) {
659
- state.buffer.presence = {
790
+ state.me.patch(op.data);
791
+ if (state.buffer.me == null) {
792
+ state.buffer.me = {
660
793
  type: "partial",
661
794
  data: op.data
662
795
  };
663
796
  } else {
664
797
  for(var key1 in op.data){
665
- state.buffer.presence.data[key1] = op.data[key1];
798
+ state.buffer.me.data[key1] = op.data[key1];
666
799
  }
667
800
  }
668
801
  result.reverse.unshift(reverse);
@@ -670,24 +803,24 @@ function makeStateMachine(state, context, mockedEffects) {
670
803
  } else {
671
804
  var source = void 0;
672
805
  if (!op.opId) {
673
- op.opId = generateOpId();
806
+ op.opId = pool.generateOpId();
674
807
  }
675
808
  if (isLocal) {
676
809
  source = 0 /* UNDOREDO_RECONNECT */ ;
677
810
  } else {
678
- var deleted = state.offlineOperations.delete(_chunkQLMVHHAZjs.nn.call(void 0, op.opId));
811
+ var deleted = state.offlineOperations.delete(_chunkZNCSOBAXjs.nn.call(void 0, op.opId));
679
812
  source = deleted ? 2 /* ACK */ : 1 /* REMOTE */ ;
680
813
  }
681
814
  var applyOpResult = applyOp(op, source);
682
815
  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;
816
+ var parentId = applyOpResult.modified.node.parent.type === "HasParent" ? _chunkZNCSOBAXjs.nn.call(void 0, applyOpResult.modified.node.parent.node._id, "Expected parent node to have an ID") : void 0;
684
817
  if (!parentId || !createdNodeIds.has(parentId)) {
685
818
  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));
819
+ result.updates.storageUpdates.set(_chunkZNCSOBAXjs.nn.call(void 0, applyOpResult.modified.node._id), _chunkZNCSOBAXjs.mergeStorageUpdates.call(void 0, result.updates.storageUpdates.get(_chunkZNCSOBAXjs.nn.call(void 0, applyOpResult.modified.node._id)), applyOpResult.modified));
687
820
  (_reverse = result.reverse).unshift.apply(_reverse, _toConsumableArray(applyOpResult.reverse));
688
821
  }
689
822
  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));
823
+ createdNodeIds.add(_chunkZNCSOBAXjs.nn.call(void 0, applyOpResult.modified.node._id));
691
824
  }
692
825
  }
693
826
  }
@@ -714,24 +847,24 @@ function makeStateMachine(state, context, mockedEffects) {
714
847
  case 3 /* UPDATE_OBJECT */ :
715
848
  case 5 /* DELETE_CRDT */ :
716
849
  {
717
- var item = state.items.get(op.id);
718
- if (item == null) {
850
+ var node = state.nodes.get(op.id);
851
+ if (node == null) {
719
852
  return {
720
853
  modified: false
721
854
  };
722
855
  }
723
- return item._apply(op, source === 0 /* UNDOREDO_RECONNECT */ );
856
+ return node._apply(op, source === 0 /* UNDOREDO_RECONNECT */ );
724
857
  }
725
858
  case 1 /* SET_PARENT_KEY */ :
726
859
  {
727
- var item1 = state.items.get(op.id);
728
- if (item1 == null) {
860
+ var node1 = state.nodes.get(op.id);
861
+ if (node1 == null) {
729
862
  return {
730
863
  modified: false
731
864
  };
732
865
  }
733
- if (item1.parent.type === "HasParent" && _chunkQLMVHHAZjs.isLiveList.call(void 0, item1.parent.node)) {
734
- return item1.parent.node._setChildKey(op.parentKey, item1, source);
866
+ if (node1.parent.type === "HasParent" && _chunkZNCSOBAXjs.isLiveList.call(void 0, node1.parent.node)) {
867
+ return node1.parent.node._setChildKey(op.parentKey, node1, source);
735
868
  }
736
869
  return {
737
870
  modified: false
@@ -747,26 +880,92 @@ function makeStateMachine(state, context, mockedEffects) {
747
880
  modified: false
748
881
  };
749
882
  }
750
- var parent = state.items.get(op.parentId);
751
- if (parent == null) {
883
+ var parentNode = state.nodes.get(op.parentId);
884
+ if (parentNode == null) {
752
885
  return {
753
886
  modified: false
754
887
  };
755
888
  }
756
- return parent._attachChild(op, source);
889
+ return parentNode._attachChild(op, source);
757
890
  }
758
891
  }
759
892
  };
893
+ var subscribeToLiveStructureDeeply = function subscribeToLiveStructureDeeply(node, callback) {
894
+ return eventHub.storage.subscribe(function(updates) {
895
+ var relatedUpdates = updates.filter(function(update) {
896
+ return _chunkZNCSOBAXjs.isSameNodeOrChildOf.call(void 0, update.node, node);
897
+ });
898
+ if (relatedUpdates.length > 0) {
899
+ callback(relatedUpdates);
900
+ }
901
+ });
902
+ };
903
+ var subscribeToLiveStructureShallowly = function subscribeToLiveStructureShallowly(node, callback) {
904
+ return eventHub.storage.subscribe(function(updates) {
905
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
906
+ try {
907
+ for(var _iterator = updates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
908
+ var update = _step.value;
909
+ if (update.node._id === node._id) {
910
+ callback(update.node);
911
+ }
912
+ }
913
+ } catch (err) {
914
+ _didIteratorError = true;
915
+ _iteratorError = err;
916
+ } finally{
917
+ try {
918
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
919
+ _iterator.return();
920
+ }
921
+ } finally{
922
+ if (_didIteratorError) {
923
+ throw _iteratorError;
924
+ }
925
+ }
926
+ }
927
+ });
928
+ };
760
929
  var subscribe = function subscribe(first, second, options) {
930
+ if (typeof first === "string" && _chunkZNCSOBAXjs.isRoomEventName.call(void 0, first)) {
931
+ if (typeof second !== "function") {
932
+ throw new Error("Second argument must be a callback function");
933
+ }
934
+ var callback = second;
935
+ switch(first){
936
+ case "event":
937
+ return eventHub.customEvent.subscribe(callback);
938
+ case "my-presence":
939
+ return eventHub.me.subscribe(callback);
940
+ case "others":
941
+ {
942
+ var cb = callback;
943
+ return eventHub.others.subscribe(function(param) {
944
+ var others = param.others, event = param.event;
945
+ return cb(others, event);
946
+ });
947
+ }
948
+ case "error":
949
+ return eventHub.error.subscribe(callback);
950
+ case "connection":
951
+ return eventHub.connection.subscribe(callback);
952
+ case "storage":
953
+ return eventHub.storage.subscribe(callback);
954
+ case "history":
955
+ return eventHub.history.subscribe(callback);
956
+ default:
957
+ return _chunkZNCSOBAXjs.assertNever.call(void 0, first, "Unknown event");
958
+ }
959
+ }
761
960
  if (second === void 0 || typeof first === "function") {
762
961
  if (typeof first === "function") {
763
962
  var storageCallback = first;
764
- return genericSubscribe(storageCallback);
963
+ return eventHub.storage.subscribe(storageCallback);
765
964
  } else {
766
965
  throw new Error("Please specify a listener callback");
767
966
  }
768
967
  }
769
- if (_chunkQLMVHHAZjs.isLiveNode.call(void 0, first)) {
968
+ if (_chunkZNCSOBAXjs.isLiveNode.call(void 0, first)) {
770
969
  var node = first;
771
970
  if (_optionalChain([
772
971
  options,
@@ -782,34 +981,17 @@ function makeStateMachine(state, context, mockedEffects) {
782
981
  return subscribeToLiveStructureShallowly(node, nodeCallback);
783
982
  }
784
983
  }
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
- };
984
+ throw new Error('"'.concat(first, '" is not a valid event name'));
795
985
  };
796
986
  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;
987
+ return state.connection.current.state;
806
988
  };
807
989
  var connect = function connect() {
808
- if (state.connection.state !== "closed" && state.connection.state !== "unavailable") {
990
+ if (state.connection.current.state !== "closed" && state.connection.current.state !== "unavailable") {
809
991
  return null;
810
992
  }
811
- var auth = prepareAuthEndpoint(context.authentication, _nullishCoalesce(_optionalChain([
812
- context,
993
+ var auth = prepareAuthEndpoint(config.authentication, _nullishCoalesce(_optionalChain([
994
+ config,
813
995
  "access",
814
996
  function(_2) {
815
997
  return _2.polyfills;
@@ -819,10 +1001,10 @@ function makeStateMachine(state, context, mockedEffects) {
819
1001
  return _3.fetch;
820
1002
  }
821
1003
  ]), function() {
822
- return context.fetchPolyfill;
1004
+ return config.fetchPolyfill;
823
1005
  }));
824
- var createWebSocket = prepareCreateWebSocket(context.liveblocksServer, _nullishCoalesce(_optionalChain([
825
- context,
1006
+ var createWebSocket = prepareCreateWebSocket(config.liveblocksServer, _nullishCoalesce(_optionalChain([
1007
+ config,
826
1008
  "access",
827
1009
  function(_4) {
828
1010
  return _4.polyfills;
@@ -832,30 +1014,30 @@ function makeStateMachine(state, context, mockedEffects) {
832
1014
  return _5.WebSocket;
833
1015
  }
834
1016
  ]), function() {
835
- return context.WebSocketPolyfill;
1017
+ return config.WebSocketPolyfill;
836
1018
  }));
837
1019
  updateConnection({
838
1020
  state: "authenticating"
839
1021
  });
840
1022
  effects.authenticate(auth, createWebSocket);
841
1023
  };
842
- var updatePresence = function updatePresence(overrides, options) {
1024
+ var updatePresence = function updatePresence(patch, options) {
843
1025
  var oldValues = {};
844
- if (state.buffer.presence == null) {
845
- state.buffer.presence = {
1026
+ if (state.buffer.me == null) {
1027
+ state.buffer.me = {
846
1028
  type: "partial",
847
1029
  data: {}
848
1030
  };
849
1031
  }
850
- for(var key in overrides){
851
- var overrideValue = overrides[key];
1032
+ for(var key in patch){
1033
+ var overrideValue = patch[key];
852
1034
  if (overrideValue === void 0) {
853
1035
  continue;
854
1036
  }
855
- state.buffer.presence.data[key] = overrideValue;
856
- oldValues[key] = state.me[key];
1037
+ state.buffer.me.data[key] = overrideValue;
1038
+ oldValues[key] = state.me.current[key];
857
1039
  }
858
- state.me = _objectSpread({}, state.me, overrides);
1040
+ state.me.patch(patch);
859
1041
  if (state.isBatching) {
860
1042
  if (_optionalChain([
861
1043
  options,
@@ -917,44 +1099,40 @@ function makeStateMachine(state, context, mockedEffects) {
917
1099
  state.timeoutHandles.reconnect = effects.scheduleReconnect(getRetryDelay());
918
1100
  };
919
1101
  var onVisibilityChange = function onVisibilityChange(visibilityState) {
920
- if (visibilityState === "visible" && state.connection.state === "open") {
1102
+ if (visibilityState === "visible" && state.connection.current.state === "open") {
921
1103
  log("Heartbeat after visibility change");
922
1104
  heartbeat();
923
1105
  }
924
1106
  };
925
1107
  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;
1108
+ if (message.targetActor !== void 0) {
1109
+ var oldUser = state.others.getUser(message.actor);
1110
+ state.others.setOther(message.actor, message.data);
1111
+ var newUser = state.others.getUser(message.actor);
1112
+ if (oldUser === void 0 && newUser !== void 0) {
1113
+ return {
1114
+ type: "enter",
1115
+ user: newUser
1116
+ };
1117
+ }
1118
+ } else {
1119
+ state.others.patchOther(message.actor, message.data), message;
929
1120
  }
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
1121
+ var user = state.others.getUser(message.actor);
1122
+ if (user) {
1123
+ return {
1124
+ type: "update",
1125
+ updates: message.data,
1126
+ user: user
937
1127
  };
938
1128
  } 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
- };
1129
+ return void 0;
946
1130
  }
947
- return {
948
- type: "update",
949
- updates: message.data,
950
- user: state.users[message.actor]
951
- };
952
1131
  };
953
1132
  var onUserLeftMessage = function onUserLeftMessage(message) {
954
- var userLeftMessage = message;
955
- var user = state.users[userLeftMessage.actor];
1133
+ var user = state.others.getUser(message.actor);
956
1134
  if (user) {
957
- delete state.users[userLeftMessage.actor];
1135
+ state.others.removeConnection(message.actor);
958
1136
  return {
959
1137
  type: "leave",
960
1138
  user: user
@@ -963,113 +1141,57 @@ function makeStateMachine(state, context, mockedEffects) {
963
1141
  return null;
964
1142
  };
965
1143
  var onRoomStateMessage = function onRoomStateMessage(message) {
966
- var newUsers = {};
967
1144
  for(var key in message.users){
968
- var connectionId = Number.parseInt(key);
969
1145
  var user = message.users[key];
970
- newUsers[connectionId] = {
971
- connectionId: connectionId,
972
- info: user.info,
973
- id: user.id
974
- };
1146
+ var connectionId = Number(key);
1147
+ state.others.setConnection(connectionId, user.id, user.info);
975
1148
  }
976
- state.users = newUsers;
977
1149
  return {
978
1150
  type: "reset"
979
1151
  };
980
1152
  };
981
1153
  var onNavigatorOnline = function onNavigatorOnline() {
982
- if (state.connection.state === "unavailable") {
1154
+ if (state.connection.current.state === "unavailable") {
983
1155
  log("Try to reconnect after connectivity change");
984
1156
  reconnect();
985
1157
  }
986
1158
  };
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
1159
  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
- }
1160
+ eventHub.history.notify({
1161
+ canUndo: canUndo(),
1162
+ canRedo: canRedo()
1163
+ });
1036
1164
  };
1037
1165
  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 {
1166
+ state.others.setConnection(message.actor, message.id, message.info);
1167
+ state.buffer.messages.push({
1168
+ type: 100 /* UPDATE_PRESENCE */ ,
1169
+ data: state.me.current,
1170
+ targetActor: message.actor
1171
+ });
1172
+ tryFlushing();
1173
+ var user = state.others.getUser(message.actor);
1174
+ return user ? {
1053
1175
  type: "enter",
1054
- user: state.users[message.actor]
1055
- };
1176
+ user: user
1177
+ } : void 0;
1056
1178
  };
1057
1179
  var parseServerMessage = function parseServerMessage(data) {
1058
- if (!_chunkQLMVHHAZjs.isJsonObject.call(void 0, data)) {
1180
+ if (!_chunkZNCSOBAXjs.isJsonObject.call(void 0, data)) {
1059
1181
  return null;
1060
1182
  }
1061
1183
  return data;
1062
1184
  };
1063
1185
  var parseServerMessages = function parseServerMessages(text) {
1064
- var data = _chunkQLMVHHAZjs.tryParseJson.call(void 0, text);
1186
+ var data = _chunkZNCSOBAXjs.tryParseJson.call(void 0, text);
1065
1187
  if (data === void 0) {
1066
1188
  return null;
1067
- } else if (_chunkQLMVHHAZjs.isJsonArray.call(void 0, data)) {
1068
- return _chunkQLMVHHAZjs.compact.call(void 0, data.map(function(item) {
1189
+ } else if (_chunkZNCSOBAXjs.isJsonArray.call(void 0, data)) {
1190
+ return _chunkZNCSOBAXjs.compact.call(void 0, data.map(function(item) {
1069
1191
  return parseServerMessage(item);
1070
1192
  }));
1071
1193
  } else {
1072
- return _chunkQLMVHHAZjs.compact.call(void 0, [
1194
+ return _chunkZNCSOBAXjs.compact.call(void 0, [
1073
1195
  parseServerMessage(data)
1074
1196
  ]);
1075
1197
  }
@@ -1094,7 +1216,10 @@ function makeStateMachine(state, context, mockedEffects) {
1094
1216
  switch(message.type){
1095
1217
  case 101 /* USER_JOINED */ :
1096
1218
  {
1097
- updates.others.push(onUserJoinedMessage(message));
1219
+ var userJoinedUpdate = onUserJoinedMessage(message);
1220
+ if (userJoinedUpdate) {
1221
+ updates.others.push(userJoinedUpdate);
1222
+ }
1098
1223
  break;
1099
1224
  }
1100
1225
  case 100 /* UPDATE_PRESENCE */ :
@@ -1107,7 +1232,10 @@ function makeStateMachine(state, context, mockedEffects) {
1107
1232
  }
1108
1233
  case 103 /* BROADCASTED_EVENT */ :
1109
1234
  {
1110
- onEvent(message);
1235
+ eventHub.customEvent.notify({
1236
+ connectionId: message.actor,
1237
+ event: message.event
1238
+ });
1111
1239
  break;
1112
1240
  }
1113
1241
  case 102 /* USER_LEFT */ :
@@ -1135,13 +1263,14 @@ function makeStateMachine(state, context, mockedEffects) {
1135
1263
  return _8();
1136
1264
  }
1137
1265
  ]);
1266
+ eventHub.storageDidLoad.notify();
1138
1267
  break;
1139
1268
  }
1140
1269
  case 201 /* UPDATE_STORAGE */ :
1141
1270
  {
1142
1271
  var applyResult = apply(message.ops, false);
1143
1272
  applyResult.updates.storageUpdates.forEach(function(value, key) {
1144
- updates.storageUpdates.set(key, _chunkQLMVHHAZjs.mergeStorageUpdates.call(void 0, updates.storageUpdates.get(key), value));
1273
+ updates.storageUpdates.set(key, _chunkZNCSOBAXjs.mergeStorageUpdates.call(void 0, updates.storageUpdates.get(key), value));
1145
1274
  });
1146
1275
  break;
1147
1276
  }
@@ -1171,7 +1300,7 @@ function makeStateMachine(state, context, mockedEffects) {
1171
1300
  clearTimeout(state.timeoutHandles.flush);
1172
1301
  }
1173
1302
  clearTimeout(state.timeoutHandles.reconnect);
1174
- state.users = {};
1303
+ state.others.clearOthers();
1175
1304
  notify({
1176
1305
  others: [
1177
1306
  {
@@ -1184,26 +1313,7 @@ function makeStateMachine(state, context, mockedEffects) {
1184
1313
  state: "failed"
1185
1314
  });
1186
1315
  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
- }
1316
+ eventHub.error.notify(error);
1207
1317
  var delay = getRetryDelay(true);
1208
1318
  state.numberOfRetry++;
1209
1319
  if (process.env.NODE_ENV !== "production") {
@@ -1230,27 +1340,8 @@ function makeStateMachine(state, context, mockedEffects) {
1230
1340
  }
1231
1341
  };
1232
1342
  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
- }
1343
+ state.connection.set(connection);
1344
+ eventHub.connection.notify(connection.state);
1254
1345
  };
1255
1346
  var getRetryDelay = function getRetryDelay() {
1256
1347
  var slow = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
@@ -1263,19 +1354,19 @@ function makeStateMachine(state, context, mockedEffects) {
1263
1354
  var onOpen = function onOpen() {
1264
1355
  clearInterval(state.intervalHandles.heartbeat);
1265
1356
  state.intervalHandles.heartbeat = effects.startHeartbeatInterval();
1266
- if (state.connection.state === "connecting") {
1267
- updateConnection(_objectSpreadProps(_objectSpread({}, state.connection), {
1357
+ if (state.connection.current.state === "connecting") {
1358
+ updateConnection(_objectSpreadProps(_objectSpread({}, state.connection.current), {
1268
1359
  state: "open"
1269
1360
  }));
1270
1361
  state.numberOfRetry = 0;
1271
1362
  if (state.lastConnectionId !== void 0) {
1272
- state.buffer.presence = {
1363
+ state.buffer.me = {
1273
1364
  type: "full",
1274
- data: state.me
1365
+ data: state.me.current
1275
1366
  };
1276
1367
  tryFlushing();
1277
1368
  }
1278
- state.lastConnectionId = state.connection.id;
1369
+ state.lastConnectionId = state.connection.current.id;
1279
1370
  if (state.root) {
1280
1371
  state.buffer.messages.push({
1281
1372
  type: 200 /* FETCH_STORAGE */
@@ -1336,7 +1427,7 @@ function makeStateMachine(state, context, mockedEffects) {
1336
1427
  var storageOps = state.buffer.storageOperations;
1337
1428
  if (storageOps.length > 0) {
1338
1429
  storageOps.forEach(function(op) {
1339
- state.offlineOperations.set(_chunkQLMVHHAZjs.nn.call(void 0, op.opId), op);
1430
+ state.offlineOperations.set(_chunkZNCSOBAXjs.nn.call(void 0, op.opId), op);
1340
1431
  });
1341
1432
  }
1342
1433
  if (state.socket == null || state.socket.readyState !== state.socket.OPEN) {
@@ -1345,7 +1436,7 @@ function makeStateMachine(state, context, mockedEffects) {
1345
1436
  }
1346
1437
  var now = Date.now();
1347
1438
  var elapsedTime = now - state.lastFlushTime;
1348
- if (elapsedTime > context.throttleDelay) {
1439
+ if (elapsedTime > config.throttleDelay) {
1349
1440
  var messages = flushDataToMessages(state);
1350
1441
  if (messages.length === 0) {
1351
1442
  return;
@@ -1354,26 +1445,26 @@ function makeStateMachine(state, context, mockedEffects) {
1354
1445
  state.buffer = {
1355
1446
  messages: [],
1356
1447
  storageOperations: [],
1357
- presence: null
1448
+ me: null
1358
1449
  };
1359
1450
  state.lastFlushTime = now;
1360
1451
  } else {
1361
1452
  if (state.timeoutHandles.flush != null) {
1362
1453
  clearTimeout(state.timeoutHandles.flush);
1363
1454
  }
1364
- state.timeoutHandles.flush = effects.delayFlush(context.throttleDelay - (now - state.lastFlushTime));
1455
+ state.timeoutHandles.flush = effects.delayFlush(config.throttleDelay - (now - state.lastFlushTime));
1365
1456
  }
1366
1457
  };
1367
1458
  var flushDataToMessages = function flushDataToMessages(state2) {
1368
1459
  var messages = [];
1369
- if (state2.buffer.presence) {
1370
- messages.push(state2.buffer.presence.type === "full" ? {
1460
+ if (state2.buffer.me) {
1461
+ messages.push(state2.buffer.me.type === "full" ? {
1371
1462
  type: 100 /* UPDATE_PRESENCE */ ,
1372
1463
  targetActor: -1,
1373
- data: state2.buffer.presence.data
1464
+ data: state2.buffer.me.data
1374
1465
  } : {
1375
1466
  type: 100 /* UPDATE_PRESENCE */ ,
1376
- data: state2.buffer.presence.data
1467
+ data: state2.buffer.me.data
1377
1468
  });
1378
1469
  }
1379
1470
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -1422,7 +1513,7 @@ function makeStateMachine(state, context, mockedEffects) {
1422
1513
  clearTimeout(state.timeoutHandles.reconnect);
1423
1514
  clearTimeout(state.timeoutHandles.pongTimeout);
1424
1515
  clearInterval(state.intervalHandles.heartbeat);
1425
- state.users = {};
1516
+ state.others.clearOthers();
1426
1517
  notify({
1427
1518
  others: [
1428
1519
  {
@@ -1430,18 +1521,15 @@ function makeStateMachine(state, context, mockedEffects) {
1430
1521
  }
1431
1522
  ]
1432
1523
  });
1433
- clearListeners();
1434
- };
1435
- var clearListeners = function clearListeners() {
1436
- for(var key in state.listeners){
1437
- state.listeners[key] = [];
1438
- }
1524
+ Object.values(eventHub).forEach(function(eventSource) {
1525
+ return eventSource.clear();
1526
+ });
1439
1527
  };
1440
1528
  var getPresence = function getPresence() {
1441
- return state.me;
1529
+ return state.me.current;
1442
1530
  };
1443
1531
  var getOthers = function getOthers() {
1444
- return state.others;
1532
+ return state.others.current;
1445
1533
  };
1446
1534
  var broadcastEvent = function broadcastEvent(event) {
1447
1535
  var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
@@ -1456,19 +1544,12 @@ function makeStateMachine(state, context, mockedEffects) {
1456
1544
  });
1457
1545
  tryFlushing();
1458
1546
  };
1459
- var dispatch = function dispatch(ops) {
1547
+ var dispatchOps = function dispatchOps(ops) {
1460
1548
  var _storageOperations;
1461
1549
  (_storageOperations = state.buffer.storageOperations).push.apply(_storageOperations, _toConsumableArray(ops));
1462
1550
  tryFlushing();
1463
1551
  };
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
- }
1552
+ var startLoadingStorage = function startLoadingStorage() {
1472
1553
  if (_getInitialStatePromise == null) {
1473
1554
  state.buffer.messages.push({
1474
1555
  type: 200 /* FETCH_STORAGE */
@@ -1478,9 +1559,26 @@ function makeStateMachine(state, context, mockedEffects) {
1478
1559
  return _getInitialStateResolver = resolve;
1479
1560
  });
1480
1561
  }
1481
- return _getInitialStatePromise.then(function() {
1562
+ return _getInitialStatePromise;
1563
+ };
1564
+ var getStorageSnapshot = function getStorageSnapshot() {
1565
+ var root = state.root;
1566
+ if (root !== void 0) {
1567
+ return root;
1568
+ } else {
1569
+ startLoadingStorage();
1570
+ return null;
1571
+ }
1572
+ };
1573
+ var getStorage = function getStorage() {
1574
+ if (state.root) {
1575
+ return Promise.resolve({
1576
+ root: state.root
1577
+ });
1578
+ }
1579
+ return startLoadingStorage().then(function() {
1482
1580
  return {
1483
- root: _chunkQLMVHHAZjs.nn.call(void 0, state.root)
1581
+ root: _chunkZNCSOBAXjs.nn.call(void 0, state.root)
1484
1582
  };
1485
1583
  });
1486
1584
  };
@@ -1580,7 +1678,7 @@ function makeStateMachine(state, context, mockedEffects) {
1580
1678
  state.redoStack = [];
1581
1679
  }
1582
1680
  if (state.batch.ops.length > 0) {
1583
- dispatch(state.batch.ops);
1681
+ dispatchOps(state.batch.ops);
1584
1682
  }
1585
1683
  notify(state.batch.updates);
1586
1684
  state.batch = {
@@ -1614,20 +1712,65 @@ function makeStateMachine(state, context, mockedEffects) {
1614
1712
  var simulateSendCloseEvent = function simulateSendCloseEvent(event) {
1615
1713
  onClose(event);
1616
1714
  };
1715
+ var pool = {
1716
+ roomId: config.roomId,
1717
+ getNode: function(id) {
1718
+ return state.nodes.get(id);
1719
+ },
1720
+ addNode: function(id, node) {
1721
+ return void state.nodes.set(id, node);
1722
+ },
1723
+ deleteNode: function(id) {
1724
+ return void state.nodes.delete(id);
1725
+ },
1726
+ generateId: function() {
1727
+ return "".concat(getConnectionId(), ":").concat(state.clock++);
1728
+ },
1729
+ generateOpId: function() {
1730
+ return "".concat(getConnectionId(), ":").concat(state.opClock++);
1731
+ },
1732
+ dispatch: function dispatch(ops, reverse, storageUpdates) {
1733
+ if (state.isBatching) {
1734
+ var _ops, _reverseOps;
1735
+ (_ops = state.batch.ops).push.apply(_ops, _toConsumableArray(ops));
1736
+ storageUpdates.forEach(function(value, key) {
1737
+ state.batch.updates.storageUpdates.set(key, _chunkZNCSOBAXjs.mergeStorageUpdates.call(void 0, state.batch.updates.storageUpdates.get(key), value));
1738
+ });
1739
+ (_reverseOps = state.batch.reverseOps).push.apply(_reverseOps, _toConsumableArray(reverse));
1740
+ } else {
1741
+ addToUndoStack(reverse);
1742
+ state.redoStack = [];
1743
+ dispatchOps(ops);
1744
+ notify({
1745
+ storageUpdates: storageUpdates
1746
+ });
1747
+ }
1748
+ }
1749
+ };
1750
+ var eventHub = {
1751
+ customEvent: makeEventSource(),
1752
+ me: makeEventSource(),
1753
+ others: makeEventSource(),
1754
+ error: makeEventSource(),
1755
+ connection: makeEventSource(),
1756
+ storage: makeEventSource(),
1757
+ history: makeEventSource(),
1758
+ storageDidLoad: makeEventSource()
1759
+ };
1617
1760
  var effects = mockedEffects || {
1618
1761
  authenticate: function authenticate(auth, createWebSocket) {
1619
1762
  var rawToken = state.token;
1620
- var parsedToken = rawToken !== null && _chunkQLMVHHAZjs.parseRoomAuthToken.call(void 0, rawToken);
1621
- if (parsedToken && !_chunkQLMVHHAZjs.isTokenExpired.call(void 0, parsedToken)) {
1763
+ var parsedToken = rawToken !== null && _chunkZNCSOBAXjs.parseRoomAuthToken.call(void 0, rawToken);
1764
+ if (parsedToken && !_chunkZNCSOBAXjs.isTokenExpired.call(void 0, parsedToken)) {
1622
1765
  var socket = createWebSocket(rawToken);
1623
1766
  authenticationSuccess(parsedToken, socket);
1624
1767
  } else {
1625
- return auth(context.roomId).then(function(param) {
1768
+ return auth(config.roomId).then(function(param) {
1626
1769
  var token = param.token;
1627
- if (state.connection.state !== "authenticating") {
1770
+ if (state.connection.current.state !== "authenticating") {
1628
1771
  return;
1629
1772
  }
1630
- var parsedToken2 = _chunkQLMVHHAZjs.parseRoomAuthToken.call(void 0, token);
1773
+ var parsedToken2 = _chunkZNCSOBAXjs.parseRoomAuthToken.call(void 0, token);
1631
1774
  var socket = createWebSocket(token);
1632
1775
  authenticationSuccess(parsedToken2, socket);
1633
1776
  state.token = token;
@@ -1655,6 +1798,17 @@ function makeStateMachine(state, context, mockedEffects) {
1655
1798
  return setTimeout(connect, delay);
1656
1799
  }
1657
1800
  };
1801
+ var self = new DerivedRef([
1802
+ state.connection,
1803
+ state.me
1804
+ ], function(conn, me) {
1805
+ return isConnectionSelfAware(conn) ? {
1806
+ connectionId: conn.id,
1807
+ id: conn.userId,
1808
+ info: conn.userInfo,
1809
+ presence: me
1810
+ } : null;
1811
+ });
1658
1812
  var _getInitialStatePromise = null;
1659
1813
  var _getInitialStateResolver = null;
1660
1814
  return {
@@ -1670,7 +1824,7 @@ function makeStateMachine(state, context, mockedEffects) {
1670
1824
  return state.undoStack;
1671
1825
  },
1672
1826
  getItemsCount: function() {
1673
- return state.items.size;
1827
+ return state.nodes.size;
1674
1828
  },
1675
1829
  connect: connect,
1676
1830
  disconnect: disconnect,
@@ -1685,31 +1839,37 @@ function makeStateMachine(state, context, mockedEffects) {
1685
1839
  pauseHistory: pauseHistory,
1686
1840
  resumeHistory: resumeHistory,
1687
1841
  getStorage: getStorage,
1688
- selectors: {
1689
- getConnectionState: getConnectionState,
1690
- getSelf: getSelf,
1691
- getPresence: getPresence,
1692
- getOthers: getOthers
1693
- }
1842
+ getStorageSnapshot: getStorageSnapshot,
1843
+ events: {
1844
+ customEvent: eventHub.customEvent.observable,
1845
+ others: eventHub.others.observable,
1846
+ me: eventHub.me.observable,
1847
+ error: eventHub.error.observable,
1848
+ connection: eventHub.connection.observable,
1849
+ storage: eventHub.storage.observable,
1850
+ history: eventHub.history.observable,
1851
+ storageDidLoad: eventHub.storageDidLoad.observable
1852
+ },
1853
+ getConnectionState: getConnectionState,
1854
+ isSelfAware: function() {
1855
+ return isConnectionSelfAware(state.connection.current);
1856
+ },
1857
+ getSelf: function() {
1858
+ return self.current;
1859
+ },
1860
+ getPresence: getPresence,
1861
+ getOthers: getOthers
1694
1862
  };
1695
1863
  }
1696
1864
  function defaultState(initialPresence, initialStorage) {
1865
+ var others = new OthersRef();
1866
+ var connection = new ValueRef({
1867
+ state: "closed"
1868
+ });
1697
1869
  return {
1698
- connection: {
1699
- state: "closed"
1700
- },
1701
1870
  token: null,
1702
1871
  lastConnectionId: null,
1703
1872
  socket: null,
1704
- listeners: {
1705
- event: [],
1706
- others: [],
1707
- "my-presence": [],
1708
- error: [],
1709
- connection: [],
1710
- storage: [],
1711
- history: []
1712
- },
1713
1873
  numberOfRetry: 0,
1714
1874
  lastFlushTime: 0,
1715
1875
  timeoutHandles: {
@@ -1718,9 +1878,9 @@ function defaultState(initialPresence, initialStorage) {
1718
1878
  pongTimeout: 0
1719
1879
  },
1720
1880
  buffer: {
1721
- presence: {
1881
+ me: {
1722
1882
  type: "full",
1723
- data: initialPresence == null ? {} : initialPresence
1883
+ data: initialPresence
1724
1884
  },
1725
1885
  messages: [],
1726
1886
  storageOperations: []
@@ -1728,14 +1888,14 @@ function defaultState(initialPresence, initialStorage) {
1728
1888
  intervalHandles: {
1729
1889
  heartbeat: 0
1730
1890
  },
1731
- me: initialPresence == null ? {} : initialPresence,
1732
- users: {},
1733
- others: makeOthers({}),
1891
+ connection: connection,
1892
+ me: new MeRef(initialPresence),
1893
+ others: others,
1734
1894
  defaultStorageRoot: initialStorage,
1735
1895
  idFactory: null,
1736
1896
  clock: 0,
1737
1897
  opClock: 0,
1738
- items: /* @__PURE__ */ new Map(),
1898
+ nodes: /* @__PURE__ */ new Map(),
1739
1899
  root: void 0,
1740
1900
  undoStack: [],
1741
1901
  redoStack: [],
@@ -1754,25 +1914,23 @@ function defaultState(initialPresence, initialStorage) {
1754
1914
  offlineOperations: /* @__PURE__ */ new Map()
1755
1915
  };
1756
1916
  }
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);
1917
+ function createRoom(options, config) {
1918
+ var initialPresence = options.initialPresence, initialStorage = options.initialStorage;
1919
+ var state = defaultState(typeof initialPresence === "function" ? initialPresence(config.roomId) : initialPresence, typeof initialStorage === "function" ? initialStorage(config.roomId) : initialStorage);
1920
+ var machine = makeStateMachine(state, config);
1766
1921
  var room = {
1767
- id: context.roomId,
1768
- getConnectionState: machine.selectors.getConnectionState,
1769
- getSelf: machine.selectors.getSelf,
1922
+ id: config.roomId,
1923
+ getConnectionState: machine.getConnectionState,
1924
+ isSelfAware: machine.isSelfAware,
1925
+ getSelf: machine.getSelf,
1770
1926
  subscribe: machine.subscribe,
1771
- getPresence: machine.selectors.getPresence,
1927
+ getPresence: machine.getPresence,
1772
1928
  updatePresence: machine.updatePresence,
1773
- getOthers: machine.selectors.getOthers,
1929
+ getOthers: machine.getOthers,
1774
1930
  broadcastEvent: machine.broadcastEvent,
1775
1931
  getStorage: machine.getStorage,
1932
+ getStorageSnapshot: machine.getStorageSnapshot,
1933
+ events: machine.events,
1776
1934
  batch: machine.batch,
1777
1935
  history: {
1778
1936
  undo: machine.undo,
@@ -1813,7 +1971,7 @@ function prepareCreateWebSocket(liveblocksServer, WebSocketPolyfill) {
1813
1971
  }
1814
1972
  var ws = WebSocketPolyfill || WebSocket;
1815
1973
  return function(token) {
1816
- return new ws("".concat(liveblocksServer, "/?token=").concat(token, "&version=").concat(true ? "0.17.11-debug2" : "dev"));
1974
+ return new ws("".concat(liveblocksServer, "/?token=").concat(token, "&version=").concat(true ? "0.18.0-beta1" : "dev"));
1817
1975
  };
1818
1976
  }
1819
1977
  function prepareAuthEndpoint(authentication, fetchPolyfill) {
@@ -1866,7 +2024,7 @@ function fetchAuthEndpoint(fetch2, endpoint, body) {
1866
2024
  throw new AuthenticationError('Expected a JSON response when doing a POST request on "'.concat(endpoint, '". ').concat(er));
1867
2025
  });
1868
2026
  }).then(function(data) {
1869
- if (!_chunkQLMVHHAZjs.isPlainObject.call(void 0, data) || typeof data.token !== "string") {
2027
+ if (!_chunkZNCSOBAXjs.isPlainObject.call(void 0, data) || typeof data.token !== "string") {
1870
2028
  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
2029
  }
1872
2030
  var token = data.token;
@@ -1890,19 +2048,17 @@ function createClient(options) {
1890
2048
  var internalRoom = rooms.get(roomId);
1891
2049
  return internalRoom ? internalRoom.room : null;
1892
2050
  };
1893
- var enter = function enter(roomId) {
1894
- var options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2051
+ var enter = function enter(roomId, options2) {
1895
2052
  var internalRoom = rooms.get(roomId);
1896
2053
  if (internalRoom) {
1897
2054
  return internalRoom.room;
1898
2055
  }
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");
2056
+ _chunkZNCSOBAXjs.deprecateIf.call(void 0, options2.initialPresence == null, "Please provide an initial presence value for the current user when entering the room.");
1901
2057
  internalRoom = createRoom({
1902
- initialPresence: options2.initialPresence,
1903
- initialStorage: options2.initialStorage,
1904
- defaultPresence: options2.defaultPresence,
1905
- defaultStorageRoot: options2.defaultStorageRoot
2058
+ initialPresence: _nullishCoalesce(options2.initialPresence, function() {
2059
+ return {};
2060
+ }),
2061
+ initialStorage: options2.initialStorage
1906
2062
  }, {
1907
2063
  roomId: roomId,
1908
2064
  throttleDelay: throttleDelay,
@@ -2051,7 +2207,46 @@ function buildLiveblocksPublicAuthorizeEndpoint(options, roomId) {
2051
2207
  }
2052
2208
  return "https://api.liveblocks.io/v2/rooms/".concat(encodeURIComponent(roomId), "/public/authorize");
2053
2209
  }
2054
- exports.LiveList = _chunkQLMVHHAZjs.LiveList;
2055
- exports.LiveMap = _chunkQLMVHHAZjs.LiveMap;
2056
- exports.LiveObject = _chunkQLMVHHAZjs.LiveObject;
2210
+ // src/shallow.ts
2211
+ function shallowArray(xs, ys) {
2212
+ if (xs.length !== ys.length) {
2213
+ return false;
2214
+ }
2215
+ for(var i = 0; i < xs.length; i++){
2216
+ if (!Object.is(xs[i], ys[i])) {
2217
+ return false;
2218
+ }
2219
+ }
2220
+ return true;
2221
+ }
2222
+ function shallowObj(objA, objB) {
2223
+ 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]") {
2224
+ return false;
2225
+ }
2226
+ var keysA = Object.keys(objA);
2227
+ if (keysA.length !== Object.keys(objB).length) {
2228
+ return false;
2229
+ }
2230
+ return keysA.every(function(key) {
2231
+ return Object.prototype.hasOwnProperty.call(objB, key) && Object.is(objA[key], objB[key]);
2232
+ });
2233
+ }
2234
+ function shallow(a, b) {
2235
+ if (Object.is(a, b)) {
2236
+ return true;
2237
+ }
2238
+ var isArrayA = Array.isArray(a);
2239
+ var isArrayB = Array.isArray(b);
2240
+ if (isArrayA || isArrayB) {
2241
+ if (!isArrayA || !isArrayB) {
2242
+ return false;
2243
+ }
2244
+ return shallowArray(a, b);
2245
+ }
2246
+ return shallowObj(a, b);
2247
+ }
2248
+ exports.LiveList = _chunkZNCSOBAXjs.LiveList;
2249
+ exports.LiveMap = _chunkZNCSOBAXjs.LiveMap;
2250
+ exports.LiveObject = _chunkZNCSOBAXjs.LiveObject;
2057
2251
  exports.createClient = createClient;
2252
+ exports.shallow = shallow;