1 |
- {"ast":null,"code":"import _asyncToGenerator from \"F:/workspace/202226701027/huinongbao-app/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport PQueueMod from \"p-queue\";\nimport { getGlobalAsyncLocalStorageInstance } from \"./async_local_storage/globals.js\";\nlet queue;\n/**\n * Creates a queue using the p-queue library. The queue is configured to\n * auto-start and has a concurrency of 1, meaning it will process tasks\n * one at a time.\n */\nfunction createQueue() {\n const PQueue = \"default\" in PQueueMod ? PQueueMod.default : PQueueMod;\n return new PQueue({\n autoStart: true,\n concurrency: 1\n });\n}\nexport function getQueue() {\n if (typeof queue === \"undefined\") {\n queue = createQueue();\n }\n return queue;\n}\n/**\n * Consume a promise, either adding it to the queue or waiting for it to resolve\n * @param promiseFn Promise to consume\n * @param wait Whether to wait for the promise to resolve or resolve immediately\n */\nexport function consumeCallback(_x, _x2) {\n return _consumeCallback.apply(this, arguments);\n}\n/**\n * Waits for all promises in the queue to resolve. If the queue is\n * undefined, it immediately resolves a promise.\n */\nfunction _consumeCallback() {\n _consumeCallback = _asyncToGenerator(function* (promiseFn, wait) {\n if (wait === true) {\n // Clear config since callbacks are not part of the root run\n // Avoid using global singleton due to circuluar dependency issues\n if (getGlobalAsyncLocalStorageInstance() !== undefined) {\n yield getGlobalAsyncLocalStorageInstance().run(undefined, /*#__PURE__*/_asyncToGenerator(function* () {\n return promiseFn();\n }));\n } else {\n yield promiseFn();\n }\n } else {\n queue = getQueue();\n void queue.add( /*#__PURE__*/_asyncToGenerator(function* () {\n if (getGlobalAsyncLocalStorageInstance() !== undefined) {\n yield getGlobalAsyncLocalStorageInstance().run(undefined, /*#__PURE__*/_asyncToGenerator(function* () {\n return promiseFn();\n }));\n } else {\n yield promiseFn();\n }\n }));\n }\n });\n return _consumeCallback.apply(this, arguments);\n}\nexport function awaitAllCallbacks() {\n return typeof queue !== \"undefined\" ? queue.onIdle() : Promise.resolve();\n}","map":{"version":3,"names":["PQueueMod","getGlobalAsyncLocalStorageInstance","queue","createQueue","PQueue","default","autoStart","concurrency","getQueue","consumeCallback","_x","_x2","_consumeCallback","apply","arguments","_asyncToGenerator","promiseFn","wait","undefined","run","add","awaitAllCallbacks","onIdle","Promise","resolve"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@langchain/core/dist/singletons/callbacks.js"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport PQueueMod from \"p-queue\";\nimport { getGlobalAsyncLocalStorageInstance } from \"./async_local_storage/globals.js\";\nlet queue;\n/**\n * Creates a queue using the p-queue library. The queue is configured to\n * auto-start and has a concurrency of 1, meaning it will process tasks\n * one at a time.\n */\nfunction createQueue() {\n const PQueue = \"default\" in PQueueMod ? PQueueMod.default : PQueueMod;\n return new PQueue({\n autoStart: true,\n concurrency: 1,\n });\n}\nexport function getQueue() {\n if (typeof queue === \"undefined\") {\n queue = createQueue();\n }\n return queue;\n}\n/**\n * Consume a promise, either adding it to the queue or waiting for it to resolve\n * @param promiseFn Promise to consume\n * @param wait Whether to wait for the promise to resolve or resolve immediately\n */\nexport async function consumeCallback(promiseFn, wait) {\n if (wait === true) {\n // Clear config since callbacks are not part of the root run\n // Avoid using global singleton due to circuluar dependency issues\n if (getGlobalAsyncLocalStorageInstance() !== undefined) {\n await getGlobalAsyncLocalStorageInstance().run(undefined, async () => promiseFn());\n }\n else {\n await promiseFn();\n }\n }\n else {\n queue = getQueue();\n void queue.add(async () => {\n if (getGlobalAsyncLocalStorageInstance() !== undefined) {\n await getGlobalAsyncLocalStorageInstance().run(undefined, async () => promiseFn());\n }\n else {\n await promiseFn();\n }\n });\n }\n}\n/**\n * Waits for all promises in the queue to resolve. If the queue is\n * undefined, it immediately resolves a promise.\n */\nexport function awaitAllCallbacks() {\n return typeof queue !== \"undefined\" ? queue.onIdle() : Promise.resolve();\n}\n"],"mappings":";AAAA;AACA,OAAOA,SAAS,MAAM,SAAS;AAC/B,SAASC,kCAAkC,QAAQ,kCAA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