parse 4.0.1 → 4.1.0-alpha.2

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 (251) hide show
  1. package/dist/parse.js +17995 -26193
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +8739 -17728
  4. package/dist/parse.weapp.min.js +2 -2
  5. package/lib/browser/Analytics.js +2 -20
  6. package/lib/browser/AnonymousUtils.js +6 -35
  7. package/lib/browser/Cloud.js +12 -70
  8. package/lib/browser/CloudCode.js +0 -3
  9. package/lib/browser/CoreManager.js +46 -184
  10. package/lib/browser/CryptoController.js +2 -16
  11. package/lib/browser/EventEmitter.js +1 -1
  12. package/lib/browser/EventuallyQueue.js +277 -824
  13. package/lib/browser/FacebookUtils.js +6 -35
  14. package/lib/browser/IndexedDBStorageController.js +3 -14
  15. package/lib/browser/InstallationController.js +2 -13
  16. package/lib/browser/LiveQueryClient.js +87 -204
  17. package/lib/browser/LiveQuerySubscription.js +10 -39
  18. package/lib/browser/LocalDatastore.js +451 -1081
  19. package/lib/browser/LocalDatastoreController.js +145 -602
  20. package/lib/browser/LocalDatastoreController.react-native.js +137 -573
  21. package/lib/browser/LocalDatastoreUtils.js +2 -12
  22. package/lib/browser/ObjectStateMutations.js +18 -121
  23. package/lib/browser/OfflineQuery.js +42 -222
  24. package/lib/browser/Parse.js +12 -106
  25. package/lib/browser/ParseACL.js +33 -141
  26. package/lib/browser/ParseCLP.js +96 -314
  27. package/lib/browser/ParseConfig.js +18 -88
  28. package/lib/browser/ParseError.js +63 -90
  29. package/lib/browser/ParseFile.js +129 -685
  30. package/lib/browser/ParseGeoPoint.js +23 -82
  31. package/lib/browser/ParseHooks.js +1 -34
  32. package/lib/browser/ParseInstallation.js +4 -32
  33. package/lib/browser/ParseLiveQuery.js +96 -505
  34. package/lib/browser/ParseObject.js +628 -1840
  35. package/lib/browser/ParseOp.js +41 -287
  36. package/lib/browser/ParsePolygon.js +13 -63
  37. package/lib/browser/ParseQuery.js +404 -1505
  38. package/lib/browser/ParseRelation.js +12 -61
  39. package/lib/browser/ParseRole.js +13 -75
  40. package/lib/browser/ParseSchema.js +49 -201
  41. package/lib/browser/ParseSession.js +11 -69
  42. package/lib/browser/ParseUser.js +274 -1127
  43. package/lib/browser/Push.js +7 -43
  44. package/lib/browser/RESTController.js +18 -140
  45. package/lib/browser/SingleInstanceStateController.js +19 -137
  46. package/lib/browser/Socket.weapp.js +2 -12
  47. package/lib/browser/Storage.js +10 -73
  48. package/lib/browser/StorageController.browser.js +4 -17
  49. package/lib/browser/StorageController.default.js +4 -17
  50. package/lib/browser/StorageController.react-native.js +6 -33
  51. package/lib/browser/StorageController.weapp.js +5 -16
  52. package/lib/browser/TaskQueue.js +1 -22
  53. package/lib/browser/UniqueInstanceStateController.js +19 -142
  54. package/lib/browser/Xhr.weapp.js +0 -17
  55. package/lib/browser/arrayContainsObject.js +2 -16
  56. package/lib/browser/canBeSerialized.js +3 -33
  57. package/lib/browser/decode.js +3 -33
  58. package/lib/browser/encode.js +9 -70
  59. package/lib/browser/equals.js +2 -25
  60. package/lib/browser/escape.js +1 -8
  61. package/lib/browser/isRevocableSession.js +2 -11
  62. package/lib/browser/parseDate.js +2 -13
  63. package/lib/browser/promiseUtils.js +3 -21
  64. package/lib/browser/unique.js +3 -17
  65. package/lib/browser/unsavedChildren.js +6 -50
  66. package/lib/browser/uuid.js +3 -1
  67. package/lib/node/Analytics.js +1 -18
  68. package/lib/node/AnonymousUtils.js +5 -37
  69. package/lib/node/Cloud.js +10 -66
  70. package/lib/node/CloudCode.js +0 -3
  71. package/lib/node/CoreManager.js +47 -220
  72. package/lib/node/CryptoController.js +2 -16
  73. package/lib/node/EventEmitter.js +1 -1
  74. package/lib/node/EventuallyQueue.js +16 -123
  75. package/lib/node/FacebookUtils.js +5 -37
  76. package/lib/node/IndexedDBStorageController.js +3 -19
  77. package/lib/node/InstallationController.js +2 -15
  78. package/lib/node/LiveQueryClient.js +56 -136
  79. package/lib/node/LiveQuerySubscription.js +7 -16
  80. package/lib/node/LocalDatastore.js +19 -175
  81. package/lib/node/LocalDatastoreController.js +6 -38
  82. package/lib/node/LocalDatastoreController.react-native.js +6 -45
  83. package/lib/node/LocalDatastoreUtils.js +1 -6
  84. package/lib/node/ObjectStateMutations.js +13 -93
  85. package/lib/node/OfflineQuery.js +20 -152
  86. package/lib/node/Parse.js +11 -99
  87. package/lib/node/ParseACL.js +32 -150
  88. package/lib/node/ParseCLP.js +69 -262
  89. package/lib/node/ParseConfig.js +16 -84
  90. package/lib/node/ParseError.js +61 -65
  91. package/lib/node/ParseFile.js +50 -205
  92. package/lib/node/ParseGeoPoint.js +21 -82
  93. package/lib/node/ParseHooks.js +0 -35
  94. package/lib/node/ParseInstallation.js +1 -10
  95. package/lib/node/ParseLiveQuery.js +10 -36
  96. package/lib/node/ParseObject.js +193 -939
  97. package/lib/node/ParseOp.js +31 -255
  98. package/lib/node/ParsePolygon.js +12 -62
  99. package/lib/node/ParseQuery.js +170 -882
  100. package/lib/node/ParseRelation.js +11 -61
  101. package/lib/node/ParseRole.js +10 -57
  102. package/lib/node/ParseSchema.js +46 -222
  103. package/lib/node/ParseSession.js +8 -50
  104. package/lib/node/ParseUser.js +107 -576
  105. package/lib/node/Push.js +4 -37
  106. package/lib/node/RESTController.js +8 -110
  107. package/lib/node/SingleInstanceStateController.js +17 -130
  108. package/lib/node/Socket.weapp.js +2 -9
  109. package/lib/node/Storage.js +10 -83
  110. package/lib/node/StorageController.browser.js +4 -23
  111. package/lib/node/StorageController.default.js +5 -21
  112. package/lib/node/StorageController.react-native.js +6 -40
  113. package/lib/node/StorageController.weapp.js +6 -21
  114. package/lib/node/TaskQueue.js +1 -17
  115. package/lib/node/UniqueInstanceStateController.js +16 -133
  116. package/lib/node/Xhr.weapp.js +0 -15
  117. package/lib/node/arrayContainsObject.js +1 -12
  118. package/lib/node/canBeSerialized.js +2 -28
  119. package/lib/node/decode.js +1 -26
  120. package/lib/node/encode.js +3 -54
  121. package/lib/node/equals.js +0 -18
  122. package/lib/node/escape.js +1 -6
  123. package/lib/node/isRevocableSession.js +1 -5
  124. package/lib/node/parseDate.js +1 -7
  125. package/lib/node/promiseUtils.js +2 -14
  126. package/lib/node/unique.js +1 -11
  127. package/lib/node/unsavedChildren.js +2 -38
  128. package/lib/node/uuid.js +6 -1
  129. package/lib/react-native/Analytics.js +0 -9
  130. package/lib/react-native/AnonymousUtils.js +0 -10
  131. package/lib/react-native/Cloud.js +0 -26
  132. package/lib/react-native/CoreManager.js +1 -5
  133. package/lib/react-native/CryptoController.js +0 -2
  134. package/lib/react-native/EventEmitter.js +0 -2
  135. package/lib/react-native/EventuallyQueue.js +4 -52
  136. package/lib/react-native/FacebookUtils.js +0 -22
  137. package/lib/react-native/IndexedDBStorageController.js +0 -1
  138. package/lib/react-native/InstallationController.js +0 -6
  139. package/lib/react-native/LiveQueryClient.js +24 -101
  140. package/lib/react-native/LiveQuerySubscription.js +3 -27
  141. package/lib/react-native/LocalDatastore.js +6 -113
  142. package/lib/react-native/LocalDatastoreController.js +0 -21
  143. package/lib/react-native/LocalDatastoreController.react-native.js +4 -31
  144. package/lib/react-native/LocalDatastoreUtils.js +0 -1
  145. package/lib/react-native/ObjectStateMutations.js +0 -34
  146. package/lib/react-native/OfflineQuery.js +2 -137
  147. package/lib/react-native/Parse.js +0 -65
  148. package/lib/react-native/ParseACL.js +0 -44
  149. package/lib/react-native/ParseCLP.js +32 -96
  150. package/lib/react-native/ParseConfig.js +0 -42
  151. package/lib/react-native/ParseError.js +1 -21
  152. package/lib/react-native/ParseFile.js +4 -72
  153. package/lib/react-native/ParseGeoPoint.js +0 -17
  154. package/lib/react-native/ParseHooks.js +0 -30
  155. package/lib/react-native/ParseInstallation.js +1 -23
  156. package/lib/react-native/ParseLiveQuery.js +3 -25
  157. package/lib/react-native/ParseObject.js +4 -371
  158. package/lib/react-native/ParseOp.js +1 -138
  159. package/lib/react-native/ParsePolygon.js +0 -24
  160. package/lib/react-native/ParseQuery.js +6 -262
  161. package/lib/react-native/ParseRelation.js +0 -25
  162. package/lib/react-native/ParseRole.js +1 -36
  163. package/lib/react-native/ParseSchema.js +0 -51
  164. package/lib/react-native/ParseSession.js +1 -40
  165. package/lib/react-native/ParseUser.js +1 -224
  166. package/lib/react-native/Push.js +0 -16
  167. package/lib/react-native/RESTController.js +1 -70
  168. package/lib/react-native/SingleInstanceStateController.js +0 -44
  169. package/lib/react-native/Socket.weapp.js +2 -12
  170. package/lib/react-native/Storage.js +0 -24
  171. package/lib/react-native/StorageController.browser.js +0 -2
  172. package/lib/react-native/StorageController.default.js +0 -1
  173. package/lib/react-native/StorageController.react-native.js +0 -2
  174. package/lib/react-native/TaskQueue.js +0 -15
  175. package/lib/react-native/UniqueInstanceStateController.js +0 -47
  176. package/lib/react-native/Xhr.weapp.js +0 -16
  177. package/lib/react-native/arrayContainsObject.js +0 -5
  178. package/lib/react-native/canBeSerialized.js +0 -18
  179. package/lib/react-native/decode.js +0 -21
  180. package/lib/react-native/encode.js +0 -25
  181. package/lib/react-native/equals.js +0 -18
  182. package/lib/react-native/escape.js +0 -1
  183. package/lib/react-native/isRevocableSession.js +0 -1
  184. package/lib/react-native/parseDate.js +0 -3
  185. package/lib/react-native/promiseUtils.js +0 -13
  186. package/lib/react-native/unique.js +0 -4
  187. package/lib/react-native/unsavedChildren.js +0 -21
  188. package/lib/react-native/uuid.js +3 -1
  189. package/lib/weapp/Analytics.js +2 -20
  190. package/lib/weapp/AnonymousUtils.js +6 -35
  191. package/lib/weapp/Cloud.js +12 -70
  192. package/lib/weapp/CloudCode.js +0 -3
  193. package/lib/weapp/CoreManager.js +46 -184
  194. package/lib/weapp/CryptoController.js +2 -16
  195. package/lib/weapp/EventEmitter.js +1 -1
  196. package/lib/weapp/EventuallyQueue.js +277 -824
  197. package/lib/weapp/FacebookUtils.js +6 -35
  198. package/lib/weapp/IndexedDBStorageController.js +3 -14
  199. package/lib/weapp/InstallationController.js +2 -13
  200. package/lib/weapp/LiveQueryClient.js +87 -204
  201. package/lib/weapp/LiveQuerySubscription.js +10 -39
  202. package/lib/weapp/LocalDatastore.js +451 -1081
  203. package/lib/weapp/LocalDatastoreController.js +145 -602
  204. package/lib/weapp/LocalDatastoreController.react-native.js +137 -573
  205. package/lib/weapp/LocalDatastoreUtils.js +2 -12
  206. package/lib/weapp/ObjectStateMutations.js +18 -121
  207. package/lib/weapp/OfflineQuery.js +42 -222
  208. package/lib/weapp/Parse.js +12 -106
  209. package/lib/weapp/ParseACL.js +33 -141
  210. package/lib/weapp/ParseCLP.js +96 -314
  211. package/lib/weapp/ParseConfig.js +18 -88
  212. package/lib/weapp/ParseError.js +63 -90
  213. package/lib/weapp/ParseFile.js +130 -686
  214. package/lib/weapp/ParseGeoPoint.js +23 -82
  215. package/lib/weapp/ParseHooks.js +1 -34
  216. package/lib/weapp/ParseInstallation.js +4 -32
  217. package/lib/weapp/ParseLiveQuery.js +96 -505
  218. package/lib/weapp/ParseObject.js +628 -1840
  219. package/lib/weapp/ParseOp.js +41 -287
  220. package/lib/weapp/ParsePolygon.js +13 -63
  221. package/lib/weapp/ParseQuery.js +404 -1505
  222. package/lib/weapp/ParseRelation.js +12 -61
  223. package/lib/weapp/ParseRole.js +13 -75
  224. package/lib/weapp/ParseSchema.js +49 -201
  225. package/lib/weapp/ParseSession.js +11 -69
  226. package/lib/weapp/ParseUser.js +274 -1127
  227. package/lib/weapp/Push.js +7 -43
  228. package/lib/weapp/RESTController.js +18 -140
  229. package/lib/weapp/SingleInstanceStateController.js +19 -137
  230. package/lib/weapp/Socket.weapp.js +2 -12
  231. package/lib/weapp/Storage.js +10 -73
  232. package/lib/weapp/StorageController.browser.js +4 -17
  233. package/lib/weapp/StorageController.default.js +4 -17
  234. package/lib/weapp/StorageController.react-native.js +6 -33
  235. package/lib/weapp/StorageController.weapp.js +5 -16
  236. package/lib/weapp/TaskQueue.js +1 -22
  237. package/lib/weapp/UniqueInstanceStateController.js +19 -142
  238. package/lib/weapp/Xhr.weapp.js +0 -17
  239. package/lib/weapp/arrayContainsObject.js +2 -16
  240. package/lib/weapp/canBeSerialized.js +3 -33
  241. package/lib/weapp/decode.js +3 -33
  242. package/lib/weapp/encode.js +9 -70
  243. package/lib/weapp/equals.js +2 -25
  244. package/lib/weapp/escape.js +1 -8
  245. package/lib/weapp/isRevocableSession.js +2 -11
  246. package/lib/weapp/parseDate.js +2 -13
  247. package/lib/weapp/promiseUtils.js +3 -21
  248. package/lib/weapp/unique.js +3 -17
  249. package/lib/weapp/unsavedChildren.js +6 -50
  250. package/lib/weapp/uuid.js +1 -6
  251. package/package.json +45 -43
@@ -1,473 +1,64 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
-
5
- var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
6
-
7
- var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
8
-
9
- var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
10
-
11
- var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
12
-
13
- var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
14
-
15
3
  var _Object$keys2 = require("@babel/runtime-corejs3/core-js-stable/object/keys");
16
-
17
- var _sliceInstanceProperty2 = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
18
-
19
- var _reverseInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/reverse");
20
-
21
- var _Promise2 = require("@babel/runtime-corejs3/core-js-stable/promise");
22
-
23
- var _Object$setPrototypeOf = require("@babel/runtime-corejs3/core-js-stable/object/set-prototype-of");
24
-
25
- var _typeof3 = require("@babel/runtime-corejs3/helpers/typeof");
26
-
4
+ var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
5
+ var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
6
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
27
7
  var _forEachInstanceProperty2 = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
28
-
29
- var _Object$getPrototypeOf = require("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of");
30
-
31
- var _Object$create = require("@babel/runtime-corejs3/core-js-stable/object/create");
32
-
8
+ var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
9
+ var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
33
10
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
34
-
35
- var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
36
-
11
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
37
12
  _Object$defineProperty(exports, "__esModule", {
38
13
  value: true
39
14
  });
40
-
41
15
  exports.default = void 0;
42
-
16
+ var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
17
+ var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
18
+ var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
19
+ var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
20
+ var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
21
+ var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
43
22
  var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
44
-
45
23
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
46
-
47
- var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
48
-
49
- var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
50
-
51
- var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
52
-
53
24
  var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
54
-
55
25
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
56
-
57
- var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
58
-
59
- var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
60
-
61
26
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
62
-
63
27
  var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
64
-
65
28
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
66
-
67
29
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
68
-
69
30
  function ownKeys(object, enumerableOnly) {
70
31
  var keys = _Object$keys2(object);
71
-
72
32
  if (_Object$getOwnPropertySymbols) {
73
33
  var symbols = _Object$getOwnPropertySymbols(object);
74
-
75
34
  enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
76
35
  return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
77
36
  })), keys.push.apply(keys, symbols);
78
37
  }
79
-
80
38
  return keys;
81
39
  }
82
-
83
40
  function _objectSpread(target) {
84
41
  for (var i = 1; i < arguments.length; i++) {
85
- var _context10, _context11;
86
-
42
+ var _context8, _context9;
87
43
  var source = null != arguments[i] ? arguments[i] : {};
88
- i % 2 ? _forEachInstanceProperty2(_context10 = ownKeys(Object(source), !0)).call(_context10, function (key) {
44
+ i % 2 ? _forEachInstanceProperty2(_context8 = ownKeys(Object(source), !0)).call(_context8, function (key) {
89
45
  (0, _defineProperty2.default)(target, key, source[key]);
90
- }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context11 = ownKeys(Object(source))).call(_context11, function (key) {
46
+ }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context9 = ownKeys(Object(source))).call(_context9, function (key) {
91
47
  _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
92
48
  });
93
49
  }
94
-
95
50
  return target;
96
51
  }
97
-
98
- function _regeneratorRuntime() {
99
- "use strict";
100
- /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
101
-
102
- _regeneratorRuntime = function () {
103
- return exports;
104
- };
105
-
106
- var exports = {},
107
- Op = Object.prototype,
108
- hasOwn = Op.hasOwnProperty,
109
- $Symbol = "function" == typeof _Symbol ? _Symbol : {},
110
- iteratorSymbol = $Symbol.iterator || "@@iterator",
111
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
112
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
113
-
114
- function define(obj, key, value) {
115
- return _Object$defineProperty(obj, key, {
116
- value: value,
117
- enumerable: !0,
118
- configurable: !0,
119
- writable: !0
120
- }), obj[key];
121
- }
122
-
123
- try {
124
- define({}, "");
125
- } catch (err) {
126
- define = function (obj, key, value) {
127
- return obj[key] = value;
128
- };
129
- }
130
-
131
- function wrap(innerFn, outerFn, self, tryLocsList) {
132
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
133
- generator = _Object$create(protoGenerator.prototype),
134
- context = new Context(tryLocsList || []);
135
-
136
- return generator._invoke = function (innerFn, self, context) {
137
- var state = "suspendedStart";
138
- return function (method, arg) {
139
- if ("executing" === state) throw new Error("Generator is already running");
140
-
141
- if ("completed" === state) {
142
- if ("throw" === method) throw arg;
143
- return doneResult();
144
- }
145
-
146
- for (context.method = method, context.arg = arg;;) {
147
- var delegate = context.delegate;
148
-
149
- if (delegate) {
150
- var delegateResult = maybeInvokeDelegate(delegate, context);
151
-
152
- if (delegateResult) {
153
- if (delegateResult === ContinueSentinel) continue;
154
- return delegateResult;
155
- }
156
- }
157
-
158
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
159
- if ("suspendedStart" === state) throw state = "completed", context.arg;
160
- context.dispatchException(context.arg);
161
- } else "return" === context.method && context.abrupt("return", context.arg);
162
- state = "executing";
163
- var record = tryCatch(innerFn, self, context);
164
-
165
- if ("normal" === record.type) {
166
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
167
- return {
168
- value: record.arg,
169
- done: context.done
170
- };
171
- }
172
-
173
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
174
- }
175
- };
176
- }(innerFn, self, context), generator;
177
- }
178
-
179
- function tryCatch(fn, obj, arg) {
180
- try {
181
- return {
182
- type: "normal",
183
- arg: fn.call(obj, arg)
184
- };
185
- } catch (err) {
186
- return {
187
- type: "throw",
188
- arg: err
189
- };
190
- }
191
- }
192
-
193
- exports.wrap = wrap;
194
- var ContinueSentinel = {};
195
-
196
- function Generator() {}
197
-
198
- function GeneratorFunction() {}
199
-
200
- function GeneratorFunctionPrototype() {}
201
-
202
- var IteratorPrototype = {};
203
- define(IteratorPrototype, iteratorSymbol, function () {
204
- return this;
205
- });
206
- var getProto = _Object$getPrototypeOf,
207
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
208
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
209
-
210
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype);
211
-
212
- function defineIteratorMethods(prototype) {
213
- var _context8;
214
-
215
- _forEachInstanceProperty2(_context8 = ["next", "throw", "return"]).call(_context8, function (method) {
216
- define(prototype, method, function (arg) {
217
- return this._invoke(method, arg);
218
- });
219
- });
220
- }
221
-
222
- function AsyncIterator(generator, PromiseImpl) {
223
- function invoke(method, arg, resolve, reject) {
224
- var record = tryCatch(generator[method], generator, arg);
225
-
226
- if ("throw" !== record.type) {
227
- var result = record.arg,
228
- value = result.value;
229
- return value && "object" == _typeof3(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
230
- invoke("next", value, resolve, reject);
231
- }, function (err) {
232
- invoke("throw", err, resolve, reject);
233
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
234
- result.value = unwrapped, resolve(result);
235
- }, function (error) {
236
- return invoke("throw", error, resolve, reject);
237
- });
238
- }
239
-
240
- reject(record.arg);
241
- }
242
-
243
- var previousPromise;
244
-
245
- this._invoke = function (method, arg) {
246
- function callInvokeWithMethodAndArg() {
247
- return new PromiseImpl(function (resolve, reject) {
248
- invoke(method, arg, resolve, reject);
249
- });
250
- }
251
-
252
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
253
- };
254
- }
255
-
256
- function maybeInvokeDelegate(delegate, context) {
257
- var method = delegate.iterator[context.method];
258
-
259
- if (undefined === method) {
260
- if (context.delegate = null, "throw" === context.method) {
261
- if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
262
- context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
263
- }
264
-
265
- return ContinueSentinel;
266
- }
267
-
268
- var record = tryCatch(method, delegate.iterator, context.arg);
269
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
270
- var info = record.arg;
271
- 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);
272
- }
273
-
274
- function pushTryEntry(locs) {
275
- var entry = {
276
- tryLoc: locs[0]
277
- };
278
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
279
- }
280
-
281
- function resetTryEntry(entry) {
282
- var record = entry.completion || {};
283
- record.type = "normal", delete record.arg, entry.completion = record;
284
- }
285
-
286
- function Context(tryLocsList) {
287
- this.tryEntries = [{
288
- tryLoc: "root"
289
- }], _forEachInstanceProperty2(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0);
290
- }
291
-
292
- function values(iterable) {
293
- if (iterable) {
294
- var iteratorMethod = iterable[iteratorSymbol];
295
- if (iteratorMethod) return iteratorMethod.call(iterable);
296
- if ("function" == typeof iterable.next) return iterable;
297
-
298
- if (!isNaN(iterable.length)) {
299
- var i = -1,
300
- next = function next() {
301
- for (; ++i < iterable.length;) {
302
- if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
303
- }
304
-
305
- return next.value = undefined, next.done = !0, next;
306
- };
307
-
308
- return next.next = next;
309
- }
310
- }
311
-
312
- return {
313
- next: doneResult
314
- };
315
- }
316
-
317
- function doneResult() {
318
- return {
319
- value: undefined,
320
- done: !0
321
- };
322
- }
323
-
324
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
325
- var ctor = "function" == typeof genFun && genFun.constructor;
326
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
327
- }, exports.mark = function (genFun) {
328
- return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun;
329
- }, exports.awrap = function (arg) {
330
- return {
331
- __await: arg
332
- };
333
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
334
- return this;
335
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
336
- void 0 === PromiseImpl && (PromiseImpl = _Promise2);
337
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
338
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
339
- return result.done ? result.value : iter.next();
340
- });
341
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
342
- return this;
343
- }), define(Gp, "toString", function () {
344
- return "[object Generator]";
345
- }), exports.keys = function (object) {
346
- var keys = [];
347
-
348
- for (var key in object) {
349
- keys.push(key);
350
- }
351
-
352
- return _reverseInstanceProperty(keys).call(keys), function next() {
353
- for (; keys.length;) {
354
- var key = keys.pop();
355
- if (key in object) return next.value = key, next.done = !1, next;
356
- }
357
-
358
- return next.done = !0, next;
359
- };
360
- }, exports.values = values, Context.prototype = {
361
- constructor: Context,
362
- reset: function (skipTempReset) {
363
- var _context9;
364
-
365
- if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty2(_context9 = this.tryEntries).call(_context9, resetTryEntry), !skipTempReset) for (var name in this) {
366
- "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty2(name).call(name, 1)) && (this[name] = undefined);
367
- }
368
- },
369
- stop: function () {
370
- this.done = !0;
371
- var rootRecord = this.tryEntries[0].completion;
372
- if ("throw" === rootRecord.type) throw rootRecord.arg;
373
- return this.rval;
374
- },
375
- dispatchException: function (exception) {
376
- if (this.done) throw exception;
377
- var context = this;
378
-
379
- function handle(loc, caught) {
380
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
381
- }
382
-
383
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
384
- var entry = this.tryEntries[i],
385
- record = entry.completion;
386
- if ("root" === entry.tryLoc) return handle("end");
387
-
388
- if (entry.tryLoc <= this.prev) {
389
- var hasCatch = hasOwn.call(entry, "catchLoc"),
390
- hasFinally = hasOwn.call(entry, "finallyLoc");
391
-
392
- if (hasCatch && hasFinally) {
393
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
394
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
395
- } else if (hasCatch) {
396
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
397
- } else {
398
- if (!hasFinally) throw new Error("try statement without catch or finally");
399
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
400
- }
401
- }
402
- }
403
- },
404
- abrupt: function (type, arg) {
405
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
406
- var entry = this.tryEntries[i];
407
-
408
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
409
- var finallyEntry = entry;
410
- break;
411
- }
412
- }
413
-
414
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
415
- var record = finallyEntry ? finallyEntry.completion : {};
416
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
417
- },
418
- complete: function (record, afterLoc) {
419
- if ("throw" === record.type) throw record.arg;
420
- 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;
421
- },
422
- finish: function (finallyLoc) {
423
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
424
- var entry = this.tryEntries[i];
425
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
426
- }
427
- },
428
- catch: function (tryLoc) {
429
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
430
- var entry = this.tryEntries[i];
431
-
432
- if (entry.tryLoc === tryLoc) {
433
- var record = entry.completion;
434
-
435
- if ("throw" === record.type) {
436
- var thrown = record.arg;
437
- resetTryEntry(entry);
438
- }
439
-
440
- return thrown;
441
- }
442
- }
443
-
444
- throw new Error("illegal catch attempt");
445
- },
446
- delegateYield: function (iterable, resultName, nextLoc) {
447
- return this.delegate = {
448
- iterator: values(iterable),
449
- resultName: resultName,
450
- nextLoc: nextLoc
451
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
452
- }
453
- }, exports;
454
- }
455
-
456
52
  var ParseError = require('./ParseError').default;
457
-
458
53
  var XHR = null;
459
-
460
54
  if (typeof XMLHttpRequest !== 'undefined') {
461
55
  XHR = XMLHttpRequest;
462
56
  }
463
-
464
57
  XHR = require('./Xhr.weapp');
465
- /*:: type Base64 = { base64: string };*/
466
58
 
59
+ /*:: type Base64 = { base64: string };*/
467
60
  /*:: type Uri = { uri: string };*/
468
-
469
61
  /*:: type FileData = Array<number> | Base64 | Blob | Uri;*/
470
-
471
62
  /*:: export type FileSource =
472
63
  | {
473
64
  format: 'file',
@@ -484,42 +75,31 @@ XHR = require('./Xhr.weapp');
484
75
  uri: string,
485
76
  type: string,
486
77
  };*/
487
-
488
- function b64Digit(number
489
- /*: number*/
490
- )
491
- /*: string*/
492
- {
78
+ function b64Digit(number /*: number*/) /*: string*/{
493
79
  if (number < 26) {
494
80
  return String.fromCharCode(65 + number);
495
81
  }
496
-
497
82
  if (number < 52) {
498
83
  return String.fromCharCode(97 + (number - 26));
499
84
  }
500
-
501
85
  if (number < 62) {
502
86
  return String.fromCharCode(48 + (number - 52));
503
87
  }
504
-
505
88
  if (number === 62) {
506
89
  return '+';
507
90
  }
508
-
509
91
  if (number === 63) {
510
92
  return '/';
511
93
  }
512
-
513
94
  throw new TypeError('Tried to encode large digit ' + number + ' in base64.');
514
95
  }
96
+
515
97
  /**
516
98
  * A Parse.File is a local representation of a file that is saved to the Parse
517
99
  * cloud.
518
100
  *
519
101
  * @alias Parse.File
520
102
  */
521
-
522
-
523
103
  var ParseFile = /*#__PURE__*/function () {
524
104
  /**
525
105
  * @param name {String} The file's name. This will be prefixed by a unique
@@ -551,17 +131,7 @@ var ParseFile = /*#__PURE__*/function () {
551
131
  * @param metadata {Object} Optional key value pairs to be stored with file object
552
132
  * @param tags {Object} Optional key value pairs to be stored with file object
553
133
  */
554
- function ParseFile(name
555
- /*: string*/
556
- , data
557
- /*:: ?: FileData*/
558
- , type
559
- /*:: ?: string*/
560
- , metadata
561
- /*:: ?: Object*/
562
- , tags
563
- /*:: ?: Object*/
564
- ) {
134
+ function ParseFile(name /*: string*/, data /*:: ?: FileData*/, type /*:: ?: string*/, metadata /*:: ?: Object*/, tags /*:: ?: Object*/) {
565
135
  (0, _classCallCheck2.default)(this, ParseFile);
566
136
  (0, _defineProperty2.default)(this, "_name", void 0);
567
137
  (0, _defineProperty2.default)(this, "_url", void 0);
@@ -575,7 +145,6 @@ var ParseFile = /*#__PURE__*/function () {
575
145
  this._name = name;
576
146
  this._metadata = metadata || {};
577
147
  this._tags = tags || {};
578
-
579
148
  if (data !== undefined) {
580
149
  if ((0, _isArray.default)(data)) {
581
150
  this._data = ParseFile.encodeBase64(data);
@@ -598,7 +167,6 @@ var ParseFile = /*#__PURE__*/function () {
598
167
  };
599
168
  } else if (data && typeof data.base64 === 'string') {
600
169
  var _context, _context2, _context3;
601
-
602
170
  var base64 = (0, _slice.default)(_context = data.base64.split(',')).call(_context, -1)[0];
603
171
  var dataType = specifiedType || (0, _slice.default)(_context2 = (0, _slice.default)(_context3 = data.base64.split(';')).call(_context3, 0, 1)[0].split(':')).call(_context2, 1, 2)[0] || 'text/plain';
604
172
  this._data = base64;
@@ -612,6 +180,7 @@ var ParseFile = /*#__PURE__*/function () {
612
180
  }
613
181
  }
614
182
  }
183
+
615
184
  /**
616
185
  * Return the data for the file, downloading it if not already present.
617
186
  * Data is present if initialized with Byte Array, Base64 or Saved with Uri.
@@ -619,61 +188,48 @@ var ParseFile = /*#__PURE__*/function () {
619
188
  *
620
189
  * @returns {Promise} Promise that is resolve with base64 data
621
190
  */
622
-
623
-
624
191
  (0, _createClass2.default)(ParseFile, [{
625
192
  key: "getData",
626
193
  value: function () {
627
- var _getData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
194
+ var _getData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
628
195
  var _this = this;
629
-
630
196
  var options, controller, result;
631
- return _regeneratorRuntime().wrap(function (_context4) {
632
- while (1) {
633
- switch (_context4.prev = _context4.next) {
634
- case 0:
635
- if (!this._data) {
636
- _context4.next = 2;
637
- break;
638
- }
639
-
640
- return _context4.abrupt("return", this._data);
641
-
642
- case 2:
643
- if (this._url) {
644
- _context4.next = 4;
645
- break;
197
+ return _regenerator.default.wrap(function (_context4) {
198
+ while (1) switch (_context4.prev = _context4.next) {
199
+ case 0:
200
+ if (!this._data) {
201
+ _context4.next = 2;
202
+ break;
203
+ }
204
+ return _context4.abrupt("return", this._data);
205
+ case 2:
206
+ if (this._url) {
207
+ _context4.next = 4;
208
+ break;
209
+ }
210
+ throw new Error('Cannot retrieve data for unsaved ParseFile.');
211
+ case 4:
212
+ options = {
213
+ requestTask: function (task) {
214
+ return _this._requestTask = task;
646
215
  }
647
-
648
- throw new Error('Cannot retrieve data for unsaved ParseFile.');
649
-
650
- case 4:
651
- options = {
652
- requestTask: function (task) {
653
- return _this._requestTask = task;
654
- }
655
- };
656
- controller = _CoreManager.default.getFileController();
657
- _context4.next = 8;
658
- return controller.download(this._url, options);
659
-
660
- case 8:
661
- result = _context4.sent;
662
- this._data = result.base64;
663
- return _context4.abrupt("return", this._data);
664
-
665
- case 11:
666
- case "end":
667
- return _context4.stop();
668
- }
216
+ };
217
+ controller = _CoreManager.default.getFileController();
218
+ _context4.next = 8;
219
+ return controller.download(this._url, options);
220
+ case 8:
221
+ result = _context4.sent;
222
+ this._data = result.base64;
223
+ return _context4.abrupt("return", this._data);
224
+ case 11:
225
+ case "end":
226
+ return _context4.stop();
669
227
  }
670
228
  }, _callee, this);
671
229
  }));
672
-
673
230
  function getData() {
674
231
  return _getData.apply(this, arguments);
675
232
  }
676
-
677
233
  return getData;
678
234
  }()
679
235
  /**
@@ -683,72 +239,60 @@ var ParseFile = /*#__PURE__*/function () {
683
239
  *
684
240
  * @returns {string}
685
241
  */
686
-
687
242
  }, {
688
243
  key: "name",
689
- value: function ()
690
- /*: string*/
691
- {
244
+ value: function () /*: string*/{
692
245
  return this._name;
693
246
  }
247
+
694
248
  /**
695
249
  * Gets the url of the file. It is only available after you save the file or
696
250
  * after you get the file from a Parse.Object.
697
251
  *
698
252
  * @param {object} options An object to specify url options
699
- * @returns {string}
253
+ * @returns {string | undefined}
700
254
  */
701
-
702
255
  }, {
703
256
  key: "url",
704
- value: function (options
705
- /*:: ?: { forceSecure?: boolean }*/
706
- )
707
- /*: ?string*/
708
- {
257
+ value: function (options /*:: ?: { forceSecure?: boolean }*/) /*: ?string*/{
709
258
  options = options || {};
710
-
711
259
  if (!this._url) {
712
260
  return;
713
261
  }
714
-
715
262
  if (options.forceSecure) {
716
263
  return this._url.replace(/^http:\/\//i, 'https://');
717
264
  } else {
718
265
  return this._url;
719
266
  }
720
267
  }
268
+
721
269
  /**
722
270
  * Gets the metadata of the file.
723
271
  *
724
272
  * @returns {object}
725
273
  */
726
-
727
274
  }, {
728
275
  key: "metadata",
729
- value: function ()
730
- /*: Object*/
731
- {
276
+ value: function () /*: Object*/{
732
277
  return this._metadata;
733
278
  }
279
+
734
280
  /**
735
281
  * Gets the tags of the file.
736
282
  *
737
283
  * @returns {object}
738
284
  */
739
-
740
285
  }, {
741
286
  key: "tags",
742
- value: function ()
743
- /*: Object*/
744
- {
287
+ value: function () /*: Object*/{
745
288
  return this._tags;
746
289
  }
290
+
747
291
  /**
748
292
  * Saves the file to the Parse cloud.
749
293
  *
750
294
  * @param {object} options
751
- * * Valid options are:<ul>
295
+ * Valid options are:<ul>
752
296
  * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
753
297
  * be used for this request.
754
298
  * <li>sessionToken: A valid session token, used for making a request on
@@ -765,27 +309,19 @@ var ParseFile = /*#__PURE__*/function () {
765
309
  * });
766
310
  * </pre>
767
311
  * </ul>
768
- * @returns {Promise} Promise that is resolved when the save finishes.
312
+ * @returns {Promise | undefined} Promise that is resolved when the save finishes.
769
313
  */
770
-
771
314
  }, {
772
315
  key: "save",
773
- value: function (options
774
- /*:: ?: FullOptions*/
775
- ) {
316
+ value: function (options /*:: ?: FullOptions*/) /*: ?Promise*/{
776
317
  var _this2 = this;
777
-
778
318
  options = options || {};
779
-
780
319
  options.requestTask = function (task) {
781
320
  return _this2._requestTask = task;
782
321
  };
783
-
784
322
  options.metadata = this._metadata;
785
323
  options.tags = this._tags;
786
-
787
324
  var controller = _CoreManager.default.getFileController();
788
-
789
325
  if (!this._previousSave) {
790
326
  if (this._source.format === 'file') {
791
327
  this._previousSave = controller.saveFile(this._name, this._source, options).then(function (res) {
@@ -800,7 +336,6 @@ var ParseFile = /*#__PURE__*/function () {
800
336
  if (!(result && result.base64)) {
801
337
  return {};
802
338
  }
803
-
804
339
  var newSource = {
805
340
  format: 'base64',
806
341
  base64: result.base64,
@@ -824,59 +359,50 @@ var ParseFile = /*#__PURE__*/function () {
824
359
  });
825
360
  }
826
361
  }
827
-
828
362
  if (this._previousSave) {
829
363
  return this._previousSave;
830
364
  }
831
365
  }
366
+
832
367
  /**
833
368
  * Aborts the request if it has already been sent.
834
369
  */
835
-
836
370
  }, {
837
371
  key: "cancel",
838
372
  value: function () {
839
373
  if (this._requestTask && typeof this._requestTask.abort === 'function') {
374
+ this._requestTask._aborted = true;
840
375
  this._requestTask.abort();
841
376
  }
842
-
843
377
  this._requestTask = null;
844
378
  }
379
+
845
380
  /**
846
381
  * Deletes the file from the Parse cloud.
847
382
  * In Cloud Code and Node only with Master Key.
848
383
  *
849
384
  * @param {object} options
850
- * * Valid options are:<ul>
385
+ * Valid options are:<ul>
851
386
  * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
852
387
  * be used for this request.
853
388
  * <pre>
854
389
  * @returns {Promise} Promise that is resolved when the delete finishes.
855
390
  */
856
-
857
391
  }, {
858
392
  key: "destroy",
859
393
  value: function () {
860
394
  var _this3 = this;
861
-
862
- var options
863
- /*:: ?: FullOptions*/
864
- = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
865
-
395
+ var options /*:: ?: FullOptions*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
866
396
  if (!this._name) {
867
397
  throw new ParseError(ParseError.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.');
868
398
  }
869
-
870
399
  var destroyOptions = {
871
400
  useMasterKey: true
872
401
  };
873
-
874
402
  if (options.hasOwnProperty('useMasterKey')) {
875
403
  destroyOptions.useMasterKey = options.useMasterKey;
876
404
  }
877
-
878
405
  var controller = _CoreManager.default.getFileController();
879
-
880
406
  return controller.deleteFile(this._name, destroyOptions).then(function () {
881
407
  _this3._data = null;
882
408
  _this3._requestTask = null;
@@ -885,9 +411,7 @@ var ParseFile = /*#__PURE__*/function () {
885
411
  }
886
412
  }, {
887
413
  key: "toJSON",
888
- value: function ()
889
- /*: { name: ?string, url: ?string }*/
890
- {
414
+ value: function () /*: { name: ?string, url: ?string }*/{
891
415
  return {
892
416
  __type: 'File',
893
417
  name: this._name,
@@ -896,119 +420,90 @@ var ParseFile = /*#__PURE__*/function () {
896
420
  }
897
421
  }, {
898
422
  key: "equals",
899
- value: function (other
900
- /*: mixed*/
901
- )
902
- /*: boolean*/
903
- {
423
+ value: function (other /*: mixed*/) /*: boolean*/{
904
424
  if (this === other) {
905
425
  return true;
906
- } // Unsaved Files are never equal, since they will be saved to different URLs
907
-
908
-
426
+ }
427
+ // Unsaved Files are never equal, since they will be saved to different URLs
909
428
  return other instanceof ParseFile && this.name() === other.name() && this.url() === other.url() && typeof this.url() !== 'undefined';
910
429
  }
430
+
911
431
  /**
912
432
  * Sets metadata to be saved with file object. Overwrites existing metadata
913
433
  *
914
434
  * @param {object} metadata Key value pairs to be stored with file object
915
435
  */
916
-
917
436
  }, {
918
437
  key: "setMetadata",
919
- value: function (metadata
920
- /*: any*/
921
- ) {
438
+ value: function (metadata /*: any*/) {
922
439
  var _this4 = this;
923
-
924
440
  if (metadata && (0, _typeof2.default)(metadata) === 'object') {
925
441
  var _context5;
926
-
927
442
  (0, _forEach.default)(_context5 = (0, _keys.default)(metadata)).call(_context5, function (key) {
928
443
  _this4.addMetadata(key, metadata[key]);
929
444
  });
930
445
  }
931
446
  }
447
+
932
448
  /**
933
449
  * Sets metadata to be saved with file object. Adds to existing metadata.
934
450
  *
935
451
  * @param {string} key key to store the metadata
936
452
  * @param {*} value metadata
937
453
  */
938
-
939
454
  }, {
940
455
  key: "addMetadata",
941
- value: function (key
942
- /*: string*/
943
- , value
944
- /*: any*/
945
- ) {
456
+ value: function (key /*: string*/, value /*: any*/) {
946
457
  if (typeof key === 'string') {
947
458
  this._metadata[key] = value;
948
459
  }
949
460
  }
461
+
950
462
  /**
951
463
  * Sets tags to be saved with file object. Overwrites existing tags
952
464
  *
953
465
  * @param {object} tags Key value pairs to be stored with file object
954
466
  */
955
-
956
467
  }, {
957
468
  key: "setTags",
958
- value: function (tags
959
- /*: any*/
960
- ) {
469
+ value: function (tags /*: any*/) {
961
470
  var _this5 = this;
962
-
963
471
  if (tags && (0, _typeof2.default)(tags) === 'object') {
964
472
  var _context6;
965
-
966
473
  (0, _forEach.default)(_context6 = (0, _keys.default)(tags)).call(_context6, function (key) {
967
474
  _this5.addTag(key, tags[key]);
968
475
  });
969
476
  }
970
477
  }
478
+
971
479
  /**
972
480
  * Sets tags to be saved with file object. Adds to existing tags.
973
481
  *
974
482
  * @param {string} key key to store tags
975
483
  * @param {*} value tag
976
484
  */
977
-
978
485
  }, {
979
486
  key: "addTag",
980
- value: function (key
981
- /*: string*/
982
- , value
983
- /*: string*/
984
- ) {
487
+ value: function (key /*: string*/, value /*: string*/) {
985
488
  if (typeof key === 'string') {
986
489
  this._tags[key] = value;
987
490
  }
988
491
  }
989
492
  }], [{
990
493
  key: "fromJSON",
991
- value: function (obj)
992
- /*: ParseFile*/
993
- {
494
+ value: function (obj) /*: ParseFile*/{
994
495
  if (obj.__type !== 'File') {
995
496
  throw new TypeError('JSON object does not represent a ParseFile');
996
497
  }
997
-
998
498
  var file = new ParseFile(obj.name);
999
499
  file._url = obj.url;
1000
500
  return file;
1001
501
  }
1002
502
  }, {
1003
503
  key: "encodeBase64",
1004
- value: function (bytes
1005
- /*: Array<number>*/
1006
- )
1007
- /*: string*/
1008
- {
504
+ value: function (bytes /*: Array<number>*/) /*: string*/{
1009
505
  var chunks = [];
1010
506
  chunks.length = Math.ceil(bytes.length / 3);
1011
-
1012
507
  for (var i = 0; i < chunks.length; i++) {
1013
508
  var b1 = bytes[i * 3];
1014
509
  var b2 = bytes[i * 3 + 1] || 0;
@@ -1017,99 +512,68 @@ var ParseFile = /*#__PURE__*/function () {
1017
512
  var has3 = i * 3 + 2 < bytes.length;
1018
513
  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('');
1019
514
  }
1020
-
1021
515
  return chunks.join('');
1022
516
  }
1023
517
  }]);
1024
518
  return ParseFile;
1025
519
  }();
1026
-
1027
520
  var DefaultController = {
1028
521
  saveFile: function () {
1029
- var _saveFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(name
1030
- /*: string*/
1031
- , source
1032
- /*: FileSource*/
1033
- , options
1034
- /*:: ?: FullOptions*/
1035
- ) {
522
+ var _saveFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(name /*: string*/, source /*: FileSource*/, options /*:: ?: FullOptions*/) {
1036
523
  var base64Data, _base64Data$split, _base64Data$split2, first, second, data, newSource;
1037
-
1038
- return _regeneratorRuntime().wrap(function _callee2$(_context7) {
1039
- while (1) {
1040
- switch (_context7.prev = _context7.next) {
1041
- case 0:
1042
- if (!(source.format !== 'file')) {
1043
- _context7.next = 2;
1044
- break;
1045
- }
1046
-
1047
- throw new Error('saveFile can only be used with File-type sources.');
1048
-
1049
- case 2:
1050
- _context7.next = 4;
1051
- return new _promise.default(function (res, rej) {
1052
- // eslint-disable-next-line no-undef
1053
- var reader = new FileReader();
1054
-
1055
- reader.onload = function () {
1056
- return res(reader.result);
1057
- };
1058
-
1059
- reader.onerror = function (error) {
1060
- return rej(error);
1061
- };
1062
-
1063
- reader.readAsDataURL(source.file);
1064
- });
1065
-
1066
- case 4:
1067
- base64Data = _context7.sent; // we only want the data after the comma
1068
- // For example: "data:application/pdf;base64,JVBERi0xLjQKJ..." we would only want "JVBERi0xLjQKJ..."
1069
-
1070
- _base64Data$split = base64Data.split(','), _base64Data$split2 = (0, _slicedToArray2.default)(_base64Data$split, 2), first = _base64Data$split2[0], second = _base64Data$split2[1]; // in the event there is no 'data:application/pdf;base64,' at the beginning of the base64 string
1071
- // use the entire string instead
1072
-
1073
- data = second ? second : first;
1074
- newSource = {
1075
- format: 'base64',
1076
- base64: data,
1077
- type: source.type || (source.file ? source.file.type : null)
524
+ return _regenerator.default.wrap(function (_context7) {
525
+ while (1) switch (_context7.prev = _context7.next) {
526
+ case 0:
527
+ if (!(source.format !== 'file')) {
528
+ _context7.next = 2;
529
+ break;
530
+ }
531
+ throw new Error('saveFile can only be used with File-type sources.');
532
+ case 2:
533
+ _context7.next = 4;
534
+ return new _promise.default(function (res, rej) {
535
+ // eslint-disable-next-line no-undef
536
+ var reader = new FileReader();
537
+ reader.onload = function () {
538
+ return res(reader.result);
1078
539
  };
1079
- _context7.next = 10;
1080
- return DefaultController.saveBase64(name, newSource, options);
1081
-
1082
- case 10:
1083
- return _context7.abrupt("return", _context7.sent);
1084
-
1085
- case 11:
1086
- case "end":
1087
- return _context7.stop();
1088
- }
540
+ reader.onerror = function (error) {
541
+ return rej(error);
542
+ };
543
+ reader.readAsDataURL(source.file);
544
+ });
545
+ case 4:
546
+ base64Data = _context7.sent;
547
+ // we only want the data after the comma
548
+ // For example: "data:application/pdf;base64,JVBERi0xLjQKJ..." we would only want "JVBERi0xLjQKJ..."
549
+ _base64Data$split = base64Data.split(','), _base64Data$split2 = (0, _slicedToArray2.default)(_base64Data$split, 2), first = _base64Data$split2[0], second = _base64Data$split2[1]; // in the event there is no 'data:application/pdf;base64,' at the beginning of the base64 string
550
+ // use the entire string instead
551
+ data = second ? second : first;
552
+ newSource = {
553
+ format: 'base64',
554
+ base64: data,
555
+ type: source.type || (source.file ? source.file.type : null)
556
+ };
557
+ _context7.next = 10;
558
+ return DefaultController.saveBase64(name, newSource, options);
559
+ case 10:
560
+ return _context7.abrupt("return", _context7.sent);
561
+ case 11:
562
+ case "end":
563
+ return _context7.stop();
1089
564
  }
1090
565
  }, _callee2);
1091
566
  }));
1092
-
1093
- function saveFile(_x, _x2, _x3) {
567
+ function saveFile() {
1094
568
  return _saveFile.apply(this, arguments);
1095
569
  }
1096
-
1097
570
  return saveFile;
1098
571
  }(),
1099
- saveBase64: function saveBase64(name
1100
- /*: string*/
1101
- , source
1102
- /*: FileSource*/
1103
- , options
1104
- /*:: ?: FullOptions*/
1105
- ) {
572
+ saveBase64: function (name /*: string*/, source /*: FileSource*/, options /*:: ?: FullOptions*/) {
1106
573
  if (source.format !== 'base64') {
1107
574
  throw new Error('saveBase64 can only be used with Base64-type sources.');
1108
575
  }
1109
-
1110
- var data
1111
- /*: { base64: any, _ContentType?: any, fileData: Object }*/
1112
- = {
576
+ var data /*: { base64: any, _ContentType?: any, fileData: Object }*/ = {
1113
577
  base64: source.base64,
1114
578
  fileData: {
1115
579
  metadata: _objectSpread({}, options.metadata),
@@ -1118,70 +582,54 @@ var DefaultController = {
1118
582
  };
1119
583
  delete options.metadata;
1120
584
  delete options.tags;
1121
-
1122
585
  if (source.type) {
1123
586
  data._ContentType = source.type;
1124
587
  }
1125
-
1126
- var path = 'files/' + name;
1127
- return _CoreManager.default.getRESTController().request('POST', path, data, options);
588
+ return _CoreManager.default.getRESTController().request('POST', 'files/' + name, data, options);
1128
589
  },
1129
- download: function download(uri, options) {
590
+ download: function (uri, options) {
1130
591
  if (XHR) {
1131
592
  return this.downloadAjax(uri, options);
1132
593
  } else {
1133
594
  return _promise.default.reject('Cannot make a request: No definition of XMLHttpRequest was found.');
1134
595
  }
1135
596
  },
1136
- downloadAjax: function downloadAjax(uri, options) {
597
+ downloadAjax: function (uri, options) {
1137
598
  return new _promise.default(function (resolve, reject) {
1138
599
  var xhr = new XHR();
1139
600
  xhr.open('GET', uri, true);
1140
601
  xhr.responseType = 'arraybuffer';
1141
-
1142
602
  xhr.onerror = function (e) {
1143
603
  reject(e);
1144
604
  };
1145
-
1146
605
  xhr.onreadystatechange = function () {
1147
606
  if (xhr.readyState !== xhr.DONE) {
1148
607
  return;
1149
608
  }
1150
-
1151
609
  if (!this.response) {
1152
610
  return resolve({});
1153
611
  }
1154
-
1155
612
  var bytes = new Uint8Array(this.response);
1156
613
  resolve({
1157
614
  base64: ParseFile.encodeBase64(bytes),
1158
615
  contentType: xhr.getResponseHeader('content-type')
1159
616
  });
1160
617
  };
1161
-
1162
618
  options.requestTask(xhr);
1163
619
  xhr.send();
1164
620
  });
1165
621
  },
1166
- deleteFile: function deleteFile(name
1167
- /*: string*/
1168
- , options
1169
- /*:: ?: FullOptions*/
1170
- ) {
622
+ deleteFile: function (name /*: string*/, options /*:: ?: FullOptions*/) {
1171
623
  var headers = {
1172
624
  'X-Parse-Application-ID': _CoreManager.default.get('APPLICATION_ID')
1173
625
  };
1174
-
1175
626
  if (options.useMasterKey) {
1176
627
  headers['X-Parse-Master-Key'] = _CoreManager.default.get('MASTER_KEY');
1177
628
  }
1178
-
1179
629
  var url = _CoreManager.default.get('SERVER_URL');
1180
-
1181
630
  if (url[url.length - 1] !== '/') {
1182
631
  url += '/';
1183
632
  }
1184
-
1185
633
  url += 'files/' + name;
1186
634
  return _CoreManager.default.getRESTController().ajax('DELETE', url, '', headers).catch(function (response) {
1187
635
  // TODO: return JSON object in server
@@ -1192,18 +640,14 @@ var DefaultController = {
1192
640
  }
1193
641
  });
1194
642
  },
1195
- _setXHR: function _setXHR(xhr
1196
- /*: any*/
1197
- ) {
643
+ _setXHR: function (xhr /*: any*/) {
1198
644
  XHR = xhr;
1199
645
  },
1200
- _getXHR: function _getXHR() {
646
+ _getXHR: function () {
1201
647
  return XHR;
1202
648
  }
1203
649
  };
1204
-
1205
650
  _CoreManager.default.setFileController(DefaultController);
1206
-
1207
651
  var _default = ParseFile;
1208
652
  exports.default = _default;
1209
653
  exports.b64Digit = b64Digit;