parse 4.0.0-alpha.1 → 4.0.0-alpha.11

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.
Files changed (255) hide show
  1. package/LICENSE +167 -25
  2. package/NOTICE +10 -0
  3. package/README.md +6 -5
  4. package/dist/parse.js +12838 -21190
  5. package/dist/parse.min.js +7 -6
  6. package/dist/parse.weapp.js +7921 -17062
  7. package/dist/parse.weapp.min.js +7 -6
  8. package/lib/browser/Analytics.js +2 -27
  9. package/lib/browser/AnonymousUtils.js +6 -42
  10. package/lib/browser/Cloud.js +12 -77
  11. package/lib/browser/CloudCode.js +0 -3
  12. package/lib/browser/CoreManager.js +46 -191
  13. package/lib/browser/CryptoController.js +2 -16
  14. package/lib/browser/EventEmitter.js +1 -8
  15. package/lib/browser/EventuallyQueue.js +277 -824
  16. package/lib/browser/FacebookUtils.js +6 -42
  17. package/lib/browser/IndexedDBStorageController.js +3 -14
  18. package/lib/browser/InstallationController.js +2 -20
  19. package/lib/browser/LiveQueryClient.js +105 -213
  20. package/lib/browser/LiveQuerySubscription.js +10 -39
  21. package/lib/browser/LocalDatastore.js +451 -1081
  22. package/lib/browser/LocalDatastoreController.js +145 -602
  23. package/lib/browser/LocalDatastoreController.react-native.js +137 -573
  24. package/lib/browser/LocalDatastoreUtils.js +2 -19
  25. package/lib/browser/ObjectStateMutations.js +18 -121
  26. package/lib/browser/OfflineQuery.js +61 -222
  27. package/lib/browser/Parse.js +12 -115
  28. package/lib/browser/ParseACL.js +33 -148
  29. package/lib/browser/ParseCLP.js +96 -314
  30. package/lib/browser/ParseConfig.js +18 -95
  31. package/lib/browser/ParseError.js +63 -99
  32. package/lib/browser/ParseFile.js +128 -685
  33. package/lib/browser/ParseGeoPoint.js +23 -89
  34. package/lib/browser/ParseHooks.js +1 -34
  35. package/lib/browser/ParseInstallation.js +4 -32
  36. package/lib/browser/ParseLiveQuery.js +96 -505
  37. package/lib/browser/ParseObject.js +665 -1845
  38. package/lib/browser/ParseOp.js +41 -287
  39. package/lib/browser/ParsePolygon.js +13 -70
  40. package/lib/browser/ParseQuery.js +403 -1504
  41. package/lib/browser/ParseRelation.js +12 -68
  42. package/lib/browser/ParseRole.js +13 -75
  43. package/lib/browser/ParseSchema.js +49 -208
  44. package/lib/browser/ParseSession.js +11 -69
  45. package/lib/browser/ParseUser.js +274 -1127
  46. package/lib/browser/Push.js +7 -50
  47. package/lib/browser/RESTController.js +28 -157
  48. package/lib/browser/SingleInstanceStateController.js +19 -144
  49. package/lib/browser/Socket.weapp.js +0 -10
  50. package/lib/browser/Storage.js +10 -80
  51. package/lib/browser/StorageController.browser.js +4 -24
  52. package/lib/browser/StorageController.default.js +4 -24
  53. package/lib/browser/StorageController.react-native.js +6 -40
  54. package/lib/browser/StorageController.weapp.js +5 -23
  55. package/lib/browser/TaskQueue.js +1 -29
  56. package/lib/browser/UniqueInstanceStateController.js +19 -149
  57. package/lib/browser/Xhr.weapp.js +0 -17
  58. package/lib/browser/arrayContainsObject.js +2 -23
  59. package/lib/browser/canBeSerialized.js +3 -40
  60. package/lib/browser/decode.js +3 -40
  61. package/lib/browser/encode.js +9 -77
  62. package/lib/browser/equals.js +2 -34
  63. package/lib/browser/escape.js +1 -15
  64. package/lib/browser/isRevocableSession.js +2 -18
  65. package/lib/browser/parseDate.js +2 -20
  66. package/lib/browser/promiseUtils.js +3 -21
  67. package/lib/browser/unique.js +3 -24
  68. package/lib/browser/unsavedChildren.js +6 -57
  69. package/lib/browser/uuid.js +3 -1
  70. package/lib/node/Analytics.js +1 -25
  71. package/lib/node/AnonymousUtils.js +5 -44
  72. package/lib/node/Cloud.js +10 -73
  73. package/lib/node/CloudCode.js +0 -3
  74. package/lib/node/CoreManager.js +47 -227
  75. package/lib/node/CryptoController.js +2 -16
  76. package/lib/node/EventEmitter.js +1 -8
  77. package/lib/node/EventuallyQueue.js +16 -123
  78. package/lib/node/FacebookUtils.js +5 -44
  79. package/lib/node/IndexedDBStorageController.js +3 -19
  80. package/lib/node/InstallationController.js +2 -22
  81. package/lib/node/LiveQueryClient.js +72 -154
  82. package/lib/node/LiveQuerySubscription.js +7 -26
  83. package/lib/node/LocalDatastore.js +19 -182
  84. package/lib/node/LocalDatastoreController.js +6 -45
  85. package/lib/node/LocalDatastoreController.react-native.js +6 -52
  86. package/lib/node/LocalDatastoreUtils.js +1 -13
  87. package/lib/node/ObjectStateMutations.js +13 -100
  88. package/lib/node/OfflineQuery.js +27 -151
  89. package/lib/node/Parse.js +11 -108
  90. package/lib/node/ParseACL.js +32 -157
  91. package/lib/node/ParseCLP.js +69 -269
  92. package/lib/node/ParseConfig.js +16 -91
  93. package/lib/node/ParseError.js +61 -74
  94. package/lib/node/ParseFile.js +49 -212
  95. package/lib/node/ParseGeoPoint.js +21 -89
  96. package/lib/node/ParseHooks.js +0 -35
  97. package/lib/node/ParseInstallation.js +1 -17
  98. package/lib/node/ParseLiveQuery.js +10 -43
  99. package/lib/node/ParseObject.js +229 -964
  100. package/lib/node/ParseOp.js +31 -262
  101. package/lib/node/ParsePolygon.js +12 -69
  102. package/lib/node/ParseQuery.js +169 -888
  103. package/lib/node/ParseRelation.js +11 -68
  104. package/lib/node/ParseRole.js +10 -64
  105. package/lib/node/ParseSchema.js +46 -229
  106. package/lib/node/ParseSession.js +8 -57
  107. package/lib/node/ParseUser.js +107 -583
  108. package/lib/node/Push.js +4 -44
  109. package/lib/node/RESTController.js +18 -127
  110. package/lib/node/SingleInstanceStateController.js +17 -137
  111. package/lib/node/Socket.weapp.js +0 -7
  112. package/lib/node/Storage.js +10 -90
  113. package/lib/node/StorageController.browser.js +4 -30
  114. package/lib/node/StorageController.default.js +5 -28
  115. package/lib/node/StorageController.react-native.js +6 -47
  116. package/lib/node/StorageController.weapp.js +6 -28
  117. package/lib/node/TaskQueue.js +1 -24
  118. package/lib/node/UniqueInstanceStateController.js +16 -140
  119. package/lib/node/Xhr.weapp.js +0 -15
  120. package/lib/node/arrayContainsObject.js +1 -19
  121. package/lib/node/canBeSerialized.js +2 -35
  122. package/lib/node/decode.js +1 -33
  123. package/lib/node/encode.js +3 -61
  124. package/lib/node/equals.js +0 -27
  125. package/lib/node/escape.js +1 -13
  126. package/lib/node/isRevocableSession.js +1 -12
  127. package/lib/node/parseDate.js +1 -14
  128. package/lib/node/promiseUtils.js +2 -14
  129. package/lib/node/unique.js +1 -18
  130. package/lib/node/unsavedChildren.js +2 -45
  131. package/lib/node/uuid.js +6 -1
  132. package/lib/react-native/Analytics.js +0 -9
  133. package/lib/react-native/AnonymousUtils.js +0 -10
  134. package/lib/react-native/Cloud.js +0 -26
  135. package/lib/react-native/CoreManager.js +2 -6
  136. package/lib/react-native/CryptoController.js +0 -2
  137. package/lib/react-native/EventEmitter.js +0 -2
  138. package/lib/react-native/EventuallyQueue.js +156 -711
  139. package/lib/react-native/FacebookUtils.js +0 -22
  140. package/lib/react-native/IndexedDBStorageController.js +0 -1
  141. package/lib/react-native/InstallationController.js +0 -6
  142. package/lib/react-native/LiveQueryClient.js +46 -157
  143. package/lib/react-native/LiveQuerySubscription.js +3 -27
  144. package/lib/react-native/LocalDatastore.js +281 -948
  145. package/lib/react-native/LocalDatastoreController.js +71 -552
  146. package/lib/react-native/LocalDatastoreController.react-native.js +91 -526
  147. package/lib/react-native/LocalDatastoreUtils.js +0 -1
  148. package/lib/react-native/ObjectStateMutations.js +2 -65
  149. package/lib/react-native/OfflineQuery.js +25 -196
  150. package/lib/react-native/Parse.js +0 -65
  151. package/lib/react-native/ParseACL.js +0 -44
  152. package/lib/react-native/ParseCLP.js +23 -161
  153. package/lib/react-native/ParseConfig.js +0 -42
  154. package/lib/react-native/ParseError.js +1 -21
  155. package/lib/react-native/ParseFile.js +55 -529
  156. package/lib/react-native/ParseGeoPoint.js +0 -17
  157. package/lib/react-native/ParseHooks.js +0 -30
  158. package/lib/react-native/ParseInstallation.js +1 -23
  159. package/lib/react-native/ParseLiveQuery.js +55 -472
  160. package/lib/react-native/ParseObject.js +245 -1246
  161. package/lib/react-native/ParseOp.js +1 -138
  162. package/lib/react-native/ParsePolygon.js +0 -24
  163. package/lib/react-native/ParseQuery.js +182 -874
  164. package/lib/react-native/ParseRelation.js +0 -25
  165. package/lib/react-native/ParseRole.js +1 -36
  166. package/lib/react-native/ParseSchema.js +3 -54
  167. package/lib/react-native/ParseSession.js +1 -40
  168. package/lib/react-native/ParseUser.js +95 -773
  169. package/lib/react-native/Push.js +0 -16
  170. package/lib/react-native/RESTController.js +12 -109
  171. package/lib/react-native/SingleInstanceStateController.js +0 -44
  172. package/lib/react-native/Socket.weapp.js +0 -10
  173. package/lib/react-native/Storage.js +0 -24
  174. package/lib/react-native/StorageController.browser.js +0 -2
  175. package/lib/react-native/StorageController.default.js +0 -1
  176. package/lib/react-native/StorageController.react-native.js +0 -2
  177. package/lib/react-native/TaskQueue.js +0 -15
  178. package/lib/react-native/UniqueInstanceStateController.js +0 -47
  179. package/lib/react-native/Xhr.weapp.js +0 -16
  180. package/lib/react-native/arrayContainsObject.js +0 -5
  181. package/lib/react-native/canBeSerialized.js +0 -18
  182. package/lib/react-native/decode.js +0 -21
  183. package/lib/react-native/encode.js +0 -25
  184. package/lib/react-native/equals.js +0 -18
  185. package/lib/react-native/escape.js +0 -1
  186. package/lib/react-native/isRevocableSession.js +0 -1
  187. package/lib/react-native/parseDate.js +0 -3
  188. package/lib/react-native/promiseUtils.js +0 -13
  189. package/lib/react-native/unique.js +0 -4
  190. package/lib/react-native/unsavedChildren.js +0 -21
  191. package/lib/react-native/uuid.js +3 -1
  192. package/lib/weapp/Analytics.js +2 -27
  193. package/lib/weapp/AnonymousUtils.js +6 -42
  194. package/lib/weapp/Cloud.js +12 -77
  195. package/lib/weapp/CloudCode.js +0 -3
  196. package/lib/weapp/CoreManager.js +46 -191
  197. package/lib/weapp/CryptoController.js +2 -16
  198. package/lib/weapp/EventEmitter.js +1 -8
  199. package/lib/weapp/EventuallyQueue.js +277 -824
  200. package/lib/weapp/FacebookUtils.js +6 -42
  201. package/lib/weapp/IndexedDBStorageController.js +3 -14
  202. package/lib/weapp/InstallationController.js +2 -20
  203. package/lib/weapp/LiveQueryClient.js +105 -213
  204. package/lib/weapp/LiveQuerySubscription.js +10 -39
  205. package/lib/weapp/LocalDatastore.js +451 -1081
  206. package/lib/weapp/LocalDatastoreController.js +145 -602
  207. package/lib/weapp/LocalDatastoreController.react-native.js +137 -573
  208. package/lib/weapp/LocalDatastoreUtils.js +2 -19
  209. package/lib/weapp/ObjectStateMutations.js +18 -121
  210. package/lib/weapp/OfflineQuery.js +61 -222
  211. package/lib/weapp/Parse.js +12 -115
  212. package/lib/weapp/ParseACL.js +33 -148
  213. package/lib/weapp/ParseCLP.js +96 -314
  214. package/lib/weapp/ParseConfig.js +18 -95
  215. package/lib/weapp/ParseError.js +63 -99
  216. package/lib/weapp/ParseFile.js +129 -686
  217. package/lib/weapp/ParseGeoPoint.js +23 -89
  218. package/lib/weapp/ParseHooks.js +1 -34
  219. package/lib/weapp/ParseInstallation.js +4 -32
  220. package/lib/weapp/ParseLiveQuery.js +96 -505
  221. package/lib/weapp/ParseObject.js +665 -1845
  222. package/lib/weapp/ParseOp.js +41 -287
  223. package/lib/weapp/ParsePolygon.js +13 -70
  224. package/lib/weapp/ParseQuery.js +403 -1504
  225. package/lib/weapp/ParseRelation.js +12 -68
  226. package/lib/weapp/ParseRole.js +13 -75
  227. package/lib/weapp/ParseSchema.js +49 -208
  228. package/lib/weapp/ParseSession.js +11 -69
  229. package/lib/weapp/ParseUser.js +274 -1127
  230. package/lib/weapp/Push.js +7 -50
  231. package/lib/weapp/RESTController.js +28 -157
  232. package/lib/weapp/SingleInstanceStateController.js +19 -144
  233. package/lib/weapp/Socket.weapp.js +0 -10
  234. package/lib/weapp/Storage.js +10 -80
  235. package/lib/weapp/StorageController.browser.js +4 -24
  236. package/lib/weapp/StorageController.default.js +4 -24
  237. package/lib/weapp/StorageController.react-native.js +6 -40
  238. package/lib/weapp/StorageController.weapp.js +5 -23
  239. package/lib/weapp/TaskQueue.js +1 -29
  240. package/lib/weapp/UniqueInstanceStateController.js +19 -149
  241. package/lib/weapp/Xhr.weapp.js +0 -17
  242. package/lib/weapp/arrayContainsObject.js +2 -23
  243. package/lib/weapp/canBeSerialized.js +3 -40
  244. package/lib/weapp/decode.js +3 -40
  245. package/lib/weapp/encode.js +9 -77
  246. package/lib/weapp/equals.js +2 -34
  247. package/lib/weapp/escape.js +1 -15
  248. package/lib/weapp/isRevocableSession.js +2 -18
  249. package/lib/weapp/parseDate.js +2 -20
  250. package/lib/weapp/promiseUtils.js +3 -21
  251. package/lib/weapp/unique.js +3 -24
  252. package/lib/weapp/unsavedChildren.js +6 -57
  253. package/lib/weapp/uuid.js +1 -6
  254. package/package.json +35 -31
  255. 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 (name, objects) {
438
- var pinName, toPinPromises, objectKeys, _iterator, _step, parent, children, parentKey, json, objectKey, fromPinPromise, _await$Promise$all, _await$Promise$all2, pinned, toPin;
439
-
440
- return _regeneratorRuntime().async(function (_context) {
441
- while (1) {
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
- }
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
- }, 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
-
508
- objectKeys = (0, _toConsumableArray2.default)(new Set(objectKeys));
509
- pinned = localDatastore[pinName] || [];
510
- pinned = pinned.filter(function (item) {
511
- return !objectKeys.includes(item);
512
- });
513
-
514
- if (pinned.length == 0) {
515
- promises.push(this.unPinWithName(pinName));
516
- delete localDatastore[pinName];
517
- } else {
518
- promises.push(this.pinWithName(pinName, pinned));
519
- localDatastore[pinName] = pinned;
520
- }
521
-
522
- _iterator3 = _createForOfIteratorHelperLoose(objectKeys);
523
-
524
- case 12:
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
- hasReference = true;
555
- return _context2.abrupt("break", 25);
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
- }, null, this, null, Promise);
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 (name) {
619
- var _this = this,
141
+ _serializeObjectsFromPinName: function () {
142
+ var _serializeObjectsFromPinName2 = (0, _asyncToGenerator2.default)(function* (name) {
143
+ var _this = this,
620
144
  _ref;
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
- }
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
- }, 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
-
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
- }, 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
-
755
- return _context5.abrupt("return");
756
-
757
- case 2:
758
- objectKey = this.getKeyForObject(object);
759
- _context5.next = 5;
760
- return _regeneratorRuntime().awrap(this.fromPinWithName(objectKey));
761
-
762
- case 5:
763
- pinned = _context5.sent;
764
-
765
- if (!(!pinned || pinned.length === 0)) {
766
- _context5.next = 8;
767
- break;
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
- }, 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
- }
792
-
793
- return _context6.abrupt("return");
794
-
795
- case 2:
796
- _context6.next = 4;
797
- return _regeneratorRuntime().awrap(this._getAllContents());
798
-
799
- case 4:
800
- localDatastore = _context6.sent;
801
- objectKey = this.getKeyForObject(object);
802
- pin = localDatastore[objectKey];
803
-
804
- if (pin) {
805
- _context6.next = 9;
806
- break;
807
- }
808
-
809
- return _context6.abrupt("return");
810
-
811
- case 9:
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
- }
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
- }, 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
-
855
- return _context7.abrupt("return");
856
-
857
- case 2:
858
- localKey = "" + _LocalDatastoreUtils.OBJECT_PREFIX + object.className + "_" + localId;
859
- objectKey = this.getKeyForObject(object);
860
- _context7.next = 6;
861
- return _regeneratorRuntime().awrap(this.fromPinWithName(localKey));
862
-
863
- case 6:
864
- unsaved = _context7.sent;
865
-
866
- if (!(!unsaved || unsaved.length === 0)) {
867
- _context7.next = 9;
868
- break;
869
- }
870
-
871
- return _context7.abrupt("return");
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
- }, null, this, null, Promise);
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 _this2 = this;
907
-
908
- var localDatastore, keys, key, pointersHash, _i, _keys, _key, _key$split, _key$split2, className, objectId, queryPromises, responses, objects, pinPromises;
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");
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
- }, null, this, [[24, 35]], Promise);
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);