@liveblocks/client 0.18.0-beta0 → 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/.built-by-link-script +1 -1
- package/{chunk-ZR7CHFN6.js → chunk-ZNCSOBAX.js} +15 -0
- package/{index-4e7d8cac.d.ts → index-f955942f.d.ts} +13 -11
- package/index.d.ts +2 -2
- package/index.js +41 -51
- package/internal.d.ts +2 -2
- package/internal.js +41 -40
- package/internal.mjs +1 -0
- package/package.json +1 -1
package/.built-by-link-script
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
b52b54aa52de165ec5e85d34ab7097407a3d4df1
|
|
@@ -3674,6 +3674,20 @@ function parseRoomAuthToken(tokenString) {
|
|
|
3674
3674
|
throw new Error("Authentication error: we expected a room token but did not get one. Hint: if you are using a callback, ensure the room is passed when creating the token. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientCallback");
|
|
3675
3675
|
}
|
|
3676
3676
|
}
|
|
3677
|
+
// src/LegacyArray.ts
|
|
3678
|
+
function asArrayWithLegacyMethods(arr) {
|
|
3679
|
+
Object.defineProperty(arr, "count", {
|
|
3680
|
+
value: arr.length,
|
|
3681
|
+
enumerable: false
|
|
3682
|
+
});
|
|
3683
|
+
Object.defineProperty(arr, "toArray", {
|
|
3684
|
+
value: function() {
|
|
3685
|
+
return arr;
|
|
3686
|
+
},
|
|
3687
|
+
enumerable: false
|
|
3688
|
+
});
|
|
3689
|
+
return freeze(arr);
|
|
3690
|
+
}
|
|
3677
3691
|
// src/types/Json.ts
|
|
3678
3692
|
function isJsonScalar(data) {
|
|
3679
3693
|
return data === null || typeof data === "string" || typeof data === "number" || typeof data === "boolean";
|
|
@@ -3723,6 +3737,7 @@ exports.isAppOnlyAuthToken = isAppOnlyAuthToken;
|
|
|
3723
3737
|
exports.isRoomAuthToken = isRoomAuthToken;
|
|
3724
3738
|
exports.isAuthToken = isAuthToken;
|
|
3725
3739
|
exports.parseRoomAuthToken = parseRoomAuthToken;
|
|
3740
|
+
exports.asArrayWithLegacyMethods = asArrayWithLegacyMethods;
|
|
3726
3741
|
exports.isJsonScalar = isJsonScalar;
|
|
3727
3742
|
exports.isJsonArray = isJsonArray;
|
|
3728
3743
|
exports.isJsonObject = isJsonObject;
|
|
@@ -5,6 +5,18 @@ declare type Observable<T> = {
|
|
|
5
5
|
subscribeOnce(callback: Callback<T>): UnsubscribeCallback;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
+
declare type ReadonlyArrayWithLegacyMethods<T> = readonly T[] & {
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Prefer the normal .length property on arrays.
|
|
11
|
+
*/
|
|
12
|
+
readonly count: number;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Calling .toArray() is no longer needed
|
|
15
|
+
*/
|
|
16
|
+
readonly toArray: () => readonly T[];
|
|
17
|
+
};
|
|
18
|
+
declare function asArrayWithLegacyMethods<T>(arr: readonly T[]): ReadonlyArrayWithLegacyMethods<T>;
|
|
19
|
+
|
|
8
20
|
/**
|
|
9
21
|
* The LiveMap class is similar to a JavaScript Map that is synchronized on all clients.
|
|
10
22
|
* Keys should be a string, and values should be serializable to JSON.
|
|
@@ -452,16 +464,6 @@ declare type Client = {
|
|
|
452
464
|
*/
|
|
453
465
|
leave(roomId: string): void;
|
|
454
466
|
};
|
|
455
|
-
declare type ReadonlyArrayWithLegacyMethods<T> = readonly T[] & {
|
|
456
|
-
/**
|
|
457
|
-
* @deprecated Prefer the normal .length property on arrays.
|
|
458
|
-
*/
|
|
459
|
-
readonly count: number;
|
|
460
|
-
/**
|
|
461
|
-
* @deprecated Calling .toArray() is no longer needed
|
|
462
|
-
*/
|
|
463
|
-
readonly toArray: () => readonly T[];
|
|
464
|
-
};
|
|
465
467
|
/**
|
|
466
468
|
* Represents all the other users connected in the room. Treated as immutable.
|
|
467
469
|
*/
|
|
@@ -865,4 +867,4 @@ declare enum WebsocketCloseCodes {
|
|
|
865
867
|
CLOSE_WITHOUT_RETRY = 4999
|
|
866
868
|
}
|
|
867
869
|
|
|
868
|
-
export { BaseUserMeta as B, ClientOptions as C, History as H, Immutable as I, Json as J, LiveList as L, Others as O, Room as R, StorageUpdate as S, ToJson as T, User as U, WebsocketCloseCodes as W, Client as a, LiveMap as b, LiveObject as c, BroadcastOptions as d, ImmutableList as e, ImmutableMap as f, ImmutableObject as g, ImmutableRef as h, JsonObject as i, LiveStructure as j, Lson as k, LsonObject as l,
|
|
870
|
+
export { BaseUserMeta as B, ClientOptions as C, History as H, Immutable as I, Json as J, LiveList as L, Others as O, Room as R, StorageUpdate as S, ToJson as T, User as U, WebsocketCloseCodes as W, Client as a, LiveMap as b, LiveObject as c, BroadcastOptions as d, ImmutableList as e, ImmutableMap as f, ImmutableObject as g, ImmutableRef as h, JsonObject as i, LiveStructure as j, Lson as k, LsonObject as l, asArrayWithLegacyMethods as m, LiveNode as n, Resolve as o, RoomInitializers as p, ToImmutable as q, isJsonArray as r, isJsonObject as s, isJsonScalar as t };
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ClientOptions, a as Client } from './index-
|
|
2
|
-
export { B as BaseUserMeta, d as BroadcastOptions, a as Client, H as History, I as Immutable, e as ImmutableList, f as ImmutableMap, g as ImmutableObject, h as ImmutableRef, J as Json, i as JsonObject, L as LiveList, b as LiveMap, c as LiveObject, j as LiveStructure, k as Lson, l as LsonObject, O as Others, R as Room, S as StorageUpdate, U as User } from './index-
|
|
1
|
+
import { C as ClientOptions, a as Client } from './index-f955942f.js';
|
|
2
|
+
export { B as BaseUserMeta, d as BroadcastOptions, a as Client, H as History, I as Immutable, e as ImmutableList, f as ImmutableMap, g as ImmutableObject, h as ImmutableRef, J as Json, i as JsonObject, L as LiveList, b as LiveMap, c as LiveObject, j as LiveStructure, k as Lson, l as LsonObject, O as Others, R as Room, S as StorageUpdate, U as User } from './index-f955942f.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Create a client that will be responsible to communicate with liveblocks servers.
|
package/index.js
CHANGED
|
@@ -297,7 +297,7 @@ function _optionalChain(ops) {
|
|
|
297
297
|
}
|
|
298
298
|
return value;
|
|
299
299
|
}
|
|
300
|
-
var
|
|
300
|
+
var _chunkZNCSOBAXjs = require("./chunk-ZNCSOBAX.js");
|
|
301
301
|
// src/EventSource.ts
|
|
302
302
|
function makeEventSource() {
|
|
303
303
|
var subscribe = function subscribe(callback) {
|
|
@@ -397,7 +397,7 @@ var MeRef = /*#__PURE__*/ function(ImmutableRef) {
|
|
|
397
397
|
_classCallCheck(this, MeRef);
|
|
398
398
|
var _this;
|
|
399
399
|
_this = _super.call(this);
|
|
400
|
-
_this._me =
|
|
400
|
+
_this._me = _chunkZNCSOBAXjs.freeze.call(void 0, _chunkZNCSOBAXjs.compactObject.call(void 0, initialPresence));
|
|
401
401
|
return _this;
|
|
402
402
|
}
|
|
403
403
|
_createClass(MeRef, [
|
|
@@ -413,7 +413,7 @@ var MeRef = /*#__PURE__*/ function(ImmutableRef) {
|
|
|
413
413
|
var oldMe = this._me;
|
|
414
414
|
var newMe = merge(oldMe, patch1);
|
|
415
415
|
if (oldMe !== newMe) {
|
|
416
|
-
this._me =
|
|
416
|
+
this._me = _chunkZNCSOBAXjs.freeze.call(void 0, newMe);
|
|
417
417
|
this.invalidate();
|
|
418
418
|
}
|
|
419
419
|
}
|
|
@@ -423,7 +423,7 @@ var MeRef = /*#__PURE__*/ function(ImmutableRef) {
|
|
|
423
423
|
}(ImmutableRef);
|
|
424
424
|
// src/OthersRef.ts
|
|
425
425
|
function makeUser(conn, presence) {
|
|
426
|
-
return
|
|
426
|
+
return _chunkZNCSOBAXjs.freeze.call(void 0, _chunkZNCSOBAXjs.compactObject.call(void 0, _objectSpreadProps(_objectSpread({}, conn), {
|
|
427
427
|
presence: presence
|
|
428
428
|
})));
|
|
429
429
|
}
|
|
@@ -444,20 +444,10 @@ var OthersRef = /*#__PURE__*/ function(ImmutableRef) {
|
|
|
444
444
|
key: "_toImmutable",
|
|
445
445
|
value: function _toImmutable() {
|
|
446
446
|
var _this = this;
|
|
447
|
-
var users =
|
|
447
|
+
var users = _chunkZNCSOBAXjs.compact.call(void 0, Object.keys(this._presences).map(function(connectionId) {
|
|
448
448
|
return _this.getUser(Number(connectionId));
|
|
449
449
|
}));
|
|
450
|
-
|
|
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);
|
|
450
|
+
return _chunkZNCSOBAXjs.asArrayWithLegacyMethods.call(void 0, users);
|
|
461
451
|
}
|
|
462
452
|
},
|
|
463
453
|
{
|
|
@@ -507,7 +497,7 @@ var OthersRef = /*#__PURE__*/ function(ImmutableRef) {
|
|
|
507
497
|
{
|
|
508
498
|
key: "setConnection",
|
|
509
499
|
value: function setConnection(connectionId, metaUserId, metaUserInfo) {
|
|
510
|
-
this._connections[connectionId] =
|
|
500
|
+
this._connections[connectionId] = _chunkZNCSOBAXjs.freeze.call(void 0, {
|
|
511
501
|
connectionId: connectionId,
|
|
512
502
|
id: metaUserId,
|
|
513
503
|
info: metaUserInfo
|
|
@@ -528,7 +518,7 @@ var OthersRef = /*#__PURE__*/ function(ImmutableRef) {
|
|
|
528
518
|
{
|
|
529
519
|
key: "setOther",
|
|
530
520
|
value: function setOther(connectionId, presence) {
|
|
531
|
-
this._presences[connectionId] =
|
|
521
|
+
this._presences[connectionId] = _chunkZNCSOBAXjs.freeze.call(void 0, _chunkZNCSOBAXjs.compactObject.call(void 0, presence));
|
|
532
522
|
if (this._connections[connectionId] !== void 0) {
|
|
533
523
|
this._invalidateUser(connectionId);
|
|
534
524
|
}
|
|
@@ -543,7 +533,7 @@ var OthersRef = /*#__PURE__*/ function(ImmutableRef) {
|
|
|
543
533
|
}
|
|
544
534
|
var newPresence = merge(oldPresence, patch);
|
|
545
535
|
if (oldPresence !== newPresence) {
|
|
546
|
-
this._presences[connectionId] =
|
|
536
|
+
this._presences[connectionId] = _chunkZNCSOBAXjs.freeze.call(void 0, newPresence);
|
|
547
537
|
this._invalidateUser(connectionId);
|
|
548
538
|
}
|
|
549
539
|
}
|
|
@@ -559,7 +549,7 @@ var ValueRef = /*#__PURE__*/ function(ImmutableRef) {
|
|
|
559
549
|
_classCallCheck(this, ValueRef);
|
|
560
550
|
var _this;
|
|
561
551
|
_this = _super.call(this);
|
|
562
|
-
_this._value =
|
|
552
|
+
_this._value = _chunkZNCSOBAXjs.freeze.call(void 0, _chunkZNCSOBAXjs.compactObject.call(void 0, initialValue));
|
|
563
553
|
return _this;
|
|
564
554
|
}
|
|
565
555
|
_createClass(ValueRef, [
|
|
@@ -572,7 +562,7 @@ var ValueRef = /*#__PURE__*/ function(ImmutableRef) {
|
|
|
572
562
|
{
|
|
573
563
|
key: "set",
|
|
574
564
|
value: function set(newValue) {
|
|
575
|
-
this._value =
|
|
565
|
+
this._value = _chunkZNCSOBAXjs.freeze.call(void 0, newValue);
|
|
576
566
|
this.invalidate();
|
|
577
567
|
}
|
|
578
568
|
}
|
|
@@ -661,7 +651,7 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
661
651
|
try {
|
|
662
652
|
for(var _iterator = items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
663
653
|
var _value = _slicedToArray(_step.value, 2), id = _value[0], crdt = _value[1];
|
|
664
|
-
if (
|
|
654
|
+
if (_chunkZNCSOBAXjs.isRootCrdt.call(void 0, crdt)) {
|
|
665
655
|
root = [
|
|
666
656
|
id,
|
|
667
657
|
crdt
|
|
@@ -711,13 +701,13 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
711
701
|
state.nodes.forEach(function(node, id) {
|
|
712
702
|
currentItems.set(id, node._serialize());
|
|
713
703
|
});
|
|
714
|
-
var ops =
|
|
704
|
+
var ops = _chunkZNCSOBAXjs.getTreesDiffOperations.call(void 0, currentItems, new Map(items));
|
|
715
705
|
var result = apply(ops, false);
|
|
716
706
|
notify(result.updates);
|
|
717
707
|
};
|
|
718
708
|
var load = function load(items) {
|
|
719
709
|
var ref = _slicedToArray(buildRootAndParentToChildren(items), 2), root = ref[0], parentToChildren = ref[1];
|
|
720
|
-
return
|
|
710
|
+
return _chunkZNCSOBAXjs.LiveObject._deserialize(root, parentToChildren, pool);
|
|
721
711
|
};
|
|
722
712
|
var addToUndoStack = function addToUndoStack(historyItem) {
|
|
723
713
|
if (state.undoStack.length >= 50) {
|
|
@@ -818,19 +808,19 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
818
808
|
if (isLocal) {
|
|
819
809
|
source = 0 /* UNDOREDO_RECONNECT */ ;
|
|
820
810
|
} else {
|
|
821
|
-
var deleted = state.offlineOperations.delete(
|
|
811
|
+
var deleted = state.offlineOperations.delete(_chunkZNCSOBAXjs.nn.call(void 0, op.opId));
|
|
822
812
|
source = deleted ? 2 /* ACK */ : 1 /* REMOTE */ ;
|
|
823
813
|
}
|
|
824
814
|
var applyOpResult = applyOp(op, source);
|
|
825
815
|
if (applyOpResult.modified) {
|
|
826
|
-
var parentId = applyOpResult.modified.node.parent.type === "HasParent" ?
|
|
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;
|
|
827
817
|
if (!parentId || !createdNodeIds.has(parentId)) {
|
|
828
818
|
var _reverse;
|
|
829
|
-
result.updates.storageUpdates.set(
|
|
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));
|
|
830
820
|
(_reverse = result.reverse).unshift.apply(_reverse, _toConsumableArray(applyOpResult.reverse));
|
|
831
821
|
}
|
|
832
822
|
if (op.type === 2 /* CREATE_LIST */ || op.type === 7 /* CREATE_MAP */ || op.type === 4 /* CREATE_OBJECT */ ) {
|
|
833
|
-
createdNodeIds.add(
|
|
823
|
+
createdNodeIds.add(_chunkZNCSOBAXjs.nn.call(void 0, applyOpResult.modified.node._id));
|
|
834
824
|
}
|
|
835
825
|
}
|
|
836
826
|
}
|
|
@@ -873,7 +863,7 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
873
863
|
modified: false
|
|
874
864
|
};
|
|
875
865
|
}
|
|
876
|
-
if (node1.parent.type === "HasParent" &&
|
|
866
|
+
if (node1.parent.type === "HasParent" && _chunkZNCSOBAXjs.isLiveList.call(void 0, node1.parent.node)) {
|
|
877
867
|
return node1.parent.node._setChildKey(op.parentKey, node1, source);
|
|
878
868
|
}
|
|
879
869
|
return {
|
|
@@ -903,7 +893,7 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
903
893
|
var subscribeToLiveStructureDeeply = function subscribeToLiveStructureDeeply(node, callback) {
|
|
904
894
|
return eventHub.storage.subscribe(function(updates) {
|
|
905
895
|
var relatedUpdates = updates.filter(function(update) {
|
|
906
|
-
return
|
|
896
|
+
return _chunkZNCSOBAXjs.isSameNodeOrChildOf.call(void 0, update.node, node);
|
|
907
897
|
});
|
|
908
898
|
if (relatedUpdates.length > 0) {
|
|
909
899
|
callback(relatedUpdates);
|
|
@@ -937,7 +927,7 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
937
927
|
});
|
|
938
928
|
};
|
|
939
929
|
var subscribe = function subscribe(first, second, options) {
|
|
940
|
-
if (typeof first === "string" &&
|
|
930
|
+
if (typeof first === "string" && _chunkZNCSOBAXjs.isRoomEventName.call(void 0, first)) {
|
|
941
931
|
if (typeof second !== "function") {
|
|
942
932
|
throw new Error("Second argument must be a callback function");
|
|
943
933
|
}
|
|
@@ -964,7 +954,7 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
964
954
|
case "history":
|
|
965
955
|
return eventHub.history.subscribe(callback);
|
|
966
956
|
default:
|
|
967
|
-
return
|
|
957
|
+
return _chunkZNCSOBAXjs.assertNever.call(void 0, first, "Unknown event");
|
|
968
958
|
}
|
|
969
959
|
}
|
|
970
960
|
if (second === void 0 || typeof first === "function") {
|
|
@@ -975,7 +965,7 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
975
965
|
throw new Error("Please specify a listener callback");
|
|
976
966
|
}
|
|
977
967
|
}
|
|
978
|
-
if (
|
|
968
|
+
if (_chunkZNCSOBAXjs.isLiveNode.call(void 0, first)) {
|
|
979
969
|
var node = first;
|
|
980
970
|
if (_optionalChain([
|
|
981
971
|
options,
|
|
@@ -1187,21 +1177,21 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
1187
1177
|
} : void 0;
|
|
1188
1178
|
};
|
|
1189
1179
|
var parseServerMessage = function parseServerMessage(data) {
|
|
1190
|
-
if (!
|
|
1180
|
+
if (!_chunkZNCSOBAXjs.isJsonObject.call(void 0, data)) {
|
|
1191
1181
|
return null;
|
|
1192
1182
|
}
|
|
1193
1183
|
return data;
|
|
1194
1184
|
};
|
|
1195
1185
|
var parseServerMessages = function parseServerMessages(text) {
|
|
1196
|
-
var data =
|
|
1186
|
+
var data = _chunkZNCSOBAXjs.tryParseJson.call(void 0, text);
|
|
1197
1187
|
if (data === void 0) {
|
|
1198
1188
|
return null;
|
|
1199
|
-
} else if (
|
|
1200
|
-
return
|
|
1189
|
+
} else if (_chunkZNCSOBAXjs.isJsonArray.call(void 0, data)) {
|
|
1190
|
+
return _chunkZNCSOBAXjs.compact.call(void 0, data.map(function(item) {
|
|
1201
1191
|
return parseServerMessage(item);
|
|
1202
1192
|
}));
|
|
1203
1193
|
} else {
|
|
1204
|
-
return
|
|
1194
|
+
return _chunkZNCSOBAXjs.compact.call(void 0, [
|
|
1205
1195
|
parseServerMessage(data)
|
|
1206
1196
|
]);
|
|
1207
1197
|
}
|
|
@@ -1280,7 +1270,7 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
1280
1270
|
{
|
|
1281
1271
|
var applyResult = apply(message.ops, false);
|
|
1282
1272
|
applyResult.updates.storageUpdates.forEach(function(value, key) {
|
|
1283
|
-
updates.storageUpdates.set(key,
|
|
1273
|
+
updates.storageUpdates.set(key, _chunkZNCSOBAXjs.mergeStorageUpdates.call(void 0, updates.storageUpdates.get(key), value));
|
|
1284
1274
|
});
|
|
1285
1275
|
break;
|
|
1286
1276
|
}
|
|
@@ -1437,7 +1427,7 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
1437
1427
|
var storageOps = state.buffer.storageOperations;
|
|
1438
1428
|
if (storageOps.length > 0) {
|
|
1439
1429
|
storageOps.forEach(function(op) {
|
|
1440
|
-
state.offlineOperations.set(
|
|
1430
|
+
state.offlineOperations.set(_chunkZNCSOBAXjs.nn.call(void 0, op.opId), op);
|
|
1441
1431
|
});
|
|
1442
1432
|
}
|
|
1443
1433
|
if (state.socket == null || state.socket.readyState !== state.socket.OPEN) {
|
|
@@ -1588,7 +1578,7 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
1588
1578
|
}
|
|
1589
1579
|
return startLoadingStorage().then(function() {
|
|
1590
1580
|
return {
|
|
1591
|
-
root:
|
|
1581
|
+
root: _chunkZNCSOBAXjs.nn.call(void 0, state.root)
|
|
1592
1582
|
};
|
|
1593
1583
|
});
|
|
1594
1584
|
};
|
|
@@ -1744,7 +1734,7 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
1744
1734
|
var _ops, _reverseOps;
|
|
1745
1735
|
(_ops = state.batch.ops).push.apply(_ops, _toConsumableArray(ops));
|
|
1746
1736
|
storageUpdates.forEach(function(value, key) {
|
|
1747
|
-
state.batch.updates.storageUpdates.set(key,
|
|
1737
|
+
state.batch.updates.storageUpdates.set(key, _chunkZNCSOBAXjs.mergeStorageUpdates.call(void 0, state.batch.updates.storageUpdates.get(key), value));
|
|
1748
1738
|
});
|
|
1749
1739
|
(_reverseOps = state.batch.reverseOps).push.apply(_reverseOps, _toConsumableArray(reverse));
|
|
1750
1740
|
} else {
|
|
@@ -1770,8 +1760,8 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
1770
1760
|
var effects = mockedEffects || {
|
|
1771
1761
|
authenticate: function authenticate(auth, createWebSocket) {
|
|
1772
1762
|
var rawToken = state.token;
|
|
1773
|
-
var parsedToken = rawToken !== null &&
|
|
1774
|
-
if (parsedToken && !
|
|
1763
|
+
var parsedToken = rawToken !== null && _chunkZNCSOBAXjs.parseRoomAuthToken.call(void 0, rawToken);
|
|
1764
|
+
if (parsedToken && !_chunkZNCSOBAXjs.isTokenExpired.call(void 0, parsedToken)) {
|
|
1775
1765
|
var socket = createWebSocket(rawToken);
|
|
1776
1766
|
authenticationSuccess(parsedToken, socket);
|
|
1777
1767
|
} else {
|
|
@@ -1780,7 +1770,7 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
1780
1770
|
if (state.connection.current.state !== "authenticating") {
|
|
1781
1771
|
return;
|
|
1782
1772
|
}
|
|
1783
|
-
var parsedToken2 =
|
|
1773
|
+
var parsedToken2 = _chunkZNCSOBAXjs.parseRoomAuthToken.call(void 0, token);
|
|
1784
1774
|
var socket = createWebSocket(token);
|
|
1785
1775
|
authenticationSuccess(parsedToken2, socket);
|
|
1786
1776
|
state.token = token;
|
|
@@ -1981,7 +1971,7 @@ function prepareCreateWebSocket(liveblocksServer, WebSocketPolyfill) {
|
|
|
1981
1971
|
}
|
|
1982
1972
|
var ws = WebSocketPolyfill || WebSocket;
|
|
1983
1973
|
return function(token) {
|
|
1984
|
-
return new ws("".concat(liveblocksServer, "/?token=").concat(token, "&version=").concat(true ? "0.18.0-
|
|
1974
|
+
return new ws("".concat(liveblocksServer, "/?token=").concat(token, "&version=").concat(true ? "0.18.0-beta1" : "dev"));
|
|
1985
1975
|
};
|
|
1986
1976
|
}
|
|
1987
1977
|
function prepareAuthEndpoint(authentication, fetchPolyfill) {
|
|
@@ -2034,7 +2024,7 @@ function fetchAuthEndpoint(fetch2, endpoint, body) {
|
|
|
2034
2024
|
throw new AuthenticationError('Expected a JSON response when doing a POST request on "'.concat(endpoint, '". ').concat(er));
|
|
2035
2025
|
});
|
|
2036
2026
|
}).then(function(data) {
|
|
2037
|
-
if (!
|
|
2027
|
+
if (!_chunkZNCSOBAXjs.isPlainObject.call(void 0, data) || typeof data.token !== "string") {
|
|
2038
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)));
|
|
2039
2029
|
}
|
|
2040
2030
|
var token = data.token;
|
|
@@ -2063,7 +2053,7 @@ function createClient(options) {
|
|
|
2063
2053
|
if (internalRoom) {
|
|
2064
2054
|
return internalRoom.room;
|
|
2065
2055
|
}
|
|
2066
|
-
|
|
2056
|
+
_chunkZNCSOBAXjs.deprecateIf.call(void 0, options2.initialPresence == null, "Please provide an initial presence value for the current user when entering the room.");
|
|
2067
2057
|
internalRoom = createRoom({
|
|
2068
2058
|
initialPresence: _nullishCoalesce(options2.initialPresence, function() {
|
|
2069
2059
|
return {};
|
|
@@ -2255,8 +2245,8 @@ function shallow(a, b) {
|
|
|
2255
2245
|
}
|
|
2256
2246
|
return shallowObj(a, b);
|
|
2257
2247
|
}
|
|
2258
|
-
exports.LiveList =
|
|
2259
|
-
exports.LiveMap =
|
|
2260
|
-
exports.LiveObject =
|
|
2248
|
+
exports.LiveList = _chunkZNCSOBAXjs.LiveList;
|
|
2249
|
+
exports.LiveMap = _chunkZNCSOBAXjs.LiveMap;
|
|
2250
|
+
exports.LiveObject = _chunkZNCSOBAXjs.LiveObject;
|
|
2261
2251
|
exports.createClient = createClient;
|
|
2262
2252
|
exports.shallow = shallow;
|
package/internal.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as JsonObject, J as Json, B as BaseUserMeta, k as Lson, l as LsonObject, c as LiveObject, S as StorageUpdate } from './index-
|
|
2
|
-
export {
|
|
1
|
+
import { i as JsonObject, J as Json, B as BaseUserMeta, k as Lson, l as LsonObject, c as LiveObject, S as StorageUpdate } from './index-f955942f.js';
|
|
2
|
+
export { n as LiveNode, o as Resolve, p as RoomInitializers, q as ToImmutable, T as ToJson, W as WebsocketCloseCodes, m as asArrayWithLegacyMethods, r as isJsonArray, s as isJsonObject, t as isJsonScalar } from './index-f955942f.js';
|
|
3
3
|
|
|
4
4
|
declare enum OpCode {
|
|
5
5
|
INIT = 0,
|
package/internal.js
CHANGED
|
@@ -148,7 +148,7 @@ function _optionalChain(ops) {
|
|
|
148
148
|
}
|
|
149
149
|
return value;
|
|
150
150
|
}
|
|
151
|
-
var
|
|
151
|
+
var _chunkZNCSOBAXjs = require("./chunk-ZNCSOBAX.js");
|
|
152
152
|
// src/immutable.ts
|
|
153
153
|
function lsonObjectToJson(obj) {
|
|
154
154
|
var result = {};
|
|
@@ -194,26 +194,26 @@ function liveListToJson(value) {
|
|
|
194
194
|
return lsonListToJson(value.toArray());
|
|
195
195
|
}
|
|
196
196
|
function lsonToJson(value) {
|
|
197
|
-
if (_instanceof(value,
|
|
197
|
+
if (_instanceof(value, _chunkZNCSOBAXjs.LiveObject)) {
|
|
198
198
|
return liveObjectToJson(value);
|
|
199
|
-
} else if (_instanceof(value,
|
|
199
|
+
} else if (_instanceof(value, _chunkZNCSOBAXjs.LiveList)) {
|
|
200
200
|
return liveListToJson(value);
|
|
201
|
-
} else if (_instanceof(value,
|
|
201
|
+
} else if (_instanceof(value, _chunkZNCSOBAXjs.LiveMap)) {
|
|
202
202
|
return liveMapToJson(value);
|
|
203
|
-
} else if (_instanceof(value,
|
|
203
|
+
} else if (_instanceof(value, _chunkZNCSOBAXjs.LiveRegister)) {
|
|
204
204
|
return value.data;
|
|
205
205
|
}
|
|
206
206
|
if (Array.isArray(value)) {
|
|
207
207
|
return lsonListToJson(value);
|
|
208
|
-
} else if (
|
|
208
|
+
} else if (_chunkZNCSOBAXjs.isPlainObject.call(void 0, value)) {
|
|
209
209
|
return lsonObjectToJson(value);
|
|
210
210
|
}
|
|
211
211
|
return value;
|
|
212
212
|
}
|
|
213
213
|
function deepLiveify(value) {
|
|
214
214
|
if (Array.isArray(value)) {
|
|
215
|
-
return new (0,
|
|
216
|
-
} else if (
|
|
215
|
+
return new (0, _chunkZNCSOBAXjs.LiveList)(value.map(deepLiveify));
|
|
216
|
+
} else if (_chunkZNCSOBAXjs.isPlainObject.call(void 0, value)) {
|
|
217
217
|
var init = {};
|
|
218
218
|
for(var key in value){
|
|
219
219
|
var val = value[key];
|
|
@@ -222,7 +222,7 @@ function deepLiveify(value) {
|
|
|
222
222
|
}
|
|
223
223
|
init[key] = deepLiveify(val);
|
|
224
224
|
}
|
|
225
|
-
return new (0,
|
|
225
|
+
return new (0, _chunkZNCSOBAXjs.LiveObject)(init);
|
|
226
226
|
} else {
|
|
227
227
|
return value;
|
|
228
228
|
}
|
|
@@ -272,7 +272,7 @@ function patchLiveList(liveList, prev, next) {
|
|
|
272
272
|
prevNode = prev[i];
|
|
273
273
|
nextNode = next[i];
|
|
274
274
|
var liveListNode = liveList.get(i);
|
|
275
|
-
if (
|
|
275
|
+
if (_chunkZNCSOBAXjs.isLiveObject.call(void 0, liveListNode) && _chunkZNCSOBAXjs.isPlainObject.call(void 0, prevNode) && _chunkZNCSOBAXjs.isPlainObject.call(void 0, nextNode)) {
|
|
276
276
|
patchLiveObject(liveListNode, prevNode, nextNode);
|
|
277
277
|
} else {
|
|
278
278
|
liveList.set(i, deepLiveify(nextNode));
|
|
@@ -292,7 +292,7 @@ function patchLiveList(liveList, prev, next) {
|
|
|
292
292
|
}
|
|
293
293
|
function patchLiveObjectKey(liveObject, key, prev, next) {
|
|
294
294
|
if (process.env.NODE_ENV !== "production") {
|
|
295
|
-
var nonSerializableValue =
|
|
295
|
+
var nonSerializableValue = _chunkZNCSOBAXjs.findNonSerializableValue.call(void 0, next);
|
|
296
296
|
if (nonSerializableValue) {
|
|
297
297
|
console.error("New state path: '".concat(nonSerializableValue.path, "' value: '").concat(nonSerializableValue.value, "' is not serializable.\nOnly serializable value can be synced with Liveblocks."));
|
|
298
298
|
return;
|
|
@@ -305,9 +305,9 @@ function patchLiveObjectKey(liveObject, key, prev, next) {
|
|
|
305
305
|
liveObject.set(key, deepLiveify(next));
|
|
306
306
|
} else if (prev === next) {
|
|
307
307
|
return;
|
|
308
|
-
} else if (
|
|
308
|
+
} else if (_chunkZNCSOBAXjs.isLiveList.call(void 0, value) && Array.isArray(prev) && Array.isArray(next)) {
|
|
309
309
|
patchLiveList(value, prev, next);
|
|
310
|
-
} else if (
|
|
310
|
+
} else if (_chunkZNCSOBAXjs.isLiveObject.call(void 0, value) && _chunkZNCSOBAXjs.isPlainObject.call(void 0, prev) && _chunkZNCSOBAXjs.isPlainObject.call(void 0, next)) {
|
|
311
311
|
patchLiveObject(value, prev, next);
|
|
312
312
|
} else {
|
|
313
313
|
liveObject.set(key, deepLiveify(next));
|
|
@@ -330,7 +330,7 @@ function patchLiveObject(root, prev, next) {
|
|
|
330
330
|
function getParentsPath(node) {
|
|
331
331
|
var path = [];
|
|
332
332
|
while(node.parent.type === "HasParent"){
|
|
333
|
-
if (
|
|
333
|
+
if (_chunkZNCSOBAXjs.isLiveList.call(void 0, node.parent.node)) {
|
|
334
334
|
path.push(node.parent.node._indexOfPosition(node.parent.key));
|
|
335
335
|
} else {
|
|
336
336
|
path.push(node.parent.key);
|
|
@@ -518,32 +518,33 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
518
518
|
return state;
|
|
519
519
|
}
|
|
520
520
|
}
|
|
521
|
-
exports.ClientMsgCode =
|
|
522
|
-
exports.CrdtType =
|
|
523
|
-
exports.OpCode =
|
|
524
|
-
exports.ServerMsgCode =
|
|
525
|
-
exports.WebsocketCloseCodes =
|
|
526
|
-
exports.
|
|
527
|
-
exports.
|
|
528
|
-
exports.
|
|
529
|
-
exports.
|
|
530
|
-
exports.
|
|
531
|
-
exports.
|
|
532
|
-
exports.
|
|
533
|
-
exports.
|
|
534
|
-
exports.
|
|
535
|
-
exports.
|
|
536
|
-
exports.
|
|
537
|
-
exports.
|
|
538
|
-
exports.
|
|
539
|
-
exports.
|
|
540
|
-
exports.
|
|
541
|
-
exports.
|
|
542
|
-
exports.
|
|
521
|
+
exports.ClientMsgCode = _chunkZNCSOBAXjs.ClientMsgCode;
|
|
522
|
+
exports.CrdtType = _chunkZNCSOBAXjs.CrdtType;
|
|
523
|
+
exports.OpCode = _chunkZNCSOBAXjs.OpCode;
|
|
524
|
+
exports.ServerMsgCode = _chunkZNCSOBAXjs.ServerMsgCode;
|
|
525
|
+
exports.WebsocketCloseCodes = _chunkZNCSOBAXjs.WebsocketCloseCodes;
|
|
526
|
+
exports.asArrayWithLegacyMethods = _chunkZNCSOBAXjs.asArrayWithLegacyMethods;
|
|
527
|
+
exports.assertNever = _chunkZNCSOBAXjs.assertNever;
|
|
528
|
+
exports.b64decode = _chunkZNCSOBAXjs.b64decode;
|
|
529
|
+
exports.comparePosition = _chunkZNCSOBAXjs.comparePosition;
|
|
530
|
+
exports.deprecate = _chunkZNCSOBAXjs.deprecate;
|
|
531
|
+
exports.deprecateIf = _chunkZNCSOBAXjs.deprecateIf;
|
|
532
|
+
exports.errorIf = _chunkZNCSOBAXjs.errorIf;
|
|
533
|
+
exports.freeze = _chunkZNCSOBAXjs.freeze;
|
|
534
|
+
exports.isAppOnlyAuthToken = _chunkZNCSOBAXjs.isAppOnlyAuthToken;
|
|
535
|
+
exports.isAuthToken = _chunkZNCSOBAXjs.isAuthToken;
|
|
536
|
+
exports.isChildCrdt = _chunkZNCSOBAXjs.isChildCrdt;
|
|
537
|
+
exports.isJsonArray = _chunkZNCSOBAXjs.isJsonArray;
|
|
538
|
+
exports.isJsonObject = _chunkZNCSOBAXjs.isJsonObject;
|
|
539
|
+
exports.isJsonScalar = _chunkZNCSOBAXjs.isJsonScalar;
|
|
540
|
+
exports.isPlainObject = _chunkZNCSOBAXjs.isPlainObject;
|
|
541
|
+
exports.isRoomAuthToken = _chunkZNCSOBAXjs.isRoomAuthToken;
|
|
542
|
+
exports.isRootCrdt = _chunkZNCSOBAXjs.isRootCrdt;
|
|
543
|
+
exports.isScope = _chunkZNCSOBAXjs.isScope;
|
|
543
544
|
exports.legacy_patchImmutableObject = legacy_patchImmutableObject;
|
|
544
545
|
exports.lsonToJson = lsonToJson;
|
|
545
|
-
exports.makePosition =
|
|
546
|
-
exports.nn =
|
|
546
|
+
exports.makePosition = _chunkZNCSOBAXjs.makePosition;
|
|
547
|
+
exports.nn = _chunkZNCSOBAXjs.nn;
|
|
547
548
|
exports.patchLiveObjectKey = patchLiveObjectKey;
|
|
548
|
-
exports.throwUsageError =
|
|
549
|
-
exports.tryParseJson =
|
|
549
|
+
exports.throwUsageError = _chunkZNCSOBAXjs.throwUsageError;
|
|
550
|
+
exports.tryParseJson = _chunkZNCSOBAXjs.tryParseJson;
|
package/internal.mjs
CHANGED
|
@@ -6,6 +6,7 @@ export const CrdtType = mod.CrdtType;
|
|
|
6
6
|
export const OpCode = mod.OpCode;
|
|
7
7
|
export const ServerMsgCode = mod.ServerMsgCode;
|
|
8
8
|
export const WebsocketCloseCodes = mod.WebsocketCloseCodes;
|
|
9
|
+
export const asArrayWithLegacyMethods = mod.asArrayWithLegacyMethods;
|
|
9
10
|
export const assertNever = mod.assertNever;
|
|
10
11
|
export const b64decode = mod.b64decode;
|
|
11
12
|
export const comparePosition = mod.comparePosition;
|