@liveblocks/client 0.18.0-beta0 → 0.18.0-beta3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.built-by-link-script +1 -1
- package/chunk-UV2F4F4R.js +2457 -0
- package/{index-4e7d8cac.d.ts → index-29762efc.d.ts} +23 -21
- package/index.d.ts +2 -2
- package/index.js +1511 -2188
- package/internal.d.ts +2 -2
- package/internal.js +330 -509
- package/internal.mjs +1 -0
- package/package.json +1 -1
- package/chunk-ZR7CHFN6.js +0 -3728
package/internal.js
CHANGED
|
@@ -1,549 +1,370 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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 _chunkZR7CHFN6js = require("./chunk-ZR7CHFN6.js");
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
var _chunkUV2F4F4Rjs = require('./chunk-UV2F4F4R.js');
|
|
39
|
+
|
|
152
40
|
// src/immutable.ts
|
|
153
41
|
function lsonObjectToJson(obj) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
42
|
+
const result = {};
|
|
43
|
+
for (const key in obj) {
|
|
44
|
+
const val = obj[key];
|
|
45
|
+
if (val !== void 0) {
|
|
46
|
+
result[key] = lsonToJson(val);
|
|
160
47
|
}
|
|
161
|
-
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
162
50
|
}
|
|
163
51
|
function liveObjectToJson(liveObject) {
|
|
164
|
-
|
|
52
|
+
return lsonObjectToJson(liveObject.toObject());
|
|
165
53
|
}
|
|
166
54
|
function liveMapToJson(map) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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;
|
|
55
|
+
const result = {};
|
|
56
|
+
for (const [key, value] of map.entries()) {
|
|
57
|
+
result[key] = lsonToJson(value);
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
189
60
|
}
|
|
190
61
|
function lsonListToJson(value) {
|
|
191
|
-
|
|
62
|
+
return value.map(lsonToJson);
|
|
192
63
|
}
|
|
193
64
|
function liveListToJson(value) {
|
|
194
|
-
|
|
65
|
+
return lsonListToJson(value.toArray());
|
|
195
66
|
}
|
|
196
67
|
function lsonToJson(value) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
68
|
+
if (value instanceof _chunkUV2F4F4Rjs.LiveObject) {
|
|
69
|
+
return liveObjectToJson(value);
|
|
70
|
+
} else if (value instanceof _chunkUV2F4F4Rjs.LiveList) {
|
|
71
|
+
return liveListToJson(value);
|
|
72
|
+
} else if (value instanceof _chunkUV2F4F4Rjs.LiveMap) {
|
|
73
|
+
return liveMapToJson(value);
|
|
74
|
+
} else if (value instanceof _chunkUV2F4F4Rjs.LiveRegister) {
|
|
75
|
+
return value.data;
|
|
76
|
+
}
|
|
77
|
+
if (Array.isArray(value)) {
|
|
78
|
+
return lsonListToJson(value);
|
|
79
|
+
} else if (_chunkUV2F4F4Rjs.isPlainObject.call(void 0, value)) {
|
|
80
|
+
return lsonObjectToJson(value);
|
|
81
|
+
}
|
|
82
|
+
return value;
|
|
212
83
|
}
|
|
213
84
|
function deepLiveify(value) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
return new (0, _chunkZR7CHFN6js.LiveObject)(init);
|
|
226
|
-
} else {
|
|
227
|
-
return value;
|
|
85
|
+
if (Array.isArray(value)) {
|
|
86
|
+
return new (0, _chunkUV2F4F4Rjs.LiveList)(value.map(deepLiveify));
|
|
87
|
+
} else if (_chunkUV2F4F4Rjs.isPlainObject.call(void 0, value)) {
|
|
88
|
+
const init = {};
|
|
89
|
+
for (const key in value) {
|
|
90
|
+
const val = value[key];
|
|
91
|
+
if (val === void 0) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
init[key] = deepLiveify(val);
|
|
228
95
|
}
|
|
96
|
+
return new (0, _chunkUV2F4F4Rjs.LiveObject)(init);
|
|
97
|
+
} else {
|
|
98
|
+
return value;
|
|
99
|
+
}
|
|
229
100
|
}
|
|
230
101
|
function patchLiveList(liveList, prev, next) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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;
|
|
252
|
-
}
|
|
253
|
-
prevNode = prev[prevEnd];
|
|
254
|
-
nextNode = next[nextEnd];
|
|
255
|
-
}
|
|
102
|
+
let i = 0;
|
|
103
|
+
let prevEnd = prev.length - 1;
|
|
104
|
+
let nextEnd = next.length - 1;
|
|
105
|
+
let prevNode = prev[0];
|
|
106
|
+
let nextNode = next[0];
|
|
107
|
+
outer: {
|
|
108
|
+
while (prevNode === nextNode) {
|
|
109
|
+
++i;
|
|
110
|
+
if (i > prevEnd || i > nextEnd) {
|
|
111
|
+
break outer;
|
|
112
|
+
}
|
|
113
|
+
prevNode = prev[i];
|
|
114
|
+
nextNode = next[i];
|
|
256
115
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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
|
-
|
|
116
|
+
prevNode = prev[prevEnd];
|
|
117
|
+
nextNode = next[nextEnd];
|
|
118
|
+
while (prevNode === nextNode) {
|
|
119
|
+
prevEnd--;
|
|
120
|
+
nextEnd--;
|
|
121
|
+
if (i > prevEnd || i > nextEnd) {
|
|
122
|
+
break outer;
|
|
123
|
+
}
|
|
124
|
+
prevNode = prev[prevEnd];
|
|
125
|
+
nextNode = next[nextEnd];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (i > prevEnd) {
|
|
129
|
+
if (i <= nextEnd) {
|
|
130
|
+
while (i <= nextEnd) {
|
|
131
|
+
liveList.insert(deepLiveify(next[i]), i);
|
|
132
|
+
i++;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
} else if (i > nextEnd) {
|
|
136
|
+
let localI = i;
|
|
137
|
+
while (localI <= prevEnd) {
|
|
138
|
+
liveList.delete(i);
|
|
139
|
+
localI++;
|
|
140
|
+
}
|
|
141
|
+
} else {
|
|
142
|
+
while (i <= prevEnd && i <= nextEnd) {
|
|
143
|
+
prevNode = prev[i];
|
|
144
|
+
nextNode = next[i];
|
|
145
|
+
const liveListNode = liveList.get(i);
|
|
146
|
+
if (_chunkUV2F4F4Rjs.isLiveObject.call(void 0, liveListNode) && _chunkUV2F4F4Rjs.isPlainObject.call(void 0, prevNode) && _chunkUV2F4F4Rjs.isPlainObject.call(void 0, nextNode)) {
|
|
147
|
+
patchLiveObject(liveListNode, prevNode, nextNode);
|
|
148
|
+
} else {
|
|
149
|
+
liveList.set(i, deepLiveify(nextNode));
|
|
150
|
+
}
|
|
151
|
+
i++;
|
|
152
|
+
}
|
|
153
|
+
while (i <= nextEnd) {
|
|
154
|
+
liveList.insert(deepLiveify(next[i]), i);
|
|
155
|
+
i++;
|
|
291
156
|
}
|
|
157
|
+
let localI = i;
|
|
158
|
+
while (localI <= prevEnd) {
|
|
159
|
+
liveList.delete(i);
|
|
160
|
+
localI++;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
292
163
|
}
|
|
293
164
|
function patchLiveObjectKey(liveObject, key, prev, next) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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 (_chunkZR7CHFN6js.isLiveList.call(void 0, value) && Array.isArray(prev) && Array.isArray(next)) {
|
|
309
|
-
patchLiveList(value, prev, next);
|
|
310
|
-
} else if (_chunkZR7CHFN6js.isLiveObject.call(void 0, value) && _chunkZR7CHFN6js.isPlainObject.call(void 0, prev) && _chunkZR7CHFN6js.isPlainObject.call(void 0, next)) {
|
|
311
|
-
patchLiveObject(value, prev, next);
|
|
312
|
-
} else {
|
|
313
|
-
liveObject.set(key, deepLiveify(next));
|
|
165
|
+
if (process.env.NODE_ENV !== "production") {
|
|
166
|
+
const nonSerializableValue = _chunkUV2F4F4Rjs.findNonSerializableValue.call(void 0, next);
|
|
167
|
+
if (nonSerializableValue) {
|
|
168
|
+
console.error(
|
|
169
|
+
`New state path: '${nonSerializableValue.path}' value: '${nonSerializableValue.value}' is not serializable.
|
|
170
|
+
Only serializable value can be synced with Liveblocks.`
|
|
171
|
+
);
|
|
172
|
+
return;
|
|
314
173
|
}
|
|
174
|
+
}
|
|
175
|
+
const value = liveObject.get(key);
|
|
176
|
+
if (next === void 0) {
|
|
177
|
+
liveObject.delete(key);
|
|
178
|
+
} else if (value === void 0) {
|
|
179
|
+
liveObject.set(key, deepLiveify(next));
|
|
180
|
+
} else if (prev === next) {
|
|
181
|
+
return;
|
|
182
|
+
} else if (_chunkUV2F4F4Rjs.isLiveList.call(void 0, value) && Array.isArray(prev) && Array.isArray(next)) {
|
|
183
|
+
patchLiveList(value, prev, next);
|
|
184
|
+
} else if (_chunkUV2F4F4Rjs.isLiveObject.call(void 0, value) && _chunkUV2F4F4Rjs.isPlainObject.call(void 0, prev) && _chunkUV2F4F4Rjs.isPlainObject.call(void 0, next)) {
|
|
185
|
+
patchLiveObject(value, prev, next);
|
|
186
|
+
} else {
|
|
187
|
+
liveObject.set(key, deepLiveify(next));
|
|
188
|
+
}
|
|
315
189
|
}
|
|
316
190
|
function patchLiveObject(root, prev, next) {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
if (Object.keys(updates).length > 0) {
|
|
327
|
-
root.update(updates);
|
|
191
|
+
const updates = {};
|
|
192
|
+
for (const key in next) {
|
|
193
|
+
patchLiveObjectKey(root, key, prev[key], next[key]);
|
|
194
|
+
}
|
|
195
|
+
for (const key in prev) {
|
|
196
|
+
if (next[key] === void 0) {
|
|
197
|
+
root.delete(key);
|
|
328
198
|
}
|
|
199
|
+
}
|
|
200
|
+
if (Object.keys(updates).length > 0) {
|
|
201
|
+
root.update(updates);
|
|
202
|
+
}
|
|
329
203
|
}
|
|
330
204
|
function getParentsPath(node) {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
}
|
|
338
|
-
node = node.parent.node;
|
|
205
|
+
const path = [];
|
|
206
|
+
while (node.parent.type === "HasParent") {
|
|
207
|
+
if (_chunkUV2F4F4Rjs.isLiveList.call(void 0, node.parent.node)) {
|
|
208
|
+
path.push(node.parent.node._indexOfPosition(node.parent.key));
|
|
209
|
+
} else {
|
|
210
|
+
path.push(node.parent.key);
|
|
339
211
|
}
|
|
340
|
-
|
|
212
|
+
node = node.parent.node;
|
|
213
|
+
}
|
|
214
|
+
return path;
|
|
341
215
|
}
|
|
342
216
|
function legacy_patchImmutableObject(state, updates) {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
217
|
+
return updates.reduce(
|
|
218
|
+
(state2, update) => legacy_patchImmutableObjectWithUpdate(state2, update),
|
|
219
|
+
state
|
|
220
|
+
);
|
|
346
221
|
}
|
|
347
222
|
function legacy_patchImmutableObjectWithUpdate(state, update) {
|
|
348
|
-
|
|
349
|
-
|
|
223
|
+
const path = getParentsPath(update.node);
|
|
224
|
+
return legacy_patchImmutableNode(state, path, update);
|
|
350
225
|
}
|
|
351
226
|
function legacy_patchImmutableNode(state, path, update) {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
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
|
-
}
|
|
227
|
+
var _a, _b, _c, _d;
|
|
228
|
+
const pathItem = path.pop();
|
|
229
|
+
if (pathItem === void 0) {
|
|
230
|
+
switch (update.type) {
|
|
231
|
+
case "LiveObject": {
|
|
232
|
+
if (state === null || typeof state !== "object" || Array.isArray(state)) {
|
|
233
|
+
throw new Error(
|
|
234
|
+
"Internal: received update on LiveObject but state was not an object"
|
|
235
|
+
);
|
|
504
236
|
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
return _objectSpreadProps(_objectSpread({}, state), _defineProperty({}, pathItem, legacy_patchImmutableNode(node, path, update)));
|
|
237
|
+
const newState = Object.assign({}, state);
|
|
238
|
+
for (const key in update.updates) {
|
|
239
|
+
if (((_a = update.updates[key]) == null ? void 0 : _a.type) === "update") {
|
|
240
|
+
const val = update.node.get(key);
|
|
241
|
+
if (val !== void 0) {
|
|
242
|
+
newState[key] = lsonToJson(val);
|
|
243
|
+
}
|
|
244
|
+
} else if (((_b = update.updates[key]) == null ? void 0 : _b.type) === "delete") {
|
|
245
|
+
delete newState[key];
|
|
246
|
+
}
|
|
516
247
|
}
|
|
248
|
+
return newState;
|
|
249
|
+
}
|
|
250
|
+
case "LiveList": {
|
|
251
|
+
if (!Array.isArray(state)) {
|
|
252
|
+
throw new Error(
|
|
253
|
+
"Internal: received update on LiveList but state was not an array"
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
let newState = state.map((x) => x);
|
|
257
|
+
for (const listUpdate of update.updates) {
|
|
258
|
+
if (listUpdate.type === "set") {
|
|
259
|
+
newState = newState.map(
|
|
260
|
+
(item, index) => index === listUpdate.index ? lsonToJson(listUpdate.item) : item
|
|
261
|
+
);
|
|
262
|
+
} else if (listUpdate.type === "insert") {
|
|
263
|
+
if (listUpdate.index === newState.length) {
|
|
264
|
+
newState.push(lsonToJson(listUpdate.item));
|
|
265
|
+
} else {
|
|
266
|
+
newState = [
|
|
267
|
+
...newState.slice(0, listUpdate.index),
|
|
268
|
+
lsonToJson(listUpdate.item),
|
|
269
|
+
...newState.slice(listUpdate.index)
|
|
270
|
+
];
|
|
271
|
+
}
|
|
272
|
+
} else if (listUpdate.type === "delete") {
|
|
273
|
+
newState.splice(listUpdate.index, 1);
|
|
274
|
+
} else if (listUpdate.type === "move") {
|
|
275
|
+
if (listUpdate.previousIndex > listUpdate.index) {
|
|
276
|
+
newState = [
|
|
277
|
+
...newState.slice(0, listUpdate.index),
|
|
278
|
+
lsonToJson(listUpdate.item),
|
|
279
|
+
...newState.slice(listUpdate.index, listUpdate.previousIndex),
|
|
280
|
+
...newState.slice(listUpdate.previousIndex + 1)
|
|
281
|
+
];
|
|
282
|
+
} else {
|
|
283
|
+
newState = [
|
|
284
|
+
...newState.slice(0, listUpdate.previousIndex),
|
|
285
|
+
...newState.slice(
|
|
286
|
+
listUpdate.previousIndex + 1,
|
|
287
|
+
listUpdate.index + 1
|
|
288
|
+
),
|
|
289
|
+
lsonToJson(listUpdate.item),
|
|
290
|
+
...newState.slice(listUpdate.index + 1)
|
|
291
|
+
];
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return newState;
|
|
296
|
+
}
|
|
297
|
+
case "LiveMap": {
|
|
298
|
+
if (state === null || typeof state !== "object" || Array.isArray(state)) {
|
|
299
|
+
throw new Error(
|
|
300
|
+
"Internal: received update on LiveMap but state was not an object"
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
const newState = Object.assign({}, state);
|
|
304
|
+
for (const key in update.updates) {
|
|
305
|
+
if (((_c = update.updates[key]) == null ? void 0 : _c.type) === "update") {
|
|
306
|
+
const value = update.node.get(key);
|
|
307
|
+
if (value !== void 0) {
|
|
308
|
+
newState[key] = lsonToJson(value);
|
|
309
|
+
}
|
|
310
|
+
} else if (((_d = update.updates[key]) == null ? void 0 : _d.type) === "delete") {
|
|
311
|
+
delete newState[key];
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return newState;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (Array.isArray(state)) {
|
|
319
|
+
const newArray = [...state];
|
|
320
|
+
newArray[pathItem] = legacy_patchImmutableNode(
|
|
321
|
+
state[pathItem],
|
|
322
|
+
path,
|
|
323
|
+
update
|
|
324
|
+
);
|
|
325
|
+
return newArray;
|
|
326
|
+
} else if (state !== null && typeof state === "object") {
|
|
327
|
+
const node = state[pathItem];
|
|
328
|
+
if (node === void 0) {
|
|
329
|
+
return state;
|
|
517
330
|
} else {
|
|
518
|
-
|
|
331
|
+
return _chunkUV2F4F4Rjs.__spreadProps.call(void 0, _chunkUV2F4F4Rjs.__spreadValues.call(void 0, {}, state), {
|
|
332
|
+
[pathItem]: legacy_patchImmutableNode(node, path, update)
|
|
333
|
+
});
|
|
519
334
|
}
|
|
335
|
+
} else {
|
|
336
|
+
return state;
|
|
337
|
+
}
|
|
520
338
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
exports.ClientMsgCode = _chunkUV2F4F4Rjs.ClientMsgCode; exports.CrdtType = _chunkUV2F4F4Rjs.CrdtType; exports.OpCode = _chunkUV2F4F4Rjs.OpCode; exports.ServerMsgCode = _chunkUV2F4F4Rjs.ServerMsgCode; exports.WebsocketCloseCodes = _chunkUV2F4F4Rjs.WebsocketCloseCodes; exports.asArrayWithLegacyMethods = _chunkUV2F4F4Rjs.asArrayWithLegacyMethods; exports.assertNever = _chunkUV2F4F4Rjs.assertNever; exports.b64decode = _chunkUV2F4F4Rjs.b64decode; exports.comparePosition = _chunkUV2F4F4Rjs.comparePosition; exports.deprecate = _chunkUV2F4F4Rjs.deprecate; exports.deprecateIf = _chunkUV2F4F4Rjs.deprecateIf; exports.errorIf = _chunkUV2F4F4Rjs.errorIf; exports.freeze = _chunkUV2F4F4Rjs.freeze; exports.isAppOnlyAuthToken = _chunkUV2F4F4Rjs.isAppOnlyAuthToken; exports.isAuthToken = _chunkUV2F4F4Rjs.isAuthToken; exports.isChildCrdt = _chunkUV2F4F4Rjs.isChildCrdt; exports.isJsonArray = _chunkUV2F4F4Rjs.isJsonArray; exports.isJsonObject = _chunkUV2F4F4Rjs.isJsonObject; exports.isJsonScalar = _chunkUV2F4F4Rjs.isJsonScalar; exports.isPlainObject = _chunkUV2F4F4Rjs.isPlainObject; exports.isRoomAuthToken = _chunkUV2F4F4Rjs.isRoomAuthToken; exports.isRootCrdt = _chunkUV2F4F4Rjs.isRootCrdt; exports.isScope = _chunkUV2F4F4Rjs.isScope; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makePosition = _chunkUV2F4F4Rjs.makePosition; exports.nn = _chunkUV2F4F4Rjs.nn; exports.patchLiveObjectKey = patchLiveObjectKey; exports.throwUsageError = _chunkUV2F4F4Rjs.throwUsageError; exports.tryParseJson = _chunkUV2F4F4Rjs.tryParseJson;
|