parse 5.1.1-alpha.1 → 5.2.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 +10186 -14918
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +10180 -15057
- 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 +24 -46
- 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 -446
- package/lib/browser/LiveQuerySubscription.js +25 -28
- package/lib/browser/LocalDatastore.js +254 -578
- package/lib/browser/LocalDatastoreController.default.js +48 -227
- package/lib/browser/LocalDatastoreController.js +11 -1
- package/lib/browser/LocalDatastoreController.react-native.js +72 -164
- package/lib/browser/LocalDatastoreUtils.js +4 -12
- package/lib/browser/ObjectStateMutations.js +89 -95
- package/lib/browser/OfflineQuery.js +106 -198
- package/lib/browser/Parse.js +45 -61
- package/lib/browser/ParseACL.js +242 -288
- package/lib/browser/ParseCLP.js +372 -580
- package/lib/browser/ParseConfig.js +115 -138
- package/lib/browser/ParseError.js +85 -182
- package/lib/browser/ParseFile.js +296 -444
- package/lib/browser/ParseGeoPoint.js +121 -140
- package/lib/browser/ParseHooks.js +12 -14
- package/lib/browser/ParseInstallation.js +226 -354
- package/lib/browser/ParseLiveQuery.js +74 -148
- package/lib/browser/ParseObject.js +2017 -2622
- package/lib/browser/ParseOp.js +343 -484
- package/lib/browser/ParsePolygon.js +101 -120
- package/lib/browser/ParseQuery.js +1722 -2068
- package/lib/browser/ParseRelation.js +99 -118
- package/lib/browser/ParseRole.js +88 -144
- package/lib/browser/ParseSchema.js +372 -434
- package/lib/browser/ParseSession.js +62 -110
- package/lib/browser/ParseUser.js +942 -1270
- package/lib/browser/Push.js +16 -44
- 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 +37 -49
- 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 +2 -6
- package/lib/node/AnonymousUtils.js +7 -12
- package/lib/node/Cloud.js +8 -12
- 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 +18 -37
- package/lib/node/FacebookUtils.js +1 -5
- package/lib/node/IndexedDBStorageController.js +14 -10
- package/lib/node/InstallationController.js +7 -8
- package/lib/node/LiveQueryClient.js +20 -32
- package/lib/node/LiveQuerySubscription.js +3 -4
- package/lib/node/LocalDatastore.js +20 -24
- package/lib/node/LocalDatastoreController.default.js +12 -11
- package/lib/node/LocalDatastoreController.js +14 -1
- package/lib/node/LocalDatastoreController.react-native.js +27 -22
- package/lib/node/LocalDatastoreUtils.js +4 -12
- package/lib/node/ObjectStateMutations.js +52 -36
- package/lib/node/OfflineQuery.js +37 -23
- package/lib/node/Parse.js +35 -49
- package/lib/node/ParseACL.js +18 -27
- package/lib/node/ParseCLP.js +38 -50
- package/lib/node/ParseConfig.js +7 -14
- package/lib/node/ParseError.js +457 -458
- package/lib/node/ParseFile.js +33 -66
- package/lib/node/ParseGeoPoint.js +22 -17
- package/lib/node/ParseHooks.js +0 -2
- package/lib/node/ParseInstallation.js +21 -8
- package/lib/node/ParseLiveQuery.js +6 -11
- package/lib/node/ParseObject.js +138 -167
- package/lib/node/ParseOp.js +32 -44
- package/lib/node/ParsePolygon.js +11 -17
- package/lib/node/ParseQuery.js +118 -164
- package/lib/node/ParseRelation.js +7 -16
- package/lib/node/ParseRole.js +7 -13
- package/lib/node/ParseSchema.js +26 -39
- package/lib/node/ParseSession.js +7 -8
- package/lib/node/ParseUser.js +70 -76
- package/lib/node/Push.js +5 -15
- package/lib/node/RESTController.js +21 -33
- package/lib/node/SingleInstanceStateController.js +41 -69
- package/lib/node/Socket.weapp.js +23 -2
- package/lib/node/Storage.js +11 -16
- 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 +17 -17
- package/lib/node/StorageController.weapp.js +14 -8
- package/lib/node/TaskQueue.js +8 -11
- package/lib/node/UniqueInstanceStateController.js +40 -60
- package/lib/node/WebSocketController.js +15 -2
- package/lib/node/Xhr.weapp.js +11 -2
- package/lib/node/arrayContainsObject.js +1 -1
- package/lib/node/canBeSerialized.js +2 -2
- package/lib/node/decode.js +1 -1
- package/lib/node/encode.js +2 -2
- package/lib/node/equals.js +1 -1
- 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 +2 -2
- package/lib/node/unsavedChildren.js +2 -2
- 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/Cloud.js +0 -1
- 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 +51 -36
- package/lib/react-native/LiveQuerySubscription.js +2 -4
- package/lib/react-native/LocalDatastore.js +41 -17
- package/lib/react-native/LocalDatastoreController.default.js +6 -1
- package/lib/react-native/LocalDatastoreController.js +11 -1
- package/lib/react-native/LocalDatastoreController.react-native.js +16 -11
- package/lib/react-native/LocalDatastoreUtils.js +3 -6
- package/lib/react-native/ObjectStateMutations.js +30 -9
- 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 +5 -7
- package/lib/react-native/ParseConfig.js +4 -6
- package/lib/react-native/ParseError.js +13 -31
- package/lib/react-native/ParseFile.js +10 -10
- 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 +81 -90
- package/lib/react-native/ParseOp.js +41 -79
- package/lib/react-native/ParsePolygon.js +2 -4
- package/lib/react-native/ParseQuery.js +87 -81
- package/lib/react-native/ParseRelation.js +2 -4
- package/lib/react-native/ParseRole.js +14 -31
- package/lib/react-native/ParseSchema.js +3 -5
- package/lib/react-native/ParseSession.js +12 -29
- package/lib/react-native/ParseUser.js +32 -51
- 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 +8 -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 +24 -46
- 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 -446
- package/lib/weapp/LiveQuerySubscription.js +25 -28
- package/lib/weapp/LocalDatastore.js +254 -578
- package/lib/weapp/LocalDatastoreController.default.js +48 -227
- package/lib/weapp/LocalDatastoreController.js +11 -1
- package/lib/weapp/LocalDatastoreController.react-native.js +72 -164
- package/lib/weapp/LocalDatastoreUtils.js +4 -12
- package/lib/weapp/ObjectStateMutations.js +89 -95
- package/lib/weapp/OfflineQuery.js +106 -198
- package/lib/weapp/Parse.js +45 -60
- package/lib/weapp/ParseACL.js +242 -288
- package/lib/weapp/ParseCLP.js +372 -580
- package/lib/weapp/ParseConfig.js +115 -138
- package/lib/weapp/ParseError.js +85 -182
- package/lib/weapp/ParseFile.js +297 -446
- package/lib/weapp/ParseGeoPoint.js +121 -140
- package/lib/weapp/ParseHooks.js +12 -14
- package/lib/weapp/ParseInstallation.js +226 -354
- package/lib/weapp/ParseLiveQuery.js +74 -148
- package/lib/weapp/ParseObject.js +2017 -2622
- package/lib/weapp/ParseOp.js +343 -484
- package/lib/weapp/ParsePolygon.js +101 -120
- package/lib/weapp/ParseQuery.js +1722 -2068
- package/lib/weapp/ParseRelation.js +99 -118
- package/lib/weapp/ParseRole.js +88 -144
- package/lib/weapp/ParseSchema.js +372 -434
- package/lib/weapp/ParseSession.js +62 -110
- package/lib/weapp/ParseUser.js +942 -1270
- package/lib/weapp/Push.js +16 -44
- 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 +37 -49
- 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 +23 -30
|
@@ -6,21 +6,12 @@ _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
|
-
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
11
9
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
12
10
|
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
13
|
-
var
|
|
14
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
|
|
15
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
16
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
11
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
17
12
|
var _LiveQueryClient = _interopRequireDefault(require("./LiveQueryClient"));
|
|
18
13
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
19
|
-
|
|
20
|
-
* @flow
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
function getLiveQueryClient() /*: Promise<LiveQueryClient>*/{
|
|
14
|
+
function getLiveQueryClient() {
|
|
24
15
|
return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
|
|
25
16
|
}
|
|
26
17
|
|
|
@@ -51,161 +42,96 @@ function getLiveQueryClient() /*: Promise<LiveQueryClient>*/{
|
|
|
51
42
|
* @class Parse.LiveQuery
|
|
52
43
|
* @static
|
|
53
44
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
class LiveQuery {
|
|
46
|
+
constructor() {
|
|
56
47
|
var _this = this;
|
|
57
|
-
(0,
|
|
58
|
-
|
|
48
|
+
(0, _defineProperty2.default)(this, "emitter", void 0);
|
|
49
|
+
(0, _defineProperty2.default)(this, "on", void 0);
|
|
50
|
+
(0, _defineProperty2.default)(this, "emit", void 0);
|
|
51
|
+
const EventEmitter = _CoreManager.default.getEventEmitter();
|
|
59
52
|
this.emitter = new EventEmitter();
|
|
60
|
-
this.on =
|
|
61
|
-
return _this.emitter.on(eventName, listener);
|
|
62
|
-
};
|
|
53
|
+
this.on = (eventName, listener) => this.emitter.on(eventName, listener);
|
|
63
54
|
this.emit = function (eventName) {
|
|
64
|
-
var _this$emitter, _context;
|
|
65
55
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
66
56
|
args[_key - 1] = arguments[_key];
|
|
67
57
|
}
|
|
68
|
-
return
|
|
58
|
+
return _this.emitter.emit(eventName, ...args);
|
|
69
59
|
};
|
|
70
60
|
// adding listener so process does not crash
|
|
71
61
|
// best practice is for developer to register their own listener
|
|
72
|
-
this.on('error',
|
|
62
|
+
this.on('error', () => {});
|
|
73
63
|
}
|
|
74
64
|
|
|
75
65
|
/**
|
|
76
66
|
* After open is called, the LiveQuery will try to send a connect request
|
|
77
67
|
* to the LiveQuery server.
|
|
78
68
|
*/
|
|
79
|
-
(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
return open;
|
|
102
|
-
}()
|
|
103
|
-
/**
|
|
104
|
-
* When you're done using LiveQuery, you can call Parse.LiveQuery.close().
|
|
105
|
-
* This function will close the WebSocket connection to the LiveQuery server,
|
|
106
|
-
* cancel the auto reconnect, and unsubscribe all subscriptions based on it.
|
|
107
|
-
* If you call query.subscribe() after this, we'll create a new WebSocket
|
|
108
|
-
* connection to the LiveQuery server.
|
|
109
|
-
*/
|
|
110
|
-
}, {
|
|
111
|
-
key: "close",
|
|
112
|
-
value: function () {
|
|
113
|
-
var _close = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
114
|
-
var liveQueryClient;
|
|
115
|
-
return _regenerator.default.wrap(function (_context3) {
|
|
116
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
117
|
-
case 0:
|
|
118
|
-
_context3.next = 2;
|
|
119
|
-
return getLiveQueryClient();
|
|
120
|
-
case 2:
|
|
121
|
-
liveQueryClient = _context3.sent;
|
|
122
|
-
liveQueryClient.close();
|
|
123
|
-
case 4:
|
|
124
|
-
case "end":
|
|
125
|
-
return _context3.stop();
|
|
126
|
-
}
|
|
127
|
-
}, _callee2);
|
|
128
|
-
}));
|
|
129
|
-
function close() {
|
|
130
|
-
return _close.apply(this, arguments);
|
|
131
|
-
}
|
|
132
|
-
return close;
|
|
133
|
-
}()
|
|
134
|
-
}]);
|
|
135
|
-
return LiveQuery;
|
|
136
|
-
}();
|
|
137
|
-
var _default = LiveQuery;
|
|
138
|
-
exports.default = _default;
|
|
139
|
-
var defaultLiveQueryClient;
|
|
140
|
-
var DefaultLiveQueryController = {
|
|
141
|
-
setDefaultLiveQueryClient: function (liveQueryClient /*: LiveQueryClient*/) {
|
|
69
|
+
async open() {
|
|
70
|
+
const liveQueryClient = await getLiveQueryClient();
|
|
71
|
+
liveQueryClient.open();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* When you're done using LiveQuery, you can call Parse.LiveQuery.close().
|
|
76
|
+
* This function will close the WebSocket connection to the LiveQuery server,
|
|
77
|
+
* cancel the auto reconnect, and unsubscribe all subscriptions based on it.
|
|
78
|
+
* If you call query.subscribe() after this, we'll create a new WebSocket
|
|
79
|
+
* connection to the LiveQuery server.
|
|
80
|
+
*/
|
|
81
|
+
async close() {
|
|
82
|
+
const liveQueryClient = await getLiveQueryClient();
|
|
83
|
+
liveQueryClient.close();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
var _default = exports.default = LiveQuery;
|
|
87
|
+
let defaultLiveQueryClient;
|
|
88
|
+
const DefaultLiveQueryController = {
|
|
89
|
+
setDefaultLiveQueryClient(liveQueryClient) {
|
|
142
90
|
defaultLiveQueryClient = liveQueryClient;
|
|
143
91
|
},
|
|
144
|
-
getDefaultLiveQueryClient
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
javascriptKey: javascriptKey,
|
|
186
|
-
masterKey: masterKey,
|
|
187
|
-
sessionToken: sessionToken,
|
|
188
|
-
installationId: installationId
|
|
189
|
-
});
|
|
190
|
-
LiveQuery = _CoreManager.default.getLiveQuery();
|
|
191
|
-
defaultLiveQueryClient.on('error', function (error) {
|
|
192
|
-
LiveQuery.emit('error', error);
|
|
193
|
-
});
|
|
194
|
-
defaultLiveQueryClient.on('open', function () {
|
|
195
|
-
LiveQuery.emit('open');
|
|
196
|
-
});
|
|
197
|
-
defaultLiveQueryClient.on('close', function () {
|
|
198
|
-
LiveQuery.emit('close');
|
|
199
|
-
});
|
|
200
|
-
return _context4.abrupt("return", defaultLiveQueryClient);
|
|
201
|
-
case 22:
|
|
202
|
-
case "end":
|
|
203
|
-
return _context4.stop();
|
|
204
|
-
}
|
|
205
|
-
}, _callee3);
|
|
206
|
-
}))();
|
|
92
|
+
async getDefaultLiveQueryClient() {
|
|
93
|
+
if (defaultLiveQueryClient) {
|
|
94
|
+
return defaultLiveQueryClient;
|
|
95
|
+
}
|
|
96
|
+
const [currentUser, installationId] = await _promise.default.all([_CoreManager.default.getUserController().currentUserAsync(), _CoreManager.default.getInstallationController().currentInstallationId()]);
|
|
97
|
+
const sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
|
|
98
|
+
let liveQueryServerURL = _CoreManager.default.get('LIVEQUERY_SERVER_URL');
|
|
99
|
+
if (liveQueryServerURL && (0, _indexOf.default)(liveQueryServerURL).call(liveQueryServerURL, 'ws') !== 0) {
|
|
100
|
+
throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// If we can not find Parse.liveQueryServerURL, we try to extract it from Parse.serverURL
|
|
104
|
+
if (!liveQueryServerURL) {
|
|
105
|
+
const serverURL = _CoreManager.default.get('SERVER_URL');
|
|
106
|
+
const protocol = (0, _indexOf.default)(serverURL).call(serverURL, 'https') === 0 ? 'wss://' : 'ws://';
|
|
107
|
+
const host = serverURL.replace(/^https?:\/\//, '');
|
|
108
|
+
liveQueryServerURL = protocol + host;
|
|
109
|
+
_CoreManager.default.set('LIVEQUERY_SERVER_URL', liveQueryServerURL);
|
|
110
|
+
}
|
|
111
|
+
const applicationId = _CoreManager.default.get('APPLICATION_ID');
|
|
112
|
+
const javascriptKey = _CoreManager.default.get('JAVASCRIPT_KEY');
|
|
113
|
+
const masterKey = _CoreManager.default.get('MASTER_KEY');
|
|
114
|
+
defaultLiveQueryClient = new _LiveQueryClient.default({
|
|
115
|
+
applicationId,
|
|
116
|
+
serverURL: liveQueryServerURL,
|
|
117
|
+
javascriptKey,
|
|
118
|
+
masterKey,
|
|
119
|
+
sessionToken,
|
|
120
|
+
installationId
|
|
121
|
+
});
|
|
122
|
+
const LiveQuery = _CoreManager.default.getLiveQuery();
|
|
123
|
+
defaultLiveQueryClient.on('error', error => {
|
|
124
|
+
LiveQuery.emit('error', error);
|
|
125
|
+
});
|
|
126
|
+
defaultLiveQueryClient.on('open', () => {
|
|
127
|
+
LiveQuery.emit('open');
|
|
128
|
+
});
|
|
129
|
+
defaultLiveQueryClient.on('close', () => {
|
|
130
|
+
LiveQuery.emit('close');
|
|
131
|
+
});
|
|
132
|
+
return defaultLiveQueryClient;
|
|
207
133
|
},
|
|
208
|
-
_clearCachedDefaultClient
|
|
134
|
+
_clearCachedDefaultClient() {
|
|
209
135
|
defaultLiveQueryClient = null;
|
|
210
136
|
}
|
|
211
137
|
};
|