parse 5.2.0-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 +10102 -15029
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +10093 -15165
- 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 +308 -484
- 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 +2 -6
- package/lib/node/AnonymousUtils.js +7 -12
- package/lib/node/Cloud.js +8 -8
- 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 +17 -36
- package/lib/node/FacebookUtils.js +1 -5
- package/lib/node/IndexedDBStorageController.js +14 -10
- package/lib/node/InstallationController.js +9 -10
- package/lib/node/LiveQueryClient.js +12 -14
- package/lib/node/LiveQuerySubscription.js +3 -4
- package/lib/node/LocalDatastore.js +20 -20
- package/lib/node/LocalDatastoreController.default.js +8 -9
- 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 +9 -19
- package/lib/node/OfflineQuery.js +37 -23
- package/lib/node/Parse.js +33 -47
- package/lib/node/ParseACL.js +18 -27
- package/lib/node/ParseCLP.js +35 -37
- package/lib/node/ParseConfig.js +7 -14
- package/lib/node/ParseError.js +457 -458
- package/lib/node/ParseFile.js +24 -44
- package/lib/node/ParseGeoPoint.js +16 -17
- package/lib/node/ParseHooks.js +13 -15
- package/lib/node/ParseInstallation.js +7 -8
- package/lib/node/ParseLiveQuery.js +6 -11
- package/lib/node/ParseObject.js +139 -170
- package/lib/node/ParseOp.js +32 -44
- package/lib/node/ParsePolygon.js +11 -17
- package/lib/node/ParseQuery.js +97 -120
- package/lib/node/ParseRelation.js +7 -16
- package/lib/node/ParseRole.js +7 -8
- package/lib/node/ParseSchema.js +26 -39
- package/lib/node/ParseSession.js +7 -8
- package/lib/node/ParseUser.js +73 -84
- package/lib/node/Push.js +4 -9
- 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 +2 -3
- 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/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 +2 -4
- 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 +308 -484
- 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 +19 -25
|
@@ -1,50 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _uuid = _interopRequireDefault(require("./uuid"));
|
|
3
8
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
4
9
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
5
10
|
var _promiseUtils = require("./promiseUtils");
|
|
11
|
+
var _Xhr = _interopRequireDefault(require("./Xhr.weapp"));
|
|
6
12
|
function _interopRequireDefault(obj) {
|
|
7
13
|
return obj && obj.__esModule ? obj : {
|
|
8
14
|
default: obj
|
|
9
15
|
};
|
|
10
16
|
}
|
|
11
|
-
/**
|
|
12
|
-
* @flow
|
|
13
|
-
*/
|
|
14
17
|
/* global XMLHttpRequest, XDomainRequest */
|
|
15
|
-
|
|
16
|
-
/*:: export type RequestOptions = {
|
|
17
|
-
useMasterKey?: boolean,
|
|
18
|
-
sessionToken?: string,
|
|
19
|
-
installationId?: string,
|
|
20
|
-
returnStatus?: boolean,
|
|
21
|
-
batchSize?: number,
|
|
22
|
-
include?: any,
|
|
23
|
-
progress?: any,
|
|
24
|
-
context?: any,
|
|
25
|
-
usePost?: boolean,
|
|
26
|
-
ignoreEmailVerification?: boolean,
|
|
27
|
-
};*/
|
|
28
|
-
/*:: export type FullOptions = {
|
|
29
|
-
success?: any,
|
|
30
|
-
error?: any,
|
|
31
|
-
useMasterKey?: boolean,
|
|
32
|
-
sessionToken?: string,
|
|
33
|
-
installationId?: string,
|
|
34
|
-
progress?: any,
|
|
35
|
-
usePost?: boolean,
|
|
36
|
-
};*/
|
|
18
|
+
|
|
37
19
|
let XHR = null;
|
|
38
20
|
if (typeof XMLHttpRequest !== 'undefined') {
|
|
39
21
|
XHR = XMLHttpRequest;
|
|
40
22
|
}
|
|
41
23
|
XHR = require('xmlhttprequest').XMLHttpRequest;
|
|
42
24
|
let useXDomainRequest = false;
|
|
25
|
+
// @ts-ignore
|
|
43
26
|
if (typeof XDomainRequest !== 'undefined' && !('withCredentials' in new XMLHttpRequest())) {
|
|
44
27
|
useXDomainRequest = true;
|
|
45
28
|
}
|
|
46
|
-
function ajaxIE9(method
|
|
29
|
+
function ajaxIE9(method, url, data, headers, options) {
|
|
47
30
|
return new Promise((resolve, reject) => {
|
|
31
|
+
// @ts-ignore
|
|
48
32
|
const xdr = new XDomainRequest();
|
|
49
33
|
xdr.onload = function () {
|
|
50
34
|
let response;
|
|
@@ -76,19 +60,21 @@ function ajaxIE9(method /*: string*/, url /*: string*/, data /*: any*/, headers
|
|
|
76
60
|
};
|
|
77
61
|
xdr.open(method, url);
|
|
78
62
|
xdr.send(data);
|
|
63
|
+
// @ts-ignore
|
|
79
64
|
if (options && typeof options.requestTask === 'function') {
|
|
65
|
+
// @ts-ignore
|
|
80
66
|
options.requestTask(xdr);
|
|
81
67
|
}
|
|
82
68
|
});
|
|
83
69
|
}
|
|
84
70
|
const RESTController = {
|
|
85
|
-
ajax(method
|
|
71
|
+
ajax(method, url, data, headers, options) {
|
|
86
72
|
if (useXDomainRequest) {
|
|
87
73
|
return ajaxIE9(method, url, data, headers, options);
|
|
88
74
|
}
|
|
89
75
|
const promise = (0, _promiseUtils.resolvingPromise)();
|
|
90
76
|
const isIdempotent = _CoreManager.default.get('IDEMPOTENCY') && ['POST', 'PUT'].includes(method);
|
|
91
|
-
const requestId = isIdempotent ?
|
|
77
|
+
const requestId = isIdempotent ? (0, _uuid.default)() : '';
|
|
92
78
|
let attempts = 0;
|
|
93
79
|
const dispatch = function () {
|
|
94
80
|
if (XHR == null) {
|
|
@@ -105,7 +91,7 @@ const RESTController = {
|
|
|
105
91
|
let response;
|
|
106
92
|
try {
|
|
107
93
|
response = JSON.parse(xhr.responseText);
|
|
108
|
-
const availableHeaders = typeof xhr.getAllResponseHeaders === 'function' ? xhr.getAllResponseHeaders() :
|
|
94
|
+
const availableHeaders = typeof xhr.getAllResponseHeaders === 'function' ? xhr.getAllResponseHeaders() : '';
|
|
109
95
|
headers = {};
|
|
110
96
|
if (typeof xhr.getResponseHeader === 'function' && (availableHeaders === null || availableHeaders === void 0 ? void 0 : availableHeaders.indexOf('access-control-expose-headers')) >= 0) {
|
|
111
97
|
const responseHeaders = xhr.getResponseHeader('access-control-expose-headers').split(', ');
|
|
@@ -146,7 +132,6 @@ const RESTController = {
|
|
|
146
132
|
if (typeof headers['Content-Type'] !== 'string') {
|
|
147
133
|
headers['Content-Type'] = 'text/plain'; // Avoid pre-flight
|
|
148
134
|
}
|
|
149
|
-
|
|
150
135
|
if (_CoreManager.default.get('IS_NODE')) {
|
|
151
136
|
headers['User-Agent'] = 'Parse/' + _CoreManager.default.get('VERSION') + ' (NodeJS ' + process.versions.node + ')';
|
|
152
137
|
}
|
|
@@ -195,14 +180,16 @@ const RESTController = {
|
|
|
195
180
|
});
|
|
196
181
|
};
|
|
197
182
|
xhr.send(data);
|
|
183
|
+
// @ts-ignore
|
|
198
184
|
if (options && typeof options.requestTask === 'function') {
|
|
185
|
+
// @ts-ignore
|
|
199
186
|
options.requestTask(xhr);
|
|
200
187
|
}
|
|
201
188
|
};
|
|
202
189
|
dispatch();
|
|
203
190
|
return promise;
|
|
204
191
|
},
|
|
205
|
-
request(method
|
|
192
|
+
request(method, path, data, options) {
|
|
206
193
|
options = options || {};
|
|
207
194
|
let url = _CoreManager.default.get('SERVER_URL');
|
|
208
195
|
if (url[url.length - 1] !== '/') {
|
|
@@ -310,11 +297,12 @@ const RESTController = {
|
|
|
310
297
|
}
|
|
311
298
|
return Promise.reject(error);
|
|
312
299
|
},
|
|
313
|
-
_setXHR(xhr
|
|
300
|
+
_setXHR(xhr) {
|
|
314
301
|
XHR = xhr;
|
|
315
302
|
},
|
|
316
303
|
_getXHR() {
|
|
317
304
|
return XHR;
|
|
318
305
|
}
|
|
319
306
|
};
|
|
320
|
-
module.exports = RESTController;
|
|
307
|
+
module.exports = RESTController;
|
|
308
|
+
var _default = exports.default = RESTController;
|
|
@@ -21,68 +21,40 @@ exports.removeState = removeState;
|
|
|
21
21
|
exports.setPendingOp = setPendingOp;
|
|
22
22
|
exports.setServerData = setServerData;
|
|
23
23
|
var ObjectStateMutations = _interopRequireWildcard(require("./ObjectStateMutations"));
|
|
24
|
-
function _getRequireWildcardCache(
|
|
25
|
-
if (typeof WeakMap
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
return (_getRequireWildcardCache = function (
|
|
29
|
-
return
|
|
30
|
-
})(
|
|
31
|
-
}
|
|
32
|
-
function _interopRequireWildcard(
|
|
33
|
-
if (!
|
|
34
|
-
|
|
24
|
+
function _getRequireWildcardCache(e) {
|
|
25
|
+
if ("function" != typeof WeakMap) return null;
|
|
26
|
+
var r = new WeakMap(),
|
|
27
|
+
t = new WeakMap();
|
|
28
|
+
return (_getRequireWildcardCache = function (e) {
|
|
29
|
+
return e ? t : r;
|
|
30
|
+
})(e);
|
|
31
|
+
}
|
|
32
|
+
function _interopRequireWildcard(e, r) {
|
|
33
|
+
if (!r && e && e.__esModule) return e;
|
|
34
|
+
if (null === e || "object" != typeof e && "function" != typeof e) return {
|
|
35
|
+
default: e
|
|
36
|
+
};
|
|
37
|
+
var t = _getRequireWildcardCache(r);
|
|
38
|
+
if (t && t.has(e)) return t.get(e);
|
|
39
|
+
var n = {
|
|
40
|
+
__proto__: null
|
|
41
|
+
},
|
|
42
|
+
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
43
|
+
for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
44
|
+
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
45
|
+
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
|
|
35
46
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
42
|
-
if (cache && cache.has(obj)) {
|
|
43
|
-
return cache.get(obj);
|
|
44
|
-
}
|
|
45
|
-
var newObj = {};
|
|
46
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
47
|
-
for (var key in obj) {
|
|
48
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
49
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
50
|
-
if (desc && (desc.get || desc.set)) {
|
|
51
|
-
Object.defineProperty(newObj, key, desc);
|
|
52
|
-
} else {
|
|
53
|
-
newObj[key] = obj[key];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
newObj.default = obj;
|
|
58
|
-
if (cache) {
|
|
59
|
-
cache.set(obj, newObj);
|
|
60
|
-
}
|
|
61
|
-
return newObj;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* @flow
|
|
65
|
-
*/
|
|
66
|
-
/*:: import type { Op } from './ParseOp';*/
|
|
67
|
-
/*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
|
|
68
|
-
/*:: type ObjectIdentifier = {
|
|
69
|
-
className: string,
|
|
70
|
-
id: string,
|
|
71
|
-
};*/
|
|
72
|
-
let objectState
|
|
73
|
-
/*: {
|
|
74
|
-
[className: string]: {
|
|
75
|
-
[id: string]: State,
|
|
76
|
-
},
|
|
77
|
-
}*/ = {};
|
|
78
|
-
function getState(obj /*: ObjectIdentifier*/) /*: ?State*/{
|
|
47
|
+
return n.default = e, t && t.set(e, n), n;
|
|
48
|
+
}
|
|
49
|
+
let objectState = {};
|
|
50
|
+
function getState(obj) {
|
|
79
51
|
const classData = objectState[obj.className];
|
|
80
52
|
if (classData) {
|
|
81
53
|
return classData[obj.id] || null;
|
|
82
54
|
}
|
|
83
55
|
return null;
|
|
84
56
|
}
|
|
85
|
-
function initializeState(obj
|
|
57
|
+
function initializeState(obj, initial) {
|
|
86
58
|
let state = getState(obj);
|
|
87
59
|
if (state) {
|
|
88
60
|
return state;
|
|
@@ -96,7 +68,7 @@ function initializeState(obj /*: ObjectIdentifier*/, initial /*:: ?: State*/) /*
|
|
|
96
68
|
state = objectState[obj.className][obj.id] = initial;
|
|
97
69
|
return state;
|
|
98
70
|
}
|
|
99
|
-
function removeState(obj
|
|
71
|
+
function removeState(obj) {
|
|
100
72
|
const state = getState(obj);
|
|
101
73
|
if (state === null) {
|
|
102
74
|
return null;
|
|
@@ -104,68 +76,68 @@ function removeState(obj /*: ObjectIdentifier*/) /*: ?State*/{
|
|
|
104
76
|
delete objectState[obj.className][obj.id];
|
|
105
77
|
return state;
|
|
106
78
|
}
|
|
107
|
-
function getServerData(obj
|
|
79
|
+
function getServerData(obj) {
|
|
108
80
|
const state = getState(obj);
|
|
109
81
|
if (state) {
|
|
110
82
|
return state.serverData;
|
|
111
83
|
}
|
|
112
84
|
return {};
|
|
113
85
|
}
|
|
114
|
-
function setServerData(obj
|
|
86
|
+
function setServerData(obj, attributes) {
|
|
115
87
|
const serverData = initializeState(obj).serverData;
|
|
116
88
|
ObjectStateMutations.setServerData(serverData, attributes);
|
|
117
89
|
}
|
|
118
|
-
function getPendingOps(obj
|
|
90
|
+
function getPendingOps(obj) {
|
|
119
91
|
const state = getState(obj);
|
|
120
92
|
if (state) {
|
|
121
93
|
return state.pendingOps;
|
|
122
94
|
}
|
|
123
95
|
return [{}];
|
|
124
96
|
}
|
|
125
|
-
function setPendingOp(obj
|
|
97
|
+
function setPendingOp(obj, attr, op) {
|
|
126
98
|
const pendingOps = initializeState(obj).pendingOps;
|
|
127
99
|
ObjectStateMutations.setPendingOp(pendingOps, attr, op);
|
|
128
100
|
}
|
|
129
|
-
function pushPendingState(obj
|
|
101
|
+
function pushPendingState(obj) {
|
|
130
102
|
const pendingOps = initializeState(obj).pendingOps;
|
|
131
103
|
ObjectStateMutations.pushPendingState(pendingOps);
|
|
132
104
|
}
|
|
133
|
-
function popPendingState(obj
|
|
105
|
+
function popPendingState(obj) {
|
|
134
106
|
const pendingOps = initializeState(obj).pendingOps;
|
|
135
107
|
return ObjectStateMutations.popPendingState(pendingOps);
|
|
136
108
|
}
|
|
137
|
-
function mergeFirstPendingState(obj
|
|
109
|
+
function mergeFirstPendingState(obj) {
|
|
138
110
|
const pendingOps = getPendingOps(obj);
|
|
139
111
|
ObjectStateMutations.mergeFirstPendingState(pendingOps);
|
|
140
112
|
}
|
|
141
|
-
function getObjectCache(obj
|
|
113
|
+
function getObjectCache(obj) {
|
|
142
114
|
const state = getState(obj);
|
|
143
115
|
if (state) {
|
|
144
116
|
return state.objectCache;
|
|
145
117
|
}
|
|
146
118
|
return {};
|
|
147
119
|
}
|
|
148
|
-
function estimateAttribute(obj
|
|
120
|
+
function estimateAttribute(obj, attr) {
|
|
149
121
|
const serverData = getServerData(obj);
|
|
150
122
|
const pendingOps = getPendingOps(obj);
|
|
151
123
|
return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj, attr);
|
|
152
124
|
}
|
|
153
|
-
function estimateAttributes(obj
|
|
125
|
+
function estimateAttributes(obj) {
|
|
154
126
|
const serverData = getServerData(obj);
|
|
155
127
|
const pendingOps = getPendingOps(obj);
|
|
156
128
|
return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj);
|
|
157
129
|
}
|
|
158
|
-
function commitServerChanges(obj
|
|
130
|
+
function commitServerChanges(obj, changes) {
|
|
159
131
|
const state = initializeState(obj);
|
|
160
132
|
ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
|
|
161
133
|
}
|
|
162
|
-
function enqueueTask(obj
|
|
134
|
+
function enqueueTask(obj, task) {
|
|
163
135
|
const state = initializeState(obj);
|
|
164
136
|
return state.tasks.enqueue(task);
|
|
165
137
|
}
|
|
166
138
|
function clearAllState() {
|
|
167
139
|
objectState = {};
|
|
168
140
|
}
|
|
169
|
-
function duplicateState(source
|
|
141
|
+
function duplicateState(source, dest) {
|
|
170
142
|
dest.id = source.id;
|
|
171
143
|
}
|
package/lib/node/Socket.weapp.js
CHANGED
|
@@ -1,33 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
class SocketWeapp {
|
|
4
8
|
constructor(serverURL) {
|
|
5
9
|
this.onopen = () => {};
|
|
6
10
|
this.onmessage = () => {};
|
|
7
11
|
this.onclose = () => {};
|
|
8
12
|
this.onerror = () => {};
|
|
13
|
+
|
|
14
|
+
// @ts-ignore
|
|
9
15
|
wx.onSocketOpen(() => {
|
|
10
16
|
this.onopen();
|
|
11
17
|
});
|
|
18
|
+
|
|
19
|
+
// @ts-ignore
|
|
12
20
|
wx.onSocketMessage(msg => {
|
|
21
|
+
// @ts-ignore
|
|
13
22
|
this.onmessage(msg);
|
|
14
23
|
});
|
|
24
|
+
|
|
25
|
+
// @ts-ignore
|
|
15
26
|
wx.onSocketClose(event => {
|
|
27
|
+
// @ts-ignore
|
|
16
28
|
this.onclose(event);
|
|
17
29
|
});
|
|
30
|
+
|
|
31
|
+
// @ts-ignore
|
|
18
32
|
wx.onSocketError(error => {
|
|
33
|
+
// @ts-ignore
|
|
19
34
|
this.onerror(error);
|
|
20
35
|
});
|
|
36
|
+
|
|
37
|
+
// @ts-ignore
|
|
21
38
|
wx.connectSocket({
|
|
22
39
|
url: serverURL
|
|
23
40
|
});
|
|
24
41
|
}
|
|
25
42
|
send(data) {
|
|
43
|
+
// @ts-ignore
|
|
26
44
|
wx.sendSocketMessage({
|
|
27
45
|
data
|
|
28
46
|
});
|
|
29
47
|
}
|
|
30
48
|
close() {
|
|
49
|
+
// @ts-ignore
|
|
31
50
|
wx.closeSocket();
|
|
32
51
|
}
|
|
33
|
-
}
|
|
52
|
+
}
|
|
53
|
+
module.exports = SocketWeapp;
|
|
54
|
+
var _default = exports.default = SocketWeapp;
|
package/lib/node/Storage.js
CHANGED
|
@@ -10,72 +10,68 @@ function _interopRequireDefault(obj) {
|
|
|
10
10
|
default: obj
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
/**
|
|
14
|
-
* @flow
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
13
|
const Storage = {
|
|
18
|
-
async()
|
|
14
|
+
async() {
|
|
19
15
|
const controller = _CoreManager.default.getStorageController();
|
|
20
16
|
return !!controller.async;
|
|
21
17
|
},
|
|
22
|
-
getItem(path
|
|
18
|
+
getItem(path) {
|
|
23
19
|
const controller = _CoreManager.default.getStorageController();
|
|
24
20
|
if (controller.async === 1) {
|
|
25
21
|
throw new Error('Synchronous storage is not supported by the current storage controller');
|
|
26
22
|
}
|
|
27
23
|
return controller.getItem(path);
|
|
28
24
|
},
|
|
29
|
-
getItemAsync(path
|
|
25
|
+
getItemAsync(path) {
|
|
30
26
|
const controller = _CoreManager.default.getStorageController();
|
|
31
27
|
if (controller.async === 1) {
|
|
32
28
|
return controller.getItemAsync(path);
|
|
33
29
|
}
|
|
34
30
|
return Promise.resolve(controller.getItem(path));
|
|
35
31
|
},
|
|
36
|
-
setItem(path
|
|
32
|
+
setItem(path, value) {
|
|
37
33
|
const controller = _CoreManager.default.getStorageController();
|
|
38
34
|
if (controller.async === 1) {
|
|
39
35
|
throw new Error('Synchronous storage is not supported by the current storage controller');
|
|
40
36
|
}
|
|
41
37
|
return controller.setItem(path, value);
|
|
42
38
|
},
|
|
43
|
-
setItemAsync(path
|
|
39
|
+
setItemAsync(path, value) {
|
|
44
40
|
const controller = _CoreManager.default.getStorageController();
|
|
45
41
|
if (controller.async === 1) {
|
|
46
42
|
return controller.setItemAsync(path, value);
|
|
47
43
|
}
|
|
48
44
|
return Promise.resolve(controller.setItem(path, value));
|
|
49
45
|
},
|
|
50
|
-
removeItem(path
|
|
46
|
+
removeItem(path) {
|
|
51
47
|
const controller = _CoreManager.default.getStorageController();
|
|
52
48
|
if (controller.async === 1) {
|
|
53
49
|
throw new Error('Synchronous storage is not supported by the current storage controller');
|
|
54
50
|
}
|
|
55
51
|
return controller.removeItem(path);
|
|
56
52
|
},
|
|
57
|
-
removeItemAsync(path
|
|
53
|
+
removeItemAsync(path) {
|
|
58
54
|
const controller = _CoreManager.default.getStorageController();
|
|
59
55
|
if (controller.async === 1) {
|
|
60
56
|
return controller.removeItemAsync(path);
|
|
61
57
|
}
|
|
62
58
|
return Promise.resolve(controller.removeItem(path));
|
|
63
59
|
},
|
|
64
|
-
getAllKeys()
|
|
60
|
+
getAllKeys() {
|
|
65
61
|
const controller = _CoreManager.default.getStorageController();
|
|
66
62
|
if (controller.async === 1) {
|
|
67
63
|
throw new Error('Synchronous storage is not supported by the current storage controller');
|
|
68
64
|
}
|
|
69
65
|
return controller.getAllKeys();
|
|
70
66
|
},
|
|
71
|
-
getAllKeysAsync()
|
|
67
|
+
getAllKeysAsync() {
|
|
72
68
|
const controller = _CoreManager.default.getStorageController();
|
|
73
69
|
if (controller.async === 1) {
|
|
74
70
|
return controller.getAllKeysAsync();
|
|
75
71
|
}
|
|
76
72
|
return Promise.resolve(controller.getAllKeys());
|
|
77
73
|
},
|
|
78
|
-
generatePath(path
|
|
74
|
+
generatePath(path) {
|
|
79
75
|
if (!_CoreManager.default.get('APPLICATION_ID')) {
|
|
80
76
|
throw new Error('You need to call Parse.initialize before using Parse.');
|
|
81
77
|
}
|
|
@@ -95,5 +91,4 @@ const Storage = {
|
|
|
95
91
|
}
|
|
96
92
|
};
|
|
97
93
|
module.exports = Storage;
|
|
98
|
-
var _default = Storage;
|
|
99
|
-
exports.default = _default;
|
|
94
|
+
var _default = exports.default = Storage;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
/* global localStorage */
|
|
8
|
+
|
|
8
9
|
const StorageController = {
|
|
9
10
|
async: 0,
|
|
10
|
-
getItem(path
|
|
11
|
+
getItem(path) {
|
|
11
12
|
return localStorage.getItem(path);
|
|
12
13
|
},
|
|
13
|
-
setItem(path
|
|
14
|
+
setItem(path, value) {
|
|
14
15
|
try {
|
|
15
16
|
localStorage.setItem(path, value);
|
|
16
17
|
} catch (e) {
|
|
@@ -18,7 +19,7 @@ const StorageController = {
|
|
|
18
19
|
console.log(e.message);
|
|
19
20
|
}
|
|
20
21
|
},
|
|
21
|
-
removeItem(path
|
|
22
|
+
removeItem(path) {
|
|
22
23
|
localStorage.removeItem(path);
|
|
23
24
|
},
|
|
24
25
|
getAllKeys() {
|
|
@@ -32,4 +33,5 @@ const StorageController = {
|
|
|
32
33
|
localStorage.clear();
|
|
33
34
|
}
|
|
34
35
|
};
|
|
35
|
-
module.exports = StorageController;
|
|
36
|
+
module.exports = StorageController;
|
|
37
|
+
var _default = exports.default = StorageController;
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
8
7
|
// When there is no native storage interface, we default to an in-memory map
|
|
9
8
|
const memMap = {};
|
|
10
9
|
const StorageController = {
|
|
11
10
|
async: 0,
|
|
12
|
-
getItem(path
|
|
11
|
+
getItem(path) {
|
|
13
12
|
if (memMap.hasOwnProperty(path)) {
|
|
14
13
|
return memMap[path];
|
|
15
14
|
}
|
|
16
15
|
return null;
|
|
17
16
|
},
|
|
18
|
-
setItem(path
|
|
17
|
+
setItem(path, value) {
|
|
19
18
|
memMap[path] = String(value);
|
|
20
19
|
},
|
|
21
|
-
removeItem(path
|
|
20
|
+
removeItem(path) {
|
|
22
21
|
delete memMap[path];
|
|
23
22
|
},
|
|
24
23
|
getAllKeys() {
|
|
@@ -32,4 +31,5 @@ const StorageController = {
|
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
33
|
};
|
|
35
|
-
module.exports = StorageController;
|
|
34
|
+
module.exports = StorageController;
|
|
35
|
+
var _default = exports.default = StorageController;
|
|
@@ -1,3 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _StorageController = _interopRequireDefault(require("./StorageController.react-native"));
|
|
8
|
+
var _StorageController2 = _interopRequireDefault(require("./StorageController.browser"));
|
|
9
|
+
var _StorageController3 = _interopRequireDefault(require("./StorageController.weapp"));
|
|
10
|
+
var _StorageController4 = _interopRequireDefault(require("./StorageController.default"));
|
|
11
|
+
function _interopRequireDefault(obj) {
|
|
12
|
+
return obj && obj.__esModule ? obj : {
|
|
13
|
+
default: obj
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
let StorageController = _StorageController4.default;
|
|
17
|
+
module.exports = StorageController;
|
|
18
|
+
var _default = exports.default = StorageController;
|
|
@@ -1,41 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
3
7
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
4
8
|
function _interopRequireDefault(obj) {
|
|
5
9
|
return obj && obj.__esModule ? obj : {
|
|
6
10
|
default: obj
|
|
7
11
|
};
|
|
8
12
|
}
|
|
9
|
-
/**
|
|
10
|
-
* @flow
|
|
11
|
-
* @private
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
13
|
const StorageController = {
|
|
15
14
|
async: 1,
|
|
16
|
-
getItemAsync(path
|
|
15
|
+
getItemAsync(path) {
|
|
17
16
|
return new Promise((resolve, reject) => {
|
|
18
17
|
_CoreManager.default.getAsyncStorage().getItem(path, (err, value) => {
|
|
19
18
|
if (err) {
|
|
20
19
|
reject(err);
|
|
21
20
|
} else {
|
|
22
|
-
resolve(value);
|
|
21
|
+
resolve(value || null);
|
|
23
22
|
}
|
|
24
23
|
});
|
|
25
24
|
});
|
|
26
25
|
},
|
|
27
|
-
setItemAsync(path
|
|
26
|
+
setItemAsync(path, value) {
|
|
28
27
|
return new Promise((resolve, reject) => {
|
|
29
|
-
_CoreManager.default.getAsyncStorage().setItem(path, value,
|
|
28
|
+
_CoreManager.default.getAsyncStorage().setItem(path, value, err => {
|
|
30
29
|
if (err) {
|
|
31
30
|
reject(err);
|
|
32
31
|
} else {
|
|
33
|
-
resolve(
|
|
32
|
+
resolve();
|
|
34
33
|
}
|
|
35
34
|
});
|
|
36
35
|
});
|
|
37
36
|
},
|
|
38
|
-
removeItemAsync(path
|
|
37
|
+
removeItemAsync(path) {
|
|
39
38
|
return new Promise((resolve, reject) => {
|
|
40
39
|
_CoreManager.default.getAsyncStorage().removeItem(path, err => {
|
|
41
40
|
if (err) {
|
|
@@ -46,29 +45,29 @@ const StorageController = {
|
|
|
46
45
|
});
|
|
47
46
|
});
|
|
48
47
|
},
|
|
49
|
-
getAllKeysAsync()
|
|
48
|
+
getAllKeysAsync() {
|
|
50
49
|
return new Promise((resolve, reject) => {
|
|
51
50
|
_CoreManager.default.getAsyncStorage().getAllKeys((err, keys) => {
|
|
52
51
|
if (err) {
|
|
53
52
|
reject(err);
|
|
54
53
|
} else {
|
|
55
|
-
resolve(keys);
|
|
54
|
+
resolve(keys || []);
|
|
56
55
|
}
|
|
57
56
|
});
|
|
58
57
|
});
|
|
59
58
|
},
|
|
60
|
-
multiGet(keys
|
|
59
|
+
multiGet(keys) {
|
|
61
60
|
return new Promise((resolve, reject) => {
|
|
62
61
|
_CoreManager.default.getAsyncStorage().multiGet(keys, (err, result) => {
|
|
63
62
|
if (err) {
|
|
64
63
|
reject(err);
|
|
65
64
|
} else {
|
|
66
|
-
resolve(result);
|
|
65
|
+
resolve(result || null);
|
|
67
66
|
}
|
|
68
67
|
});
|
|
69
68
|
});
|
|
70
69
|
},
|
|
71
|
-
multiRemove(keys
|
|
70
|
+
multiRemove(keys) {
|
|
72
71
|
return new Promise((resolve, reject) => {
|
|
73
72
|
_CoreManager.default.getAsyncStorage().multiRemove(keys, err => {
|
|
74
73
|
if (err) {
|
|
@@ -83,4 +82,5 @@ const StorageController = {
|
|
|
83
82
|
return _CoreManager.default.getAsyncStorage().clear();
|
|
84
83
|
}
|
|
85
84
|
};
|
|
86
|
-
module.exports = StorageController;
|
|
85
|
+
module.exports = StorageController;
|
|
86
|
+
var _default = exports.default = StorageController;
|