@liveblocks/client 0.16.16 → 0.17.0-beta2
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 +28 -8
- package/index.js +1290 -830
- package/index.mjs +1091 -782
- package/internal.d.ts +418 -276
- package/internal.js +313 -205
- package/internal.mjs +265 -171
- package/package.json +15 -10
- package/shared.d.ts +719 -650
- package/shared.js +2583 -1326
- package/shared.mjs +2000 -1204
package/internal.js
CHANGED
|
@@ -1,223 +1,331 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: !0
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var LiveObject = require("./shared.js"), SCOPES = [ "websocket:presence", "websocket:storage", "room:read", "room:write", "rooms:read", "rooms:write" ];
|
|
8
|
-
|
|
9
|
-
function isStringList(value) {
|
|
10
|
-
return Array.isArray(value) && value.every((function(i) {
|
|
11
|
-
return "string" == typeof i;
|
|
12
|
-
}));
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function isAppOnlyAuthToken(data) {
|
|
16
|
-
return "string" == typeof data.appId && void 0 === data.roomId && isStringList(data.scopes);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function isRoomAuthToken(data) {
|
|
20
|
-
return "string" == typeof data.appId && "string" == typeof data.roomId && "number" == typeof data.actor && (void 0 === data.id || "string" == typeof data.id) && isStringList(data.scopes) && "number" == typeof data.maxConnections && (void 0 === data.maxConnectionsPerRoom || "number" == typeof data.maxConnectionsPerRoom);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function isAuthToken(data) {
|
|
24
|
-
return isAppOnlyAuthToken(data) || isRoomAuthToken(data);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function parseJwtToken(token) {
|
|
28
|
-
var tokenParts = token.split(".");
|
|
29
|
-
if (3 !== tokenParts.length) throw new Error("Authentication error: invalid JWT token");
|
|
30
|
-
var data = LiveObject.tryParseJson(LiveObject.b64decode(tokenParts[1]));
|
|
31
|
-
if (data && function(data) {
|
|
32
|
-
if (!LiveObject.isPlainObject(data)) return !1;
|
|
33
|
-
var iat = data.iat, exp = data.exp;
|
|
34
|
-
return "number" == typeof iat && "number" == typeof exp;
|
|
35
|
-
}(data)) return data;
|
|
36
|
-
throw new Error("Authentication error: missing JWT metadata");
|
|
37
|
-
}
|
|
38
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
+
var Json = require("./shared.js");
|
|
39
4
|
function lsonObjectToJson(obj) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
return result;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function lsonListToJson(value) {
|
|
49
|
-
return value.map(lsonToJson);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function lsonToJson(value) {
|
|
53
|
-
if (value instanceof LiveObject.LiveObject) return lsonObjectToJson(value.toObject());
|
|
54
|
-
if (value instanceof LiveObject.LiveList) return function(value) {
|
|
55
|
-
return lsonListToJson(value.toArray());
|
|
56
|
-
}(value);
|
|
57
|
-
if (value instanceof LiveObject.LiveMap) return function(map) {
|
|
58
|
-
for (var _step, result = {}, _iterator = LiveObject._createForOfIteratorHelperLoose(map.entries()); !(_step = _iterator()).done; ) {
|
|
59
|
-
var _step$value = _step.value, _key2 = _step$value[0], value = _step$value[1];
|
|
60
|
-
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));
|
|
61
9
|
}
|
|
62
10
|
return result;
|
|
63
|
-
}(value);
|
|
64
|
-
if (value instanceof LiveObject.LiveRegister) return value.data;
|
|
65
|
-
if (value instanceof LiveObject.AbstractCrdt) throw new Error("Unhandled subclass of AbstractCrdt encountered");
|
|
66
|
-
return Array.isArray(value) ? lsonListToJson(value) : isPlainObject(value) ? lsonObjectToJson(value) : value;
|
|
67
11
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return null !== obj && "[object Object]" === Object.prototype.toString.call(obj);
|
|
12
|
+
function lsonListToJson(value) {
|
|
13
|
+
return value.map(lsonToJson);
|
|
71
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;
|
|
72
29
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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;
|
|
82
45
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (void 0 === next) liveObject.delete(key); else if (void 0 === value) liveObject.set(key, anyToCrdt(next)); else {
|
|
91
|
-
if (prev === next) return;
|
|
92
|
-
value instanceof LiveObject.LiveList && Array.isArray(prev) && Array.isArray(next) ? function(liveList, prev, next) {
|
|
93
|
-
var i = 0, prevEnd = prev.length - 1, nextEnd = next.length - 1, prevNode = prev[0], nextNode = next[0];
|
|
94
|
-
outer: {
|
|
95
|
-
for (;prevNode === nextNode; ) {
|
|
96
|
-
if (++i > prevEnd || i > nextEnd) break outer;
|
|
97
|
-
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));
|
|
98
53
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
if (i > prevEnd) {
|
|
105
|
-
if (i <= nextEnd) for (;i <= nextEnd; ) liveList.insert(anyToCrdt(next[i]), i),
|
|
106
|
-
i++;
|
|
107
|
-
} else if (i > nextEnd) for (var localI = i; localI <= prevEnd; ) liveList.delete(i),
|
|
108
|
-
localI++; else {
|
|
109
|
-
for (;i <= prevEnd && i <= nextEnd; ) {
|
|
110
|
-
prevNode = prev[i], nextNode = next[i];
|
|
111
|
-
var liveListNode = liveList.get(i);
|
|
112
|
-
liveListNode instanceof LiveObject.LiveObject && isPlainObject(prevNode) && isPlainObject(nextNode) ? patchLiveObject(liveListNode, prevNode, nextNode) : liveList.set(i, anyToCrdt(nextNode)),
|
|
113
|
-
i++;
|
|
114
|
-
}
|
|
115
|
-
for (;i <= nextEnd; ) liveList.insert(anyToCrdt(next[i]), i), i++;
|
|
116
|
-
for (var _localI = i; _localI <= prevEnd; ) liveList.delete(i), _localI++;
|
|
117
|
-
}
|
|
118
|
-
}(value, prev, next) : value instanceof LiveObject.LiveObject && isPlainObject(prev) && isPlainObject(next) ? patchLiveObject(value, prev, next) : liveObject.set(key, anyToCrdt(next));
|
|
119
|
-
}
|
|
54
|
+
return new Json.LiveObject(init);
|
|
55
|
+
}
|
|
56
|
+
return value;
|
|
120
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;
|
|
121
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
|
+
}
|
|
122
127
|
function patchLiveObject(root, prev, next) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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);
|
|
127
132
|
}
|
|
128
|
-
|
|
129
133
|
function patchImmutableNode(state, path, update) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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;
|
|
143
212
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
+
);
|
|
162
246
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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;
|
|
171
264
|
}
|
|
172
|
-
|
|
173
265
|
Object.defineProperty(exports, "ClientMsgCode", {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}),
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
exports.
|
|
204
|
-
exports.
|
|
205
|
-
exports.
|
|
206
|
-
exports.
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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.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);
|