a2c47351bfd1968f61db29c6d17229d5afa9086c316b3c34f59fbbdcf889fc72.json 14 KB

1
  1. {"ast":null,"code":"\"use strict\";\n\nvar _Object$defineProperty = require(\"@babel/runtime-corejs3/core-js-stable/object/define-property\");\nvar _interopRequireDefault = require(\"@babel/runtime-corejs3/helpers/interopRequireDefault\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\nvar _defineProperty2 = _interopRequireDefault(require(\"@babel/runtime-corejs3/helpers/defineProperty\"));\nvar _CoreManager = _interopRequireDefault(require(\"./CoreManager\"));\nvar _promiseUtils = require(\"./promiseUtils\");\n/**\n * Creates a new LiveQuery Subscription.\n * <a href=\"https://nodejs.org/api/events.html#events_class_eventemitter\">cloud functions</a>.\n *\n * <p>Response Object - Contains data from the client that made the request\n * <ul>\n * <li>clientId</li>\n * <li>installationId - requires Parse Server 4.0.0+</li>\n * </ul>\n * </p>\n *\n * <p>Open Event - When you call query.subscribe(), we send a subscribe request to\n * the LiveQuery server, when we get the confirmation from the LiveQuery server,\n * this event will be emitted. When the client loses WebSocket connection to the\n * LiveQuery server, we will try to auto reconnect the LiveQuery server. If we\n * reconnect the LiveQuery server and successfully resubscribe the ParseQuery,\n * you'll also get this event.\n *\n * <pre>\n * subscription.on('open', (response) => {\n *\n * });</pre></p>\n *\n * <p>Create Event - When a new ParseObject is created and it fulfills the ParseQuery you subscribe,\n * you'll get this event. The object is the ParseObject which is created.\n *\n * <pre>\n * subscription.on('create', (object, response) => {\n *\n * });</pre></p>\n *\n * <p>Update Event - When an existing ParseObject (original) which fulfills the ParseQuery you subscribe\n * is updated (The ParseObject fulfills the ParseQuery before and after changes),\n * you'll get this event. The object is the ParseObject which is updated.\n * Its content is the latest value of the ParseObject.\n *\n * Parse-Server 3.1.3+ Required for original object parameter\n *\n * <pre>\n * subscription.on('update', (object, original, response) => {\n *\n * });</pre></p>\n *\n * <p>Enter Event - When an existing ParseObject's (original) old value doesn't fulfill the ParseQuery\n * but its new value fulfills the ParseQuery, you'll get this event. The object is the\n * ParseObject which enters the ParseQuery. Its content is the latest value of the ParseObject.\n *\n * Parse-Server 3.1.3+ Required for original object parameter\n *\n * <pre>\n * subscription.on('enter', (object, original, response) => {\n *\n * });</pre></p>\n *\n *\n * <p>Update Event - When an existing ParseObject's old value fulfills the ParseQuery but its new value\n * doesn't fulfill the ParseQuery, you'll get this event. The object is the ParseObject\n * which leaves the ParseQuery. Its content is the latest value of the ParseObject.\n *\n * <pre>\n * subscription.on('leave', (object, response) => {\n *\n * });</pre></p>\n *\n *\n * <p>Delete Event - When an existing ParseObject which fulfills the ParseQuery is deleted, you'll\n * get this event. The object is the ParseObject which is deleted.\n *\n * <pre>\n * subscription.on('delete', (object, response) => {\n *\n * });</pre></p>\n *\n *\n * <p>Close Event - When the client loses the WebSocket connection to the LiveQuery\n * server and we stop receiving events, you'll get this event.\n *\n * <pre>\n * subscription.on('close', () => {\n *\n * });</pre></p>\n */\nclass Subscription {\n /*\n * @param {string | number} id - subscription id\n * @param {string} query - query to subscribe to\n * @param {string} sessionToken - optional session token\n */\n constructor(id, query, sessionToken) {\n var _this = this;\n (0, _defineProperty2.default)(this, \"id\", void 0);\n (0, _defineProperty2.default)(this, \"query\", void 0);\n (0, _defineProperty2.default)(this, \"sessionToken\", void 0);\n (0, _defineProperty2.default)(this, \"subscribePromise\", void 0);\n (0, _defineProperty2.default)(this, \"unsubscribePromise\", void 0);\n (0, _defineProperty2.default)(this, \"subscribed\", void 0);\n (0, _defineProperty2.default)(this, \"emitter\", void 0);\n (0, _defineProperty2.default)(this, \"on\", void 0);\n (0, _defineProperty2.default)(this, \"emit\", void 0);\n this.id = id;\n this.query = query;\n this.sessionToken = sessionToken;\n this.subscribePromise = (0, _promiseUtils.resolvingPromise)();\n this.unsubscribePromise = (0, _promiseUtils.resolvingPromise)();\n this.subscribed = false;\n const EventEmitter = _CoreManager.default.getEventEmitter();\n this.emitter = new EventEmitter();\n this.on = (eventName, listener) => this.emitter.on(eventName, listener);\n this.emit = function (eventName) {\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n return _this.emitter.emit(eventName, ...args);\n };\n // adding listener so process does not crash\n // best practice is for developer to register their own listener\n this.on('error', () => {});\n }\n\n /**\n * Close the subscription\n *\n * @returns {Promise}\n */\n unsubscribe() {\n return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient().then(liveQueryClient => {\n this.emit('close');\n return liveQueryClient.unsubscribe(this);\n });\n }\n}\nvar _default = exports.default = Subscription;","map":{"version":3,"names":["_Object$defineProperty","require","_interopRequireDefault","exports","value","default","_defineProperty2","_CoreManager","_promiseUtils","Subscription","constructor","id","query","sessionToken","_this","subscribePromise","resolvingPromise","unsubscribePromise","subscribed","EventEmitter","getEventEmitter","emitter","on","eventName","listener","emit","_len","arguments","length","args","Array","_key","unsubscribe","getLiveQueryController","getDefaultLiveQueryClient","then","liveQueryClient","_default"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/parse/lib/browser/LiveQuerySubscription.js"],"sourcesContent":["\"use strict\";\n\nvar _Object$defineProperty = require(\"@babel/runtime-corejs3/core-js-stable/object/define-property\");\nvar _interopRequireDefault = require(\"@babel/runtime-corejs3/helpers/interopRequireDefault\");\n_Object$defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\nvar _defineProperty2 = _interopRequireDefault(require(\"@babel/runtime-corejs3/helpers/defineProperty\"));\nvar _CoreManager = _interopRequireDefault(require(\"./CoreManager\"));\nvar _promiseUtils = require(\"./promiseUtils\");\n/**\n * Creates a new LiveQuery Subscription.\n * <a href=\"https://nodejs.org/api/events.html#events_class_eventemitter\">cloud functions</a>.\n *\n * <p>Response Object - Contains data from the client that made the request\n * <ul>\n * <li>clientId</li>\n * <li>installationId - requires Parse Server 4.0.0+</li>\n * </ul>\n * </p>\n *\n * <p>Open Event - When you call query.subscribe(), we send a subscribe request to\n * the LiveQuery server, when we get the confirmation from the LiveQuery server,\n * this event will be emitted. When the client loses WebSocket connection to the\n * LiveQuery server, we will try to auto reconnect the LiveQuery server. If we\n * reconnect the LiveQuery server and successfully resubscribe the ParseQuery,\n * you'll also get this event.\n *\n * <pre>\n * subscription.on('open', (response) => {\n *\n * });</pre></p>\n *\n * <p>Create Event - When a new ParseObject is created and it fulfills the ParseQuery you subscribe,\n * you'll get this event. The object is the ParseObject which is created.\n *\n * <pre>\n * subscription.on('create', (object, response) => {\n *\n * });</pre></p>\n *\n * <p>Update Event - When an existing ParseObject (original) which fulfills the ParseQuery you subscribe\n * is updated (The ParseObject fulfills the ParseQuery before and after changes),\n * you'll get this event. The object is the ParseObject which is updated.\n * Its content is the latest value of the ParseObject.\n *\n * Parse-Server 3.1.3+ Required for original object parameter\n *\n * <pre>\n * subscription.on('update', (object, original, response) => {\n *\n * });</pre></p>\n *\n * <p>Enter Event - When an existing ParseObject's (original) old value doesn't fulfill the ParseQuery\n * but its new value fulfills the ParseQuery, you'll get this event. The object is the\n * ParseObject which enters the ParseQuery. Its content is the latest value of the ParseObject.\n *\n * Parse-Server 3.1.3+ Required for original object parameter\n *\n * <pre>\n * subscription.on('enter', (object, original, response) => {\n *\n * });</pre></p>\n *\n *\n * <p>Update Event - When an existing ParseObject's old value fulfills the ParseQuery but its new value\n * doesn't fulfill the ParseQuery, you'll get this event. The object is the ParseObject\n * which leaves the ParseQuery. Its content is the latest value of the ParseObject.\n *\n * <pre>\n * subscription.on('leave', (object, response) => {\n *\n * });</pre></p>\n *\n *\n * <p>Delete Event - When an existing ParseObject which fulfills the ParseQuery is deleted, you'll\n * get this event. The object is the ParseObject which is deleted.\n *\n * <pre>\n * subscription.on('delete', (object, response) => {\n *\n * });</pre></p>\n *\n *\n * <p>Close Event - When the client loses the WebSocket connection to the LiveQuery\n * server and we stop receiving events, you'll get this event.\n *\n * <pre>\n * subscription.on('close', () => {\n *\n * });</pre></p>\n */\nclass Subscription {\n /*\n * @param {string | number} id - subscription id\n * @param {string} query - query to subscribe to\n * @param {string} sessionToken - optional session token\n */\n constructor(id, query, sessionToken) {\n var _this = this;\n (0, _defineProperty2.default)(this, \"id\", void 0);\n (0, _defineProperty2.default)(this, \"query\", void 0);\n (0, _defineProperty2.default)(this, \"sessionToken\", void 0);\n (0, _defineProperty2.default)(this, \"subscribePromise\", void 0);\n (0, _defineProperty2.default)(this, \"unsubscribePromise\", void 0);\n (0, _defineProperty2.default)(this, \"subscribed\", void 0);\n (0, _defineProperty2.default)(this, \"emitter\", void 0);\n (0, _defineProperty2.default)(this, \"on\", void 0);\n (0, _defineProperty2.default)(this, \"emit\", void 0);\n this.id = id;\n this.query = query;\n this.sessionToken = sessionToken;\n this.subscribePromise = (0, _promiseUtils.resolvingPromise)();\n this.unsubscribePromise = (0, _promiseUtils.resolvingPromise)();\n this.subscribed = false;\n const EventEmitter = _CoreManager.default.getEventEmitter();\n this.emitter = new EventEmitter();\n this.on = (eventName, listener) => this.emitter.on(eventName, listener);\n this.emit = function (eventName) {\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n return _this.emitter.emit(eventName, ...args);\n };\n // adding listener so process does not crash\n // best practice is for developer to register their own listener\n this.on('error', () => {});\n }\n\n /**\n * Close the subscription\n *\n * @returns {Promise}\n */\n unsubscribe() {\n return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient().then(liveQueryClient => {\n this.emit('close');\n return liveQueryClient.unsubscribe(this);\n });\n }\n}\nvar _default = exports.default = Subscription;"],"mappings":"AAAA,YAAY;;AAEZ,IAAIA,sBAAsB,GAAGC,OAAO,CAAC,8DAA8D,CAAC;AACpG,IAAIC,sBAAsB,GAAGD,OAAO,CAAC,sDAAsD,CAAC;AAC5FD,sBAAsB,CAACG,OAAO,EAAE,YAAY,EAAE;EAC5CC,KAAK,EAAE;AACT,CAAC,CAAC;AACFD,OAAO,CAACE,OAAO,GAAG,KAAK,CAAC;AAC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