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
|
@@ -7,24 +7,20 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _ParseUser = _interopRequireDefault(require("./ParseUser"));
|
|
10
|
-
/**
|
|
11
|
-
* @flow-weak
|
|
12
|
-
*/
|
|
13
10
|
/* global FB */
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
authenticate
|
|
20
|
-
var _this = this;
|
|
12
|
+
let initialized = false;
|
|
13
|
+
let requestedPermissions;
|
|
14
|
+
let initOptions;
|
|
15
|
+
const provider = {
|
|
16
|
+
authenticate(options) {
|
|
21
17
|
if (typeof FB === 'undefined') {
|
|
22
18
|
options.error(this, 'Facebook SDK not found.');
|
|
23
19
|
}
|
|
24
|
-
FB.login(
|
|
20
|
+
FB.login(response => {
|
|
25
21
|
if (response.authResponse) {
|
|
26
22
|
if (options.success) {
|
|
27
|
-
options.success(
|
|
23
|
+
options.success(this, {
|
|
28
24
|
id: response.authResponse.userID,
|
|
29
25
|
access_token: response.authResponse.accessToken,
|
|
30
26
|
expiration_date: new Date(response.authResponse.expiresIn * 1000 + new Date().getTime()).toJSON()
|
|
@@ -32,18 +28,18 @@ var provider = {
|
|
|
32
28
|
}
|
|
33
29
|
} else {
|
|
34
30
|
if (options.error) {
|
|
35
|
-
options.error(
|
|
31
|
+
options.error(this, response);
|
|
36
32
|
}
|
|
37
33
|
}
|
|
38
34
|
}, {
|
|
39
35
|
scope: requestedPermissions
|
|
40
36
|
});
|
|
41
37
|
},
|
|
42
|
-
restoreAuthentication
|
|
38
|
+
restoreAuthentication(authData) {
|
|
43
39
|
if (authData) {
|
|
44
|
-
|
|
40
|
+
const newOptions = {};
|
|
45
41
|
if (initOptions) {
|
|
46
|
-
for (
|
|
42
|
+
for (const key in initOptions) {
|
|
47
43
|
newOptions[key] = initOptions[key];
|
|
48
44
|
}
|
|
49
45
|
}
|
|
@@ -54,7 +50,7 @@ var provider = {
|
|
|
54
50
|
// Most of the time, the users will match -- it's only in cases where
|
|
55
51
|
// the FB SDK knows of a different user than the one being restored
|
|
56
52
|
// from a Parse User that logged in with username/password.
|
|
57
|
-
|
|
53
|
+
const existingResponse = FB.getAuthResponse();
|
|
58
54
|
if (existingResponse && existingResponse.userID !== authData.id) {
|
|
59
55
|
FB.logout();
|
|
60
56
|
}
|
|
@@ -62,10 +58,10 @@ var provider = {
|
|
|
62
58
|
}
|
|
63
59
|
return true;
|
|
64
60
|
},
|
|
65
|
-
getAuthType
|
|
61
|
+
getAuthType() {
|
|
66
62
|
return 'facebook';
|
|
67
63
|
},
|
|
68
|
-
deauthenticate
|
|
64
|
+
deauthenticate() {
|
|
69
65
|
this.restoreAuthentication(null);
|
|
70
66
|
}
|
|
71
67
|
};
|
|
@@ -77,7 +73,7 @@ var provider = {
|
|
|
77
73
|
* @static
|
|
78
74
|
* @hideconstructor
|
|
79
75
|
*/
|
|
80
|
-
|
|
76
|
+
const FacebookUtils = {
|
|
81
77
|
/**
|
|
82
78
|
* Initializes Parse Facebook integration. Call this function after you
|
|
83
79
|
* have loaded the Facebook Javascript SDK with the same parameters
|
|
@@ -96,18 +92,18 @@ var FacebookUtils = {
|
|
|
96
92
|
* interferes with Parse Facebook integration. Call FB.getLoginStatus()
|
|
97
93
|
* explicitly if this behavior is required by your application.
|
|
98
94
|
*/
|
|
99
|
-
init
|
|
95
|
+
init(options) {
|
|
100
96
|
if (typeof FB === 'undefined') {
|
|
101
97
|
throw new Error('The Facebook JavaScript SDK must be loaded before calling init.');
|
|
102
98
|
}
|
|
103
99
|
initOptions = {};
|
|
104
100
|
if (options) {
|
|
105
|
-
for (
|
|
101
|
+
for (const key in options) {
|
|
106
102
|
initOptions[key] = options[key];
|
|
107
103
|
}
|
|
108
104
|
}
|
|
109
105
|
if (initOptions.status && typeof console !== 'undefined') {
|
|
110
|
-
|
|
106
|
+
const warn = console.warn || console.log || function () {}; // eslint-disable-line no-console
|
|
111
107
|
warn.call(console, 'The "status" flag passed into' + ' FB.init, when set to true, can interfere with Parse Facebook' + ' integration, so it has been suppressed. Please call' + ' FB.getLoginStatus() explicitly if you require this behavior.');
|
|
112
108
|
}
|
|
113
109
|
initOptions.status = false;
|
|
@@ -125,7 +121,7 @@ var FacebookUtils = {
|
|
|
125
121
|
* @returns {boolean} <code>true</code> if the user has their account
|
|
126
122
|
* linked to Facebook.
|
|
127
123
|
*/
|
|
128
|
-
isLinked
|
|
124
|
+
isLinked(user) {
|
|
129
125
|
return user._isLinked('facebook');
|
|
130
126
|
},
|
|
131
127
|
/**
|
|
@@ -152,7 +148,7 @@ var FacebookUtils = {
|
|
|
152
148
|
* @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string
|
|
153
149
|
* @returns {Promise}
|
|
154
150
|
*/
|
|
155
|
-
logIn
|
|
151
|
+
logIn(permissions, options) {
|
|
156
152
|
if (!permissions || typeof permissions === 'string') {
|
|
157
153
|
if (!initialized) {
|
|
158
154
|
throw new Error('You must initialize FacebookUtils before calling logIn.');
|
|
@@ -190,7 +186,7 @@ var FacebookUtils = {
|
|
|
190
186
|
* @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string
|
|
191
187
|
* @returns {Promise}
|
|
192
188
|
*/
|
|
193
|
-
link
|
|
189
|
+
link(user, permissions, options) {
|
|
194
190
|
if (!permissions || typeof permissions === 'string') {
|
|
195
191
|
if (!initialized) {
|
|
196
192
|
throw new Error('You must initialize FacebookUtils before calling link.');
|
|
@@ -220,9 +216,8 @@ var FacebookUtils = {
|
|
|
220
216
|
return user._unlinkFrom('facebook', options);
|
|
221
217
|
},
|
|
222
218
|
// Used for testing purposes
|
|
223
|
-
_getAuthProvider
|
|
219
|
+
_getAuthProvider() {
|
|
224
220
|
return provider;
|
|
225
221
|
}
|
|
226
222
|
};
|
|
227
|
-
var _default = FacebookUtils;
|
|
228
|
-
exports.default = _default;
|
|
223
|
+
var _default = exports.default = FacebookUtils;
|
|
@@ -1,39 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _keysInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/keys");
|
|
4
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
4
9
|
var _idbKeyval = require("idb-keyval");
|
|
5
|
-
/**
|
|
6
|
-
* @flow
|
|
7
|
-
*/
|
|
8
10
|
/* global window */
|
|
9
11
|
|
|
12
|
+
let IndexedDBStorageController;
|
|
10
13
|
if (typeof window !== 'undefined' && window.indexedDB) {
|
|
11
14
|
try {
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
const ParseStore = (0, _idbKeyval.createStore)('parseDB', 'parseStore');
|
|
16
|
+
IndexedDBStorageController = {
|
|
14
17
|
async: 1,
|
|
15
|
-
getItemAsync
|
|
18
|
+
getItemAsync(path) {
|
|
16
19
|
return (0, _idbKeyval.get)(path, ParseStore);
|
|
17
20
|
},
|
|
18
|
-
setItemAsync
|
|
21
|
+
setItemAsync(path, value) {
|
|
19
22
|
return (0, _idbKeyval.set)(path, value, ParseStore);
|
|
20
23
|
},
|
|
21
|
-
removeItemAsync
|
|
24
|
+
removeItemAsync(path) {
|
|
22
25
|
return (0, _idbKeyval.del)(path, ParseStore);
|
|
23
26
|
},
|
|
24
|
-
getAllKeysAsync
|
|
27
|
+
getAllKeysAsync() {
|
|
25
28
|
return (0, _keysInstanceProperty(_idbKeyval))(ParseStore);
|
|
26
29
|
},
|
|
27
|
-
clear
|
|
30
|
+
clear() {
|
|
28
31
|
return (0, _idbKeyval.clear)(ParseStore);
|
|
29
32
|
}
|
|
30
33
|
};
|
|
31
|
-
module.exports = IndexedDBStorageController;
|
|
32
34
|
} catch (_) {
|
|
33
35
|
// IndexedDB not accessible
|
|
34
|
-
|
|
36
|
+
IndexedDBStorageController = undefined;
|
|
35
37
|
}
|
|
36
38
|
} else {
|
|
37
39
|
// IndexedDB not supported
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
+
IndexedDBStorageController = undefined;
|
|
41
|
+
}
|
|
42
|
+
module.exports = IndexedDBStorageController;
|
|
43
|
+
var _default = exports.default = IndexedDBStorageController;
|
|
@@ -6,143 +6,77 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
|
|
10
9
|
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
11
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
|
|
12
10
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
13
11
|
var _Storage = _interopRequireDefault(require("./Storage"));
|
|
14
12
|
var _ParseInstallation = _interopRequireDefault(require("./ParseInstallation"));
|
|
15
13
|
var _uuid = _interopRequireDefault(require("./uuid"));
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
updateInstallationOnDisk
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return _regenerator.default.wrap(function (_context) {
|
|
27
|
-
while (1) switch (_context.prev = _context.next) {
|
|
28
|
-
case 0:
|
|
29
|
-
path = _Storage.default.generatePath(CURRENT_INSTALLATION_KEY);
|
|
30
|
-
_context.next = 3;
|
|
31
|
-
return _Storage.default.setItemAsync(path, (0, _stringify.default)(installation.toJSON()));
|
|
32
|
-
case 3:
|
|
33
|
-
_this._setCurrentInstallationCache(installation);
|
|
34
|
-
case 4:
|
|
35
|
-
case "end":
|
|
36
|
-
return _context.stop();
|
|
37
|
-
}
|
|
38
|
-
}, _callee);
|
|
39
|
-
}))();
|
|
14
|
+
const CURRENT_INSTALLATION_KEY = 'currentInstallation';
|
|
15
|
+
const CURRENT_INSTALLATION_ID_KEY = 'currentInstallationId';
|
|
16
|
+
let iidCache = null;
|
|
17
|
+
let currentInstallationCache = null;
|
|
18
|
+
let currentInstallationCacheMatchesDisk = false;
|
|
19
|
+
const InstallationController = {
|
|
20
|
+
async updateInstallationOnDisk(installation) {
|
|
21
|
+
const path = _Storage.default.generatePath(CURRENT_INSTALLATION_KEY);
|
|
22
|
+
await _Storage.default.setItemAsync(path, (0, _stringify.default)(installation.toJSON()));
|
|
23
|
+
this._setCurrentInstallationCache(installation);
|
|
40
24
|
},
|
|
41
|
-
currentInstallationId
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
case 5:
|
|
57
|
-
iid = _context2.sent;
|
|
58
|
-
if (iid) {
|
|
59
|
-
_context2.next = 9;
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
iid = (0, _uuid.default)();
|
|
63
|
-
return _context2.abrupt("return", _Storage.default.setItemAsync(path, iid).then(function () {
|
|
64
|
-
iidCache = iid;
|
|
65
|
-
return iid;
|
|
66
|
-
}));
|
|
67
|
-
case 9:
|
|
68
|
-
iidCache = iid;
|
|
69
|
-
return _context2.abrupt("return", iid);
|
|
70
|
-
case 11:
|
|
71
|
-
case "end":
|
|
72
|
-
return _context2.stop();
|
|
73
|
-
}
|
|
74
|
-
}, _callee2);
|
|
75
|
-
}))();
|
|
25
|
+
async currentInstallationId() {
|
|
26
|
+
if (typeof iidCache === 'string') {
|
|
27
|
+
return iidCache;
|
|
28
|
+
}
|
|
29
|
+
const path = _Storage.default.generatePath(CURRENT_INSTALLATION_ID_KEY);
|
|
30
|
+
let iid = await _Storage.default.getItemAsync(path);
|
|
31
|
+
if (!iid) {
|
|
32
|
+
iid = (0, _uuid.default)();
|
|
33
|
+
return _Storage.default.setItemAsync(path, iid).then(() => {
|
|
34
|
+
iidCache = iid;
|
|
35
|
+
return iid;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
iidCache = iid;
|
|
39
|
+
return iid;
|
|
76
40
|
},
|
|
77
|
-
currentInstallation
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (!installationData) {
|
|
103
|
-
_context3.next = 15;
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
installationData = JSON.parse(installationData);
|
|
107
|
-
installationData.className = '_Installation';
|
|
108
|
-
current = _ParseInstallation.default.fromJSON(installationData);
|
|
109
|
-
currentInstallationCache = current;
|
|
110
|
-
return _context3.abrupt("return", current);
|
|
111
|
-
case 15:
|
|
112
|
-
_context3.next = 17;
|
|
113
|
-
return _this2.currentInstallationId();
|
|
114
|
-
case 17:
|
|
115
|
-
installationId = _context3.sent;
|
|
116
|
-
installation = new _ParseInstallation.default();
|
|
117
|
-
installation.set('deviceType', _ParseInstallation.default.DEVICE_TYPES.WEB);
|
|
118
|
-
installation.set('installationId', installationId);
|
|
119
|
-
installation.set('parseVersion', _CoreManager.default.get('VERSION'));
|
|
120
|
-
currentInstallationCache = installation;
|
|
121
|
-
_context3.next = 25;
|
|
122
|
-
return _Storage.default.setItemAsync(path, (0, _stringify.default)(installation.toJSON()));
|
|
123
|
-
case 25:
|
|
124
|
-
return _context3.abrupt("return", installation);
|
|
125
|
-
case 26:
|
|
126
|
-
case "end":
|
|
127
|
-
return _context3.stop();
|
|
128
|
-
}
|
|
129
|
-
}, _callee3);
|
|
130
|
-
}))();
|
|
41
|
+
async currentInstallation() {
|
|
42
|
+
if (currentInstallationCache) {
|
|
43
|
+
return currentInstallationCache;
|
|
44
|
+
}
|
|
45
|
+
if (currentInstallationCacheMatchesDisk) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const path = _Storage.default.generatePath(CURRENT_INSTALLATION_KEY);
|
|
49
|
+
let installationData = await _Storage.default.getItemAsync(path);
|
|
50
|
+
currentInstallationCacheMatchesDisk = true;
|
|
51
|
+
if (installationData) {
|
|
52
|
+
installationData = JSON.parse(installationData);
|
|
53
|
+
installationData.className = '_Installation';
|
|
54
|
+
const current = _ParseInstallation.default.fromJSON(installationData);
|
|
55
|
+
currentInstallationCache = current;
|
|
56
|
+
return current;
|
|
57
|
+
}
|
|
58
|
+
const installationId = await this.currentInstallationId();
|
|
59
|
+
const installation = new _ParseInstallation.default();
|
|
60
|
+
installation.set('deviceType', _ParseInstallation.default.DEVICE_TYPES.WEB);
|
|
61
|
+
installation.set('installationId', installationId);
|
|
62
|
+
installation.set('parseVersion', _CoreManager.default.get('VERSION'));
|
|
63
|
+
currentInstallationCache = installation;
|
|
64
|
+
await _Storage.default.setItemAsync(path, (0, _stringify.default)(installation.toJSON()));
|
|
65
|
+
return installation;
|
|
131
66
|
},
|
|
132
|
-
_clearCache
|
|
67
|
+
_clearCache() {
|
|
133
68
|
iidCache = null;
|
|
134
69
|
currentInstallationCache = null;
|
|
135
70
|
currentInstallationCacheMatchesDisk = false;
|
|
136
71
|
},
|
|
137
|
-
_setInstallationIdCache
|
|
72
|
+
_setInstallationIdCache(iid) {
|
|
138
73
|
iidCache = iid;
|
|
139
74
|
},
|
|
140
|
-
_setCurrentInstallationCache
|
|
141
|
-
|
|
75
|
+
_setCurrentInstallationCache(installation) {
|
|
76
|
+
let matchesDisk = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
142
77
|
currentInstallationCache = installation;
|
|
143
78
|
currentInstallationCacheMatchesDisk = matchesDisk;
|
|
144
79
|
}
|
|
145
80
|
};
|
|
146
81
|
module.exports = InstallationController;
|
|
147
|
-
var _default = InstallationController;
|
|
148
|
-
exports.default = _default;
|
|
82
|
+
var _default = exports.default = InstallationController;
|