parse 5.2.0-alpha.1 → 5.2.0-alpha.3
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 +10519 -15246
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +10499 -15371
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Analytics.js +7 -11
- package/lib/browser/AnonymousUtils.js +17 -22
- package/lib/browser/Cloud.js +23 -41
- package/lib/browser/CoreManager.js +71 -79
- package/lib/browser/CryptoController.js +14 -9
- package/lib/browser/EventEmitter.js +9 -2
- package/lib/browser/EventuallyQueue.js +156 -357
- package/lib/browser/FacebookUtils.js +23 -28
- package/lib/browser/IndexedDBStorageController.js +18 -14
- package/lib/browser/InstallationController.js +55 -121
- package/lib/browser/LiveQueryClient.js +312 -485
- package/lib/browser/LiveQuerySubscription.js +25 -28
- package/lib/browser/LocalDatastore.js +258 -624
- package/lib/browser/LocalDatastoreController.default.js +42 -226
- package/lib/browser/LocalDatastoreController.js +11 -1
- package/lib/browser/LocalDatastoreController.react-native.js +66 -160
- package/lib/browser/LocalDatastoreUtils.js +4 -7
- package/lib/browser/ObjectStateMutations.js +54 -96
- package/lib/browser/OfflineQuery.js +106 -198
- package/lib/browser/Parse.js +44 -60
- package/lib/browser/ParseACL.js +242 -288
- package/lib/browser/ParseCLP.js +372 -572
- package/lib/browser/ParseConfig.js +115 -138
- package/lib/browser/ParseError.js +85 -182
- package/lib/browser/ParseFile.js +294 -438
- package/lib/browser/ParseGeoPoint.js +121 -146
- package/lib/browser/ParseHooks.js +23 -25
- package/lib/browser/ParseInstallation.js +225 -367
- package/lib/browser/ParseLiveQuery.js +74 -148
- package/lib/browser/ParseObject.js +2014 -2621
- package/lib/browser/ParseOp.js +343 -484
- package/lib/browser/ParsePolygon.js +101 -120
- package/lib/browser/ParseQuery.js +1708 -2052
- package/lib/browser/ParseRelation.js +99 -118
- package/lib/browser/ParseRole.js +88 -140
- package/lib/browser/ParseSchema.js +372 -434
- package/lib/browser/ParseSession.js +62 -110
- package/lib/browser/ParseUser.js +941 -1284
- package/lib/browser/Push.js +15 -38
- package/lib/browser/RESTController.js +85 -124
- package/lib/browser/SingleInstanceStateController.js +57 -86
- package/lib/browser/Socket.weapp.js +50 -33
- package/lib/browser/Storage.js +23 -28
- package/lib/browser/StorageController.browser.js +16 -13
- package/lib/browser/StorageController.default.js +15 -14
- package/lib/browser/StorageController.js +14 -1
- package/lib/browser/StorageController.react-native.js +31 -30
- package/lib/browser/StorageController.weapp.js +19 -13
- package/lib/browser/TaskQueue.js +31 -43
- package/lib/browser/UniqueInstanceStateController.js +65 -86
- package/lib/browser/WebSocketController.js +11 -4
- package/lib/browser/Xhr.weapp.js +90 -78
- package/lib/browser/arrayContainsObject.js +3 -3
- package/lib/browser/canBeSerialized.js +10 -11
- package/lib/browser/decode.js +11 -11
- package/lib/browser/encode.js +11 -11
- package/lib/browser/equals.js +9 -10
- package/lib/browser/escape.js +2 -2
- package/lib/browser/isRevocableSession.js +1 -1
- package/lib/browser/parseDate.js +10 -10
- package/lib/browser/promiseUtils.js +19 -19
- package/lib/browser/unique.js +4 -4
- package/lib/browser/unsavedChildren.js +20 -21
- package/lib/browser/uuid.js +2 -4
- package/lib/node/Analytics.js +5 -9
- package/lib/node/AnonymousUtils.js +10 -15
- package/lib/node/Cloud.js +11 -11
- package/lib/node/CoreManager.js +59 -67
- package/lib/node/CryptoController.js +8 -3
- package/lib/node/EventEmitter.js +7 -1
- package/lib/node/EventuallyQueue.js +20 -39
- package/lib/node/FacebookUtils.js +4 -8
- package/lib/node/IndexedDBStorageController.js +14 -10
- package/lib/node/InstallationController.js +12 -13
- package/lib/node/LiveQueryClient.js +23 -21
- package/lib/node/LiveQuerySubscription.js +6 -7
- package/lib/node/LocalDatastore.js +23 -23
- package/lib/node/LocalDatastoreController.default.js +11 -12
- package/lib/node/LocalDatastoreController.js +14 -1
- package/lib/node/LocalDatastoreController.react-native.js +25 -21
- package/lib/node/LocalDatastoreUtils.js +4 -7
- package/lib/node/ObjectStateMutations.js +12 -22
- package/lib/node/OfflineQuery.js +37 -23
- package/lib/node/Parse.js +36 -50
- package/lib/node/ParseACL.js +21 -30
- package/lib/node/ParseCLP.js +38 -40
- package/lib/node/ParseConfig.js +10 -17
- package/lib/node/ParseError.js +460 -461
- package/lib/node/ParseFile.js +27 -47
- package/lib/node/ParseGeoPoint.js +16 -17
- package/lib/node/ParseHooks.js +16 -18
- package/lib/node/ParseInstallation.js +10 -11
- package/lib/node/ParseLiveQuery.js +9 -14
- package/lib/node/ParseObject.js +142 -173
- package/lib/node/ParseOp.js +35 -47
- package/lib/node/ParsePolygon.js +14 -20
- package/lib/node/ParseQuery.js +100 -123
- package/lib/node/ParseRelation.js +10 -19
- package/lib/node/ParseRole.js +10 -11
- package/lib/node/ParseSchema.js +29 -42
- package/lib/node/ParseSession.js +10 -11
- package/lib/node/ParseUser.js +76 -87
- package/lib/node/Push.js +7 -12
- package/lib/node/RESTController.js +24 -36
- package/lib/node/SingleInstanceStateController.js +41 -69
- package/lib/node/Socket.weapp.js +23 -2
- package/lib/node/Storage.js +14 -19
- package/lib/node/StorageController.browser.js +10 -8
- package/lib/node/StorageController.default.js +9 -9
- package/lib/node/StorageController.js +16 -1
- package/lib/node/StorageController.react-native.js +20 -20
- package/lib/node/StorageController.weapp.js +14 -8
- package/lib/node/TaskQueue.js +2 -3
- package/lib/node/UniqueInstanceStateController.js +43 -63
- package/lib/node/WebSocketController.js +15 -2
- package/lib/node/Xhr.weapp.js +11 -2
- package/lib/node/arrayContainsObject.js +4 -4
- package/lib/node/canBeSerialized.js +5 -5
- package/lib/node/decode.js +4 -4
- package/lib/node/encode.js +5 -5
- package/lib/node/equals.js +4 -4
- package/lib/node/escape.js +1 -1
- package/lib/node/isRevocableSession.js +1 -1
- package/lib/node/parseDate.js +1 -1
- package/lib/node/promiseUtils.js +7 -7
- package/lib/node/unique.js +5 -5
- package/lib/node/unsavedChildren.js +5 -5
- package/lib/node/uuid.js +2 -4
- package/lib/react-native/Analytics.js +2 -2
- package/lib/react-native/AnonymousUtils.js +3 -4
- package/lib/react-native/CoreManager.js +2 -3
- package/lib/react-native/CryptoController.js +6 -1
- package/lib/react-native/EventEmitter.js +6 -1
- package/lib/react-native/EventuallyQueue.js +1 -2
- package/lib/react-native/FacebookUtils.js +1 -2
- package/lib/react-native/IndexedDBStorageController.js +11 -5
- package/lib/react-native/InstallationController.js +1 -2
- package/lib/react-native/LiveQueryClient.js +8 -7
- package/lib/react-native/LiveQuerySubscription.js +2 -4
- package/lib/react-native/LocalDatastore.js +3 -3
- package/lib/react-native/LocalDatastoreController.default.js +1 -2
- package/lib/react-native/LocalDatastoreController.js +11 -1
- package/lib/react-native/LocalDatastoreController.react-native.js +11 -12
- package/lib/react-native/LocalDatastoreUtils.js +3 -6
- package/lib/react-native/OfflineQuery.js +25 -20
- package/lib/react-native/Parse.js +24 -38
- package/lib/react-native/ParseACL.js +4 -6
- package/lib/react-native/ParseCLP.js +2 -4
- package/lib/react-native/ParseConfig.js +4 -6
- package/lib/react-native/ParseError.js +13 -31
- package/lib/react-native/ParseFile.js +3 -4
- package/lib/react-native/ParseGeoPoint.js +2 -4
- package/lib/react-native/ParseInstallation.js +13 -30
- package/lib/react-native/ParseLiveQuery.js +2 -4
- package/lib/react-native/ParseObject.js +77 -87
- package/lib/react-native/ParseOp.js +41 -79
- package/lib/react-native/ParsePolygon.js +2 -4
- package/lib/react-native/ParseQuery.js +43 -45
- package/lib/react-native/ParseRelation.js +2 -4
- package/lib/react-native/ParseRole.js +13 -30
- package/lib/react-native/ParseSchema.js +3 -5
- package/lib/react-native/ParseSession.js +12 -29
- package/lib/react-native/ParseUser.js +24 -49
- package/lib/react-native/RESTController.js +10 -4
- package/lib/react-native/SingleInstanceStateController.js +23 -37
- package/lib/react-native/Socket.weapp.js +9 -4
- package/lib/react-native/Storage.js +1 -2
- package/lib/react-native/StorageController.browser.js +6 -1
- package/lib/react-native/StorageController.default.js +6 -1
- package/lib/react-native/StorageController.js +13 -1
- package/lib/react-native/StorageController.react-native.js +11 -6
- package/lib/react-native/StorageController.weapp.js +6 -1
- package/lib/react-native/TaskQueue.js +2 -4
- package/lib/react-native/UniqueInstanceStateController.js +23 -37
- package/lib/react-native/WebSocketController.js +9 -1
- package/lib/react-native/Xhr.weapp.js +9 -4
- package/lib/react-native/unsavedChildren.js +3 -3
- package/lib/react-native/uuid.js +1 -2
- package/lib/weapp/Analytics.js +7 -11
- package/lib/weapp/AnonymousUtils.js +17 -22
- package/lib/weapp/Cloud.js +23 -41
- package/lib/weapp/CoreManager.js +71 -79
- package/lib/weapp/CryptoController.js +14 -9
- package/lib/weapp/EventEmitter.js +9 -2
- package/lib/weapp/EventuallyQueue.js +156 -357
- package/lib/weapp/FacebookUtils.js +23 -28
- package/lib/weapp/IndexedDBStorageController.js +18 -14
- package/lib/weapp/InstallationController.js +55 -121
- package/lib/weapp/LiveQueryClient.js +312 -485
- package/lib/weapp/LiveQuerySubscription.js +25 -28
- package/lib/weapp/LocalDatastore.js +258 -624
- package/lib/weapp/LocalDatastoreController.default.js +42 -226
- package/lib/weapp/LocalDatastoreController.js +11 -1
- package/lib/weapp/LocalDatastoreController.react-native.js +66 -160
- package/lib/weapp/LocalDatastoreUtils.js +4 -7
- package/lib/weapp/ObjectStateMutations.js +54 -96
- package/lib/weapp/OfflineQuery.js +106 -198
- package/lib/weapp/Parse.js +44 -59
- package/lib/weapp/ParseACL.js +242 -288
- package/lib/weapp/ParseCLP.js +372 -572
- package/lib/weapp/ParseConfig.js +115 -138
- package/lib/weapp/ParseError.js +85 -182
- package/lib/weapp/ParseFile.js +295 -440
- package/lib/weapp/ParseGeoPoint.js +121 -146
- package/lib/weapp/ParseHooks.js +23 -25
- package/lib/weapp/ParseInstallation.js +225 -367
- package/lib/weapp/ParseLiveQuery.js +74 -148
- package/lib/weapp/ParseObject.js +2014 -2621
- package/lib/weapp/ParseOp.js +343 -484
- package/lib/weapp/ParsePolygon.js +101 -120
- package/lib/weapp/ParseQuery.js +1708 -2052
- package/lib/weapp/ParseRelation.js +99 -118
- package/lib/weapp/ParseRole.js +88 -140
- package/lib/weapp/ParseSchema.js +372 -434
- package/lib/weapp/ParseSession.js +62 -110
- package/lib/weapp/ParseUser.js +941 -1284
- package/lib/weapp/Push.js +15 -38
- package/lib/weapp/RESTController.js +86 -125
- package/lib/weapp/SingleInstanceStateController.js +57 -86
- package/lib/weapp/Socket.weapp.js +50 -33
- package/lib/weapp/Storage.js +23 -28
- package/lib/weapp/StorageController.browser.js +16 -13
- package/lib/weapp/StorageController.default.js +15 -14
- package/lib/weapp/StorageController.js +14 -1
- package/lib/weapp/StorageController.react-native.js +31 -30
- package/lib/weapp/StorageController.weapp.js +19 -13
- package/lib/weapp/TaskQueue.js +31 -43
- package/lib/weapp/UniqueInstanceStateController.js +65 -86
- package/lib/weapp/WebSocketController.js +11 -4
- package/lib/weapp/Xhr.weapp.js +90 -78
- package/lib/weapp/arrayContainsObject.js +3 -3
- package/lib/weapp/canBeSerialized.js +10 -11
- package/lib/weapp/decode.js +11 -11
- package/lib/weapp/encode.js +11 -11
- package/lib/weapp/equals.js +9 -10
- package/lib/weapp/escape.js +2 -2
- package/lib/weapp/isRevocableSession.js +1 -1
- package/lib/weapp/parseDate.js +10 -10
- package/lib/weapp/promiseUtils.js +19 -19
- package/lib/weapp/unique.js +4 -4
- package/lib/weapp/unsavedChildren.js +20 -21
- package/lib/weapp/uuid.js +6 -8
- package/package.json +24 -30
|
@@ -8,9 +8,6 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
10
10
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
11
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
13
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
14
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
15
12
|
/**
|
|
16
13
|
* Creates a new GeoPoint with any of the following forms:<br>
|
|
@@ -36,20 +33,19 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/he
|
|
|
36
33
|
* @alias Parse.GeoPoint
|
|
37
34
|
*/
|
|
38
35
|
/* global navigator */
|
|
39
|
-
|
|
36
|
+
class ParseGeoPoint {
|
|
40
37
|
/**
|
|
41
38
|
* @param {(number[] | object | number)} arg1 Either a list of coordinate pairs, an object with `latitude`, `longitude`, or the latitude or the point.
|
|
42
39
|
* @param {number} arg2 The longitude of the GeoPoint
|
|
43
40
|
*/
|
|
44
|
-
|
|
45
|
-
(0, _classCallCheck2.default)(this, ParseGeoPoint);
|
|
41
|
+
constructor(arg1, arg2) {
|
|
46
42
|
(0, _defineProperty2.default)(this, "_latitude", void 0);
|
|
47
43
|
(0, _defineProperty2.default)(this, "_longitude", void 0);
|
|
48
44
|
if ((0, _isArray.default)(arg1)) {
|
|
49
45
|
ParseGeoPoint._validate(arg1[0], arg1[1]);
|
|
50
46
|
this._latitude = arg1[0];
|
|
51
47
|
this._longitude = arg1[1];
|
|
52
|
-
} else if (
|
|
48
|
+
} else if (typeof arg1 === 'object') {
|
|
53
49
|
ParseGeoPoint._validate(arg1.latitude, arg1.longitude);
|
|
54
50
|
this._latitude = arg1.latitude;
|
|
55
51
|
this._longitude = arg1.longitude;
|
|
@@ -70,150 +66,129 @@ var ParseGeoPoint = /*#__PURE__*/function () {
|
|
|
70
66
|
* @property {number} latitude
|
|
71
67
|
* @returns {number}
|
|
72
68
|
*/
|
|
73
|
-
(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
this._latitude = val;
|
|
81
|
-
}
|
|
69
|
+
get latitude() {
|
|
70
|
+
return this._latitude;
|
|
71
|
+
}
|
|
72
|
+
set latitude(val) {
|
|
73
|
+
ParseGeoPoint._validate(val, this.longitude);
|
|
74
|
+
this._latitude = val;
|
|
75
|
+
}
|
|
82
76
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
this._longitude = val;
|
|
98
|
-
}
|
|
77
|
+
/**
|
|
78
|
+
* East-west portion of the coordinate, in range [-180, 180].
|
|
79
|
+
* Throws if set out of range in a modern browser.
|
|
80
|
+
*
|
|
81
|
+
* @property {number} longitude
|
|
82
|
+
* @returns {number}
|
|
83
|
+
*/
|
|
84
|
+
get longitude() {
|
|
85
|
+
return this._longitude;
|
|
86
|
+
}
|
|
87
|
+
set longitude(val) {
|
|
88
|
+
ParseGeoPoint._validate(this.latitude, val);
|
|
89
|
+
this._longitude = val;
|
|
90
|
+
}
|
|
99
91
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
key: "equals",
|
|
117
|
-
value: function (other /*: any*/) /*: boolean*/{
|
|
118
|
-
return other instanceof ParseGeoPoint && this.latitude === other.latitude && this.longitude === other.longitude;
|
|
119
|
-
}
|
|
92
|
+
/**
|
|
93
|
+
* Returns a JSON representation of the GeoPoint, suitable for Parse.
|
|
94
|
+
*
|
|
95
|
+
* @returns {object}
|
|
96
|
+
*/
|
|
97
|
+
toJSON() {
|
|
98
|
+
ParseGeoPoint._validate(this._latitude, this._longitude);
|
|
99
|
+
return {
|
|
100
|
+
__type: 'GeoPoint',
|
|
101
|
+
latitude: this._latitude,
|
|
102
|
+
longitude: this._longitude
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
equals(other) {
|
|
106
|
+
return other instanceof ParseGeoPoint && this.latitude === other.latitude && this.longitude === other.longitude;
|
|
107
|
+
}
|
|
120
108
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return 2 * Math.asin(Math.sqrt(a));
|
|
141
|
-
}
|
|
109
|
+
/**
|
|
110
|
+
* Returns the distance from this GeoPoint to another in radians.
|
|
111
|
+
*
|
|
112
|
+
* @param {Parse.GeoPoint} point the other Parse.GeoPoint.
|
|
113
|
+
* @returns {number}
|
|
114
|
+
*/
|
|
115
|
+
radiansTo(point) {
|
|
116
|
+
const d2r = Math.PI / 180.0;
|
|
117
|
+
const lat1rad = this.latitude * d2r;
|
|
118
|
+
const long1rad = this.longitude * d2r;
|
|
119
|
+
const lat2rad = point.latitude * d2r;
|
|
120
|
+
const long2rad = point.longitude * d2r;
|
|
121
|
+
const sinDeltaLatDiv2 = Math.sin((lat1rad - lat2rad) / 2);
|
|
122
|
+
const sinDeltaLongDiv2 = Math.sin((long1rad - long2rad) / 2);
|
|
123
|
+
// Square of half the straight line chord distance between both points.
|
|
124
|
+
let a = sinDeltaLatDiv2 * sinDeltaLatDiv2 + Math.cos(lat1rad) * Math.cos(lat2rad) * sinDeltaLongDiv2 * sinDeltaLongDiv2;
|
|
125
|
+
a = Math.min(1.0, a);
|
|
126
|
+
return 2 * Math.asin(Math.sqrt(a));
|
|
127
|
+
}
|
|
142
128
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return this.radiansTo(point) * 6371.0;
|
|
153
|
-
}
|
|
129
|
+
/**
|
|
130
|
+
* Returns the distance from this GeoPoint to another in kilometers.
|
|
131
|
+
*
|
|
132
|
+
* @param {Parse.GeoPoint} point the other Parse.GeoPoint.
|
|
133
|
+
* @returns {number}
|
|
134
|
+
*/
|
|
135
|
+
kilometersTo(point) {
|
|
136
|
+
return this.radiansTo(point) * 6371.0;
|
|
137
|
+
}
|
|
154
138
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return this.radiansTo(point) * 3958.8;
|
|
165
|
-
}
|
|
139
|
+
/**
|
|
140
|
+
* Returns the distance from this GeoPoint to another in miles.
|
|
141
|
+
*
|
|
142
|
+
* @param {Parse.GeoPoint} point the other Parse.GeoPoint.
|
|
143
|
+
* @returns {number}
|
|
144
|
+
*/
|
|
145
|
+
milesTo(point) {
|
|
146
|
+
return this.radiansTo(point) * 3958.8;
|
|
147
|
+
}
|
|
166
148
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (isNaN(latitude) || isNaN(longitude) || typeof latitude !== 'number' || typeof longitude !== 'number') {
|
|
174
|
-
throw new TypeError('GeoPoint latitude and longitude must be valid numbers');
|
|
175
|
-
}
|
|
176
|
-
if (latitude < -90.0) {
|
|
177
|
-
throw new TypeError('GeoPoint latitude out of bounds: ' + latitude + ' < -90.0.');
|
|
178
|
-
}
|
|
179
|
-
if (latitude > 90.0) {
|
|
180
|
-
throw new TypeError('GeoPoint latitude out of bounds: ' + latitude + ' > 90.0.');
|
|
181
|
-
}
|
|
182
|
-
if (longitude < -180.0) {
|
|
183
|
-
throw new TypeError('GeoPoint longitude out of bounds: ' + longitude + ' < -180.0.');
|
|
184
|
-
}
|
|
185
|
-
if (longitude > 180.0) {
|
|
186
|
-
throw new TypeError('GeoPoint longitude out of bounds: ' + longitude + ' > 180.0.');
|
|
187
|
-
}
|
|
149
|
+
/*
|
|
150
|
+
* Throws an exception if the given lat-long is out of bounds.
|
|
151
|
+
*/
|
|
152
|
+
static _validate(latitude, longitude) {
|
|
153
|
+
if (isNaN(latitude) || isNaN(longitude) || typeof latitude !== 'number' || typeof longitude !== 'number') {
|
|
154
|
+
throw new TypeError('GeoPoint latitude and longitude must be valid numbers');
|
|
188
155
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
* @param {boolean} [options.enableHighAccuracy=false] A boolean value that indicates the application would like to receive the best possible results.
|
|
195
|
-
* If true and if the device is able to provide a more accurate position, it will do so.
|
|
196
|
-
* Note that this can result in slower response times or increased power consumption (with a GPS chip on a mobile device for example).
|
|
197
|
-
* On the other hand, if false, the device can take the liberty to save resources by responding more quickly and/or using less power. Default: false.
|
|
198
|
-
* @param {number} [options.timeout=Infinity] A positive long value representing the maximum length of time (in milliseconds) the device is allowed to take in order to return a position.
|
|
199
|
-
* The default value is Infinity, meaning that getCurrentPosition() won't return until the position is available.
|
|
200
|
-
* @param {number} [options.maximumAge=0] A positive long value indicating the maximum age in milliseconds of a possible cached position that is acceptable to return.
|
|
201
|
-
* If set to 0, it means that the device cannot use a cached position and must attempt to retrieve the real current position.
|
|
202
|
-
* If set to Infinity the device must return a cached position regardless of its age. Default: 0.
|
|
203
|
-
* @static
|
|
204
|
-
* @returns {Promise<Parse.GeoPoint>} User's current location
|
|
205
|
-
*/
|
|
206
|
-
}, {
|
|
207
|
-
key: "current",
|
|
208
|
-
value: function (options) /*: Promise<ParseGeoPoint>*/{
|
|
209
|
-
return new _promise.default(function (resolve, reject) {
|
|
210
|
-
navigator.geolocation.getCurrentPosition(function (location) {
|
|
211
|
-
resolve(new ParseGeoPoint(location.coords.latitude, location.coords.longitude));
|
|
212
|
-
}, reject, options);
|
|
213
|
-
});
|
|
156
|
+
if (latitude < -90.0) {
|
|
157
|
+
throw new TypeError('GeoPoint latitude out of bounds: ' + latitude + ' < -90.0.');
|
|
158
|
+
}
|
|
159
|
+
if (latitude > 90.0) {
|
|
160
|
+
throw new TypeError('GeoPoint latitude out of bounds: ' + latitude + ' > 90.0.');
|
|
214
161
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
162
|
+
if (longitude < -180.0) {
|
|
163
|
+
throw new TypeError('GeoPoint longitude out of bounds: ' + longitude + ' < -180.0.');
|
|
164
|
+
}
|
|
165
|
+
if (longitude > 180.0) {
|
|
166
|
+
throw new TypeError('GeoPoint longitude out of bounds: ' + longitude + ' > 180.0.');
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Creates a GeoPoint with the user's current location, if available.
|
|
172
|
+
*
|
|
173
|
+
* @param {object} options The options.
|
|
174
|
+
* @param {boolean} [options.enableHighAccuracy] A boolean value that indicates the application would like to receive the best possible results.
|
|
175
|
+
* If true and if the device is able to provide a more accurate position, it will do so.
|
|
176
|
+
* Note that this can result in slower response times or increased power consumption (with a GPS chip on a mobile device for example).
|
|
177
|
+
* On the other hand, if false, the device can take the liberty to save resources by responding more quickly and/or using less power. Default: false.
|
|
178
|
+
* @param {number} [options.timeout] A positive long value representing the maximum length of time (in milliseconds) the device is allowed to take in order to return a position.
|
|
179
|
+
* The default value is Infinity, meaning that getCurrentPosition() won't return until the position is available.
|
|
180
|
+
* @param {number} [options.maximumAge] A positive long value indicating the maximum age in milliseconds of a possible cached position that is acceptable to return.
|
|
181
|
+
* If set to 0, it means that the device cannot use a cached position and must attempt to retrieve the real current position.
|
|
182
|
+
* If set to Infinity the device must return a cached position regardless of its age. Default: 0.
|
|
183
|
+
* @static
|
|
184
|
+
* @returns {Promise<Parse.GeoPoint>} User's current location
|
|
185
|
+
*/
|
|
186
|
+
static current(options) {
|
|
187
|
+
return new _promise.default((resolve, reject) => {
|
|
188
|
+
navigator.geolocation.getCurrentPosition(location => {
|
|
189
|
+
resolve(new ParseGeoPoint(location.coords.latitude, location.coords.longitude));
|
|
190
|
+
}, reject, options);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
var _default = exports.default = ParseGeoPoint;
|
package/lib/weapp/ParseHooks.js
CHANGED
|
@@ -22,69 +22,67 @@ var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-st
|
|
|
22
22
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
23
23
|
var _decode = _interopRequireDefault(require("./decode"));
|
|
24
24
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
25
|
-
/*:: export type HookDeclaration = { functionName: string, url: string } | { className: string, triggerName: string, url: string };*/
|
|
26
|
-
/*:: export type HookDeleteArg = { functionName: string } | { className: string, triggerName: string };*/
|
|
27
25
|
function getFunctions() {
|
|
28
26
|
return _CoreManager.default.getHooksController().get('functions');
|
|
29
27
|
}
|
|
30
28
|
function getTriggers() {
|
|
31
29
|
return _CoreManager.default.getHooksController().get('triggers');
|
|
32
30
|
}
|
|
33
|
-
function getFunction(name
|
|
31
|
+
function getFunction(name) {
|
|
34
32
|
return _CoreManager.default.getHooksController().get('functions', name);
|
|
35
33
|
}
|
|
36
|
-
function getTrigger(className
|
|
34
|
+
function getTrigger(className, triggerName) {
|
|
37
35
|
return _CoreManager.default.getHooksController().get('triggers', className, triggerName);
|
|
38
36
|
}
|
|
39
|
-
function createFunction(functionName
|
|
37
|
+
function createFunction(functionName, url) {
|
|
40
38
|
return create({
|
|
41
39
|
functionName: functionName,
|
|
42
40
|
url: url
|
|
43
41
|
});
|
|
44
42
|
}
|
|
45
|
-
function createTrigger(className
|
|
43
|
+
function createTrigger(className, triggerName, url) {
|
|
46
44
|
return create({
|
|
47
45
|
className: className,
|
|
48
46
|
triggerName: triggerName,
|
|
49
47
|
url: url
|
|
50
48
|
});
|
|
51
49
|
}
|
|
52
|
-
function create(hook
|
|
50
|
+
function create(hook) {
|
|
53
51
|
return _CoreManager.default.getHooksController().create(hook);
|
|
54
52
|
}
|
|
55
|
-
function updateFunction(functionName
|
|
53
|
+
function updateFunction(functionName, url) {
|
|
56
54
|
return update({
|
|
57
55
|
functionName: functionName,
|
|
58
56
|
url: url
|
|
59
57
|
});
|
|
60
58
|
}
|
|
61
|
-
function updateTrigger(className
|
|
59
|
+
function updateTrigger(className, triggerName, url) {
|
|
62
60
|
return update({
|
|
63
61
|
className: className,
|
|
64
62
|
triggerName: triggerName,
|
|
65
63
|
url: url
|
|
66
64
|
});
|
|
67
65
|
}
|
|
68
|
-
function update(hook
|
|
66
|
+
function update(hook) {
|
|
69
67
|
return _CoreManager.default.getHooksController().update(hook);
|
|
70
68
|
}
|
|
71
|
-
function removeFunction(functionName
|
|
69
|
+
function removeFunction(functionName) {
|
|
72
70
|
return remove({
|
|
73
71
|
functionName: functionName
|
|
74
72
|
});
|
|
75
73
|
}
|
|
76
|
-
function removeTrigger(className
|
|
74
|
+
function removeTrigger(className, triggerName) {
|
|
77
75
|
return remove({
|
|
78
76
|
className: className,
|
|
79
77
|
triggerName: triggerName
|
|
80
78
|
});
|
|
81
79
|
}
|
|
82
|
-
function remove(hook
|
|
80
|
+
function remove(hook) {
|
|
83
81
|
return _CoreManager.default.getHooksController().remove(hook);
|
|
84
82
|
}
|
|
85
|
-
|
|
86
|
-
get
|
|
87
|
-
|
|
83
|
+
const DefaultController = {
|
|
84
|
+
get(type, functionName, triggerName) {
|
|
85
|
+
let url = '/hooks/' + type;
|
|
88
86
|
if (functionName) {
|
|
89
87
|
url += '/' + functionName;
|
|
90
88
|
if (triggerName) {
|
|
@@ -93,8 +91,8 @@ var DefaultController = {
|
|
|
93
91
|
}
|
|
94
92
|
return this.sendRequest('GET', url);
|
|
95
93
|
},
|
|
96
|
-
create
|
|
97
|
-
|
|
94
|
+
create(hook) {
|
|
95
|
+
let url;
|
|
98
96
|
if (hook.functionName && hook.url) {
|
|
99
97
|
url = '/hooks/functions';
|
|
100
98
|
} else if (hook.className && hook.triggerName && hook.url) {
|
|
@@ -107,8 +105,8 @@ var DefaultController = {
|
|
|
107
105
|
}
|
|
108
106
|
return this.sendRequest('POST', url, hook);
|
|
109
107
|
},
|
|
110
|
-
remove
|
|
111
|
-
|
|
108
|
+
remove(hook) {
|
|
109
|
+
let url;
|
|
112
110
|
if (hook.functionName) {
|
|
113
111
|
url = '/hooks/functions/' + hook.functionName;
|
|
114
112
|
delete hook.functionName;
|
|
@@ -126,8 +124,8 @@ var DefaultController = {
|
|
|
126
124
|
__op: 'Delete'
|
|
127
125
|
});
|
|
128
126
|
},
|
|
129
|
-
update
|
|
130
|
-
|
|
127
|
+
update(hook) {
|
|
128
|
+
let url;
|
|
131
129
|
if (hook.functionName && hook.url) {
|
|
132
130
|
url = '/hooks/functions/' + hook.functionName;
|
|
133
131
|
delete hook.functionName;
|
|
@@ -143,11 +141,11 @@ var DefaultController = {
|
|
|
143
141
|
}
|
|
144
142
|
return this.sendRequest('PUT', url, hook);
|
|
145
143
|
},
|
|
146
|
-
sendRequest
|
|
144
|
+
sendRequest(method, url, body) {
|
|
147
145
|
return _CoreManager.default.getRESTController().request(method, url, body, {
|
|
148
146
|
useMasterKey: true
|
|
149
|
-
}).then(
|
|
150
|
-
|
|
147
|
+
}).then(res => {
|
|
148
|
+
const decoded = (0, _decode.default)(res);
|
|
151
149
|
if (decoded) {
|
|
152
150
|
return _promise.default.resolve(decoded);
|
|
153
151
|
}
|