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.
- package/dist/parse.js +17995 -26193
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +8739 -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 +129 -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 +50 -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 +4 -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 +130 -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,50 @@ 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') {
|
|
372
|
+
this._requestTask._aborted = true;
|
|
838
373
|
this._requestTask.abort();
|
|
839
374
|
}
|
|
840
|
-
|
|
841
375
|
this._requestTask = null;
|
|
842
376
|
}
|
|
377
|
+
|
|
843
378
|
/**
|
|
844
379
|
* Deletes the file from the Parse cloud.
|
|
845
380
|
* In Cloud Code and Node only with Master Key.
|
|
846
381
|
*
|
|
847
382
|
* @param {object} options
|
|
848
|
-
*
|
|
383
|
+
* Valid options are:<ul>
|
|
849
384
|
* <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
|
|
850
385
|
* be used for this request.
|
|
851
386
|
* <pre>
|
|
852
387
|
* @returns {Promise} Promise that is resolved when the delete finishes.
|
|
853
388
|
*/
|
|
854
|
-
|
|
855
389
|
}, {
|
|
856
390
|
key: "destroy",
|
|
857
391
|
value: function () {
|
|
858
392
|
var _this3 = this;
|
|
859
|
-
|
|
860
|
-
var options
|
|
861
|
-
/*:: ?: FullOptions*/
|
|
862
|
-
= arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
863
|
-
|
|
393
|
+
var options /*:: ?: FullOptions*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
864
394
|
if (!this._name) {
|
|
865
395
|
throw new ParseError(ParseError.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.');
|
|
866
396
|
}
|
|
867
|
-
|
|
868
397
|
var destroyOptions = {
|
|
869
398
|
useMasterKey: true
|
|
870
399
|
};
|
|
871
|
-
|
|
872
400
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
873
401
|
destroyOptions.useMasterKey = options.useMasterKey;
|
|
874
402
|
}
|
|
875
|
-
|
|
876
403
|
var controller = _CoreManager.default.getFileController();
|
|
877
|
-
|
|
878
404
|
return controller.deleteFile(this._name, destroyOptions).then(function () {
|
|
879
405
|
_this3._data = null;
|
|
880
406
|
_this3._requestTask = null;
|
|
@@ -883,9 +409,7 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
883
409
|
}
|
|
884
410
|
}, {
|
|
885
411
|
key: "toJSON",
|
|
886
|
-
value: function ()
|
|
887
|
-
/*: { name: ?string, url: ?string }*/
|
|
888
|
-
{
|
|
412
|
+
value: function () /*: { name: ?string, url: ?string }*/{
|
|
889
413
|
return {
|
|
890
414
|
__type: 'File',
|
|
891
415
|
name: this._name,
|
|
@@ -894,119 +418,90 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
894
418
|
}
|
|
895
419
|
}, {
|
|
896
420
|
key: "equals",
|
|
897
|
-
value: function (other
|
|
898
|
-
/*: mixed*/
|
|
899
|
-
)
|
|
900
|
-
/*: boolean*/
|
|
901
|
-
{
|
|
421
|
+
value: function (other /*: mixed*/) /*: boolean*/{
|
|
902
422
|
if (this === other) {
|
|
903
423
|
return true;
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
|
|
424
|
+
}
|
|
425
|
+
// Unsaved Files are never equal, since they will be saved to different URLs
|
|
907
426
|
return other instanceof ParseFile && this.name() === other.name() && this.url() === other.url() && typeof this.url() !== 'undefined';
|
|
908
427
|
}
|
|
428
|
+
|
|
909
429
|
/**
|
|
910
430
|
* Sets metadata to be saved with file object. Overwrites existing metadata
|
|
911
431
|
*
|
|
912
432
|
* @param {object} metadata Key value pairs to be stored with file object
|
|
913
433
|
*/
|
|
914
|
-
|
|
915
434
|
}, {
|
|
916
435
|
key: "setMetadata",
|
|
917
|
-
value: function (metadata
|
|
918
|
-
/*: any*/
|
|
919
|
-
) {
|
|
436
|
+
value: function (metadata /*: any*/) {
|
|
920
437
|
var _this4 = this;
|
|
921
|
-
|
|
922
438
|
if (metadata && (0, _typeof2.default)(metadata) === 'object') {
|
|
923
439
|
var _context5;
|
|
924
|
-
|
|
925
440
|
(0, _forEach.default)(_context5 = (0, _keys.default)(metadata)).call(_context5, function (key) {
|
|
926
441
|
_this4.addMetadata(key, metadata[key]);
|
|
927
442
|
});
|
|
928
443
|
}
|
|
929
444
|
}
|
|
445
|
+
|
|
930
446
|
/**
|
|
931
447
|
* Sets metadata to be saved with file object. Adds to existing metadata.
|
|
932
448
|
*
|
|
933
449
|
* @param {string} key key to store the metadata
|
|
934
450
|
* @param {*} value metadata
|
|
935
451
|
*/
|
|
936
|
-
|
|
937
452
|
}, {
|
|
938
453
|
key: "addMetadata",
|
|
939
|
-
value: function (key
|
|
940
|
-
/*: string*/
|
|
941
|
-
, value
|
|
942
|
-
/*: any*/
|
|
943
|
-
) {
|
|
454
|
+
value: function (key /*: string*/, value /*: any*/) {
|
|
944
455
|
if (typeof key === 'string') {
|
|
945
456
|
this._metadata[key] = value;
|
|
946
457
|
}
|
|
947
458
|
}
|
|
459
|
+
|
|
948
460
|
/**
|
|
949
461
|
* Sets tags to be saved with file object. Overwrites existing tags
|
|
950
462
|
*
|
|
951
463
|
* @param {object} tags Key value pairs to be stored with file object
|
|
952
464
|
*/
|
|
953
|
-
|
|
954
465
|
}, {
|
|
955
466
|
key: "setTags",
|
|
956
|
-
value: function (tags
|
|
957
|
-
/*: any*/
|
|
958
|
-
) {
|
|
467
|
+
value: function (tags /*: any*/) {
|
|
959
468
|
var _this5 = this;
|
|
960
|
-
|
|
961
469
|
if (tags && (0, _typeof2.default)(tags) === 'object') {
|
|
962
470
|
var _context6;
|
|
963
|
-
|
|
964
471
|
(0, _forEach.default)(_context6 = (0, _keys.default)(tags)).call(_context6, function (key) {
|
|
965
472
|
_this5.addTag(key, tags[key]);
|
|
966
473
|
});
|
|
967
474
|
}
|
|
968
475
|
}
|
|
476
|
+
|
|
969
477
|
/**
|
|
970
478
|
* Sets tags to be saved with file object. Adds to existing tags.
|
|
971
479
|
*
|
|
972
480
|
* @param {string} key key to store tags
|
|
973
481
|
* @param {*} value tag
|
|
974
482
|
*/
|
|
975
|
-
|
|
976
483
|
}, {
|
|
977
484
|
key: "addTag",
|
|
978
|
-
value: function (key
|
|
979
|
-
/*: string*/
|
|
980
|
-
, value
|
|
981
|
-
/*: string*/
|
|
982
|
-
) {
|
|
485
|
+
value: function (key /*: string*/, value /*: string*/) {
|
|
983
486
|
if (typeof key === 'string') {
|
|
984
487
|
this._tags[key] = value;
|
|
985
488
|
}
|
|
986
489
|
}
|
|
987
490
|
}], [{
|
|
988
491
|
key: "fromJSON",
|
|
989
|
-
value: function (obj)
|
|
990
|
-
/*: ParseFile*/
|
|
991
|
-
{
|
|
492
|
+
value: function (obj) /*: ParseFile*/{
|
|
992
493
|
if (obj.__type !== 'File') {
|
|
993
494
|
throw new TypeError('JSON object does not represent a ParseFile');
|
|
994
495
|
}
|
|
995
|
-
|
|
996
496
|
var file = new ParseFile(obj.name);
|
|
997
497
|
file._url = obj.url;
|
|
998
498
|
return file;
|
|
999
499
|
}
|
|
1000
500
|
}, {
|
|
1001
501
|
key: "encodeBase64",
|
|
1002
|
-
value: function (bytes
|
|
1003
|
-
/*: Array<number>*/
|
|
1004
|
-
)
|
|
1005
|
-
/*: string*/
|
|
1006
|
-
{
|
|
502
|
+
value: function (bytes /*: Array<number>*/) /*: string*/{
|
|
1007
503
|
var chunks = [];
|
|
1008
504
|
chunks.length = Math.ceil(bytes.length / 3);
|
|
1009
|
-
|
|
1010
505
|
for (var i = 0; i < chunks.length; i++) {
|
|
1011
506
|
var b1 = bytes[i * 3];
|
|
1012
507
|
var b2 = bytes[i * 3 + 1] || 0;
|
|
@@ -1015,99 +510,68 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
1015
510
|
var has3 = i * 3 + 2 < bytes.length;
|
|
1016
511
|
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
512
|
}
|
|
1018
|
-
|
|
1019
513
|
return chunks.join('');
|
|
1020
514
|
}
|
|
1021
515
|
}]);
|
|
1022
516
|
return ParseFile;
|
|
1023
517
|
}();
|
|
1024
|
-
|
|
1025
518
|
var DefaultController = {
|
|
1026
519
|
saveFile: function () {
|
|
1027
|
-
var _saveFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
1028
|
-
/*: string*/
|
|
1029
|
-
, source
|
|
1030
|
-
/*: FileSource*/
|
|
1031
|
-
, options
|
|
1032
|
-
/*:: ?: FullOptions*/
|
|
1033
|
-
) {
|
|
520
|
+
var _saveFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(name /*: string*/, source /*: FileSource*/, options /*:: ?: FullOptions*/) {
|
|
1034
521
|
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)
|
|
522
|
+
return _regenerator.default.wrap(function (_context7) {
|
|
523
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
524
|
+
case 0:
|
|
525
|
+
if (!(source.format !== 'file')) {
|
|
526
|
+
_context7.next = 2;
|
|
527
|
+
break;
|
|
528
|
+
}
|
|
529
|
+
throw new Error('saveFile can only be used with File-type sources.');
|
|
530
|
+
case 2:
|
|
531
|
+
_context7.next = 4;
|
|
532
|
+
return new _promise.default(function (res, rej) {
|
|
533
|
+
// eslint-disable-next-line no-undef
|
|
534
|
+
var reader = new FileReader();
|
|
535
|
+
reader.onload = function () {
|
|
536
|
+
return res(reader.result);
|
|
1076
537
|
};
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
538
|
+
reader.onerror = function (error) {
|
|
539
|
+
return rej(error);
|
|
540
|
+
};
|
|
541
|
+
reader.readAsDataURL(source.file);
|
|
542
|
+
});
|
|
543
|
+
case 4:
|
|
544
|
+
base64Data = _context7.sent;
|
|
545
|
+
// we only want the data after the comma
|
|
546
|
+
// For example: "data:application/pdf;base64,JVBERi0xLjQKJ..." we would only want "JVBERi0xLjQKJ..."
|
|
547
|
+
_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
|
|
548
|
+
// use the entire string instead
|
|
549
|
+
data = second ? second : first;
|
|
550
|
+
newSource = {
|
|
551
|
+
format: 'base64',
|
|
552
|
+
base64: data,
|
|
553
|
+
type: source.type || (source.file ? source.file.type : null)
|
|
554
|
+
};
|
|
555
|
+
_context7.next = 10;
|
|
556
|
+
return DefaultController.saveBase64(name, newSource, options);
|
|
557
|
+
case 10:
|
|
558
|
+
return _context7.abrupt("return", _context7.sent);
|
|
559
|
+
case 11:
|
|
560
|
+
case "end":
|
|
561
|
+
return _context7.stop();
|
|
1087
562
|
}
|
|
1088
563
|
}, _callee2);
|
|
1089
564
|
}));
|
|
1090
|
-
|
|
1091
|
-
function saveFile(_x, _x2, _x3) {
|
|
565
|
+
function saveFile() {
|
|
1092
566
|
return _saveFile.apply(this, arguments);
|
|
1093
567
|
}
|
|
1094
|
-
|
|
1095
568
|
return saveFile;
|
|
1096
569
|
}(),
|
|
1097
|
-
saveBase64: function
|
|
1098
|
-
/*: string*/
|
|
1099
|
-
, source
|
|
1100
|
-
/*: FileSource*/
|
|
1101
|
-
, options
|
|
1102
|
-
/*:: ?: FullOptions*/
|
|
1103
|
-
) {
|
|
570
|
+
saveBase64: function (name /*: string*/, source /*: FileSource*/, options /*:: ?: FullOptions*/) {
|
|
1104
571
|
if (source.format !== 'base64') {
|
|
1105
572
|
throw new Error('saveBase64 can only be used with Base64-type sources.');
|
|
1106
573
|
}
|
|
1107
|
-
|
|
1108
|
-
var data
|
|
1109
|
-
/*: { base64: any, _ContentType?: any, fileData: Object }*/
|
|
1110
|
-
= {
|
|
574
|
+
var data /*: { base64: any, _ContentType?: any, fileData: Object }*/ = {
|
|
1111
575
|
base64: source.base64,
|
|
1112
576
|
fileData: {
|
|
1113
577
|
metadata: _objectSpread({}, options.metadata),
|
|
@@ -1116,70 +580,54 @@ var DefaultController = {
|
|
|
1116
580
|
};
|
|
1117
581
|
delete options.metadata;
|
|
1118
582
|
delete options.tags;
|
|
1119
|
-
|
|
1120
583
|
if (source.type) {
|
|
1121
584
|
data._ContentType = source.type;
|
|
1122
585
|
}
|
|
1123
|
-
|
|
1124
|
-
var path = 'files/' + name;
|
|
1125
|
-
return _CoreManager.default.getRESTController().request('POST', path, data, options);
|
|
586
|
+
return _CoreManager.default.getRESTController().request('POST', 'files/' + name, data, options);
|
|
1126
587
|
},
|
|
1127
|
-
download: function
|
|
588
|
+
download: function (uri, options) {
|
|
1128
589
|
if (XHR) {
|
|
1129
590
|
return this.downloadAjax(uri, options);
|
|
1130
591
|
} else {
|
|
1131
592
|
return _promise.default.reject('Cannot make a request: No definition of XMLHttpRequest was found.');
|
|
1132
593
|
}
|
|
1133
594
|
},
|
|
1134
|
-
downloadAjax: function
|
|
595
|
+
downloadAjax: function (uri, options) {
|
|
1135
596
|
return new _promise.default(function (resolve, reject) {
|
|
1136
597
|
var xhr = new XHR();
|
|
1137
598
|
xhr.open('GET', uri, true);
|
|
1138
599
|
xhr.responseType = 'arraybuffer';
|
|
1139
|
-
|
|
1140
600
|
xhr.onerror = function (e) {
|
|
1141
601
|
reject(e);
|
|
1142
602
|
};
|
|
1143
|
-
|
|
1144
603
|
xhr.onreadystatechange = function () {
|
|
1145
604
|
if (xhr.readyState !== xhr.DONE) {
|
|
1146
605
|
return;
|
|
1147
606
|
}
|
|
1148
|
-
|
|
1149
607
|
if (!this.response) {
|
|
1150
608
|
return resolve({});
|
|
1151
609
|
}
|
|
1152
|
-
|
|
1153
610
|
var bytes = new Uint8Array(this.response);
|
|
1154
611
|
resolve({
|
|
1155
612
|
base64: ParseFile.encodeBase64(bytes),
|
|
1156
613
|
contentType: xhr.getResponseHeader('content-type')
|
|
1157
614
|
});
|
|
1158
615
|
};
|
|
1159
|
-
|
|
1160
616
|
options.requestTask(xhr);
|
|
1161
617
|
xhr.send();
|
|
1162
618
|
});
|
|
1163
619
|
},
|
|
1164
|
-
deleteFile: function
|
|
1165
|
-
/*: string*/
|
|
1166
|
-
, options
|
|
1167
|
-
/*:: ?: FullOptions*/
|
|
1168
|
-
) {
|
|
620
|
+
deleteFile: function (name /*: string*/, options /*:: ?: FullOptions*/) {
|
|
1169
621
|
var headers = {
|
|
1170
622
|
'X-Parse-Application-ID': _CoreManager.default.get('APPLICATION_ID')
|
|
1171
623
|
};
|
|
1172
|
-
|
|
1173
624
|
if (options.useMasterKey) {
|
|
1174
625
|
headers['X-Parse-Master-Key'] = _CoreManager.default.get('MASTER_KEY');
|
|
1175
626
|
}
|
|
1176
|
-
|
|
1177
627
|
var url = _CoreManager.default.get('SERVER_URL');
|
|
1178
|
-
|
|
1179
628
|
if (url[url.length - 1] !== '/') {
|
|
1180
629
|
url += '/';
|
|
1181
630
|
}
|
|
1182
|
-
|
|
1183
631
|
url += 'files/' + name;
|
|
1184
632
|
return _CoreManager.default.getRESTController().ajax('DELETE', url, '', headers).catch(function (response) {
|
|
1185
633
|
// TODO: return JSON object in server
|
|
@@ -1190,18 +638,14 @@ var DefaultController = {
|
|
|
1190
638
|
}
|
|
1191
639
|
});
|
|
1192
640
|
},
|
|
1193
|
-
_setXHR: function
|
|
1194
|
-
/*: any*/
|
|
1195
|
-
) {
|
|
641
|
+
_setXHR: function (xhr /*: any*/) {
|
|
1196
642
|
XHR = xhr;
|
|
1197
643
|
},
|
|
1198
|
-
_getXHR: function
|
|
644
|
+
_getXHR: function () {
|
|
1199
645
|
return XHR;
|
|
1200
646
|
}
|
|
1201
647
|
};
|
|
1202
|
-
|
|
1203
648
|
_CoreManager.default.setFileController(DefaultController);
|
|
1204
|
-
|
|
1205
649
|
var _default = ParseFile;
|
|
1206
650
|
exports.default = _default;
|
|
1207
651
|
exports.b64Digit = b64Digit;
|