parse 4.0.0-alpha.1 → 4.0.0-alpha.10
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 +6 -5
- package/dist/parse.js +12838 -21190
- package/dist/parse.min.js +7 -6
- package/dist/parse.weapp.js +7921 -17062
- package/dist/parse.weapp.min.js +7 -6
- package/lib/browser/Analytics.js +2 -27
- package/lib/browser/AnonymousUtils.js +6 -42
- package/lib/browser/Cloud.js +12 -77
- package/lib/browser/CloudCode.js +0 -3
- package/lib/browser/CoreManager.js +46 -191
- package/lib/browser/CryptoController.js +2 -16
- package/lib/browser/EventEmitter.js +1 -8
- package/lib/browser/EventuallyQueue.js +277 -824
- package/lib/browser/FacebookUtils.js +6 -42
- package/lib/browser/IndexedDBStorageController.js +3 -14
- package/lib/browser/InstallationController.js +2 -20
- package/lib/browser/LiveQueryClient.js +105 -213
- package/lib/browser/LiveQuerySubscription.js +10 -39
- package/lib/browser/LocalDatastore.js +451 -1081
- package/lib/browser/LocalDatastoreController.js +145 -602
- package/lib/browser/LocalDatastoreController.react-native.js +137 -573
- package/lib/browser/LocalDatastoreUtils.js +2 -19
- package/lib/browser/ObjectStateMutations.js +18 -121
- package/lib/browser/OfflineQuery.js +61 -222
- package/lib/browser/Parse.js +12 -115
- package/lib/browser/ParseACL.js +33 -148
- package/lib/browser/ParseCLP.js +96 -314
- package/lib/browser/ParseConfig.js +18 -95
- package/lib/browser/ParseError.js +63 -99
- package/lib/browser/ParseFile.js +128 -685
- package/lib/browser/ParseGeoPoint.js +23 -89
- package/lib/browser/ParseHooks.js +1 -34
- package/lib/browser/ParseInstallation.js +4 -32
- package/lib/browser/ParseLiveQuery.js +96 -505
- package/lib/browser/ParseObject.js +665 -1845
- package/lib/browser/ParseOp.js +41 -287
- package/lib/browser/ParsePolygon.js +13 -70
- package/lib/browser/ParseQuery.js +403 -1504
- package/lib/browser/ParseRelation.js +12 -68
- package/lib/browser/ParseRole.js +13 -75
- package/lib/browser/ParseSchema.js +49 -208
- package/lib/browser/ParseSession.js +11 -69
- package/lib/browser/ParseUser.js +274 -1127
- package/lib/browser/Push.js +7 -50
- package/lib/browser/RESTController.js +28 -157
- package/lib/browser/SingleInstanceStateController.js +19 -144
- package/lib/browser/Socket.weapp.js +0 -10
- package/lib/browser/Storage.js +10 -80
- package/lib/browser/StorageController.browser.js +4 -24
- package/lib/browser/StorageController.default.js +4 -24
- package/lib/browser/StorageController.react-native.js +6 -40
- package/lib/browser/StorageController.weapp.js +5 -23
- package/lib/browser/TaskQueue.js +1 -29
- package/lib/browser/UniqueInstanceStateController.js +19 -149
- package/lib/browser/Xhr.weapp.js +0 -17
- package/lib/browser/arrayContainsObject.js +2 -23
- package/lib/browser/canBeSerialized.js +3 -40
- package/lib/browser/decode.js +3 -40
- package/lib/browser/encode.js +9 -77
- package/lib/browser/equals.js +2 -34
- package/lib/browser/escape.js +1 -15
- package/lib/browser/isRevocableSession.js +2 -18
- package/lib/browser/parseDate.js +2 -20
- package/lib/browser/promiseUtils.js +3 -21
- package/lib/browser/unique.js +3 -24
- package/lib/browser/unsavedChildren.js +6 -57
- package/lib/browser/uuid.js +3 -1
- package/lib/node/Analytics.js +1 -25
- package/lib/node/AnonymousUtils.js +5 -44
- package/lib/node/Cloud.js +10 -73
- package/lib/node/CloudCode.js +0 -3
- package/lib/node/CoreManager.js +47 -227
- package/lib/node/CryptoController.js +2 -16
- package/lib/node/EventEmitter.js +1 -8
- package/lib/node/EventuallyQueue.js +16 -123
- package/lib/node/FacebookUtils.js +5 -44
- package/lib/node/IndexedDBStorageController.js +3 -19
- package/lib/node/InstallationController.js +2 -22
- package/lib/node/LiveQueryClient.js +72 -154
- package/lib/node/LiveQuerySubscription.js +7 -26
- package/lib/node/LocalDatastore.js +19 -182
- package/lib/node/LocalDatastoreController.js +6 -45
- package/lib/node/LocalDatastoreController.react-native.js +6 -52
- package/lib/node/LocalDatastoreUtils.js +1 -13
- package/lib/node/ObjectStateMutations.js +13 -100
- package/lib/node/OfflineQuery.js +27 -151
- package/lib/node/Parse.js +11 -108
- package/lib/node/ParseACL.js +32 -157
- package/lib/node/ParseCLP.js +69 -269
- package/lib/node/ParseConfig.js +16 -91
- package/lib/node/ParseError.js +61 -74
- package/lib/node/ParseFile.js +49 -212
- package/lib/node/ParseGeoPoint.js +21 -89
- package/lib/node/ParseHooks.js +0 -35
- package/lib/node/ParseInstallation.js +1 -17
- package/lib/node/ParseLiveQuery.js +10 -43
- package/lib/node/ParseObject.js +229 -964
- package/lib/node/ParseOp.js +31 -262
- package/lib/node/ParsePolygon.js +12 -69
- package/lib/node/ParseQuery.js +169 -888
- package/lib/node/ParseRelation.js +11 -68
- package/lib/node/ParseRole.js +10 -64
- package/lib/node/ParseSchema.js +46 -229
- package/lib/node/ParseSession.js +8 -57
- package/lib/node/ParseUser.js +107 -583
- package/lib/node/Push.js +4 -44
- package/lib/node/RESTController.js +18 -127
- package/lib/node/SingleInstanceStateController.js +17 -137
- package/lib/node/Socket.weapp.js +0 -7
- package/lib/node/Storage.js +10 -90
- package/lib/node/StorageController.browser.js +4 -30
- package/lib/node/StorageController.default.js +5 -28
- package/lib/node/StorageController.react-native.js +6 -47
- package/lib/node/StorageController.weapp.js +6 -28
- package/lib/node/TaskQueue.js +1 -24
- package/lib/node/UniqueInstanceStateController.js +16 -140
- package/lib/node/Xhr.weapp.js +0 -15
- package/lib/node/arrayContainsObject.js +1 -19
- package/lib/node/canBeSerialized.js +2 -35
- package/lib/node/decode.js +1 -33
- package/lib/node/encode.js +3 -61
- package/lib/node/equals.js +0 -27
- package/lib/node/escape.js +1 -13
- package/lib/node/isRevocableSession.js +1 -12
- package/lib/node/parseDate.js +1 -14
- package/lib/node/promiseUtils.js +2 -14
- package/lib/node/unique.js +1 -18
- package/lib/node/unsavedChildren.js +2 -45
- package/lib/node/uuid.js +6 -1
- package/lib/react-native/Analytics.js +0 -9
- package/lib/react-native/AnonymousUtils.js +0 -10
- package/lib/react-native/Cloud.js +0 -26
- package/lib/react-native/CoreManager.js +2 -6
- package/lib/react-native/CryptoController.js +0 -2
- package/lib/react-native/EventEmitter.js +0 -2
- package/lib/react-native/EventuallyQueue.js +156 -711
- package/lib/react-native/FacebookUtils.js +0 -22
- package/lib/react-native/IndexedDBStorageController.js +0 -1
- package/lib/react-native/InstallationController.js +0 -6
- package/lib/react-native/LiveQueryClient.js +46 -157
- package/lib/react-native/LiveQuerySubscription.js +3 -27
- package/lib/react-native/LocalDatastore.js +281 -948
- package/lib/react-native/LocalDatastoreController.js +71 -552
- package/lib/react-native/LocalDatastoreController.react-native.js +91 -526
- package/lib/react-native/LocalDatastoreUtils.js +0 -1
- package/lib/react-native/ObjectStateMutations.js +2 -65
- package/lib/react-native/OfflineQuery.js +25 -196
- package/lib/react-native/Parse.js +0 -65
- package/lib/react-native/ParseACL.js +0 -44
- package/lib/react-native/ParseCLP.js +23 -161
- package/lib/react-native/ParseConfig.js +0 -42
- package/lib/react-native/ParseError.js +1 -21
- package/lib/react-native/ParseFile.js +55 -529
- package/lib/react-native/ParseGeoPoint.js +0 -17
- package/lib/react-native/ParseHooks.js +0 -30
- package/lib/react-native/ParseInstallation.js +1 -23
- package/lib/react-native/ParseLiveQuery.js +55 -472
- package/lib/react-native/ParseObject.js +245 -1246
- package/lib/react-native/ParseOp.js +1 -138
- package/lib/react-native/ParsePolygon.js +0 -24
- package/lib/react-native/ParseQuery.js +182 -874
- package/lib/react-native/ParseRelation.js +0 -25
- package/lib/react-native/ParseRole.js +1 -36
- package/lib/react-native/ParseSchema.js +3 -54
- package/lib/react-native/ParseSession.js +1 -40
- package/lib/react-native/ParseUser.js +95 -773
- package/lib/react-native/Push.js +0 -16
- package/lib/react-native/RESTController.js +12 -109
- package/lib/react-native/SingleInstanceStateController.js +0 -44
- package/lib/react-native/Socket.weapp.js +0 -10
- package/lib/react-native/Storage.js +0 -24
- package/lib/react-native/StorageController.browser.js +0 -2
- package/lib/react-native/StorageController.default.js +0 -1
- package/lib/react-native/StorageController.react-native.js +0 -2
- package/lib/react-native/TaskQueue.js +0 -15
- package/lib/react-native/UniqueInstanceStateController.js +0 -47
- package/lib/react-native/Xhr.weapp.js +0 -16
- package/lib/react-native/arrayContainsObject.js +0 -5
- package/lib/react-native/canBeSerialized.js +0 -18
- package/lib/react-native/decode.js +0 -21
- package/lib/react-native/encode.js +0 -25
- package/lib/react-native/equals.js +0 -18
- package/lib/react-native/escape.js +0 -1
- package/lib/react-native/isRevocableSession.js +0 -1
- package/lib/react-native/parseDate.js +0 -3
- package/lib/react-native/promiseUtils.js +0 -13
- package/lib/react-native/unique.js +0 -4
- package/lib/react-native/unsavedChildren.js +0 -21
- package/lib/react-native/uuid.js +3 -1
- package/lib/weapp/Analytics.js +2 -27
- package/lib/weapp/AnonymousUtils.js +6 -42
- package/lib/weapp/Cloud.js +12 -77
- package/lib/weapp/CloudCode.js +0 -3
- package/lib/weapp/CoreManager.js +46 -191
- package/lib/weapp/CryptoController.js +2 -16
- package/lib/weapp/EventEmitter.js +1 -8
- package/lib/weapp/EventuallyQueue.js +277 -824
- package/lib/weapp/FacebookUtils.js +6 -42
- package/lib/weapp/IndexedDBStorageController.js +3 -14
- package/lib/weapp/InstallationController.js +2 -20
- package/lib/weapp/LiveQueryClient.js +105 -213
- package/lib/weapp/LiveQuerySubscription.js +10 -39
- package/lib/weapp/LocalDatastore.js +451 -1081
- package/lib/weapp/LocalDatastoreController.js +145 -602
- package/lib/weapp/LocalDatastoreController.react-native.js +137 -573
- package/lib/weapp/LocalDatastoreUtils.js +2 -19
- package/lib/weapp/ObjectStateMutations.js +18 -121
- package/lib/weapp/OfflineQuery.js +61 -222
- package/lib/weapp/Parse.js +12 -115
- package/lib/weapp/ParseACL.js +33 -148
- package/lib/weapp/ParseCLP.js +96 -314
- package/lib/weapp/ParseConfig.js +18 -95
- package/lib/weapp/ParseError.js +63 -99
- package/lib/weapp/ParseFile.js +129 -686
- package/lib/weapp/ParseGeoPoint.js +23 -89
- package/lib/weapp/ParseHooks.js +1 -34
- package/lib/weapp/ParseInstallation.js +4 -32
- package/lib/weapp/ParseLiveQuery.js +96 -505
- package/lib/weapp/ParseObject.js +665 -1845
- package/lib/weapp/ParseOp.js +41 -287
- package/lib/weapp/ParsePolygon.js +13 -70
- package/lib/weapp/ParseQuery.js +403 -1504
- package/lib/weapp/ParseRelation.js +12 -68
- package/lib/weapp/ParseRole.js +13 -75
- package/lib/weapp/ParseSchema.js +49 -208
- package/lib/weapp/ParseSession.js +11 -69
- package/lib/weapp/ParseUser.js +274 -1127
- package/lib/weapp/Push.js +7 -50
- package/lib/weapp/RESTController.js +28 -157
- package/lib/weapp/SingleInstanceStateController.js +19 -144
- package/lib/weapp/Socket.weapp.js +0 -10
- package/lib/weapp/Storage.js +10 -80
- package/lib/weapp/StorageController.browser.js +4 -24
- package/lib/weapp/StorageController.default.js +4 -24
- package/lib/weapp/StorageController.react-native.js +6 -40
- package/lib/weapp/StorageController.weapp.js +5 -23
- package/lib/weapp/TaskQueue.js +1 -29
- package/lib/weapp/UniqueInstanceStateController.js +19 -149
- package/lib/weapp/Xhr.weapp.js +0 -17
- package/lib/weapp/arrayContainsObject.js +2 -23
- package/lib/weapp/canBeSerialized.js +3 -40
- package/lib/weapp/decode.js +3 -40
- package/lib/weapp/encode.js +9 -77
- package/lib/weapp/equals.js +2 -34
- package/lib/weapp/escape.js +1 -15
- package/lib/weapp/isRevocableSession.js +2 -18
- package/lib/weapp/parseDate.js +2 -20
- package/lib/weapp/promiseUtils.js +3 -21
- package/lib/weapp/unique.js +3 -24
- package/lib/weapp/unsavedChildren.js +6 -57
- package/lib/weapp/uuid.js +1 -6
- package/package.json +34 -30
- package/PATENTS +0 -37
|
@@ -1,593 +1,121 @@
|
|
|
1
1
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
|
-
|
|
3
2
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
4
|
-
|
|
5
3
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
6
|
-
|
|
4
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
7
5
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
8
|
-
|
|
9
6
|
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
10
|
-
|
|
11
7
|
var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
|
|
12
|
-
|
|
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
8
|
var LocalDatastore = {
|
|
405
9
|
isEnabled: false,
|
|
406
10
|
isSyncing: false,
|
|
407
11
|
fromPinWithName: function (name) {
|
|
408
12
|
var controller = _CoreManager.default.getLocalDatastoreController();
|
|
409
|
-
|
|
410
13
|
return controller.fromPinWithName(name);
|
|
411
14
|
},
|
|
412
15
|
pinWithName: function (name, value) {
|
|
413
16
|
var controller = _CoreManager.default.getLocalDatastoreController();
|
|
414
|
-
|
|
415
17
|
return controller.pinWithName(name, value);
|
|
416
18
|
},
|
|
417
19
|
unPinWithName: function (name) {
|
|
418
20
|
var controller = _CoreManager.default.getLocalDatastoreController();
|
|
419
|
-
|
|
420
21
|
return controller.unPinWithName(name);
|
|
421
22
|
},
|
|
422
23
|
_getAllContents: function () {
|
|
423
24
|
var controller = _CoreManager.default.getLocalDatastoreController();
|
|
424
|
-
|
|
425
25
|
return controller.getAllContents();
|
|
426
26
|
},
|
|
427
27
|
_getRawStorage: function () {
|
|
428
28
|
var controller = _CoreManager.default.getLocalDatastoreController();
|
|
429
|
-
|
|
430
29
|
return controller.getRawStorage();
|
|
431
30
|
},
|
|
432
31
|
_clear: function () {
|
|
433
32
|
var controller = _CoreManager.default.getLocalDatastoreController();
|
|
434
|
-
|
|
435
33
|
return controller.clear();
|
|
436
34
|
},
|
|
437
|
-
_handlePinAllWithName: function (
|
|
438
|
-
var
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
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
|
-
}
|
|
465
|
-
|
|
466
|
-
fromPinPromise = this.fromPinWithName(pinName);
|
|
467
|
-
_context.next = 7;
|
|
468
|
-
return _regeneratorRuntime().awrap(Promise.all([fromPinPromise, toPinPromises]));
|
|
469
|
-
|
|
470
|
-
case 7:
|
|
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));
|
|
476
|
-
|
|
477
|
-
case 12:
|
|
478
|
-
case "end":
|
|
479
|
-
return _context.stop();
|
|
35
|
+
_handlePinAllWithName: function () {
|
|
36
|
+
var _handlePinAllWithName2 = (0, _asyncToGenerator2.default)(function* (name, objects) {
|
|
37
|
+
var pinName = this.getPinName(name);
|
|
38
|
+
var toPinPromises = [];
|
|
39
|
+
var objectKeys = [];
|
|
40
|
+
for (var parent of objects) {
|
|
41
|
+
var children = this._getChildren(parent);
|
|
42
|
+
var parentKey = this.getKeyForObject(parent);
|
|
43
|
+
var json = parent._toFullJSON(undefined, true);
|
|
44
|
+
if (parent._localId) {
|
|
45
|
+
json._localId = parent._localId;
|
|
46
|
+
}
|
|
47
|
+
children[parentKey] = json;
|
|
48
|
+
for (var objectKey in children) {
|
|
49
|
+
objectKeys.push(objectKey);
|
|
50
|
+
toPinPromises.push(this.pinWithName(objectKey, [children[objectKey]]));
|
|
480
51
|
}
|
|
481
52
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
if ((_step3 = _iterator3()).done) {
|
|
526
|
-
_context2.next = 28;
|
|
527
|
-
break;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
objectKey = _step3.value;
|
|
531
|
-
hasReference = false;
|
|
532
|
-
_context2.t0 = _regeneratorRuntime().keys(localDatastore);
|
|
533
|
-
|
|
534
|
-
case 16:
|
|
535
|
-
if ((_context2.t1 = _context2.t0()).done) {
|
|
536
|
-
_context2.next = 25;
|
|
537
|
-
break;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
key = _context2.t1.value;
|
|
541
|
-
|
|
542
|
-
if (!(key === _LocalDatastoreUtils.DEFAULT_PIN || key.startsWith(_LocalDatastoreUtils.PIN_PREFIX))) {
|
|
543
|
-
_context2.next = 23;
|
|
544
|
-
break;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
pinnedObjects = localDatastore[key] || [];
|
|
548
|
-
|
|
549
|
-
if (!pinnedObjects.includes(objectKey)) {
|
|
550
|
-
_context2.next = 23;
|
|
53
|
+
var fromPinPromise = this.fromPinWithName(pinName);
|
|
54
|
+
var _yield$Promise$all = yield Promise.all([fromPinPromise, toPinPromises]),
|
|
55
|
+
_yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 1),
|
|
56
|
+
pinned = _yield$Promise$all2[0];
|
|
57
|
+
var toPin = (0, _toConsumableArray2.default)(new Set([].concat((0, _toConsumableArray2.default)(pinned || []), objectKeys)));
|
|
58
|
+
return this.pinWithName(pinName, toPin);
|
|
59
|
+
});
|
|
60
|
+
function _handlePinAllWithName() {
|
|
61
|
+
return _handlePinAllWithName2.apply(this, arguments);
|
|
62
|
+
}
|
|
63
|
+
return _handlePinAllWithName;
|
|
64
|
+
}(),
|
|
65
|
+
_handleUnPinAllWithName: function () {
|
|
66
|
+
var _handleUnPinAllWithName2 = (0, _asyncToGenerator2.default)(function* (name, objects) {
|
|
67
|
+
var localDatastore = yield this._getAllContents();
|
|
68
|
+
var pinName = this.getPinName(name);
|
|
69
|
+
var promises = [];
|
|
70
|
+
var objectKeys = [];
|
|
71
|
+
for (var parent of objects) {
|
|
72
|
+
var _objectKeys;
|
|
73
|
+
var children = this._getChildren(parent);
|
|
74
|
+
var parentKey = this.getKeyForObject(parent);
|
|
75
|
+
(_objectKeys = objectKeys).push.apply(_objectKeys, [parentKey].concat((0, _toConsumableArray2.default)(Object.keys(children))));
|
|
76
|
+
}
|
|
77
|
+
objectKeys = (0, _toConsumableArray2.default)(new Set(objectKeys));
|
|
78
|
+
var pinned = localDatastore[pinName] || [];
|
|
79
|
+
pinned = pinned.filter(function (item) {
|
|
80
|
+
return !objectKeys.includes(item);
|
|
81
|
+
});
|
|
82
|
+
if (pinned.length == 0) {
|
|
83
|
+
promises.push(this.unPinWithName(pinName));
|
|
84
|
+
delete localDatastore[pinName];
|
|
85
|
+
} else {
|
|
86
|
+
promises.push(this.pinWithName(pinName, pinned));
|
|
87
|
+
localDatastore[pinName] = pinned;
|
|
88
|
+
}
|
|
89
|
+
for (var objectKey of objectKeys) {
|
|
90
|
+
var hasReference = false;
|
|
91
|
+
for (var key in localDatastore) {
|
|
92
|
+
if (key === _LocalDatastoreUtils.DEFAULT_PIN || key.startsWith(_LocalDatastoreUtils.PIN_PREFIX)) {
|
|
93
|
+
var pinnedObjects = localDatastore[key] || [];
|
|
94
|
+
if (pinnedObjects.includes(objectKey)) {
|
|
95
|
+
hasReference = true;
|
|
551
96
|
break;
|
|
552
97
|
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
case 23:
|
|
558
|
-
_context2.next = 16;
|
|
559
|
-
break;
|
|
560
|
-
|
|
561
|
-
case 25:
|
|
562
|
-
if (!hasReference) {
|
|
563
|
-
promises.push(this.unPinWithName(objectKey));
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
case 26:
|
|
567
|
-
_context2.next = 12;
|
|
568
|
-
break;
|
|
569
|
-
|
|
570
|
-
case 28:
|
|
571
|
-
return _context2.abrupt("return", Promise.all(promises));
|
|
572
|
-
|
|
573
|
-
case 29:
|
|
574
|
-
case "end":
|
|
575
|
-
return _context2.stop();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (!hasReference) {
|
|
101
|
+
promises.push(this.unPinWithName(objectKey));
|
|
576
102
|
}
|
|
577
103
|
}
|
|
578
|
-
|
|
579
|
-
|
|
104
|
+
return Promise.all(promises);
|
|
105
|
+
});
|
|
106
|
+
function _handleUnPinAllWithName() {
|
|
107
|
+
return _handleUnPinAllWithName2.apply(this, arguments);
|
|
108
|
+
}
|
|
109
|
+
return _handleUnPinAllWithName;
|
|
110
|
+
}(),
|
|
580
111
|
_getChildren: function (object) {
|
|
581
112
|
var encountered = {};
|
|
582
|
-
|
|
583
113
|
var json = object._toFullJSON(undefined, true);
|
|
584
|
-
|
|
585
114
|
for (var key in json) {
|
|
586
115
|
if (json[key] && json[key].__type && json[key].__type === 'Object') {
|
|
587
116
|
this._traverse(json[key], encountered);
|
|
588
117
|
}
|
|
589
118
|
}
|
|
590
|
-
|
|
591
119
|
return encountered;
|
|
592
120
|
},
|
|
593
121
|
_traverse: function (object, encountered) {
|
|
@@ -595,457 +123,262 @@ var LocalDatastore = {
|
|
|
595
123
|
return;
|
|
596
124
|
} else {
|
|
597
125
|
var objectKey = this.getKeyForObject(object);
|
|
598
|
-
|
|
599
126
|
if (encountered[objectKey]) {
|
|
600
127
|
return;
|
|
601
128
|
}
|
|
602
|
-
|
|
603
129
|
encountered[objectKey] = object;
|
|
604
130
|
}
|
|
605
|
-
|
|
606
131
|
for (var key in object) {
|
|
607
132
|
var json = object[key];
|
|
608
|
-
|
|
609
133
|
if (!object[key]) {
|
|
610
134
|
json = object;
|
|
611
135
|
}
|
|
612
|
-
|
|
613
136
|
if (json.__type && json.__type === 'Object') {
|
|
614
137
|
this._traverse(json, encountered);
|
|
615
138
|
}
|
|
616
139
|
}
|
|
617
140
|
},
|
|
618
|
-
_serializeObjectsFromPinName: function (
|
|
619
|
-
var
|
|
141
|
+
_serializeObjectsFromPinName: function () {
|
|
142
|
+
var _serializeObjectsFromPinName2 = (0, _asyncToGenerator2.default)(function* (name) {
|
|
143
|
+
var _this = this,
|
|
620
144
|
_ref;
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
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
|
-
}
|
|
644
|
-
|
|
645
|
-
return _context3.abrupt("return", allObjects);
|
|
646
|
-
|
|
647
|
-
case 7:
|
|
648
|
-
pinName = this.getPinName(name);
|
|
649
|
-
pinned = localDatastore[pinName];
|
|
650
|
-
|
|
651
|
-
if (Array.isArray(pinned)) {
|
|
652
|
-
_context3.next = 11;
|
|
653
|
-
break;
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
return _context3.abrupt("return", []);
|
|
657
|
-
|
|
658
|
-
case 11:
|
|
659
|
-
promises = pinned.map(function (objectKey) {
|
|
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();
|
|
145
|
+
var localDatastore = yield this._getAllContents();
|
|
146
|
+
var allObjects = [];
|
|
147
|
+
for (var key in localDatastore) {
|
|
148
|
+
if (key.startsWith(_LocalDatastoreUtils.OBJECT_PREFIX)) {
|
|
149
|
+
allObjects.push(localDatastore[key][0]);
|
|
675
150
|
}
|
|
676
151
|
}
|
|
677
|
-
|
|
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
|
-
|
|
692
|
-
_context4.next = 4;
|
|
693
|
-
return _regeneratorRuntime().awrap(this._getAllContents());
|
|
694
|
-
|
|
695
|
-
case 4:
|
|
696
|
-
LDS = _context4.sent;
|
|
697
|
-
|
|
698
|
-
case 5:
|
|
699
|
-
if (!(!LDS[objectKey] || LDS[objectKey].length === 0)) {
|
|
700
|
-
_context4.next = 7;
|
|
701
|
-
break;
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
return _context4.abrupt("return", null);
|
|
705
|
-
|
|
706
|
-
case 7:
|
|
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
|
-
}
|
|
734
|
-
|
|
735
|
-
return _context4.abrupt("return", root);
|
|
736
|
-
|
|
737
|
-
case 15:
|
|
738
|
-
case "end":
|
|
739
|
-
return _context4.stop();
|
|
740
|
-
}
|
|
152
|
+
if (!name) {
|
|
153
|
+
return allObjects;
|
|
741
154
|
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
155
|
+
var pinName = this.getPinName(name);
|
|
156
|
+
var pinned = localDatastore[pinName];
|
|
157
|
+
if (!Array.isArray(pinned)) {
|
|
158
|
+
return [];
|
|
159
|
+
}
|
|
160
|
+
var promises = pinned.map(function (objectKey) {
|
|
161
|
+
return _this.fromPinWithName(objectKey);
|
|
162
|
+
});
|
|
163
|
+
var objects = yield Promise.all(promises);
|
|
164
|
+
objects = (_ref = []).concat.apply(_ref, (0, _toConsumableArray2.default)(objects));
|
|
165
|
+
return objects.filter(function (object) {
|
|
166
|
+
return object != null;
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
function _serializeObjectsFromPinName() {
|
|
170
|
+
return _serializeObjectsFromPinName2.apply(this, arguments);
|
|
171
|
+
}
|
|
172
|
+
return _serializeObjectsFromPinName;
|
|
173
|
+
}(),
|
|
174
|
+
_serializeObject: function () {
|
|
175
|
+
var _serializeObject2 = (0, _asyncToGenerator2.default)(function* (objectKey, localDatastore) {
|
|
176
|
+
var LDS = localDatastore;
|
|
177
|
+
if (!LDS) {
|
|
178
|
+
LDS = yield this._getAllContents();
|
|
179
|
+
}
|
|
180
|
+
if (!LDS[objectKey] || LDS[objectKey].length === 0) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
var root = LDS[objectKey][0];
|
|
184
|
+
var queue = [];
|
|
185
|
+
var meta = {};
|
|
186
|
+
var uniqueId = 0;
|
|
187
|
+
meta[uniqueId] = root;
|
|
188
|
+
queue.push(uniqueId);
|
|
189
|
+
while (queue.length !== 0) {
|
|
190
|
+
var nodeId = queue.shift();
|
|
191
|
+
var subTreeRoot = meta[nodeId];
|
|
192
|
+
for (var field in subTreeRoot) {
|
|
193
|
+
var value = subTreeRoot[field];
|
|
194
|
+
if (value.__type && value.__type === 'Object') {
|
|
195
|
+
var key = this.getKeyForObject(value);
|
|
196
|
+
if (LDS[key] && LDS[key].length > 0) {
|
|
197
|
+
var pointer = LDS[key][0];
|
|
198
|
+
uniqueId++;
|
|
199
|
+
meta[uniqueId] = pointer;
|
|
200
|
+
subTreeRoot[field] = pointer;
|
|
201
|
+
queue.push(uniqueId);
|
|
768
202
|
}
|
|
769
|
-
|
|
770
|
-
return _context5.abrupt("return");
|
|
771
|
-
|
|
772
|
-
case 8:
|
|
773
|
-
return _context5.abrupt("return", this.pinWithName(objectKey, [object._toFullJSON()]));
|
|
774
|
-
|
|
775
|
-
case 9:
|
|
776
|
-
case "end":
|
|
777
|
-
return _context5.stop();
|
|
203
|
+
}
|
|
778
204
|
}
|
|
779
205
|
}
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
}
|
|
206
|
+
return root;
|
|
207
|
+
});
|
|
208
|
+
function _serializeObject() {
|
|
209
|
+
return _serializeObject2.apply(this, arguments);
|
|
210
|
+
}
|
|
211
|
+
return _serializeObject;
|
|
212
|
+
}(),
|
|
213
|
+
_updateObjectIfPinned: function () {
|
|
214
|
+
var _updateObjectIfPinned2 = (0, _asyncToGenerator2.default)(function* (object) {
|
|
215
|
+
if (!this.isEnabled) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
var objectKey = this.getKeyForObject(object);
|
|
219
|
+
var pinned = yield this.fromPinWithName(objectKey);
|
|
220
|
+
if (!pinned || pinned.length === 0) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
return this.pinWithName(objectKey, [object._toFullJSON()]);
|
|
224
|
+
});
|
|
225
|
+
function _updateObjectIfPinned() {
|
|
226
|
+
return _updateObjectIfPinned2.apply(this, arguments);
|
|
227
|
+
}
|
|
228
|
+
return _updateObjectIfPinned;
|
|
229
|
+
}(),
|
|
230
|
+
_destroyObjectIfPinned: function () {
|
|
231
|
+
var _destroyObjectIfPinned2 = (0, _asyncToGenerator2.default)(function* (object) {
|
|
232
|
+
if (!this.isEnabled) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
var localDatastore = yield this._getAllContents();
|
|
236
|
+
var objectKey = this.getKeyForObject(object);
|
|
237
|
+
var pin = localDatastore[objectKey];
|
|
238
|
+
if (!pin) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
var promises = [this.unPinWithName(objectKey)];
|
|
242
|
+
delete localDatastore[objectKey];
|
|
243
|
+
for (var key in localDatastore) {
|
|
244
|
+
if (key === _LocalDatastoreUtils.DEFAULT_PIN || key.startsWith(_LocalDatastoreUtils.PIN_PREFIX)) {
|
|
245
|
+
var pinned = localDatastore[key] || [];
|
|
246
|
+
if (pinned.includes(objectKey)) {
|
|
247
|
+
pinned = pinned.filter(function (item) {
|
|
248
|
+
return item !== objectKey;
|
|
249
|
+
});
|
|
250
|
+
if (pinned.length == 0) {
|
|
251
|
+
promises.push(this.unPinWithName(key));
|
|
252
|
+
delete localDatastore[key];
|
|
253
|
+
} else {
|
|
254
|
+
promises.push(this.pinWithName(key, pinned));
|
|
255
|
+
localDatastore[key] = pinned;
|
|
833
256
|
}
|
|
834
|
-
|
|
835
|
-
return _context6.abrupt("return", Promise.all(promises));
|
|
836
|
-
|
|
837
|
-
case 13:
|
|
838
|
-
case "end":
|
|
839
|
-
return _context6.stop();
|
|
257
|
+
}
|
|
840
258
|
}
|
|
841
259
|
}
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
case 9:
|
|
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
|
-
}
|
|
895
|
-
|
|
896
|
-
return _context7.abrupt("return", Promise.all(promises));
|
|
897
|
-
|
|
898
|
-
case 15:
|
|
899
|
-
case "end":
|
|
900
|
-
return _context7.stop();
|
|
260
|
+
return Promise.all(promises);
|
|
261
|
+
});
|
|
262
|
+
function _destroyObjectIfPinned() {
|
|
263
|
+
return _destroyObjectIfPinned2.apply(this, arguments);
|
|
264
|
+
}
|
|
265
|
+
return _destroyObjectIfPinned;
|
|
266
|
+
}(),
|
|
267
|
+
_updateLocalIdForObject: function () {
|
|
268
|
+
var _updateLocalIdForObject2 = (0, _asyncToGenerator2.default)(function* (localId, object) {
|
|
269
|
+
if (!this.isEnabled) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
var localKey = `${_LocalDatastoreUtils.OBJECT_PREFIX}${object.className}_${localId}`;
|
|
273
|
+
var objectKey = this.getKeyForObject(object);
|
|
274
|
+
var unsaved = yield this.fromPinWithName(localKey);
|
|
275
|
+
if (!unsaved || unsaved.length === 0) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
var promises = [this.unPinWithName(localKey), this.pinWithName(objectKey, unsaved)];
|
|
279
|
+
var localDatastore = yield this._getAllContents();
|
|
280
|
+
for (var key in localDatastore) {
|
|
281
|
+
if (key === _LocalDatastoreUtils.DEFAULT_PIN || key.startsWith(_LocalDatastoreUtils.PIN_PREFIX)) {
|
|
282
|
+
var pinned = localDatastore[key] || [];
|
|
283
|
+
if (pinned.includes(localKey)) {
|
|
284
|
+
pinned = pinned.filter(function (item) {
|
|
285
|
+
return item !== localKey;
|
|
286
|
+
});
|
|
287
|
+
pinned.push(objectKey);
|
|
288
|
+
promises.push(this.pinWithName(key, pinned));
|
|
289
|
+
localDatastore[key] = pinned;
|
|
290
|
+
}
|
|
901
291
|
}
|
|
902
292
|
}
|
|
903
|
-
|
|
904
|
-
|
|
293
|
+
return Promise.all(promises);
|
|
294
|
+
});
|
|
295
|
+
function _updateLocalIdForObject() {
|
|
296
|
+
return _updateLocalIdForObject2.apply(this, arguments);
|
|
297
|
+
}
|
|
298
|
+
return _updateLocalIdForObject;
|
|
299
|
+
}(),
|
|
905
300
|
updateFromServer: function () {
|
|
906
|
-
var
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
break;
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
return _context8.abrupt("return");
|
|
920
|
-
|
|
921
|
-
case 2:
|
|
922
|
-
_context8.next = 4;
|
|
923
|
-
return _regeneratorRuntime().awrap(this._getAllContents());
|
|
924
|
-
|
|
925
|
-
case 4:
|
|
926
|
-
localDatastore = _context8.sent;
|
|
927
|
-
keys = [];
|
|
928
|
-
|
|
929
|
-
for (key in localDatastore) {
|
|
930
|
-
if (key.startsWith(_LocalDatastoreUtils.OBJECT_PREFIX)) {
|
|
931
|
-
keys.push(key);
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
if (!(keys.length === 0)) {
|
|
936
|
-
_context8.next = 9;
|
|
937
|
-
break;
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
return _context8.abrupt("return");
|
|
941
|
-
|
|
942
|
-
case 9:
|
|
943
|
-
this.isSyncing = true;
|
|
944
|
-
pointersHash = {};
|
|
945
|
-
_i = 0, _keys = keys;
|
|
946
|
-
|
|
947
|
-
case 12:
|
|
948
|
-
if (!(_i < _keys.length)) {
|
|
949
|
-
_context8.next = 23;
|
|
950
|
-
break;
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
_key = _keys[_i];
|
|
954
|
-
_key$split = _key.split('_'), _key$split2 = (0, _slicedToArray2.default)(_key$split, 4), className = _key$split2[2], objectId = _key$split2[3];
|
|
955
|
-
|
|
956
|
-
if (_key.split('_').length === 5 && _key.split('_')[3] === 'User') {
|
|
957
|
-
className = '_User';
|
|
958
|
-
objectId = _key.split('_')[4];
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
if (!objectId.startsWith('local')) {
|
|
962
|
-
_context8.next = 18;
|
|
963
|
-
break;
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
return _context8.abrupt("continue", 20);
|
|
967
|
-
|
|
968
|
-
case 18:
|
|
969
|
-
if (!(className in pointersHash)) {
|
|
970
|
-
pointersHash[className] = new Set();
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
pointersHash[className].add(objectId);
|
|
974
|
-
|
|
975
|
-
case 20:
|
|
976
|
-
_i++;
|
|
977
|
-
_context8.next = 12;
|
|
978
|
-
break;
|
|
979
|
-
|
|
980
|
-
case 23:
|
|
981
|
-
queryPromises = Object.keys(pointersHash).map(function (className) {
|
|
982
|
-
var objectIds = Array.from(pointersHash[className]);
|
|
983
|
-
var query = new _ParseQuery.default(className);
|
|
984
|
-
query.limit(objectIds.length);
|
|
985
|
-
|
|
986
|
-
if (objectIds.length === 1) {
|
|
987
|
-
query.equalTo('objectId', objectIds[0]);
|
|
988
|
-
} else {
|
|
989
|
-
query.containedIn('objectId', objectIds);
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
return query.find();
|
|
993
|
-
});
|
|
994
|
-
_context8.prev = 24;
|
|
995
|
-
_context8.next = 27;
|
|
996
|
-
return _regeneratorRuntime().awrap(Promise.all(queryPromises));
|
|
997
|
-
|
|
998
|
-
case 27:
|
|
999
|
-
responses = _context8.sent;
|
|
1000
|
-
objects = [].concat.apply([], responses);
|
|
1001
|
-
pinPromises = objects.map(function (object) {
|
|
1002
|
-
var objectKey = _this2.getKeyForObject(object);
|
|
1003
|
-
|
|
1004
|
-
return _this2.pinWithName(objectKey, object._toFullJSON());
|
|
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();
|
|
301
|
+
var _updateFromServer = (0, _asyncToGenerator2.default)(function* () {
|
|
302
|
+
var _this2 = this;
|
|
303
|
+
if (!this.checkIfEnabled() || this.isSyncing) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
var localDatastore = yield this._getAllContents();
|
|
307
|
+
var keys = [];
|
|
308
|
+
for (var key in localDatastore) {
|
|
309
|
+
if (key.startsWith(_LocalDatastoreUtils.OBJECT_PREFIX)) {
|
|
310
|
+
keys.push(key);
|
|
1023
311
|
}
|
|
1024
312
|
}
|
|
1025
|
-
|
|
1026
|
-
|
|
313
|
+
if (keys.length === 0) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
this.isSyncing = true;
|
|
317
|
+
var pointersHash = {};
|
|
318
|
+
for (var _key of keys) {
|
|
319
|
+
var _key$split = _key.split('_'),
|
|
320
|
+
_key$split2 = (0, _slicedToArray2.default)(_key$split, 4),
|
|
321
|
+
className = _key$split2[2],
|
|
322
|
+
objectId = _key$split2[3];
|
|
323
|
+
if (_key.split('_').length === 5 && _key.split('_')[3] === 'User') {
|
|
324
|
+
className = '_User';
|
|
325
|
+
objectId = _key.split('_')[4];
|
|
326
|
+
}
|
|
327
|
+
if (objectId.startsWith('local')) {
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
if (!(className in pointersHash)) {
|
|
331
|
+
pointersHash[className] = new Set();
|
|
332
|
+
}
|
|
333
|
+
pointersHash[className].add(objectId);
|
|
334
|
+
}
|
|
335
|
+
var queryPromises = Object.keys(pointersHash).map(function (className) {
|
|
336
|
+
var objectIds = Array.from(pointersHash[className]);
|
|
337
|
+
var query = new _ParseQuery.default(className);
|
|
338
|
+
query.limit(objectIds.length);
|
|
339
|
+
if (objectIds.length === 1) {
|
|
340
|
+
query.equalTo('objectId', objectIds[0]);
|
|
341
|
+
} else {
|
|
342
|
+
query.containedIn('objectId', objectIds);
|
|
343
|
+
}
|
|
344
|
+
return query.find();
|
|
345
|
+
});
|
|
346
|
+
try {
|
|
347
|
+
var responses = yield Promise.all(queryPromises);
|
|
348
|
+
var objects = [].concat.apply([], responses);
|
|
349
|
+
var pinPromises = objects.map(function (object) {
|
|
350
|
+
var objectKey = _this2.getKeyForObject(object);
|
|
351
|
+
return _this2.pinWithName(objectKey, object._toFullJSON());
|
|
352
|
+
});
|
|
353
|
+
yield Promise.all(pinPromises);
|
|
354
|
+
this.isSyncing = false;
|
|
355
|
+
} catch (error) {
|
|
356
|
+
console.error('Error syncing LocalDatastore: ', error);
|
|
357
|
+
this.isSyncing = false;
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
function updateFromServer() {
|
|
361
|
+
return _updateFromServer.apply(this, arguments);
|
|
362
|
+
}
|
|
363
|
+
return updateFromServer;
|
|
364
|
+
}(),
|
|
1027
365
|
getKeyForObject: function (object) {
|
|
1028
366
|
var objectId = object.objectId || object._getId();
|
|
1029
|
-
|
|
1030
|
-
return "" + _LocalDatastoreUtils.OBJECT_PREFIX + object.className + "_" + objectId;
|
|
367
|
+
return `${_LocalDatastoreUtils.OBJECT_PREFIX}${object.className}_${objectId}`;
|
|
1031
368
|
},
|
|
1032
369
|
getPinName: function (pinName) {
|
|
1033
370
|
if (!pinName || pinName === _LocalDatastoreUtils.DEFAULT_PIN) {
|
|
1034
371
|
return _LocalDatastoreUtils.DEFAULT_PIN;
|
|
1035
372
|
}
|
|
1036
|
-
|
|
1037
373
|
return _LocalDatastoreUtils.PIN_PREFIX + pinName;
|
|
1038
374
|
},
|
|
1039
375
|
checkIfEnabled: function () {
|
|
1040
376
|
if (!this.isEnabled) {
|
|
1041
377
|
console.error('Parse.enableLocalDatastore() must be called first');
|
|
1042
378
|
}
|
|
1043
|
-
|
|
1044
379
|
return this.isEnabled;
|
|
1045
380
|
}
|
|
1046
381
|
};
|
|
1047
382
|
module.exports = LocalDatastore;
|
|
1048
|
-
|
|
1049
383
|
_CoreManager.default.setLocalDatastoreController(require('./LocalDatastoreController.react-native'));
|
|
1050
|
-
|
|
1051
384
|
_CoreManager.default.setLocalDatastore(LocalDatastore);
|