ingeniuscliq-core 0.4.19 → 0.4.21
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.
- package/dist/components/common/carousel/CustomCarousel.d.ts +1 -1
- package/dist/components/common/carousel/CustomCarousel.d.ts.map +1 -1
- package/dist/components/common/carousel/CustomCarouselSection.d.ts +1 -1
- package/dist/components/common/carousel/CustomCarouselSection.d.ts.map +1 -1
- package/dist/components/common/form/FormCheckbox.d.ts +1 -1
- package/dist/components/common/form/FormCheckbox.d.ts.map +1 -1
- package/dist/components/common/form/FormInput.d.ts +1 -1
- package/dist/components/common/form/FormInput.d.ts.map +1 -1
- package/dist/components/common/form/FormSelect.d.ts +1 -1
- package/dist/components/common/form/FormSelect.d.ts.map +1 -1
- package/dist/components/common/form/FormTextArea.d.ts +1 -1
- package/dist/components/common/form/FormTextArea.d.ts.map +1 -1
- package/dist/components/common/form/FormWrapper.d.ts +1 -1
- package/dist/components/common/form/FormWrapper.d.ts.map +1 -1
- package/dist/components/common/logo/Logo.d.ts +1 -1
- package/dist/components/common/logo/Logo.d.ts.map +1 -1
- package/dist/components/common/pagination/CustomPagination.d.ts +1 -1
- package/dist/components/common/pagination/CustomPagination.d.ts.map +1 -1
- package/dist/components/common/select/CustomSelect.d.ts +1 -1
- package/dist/components/common/select/CustomSelect.d.ts.map +1 -1
- package/dist/components/common/spinner/Spinner.d.ts +1 -1
- package/dist/components/common/spinner/Spinner.d.ts.map +1 -1
- package/dist/components/common/stepper/Stepper.d.ts +1 -1
- package/dist/components/common/stepper/Stepper.d.ts.map +1 -1
- package/dist/components/common/stepper/Stepper.tsx +1 -1
- package/dist/components/layouts/CoreBaseLayout.d.ts +1 -1
- package/dist/components/layouts/CoreBaseLayout.d.ts.map +1 -1
- package/dist/components/templates/CoreHomeLayout.d.ts +1 -1
- package/dist/components/templates/CoreHomeLayout.d.ts.map +1 -1
- package/dist/components/templates/CorePreviewLayout.d.ts +1 -1
- package/dist/components/templates/CorePreviewLayout.d.ts.map +1 -1
- package/dist/components/ui/accordion.tsx +9 -9
- package/dist/components/ui/alert-dialog.d.ts +2 -2
- package/dist/components/ui/alert-dialog.tsx +16 -16
- package/dist/components/ui/alert.d.ts +3 -3
- package/dist/components/ui/alert.d.ts.map +1 -1
- package/dist/components/ui/alert.tsx +1 -1
- package/dist/components/ui/avatar.tsx +7 -7
- package/dist/components/ui/badge.d.ts +4 -4
- package/dist/components/ui/badge.d.ts.map +1 -1
- package/dist/components/ui/badge.tsx +1 -1
- package/dist/components/ui/breadcrumb.d.ts +2 -2
- package/dist/components/ui/breadcrumb.tsx +3 -4
- package/dist/components/ui/button.d.ts +4 -4
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.tsx +2 -2
- package/dist/components/ui/carousel.tsx +2 -3
- package/dist/components/ui/checkbox.tsx +5 -5
- package/dist/components/ui/dialog.d.ts +2 -2
- package/dist/components/ui/dialog.tsx +15 -15
- package/dist/components/ui/dropdown-menu.d.ts +1 -1
- package/dist/components/ui/dropdown-menu.tsx +27 -29
- package/dist/components/ui/form.d.ts +1 -1
- package/dist/components/ui/form.d.ts.map +1 -1
- package/dist/components/ui/form.tsx +2 -2
- package/dist/components/ui/label.d.ts +1 -1
- package/dist/components/ui/label.d.ts.map +1 -1
- package/dist/components/ui/label.tsx +4 -4
- package/dist/components/ui/pagination.d.ts +5 -5
- package/dist/components/ui/pagination.tsx +2 -4
- package/dist/components/ui/popover.tsx +7 -7
- package/dist/components/ui/radio-group.tsx +7 -7
- package/dist/components/ui/select.tsx +25 -27
- package/dist/components/ui/separator.tsx +3 -3
- package/dist/components/ui/sheet.d.ts +5 -5
- package/dist/components/ui/sheet.d.ts.map +1 -1
- package/dist/components/ui/sheet.tsx +16 -16
- package/dist/components/ui/skeleton.d.ts +1 -1
- package/dist/components/ui/skeleton.d.ts.map +1 -1
- package/dist/components/ui/slider.tsx +6 -6
- package/dist/components/ui/stepper.tsx +4 -4
- package/dist/components/ui/switch.tsx +4 -4
- package/dist/components/ui/tabs.tsx +9 -9
- package/dist/components/ui/tooltip.tsx +6 -6
- package/dist/helpers/axiosGlobal.js +1 -2
- package/dist/hooks/useLanguage.js +2 -5
- package/dist/hooks/useNotification.js +1 -1
- package/dist/i18n/config.js +1 -5
- package/dist/lib/utils.js +1 -1
- package/dist/modules/CoreAuth/classes/CoreAuthBuilder.d.ts +2 -2
- package/dist/modules/CoreAuth/classes/CoreAuthBuilder.js +1 -1
- package/dist/modules/CoreAuth/context/AuthContext.d.ts +2 -2
- package/dist/modules/CoreAuth/context/AuthContext.d.ts.map +1 -1
- package/dist/modules/CoreAuth/hooks/useAuth.d.ts +3 -3
- package/dist/modules/CoreAuth/index.js +1 -0
- package/dist/modules/CoreAuth/stores/authStore.d.ts +2 -2
- package/dist/modules/CoreCustomization/classes/CoreCustomizationBuilder.d.ts +8 -8
- package/dist/modules/CoreCustomization/classes/CoreCustomizationBuilder.d.ts.map +1 -1
- package/dist/modules/CoreCustomization/classes/CoreCustomizationBuilder.js +30 -16
- package/dist/modules/CoreCustomization/index.js +1 -0
- package/dist/modules/CoreOrder/classes/CoreOrderBuilder.d.ts.map +1 -1
- package/dist/modules/CoreOrder/classes/CoreOrderBuilder.js +15 -8
- package/dist/modules/CoreOrder/index.js +1 -0
- package/dist/modules/CorePayForm/classes/CorePayFormBuilder.d.ts +2 -2
- package/dist/modules/CorePayForm/classes/CorePayFormBuilder.d.ts.map +1 -1
- package/dist/modules/CorePayForm/classes/CorePayFormBuilder.js +15 -8
- package/dist/modules/CorePayForm/index.js +1 -0
- package/dist/modules/CoreProduct/classes/CoreProductBuilder.d.ts +8 -8
- package/dist/modules/CoreProduct/classes/CoreProductBuilder.d.ts.map +1 -1
- package/dist/modules/CoreProduct/classes/CoreProductBuilder.js +34 -13
- package/dist/modules/CoreProduct/index.js +1 -0
- package/dist/modules/CoreShipment/classes/CoreShipmentBuilder.d.ts +6 -6
- package/dist/modules/CoreShipment/classes/CoreShipmentBuilder.d.ts.map +1 -1
- package/dist/modules/CoreShipment/classes/CoreShipmentBuilder.js +34 -13
- package/dist/modules/CoreShipment/index.js +1 -0
- package/dist/modules/CoreShopCart/classes/CoreShopCartBuilder.d.ts +4 -4
- package/dist/modules/CoreShopCart/classes/CoreShopCartBuilder.d.ts.map +1 -1
- package/dist/modules/CoreShopCart/classes/CoreShopCartBuilder.js +12 -5
- package/package.json +21 -13
- package/src/commands/common/constants.js +10 -0
- package/src/commands/helpers/index.js +15 -0
- package/src/commands/helpers/strings.js +4 -0
- package/src/commands/templates/locale.js +14 -0
- package/src/commands/templates/service.js +12 -0
- package/src/commands/templates/type.js +10 -0
- package/README.md +0 -417
- package/dist/_virtual/index.js +0 -5
- package/dist/_virtual/index2.js +0 -3
- package/dist/_virtual/use-sync-external-store-shim.development.js +0 -3
- package/dist/_virtual/use-sync-external-store-shim.production.js +0 -3
- package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +0 -814
- package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +0 -751
- package/dist/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +0 -350
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +0 -161
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +0 -137
- package/dist/node_modules/@radix-ui/number/dist/index.js +0 -6
- package/dist/node_modules/@radix-ui/primitive/dist/index.js +0 -11
- package/dist/node_modules/@radix-ui/react-accordion/dist/index.js +0 -305
- package/dist/node_modules/@radix-ui/react-alert-dialog/dist/index.js +0 -147
- package/dist/node_modules/@radix-ui/react-arrow/dist/index.js +0 -25
- package/dist/node_modules/@radix-ui/react-avatar/dist/index.js +0 -118
- package/dist/node_modules/@radix-ui/react-checkbox/dist/index.js +0 -270
- package/dist/node_modules/@radix-ui/react-collapsible/dist/index.js +0 -145
- package/dist/node_modules/@radix-ui/react-collection/dist/index.js +0 -70
- package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.js +0 -39
- package/dist/node_modules/@radix-ui/react-context/dist/index.js +0 -79
- package/dist/node_modules/@radix-ui/react-dialog/dist/index.js +0 -321
- package/dist/node_modules/@radix-ui/react-direction/dist/index.js +0 -11
- package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +0 -211
- package/dist/node_modules/@radix-ui/react-dropdown-menu/dist/index.js +0 -267
- package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.js +0 -29
- package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.js +0 -207
- package/dist/node_modules/@radix-ui/react-id/dist/index.js +0 -15
- package/dist/node_modules/@radix-ui/react-label/dist/index.js +0 -24
- package/dist/node_modules/@radix-ui/react-menu/dist/index.js +0 -834
- package/dist/node_modules/@radix-ui/react-popover/dist/index.js +0 -299
- package/dist/node_modules/@radix-ui/react-popper/dist/index.js +0 -283
- package/dist/node_modules/@radix-ui/react-portal/dist/index.js +0 -17
- package/dist/node_modules/@radix-ui/react-presence/dist/index.js +0 -130
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.js +0 -43
- package/dist/node_modules/@radix-ui/react-radio-group/dist/index.js +0 -282
- package/dist/node_modules/@radix-ui/react-roving-focus/dist/index.js +0 -223
- package/dist/node_modules/@radix-ui/react-select/dist/index.js +0 -1156
- package/dist/node_modules/@radix-ui/react-separator/dist/index.js +0 -30
- package/dist/node_modules/@radix-ui/react-slider/dist/index.js +0 -554
- package/dist/node_modules/@radix-ui/react-slot/dist/index.js +0 -99
- package/dist/node_modules/@radix-ui/react-switch/dist/index.js +0 -152
- package/dist/node_modules/@radix-ui/react-tabs/dist/index.js +0 -187
- package/dist/node_modules/@radix-ui/react-tooltip/dist/index.js +0 -482
- package/dist/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +0 -12
- package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +0 -70
- package/dist/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +0 -18
- package/dist/node_modules/@radix-ui/react-use-is-hydrated/dist/index.js +0 -16
- package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +0 -7
- package/dist/node_modules/@radix-ui/react-use-previous/dist/index.js +0 -15
- package/dist/node_modules/@radix-ui/react-use-size/dist/index.js +0 -40
- package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.js +0 -35
- package/dist/node_modules/@stepperize/core/dist/index.js +0 -3
- package/dist/node_modules/@stepperize/react/dist/index.js +0 -6
- package/dist/node_modules/aria-hidden/dist/es2015/index.js +0 -137
- package/dist/node_modules/axios/index.js +0 -25
- package/dist/node_modules/axios/lib/adapters/adapters.js +0 -81
- package/dist/node_modules/axios/lib/adapters/fetch.js +0 -229
- package/dist/node_modules/axios/lib/adapters/xhr.js +0 -199
- package/dist/node_modules/axios/lib/axios.js +0 -86
- package/dist/node_modules/axios/lib/cancel/CancelToken.js +0 -133
- package/dist/node_modules/axios/lib/cancel/CanceledError.js +0 -23
- package/dist/node_modules/axios/lib/cancel/isCancel.js +0 -5
- package/dist/node_modules/axios/lib/core/Axios.js +0 -238
- package/dist/node_modules/axios/lib/core/AxiosError.js +0 -101
- package/dist/node_modules/axios/lib/core/AxiosHeaders.js +0 -312
- package/dist/node_modules/axios/lib/core/InterceptorManager.js +0 -69
- package/dist/node_modules/axios/lib/core/buildFullPath.js +0 -22
- package/dist/node_modules/axios/lib/core/dispatchRequest.js +0 -81
- package/dist/node_modules/axios/lib/core/mergeConfig.js +0 -106
- package/dist/node_modules/axios/lib/core/settle.js +0 -27
- package/dist/node_modules/axios/lib/core/transformData.js +0 -28
- package/dist/node_modules/axios/lib/defaults/index.js +0 -159
- package/dist/node_modules/axios/lib/defaults/transitional.js +0 -7
- package/dist/node_modules/axios/lib/env/data.js +0 -3
- package/dist/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +0 -56
- package/dist/node_modules/axios/lib/helpers/HttpStatusCode.js +0 -71
- package/dist/node_modules/axios/lib/helpers/bind.js +0 -7
- package/dist/node_modules/axios/lib/helpers/buildURL.js +0 -69
- package/dist/node_modules/axios/lib/helpers/combineURLs.js +0 -15
- package/dist/node_modules/axios/lib/helpers/composeSignals.js +0 -48
- package/dist/node_modules/axios/lib/helpers/cookies.js +0 -43
- package/dist/node_modules/axios/lib/helpers/formDataToJSON.js +0 -93
- package/dist/node_modules/axios/lib/helpers/isAbsoluteURL.js +0 -15
- package/dist/node_modules/axios/lib/helpers/isAxiosError.js +0 -14
- package/dist/node_modules/axios/lib/helpers/isURLSameOrigin.js +0 -16
- package/dist/node_modules/axios/lib/helpers/null.js +0 -4
- package/dist/node_modules/axios/lib/helpers/parseHeaders.js +0 -55
- package/dist/node_modules/axios/lib/helpers/parseProtocol.js +0 -6
- package/dist/node_modules/axios/lib/helpers/progressEventReducer.js +0 -46
- package/dist/node_modules/axios/lib/helpers/resolveConfig.js +0 -58
- package/dist/node_modules/axios/lib/helpers/speedometer.js +0 -53
- package/dist/node_modules/axios/lib/helpers/spread.js +0 -28
- package/dist/node_modules/axios/lib/helpers/throttle.js +0 -44
- package/dist/node_modules/axios/lib/helpers/toFormData.js +0 -219
- package/dist/node_modules/axios/lib/helpers/toURLEncodedForm.js +0 -19
- package/dist/node_modules/axios/lib/helpers/trackStream.js +0 -88
- package/dist/node_modules/axios/lib/helpers/validator.js +0 -99
- package/dist/node_modules/axios/lib/platform/browser/classes/Blob.js +0 -3
- package/dist/node_modules/axios/lib/platform/browser/classes/FormData.js +0 -3
- package/dist/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +0 -5
- package/dist/node_modules/axios/lib/platform/browser/index.js +0 -15
- package/dist/node_modules/axios/lib/platform/common/utils.js +0 -45
- package/dist/node_modules/axios/lib/platform/index.js +0 -9
- package/dist/node_modules/axios/lib/utils.js +0 -780
- package/dist/node_modules/class-variance-authority/dist/index.js +0 -44
- package/dist/node_modules/clsx/dist/clsx.js +0 -3
- package/dist/node_modules/embla-carousel/esm/embla-carousel.esm.js +0 -1669
- package/dist/node_modules/embla-carousel-react/esm/embla-carousel-react.esm.js +0 -37
- package/dist/node_modules/embla-carousel-reactive-utils/esm/embla-carousel-reactive-utils.esm.js +0 -38
- package/dist/node_modules/get-nonce/dist/es2015/index.js +0 -8
- package/dist/node_modules/lucide-react/dist/esm/Icon.js +0 -43
- package/dist/node_modules/lucide-react/dist/esm/createLucideIcon.js +0 -30
- package/dist/node_modules/lucide-react/dist/esm/defaultAttributes.js +0 -20
- package/dist/node_modules/lucide-react/dist/esm/icons/arrow-left.js +0 -17
- package/dist/node_modules/lucide-react/dist/esm/icons/arrow-right.js +0 -17
- package/dist/node_modules/lucide-react/dist/esm/icons/check.js +0 -14
- package/dist/node_modules/lucide-react/dist/esm/icons/chevron-down.js +0 -14
- package/dist/node_modules/lucide-react/dist/esm/icons/chevron-left.js +0 -14
- package/dist/node_modules/lucide-react/dist/esm/icons/chevron-right.js +0 -14
- package/dist/node_modules/lucide-react/dist/esm/icons/chevron-up.js +0 -14
- package/dist/node_modules/lucide-react/dist/esm/icons/circle.js +0 -14
- package/dist/node_modules/lucide-react/dist/esm/icons/ellipsis.js +0 -18
- package/dist/node_modules/lucide-react/dist/esm/icons/x.js +0 -17
- package/dist/node_modules/lucide-react/dist/esm/shared/src/utils.js +0 -28
- package/dist/node_modules/react-hook-form/dist/index.esm.js +0 -560
- package/dist/node_modules/react-i18next/dist/es/IcuTransUtils/htmlEntityDecoder.js +0 -210
- package/dist/node_modules/react-i18next/dist/es/context.js +0 -18
- package/dist/node_modules/react-i18next/dist/es/defaults.js +0 -22
- package/dist/node_modules/react-i18next/dist/es/i18nInstance.js +0 -7
- package/dist/node_modules/react-i18next/dist/es/initReactI18next.js +0 -12
- package/dist/node_modules/react-i18next/dist/es/unescape.js +0 -27
- package/dist/node_modules/react-i18next/dist/es/useTranslation.js +0 -157
- package/dist/node_modules/react-i18next/dist/es/utils.js +0 -63
- package/dist/node_modules/react-remove-scroll/dist/es2015/Combination.js +0 -9
- package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +0 -167
- package/dist/node_modules/react-remove-scroll/dist/es2015/UI.js +0 -38
- package/dist/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +0 -21
- package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +0 -110
- package/dist/node_modules/react-remove-scroll/dist/es2015/medium.js +0 -5
- package/dist/node_modules/react-remove-scroll/dist/es2015/sidecar.js +0 -7
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/component.js +0 -56
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +0 -10
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +0 -31
- package/dist/node_modules/react-style-singleton/dist/es2015/component.js +0 -19
- package/dist/node_modules/react-style-singleton/dist/es2015/hook.js +0 -25
- package/dist/node_modules/react-style-singleton/dist/es2015/singleton.js +0 -51
- package/dist/node_modules/sonner/dist/index.js +0 -299
- package/dist/node_modules/tslib/tslib.es6.js +0 -56
- package/dist/node_modules/use-callback-ref/dist/es2015/assignRef.js +0 -24
- package/dist/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +0 -48
- package/dist/node_modules/use-callback-ref/dist/es2015/useRef.js +0 -42
- package/dist/node_modules/use-sidecar/dist/es2015/exports.js +0 -21
- package/dist/node_modules/use-sidecar/dist/es2015/medium.js +0 -77
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +0 -106
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +0 -77
- package/dist/node_modules/use-sync-external-store/shim/index.js +0 -19
- package/dist/node_modules/zustand/esm/react.js +0 -22
- package/dist/node_modules/zustand/esm/vanilla.js +0 -24
- /package/src/{core/commands → commands}/create-core-module.js +0 -0
- /package/src/{core/commands → commands}/create-module.js +0 -0
- /package/src/{core/commands → commands}/create-template.js +0 -0
- /package/src/{core/commands → commands}/rollback-core-module.js +0 -0
- /package/src/{core/commands → commands}/rollback-module.js +0 -0
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import utils from '../utils.js';
|
|
2
|
-
|
|
3
|
-
// RawAxiosHeaders whose duplicates are ignored by node
|
|
4
|
-
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
5
|
-
const ignoreDuplicateOf = utils.toObjectSet([
|
|
6
|
-
'age', 'authorization', 'content-length', 'content-type', 'etag',
|
|
7
|
-
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
|
|
8
|
-
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
|
|
9
|
-
'referer', 'retry-after', 'user-agent'
|
|
10
|
-
]);
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Parse headers into an object
|
|
14
|
-
*
|
|
15
|
-
* ```
|
|
16
|
-
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
|
17
|
-
* Content-Type: application/json
|
|
18
|
-
* Connection: keep-alive
|
|
19
|
-
* Transfer-Encoding: chunked
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* @param {String} rawHeaders Headers needing to be parsed
|
|
23
|
-
*
|
|
24
|
-
* @returns {Object} Headers parsed into an object
|
|
25
|
-
*/
|
|
26
|
-
const parseHeaders = rawHeaders => {
|
|
27
|
-
const parsed = {};
|
|
28
|
-
let key;
|
|
29
|
-
let val;
|
|
30
|
-
let i;
|
|
31
|
-
|
|
32
|
-
rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
|
|
33
|
-
i = line.indexOf(':');
|
|
34
|
-
key = line.substring(0, i).trim().toLowerCase();
|
|
35
|
-
val = line.substring(i + 1).trim();
|
|
36
|
-
|
|
37
|
-
if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (key === 'set-cookie') {
|
|
42
|
-
if (parsed[key]) {
|
|
43
|
-
parsed[key].push(val);
|
|
44
|
-
} else {
|
|
45
|
-
parsed[key] = [val];
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
return parsed;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export { parseHeaders as default };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import speedometer from './speedometer.js';
|
|
2
|
-
import throttle from './throttle.js';
|
|
3
|
-
import utils from '../utils.js';
|
|
4
|
-
|
|
5
|
-
const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
6
|
-
let bytesNotified = 0;
|
|
7
|
-
const _speedometer = speedometer(50, 250);
|
|
8
|
-
|
|
9
|
-
return throttle(e => {
|
|
10
|
-
const loaded = e.loaded;
|
|
11
|
-
const total = e.lengthComputable ? e.total : undefined;
|
|
12
|
-
const progressBytes = loaded - bytesNotified;
|
|
13
|
-
const rate = _speedometer(progressBytes);
|
|
14
|
-
const inRange = loaded <= total;
|
|
15
|
-
|
|
16
|
-
bytesNotified = loaded;
|
|
17
|
-
|
|
18
|
-
const data = {
|
|
19
|
-
loaded,
|
|
20
|
-
total,
|
|
21
|
-
progress: total ? (loaded / total) : undefined,
|
|
22
|
-
bytes: progressBytes,
|
|
23
|
-
rate: rate ? rate : undefined,
|
|
24
|
-
estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
|
|
25
|
-
event: e,
|
|
26
|
-
lengthComputable: total != null,
|
|
27
|
-
[isDownloadStream ? 'download' : 'upload']: true
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
listener(data);
|
|
31
|
-
}, freq);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const progressEventDecorator = (total, throttled) => {
|
|
35
|
-
const lengthComputable = total != null;
|
|
36
|
-
|
|
37
|
-
return [(loaded) => throttled[0]({
|
|
38
|
-
lengthComputable,
|
|
39
|
-
total,
|
|
40
|
-
loaded
|
|
41
|
-
}), throttled[1]];
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const asyncDecorator = (fn) => (...args) => utils.asap(() => fn(...args));
|
|
45
|
-
|
|
46
|
-
export { asyncDecorator, progressEventDecorator, progressEventReducer };
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import platform from '../platform/index.js';
|
|
2
|
-
import utils from '../utils.js';
|
|
3
|
-
import isURLSameOrigin from './isURLSameOrigin.js';
|
|
4
|
-
import cookies from './cookies.js';
|
|
5
|
-
import buildFullPath from '../core/buildFullPath.js';
|
|
6
|
-
import mergeConfig from '../core/mergeConfig.js';
|
|
7
|
-
import AxiosHeaders from '../core/AxiosHeaders.js';
|
|
8
|
-
import buildURL from './buildURL.js';
|
|
9
|
-
|
|
10
|
-
const resolveConfig = (config) => {
|
|
11
|
-
const newConfig = mergeConfig({}, config);
|
|
12
|
-
|
|
13
|
-
let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
|
|
14
|
-
|
|
15
|
-
newConfig.headers = headers = AxiosHeaders.from(headers);
|
|
16
|
-
|
|
17
|
-
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
|
|
18
|
-
|
|
19
|
-
// HTTP basic authentication
|
|
20
|
-
if (auth) {
|
|
21
|
-
headers.set('Authorization', 'Basic ' +
|
|
22
|
-
btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
let contentType;
|
|
27
|
-
|
|
28
|
-
if (utils.isFormData(data)) {
|
|
29
|
-
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
30
|
-
headers.setContentType(undefined); // Let the browser set it
|
|
31
|
-
} else if ((contentType = headers.getContentType()) !== false) {
|
|
32
|
-
// fix semicolon duplication issue for ReactNative FormData implementation
|
|
33
|
-
const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
|
|
34
|
-
headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Add xsrf header
|
|
39
|
-
// This is only done if running in a standard browser environment.
|
|
40
|
-
// Specifically not if we're in a web worker, or react-native.
|
|
41
|
-
|
|
42
|
-
if (platform.hasStandardBrowserEnv) {
|
|
43
|
-
withXSRFToken && utils.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
|
|
44
|
-
|
|
45
|
-
if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
|
|
46
|
-
// Add xsrf header
|
|
47
|
-
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
48
|
-
|
|
49
|
-
if (xsrfValue) {
|
|
50
|
-
headers.set(xsrfHeaderName, xsrfValue);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return newConfig;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export { resolveConfig as default };
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Calculate data maxRate
|
|
3
|
-
* @param {Number} [samplesCount= 10]
|
|
4
|
-
* @param {Number} [min= 1000]
|
|
5
|
-
* @returns {Function}
|
|
6
|
-
*/
|
|
7
|
-
function speedometer(samplesCount, min) {
|
|
8
|
-
samplesCount = samplesCount || 10;
|
|
9
|
-
const bytes = new Array(samplesCount);
|
|
10
|
-
const timestamps = new Array(samplesCount);
|
|
11
|
-
let head = 0;
|
|
12
|
-
let tail = 0;
|
|
13
|
-
let firstSampleTS;
|
|
14
|
-
|
|
15
|
-
min = min !== undefined ? min : 1000;
|
|
16
|
-
|
|
17
|
-
return function push(chunkLength) {
|
|
18
|
-
const now = Date.now();
|
|
19
|
-
|
|
20
|
-
const startedAt = timestamps[tail];
|
|
21
|
-
|
|
22
|
-
if (!firstSampleTS) {
|
|
23
|
-
firstSampleTS = now;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
bytes[head] = chunkLength;
|
|
27
|
-
timestamps[head] = now;
|
|
28
|
-
|
|
29
|
-
let i = tail;
|
|
30
|
-
let bytesCount = 0;
|
|
31
|
-
|
|
32
|
-
while (i !== head) {
|
|
33
|
-
bytesCount += bytes[i++];
|
|
34
|
-
i = i % samplesCount;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
head = (head + 1) % samplesCount;
|
|
38
|
-
|
|
39
|
-
if (head === tail) {
|
|
40
|
-
tail = (tail + 1) % samplesCount;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (now - firstSampleTS < min) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const passed = startedAt && now - startedAt;
|
|
48
|
-
|
|
49
|
-
return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export { speedometer as default };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Syntactic sugar for invoking a function and expanding an array for arguments.
|
|
3
|
-
*
|
|
4
|
-
* Common use case would be to use `Function.prototype.apply`.
|
|
5
|
-
*
|
|
6
|
-
* ```js
|
|
7
|
-
* function f(x, y, z) {}
|
|
8
|
-
* var args = [1, 2, 3];
|
|
9
|
-
* f.apply(null, args);
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* With `spread` this example can be re-written.
|
|
13
|
-
*
|
|
14
|
-
* ```js
|
|
15
|
-
* spread(function(x, y, z) {})([1, 2, 3]);
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @param {Function} callback
|
|
19
|
-
*
|
|
20
|
-
* @returns {Function}
|
|
21
|
-
*/
|
|
22
|
-
function spread(callback) {
|
|
23
|
-
return function wrap(arr) {
|
|
24
|
-
return callback.apply(null, arr);
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { spread as default };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Throttle decorator
|
|
3
|
-
* @param {Function} fn
|
|
4
|
-
* @param {Number} freq
|
|
5
|
-
* @return {Function}
|
|
6
|
-
*/
|
|
7
|
-
function throttle(fn, freq) {
|
|
8
|
-
let timestamp = 0;
|
|
9
|
-
let threshold = 1000 / freq;
|
|
10
|
-
let lastArgs;
|
|
11
|
-
let timer;
|
|
12
|
-
|
|
13
|
-
const invoke = (args, now = Date.now()) => {
|
|
14
|
-
timestamp = now;
|
|
15
|
-
lastArgs = null;
|
|
16
|
-
if (timer) {
|
|
17
|
-
clearTimeout(timer);
|
|
18
|
-
timer = null;
|
|
19
|
-
}
|
|
20
|
-
fn(...args);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const throttled = (...args) => {
|
|
24
|
-
const now = Date.now();
|
|
25
|
-
const passed = now - timestamp;
|
|
26
|
-
if ( passed >= threshold) {
|
|
27
|
-
invoke(args, now);
|
|
28
|
-
} else {
|
|
29
|
-
lastArgs = args;
|
|
30
|
-
if (!timer) {
|
|
31
|
-
timer = setTimeout(() => {
|
|
32
|
-
timer = null;
|
|
33
|
-
invoke(lastArgs);
|
|
34
|
-
}, threshold - passed);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const flush = () => lastArgs && invoke(lastArgs);
|
|
40
|
-
|
|
41
|
-
return [throttled, flush];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { throttle as default };
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import utils from '../utils.js';
|
|
2
|
-
import AxiosError from '../core/AxiosError.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Determines if the given thing is a array or js object.
|
|
6
|
-
*
|
|
7
|
-
* @param {string} thing - The object or array to be visited.
|
|
8
|
-
*
|
|
9
|
-
* @returns {boolean}
|
|
10
|
-
*/
|
|
11
|
-
function isVisitable(thing) {
|
|
12
|
-
return utils.isPlainObject(thing) || utils.isArray(thing);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* It removes the brackets from the end of a string
|
|
17
|
-
*
|
|
18
|
-
* @param {string} key - The key of the parameter.
|
|
19
|
-
*
|
|
20
|
-
* @returns {string} the key without the brackets.
|
|
21
|
-
*/
|
|
22
|
-
function removeBrackets(key) {
|
|
23
|
-
return utils.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* It takes a path, a key, and a boolean, and returns a string
|
|
28
|
-
*
|
|
29
|
-
* @param {string} path - The path to the current key.
|
|
30
|
-
* @param {string} key - The key of the current object being iterated over.
|
|
31
|
-
* @param {string} dots - If true, the key will be rendered with dots instead of brackets.
|
|
32
|
-
*
|
|
33
|
-
* @returns {string} The path to the current key.
|
|
34
|
-
*/
|
|
35
|
-
function renderKey(path, key, dots) {
|
|
36
|
-
if (!path) return key;
|
|
37
|
-
return path.concat(key).map(function each(token, i) {
|
|
38
|
-
// eslint-disable-next-line no-param-reassign
|
|
39
|
-
token = removeBrackets(token);
|
|
40
|
-
return !dots && i ? '[' + token + ']' : token;
|
|
41
|
-
}).join(dots ? '.' : '');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* If the array is an array and none of its elements are visitable, then it's a flat array.
|
|
46
|
-
*
|
|
47
|
-
* @param {Array<any>} arr - The array to check
|
|
48
|
-
*
|
|
49
|
-
* @returns {boolean}
|
|
50
|
-
*/
|
|
51
|
-
function isFlatArray(arr) {
|
|
52
|
-
return utils.isArray(arr) && !arr.some(isVisitable);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
|
|
56
|
-
return /^is[A-Z]/.test(prop);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Convert a data object to FormData
|
|
61
|
-
*
|
|
62
|
-
* @param {Object} obj
|
|
63
|
-
* @param {?Object} [formData]
|
|
64
|
-
* @param {?Object} [options]
|
|
65
|
-
* @param {Function} [options.visitor]
|
|
66
|
-
* @param {Boolean} [options.metaTokens = true]
|
|
67
|
-
* @param {Boolean} [options.dots = false]
|
|
68
|
-
* @param {?Boolean} [options.indexes = false]
|
|
69
|
-
*
|
|
70
|
-
* @returns {Object}
|
|
71
|
-
**/
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* It converts an object into a FormData object
|
|
75
|
-
*
|
|
76
|
-
* @param {Object<any, any>} obj - The object to convert to form data.
|
|
77
|
-
* @param {string} formData - The FormData object to append to.
|
|
78
|
-
* @param {Object<string, any>} options
|
|
79
|
-
*
|
|
80
|
-
* @returns
|
|
81
|
-
*/
|
|
82
|
-
function toFormData(obj, formData, options) {
|
|
83
|
-
if (!utils.isObject(obj)) {
|
|
84
|
-
throw new TypeError('target must be an object');
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// eslint-disable-next-line no-param-reassign
|
|
88
|
-
formData = formData || new (FormData)();
|
|
89
|
-
|
|
90
|
-
// eslint-disable-next-line no-param-reassign
|
|
91
|
-
options = utils.toFlatObject(options, {
|
|
92
|
-
metaTokens: true,
|
|
93
|
-
dots: false,
|
|
94
|
-
indexes: false
|
|
95
|
-
}, false, function defined(option, source) {
|
|
96
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
97
|
-
return !utils.isUndefined(source[option]);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
const metaTokens = options.metaTokens;
|
|
101
|
-
// eslint-disable-next-line no-use-before-define
|
|
102
|
-
const visitor = options.visitor || defaultVisitor;
|
|
103
|
-
const dots = options.dots;
|
|
104
|
-
const indexes = options.indexes;
|
|
105
|
-
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
|
106
|
-
const useBlob = _Blob && utils.isSpecCompliantForm(formData);
|
|
107
|
-
|
|
108
|
-
if (!utils.isFunction(visitor)) {
|
|
109
|
-
throw new TypeError('visitor must be a function');
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function convertValue(value) {
|
|
113
|
-
if (value === null) return '';
|
|
114
|
-
|
|
115
|
-
if (utils.isDate(value)) {
|
|
116
|
-
return value.toISOString();
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (utils.isBoolean(value)) {
|
|
120
|
-
return value.toString();
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (!useBlob && utils.isBlob(value)) {
|
|
124
|
-
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
|
|
128
|
-
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return value;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Default visitor.
|
|
136
|
-
*
|
|
137
|
-
* @param {*} value
|
|
138
|
-
* @param {String|Number} key
|
|
139
|
-
* @param {Array<String|Number>} path
|
|
140
|
-
* @this {FormData}
|
|
141
|
-
*
|
|
142
|
-
* @returns {boolean} return true to visit the each prop of the value recursively
|
|
143
|
-
*/
|
|
144
|
-
function defaultVisitor(value, key, path) {
|
|
145
|
-
let arr = value;
|
|
146
|
-
|
|
147
|
-
if (value && !path && typeof value === 'object') {
|
|
148
|
-
if (utils.endsWith(key, '{}')) {
|
|
149
|
-
// eslint-disable-next-line no-param-reassign
|
|
150
|
-
key = metaTokens ? key : key.slice(0, -2);
|
|
151
|
-
// eslint-disable-next-line no-param-reassign
|
|
152
|
-
value = JSON.stringify(value);
|
|
153
|
-
} else if (
|
|
154
|
-
(utils.isArray(value) && isFlatArray(value)) ||
|
|
155
|
-
((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))
|
|
156
|
-
)) {
|
|
157
|
-
// eslint-disable-next-line no-param-reassign
|
|
158
|
-
key = removeBrackets(key);
|
|
159
|
-
|
|
160
|
-
arr.forEach(function each(el, index) {
|
|
161
|
-
!(utils.isUndefined(el) || el === null) && formData.append(
|
|
162
|
-
// eslint-disable-next-line no-nested-ternary
|
|
163
|
-
indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
|
|
164
|
-
convertValue(el)
|
|
165
|
-
);
|
|
166
|
-
});
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (isVisitable(value)) {
|
|
172
|
-
return true;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
176
|
-
|
|
177
|
-
return false;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const stack = [];
|
|
181
|
-
|
|
182
|
-
const exposedHelpers = Object.assign(predicates, {
|
|
183
|
-
defaultVisitor,
|
|
184
|
-
convertValue,
|
|
185
|
-
isVisitable
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
function build(value, path) {
|
|
189
|
-
if (utils.isUndefined(value)) return;
|
|
190
|
-
|
|
191
|
-
if (stack.indexOf(value) !== -1) {
|
|
192
|
-
throw Error('Circular reference detected in ' + path.join('.'));
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
stack.push(value);
|
|
196
|
-
|
|
197
|
-
utils.forEach(value, function each(el, key) {
|
|
198
|
-
const result = !(utils.isUndefined(el) || el === null) && visitor.call(
|
|
199
|
-
formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
if (result === true) {
|
|
203
|
-
build(el, path ? path.concat(key) : [key]);
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
stack.pop();
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (!utils.isObject(obj)) {
|
|
211
|
-
throw new TypeError('data must be an object');
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
build(obj);
|
|
215
|
-
|
|
216
|
-
return formData;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
export { toFormData as default };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import utils from '../utils.js';
|
|
2
|
-
import toFormData from './toFormData.js';
|
|
3
|
-
import platform from '../platform/index.js';
|
|
4
|
-
|
|
5
|
-
function toURLEncodedForm(data, options) {
|
|
6
|
-
return toFormData(data, new platform.classes.URLSearchParams(), {
|
|
7
|
-
visitor: function(value, key, path, helpers) {
|
|
8
|
-
if (platform.isNode && utils.isBuffer(value)) {
|
|
9
|
-
this.append(key, value.toString('base64'));
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return helpers.defaultVisitor.apply(this, arguments);
|
|
14
|
-
},
|
|
15
|
-
...options
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export { toURLEncodedForm as default };
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
const streamChunk = function* (chunk, chunkSize) {
|
|
2
|
-
let len = chunk.byteLength;
|
|
3
|
-
|
|
4
|
-
if (len < chunkSize) {
|
|
5
|
-
yield chunk;
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
let pos = 0;
|
|
10
|
-
let end;
|
|
11
|
-
|
|
12
|
-
while (pos < len) {
|
|
13
|
-
end = pos + chunkSize;
|
|
14
|
-
yield chunk.slice(pos, end);
|
|
15
|
-
pos = end;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const readBytes = async function* (iterable, chunkSize) {
|
|
20
|
-
for await (const chunk of readStream(iterable)) {
|
|
21
|
-
yield* streamChunk(chunk, chunkSize);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const readStream = async function* (stream) {
|
|
26
|
-
if (stream[Symbol.asyncIterator]) {
|
|
27
|
-
yield* stream;
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const reader = stream.getReader();
|
|
32
|
-
try {
|
|
33
|
-
for (;;) {
|
|
34
|
-
const {done, value} = await reader.read();
|
|
35
|
-
if (done) {
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
yield value;
|
|
39
|
-
}
|
|
40
|
-
} finally {
|
|
41
|
-
await reader.cancel();
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
46
|
-
const iterator = readBytes(stream, chunkSize);
|
|
47
|
-
|
|
48
|
-
let bytes = 0;
|
|
49
|
-
let done;
|
|
50
|
-
let _onFinish = (e) => {
|
|
51
|
-
if (!done) {
|
|
52
|
-
done = true;
|
|
53
|
-
onFinish && onFinish(e);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
return new ReadableStream({
|
|
58
|
-
async pull(controller) {
|
|
59
|
-
try {
|
|
60
|
-
const {done, value} = await iterator.next();
|
|
61
|
-
|
|
62
|
-
if (done) {
|
|
63
|
-
_onFinish();
|
|
64
|
-
controller.close();
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
let len = value.byteLength;
|
|
69
|
-
if (onProgress) {
|
|
70
|
-
let loadedBytes = bytes += len;
|
|
71
|
-
onProgress(loadedBytes);
|
|
72
|
-
}
|
|
73
|
-
controller.enqueue(new Uint8Array(value));
|
|
74
|
-
} catch (err) {
|
|
75
|
-
_onFinish(err);
|
|
76
|
-
throw err;
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
cancel(reason) {
|
|
80
|
-
_onFinish(reason);
|
|
81
|
-
return iterator.return();
|
|
82
|
-
}
|
|
83
|
-
}, {
|
|
84
|
-
highWaterMark: 2
|
|
85
|
-
})
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export { readBytes, streamChunk, trackStream };
|