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,10 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _sliceInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
|
|
4
|
-
var _Array$from = require("@babel/runtime-corejs3/core-js-stable/array/from");
|
|
5
|
-
var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
|
|
6
|
-
var _getIteratorMethod = require("@babel/runtime-corejs3/core-js/get-iterator-method");
|
|
7
|
-
var _Array$isArray = require("@babel/runtime-corejs3/core-js-stable/array/is-array");
|
|
8
3
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
9
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
10
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
@@ -15,239 +10,60 @@ var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-
|
|
|
15
10
|
var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
|
|
16
11
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
17
12
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
18
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
|
|
19
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
|
|
20
13
|
var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
|
|
21
14
|
var _Storage = _interopRequireDefault(require("./Storage"));
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
var i = 0;
|
|
28
|
-
var F = function () {};
|
|
29
|
-
return {
|
|
30
|
-
s: F,
|
|
31
|
-
n: function () {
|
|
32
|
-
if (i >= o.length) return {
|
|
33
|
-
done: true
|
|
34
|
-
};
|
|
35
|
-
return {
|
|
36
|
-
done: false,
|
|
37
|
-
value: o[i++]
|
|
38
|
-
};
|
|
39
|
-
},
|
|
40
|
-
e: function (_e) {
|
|
41
|
-
throw _e;
|
|
42
|
-
},
|
|
43
|
-
f: F
|
|
44
|
-
};
|
|
15
|
+
const LocalDatastoreController = {
|
|
16
|
+
async fromPinWithName(name) {
|
|
17
|
+
const values = await _Storage.default.getItemAsync(name);
|
|
18
|
+
if (!values) {
|
|
19
|
+
return [];
|
|
45
20
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
var normalCompletion = true,
|
|
49
|
-
didErr = false,
|
|
50
|
-
err;
|
|
51
|
-
return {
|
|
52
|
-
s: function () {
|
|
53
|
-
it = it.call(o);
|
|
54
|
-
},
|
|
55
|
-
n: function () {
|
|
56
|
-
var step = it.next();
|
|
57
|
-
normalCompletion = step.done;
|
|
58
|
-
return step;
|
|
59
|
-
},
|
|
60
|
-
e: function (_e2) {
|
|
61
|
-
didErr = true;
|
|
62
|
-
err = _e2;
|
|
63
|
-
},
|
|
64
|
-
f: function () {
|
|
65
|
-
try {
|
|
66
|
-
if (!normalCompletion && it.return != null) it.return();
|
|
67
|
-
} finally {
|
|
68
|
-
if (didErr) throw err;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
74
|
-
var _context7;
|
|
75
|
-
if (!o) return;
|
|
76
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
77
|
-
var n = _sliceInstanceProperty(_context7 = Object.prototype.toString.call(o)).call(_context7, 8, -1);
|
|
78
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
79
|
-
if (n === "Map" || n === "Set") return _Array$from(o);
|
|
80
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
81
|
-
}
|
|
82
|
-
function _arrayLikeToArray(arr, len) {
|
|
83
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
84
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
85
|
-
return arr2;
|
|
86
|
-
}
|
|
87
|
-
var LocalDatastoreController = {
|
|
88
|
-
fromPinWithName: function (name /*: string*/) /*: Promise<Array<any>>*/{
|
|
89
|
-
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
90
|
-
var values, objects;
|
|
91
|
-
return _regenerator.default.wrap(function (_context) {
|
|
92
|
-
while (1) switch (_context.prev = _context.next) {
|
|
93
|
-
case 0:
|
|
94
|
-
_context.next = 2;
|
|
95
|
-
return _Storage.default.getItemAsync(name);
|
|
96
|
-
case 2:
|
|
97
|
-
values = _context.sent;
|
|
98
|
-
if (values) {
|
|
99
|
-
_context.next = 5;
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
return _context.abrupt("return", []);
|
|
103
|
-
case 5:
|
|
104
|
-
objects = JSON.parse(values);
|
|
105
|
-
return _context.abrupt("return", objects);
|
|
106
|
-
case 7:
|
|
107
|
-
case "end":
|
|
108
|
-
return _context.stop();
|
|
109
|
-
}
|
|
110
|
-
}, _callee);
|
|
111
|
-
}))();
|
|
21
|
+
const objects = JSON.parse(values);
|
|
22
|
+
return objects;
|
|
112
23
|
},
|
|
113
|
-
pinWithName
|
|
114
|
-
|
|
24
|
+
pinWithName(name, value) {
|
|
25
|
+
const values = (0, _stringify.default)(value);
|
|
115
26
|
return _Storage.default.setItemAsync(name, values);
|
|
116
27
|
},
|
|
117
|
-
unPinWithName
|
|
28
|
+
unPinWithName(name) {
|
|
118
29
|
return _Storage.default.removeItemAsync(name);
|
|
119
30
|
},
|
|
120
|
-
getAllContents
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return _context3.abrupt("return", (0, _reduce.default)(keys).call(keys, /*#__PURE__*/function () {
|
|
131
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(previousPromise, key) {
|
|
132
|
-
var LDS, value;
|
|
133
|
-
return _regenerator.default.wrap(function (_context2) {
|
|
134
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
135
|
-
case 0:
|
|
136
|
-
_context2.next = 2;
|
|
137
|
-
return previousPromise;
|
|
138
|
-
case 2:
|
|
139
|
-
LDS = _context2.sent;
|
|
140
|
-
if (!(0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
|
|
141
|
-
_context2.next = 8;
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
_context2.next = 6;
|
|
145
|
-
return _Storage.default.getItemAsync(key);
|
|
146
|
-
case 6:
|
|
147
|
-
value = _context2.sent;
|
|
148
|
-
try {
|
|
149
|
-
LDS[key] = JSON.parse(value);
|
|
150
|
-
} catch (error) {
|
|
151
|
-
console.error('Error getAllContents: ', error);
|
|
152
|
-
}
|
|
153
|
-
case 8:
|
|
154
|
-
return _context2.abrupt("return", LDS);
|
|
155
|
-
case 9:
|
|
156
|
-
case "end":
|
|
157
|
-
return _context2.stop();
|
|
158
|
-
}
|
|
159
|
-
}, _callee2);
|
|
160
|
-
}));
|
|
161
|
-
return function () {
|
|
162
|
-
return _ref.apply(this, arguments);
|
|
163
|
-
};
|
|
164
|
-
}(), _promise.default.resolve({})));
|
|
165
|
-
case 4:
|
|
166
|
-
case "end":
|
|
167
|
-
return _context3.stop();
|
|
31
|
+
async getAllContents() {
|
|
32
|
+
const keys = await _Storage.default.getAllKeysAsync();
|
|
33
|
+
return (0, _reduce.default)(keys).call(keys, async (previousPromise, key) => {
|
|
34
|
+
const LDS = await previousPromise;
|
|
35
|
+
if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
|
|
36
|
+
const value = await _Storage.default.getItemAsync(key);
|
|
37
|
+
try {
|
|
38
|
+
LDS[key] = JSON.parse(value);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error('Error getAllContents: ', error);
|
|
168
41
|
}
|
|
169
|
-
}
|
|
170
|
-
|
|
42
|
+
}
|
|
43
|
+
return LDS;
|
|
44
|
+
}, _promise.default.resolve({}));
|
|
171
45
|
},
|
|
172
46
|
// Used for testing
|
|
173
|
-
getRawStorage
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
case 2:
|
|
182
|
-
keys = _context5.sent;
|
|
183
|
-
return _context5.abrupt("return", (0, _reduce.default)(keys).call(keys, /*#__PURE__*/function () {
|
|
184
|
-
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(previousPromise, key) {
|
|
185
|
-
var LDS, value;
|
|
186
|
-
return _regenerator.default.wrap(function (_context4) {
|
|
187
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
188
|
-
case 0:
|
|
189
|
-
_context4.next = 2;
|
|
190
|
-
return previousPromise;
|
|
191
|
-
case 2:
|
|
192
|
-
LDS = _context4.sent;
|
|
193
|
-
_context4.next = 5;
|
|
194
|
-
return _Storage.default.getItemAsync(key);
|
|
195
|
-
case 5:
|
|
196
|
-
value = _context4.sent;
|
|
197
|
-
LDS[key] = value;
|
|
198
|
-
return _context4.abrupt("return", LDS);
|
|
199
|
-
case 8:
|
|
200
|
-
case "end":
|
|
201
|
-
return _context4.stop();
|
|
202
|
-
}
|
|
203
|
-
}, _callee4);
|
|
204
|
-
}));
|
|
205
|
-
return function () {
|
|
206
|
-
return _ref2.apply(this, arguments);
|
|
207
|
-
};
|
|
208
|
-
}(), _promise.default.resolve({})));
|
|
209
|
-
case 4:
|
|
210
|
-
case "end":
|
|
211
|
-
return _context5.stop();
|
|
212
|
-
}
|
|
213
|
-
}, _callee5);
|
|
214
|
-
}))();
|
|
47
|
+
async getRawStorage() {
|
|
48
|
+
const keys = await _Storage.default.getAllKeysAsync();
|
|
49
|
+
return (0, _reduce.default)(keys).call(keys, async (previousPromise, key) => {
|
|
50
|
+
const LDS = await previousPromise;
|
|
51
|
+
const value = await _Storage.default.getItemAsync(key);
|
|
52
|
+
LDS[key] = value;
|
|
53
|
+
return LDS;
|
|
54
|
+
}, _promise.default.resolve({}));
|
|
215
55
|
},
|
|
216
|
-
clear
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
keys = _context6.sent;
|
|
227
|
-
toRemove /*: string[]*/ = [];
|
|
228
|
-
_iterator = _createForOfIteratorHelper(keys);
|
|
229
|
-
try {
|
|
230
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
231
|
-
key = _step.value;
|
|
232
|
-
if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
|
|
233
|
-
toRemove.push(key);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
} catch (err) {
|
|
237
|
-
_iterator.e(err);
|
|
238
|
-
} finally {
|
|
239
|
-
_iterator.f();
|
|
240
|
-
}
|
|
241
|
-
promises = (0, _map.default)(toRemove).call(toRemove, _this.unPinWithName);
|
|
242
|
-
return _context6.abrupt("return", _promise.default.all(promises));
|
|
243
|
-
case 8:
|
|
244
|
-
case "end":
|
|
245
|
-
return _context6.stop();
|
|
246
|
-
}
|
|
247
|
-
}, _callee6);
|
|
248
|
-
}))();
|
|
56
|
+
async clear() {
|
|
57
|
+
const keys = await _Storage.default.getAllKeysAsync();
|
|
58
|
+
const toRemove = [];
|
|
59
|
+
for (const key of keys) {
|
|
60
|
+
if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
|
|
61
|
+
toRemove.push(key);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const promises = (0, _map.default)(toRemove).call(toRemove, this.unPinWithName);
|
|
65
|
+
return _promise.default.all(promises);
|
|
249
66
|
}
|
|
250
67
|
};
|
|
251
68
|
module.exports = LocalDatastoreController;
|
|
252
|
-
var _default = LocalDatastoreController;
|
|
253
|
-
exports.default = _default;
|
|
69
|
+
var _default = exports.default = LocalDatastoreController;
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _LocalDatastoreController = _interopRequireDefault(require("./LocalDatastoreController.react-native"));
|
|
10
|
+
var _LocalDatastoreController2 = _interopRequireDefault(require("./LocalDatastoreController.default"));
|
|
11
|
+
let LocalDatastoreController = _LocalDatastoreController2.default;
|
|
12
|
+
module.exports = LocalDatastoreController;
|
|
13
|
+
var _default = exports.default = LocalDatastoreController;
|
|
@@ -9,173 +9,79 @@ exports.default = void 0;
|
|
|
9
9
|
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
10
10
|
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
11
11
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
12
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
|
|
13
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
|
14
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
|
|
15
12
|
var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
fromPinWithName
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return RNStorage.getItemAsync(name);
|
|
26
|
-
case 2:
|
|
27
|
-
values = _context.sent;
|
|
28
|
-
if (values) {
|
|
29
|
-
_context.next = 5;
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
return _context.abrupt("return", []);
|
|
33
|
-
case 5:
|
|
34
|
-
objects = JSON.parse(values);
|
|
35
|
-
return _context.abrupt("return", objects);
|
|
36
|
-
case 7:
|
|
37
|
-
case "end":
|
|
38
|
-
return _context.stop();
|
|
39
|
-
}
|
|
40
|
-
}, _callee);
|
|
41
|
-
}))();
|
|
13
|
+
var _StorageController = _interopRequireDefault(require("./StorageController.react-native"));
|
|
14
|
+
const LocalDatastoreController = {
|
|
15
|
+
async fromPinWithName(name) {
|
|
16
|
+
const values = await _StorageController.default.getItemAsync(name);
|
|
17
|
+
if (!values) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
const objects = JSON.parse(values);
|
|
21
|
+
return objects;
|
|
42
22
|
},
|
|
43
|
-
pinWithName
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
_context2.next = 4;
|
|
52
|
-
return RNStorage.setItemAsync(name, values);
|
|
53
|
-
case 4:
|
|
54
|
-
_context2.next = 9;
|
|
55
|
-
break;
|
|
56
|
-
case 6:
|
|
57
|
-
_context2.prev = 6;
|
|
58
|
-
_context2.t0 = _context2["catch"](0);
|
|
59
|
-
// Quota exceeded, possibly due to Safari Private Browsing mode
|
|
60
|
-
console.error(_context2.t0.message);
|
|
61
|
-
case 9:
|
|
62
|
-
case "end":
|
|
63
|
-
return _context2.stop();
|
|
64
|
-
}
|
|
65
|
-
}, _callee2, null, [[0, 6]]);
|
|
66
|
-
}))();
|
|
23
|
+
async pinWithName(name, value) {
|
|
24
|
+
try {
|
|
25
|
+
const values = (0, _stringify.default)(value);
|
|
26
|
+
await _StorageController.default.setItemAsync(name, values);
|
|
27
|
+
} catch (e) {
|
|
28
|
+
// Quota exceeded, possibly due to Safari Private Browsing mode
|
|
29
|
+
console.error(e.message);
|
|
30
|
+
}
|
|
67
31
|
},
|
|
68
|
-
unPinWithName
|
|
69
|
-
return
|
|
32
|
+
unPinWithName(name) {
|
|
33
|
+
return _StorageController.default.removeItemAsync(name);
|
|
70
34
|
},
|
|
71
|
-
getAllContents
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
case 13:
|
|
98
|
-
_context3.prev = 13;
|
|
99
|
-
_context3.t0 = _context3["catch"](7);
|
|
100
|
-
console.error('Error getAllContents: ', _context3.t0);
|
|
101
|
-
return _context3.abrupt("return", {});
|
|
102
|
-
case 17:
|
|
103
|
-
(0, _forEach.default)(results).call(results, function (pair) {
|
|
104
|
-
var _pair = (0, _slicedToArray2.default)(pair, 2),
|
|
105
|
-
key = _pair[0],
|
|
106
|
-
value = _pair[1];
|
|
107
|
-
try {
|
|
108
|
-
LDS[key] = JSON.parse(value);
|
|
109
|
-
} catch (error) {
|
|
110
|
-
LDS[key] = null;
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
return _context3.abrupt("return", LDS);
|
|
114
|
-
case 19:
|
|
115
|
-
case "end":
|
|
116
|
-
return _context3.stop();
|
|
117
|
-
}
|
|
118
|
-
}, _callee3, null, [[7, 13]]);
|
|
119
|
-
}))();
|
|
35
|
+
async getAllContents() {
|
|
36
|
+
const keys = await _StorageController.default.getAllKeysAsync();
|
|
37
|
+
const batch = [];
|
|
38
|
+
for (let i = 0; i < keys.length; i += 1) {
|
|
39
|
+
const key = keys[i];
|
|
40
|
+
if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
|
|
41
|
+
batch.push(key);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const LDS = {};
|
|
45
|
+
let results = [];
|
|
46
|
+
try {
|
|
47
|
+
results = await _StorageController.default.multiGet(batch);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.error('Error getAllContents: ', error);
|
|
50
|
+
return {};
|
|
51
|
+
}
|
|
52
|
+
(0, _forEach.default)(results).call(results, pair => {
|
|
53
|
+
const [key, value] = pair;
|
|
54
|
+
try {
|
|
55
|
+
LDS[key] = JSON.parse(value);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
LDS[key] = null;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return LDS;
|
|
120
61
|
},
|
|
121
62
|
// Used for testing
|
|
122
|
-
getRawStorage
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
storage = {};
|
|
133
|
-
_context4.next = 6;
|
|
134
|
-
return RNStorage.multiGet(keys);
|
|
135
|
-
case 6:
|
|
136
|
-
results = _context4.sent;
|
|
137
|
-
(0, _map.default)(results).call(results, function (pair) {
|
|
138
|
-
var _pair2 = (0, _slicedToArray2.default)(pair, 2),
|
|
139
|
-
key = _pair2[0],
|
|
140
|
-
value = _pair2[1];
|
|
141
|
-
storage[key] = value;
|
|
142
|
-
});
|
|
143
|
-
return _context4.abrupt("return", storage);
|
|
144
|
-
case 9:
|
|
145
|
-
case "end":
|
|
146
|
-
return _context4.stop();
|
|
147
|
-
}
|
|
148
|
-
}, _callee4);
|
|
149
|
-
}))();
|
|
63
|
+
async getRawStorage() {
|
|
64
|
+
var _context;
|
|
65
|
+
const keys = await _StorageController.default.getAllKeysAsync();
|
|
66
|
+
const storage = {};
|
|
67
|
+
const results = await _StorageController.default.multiGet(keys);
|
|
68
|
+
(0, _map.default)(_context = results).call(_context, pair => {
|
|
69
|
+
const [key, value] = pair;
|
|
70
|
+
storage[key] = value;
|
|
71
|
+
});
|
|
72
|
+
return storage;
|
|
150
73
|
},
|
|
151
|
-
clear
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
batch /*: string[]*/ = [];
|
|
162
|
-
for (i = 0; i < keys.length; i += 1) {
|
|
163
|
-
key = keys[i];
|
|
164
|
-
if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
|
|
165
|
-
batch.push(key);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return _context5.abrupt("return", RNStorage.multiRemove(batch).catch(function (error) {
|
|
169
|
-
return console.error('Error clearing local datastore: ', error);
|
|
170
|
-
}));
|
|
171
|
-
case 6:
|
|
172
|
-
case "end":
|
|
173
|
-
return _context5.stop();
|
|
174
|
-
}
|
|
175
|
-
}, _callee5);
|
|
176
|
-
}))();
|
|
74
|
+
async clear() {
|
|
75
|
+
const keys = await _StorageController.default.getAllKeysAsync();
|
|
76
|
+
const batch = [];
|
|
77
|
+
for (let i = 0; i < keys.length; i += 1) {
|
|
78
|
+
const key = keys[i];
|
|
79
|
+
if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
|
|
80
|
+
batch.push(key);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
await _StorageController.default.multiRemove(batch).catch(error => console.error('Error clearing local datastore: ', error));
|
|
177
84
|
}
|
|
178
85
|
};
|
|
179
86
|
module.exports = LocalDatastoreController;
|
|
180
|
-
var _default = LocalDatastoreController;
|
|
181
|
-
exports.default = _default;
|
|
87
|
+
var _default = exports.default = LocalDatastoreController;
|
|
@@ -8,12 +8,9 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.PIN_PREFIX = exports.OBJECT_PREFIX = exports.DEFAULT_PIN = void 0;
|
|
9
9
|
exports.isLocalDatastoreKey = isLocalDatastoreKey;
|
|
10
10
|
var _startsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
|
|
11
|
-
|
|
12
|
-
exports.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var OBJECT_PREFIX = 'Parse_LDS_';
|
|
16
|
-
exports.OBJECT_PREFIX = OBJECT_PREFIX;
|
|
17
|
-
function isLocalDatastoreKey(key /*: string*/) /*: boolean*/{
|
|
11
|
+
const DEFAULT_PIN = exports.DEFAULT_PIN = '_default';
|
|
12
|
+
const PIN_PREFIX = exports.PIN_PREFIX = 'parsePin_';
|
|
13
|
+
const OBJECT_PREFIX = exports.OBJECT_PREFIX = 'Parse_LDS_';
|
|
14
|
+
function isLocalDatastoreKey(key) {
|
|
18
15
|
return !!(key && (key === DEFAULT_PIN || (0, _startsWith.default)(key).call(key, PIN_PREFIX) || (0, _startsWith.default)(key).call(key, OBJECT_PREFIX)));
|
|
19
16
|
}
|