parse 4.0.0-beta.1 → 4.0.1-beta.1
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/LICENSE +167 -25
- package/NOTICE +10 -0
- package/README.md +1 -3
- package/dist/parse.js +188 -374
- package/dist/parse.min.js +7 -6
- package/dist/parse.weapp.js +188 -374
- package/dist/parse.weapp.min.js +7 -6
- package/lib/browser/Analytics.js +0 -7
- package/lib/browser/AnonymousUtils.js +0 -7
- package/lib/browser/Cloud.js +0 -7
- package/lib/browser/CoreManager.js +1 -8
- package/lib/browser/EventEmitter.js +0 -7
- package/lib/browser/FacebookUtils.js +0 -7
- package/lib/browser/InstallationController.js +0 -7
- package/lib/browser/LocalDatastoreUtils.js +0 -7
- package/lib/browser/OfflineQuery.js +27 -8
- package/lib/browser/Parse.js +0 -9
- package/lib/browser/ParseACL.js +0 -7
- package/lib/browser/ParseConfig.js +0 -7
- package/lib/browser/ParseError.js +0 -9
- package/lib/browser/ParseGeoPoint.js +0 -7
- package/lib/browser/ParseObject.js +158 -126
- package/lib/browser/ParsePolygon.js +0 -7
- package/lib/browser/ParseRelation.js +0 -7
- package/lib/browser/ParseSchema.js +0 -7
- package/lib/browser/Push.js +0 -7
- package/lib/browser/RESTController.js +0 -7
- package/lib/browser/SingleInstanceStateController.js +0 -7
- package/lib/browser/Storage.js +0 -7
- package/lib/browser/StorageController.browser.js +0 -7
- package/lib/browser/StorageController.default.js +0 -7
- package/lib/browser/StorageController.react-native.js +0 -7
- package/lib/browser/StorageController.weapp.js +0 -7
- package/lib/browser/TaskQueue.js +0 -7
- package/lib/browser/UniqueInstanceStateController.js +0 -7
- package/lib/browser/arrayContainsObject.js +0 -7
- package/lib/browser/canBeSerialized.js +0 -7
- package/lib/browser/decode.js +0 -7
- package/lib/browser/encode.js +0 -7
- package/lib/browser/equals.js +0 -9
- package/lib/browser/escape.js +0 -7
- package/lib/browser/isRevocableSession.js +0 -7
- package/lib/browser/parseDate.js +0 -7
- package/lib/browser/unique.js +0 -7
- package/lib/browser/unsavedChildren.js +0 -7
- package/lib/node/Analytics.js +0 -7
- package/lib/node/AnonymousUtils.js +0 -7
- package/lib/node/Cloud.js +0 -7
- package/lib/node/CoreManager.js +1 -8
- package/lib/node/EventEmitter.js +0 -7
- package/lib/node/FacebookUtils.js +0 -7
- package/lib/node/InstallationController.js +0 -7
- package/lib/node/LiveQueryClient.js +0 -10
- package/lib/node/LiveQuerySubscription.js +0 -10
- package/lib/node/LocalDatastore.js +0 -7
- package/lib/node/LocalDatastoreController.js +0 -7
- package/lib/node/LocalDatastoreController.react-native.js +0 -7
- package/lib/node/LocalDatastoreUtils.js +0 -7
- package/lib/node/ObjectStateMutations.js +0 -7
- package/lib/node/OfflineQuery.js +8 -0
- package/lib/node/Parse.js +0 -9
- package/lib/node/ParseACL.js +0 -7
- package/lib/node/ParseCLP.js +0 -7
- package/lib/node/ParseConfig.js +0 -7
- package/lib/node/ParseError.js +0 -9
- package/lib/node/ParseFile.js +0 -7
- package/lib/node/ParseGeoPoint.js +0 -7
- package/lib/node/ParseInstallation.js +0 -7
- package/lib/node/ParseLiveQuery.js +0 -7
- package/lib/node/ParseObject.js +40 -29
- package/lib/node/ParseOp.js +0 -7
- package/lib/node/ParsePolygon.js +0 -7
- package/lib/node/ParseQuery.js +0 -7
- package/lib/node/ParseRelation.js +0 -7
- package/lib/node/ParseRole.js +0 -7
- package/lib/node/ParseSchema.js +0 -7
- package/lib/node/ParseSession.js +0 -7
- package/lib/node/ParseUser.js +0 -7
- package/lib/node/Push.js +0 -7
- package/lib/node/RESTController.js +0 -7
- package/lib/node/SingleInstanceStateController.js +0 -7
- package/lib/node/Storage.js +0 -7
- package/lib/node/StorageController.browser.js +0 -7
- package/lib/node/StorageController.default.js +0 -7
- package/lib/node/StorageController.react-native.js +0 -7
- package/lib/node/StorageController.weapp.js +0 -7
- package/lib/node/TaskQueue.js +0 -7
- package/lib/node/UniqueInstanceStateController.js +0 -7
- package/lib/node/arrayContainsObject.js +0 -7
- package/lib/node/canBeSerialized.js +0 -7
- package/lib/node/decode.js +0 -7
- package/lib/node/encode.js +0 -7
- package/lib/node/equals.js +0 -9
- package/lib/node/escape.js +0 -7
- package/lib/node/isRevocableSession.js +0 -7
- package/lib/node/parseDate.js +0 -7
- package/lib/node/unique.js +0 -7
- package/lib/node/unsavedChildren.js +0 -7
- package/lib/react-native/CoreManager.js +2 -2
- package/lib/react-native/EventuallyQueue.js +169 -676
- package/lib/react-native/LiveQueryClient.js +3 -46
- package/lib/react-native/LocalDatastore.js +303 -863
- package/lib/react-native/LocalDatastoreController.js +75 -535
- package/lib/react-native/LocalDatastoreController.react-native.js +95 -503
- package/lib/react-native/ObjectStateMutations.js +2 -31
- package/lib/react-native/OfflineQuery.js +24 -60
- package/lib/react-native/ParseCLP.js +55 -129
- package/lib/react-native/ParseFile.js +63 -468
- package/lib/react-native/ParseLiveQuery.js +60 -455
- package/lib/react-native/ParseObject.js +263 -897
- package/lib/react-native/ParseQuery.js +207 -643
- package/lib/react-native/ParseSchema.js +3 -3
- package/lib/react-native/ParseUser.js +118 -573
- package/lib/react-native/RESTController.js +1 -29
- package/lib/weapp/Analytics.js +0 -7
- package/lib/weapp/AnonymousUtils.js +0 -7
- package/lib/weapp/Cloud.js +0 -7
- package/lib/weapp/CoreManager.js +1 -8
- package/lib/weapp/EventEmitter.js +0 -7
- package/lib/weapp/FacebookUtils.js +0 -7
- package/lib/weapp/InstallationController.js +0 -7
- package/lib/weapp/LocalDatastoreUtils.js +0 -7
- package/lib/weapp/OfflineQuery.js +27 -8
- package/lib/weapp/Parse.js +0 -9
- package/lib/weapp/ParseACL.js +0 -7
- package/lib/weapp/ParseConfig.js +0 -7
- package/lib/weapp/ParseError.js +0 -9
- package/lib/weapp/ParseGeoPoint.js +0 -7
- package/lib/weapp/ParseObject.js +158 -126
- package/lib/weapp/ParsePolygon.js +0 -7
- package/lib/weapp/ParseRelation.js +0 -7
- package/lib/weapp/ParseSchema.js +0 -7
- package/lib/weapp/Push.js +0 -7
- package/lib/weapp/RESTController.js +0 -7
- package/lib/weapp/SingleInstanceStateController.js +0 -7
- package/lib/weapp/Storage.js +0 -7
- package/lib/weapp/StorageController.browser.js +0 -7
- package/lib/weapp/StorageController.default.js +0 -7
- package/lib/weapp/StorageController.react-native.js +0 -7
- package/lib/weapp/StorageController.weapp.js +0 -7
- package/lib/weapp/TaskQueue.js +0 -7
- package/lib/weapp/UniqueInstanceStateController.js +0 -7
- package/lib/weapp/arrayContainsObject.js +0 -7
- package/lib/weapp/canBeSerialized.js +0 -7
- package/lib/weapp/decode.js +0 -7
- package/lib/weapp/encode.js +0 -7
- package/lib/weapp/equals.js +0 -9
- package/lib/weapp/escape.js +0 -7
- package/lib/weapp/isRevocableSession.js +0 -7
- package/lib/weapp/parseDate.js +0 -7
- package/lib/weapp/unique.js +0 -7
- package/lib/weapp/unsavedChildren.js +0 -7
- package/package.json +9 -9
- package/PATENTS +0 -37
|
@@ -4,403 +4,14 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
4
4
|
|
|
5
5
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
6
6
|
|
|
7
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
|
+
|
|
7
9
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
8
10
|
|
|
9
11
|
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
10
12
|
|
|
11
13
|
var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
|
|
12
14
|
|
|
13
|
-
function _regeneratorRuntime() {
|
|
14
|
-
"use strict";
|
|
15
|
-
|
|
16
|
-
_regeneratorRuntime = function () {
|
|
17
|
-
return exports;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
var exports = {},
|
|
21
|
-
Op = Object.prototype,
|
|
22
|
-
hasOwn = Op.hasOwnProperty,
|
|
23
|
-
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
24
|
-
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
25
|
-
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
26
|
-
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
27
|
-
|
|
28
|
-
function define(obj, key, value) {
|
|
29
|
-
return Object.defineProperty(obj, key, {
|
|
30
|
-
value: value,
|
|
31
|
-
enumerable: !0,
|
|
32
|
-
configurable: !0,
|
|
33
|
-
writable: !0
|
|
34
|
-
}), obj[key];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
define({}, "");
|
|
39
|
-
} catch (err) {
|
|
40
|
-
define = function (obj, key, value) {
|
|
41
|
-
return obj[key] = value;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
46
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
47
|
-
generator = Object.create(protoGenerator.prototype),
|
|
48
|
-
context = new Context(tryLocsList || []);
|
|
49
|
-
return generator._invoke = function (innerFn, self, context) {
|
|
50
|
-
var state = "suspendedStart";
|
|
51
|
-
return function (method, arg) {
|
|
52
|
-
if ("executing" === state) throw new Error("Generator is already running");
|
|
53
|
-
|
|
54
|
-
if ("completed" === state) {
|
|
55
|
-
if ("throw" === method) throw arg;
|
|
56
|
-
return doneResult();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
for (context.method = method, context.arg = arg;;) {
|
|
60
|
-
var delegate = context.delegate;
|
|
61
|
-
|
|
62
|
-
if (delegate) {
|
|
63
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
64
|
-
|
|
65
|
-
if (delegateResult) {
|
|
66
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
67
|
-
return delegateResult;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
72
|
-
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
73
|
-
context.dispatchException(context.arg);
|
|
74
|
-
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
75
|
-
state = "executing";
|
|
76
|
-
var record = tryCatch(innerFn, self, context);
|
|
77
|
-
|
|
78
|
-
if ("normal" === record.type) {
|
|
79
|
-
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
80
|
-
return {
|
|
81
|
-
value: record.arg,
|
|
82
|
-
done: context.done
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
}(innerFn, self, context), generator;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function tryCatch(fn, obj, arg) {
|
|
93
|
-
try {
|
|
94
|
-
return {
|
|
95
|
-
type: "normal",
|
|
96
|
-
arg: fn.call(obj, arg)
|
|
97
|
-
};
|
|
98
|
-
} catch (err) {
|
|
99
|
-
return {
|
|
100
|
-
type: "throw",
|
|
101
|
-
arg: err
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
exports.wrap = wrap;
|
|
107
|
-
var ContinueSentinel = {};
|
|
108
|
-
|
|
109
|
-
function Generator() {}
|
|
110
|
-
|
|
111
|
-
function GeneratorFunction() {}
|
|
112
|
-
|
|
113
|
-
function GeneratorFunctionPrototype() {}
|
|
114
|
-
|
|
115
|
-
var IteratorPrototype = {};
|
|
116
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
117
|
-
return this;
|
|
118
|
-
});
|
|
119
|
-
var getProto = Object.getPrototypeOf,
|
|
120
|
-
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
121
|
-
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
122
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
123
|
-
|
|
124
|
-
function defineIteratorMethods(prototype) {
|
|
125
|
-
["next", "throw", "return"].forEach(function (method) {
|
|
126
|
-
define(prototype, method, function (arg) {
|
|
127
|
-
return this._invoke(method, arg);
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
133
|
-
function invoke(method, arg, resolve, reject) {
|
|
134
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
135
|
-
|
|
136
|
-
if ("throw" !== record.type) {
|
|
137
|
-
var result = record.arg,
|
|
138
|
-
value = result.value;
|
|
139
|
-
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
140
|
-
invoke("next", value, resolve, reject);
|
|
141
|
-
}, function (err) {
|
|
142
|
-
invoke("throw", err, resolve, reject);
|
|
143
|
-
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
144
|
-
result.value = unwrapped, resolve(result);
|
|
145
|
-
}, function (error) {
|
|
146
|
-
return invoke("throw", error, resolve, reject);
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
reject(record.arg);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
var previousPromise;
|
|
154
|
-
|
|
155
|
-
this._invoke = function (method, arg) {
|
|
156
|
-
function callInvokeWithMethodAndArg() {
|
|
157
|
-
return new PromiseImpl(function (resolve, reject) {
|
|
158
|
-
invoke(method, arg, resolve, reject);
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
167
|
-
var method = delegate.iterator[context.method];
|
|
168
|
-
|
|
169
|
-
if (undefined === method) {
|
|
170
|
-
if (context.delegate = null, "throw" === context.method) {
|
|
171
|
-
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
172
|
-
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return ContinueSentinel;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
179
|
-
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
180
|
-
var info = record.arg;
|
|
181
|
-
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function pushTryEntry(locs) {
|
|
185
|
-
var entry = {
|
|
186
|
-
tryLoc: locs[0]
|
|
187
|
-
};
|
|
188
|
-
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function resetTryEntry(entry) {
|
|
192
|
-
var record = entry.completion || {};
|
|
193
|
-
record.type = "normal", delete record.arg, entry.completion = record;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function Context(tryLocsList) {
|
|
197
|
-
this.tryEntries = [{
|
|
198
|
-
tryLoc: "root"
|
|
199
|
-
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
function values(iterable) {
|
|
203
|
-
if (iterable) {
|
|
204
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
205
|
-
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
206
|
-
if ("function" == typeof iterable.next) return iterable;
|
|
207
|
-
|
|
208
|
-
if (!isNaN(iterable.length)) {
|
|
209
|
-
var i = -1,
|
|
210
|
-
next = function next() {
|
|
211
|
-
for (; ++i < iterable.length;) {
|
|
212
|
-
if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return next.value = undefined, next.done = !0, next;
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
return next.next = next;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return {
|
|
223
|
-
next: doneResult
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
function doneResult() {
|
|
228
|
-
return {
|
|
229
|
-
value: undefined,
|
|
230
|
-
done: !0
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
235
|
-
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
236
|
-
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
237
|
-
}, exports.mark = function (genFun) {
|
|
238
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
239
|
-
}, exports.awrap = function (arg) {
|
|
240
|
-
return {
|
|
241
|
-
__await: arg
|
|
242
|
-
};
|
|
243
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
244
|
-
return this;
|
|
245
|
-
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
246
|
-
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
247
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
248
|
-
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
249
|
-
return result.done ? result.value : iter.next();
|
|
250
|
-
});
|
|
251
|
-
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
252
|
-
return this;
|
|
253
|
-
}), define(Gp, "toString", function () {
|
|
254
|
-
return "[object Generator]";
|
|
255
|
-
}), exports.keys = function (object) {
|
|
256
|
-
var keys = [];
|
|
257
|
-
|
|
258
|
-
for (var key in object) {
|
|
259
|
-
keys.push(key);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
return keys.reverse(), function next() {
|
|
263
|
-
for (; keys.length;) {
|
|
264
|
-
var key = keys.pop();
|
|
265
|
-
if (key in object) return next.value = key, next.done = !1, next;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
return next.done = !0, next;
|
|
269
|
-
};
|
|
270
|
-
}, exports.values = values, Context.prototype = {
|
|
271
|
-
constructor: Context,
|
|
272
|
-
reset: function (skipTempReset) {
|
|
273
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
|
|
274
|
-
"t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
275
|
-
}
|
|
276
|
-
},
|
|
277
|
-
stop: function () {
|
|
278
|
-
this.done = !0;
|
|
279
|
-
var rootRecord = this.tryEntries[0].completion;
|
|
280
|
-
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
281
|
-
return this.rval;
|
|
282
|
-
},
|
|
283
|
-
dispatchException: function (exception) {
|
|
284
|
-
if (this.done) throw exception;
|
|
285
|
-
var context = this;
|
|
286
|
-
|
|
287
|
-
function handle(loc, caught) {
|
|
288
|
-
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
292
|
-
var entry = this.tryEntries[i],
|
|
293
|
-
record = entry.completion;
|
|
294
|
-
if ("root" === entry.tryLoc) return handle("end");
|
|
295
|
-
|
|
296
|
-
if (entry.tryLoc <= this.prev) {
|
|
297
|
-
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
298
|
-
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
299
|
-
|
|
300
|
-
if (hasCatch && hasFinally) {
|
|
301
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
302
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
303
|
-
} else if (hasCatch) {
|
|
304
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
305
|
-
} else {
|
|
306
|
-
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
307
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
},
|
|
312
|
-
abrupt: function (type, arg) {
|
|
313
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
314
|
-
var entry = this.tryEntries[i];
|
|
315
|
-
|
|
316
|
-
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
317
|
-
var finallyEntry = entry;
|
|
318
|
-
break;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
323
|
-
var record = finallyEntry ? finallyEntry.completion : {};
|
|
324
|
-
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
325
|
-
},
|
|
326
|
-
complete: function (record, afterLoc) {
|
|
327
|
-
if ("throw" === record.type) throw record.arg;
|
|
328
|
-
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
329
|
-
},
|
|
330
|
-
finish: function (finallyLoc) {
|
|
331
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
332
|
-
var entry = this.tryEntries[i];
|
|
333
|
-
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
334
|
-
}
|
|
335
|
-
},
|
|
336
|
-
catch: function (tryLoc) {
|
|
337
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
338
|
-
var entry = this.tryEntries[i];
|
|
339
|
-
|
|
340
|
-
if (entry.tryLoc === tryLoc) {
|
|
341
|
-
var record = entry.completion;
|
|
342
|
-
|
|
343
|
-
if ("throw" === record.type) {
|
|
344
|
-
var thrown = record.arg;
|
|
345
|
-
resetTryEntry(entry);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
return thrown;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
throw new Error("illegal catch attempt");
|
|
353
|
-
},
|
|
354
|
-
delegateYield: function (iterable, resultName, nextLoc) {
|
|
355
|
-
return this.delegate = {
|
|
356
|
-
iterator: values(iterable),
|
|
357
|
-
resultName: resultName,
|
|
358
|
-
nextLoc: nextLoc
|
|
359
|
-
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
360
|
-
}
|
|
361
|
-
}, exports;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
365
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
366
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
367
|
-
|
|
368
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
369
|
-
if (it) o = it;
|
|
370
|
-
var i = 0;
|
|
371
|
-
return function () {
|
|
372
|
-
if (i >= o.length) return {
|
|
373
|
-
done: true
|
|
374
|
-
};
|
|
375
|
-
return {
|
|
376
|
-
done: false,
|
|
377
|
-
value: o[i++]
|
|
378
|
-
};
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
386
|
-
if (!o) return;
|
|
387
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
388
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
389
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
390
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
391
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
function _arrayLikeToArray(arr, len) {
|
|
395
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
396
|
-
|
|
397
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
398
|
-
arr2[i] = arr[i];
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
return arr2;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
15
|
var LocalDatastore = {
|
|
405
16
|
isEnabled: false,
|
|
406
17
|
isSyncing: false,
|
|
@@ -434,149 +45,106 @@ var LocalDatastore = {
|
|
|
434
45
|
|
|
435
46
|
return controller.clear();
|
|
436
47
|
},
|
|
437
|
-
_handlePinAllWithName: function (
|
|
438
|
-
var
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
switch (_context.prev = _context.next) {
|
|
443
|
-
case 0:
|
|
444
|
-
pinName = this.getPinName(name);
|
|
445
|
-
toPinPromises = [];
|
|
446
|
-
objectKeys = [];
|
|
447
|
-
|
|
448
|
-
for (_iterator = _createForOfIteratorHelperLoose(objects); !(_step = _iterator()).done;) {
|
|
449
|
-
parent = _step.value;
|
|
450
|
-
children = this._getChildren(parent);
|
|
451
|
-
parentKey = this.getKeyForObject(parent);
|
|
452
|
-
json = parent._toFullJSON(undefined, true);
|
|
453
|
-
|
|
454
|
-
if (parent._localId) {
|
|
455
|
-
json._localId = parent._localId;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
children[parentKey] = json;
|
|
459
|
-
|
|
460
|
-
for (objectKey in children) {
|
|
461
|
-
objectKeys.push(objectKey);
|
|
462
|
-
toPinPromises.push(this.pinWithName(objectKey, [children[objectKey]]));
|
|
463
|
-
}
|
|
464
|
-
}
|
|
48
|
+
_handlePinAllWithName: function () {
|
|
49
|
+
var _handlePinAllWithName2 = (0, _asyncToGenerator2.default)(function* (name, objects) {
|
|
50
|
+
var pinName = this.getPinName(name);
|
|
51
|
+
var toPinPromises = [];
|
|
52
|
+
var objectKeys = [];
|
|
465
53
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
return _regeneratorRuntime().awrap(Promise.all([fromPinPromise, toPinPromises]));
|
|
54
|
+
for (var parent of objects) {
|
|
55
|
+
var children = this._getChildren(parent);
|
|
469
56
|
|
|
470
|
-
|
|
471
|
-
_await$Promise$all = _context.sent;
|
|
472
|
-
_await$Promise$all2 = (0, _slicedToArray2.default)(_await$Promise$all, 1);
|
|
473
|
-
pinned = _await$Promise$all2[0];
|
|
474
|
-
toPin = (0, _toConsumableArray2.default)(new Set([].concat((0, _toConsumableArray2.default)(pinned || []), objectKeys)));
|
|
475
|
-
return _context.abrupt("return", this.pinWithName(pinName, toPin));
|
|
57
|
+
var parentKey = this.getKeyForObject(parent);
|
|
476
58
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
59
|
+
var json = parent._toFullJSON(undefined, true);
|
|
60
|
+
|
|
61
|
+
if (parent._localId) {
|
|
62
|
+
json._localId = parent._localId;
|
|
480
63
|
}
|
|
481
|
-
}
|
|
482
|
-
}, null, this, null, Promise);
|
|
483
|
-
},
|
|
484
|
-
_handleUnPinAllWithName: function (name, objects) {
|
|
485
|
-
var localDatastore, pinName, promises, objectKeys, _iterator2, _step2, _objectKeys, parent, children, parentKey, pinned, _iterator3, _step3, objectKey, hasReference, key, pinnedObjects;
|
|
486
|
-
|
|
487
|
-
return _regeneratorRuntime().async(function (_context2) {
|
|
488
|
-
while (1) {
|
|
489
|
-
switch (_context2.prev = _context2.next) {
|
|
490
|
-
case 0:
|
|
491
|
-
_context2.next = 2;
|
|
492
|
-
return _regeneratorRuntime().awrap(this._getAllContents());
|
|
493
|
-
|
|
494
|
-
case 2:
|
|
495
|
-
localDatastore = _context2.sent;
|
|
496
|
-
pinName = this.getPinName(name);
|
|
497
|
-
promises = [];
|
|
498
|
-
objectKeys = [];
|
|
499
|
-
|
|
500
|
-
for (_iterator2 = _createForOfIteratorHelperLoose(objects); !(_step2 = _iterator2()).done;) {
|
|
501
|
-
parent = _step2.value;
|
|
502
|
-
children = this._getChildren(parent);
|
|
503
|
-
parentKey = this.getKeyForObject(parent);
|
|
504
|
-
|
|
505
|
-
(_objectKeys = objectKeys).push.apply(_objectKeys, [parentKey].concat((0, _toConsumableArray2.default)(Object.keys(children))));
|
|
506
|
-
}
|
|
507
64
|
|
|
508
|
-
|
|
509
|
-
pinned = localDatastore[pinName] || [];
|
|
510
|
-
pinned = pinned.filter(function (item) {
|
|
511
|
-
return !objectKeys.includes(item);
|
|
512
|
-
});
|
|
65
|
+
children[parentKey] = json;
|
|
513
66
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
localDatastore[pinName] = pinned;
|
|
520
|
-
}
|
|
67
|
+
for (var objectKey in children) {
|
|
68
|
+
objectKeys.push(objectKey);
|
|
69
|
+
toPinPromises.push(this.pinWithName(objectKey, [children[objectKey]]));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
521
72
|
|
|
522
|
-
|
|
73
|
+
var fromPinPromise = this.fromPinWithName(pinName);
|
|
523
74
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
break;
|
|
528
|
-
}
|
|
75
|
+
var _yield$Promise$all = yield Promise.all([fromPinPromise, toPinPromises]),
|
|
76
|
+
_yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 1),
|
|
77
|
+
pinned = _yield$Promise$all2[0];
|
|
529
78
|
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
79
|
+
var toPin = (0, _toConsumableArray2.default)(new Set([].concat((0, _toConsumableArray2.default)(pinned || []), objectKeys)));
|
|
80
|
+
return this.pinWithName(pinName, toPin);
|
|
81
|
+
});
|
|
533
82
|
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
break;
|
|
538
|
-
}
|
|
83
|
+
function _handlePinAllWithName() {
|
|
84
|
+
return _handlePinAllWithName2.apply(this, arguments);
|
|
85
|
+
}
|
|
539
86
|
|
|
540
|
-
|
|
87
|
+
return _handlePinAllWithName;
|
|
88
|
+
}(),
|
|
89
|
+
_handleUnPinAllWithName: function () {
|
|
90
|
+
var _handleUnPinAllWithName2 = (0, _asyncToGenerator2.default)(function* (name, objects) {
|
|
91
|
+
var localDatastore = yield this._getAllContents();
|
|
92
|
+
var pinName = this.getPinName(name);
|
|
93
|
+
var promises = [];
|
|
94
|
+
var objectKeys = [];
|
|
541
95
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
break;
|
|
545
|
-
}
|
|
96
|
+
for (var parent of objects) {
|
|
97
|
+
var _objectKeys;
|
|
546
98
|
|
|
547
|
-
|
|
99
|
+
var children = this._getChildren(parent);
|
|
548
100
|
|
|
549
|
-
|
|
550
|
-
_context2.next = 23;
|
|
551
|
-
break;
|
|
552
|
-
}
|
|
101
|
+
var parentKey = this.getKeyForObject(parent);
|
|
553
102
|
|
|
554
|
-
|
|
555
|
-
|
|
103
|
+
(_objectKeys = objectKeys).push.apply(_objectKeys, [parentKey].concat((0, _toConsumableArray2.default)(Object.keys(children))));
|
|
104
|
+
}
|
|
556
105
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
106
|
+
objectKeys = (0, _toConsumableArray2.default)(new Set(objectKeys));
|
|
107
|
+
var pinned = localDatastore[pinName] || [];
|
|
108
|
+
pinned = pinned.filter(function (item) {
|
|
109
|
+
return !objectKeys.includes(item);
|
|
110
|
+
});
|
|
560
111
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
112
|
+
if (pinned.length == 0) {
|
|
113
|
+
promises.push(this.unPinWithName(pinName));
|
|
114
|
+
delete localDatastore[pinName];
|
|
115
|
+
} else {
|
|
116
|
+
promises.push(this.pinWithName(pinName, pinned));
|
|
117
|
+
localDatastore[pinName] = pinned;
|
|
118
|
+
}
|
|
565
119
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
break;
|
|
120
|
+
for (var objectKey of objectKeys) {
|
|
121
|
+
var hasReference = false;
|
|
569
122
|
|
|
570
|
-
|
|
571
|
-
|
|
123
|
+
for (var key in localDatastore) {
|
|
124
|
+
if (key === _LocalDatastoreUtils.DEFAULT_PIN || key.startsWith(_LocalDatastoreUtils.PIN_PREFIX)) {
|
|
125
|
+
var pinnedObjects = localDatastore[key] || [];
|
|
572
126
|
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
127
|
+
if (pinnedObjects.includes(objectKey)) {
|
|
128
|
+
hasReference = true;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (!hasReference) {
|
|
135
|
+
promises.push(this.unPinWithName(objectKey));
|
|
576
136
|
}
|
|
577
137
|
}
|
|
578
|
-
|
|
579
|
-
|
|
138
|
+
|
|
139
|
+
return Promise.all(promises);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
function _handleUnPinAllWithName() {
|
|
143
|
+
return _handleUnPinAllWithName2.apply(this, arguments);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return _handleUnPinAllWithName;
|
|
147
|
+
}(),
|
|
580
148
|
_getChildren: function (object) {
|
|
581
149
|
var encountered = {};
|
|
582
150
|
|
|
@@ -615,419 +183,291 @@ var LocalDatastore = {
|
|
|
615
183
|
}
|
|
616
184
|
}
|
|
617
185
|
},
|
|
618
|
-
_serializeObjectsFromPinName: function (
|
|
619
|
-
var
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
var localDatastore, allObjects, key, pinName, pinned, promises, objects;
|
|
623
|
-
return _regeneratorRuntime().async(function (_context3) {
|
|
624
|
-
while (1) {
|
|
625
|
-
switch (_context3.prev = _context3.next) {
|
|
626
|
-
case 0:
|
|
627
|
-
_context3.next = 2;
|
|
628
|
-
return _regeneratorRuntime().awrap(this._getAllContents());
|
|
629
|
-
|
|
630
|
-
case 2:
|
|
631
|
-
localDatastore = _context3.sent;
|
|
632
|
-
allObjects = [];
|
|
633
|
-
|
|
634
|
-
for (key in localDatastore) {
|
|
635
|
-
if (key.startsWith(_LocalDatastoreUtils.OBJECT_PREFIX)) {
|
|
636
|
-
allObjects.push(localDatastore[key][0]);
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
if (name) {
|
|
641
|
-
_context3.next = 7;
|
|
642
|
-
break;
|
|
643
|
-
}
|
|
186
|
+
_serializeObjectsFromPinName: function () {
|
|
187
|
+
var _serializeObjectsFromPinName2 = (0, _asyncToGenerator2.default)(function* (name) {
|
|
188
|
+
var _this = this,
|
|
189
|
+
_ref;
|
|
644
190
|
|
|
645
|
-
|
|
191
|
+
var localDatastore = yield this._getAllContents();
|
|
192
|
+
var allObjects = [];
|
|
646
193
|
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
194
|
+
for (var key in localDatastore) {
|
|
195
|
+
if (key.startsWith(_LocalDatastoreUtils.OBJECT_PREFIX)) {
|
|
196
|
+
allObjects.push(localDatastore[key][0]);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
650
199
|
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
}
|
|
200
|
+
if (!name) {
|
|
201
|
+
return allObjects;
|
|
202
|
+
}
|
|
655
203
|
|
|
656
|
-
|
|
204
|
+
var pinName = this.getPinName(name);
|
|
205
|
+
var pinned = localDatastore[pinName];
|
|
657
206
|
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
return _this.fromPinWithName(objectKey);
|
|
661
|
-
});
|
|
662
|
-
_context3.next = 14;
|
|
663
|
-
return _regeneratorRuntime().awrap(Promise.all(promises));
|
|
664
|
-
|
|
665
|
-
case 14:
|
|
666
|
-
objects = _context3.sent;
|
|
667
|
-
objects = (_ref = []).concat.apply(_ref, (0, _toConsumableArray2.default)(objects));
|
|
668
|
-
return _context3.abrupt("return", objects.filter(function (object) {
|
|
669
|
-
return object != null;
|
|
670
|
-
}));
|
|
671
|
-
|
|
672
|
-
case 17:
|
|
673
|
-
case "end":
|
|
674
|
-
return _context3.stop();
|
|
675
|
-
}
|
|
207
|
+
if (!Array.isArray(pinned)) {
|
|
208
|
+
return [];
|
|
676
209
|
}
|
|
677
|
-
}, null, this, null, Promise);
|
|
678
|
-
},
|
|
679
|
-
_serializeObject: function (objectKey, localDatastore) {
|
|
680
|
-
var LDS, root, queue, meta, uniqueId, nodeId, subTreeRoot, field, value, key, pointer;
|
|
681
|
-
return _regeneratorRuntime().async(function (_context4) {
|
|
682
|
-
while (1) {
|
|
683
|
-
switch (_context4.prev = _context4.next) {
|
|
684
|
-
case 0:
|
|
685
|
-
LDS = localDatastore;
|
|
686
|
-
|
|
687
|
-
if (LDS) {
|
|
688
|
-
_context4.next = 5;
|
|
689
|
-
break;
|
|
690
|
-
}
|
|
691
210
|
|
|
692
|
-
|
|
693
|
-
|
|
211
|
+
var promises = pinned.map(function (objectKey) {
|
|
212
|
+
return _this.fromPinWithName(objectKey);
|
|
213
|
+
});
|
|
214
|
+
var objects = yield Promise.all(promises);
|
|
215
|
+
objects = (_ref = []).concat.apply(_ref, (0, _toConsumableArray2.default)(objects));
|
|
216
|
+
return objects.filter(function (object) {
|
|
217
|
+
return object != null;
|
|
218
|
+
});
|
|
219
|
+
});
|
|
694
220
|
|
|
695
|
-
|
|
696
|
-
|
|
221
|
+
function _serializeObjectsFromPinName() {
|
|
222
|
+
return _serializeObjectsFromPinName2.apply(this, arguments);
|
|
223
|
+
}
|
|
697
224
|
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
225
|
+
return _serializeObjectsFromPinName;
|
|
226
|
+
}(),
|
|
227
|
+
_serializeObject: function () {
|
|
228
|
+
var _serializeObject2 = (0, _asyncToGenerator2.default)(function* (objectKey, localDatastore) {
|
|
229
|
+
var LDS = localDatastore;
|
|
703
230
|
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
root = LDS[objectKey][0];
|
|
708
|
-
queue = [];
|
|
709
|
-
meta = {};
|
|
710
|
-
uniqueId = 0;
|
|
711
|
-
meta[uniqueId] = root;
|
|
712
|
-
queue.push(uniqueId);
|
|
713
|
-
|
|
714
|
-
while (queue.length !== 0) {
|
|
715
|
-
nodeId = queue.shift();
|
|
716
|
-
subTreeRoot = meta[nodeId];
|
|
717
|
-
|
|
718
|
-
for (field in subTreeRoot) {
|
|
719
|
-
value = subTreeRoot[field];
|
|
720
|
-
|
|
721
|
-
if (value.__type && value.__type === 'Object') {
|
|
722
|
-
key = this.getKeyForObject(value);
|
|
723
|
-
|
|
724
|
-
if (LDS[key] && LDS[key].length > 0) {
|
|
725
|
-
pointer = LDS[key][0];
|
|
726
|
-
uniqueId++;
|
|
727
|
-
meta[uniqueId] = pointer;
|
|
728
|
-
subTreeRoot[field] = pointer;
|
|
729
|
-
queue.push(uniqueId);
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
}
|
|
231
|
+
if (!LDS) {
|
|
232
|
+
LDS = yield this._getAllContents();
|
|
233
|
+
}
|
|
734
234
|
|
|
735
|
-
|
|
235
|
+
if (!LDS[objectKey] || LDS[objectKey].length === 0) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
736
238
|
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
239
|
+
var root = LDS[objectKey][0];
|
|
240
|
+
var queue = [];
|
|
241
|
+
var meta = {};
|
|
242
|
+
var uniqueId = 0;
|
|
243
|
+
meta[uniqueId] = root;
|
|
244
|
+
queue.push(uniqueId);
|
|
245
|
+
|
|
246
|
+
while (queue.length !== 0) {
|
|
247
|
+
var nodeId = queue.shift();
|
|
248
|
+
var subTreeRoot = meta[nodeId];
|
|
249
|
+
|
|
250
|
+
for (var field in subTreeRoot) {
|
|
251
|
+
var value = subTreeRoot[field];
|
|
252
|
+
|
|
253
|
+
if (value.__type && value.__type === 'Object') {
|
|
254
|
+
var key = this.getKeyForObject(value);
|
|
255
|
+
|
|
256
|
+
if (LDS[key] && LDS[key].length > 0) {
|
|
257
|
+
var pointer = LDS[key][0];
|
|
258
|
+
uniqueId++;
|
|
259
|
+
meta[uniqueId] = pointer;
|
|
260
|
+
subTreeRoot[field] = pointer;
|
|
261
|
+
queue.push(uniqueId);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
740
264
|
}
|
|
741
265
|
}
|
|
742
|
-
}, null, this, null, Promise);
|
|
743
|
-
},
|
|
744
|
-
_updateObjectIfPinned: function (object) {
|
|
745
|
-
var objectKey, pinned;
|
|
746
|
-
return _regeneratorRuntime().async(function (_context5) {
|
|
747
|
-
while (1) {
|
|
748
|
-
switch (_context5.prev = _context5.next) {
|
|
749
|
-
case 0:
|
|
750
|
-
if (this.isEnabled) {
|
|
751
|
-
_context5.next = 2;
|
|
752
|
-
break;
|
|
753
|
-
}
|
|
754
266
|
|
|
755
|
-
|
|
267
|
+
return root;
|
|
268
|
+
});
|
|
756
269
|
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
return _regeneratorRuntime().awrap(this.fromPinWithName(objectKey));
|
|
270
|
+
function _serializeObject() {
|
|
271
|
+
return _serializeObject2.apply(this, arguments);
|
|
272
|
+
}
|
|
761
273
|
|
|
762
|
-
|
|
763
|
-
|
|
274
|
+
return _serializeObject;
|
|
275
|
+
}(),
|
|
276
|
+
_updateObjectIfPinned: function () {
|
|
277
|
+
var _updateObjectIfPinned2 = (0, _asyncToGenerator2.default)(function* (object) {
|
|
278
|
+
if (!this.isEnabled) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
764
281
|
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
break;
|
|
768
|
-
}
|
|
282
|
+
var objectKey = this.getKeyForObject(object);
|
|
283
|
+
var pinned = yield this.fromPinWithName(objectKey);
|
|
769
284
|
|
|
770
|
-
|
|
285
|
+
if (!pinned || pinned.length === 0) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
771
288
|
|
|
772
|
-
|
|
773
|
-
|
|
289
|
+
return this.pinWithName(objectKey, [object._toFullJSON()]);
|
|
290
|
+
});
|
|
774
291
|
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
}, null, this, null, Promise);
|
|
781
|
-
},
|
|
782
|
-
_destroyObjectIfPinned: function (object) {
|
|
783
|
-
var localDatastore, objectKey, pin, promises, key, pinned;
|
|
784
|
-
return _regeneratorRuntime().async(function (_context6) {
|
|
785
|
-
while (1) {
|
|
786
|
-
switch (_context6.prev = _context6.next) {
|
|
787
|
-
case 0:
|
|
788
|
-
if (this.isEnabled) {
|
|
789
|
-
_context6.next = 2;
|
|
790
|
-
break;
|
|
791
|
-
}
|
|
292
|
+
function _updateObjectIfPinned() {
|
|
293
|
+
return _updateObjectIfPinned2.apply(this, arguments);
|
|
294
|
+
}
|
|
792
295
|
|
|
793
|
-
|
|
296
|
+
return _updateObjectIfPinned;
|
|
297
|
+
}(),
|
|
298
|
+
_destroyObjectIfPinned: function () {
|
|
299
|
+
var _destroyObjectIfPinned2 = (0, _asyncToGenerator2.default)(function* (object) {
|
|
300
|
+
if (!this.isEnabled) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
794
303
|
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
304
|
+
var localDatastore = yield this._getAllContents();
|
|
305
|
+
var objectKey = this.getKeyForObject(object);
|
|
306
|
+
var pin = localDatastore[objectKey];
|
|
798
307
|
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
pin = localDatastore[objectKey];
|
|
308
|
+
if (!pin) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
803
311
|
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
break;
|
|
807
|
-
}
|
|
312
|
+
var promises = [this.unPinWithName(objectKey)];
|
|
313
|
+
delete localDatastore[objectKey];
|
|
808
314
|
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
promises = [this.unPinWithName(objectKey)];
|
|
813
|
-
delete localDatastore[objectKey];
|
|
814
|
-
|
|
815
|
-
for (key in localDatastore) {
|
|
816
|
-
if (key === _LocalDatastoreUtils.DEFAULT_PIN || key.startsWith(_LocalDatastoreUtils.PIN_PREFIX)) {
|
|
817
|
-
pinned = localDatastore[key] || [];
|
|
818
|
-
|
|
819
|
-
if (pinned.includes(objectKey)) {
|
|
820
|
-
pinned = pinned.filter(function (item) {
|
|
821
|
-
return item !== objectKey;
|
|
822
|
-
});
|
|
823
|
-
|
|
824
|
-
if (pinned.length == 0) {
|
|
825
|
-
promises.push(this.unPinWithName(key));
|
|
826
|
-
delete localDatastore[key];
|
|
827
|
-
} else {
|
|
828
|
-
promises.push(this.pinWithName(key, pinned));
|
|
829
|
-
localDatastore[key] = pinned;
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
}
|
|
315
|
+
for (var key in localDatastore) {
|
|
316
|
+
if (key === _LocalDatastoreUtils.DEFAULT_PIN || key.startsWith(_LocalDatastoreUtils.PIN_PREFIX)) {
|
|
317
|
+
var pinned = localDatastore[key] || [];
|
|
834
318
|
|
|
835
|
-
|
|
319
|
+
if (pinned.includes(objectKey)) {
|
|
320
|
+
pinned = pinned.filter(function (item) {
|
|
321
|
+
return item !== objectKey;
|
|
322
|
+
});
|
|
836
323
|
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
324
|
+
if (pinned.length == 0) {
|
|
325
|
+
promises.push(this.unPinWithName(key));
|
|
326
|
+
delete localDatastore[key];
|
|
327
|
+
} else {
|
|
328
|
+
promises.push(this.pinWithName(key, pinned));
|
|
329
|
+
localDatastore[key] = pinned;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
840
332
|
}
|
|
841
333
|
}
|
|
842
|
-
}, null, this, null, Promise);
|
|
843
|
-
},
|
|
844
|
-
_updateLocalIdForObject: function (localId, object) {
|
|
845
|
-
var localKey, objectKey, unsaved, promises, localDatastore, key, pinned;
|
|
846
|
-
return _regeneratorRuntime().async(function (_context7) {
|
|
847
|
-
while (1) {
|
|
848
|
-
switch (_context7.prev = _context7.next) {
|
|
849
|
-
case 0:
|
|
850
|
-
if (this.isEnabled) {
|
|
851
|
-
_context7.next = 2;
|
|
852
|
-
break;
|
|
853
|
-
}
|
|
854
334
|
|
|
855
|
-
|
|
335
|
+
return Promise.all(promises);
|
|
336
|
+
});
|
|
856
337
|
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
_context7.next = 6;
|
|
861
|
-
return _regeneratorRuntime().awrap(this.fromPinWithName(localKey));
|
|
338
|
+
function _destroyObjectIfPinned() {
|
|
339
|
+
return _destroyObjectIfPinned2.apply(this, arguments);
|
|
340
|
+
}
|
|
862
341
|
|
|
863
|
-
|
|
864
|
-
|
|
342
|
+
return _destroyObjectIfPinned;
|
|
343
|
+
}(),
|
|
344
|
+
_updateLocalIdForObject: function () {
|
|
345
|
+
var _updateLocalIdForObject2 = (0, _asyncToGenerator2.default)(function* (localId, object) {
|
|
346
|
+
if (!this.isEnabled) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
865
349
|
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
}
|
|
350
|
+
var localKey = `${_LocalDatastoreUtils.OBJECT_PREFIX}${object.className}_${localId}`;
|
|
351
|
+
var objectKey = this.getKeyForObject(object);
|
|
352
|
+
var unsaved = yield this.fromPinWithName(localKey);
|
|
870
353
|
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
promises = [this.unPinWithName(localKey), this.pinWithName(objectKey, unsaved)];
|
|
875
|
-
_context7.next = 12;
|
|
876
|
-
return _regeneratorRuntime().awrap(this._getAllContents());
|
|
877
|
-
|
|
878
|
-
case 12:
|
|
879
|
-
localDatastore = _context7.sent;
|
|
880
|
-
|
|
881
|
-
for (key in localDatastore) {
|
|
882
|
-
if (key === _LocalDatastoreUtils.DEFAULT_PIN || key.startsWith(_LocalDatastoreUtils.PIN_PREFIX)) {
|
|
883
|
-
pinned = localDatastore[key] || [];
|
|
884
|
-
|
|
885
|
-
if (pinned.includes(localKey)) {
|
|
886
|
-
pinned = pinned.filter(function (item) {
|
|
887
|
-
return item !== localKey;
|
|
888
|
-
});
|
|
889
|
-
pinned.push(objectKey);
|
|
890
|
-
promises.push(this.pinWithName(key, pinned));
|
|
891
|
-
localDatastore[key] = pinned;
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
}
|
|
354
|
+
if (!unsaved || unsaved.length === 0) {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
895
357
|
|
|
896
|
-
|
|
358
|
+
var promises = [this.unPinWithName(localKey), this.pinWithName(objectKey, unsaved)];
|
|
359
|
+
var localDatastore = yield this._getAllContents();
|
|
897
360
|
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
361
|
+
for (var key in localDatastore) {
|
|
362
|
+
if (key === _LocalDatastoreUtils.DEFAULT_PIN || key.startsWith(_LocalDatastoreUtils.PIN_PREFIX)) {
|
|
363
|
+
var pinned = localDatastore[key] || [];
|
|
364
|
+
|
|
365
|
+
if (pinned.includes(localKey)) {
|
|
366
|
+
pinned = pinned.filter(function (item) {
|
|
367
|
+
return item !== localKey;
|
|
368
|
+
});
|
|
369
|
+
pinned.push(objectKey);
|
|
370
|
+
promises.push(this.pinWithName(key, pinned));
|
|
371
|
+
localDatastore[key] = pinned;
|
|
372
|
+
}
|
|
901
373
|
}
|
|
902
374
|
}
|
|
903
|
-
}, null, this, null, Promise);
|
|
904
|
-
},
|
|
905
|
-
updateFromServer: function () {
|
|
906
|
-
var _this2 = this;
|
|
907
375
|
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
return _regeneratorRuntime().async(function (_context8) {
|
|
911
|
-
while (1) {
|
|
912
|
-
switch (_context8.prev = _context8.next) {
|
|
913
|
-
case 0:
|
|
914
|
-
if (!(!this.checkIfEnabled() || this.isSyncing)) {
|
|
915
|
-
_context8.next = 2;
|
|
916
|
-
break;
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
return _context8.abrupt("return");
|
|
376
|
+
return Promise.all(promises);
|
|
377
|
+
});
|
|
920
378
|
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
379
|
+
function _updateLocalIdForObject() {
|
|
380
|
+
return _updateLocalIdForObject2.apply(this, arguments);
|
|
381
|
+
}
|
|
924
382
|
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
383
|
+
return _updateLocalIdForObject;
|
|
384
|
+
}(),
|
|
385
|
+
updateFromServer: function () {
|
|
386
|
+
var _updateFromServer = (0, _asyncToGenerator2.default)(function* () {
|
|
387
|
+
var _this2 = this;
|
|
928
388
|
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
}
|
|
933
|
-
}
|
|
389
|
+
if (!this.checkIfEnabled() || this.isSyncing) {
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
934
392
|
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
break;
|
|
938
|
-
}
|
|
393
|
+
var localDatastore = yield this._getAllContents();
|
|
394
|
+
var keys = [];
|
|
939
395
|
|
|
940
|
-
|
|
396
|
+
for (var key in localDatastore) {
|
|
397
|
+
if (key.startsWith(_LocalDatastoreUtils.OBJECT_PREFIX)) {
|
|
398
|
+
keys.push(key);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
941
401
|
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
_i = 0, _keys = keys;
|
|
402
|
+
if (keys.length === 0) {
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
946
405
|
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
_context8.next = 23;
|
|
950
|
-
break;
|
|
951
|
-
}
|
|
406
|
+
this.isSyncing = true;
|
|
407
|
+
var pointersHash = {};
|
|
952
408
|
|
|
953
|
-
|
|
954
|
-
|
|
409
|
+
for (var _key of keys) {
|
|
410
|
+
var _key$split = _key.split('_'),
|
|
411
|
+
_key$split2 = (0, _slicedToArray2.default)(_key$split, 4),
|
|
412
|
+
className = _key$split2[2],
|
|
413
|
+
objectId = _key$split2[3];
|
|
955
414
|
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
415
|
+
if (_key.split('_').length === 5 && _key.split('_')[3] === 'User') {
|
|
416
|
+
className = '_User';
|
|
417
|
+
objectId = _key.split('_')[4];
|
|
418
|
+
}
|
|
960
419
|
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
}
|
|
420
|
+
if (objectId.startsWith('local')) {
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
965
423
|
|
|
966
|
-
|
|
424
|
+
if (!(className in pointersHash)) {
|
|
425
|
+
pointersHash[className] = new Set();
|
|
426
|
+
}
|
|
967
427
|
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
pointersHash[className] = new Set();
|
|
971
|
-
}
|
|
428
|
+
pointersHash[className].add(objectId);
|
|
429
|
+
}
|
|
972
430
|
|
|
973
|
-
|
|
431
|
+
var queryPromises = Object.keys(pointersHash).map(function (className) {
|
|
432
|
+
var objectIds = Array.from(pointersHash[className]);
|
|
433
|
+
var query = new _ParseQuery.default(className);
|
|
434
|
+
query.limit(objectIds.length);
|
|
974
435
|
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
436
|
+
if (objectIds.length === 1) {
|
|
437
|
+
query.equalTo('objectId', objectIds[0]);
|
|
438
|
+
} else {
|
|
439
|
+
query.containedIn('objectId', objectIds);
|
|
440
|
+
}
|
|
979
441
|
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
var objectIds = Array.from(pointersHash[className]);
|
|
983
|
-
var query = new _ParseQuery.default(className);
|
|
984
|
-
query.limit(objectIds.length);
|
|
442
|
+
return query.find();
|
|
443
|
+
});
|
|
985
444
|
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
445
|
+
try {
|
|
446
|
+
var responses = yield Promise.all(queryPromises);
|
|
447
|
+
var objects = [].concat.apply([], responses);
|
|
448
|
+
var pinPromises = objects.map(function (object) {
|
|
449
|
+
var objectKey = _this2.getKeyForObject(object);
|
|
991
450
|
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
451
|
+
return _this2.pinWithName(objectKey, object._toFullJSON());
|
|
452
|
+
});
|
|
453
|
+
yield Promise.all(pinPromises);
|
|
454
|
+
this.isSyncing = false;
|
|
455
|
+
} catch (error) {
|
|
456
|
+
console.error('Error syncing LocalDatastore: ', error);
|
|
457
|
+
this.isSyncing = false;
|
|
458
|
+
}
|
|
459
|
+
});
|
|
997
460
|
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
pinPromises = objects.map(function (object) {
|
|
1002
|
-
var objectKey = _this2.getKeyForObject(object);
|
|
461
|
+
function updateFromServer() {
|
|
462
|
+
return _updateFromServer.apply(this, arguments);
|
|
463
|
+
}
|
|
1003
464
|
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
_context8.next = 32;
|
|
1007
|
-
return _regeneratorRuntime().awrap(Promise.all(pinPromises));
|
|
1008
|
-
|
|
1009
|
-
case 32:
|
|
1010
|
-
this.isSyncing = false;
|
|
1011
|
-
_context8.next = 39;
|
|
1012
|
-
break;
|
|
1013
|
-
|
|
1014
|
-
case 35:
|
|
1015
|
-
_context8.prev = 35;
|
|
1016
|
-
_context8.t0 = _context8["catch"](24);
|
|
1017
|
-
console.error('Error syncing LocalDatastore: ', _context8.t0);
|
|
1018
|
-
this.isSyncing = false;
|
|
1019
|
-
|
|
1020
|
-
case 39:
|
|
1021
|
-
case "end":
|
|
1022
|
-
return _context8.stop();
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
}, null, this, [[24, 35]], Promise);
|
|
1026
|
-
},
|
|
465
|
+
return updateFromServer;
|
|
466
|
+
}(),
|
|
1027
467
|
getKeyForObject: function (object) {
|
|
1028
468
|
var objectId = object.objectId || object._getId();
|
|
1029
469
|
|
|
1030
|
-
return
|
|
470
|
+
return `${_LocalDatastoreUtils.OBJECT_PREFIX}${object.className}_${objectId}`;
|
|
1031
471
|
},
|
|
1032
472
|
getPinName: function (pinName) {
|
|
1033
473
|
if (!pinName || pinName === _LocalDatastoreUtils.DEFAULT_PIN) {
|