parse 4.0.1 → 4.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. package/dist/parse.js +17994 -26193
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +8738 -17728
  4. package/dist/parse.weapp.min.js +2 -2
  5. package/lib/browser/Analytics.js +2 -20
  6. package/lib/browser/AnonymousUtils.js +6 -35
  7. package/lib/browser/Cloud.js +12 -70
  8. package/lib/browser/CloudCode.js +0 -3
  9. package/lib/browser/CoreManager.js +46 -184
  10. package/lib/browser/CryptoController.js +2 -16
  11. package/lib/browser/EventEmitter.js +1 -1
  12. package/lib/browser/EventuallyQueue.js +277 -824
  13. package/lib/browser/FacebookUtils.js +6 -35
  14. package/lib/browser/IndexedDBStorageController.js +3 -14
  15. package/lib/browser/InstallationController.js +2 -13
  16. package/lib/browser/LiveQueryClient.js +87 -204
  17. package/lib/browser/LiveQuerySubscription.js +10 -39
  18. package/lib/browser/LocalDatastore.js +451 -1081
  19. package/lib/browser/LocalDatastoreController.js +145 -602
  20. package/lib/browser/LocalDatastoreController.react-native.js +137 -573
  21. package/lib/browser/LocalDatastoreUtils.js +2 -12
  22. package/lib/browser/ObjectStateMutations.js +18 -121
  23. package/lib/browser/OfflineQuery.js +42 -222
  24. package/lib/browser/Parse.js +12 -106
  25. package/lib/browser/ParseACL.js +33 -141
  26. package/lib/browser/ParseCLP.js +96 -314
  27. package/lib/browser/ParseConfig.js +18 -88
  28. package/lib/browser/ParseError.js +63 -90
  29. package/lib/browser/ParseFile.js +128 -685
  30. package/lib/browser/ParseGeoPoint.js +23 -82
  31. package/lib/browser/ParseHooks.js +1 -34
  32. package/lib/browser/ParseInstallation.js +4 -32
  33. package/lib/browser/ParseLiveQuery.js +96 -505
  34. package/lib/browser/ParseObject.js +628 -1840
  35. package/lib/browser/ParseOp.js +41 -287
  36. package/lib/browser/ParsePolygon.js +13 -63
  37. package/lib/browser/ParseQuery.js +404 -1505
  38. package/lib/browser/ParseRelation.js +12 -61
  39. package/lib/browser/ParseRole.js +13 -75
  40. package/lib/browser/ParseSchema.js +49 -201
  41. package/lib/browser/ParseSession.js +11 -69
  42. package/lib/browser/ParseUser.js +274 -1127
  43. package/lib/browser/Push.js +7 -43
  44. package/lib/browser/RESTController.js +18 -140
  45. package/lib/browser/SingleInstanceStateController.js +19 -137
  46. package/lib/browser/Socket.weapp.js +2 -12
  47. package/lib/browser/Storage.js +10 -73
  48. package/lib/browser/StorageController.browser.js +4 -17
  49. package/lib/browser/StorageController.default.js +4 -17
  50. package/lib/browser/StorageController.react-native.js +6 -33
  51. package/lib/browser/StorageController.weapp.js +5 -16
  52. package/lib/browser/TaskQueue.js +1 -22
  53. package/lib/browser/UniqueInstanceStateController.js +19 -142
  54. package/lib/browser/Xhr.weapp.js +0 -17
  55. package/lib/browser/arrayContainsObject.js +2 -16
  56. package/lib/browser/canBeSerialized.js +3 -33
  57. package/lib/browser/decode.js +3 -33
  58. package/lib/browser/encode.js +9 -70
  59. package/lib/browser/equals.js +2 -25
  60. package/lib/browser/escape.js +1 -8
  61. package/lib/browser/isRevocableSession.js +2 -11
  62. package/lib/browser/parseDate.js +2 -13
  63. package/lib/browser/promiseUtils.js +3 -21
  64. package/lib/browser/unique.js +3 -17
  65. package/lib/browser/unsavedChildren.js +6 -50
  66. package/lib/browser/uuid.js +3 -1
  67. package/lib/node/Analytics.js +1 -18
  68. package/lib/node/AnonymousUtils.js +5 -37
  69. package/lib/node/Cloud.js +10 -66
  70. package/lib/node/CloudCode.js +0 -3
  71. package/lib/node/CoreManager.js +47 -220
  72. package/lib/node/CryptoController.js +2 -16
  73. package/lib/node/EventEmitter.js +1 -1
  74. package/lib/node/EventuallyQueue.js +16 -123
  75. package/lib/node/FacebookUtils.js +5 -37
  76. package/lib/node/IndexedDBStorageController.js +3 -19
  77. package/lib/node/InstallationController.js +2 -15
  78. package/lib/node/LiveQueryClient.js +56 -136
  79. package/lib/node/LiveQuerySubscription.js +7 -16
  80. package/lib/node/LocalDatastore.js +19 -175
  81. package/lib/node/LocalDatastoreController.js +6 -38
  82. package/lib/node/LocalDatastoreController.react-native.js +6 -45
  83. package/lib/node/LocalDatastoreUtils.js +1 -6
  84. package/lib/node/ObjectStateMutations.js +13 -93
  85. package/lib/node/OfflineQuery.js +20 -152
  86. package/lib/node/Parse.js +11 -99
  87. package/lib/node/ParseACL.js +32 -150
  88. package/lib/node/ParseCLP.js +69 -262
  89. package/lib/node/ParseConfig.js +16 -84
  90. package/lib/node/ParseError.js +61 -65
  91. package/lib/node/ParseFile.js +49 -205
  92. package/lib/node/ParseGeoPoint.js +21 -82
  93. package/lib/node/ParseHooks.js +0 -35
  94. package/lib/node/ParseInstallation.js +1 -10
  95. package/lib/node/ParseLiveQuery.js +10 -36
  96. package/lib/node/ParseObject.js +193 -939
  97. package/lib/node/ParseOp.js +31 -255
  98. package/lib/node/ParsePolygon.js +12 -62
  99. package/lib/node/ParseQuery.js +170 -882
  100. package/lib/node/ParseRelation.js +11 -61
  101. package/lib/node/ParseRole.js +10 -57
  102. package/lib/node/ParseSchema.js +46 -222
  103. package/lib/node/ParseSession.js +8 -50
  104. package/lib/node/ParseUser.js +107 -576
  105. package/lib/node/Push.js +4 -37
  106. package/lib/node/RESTController.js +8 -110
  107. package/lib/node/SingleInstanceStateController.js +17 -130
  108. package/lib/node/Socket.weapp.js +2 -9
  109. package/lib/node/Storage.js +10 -83
  110. package/lib/node/StorageController.browser.js +4 -23
  111. package/lib/node/StorageController.default.js +5 -21
  112. package/lib/node/StorageController.react-native.js +6 -40
  113. package/lib/node/StorageController.weapp.js +6 -21
  114. package/lib/node/TaskQueue.js +1 -17
  115. package/lib/node/UniqueInstanceStateController.js +16 -133
  116. package/lib/node/Xhr.weapp.js +0 -15
  117. package/lib/node/arrayContainsObject.js +1 -12
  118. package/lib/node/canBeSerialized.js +2 -28
  119. package/lib/node/decode.js +1 -26
  120. package/lib/node/encode.js +3 -54
  121. package/lib/node/equals.js +0 -18
  122. package/lib/node/escape.js +1 -6
  123. package/lib/node/isRevocableSession.js +1 -5
  124. package/lib/node/parseDate.js +1 -7
  125. package/lib/node/promiseUtils.js +2 -14
  126. package/lib/node/unique.js +1 -11
  127. package/lib/node/unsavedChildren.js +2 -38
  128. package/lib/node/uuid.js +6 -1
  129. package/lib/react-native/Analytics.js +0 -9
  130. package/lib/react-native/AnonymousUtils.js +0 -10
  131. package/lib/react-native/Cloud.js +0 -26
  132. package/lib/react-native/CoreManager.js +1 -5
  133. package/lib/react-native/CryptoController.js +0 -2
  134. package/lib/react-native/EventEmitter.js +0 -2
  135. package/lib/react-native/EventuallyQueue.js +4 -52
  136. package/lib/react-native/FacebookUtils.js +0 -22
  137. package/lib/react-native/IndexedDBStorageController.js +0 -1
  138. package/lib/react-native/InstallationController.js +0 -6
  139. package/lib/react-native/LiveQueryClient.js +24 -101
  140. package/lib/react-native/LiveQuerySubscription.js +3 -27
  141. package/lib/react-native/LocalDatastore.js +6 -113
  142. package/lib/react-native/LocalDatastoreController.js +0 -21
  143. package/lib/react-native/LocalDatastoreController.react-native.js +4 -31
  144. package/lib/react-native/LocalDatastoreUtils.js +0 -1
  145. package/lib/react-native/ObjectStateMutations.js +0 -34
  146. package/lib/react-native/OfflineQuery.js +2 -137
  147. package/lib/react-native/Parse.js +0 -65
  148. package/lib/react-native/ParseACL.js +0 -44
  149. package/lib/react-native/ParseCLP.js +32 -96
  150. package/lib/react-native/ParseConfig.js +0 -42
  151. package/lib/react-native/ParseError.js +1 -21
  152. package/lib/react-native/ParseFile.js +3 -72
  153. package/lib/react-native/ParseGeoPoint.js +0 -17
  154. package/lib/react-native/ParseHooks.js +0 -30
  155. package/lib/react-native/ParseInstallation.js +1 -23
  156. package/lib/react-native/ParseLiveQuery.js +3 -25
  157. package/lib/react-native/ParseObject.js +4 -371
  158. package/lib/react-native/ParseOp.js +1 -138
  159. package/lib/react-native/ParsePolygon.js +0 -24
  160. package/lib/react-native/ParseQuery.js +6 -262
  161. package/lib/react-native/ParseRelation.js +0 -25
  162. package/lib/react-native/ParseRole.js +1 -36
  163. package/lib/react-native/ParseSchema.js +0 -51
  164. package/lib/react-native/ParseSession.js +1 -40
  165. package/lib/react-native/ParseUser.js +1 -224
  166. package/lib/react-native/Push.js +0 -16
  167. package/lib/react-native/RESTController.js +1 -70
  168. package/lib/react-native/SingleInstanceStateController.js +0 -44
  169. package/lib/react-native/Socket.weapp.js +2 -12
  170. package/lib/react-native/Storage.js +0 -24
  171. package/lib/react-native/StorageController.browser.js +0 -2
  172. package/lib/react-native/StorageController.default.js +0 -1
  173. package/lib/react-native/StorageController.react-native.js +0 -2
  174. package/lib/react-native/TaskQueue.js +0 -15
  175. package/lib/react-native/UniqueInstanceStateController.js +0 -47
  176. package/lib/react-native/Xhr.weapp.js +0 -16
  177. package/lib/react-native/arrayContainsObject.js +0 -5
  178. package/lib/react-native/canBeSerialized.js +0 -18
  179. package/lib/react-native/decode.js +0 -21
  180. package/lib/react-native/encode.js +0 -25
  181. package/lib/react-native/equals.js +0 -18
  182. package/lib/react-native/escape.js +0 -1
  183. package/lib/react-native/isRevocableSession.js +0 -1
  184. package/lib/react-native/parseDate.js +0 -3
  185. package/lib/react-native/promiseUtils.js +0 -13
  186. package/lib/react-native/unique.js +0 -4
  187. package/lib/react-native/unsavedChildren.js +0 -21
  188. package/lib/react-native/uuid.js +3 -1
  189. package/lib/weapp/Analytics.js +2 -20
  190. package/lib/weapp/AnonymousUtils.js +6 -35
  191. package/lib/weapp/Cloud.js +12 -70
  192. package/lib/weapp/CloudCode.js +0 -3
  193. package/lib/weapp/CoreManager.js +46 -184
  194. package/lib/weapp/CryptoController.js +2 -16
  195. package/lib/weapp/EventEmitter.js +1 -1
  196. package/lib/weapp/EventuallyQueue.js +277 -824
  197. package/lib/weapp/FacebookUtils.js +6 -35
  198. package/lib/weapp/IndexedDBStorageController.js +3 -14
  199. package/lib/weapp/InstallationController.js +2 -13
  200. package/lib/weapp/LiveQueryClient.js +87 -204
  201. package/lib/weapp/LiveQuerySubscription.js +10 -39
  202. package/lib/weapp/LocalDatastore.js +451 -1081
  203. package/lib/weapp/LocalDatastoreController.js +145 -602
  204. package/lib/weapp/LocalDatastoreController.react-native.js +137 -573
  205. package/lib/weapp/LocalDatastoreUtils.js +2 -12
  206. package/lib/weapp/ObjectStateMutations.js +18 -121
  207. package/lib/weapp/OfflineQuery.js +42 -222
  208. package/lib/weapp/Parse.js +12 -106
  209. package/lib/weapp/ParseACL.js +33 -141
  210. package/lib/weapp/ParseCLP.js +96 -314
  211. package/lib/weapp/ParseConfig.js +18 -88
  212. package/lib/weapp/ParseError.js +63 -90
  213. package/lib/weapp/ParseFile.js +129 -686
  214. package/lib/weapp/ParseGeoPoint.js +23 -82
  215. package/lib/weapp/ParseHooks.js +1 -34
  216. package/lib/weapp/ParseInstallation.js +4 -32
  217. package/lib/weapp/ParseLiveQuery.js +96 -505
  218. package/lib/weapp/ParseObject.js +628 -1840
  219. package/lib/weapp/ParseOp.js +41 -287
  220. package/lib/weapp/ParsePolygon.js +13 -63
  221. package/lib/weapp/ParseQuery.js +404 -1505
  222. package/lib/weapp/ParseRelation.js +12 -61
  223. package/lib/weapp/ParseRole.js +13 -75
  224. package/lib/weapp/ParseSchema.js +49 -201
  225. package/lib/weapp/ParseSession.js +11 -69
  226. package/lib/weapp/ParseUser.js +274 -1127
  227. package/lib/weapp/Push.js +7 -43
  228. package/lib/weapp/RESTController.js +18 -140
  229. package/lib/weapp/SingleInstanceStateController.js +19 -137
  230. package/lib/weapp/Socket.weapp.js +2 -12
  231. package/lib/weapp/Storage.js +10 -73
  232. package/lib/weapp/StorageController.browser.js +4 -17
  233. package/lib/weapp/StorageController.default.js +4 -17
  234. package/lib/weapp/StorageController.react-native.js +6 -33
  235. package/lib/weapp/StorageController.weapp.js +5 -16
  236. package/lib/weapp/TaskQueue.js +1 -22
  237. package/lib/weapp/UniqueInstanceStateController.js +19 -142
  238. package/lib/weapp/Xhr.weapp.js +0 -17
  239. package/lib/weapp/arrayContainsObject.js +2 -16
  240. package/lib/weapp/canBeSerialized.js +3 -33
  241. package/lib/weapp/decode.js +3 -33
  242. package/lib/weapp/encode.js +9 -70
  243. package/lib/weapp/equals.js +2 -25
  244. package/lib/weapp/escape.js +1 -8
  245. package/lib/weapp/isRevocableSession.js +2 -11
  246. package/lib/weapp/parseDate.js +2 -13
  247. package/lib/weapp/promiseUtils.js +3 -21
  248. package/lib/weapp/unique.js +3 -17
  249. package/lib/weapp/unsavedChildren.js +6 -50
  250. package/lib/weapp/uuid.js +1 -6
  251. package/package.json +45 -43
@@ -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,217 +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
64
  * @flow
77
65
  */
78
66
 
79
-
80
67
  let objectState
81
68
  /*: {
82
69
  [className: string]: {
83
70
  [id: string]: State,
84
71
  },
85
- }*/
86
- = {};
87
-
88
- function getState(obj
89
- /*: ObjectIdentifier*/
90
- )
91
- /*: ?State*/
92
- {
72
+ }*/ = {};
73
+ function getState(obj /*: ObjectIdentifier*/) /*: ?State*/{
93
74
  const classData = objectState[obj.className];
94
-
95
75
  if (classData) {
96
76
  return classData[obj.id] || null;
97
77
  }
98
-
99
78
  return null;
100
79
  }
101
-
102
- function initializeState(obj
103
- /*: ObjectIdentifier*/
104
- , initial
105
- /*:: ?: State*/
106
- )
107
- /*: State*/
108
- {
80
+ function initializeState(obj /*: ObjectIdentifier*/, initial /*:: ?: State*/) /*: State*/{
109
81
  let state = getState(obj);
110
-
111
82
  if (state) {
112
83
  return state;
113
84
  }
114
-
115
85
  if (!objectState[obj.className]) {
116
86
  objectState[obj.className] = {};
117
87
  }
118
-
119
88
  if (!initial) {
120
89
  initial = ObjectStateMutations.defaultState();
121
90
  }
122
-
123
91
  state = objectState[obj.className][obj.id] = initial;
124
92
  return state;
125
93
  }
126
-
127
- function removeState(obj
128
- /*: ObjectIdentifier*/
129
- )
130
- /*: ?State*/
131
- {
94
+ function removeState(obj /*: ObjectIdentifier*/) /*: ?State*/{
132
95
  const state = getState(obj);
133
-
134
96
  if (state === null) {
135
97
  return null;
136
98
  }
137
-
138
99
  delete objectState[obj.className][obj.id];
139
100
  return state;
140
101
  }
141
-
142
- function getServerData(obj
143
- /*: ObjectIdentifier*/
144
- )
145
- /*: AttributeMap*/
146
- {
102
+ function getServerData(obj /*: ObjectIdentifier*/) /*: AttributeMap*/{
147
103
  const state = getState(obj);
148
-
149
104
  if (state) {
150
105
  return state.serverData;
151
106
  }
152
-
153
107
  return {};
154
108
  }
155
-
156
- function setServerData(obj
157
- /*: ObjectIdentifier*/
158
- , attributes
159
- /*: AttributeMap*/
160
- ) {
109
+ function setServerData(obj /*: ObjectIdentifier*/, attributes /*: AttributeMap*/) {
161
110
  const serverData = initializeState(obj).serverData;
162
111
  ObjectStateMutations.setServerData(serverData, attributes);
163
112
  }
164
-
165
- function getPendingOps(obj
166
- /*: ObjectIdentifier*/
167
- )
168
- /*: Array<OpsMap>*/
169
- {
113
+ function getPendingOps(obj /*: ObjectIdentifier*/) /*: Array<OpsMap>*/{
170
114
  const state = getState(obj);
171
-
172
115
  if (state) {
173
116
  return state.pendingOps;
174
117
  }
175
-
176
118
  return [{}];
177
119
  }
178
-
179
- function setPendingOp(obj
180
- /*: ObjectIdentifier*/
181
- , attr
182
- /*: string*/
183
- , op
184
- /*: ?Op*/
185
- ) {
120
+ function setPendingOp(obj /*: ObjectIdentifier*/, attr /*: string*/, op /*: ?Op*/) {
186
121
  const pendingOps = initializeState(obj).pendingOps;
187
122
  ObjectStateMutations.setPendingOp(pendingOps, attr, op);
188
123
  }
189
-
190
- function pushPendingState(obj
191
- /*: ObjectIdentifier*/
192
- ) {
124
+ function pushPendingState(obj /*: ObjectIdentifier*/) {
193
125
  const pendingOps = initializeState(obj).pendingOps;
194
126
  ObjectStateMutations.pushPendingState(pendingOps);
195
127
  }
196
-
197
- function popPendingState(obj
198
- /*: ObjectIdentifier*/
199
- )
200
- /*: OpsMap*/
201
- {
128
+ function popPendingState(obj /*: ObjectIdentifier*/) /*: OpsMap*/{
202
129
  const pendingOps = initializeState(obj).pendingOps;
203
130
  return ObjectStateMutations.popPendingState(pendingOps);
204
131
  }
205
-
206
- function mergeFirstPendingState(obj
207
- /*: ObjectIdentifier*/
208
- ) {
132
+ function mergeFirstPendingState(obj /*: ObjectIdentifier*/) {
209
133
  const pendingOps = getPendingOps(obj);
210
134
  ObjectStateMutations.mergeFirstPendingState(pendingOps);
211
135
  }
212
-
213
- function getObjectCache(obj
214
- /*: ObjectIdentifier*/
215
- )
216
- /*: ObjectCache*/
217
- {
136
+ function getObjectCache(obj /*: ObjectIdentifier*/) /*: ObjectCache*/{
218
137
  const state = getState(obj);
219
-
220
138
  if (state) {
221
139
  return state.objectCache;
222
140
  }
223
-
224
141
  return {};
225
142
  }
226
-
227
- function estimateAttribute(obj
228
- /*: ObjectIdentifier*/
229
- , attr
230
- /*: string*/
231
- )
232
- /*: mixed*/
233
- {
143
+ function estimateAttribute(obj /*: ObjectIdentifier*/, attr /*: string*/) /*: mixed*/{
234
144
  const serverData = getServerData(obj);
235
145
  const pendingOps = getPendingOps(obj);
236
146
  return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj.className, obj.id, attr);
237
147
  }
238
-
239
- function estimateAttributes(obj
240
- /*: ObjectIdentifier*/
241
- )
242
- /*: AttributeMap*/
243
- {
148
+ function estimateAttributes(obj /*: ObjectIdentifier*/) /*: AttributeMap*/{
244
149
  const serverData = getServerData(obj);
245
150
  const pendingOps = getPendingOps(obj);
246
151
  return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj.className, obj.id);
247
152
  }
248
-
249
- function commitServerChanges(obj
250
- /*: ObjectIdentifier*/
251
- , changes
252
- /*: AttributeMap*/
253
- ) {
153
+ function commitServerChanges(obj /*: ObjectIdentifier*/, changes /*: AttributeMap*/) {
254
154
  const state = initializeState(obj);
255
155
  ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
256
156
  }
257
-
258
- function enqueueTask(obj
259
- /*: ObjectIdentifier*/
260
- , task
261
- /*: () => Promise*/
262
- )
263
- /*: Promise*/
264
- {
157
+ function enqueueTask(obj /*: ObjectIdentifier*/, task /*: () => Promise*/) /*: Promise*/{
265
158
  const state = initializeState(obj);
266
159
  return state.tasks.enqueue(task);
267
160
  }
268
-
269
161
  function clearAllState() {
270
162
  objectState = {};
271
163
  }
272
-
273
- function duplicateState(source
274
- /*: { id: string }*/
275
- , dest
276
- /*: { id: string }*/
277
- ) {
164
+ function duplicateState(source /*: { id: string }*/, dest /*: { id: string }*/) {
278
165
  dest.id = source.id;
279
166
  }
@@ -3,21 +3,17 @@
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
  });
16
12
  wx.onSocketMessage(msg => {
17
13
  this.onmessage(msg);
18
14
  });
19
- wx.onSocketClose(() => {
20
- this.onclose();
15
+ wx.onSocketClose(event => {
16
+ this.onclose(event);
21
17
  });
22
18
  wx.onSocketError(error => {
23
19
  this.onerror(error);
@@ -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,7 +1,6 @@
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
@@ -11,157 +10,85 @@ function _interopRequireDefault(obj) {
11
10
  * @flow
12
11
  */
13
12
 
14
-
15
13
  const Storage = {
16
- async()
17
- /*: boolean*/
18
- {
14
+ async() /*: boolean*/{
19
15
  const controller = _CoreManager.default.getStorageController();
20
-
21
16
  return !!controller.async;
22
17
  },
23
-
24
- getItem(path
25
- /*: string*/
26
- )
27
- /*: ?string*/
28
- {
18
+ getItem(path /*: string*/) /*: ?string*/{
29
19
  const controller = _CoreManager.default.getStorageController();
30
-
31
20
  if (controller.async === 1) {
32
21
  throw new Error('Synchronous storage is not supported by the current storage controller');
33
22
  }
34
-
35
23
  return controller.getItem(path);
36
24
  },
37
-
38
- getItemAsync(path
39
- /*: string*/
40
- )
41
- /*: Promise<string>*/
42
- {
25
+ getItemAsync(path /*: string*/) /*: Promise<string>*/{
43
26
  const controller = _CoreManager.default.getStorageController();
44
-
45
27
  if (controller.async === 1) {
46
28
  return controller.getItemAsync(path);
47
29
  }
48
-
49
30
  return Promise.resolve(controller.getItem(path));
50
31
  },
51
-
52
- setItem(path
53
- /*: string*/
54
- , value
55
- /*: string*/
56
- )
57
- /*: void*/
58
- {
32
+ setItem(path /*: string*/, value /*: string*/) /*: void*/{
59
33
  const controller = _CoreManager.default.getStorageController();
60
-
61
34
  if (controller.async === 1) {
62
35
  throw new Error('Synchronous storage is not supported by the current storage controller');
63
36
  }
64
-
65
37
  return controller.setItem(path, value);
66
38
  },
67
-
68
- setItemAsync(path
69
- /*: string*/
70
- , value
71
- /*: string*/
72
- )
73
- /*: Promise<void>*/
74
- {
39
+ setItemAsync(path /*: string*/, value /*: string*/) /*: Promise<void>*/{
75
40
  const controller = _CoreManager.default.getStorageController();
76
-
77
41
  if (controller.async === 1) {
78
42
  return controller.setItemAsync(path, value);
79
43
  }
80
-
81
44
  return Promise.resolve(controller.setItem(path, value));
82
45
  },
83
-
84
- removeItem(path
85
- /*: string*/
86
- )
87
- /*: void*/
88
- {
46
+ removeItem(path /*: string*/) /*: void*/{
89
47
  const controller = _CoreManager.default.getStorageController();
90
-
91
48
  if (controller.async === 1) {
92
49
  throw new Error('Synchronous storage is not supported by the current storage controller');
93
50
  }
94
-
95
51
  return controller.removeItem(path);
96
52
  },
97
-
98
- removeItemAsync(path
99
- /*: string*/
100
- )
101
- /*: Promise<void>*/
102
- {
53
+ removeItemAsync(path /*: string*/) /*: Promise<void>*/{
103
54
  const controller = _CoreManager.default.getStorageController();
104
-
105
55
  if (controller.async === 1) {
106
56
  return controller.removeItemAsync(path);
107
57
  }
108
-
109
58
  return Promise.resolve(controller.removeItem(path));
110
59
  },
111
-
112
- getAllKeys()
113
- /*: Array<string>*/
114
- {
60
+ getAllKeys() /*: Array<string>*/{
115
61
  const controller = _CoreManager.default.getStorageController();
116
-
117
62
  if (controller.async === 1) {
118
63
  throw new Error('Synchronous storage is not supported by the current storage controller');
119
64
  }
120
-
121
65
  return controller.getAllKeys();
122
66
  },
123
-
124
- getAllKeysAsync()
125
- /*: Promise<Array<string>>*/
126
- {
67
+ getAllKeysAsync() /*: Promise<Array<string>>*/{
127
68
  const controller = _CoreManager.default.getStorageController();
128
-
129
69
  if (controller.async === 1) {
130
70
  return controller.getAllKeysAsync();
131
71
  }
132
-
133
72
  return Promise.resolve(controller.getAllKeys());
134
73
  },
135
-
136
- generatePath(path
137
- /*: string*/
138
- )
139
- /*: string*/
140
- {
74
+ generatePath(path /*: string*/) /*: string*/{
141
75
  if (!_CoreManager.default.get('APPLICATION_ID')) {
142
76
  throw new Error('You need to call Parse.initialize before using Parse.');
143
77
  }
144
-
145
78
  if (typeof path !== 'string') {
146
79
  throw new Error('Tried to get a Storage path that was not a String.');
147
80
  }
148
-
149
81
  if (path[0] === '/') {
150
82
  path = path.substr(1);
151
83
  }
152
-
153
84
  return 'Parse/' + _CoreManager.default.get('APPLICATION_ID') + '/' + path;
154
85
  },
155
-
156
86
  _clear() {
157
87
  const controller = _CoreManager.default.getStorageController();
158
-
159
88
  if (controller.hasOwnProperty('clear')) {
160
89
  controller.clear();
161
90
  }
162
91
  }
163
-
164
92
  };
165
93
  module.exports = Storage;
166
-
167
94
  _CoreManager.default.setStorageController(require('./StorageController.default'));
@@ -1,27 +1,16 @@
1
1
  "use strict";
2
+
2
3
  /**
3
4
  * @flow
4
5
  * @private
5
6
  */
6
-
7
7
  /* global localStorage */
8
-
9
8
  const StorageController = {
10
9
  async: 0,
11
-
12
- getItem(path
13
- /*: string*/
14
- )
15
- /*: ?string*/
16
- {
10
+ getItem(path /*: string*/) /*: ?string*/{
17
11
  return localStorage.getItem(path);
18
12
  },
19
-
20
- setItem(path
21
- /*: string*/
22
- , value
23
- /*: string*/
24
- ) {
13
+ setItem(path /*: string*/, value /*: string*/) {
25
14
  try {
26
15
  localStorage.setItem(path, value);
27
16
  } catch (e) {
@@ -29,26 +18,18 @@ const StorageController = {
29
18
  console.log(e.message);
30
19
  }
31
20
  },
32
-
33
- removeItem(path
34
- /*: string*/
35
- ) {
21
+ removeItem(path /*: string*/) {
36
22
  localStorage.removeItem(path);
37
23
  },
38
-
39
24
  getAllKeys() {
40
25
  const keys = [];
41
-
42
26
  for (let i = 0; i < localStorage.length; i += 1) {
43
27
  keys.push(localStorage.key(i));
44
28
  }
45
-
46
29
  return keys;
47
30
  },
48
-
49
31
  clear() {
50
32
  localStorage.clear();
51
33
  }
52
-
53
34
  };
54
35
  module.exports = StorageController;
@@ -1,44 +1,29 @@
1
1
  "use strict";
2
+
2
3
  /**
3
4
  * @flow
4
5
  * @private
5
6
  */
6
- // When there is no native storage interface, we default to an in-memory map
7
7
 
8
+ // When there is no native storage interface, we default to an in-memory map
8
9
  const memMap = {};
9
10
  const StorageController = {
10
11
  async: 0,
11
-
12
- getItem(path
13
- /*: string*/
14
- )
15
- /*: ?string*/
16
- {
12
+ getItem(path /*: string*/) /*: ?string*/{
17
13
  if (memMap.hasOwnProperty(path)) {
18
14
  return memMap[path];
19
15
  }
20
-
21
16
  return null;
22
17
  },
23
-
24
- setItem(path
25
- /*: string*/
26
- , value
27
- /*: string*/
28
- ) {
18
+ setItem(path /*: string*/, value /*: string*/) {
29
19
  memMap[path] = String(value);
30
20
  },
31
-
32
- removeItem(path
33
- /*: string*/
34
- ) {
21
+ removeItem(path /*: string*/) {
35
22
  delete memMap[path];
36
23
  },
37
-
38
24
  getAllKeys() {
39
25
  return Object.keys(memMap);
40
26
  },
41
-
42
27
  clear() {
43
28
  for (const key in memMap) {
44
29
  if (memMap.hasOwnProperty(key)) {
@@ -46,6 +31,5 @@ const StorageController = {
46
31
  }
47
32
  }
48
33
  }
49
-
50
34
  };
51
35
  module.exports = StorageController;
@@ -1,7 +1,6 @@
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
@@ -12,15 +11,9 @@ function _interopRequireDefault(obj) {
12
11
  * @private
13
12
  */
14
13
 
15
-
16
14
  const StorageController = {
17
15
  async: 1,
18
-
19
- getItemAsync(path
20
- /*: string*/
21
- )
22
- /*: Promise*/
23
- {
16
+ getItemAsync(path /*: string*/) /*: Promise*/{
24
17
  return new Promise((resolve, reject) => {
25
18
  _CoreManager.default.getAsyncStorage().getItem(path, (err, value) => {
26
19
  if (err) {
@@ -31,14 +24,7 @@ const StorageController = {
31
24
  });
32
25
  });
33
26
  },
34
-
35
- setItemAsync(path
36
- /*: string*/
37
- , value
38
- /*: string*/
39
- )
40
- /*: Promise*/
41
- {
27
+ setItemAsync(path /*: string*/, value /*: string*/) /*: Promise*/{
42
28
  return new Promise((resolve, reject) => {
43
29
  _CoreManager.default.getAsyncStorage().setItem(path, value, (err, value) => {
44
30
  if (err) {
@@ -49,12 +35,7 @@ const StorageController = {
49
35
  });
50
36
  });
51
37
  },
52
-
53
- removeItemAsync(path
54
- /*: string*/
55
- )
56
- /*: Promise*/
57
- {
38
+ removeItemAsync(path /*: string*/) /*: Promise*/{
58
39
  return new Promise((resolve, reject) => {
59
40
  _CoreManager.default.getAsyncStorage().removeItem(path, err => {
60
41
  if (err) {
@@ -65,10 +46,7 @@ const StorageController = {
65
46
  });
66
47
  });
67
48
  },
68
-
69
- getAllKeysAsync()
70
- /*: Promise*/
71
- {
49
+ getAllKeysAsync() /*: Promise*/{
72
50
  return new Promise((resolve, reject) => {
73
51
  _CoreManager.default.getAsyncStorage().getAllKeys((err, keys) => {
74
52
  if (err) {
@@ -79,12 +57,7 @@ const StorageController = {
79
57
  });
80
58
  });
81
59
  },
82
-
83
- multiGet(keys
84
- /*: Array<string>*/
85
- )
86
- /*: Promise<Array<Array<string>>>*/
87
- {
60
+ multiGet(keys /*: Array<string>*/) /*: Promise<Array<Array<string>>>*/{
88
61
  return new Promise((resolve, reject) => {
89
62
  _CoreManager.default.getAsyncStorage().multiGet(keys, (err, result) => {
90
63
  if (err) {
@@ -95,12 +68,7 @@ const StorageController = {
95
68
  });
96
69
  });
97
70
  },
98
-
99
- multiRemove(keys
100
- /*: Array<string>*/
101
- )
102
- /*: Promise*/
103
- {
71
+ multiRemove(keys /*: Array<string>*/) /*: Promise*/{
104
72
  return new Promise((resolve, reject) => {
105
73
  _CoreManager.default.getAsyncStorage().multiRemove(keys, err => {
106
74
  if (err) {
@@ -111,10 +79,8 @@ const StorageController = {
111
79
  });
112
80
  });
113
81
  },
114
-
115
82
  clear() {
116
83
  return _CoreManager.default.getAsyncStorage().clear();
117
84
  }
118
-
119
85
  };
120
86
  module.exports = StorageController;