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