parse 4.0.0-alpha.1 → 4.0.0-alpha.11

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 +6 -5
  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 +13 -100
  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 +69 -269
  92. package/lib/node/ParseConfig.js +16 -91
  93. package/lib/node/ParseError.js +61 -74
  94. package/lib/node/ParseFile.js +49 -212
  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 +229 -964
  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 +18 -127
  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 +35 -31
  255. package/PATENTS +0 -37
@@ -1,33 +1,19 @@
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
  * @private
20
12
  */
21
13
 
22
-
23
14
  const StorageController = {
24
15
  async: 1,
25
-
26
- getItemAsync(path
27
- /*: string*/
28
- )
29
- /*: Promise*/
30
- {
16
+ getItemAsync(path /*: string*/) /*: Promise*/{
31
17
  return new Promise((resolve, reject) => {
32
18
  _CoreManager.default.getAsyncStorage().getItem(path, (err, value) => {
33
19
  if (err) {
@@ -38,14 +24,7 @@ const StorageController = {
38
24
  });
39
25
  });
40
26
  },
41
-
42
- setItemAsync(path
43
- /*: string*/
44
- , value
45
- /*: string*/
46
- )
47
- /*: Promise*/
48
- {
27
+ setItemAsync(path /*: string*/, value /*: string*/) /*: Promise*/{
49
28
  return new Promise((resolve, reject) => {
50
29
  _CoreManager.default.getAsyncStorage().setItem(path, value, (err, value) => {
51
30
  if (err) {
@@ -56,12 +35,7 @@ const StorageController = {
56
35
  });
57
36
  });
58
37
  },
59
-
60
- removeItemAsync(path
61
- /*: string*/
62
- )
63
- /*: Promise*/
64
- {
38
+ removeItemAsync(path /*: string*/) /*: Promise*/{
65
39
  return new Promise((resolve, reject) => {
66
40
  _CoreManager.default.getAsyncStorage().removeItem(path, err => {
67
41
  if (err) {
@@ -72,10 +46,7 @@ const StorageController = {
72
46
  });
73
47
  });
74
48
  },
75
-
76
- getAllKeysAsync()
77
- /*: Promise*/
78
- {
49
+ getAllKeysAsync() /*: Promise*/{
79
50
  return new Promise((resolve, reject) => {
80
51
  _CoreManager.default.getAsyncStorage().getAllKeys((err, keys) => {
81
52
  if (err) {
@@ -86,12 +57,7 @@ const StorageController = {
86
57
  });
87
58
  });
88
59
  },
89
-
90
- multiGet(keys
91
- /*: Array<string>*/
92
- )
93
- /*: Promise<Array<Array<string>>>*/
94
- {
60
+ multiGet(keys /*: Array<string>*/) /*: Promise<Array<Array<string>>>*/{
95
61
  return new Promise((resolve, reject) => {
96
62
  _CoreManager.default.getAsyncStorage().multiGet(keys, (err, result) => {
97
63
  if (err) {
@@ -102,12 +68,7 @@ const StorageController = {
102
68
  });
103
69
  });
104
70
  },
105
-
106
- multiRemove(keys
107
- /*: Array<string>*/
108
- )
109
- /*: Promise*/
110
- {
71
+ multiRemove(keys /*: Array<string>*/) /*: Promise*/{
111
72
  return new Promise((resolve, reject) => {
112
73
  _CoreManager.default.getAsyncStorage().multiRemove(keys, err => {
113
74
  if (err) {
@@ -118,10 +79,8 @@ const StorageController = {
118
79
  });
119
80
  });
120
81
  },
121
-
122
82
  clear() {
123
83
  return _CoreManager.default.getAsyncStorage().clear();
124
84
  }
125
-
126
85
  };
127
86
  module.exports = StorageController;
@@ -1,52 +1,30 @@
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
  const StorageController = {
15
8
  async: 0,
16
-
17
- getItem(path
18
- /*: string*/
19
- )
20
- /*: ?string*/
21
- {
9
+ getItem(path /*: string*/) /*: ?string*/{
22
10
  return wx.getStorageSync(path);
23
11
  },
24
-
25
- setItem(path
26
- /*: string*/
27
- , value
28
- /*: string*/
29
- ) {
12
+ setItem(path /*: string*/, value /*: string*/) {
30
13
  try {
31
14
  wx.setStorageSync(path, value);
32
- } catch (e) {// Quota exceeded
15
+ } catch (e) {
16
+ // Quota exceeded
33
17
  }
34
18
  },
35
-
36
- removeItem(path
37
- /*: string*/
38
- ) {
19
+ removeItem(path /*: string*/) {
39
20
  wx.removeStorageSync(path);
40
21
  },
41
-
42
22
  getAllKeys() {
43
23
  const res = wx.getStorageInfoSync();
44
24
  return res.keys;
45
25
  },
46
-
47
26
  clear() {
48
27
  wx.clearStorageSync();
49
28
  }
50
-
51
29
  };
52
30
  module.exports = StorageController;
@@ -2,66 +2,43 @@
2
2
 
3
3
  var _promiseUtils = require("./promiseUtils");
4
4
  /**
5
- * Copyright (c) 2015-present, Parse, LLC.
6
- * All rights reserved.
7
- *
8
- * This source code is licensed under the BSD-style license found in the
9
- * LICENSE file in the root directory of this source tree. An additional grant
10
- * of patent rights can be found in the PATENTS file in the same directory.
11
- *
12
5
  * @flow
13
6
  */
14
7
 
15
-
16
8
  class TaskQueue {
17
9
  /*:: queue: Array<Task>;*/
18
10
  constructor() {
19
11
  this.queue = [];
20
12
  }
21
-
22
- enqueue(task
23
- /*: () => Promise*/
24
- )
25
- /*: Promise*/
26
- {
13
+ enqueue(task /*: () => Promise*/) /*: Promise*/{
27
14
  const taskComplete = new _promiseUtils.resolvingPromise();
28
15
  this.queue.push({
29
16
  task: task,
30
17
  _completion: taskComplete
31
18
  });
32
-
33
19
  if (this.queue.length === 1) {
34
20
  task().then(() => {
35
21
  this._dequeue();
36
-
37
22
  taskComplete.resolve();
38
23
  }, error => {
39
24
  this._dequeue();
40
-
41
25
  taskComplete.reject(error);
42
26
  });
43
27
  }
44
-
45
28
  return taskComplete;
46
29
  }
47
-
48
30
  _dequeue() {
49
31
  this.queue.shift();
50
-
51
32
  if (this.queue.length) {
52
33
  const next = this.queue[0];
53
34
  next.task().then(() => {
54
35
  this._dequeue();
55
-
56
36
  next._completion.resolve();
57
37
  }, error => {
58
38
  this._dequeue();
59
-
60
39
  next._completion.reject(error);
61
40
  });
62
41
  }
63
42
  }
64
-
65
43
  }
66
-
67
44
  module.exports = TaskQueue;
@@ -20,17 +20,13 @@ 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
  var _TaskQueue = _interopRequireDefault(require("./TaskQueue"));
27
-
28
25
  function _interopRequireDefault(obj) {
29
26
  return obj && obj.__esModule ? obj : {
30
27
  default: obj
31
28
  };
32
29
  }
33
-
34
30
  function _getRequireWildcardCache(nodeInterop) {
35
31
  if (typeof WeakMap !== "function") return null;
36
32
  var cacheBabelInterop = new WeakMap();
@@ -39,31 +35,24 @@ function _getRequireWildcardCache(nodeInterop) {
39
35
  return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
40
36
  })(nodeInterop);
41
37
  }
42
-
43
38
  function _interopRequireWildcard(obj, nodeInterop) {
44
39
  if (!nodeInterop && obj && obj.__esModule) {
45
40
  return obj;
46
41
  }
47
-
48
42
  if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
49
43
  return {
50
44
  default: obj
51
45
  };
52
46
  }
53
-
54
47
  var cache = _getRequireWildcardCache(nodeInterop);
55
-
56
48
  if (cache && cache.has(obj)) {
57
49
  return cache.get(obj);
58
50
  }
59
-
60
51
  var newObj = {};
61
52
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
62
-
63
53
  for (var key in obj) {
64
54
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
65
55
  var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
66
-
67
56
  if (desc && (desc.get || desc.set)) {
68
57
  Object.defineProperty(newObj, key, desc);
69
58
  } else {
@@ -71,51 +60,26 @@ function _interopRequireWildcard(obj, nodeInterop) {
71
60
  }
72
61
  }
73
62
  }
74
-
75
63
  newObj.default = obj;
76
-
77
64
  if (cache) {
78
65
  cache.set(obj, newObj);
79
66
  }
80
-
81
67
  return newObj;
82
68
  }
83
69
  /**
84
- * Copyright (c) 2015-present, Parse, LLC.
85
- * All rights reserved.
86
- *
87
- * This source code is licensed under the BSD-style license found in the
88
- * LICENSE file in the root directory of this source tree. An additional grant
89
- * of patent rights can be found in the PATENTS file in the same directory.
90
- *
91
70
  * @flow
92
71
  */
93
72
 
94
-
95
73
  let objectState = new WeakMap();
96
-
97
- function getState(obj
98
- /*: ParseObject*/
99
- )
100
- /*: ?State*/
101
- {
74
+ function getState(obj /*: ParseObject*/) /*: ?State*/{
102
75
  const classData = objectState.get(obj);
103
76
  return classData || null;
104
77
  }
105
-
106
- function initializeState(obj
107
- /*: ParseObject*/
108
- , initial
109
- /*:: ?: State*/
110
- )
111
- /*: State*/
112
- {
78
+ function initializeState(obj /*: ParseObject*/, initial /*:: ?: State*/) /*: State*/{
113
79
  let state = getState(obj);
114
-
115
80
  if (state) {
116
81
  return state;
117
82
  }
118
-
119
83
  if (!initial) {
120
84
  initial = {
121
85
  serverData: {},
@@ -125,181 +89,93 @@ function initializeState(obj
125
89
  existed: false
126
90
  };
127
91
  }
128
-
129
92
  state = initial;
130
93
  objectState.set(obj, state);
131
94
  return state;
132
95
  }
133
-
134
- function removeState(obj
135
- /*: ParseObject*/
136
- )
137
- /*: ?State*/
138
- {
96
+ function removeState(obj /*: ParseObject*/) /*: ?State*/{
139
97
  const state = getState(obj);
140
-
141
98
  if (state === null) {
142
99
  return null;
143
100
  }
144
-
145
101
  objectState.delete(obj);
146
102
  return state;
147
103
  }
148
-
149
- function getServerData(obj
150
- /*: ParseObject*/
151
- )
152
- /*: AttributeMap*/
153
- {
104
+ function getServerData(obj /*: ParseObject*/) /*: AttributeMap*/{
154
105
  const state = getState(obj);
155
-
156
106
  if (state) {
157
107
  return state.serverData;
158
108
  }
159
-
160
109
  return {};
161
110
  }
162
-
163
- function setServerData(obj
164
- /*: ParseObject*/
165
- , attributes
166
- /*: AttributeMap*/
167
- ) {
111
+ function setServerData(obj /*: ParseObject*/, attributes /*: AttributeMap*/) {
168
112
  const serverData = initializeState(obj).serverData;
169
113
  ObjectStateMutations.setServerData(serverData, attributes);
170
114
  }
171
-
172
- function getPendingOps(obj
173
- /*: ParseObject*/
174
- )
175
- /*: Array<OpsMap>*/
176
- {
115
+ function getPendingOps(obj /*: ParseObject*/) /*: Array<OpsMap>*/{
177
116
  const state = getState(obj);
178
-
179
117
  if (state) {
180
118
  return state.pendingOps;
181
119
  }
182
-
183
120
  return [{}];
184
121
  }
185
-
186
- function setPendingOp(obj
187
- /*: ParseObject*/
188
- , attr
189
- /*: string*/
190
- , op
191
- /*: ?Op*/
192
- ) {
122
+ function setPendingOp(obj /*: ParseObject*/, attr /*: string*/, op /*: ?Op*/) {
193
123
  const pendingOps = initializeState(obj).pendingOps;
194
124
  ObjectStateMutations.setPendingOp(pendingOps, attr, op);
195
125
  }
196
-
197
- function pushPendingState(obj
198
- /*: ParseObject*/
199
- ) {
126
+ function pushPendingState(obj /*: ParseObject*/) {
200
127
  const pendingOps = initializeState(obj).pendingOps;
201
128
  ObjectStateMutations.pushPendingState(pendingOps);
202
129
  }
203
-
204
- function popPendingState(obj
205
- /*: ParseObject*/
206
- )
207
- /*: OpsMap*/
208
- {
130
+ function popPendingState(obj /*: ParseObject*/) /*: OpsMap*/{
209
131
  const pendingOps = initializeState(obj).pendingOps;
210
132
  return ObjectStateMutations.popPendingState(pendingOps);
211
133
  }
212
-
213
- function mergeFirstPendingState(obj
214
- /*: ParseObject*/
215
- ) {
134
+ function mergeFirstPendingState(obj /*: ParseObject*/) {
216
135
  const pendingOps = getPendingOps(obj);
217
136
  ObjectStateMutations.mergeFirstPendingState(pendingOps);
218
137
  }
219
-
220
- function getObjectCache(obj
221
- /*: ParseObject*/
222
- )
223
- /*: ObjectCache*/
224
- {
138
+ function getObjectCache(obj /*: ParseObject*/) /*: ObjectCache*/{
225
139
  const state = getState(obj);
226
-
227
140
  if (state) {
228
141
  return state.objectCache;
229
142
  }
230
-
231
143
  return {};
232
144
  }
233
-
234
- function estimateAttribute(obj
235
- /*: ParseObject*/
236
- , attr
237
- /*: string*/
238
- )
239
- /*: mixed*/
240
- {
145
+ function estimateAttribute(obj /*: ParseObject*/, attr /*: string*/) /*: mixed*/{
241
146
  const serverData = getServerData(obj);
242
147
  const pendingOps = getPendingOps(obj);
243
148
  return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj.className, obj.id, attr);
244
149
  }
245
-
246
- function estimateAttributes(obj
247
- /*: ParseObject*/
248
- )
249
- /*: AttributeMap*/
250
- {
150
+ function estimateAttributes(obj /*: ParseObject*/) /*: AttributeMap*/{
251
151
  const serverData = getServerData(obj);
252
152
  const pendingOps = getPendingOps(obj);
253
153
  return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj.className, obj.id);
254
154
  }
255
-
256
- function commitServerChanges(obj
257
- /*: ParseObject*/
258
- , changes
259
- /*: AttributeMap*/
260
- ) {
155
+ function commitServerChanges(obj /*: ParseObject*/, changes /*: AttributeMap*/) {
261
156
  const state = initializeState(obj);
262
157
  ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
263
158
  }
264
-
265
- function enqueueTask(obj
266
- /*: ParseObject*/
267
- , task
268
- /*: () => Promise*/
269
- )
270
- /*: Promise*/
271
- {
159
+ function enqueueTask(obj /*: ParseObject*/, task /*: () => Promise*/) /*: Promise*/{
272
160
  const state = initializeState(obj);
273
161
  return state.tasks.enqueue(task);
274
162
  }
275
-
276
- function duplicateState(source
277
- /*: ParseObject*/
278
- , dest
279
- /*: ParseObject*/
280
- )
281
- /*: void*/
282
- {
163
+ function duplicateState(source /*: ParseObject*/, dest /*: ParseObject*/) /*: void*/{
283
164
  const oldState = initializeState(source);
284
165
  const newState = initializeState(dest);
285
-
286
166
  for (const key in oldState.serverData) {
287
167
  newState.serverData[key] = oldState.serverData[key];
288
168
  }
289
-
290
169
  for (let index = 0; index < oldState.pendingOps.length; index++) {
291
170
  for (const key in oldState.pendingOps[index]) {
292
171
  newState.pendingOps[index][key] = oldState.pendingOps[index][key];
293
172
  }
294
173
  }
295
-
296
174
  for (const key in oldState.objectCache) {
297
175
  newState.objectCache[key] = oldState.objectCache[key];
298
176
  }
299
-
300
177
  newState.existed = oldState.existed;
301
178
  }
302
-
303
179
  function clearAllState() {
304
180
  objectState = new WeakMap();
305
181
  }
@@ -16,53 +16,39 @@ module.exports = class {
16
16
  this.responseHeader = {};
17
17
  this.method = '';
18
18
  this.url = '';
19
-
20
19
  this.onabort = () => {};
21
-
22
20
  this.onprogress = () => {};
23
-
24
21
  this.onerror = () => {};
25
-
26
22
  this.onreadystatechange = () => {};
27
-
28
23
  this.requestTask = null;
29
24
  }
30
-
31
25
  getAllResponseHeaders() {
32
26
  let header = '';
33
-
34
27
  for (const key in this.responseHeader) {
35
28
  header += key + ':' + this.getResponseHeader(key) + '\r\n';
36
29
  }
37
-
38
30
  return header;
39
31
  }
40
-
41
32
  getResponseHeader(key) {
42
33
  return this.responseHeader[key];
43
34
  }
44
-
45
35
  setRequestHeader(key, value) {
46
36
  this.header[key] = value;
47
37
  }
48
-
49
38
  open(method, url) {
50
39
  this.method = method;
51
40
  this.url = url;
52
41
  }
53
-
54
42
  abort() {
55
43
  if (!this.requestTask) {
56
44
  return;
57
45
  }
58
-
59
46
  this.requestTask.abort();
60
47
  this.status = 0;
61
48
  this.response = undefined;
62
49
  this.onabort();
63
50
  this.onreadystatechange();
64
51
  }
65
-
66
52
  send(data) {
67
53
  this.requestTask = wx.request({
68
54
  url: this.url,
@@ -92,5 +78,4 @@ module.exports = class {
92
78
  this.onprogress(event);
93
79
  });
94
80
  }
95
-
96
81
  };
@@ -4,42 +4,24 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = arrayContainsObject;
7
-
8
7
  var _ParseObject = _interopRequireDefault(require("./ParseObject"));
9
-
10
8
  function _interopRequireDefault(obj) {
11
9
  return obj && obj.__esModule ? obj : {
12
10
  default: obj
13
11
  };
14
12
  }
15
13
  /**
16
- * Copyright (c) 2015-present, Parse, LLC.
17
- * All rights reserved.
18
- *
19
- * This source code is licensed under the BSD-style license found in the
20
- * LICENSE file in the root directory of this source tree. An additional grant
21
- * of patent rights can be found in the PATENTS file in the same directory.
22
- *
23
14
  * @flow
24
15
  */
25
16
 
26
-
27
- function arrayContainsObject(array
28
- /*: Array<any>*/
29
- , object
30
- /*: ParseObject*/
31
- )
32
- /*: boolean*/
33
- {
17
+ function arrayContainsObject(array /*: Array<any>*/, object /*: ParseObject*/) /*: boolean*/{
34
18
  if (array.indexOf(object) > -1) {
35
19
  return true;
36
20
  }
37
-
38
21
  for (let i = 0; i < array.length; i++) {
39
22
  if (array[i] instanceof _ParseObject.default && array[i].className === object.className && array[i]._getId() === object._getId()) {
40
23
  return true;
41
24
  }
42
25
  }
43
-
44
26
  return false;
45
27
  }