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,429 +1,36 @@
1
1
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
3
  value: true
5
4
  });
6
5
  exports.default = void 0;
7
-
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
-
10
6
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
-
7
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
12
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
10
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
17
-
18
- function ownKeys(object, enumerableOnly) {
19
- var keys = Object.keys(object);
20
-
21
- if (Object.getOwnPropertySymbols) {
22
- var symbols = Object.getOwnPropertySymbols(object);
23
- enumerableOnly && (symbols = symbols.filter(function (sym) {
24
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
25
- })), keys.push.apply(keys, symbols);
26
- }
27
-
28
- return keys;
29
- }
30
-
31
- function _objectSpread(target) {
32
- for (var i = 1; i < arguments.length; i++) {
33
- var source = null != arguments[i] ? arguments[i] : {};
34
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
35
- (0, _defineProperty2.default)(target, key, source[key]);
36
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
37
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
38
- });
39
- }
40
-
41
- return target;
42
- }
43
-
44
- function _regeneratorRuntime() {
45
- "use strict";
46
-
47
- _regeneratorRuntime = function () {
48
- return exports;
49
- };
50
-
51
- var exports = {},
52
- Op = Object.prototype,
53
- hasOwn = Op.hasOwnProperty,
54
- $Symbol = "function" == typeof Symbol ? Symbol : {},
55
- iteratorSymbol = $Symbol.iterator || "@@iterator",
56
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
57
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
58
-
59
- function define(obj, key, value) {
60
- return Object.defineProperty(obj, key, {
61
- value: value,
62
- enumerable: !0,
63
- configurable: !0,
64
- writable: !0
65
- }), obj[key];
66
- }
67
-
68
- try {
69
- define({}, "");
70
- } catch (err) {
71
- define = function (obj, key, value) {
72
- return obj[key] = value;
73
- };
74
- }
75
-
76
- function wrap(innerFn, outerFn, self, tryLocsList) {
77
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
78
- generator = Object.create(protoGenerator.prototype),
79
- context = new Context(tryLocsList || []);
80
- return generator._invoke = function (innerFn, self, context) {
81
- var state = "suspendedStart";
82
- return function (method, arg) {
83
- if ("executing" === state) throw new Error("Generator is already running");
84
-
85
- if ("completed" === state) {
86
- if ("throw" === method) throw arg;
87
- return doneResult();
88
- }
89
-
90
- for (context.method = method, context.arg = arg;;) {
91
- var delegate = context.delegate;
92
-
93
- if (delegate) {
94
- var delegateResult = maybeInvokeDelegate(delegate, context);
95
-
96
- if (delegateResult) {
97
- if (delegateResult === ContinueSentinel) continue;
98
- return delegateResult;
99
- }
100
- }
101
-
102
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
103
- if ("suspendedStart" === state) throw state = "completed", context.arg;
104
- context.dispatchException(context.arg);
105
- } else "return" === context.method && context.abrupt("return", context.arg);
106
- state = "executing";
107
- var record = tryCatch(innerFn, self, context);
108
-
109
- if ("normal" === record.type) {
110
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
111
- return {
112
- value: record.arg,
113
- done: context.done
114
- };
115
- }
116
-
117
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
118
- }
119
- };
120
- }(innerFn, self, context), generator;
121
- }
122
-
123
- function tryCatch(fn, obj, arg) {
124
- try {
125
- return {
126
- type: "normal",
127
- arg: fn.call(obj, arg)
128
- };
129
- } catch (err) {
130
- return {
131
- type: "throw",
132
- arg: err
133
- };
134
- }
135
- }
136
-
137
- exports.wrap = wrap;
138
- var ContinueSentinel = {};
139
-
140
- function Generator() {}
141
-
142
- function GeneratorFunction() {}
143
-
144
- function GeneratorFunctionPrototype() {}
145
-
146
- var IteratorPrototype = {};
147
- define(IteratorPrototype, iteratorSymbol, function () {
148
- return this;
149
- });
150
- var getProto = Object.getPrototypeOf,
151
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
152
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
153
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
154
-
155
- function defineIteratorMethods(prototype) {
156
- ["next", "throw", "return"].forEach(function (method) {
157
- define(prototype, method, function (arg) {
158
- return this._invoke(method, arg);
159
- });
160
- });
161
- }
162
-
163
- function AsyncIterator(generator, PromiseImpl) {
164
- function invoke(method, arg, resolve, reject) {
165
- var record = tryCatch(generator[method], generator, arg);
166
-
167
- if ("throw" !== record.type) {
168
- var result = record.arg,
169
- value = result.value;
170
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
171
- invoke("next", value, resolve, reject);
172
- }, function (err) {
173
- invoke("throw", err, resolve, reject);
174
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
175
- result.value = unwrapped, resolve(result);
176
- }, function (error) {
177
- return invoke("throw", error, resolve, reject);
178
- });
179
- }
180
-
181
- reject(record.arg);
182
- }
183
-
184
- var previousPromise;
185
-
186
- this._invoke = function (method, arg) {
187
- function callInvokeWithMethodAndArg() {
188
- return new PromiseImpl(function (resolve, reject) {
189
- invoke(method, arg, resolve, reject);
190
- });
191
- }
192
-
193
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
194
- };
195
- }
196
-
197
- function maybeInvokeDelegate(delegate, context) {
198
- var method = delegate.iterator[context.method];
199
-
200
- if (undefined === method) {
201
- if (context.delegate = null, "throw" === context.method) {
202
- if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
203
- context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
204
- }
205
-
206
- return ContinueSentinel;
207
- }
208
-
209
- var record = tryCatch(method, delegate.iterator, context.arg);
210
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
211
- var info = record.arg;
212
- 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);
213
- }
214
-
215
- function pushTryEntry(locs) {
216
- var entry = {
217
- tryLoc: locs[0]
218
- };
219
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
220
- }
221
-
222
- function resetTryEntry(entry) {
223
- var record = entry.completion || {};
224
- record.type = "normal", delete record.arg, entry.completion = record;
225
- }
226
-
227
- function Context(tryLocsList) {
228
- this.tryEntries = [{
229
- tryLoc: "root"
230
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
231
- }
232
-
233
- function values(iterable) {
234
- if (iterable) {
235
- var iteratorMethod = iterable[iteratorSymbol];
236
- if (iteratorMethod) return iteratorMethod.call(iterable);
237
- if ("function" == typeof iterable.next) return iterable;
238
-
239
- if (!isNaN(iterable.length)) {
240
- var i = -1,
241
- next = function next() {
242
- for (; ++i < iterable.length;) {
243
- if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
244
- }
245
-
246
- return next.value = undefined, next.done = !0, next;
247
- };
248
-
249
- return next.next = next;
250
- }
251
- }
252
-
253
- return {
254
- next: doneResult
255
- };
256
- }
257
-
258
- function doneResult() {
259
- return {
260
- value: undefined,
261
- done: !0
262
- };
263
- }
264
-
265
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
266
- var ctor = "function" == typeof genFun && genFun.constructor;
267
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
268
- }, exports.mark = function (genFun) {
269
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
270
- }, exports.awrap = function (arg) {
271
- return {
272
- __await: arg
273
- };
274
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
275
- return this;
276
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
277
- void 0 === PromiseImpl && (PromiseImpl = Promise);
278
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
279
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
280
- return result.done ? result.value : iter.next();
281
- });
282
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
283
- return this;
284
- }), define(Gp, "toString", function () {
285
- return "[object Generator]";
286
- }), exports.keys = function (object) {
287
- var keys = [];
288
-
289
- for (var key in object) {
290
- keys.push(key);
291
- }
292
-
293
- return keys.reverse(), function next() {
294
- for (; keys.length;) {
295
- var key = keys.pop();
296
- if (key in object) return next.value = key, next.done = !1, next;
297
- }
298
-
299
- return next.done = !0, next;
300
- };
301
- }, exports.values = values, Context.prototype = {
302
- constructor: Context,
303
- reset: function (skipTempReset) {
304
- 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) {
305
- "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
306
- }
307
- },
308
- stop: function () {
309
- this.done = !0;
310
- var rootRecord = this.tryEntries[0].completion;
311
- if ("throw" === rootRecord.type) throw rootRecord.arg;
312
- return this.rval;
313
- },
314
- dispatchException: function (exception) {
315
- if (this.done) throw exception;
316
- var context = this;
317
-
318
- function handle(loc, caught) {
319
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
320
- }
321
-
322
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
323
- var entry = this.tryEntries[i],
324
- record = entry.completion;
325
- if ("root" === entry.tryLoc) return handle("end");
326
-
327
- if (entry.tryLoc <= this.prev) {
328
- var hasCatch = hasOwn.call(entry, "catchLoc"),
329
- hasFinally = hasOwn.call(entry, "finallyLoc");
330
-
331
- if (hasCatch && hasFinally) {
332
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
333
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
334
- } else if (hasCatch) {
335
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
336
- } else {
337
- if (!hasFinally) throw new Error("try statement without catch or finally");
338
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
339
- }
340
- }
341
- }
342
- },
343
- abrupt: function (type, arg) {
344
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
345
- var entry = this.tryEntries[i];
346
-
347
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
348
- var finallyEntry = entry;
349
- break;
350
- }
351
- }
352
-
353
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
354
- var record = finallyEntry ? finallyEntry.completion : {};
355
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
356
- },
357
- complete: function (record, afterLoc) {
358
- if ("throw" === record.type) throw record.arg;
359
- 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;
360
- },
361
- finish: function (finallyLoc) {
362
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
363
- var entry = this.tryEntries[i];
364
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
365
- }
366
- },
367
- catch: function (tryLoc) {
368
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
369
- var entry = this.tryEntries[i];
370
-
371
- if (entry.tryLoc === tryLoc) {
372
- var record = entry.completion;
373
-
374
- if ("throw" === record.type) {
375
- var thrown = record.arg;
376
- resetTryEntry(entry);
377
- }
378
-
379
- return thrown;
380
- }
381
- }
382
-
383
- throw new Error("illegal catch attempt");
384
- },
385
- delegateYield: function (iterable, resultName, nextLoc) {
386
- return this.delegate = {
387
- iterator: values(iterable),
388
- resultName: resultName,
389
- nextLoc: nextLoc
390
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
391
- }
392
- }, exports;
393
- }
394
-
395
11
  var ParseError = require('./ParseError').default;
396
-
397
12
  var XHR = null;
398
-
399
13
  if (typeof XMLHttpRequest !== 'undefined') {
400
14
  XHR = XMLHttpRequest;
401
15
  }
402
-
403
16
  function b64Digit(number) {
404
17
  if (number < 26) {
405
18
  return String.fromCharCode(65 + number);
406
19
  }
407
-
408
20
  if (number < 52) {
409
21
  return String.fromCharCode(97 + (number - 26));
410
22
  }
411
-
412
23
  if (number < 62) {
413
24
  return String.fromCharCode(48 + (number - 52));
414
25
  }
415
-
416
26
  if (number === 62) {
417
27
  return '+';
418
28
  }
419
-
420
29
  if (number === 63) {
421
30
  return '/';
422
31
  }
423
-
424
32
  throw new TypeError('Tried to encode large digit ' + number + ' in base64.');
425
33
  }
426
-
427
34
  var ParseFile = function () {
428
35
  function ParseFile(name, data, type, metadata, tags) {
429
36
  (0, _classCallCheck2.default)(this, ParseFile);
@@ -431,7 +38,6 @@ var ParseFile = function () {
431
38
  this._name = name;
432
39
  this._metadata = metadata || {};
433
40
  this._tags = tags || {};
434
-
435
41
  if (data !== undefined) {
436
42
  if (Array.isArray(data)) {
437
43
  this._data = ParseFile.encodeBase64(data);
@@ -466,54 +72,31 @@ var ParseFile = function () {
466
72
  }
467
73
  }
468
74
  }
469
-
470
75
  (0, _createClass2.default)(ParseFile, [{
471
76
  key: "getData",
472
77
  value: function () {
473
- var _this = this;
474
-
475
- var options, controller, result;
476
- return _regeneratorRuntime().async(function (_context) {
477
- while (1) {
478
- switch (_context.prev = _context.next) {
479
- case 0:
480
- if (!this._data) {
481
- _context.next = 2;
482
- break;
483
- }
484
-
485
- return _context.abrupt("return", this._data);
486
-
487
- case 2:
488
- if (this._url) {
489
- _context.next = 4;
490
- break;
491
- }
492
-
493
- throw new Error('Cannot retrieve data for unsaved ParseFile.');
494
-
495
- case 4:
496
- options = {
497
- requestTask: function (task) {
498
- return _this._requestTask = task;
499
- }
500
- };
501
- controller = _CoreManager.default.getFileController();
502
- _context.next = 8;
503
- return _regeneratorRuntime().awrap(controller.download(this._url, options));
504
-
505
- case 8:
506
- result = _context.sent;
507
- this._data = result.base64;
508
- return _context.abrupt("return", this._data);
509
-
510
- case 11:
511
- case "end":
512
- return _context.stop();
513
- }
78
+ var _getData = (0, _asyncToGenerator2.default)(function* () {
79
+ var _this = this;
80
+ if (this._data) {
81
+ return this._data;
514
82
  }
515
- }, null, this, null, Promise);
516
- }
83
+ if (!this._url) {
84
+ throw new Error('Cannot retrieve data for unsaved ParseFile.');
85
+ }
86
+ var controller = _CoreManager.default.getFileController();
87
+ var result = yield controller.download(this._url, {
88
+ requestTask: function (task) {
89
+ return _this._requestTask = task;
90
+ }
91
+ });
92
+ this._data = result.base64;
93
+ return this._data;
94
+ });
95
+ function getData() {
96
+ return _getData.apply(this, arguments);
97
+ }
98
+ return getData;
99
+ }()
517
100
  }, {
518
101
  key: "name",
519
102
  value: function () {
@@ -523,11 +106,9 @@ var ParseFile = function () {
523
106
  key: "url",
524
107
  value: function (options) {
525
108
  options = options || {};
526
-
527
109
  if (!this._url) {
528
110
  return;
529
111
  }
530
-
531
112
  if (options.forceSecure) {
532
113
  return this._url.replace(/^http:\/\//i, 'https://');
533
114
  } else {
@@ -548,18 +129,13 @@ var ParseFile = function () {
548
129
  key: "save",
549
130
  value: function (options) {
550
131
  var _this2 = this;
551
-
552
132
  options = options || {};
553
-
554
133
  options.requestTask = function (task) {
555
134
  return _this2._requestTask = task;
556
135
  };
557
-
558
136
  options.metadata = this._metadata;
559
137
  options.tags = this._tags;
560
-
561
138
  var controller = _CoreManager.default.getFileController();
562
-
563
139
  if (!this._previousSave) {
564
140
  if (this._source.format === 'file') {
565
141
  this._previousSave = controller.saveFile(this._name, this._source, options).then(function (res) {
@@ -574,7 +150,6 @@ var ParseFile = function () {
574
150
  if (!(result && result.base64)) {
575
151
  return {};
576
152
  }
577
-
578
153
  var newSource = {
579
154
  format: 'base64',
580
155
  base64: result.base64,
@@ -598,7 +173,6 @@ var ParseFile = function () {
598
173
  });
599
174
  }
600
175
  }
601
-
602
176
  if (this._previousSave) {
603
177
  return this._previousSave;
604
178
  }
@@ -609,30 +183,23 @@ var ParseFile = function () {
609
183
  if (this._requestTask && typeof this._requestTask.abort === 'function') {
610
184
  this._requestTask.abort();
611
185
  }
612
-
613
186
  this._requestTask = null;
614
187
  }
615
188
  }, {
616
189
  key: "destroy",
617
190
  value: function () {
618
191
  var _this3 = this;
619
-
620
192
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
621
-
622
193
  if (!this._name) {
623
194
  throw new ParseError(ParseError.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.');
624
195
  }
625
-
626
196
  var destroyOptions = {
627
197
  useMasterKey: true
628
198
  };
629
-
630
199
  if (options.hasOwnProperty('useMasterKey')) {
631
200
  destroyOptions.useMasterKey = options.useMasterKey;
632
201
  }
633
-
634
202
  var controller = _CoreManager.default.getFileController();
635
-
636
203
  return controller.deleteFile(this._name, destroyOptions).then(function () {
637
204
  _this3._data = null;
638
205
  _this3._requestTask = null;
@@ -654,14 +221,12 @@ var ParseFile = function () {
654
221
  if (this === other) {
655
222
  return true;
656
223
  }
657
-
658
224
  return other instanceof ParseFile && this.name() === other.name() && this.url() === other.url() && typeof this.url() !== 'undefined';
659
225
  }
660
226
  }, {
661
227
  key: "setMetadata",
662
228
  value: function (metadata) {
663
229
  var _this4 = this;
664
-
665
230
  if (metadata && typeof metadata === 'object') {
666
231
  Object.keys(metadata).forEach(function (key) {
667
232
  _this4.addMetadata(key, metadata[key]);
@@ -679,7 +244,6 @@ var ParseFile = function () {
679
244
  key: "setTags",
680
245
  value: function (tags) {
681
246
  var _this5 = this;
682
-
683
247
  if (tags && typeof tags === 'object') {
684
248
  Object.keys(tags).forEach(function (key) {
685
249
  _this5.addTag(key, tags[key]);
@@ -699,7 +263,6 @@ var ParseFile = function () {
699
263
  if (obj.__type !== 'File') {
700
264
  throw new TypeError('JSON object does not represent a ParseFile');
701
265
  }
702
-
703
266
  var file = new ParseFile(obj.name);
704
267
  file._url = obj.url;
705
268
  return file;
@@ -709,7 +272,6 @@ var ParseFile = function () {
709
272
  value: function (bytes) {
710
273
  var chunks = [];
711
274
  chunks.length = Math.ceil(bytes.length / 3);
712
-
713
275
  for (var i = 0; i < chunks.length; i++) {
714
276
  var b1 = bytes[i * 3];
715
277
  var b2 = bytes[i * 3 + 1] || 0;
@@ -718,85 +280,60 @@ var ParseFile = function () {
718
280
  var has3 = i * 3 + 2 < bytes.length;
719
281
  chunks[i] = [b64Digit(b1 >> 2 & 0x3f), b64Digit(b1 << 4 & 0x30 | b2 >> 4 & 0x0f), has2 ? b64Digit(b2 << 2 & 0x3c | b3 >> 6 & 0x03) : '=', has3 ? b64Digit(b3 & 0x3f) : '='].join('');
720
282
  }
721
-
722
283
  return chunks.join('');
723
284
  }
724
285
  }]);
725
286
  return ParseFile;
726
287
  }();
727
-
728
288
  var DefaultController = {
729
- saveFile: function (name, source, options) {
730
- var base64Data, _base64Data$split, _base64Data$split2, first, second, data, newSource;
731
-
732
- return _regeneratorRuntime().async(function (_context2) {
733
- while (1) {
734
- switch (_context2.prev = _context2.next) {
735
- case 0:
736
- if (!(source.format !== 'file')) {
737
- _context2.next = 2;
738
- break;
739
- }
740
-
741
- throw new Error('saveFile can only be used with File-type sources.');
742
-
743
- case 2:
744
- _context2.next = 4;
745
- return _regeneratorRuntime().awrap(new Promise(function (res, rej) {
746
- var reader = new FileReader();
747
-
748
- reader.onload = function () {
749
- return res(reader.result);
750
- };
751
-
752
- reader.onerror = function (error) {
753
- return rej(error);
754
- };
755
-
756
- reader.readAsDataURL(source.file);
757
- }));
758
-
759
- case 4:
760
- base64Data = _context2.sent;
761
- _base64Data$split = base64Data.split(','), _base64Data$split2 = (0, _slicedToArray2.default)(_base64Data$split, 2), first = _base64Data$split2[0], second = _base64Data$split2[1];
762
- data = second ? second : first;
763
- newSource = {
764
- format: 'base64',
765
- base64: data,
766
- type: source.type || (source.file ? source.file.type : null)
767
- };
768
- _context2.next = 10;
769
- return _regeneratorRuntime().awrap(DefaultController.saveBase64(name, newSource, options));
770
-
771
- case 10:
772
- return _context2.abrupt("return", _context2.sent);
773
-
774
- case 11:
775
- case "end":
776
- return _context2.stop();
777
- }
289
+ saveFile: function () {
290
+ var _saveFile = (0, _asyncToGenerator2.default)(function* (name, source, options) {
291
+ if (source.format !== 'file') {
292
+ throw new Error('saveFile can only be used with File-type sources.');
778
293
  }
779
- }, null, null, null, Promise);
780
- },
294
+ var base64Data = yield new Promise(function (res, rej) {
295
+ var reader = new FileReader();
296
+ reader.onload = function () {
297
+ return res(reader.result);
298
+ };
299
+ reader.onerror = function (error) {
300
+ return rej(error);
301
+ };
302
+ reader.readAsDataURL(source.file);
303
+ });
304
+ var _base64Data$split = base64Data.split(','),
305
+ _base64Data$split2 = (0, _slicedToArray2.default)(_base64Data$split, 2),
306
+ first = _base64Data$split2[0],
307
+ second = _base64Data$split2[1];
308
+ var data = second ? second : first;
309
+ var newSource = {
310
+ format: 'base64',
311
+ base64: data,
312
+ type: source.type || (source.file ? source.file.type : null)
313
+ };
314
+ return yield DefaultController.saveBase64(name, newSource, options);
315
+ });
316
+ function saveFile() {
317
+ return _saveFile.apply(this, arguments);
318
+ }
319
+ return saveFile;
320
+ }(),
781
321
  saveBase64: function (name, source, options) {
782
322
  if (source.format !== 'base64') {
783
323
  throw new Error('saveBase64 can only be used with Base64-type sources.');
784
324
  }
785
-
786
325
  var data = {
787
326
  base64: source.base64,
788
327
  fileData: {
789
- metadata: _objectSpread({}, options.metadata),
790
- tags: _objectSpread({}, options.tags)
328
+ metadata: Object.assign({}, options.metadata),
329
+ tags: Object.assign({}, options.tags)
791
330
  }
792
331
  };
793
332
  delete options.metadata;
794
333
  delete options.tags;
795
-
796
334
  if (source.type) {
797
335
  data._ContentType = source.type;
798
336
  }
799
-
800
337
  return _CoreManager.default.getRESTController().request('POST', 'files/' + name, data, options);
801
338
  },
802
339
  download: function (uri, options) {
@@ -811,27 +348,22 @@ var DefaultController = {
811
348
  var xhr = new XHR();
812
349
  xhr.open('GET', uri, true);
813
350
  xhr.responseType = 'arraybuffer';
814
-
815
351
  xhr.onerror = function (e) {
816
352
  reject(e);
817
353
  };
818
-
819
354
  xhr.onreadystatechange = function () {
820
355
  if (xhr.readyState !== xhr.DONE) {
821
356
  return;
822
357
  }
823
-
824
358
  if (!this.response) {
825
359
  return resolve({});
826
360
  }
827
-
828
361
  var bytes = new Uint8Array(this.response);
829
362
  resolve({
830
363
  base64: ParseFile.encodeBase64(bytes),
831
364
  contentType: xhr.getResponseHeader('content-type')
832
365
  });
833
366
  };
834
-
835
367
  options.requestTask(xhr);
836
368
  xhr.send();
837
369
  });
@@ -840,17 +372,13 @@ var DefaultController = {
840
372
  var headers = {
841
373
  'X-Parse-Application-ID': _CoreManager.default.get('APPLICATION_ID')
842
374
  };
843
-
844
375
  if (options.useMasterKey) {
845
376
  headers['X-Parse-Master-Key'] = _CoreManager.default.get('MASTER_KEY');
846
377
  }
847
-
848
378
  var url = _CoreManager.default.get('SERVER_URL');
849
-
850
379
  if (url[url.length - 1] !== '/') {
851
380
  url += '/';
852
381
  }
853
-
854
382
  url += 'files/' + name;
855
383
  return _CoreManager.default.getRESTController().ajax('DELETE', url, '', headers).catch(function (response) {
856
384
  if (!response || response === 'SyntaxError: Unexpected end of JSON input') {
@@ -867,9 +395,7 @@ var DefaultController = {
867
395
  return XHR;
868
396
  }
869
397
  };
870
-
871
398
  _CoreManager.default.setFileController(DefaultController);
872
-
873
399
  var _default = ParseFile;
874
400
  exports.default = _default;
875
401
  exports.b64Digit = b64Digit;