@liveblocks/client 0.16.15 → 0.17.0-test1
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.d.ts +26 -7
- package/index.js +1230 -830
- package/index.mjs +1030 -782
- package/internal.d.ts +271 -251
- package/internal.js +314 -168
- package/internal.mjs +265 -130
- package/package.json +15 -10
- package/shared.d.ts +973 -628
- package/shared.js +2568 -1331
- package/shared.mjs +1989 -1210
package/internal.js
CHANGED
|
@@ -1,186 +1,332 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: !0
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var LiveObject = require("./shared.js");
|
|
8
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
+
var Json = require("./shared.js");
|
|
9
4
|
function lsonObjectToJson(obj) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
return result;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function lsonListToJson(value) {
|
|
19
|
-
return value.map(lsonToJson);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function lsonToJson(value) {
|
|
23
|
-
if (value instanceof LiveObject.LiveObject) return lsonObjectToJson(value.toObject());
|
|
24
|
-
if (value instanceof LiveObject.LiveList) return function(value) {
|
|
25
|
-
return lsonListToJson(value.toArray());
|
|
26
|
-
}(value);
|
|
27
|
-
if (value instanceof LiveObject.LiveMap) return function(map) {
|
|
28
|
-
for (var _step, result = {}, _iterator = LiveObject._createForOfIteratorHelperLoose(map.entries()); !(_step = _iterator()).done; ) {
|
|
29
|
-
var _step$value = _step.value, _key2 = _step$value[0], value = _step$value[1];
|
|
30
|
-
result[_key2] = lsonToJson(value);
|
|
5
|
+
var result = {};
|
|
6
|
+
for (var key in obj) {
|
|
7
|
+
var val = obj[key];
|
|
8
|
+
void 0 !== val && (result[key] = lsonToJson(val));
|
|
31
9
|
}
|
|
32
10
|
return result;
|
|
33
|
-
}(value);
|
|
34
|
-
if (value instanceof LiveObject.LiveRegister) return value.data;
|
|
35
|
-
if (value instanceof LiveObject.AbstractCrdt) throw new Error("Unhandled subclass of AbstractCrdt encountered");
|
|
36
|
-
return Array.isArray(value) ? lsonListToJson(value) : isPlainObject(value) ? lsonObjectToJson(value) : value;
|
|
37
11
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return null !== obj && "[object Object]" === Object.prototype.toString.call(obj);
|
|
12
|
+
function lsonListToJson(value) {
|
|
13
|
+
return value.map(lsonToJson);
|
|
41
14
|
}
|
|
15
|
+
function lsonToJson(value) {
|
|
16
|
+
return value instanceof Json.LiveObject
|
|
17
|
+
? lsonObjectToJson(value.toObject())
|
|
18
|
+
: value instanceof Json.LiveList
|
|
19
|
+
? (function (value) {
|
|
20
|
+
return lsonListToJson(value.toArray());
|
|
21
|
+
})(value)
|
|
22
|
+
: value instanceof Json.LiveMap
|
|
23
|
+
? (function (map) {
|
|
24
|
+
for (
|
|
25
|
+
var _step,
|
|
26
|
+
result = {},
|
|
27
|
+
_iterator = Json._createForOfIteratorHelperLoose(map.entries());
|
|
28
|
+
!(_step = _iterator()).done;
|
|
42
29
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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;
|
|
52
45
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (void 0 === next) liveObject.delete(key); else if (void 0 === value) liveObject.set(key, anyToCrdt(next)); else {
|
|
61
|
-
if (prev === next) return;
|
|
62
|
-
value instanceof LiveObject.LiveList && Array.isArray(prev) && Array.isArray(next) ? function(liveList, prev, next) {
|
|
63
|
-
var i = 0, prevEnd = prev.length - 1, nextEnd = next.length - 1, prevNode = prev[0], nextNode = next[0];
|
|
64
|
-
outer: {
|
|
65
|
-
for (;prevNode === nextNode; ) {
|
|
66
|
-
if (++i > prevEnd || i > nextEnd) break outer;
|
|
67
|
-
prevNode = prev[i], nextNode = next[i];
|
|
46
|
+
function deepLiveify(value) {
|
|
47
|
+
if (Array.isArray(value)) return new Json.LiveList(value.map(deepLiveify));
|
|
48
|
+
if (Json.isPlainObject(value)) {
|
|
49
|
+
var init = {};
|
|
50
|
+
for (var key in value) {
|
|
51
|
+
var val = value[key];
|
|
52
|
+
void 0 !== val && (init[key] = deepLiveify(val));
|
|
68
53
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (i > prevEnd) {
|
|
75
|
-
if (i <= nextEnd) for (;i <= nextEnd; ) liveList.insert(anyToCrdt(next[i]), i),
|
|
76
|
-
i++;
|
|
77
|
-
} else if (i > nextEnd) for (var localI = i; localI <= prevEnd; ) liveList.delete(i),
|
|
78
|
-
localI++; else {
|
|
79
|
-
for (;i <= prevEnd && i <= nextEnd; ) {
|
|
80
|
-
prevNode = prev[i], nextNode = next[i];
|
|
81
|
-
var liveListNode = liveList.get(i);
|
|
82
|
-
liveListNode instanceof LiveObject.LiveObject && isPlainObject(prevNode) && isPlainObject(nextNode) ? patchLiveObject(liveListNode, prevNode, nextNode) : liveList.set(i, anyToCrdt(nextNode)),
|
|
83
|
-
i++;
|
|
84
|
-
}
|
|
85
|
-
for (;i <= nextEnd; ) liveList.insert(anyToCrdt(next[i]), i), i++;
|
|
86
|
-
for (var _localI = i; _localI <= prevEnd; ) liveList.delete(i), _localI++;
|
|
87
|
-
}
|
|
88
|
-
}(value, prev, next) : value instanceof LiveObject.LiveObject && isPlainObject(prev) && isPlainObject(next) ? patchLiveObject(value, prev, next) : liveObject.set(key, anyToCrdt(next));
|
|
89
|
-
}
|
|
54
|
+
return new Json.LiveObject(init);
|
|
55
|
+
}
|
|
56
|
+
return value;
|
|
90
57
|
}
|
|
58
|
+
function patchLiveObjectKey(liveObject, key, prev, next) {
|
|
59
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
60
|
+
var nonSerializableValue = Json.findNonSerializableValue(next);
|
|
61
|
+
if (nonSerializableValue)
|
|
62
|
+
return void console.error(
|
|
63
|
+
"New state path: '" +
|
|
64
|
+
nonSerializableValue.path +
|
|
65
|
+
"' value: '" +
|
|
66
|
+
nonSerializableValue.value +
|
|
67
|
+
"' is not serializable.\nOnly serializable value can be synced with Liveblocks."
|
|
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]);
|
|
86
|
+
}
|
|
87
|
+
for (
|
|
88
|
+
prevNode = prev[prevEnd], nextNode = next[nextEnd];
|
|
89
|
+
prevNode === nextNode;
|
|
91
90
|
|
|
91
|
+
) {
|
|
92
|
+
if ((nextEnd--, i > --prevEnd || i > nextEnd)) break outer;
|
|
93
|
+
(prevNode = prev[prevEnd]), (nextNode = next[nextEnd]);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (i > prevEnd) {
|
|
97
|
+
if (i <= nextEnd)
|
|
98
|
+
for (; i <= nextEnd; )
|
|
99
|
+
liveList.insert(deepLiveify(next[i]), i), i++;
|
|
100
|
+
} else if (i > nextEnd)
|
|
101
|
+
for (var localI = i; localI <= prevEnd; )
|
|
102
|
+
liveList.delete(i), localI++;
|
|
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)),
|
|
112
|
+
i++;
|
|
113
|
+
}
|
|
114
|
+
for (; i <= nextEnd; )
|
|
115
|
+
liveList.insert(deepLiveify(next[i]), i), i++;
|
|
116
|
+
for (var _localI = i; _localI <= prevEnd; )
|
|
117
|
+
liveList.delete(i), _localI++;
|
|
118
|
+
}
|
|
119
|
+
})(value, prev, next)
|
|
120
|
+
: Json.isLiveObject(value) &&
|
|
121
|
+
Json.isPlainObject(prev) &&
|
|
122
|
+
Json.isPlainObject(next)
|
|
123
|
+
? patchLiveObject(value, prev, next)
|
|
124
|
+
: liveObject.set(key, deepLiveify(next));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
92
127
|
function patchLiveObject(root, prev, next) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
128
|
+
var updates = {};
|
|
129
|
+
for (var key in next) patchLiveObjectKey(root, key, prev[key], next[key]);
|
|
130
|
+
for (var _key in prev) void 0 === next[_key] && root.delete(_key);
|
|
131
|
+
Object.keys(updates).length > 0 && root.update(updates);
|
|
97
132
|
}
|
|
98
|
-
|
|
99
133
|
function patchImmutableNode(state, path, update) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
134
|
+
var pathItem = path.pop();
|
|
135
|
+
if (void 0 === pathItem)
|
|
136
|
+
switch (update.type) {
|
|
137
|
+
case "LiveObject":
|
|
138
|
+
if (null === state || "object" != typeof state || Array.isArray(state))
|
|
139
|
+
throw new Error(
|
|
140
|
+
"Internal: received update on LiveObject but state was not an object"
|
|
141
|
+
);
|
|
142
|
+
var newState = Object.assign({}, state);
|
|
143
|
+
for (var key in update.updates) {
|
|
144
|
+
var _update$updates$key, _update$updates$key2;
|
|
145
|
+
if (
|
|
146
|
+
"update" ===
|
|
147
|
+
(null == (_update$updates$key = update.updates[key])
|
|
148
|
+
? void 0
|
|
149
|
+
: _update$updates$key.type)
|
|
150
|
+
) {
|
|
151
|
+
var val = update.node.get(key);
|
|
152
|
+
void 0 !== val && (newState[key] = lsonToJson(val));
|
|
153
|
+
} else
|
|
154
|
+
"delete" ===
|
|
155
|
+
(null == (_update$updates$key2 = update.updates[key])
|
|
156
|
+
? void 0
|
|
157
|
+
: _update$updates$key2.type) && delete newState[key];
|
|
158
|
+
}
|
|
159
|
+
return newState;
|
|
160
|
+
case "LiveList":
|
|
161
|
+
if (!Array.isArray(state))
|
|
162
|
+
throw new Error(
|
|
163
|
+
"Internal: received update on LiveList but state was not an array"
|
|
164
|
+
);
|
|
165
|
+
for (
|
|
166
|
+
var _step2,
|
|
167
|
+
_newState = state.map(function (x) {
|
|
168
|
+
return x;
|
|
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;
|
|
125
212
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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];
|
|
237
|
+
}
|
|
238
|
+
return _newState2;
|
|
239
|
+
}
|
|
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
|
+
);
|
|
132
262
|
}
|
|
133
|
-
return
|
|
134
|
-
}
|
|
135
|
-
if (Array.isArray(state)) {
|
|
136
|
-
var newArray = [].concat(state);
|
|
137
|
-
return newArray[pathItem] = patchImmutableNode(state[pathItem], path, update), newArray;
|
|
138
|
-
}
|
|
139
|
-
return LiveObject._extends({}, state, ((_extends2 = {})[pathItem] = patchImmutableNode(state[pathItem], path, update),
|
|
140
|
-
_extends2));
|
|
263
|
+
return state;
|
|
141
264
|
}
|
|
142
|
-
|
|
143
265
|
Object.defineProperty(exports, "ClientMsgCode", {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}),
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
exports.
|
|
174
|
-
exports.
|
|
175
|
-
exports.
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
266
|
+
enumerable: !0,
|
|
267
|
+
get: function () {
|
|
268
|
+
return Json.ClientMsgCode;
|
|
269
|
+
},
|
|
270
|
+
}),
|
|
271
|
+
Object.defineProperty(exports, "CrdtType", {
|
|
272
|
+
enumerable: !0,
|
|
273
|
+
get: function () {
|
|
274
|
+
return Json.CrdtType;
|
|
275
|
+
},
|
|
276
|
+
}),
|
|
277
|
+
Object.defineProperty(exports, "OpCode", {
|
|
278
|
+
enumerable: !0,
|
|
279
|
+
get: function () {
|
|
280
|
+
return Json.OpCode;
|
|
281
|
+
},
|
|
282
|
+
}),
|
|
283
|
+
Object.defineProperty(exports, "ServerMsgCode", {
|
|
284
|
+
enumerable: !0,
|
|
285
|
+
get: function () {
|
|
286
|
+
return Json.ServerMsgCode;
|
|
287
|
+
},
|
|
288
|
+
}),
|
|
289
|
+
Object.defineProperty(exports, "WebsocketCloseCodes", {
|
|
290
|
+
enumerable: !0,
|
|
291
|
+
get: function () {
|
|
292
|
+
return Json.WebsocketCloseCodes;
|
|
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.parseAuthToken = Json.parseAuthToken),
|
|
314
|
+
(exports.throwUsageError = Json.throwUsageError),
|
|
315
|
+
(exports.tryParseJson = Json.tryParseJson),
|
|
316
|
+
(exports.lsonToJson = lsonToJson),
|
|
317
|
+
(exports.patchImmutableObject = function (state, updates) {
|
|
318
|
+
return updates.reduce(function (state, update) {
|
|
319
|
+
return (function (state, update) {
|
|
320
|
+
var path = (function (node) {
|
|
321
|
+
for (var path = []; "HasParent" === node.parent.type; )
|
|
322
|
+
Json.isLiveList(node.parent.node)
|
|
323
|
+
? path.push(node.parent.node._indexOfPosition(node.parent.key))
|
|
324
|
+
: path.push(node.parent.key),
|
|
325
|
+
(node = node.parent.node);
|
|
326
|
+
return path;
|
|
327
|
+
})(update.node);
|
|
328
|
+
return patchImmutableNode(state, path, update);
|
|
329
|
+
})(state, update);
|
|
330
|
+
}, state);
|
|
331
|
+
}),
|
|
332
|
+
(exports.patchLiveObjectKey = patchLiveObjectKey);
|