1 |
- {"ast":null,"code":"\"use strict\";\n\nvar _asyncToGenerator = require(\"F:/workspace/202226701027/huinongbao-app/node_modules/@babel/runtime/helpers/asyncToGenerator.js\").default;\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 _promise = _interopRequireDefault(require(\"@babel/runtime-corejs3/core-js-stable/promise\"));\nvar _indexOf = _interopRequireDefault(require(\"@babel/runtime-corejs3/core-js-stable/instance/index-of\"));\nvar _defineProperty2 = _interopRequireDefault(require(\"@babel/runtime-corejs3/helpers/defineProperty\"));\nvar _LiveQueryClient = _interopRequireDefault(require(\"./LiveQueryClient\"));\nvar _CoreManager = _interopRequireDefault(require(\"./CoreManager\"));\nfunction getLiveQueryClient() {\n return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();\n}\n\n/**\n * We expose three events to help you monitor the status of the WebSocket connection:\n *\n * <p>Open - When we establish the WebSocket connection to the LiveQuery server, you'll get this event.\n *\n * <pre>\n * Parse.LiveQuery.on('open', () => {\n *\n * });</pre></p>\n *\n * <p>Close - When we lose the WebSocket connection to the LiveQuery server, you'll get this event.\n *\n * <pre>\n * Parse.LiveQuery.on('close', () => {\n *\n * });</pre></p>\n *\n * <p>Error - When some network error or LiveQuery server error happens, you'll get this event.\n *\n * <pre>\n * Parse.LiveQuery.on('error', (error) => {\n *\n * });</pre></p>\n *\n * @class Parse.LiveQuery\n * @static\n */\nclass LiveQuery {\n constructor() {\n var _this = this;\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 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 * After open is called, the LiveQuery will try to send a connect request\n * to the LiveQuery server.\n */\n open() {\n return _asyncToGenerator(function* () {\n const liveQueryClient = yield getLiveQueryClient();\n liveQueryClient.open();\n })();\n }\n\n /**\n * When you're done using LiveQuery, you can call Parse.LiveQuery.close().\n * This function will close the WebSocket connection to the LiveQuery server,\n * cancel the auto reconnect, and unsubscribe all subscriptions based on it.\n * If you call query.subscribe() after this, we'll create a new WebSocket\n * connection to the LiveQuery server.\n */\n close() {\n return _asyncToGenerator(function* () {\n const liveQueryClient = yield getLiveQueryClient();\n liveQueryClient.close();\n })();\n }\n}\nvar _default = exports.default = LiveQuery;\nlet defaultLiveQueryClient;\nconst DefaultLiveQueryController = {\n setDefaultLiveQueryClient(liveQueryClient) {\n defaultLiveQueryClient = liveQueryClient;\n },\n getDefaultLiveQueryClient() {\n return _asyncToGenerator(function* () {\n if (defaultLiveQueryClient) {\n return defaultLiveQueryClient;\n }\n const [currentUser, installationId] = yield _promise.default.all([_CoreManager.default.getUserController().currentUserAsync(), _CoreManager.default.getInstallationController().currentInstallationId()]);\n const sessionToken = currentUser ? currentUser.getSessionToken() : undefined;\n let liveQueryServerURL = _CoreManager.default.get('LIVEQUERY_SERVER_URL');\n if (liveQueryServerURL && (0, _indexOf.default)(liveQueryServerURL).call(liveQueryServerURL, 'ws') !== 0) {\n throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');\n }\n\n // If we can not find Parse.liveQueryServerURL, we try to extract it from Parse.serverURL\n if (!liveQueryServerURL) {\n const serverURL = _CoreManager.default.get('SERVER_URL');\n const protocol = (0, _indexOf.default)(serverURL).call(serverURL, 'https') === 0 ? 'wss://' : 'ws://';\n const host = serverURL.replace(/^https?:\\/\\//, '');\n liveQueryServerURL = protocol + host;\n _CoreManager.default.set('LIVEQUERY_SERVER_URL', liveQueryServerURL);\n }\n const applicationId = _CoreManager.default.get('APPLICATION_ID');\n const javascriptKey = _CoreManager.default.get('JAVASCRIPT_KEY');\n const masterKey = _CoreManager.default.get('MASTER_KEY');\n defaultLiveQueryClient = new _LiveQueryClient.default({\n applicationId,\n serverURL: liveQueryServerURL,\n javascriptKey,\n masterKey,\n sessionToken,\n installationId\n });\n const LiveQuery = _CoreManager.default.getLiveQuery();\n defaultLiveQueryClient.on('error', error => {\n LiveQuery.emit('error', error);\n });\n defaultLiveQueryClient.on('open', () => {\n LiveQuery.emit('open');\n });\n defaultLiveQueryClient.on('close', () => {\n LiveQuery.emit('close');\n });\n return defaultLiveQueryClient;\n })();\n },\n _clearCachedDefaultClient() {\n defaultLiveQueryClient = null;\n }\n};\n_CoreManager.default.setLiveQueryController(DefaultLiveQueryController);","map":{"version":3,"names":["_asyncToGenerator","require","default","_Object$defineProperty","_interopRequireDefault","exports","value","_promise","_indexOf","_defineProperty2","_LiveQueryClient","_CoreManager","getLiveQueryClient","getLiveQueryController","getDefaultLiveQueryClient","LiveQuery","constructor","_this","EventEmitter","getEventEmitter","emitter","on","eventName","listener","emit","_len","arguments","length","args","Array","_key","open","liveQueryClient","close","_default","defaultLiveQueryClient","DefaultLiveQueryController","setDefaultLiveQueryClient","currentUser","installationId","all","getUserController","currentUserAsync","getInstallationController","currentInstallationId","sessionToken","getSessionToken","undefined","liveQueryServerURL","get","call","Error","serverURL","protocol","host","replace","set","applicationId","javascriptKey","masterKey","getLiveQuery","error","_clearCachedDefaultClient","setLiveQueryController"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/parse/lib/browser/ParseLiveQuery.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 _promise = _interopRequireDefault(require(\"@babel/runtime-corejs3/core-js-stable/promise\"));\nvar _indexOf = _interopRequireDefault(require(\"@babel/runtime-corejs3/core-js-stable/instance/index-of\"));\nvar _defineProperty2 = _interopRequireDefault(require(\"@babel/runtime-corejs3/helpers/defineProperty\"));\nvar _LiveQueryClient = _interopRequireDefault(require(\"./LiveQueryClient\"));\nvar _CoreManager = _interopRequireDefault(require(\"./CoreManager\"));\nfunction getLiveQueryClient() {\n return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();\n}\n\n/**\n * We expose three events to help you monitor the status of the WebSocket connection:\n *\n * <p>Open - When we establish the WebSocket connection to the LiveQuery server, you'll get this event.\n *\n * <pre>\n * Parse.LiveQuery.on('open', () => {\n *\n * });</pre></p>\n *\n * <p>Close - When we lose the WebSocket connection to the LiveQuery server, you'll get this event.\n *\n * <pre>\n * Parse.LiveQuery.on('close', () => {\n *\n * });</pre></p>\n *\n * <p>Error - When some network error or LiveQuery server error happens, you'll get this event.\n *\n * <pre>\n * Parse.LiveQuery.on('error', (error) => {\n *\n * });</pre></p>\n *\n * @class Parse.LiveQuery\n * @static\n */\nclass LiveQuery {\n constructor() {\n var _this = this;\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 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 * After open is called, the LiveQuery will try to send a connect request\n * to the LiveQuery server.\n */\n async open() {\n const liveQueryClient = await getLiveQueryClient();\n liveQueryClient.open();\n }\n\n /**\n * When you're done using LiveQuery, you can call Parse.LiveQuery.close().\n * This function will close the WebSocket connection to the LiveQuery server,\n * cancel the auto reconnect, and unsubscribe all subscriptions based on it.\n * If you call query.subscribe() after this, we'll create a new WebSocket\n * connection to the LiveQuery server.\n */\n async close() {\n const liveQueryClient = await getLiveQueryClient();\n liveQueryClient.close();\n }\n}\nvar _default = exports.default = LiveQuery;\nlet defaultLiveQueryClient;\nconst DefaultLiveQueryController = {\n setDefaultLiveQueryClient(liveQueryClient) {\n defaultLiveQueryClient = liveQueryClient;\n },\n async getDefaultLiveQueryClient() {\n if (defaultLiveQueryClient) {\n return defaultLiveQueryClient;\n }\n const [currentUser, installationId] = await _promise.default.all([_CoreManager.default.getUserController().currentUserAsync(), _CoreManager.default.getInstallationController().currentInstallationId()]);\n const sessionToken = currentUser ? currentUser.getSessionToken() : undefined;\n let liveQueryServerURL = _CoreManager.default.get('LIVEQUERY_SERVER_URL');\n if (liveQueryServerURL && (0, _indexOf.default)(liveQueryServerURL).call(liveQueryServerURL, 'ws') !== 0) {\n throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');\n }\n\n // If we can not find Parse.liveQueryServerURL, we try to extract it from Parse.serverURL\n if (!liveQueryServerURL) {\n const serverURL = _CoreManager.default.get('SERVER_URL');\n const protocol = (0, _indexOf.default)(serverURL).call(serverURL, 'https') === 0 ? 'wss://' : 'ws://';\n const host = serverURL.replace(/^https?:\\/\\//, '');\n liveQueryServerURL = protocol + host;\n _CoreManager.default.set('LIVEQUERY_SERVER_URL', liveQueryServerURL);\n }\n const applicationId = _CoreManager.default.get('APPLICATION_ID');\n const javascriptKey = _CoreManager.default.get('JAVASCRIPT_KEY');\n const masterKey = _CoreManager.default.get('MASTER_KEY');\n defaultLiveQueryClient = new _LiveQueryClient.default({\n applicationId,\n serverURL: liveQueryServerURL,\n javascriptKey,\n masterKey,\n sessionToken,\n installationId\n });\n const LiveQuery = _CoreManager.default.getLiveQuery();\n defaultLiveQueryClient.on('error', error => {\n LiveQuery.emit('error', error);\n });\n defaultLiveQueryClient.on('open', () => {\n LiveQuery.emit('open');\n });\n defaultLiveQueryClient.on('close', () => {\n LiveQuery.emit('close');\n });\n return defaultLiveQueryClient;\n },\n _clearCachedDefaultClient() {\n defaultLiveQueryClient = null;\n }\n};\n_CoreManager.default.setLiveQueryController(DefaultLiveQueryController);"],"mappings":"AAAA,YAAY;;AAAC,IAAAA,iBAAA,GAAAC,OAAA,qGAAAC,OAAA;AAEb,IAAIC,sBAAsB,GAAGF,OAAO,CAAC,8DAA8D,CAAC;AACpG,IAAIG,sBAAsB,GAAGH,OAAO,CAAC,sDAAsD,CAAC;AAC5FE,sBAAsB,CAACE,OAAO,EAAE,YAAY,EAAE;EAC5CC,KAAK,EAAE;AACT,CAAC,CAAC;AACFD,OAAO,CAACH,OAAO,GAAG,KAAK,CAAC;AACxB,IAAIK,QAAQ,GAAGH,sBAAsB,CAACH,OAAO,CAAC,+CAA+C,CAAC,CAAC;AAC/F,IAAIO,QAAQ,GAAGJ,sBAAsB,CAACH,OAAO,CAAC,yDAAyD,CAAC,CAAC;AACzG,IAAIQ,gBAAgB,GAAGL,sBAAsB,CAACH,OAAO,CAAC,+CAA+C,CAAC,CAAC;AACvG,IAAIS,gBAAgB,GAAGN,sBAAsB,CAACH,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC3E,IAAIU,YAAY,GAAGP,sBAAsB,CAACH,OAAO,CAAC,eAAe,CAAC,CAAC;AACnE,SAASW,kBAAkBA,CAAA,EAAG;EAC5B,OAAOD,YAAY,CAACT,OAAO,CAACW,sBAAsB,CAAC,CAAC,CAACC,yBAAyB,CAAC,CAAC;AAClF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,SAAS,CAAC;EACdC,WAAWA,C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