@oj-module/cli 0.2.63 → 0.2.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/devkit/README.md +9 -3
  2. package/devkit/SKILL.md +5 -2
  3. package/devkit/framework-dev.md +12 -7
  4. package/devkit/manual.md +123 -56
  5. package/devkit/menu-rules.md +4 -1
  6. package/package.json +3 -2
  7. package/shell-dist/assets/ahooks.2l850ymmh0.js +18 -0
  8. package/shell-dist/assets/antd-es-locale-zh_CN.1gjjsvxbf0.js +1 -0
  9. package/shell-dist/assets/antd-img-crop.196rkty480.js +99 -0
  10. package/shell-dist/assets/antd-locale-en_US.561tozx860.js +1 -0
  11. package/shell-dist/assets/antd-locale-zh_CN.1cmpmgzh70.js +1 -0
  12. package/shell-dist/assets/antd.uw1coq15l0.js +348 -0
  13. package/shell-dist/assets/clsx.jotilrt2e0.js +1 -0
  14. package/shell-dist/assets/contract-errors.2o17vz9u50.js +1 -0
  15. package/shell-dist/assets/contract.3h327o3mj0.js +57 -0
  16. package/shell-dist/assets/cssinjs.atgmhan7m0.js +3 -0
  17. package/shell-dist/assets/dayjs-plugin-advancedFormat.3vsyd2eis0.js +1 -0
  18. package/shell-dist/assets/dayjs-plugin-customParseFormat.13xhghv1d0.js +1 -0
  19. package/shell-dist/assets/dayjs-plugin-isoWeek.1fn1tw82p0.js +1 -0
  20. package/shell-dist/assets/dayjs-plugin-localeData.2rwbjp9nk0.js +1 -0
  21. package/shell-dist/assets/dayjs-plugin-quarterOfYear.2oqo1lcx80.js +1 -0
  22. package/shell-dist/assets/dayjs-plugin-relativeTime.2pqs3et4y0.js +1 -0
  23. package/shell-dist/assets/dayjs-plugin-weekOfYear.gvn9iph080.js +1 -0
  24. package/shell-dist/assets/dayjs-plugin-weekYear.2u78l3ex10.js +1 -0
  25. package/shell-dist/assets/dayjs-plugin-weekday.2d56a4tml0.js +1 -0
  26. package/shell-dist/assets/dayjs.pa60l6wjo0.js +1 -0
  27. package/shell-dist/assets/dnd-kit-core.1xyreig6r0.js +5 -0
  28. package/shell-dist/assets/dnd-kit-sortable.s94qciuft0.js +1 -0
  29. package/shell-dist/assets/dnd-kit-utilities.1umw4xphb0.js +1 -0
  30. package/shell-dist/assets/i18next.33zqofapj0.js +1 -0
  31. package/shell-dist/assets/icons-es-components-Context.365qmflwg0.js +1 -0
  32. package/shell-dist/assets/icons.159wjwals0.js +57 -0
  33. package/shell-dist/assets/{index-BKtXxIXz.js → index.i0kqbxp050.js} +11 -6
  34. package/shell-dist/assets/jsx-dev-runtime.3uibuc82f0.js +14 -0
  35. package/shell-dist/assets/jsx-runtime.h40xu4o5b0.js +14 -0
  36. package/shell-dist/assets/keepalive-for-react.xenu5vam70.js +1 -0
  37. package/shell-dist/assets/kit.37kr8ui390.js +1 -0
  38. package/shell-dist/assets/ky.1cgch7gu60.js +6 -0
  39. package/shell-dist/assets/motion-react.pjsxytvjs0.js +12 -0
  40. package/shell-dist/assets/motion.21tciqutg0.js +4 -0
  41. package/shell-dist/assets/nprogress.2nz76n9ny0.js +7 -0
  42. package/shell-dist/assets/ojm-dayjs-locale-zh-cn.3vr3beiyp0.js +9 -0
  43. package/shell-dist/assets/pinyin-pro.3v0mnxczn0.js +1 -0
  44. package/shell-dist/assets/pro-components.2kyot1vcl0.js +83 -0
  45. package/shell-dist/assets/react-countup.2x8idnr8y0.js +10 -0
  46. package/shell-dist/assets/react-dom-client.ick0v05ob0.js +43 -0
  47. package/shell-dist/assets/react-dom.2so9uxg3f0.js +22 -0
  48. package/shell-dist/assets/react-error-boundary.2dncdfj3b0.js +1 -0
  49. package/shell-dist/assets/react-i18next.auhvjhqv00.js +1 -0
  50. package/shell-dist/assets/react-jss.1ei6dr9e00.js +29 -0
  51. package/shell-dist/assets/react-query.3rln45ow00.js +1 -0
  52. package/shell-dist/assets/react-router-dom.3c6zld8h40.js +44 -0
  53. package/shell-dist/assets/react-router.2h9rebcv50.js +56 -0
  54. package/shell-dist/assets/react.1ew63mwts0.js +14 -0
  55. package/shell-dist/assets/runtime.1xfsxcajj0.js +21702 -0
  56. package/shell-dist/assets/simplebar-react.2g739uvai0.js +1 -0
  57. package/shell-dist/assets/spin-delay.yjeyj6iwp0.js +9 -0
  58. package/shell-dist/assets/tailwind-merge.125ehiqjw0.js +1 -0
  59. package/shell-dist/assets/use-sync-external-store-shim.1nz1pi9bb0.js +22 -0
  60. package/shell-dist/assets/zustand-middleware.1xaxjueme0.js +6 -0
  61. package/shell-dist/assets/zustand-react-shallow.pybayv1hx0.js +1 -0
  62. package/shell-dist/assets/zustand-react.9fsl9brxy0.js +1 -0
  63. package/shell-dist/assets/zustand-shallow.6cz0yyv9x0.js +1 -0
  64. package/shell-dist/assets/zustand-vanilla-shallow.3424monv50.js +1 -0
  65. package/shell-dist/assets/zustand-vanilla.1mo3ka3g30.js +1 -0
  66. package/shell-dist/assets/zustand.3gjgzlnqo0.js +1 -0
  67. package/shell-dist/index.html +67 -118
  68. package/shell-dist/versions.json +3 -3
  69. package/src/build/module-def.ts +1 -0
  70. package/src/esm-exports.ts +152 -70
  71. package/src/market/__tests__/bootstrap.test.ts +36 -1
  72. package/src/shared-deps.ts +69 -19
  73. package/src/site-base.ts +4 -0
  74. package/templates/src/app/web/home/pages/components/bar-chart.tsx +5 -3
  75. package/templates/src/app/web/home/pages/components/echarts-setup.ts +30 -0
  76. package/templates/src/app/web/home/pages/components/line-chart.tsx +5 -3
  77. package/templates/src/app/web/home/pages/components/pie-chart.tsx +6 -3
  78. package/templates/src/app/web/home/pages/index.tsx +3 -2
  79. package/templates/src/app/web/home/routes.ts +3 -2
  80. package/templates/src/app/web/personal-center/locales/en-US.json +15 -0
  81. package/templates/src/app/web/personal-center/locales/zh-CN.json +15 -0
  82. package/templates/src/app/web/personal-center/pages/my-profile/index.tsx +15 -13
  83. package/templates/src/app/web/system/locales/en-US.json +24 -3
  84. package/templates/src/app/web/system/locales/zh-CN.json +24 -3
  85. package/templates/src/app/web/system/pages/roles/index.tsx +13 -6
  86. package/templates/src/app/web/system/pages/settings/index.tsx +1 -1
  87. package/templates/src/app/web/system/pages/users/index.tsx +3 -3
  88. package/templates/src/app/web/system/pages/users/roles.tsx +1 -1
  89. package/templates/src/oj-market/web/locales/en-US.json +14 -1
  90. package/templates/src/oj-market/web/locales/zh-CN.json +14 -1
  91. package/vendor/host-versions.json +3 -3
  92. package/shell-dist/assets/ahooks.js +0 -6909
  93. package/shell-dist/assets/antd-es-locale-zh_CN.js +0 -257
  94. package/shell-dist/assets/antd-img-crop.js +0 -1495
  95. package/shell-dist/assets/antd-locale-en_US.js +0 -374
  96. package/shell-dist/assets/antd-locale-zh_CN.js +0 -379
  97. package/shell-dist/assets/antd.js +0 -106874
  98. package/shell-dist/assets/clsx.js +0 -33
  99. package/shell-dist/assets/contract-errors.js +0 -30
  100. package/shell-dist/assets/contract.js +0 -18900
  101. package/shell-dist/assets/cssinjs.js +0 -2595
  102. package/shell-dist/assets/dayjs-plugin-advancedFormat.js +0 -98
  103. package/shell-dist/assets/dayjs-plugin-customParseFormat.js +0 -173
  104. package/shell-dist/assets/dayjs-plugin-isoWeek.js +0 -77
  105. package/shell-dist/assets/dayjs-plugin-localeData.js +0 -126
  106. package/shell-dist/assets/dayjs-plugin-quarterOfYear.js +0 -77
  107. package/shell-dist/assets/dayjs-plugin-relativeTime.js +0 -92
  108. package/shell-dist/assets/dayjs-plugin-weekOfYear.js +0 -73
  109. package/shell-dist/assets/dayjs-plugin-weekYear.js +0 -63
  110. package/shell-dist/assets/dayjs-plugin-weekday.js +0 -63
  111. package/shell-dist/assets/dayjs.js +0 -326
  112. package/shell-dist/assets/dnd-kit-core.js +0 -3601
  113. package/shell-dist/assets/dnd-kit-sortable.js +0 -717
  114. package/shell-dist/assets/dnd-kit-utilities.js +0 -340
  115. package/shell-dist/assets/i18next.js +0 -2321
  116. package/shell-dist/assets/icons-es-components-Context.js +0 -20
  117. package/shell-dist/assets/icons.js +0 -34961
  118. package/shell-dist/assets/jsx-dev-runtime.js +0 -75
  119. package/shell-dist/assets/jsx-runtime.js +0 -97
  120. package/shell-dist/assets/keepalive-for-react.js +0 -283
  121. package/shell-dist/assets/kit.js +0 -151
  122. package/shell-dist/assets/ky.js +0 -1427
  123. package/shell-dist/assets/motion-react.js +0 -13589
  124. package/shell-dist/assets/motion.js +0 -9959
  125. package/shell-dist/assets/nprogress.js +0 -314
  126. package/shell-dist/assets/ojm--ant-design-icons-es-icons-BarsOutlined.js +0 -7
  127. package/shell-dist/assets/ojm--ant-design-icons-es-icons-CalendarOutlined.js +0 -7
  128. package/shell-dist/assets/ojm--ant-design-icons-es-icons-CaretDownFilled.js +0 -7
  129. package/shell-dist/assets/ojm--ant-design-icons-es-icons-CaretDownOutlined.js +0 -7
  130. package/shell-dist/assets/ojm--ant-design-icons-es-icons-CaretUpOutlined.js +0 -7
  131. package/shell-dist/assets/ojm--ant-design-icons-es-icons-CheckCircleFilled.js +0 -7
  132. package/shell-dist/assets/ojm--ant-design-icons-es-icons-CheckOutlined.js +0 -7
  133. package/shell-dist/assets/ojm--ant-design-icons-es-icons-ClockCircleOutlined.js +0 -7
  134. package/shell-dist/assets/ojm--ant-design-icons-es-icons-CloseCircleFilled.js +0 -7
  135. package/shell-dist/assets/ojm--ant-design-icons-es-icons-CloseOutlined.js +0 -7
  136. package/shell-dist/assets/ojm--ant-design-icons-es-icons-CopyOutlined.js +0 -7
  137. package/shell-dist/assets/ojm--ant-design-icons-es-icons-DeleteOutlined.js +0 -7
  138. package/shell-dist/assets/ojm--ant-design-icons-es-icons-DoubleLeftOutlined.js +0 -7
  139. package/shell-dist/assets/ojm--ant-design-icons-es-icons-DoubleRightOutlined.js +0 -7
  140. package/shell-dist/assets/ojm--ant-design-icons-es-icons-DownOutlined.js +0 -7
  141. package/shell-dist/assets/ojm--ant-design-icons-es-icons-DownloadOutlined.js +0 -7
  142. package/shell-dist/assets/ojm--ant-design-icons-es-icons-EditOutlined.js +0 -7
  143. package/shell-dist/assets/ojm--ant-design-icons-es-icons-EllipsisOutlined.js +0 -7
  144. package/shell-dist/assets/ojm--ant-design-icons-es-icons-EnterOutlined.js +0 -7
  145. package/shell-dist/assets/ojm--ant-design-icons-es-icons-ExclamationCircleFilled.js +0 -7
  146. package/shell-dist/assets/ojm--ant-design-icons-es-icons-EyeInvisibleOutlined.js +0 -7
  147. package/shell-dist/assets/ojm--ant-design-icons-es-icons-EyeOutlined.js +0 -7
  148. package/shell-dist/assets/ojm--ant-design-icons-es-icons-FileOutlined.js +0 -7
  149. package/shell-dist/assets/ojm--ant-design-icons-es-icons-FileTextOutlined.js +0 -7
  150. package/shell-dist/assets/ojm--ant-design-icons-es-icons-FilterFilled.js +0 -7
  151. package/shell-dist/assets/ojm--ant-design-icons-es-icons-FolderOpenOutlined.js +0 -7
  152. package/shell-dist/assets/ojm--ant-design-icons-es-icons-FolderOutlined.js +0 -7
  153. package/shell-dist/assets/ojm--ant-design-icons-es-icons-HolderOutlined.js +0 -7
  154. package/shell-dist/assets/ojm--ant-design-icons-es-icons-InfoCircleFilled.js +0 -7
  155. package/shell-dist/assets/ojm--ant-design-icons-es-icons-LeftOutlined.js +0 -7
  156. package/shell-dist/assets/ojm--ant-design-icons-es-icons-LoadingOutlined.js +0 -7
  157. package/shell-dist/assets/ojm--ant-design-icons-es-icons-MinusOutlined.js +0 -7
  158. package/shell-dist/assets/ojm--ant-design-icons-es-icons-MinusSquareOutlined.js +0 -7
  159. package/shell-dist/assets/ojm--ant-design-icons-es-icons-PaperClipOutlined.js +0 -7
  160. package/shell-dist/assets/ojm--ant-design-icons-es-icons-PictureOutlined.js +0 -7
  161. package/shell-dist/assets/ojm--ant-design-icons-es-icons-PlusOutlined.js +0 -7
  162. package/shell-dist/assets/ojm--ant-design-icons-es-icons-PlusSquareOutlined.js +0 -7
  163. package/shell-dist/assets/ojm--ant-design-icons-es-icons-QuestionCircleOutlined.js +0 -7
  164. package/shell-dist/assets/ojm--ant-design-icons-es-icons-ReloadOutlined.js +0 -7
  165. package/shell-dist/assets/ojm--ant-design-icons-es-icons-RightOutlined.js +0 -7
  166. package/shell-dist/assets/ojm--ant-design-icons-es-icons-RotateLeftOutlined.js +0 -7
  167. package/shell-dist/assets/ojm--ant-design-icons-es-icons-RotateRightOutlined.js +0 -7
  168. package/shell-dist/assets/ojm--ant-design-icons-es-icons-SearchOutlined.js +0 -7
  169. package/shell-dist/assets/ojm--ant-design-icons-es-icons-StarFilled.js +0 -7
  170. package/shell-dist/assets/ojm--ant-design-icons-es-icons-SwapOutlined.js +0 -7
  171. package/shell-dist/assets/ojm--ant-design-icons-es-icons-SwapRightOutlined.js +0 -7
  172. package/shell-dist/assets/ojm--ant-design-icons-es-icons-UpOutlined.js +0 -7
  173. package/shell-dist/assets/ojm--ant-design-icons-es-icons-VerticalAlignTopOutlined.js +0 -7
  174. package/shell-dist/assets/ojm--ant-design-icons-es-icons-WarningFilled.js +0 -7
  175. package/shell-dist/assets/ojm--ant-design-icons-es-icons-ZoomInOutlined.js +0 -7
  176. package/shell-dist/assets/ojm--ant-design-icons-es-icons-ZoomOutOutlined.js +0 -7
  177. package/shell-dist/assets/ojm-dayjs-locale-zh-cn.js +0 -81
  178. package/shell-dist/assets/pinyin-pro.js +0 -25175
  179. package/shell-dist/assets/pro-components.js +0 -44627
  180. package/shell-dist/assets/react-countup.js +0 -525
  181. package/shell-dist/assets/react-dom-client.js +0 -12134
  182. package/shell-dist/assets/react-dom.js +0 -266
  183. package/shell-dist/assets/react-error-boundary.js +0 -141
  184. package/shell-dist/assets/react-i18next.js +0 -1773
  185. package/shell-dist/assets/react-jss.js +0 -4089
  186. package/shell-dist/assets/react-query.js +0 -3072
  187. package/shell-dist/assets/react-router-dom.js +0 -9927
  188. package/shell-dist/assets/react-router.js +0 -14584
  189. package/shell-dist/assets/react.js +0 -590
  190. package/shell-dist/assets/runtime.js +0 -28294
  191. package/shell-dist/assets/simplebar-react.js +0 -1119
  192. package/shell-dist/assets/spin-delay.js +0 -111
  193. package/shell-dist/assets/tailwind-merge.js +0 -3364
  194. package/shell-dist/assets/use-sync-external-store-shim.js +0 -130
  195. package/shell-dist/assets/zustand-middleware.js +0 -513
  196. package/shell-dist/assets/zustand-react-shallow.js +0 -27
  197. package/shell-dist/assets/zustand-react.js +0 -39
  198. package/shell-dist/assets/zustand-shallow.js +0 -22
  199. package/shell-dist/assets/zustand-vanilla-shallow.js +0 -71
  200. package/shell-dist/assets/zustand-vanilla.js +0 -40
  201. package/shell-dist/assets/zustand.js +0 -32
  202. /package/shell-dist/assets/{nprogress-css.js → nprogress-css.1cq2pzkre0.js} +0 -0
  203. /package/shell-dist/assets/{ojm-antd-es-button.js → ojm-antd-es-button.2uriphio50.js} +0 -0
  204. /package/shell-dist/assets/{ojm-antd-es-modal.js → ojm-antd-es-modal.bf3tgdh8v0.js} +0 -0
  205. /package/shell-dist/assets/{ojm-antd-es-slider.js → ojm-antd-es-slider.xyvptuhid0.js} +0 -0
  206. /package/shell-dist/assets/{ojm-antd-es-upload.js → ojm-antd-es-upload.13gx45e0g0.js} +0 -0
@@ -1,1427 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __typeError = (msg) => {
3
- throw TypeError(msg);
4
- };
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
11
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
12
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
13
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
14
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
15
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
16
- var __privateWrapper = (obj, member, setter, getter) => ({
17
- set _(value) {
18
- __privateSet(obj, member, value, setter);
19
- },
20
- get _() {
21
- return __privateGet(obj, member, getter);
22
- }
23
- });
24
-
25
- // ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/index.js
26
- var distribution_exports = {};
27
- __export(distribution_exports, {
28
- ForceRetryError: () => ForceRetryError,
29
- HTTPError: () => HTTPError,
30
- KyError: () => KyError,
31
- NetworkError: () => NetworkError,
32
- SchemaValidationError: () => SchemaValidationError,
33
- TimeoutError: () => TimeoutError,
34
- default: () => distribution_default,
35
- isForceRetryError: () => isForceRetryError,
36
- isHTTPError: () => isHTTPError,
37
- isKyError: () => isKyError,
38
- isNetworkError: () => isNetworkError,
39
- isTimeoutError: () => isTimeoutError,
40
- replaceOption: () => replaceOption
41
- });
42
-
43
- // ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/errors/KyError.js
44
- var KyError = class extends Error {
45
- constructor() {
46
- super(...arguments);
47
- __publicField(this, "name", "KyError");
48
- }
49
- get isKyError() {
50
- return true;
51
- }
52
- };
53
-
54
- // ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/errors/HTTPError.js
55
- var HTTPError = class extends KyError {
56
- constructor(response, request, options) {
57
- const code = response.status || response.status === 0 ? response.status : "";
58
- const title = response.statusText ?? "";
59
- const status = `${code} ${title}`.trim();
60
- const reason = status ? `status code ${status}` : "an unknown error";
61
- super(`Request failed with ${reason}: ${request.method} ${request.url}`);
62
- __publicField(this, "name", "HTTPError");
63
- __publicField(this, "response");
64
- __publicField(this, "request");
65
- __publicField(this, "options");
66
- __publicField(this, "data");
67
- this.response = response;
68
- this.request = request;
69
- this.options = options;
70
- }
71
- };
72
-
73
- // ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/errors/NetworkError.js
74
- var NetworkError = class extends KyError {
75
- constructor(request, options) {
76
- super(`Request failed due to a network error: ${request.method} ${request.url}`, options);
77
- __publicField(this, "name", "NetworkError");
78
- __publicField(this, "request");
79
- this.request = request;
80
- }
81
- };
82
-
83
- // ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/errors/NonError.js
84
- var NonError = class extends Error {
85
- constructor(value) {
86
- let message = "Non-error value was thrown";
87
- try {
88
- if (typeof value === "string") {
89
- message = value;
90
- } else if (value && typeof value === "object" && "message" in value && typeof value.message === "string") {
91
- message = value.message;
92
- }
93
- } catch {
94
- }
95
- super(message);
96
- __publicField(this, "name", "NonError");
97
- __publicField(this, "value");
98
- this.value = value;
99
- }
100
- };
101
-
102
- // ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/errors/ForceRetryError.js
103
- var ForceRetryError = class extends KyError {
104
- constructor(options) {
105
- const cause = options?.cause ? options.cause instanceof Error ? options.cause : new NonError(options.cause) : void 0;
106
- super(options?.code ? `Forced retry: ${options.code}` : "Forced retry", cause ? { cause } : void 0);
107
- __publicField(this, "name", "ForceRetryError");
108
- __publicField(this, "customDelay");
109
- __publicField(this, "code");
110
- __publicField(this, "customRequest");
111
- this.customDelay = options?.delay;
112
- this.code = options?.code;
113
- this.customRequest = options?.request;
114
- }
115
- };
116
-
117
- // ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/errors/SchemaValidationError.js
118
- var SchemaValidationError = class extends Error {
119
- constructor(issues) {
120
- super("Response schema validation failed");
121
- __publicField(this, "name", "SchemaValidationError");
122
- __publicField(this, "issues");
123
- this.issues = issues;
124
- }
125
- };
126
-
127
- // ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/errors/TimeoutError.js
128
- var TimeoutError = class extends KyError {
129
- constructor(request) {
130
- super(`Request timed out: ${request.method} ${request.url}`);
131
- __publicField(this, "name", "TimeoutError");
132
- __publicField(this, "request");
133
- this.request = request;
134
- }
135
- };
136
-
137
- // ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/core/constants.js
138
- var supportsRequestStreams = (() => {
139
- let duplexAccessed = false;
140
- let hasContentType = false;
141
- const supportsReadableStream = typeof globalThis.ReadableStream === "function";
142
- const supportsRequest = typeof globalThis.Request === "function";
143
- if (supportsReadableStream && supportsRequest) {
144
- try {
145
- hasContentType = new globalThis.Request("https://empty.invalid", {
146
- body: new globalThis.ReadableStream(),
147
- method: "POST",
148
- // @ts-expect-error - Types are outdated.
149
- get duplex() {
150
- duplexAccessed = true;
151
- return "half";
152
- }
153
- }).headers.has("Content-Type");
154
- } catch (error) {
155
- if (error instanceof Error && error.message === "unsupported BodyInit type") {
156
- return false;
157
- }
158
- throw error;
159
- }
160
- }
161
- return duplexAccessed && !hasContentType;
162
- })();
163
- var supportsAbortController = typeof globalThis.AbortController === "function";
164
- var supportsAbortSignal = typeof globalThis.AbortSignal === "function" && typeof globalThis.AbortSignal.any === "function";
165
- var supportsResponseStreams = typeof globalThis.ReadableStream === "function";
166
- var supportsFormData = typeof globalThis.FormData === "function";
167
- var requestMethods = ["get", "post", "put", "patch", "head", "delete"];
168
- var validate = () => void 0;
169
- validate();
170
- var responseTypes = {
171
- json: "application/json",
172
- text: "text/*",
173
- formData: "multipart/form-data",
174
- arrayBuffer: "*/*",
175
- blob: "*/*",
176
- // Supported in modern Fetch implementations (for example, browsers and recent Node.js/undici).
177
- // We still feature-check at runtime before exposing the shortcut.
178
- bytes: "*/*"
179
- };
180
- var maxSafeTimeout = 2147483647;
181
- var usualFormBoundarySize = 40;
182
- var stop = /* @__PURE__ */ Symbol("stop");
183
- var RetryMarker = class {
184
- constructor(options) {
185
- __publicField(this, "options");
186
- this.options = options;
187
- }
188
- };
189
- var retry = (options) => new RetryMarker(options);
190
- var kyOptionKeys = {
191
- json: true,
192
- parseJson: true,
193
- stringifyJson: true,
194
- searchParams: true,
195
- baseUrl: true,
196
- prefix: true,
197
- retry: true,
198
- timeout: true,
199
- totalTimeout: true,
200
- hooks: true,
201
- throwHttpErrors: true,
202
- onDownloadProgress: true,
203
- onUploadProgress: true,
204
- fetch: true,
205
- context: true
206
- };
207
- var requestOptionsRegistry = {
208
- method: true,
209
- headers: true,
210
- body: true,
211
- mode: true,
212
- credentials: true,
213
- cache: true,
214
- redirect: true,
215
- referrer: true,
216
- referrerPolicy: true,
217
- integrity: true,
218
- keepalive: true,
219
- signal: true,
220
- window: true,
221
- duplex: true
222
- };
223
-
224
- // ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/utils/body.js
225
- var encoder = new TextEncoder();
226
- var getBodySize = (body) => {
227
- if (!body) {
228
- return 0;
229
- }
230
- if (body instanceof FormData) {
231
- let size = 0;
232
- for (const [key, value] of body) {
233
- size += usualFormBoundarySize;
234
- size += encoder.encode(`Content-Disposition: form-data; name="${key}"`).byteLength;
235
- size += typeof value === "string" ? encoder.encode(value).byteLength : value.size;
236
- }
237
- return size;
238
- }
239
- if (body instanceof Blob) {
240
- return body.size;
241
- }
242
- if (body instanceof ArrayBuffer || ArrayBuffer.isView(body)) {
243
- return body.byteLength;
244
- }
245
- if (typeof body === "string") {
246
- return encoder.encode(body).byteLength;
247
- }
248
- if (body instanceof URLSearchParams) {
249
- return encoder.encode(body.toString()).byteLength;
250
- }
251
- return 0;
252
- };
253
- var withProgress = (stream, totalBytes, onProgress) => {
254
- let previousChunk;
255
- let transferredBytes = 0;
256
- return stream.pipeThrough(new TransformStream({
257
- transform(currentChunk, controller) {
258
- controller.enqueue(currentChunk);
259
- if (previousChunk) {
260
- transferredBytes += previousChunk.byteLength;
261
- let percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;
262
- if (percent >= 1) {
263
- percent = 1 - Number.EPSILON;
264
- }
265
- onProgress?.({ percent, totalBytes: Math.max(totalBytes, transferredBytes), transferredBytes }, previousChunk);
266
- }
267
- previousChunk = currentChunk;
268
- },
269
- flush() {
270
- if (previousChunk) {
271
- transferredBytes += previousChunk.byteLength;
272
- onProgress?.({ percent: 1, totalBytes: Math.max(totalBytes, transferredBytes), transferredBytes }, previousChunk);
273
- }
274
- }
275
- }));
276
- };
277
- var streamResponse = (response, onDownloadProgress) => {
278
- if (!response.body) {
279
- return response;
280
- }
281
- const responseInit = {
282
- status: response.status,
283
- statusText: response.statusText,
284
- headers: response.headers
285
- };
286
- if (response.status === 204) {
287
- return new Response(null, responseInit);
288
- }
289
- const totalBytes = Math.max(0, Number(response.headers.get("content-length")) || 0);
290
- return new Response(withProgress(response.body, totalBytes, onDownloadProgress), responseInit);
291
- };
292
- var streamRequest = (request, onUploadProgress, originalBody) => {
293
- if (!request.body) {
294
- return request;
295
- }
296
- const totalBytes = getBodySize(originalBody ?? request.body);
297
- return new Request(request, {
298
- // @ts-expect-error - Types are outdated.
299
- duplex: "half",
300
- body: withProgress(request.body, totalBytes, onUploadProgress)
301
- });
302
- };
303
-
304
- // ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/utils/is.js
305
- var isObject = (value) => value !== null && typeof value === "object";
306
-
307
- // ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/utils/merge.js
308
- var replaceSymbol = /* @__PURE__ */ Symbol("replaceOption");
309
- var getReplaceState = (value) => isObject(value) && value[replaceSymbol] === true ? {
310
- isReplace: true,
311
- value: value.value
312
- } : {
313
- isReplace: false,
314
- value
315
- };
316
- var replaceOption = (value) => {
317
- const markedValue = { [replaceSymbol]: true, value };
318
- return markedValue;
319
- };
320
- var validateAndMerge = (...sources) => {
321
- for (const source of sources) {
322
- if ((!isObject(source) || Array.isArray(source)) && source !== void 0) {
323
- throw new TypeError("The `options` argument must be an object");
324
- }
325
- }
326
- return deepMerge({}, ...sources);
327
- };
328
- var mergeHeaders = (source1 = {}, source2 = {}) => {
329
- const result = new globalThis.Headers(source1);
330
- const isHeadersInstance = source2 instanceof globalThis.Headers;
331
- const source = new globalThis.Headers(source2);
332
- for (const [key, value] of source.entries()) {
333
- if (isHeadersInstance && value === "undefined" || value === void 0) {
334
- result.delete(key);
335
- } else {
336
- result.set(key, value);
337
- }
338
- }
339
- return result;
340
- };
341
- var isPlainObject = (value) => {
342
- if (!isObject(value) || Array.isArray(value)) {
343
- return false;
344
- }
345
- const prototype = Object.getPrototypeOf(value);
346
- return prototype === Object.prototype || prototype === null;
347
- };
348
- var cloneShallow = (value) => {
349
- if (value instanceof URLSearchParams) {
350
- const copy = new URLSearchParams(value);
351
- const deleted = value[deletedParametersSymbol];
352
- if (deleted) {
353
- copy[deletedParametersSymbol] = new Set(deleted);
354
- }
355
- return copy;
356
- }
357
- if (value instanceof globalThis.Headers) {
358
- return new globalThis.Headers(value);
359
- }
360
- if (Array.isArray(value)) {
361
- return [...value];
362
- }
363
- if (isPlainObject(value)) {
364
- const copy = { ...value };
365
- return copy;
366
- }
367
- return value;
368
- };
369
- var normalizeHeaderObject = (headers) => Object.fromEntries(Object.entries(headers).filter((entry) => entry[1] !== void 0));
370
- var mergeHeaderContainers = (source1, source2) => {
371
- if (isPlainObject(source1) && isPlainObject(source2)) {
372
- return normalizeHeaderObject({ ...source1, ...source2 });
373
- }
374
- return mergeHeaders(source1, source2);
375
- };
376
- function newHookValue(original, incoming, property) {
377
- return Object.hasOwn(incoming, property) && incoming[property] === void 0 ? [] : deepMerge(original[property] ?? [], incoming[property] ?? []);
378
- }
379
- var mergeHooks = (original = {}, incoming = {}) => ({
380
- init: newHookValue(original, incoming, "init"),
381
- beforeRequest: newHookValue(original, incoming, "beforeRequest"),
382
- beforeRetry: newHookValue(original, incoming, "beforeRetry"),
383
- beforeError: newHookValue(original, incoming, "beforeError"),
384
- afterResponse: newHookValue(original, incoming, "afterResponse")
385
- });
386
- var deletedParametersSymbol = /* @__PURE__ */ Symbol("deletedParameters");
387
- var appendSearchParameters = (target, source) => {
388
- const result = new URLSearchParams();
389
- const deleted = /* @__PURE__ */ new Set();
390
- for (const input of [target, source]) {
391
- if (input === void 0) {
392
- continue;
393
- }
394
- if (input instanceof URLSearchParams) {
395
- for (const [key, value] of input.entries()) {
396
- result.append(key, value);
397
- deleted.delete(key);
398
- }
399
- const inputDeleted = input[deletedParametersSymbol];
400
- if (inputDeleted) {
401
- for (const key of inputDeleted) {
402
- result.delete(key);
403
- deleted.add(key);
404
- }
405
- }
406
- } else if (Array.isArray(input)) {
407
- for (const pair of input) {
408
- if (!Array.isArray(pair) || pair.length !== 2) {
409
- throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");
410
- }
411
- result.append(String(pair[0]), String(pair[1]));
412
- deleted.delete(String(pair[0]));
413
- }
414
- } else if (isObject(input)) {
415
- for (const [key, value] of Object.entries(input)) {
416
- if (value === void 0) {
417
- result.delete(key);
418
- deleted.add(key);
419
- } else {
420
- result.append(key, String(value));
421
- deleted.delete(key);
422
- }
423
- }
424
- } else {
425
- const parameters = new URLSearchParams(input);
426
- for (const [key, value] of parameters.entries()) {
427
- result.append(key, value);
428
- deleted.delete(key);
429
- }
430
- }
431
- }
432
- if (deleted.size > 0) {
433
- result[deletedParametersSymbol] = deleted;
434
- }
435
- return result;
436
- };
437
- var deepMerge = (...sources) => {
438
- let returnValue = {};
439
- let headers = {};
440
- let hooks = {};
441
- let searchParameters;
442
- const signals = [];
443
- for (const source of sources) {
444
- if (Array.isArray(source)) {
445
- if (!Array.isArray(returnValue)) {
446
- returnValue = [];
447
- }
448
- returnValue = [...returnValue, ...source];
449
- } else if (isObject(source)) {
450
- for (let [key, value] of Object.entries(source)) {
451
- if (key === "signal" && value instanceof globalThis.AbortSignal) {
452
- signals.push(value);
453
- continue;
454
- }
455
- const replaceState = getReplaceState(value);
456
- const { isReplace } = replaceState;
457
- value = replaceState.value;
458
- if (key === "context") {
459
- if (value !== void 0 && value !== null && (!isObject(value) || Array.isArray(value))) {
460
- throw new TypeError("The `context` option must be an object");
461
- }
462
- returnValue = {
463
- ...returnValue,
464
- context: value === void 0 || value === null ? {} : isReplace ? { ...value } : { ...returnValue.context, ...value }
465
- };
466
- continue;
467
- }
468
- if (key === "searchParams") {
469
- if (value === void 0 || value === null) {
470
- searchParameters = void 0;
471
- } else if (isReplace) {
472
- searchParameters = value;
473
- } else {
474
- searchParameters = searchParameters === void 0 ? value : appendSearchParameters(searchParameters, value);
475
- }
476
- continue;
477
- }
478
- if (isObject(value) && !isReplace && key in returnValue) {
479
- value = deepMerge(returnValue[key], value);
480
- }
481
- returnValue = { ...returnValue, [key]: value };
482
- }
483
- if (isObject(source.hooks)) {
484
- const { value: hookValue, isReplace } = getReplaceState(source.hooks);
485
- hooks = isReplace ? mergeHooks({}, hookValue) : mergeHooks(hooks, hookValue);
486
- returnValue.hooks = hooks;
487
- }
488
- if (isObject(source.headers)) {
489
- const { value: headerValue, isReplace } = getReplaceState(source.headers);
490
- headers = isReplace ? cloneShallow(headerValue) : mergeHeaderContainers(headers, headerValue);
491
- returnValue.headers = headers;
492
- }
493
- }
494
- }
495
- if (searchParameters !== void 0) {
496
- returnValue.searchParams = searchParameters;
497
- }
498
- if (signals.length > 0) {
499
- if (signals.length === 1) {
500
- returnValue.signal = signals[0];
501
- } else if (supportsAbortSignal) {
502
- returnValue.signal = AbortSignal.any(signals);
503
- } else {
504
- returnValue.signal = signals.at(-1);
505
- }
506
- }
507
- return returnValue;
508
- };
509
-
510
- // ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/utils/normalize.js
511
- var normalizeRequestMethod = (input) => requestMethods.includes(input) ? input.toUpperCase() : input;
512
- var retryMethods = ["get", "put", "head", "delete", "options", "trace"];
513
- var retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];
514
- var retryAfterStatusCodes = [413, 429, 503];
515
- var defaultRetryOptions = {
516
- limit: 2,
517
- methods: retryMethods,
518
- statusCodes: retryStatusCodes,
519
- afterStatusCodes: retryAfterStatusCodes,
520
- maxRetryAfter: Number.POSITIVE_INFINITY,
521
- backoffLimit: Number.POSITIVE_INFINITY,
522
- delay: (attemptCount) => 0.3 * 2 ** (attemptCount - 1) * 1e3,
523
- jitter: void 0,
524
- retryOnTimeout: false
525
- };
526
- var normalizeRetryOptions = (retry2 = {}) => {
527
- if (typeof retry2 === "number") {
528
- return {
529
- ...defaultRetryOptions,
530
- limit: retry2
531
- };
532
- }
533
- if (retry2.methods && !Array.isArray(retry2.methods)) {
534
- throw new Error("retry.methods must be an array");
535
- }
536
- if (retry2.statusCodes && !Array.isArray(retry2.statusCodes)) {
537
- throw new Error("retry.statusCodes must be an array");
538
- }
539
- const normalizedRetry = Object.fromEntries(Object.entries({
540
- ...retry2,
541
- methods: retry2.methods?.map((method) => method.toLowerCase())
542
- }).filter(([, value]) => value !== void 0));
543
- return {
544
- ...defaultRetryOptions,
545
- ...normalizedRetry
546
- };
547
- };
548
-
549
- // ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/utils/timeout.js
550
- async function timeout(request, init, abortController, options) {
551
- return new Promise((resolve, reject) => {
552
- const timeoutId = setTimeout(() => {
553
- if (abortController) {
554
- abortController.abort();
555
- }
556
- reject(new TimeoutError(request));
557
- }, options.timeout);
558
- void options.fetch(request, init).then(resolve).catch(reject).then(() => {
559
- clearTimeout(timeoutId);
560
- });
561
- });
562
- }
563
-
564
- // ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/utils/delay.js
565
- async function delay(ms, { signal }) {
566
- return new Promise((resolve, reject) => {
567
- if (signal) {
568
- signal.throwIfAborted();
569
- signal.addEventListener("abort", abortHandler, { once: true });
570
- }
571
- function abortHandler() {
572
- clearTimeout(timeoutId);
573
- reject(signal.reason);
574
- }
575
- const timeoutId = setTimeout(() => {
576
- signal?.removeEventListener("abort", abortHandler);
577
- resolve();
578
- }, ms);
579
- });
580
- }
581
-
582
- // ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/utils/options.js
583
- var findUnknownOptions = (options) => {
584
- const unknownOptions = {};
585
- for (const key in options) {
586
- if (!Object.hasOwn(options, key)) {
587
- continue;
588
- }
589
- if (!(key in requestOptionsRegistry) && !(key in kyOptionKeys)) {
590
- unknownOptions[key] = options[key];
591
- }
592
- }
593
- return unknownOptions;
594
- };
595
- var hasSearchParameters = (search) => {
596
- if (search === void 0) {
597
- return false;
598
- }
599
- if (Array.isArray(search)) {
600
- return search.length > 0;
601
- }
602
- if (search instanceof URLSearchParams) {
603
- return search.size > 0 || Boolean(search[deletedParametersSymbol]?.size);
604
- }
605
- if (typeof search === "object") {
606
- return Object.keys(search).length > 0;
607
- }
608
- if (typeof search === "string") {
609
- return search.trim().length > 0;
610
- }
611
- return Boolean(search);
612
- };
613
-
614
- // ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/utils/is-network-error.js
615
- var objectToString = Object.prototype.toString;
616
- var isError = (value) => objectToString.call(value) === "[object Error]";
617
- var errorMessages = /* @__PURE__ */ new Set([
618
- "network error",
619
- // Chrome
620
- "NetworkError when attempting to fetch resource.",
621
- // Firefox
622
- "The Internet connection appears to be offline.",
623
- // Safari 16
624
- "Network request failed",
625
- // `cross-fetch`
626
- "fetch failed",
627
- // Undici (Node.js)
628
- "terminated",
629
- // Undici (Node.js)
630
- " A network error occurred.",
631
- // Bun (WebKit) - leading space is intentional
632
- "Network connection lost"
633
- // Cloudflare Workers (fetch)
634
- ]);
635
- function isRawNetworkError(error) {
636
- const isValid = error && isError(error) && error.name === "TypeError" && typeof error.message === "string";
637
- if (!isValid) {
638
- return false;
639
- }
640
- const { message, stack } = error;
641
- if (message === "Load failed") {
642
- return stack === void 0 || "__sentry_captured__" in error;
643
- }
644
- if (message.startsWith("error sending request for url")) {
645
- return true;
646
- }
647
- if (message === "Failed to fetch" || message.startsWith("Failed to fetch (") && message.endsWith(")")) {
648
- return true;
649
- }
650
- return errorMessages.has(message);
651
- }
652
-
653
- // ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/utils/type-guards.js
654
- var isErrorType = (error, cls) => error instanceof cls || error?.name === cls.name;
655
- function isKyError(error) {
656
- return error?.isKyError === true || isHTTPError(error) || isNetworkError(error) || isTimeoutError(error) || isForceRetryError(error);
657
- }
658
- function isHTTPError(error) {
659
- return isErrorType(error, HTTPError);
660
- }
661
- function isNetworkError(error) {
662
- return isErrorType(error, NetworkError);
663
- }
664
- function isTimeoutError(error) {
665
- return isErrorType(error, TimeoutError);
666
- }
667
- function isForceRetryError(error) {
668
- return isErrorType(error, ForceRetryError);
669
- }
670
-
671
- // ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/core/Ky.js
672
- var maxErrorResponseBodySize = 10 * 1024 * 1024;
673
- var prefixUrlRenamedErrorMessage = "The `prefixUrl` option has been renamed `prefix` in v2 and enhanced to allow slashes in input. See also the new `baseUrl` option for improved flexibility with standard URL resolution: https://github.com/sindresorhus/ky#baseurl";
674
- var timedOutResponseData = /* @__PURE__ */ Symbol("timedOutResponseData");
675
- var createTextDecoder = (contentType) => {
676
- const match = /;\s*charset\s*=\s*(?:"([^"]+)"|([^;,\s]+))/i.exec(contentType);
677
- const charset = match?.[1] ?? match?.[2];
678
- if (charset) {
679
- try {
680
- return new TextDecoder(charset);
681
- } catch {
682
- }
683
- }
684
- return new TextDecoder();
685
- };
686
- var invalidSchemaMessage = "The `schema` argument must follow the Standard Schema specification";
687
- var cloneRetryOptions = (retry2) => {
688
- if (typeof retry2 !== "object") {
689
- return retry2;
690
- }
691
- return {
692
- ...retry2,
693
- ...retry2.methods && { methods: [...retry2.methods] },
694
- ...retry2.statusCodes && { statusCodes: [...retry2.statusCodes] },
695
- ...retry2.afterStatusCodes && { afterStatusCodes: [...retry2.afterStatusCodes] }
696
- };
697
- };
698
- var objectToString2 = Object.prototype.toString;
699
- var isRequestInstance = (value) => value instanceof globalThis.Request || objectToString2.call(value) === "[object Request]";
700
- var isResponseInstance = (value) => value instanceof globalThis.Response || objectToString2.call(value) === "[object Response]";
701
- var cloneSearchParametersForInitHook = (searchParameters) => {
702
- if (Array.isArray(searchParameters)) {
703
- return searchParameters.map((parameter) => [...parameter]);
704
- }
705
- return cloneShallow(searchParameters);
706
- };
707
- function cloneInitHookOptions(options) {
708
- const clonedOptions = {
709
- ...options,
710
- json: cloneShallow(options.json),
711
- context: cloneShallow(options.context),
712
- headers: cloneShallow(options.headers),
713
- searchParams: cloneSearchParametersForInitHook(options.searchParams)
714
- };
715
- if (options.retry !== void 0) {
716
- clonedOptions.retry = cloneRetryOptions(options.retry);
717
- }
718
- return clonedOptions;
719
- }
720
- var validateJsonWithSchema = async (jsonValue, schema) => {
721
- if (typeof schema !== "object" && typeof schema !== "function" || schema === null) {
722
- throw new TypeError(invalidSchemaMessage);
723
- }
724
- const standardSchema = schema["~standard"];
725
- if (typeof standardSchema !== "object" || standardSchema === null || typeof standardSchema.validate !== "function") {
726
- throw new TypeError(invalidSchemaMessage);
727
- }
728
- const validationResult = await standardSchema.validate(jsonValue);
729
- if (validationResult.issues) {
730
- throw new SchemaValidationError(validationResult.issues);
731
- }
732
- return validationResult.value;
733
- };
734
- var _Ky_static, normalizeSearchParams_fn, _abortController, _retryCount, _input, _options, _originalRequest, _userProvidedAbortSignal, _beforeRetryHookErrors, _cachedNormalizedOptions, _startTime, _returnedResponseFromBeforeRetryHook, _responseRequests, _Ky_instances, calculateDelay_fn, calculateRetryDelay_fn, decorateResponse_fn, getResponseData_fn, getErrorDataTimeout_fn, isJsonContentType_fn, readResponseText_fn, parseJson_fn, cancelBody_fn, cancelResponseBody_fn, createManagedSignal_fn, throwIfTotalTimeoutExhausted_fn, runBeforeRequestHooks_fn, runAfterResponseHooks_fn, retry_fn, retryFromError_fn, consumeReturnedResponseFromBeforeRetryHook_fn, fetch_fn, getRemainingTotalTimeout_fn, getCurrentTime_fn, getNormalizedOptions_fn, assignRequest_fn, getResponseRequest_fn, setResponseRequest_fn, wrapRequestWithUploadProgress_fn;
735
- var _Ky = class _Ky {
736
- // eslint-disable-next-line complexity
737
- constructor(input, options = {}) {
738
- __privateAdd(this, _Ky_instances);
739
- __publicField(this, "request");
740
- __privateAdd(this, _abortController);
741
- __privateAdd(this, _retryCount, 0);
742
- // eslint-disable-next-line @typescript-eslint/prefer-readonly -- False positive: #input is reassigned on line 202
743
- __privateAdd(this, _input);
744
- __privateAdd(this, _options);
745
- __privateAdd(this, _originalRequest);
746
- __privateAdd(this, _userProvidedAbortSignal);
747
- __privateAdd(this, _beforeRetryHookErrors, /* @__PURE__ */ new WeakSet());
748
- __privateAdd(this, _cachedNormalizedOptions);
749
- __privateAdd(this, _startTime);
750
- __privateAdd(this, _returnedResponseFromBeforeRetryHook, false);
751
- __privateAdd(this, _responseRequests, /* @__PURE__ */ new WeakMap());
752
- var _a;
753
- __privateSet(this, _input, input);
754
- if (Object.hasOwn(options, "prefixUrl")) {
755
- throw new Error(prefixUrlRenamedErrorMessage);
756
- }
757
- __privateSet(this, _options, {
758
- ...options,
759
- headers: mergeHeaders(__privateGet(this, _input).headers, options.headers),
760
- hooks: mergeHooks({}, options.hooks),
761
- method: normalizeRequestMethod(options.method ?? __privateGet(this, _input).method ?? "GET"),
762
- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
763
- prefix: String(options.prefix || ""),
764
- retry: normalizeRetryOptions(options.retry),
765
- throwHttpErrors: options.throwHttpErrors ?? true,
766
- timeout: options.timeout ?? 1e4,
767
- totalTimeout: options.totalTimeout ?? false,
768
- fetch: options.fetch ?? globalThis.fetch.bind(globalThis),
769
- context: options.context ?? {}
770
- });
771
- if (typeof __privateGet(this, _input) !== "string" && !(__privateGet(this, _input) instanceof URL || __privateGet(this, _input) instanceof globalThis.Request)) {
772
- throw new TypeError("`input` must be a string, URL, or Request");
773
- }
774
- if (typeof __privateGet(this, _input) === "string") {
775
- if (__privateGet(this, _options).prefix) {
776
- const normalizedPrefix = __privateGet(this, _options).prefix.replace(/\/+$/, "");
777
- const normalizedInput = __privateGet(this, _input).replace(/^\/+/, "");
778
- __privateSet(this, _input, `${normalizedPrefix}/${normalizedInput}`);
779
- }
780
- if (__privateGet(this, _options).baseUrl) {
781
- let absoluteInput;
782
- try {
783
- absoluteInput = new URL(__privateGet(this, _input));
784
- } catch {
785
- }
786
- if (!absoluteInput) {
787
- __privateSet(this, _input, new URL(__privateGet(this, _input), new Request(__privateGet(this, _options).baseUrl).url));
788
- }
789
- }
790
- }
791
- if (supportsAbortController && supportsAbortSignal) {
792
- __privateSet(this, _userProvidedAbortSignal, __privateGet(this, _options).signal ?? __privateGet(this, _input).signal);
793
- __privateSet(this, _abortController, new globalThis.AbortController());
794
- __privateGet(this, _options).signal = __privateMethod(this, _Ky_instances, createManagedSignal_fn).call(this);
795
- }
796
- if (supportsRequestStreams) {
797
- __privateGet(this, _options).duplex = "half";
798
- }
799
- if (__privateGet(this, _options).json !== void 0) {
800
- __privateGet(this, _options).body = __privateGet(this, _options).stringifyJson?.(__privateGet(this, _options).json) ?? JSON.stringify(__privateGet(this, _options).json);
801
- __privateGet(this, _options).headers.set("content-type", __privateGet(this, _options).headers.get("content-type") ?? "application/json");
802
- }
803
- const userProvidedContentType = options.headers && new globalThis.Headers(options.headers).has("content-type");
804
- if (__privateGet(this, _input) instanceof globalThis.Request && (supportsFormData && __privateGet(this, _options).body instanceof globalThis.FormData || __privateGet(this, _options).body instanceof URLSearchParams) && !userProvidedContentType) {
805
- __privateGet(this, _options).headers.delete("content-type");
806
- }
807
- this.request = new globalThis.Request(__privateGet(this, _input), __privateGet(this, _options));
808
- if (hasSearchParameters(__privateGet(this, _options).searchParams)) {
809
- const url = new URL(this.request.url);
810
- const deleted = __privateGet(this, _options).searchParams?.[deletedParametersSymbol];
811
- if (deleted) {
812
- for (const key of deleted) {
813
- url.searchParams.delete(key);
814
- }
815
- }
816
- if (typeof __privateGet(this, _options).searchParams === "string") {
817
- const stringSearchParameters = __privateGet(this, _options).searchParams.replace(/^\?/, "");
818
- if (stringSearchParameters !== "") {
819
- url.search = url.search ? `${url.search}&${stringSearchParameters}` : `?${stringSearchParameters}`;
820
- }
821
- } else {
822
- const optionsSearchParameters = new URLSearchParams(__privateMethod(_a = _Ky, _Ky_static, normalizeSearchParams_fn).call(_a, __privateGet(this, _options).searchParams));
823
- for (const [key, value] of optionsSearchParameters.entries()) {
824
- url.searchParams.append(key, value);
825
- }
826
- }
827
- if (__privateGet(this, _options).searchParams && typeof __privateGet(this, _options).searchParams === "object" && !Array.isArray(__privateGet(this, _options).searchParams) && !(__privateGet(this, _options).searchParams instanceof URLSearchParams)) {
828
- for (const [key, value] of Object.entries(__privateGet(this, _options).searchParams)) {
829
- if (value === void 0) {
830
- url.searchParams.delete(key);
831
- }
832
- }
833
- }
834
- this.request = new globalThis.Request(url, __privateGet(this, _options));
835
- }
836
- if (__privateGet(this, _options).onUploadProgress && typeof __privateGet(this, _options).onUploadProgress !== "function") {
837
- throw new TypeError("The `onUploadProgress` option must be a function");
838
- }
839
- __privateSet(this, _startTime, typeof __privateGet(this, _options).totalTimeout === "number" ? __privateMethod(this, _Ky_instances, getCurrentTime_fn).call(this) : void 0);
840
- }
841
- static create(input, options) {
842
- const initHooks = options.hooks?.init ?? [];
843
- const initHookOptions = initHooks.length > 0 ? cloneInitHookOptions(options) : options;
844
- for (const hook of initHooks) {
845
- hook(initHookOptions);
846
- }
847
- const ky2 = new _Ky(input, initHookOptions);
848
- const function_ = async () => {
849
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
850
- if (typeof __privateGet(ky2, _options).timeout === "number" && __privateGet(ky2, _options).timeout > maxSafeTimeout) {
851
- throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);
852
- }
853
- if (typeof __privateGet(ky2, _options).totalTimeout === "number" && __privateGet(ky2, _options).totalTimeout > maxSafeTimeout) {
854
- throw new RangeError(`The \`totalTimeout\` option cannot be greater than ${maxSafeTimeout}`);
855
- }
856
- await Promise.resolve();
857
- const beforeRequestResponse = await __privateMethod(_a = ky2, _Ky_instances, runBeforeRequestHooks_fn).call(_a);
858
- let response = beforeRequestResponse ?? await __privateMethod(_b = ky2, _Ky_instances, retry_fn).call(_b, async () => {
859
- var _a2;
860
- return __privateMethod(_a2 = ky2, _Ky_instances, fetch_fn).call(_a2);
861
- });
862
- let responseFromHook = beforeRequestResponse !== void 0 || __privateMethod(_c = ky2, _Ky_instances, consumeReturnedResponseFromBeforeRetryHook_fn).call(_c);
863
- for (; ; ) {
864
- if (response === void 0) {
865
- return response;
866
- }
867
- if (isResponseInstance(response)) {
868
- try {
869
- response = await __privateMethod(_d = ky2, _Ky_instances, runAfterResponseHooks_fn).call(_d, response);
870
- } catch (error) {
871
- if (!(error instanceof ForceRetryError)) {
872
- throw error;
873
- }
874
- const retriedResponse = await __privateMethod(_e = ky2, _Ky_instances, retryFromError_fn).call(_e, error, async () => {
875
- var _a2;
876
- return __privateMethod(_a2 = ky2, _Ky_instances, fetch_fn).call(_a2);
877
- });
878
- if (retriedResponse === void 0) {
879
- return retriedResponse;
880
- }
881
- response = retriedResponse;
882
- responseFromHook = __privateMethod(_f = ky2, _Ky_instances, consumeReturnedResponseFromBeforeRetryHook_fn).call(_f);
883
- continue;
884
- }
885
- }
886
- const currentResponse = response;
887
- if (!currentResponse.ok && currentResponse.type !== "opaque" && (typeof __privateGet(ky2, _options).throwHttpErrors === "function" ? __privateGet(ky2, _options).throwHttpErrors(currentResponse.status) : __privateGet(ky2, _options).throwHttpErrors)) {
888
- const httpError = new HTTPError(currentResponse, __privateMethod(_g = ky2, _Ky_instances, getResponseRequest_fn).call(_g, currentResponse), __privateMethod(_h = ky2, _Ky_instances, getNormalizedOptions_fn).call(_h));
889
- const errorToThrow = httpError;
890
- httpError.data = await __privateMethod(_i = ky2, _Ky_instances, getResponseData_fn).call(_i, currentResponse);
891
- if (responseFromHook) {
892
- throw errorToThrow;
893
- }
894
- const retriedResponse = await __privateMethod(_j = ky2, _Ky_instances, retryFromError_fn).call(_j, httpError, async () => {
895
- var _a2;
896
- return __privateMethod(_a2 = ky2, _Ky_instances, fetch_fn).call(_a2);
897
- });
898
- if (retriedResponse === void 0) {
899
- return retriedResponse;
900
- }
901
- response = retriedResponse;
902
- responseFromHook = __privateMethod(_k = ky2, _Ky_instances, consumeReturnedResponseFromBeforeRetryHook_fn).call(_k);
903
- continue;
904
- }
905
- break;
906
- }
907
- if (!isResponseInstance(response)) {
908
- return response;
909
- }
910
- __privateMethod(_l = ky2, _Ky_instances, decorateResponse_fn).call(_l, response);
911
- if (__privateGet(ky2, _options).onDownloadProgress) {
912
- if (typeof __privateGet(ky2, _options).onDownloadProgress !== "function") {
913
- throw new TypeError("The `onDownloadProgress` option must be a function");
914
- }
915
- if (!supportsResponseStreams) {
916
- throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
917
- }
918
- const progressResponse = response.clone();
919
- __privateMethod(_m = ky2, _Ky_instances, cancelResponseBody_fn).call(_m, response);
920
- return streamResponse(progressResponse, __privateGet(ky2, _options).onDownloadProgress);
921
- }
922
- return response;
923
- };
924
- const result = (async () => {
925
- var _a, _b, _c;
926
- try {
927
- return await function_();
928
- } catch (error) {
929
- if (!(error instanceof Error)) {
930
- throw error;
931
- }
932
- if (__privateGet(ky2, _beforeRetryHookErrors).has(error)) {
933
- throw error;
934
- }
935
- let processedError = error;
936
- for (const hook of __privateGet(ky2, _options).hooks.beforeError) {
937
- const hookResult = await hook({
938
- request: ky2.request,
939
- options: __privateMethod(_a = ky2, _Ky_instances, getNormalizedOptions_fn).call(_a),
940
- error: processedError,
941
- retryCount: __privateGet(ky2, _retryCount)
942
- });
943
- if (hookResult instanceof Error) {
944
- processedError = hookResult;
945
- }
946
- }
947
- throw processedError;
948
- } finally {
949
- const originalRequest = __privateGet(ky2, _originalRequest);
950
- __privateMethod(_b = ky2, _Ky_instances, cancelBody_fn).call(_b, originalRequest?.body ?? void 0);
951
- if (ky2.request !== originalRequest) {
952
- __privateMethod(_c = ky2, _Ky_instances, cancelBody_fn).call(_c, ky2.request.body ?? void 0);
953
- }
954
- }
955
- })();
956
- for (const [type, mimeType] of Object.entries(responseTypes)) {
957
- if (type === "bytes" && typeof globalThis.Response?.prototype?.bytes !== "function") {
958
- continue;
959
- }
960
- result[type] = async (schema) => {
961
- var _a;
962
- ky2.request.headers.set("accept", ky2.request.headers.get("accept") || mimeType);
963
- const response = await result;
964
- if (type !== "json") {
965
- return response[type]();
966
- }
967
- const text = await response.text();
968
- if (text === "") {
969
- if (schema !== void 0) {
970
- return validateJsonWithSchema(void 0, schema);
971
- }
972
- return JSON.parse(text);
973
- }
974
- const jsonValue = initHookOptions.parseJson ? await initHookOptions.parseJson(text, { request: __privateMethod(_a = ky2, _Ky_instances, getResponseRequest_fn).call(_a, response), response }) : JSON.parse(text);
975
- return schema === void 0 ? jsonValue : validateJsonWithSchema(jsonValue, schema);
976
- };
977
- }
978
- return result;
979
- }
980
- };
981
- _Ky_static = new WeakSet();
982
- normalizeSearchParams_fn = function(searchParams) {
983
- if (searchParams && typeof searchParams === "object" && !Array.isArray(searchParams) && !(searchParams instanceof URLSearchParams)) {
984
- return Object.fromEntries(Object.entries(searchParams).filter(([, value]) => value !== void 0));
985
- }
986
- return searchParams;
987
- };
988
- _abortController = new WeakMap();
989
- _retryCount = new WeakMap();
990
- _input = new WeakMap();
991
- _options = new WeakMap();
992
- _originalRequest = new WeakMap();
993
- _userProvidedAbortSignal = new WeakMap();
994
- _beforeRetryHookErrors = new WeakMap();
995
- _cachedNormalizedOptions = new WeakMap();
996
- _startTime = new WeakMap();
997
- _returnedResponseFromBeforeRetryHook = new WeakMap();
998
- _responseRequests = new WeakMap();
999
- _Ky_instances = new WeakSet();
1000
- calculateDelay_fn = function() {
1001
- const retryDelay = __privateGet(this, _options).retry.delay(__privateGet(this, _retryCount) + 1);
1002
- let jitteredDelay = retryDelay;
1003
- if (__privateGet(this, _options).retry.jitter === true) {
1004
- jitteredDelay = Math.random() * retryDelay;
1005
- } else if (typeof __privateGet(this, _options).retry.jitter === "function") {
1006
- jitteredDelay = __privateGet(this, _options).retry.jitter(retryDelay);
1007
- if (!Number.isFinite(jitteredDelay) || jitteredDelay < 0) {
1008
- jitteredDelay = retryDelay;
1009
- }
1010
- }
1011
- return Math.min(__privateGet(this, _options).retry.backoffLimit, jitteredDelay);
1012
- };
1013
- calculateRetryDelay_fn = async function(error) {
1014
- if (__privateGet(this, _retryCount) >= __privateGet(this, _options).retry.limit) {
1015
- throw error;
1016
- }
1017
- const errorObject = error instanceof Error ? error : new NonError(error);
1018
- if (errorObject instanceof ForceRetryError) {
1019
- return errorObject.customDelay ?? __privateMethod(this, _Ky_instances, calculateDelay_fn).call(this);
1020
- }
1021
- if (!__privateGet(this, _options).retry.methods.includes(this.request.method.toLowerCase())) {
1022
- throw error;
1023
- }
1024
- if (__privateGet(this, _options).retry.shouldRetry !== void 0) {
1025
- const result = await __privateGet(this, _options).retry.shouldRetry({ error: errorObject, retryCount: __privateGet(this, _retryCount) + 1 });
1026
- if (result === false) {
1027
- throw error;
1028
- }
1029
- if (result === true) {
1030
- return __privateMethod(this, _Ky_instances, calculateDelay_fn).call(this);
1031
- }
1032
- }
1033
- if (isTimeoutError(error)) {
1034
- if (!__privateGet(this, _options).retry.retryOnTimeout) {
1035
- throw error;
1036
- }
1037
- return __privateMethod(this, _Ky_instances, calculateDelay_fn).call(this);
1038
- }
1039
- if (isHTTPError(error)) {
1040
- if (!__privateGet(this, _options).retry.statusCodes.includes(error.response.status)) {
1041
- throw error;
1042
- }
1043
- const retryAfter = error.response.headers.get("Retry-After") ?? error.response.headers.get("RateLimit-Reset") ?? error.response.headers.get("X-RateLimit-Retry-After") ?? error.response.headers.get("X-RateLimit-Reset") ?? error.response.headers.get("X-Rate-Limit-Reset");
1044
- if (retryAfter && __privateGet(this, _options).retry.afterStatusCodes.includes(error.response.status)) {
1045
- let after = Number(retryAfter) * 1e3;
1046
- if (Number.isNaN(after)) {
1047
- after = Date.parse(retryAfter) - Date.now();
1048
- } else if (after >= Date.parse("2024-01-01")) {
1049
- after -= Date.now();
1050
- }
1051
- if (!Number.isFinite(after)) {
1052
- return Math.min(__privateGet(this, _options).retry.maxRetryAfter, __privateMethod(this, _Ky_instances, calculateDelay_fn).call(this));
1053
- }
1054
- after = Math.max(0, after);
1055
- return Math.min(__privateGet(this, _options).retry.maxRetryAfter, after);
1056
- }
1057
- if (error.response.status === 413) {
1058
- throw error;
1059
- }
1060
- return __privateMethod(this, _Ky_instances, calculateDelay_fn).call(this);
1061
- }
1062
- if (!isNetworkError(error)) {
1063
- throw error;
1064
- }
1065
- return __privateMethod(this, _Ky_instances, calculateDelay_fn).call(this);
1066
- };
1067
- decorateResponse_fn = function(response) {
1068
- const request = __privateMethod(this, _Ky_instances, getResponseRequest_fn).call(this, response);
1069
- if (__privateGet(this, _options).parseJson) {
1070
- response.json = async () => {
1071
- const text = await response.text();
1072
- if (text === "") {
1073
- return JSON.parse(text);
1074
- }
1075
- return __privateGet(this, _options).parseJson(text, { request, response });
1076
- };
1077
- }
1078
- return response;
1079
- };
1080
- getResponseData_fn = async function(response) {
1081
- const text = await __privateMethod(this, _Ky_instances, readResponseText_fn).call(this, response, __privateMethod(this, _Ky_instances, getErrorDataTimeout_fn).call(this));
1082
- if (text === timedOutResponseData) {
1083
- __privateMethod(this, _Ky_instances, throwIfTotalTimeoutExhausted_fn).call(this);
1084
- return void 0;
1085
- }
1086
- if (!text) {
1087
- return void 0;
1088
- }
1089
- if (!__privateMethod(this, _Ky_instances, isJsonContentType_fn).call(this, response.headers.get("content-type") ?? "")) {
1090
- return text;
1091
- }
1092
- const data = await __privateMethod(this, _Ky_instances, parseJson_fn).call(this, text, response, __privateMethod(this, _Ky_instances, getErrorDataTimeout_fn).call(this), __privateMethod(this, _Ky_instances, getResponseRequest_fn).call(this, response));
1093
- if (data === timedOutResponseData) {
1094
- __privateMethod(this, _Ky_instances, throwIfTotalTimeoutExhausted_fn).call(this);
1095
- return void 0;
1096
- }
1097
- return data;
1098
- };
1099
- getErrorDataTimeout_fn = function() {
1100
- const errorDataTimeout = __privateGet(this, _options).timeout === false ? 1e4 : __privateGet(this, _options).timeout;
1101
- const remainingTotal = __privateMethod(this, _Ky_instances, getRemainingTotalTimeout_fn).call(this);
1102
- if (remainingTotal === void 0) {
1103
- return errorDataTimeout;
1104
- }
1105
- if (remainingTotal <= 0) {
1106
- throw new TimeoutError(this.request);
1107
- }
1108
- return Math.min(errorDataTimeout, remainingTotal);
1109
- };
1110
- isJsonContentType_fn = function(contentType) {
1111
- const mimeType = (contentType.split(";", 1)[0] ?? "").trim().toLowerCase();
1112
- return /\/(?:.*[.+-])?json$/.test(mimeType);
1113
- };
1114
- readResponseText_fn = async function(response, timeoutMs) {
1115
- const { body } = response;
1116
- if (!body) {
1117
- try {
1118
- return await response.text();
1119
- } catch {
1120
- return void 0;
1121
- }
1122
- }
1123
- let reader;
1124
- try {
1125
- reader = body.getReader();
1126
- } catch {
1127
- return void 0;
1128
- }
1129
- const decoder = createTextDecoder(response.headers.get("content-type") ?? "");
1130
- const chunks = [];
1131
- let totalBytes = 0;
1132
- const readAll = (async () => {
1133
- try {
1134
- for (; ; ) {
1135
- const { done, value } = await reader.read();
1136
- if (done) {
1137
- break;
1138
- }
1139
- totalBytes += value.byteLength;
1140
- if (totalBytes > maxErrorResponseBodySize) {
1141
- void reader.cancel().catch(() => void 0);
1142
- return void 0;
1143
- }
1144
- chunks.push(decoder.decode(value, { stream: true }));
1145
- }
1146
- } catch {
1147
- return void 0;
1148
- }
1149
- chunks.push(decoder.decode());
1150
- return chunks.join("");
1151
- })();
1152
- const timeoutPromise = new Promise((resolve) => {
1153
- const timeoutId = setTimeout(() => {
1154
- resolve(timedOutResponseData);
1155
- }, timeoutMs);
1156
- void readAll.finally(() => {
1157
- clearTimeout(timeoutId);
1158
- });
1159
- });
1160
- const result = await Promise.race([readAll, timeoutPromise]);
1161
- if (result === timedOutResponseData) {
1162
- void reader.cancel().catch(() => void 0);
1163
- }
1164
- return result;
1165
- };
1166
- parseJson_fn = async function(text, response, timeoutMs, request) {
1167
- let timeoutId;
1168
- try {
1169
- return await Promise.race([
1170
- Promise.resolve().then(() => __privateGet(this, _options).parseJson ? __privateGet(this, _options).parseJson(text, { request, response }) : JSON.parse(text)),
1171
- new Promise((resolve) => {
1172
- timeoutId = setTimeout(() => {
1173
- resolve(timedOutResponseData);
1174
- }, timeoutMs);
1175
- })
1176
- ]);
1177
- } catch {
1178
- return void 0;
1179
- } finally {
1180
- clearTimeout(timeoutId);
1181
- }
1182
- };
1183
- cancelBody_fn = function(body) {
1184
- if (!body) {
1185
- return;
1186
- }
1187
- void body.cancel().catch(() => void 0);
1188
- };
1189
- cancelResponseBody_fn = function(response) {
1190
- __privateMethod(this, _Ky_instances, cancelBody_fn).call(this, response.body ?? void 0);
1191
- };
1192
- createManagedSignal_fn = function() {
1193
- return __privateGet(this, _userProvidedAbortSignal) ? AbortSignal.any([__privateGet(this, _userProvidedAbortSignal), __privateGet(this, _abortController).signal]) : __privateGet(this, _abortController).signal;
1194
- };
1195
- throwIfTotalTimeoutExhausted_fn = function() {
1196
- const remaining = __privateMethod(this, _Ky_instances, getRemainingTotalTimeout_fn).call(this);
1197
- if (remaining !== void 0 && remaining <= 0) {
1198
- throw new TimeoutError(this.request);
1199
- }
1200
- };
1201
- runBeforeRequestHooks_fn = async function() {
1202
- for (const hook of __privateGet(this, _options).hooks.beforeRequest) {
1203
- const result = await hook({
1204
- request: this.request,
1205
- options: __privateMethod(this, _Ky_instances, getNormalizedOptions_fn).call(this),
1206
- retryCount: 0
1207
- });
1208
- if (isRequestInstance(result)) {
1209
- __privateMethod(this, _Ky_instances, assignRequest_fn).call(this, result);
1210
- } else if (isResponseInstance(result)) {
1211
- return result;
1212
- }
1213
- }
1214
- return void 0;
1215
- };
1216
- runAfterResponseHooks_fn = async function(response) {
1217
- const responseRequest = __privateMethod(this, _Ky_instances, getResponseRequest_fn).call(this, response);
1218
- for (const hook of __privateGet(this, _options).hooks.afterResponse) {
1219
- const hookResponse = __privateMethod(this, _Ky_instances, setResponseRequest_fn).call(this, response.clone(), responseRequest);
1220
- __privateMethod(this, _Ky_instances, decorateResponse_fn).call(this, hookResponse);
1221
- let modifiedResponse;
1222
- try {
1223
- modifiedResponse = await hook({
1224
- request: this.request,
1225
- options: __privateMethod(this, _Ky_instances, getNormalizedOptions_fn).call(this),
1226
- response: hookResponse,
1227
- retryCount: __privateGet(this, _retryCount)
1228
- });
1229
- } catch (error) {
1230
- if (hookResponse !== response) {
1231
- __privateMethod(this, _Ky_instances, cancelResponseBody_fn).call(this, hookResponse);
1232
- }
1233
- __privateMethod(this, _Ky_instances, cancelResponseBody_fn).call(this, response);
1234
- throw error;
1235
- }
1236
- if (modifiedResponse instanceof RetryMarker) {
1237
- if (hookResponse !== response) {
1238
- __privateMethod(this, _Ky_instances, cancelResponseBody_fn).call(this, hookResponse);
1239
- }
1240
- __privateMethod(this, _Ky_instances, cancelResponseBody_fn).call(this, response);
1241
- throw new ForceRetryError(modifiedResponse.options);
1242
- }
1243
- const nextResponse = isResponseInstance(modifiedResponse) ? __privateMethod(this, _Ky_instances, setResponseRequest_fn).call(this, modifiedResponse, responseRequest) : response;
1244
- if (hookResponse !== response && hookResponse !== nextResponse && hookResponse.body !== nextResponse.body) {
1245
- __privateMethod(this, _Ky_instances, cancelResponseBody_fn).call(this, hookResponse);
1246
- }
1247
- if (response !== nextResponse && response.body !== nextResponse.body) {
1248
- __privateMethod(this, _Ky_instances, cancelResponseBody_fn).call(this, response);
1249
- }
1250
- response = nextResponse;
1251
- }
1252
- return response;
1253
- };
1254
- retry_fn = async function(function_) {
1255
- try {
1256
- return await function_();
1257
- } catch (error) {
1258
- return __privateMethod(this, _Ky_instances, retryFromError_fn).call(this, error, function_);
1259
- }
1260
- };
1261
- retryFromError_fn = async function(error, function_) {
1262
- __privateSet(this, _returnedResponseFromBeforeRetryHook, false);
1263
- const retryDelay = Math.min(await __privateMethod(this, _Ky_instances, calculateRetryDelay_fn).call(this, error), maxSafeTimeout);
1264
- const delayOptions = { signal: __privateGet(this, _userProvidedAbortSignal) };
1265
- const remainingTimeout = __privateMethod(this, _Ky_instances, getRemainingTotalTimeout_fn).call(this);
1266
- if (remainingTimeout !== void 0) {
1267
- if (remainingTimeout <= 0) {
1268
- throw new TimeoutError(this.request);
1269
- }
1270
- if (retryDelay >= remainingTimeout) {
1271
- await delay(remainingTimeout, delayOptions);
1272
- throw new TimeoutError(this.request);
1273
- }
1274
- }
1275
- await delay(retryDelay, delayOptions);
1276
- __privateMethod(this, _Ky_instances, throwIfTotalTimeoutExhausted_fn).call(this);
1277
- if (error instanceof ForceRetryError && error.customRequest) {
1278
- const customRequest = new globalThis.Request(error.customRequest, __privateGet(this, _options).signal ? { signal: __privateGet(this, _options).signal } : void 0);
1279
- __privateMethod(this, _Ky_instances, assignRequest_fn).call(this, customRequest);
1280
- }
1281
- for (const hook of __privateGet(this, _options).hooks.beforeRetry) {
1282
- let hookResult;
1283
- try {
1284
- hookResult = await hook({
1285
- request: this.request,
1286
- options: __privateMethod(this, _Ky_instances, getNormalizedOptions_fn).call(this),
1287
- error,
1288
- retryCount: __privateGet(this, _retryCount) + 1
1289
- });
1290
- } catch (hookError) {
1291
- if (hookError instanceof Error && hookError !== error) {
1292
- __privateGet(this, _beforeRetryHookErrors).add(hookError);
1293
- }
1294
- throw hookError;
1295
- }
1296
- if (isRequestInstance(hookResult)) {
1297
- __privateMethod(this, _Ky_instances, assignRequest_fn).call(this, hookResult);
1298
- break;
1299
- }
1300
- if (isResponseInstance(hookResult)) {
1301
- __privateSet(this, _returnedResponseFromBeforeRetryHook, true);
1302
- __privateWrapper(this, _retryCount)._++;
1303
- return hookResult;
1304
- }
1305
- if (hookResult === stop) {
1306
- return;
1307
- }
1308
- }
1309
- __privateMethod(this, _Ky_instances, throwIfTotalTimeoutExhausted_fn).call(this);
1310
- __privateWrapper(this, _retryCount)._++;
1311
- return __privateMethod(this, _Ky_instances, retry_fn).call(this, function_);
1312
- };
1313
- consumeReturnedResponseFromBeforeRetryHook_fn = function() {
1314
- const value = __privateGet(this, _returnedResponseFromBeforeRetryHook);
1315
- __privateSet(this, _returnedResponseFromBeforeRetryHook, false);
1316
- return value;
1317
- };
1318
- fetch_fn = async function() {
1319
- if (__privateGet(this, _abortController)?.signal.aborted) {
1320
- __privateSet(this, _abortController, new globalThis.AbortController());
1321
- __privateGet(this, _options).signal = __privateMethod(this, _Ky_instances, createManagedSignal_fn).call(this);
1322
- this.request = new globalThis.Request(this.request, { signal: __privateGet(this, _options).signal });
1323
- }
1324
- const nonRequestOptions = findUnknownOptions(__privateGet(this, _options));
1325
- const retryRequest = __privateGet(this, _options).retry.limit > 0 ? this.request.clone() : void 0;
1326
- const request = __privateMethod(this, _Ky_instances, wrapRequestWithUploadProgress_fn).call(this, this.request, __privateGet(this, _options).body ?? void 0);
1327
- __privateSet(this, _originalRequest, request);
1328
- if (retryRequest) {
1329
- this.request = retryRequest;
1330
- }
1331
- try {
1332
- const remainingTotal = __privateMethod(this, _Ky_instances, getRemainingTotalTimeout_fn).call(this);
1333
- if (remainingTotal !== void 0 && remainingTotal <= 0) {
1334
- throw new TimeoutError(this.request);
1335
- }
1336
- const effectiveTimeout = __privateGet(this, _options).timeout === false ? remainingTotal : remainingTotal === void 0 ? __privateGet(this, _options).timeout : Math.min(__privateGet(this, _options).timeout, remainingTotal);
1337
- const response = effectiveTimeout === void 0 ? await __privateGet(this, _options).fetch(request, nonRequestOptions) : await timeout(request, nonRequestOptions, __privateGet(this, _abortController), {
1338
- timeout: effectiveTimeout,
1339
- fetch: __privateGet(this, _options).fetch
1340
- });
1341
- return __privateMethod(this, _Ky_instances, setResponseRequest_fn).call(this, response, request);
1342
- } catch (error) {
1343
- if (isRawNetworkError(error)) {
1344
- throw new NetworkError(this.request, { cause: error });
1345
- }
1346
- throw error;
1347
- }
1348
- };
1349
- getRemainingTotalTimeout_fn = function() {
1350
- if (__privateGet(this, _startTime) === void 0) {
1351
- return void 0;
1352
- }
1353
- const elapsed = __privateMethod(this, _Ky_instances, getCurrentTime_fn).call(this) - __privateGet(this, _startTime);
1354
- return Math.max(0, __privateGet(this, _options).totalTimeout - elapsed);
1355
- };
1356
- getCurrentTime_fn = function() {
1357
- return globalThis.performance?.now() ?? Date.now();
1358
- };
1359
- getNormalizedOptions_fn = function() {
1360
- if (!__privateGet(this, _cachedNormalizedOptions)) {
1361
- const { hooks, json, parseJson, stringifyJson, searchParams, timeout: timeout2, totalTimeout, throwHttpErrors, fetch, ...normalizedOptions } = __privateGet(this, _options);
1362
- __privateSet(this, _cachedNormalizedOptions, Object.freeze(normalizedOptions));
1363
- }
1364
- return __privateGet(this, _cachedNormalizedOptions);
1365
- };
1366
- assignRequest_fn = function(request) {
1367
- __privateSet(this, _cachedNormalizedOptions, void 0);
1368
- this.request = request;
1369
- };
1370
- getResponseRequest_fn = function(response) {
1371
- return __privateGet(this, _responseRequests).get(response) ?? this.request;
1372
- };
1373
- setResponseRequest_fn = function(response, request) {
1374
- __privateGet(this, _responseRequests).set(response, request);
1375
- return response;
1376
- };
1377
- wrapRequestWithUploadProgress_fn = function(request, originalBody) {
1378
- if (!__privateGet(this, _options).onUploadProgress || !request.body || !supportsRequestStreams) {
1379
- return request;
1380
- }
1381
- return streamRequest(request, __privateGet(this, _options).onUploadProgress, originalBody ?? __privateGet(this, _options).body ?? void 0);
1382
- };
1383
- __privateAdd(_Ky, _Ky_static);
1384
- var Ky = _Ky;
1385
-
1386
- // ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/index.js
1387
- var createInstance = (defaults) => {
1388
- const ky2 = (input, options) => Ky.create(input, validateAndMerge(defaults, options));
1389
- for (const method of requestMethods) {
1390
- ky2[method] = (input, options) => Ky.create(input, validateAndMerge(defaults, options, { method }));
1391
- }
1392
- ky2.create = (newDefaults) => createInstance(validateAndMerge(newDefaults));
1393
- ky2.extend = (newDefaults) => {
1394
- if (typeof newDefaults === "function") {
1395
- newDefaults = newDefaults(defaults ?? {});
1396
- }
1397
- return createInstance(validateAndMerge(defaults, newDefaults));
1398
- };
1399
- ky2.stop = stop;
1400
- ky2.retry = retry;
1401
- return ky2;
1402
- };
1403
- var ky = createInstance();
1404
- var distribution_default = ky;
1405
-
1406
- // shell/.ojm-shim-ky.mjs
1407
- var ojm_shim_ky_default = distribution_default ?? distribution_exports;
1408
- export {
1409
- ForceRetryError,
1410
- HTTPError,
1411
- KyError,
1412
- NetworkError,
1413
- SchemaValidationError,
1414
- TimeoutError,
1415
- ojm_shim_ky_default as default,
1416
- isForceRetryError,
1417
- isHTTPError,
1418
- isKyError,
1419
- isNetworkError,
1420
- isTimeoutError,
1421
- replaceOption
1422
- };
1423
- /*! Bundled license information:
1424
-
1425
- ky/distribution/index.js:
1426
- (*! MIT License © Sindre Sorhus *)
1427
- */