parse 4.0.1-beta.1 → 4.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/parse.js +17994 -26193
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +8738 -17728
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Analytics.js +2 -20
- package/lib/browser/AnonymousUtils.js +6 -35
- package/lib/browser/Cloud.js +12 -70
- package/lib/browser/CloudCode.js +0 -3
- package/lib/browser/CoreManager.js +46 -184
- package/lib/browser/CryptoController.js +2 -16
- package/lib/browser/EventEmitter.js +1 -1
- package/lib/browser/EventuallyQueue.js +277 -824
- package/lib/browser/FacebookUtils.js +6 -35
- package/lib/browser/IndexedDBStorageController.js +3 -14
- package/lib/browser/InstallationController.js +2 -13
- package/lib/browser/LiveQueryClient.js +87 -204
- package/lib/browser/LiveQuerySubscription.js +10 -39
- package/lib/browser/LocalDatastore.js +451 -1081
- package/lib/browser/LocalDatastoreController.js +145 -602
- package/lib/browser/LocalDatastoreController.react-native.js +137 -573
- package/lib/browser/LocalDatastoreUtils.js +2 -12
- package/lib/browser/ObjectStateMutations.js +18 -121
- package/lib/browser/OfflineQuery.js +42 -222
- package/lib/browser/Parse.js +12 -106
- package/lib/browser/ParseACL.js +33 -141
- package/lib/browser/ParseCLP.js +96 -314
- package/lib/browser/ParseConfig.js +18 -88
- package/lib/browser/ParseError.js +63 -90
- package/lib/browser/ParseFile.js +128 -685
- package/lib/browser/ParseGeoPoint.js +23 -82
- package/lib/browser/ParseHooks.js +1 -34
- package/lib/browser/ParseInstallation.js +4 -32
- package/lib/browser/ParseLiveQuery.js +96 -505
- package/lib/browser/ParseObject.js +628 -1840
- package/lib/browser/ParseOp.js +41 -287
- package/lib/browser/ParsePolygon.js +13 -63
- package/lib/browser/ParseQuery.js +404 -1505
- package/lib/browser/ParseRelation.js +12 -61
- package/lib/browser/ParseRole.js +13 -75
- package/lib/browser/ParseSchema.js +49 -201
- package/lib/browser/ParseSession.js +11 -69
- package/lib/browser/ParseUser.js +274 -1127
- package/lib/browser/Push.js +7 -43
- package/lib/browser/RESTController.js +18 -140
- package/lib/browser/SingleInstanceStateController.js +19 -137
- package/lib/browser/Socket.weapp.js +2 -12
- package/lib/browser/Storage.js +10 -73
- package/lib/browser/StorageController.browser.js +4 -17
- package/lib/browser/StorageController.default.js +4 -17
- package/lib/browser/StorageController.react-native.js +6 -33
- package/lib/browser/StorageController.weapp.js +5 -16
- package/lib/browser/TaskQueue.js +1 -22
- package/lib/browser/UniqueInstanceStateController.js +19 -142
- package/lib/browser/Xhr.weapp.js +0 -17
- package/lib/browser/arrayContainsObject.js +2 -16
- package/lib/browser/canBeSerialized.js +3 -33
- package/lib/browser/decode.js +3 -33
- package/lib/browser/encode.js +9 -70
- package/lib/browser/equals.js +2 -25
- package/lib/browser/escape.js +1 -8
- package/lib/browser/isRevocableSession.js +2 -11
- package/lib/browser/parseDate.js +2 -13
- package/lib/browser/promiseUtils.js +3 -21
- package/lib/browser/unique.js +3 -17
- package/lib/browser/unsavedChildren.js +6 -50
- package/lib/browser/uuid.js +3 -1
- package/lib/node/Analytics.js +1 -18
- package/lib/node/AnonymousUtils.js +5 -37
- package/lib/node/Cloud.js +10 -66
- package/lib/node/CloudCode.js +0 -3
- package/lib/node/CoreManager.js +47 -220
- package/lib/node/CryptoController.js +2 -16
- package/lib/node/EventEmitter.js +1 -1
- package/lib/node/EventuallyQueue.js +16 -123
- package/lib/node/FacebookUtils.js +5 -37
- package/lib/node/IndexedDBStorageController.js +3 -19
- package/lib/node/InstallationController.js +2 -15
- package/lib/node/LiveQueryClient.js +56 -136
- package/lib/node/LiveQuerySubscription.js +7 -16
- package/lib/node/LocalDatastore.js +19 -175
- package/lib/node/LocalDatastoreController.js +6 -38
- package/lib/node/LocalDatastoreController.react-native.js +6 -45
- package/lib/node/LocalDatastoreUtils.js +1 -6
- package/lib/node/ObjectStateMutations.js +13 -93
- package/lib/node/OfflineQuery.js +20 -152
- package/lib/node/Parse.js +11 -99
- package/lib/node/ParseACL.js +32 -150
- package/lib/node/ParseCLP.js +69 -262
- package/lib/node/ParseConfig.js +16 -84
- package/lib/node/ParseError.js +61 -65
- package/lib/node/ParseFile.js +49 -205
- package/lib/node/ParseGeoPoint.js +21 -82
- package/lib/node/ParseHooks.js +0 -35
- package/lib/node/ParseInstallation.js +1 -10
- package/lib/node/ParseLiveQuery.js +10 -36
- package/lib/node/ParseObject.js +193 -939
- package/lib/node/ParseOp.js +31 -255
- package/lib/node/ParsePolygon.js +12 -62
- package/lib/node/ParseQuery.js +170 -882
- package/lib/node/ParseRelation.js +11 -61
- package/lib/node/ParseRole.js +10 -57
- package/lib/node/ParseSchema.js +46 -222
- package/lib/node/ParseSession.js +8 -50
- package/lib/node/ParseUser.js +107 -576
- package/lib/node/Push.js +4 -37
- package/lib/node/RESTController.js +8 -110
- package/lib/node/SingleInstanceStateController.js +17 -130
- package/lib/node/Socket.weapp.js +2 -9
- package/lib/node/Storage.js +10 -83
- package/lib/node/StorageController.browser.js +4 -23
- package/lib/node/StorageController.default.js +5 -21
- package/lib/node/StorageController.react-native.js +6 -40
- package/lib/node/StorageController.weapp.js +6 -21
- package/lib/node/TaskQueue.js +1 -17
- package/lib/node/UniqueInstanceStateController.js +16 -133
- package/lib/node/Xhr.weapp.js +0 -15
- package/lib/node/arrayContainsObject.js +1 -12
- package/lib/node/canBeSerialized.js +2 -28
- package/lib/node/decode.js +1 -26
- package/lib/node/encode.js +3 -54
- package/lib/node/equals.js +0 -18
- package/lib/node/escape.js +1 -6
- package/lib/node/isRevocableSession.js +1 -5
- package/lib/node/parseDate.js +1 -7
- package/lib/node/promiseUtils.js +2 -14
- package/lib/node/unique.js +1 -11
- package/lib/node/unsavedChildren.js +2 -38
- package/lib/node/uuid.js +6 -1
- package/lib/react-native/Analytics.js +0 -9
- package/lib/react-native/AnonymousUtils.js +0 -10
- package/lib/react-native/Cloud.js +0 -26
- package/lib/react-native/CoreManager.js +1 -5
- package/lib/react-native/CryptoController.js +0 -2
- package/lib/react-native/EventEmitter.js +0 -2
- package/lib/react-native/EventuallyQueue.js +4 -52
- package/lib/react-native/FacebookUtils.js +0 -22
- package/lib/react-native/IndexedDBStorageController.js +0 -1
- package/lib/react-native/InstallationController.js +0 -6
- package/lib/react-native/LiveQueryClient.js +24 -101
- package/lib/react-native/LiveQuerySubscription.js +3 -27
- package/lib/react-native/LocalDatastore.js +6 -113
- package/lib/react-native/LocalDatastoreController.js +0 -21
- package/lib/react-native/LocalDatastoreController.react-native.js +4 -31
- package/lib/react-native/LocalDatastoreUtils.js +0 -1
- package/lib/react-native/ObjectStateMutations.js +0 -34
- package/lib/react-native/OfflineQuery.js +2 -137
- package/lib/react-native/Parse.js +0 -65
- package/lib/react-native/ParseACL.js +0 -44
- package/lib/react-native/ParseCLP.js +32 -96
- package/lib/react-native/ParseConfig.js +0 -42
- package/lib/react-native/ParseError.js +1 -21
- package/lib/react-native/ParseFile.js +3 -72
- package/lib/react-native/ParseGeoPoint.js +0 -17
- package/lib/react-native/ParseHooks.js +0 -30
- package/lib/react-native/ParseInstallation.js +1 -23
- package/lib/react-native/ParseLiveQuery.js +3 -25
- package/lib/react-native/ParseObject.js +4 -371
- package/lib/react-native/ParseOp.js +1 -138
- package/lib/react-native/ParsePolygon.js +0 -24
- package/lib/react-native/ParseQuery.js +6 -262
- package/lib/react-native/ParseRelation.js +0 -25
- package/lib/react-native/ParseRole.js +1 -36
- package/lib/react-native/ParseSchema.js +0 -51
- package/lib/react-native/ParseSession.js +1 -40
- package/lib/react-native/ParseUser.js +1 -224
- package/lib/react-native/Push.js +0 -16
- package/lib/react-native/RESTController.js +1 -70
- package/lib/react-native/SingleInstanceStateController.js +0 -44
- package/lib/react-native/Socket.weapp.js +2 -12
- package/lib/react-native/Storage.js +0 -24
- package/lib/react-native/StorageController.browser.js +0 -2
- package/lib/react-native/StorageController.default.js +0 -1
- package/lib/react-native/StorageController.react-native.js +0 -2
- package/lib/react-native/TaskQueue.js +0 -15
- package/lib/react-native/UniqueInstanceStateController.js +0 -47
- package/lib/react-native/Xhr.weapp.js +0 -16
- package/lib/react-native/arrayContainsObject.js +0 -5
- package/lib/react-native/canBeSerialized.js +0 -18
- package/lib/react-native/decode.js +0 -21
- package/lib/react-native/encode.js +0 -25
- package/lib/react-native/equals.js +0 -18
- package/lib/react-native/escape.js +0 -1
- package/lib/react-native/isRevocableSession.js +0 -1
- package/lib/react-native/parseDate.js +0 -3
- package/lib/react-native/promiseUtils.js +0 -13
- package/lib/react-native/unique.js +0 -4
- package/lib/react-native/unsavedChildren.js +0 -21
- package/lib/react-native/uuid.js +3 -1
- package/lib/weapp/Analytics.js +2 -20
- package/lib/weapp/AnonymousUtils.js +6 -35
- package/lib/weapp/Cloud.js +12 -70
- package/lib/weapp/CloudCode.js +0 -3
- package/lib/weapp/CoreManager.js +46 -184
- package/lib/weapp/CryptoController.js +2 -16
- package/lib/weapp/EventEmitter.js +1 -1
- package/lib/weapp/EventuallyQueue.js +277 -824
- package/lib/weapp/FacebookUtils.js +6 -35
- package/lib/weapp/IndexedDBStorageController.js +3 -14
- package/lib/weapp/InstallationController.js +2 -13
- package/lib/weapp/LiveQueryClient.js +87 -204
- package/lib/weapp/LiveQuerySubscription.js +10 -39
- package/lib/weapp/LocalDatastore.js +451 -1081
- package/lib/weapp/LocalDatastoreController.js +145 -602
- package/lib/weapp/LocalDatastoreController.react-native.js +137 -573
- package/lib/weapp/LocalDatastoreUtils.js +2 -12
- package/lib/weapp/ObjectStateMutations.js +18 -121
- package/lib/weapp/OfflineQuery.js +42 -222
- package/lib/weapp/Parse.js +12 -106
- package/lib/weapp/ParseACL.js +33 -141
- package/lib/weapp/ParseCLP.js +96 -314
- package/lib/weapp/ParseConfig.js +18 -88
- package/lib/weapp/ParseError.js +63 -90
- package/lib/weapp/ParseFile.js +129 -686
- package/lib/weapp/ParseGeoPoint.js +23 -82
- package/lib/weapp/ParseHooks.js +1 -34
- package/lib/weapp/ParseInstallation.js +4 -32
- package/lib/weapp/ParseLiveQuery.js +96 -505
- package/lib/weapp/ParseObject.js +628 -1840
- package/lib/weapp/ParseOp.js +41 -287
- package/lib/weapp/ParsePolygon.js +13 -63
- package/lib/weapp/ParseQuery.js +404 -1505
- package/lib/weapp/ParseRelation.js +12 -61
- package/lib/weapp/ParseRole.js +13 -75
- package/lib/weapp/ParseSchema.js +49 -201
- package/lib/weapp/ParseSession.js +11 -69
- package/lib/weapp/ParseUser.js +274 -1127
- package/lib/weapp/Push.js +7 -43
- package/lib/weapp/RESTController.js +18 -140
- package/lib/weapp/SingleInstanceStateController.js +19 -137
- package/lib/weapp/Socket.weapp.js +2 -12
- package/lib/weapp/Storage.js +10 -73
- package/lib/weapp/StorageController.browser.js +4 -17
- package/lib/weapp/StorageController.default.js +4 -17
- package/lib/weapp/StorageController.react-native.js +6 -33
- package/lib/weapp/StorageController.weapp.js +5 -16
- package/lib/weapp/TaskQueue.js +1 -22
- package/lib/weapp/UniqueInstanceStateController.js +19 -142
- package/lib/weapp/Xhr.weapp.js +0 -17
- package/lib/weapp/arrayContainsObject.js +2 -16
- package/lib/weapp/canBeSerialized.js +3 -33
- package/lib/weapp/decode.js +3 -33
- package/lib/weapp/encode.js +9 -70
- package/lib/weapp/equals.js +2 -25
- package/lib/weapp/escape.js +1 -8
- package/lib/weapp/isRevocableSession.js +2 -11
- package/lib/weapp/parseDate.js +2 -13
- package/lib/weapp/promiseUtils.js +3 -21
- package/lib/weapp/unique.js +3 -17
- package/lib/weapp/unsavedChildren.js +6 -50
- package/lib/weapp/uuid.js +1 -6
- package/package.json +48 -46
|
@@ -1,55 +1,37 @@
|
|
|
1
1
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
3
|
value: true
|
|
5
4
|
});
|
|
6
5
|
exports.default = void 0;
|
|
7
|
-
|
|
8
6
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
|
|
10
7
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
|
|
12
8
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
-
|
|
14
9
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
15
|
-
|
|
16
10
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
17
|
-
|
|
18
11
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
19
|
-
|
|
20
12
|
var _EventEmitter2 = _interopRequireDefault(require("./EventEmitter"));
|
|
21
|
-
|
|
22
13
|
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
23
|
-
|
|
24
14
|
var _LiveQuerySubscription = _interopRequireDefault(require("./LiveQuerySubscription"));
|
|
25
|
-
|
|
26
15
|
var _promiseUtils = require("./promiseUtils");
|
|
27
|
-
|
|
28
16
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
29
|
-
|
|
30
17
|
function _createSuper(Derived) {
|
|
31
18
|
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
32
|
-
|
|
33
19
|
return function () {
|
|
34
20
|
var Super = (0, _getPrototypeOf2.default)(Derived),
|
|
35
|
-
|
|
36
|
-
|
|
21
|
+
result;
|
|
37
22
|
if (hasNativeReflectConstruct) {
|
|
38
23
|
var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
|
|
39
24
|
result = Reflect.construct(Super, arguments, NewTarget);
|
|
40
25
|
} else {
|
|
41
26
|
result = Super.apply(this, arguments);
|
|
42
27
|
}
|
|
43
|
-
|
|
44
28
|
return (0, _possibleConstructorReturn2.default)(this, result);
|
|
45
29
|
};
|
|
46
30
|
}
|
|
47
|
-
|
|
48
31
|
function _isNativeReflectConstruct() {
|
|
49
32
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
50
33
|
if (Reflect.construct.sham) return false;
|
|
51
34
|
if (typeof Proxy === "function") return true;
|
|
52
|
-
|
|
53
35
|
try {
|
|
54
36
|
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
55
37
|
return true;
|
|
@@ -57,7 +39,6 @@ function _isNativeReflectConstruct() {
|
|
|
57
39
|
return false;
|
|
58
40
|
}
|
|
59
41
|
}
|
|
60
|
-
|
|
61
42
|
var CLIENT_STATE = {
|
|
62
43
|
INITIALIZED: 'initialized',
|
|
63
44
|
CONNECTING: 'connecting',
|
|
@@ -98,32 +79,25 @@ var SUBSCRIPTION_EMMITER_TYPES = {
|
|
|
98
79
|
LEAVE: 'leave',
|
|
99
80
|
DELETE: 'delete'
|
|
100
81
|
};
|
|
101
|
-
|
|
102
82
|
var generateInterval = function (k) {
|
|
103
83
|
return Math.random() * Math.min(30, Math.pow(2, k) - 1) * 1000;
|
|
104
84
|
};
|
|
105
|
-
|
|
106
85
|
var LiveQueryClient = function (_EventEmitter) {
|
|
107
86
|
(0, _inherits2.default)(LiveQueryClient, _EventEmitter);
|
|
108
|
-
|
|
109
87
|
var _super = _createSuper(LiveQueryClient);
|
|
110
|
-
|
|
111
88
|
function LiveQueryClient(_ref) {
|
|
112
89
|
var _this;
|
|
113
|
-
|
|
114
90
|
var applicationId = _ref.applicationId,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
91
|
+
serverURL = _ref.serverURL,
|
|
92
|
+
javascriptKey = _ref.javascriptKey,
|
|
93
|
+
masterKey = _ref.masterKey,
|
|
94
|
+
sessionToken = _ref.sessionToken,
|
|
95
|
+
installationId = _ref.installationId;
|
|
120
96
|
(0, _classCallCheck2.default)(this, LiveQueryClient);
|
|
121
97
|
_this = _super.call(this);
|
|
122
|
-
|
|
123
98
|
if (!serverURL || serverURL.indexOf('ws') !== 0) {
|
|
124
99
|
throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
|
|
125
100
|
}
|
|
126
|
-
|
|
127
101
|
_this.reconnectHandle = null;
|
|
128
102
|
_this.attempts = 1;
|
|
129
103
|
_this.id = 0;
|
|
@@ -138,12 +112,9 @@ var LiveQueryClient = function (_EventEmitter) {
|
|
|
138
112
|
_this.connectPromise = (0, _promiseUtils.resolvingPromise)();
|
|
139
113
|
_this.subscriptions = new Map();
|
|
140
114
|
_this.state = CLIENT_STATE.INITIALIZED;
|
|
141
|
-
|
|
142
115
|
_this.on('error', function () {});
|
|
143
|
-
|
|
144
116
|
return _this;
|
|
145
117
|
}
|
|
146
|
-
|
|
147
118
|
(0, _createClass2.default)(LiveQueryClient, [{
|
|
148
119
|
key: "shouldOpen",
|
|
149
120
|
value: function () {
|
|
@@ -153,11 +124,9 @@ var LiveQueryClient = function (_EventEmitter) {
|
|
|
153
124
|
key: "subscribe",
|
|
154
125
|
value: function (query, sessionToken) {
|
|
155
126
|
var _this2 = this;
|
|
156
|
-
|
|
157
127
|
if (!query) {
|
|
158
128
|
return;
|
|
159
129
|
}
|
|
160
|
-
|
|
161
130
|
var className = query.className;
|
|
162
131
|
var queryJSON = query.toJSON();
|
|
163
132
|
var where = queryJSON.where;
|
|
@@ -171,11 +140,9 @@ var LiveQueryClient = function (_EventEmitter) {
|
|
|
171
140
|
fields: fields
|
|
172
141
|
}
|
|
173
142
|
};
|
|
174
|
-
|
|
175
143
|
if (sessionToken) {
|
|
176
144
|
subscribeRequest.sessionToken = sessionToken;
|
|
177
145
|
}
|
|
178
|
-
|
|
179
146
|
var subscription = new _LiveQuerySubscription.default(this.requestId, query, sessionToken);
|
|
180
147
|
this.subscriptions.set(this.requestId, subscription);
|
|
181
148
|
this.requestId += 1;
|
|
@@ -190,50 +157,43 @@ var LiveQueryClient = function (_EventEmitter) {
|
|
|
190
157
|
key: "unsubscribe",
|
|
191
158
|
value: function (subscription) {
|
|
192
159
|
var _this3 = this;
|
|
193
|
-
|
|
194
160
|
if (!subscription) {
|
|
195
161
|
return;
|
|
196
162
|
}
|
|
197
|
-
|
|
198
|
-
this.subscriptions.delete(subscription.id);
|
|
199
163
|
var unsubscribeRequest = {
|
|
200
164
|
op: OP_TYPES.UNSUBSCRIBE,
|
|
201
165
|
requestId: subscription.id
|
|
202
166
|
};
|
|
203
|
-
this.connectPromise.then(function () {
|
|
204
|
-
_this3.socket.send(JSON.stringify(unsubscribeRequest));
|
|
167
|
+
return this.connectPromise.then(function () {
|
|
168
|
+
return _this3.socket.send(JSON.stringify(unsubscribeRequest));
|
|
169
|
+
}).then(function () {
|
|
170
|
+
return subscription.unsubscribePromise;
|
|
205
171
|
});
|
|
206
172
|
}
|
|
207
173
|
}, {
|
|
208
174
|
key: "open",
|
|
209
175
|
value: function () {
|
|
210
176
|
var _this4 = this;
|
|
211
|
-
|
|
212
177
|
var WebSocketImplementation = _CoreManager.default.getWebSocketController();
|
|
213
|
-
|
|
214
178
|
if (!WebSocketImplementation) {
|
|
215
179
|
this.emit(CLIENT_EMMITER_TYPES.ERROR, 'Can not find WebSocket implementation');
|
|
216
180
|
return;
|
|
217
181
|
}
|
|
218
|
-
|
|
219
182
|
if (this.state !== CLIENT_STATE.RECONNECTING) {
|
|
220
183
|
this.state = CLIENT_STATE.CONNECTING;
|
|
221
184
|
}
|
|
222
|
-
|
|
223
185
|
this.socket = new WebSocketImplementation(this.serverURL);
|
|
224
|
-
|
|
186
|
+
this.socket.closingPromise = (0, _promiseUtils.resolvingPromise)();
|
|
225
187
|
this.socket.onopen = function () {
|
|
226
188
|
_this4._handleWebSocketOpen();
|
|
227
189
|
};
|
|
228
|
-
|
|
229
190
|
this.socket.onmessage = function (event) {
|
|
230
191
|
_this4._handleWebSocketMessage(event);
|
|
231
192
|
};
|
|
232
|
-
|
|
233
|
-
|
|
193
|
+
this.socket.onclose = function (event) {
|
|
194
|
+
_this4.socket.closingPromise.resolve(event);
|
|
234
195
|
_this4._handleWebSocketClose();
|
|
235
196
|
};
|
|
236
|
-
|
|
237
197
|
this.socket.onerror = function (error) {
|
|
238
198
|
_this4._handleWebSocketError(error);
|
|
239
199
|
};
|
|
@@ -242,7 +202,6 @@ var LiveQueryClient = function (_EventEmitter) {
|
|
|
242
202
|
key: "resubscribe",
|
|
243
203
|
value: function () {
|
|
244
204
|
var _this5 = this;
|
|
245
|
-
|
|
246
205
|
this.subscriptions.forEach(function (subscription, requestId) {
|
|
247
206
|
var query = subscription.query;
|
|
248
207
|
var queryJSON = query.toJSON();
|
|
@@ -259,11 +218,9 @@ var LiveQueryClient = function (_EventEmitter) {
|
|
|
259
218
|
fields: fields
|
|
260
219
|
}
|
|
261
220
|
};
|
|
262
|
-
|
|
263
221
|
if (sessionToken) {
|
|
264
222
|
subscribeRequest.sessionToken = sessionToken;
|
|
265
223
|
}
|
|
266
|
-
|
|
267
224
|
_this5.connectPromise.then(function () {
|
|
268
225
|
_this5.socket.send(JSON.stringify(subscribeRequest));
|
|
269
226
|
});
|
|
@@ -272,21 +229,19 @@ var LiveQueryClient = function (_EventEmitter) {
|
|
|
272
229
|
}, {
|
|
273
230
|
key: "close",
|
|
274
231
|
value: function () {
|
|
232
|
+
var _this$socket, _this$socket2;
|
|
275
233
|
if (this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED) {
|
|
276
234
|
return;
|
|
277
235
|
}
|
|
278
|
-
|
|
279
236
|
this.state = CLIENT_STATE.DISCONNECTED;
|
|
280
|
-
this.socket.close();
|
|
281
|
-
|
|
237
|
+
(_this$socket = this.socket) == null ? void 0 : _this$socket.close();
|
|
282
238
|
for (var subscription of this.subscriptions.values()) {
|
|
283
239
|
subscription.subscribed = false;
|
|
284
240
|
subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
|
|
285
241
|
}
|
|
286
|
-
|
|
287
242
|
this._handleReset();
|
|
288
|
-
|
|
289
243
|
this.emit(CLIENT_EMMITER_TYPES.CLOSE);
|
|
244
|
+
return (_this$socket2 = this.socket) == null ? void 0 : _this$socket2.closingPromise;
|
|
290
245
|
}
|
|
291
246
|
}, {
|
|
292
247
|
key: "_handleReset",
|
|
@@ -308,45 +263,36 @@ var LiveQueryClient = function (_EventEmitter) {
|
|
|
308
263
|
masterKey: this.masterKey,
|
|
309
264
|
sessionToken: this.sessionToken
|
|
310
265
|
};
|
|
311
|
-
|
|
312
266
|
if (this.additionalProperties) {
|
|
313
267
|
connectRequest.installationId = this.installationId;
|
|
314
268
|
}
|
|
315
|
-
|
|
316
269
|
this.socket.send(JSON.stringify(connectRequest));
|
|
317
270
|
}
|
|
318
271
|
}, {
|
|
319
272
|
key: "_handleWebSocketMessage",
|
|
320
273
|
value: function (event) {
|
|
321
274
|
var data = event.data;
|
|
322
|
-
|
|
323
275
|
if (typeof data === 'string') {
|
|
324
276
|
data = JSON.parse(data);
|
|
325
277
|
}
|
|
326
|
-
|
|
327
278
|
var subscription = null;
|
|
328
|
-
|
|
329
279
|
if (data.requestId) {
|
|
330
280
|
subscription = this.subscriptions.get(data.requestId);
|
|
331
281
|
}
|
|
332
|
-
|
|
333
282
|
var response = {
|
|
334
283
|
clientId: data.clientId,
|
|
335
284
|
installationId: data.installationId
|
|
336
285
|
};
|
|
337
|
-
|
|
338
286
|
switch (data.op) {
|
|
339
287
|
case OP_EVENTS.CONNECTED:
|
|
340
288
|
if (this.state === CLIENT_STATE.RECONNECTING) {
|
|
341
289
|
this.resubscribe();
|
|
342
290
|
}
|
|
343
|
-
|
|
344
291
|
this.emit(CLIENT_EMMITER_TYPES.OPEN);
|
|
345
292
|
this.id = data.clientId;
|
|
346
293
|
this.connectPromise.resolve();
|
|
347
294
|
this.state = CLIENT_STATE.CONNECTED;
|
|
348
295
|
break;
|
|
349
|
-
|
|
350
296
|
case OP_EVENTS.SUBSCRIBED:
|
|
351
297
|
if (subscription) {
|
|
352
298
|
subscription.subscribed = true;
|
|
@@ -355,18 +301,14 @@ var LiveQueryClient = function (_EventEmitter) {
|
|
|
355
301
|
return subscription.emit(SUBSCRIPTION_EMMITER_TYPES.OPEN, response);
|
|
356
302
|
}, 200);
|
|
357
303
|
}
|
|
358
|
-
|
|
359
304
|
break;
|
|
360
|
-
|
|
361
305
|
case OP_EVENTS.ERROR:
|
|
362
306
|
{
|
|
363
307
|
var parseError = new _ParseError.default(data.code, data.error);
|
|
364
|
-
|
|
365
308
|
if (!this.id) {
|
|
366
309
|
this.connectPromise.reject(parseError);
|
|
367
310
|
this.state = CLIENT_STATE.DISCONNECTED;
|
|
368
311
|
}
|
|
369
|
-
|
|
370
312
|
if (data.requestId) {
|
|
371
313
|
if (subscription) {
|
|
372
314
|
subscription.subscribePromise.reject(parseError);
|
|
@@ -377,54 +319,47 @@ var LiveQueryClient = function (_EventEmitter) {
|
|
|
377
319
|
} else {
|
|
378
320
|
this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error);
|
|
379
321
|
}
|
|
380
|
-
|
|
381
322
|
if (data.error === 'Additional properties not allowed') {
|
|
382
323
|
this.additionalProperties = false;
|
|
383
324
|
}
|
|
384
|
-
|
|
385
325
|
if (data.reconnect) {
|
|
386
326
|
this._handleReconnect();
|
|
387
327
|
}
|
|
388
|
-
|
|
389
328
|
break;
|
|
390
329
|
}
|
|
391
|
-
|
|
392
330
|
case OP_EVENTS.UNSUBSCRIBED:
|
|
393
|
-
|
|
394
|
-
|
|
331
|
+
{
|
|
332
|
+
if (subscription) {
|
|
333
|
+
this.subscriptions.delete(data.requestId);
|
|
334
|
+
subscription.subscribed = false;
|
|
335
|
+
subscription.unsubscribePromise.resolve();
|
|
336
|
+
}
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
395
339
|
default:
|
|
396
340
|
{
|
|
397
341
|
if (!subscription) {
|
|
398
342
|
break;
|
|
399
343
|
}
|
|
400
|
-
|
|
401
344
|
var override = false;
|
|
402
|
-
|
|
403
345
|
if (data.original) {
|
|
404
346
|
override = true;
|
|
405
347
|
delete data.original.__type;
|
|
406
|
-
|
|
407
348
|
for (var field in data.original) {
|
|
408
349
|
if (!(field in data.object)) {
|
|
409
350
|
data.object[field] = undefined;
|
|
410
351
|
}
|
|
411
352
|
}
|
|
412
|
-
|
|
413
353
|
data.original = _ParseObject.default.fromJSON(data.original, false);
|
|
414
354
|
}
|
|
415
|
-
|
|
416
355
|
delete data.object.__type;
|
|
417
|
-
|
|
418
356
|
var parseObject = _ParseObject.default.fromJSON(data.object, !(subscription.query && subscription.query._select) ? override : false);
|
|
419
|
-
|
|
420
357
|
if (data.original) {
|
|
421
358
|
subscription.emit(data.op, parseObject, data.original, response);
|
|
422
359
|
} else {
|
|
423
360
|
subscription.emit(data.op, parseObject, response);
|
|
424
361
|
}
|
|
425
|
-
|
|
426
362
|
var localDatastore = _CoreManager.default.getLocalDatastore();
|
|
427
|
-
|
|
428
363
|
if (override && localDatastore.isEnabled) {
|
|
429
364
|
localDatastore._updateObjectIfPinned(parseObject).then(function () {});
|
|
430
365
|
}
|
|
@@ -437,55 +372,43 @@ var LiveQueryClient = function (_EventEmitter) {
|
|
|
437
372
|
if (this.state === CLIENT_STATE.DISCONNECTED) {
|
|
438
373
|
return;
|
|
439
374
|
}
|
|
440
|
-
|
|
441
375
|
this.state = CLIENT_STATE.CLOSED;
|
|
442
376
|
this.emit(CLIENT_EMMITER_TYPES.CLOSE);
|
|
443
|
-
|
|
444
377
|
for (var subscription of this.subscriptions.values()) {
|
|
445
378
|
subscription.emit(SUBSCRIPTION_EMMITER_TYPES.CLOSE);
|
|
446
379
|
}
|
|
447
|
-
|
|
448
380
|
this._handleReconnect();
|
|
449
381
|
}
|
|
450
382
|
}, {
|
|
451
383
|
key: "_handleWebSocketError",
|
|
452
384
|
value: function (error) {
|
|
453
385
|
this.emit(CLIENT_EMMITER_TYPES.ERROR, error);
|
|
454
|
-
|
|
455
386
|
for (var subscription of this.subscriptions.values()) {
|
|
456
387
|
subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, error);
|
|
457
388
|
}
|
|
458
|
-
|
|
459
389
|
this._handleReconnect();
|
|
460
390
|
}
|
|
461
391
|
}, {
|
|
462
392
|
key: "_handleReconnect",
|
|
463
393
|
value: function () {
|
|
464
394
|
var _this6 = this;
|
|
465
|
-
|
|
466
395
|
if (this.state === CLIENT_STATE.DISCONNECTED) {
|
|
467
396
|
return;
|
|
468
397
|
}
|
|
469
|
-
|
|
470
398
|
this.state = CLIENT_STATE.RECONNECTING;
|
|
471
399
|
var time = generateInterval(this.attempts);
|
|
472
|
-
|
|
473
400
|
if (this.reconnectHandle) {
|
|
474
401
|
clearTimeout(this.reconnectHandle);
|
|
475
402
|
}
|
|
476
|
-
|
|
477
403
|
this.reconnectHandle = setTimeout(function () {
|
|
478
404
|
_this6.attempts++;
|
|
479
405
|
_this6.connectPromise = (0, _promiseUtils.resolvingPromise)();
|
|
480
|
-
|
|
481
406
|
_this6.open();
|
|
482
407
|
}.bind(this), time);
|
|
483
408
|
}
|
|
484
409
|
}]);
|
|
485
410
|
return LiveQueryClient;
|
|
486
411
|
}(_EventEmitter2.default);
|
|
487
|
-
|
|
488
412
|
_CoreManager.default.setWebSocketController(WebSocket);
|
|
489
|
-
|
|
490
413
|
var _default = LiveQueryClient;
|
|
491
414
|
exports.default = _default;
|
|
@@ -1,49 +1,34 @@
|
|
|
1
1
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
3
|
value: true
|
|
5
4
|
});
|
|
6
5
|
exports.default = void 0;
|
|
7
|
-
|
|
8
6
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
|
|
10
7
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
|
|
12
8
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
-
|
|
14
9
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
15
|
-
|
|
16
10
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
17
|
-
|
|
18
11
|
var _EventEmitter2 = _interopRequireDefault(require("./EventEmitter"));
|
|
19
|
-
|
|
20
12
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
21
|
-
|
|
22
13
|
var _promiseUtils = require("./promiseUtils");
|
|
23
|
-
|
|
24
14
|
function _createSuper(Derived) {
|
|
25
15
|
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
26
|
-
|
|
27
16
|
return function () {
|
|
28
17
|
var Super = (0, _getPrototypeOf2.default)(Derived),
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
result;
|
|
31
19
|
if (hasNativeReflectConstruct) {
|
|
32
20
|
var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
|
|
33
21
|
result = Reflect.construct(Super, arguments, NewTarget);
|
|
34
22
|
} else {
|
|
35
23
|
result = Super.apply(this, arguments);
|
|
36
24
|
}
|
|
37
|
-
|
|
38
25
|
return (0, _possibleConstructorReturn2.default)(this, result);
|
|
39
26
|
};
|
|
40
27
|
}
|
|
41
|
-
|
|
42
28
|
function _isNativeReflectConstruct() {
|
|
43
29
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
44
30
|
if (Reflect.construct.sham) return false;
|
|
45
31
|
if (typeof Proxy === "function") return true;
|
|
46
|
-
|
|
47
32
|
try {
|
|
48
33
|
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
49
34
|
return true;
|
|
@@ -51,42 +36,33 @@ function _isNativeReflectConstruct() {
|
|
|
51
36
|
return false;
|
|
52
37
|
}
|
|
53
38
|
}
|
|
54
|
-
|
|
55
39
|
var Subscription = function (_EventEmitter) {
|
|
56
40
|
(0, _inherits2.default)(Subscription, _EventEmitter);
|
|
57
|
-
|
|
58
41
|
var _super = _createSuper(Subscription);
|
|
59
|
-
|
|
60
42
|
function Subscription(id, query, sessionToken) {
|
|
61
43
|
var _this;
|
|
62
|
-
|
|
63
44
|
(0, _classCallCheck2.default)(this, Subscription);
|
|
64
45
|
_this = _super.call(this);
|
|
65
46
|
_this.id = id;
|
|
66
47
|
_this.query = query;
|
|
67
48
|
_this.sessionToken = sessionToken;
|
|
68
49
|
_this.subscribePromise = (0, _promiseUtils.resolvingPromise)();
|
|
50
|
+
_this.unsubscribePromise = (0, _promiseUtils.resolvingPromise)();
|
|
69
51
|
_this.subscribed = false;
|
|
70
|
-
|
|
71
52
|
_this.on('error', function () {});
|
|
72
|
-
|
|
73
53
|
return _this;
|
|
74
54
|
}
|
|
75
|
-
|
|
76
55
|
(0, _createClass2.default)(Subscription, [{
|
|
77
56
|
key: "unsubscribe",
|
|
78
57
|
value: function () {
|
|
79
58
|
var _this2 = this;
|
|
80
|
-
|
|
81
59
|
return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient().then(function (liveQueryClient) {
|
|
82
|
-
liveQueryClient.unsubscribe(_this2);
|
|
83
|
-
|
|
84
60
|
_this2.emit('close');
|
|
61
|
+
return liveQueryClient.unsubscribe(_this2);
|
|
85
62
|
});
|
|
86
63
|
}
|
|
87
64
|
}]);
|
|
88
65
|
return Subscription;
|
|
89
66
|
}(_EventEmitter2.default);
|
|
90
|
-
|
|
91
67
|
var _default = Subscription;
|
|
92
68
|
exports.default = _default;
|