| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 | 
							- "use strict";
 
- var _typeof = require("@babel/runtime-corejs3/helpers/typeof");
 
- var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
 
- var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
 
- var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
 
- _Object$defineProperty(exports, "__esModule", {
 
-   value: true
 
- });
 
- exports.clearAllState = clearAllState;
 
- exports.commitServerChanges = commitServerChanges;
 
- exports.duplicateState = duplicateState;
 
- exports.enqueueTask = enqueueTask;
 
- exports.estimateAttribute = estimateAttribute;
 
- exports.estimateAttributes = estimateAttributes;
 
- exports.getObjectCache = getObjectCache;
 
- exports.getPendingOps = getPendingOps;
 
- exports.getServerData = getServerData;
 
- exports.getState = getState;
 
- exports.initializeState = initializeState;
 
- exports.mergeFirstPendingState = mergeFirstPendingState;
 
- exports.popPendingState = popPendingState;
 
- exports.pushPendingState = pushPendingState;
 
- exports.removeState = removeState;
 
- exports.setPendingOp = setPendingOp;
 
- exports.setServerData = setServerData;
 
- var ObjectStateMutations = _interopRequireWildcard(require("./ObjectStateMutations"));
 
- function _getRequireWildcardCache(nodeInterop) {
 
-   if (typeof _WeakMap !== "function") return null;
 
-   var cacheBabelInterop = new _WeakMap();
 
-   var cacheNodeInterop = new _WeakMap();
 
-   return (_getRequireWildcardCache = function (nodeInterop) {
 
-     return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
 
-   })(nodeInterop);
 
- }
 
- function _interopRequireWildcard(obj, nodeInterop) {
 
-   if (!nodeInterop && obj && obj.__esModule) {
 
-     return obj;
 
-   }
 
-   if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
 
-     return {
 
-       default: obj
 
-     };
 
-   }
 
-   var cache = _getRequireWildcardCache(nodeInterop);
 
-   if (cache && cache.has(obj)) {
 
-     return cache.get(obj);
 
-   }
 
-   var newObj = {};
 
-   for (var key in obj) {
 
-     if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
 
-       var desc = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null;
 
-       if (desc && (desc.get || desc.set)) {
 
-         _Object$defineProperty(newObj, key, desc);
 
-       } else {
 
-         newObj[key] = obj[key];
 
-       }
 
-     }
 
-   }
 
-   newObj.default = obj;
 
-   if (cache) {
 
-     cache.set(obj, newObj);
 
-   }
 
-   return newObj;
 
- }
 
- /**
 
-  * Copyright (c) 2015-present, Parse, LLC.
 
-  * All rights reserved.
 
-  *
 
-  * This source code is licensed under the BSD-style license found in the
 
-  * LICENSE file in the root directory of this source tree. An additional grant
 
-  * of patent rights can be found in the PATENTS file in the same directory.
 
-  *
 
-  * @flow
 
-  */
 
- var objectState
 
- /*: {
 
-   [className: string]: {
 
-     [id: string]: State,
 
-   },
 
- }*/
 
- = {};
 
- function getState(obj
 
- /*: ObjectIdentifier*/
 
- )
 
- /*: ?State*/
 
- {
 
-   var classData = objectState[obj.className];
 
-   if (classData) {
 
-     return classData[obj.id] || null;
 
-   }
 
-   return null;
 
- }
 
- function initializeState(obj
 
- /*: ObjectIdentifier*/
 
- , initial
 
- /*:: ?: State*/
 
- )
 
- /*: State*/
 
- {
 
-   var state = getState(obj);
 
-   if (state) {
 
-     return state;
 
-   }
 
-   if (!objectState[obj.className]) {
 
-     objectState[obj.className] = {};
 
-   }
 
-   if (!initial) {
 
-     initial = ObjectStateMutations.defaultState();
 
-   }
 
-   state = objectState[obj.className][obj.id] = initial;
 
-   return state;
 
- }
 
- function removeState(obj
 
- /*: ObjectIdentifier*/
 
- )
 
- /*: ?State*/
 
- {
 
-   var state = getState(obj);
 
-   if (state === null) {
 
-     return null;
 
-   }
 
-   delete objectState[obj.className][obj.id];
 
-   return state;
 
- }
 
- function getServerData(obj
 
- /*: ObjectIdentifier*/
 
- )
 
- /*: AttributeMap*/
 
- {
 
-   var state = getState(obj);
 
-   if (state) {
 
-     return state.serverData;
 
-   }
 
-   return {};
 
- }
 
- function setServerData(obj
 
- /*: ObjectIdentifier*/
 
- , attributes
 
- /*: AttributeMap*/
 
- ) {
 
-   var _initializeState = initializeState(obj),
 
-       serverData = _initializeState.serverData;
 
-   ObjectStateMutations.setServerData(serverData, attributes);
 
- }
 
- function getPendingOps(obj
 
- /*: ObjectIdentifier*/
 
- )
 
- /*: Array<OpsMap>*/
 
- {
 
-   var state = getState(obj);
 
-   if (state) {
 
-     return state.pendingOps;
 
-   }
 
-   return [{}];
 
- }
 
- function setPendingOp(obj
 
- /*: ObjectIdentifier*/
 
- , attr
 
- /*: string*/
 
- , op
 
- /*: ?Op*/
 
- ) {
 
-   var _initializeState2 = initializeState(obj),
 
-       pendingOps = _initializeState2.pendingOps;
 
-   ObjectStateMutations.setPendingOp(pendingOps, attr, op);
 
- }
 
- function pushPendingState(obj
 
- /*: ObjectIdentifier*/
 
- ) {
 
-   var _initializeState3 = initializeState(obj),
 
-       pendingOps = _initializeState3.pendingOps;
 
-   ObjectStateMutations.pushPendingState(pendingOps);
 
- }
 
- function popPendingState(obj
 
- /*: ObjectIdentifier*/
 
- )
 
- /*: OpsMap*/
 
- {
 
-   var _initializeState4 = initializeState(obj),
 
-       pendingOps = _initializeState4.pendingOps;
 
-   return ObjectStateMutations.popPendingState(pendingOps);
 
- }
 
- function mergeFirstPendingState(obj
 
- /*: ObjectIdentifier*/
 
- ) {
 
-   var pendingOps = getPendingOps(obj);
 
-   ObjectStateMutations.mergeFirstPendingState(pendingOps);
 
- }
 
- function getObjectCache(obj
 
- /*: ObjectIdentifier*/
 
- )
 
- /*: ObjectCache*/
 
- {
 
-   var state = getState(obj);
 
-   if (state) {
 
-     return state.objectCache;
 
-   }
 
-   return {};
 
- }
 
- function estimateAttribute(obj
 
- /*: ObjectIdentifier*/
 
- , attr
 
- /*: string*/
 
- )
 
- /*: mixed*/
 
- {
 
-   var serverData = getServerData(obj);
 
-   var pendingOps = getPendingOps(obj);
 
-   return ObjectStateMutations.estimateAttribute(serverData, pendingOps, obj.className, obj.id, attr);
 
- }
 
- function estimateAttributes(obj
 
- /*: ObjectIdentifier*/
 
- )
 
- /*: AttributeMap*/
 
- {
 
-   var serverData = getServerData(obj);
 
-   var pendingOps = getPendingOps(obj);
 
-   return ObjectStateMutations.estimateAttributes(serverData, pendingOps, obj.className, obj.id);
 
- }
 
- function commitServerChanges(obj
 
- /*: ObjectIdentifier*/
 
- , changes
 
- /*: AttributeMap*/
 
- ) {
 
-   var state = initializeState(obj);
 
-   ObjectStateMutations.commitServerChanges(state.serverData, state.objectCache, changes);
 
- }
 
- function enqueueTask(obj
 
- /*: ObjectIdentifier*/
 
- , task
 
- /*: () => Promise*/
 
- )
 
- /*: Promise*/
 
- {
 
-   var state = initializeState(obj);
 
-   return state.tasks.enqueue(task);
 
- }
 
- function clearAllState() {
 
-   objectState = {};
 
- }
 
- function duplicateState(source
 
- /*: { id: string }*/
 
- , dest
 
- /*: { id: string }*/
 
- ) {
 
-   dest.id = source.id;
 
- }
 
 
  |