@liveblocks/client 0.17.6 → 0.17.9
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 -0
- package/chunk-QLMVHHAZ.js +3592 -0
- package/index-0007883d.d.ts +793 -0
- package/index.d.ts +7 -27
- package/index.js +2007 -1269
- package/index.mjs +7 -1114
- package/internal.d.ts +198 -307
- package/internal.js +526 -309
- package/internal.mjs +30 -281
- package/package.json +1 -1
- package/shared.d.ts +0 -855
- package/shared.js +0 -2655
- package/shared.mjs +0 -2069
package/internal.js
CHANGED
|
@@ -1,331 +1,548 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
function _arrayLikeToArray(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _arrayWithHoles(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return arr;
|
|
9
|
+
}
|
|
10
|
+
function _arrayWithoutHoles(arr) {
|
|
11
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
12
|
+
}
|
|
13
|
+
function _defineProperty(obj, key, value) {
|
|
14
|
+
if (key in obj) {
|
|
15
|
+
Object.defineProperty(obj, key, {
|
|
16
|
+
value: value,
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true
|
|
20
|
+
});
|
|
21
|
+
} else {
|
|
22
|
+
obj[key] = value;
|
|
23
|
+
}
|
|
24
|
+
return obj;
|
|
25
|
+
}
|
|
26
|
+
function _instanceof(left, right) {
|
|
27
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
28
|
+
return !!right[Symbol.hasInstance](left);
|
|
29
|
+
} else {
|
|
30
|
+
return left instanceof right;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function _iterableToArray(iter) {
|
|
34
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
35
|
+
}
|
|
36
|
+
function _iterableToArrayLimit(arr, i) {
|
|
37
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
38
|
+
if (_i == null) return;
|
|
39
|
+
var _arr = [];
|
|
40
|
+
var _n = true;
|
|
41
|
+
var _d = false;
|
|
42
|
+
var _s, _e;
|
|
43
|
+
try {
|
|
44
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
45
|
+
_arr.push(_s.value);
|
|
46
|
+
if (i && _arr.length === i) break;
|
|
47
|
+
}
|
|
48
|
+
} catch (err) {
|
|
49
|
+
_d = true;
|
|
50
|
+
_e = err;
|
|
51
|
+
} finally{
|
|
52
|
+
try {
|
|
53
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
54
|
+
} finally{
|
|
55
|
+
if (_d) throw _e;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return _arr;
|
|
59
|
+
}
|
|
60
|
+
function _nonIterableRest() {
|
|
61
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
62
|
+
}
|
|
63
|
+
function _nonIterableSpread() {
|
|
64
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
65
|
+
}
|
|
66
|
+
function _objectSpread(target) {
|
|
67
|
+
for(var i = 1; i < arguments.length; i++){
|
|
68
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
69
|
+
var ownKeys = Object.keys(source);
|
|
70
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
71
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
72
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
ownKeys.forEach(function(key) {
|
|
76
|
+
_defineProperty(target, key, source[key]);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return target;
|
|
80
|
+
}
|
|
81
|
+
function ownKeys(object, enumerableOnly) {
|
|
82
|
+
var keys = Object.keys(object);
|
|
83
|
+
if (Object.getOwnPropertySymbols) {
|
|
84
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
85
|
+
if (enumerableOnly) {
|
|
86
|
+
symbols = symbols.filter(function(sym) {
|
|
87
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
keys.push.apply(keys, symbols);
|
|
91
|
+
}
|
|
92
|
+
return keys;
|
|
93
|
+
}
|
|
94
|
+
function _objectSpreadProps(target, source) {
|
|
95
|
+
source = source != null ? source : {};
|
|
96
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
97
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
98
|
+
} else {
|
|
99
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
100
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return target;
|
|
104
|
+
}
|
|
105
|
+
function _slicedToArray(arr, i) {
|
|
106
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
107
|
+
}
|
|
108
|
+
function _toConsumableArray(arr) {
|
|
109
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
110
|
+
}
|
|
111
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
112
|
+
if (!o) return;
|
|
113
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
114
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
115
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
116
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
117
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
118
|
+
}
|
|
119
|
+
Object.defineProperty(exports, "__esModule", {
|
|
120
|
+
value: true
|
|
121
|
+
});
|
|
122
|
+
function _optionalChain(ops) {
|
|
123
|
+
var lastAccessLHS = undefined;
|
|
124
|
+
var value = ops[0];
|
|
125
|
+
var i = 1;
|
|
126
|
+
while(i < ops.length){
|
|
127
|
+
var op = ops[i];
|
|
128
|
+
var fn = ops[i + 1];
|
|
129
|
+
i += 2;
|
|
130
|
+
if ((op === "optionalAccess" || op === "optionalCall") && value == null) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
if (op === "access" || op === "optionalAccess") {
|
|
134
|
+
lastAccessLHS = value;
|
|
135
|
+
value = fn(value);
|
|
136
|
+
} else if (op === "call" || op === "optionalCall") {
|
|
137
|
+
var _value;
|
|
138
|
+
value = fn(function() {
|
|
139
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
140
|
+
args[_key] = arguments[_key];
|
|
141
|
+
}
|
|
142
|
+
return (_value = value).call.apply(_value, [
|
|
143
|
+
lastAccessLHS
|
|
144
|
+
].concat(_toConsumableArray(args)));
|
|
145
|
+
});
|
|
146
|
+
lastAccessLHS = undefined;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return value;
|
|
150
|
+
}
|
|
151
|
+
var _chunkQLMVHHAZjs = require("./chunk-QLMVHHAZ.js");
|
|
152
|
+
// src/immutable.ts
|
|
4
153
|
function lsonObjectToJson(obj) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
154
|
+
var result = {};
|
|
155
|
+
for(var key in obj){
|
|
156
|
+
var val = obj[key];
|
|
157
|
+
if (val !== void 0) {
|
|
158
|
+
result[key] = lsonToJson(val);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return result;
|
|
162
|
+
}
|
|
163
|
+
function liveObjectToJson(liveObject) {
|
|
164
|
+
return lsonObjectToJson(liveObject.toObject());
|
|
165
|
+
}
|
|
166
|
+
function liveMapToJson(map) {
|
|
167
|
+
var result = {};
|
|
168
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
169
|
+
try {
|
|
170
|
+
for(var _iterator = map.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
171
|
+
var _value = _slicedToArray(_step.value, 2), key = _value[0], value = _value[1];
|
|
172
|
+
result[key] = lsonToJson(value);
|
|
173
|
+
}
|
|
174
|
+
} catch (err) {
|
|
175
|
+
_didIteratorError = true;
|
|
176
|
+
_iteratorError = err;
|
|
177
|
+
} finally{
|
|
178
|
+
try {
|
|
179
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
180
|
+
_iterator.return();
|
|
181
|
+
}
|
|
182
|
+
} finally{
|
|
183
|
+
if (_didIteratorError) {
|
|
184
|
+
throw _iteratorError;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return result;
|
|
11
189
|
}
|
|
12
190
|
function lsonListToJson(value) {
|
|
13
|
-
|
|
191
|
+
return value.map(lsonToJson);
|
|
192
|
+
}
|
|
193
|
+
function liveListToJson(value) {
|
|
194
|
+
return lsonListToJson(value.toArray());
|
|
14
195
|
}
|
|
15
196
|
function lsonToJson(value) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var _step$value = _step.value,
|
|
32
|
-
key = _step$value[0],
|
|
33
|
-
value = _step$value[1];
|
|
34
|
-
result[key] = lsonToJson(value);
|
|
35
|
-
}
|
|
36
|
-
return result;
|
|
37
|
-
})(value)
|
|
38
|
-
: value instanceof Json.LiveRegister
|
|
39
|
-
? value.data
|
|
40
|
-
: Array.isArray(value)
|
|
41
|
-
? lsonListToJson(value)
|
|
42
|
-
: Json.isPlainObject(value)
|
|
43
|
-
? lsonObjectToJson(value)
|
|
44
|
-
: value;
|
|
197
|
+
if (_instanceof(value, _chunkQLMVHHAZjs.LiveObject)) {
|
|
198
|
+
return liveObjectToJson(value);
|
|
199
|
+
} else if (_instanceof(value, _chunkQLMVHHAZjs.LiveList)) {
|
|
200
|
+
return liveListToJson(value);
|
|
201
|
+
} else if (_instanceof(value, _chunkQLMVHHAZjs.LiveMap)) {
|
|
202
|
+
return liveMapToJson(value);
|
|
203
|
+
} else if (_instanceof(value, _chunkQLMVHHAZjs.LiveRegister)) {
|
|
204
|
+
return value.data;
|
|
205
|
+
}
|
|
206
|
+
if (Array.isArray(value)) {
|
|
207
|
+
return lsonListToJson(value);
|
|
208
|
+
} else if (_chunkQLMVHHAZjs.isPlainObject.call(void 0, value)) {
|
|
209
|
+
return lsonObjectToJson(value);
|
|
210
|
+
}
|
|
211
|
+
return value;
|
|
45
212
|
}
|
|
46
213
|
function deepLiveify(value) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
214
|
+
if (Array.isArray(value)) {
|
|
215
|
+
return new (0, _chunkQLMVHHAZjs.LiveList)(value.map(deepLiveify));
|
|
216
|
+
} else if (_chunkQLMVHHAZjs.isPlainObject.call(void 0, value)) {
|
|
217
|
+
var init = {};
|
|
218
|
+
for(var key in value){
|
|
219
|
+
var val = value[key];
|
|
220
|
+
if (val === void 0) {
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
init[key] = deepLiveify(val);
|
|
224
|
+
}
|
|
225
|
+
return new (0, _chunkQLMVHHAZjs.LiveObject)(init);
|
|
226
|
+
} else {
|
|
227
|
+
return value;
|
|
53
228
|
}
|
|
54
|
-
return new Json.LiveObject(init);
|
|
55
|
-
}
|
|
56
|
-
return value;
|
|
57
229
|
}
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
var
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
var value = liveObject.get(key);
|
|
71
|
-
if (void 0 === next) liveObject.delete(key);
|
|
72
|
-
else if (void 0 === value) liveObject.set(key, deepLiveify(next));
|
|
73
|
-
else {
|
|
74
|
-
if (prev === next) return;
|
|
75
|
-
Json.isLiveList(value) && Array.isArray(prev) && Array.isArray(next)
|
|
76
|
-
? (function (liveList, prev, next) {
|
|
77
|
-
var i = 0,
|
|
78
|
-
prevEnd = prev.length - 1,
|
|
79
|
-
nextEnd = next.length - 1,
|
|
80
|
-
prevNode = prev[0],
|
|
81
|
-
nextNode = next[0];
|
|
82
|
-
outer: {
|
|
83
|
-
for (; prevNode === nextNode; ) {
|
|
84
|
-
if (++i > prevEnd || i > nextEnd) break outer;
|
|
85
|
-
(prevNode = prev[i]), (nextNode = next[i]);
|
|
230
|
+
function patchLiveList(liveList, prev, next) {
|
|
231
|
+
var i = 0;
|
|
232
|
+
var prevEnd = prev.length - 1;
|
|
233
|
+
var nextEnd = next.length - 1;
|
|
234
|
+
var prevNode = prev[0];
|
|
235
|
+
var nextNode = next[0];
|
|
236
|
+
outer: {
|
|
237
|
+
while(prevNode === nextNode){
|
|
238
|
+
++i;
|
|
239
|
+
if (i > prevEnd || i > nextEnd) {
|
|
240
|
+
break outer;
|
|
86
241
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
242
|
+
prevNode = prev[i];
|
|
243
|
+
nextNode = next[i];
|
|
244
|
+
}
|
|
245
|
+
prevNode = prev[prevEnd];
|
|
246
|
+
nextNode = next[nextEnd];
|
|
247
|
+
while(prevNode === nextNode){
|
|
248
|
+
prevEnd--;
|
|
249
|
+
nextEnd--;
|
|
250
|
+
if (i > prevEnd || i > nextEnd) {
|
|
251
|
+
break outer;
|
|
94
252
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
else {
|
|
104
|
-
for (; i <= prevEnd && i <= nextEnd; ) {
|
|
105
|
-
(prevNode = prev[i]), (nextNode = next[i]);
|
|
106
|
-
var liveListNode = liveList.get(i);
|
|
107
|
-
Json.isLiveObject(liveListNode) &&
|
|
108
|
-
Json.isPlainObject(prevNode) &&
|
|
109
|
-
Json.isPlainObject(nextNode)
|
|
110
|
-
? patchLiveObject(liveListNode, prevNode, nextNode)
|
|
111
|
-
: liveList.set(i, deepLiveify(nextNode)),
|
|
253
|
+
prevNode = prev[prevEnd];
|
|
254
|
+
nextNode = next[nextEnd];
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (i > prevEnd) {
|
|
258
|
+
if (i <= nextEnd) {
|
|
259
|
+
while(i <= nextEnd){
|
|
260
|
+
liveList.insert(deepLiveify(next[i]), i);
|
|
112
261
|
i++;
|
|
113
262
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
263
|
+
}
|
|
264
|
+
} else if (i > nextEnd) {
|
|
265
|
+
var localI = i;
|
|
266
|
+
while(localI <= prevEnd){
|
|
267
|
+
liveList.delete(i);
|
|
268
|
+
localI++;
|
|
269
|
+
}
|
|
270
|
+
} else {
|
|
271
|
+
while(i <= prevEnd && i <= nextEnd){
|
|
272
|
+
prevNode = prev[i];
|
|
273
|
+
nextNode = next[i];
|
|
274
|
+
var liveListNode = liveList.get(i);
|
|
275
|
+
if (_chunkQLMVHHAZjs.isLiveObject.call(void 0, liveListNode) && _chunkQLMVHHAZjs.isPlainObject.call(void 0, prevNode) && _chunkQLMVHHAZjs.isPlainObject.call(void 0, nextNode)) {
|
|
276
|
+
patchLiveObject(liveListNode, prevNode, nextNode);
|
|
277
|
+
} else {
|
|
278
|
+
liveList.set(i, deepLiveify(nextNode));
|
|
279
|
+
}
|
|
280
|
+
i++;
|
|
281
|
+
}
|
|
282
|
+
while(i <= nextEnd){
|
|
283
|
+
liveList.insert(deepLiveify(next[i]), i);
|
|
284
|
+
i++;
|
|
285
|
+
}
|
|
286
|
+
var localI1 = i;
|
|
287
|
+
while(localI1 <= prevEnd){
|
|
288
|
+
liveList.delete(i);
|
|
289
|
+
localI1++;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
function patchLiveObjectKey(liveObject, key, prev, next) {
|
|
294
|
+
if (process.env.NODE_ENV !== "production") {
|
|
295
|
+
var nonSerializableValue = _chunkQLMVHHAZjs.findNonSerializableValue.call(void 0, next);
|
|
296
|
+
if (nonSerializableValue) {
|
|
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
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
var value = liveObject.get(key);
|
|
302
|
+
if (next === void 0) {
|
|
303
|
+
liveObject.delete(key);
|
|
304
|
+
} else if (value === void 0) {
|
|
305
|
+
liveObject.set(key, deepLiveify(next));
|
|
306
|
+
} else if (prev === next) {
|
|
307
|
+
return;
|
|
308
|
+
} else if (_chunkQLMVHHAZjs.isLiveList.call(void 0, value) && Array.isArray(prev) && Array.isArray(next)) {
|
|
309
|
+
patchLiveList(value, prev, next);
|
|
310
|
+
} else if (_chunkQLMVHHAZjs.isLiveObject.call(void 0, value) && _chunkQLMVHHAZjs.isPlainObject.call(void 0, prev) && _chunkQLMVHHAZjs.isPlainObject.call(void 0, next)) {
|
|
311
|
+
patchLiveObject(value, prev, next);
|
|
312
|
+
} else {
|
|
313
|
+
liveObject.set(key, deepLiveify(next));
|
|
314
|
+
}
|
|
126
315
|
}
|
|
127
316
|
function patchLiveObject(root, prev, next) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
317
|
+
var updates = {};
|
|
318
|
+
for(var key in next){
|
|
319
|
+
patchLiveObjectKey(root, key, prev[key], next[key]);
|
|
320
|
+
}
|
|
321
|
+
for(var key1 in prev){
|
|
322
|
+
if (next[key1] === void 0) {
|
|
323
|
+
root.delete(key1);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (Object.keys(updates).length > 0) {
|
|
327
|
+
root.update(updates);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
function getParentsPath(node) {
|
|
331
|
+
var path = [];
|
|
332
|
+
while(node.parent.type === "HasParent"){
|
|
333
|
+
if (_chunkQLMVHHAZjs.isLiveList.call(void 0, node.parent.node)) {
|
|
334
|
+
path.push(node.parent.node._indexOfPosition(node.parent.key));
|
|
335
|
+
} else {
|
|
336
|
+
path.push(node.parent.key);
|
|
337
|
+
}
|
|
338
|
+
node = node.parent.node;
|
|
339
|
+
}
|
|
340
|
+
return path;
|
|
341
|
+
}
|
|
342
|
+
function patchImmutableObject(state, updates) {
|
|
343
|
+
return updates.reduce(function(state2, update) {
|
|
344
|
+
return patchImmutableObjectWithUpdate(state2, update);
|
|
345
|
+
}, state);
|
|
346
|
+
}
|
|
347
|
+
function patchImmutableObjectWithUpdate(state, update) {
|
|
348
|
+
var path = getParentsPath(update.node);
|
|
349
|
+
return patchImmutableNode(state, path, update);
|
|
132
350
|
}
|
|
133
351
|
function patchImmutableNode(state, path, update) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
352
|
+
var pathItem = path.pop();
|
|
353
|
+
if (pathItem === void 0) {
|
|
354
|
+
switch(update.type){
|
|
355
|
+
case "LiveObject":
|
|
356
|
+
{
|
|
357
|
+
var _loop = function(key) {
|
|
358
|
+
if (_optionalChain([
|
|
359
|
+
update,
|
|
360
|
+
"access",
|
|
361
|
+
function(_) {
|
|
362
|
+
return _.updates;
|
|
363
|
+
},
|
|
364
|
+
"access",
|
|
365
|
+
function(_2) {
|
|
366
|
+
return _2[key];
|
|
367
|
+
},
|
|
368
|
+
"optionalAccess",
|
|
369
|
+
function(_3) {
|
|
370
|
+
return _3.type;
|
|
371
|
+
}
|
|
372
|
+
]) === "update") {
|
|
373
|
+
var val = update.node.get(key);
|
|
374
|
+
if (val !== void 0) {
|
|
375
|
+
newState[key] = lsonToJson(val);
|
|
376
|
+
}
|
|
377
|
+
} else if (_optionalChain([
|
|
378
|
+
update,
|
|
379
|
+
"access",
|
|
380
|
+
function(_4) {
|
|
381
|
+
return _4.updates;
|
|
382
|
+
},
|
|
383
|
+
"access",
|
|
384
|
+
function(_5) {
|
|
385
|
+
return _5[key];
|
|
386
|
+
},
|
|
387
|
+
"optionalAccess",
|
|
388
|
+
function(_6) {
|
|
389
|
+
return _6.type;
|
|
390
|
+
}
|
|
391
|
+
]) === "delete") {
|
|
392
|
+
delete newState[key];
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
if (state === null || typeof state !== "object" || Array.isArray(state)) {
|
|
396
|
+
throw new Error("Internal: received update on LiveObject but state was not an object");
|
|
397
|
+
}
|
|
398
|
+
var newState = Object.assign({}, state);
|
|
399
|
+
for(var key in update.updates)_loop(key);
|
|
400
|
+
return newState;
|
|
401
|
+
}
|
|
402
|
+
case "LiveList":
|
|
403
|
+
{
|
|
404
|
+
if (!Array.isArray(state)) {
|
|
405
|
+
throw new Error("Internal: received update on LiveList but state was not an array");
|
|
406
|
+
}
|
|
407
|
+
var newState1 = state.map(function(x) {
|
|
408
|
+
return x;
|
|
409
|
+
});
|
|
410
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
411
|
+
try {
|
|
412
|
+
var _loop1 = function() {
|
|
413
|
+
var listUpdate = _step.value;
|
|
414
|
+
if (listUpdate.type === "set") {
|
|
415
|
+
newState1 = newState1.map(function(item, index) {
|
|
416
|
+
return index === listUpdate.index ? lsonToJson(listUpdate.item) : item;
|
|
417
|
+
});
|
|
418
|
+
} else if (listUpdate.type === "insert") {
|
|
419
|
+
if (listUpdate.index === newState1.length) {
|
|
420
|
+
newState1.push(lsonToJson(listUpdate.item));
|
|
421
|
+
} else {
|
|
422
|
+
newState1 = _toConsumableArray(newState1.slice(0, listUpdate.index)).concat([
|
|
423
|
+
lsonToJson(listUpdate.item)
|
|
424
|
+
], _toConsumableArray(newState1.slice(listUpdate.index)));
|
|
425
|
+
}
|
|
426
|
+
} else if (listUpdate.type === "delete") {
|
|
427
|
+
newState1.splice(listUpdate.index, 1);
|
|
428
|
+
} else if (listUpdate.type === "move") {
|
|
429
|
+
if (listUpdate.previousIndex > listUpdate.index) {
|
|
430
|
+
newState1 = _toConsumableArray(newState1.slice(0, listUpdate.index)).concat([
|
|
431
|
+
lsonToJson(listUpdate.item)
|
|
432
|
+
], _toConsumableArray(newState1.slice(listUpdate.index, listUpdate.previousIndex)), _toConsumableArray(newState1.slice(listUpdate.previousIndex + 1)));
|
|
433
|
+
} else {
|
|
434
|
+
newState1 = _toConsumableArray(newState1.slice(0, listUpdate.previousIndex)).concat(_toConsumableArray(newState1.slice(listUpdate.previousIndex + 1, listUpdate.index + 1)), [
|
|
435
|
+
lsonToJson(listUpdate.item)
|
|
436
|
+
], _toConsumableArray(newState1.slice(listUpdate.index + 1)));
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
for(var _iterator = update.updates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop1();
|
|
441
|
+
} catch (err) {
|
|
442
|
+
_didIteratorError = true;
|
|
443
|
+
_iteratorError = err;
|
|
444
|
+
} finally{
|
|
445
|
+
try {
|
|
446
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
447
|
+
_iterator.return();
|
|
448
|
+
}
|
|
449
|
+
} finally{
|
|
450
|
+
if (_didIteratorError) {
|
|
451
|
+
throw _iteratorError;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return newState1;
|
|
456
|
+
}
|
|
457
|
+
case "LiveMap":
|
|
458
|
+
{
|
|
459
|
+
var _loop2 = function(key1) {
|
|
460
|
+
if (_optionalChain([
|
|
461
|
+
update,
|
|
462
|
+
"access",
|
|
463
|
+
function(_7) {
|
|
464
|
+
return _7.updates;
|
|
465
|
+
},
|
|
466
|
+
"access",
|
|
467
|
+
function(_8) {
|
|
468
|
+
return _8[key1];
|
|
469
|
+
},
|
|
470
|
+
"optionalAccess",
|
|
471
|
+
function(_9) {
|
|
472
|
+
return _9.type;
|
|
473
|
+
}
|
|
474
|
+
]) === "update") {
|
|
475
|
+
var value = update.node.get(key1);
|
|
476
|
+
if (value !== void 0) {
|
|
477
|
+
newState2[key1] = lsonToJson(value);
|
|
478
|
+
}
|
|
479
|
+
} else if (_optionalChain([
|
|
480
|
+
update,
|
|
481
|
+
"access",
|
|
482
|
+
function(_10) {
|
|
483
|
+
return _10.updates;
|
|
484
|
+
},
|
|
485
|
+
"access",
|
|
486
|
+
function(_11) {
|
|
487
|
+
return _11[key1];
|
|
488
|
+
},
|
|
489
|
+
"optionalAccess",
|
|
490
|
+
function(_12) {
|
|
491
|
+
return _12.type;
|
|
492
|
+
}
|
|
493
|
+
]) === "delete") {
|
|
494
|
+
delete newState2[key1];
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
if (state === null || typeof state !== "object" || Array.isArray(state)) {
|
|
498
|
+
throw new Error("Internal: received update on LiveMap but state was not an object");
|
|
499
|
+
}
|
|
500
|
+
var newState2 = Object.assign({}, state);
|
|
501
|
+
for(var key1 in update.updates)_loop2(key1);
|
|
502
|
+
return newState2;
|
|
503
|
+
}
|
|
158
504
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}),
|
|
170
|
-
_loop = function () {
|
|
171
|
-
var listUpdate = _step2.value;
|
|
172
|
-
"set" === listUpdate.type
|
|
173
|
-
? (_newState = _newState.map(function (item, index) {
|
|
174
|
-
return index === listUpdate.index
|
|
175
|
-
? lsonToJson(listUpdate.item)
|
|
176
|
-
: item;
|
|
177
|
-
}))
|
|
178
|
-
: "insert" === listUpdate.type
|
|
179
|
-
? listUpdate.index === _newState.length
|
|
180
|
-
? _newState.push(lsonToJson(listUpdate.item))
|
|
181
|
-
: (_newState = [].concat(
|
|
182
|
-
_newState.slice(0, listUpdate.index),
|
|
183
|
-
[lsonToJson(listUpdate.item)],
|
|
184
|
-
_newState.slice(listUpdate.index)
|
|
185
|
-
))
|
|
186
|
-
: "delete" === listUpdate.type
|
|
187
|
-
? _newState.splice(listUpdate.index, 1)
|
|
188
|
-
: "move" === listUpdate.type &&
|
|
189
|
-
(_newState =
|
|
190
|
-
listUpdate.previousIndex > listUpdate.index
|
|
191
|
-
? [].concat(
|
|
192
|
-
_newState.slice(0, listUpdate.index),
|
|
193
|
-
[lsonToJson(listUpdate.item)],
|
|
194
|
-
_newState.slice(
|
|
195
|
-
listUpdate.index,
|
|
196
|
-
listUpdate.previousIndex
|
|
197
|
-
),
|
|
198
|
-
_newState.slice(listUpdate.previousIndex + 1)
|
|
199
|
-
)
|
|
200
|
-
: [].concat(
|
|
201
|
-
_newState.slice(0, listUpdate.previousIndex),
|
|
202
|
-
_newState.slice(
|
|
203
|
-
listUpdate.previousIndex + 1,
|
|
204
|
-
listUpdate.index + 1
|
|
205
|
-
),
|
|
206
|
-
[lsonToJson(listUpdate.item)],
|
|
207
|
-
_newState.slice(listUpdate.index + 1)
|
|
208
|
-
));
|
|
209
|
-
},
|
|
210
|
-
_iterator2 = Json._createForOfIteratorHelperLoose(update.updates);
|
|
211
|
-
!(_step2 = _iterator2()).done;
|
|
212
|
-
|
|
213
|
-
)
|
|
214
|
-
_loop();
|
|
215
|
-
return _newState;
|
|
216
|
-
case "LiveMap":
|
|
217
|
-
if (null === state || "object" != typeof state || Array.isArray(state))
|
|
218
|
-
throw new Error(
|
|
219
|
-
"Internal: received update on LiveMap but state was not an object"
|
|
220
|
-
);
|
|
221
|
-
var _newState2 = Object.assign({}, state);
|
|
222
|
-
for (var _key2 in update.updates) {
|
|
223
|
-
var _update$updates$_key, _update$updates$_key2;
|
|
224
|
-
if (
|
|
225
|
-
"update" ===
|
|
226
|
-
(null == (_update$updates$_key = update.updates[_key2])
|
|
227
|
-
? void 0
|
|
228
|
-
: _update$updates$_key.type)
|
|
229
|
-
) {
|
|
230
|
-
var value = update.node.get(_key2);
|
|
231
|
-
void 0 !== value && (_newState2[_key2] = lsonToJson(value));
|
|
232
|
-
} else
|
|
233
|
-
"delete" ===
|
|
234
|
-
(null == (_update$updates$_key2 = update.updates[_key2])
|
|
235
|
-
? void 0
|
|
236
|
-
: _update$updates$_key2.type) && delete _newState2[_key2];
|
|
505
|
+
}
|
|
506
|
+
if (Array.isArray(state)) {
|
|
507
|
+
var newArray = _toConsumableArray(state);
|
|
508
|
+
newArray[pathItem] = patchImmutableNode(state[pathItem], path, update);
|
|
509
|
+
return newArray;
|
|
510
|
+
} else if (state !== null && typeof state === "object") {
|
|
511
|
+
var node = state[pathItem];
|
|
512
|
+
if (node === void 0) {
|
|
513
|
+
return state;
|
|
514
|
+
} else {
|
|
515
|
+
return _objectSpreadProps(_objectSpread({}, state), _defineProperty({}, pathItem, patchImmutableNode(node, path, update)));
|
|
237
516
|
}
|
|
238
|
-
|
|
517
|
+
} else {
|
|
518
|
+
return state;
|
|
239
519
|
}
|
|
240
|
-
if (Array.isArray(state)) {
|
|
241
|
-
var newArray = [].concat(state);
|
|
242
|
-
return (
|
|
243
|
-
(newArray[pathItem] = patchImmutableNode(state[pathItem], path, update)),
|
|
244
|
-
newArray
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
if (null !== state && "object" == typeof state) {
|
|
248
|
-
var _extends2,
|
|
249
|
-
node = state[pathItem];
|
|
250
|
-
return void 0 === node
|
|
251
|
-
? state
|
|
252
|
-
: Json._extends(
|
|
253
|
-
{},
|
|
254
|
-
state,
|
|
255
|
-
(((_extends2 = {})[pathItem] = patchImmutableNode(
|
|
256
|
-
node,
|
|
257
|
-
path,
|
|
258
|
-
update
|
|
259
|
-
)),
|
|
260
|
-
_extends2)
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
return state;
|
|
264
520
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
},
|
|
294
|
-
}),
|
|
295
|
-
(exports.assertNever = Json.assertNever),
|
|
296
|
-
(exports.b64decode = Json.b64decode),
|
|
297
|
-
(exports.comparePosition = Json.comparePosition),
|
|
298
|
-
(exports.deprecate = Json.deprecate),
|
|
299
|
-
(exports.deprecateIf = Json.deprecateIf),
|
|
300
|
-
(exports.errorIf = Json.errorIf),
|
|
301
|
-
(exports.isAppOnlyAuthToken = Json.isAppOnlyAuthToken),
|
|
302
|
-
(exports.isAuthToken = Json.isAuthToken),
|
|
303
|
-
(exports.isChildCrdt = Json.isChildCrdt),
|
|
304
|
-
(exports.isJsonArray = Json.isJsonArray),
|
|
305
|
-
(exports.isJsonObject = Json.isJsonObject),
|
|
306
|
-
(exports.isJsonScalar = Json.isJsonScalar),
|
|
307
|
-
(exports.isPlainObject = Json.isPlainObject),
|
|
308
|
-
(exports.isRoomAuthToken = Json.isRoomAuthToken),
|
|
309
|
-
(exports.isRootCrdt = Json.isRootCrdt),
|
|
310
|
-
(exports.isScope = Json.isScope),
|
|
311
|
-
(exports.makePosition = Json.makePosition),
|
|
312
|
-
(exports.nn = Json.nn),
|
|
313
|
-
(exports.throwUsageError = Json.throwUsageError),
|
|
314
|
-
(exports.tryParseJson = Json.tryParseJson),
|
|
315
|
-
(exports.lsonToJson = lsonToJson),
|
|
316
|
-
(exports.patchImmutableObject = function (state, updates) {
|
|
317
|
-
return updates.reduce(function (state, update) {
|
|
318
|
-
return (function (state, update) {
|
|
319
|
-
var path = (function (node) {
|
|
320
|
-
for (var path = []; "HasParent" === node.parent.type; )
|
|
321
|
-
Json.isLiveList(node.parent.node)
|
|
322
|
-
? path.push(node.parent.node._indexOfPosition(node.parent.key))
|
|
323
|
-
: path.push(node.parent.key),
|
|
324
|
-
(node = node.parent.node);
|
|
325
|
-
return path;
|
|
326
|
-
})(update.node);
|
|
327
|
-
return patchImmutableNode(state, path, update);
|
|
328
|
-
})(state, update);
|
|
329
|
-
}, state);
|
|
330
|
-
}),
|
|
331
|
-
(exports.patchLiveObjectKey = patchLiveObjectKey);
|
|
521
|
+
exports.ClientMsgCode = _chunkQLMVHHAZjs.ClientMsgCode;
|
|
522
|
+
exports.CrdtType = _chunkQLMVHHAZjs.CrdtType;
|
|
523
|
+
exports.OpCode = _chunkQLMVHHAZjs.OpCode;
|
|
524
|
+
exports.ServerMsgCode = _chunkQLMVHHAZjs.ServerMsgCode;
|
|
525
|
+
exports.WebsocketCloseCodes = _chunkQLMVHHAZjs.WebsocketCloseCodes;
|
|
526
|
+
exports.assertNever = _chunkQLMVHHAZjs.assertNever;
|
|
527
|
+
exports.b64decode = _chunkQLMVHHAZjs.b64decode;
|
|
528
|
+
exports.comparePosition = _chunkQLMVHHAZjs.comparePosition;
|
|
529
|
+
exports.deprecate = _chunkQLMVHHAZjs.deprecate;
|
|
530
|
+
exports.deprecateIf = _chunkQLMVHHAZjs.deprecateIf;
|
|
531
|
+
exports.errorIf = _chunkQLMVHHAZjs.errorIf;
|
|
532
|
+
exports.isAppOnlyAuthToken = _chunkQLMVHHAZjs.isAppOnlyAuthToken;
|
|
533
|
+
exports.isAuthToken = _chunkQLMVHHAZjs.isAuthToken;
|
|
534
|
+
exports.isChildCrdt = _chunkQLMVHHAZjs.isChildCrdt;
|
|
535
|
+
exports.isJsonArray = _chunkQLMVHHAZjs.isJsonArray;
|
|
536
|
+
exports.isJsonObject = _chunkQLMVHHAZjs.isJsonObject;
|
|
537
|
+
exports.isJsonScalar = _chunkQLMVHHAZjs.isJsonScalar;
|
|
538
|
+
exports.isPlainObject = _chunkQLMVHHAZjs.isPlainObject;
|
|
539
|
+
exports.isRoomAuthToken = _chunkQLMVHHAZjs.isRoomAuthToken;
|
|
540
|
+
exports.isRootCrdt = _chunkQLMVHHAZjs.isRootCrdt;
|
|
541
|
+
exports.isScope = _chunkQLMVHHAZjs.isScope;
|
|
542
|
+
exports.lsonToJson = lsonToJson;
|
|
543
|
+
exports.makePosition = _chunkQLMVHHAZjs.makePosition;
|
|
544
|
+
exports.nn = _chunkQLMVHHAZjs.nn;
|
|
545
|
+
exports.patchImmutableObject = patchImmutableObject;
|
|
546
|
+
exports.patchLiveObjectKey = patchLiveObjectKey;
|
|
547
|
+
exports.throwUsageError = _chunkQLMVHHAZjs.throwUsageError;
|
|
548
|
+
exports.tryParseJson = _chunkQLMVHHAZjs.tryParseJson;
|