1 |
- {"ast":null,"code":"'use strict';\n\nvar _asyncToGenerator = require(\"F:/workspace/202226701027/huinongbao-app/node_modules/@babel/runtime/helpers/asyncToGenerator.js\").default;\nconst retry = require('retry');\nconst networkErrorMsgs = ['Failed to fetch',\n// Chrome\n'NetworkError when attempting to fetch resource.',\n// Firefox\n'The Internet connection appears to be offline.',\n// Safari\n'Network request failed' // `cross-fetch`\n];\nclass AbortError extends Error {\n constructor(message) {\n super();\n if (message instanceof Error) {\n this.originalError = message;\n ({\n message\n } = message);\n } else {\n this.originalError = new Error(message);\n this.originalError.stack = this.stack;\n }\n this.name = 'AbortError';\n this.message = message;\n }\n}\nconst decorateErrorWithCounts = (error, attemptNumber, options) => {\n // Minus 1 from attemptNumber because the first attempt does not count as a retry\n const retriesLeft = options.retries - (attemptNumber - 1);\n error.attemptNumber = attemptNumber;\n error.retriesLeft = retriesLeft;\n return error;\n};\nconst isNetworkError = errorMessage => networkErrorMsgs.includes(errorMessage);\nconst pRetry = (input, options) => new Promise((resolve, reject) => {\n options = {\n onFailedAttempt: () => {},\n retries: 10,\n ...options\n };\n const operation = retry.operation(options);\n operation.attempt( /*#__PURE__*/function () {\n var _ref = _asyncToGenerator(function* (attemptNumber) {\n try {\n resolve(yield input(attemptNumber));\n } catch (error) {\n if (!(error instanceof Error)) {\n reject(new TypeError(`Non-error was thrown: \"${error}\". You should only throw errors.`));\n return;\n }\n if (error instanceof AbortError) {\n operation.stop();\n reject(error.originalError);\n } else if (error instanceof TypeError && !isNetworkError(error.message)) {\n operation.stop();\n reject(error);\n } else {\n decorateErrorWithCounts(error, attemptNumber, options);\n try {\n yield options.onFailedAttempt(error);\n } catch (error) {\n reject(error);\n return;\n }\n if (!operation.retry(error)) {\n reject(operation.mainError());\n }\n }\n }\n });\n return function (_x) {\n return _ref.apply(this, arguments);\n };\n }());\n});\nmodule.exports = pRetry;\n// TODO: remove this in the next major version\nmodule.exports.default = pRetry;\nmodule.exports.AbortError = AbortError;","map":{"version":3,"names":["_asyncToGenerator","require","default","retry","networkErrorMsgs","AbortError","Error","constructor","message","originalError","stack","name","decorateErrorWithCounts","error","attemptNumber","options","retriesLeft","retries","isNetworkError","errorMessage","includes","pRetry","input","Promise","resolve","reject","onFailedAttempt","operation","attempt","_ref","TypeError","stop","mainError","_x","apply","arguments","module","exports"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@langchain/core/node_modules/p-retry/index.js"],"sourcesContent":["'use strict';\nconst retry = require('retry');\n\nconst networkErrorMsgs = [\n\t'Failed to fetch', // Chrome\n\t'NetworkError when attempting to fetch resource.', // Firefox\n\t'The Internet connection appears to be offline.', // Safari\n\t'Network request failed' // `cross-fetch`\n];\n\nclass AbortError extends Error {\n\tconstructor(message) {\n\t\tsuper();\n\n\t\tif (message instanceof Error) {\n\t\t\tthis.originalError = message;\n\t\t\t({message} = message);\n\t\t} else {\n\t\t\tthis.originalError = new Error(message);\n\t\t\tthis.originalError.stack = this.stack;\n\t\t}\n\n\t\tthis.name = 'AbortError';\n\t\tthis.message = message;\n\t}\n}\n\nconst decorateErrorWithCounts = (error, attemptNumber, options) => {\n\t// Minus 1 from attemptNumber because the first attempt does not count as a retry\n\tconst retriesLeft = options.retries - (attemptNumber - 1);\n\n\terror.attemptNumber = attemptNumber;\n\terror.retriesLeft = retriesLeft;\n\treturn error;\n};\n\nconst isNetworkError = errorMessage => networkErrorMsgs.includes(errorMessage);\n\nconst pRetry = (input, options) => new Promise((resolve, reject) => {\n\toptions = {\n\t\tonFailedAttempt: () => {},\n\t\tretries: 10,\n\t\t...options\n\t};\n\n\tconst operation = retry.operation(options);\n\n\toperation.attempt(async attemptNumber => {\n\t\ttry {\n\t\t\tresolve(await input(attemptNumber));\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof Error)) {\n\t\t\t\treject(new TypeError(`Non-error was thrown: \"${error}\". You should only throw errors.`));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (error instanceof AbortError) {\n\t\t\t\toperation.stop();\n\t\t\t\treject(error.originalError);\n\t\t\t} else if (error instanceof TypeError && !isNetworkError(error.message)) {\n\t\t\t\toperation.stop();\n\t\t\t\treject(error);\n\t\t\t} else {\n\t\t\t\tdecorateErrorWithCounts(error, attemptNumber, options);\n\n\t\t\t\ttry {\n\t\t\t\t\tawait options.onFailedAttempt(error);\n\t\t\t\t} catch (error) {\n\t\t\t\t\treject(error);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (!operation.retry(error)) {\n\t\t\t\t\treject(operation.mainError());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n});\n\nmodule.exports = pRetry;\n// TODO: remove this in the next major version\nmodule.exports.default = pRetry;\n\nmodule.exports.AbortError = AbortError;\n"],"mappings":"AAAA,YAAY;;AAAC,IAAAA,iBAAA,GAAAC,OAAA,qGAAAC,OAAA;AACb,MAAMC,KAAK,GAAGF,OAAO,CAAC,OAAO,CAAC;AAE9B,MAAMG,gBAAgB,GAAG,CACxB,iBAAiB;AAAE;AACnB,iDAAiD;AAAE;AACnD,gDAAgD;AAAE;AAClD,wBAAwB,CAAC;AAAA,CACzB;AAED,MAAMC,UAAU,SAASC,KAAK,CAAC;EAC9BC,WAAWA,CAACC,OAAO,EAAE;IACpB,KAAK,CAAC,CAAC;IAEP,IAAIA,OAAO,YAAYF,KAAK,EAAE;MAC7B,IAAI,CAACG,aAAa,GAAGD,OAAO;MAC5B,CAAC;QAACA;MAAO,CAAC,GAAGA,OAAO;IACrB,CAAC,MAAM;MACN,IAAI,CAACC,aAAa,GAAG,IAAIH,KAAK,CAACE,OAAO,CAAC;MACvC,IAAI,CAACC,aAAa,CAACC,KAAK,GAAG,IAAI,CAACA,KAAK;IACtC;IAEA,IAAI,CAACC,IAAI,GAAG,YAAY;IACxB,IAAI,CAACH,OAAO,GAAGA,OAAO;EACvB;AACD;AAEA,MAAMI,uBAAuB,GAAGA,CAACC,KAAK,EAAEC,aAAa,EAAEC,OAAO,KAAK;EAClE;EACA,MAAMC,WAAW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