parse 3.5.1 → 4.0.0-alpha.10

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.
Files changed (255) hide show
  1. package/LICENSE +167 -25
  2. package/NOTICE +10 -0
  3. package/README.md +20 -7
  4. package/dist/parse.js +12838 -21190
  5. package/dist/parse.min.js +7 -6
  6. package/dist/parse.weapp.js +7921 -17062
  7. package/dist/parse.weapp.min.js +7 -6
  8. package/lib/browser/Analytics.js +2 -27
  9. package/lib/browser/AnonymousUtils.js +6 -42
  10. package/lib/browser/Cloud.js +12 -77
  11. package/lib/browser/CloudCode.js +0 -3
  12. package/lib/browser/CoreManager.js +46 -191
  13. package/lib/browser/CryptoController.js +2 -16
  14. package/lib/browser/EventEmitter.js +1 -8
  15. package/lib/browser/EventuallyQueue.js +277 -824
  16. package/lib/browser/FacebookUtils.js +6 -42
  17. package/lib/browser/IndexedDBStorageController.js +3 -14
  18. package/lib/browser/InstallationController.js +2 -20
  19. package/lib/browser/LiveQueryClient.js +105 -213
  20. package/lib/browser/LiveQuerySubscription.js +10 -39
  21. package/lib/browser/LocalDatastore.js +451 -1081
  22. package/lib/browser/LocalDatastoreController.js +145 -602
  23. package/lib/browser/LocalDatastoreController.react-native.js +137 -573
  24. package/lib/browser/LocalDatastoreUtils.js +2 -19
  25. package/lib/browser/ObjectStateMutations.js +18 -121
  26. package/lib/browser/OfflineQuery.js +61 -222
  27. package/lib/browser/Parse.js +12 -115
  28. package/lib/browser/ParseACL.js +33 -148
  29. package/lib/browser/ParseCLP.js +96 -314
  30. package/lib/browser/ParseConfig.js +18 -95
  31. package/lib/browser/ParseError.js +63 -99
  32. package/lib/browser/ParseFile.js +128 -685
  33. package/lib/browser/ParseGeoPoint.js +23 -89
  34. package/lib/browser/ParseHooks.js +1 -34
  35. package/lib/browser/ParseInstallation.js +4 -32
  36. package/lib/browser/ParseLiveQuery.js +96 -505
  37. package/lib/browser/ParseObject.js +665 -1845
  38. package/lib/browser/ParseOp.js +41 -287
  39. package/lib/browser/ParsePolygon.js +13 -70
  40. package/lib/browser/ParseQuery.js +403 -1504
  41. package/lib/browser/ParseRelation.js +12 -68
  42. package/lib/browser/ParseRole.js +13 -75
  43. package/lib/browser/ParseSchema.js +49 -208
  44. package/lib/browser/ParseSession.js +11 -69
  45. package/lib/browser/ParseUser.js +274 -1127
  46. package/lib/browser/Push.js +7 -50
  47. package/lib/browser/RESTController.js +28 -157
  48. package/lib/browser/SingleInstanceStateController.js +19 -144
  49. package/lib/browser/Socket.weapp.js +0 -10
  50. package/lib/browser/Storage.js +10 -80
  51. package/lib/browser/StorageController.browser.js +4 -24
  52. package/lib/browser/StorageController.default.js +4 -24
  53. package/lib/browser/StorageController.react-native.js +6 -40
  54. package/lib/browser/StorageController.weapp.js +5 -23
  55. package/lib/browser/TaskQueue.js +1 -29
  56. package/lib/browser/UniqueInstanceStateController.js +19 -149
  57. package/lib/browser/Xhr.weapp.js +0 -17
  58. package/lib/browser/arrayContainsObject.js +2 -23
  59. package/lib/browser/canBeSerialized.js +3 -40
  60. package/lib/browser/decode.js +3 -40
  61. package/lib/browser/encode.js +9 -77
  62. package/lib/browser/equals.js +2 -34
  63. package/lib/browser/escape.js +1 -15
  64. package/lib/browser/isRevocableSession.js +2 -18
  65. package/lib/browser/parseDate.js +2 -20
  66. package/lib/browser/promiseUtils.js +3 -21
  67. package/lib/browser/unique.js +3 -24
  68. package/lib/browser/unsavedChildren.js +6 -57
  69. package/lib/browser/uuid.js +3 -1
  70. package/lib/node/Analytics.js +1 -25
  71. package/lib/node/AnonymousUtils.js +5 -44
  72. package/lib/node/Cloud.js +10 -73
  73. package/lib/node/CloudCode.js +0 -3
  74. package/lib/node/CoreManager.js +47 -227
  75. package/lib/node/CryptoController.js +2 -16
  76. package/lib/node/EventEmitter.js +1 -8
  77. package/lib/node/EventuallyQueue.js +16 -123
  78. package/lib/node/FacebookUtils.js +5 -44
  79. package/lib/node/IndexedDBStorageController.js +3 -19
  80. package/lib/node/InstallationController.js +2 -22
  81. package/lib/node/LiveQueryClient.js +72 -154
  82. package/lib/node/LiveQuerySubscription.js +7 -26
  83. package/lib/node/LocalDatastore.js +19 -182
  84. package/lib/node/LocalDatastoreController.js +6 -45
  85. package/lib/node/LocalDatastoreController.react-native.js +6 -52
  86. package/lib/node/LocalDatastoreUtils.js +1 -13
  87. package/lib/node/ObjectStateMutations.js +18 -134
  88. package/lib/node/OfflineQuery.js +27 -151
  89. package/lib/node/Parse.js +11 -108
  90. package/lib/node/ParseACL.js +32 -157
  91. package/lib/node/ParseCLP.js +73 -302
  92. package/lib/node/ParseConfig.js +16 -91
  93. package/lib/node/ParseError.js +61 -74
  94. package/lib/node/ParseFile.js +55 -244
  95. package/lib/node/ParseGeoPoint.js +21 -89
  96. package/lib/node/ParseHooks.js +0 -35
  97. package/lib/node/ParseInstallation.js +1 -17
  98. package/lib/node/ParseLiveQuery.js +10 -43
  99. package/lib/node/ParseObject.js +234 -997
  100. package/lib/node/ParseOp.js +31 -262
  101. package/lib/node/ParsePolygon.js +12 -69
  102. package/lib/node/ParseQuery.js +169 -888
  103. package/lib/node/ParseRelation.js +11 -68
  104. package/lib/node/ParseRole.js +10 -64
  105. package/lib/node/ParseSchema.js +46 -229
  106. package/lib/node/ParseSession.js +8 -57
  107. package/lib/node/ParseUser.js +107 -583
  108. package/lib/node/Push.js +4 -44
  109. package/lib/node/RESTController.js +19 -169
  110. package/lib/node/SingleInstanceStateController.js +17 -137
  111. package/lib/node/Socket.weapp.js +0 -7
  112. package/lib/node/Storage.js +10 -90
  113. package/lib/node/StorageController.browser.js +4 -30
  114. package/lib/node/StorageController.default.js +5 -28
  115. package/lib/node/StorageController.react-native.js +6 -47
  116. package/lib/node/StorageController.weapp.js +6 -28
  117. package/lib/node/TaskQueue.js +1 -24
  118. package/lib/node/UniqueInstanceStateController.js +16 -140
  119. package/lib/node/Xhr.weapp.js +0 -15
  120. package/lib/node/arrayContainsObject.js +1 -19
  121. package/lib/node/canBeSerialized.js +2 -35
  122. package/lib/node/decode.js +1 -33
  123. package/lib/node/encode.js +3 -61
  124. package/lib/node/equals.js +0 -27
  125. package/lib/node/escape.js +1 -13
  126. package/lib/node/isRevocableSession.js +1 -12
  127. package/lib/node/parseDate.js +1 -14
  128. package/lib/node/promiseUtils.js +2 -14
  129. package/lib/node/unique.js +1 -18
  130. package/lib/node/unsavedChildren.js +2 -45
  131. package/lib/node/uuid.js +6 -1
  132. package/lib/react-native/Analytics.js +0 -9
  133. package/lib/react-native/AnonymousUtils.js +0 -10
  134. package/lib/react-native/Cloud.js +0 -26
  135. package/lib/react-native/CoreManager.js +2 -6
  136. package/lib/react-native/CryptoController.js +0 -2
  137. package/lib/react-native/EventEmitter.js +0 -2
  138. package/lib/react-native/EventuallyQueue.js +156 -711
  139. package/lib/react-native/FacebookUtils.js +0 -22
  140. package/lib/react-native/IndexedDBStorageController.js +0 -1
  141. package/lib/react-native/InstallationController.js +0 -6
  142. package/lib/react-native/LiveQueryClient.js +46 -157
  143. package/lib/react-native/LiveQuerySubscription.js +3 -27
  144. package/lib/react-native/LocalDatastore.js +281 -948
  145. package/lib/react-native/LocalDatastoreController.js +71 -552
  146. package/lib/react-native/LocalDatastoreController.react-native.js +91 -526
  147. package/lib/react-native/LocalDatastoreUtils.js +0 -1
  148. package/lib/react-native/ObjectStateMutations.js +2 -65
  149. package/lib/react-native/OfflineQuery.js +25 -196
  150. package/lib/react-native/Parse.js +0 -65
  151. package/lib/react-native/ParseACL.js +0 -44
  152. package/lib/react-native/ParseCLP.js +23 -161
  153. package/lib/react-native/ParseConfig.js +0 -42
  154. package/lib/react-native/ParseError.js +1 -21
  155. package/lib/react-native/ParseFile.js +55 -529
  156. package/lib/react-native/ParseGeoPoint.js +0 -17
  157. package/lib/react-native/ParseHooks.js +0 -30
  158. package/lib/react-native/ParseInstallation.js +1 -23
  159. package/lib/react-native/ParseLiveQuery.js +55 -472
  160. package/lib/react-native/ParseObject.js +245 -1246
  161. package/lib/react-native/ParseOp.js +1 -138
  162. package/lib/react-native/ParsePolygon.js +0 -24
  163. package/lib/react-native/ParseQuery.js +182 -874
  164. package/lib/react-native/ParseRelation.js +0 -25
  165. package/lib/react-native/ParseRole.js +1 -36
  166. package/lib/react-native/ParseSchema.js +3 -54
  167. package/lib/react-native/ParseSession.js +1 -40
  168. package/lib/react-native/ParseUser.js +95 -773
  169. package/lib/react-native/Push.js +0 -16
  170. package/lib/react-native/RESTController.js +12 -109
  171. package/lib/react-native/SingleInstanceStateController.js +0 -44
  172. package/lib/react-native/Socket.weapp.js +0 -10
  173. package/lib/react-native/Storage.js +0 -24
  174. package/lib/react-native/StorageController.browser.js +0 -2
  175. package/lib/react-native/StorageController.default.js +0 -1
  176. package/lib/react-native/StorageController.react-native.js +0 -2
  177. package/lib/react-native/TaskQueue.js +0 -15
  178. package/lib/react-native/UniqueInstanceStateController.js +0 -47
  179. package/lib/react-native/Xhr.weapp.js +0 -16
  180. package/lib/react-native/arrayContainsObject.js +0 -5
  181. package/lib/react-native/canBeSerialized.js +0 -18
  182. package/lib/react-native/decode.js +0 -21
  183. package/lib/react-native/encode.js +0 -25
  184. package/lib/react-native/equals.js +0 -18
  185. package/lib/react-native/escape.js +0 -1
  186. package/lib/react-native/isRevocableSession.js +0 -1
  187. package/lib/react-native/parseDate.js +0 -3
  188. package/lib/react-native/promiseUtils.js +0 -13
  189. package/lib/react-native/unique.js +0 -4
  190. package/lib/react-native/unsavedChildren.js +0 -21
  191. package/lib/react-native/uuid.js +3 -1
  192. package/lib/weapp/Analytics.js +2 -27
  193. package/lib/weapp/AnonymousUtils.js +6 -42
  194. package/lib/weapp/Cloud.js +12 -77
  195. package/lib/weapp/CloudCode.js +0 -3
  196. package/lib/weapp/CoreManager.js +46 -191
  197. package/lib/weapp/CryptoController.js +2 -16
  198. package/lib/weapp/EventEmitter.js +1 -8
  199. package/lib/weapp/EventuallyQueue.js +277 -824
  200. package/lib/weapp/FacebookUtils.js +6 -42
  201. package/lib/weapp/IndexedDBStorageController.js +3 -14
  202. package/lib/weapp/InstallationController.js +2 -20
  203. package/lib/weapp/LiveQueryClient.js +105 -213
  204. package/lib/weapp/LiveQuerySubscription.js +10 -39
  205. package/lib/weapp/LocalDatastore.js +451 -1081
  206. package/lib/weapp/LocalDatastoreController.js +145 -602
  207. package/lib/weapp/LocalDatastoreController.react-native.js +137 -573
  208. package/lib/weapp/LocalDatastoreUtils.js +2 -19
  209. package/lib/weapp/ObjectStateMutations.js +18 -121
  210. package/lib/weapp/OfflineQuery.js +61 -222
  211. package/lib/weapp/Parse.js +12 -115
  212. package/lib/weapp/ParseACL.js +33 -148
  213. package/lib/weapp/ParseCLP.js +96 -314
  214. package/lib/weapp/ParseConfig.js +18 -95
  215. package/lib/weapp/ParseError.js +63 -99
  216. package/lib/weapp/ParseFile.js +129 -686
  217. package/lib/weapp/ParseGeoPoint.js +23 -89
  218. package/lib/weapp/ParseHooks.js +1 -34
  219. package/lib/weapp/ParseInstallation.js +4 -32
  220. package/lib/weapp/ParseLiveQuery.js +96 -505
  221. package/lib/weapp/ParseObject.js +665 -1845
  222. package/lib/weapp/ParseOp.js +41 -287
  223. package/lib/weapp/ParsePolygon.js +13 -70
  224. package/lib/weapp/ParseQuery.js +403 -1504
  225. package/lib/weapp/ParseRelation.js +12 -68
  226. package/lib/weapp/ParseRole.js +13 -75
  227. package/lib/weapp/ParseSchema.js +49 -208
  228. package/lib/weapp/ParseSession.js +11 -69
  229. package/lib/weapp/ParseUser.js +274 -1127
  230. package/lib/weapp/Push.js +7 -50
  231. package/lib/weapp/RESTController.js +28 -157
  232. package/lib/weapp/SingleInstanceStateController.js +19 -144
  233. package/lib/weapp/Socket.weapp.js +0 -10
  234. package/lib/weapp/Storage.js +10 -80
  235. package/lib/weapp/StorageController.browser.js +4 -24
  236. package/lib/weapp/StorageController.default.js +4 -24
  237. package/lib/weapp/StorageController.react-native.js +6 -40
  238. package/lib/weapp/StorageController.weapp.js +5 -23
  239. package/lib/weapp/TaskQueue.js +1 -29
  240. package/lib/weapp/UniqueInstanceStateController.js +19 -149
  241. package/lib/weapp/Xhr.weapp.js +0 -17
  242. package/lib/weapp/arrayContainsObject.js +2 -23
  243. package/lib/weapp/canBeSerialized.js +3 -40
  244. package/lib/weapp/decode.js +3 -40
  245. package/lib/weapp/encode.js +9 -77
  246. package/lib/weapp/equals.js +2 -34
  247. package/lib/weapp/escape.js +1 -15
  248. package/lib/weapp/isRevocableSession.js +2 -18
  249. package/lib/weapp/parseDate.js +2 -20
  250. package/lib/weapp/promiseUtils.js +3 -21
  251. package/lib/weapp/unique.js +3 -24
  252. package/lib/weapp/unsavedChildren.js +6 -57
  253. package/lib/weapp/uuid.js +1 -6
  254. package/package.json +37 -30
  255. package/PATENTS +0 -37
@@ -20,9 +20,7 @@ exports.pushPendingState = pushPendingState;
20
20
  exports.removeState = removeState;
21
21
  exports.setPendingOp = setPendingOp;
22
22
  exports.setServerData = setServerData;
23
-
24
23
  var ObjectStateMutations = _interopRequireWildcard(require("./ObjectStateMutations"));
25
-
26
24
  function _getRequireWildcardCache(nodeInterop) {
27
25
  if (typeof WeakMap !== "function") return null;
28
26
  var cacheBabelInterop = new WeakMap();
@@ -31,31 +29,24 @@ function _getRequireWildcardCache(nodeInterop) {
31
29
  return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
32
30
  })(nodeInterop);
33
31
  }
34
-
35
32
  function _interopRequireWildcard(obj, nodeInterop) {
36
33
  if (!nodeInterop && obj && obj.__esModule) {
37
34
  return obj;
38
35
  }
39
-
40
36
  if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
41
37
  return {
42
38
  default: obj
43
39
  };
44
40
  }
45
-
46
41
  var cache = _getRequireWildcardCache(nodeInterop);
47
-
48
42
  if (cache && cache.has(obj)) {
49
43
  return cache.get(obj);
50
44
  }
51
-
52
45
  var newObj = {};
53
46
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
54
-
55
47
  for (var key in obj) {
56
48
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
57
49
  var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
58
-
59
50
  if (desc && (desc.get || desc.set)) {
60
51
  Object.defineProperty(newObj, key, desc);
61
52
  } else {
@@ -63,224 +54,113 @@ function _interopRequireWildcard(obj, nodeInterop) {
63
54
  }
64
55
  }
65
56
  }
66
-
67
57
  newObj.default = obj;
68
-
69
58
  if (cache) {
70
59
  cache.set(obj, newObj);
71
60
  }
72
-
73
61
  return newObj;
74
62
  }
75
63
  /**
76
- * Copyright (c) 2015-present, Parse, LLC.
77
- * All rights reserved.
78
- *
79
- * This source code is licensed under the BSD-style license found in the
80
- * LICENSE file in the root directory of this source tree. An additional grant
81
- * of patent rights can be found in the PATENTS file in the same directory.
82
- *
83
64
  * @flow
84
65
  */
85
66
 
86
-
87
67
  let objectState
88
68
  /*: {
89
69
  [className: string]: {
90
70
  [id: string]: State,
91
71
  },
92
- }*/
93
- = {};
94
-
95
- function getState(obj
96
- /*: ObjectIdentifier*/
97
- )
98
- /*: ?State*/
99
- {
72
+ }*/ = {};
73
+ function getState(obj /*: ObjectIdentifier*/) /*: ?State*/{
100
74
  const classData = objectState[obj.className];
101
-
102
75
  if (classData) {
103
76
  return classData[obj.id] || null;
104
77
  }
105
-
106
78
  return null;
107
79
  }
108
-
109
- function initializeState(obj
110
- /*: ObjectIdentifier*/
111
- , initial
112
- /*:: ?: State*/
113
- )
114
- /*: State*/
115
- {
80
+ function initializeState(obj /*: ObjectIdentifier*/, initial /*:: ?: State*/) /*: State*/{
116
81
  let state = getState(obj);
117
-
118
82
  if (state) {
119
83
  return state;
120
84
  }
121
-
122
85
  if (!objectState[obj.className]) {
123
86
  objectState[obj.className] = {};
124
87
  }
125
-
126
88
  if (!initial) {
127
89
  initial = ObjectStateMutations.defaultState();
128
90
  }
129
-
130
91
  state = objectState[obj.className][obj.id] = initial;
131
92
  return state;
132
93
  }
133
-
134
- function removeState(obj
135
- /*: ObjectIdentifier*/
136
- )
137
- /*: ?State*/
138
- {
94
+ function removeState(obj /*: ObjectIdentifier*/) /*: ?State*/{
139
95
  const state = getState(obj);
140
-
141
96
  if (state === null) {
142
97
  return null;
143
98
  }
144
-
145
99
  delete objectState[obj.className][obj.id];
146
100
  return state;
147
101
  }
148
-
149
- function getServerData(obj
150
- /*: ObjectIdentifier*/
151
- )
152
- /*: AttributeMap*/
153
- {
102
+ function getServerData(obj /*: ObjectIdentifier*/) /*: AttributeMap*/{
154
103
  const state = getState(obj);
155
-
156
104
  if (state) {
157
105
  return state.serverData;
158
106
  }
159
-
160
107
  return {};
161
108
  }
162
-
163
- function setServerData(obj
164
- /*: ObjectIdentifier*/
165
- , attributes
166
- /*: AttributeMap*/
167
- ) {
109
+ function setServerData(obj /*: ObjectIdentifier*/, attributes /*: AttributeMap*/) {
168
110
  const serverData = initializeState(obj).serverData;
169
111
  ObjectStateMutations.setServerData(serverData, attributes);
170
112
  }
171
-
172
- function getPendingOps(obj
173
- /*: ObjectIdentifier*/
174
- )
175
- /*: Array<OpsMap>*/
176
- {
113
+ function getPendingOps(obj /*: ObjectIdentifier*/) /*: Array<OpsMap>*/{
177
114
  const state = getState(obj);
178
-
179
115
  if (state) {
180
116
  return state.pendingOps;
181
117
  }
182
-
183
118
  return [{}];
184
119
  }
185
-
186
- function setPendingOp(obj
187
- /*: ObjectIdentifier*/
188
- , attr
189
- /*: string*/
190
- , op
191
- /*: ?Op*/
192
- ) {
120
+ function setPendingOp(obj /*: ObjectIdentifier*/, attr /*: string*/, op /*: ?Op*/) {
193
121
  const pendingOps = initializeState(obj).pendingOps;
194
122
  ObjectStateMutations.setPendingOp(pendingOps, attr, op);
195
123
  }
196
-
197
- function pushPendingState(obj
198
- /*: ObjectIdentifier*/
199
- ) {
124
+ function pushPendingState(obj /*: ObjectIdentifier*/) {
200
125
  const pendingOps = initializeState(obj).pendingOps;
201
126
  ObjectStateMutations.pushPendingState(pendingOps);
202
127
  }
203
-
204
- function popPendingState(obj
205
- /*: ObjectIdentifier*/
206
- )
207
- /*: OpsMap*/
208
- {
128
+ function popPendingState(obj /*: ObjectIdentifier*/) /*: OpsMap*/{
209
129
  const pendingOps = initializeState(obj).pendingOps;
210
130
  return ObjectStateMutations.popPendingState(pendingOps);
211
131
  }
212
-
213
- function mergeFirstPendingState(obj
214
- /*: ObjectIdentifier*/
215
- ) {
132
+ function mergeFirstPendingState(obj /*: ObjectIdentifier*/) {
216
133
  const pendingOps = getPendingOps(obj);
217
134
  ObjectStateMutations.mergeFirstPendingState(pendingOps);
218
135
  }
219
-
220
- function getObjectCache(obj
221
- /*: ObjectIdentifier*/
222
- )
223
- /*: ObjectCache*/
224
- {
136
+ function getObjectCache(obj /*: ObjectIdentifier*/) /*: ObjectCache*/{
225
137
  const state = getState(obj);
226
-
227
138
  if (state) {
228
139
  return state.objectCache;
229
140
  }
230
-
231
141
  return {};
232
142
  }
233
-
234
- function estimateAttribute(obj
235
- /*: ObjectIdentifier*/
236
- , attr
237
- /*: string*/
238
- )
239
- /*: mixed*/
240
- {
143
+ function estimateAttribute(obj /*: ObjectIdentifier*/, attr /*: string*/) /*: mixed*/{
241
144
  const serverData = getServerData(obj);
242
145
  const pendingOps = getPendingOps(obj);
243
146
  return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj.className, obj.id, attr);
244
147
  }
245
-
246
- function estimateAttributes(obj
247
- /*: ObjectIdentifier*/
248
- )
249
- /*: AttributeMap*/
250
- {
148
+ function estimateAttributes(obj /*: ObjectIdentifier*/) /*: AttributeMap*/{
251
149
  const serverData = getServerData(obj);
252
150
  const pendingOps = getPendingOps(obj);
253
151
  return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj.className, obj.id);
254
152
  }
255
-
256
- function commitServerChanges(obj
257
- /*: ObjectIdentifier*/
258
- , changes
259
- /*: AttributeMap*/
260
- ) {
153
+ function commitServerChanges(obj /*: ObjectIdentifier*/, changes /*: AttributeMap*/) {
261
154
  const state = initializeState(obj);
262
155
  ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
263
156
  }
264
-
265
- function enqueueTask(obj
266
- /*: ObjectIdentifier*/
267
- , task
268
- /*: () => Promise*/
269
- )
270
- /*: Promise*/
271
- {
157
+ function enqueueTask(obj /*: ObjectIdentifier*/, task /*: () => Promise*/) /*: Promise*/{
272
158
  const state = initializeState(obj);
273
159
  return state.tasks.enqueue(task);
274
160
  }
275
-
276
161
  function clearAllState() {
277
162
  objectState = {};
278
163
  }
279
-
280
- function duplicateState(source
281
- /*: { id: string }*/
282
- , dest
283
- /*: { id: string }*/
284
- ) {
164
+ function duplicateState(source /*: { id: string }*/, dest /*: { id: string }*/) {
285
165
  dest.id = source.id;
286
166
  }
@@ -3,13 +3,9 @@
3
3
  module.exports = class {
4
4
  constructor(serverURL) {
5
5
  this.onopen = () => {};
6
-
7
6
  this.onmessage = () => {};
8
-
9
7
  this.onclose = () => {};
10
-
11
8
  this.onerror = () => {};
12
-
13
9
  wx.onSocketOpen(() => {
14
10
  this.onopen();
15
11
  });
@@ -26,15 +22,12 @@ module.exports = class {
26
22
  url: serverURL
27
23
  });
28
24
  }
29
-
30
25
  send(data) {
31
26
  wx.sendSocketMessage({
32
27
  data
33
28
  });
34
29
  }
35
-
36
30
  close() {
37
31
  wx.closeSocket();
38
32
  }
39
-
40
33
  };
@@ -1,174 +1,94 @@
1
1
  "use strict";
2
2
 
3
3
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
4
-
5
4
  function _interopRequireDefault(obj) {
6
5
  return obj && obj.__esModule ? obj : {
7
6
  default: obj
8
7
  };
9
8
  }
10
9
  /**
11
- * Copyright (c) 2015-present, Parse, LLC.
12
- * All rights reserved.
13
- *
14
- * This source code is licensed under the BSD-style license found in the
15
- * LICENSE file in the root directory of this source tree. An additional grant
16
- * of patent rights can be found in the PATENTS file in the same directory.
17
- *
18
10
  * @flow
19
11
  */
20
12
 
21
-
22
13
  const Storage = {
23
- async()
24
- /*: boolean*/
25
- {
14
+ async() /*: boolean*/{
26
15
  const controller = _CoreManager.default.getStorageController();
27
-
28
16
  return !!controller.async;
29
17
  },
30
-
31
- getItem(path
32
- /*: string*/
33
- )
34
- /*: ?string*/
35
- {
18
+ getItem(path /*: string*/) /*: ?string*/{
36
19
  const controller = _CoreManager.default.getStorageController();
37
-
38
20
  if (controller.async === 1) {
39
21
  throw new Error('Synchronous storage is not supported by the current storage controller');
40
22
  }
41
-
42
23
  return controller.getItem(path);
43
24
  },
44
-
45
- getItemAsync(path
46
- /*: string*/
47
- )
48
- /*: Promise<string>*/
49
- {
25
+ getItemAsync(path /*: string*/) /*: Promise<string>*/{
50
26
  const controller = _CoreManager.default.getStorageController();
51
-
52
27
  if (controller.async === 1) {
53
28
  return controller.getItemAsync(path);
54
29
  }
55
-
56
30
  return Promise.resolve(controller.getItem(path));
57
31
  },
58
-
59
- setItem(path
60
- /*: string*/
61
- , value
62
- /*: string*/
63
- )
64
- /*: void*/
65
- {
32
+ setItem(path /*: string*/, value /*: string*/) /*: void*/{
66
33
  const controller = _CoreManager.default.getStorageController();
67
-
68
34
  if (controller.async === 1) {
69
35
  throw new Error('Synchronous storage is not supported by the current storage controller');
70
36
  }
71
-
72
37
  return controller.setItem(path, value);
73
38
  },
74
-
75
- setItemAsync(path
76
- /*: string*/
77
- , value
78
- /*: string*/
79
- )
80
- /*: Promise<void>*/
81
- {
39
+ setItemAsync(path /*: string*/, value /*: string*/) /*: Promise<void>*/{
82
40
  const controller = _CoreManager.default.getStorageController();
83
-
84
41
  if (controller.async === 1) {
85
42
  return controller.setItemAsync(path, value);
86
43
  }
87
-
88
44
  return Promise.resolve(controller.setItem(path, value));
89
45
  },
90
-
91
- removeItem(path
92
- /*: string*/
93
- )
94
- /*: void*/
95
- {
46
+ removeItem(path /*: string*/) /*: void*/{
96
47
  const controller = _CoreManager.default.getStorageController();
97
-
98
48
  if (controller.async === 1) {
99
49
  throw new Error('Synchronous storage is not supported by the current storage controller');
100
50
  }
101
-
102
51
  return controller.removeItem(path);
103
52
  },
104
-
105
- removeItemAsync(path
106
- /*: string*/
107
- )
108
- /*: Promise<void>*/
109
- {
53
+ removeItemAsync(path /*: string*/) /*: Promise<void>*/{
110
54
  const controller = _CoreManager.default.getStorageController();
111
-
112
55
  if (controller.async === 1) {
113
56
  return controller.removeItemAsync(path);
114
57
  }
115
-
116
58
  return Promise.resolve(controller.removeItem(path));
117
59
  },
118
-
119
- getAllKeys()
120
- /*: Array<string>*/
121
- {
60
+ getAllKeys() /*: Array<string>*/{
122
61
  const controller = _CoreManager.default.getStorageController();
123
-
124
62
  if (controller.async === 1) {
125
63
  throw new Error('Synchronous storage is not supported by the current storage controller');
126
64
  }
127
-
128
65
  return controller.getAllKeys();
129
66
  },
130
-
131
- getAllKeysAsync()
132
- /*: Promise<Array<string>>*/
133
- {
67
+ getAllKeysAsync() /*: Promise<Array<string>>*/{
134
68
  const controller = _CoreManager.default.getStorageController();
135
-
136
69
  if (controller.async === 1) {
137
70
  return controller.getAllKeysAsync();
138
71
  }
139
-
140
72
  return Promise.resolve(controller.getAllKeys());
141
73
  },
142
-
143
- generatePath(path
144
- /*: string*/
145
- )
146
- /*: string*/
147
- {
74
+ generatePath(path /*: string*/) /*: string*/{
148
75
  if (!_CoreManager.default.get('APPLICATION_ID')) {
149
76
  throw new Error('You need to call Parse.initialize before using Parse.');
150
77
  }
151
-
152
78
  if (typeof path !== 'string') {
153
79
  throw new Error('Tried to get a Storage path that was not a String.');
154
80
  }
155
-
156
81
  if (path[0] === '/') {
157
82
  path = path.substr(1);
158
83
  }
159
-
160
84
  return 'Parse/' + _CoreManager.default.get('APPLICATION_ID') + '/' + path;
161
85
  },
162
-
163
86
  _clear() {
164
87
  const controller = _CoreManager.default.getStorageController();
165
-
166
88
  if (controller.hasOwnProperty('clear')) {
167
89
  controller.clear();
168
90
  }
169
91
  }
170
-
171
92
  };
172
93
  module.exports = Storage;
173
-
174
94
  _CoreManager.default.setStorageController(require('./StorageController.default'));
@@ -1,34 +1,16 @@
1
1
  "use strict";
2
+
2
3
  /**
3
- * Copyright (c) 2015-present, Parse, LLC.
4
- * All rights reserved.
5
- *
6
- * This source code is licensed under the BSD-style license found in the
7
- * LICENSE file in the root directory of this source tree. An additional grant
8
- * of patent rights can be found in the PATENTS file in the same directory.
9
- *
10
4
  * @flow
11
5
  * @private
12
6
  */
13
-
14
7
  /* global localStorage */
15
-
16
8
  const StorageController = {
17
9
  async: 0,
18
-
19
- getItem(path
20
- /*: string*/
21
- )
22
- /*: ?string*/
23
- {
10
+ getItem(path /*: string*/) /*: ?string*/{
24
11
  return localStorage.getItem(path);
25
12
  },
26
-
27
- setItem(path
28
- /*: string*/
29
- , value
30
- /*: string*/
31
- ) {
13
+ setItem(path /*: string*/, value /*: string*/) {
32
14
  try {
33
15
  localStorage.setItem(path, value);
34
16
  } catch (e) {
@@ -36,26 +18,18 @@ const StorageController = {
36
18
  console.log(e.message);
37
19
  }
38
20
  },
39
-
40
- removeItem(path
41
- /*: string*/
42
- ) {
21
+ removeItem(path /*: string*/) {
43
22
  localStorage.removeItem(path);
44
23
  },
45
-
46
24
  getAllKeys() {
47
25
  const keys = [];
48
-
49
26
  for (let i = 0; i < localStorage.length; i += 1) {
50
27
  keys.push(localStorage.key(i));
51
28
  }
52
-
53
29
  return keys;
54
30
  },
55
-
56
31
  clear() {
57
32
  localStorage.clear();
58
33
  }
59
-
60
34
  };
61
35
  module.exports = StorageController;
@@ -1,51 +1,29 @@
1
1
  "use strict";
2
+
2
3
  /**
3
- * Copyright (c) 2015-present, Parse, LLC.
4
- * All rights reserved.
5
- *
6
- * This source code is licensed under the BSD-style license found in the
7
- * LICENSE file in the root directory of this source tree. An additional grant
8
- * of patent rights can be found in the PATENTS file in the same directory.
9
- *
10
4
  * @flow
11
5
  * @private
12
6
  */
13
- // When there is no native storage interface, we default to an in-memory map
14
7
 
8
+ // When there is no native storage interface, we default to an in-memory map
15
9
  const memMap = {};
16
10
  const StorageController = {
17
11
  async: 0,
18
-
19
- getItem(path
20
- /*: string*/
21
- )
22
- /*: ?string*/
23
- {
12
+ getItem(path /*: string*/) /*: ?string*/{
24
13
  if (memMap.hasOwnProperty(path)) {
25
14
  return memMap[path];
26
15
  }
27
-
28
16
  return null;
29
17
  },
30
-
31
- setItem(path
32
- /*: string*/
33
- , value
34
- /*: string*/
35
- ) {
18
+ setItem(path /*: string*/, value /*: string*/) {
36
19
  memMap[path] = String(value);
37
20
  },
38
-
39
- removeItem(path
40
- /*: string*/
41
- ) {
21
+ removeItem(path /*: string*/) {
42
22
  delete memMap[path];
43
23
  },
44
-
45
24
  getAllKeys() {
46
25
  return Object.keys(memMap);
47
26
  },
48
-
49
27
  clear() {
50
28
  for (const key in memMap) {
51
29
  if (memMap.hasOwnProperty(key)) {
@@ -53,6 +31,5 @@ const StorageController = {
53
31
  }
54
32
  }
55
33
  }
56
-
57
34
  };
58
35
  module.exports = StorageController;