@uploadcare/file-uploader 1.28.0-alpha.0 → 1.28.0-alpha.1
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/ActivityHeader-R6Mlx-dA.js +9 -0
- package/dist/ActivityHeader.css +23 -0
- package/dist/ActivityHeader.layered.css +24 -0
- package/dist/{CameraSource-DbyO6GoK.js → CameraSource-DDwj1jCV.js} +106 -76
- package/dist/CameraSource-n1tun2Df.js +10 -0
- package/dist/CameraSource.css +180 -0
- package/dist/CameraSource.layered.css +209 -0
- package/dist/{CloudImageEditor-BIxf1V4M.js → CloudImageEditor-DcVoIRb3.js} +66 -65
- package/dist/{CloudImageEditorActivity-d4DpK6fQ.js → CloudImageEditorActivity-Csij4nlC.js} +4 -4
- package/dist/{CloudImageEditorActivity-CJxP5N0S.js → CloudImageEditorActivity-DD4NdU0P.js} +4 -4
- package/dist/CloudImageEditorActivity.css +14 -0
- package/dist/CloudImageEditorActivity.layered.css +15 -0
- package/dist/{Config-DuWre5p3.js → Config-DKOromHY.js} +27 -27
- package/dist/Config.css +4 -0
- package/dist/Config.layered.css +5 -0
- package/dist/ExternalSource-6MSUgxqy.js +10 -0
- package/dist/{ExternalSource-BKTFp95O.js → ExternalSource-DVEjSkPB.js} +56 -51
- package/dist/ExternalSource.css +98 -0
- package/dist/ExternalSource.layered.css +116 -0
- package/dist/{Icon-CqTVC82Q.js → Icon-tXRTvEF2.js} +7 -8
- package/dist/Icon.css +14 -0
- package/dist/Icon.layered.css +15 -0
- package/dist/{LitUploaderBlock-BA34rzeU.js → LitUploaderBlock-LxeOZ0ya.js} +65 -65
- package/dist/{UrlSource-DZK5EBwT.js → UrlSource-BkyX00I2.js} +5 -5
- package/dist/UrlSource-RI8TSD48.js +10 -0
- package/dist/UrlSource.css +17 -0
- package/dist/UrlSource.layered.css +18 -0
- package/dist/abstract/loadFileUploaderFrom.js +3 -3
- package/dist/cameraPlugin-weRKO7eG.js +8 -0
- package/dist/{cloud-image-editor-fNswWrI4.js → cloud-image-editor-hhbyNWLG.js} +6 -6
- package/dist/cloud-image-editor.css +1380 -0
- package/dist/cloud-image-editor.layered.css +1549 -0
- package/dist/cloudImageEditorPlugin-FjUgbMK3.js +8 -0
- package/dist/{en-DNCwRJsB.js → en-8OWEmZim.js} +2 -2
- package/dist/env-mM-ksNPq.js +8 -0
- package/dist/env.js +3 -3
- package/dist/externalSourcesPlugin-CMBmLT8S.js +8 -0
- package/dist/imageShrinkPlugin-BN6loiP2.js +8 -0
- package/dist/index-base.css +2497 -0
- package/dist/index-base.layered.css +2837 -0
- package/dist/index.css +9 -3964
- package/dist/index.d.ts +13 -0
- package/dist/index.js +827 -42
- package/dist/index.layered.css +9 -4478
- package/dist/instagramPlugin-CXRm8MGL.js +8 -0
- package/dist/{loadFileUploaderFrom-BWJM43Yq.js → loadFileUploaderFrom-Bfz8L3VB.js} +3 -3
- package/dist/locales/file-uploader/ar.js +2 -2
- package/dist/locales/file-uploader/az.js +2 -2
- package/dist/locales/file-uploader/ca.js +2 -2
- package/dist/locales/file-uploader/cs.js +2 -2
- package/dist/locales/file-uploader/da.js +2 -2
- package/dist/locales/file-uploader/de.js +2 -2
- package/dist/locales/file-uploader/el.js +2 -2
- package/dist/locales/file-uploader/en.js +3 -3
- package/dist/locales/file-uploader/es.js +2 -2
- package/dist/locales/file-uploader/et.js +2 -2
- package/dist/locales/file-uploader/fi.js +2 -2
- package/dist/locales/file-uploader/fr.js +2 -2
- package/dist/locales/file-uploader/he.js +2 -2
- package/dist/locales/file-uploader/hy.js +2 -2
- package/dist/locales/file-uploader/is.js +2 -2
- package/dist/locales/file-uploader/it.js +2 -2
- package/dist/locales/file-uploader/ja.js +2 -2
- package/dist/locales/file-uploader/ka.js +2 -2
- package/dist/locales/file-uploader/kk.js +2 -2
- package/dist/locales/file-uploader/ko.js +2 -2
- package/dist/locales/file-uploader/lv.js +2 -2
- package/dist/locales/file-uploader/nb.js +2 -2
- package/dist/locales/file-uploader/nl.js +2 -2
- package/dist/locales/file-uploader/pl.js +2 -2
- package/dist/locales/file-uploader/pt.js +2 -2
- package/dist/locales/file-uploader/ro.js +2 -2
- package/dist/locales/file-uploader/ru.js +2 -2
- package/dist/locales/file-uploader/sk.js +2 -2
- package/dist/locales/file-uploader/sr.js +2 -2
- package/dist/locales/file-uploader/sv.js +2 -2
- package/dist/locales/file-uploader/tr.js +2 -2
- package/dist/locales/file-uploader/uk.js +2 -2
- package/dist/locales/file-uploader/vi.js +2 -2
- package/dist/locales/file-uploader/zh-TW.js +2 -2
- package/dist/locales/file-uploader/zh.js +2 -2
- package/dist/{plugins-DxjsQUa8.js → plugins-CGUls7EV.js} +6 -6
- package/dist/urlSourcePlugin-_WdbEhq2.js +8 -0
- package/package.json +1 -1
- package/web/ActivityHeader-BFdTdVfD.js +9 -0
- package/web/ActivityHeader-DQy6rII1.js +9 -0
- package/web/ActivityHeader-DvzMl0uj.js +9 -0
- package/web/ActivityHeader-i4x6_Fne.js +9 -0
- package/web/CameraSource-BAWIA4Wm.js +508 -0
- package/web/CameraSource-BqZCQcij.js +11 -0
- package/web/CameraSource-Brxr4tz4.js +508 -0
- package/web/CameraSource-BvBJ5Uzy.js +508 -0
- package/web/CameraSource-CkHzIE-h.js +11 -0
- package/web/CameraSource-D964yPLu.js +508 -0
- package/web/CameraSource-DE48Az-f.js +11 -0
- package/web/CameraSource-DyPebtRF.js +478 -0
- package/web/CameraSource-pj7Xo81m.js +11 -0
- package/web/CloudImageEditor-CTgUWB07.js +2192 -0
- package/web/CloudImageEditor-CxqV9Lwm.js +2192 -0
- package/web/CloudImageEditor-DoLWHpqV.js +2192 -0
- package/web/CloudImageEditor-Drywn265.js +2192 -0
- package/web/CloudImageEditor-MXcaDtMx.js +2187 -0
- package/web/CloudImageEditorActivity-BPzmfaJV.js +85 -0
- package/web/CloudImageEditorActivity-Br8pU5gd.js +11 -0
- package/web/CloudImageEditorActivity-Cw8b2CEz.js +11 -0
- package/web/CloudImageEditorActivity-Df1ySGq0.js +86 -0
- package/web/CloudImageEditorActivity-DinG5r0y.js +11 -0
- package/web/CloudImageEditorActivity-DmnLLINR.js +85 -0
- package/web/CloudImageEditorActivity-U90BGCek.js +85 -0
- package/web/CloudImageEditorActivity-dNLQZRZI.js +11 -0
- package/web/CloudImageEditorActivity-ur-hQ-6p.js +85 -0
- package/web/Config-8hlBNhvs.js +455 -0
- package/web/Config-BDZhPIyz.js +455 -0
- package/web/Config-CJVNrrjj.js +455 -0
- package/web/Config-DvkVtlQ7.js +455 -0
- package/web/ExternalSource-B9ycBFiD.js +10 -0
- package/web/ExternalSource-BE7HX47E.js +250 -0
- package/web/ExternalSource-BL5GSlol.js +250 -0
- package/web/ExternalSource-BXQY6Dlc.js +10 -0
- package/web/ExternalSource-BXxH3JCD.js +250 -0
- package/web/ExternalSource-BYSS-PPV.js +245 -0
- package/web/ExternalSource-C57a61QN.js +10 -0
- package/web/ExternalSource-CKfMtOgU.js +250 -0
- package/web/ExternalSource-DP6q8ylB.js +10 -0
- package/web/LitUploaderBlock-AX6jOdAS.js +996 -0
- package/web/LitUploaderBlock-BjAaoLl2.js +996 -0
- package/web/LitUploaderBlock-D8E5HuwH.js +996 -0
- package/web/LitUploaderBlock-Dl3ce0Tc.js +996 -0
- package/web/LitUploaderBlock-Oi33U0uf.js +996 -0
- package/web/UrlSource-B9SX3K0L.js +10 -0
- package/web/UrlSource-C3zB1rCb.js +70 -0
- package/web/UrlSource-C7bEU6Xv.js +10 -0
- package/web/UrlSource-CE389CBz.js +70 -0
- package/web/UrlSource-CnvAJ58Y.js +10 -0
- package/web/UrlSource-CqF0h6B-.js +10 -0
- package/web/UrlSource-D-971Nut.js +70 -0
- package/web/UrlSource-DhI3YCt5.js +70 -0
- package/web/UrlSource-hWV7jtB2.js +70 -0
- package/web/abstract/CTX.d.ts +40 -0
- package/web/abstract/TypedCollection.d.ts +47 -0
- package/web/abstract/TypedCollection.test.d.ts +1 -0
- package/web/abstract/TypedData.d.ts +12 -0
- package/web/abstract/TypedData.test.d.ts +1 -0
- package/web/abstract/UploaderPublicApi.d.ts +41 -0
- package/web/abstract/buildOutputCollectionState.d.ts +3 -0
- package/web/abstract/customConfigOptions.d.ts +65 -0
- package/web/abstract/defineComponents.d.ts +1 -0
- package/web/abstract/features/ClipboardLayer.d.ts +12 -0
- package/web/abstract/loadFileUploaderFrom.d.ts +13 -0
- package/web/abstract/localeRegistry.d.ts +5 -0
- package/web/abstract/managers/LocaleManager.d.ts +10 -0
- package/web/abstract/managers/ModalManager.d.ts +53 -0
- package/web/abstract/managers/SecureUploadsManager.d.ts +7 -0
- package/web/abstract/managers/TelemetryManager.d.ts +41 -0
- package/web/abstract/managers/ValidationManager.d.ts +34 -0
- package/web/abstract/managers/__tests__/ModalManager.test.d.ts +13 -0
- package/web/abstract/managers/__tests__/SecureUploadsManager.test.d.ts +1 -0
- package/web/abstract/managers/a11y.d.ts +9 -0
- package/web/abstract/managers/plugin/PluginManager.d.ts +25 -0
- package/web/abstract/managers/plugin/PluginTypes.d.ts +146 -0
- package/web/abstract/managers/plugin/index.d.ts +2 -0
- package/web/abstract/sharedConfigKey.d.ts +2 -0
- package/web/abstract/uploadEntrySchema.d.ts +34 -0
- package/web/blocks/ActivityHeader/ActivityHeader.d.ts +8 -0
- package/web/blocks/CameraSource/CameraSource.d.ts +121 -0
- package/web/blocks/CameraSource/__tests__/calcCameraModes.test.d.ts +1 -0
- package/web/blocks/CameraSource/calcCameraModes.d.ts +5 -0
- package/web/blocks/CameraSource/constants.d.ts +15 -0
- package/web/blocks/CloudImageEditor/index.d.ts +1 -0
- package/web/blocks/CloudImageEditor/src/CloudImageEditorBlock.d.ts +60 -0
- package/web/blocks/CloudImageEditor/src/CropFrame.d.ts +56 -0
- package/web/blocks/CloudImageEditor/src/EditorAspectRatioButtonControl.d.ts +24 -0
- package/web/blocks/CloudImageEditor/src/EditorButtonControl.d.ts +14 -0
- package/web/blocks/CloudImageEditor/src/EditorCropButtonControl.d.ts +13 -0
- package/web/blocks/CloudImageEditor/src/EditorFilterControl.d.ts +35 -0
- package/web/blocks/CloudImageEditor/src/EditorImageCropper.d.ts +56 -0
- package/web/blocks/CloudImageEditor/src/EditorImageFader.d.ts +63 -0
- package/web/blocks/CloudImageEditor/src/EditorOperationControl.d.ts +15 -0
- package/web/blocks/CloudImageEditor/src/EditorScroller.d.ts +15 -0
- package/web/blocks/CloudImageEditor/src/EditorSlider.d.ts +33 -0
- package/web/blocks/CloudImageEditor/src/EditorToolbar.d.ts +68 -0
- package/web/blocks/CloudImageEditor/src/crop-utils.d.ts +36 -0
- package/web/blocks/CloudImageEditor/src/crop-utils.test.d.ts +1 -0
- package/web/blocks/CloudImageEditor/src/cropper-constants.d.ts +10 -0
- package/web/blocks/CloudImageEditor/src/elements/button/BtnUi.d.ts +31 -0
- package/web/blocks/CloudImageEditor/src/elements/line-loader/LineLoaderUi.d.ts +19 -0
- package/web/blocks/CloudImageEditor/src/elements/presence-toggle/PresenceToggle.d.ts +27 -0
- package/web/blocks/CloudImageEditor/src/elements/slider/SliderUi.d.ts +38 -0
- package/web/blocks/CloudImageEditor/src/index.d.ts +15 -0
- package/web/blocks/CloudImageEditor/src/lib/classNames.d.ts +5 -0
- package/web/blocks/CloudImageEditor/src/lib/classNames.test.d.ts +1 -0
- package/web/blocks/CloudImageEditor/src/lib/linspace.d.ts +1 -0
- package/web/blocks/CloudImageEditor/src/lib/linspace.test.d.ts +1 -0
- package/web/blocks/CloudImageEditor/src/lib/parseCropPreset.d.ts +4 -0
- package/web/blocks/CloudImageEditor/src/lib/parseCropPreset.test.d.ts +1 -0
- package/web/blocks/CloudImageEditor/src/lib/parseTabs.d.ts +2 -0
- package/web/blocks/CloudImageEditor/src/lib/pick.d.ts +1 -0
- package/web/blocks/CloudImageEditor/src/lib/pick.test.d.ts +1 -0
- package/web/blocks/CloudImageEditor/src/lib/transformationUtils.d.ts +7 -0
- package/web/blocks/CloudImageEditor/src/state.d.ts +20 -0
- package/web/blocks/CloudImageEditor/src/svg-sprite.d.ts +2 -0
- package/web/blocks/CloudImageEditor/src/toolbar-constants.d.ts +61 -0
- package/web/blocks/CloudImageEditor/src/types.d.ts +60 -0
- package/web/blocks/CloudImageEditor/src/util.d.ts +2 -0
- package/web/blocks/CloudImageEditor/src/utils/parseFilterValue.d.ts +7 -0
- package/web/blocks/CloudImageEditor/src/utils/parseFilterValue.test.d.ts +1 -0
- package/web/blocks/CloudImageEditorActivity/CloudImageEditorActivity.d.ts +25 -0
- package/web/blocks/Config/Config.d.ts +60 -0
- package/web/blocks/Config/assertions.d.ts +5 -0
- package/web/blocks/Config/computed-properties.d.ts +24 -0
- package/web/blocks/Config/computed-properties.test.d.ts +1 -0
- package/web/blocks/Config/initialConfig.d.ts +6 -0
- package/web/blocks/Config/normalizeConfigValue.d.ts +2 -0
- package/web/blocks/Config/validatorsType.d.ts +18 -0
- package/web/blocks/Copyright/Copyright.d.ts +10 -0
- package/web/blocks/DropArea/DropArea.d.ts +47 -0
- package/web/blocks/DropArea/addDropzone.d.ts +17 -0
- package/web/blocks/DropArea/getDropItems.d.ts +12 -0
- package/web/blocks/ExternalSource/ExternalSource.d.ts +45 -0
- package/web/blocks/ExternalSource/MessageBridge.d.ts +11 -0
- package/web/blocks/ExternalSource/buildThemeDefinition.d.ts +4 -0
- package/web/blocks/ExternalSource/query-string.d.ts +1 -0
- package/web/blocks/ExternalSource/types.d.ts +105 -0
- package/web/blocks/FileItem/FileItem.d.ts +50 -0
- package/web/blocks/FileItem/FileItemConfig.d.ts +10 -0
- package/web/blocks/FormInput/FormInput.d.ts +18 -0
- package/web/blocks/Icon/Icon.d.ts +19 -0
- package/web/blocks/Img/Img.d.ts +14 -0
- package/web/blocks/Img/ImgBase.d.ts +29 -0
- package/web/blocks/Img/ImgConfig.d.ts +28 -0
- package/web/blocks/Img/configurations.d.ts +11 -0
- package/web/blocks/Img/props-map.d.ts +28 -0
- package/web/blocks/Img/utils/parseObjectToString.d.ts +2 -0
- package/web/blocks/Modal/Modal.d.ts +34 -0
- package/web/blocks/PluginActivityRenderer/PluginActivityRenderer.d.ts +32 -0
- package/web/blocks/PluginActivityRenderer/index.d.ts +1 -0
- package/web/blocks/ProgressBar/ProgressBar.d.ts +21 -0
- package/web/blocks/ProgressBarCommon/ProgressBarCommon.d.ts +17 -0
- package/web/blocks/Select/Select.d.ts +18 -0
- package/web/blocks/SimpleBtn/SimpleBtn.d.ts +15 -0
- package/web/blocks/SourceBtn/SourceBtn.d.ts +23 -0
- package/web/blocks/SourceList/SourceList.d.ts +24 -0
- package/web/blocks/Spinner/Spinner.d.ts +9 -0
- package/web/blocks/StartFrom/StartFrom.d.ts +12 -0
- package/web/blocks/Thumb/Thumb.d.ts +35 -0
- package/web/blocks/UploadCtxProvider/EventEmitter.d.ts +70 -0
- package/web/blocks/UploadCtxProvider/UploadCtxProvider.d.ts +44 -0
- package/web/blocks/UploadList/UploadList.d.ts +39 -0
- package/web/blocks/UrlSource/UrlSource.d.ts +14 -0
- package/web/blocks/svg-backgrounds/svg-backgrounds.d.ts +3 -0
- package/web/blocks/themes/uc-basic/svg-sprite.d.ts +2 -0
- package/web/cameraPlugin-DeedXMWV.js +8 -0
- package/web/cameraPlugin-Duy1QwjB.js +8 -0
- package/web/cameraPlugin-QS9SUOtO.js +8 -0
- package/web/cameraPlugin-bq8ggY04.js +8 -0
- package/web/cameraPlugin-cel9YgP_.js +8 -0
- package/web/cloud-image-editor-8DrVRZ7E.js +12 -0
- package/web/cloud-image-editor-BX50EK1U.js +12 -0
- package/web/cloud-image-editor-DSW3oWq-.js +12 -0
- package/web/cloud-image-editor-DuI2Lx4M.js +12 -0
- package/web/cloudImageEditorPlugin-5my6aD36.js +8 -0
- package/web/cloudImageEditorPlugin-Bk19DmJv.js +8 -0
- package/web/cloudImageEditorPlugin-CcdnmtBW.js +8 -0
- package/web/cloudImageEditorPlugin-DQJmDl03.js +8 -0
- package/web/cloudImageEditorPlugin-kojghfqw.js +8 -0
- package/web/constants-BCfCF0cJ.js +4025 -0
- package/web/core.d.ts +42 -0
- package/web/env.d.ts +2 -0
- package/web/externalSourcesPlugin-BTeRm5C0.js +8 -0
- package/web/externalSourcesPlugin-BXgVeojg.js +8 -0
- package/web/externalSourcesPlugin-BgLpuIK9.js +8 -0
- package/web/externalSourcesPlugin-DMc9zs4T.js +8 -0
- package/web/externalSourcesPlugin-Dm9vnTBv.js +8 -0
- package/web/file-uploader.iife.min.js +697 -0
- package/web/file-uploader.min.js +1859 -0
- package/web/imageShrinkPlugin-BdHgEGZH.js +8 -0
- package/web/imageShrinkPlugin-BjkMGfvT.js +8 -0
- package/web/imageShrinkPlugin-CCkGHL2w.js +8 -0
- package/web/imageShrinkPlugin-D4WjaRGo.js +8 -0
- package/web/imageShrinkPlugin-DqYGutVx.js +8 -0
- package/web/index.d.ts +42 -0
- package/web/instagramPlugin-BTMz0K2a.js +8 -0
- package/web/instagramPlugin-BbIKgTH7.js +8 -0
- package/web/instagramPlugin-CQQhsEJa.js +8 -0
- package/web/instagramPlugin-Cm7lWKae.js +8 -0
- package/web/instagramPlugin-DcclxM_d.js +8 -0
- package/web/lit/BaseComponent.d.ts +12 -0
- package/web/lit/Constructor.d.ts +1 -0
- package/web/lit/CssDataMixin.d.ts +7 -0
- package/web/lit/LightDomMixin.d.ts +8 -0
- package/web/lit/LitActivityBlock.d.ts +53 -0
- package/web/lit/LitBlock.d.ts +83 -0
- package/web/lit/LitSolutionBlock.d.ts +21 -0
- package/web/lit/LitUploaderBlock.d.ts +53 -0
- package/web/lit/PubSubCompat.d.ts +18 -0
- package/web/lit/RegisterableElementMixin.d.ts +7 -0
- package/web/lit/SharedState.d.ts +119 -0
- package/web/lit/SymbioteCompatMixin.d.ts +40 -0
- package/web/lit/TestModeController.d.ts +16 -0
- package/web/lit/Uid.d.ts +3 -0
- package/web/lit/activity-constants.d.ts +11 -0
- package/web/lit/createDebugPrinter.d.ts +3 -0
- package/web/lit/findBlockInCtx.d.ts +3 -0
- package/web/lit/getOutputData.d.ts +2 -0
- package/web/lit/hasBlockInCtx.d.ts +3 -0
- package/web/lit/l10n.d.ts +5 -0
- package/web/lit/parseCssPropertyValue.d.ts +1 -0
- package/web/lit/shared-instances.d.ts +65 -0
- package/web/locales/file-uploader/ar.d.ts +137 -0
- package/web/locales/file-uploader/az.d.ts +129 -0
- package/web/locales/file-uploader/ca.d.ts +131 -0
- package/web/locales/file-uploader/cs.d.ts +133 -0
- package/web/locales/file-uploader/da.d.ts +129 -0
- package/web/locales/file-uploader/de.d.ts +129 -0
- package/web/locales/file-uploader/el.d.ts +129 -0
- package/web/locales/file-uploader/en.d.ts +129 -0
- package/web/locales/file-uploader/es.d.ts +131 -0
- package/web/locales/file-uploader/et.d.ts +129 -0
- package/web/locales/file-uploader/fi.d.ts +129 -0
- package/web/locales/file-uploader/fr.d.ts +131 -0
- package/web/locales/file-uploader/he.d.ts +131 -0
- package/web/locales/file-uploader/hy.d.ts +129 -0
- package/web/locales/file-uploader/is.d.ts +129 -0
- package/web/locales/file-uploader/it.d.ts +131 -0
- package/web/locales/file-uploader/ja.d.ts +129 -0
- package/web/locales/file-uploader/ka.d.ts +129 -0
- package/web/locales/file-uploader/kk.d.ts +129 -0
- package/web/locales/file-uploader/ko.d.ts +129 -0
- package/web/locales/file-uploader/lv.d.ts +131 -0
- package/web/locales/file-uploader/nb.d.ts +129 -0
- package/web/locales/file-uploader/nl.d.ts +129 -0
- package/web/locales/file-uploader/pl.d.ts +133 -0
- package/web/locales/file-uploader/pt.d.ts +131 -0
- package/web/locales/file-uploader/ro.d.ts +131 -0
- package/web/locales/file-uploader/ru.d.ts +133 -0
- package/web/locales/file-uploader/sk.d.ts +133 -0
- package/web/locales/file-uploader/sr.d.ts +131 -0
- package/web/locales/file-uploader/sv.d.ts +129 -0
- package/web/locales/file-uploader/tr.d.ts +129 -0
- package/web/locales/file-uploader/uk.d.ts +133 -0
- package/web/locales/file-uploader/vi.d.ts +129 -0
- package/web/locales/file-uploader/zh-TW.d.ts +129 -0
- package/web/locales/file-uploader/zh.d.ts +129 -0
- package/web/plugins/cameraPlugin.d.ts +2 -0
- package/web/plugins/cloudImageEditorPlugin.d.ts +2 -0
- package/web/plugins/externalSourcesPlugin.d.ts +2 -0
- package/web/plugins/imageShrinkPlugin.d.ts +2 -0
- package/web/plugins/instagramPlugin.d.ts +2 -0
- package/web/plugins/unsplashPlugin.d.ts +16 -0
- package/web/plugins/urlSourcePlugin.d.ts +2 -0
- package/web/plugins-Bt7FXHKx.js +562 -0
- package/web/plugins-CaaolyMk.js +562 -0
- package/web/plugins-Cjgw5oWg.js +562 -0
- package/web/plugins-CzNtrVQB.js +562 -0
- package/web/plugins-DS0hIs2V.js +563 -0
- package/web/ref-BOnG19ns.js +4040 -0
- package/web/ref-BejJFG7m.js +4040 -0
- package/web/ref-DcRg7zo9.js +4040 -0
- package/web/ref-ZWPcLQB9.js +4040 -0
- package/web/solutions/adaptive-image/index.d.ts +2 -0
- package/web/solutions/cloud-image-editor/CloudImageEditor.d.ts +11 -0
- package/web/solutions/cloud-image-editor/index.d.ts +5 -0
- package/web/solutions/file-uploader/inline/FileUploaderInline.d.ts +20 -0
- package/web/solutions/file-uploader/inline/index.d.ts +1 -0
- package/web/solutions/file-uploader/minimal/FileUploaderMinimal.d.ts +23 -0
- package/web/solutions/file-uploader/minimal/index.d.ts +1 -0
- package/web/solutions/file-uploader/regular/FileUploaderRegular.d.ts +17 -0
- package/web/solutions/file-uploader/regular/index.d.ts +1 -0
- package/web/style-map-BmZdux7T.js +37 -0
- package/web/style-map-CZ6fSV6e.js +37 -0
- package/web/style-map-Dk7mLCrB.js +37 -0
- package/web/style-map-HkHnu9oA.js +37 -0
- package/web/style-map-tw1yUEaj.js +37 -0
- package/web/types/dom.d.ts +1 -0
- package/web/types/events.d.ts +4 -0
- package/web/types/exported.d.ts +492 -0
- package/web/types/index.d.ts +5 -0
- package/web/uc-basic.layered.min.css +6046 -0
- package/web/uc-basic.min.css +5487 -0
- package/web/uc-cloud-image-editor.layered.min.css +1884 -0
- package/web/uc-cloud-image-editor.min.css +1675 -0
- package/web/uc-cloud-image-editor.min.js +457 -0
- package/web/uc-file-uploader-inline.layered.min.css +4352 -0
- package/web/uc-file-uploader-inline.min.css +3836 -0
- package/web/uc-file-uploader-inline.min.js +1859 -0
- package/web/uc-file-uploader-minimal.layered.min.css +4352 -0
- package/web/uc-file-uploader-minimal.min.css +3836 -0
- package/web/uc-file-uploader-minimal.min.js +1859 -0
- package/web/uc-file-uploader-regular.layered.min.css +4352 -0
- package/web/uc-file-uploader-regular.min.css +3836 -0
- package/web/uc-file-uploader-regular.min.js +1859 -0
- package/web/uc-img.min.js +895 -0
- package/web/urlSourcePlugin-9lhcr02f.js +8 -0
- package/web/urlSourcePlugin-C-sLGhGb.js +8 -0
- package/web/urlSourcePlugin-DNXDpnRD.js +8 -0
- package/web/urlSourcePlugin-JnD0cnxb.js +8 -0
- package/web/urlSourcePlugin-hcMU2K6T.js +8 -0
- package/web/utils/UID.d.ts +5 -0
- package/web/utils/UID.test.d.ts +1 -0
- package/web/utils/UploadSource.d.ts +37 -0
- package/web/utils/WindowHeightTracker.d.ts +9 -0
- package/web/utils/abilities.d.ts +1 -0
- package/web/utils/applyStyles.d.ts +1 -0
- package/web/utils/browser-info.d.ts +12 -0
- package/web/utils/browser-info.test.d.ts +1 -0
- package/web/utils/cdn-utils.d.ts +53 -0
- package/web/utils/cdn-utils.test.d.ts +1 -0
- package/web/utils/comma-separated.d.ts +2 -0
- package/web/utils/debounce.d.ts +3 -0
- package/web/utils/delay.d.ts +1 -0
- package/web/utils/fileTypes.d.ts +11 -0
- package/web/utils/fileTypes.test.d.ts +1 -0
- package/web/utils/get-top-level-origin.d.ts +1 -0
- package/web/utils/get-top-level-origin.test.d.ts +1 -0
- package/web/utils/getLocaleDirection.d.ts +1 -0
- package/web/utils/getPluralForm.d.ts +1 -0
- package/web/utils/getPluralForm.test.d.ts +1 -0
- package/web/utils/isPromiseLike.d.ts +1 -0
- package/web/utils/isPromiseLike.test.d.ts +1 -0
- package/web/utils/isSecureTokenExpired.d.ts +8 -0
- package/web/utils/isSecureTokenExpired.test.d.ts +1 -0
- package/web/utils/memoize.d.ts +1 -0
- package/web/utils/memoize.test.d.ts +1 -0
- package/web/utils/mixinClass.d.ts +8 -0
- package/web/utils/parseCdnUrl.d.ts +11 -0
- package/web/utils/parseCdnUrl.test.d.ts +1 -0
- package/web/utils/parseShrink.d.ts +7 -0
- package/web/utils/parseShrink.test.d.ts +1 -0
- package/web/utils/preloadImage.d.ts +10 -0
- package/web/utils/prettyBytes.d.ts +11 -0
- package/web/utils/prettyBytes.test.d.ts +1 -0
- package/web/utils/resizeImage.d.ts +1 -0
- package/web/utils/stringToArray.d.ts +1 -0
- package/web/utils/stringToArray.test.d.ts +1 -0
- package/web/utils/template-utils.d.ts +16 -0
- package/web/utils/template-utils.test.d.ts +1 -0
- package/web/utils/throttle.d.ts +3 -0
- package/web/utils/toKebabCase.d.ts +2 -0
- package/web/utils/toKebabCase.test.d.ts +1 -0
- package/web/utils/transparentPixelSrc.d.ts +1 -0
- package/web/utils/uniqueArray.d.ts +1 -0
- package/web/utils/uniqueArray.test.d.ts +1 -0
- package/web/utils/userAgent.d.ts +2 -0
- package/web/utils/validators/collection/index.d.ts +2 -0
- package/web/utils/validators/collection/validateCollectionUploadError.d.ts +2 -0
- package/web/utils/validators/collection/validateMultiple.d.ts +2 -0
- package/web/utils/validators/file/index.d.ts +4 -0
- package/web/utils/validators/file/validateFileType.d.ts +2 -0
- package/web/utils/validators/file/validateIsImage.d.ts +2 -0
- package/web/utils/validators/file/validateMaxSizeLimit.d.ts +2 -0
- package/web/utils/validators/file/validateUploadError.d.ts +2 -0
- package/web/utils/warnOnce.d.ts +1 -0
- package/web/utils/wildcardRegexp.d.ts +1 -0
- package/web/utils/wildcardRegexp.test.d.ts +1 -0
- package/web/utils/withResolvers.d.ts +5 -0
- package/web/utils/withResolvers.test.d.ts +1 -0
- package/dist/CameraSource-px4BzEMI.js +0 -9
- package/dist/ExternalSource-CR5DG0Jv.js +0 -9
- package/dist/UrlSource-BxVL9Pve.js +0 -9
- package/dist/cameraPlugin-dGash48Q.js +0 -8
- package/dist/cloudImageEditorPlugin-2EU0Pm_j.js +0 -8
- package/dist/env-B1nfXy9i.js +0 -8
- package/dist/externalSourcesPlugin-DKQqk3AC.js +0 -8
- package/dist/imageShrinkPlugin-DAx8eRen.js +0 -8
- package/dist/instagramPlugin-k67tMAo3.js +0 -8
- package/dist/urlSourcePlugin-9xdB7Pvw.js +0 -8
|
@@ -0,0 +1,996 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Package: @uploadcare/file-uploader@1.28.0-alpha.1 (MIT)
|
|
4
|
+
* License: https://github.com/uploadcare/blob/main/LICENSE
|
|
5
|
+
* Built: 2026-03-02T20:26:13.662Z
|
|
6
|
+
*/
|
|
7
|
+
import { Et as sharedConfigKey, F as warnOnce, H as LitBlock, J as EventType, K as PACKAGE_NAME, L as CameraSourceTypes, Ot as UID, Q as uploaderBlockCtx, St as createCdnUrlModifiers, U as createL10n, Vt as PubSub, W as getPluralForm, X as activityBlockCtx, bt as stringToArray, ct as SharedInstance, d as calculateMaxCenteredCropFrame, et as NetworkError, it as getUserAgent$1, jt as debounce, lt as DEFAULT_CDN_CNAME, nt as UploadError, ot as uploadFileGroup, q as PACKAGE_VERSION, tt as Queue, u as parseCropPreset, xt as createCdnUrl } from "./ref-BOnG19ns.js";
|
|
8
|
+
import { c as UploadSource, d as ACTIVITY_TYPES, f as deserializeCsv, l as browserFeatures, p as serializeCsv, s as ExternalUploadSource, u as browserInfo } from "./plugins-Cjgw5oWg.js";
|
|
9
|
+
var msToUnixTimestamp = (p) => typeof p == "number" ? Math.floor(p / 1e3) : 0;
|
|
10
|
+
const isSecureTokenExpired = (p, { threshold: H }) => {
|
|
11
|
+
let { secureExpire: U } = p, W = msToUnixTimestamp(Date.now()), G = Number(U);
|
|
12
|
+
return W + msToUnixTimestamp(H) >= G;
|
|
13
|
+
};
|
|
14
|
+
var SecureUploadsManager = class extends SharedInstance {
|
|
15
|
+
constructor(...p) {
|
|
16
|
+
super(...p), this._secureToken = null;
|
|
17
|
+
}
|
|
18
|
+
async getSecureToken() {
|
|
19
|
+
let { secureSignature: p, secureExpire: H, secureUploadsSignatureResolver: U, secureUploadsExpireThreshold: W } = this._cfg;
|
|
20
|
+
if ((p || H) && U && console.warn("Both secureSignature/secureExpire and secureUploadsSignatureResolver are set. secureUploadsSignatureResolver will be used."), U) {
|
|
21
|
+
if (!this._secureToken || isSecureTokenExpired(this._secureToken, { threshold: W })) {
|
|
22
|
+
this._secureToken ? this._debugPrint("Secure signature is expired. Resolving a new one...") : this._debugPrint("Secure signature is not set yet.");
|
|
23
|
+
try {
|
|
24
|
+
let p = await U();
|
|
25
|
+
p ? !p.secureSignature || !p.secureExpire ? console.error("Secure signature resolver returned an invalid result:", p) : (this._debugPrint("Secure signature resolved:", p), this._debugPrint("Secure signature will expire in", (/* @__PURE__ */ new Date(Number(p.secureExpire) * 1e3)).toISOString()), this._secureToken = p) : (this._debugPrint("Secure signature resolver returned nothing."), this._secureToken = null);
|
|
26
|
+
} catch (p) {
|
|
27
|
+
console.error("Secure signature resolving failed. Falling back to the previous one.", p), this._sharedInstancesBag.telemetryManager.sendEventError(p, "secureUploadsSignatureResolver. Secure signature resolving failed. Falling back to the previous one.");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return this._secureToken;
|
|
31
|
+
}
|
|
32
|
+
return p && H ? (this._debugPrint("Secure signature and expire are set. Using them...", {
|
|
33
|
+
secureSignature: p,
|
|
34
|
+
secureExpire: H
|
|
35
|
+
}), {
|
|
36
|
+
secureSignature: p,
|
|
37
|
+
secureExpire: H
|
|
38
|
+
}) : null;
|
|
39
|
+
}
|
|
40
|
+
destroy() {
|
|
41
|
+
super.destroy(), this._secureToken = null;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const validateCollectionUploadError = (p, H) => {
|
|
45
|
+
if (p.failedCount > 0) return {
|
|
46
|
+
type: "SOME_FILES_HAS_ERRORS",
|
|
47
|
+
message: H.l10n("some-files-were-not-uploaded")
|
|
48
|
+
};
|
|
49
|
+
}, validateMultiple = (p, H) => {
|
|
50
|
+
let U = p.totalCount, W = H.cfg.multiple ? H.cfg.multipleMin : 0, G = H.cfg.multiple ? H.cfg.multipleMax : 1;
|
|
51
|
+
if (W && U < W) return {
|
|
52
|
+
type: "TOO_FEW_FILES",
|
|
53
|
+
message: H.l10n("files-count-limit-error-too-few", {
|
|
54
|
+
min: W,
|
|
55
|
+
max: G,
|
|
56
|
+
total: U
|
|
57
|
+
}),
|
|
58
|
+
payload: {
|
|
59
|
+
total: U,
|
|
60
|
+
min: W,
|
|
61
|
+
max: G
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
if (G && U > G) return {
|
|
65
|
+
type: "TOO_MANY_FILES",
|
|
66
|
+
message: H.l10n("files-count-limit-error-too-many", {
|
|
67
|
+
min: W,
|
|
68
|
+
max: G,
|
|
69
|
+
total: U
|
|
70
|
+
}),
|
|
71
|
+
payload: {
|
|
72
|
+
total: U,
|
|
73
|
+
min: W,
|
|
74
|
+
max: G
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}, BASIC_IMAGE_WILDCARD = "image/*", HEIC_IMAGE_MIME_LIST = [
|
|
78
|
+
"image/heif",
|
|
79
|
+
"image/heif-sequence",
|
|
80
|
+
"image/heic",
|
|
81
|
+
"image/heic-sequence",
|
|
82
|
+
"image/avif",
|
|
83
|
+
"image/avif-sequence",
|
|
84
|
+
".heif",
|
|
85
|
+
".heifs",
|
|
86
|
+
".heic",
|
|
87
|
+
".heics",
|
|
88
|
+
".avif",
|
|
89
|
+
".avifs"
|
|
90
|
+
], IMAGE_ACCEPT_LIST = (() => browserInfo.safariDesktop ? [BASIC_IMAGE_WILDCARD] : [BASIC_IMAGE_WILDCARD, ...HEIC_IMAGE_MIME_LIST])(), mergeFileTypes = (p) => p ? p.filter((p) => typeof p == "string").flatMap((p) => stringToArray(p)) : [], matchMimeType = (p, H) => H.some((H) => {
|
|
91
|
+
if (H.endsWith("*")) {
|
|
92
|
+
let U = H.replace("*", "");
|
|
93
|
+
return p.startsWith(U);
|
|
94
|
+
}
|
|
95
|
+
return p === H;
|
|
96
|
+
}), matchExtension = (p, H) => H.some((H) => H.startsWith(".") ? p.toLowerCase().endsWith(H.toLowerCase()) : !1), fileIsImage = (p) => {
|
|
97
|
+
let H = p?.type;
|
|
98
|
+
return H ? matchMimeType(H, IMAGE_ACCEPT_LIST) : !1;
|
|
99
|
+
}, validateFileType = (p, H) => {
|
|
100
|
+
let U = H.cfg.imgOnly, W = H.cfg.accept, G = mergeFileTypes([...U ? IMAGE_ACCEPT_LIST : [], W]);
|
|
101
|
+
if (!G.length) return;
|
|
102
|
+
let K = p.mimeType, q = p.name;
|
|
103
|
+
if (!K || !q) return;
|
|
104
|
+
let J = matchMimeType(K, G), Y = matchExtension(q, G);
|
|
105
|
+
if (!J && !Y) return {
|
|
106
|
+
type: "FORBIDDEN_FILE_TYPE",
|
|
107
|
+
message: H.l10n("file-type-not-allowed"),
|
|
108
|
+
payload: { entry: p }
|
|
109
|
+
};
|
|
110
|
+
}, validateIsImage = (p, H) => {
|
|
111
|
+
let U = H.cfg.imgOnly, W = p.isImage;
|
|
112
|
+
if (!(!U || W) && !(!p.fileInfo && p.externalUrl) && !(!p.fileInfo && !p.mimeType)) return {
|
|
113
|
+
type: "NOT_AN_IMAGE",
|
|
114
|
+
message: H.l10n("images-only-accepted"),
|
|
115
|
+
payload: { entry: p }
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
var BASE = 1e3;
|
|
119
|
+
const ByteUnitEnum = Object.freeze({
|
|
120
|
+
AUTO: "auto",
|
|
121
|
+
BYTE: "byte",
|
|
122
|
+
KB: "kb",
|
|
123
|
+
MB: "mb",
|
|
124
|
+
GB: "gb",
|
|
125
|
+
TB: "tb",
|
|
126
|
+
PB: "pb"
|
|
127
|
+
});
|
|
128
|
+
var round = (p) => Math.ceil(p * 100) / 100;
|
|
129
|
+
const prettyBytes = (p, H = ByteUnitEnum.AUTO) => {
|
|
130
|
+
let U = H === ByteUnitEnum.AUTO;
|
|
131
|
+
return H === ByteUnitEnum.BYTE || U && p < BASE ** 1 ? `${p} ${getPluralForm("en-US", p) === "one" ? "byte" : "bytes"}` : H === ByteUnitEnum.KB || U && p < BASE ** 2 ? `${round(p / BASE ** 1)} KB` : H === ByteUnitEnum.MB || U && p < BASE ** 3 ? `${round(p / BASE ** 2)} MB` : H === ByteUnitEnum.GB || U && p < BASE ** 4 ? `${round(p / BASE ** 3)} GB` : H === ByteUnitEnum.TB || U && p < BASE ** 5 ? `${round(p / BASE ** 4)} TB` : `${round(p / BASE ** 5)} PB`;
|
|
132
|
+
}, validateMaxSizeLimit = (p, H) => {
|
|
133
|
+
let U = H.cfg.maxLocalFileSizeBytes, W = p.size;
|
|
134
|
+
if (U && W && W > U) return {
|
|
135
|
+
type: "FILE_SIZE_EXCEEDED",
|
|
136
|
+
message: H.l10n("files-max-size-limit-error", { maxFileSize: prettyBytes(U) }),
|
|
137
|
+
payload: { entry: p }
|
|
138
|
+
};
|
|
139
|
+
}, validateUploadError = (p, H) => {
|
|
140
|
+
let { internalId: U } = p;
|
|
141
|
+
if (!H._uploadCollection.hasItem(U)) return;
|
|
142
|
+
let W = H._uploadCollection.read(U)?.getValue("uploadError");
|
|
143
|
+
if (!W) return;
|
|
144
|
+
if (W instanceof UploadError) return {
|
|
145
|
+
type: "UPLOAD_ERROR",
|
|
146
|
+
message: W.message,
|
|
147
|
+
payload: {
|
|
148
|
+
entry: p,
|
|
149
|
+
error: W
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
if (W instanceof NetworkError) return {
|
|
153
|
+
type: "NETWORK_ERROR",
|
|
154
|
+
message: W.message,
|
|
155
|
+
payload: {
|
|
156
|
+
entry: p,
|
|
157
|
+
error: W
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
let G = W instanceof Error ? W : Error("Unknown error", { cause: W });
|
|
161
|
+
return {
|
|
162
|
+
type: "UNKNOWN_ERROR",
|
|
163
|
+
message: G.message,
|
|
164
|
+
payload: {
|
|
165
|
+
entry: p,
|
|
166
|
+
error: G
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
var LOG_TEXT = {
|
|
171
|
+
FILE_VALIDATION_FAILED: "File validator execution has failed",
|
|
172
|
+
FILE_VALIDATION_TIMEOUT: "File validator execution has timed out",
|
|
173
|
+
COLLECTION_VALIDATION_FAILED: "Collection validator execution has failed",
|
|
174
|
+
MISSING_ERROR_MESSAGE: "Missing message. We recommend adding message: value."
|
|
175
|
+
}, getValidatorDescriptor = (p) => typeof p == "function" ? {
|
|
176
|
+
runOn: "change",
|
|
177
|
+
validator: p
|
|
178
|
+
} : p, ValidationManager = class extends SharedInstance {
|
|
179
|
+
get _uploadCollection() {
|
|
180
|
+
return this._sharedInstancesBag.uploadCollection;
|
|
181
|
+
}
|
|
182
|
+
constructor(H) {
|
|
183
|
+
super(H), this._commonFileValidators = [
|
|
184
|
+
validateIsImage,
|
|
185
|
+
validateFileType,
|
|
186
|
+
validateMaxSizeLimit,
|
|
187
|
+
validateUploadError
|
|
188
|
+
], this._commonCollectionValidators = [validateMultiple, validateCollectionUploadError], this._queue = new Queue(20), this._runQueueDebounced = debounce(() => {
|
|
189
|
+
this._queue.run();
|
|
190
|
+
}, 500), this._isDestroyed = !1, this._entryValidationState = /* @__PURE__ */ new Map();
|
|
191
|
+
let U = debounce(() => {
|
|
192
|
+
this.runFileValidators("change"), this.runCollectionValidators();
|
|
193
|
+
}, 0);
|
|
194
|
+
this.addSub(this._ctx.sub(sharedConfigKey("maxLocalFileSizeBytes"), U)), this.addSub(this._ctx.sub(sharedConfigKey("multipleMin"), U)), this.addSub(this._ctx.sub(sharedConfigKey("multipleMax"), U)), this.addSub(this._ctx.sub(sharedConfigKey("multiple"), U)), this.addSub(this._ctx.sub(sharedConfigKey("imgOnly"), U)), this.addSub(this._ctx.sub(sharedConfigKey("accept"), U)), this.addSub(this._ctx.sub(sharedConfigKey("validationConcurrency"), (p) => {
|
|
195
|
+
this._queue.concurrency = p;
|
|
196
|
+
}));
|
|
197
|
+
}
|
|
198
|
+
runFileValidators(p, H) {
|
|
199
|
+
if (this._isDestroyed) return;
|
|
200
|
+
let U = H ?? this._uploadCollection.items();
|
|
201
|
+
for (let H of U) {
|
|
202
|
+
let U = this._uploadCollection.read(H);
|
|
203
|
+
U && this._runFileValidatorsForEntry(U, p);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
runCollectionValidators() {
|
|
207
|
+
if (this._isDestroyed) return;
|
|
208
|
+
let p = this._sharedInstancesBag.api, H = p.getOutputCollectionState(), U = [], G = this._cfg.collectionValidators;
|
|
209
|
+
for (let W of [...this._commonCollectionValidators, ...G]) try {
|
|
210
|
+
let G = W(H, p);
|
|
211
|
+
if (!G) continue;
|
|
212
|
+
G && (U.push(this._addCustomTypeToValidationError(G)), G.message || console.warn(LOG_TEXT.MISSING_ERROR_MESSAGE));
|
|
213
|
+
} catch (p) {
|
|
214
|
+
console.warn(LOG_TEXT.COLLECTION_VALIDATION_FAILED, p);
|
|
215
|
+
}
|
|
216
|
+
this._ctx.pub("*collectionErrors", U), U.length > 0 && this._sharedInstancesBag.eventEmitter.emit(EventType.COMMON_UPLOAD_FAILED, () => p.getOutputCollectionState(), { debounce: !0 });
|
|
217
|
+
}
|
|
218
|
+
cleanupValidationForEntry(p) {
|
|
219
|
+
let H = this._entryValidationState.get(p.uid);
|
|
220
|
+
H && (H.abortController?.abort(), this._entryValidationState.delete(p.uid));
|
|
221
|
+
}
|
|
222
|
+
async _runFileValidatorsForEntry(p, H) {
|
|
223
|
+
if (this._isDestroyed) return;
|
|
224
|
+
let U = this._sharedInstancesBag.api, W = this._getEntryValidationState(p), G = W.promise ?? Promise.resolve(), K = (async () => {
|
|
225
|
+
if (this._isDestroyed || (await G, this._isDestroyed)) return;
|
|
226
|
+
let K = this._getValidatorDescriptorsForEntry(p, H);
|
|
227
|
+
if (K.length === 0 || !this._uploadCollection.hasItem(p.uid)) return;
|
|
228
|
+
p.setMultipleValues({
|
|
229
|
+
isQueuedForValidation: !0,
|
|
230
|
+
isValidationPending: !0
|
|
231
|
+
});
|
|
232
|
+
let q = U.getOutputItem(p.uid), J = new AbortController();
|
|
233
|
+
W.abortController = J;
|
|
234
|
+
let Y = this._cfg.validationTimeout, X = this._getValidatorDescriptors(), Z = new Set(K.map((p) => p.validator)), Q = [];
|
|
235
|
+
for (let p of X) if (!Z.has(p.validator)) {
|
|
236
|
+
let H = W.lastErrorThrownByValidator.get(p.validator);
|
|
237
|
+
H && Q.push(H);
|
|
238
|
+
}
|
|
239
|
+
let $ = K.map((p) => async () => {
|
|
240
|
+
if (this._isDestroyed) return;
|
|
241
|
+
let H = setTimeout(() => {
|
|
242
|
+
W.skippedValidators.add(p.validator), J.abort(), console.warn(LOG_TEXT.FILE_VALIDATION_TIMEOUT);
|
|
243
|
+
}, Y);
|
|
244
|
+
try {
|
|
245
|
+
let H = await p.validator(q, U, { signal: J.signal });
|
|
246
|
+
if (!H || J.signal.aborted) {
|
|
247
|
+
W.lastErrorThrownByValidator.set(p.validator, void 0);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
let G = this._addCustomTypeToValidationError(H);
|
|
251
|
+
W.lastErrorThrownByValidator.set(p.validator, G), Q.push(G), H.message || console.warn(LOG_TEXT.MISSING_ERROR_MESSAGE);
|
|
252
|
+
} catch (H) {
|
|
253
|
+
J.signal.aborted || (W.skippedValidators.add(p.validator), console.warn(LOG_TEXT.FILE_VALIDATION_FAILED, H), this._sharedInstancesBag.telemetryManager.sendEventError(H, `file validator. ${LOG_TEXT.FILE_VALIDATION_FAILED}`));
|
|
254
|
+
} finally {
|
|
255
|
+
clearTimeout(H), p.runOn !== "change" && W.skippedValidators.add(p.validator);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
if (this._runQueueDebounced(), await this._queue.add(async () => {
|
|
259
|
+
this._isDestroyed || (p.setValue("isQueuedForValidation", !1), await Promise.all($.map((p) => p())).catch(() => {}));
|
|
260
|
+
}, { autoRun: !1 }), J.signal.aborted) {
|
|
261
|
+
p.setMultipleValues({
|
|
262
|
+
isQueuedForValidation: !1,
|
|
263
|
+
isValidationPending: !1
|
|
264
|
+
});
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
p.setMultipleValues({
|
|
268
|
+
isValidationPending: !1,
|
|
269
|
+
isQueuedForValidation: !1,
|
|
270
|
+
errors: Q
|
|
271
|
+
});
|
|
272
|
+
})();
|
|
273
|
+
W.promise = K;
|
|
274
|
+
try {
|
|
275
|
+
await K;
|
|
276
|
+
} finally {
|
|
277
|
+
W.promise === K && (W.promise = void 0);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
_addCustomTypeToValidationError(p) {
|
|
281
|
+
return {
|
|
282
|
+
...p,
|
|
283
|
+
type: p.type ?? "CUSTOM_ERROR"
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
_getEntryValidationState(p) {
|
|
287
|
+
let H = this._entryValidationState.get(p.uid);
|
|
288
|
+
if (H) return H;
|
|
289
|
+
let U = {
|
|
290
|
+
abortController: void 0,
|
|
291
|
+
skippedValidators: /* @__PURE__ */ new WeakSet(),
|
|
292
|
+
promise: void 0,
|
|
293
|
+
lastErrorThrownByValidator: /* @__PURE__ */ new WeakMap()
|
|
294
|
+
};
|
|
295
|
+
return this._entryValidationState.set(p.uid, U), U;
|
|
296
|
+
}
|
|
297
|
+
_getValidatorDescriptors() {
|
|
298
|
+
let p = this._cfg.fileValidators;
|
|
299
|
+
return [...this._commonFileValidators, ...p].map(getValidatorDescriptor);
|
|
300
|
+
}
|
|
301
|
+
_getValidatorDescriptorsForEntry(p, H) {
|
|
302
|
+
let U = this._getEntryValidationState(p);
|
|
303
|
+
return this._getValidatorDescriptors().filter((p) => !U.skippedValidators.has(p.validator)).filter((p) => p.runOn === H);
|
|
304
|
+
}
|
|
305
|
+
destroy() {
|
|
306
|
+
this._isDestroyed = !0, this._runQueueDebounced.cancel();
|
|
307
|
+
for (let p of this._entryValidationState.values()) p.abortController?.abort(), p.promise = void 0;
|
|
308
|
+
this._entryValidationState.clear();
|
|
309
|
+
}
|
|
310
|
+
}, MSG_NAME = "[Typed State] Wrong property name: ", TypedData = class {
|
|
311
|
+
constructor(p) {
|
|
312
|
+
this._ctxId = UID.generateFastUid(), this._data = PubSub.registerCtx(p, this._ctxId);
|
|
313
|
+
}
|
|
314
|
+
get uid() {
|
|
315
|
+
return this._ctxId;
|
|
316
|
+
}
|
|
317
|
+
setValue(p, H) {
|
|
318
|
+
if (!this._data.has(p)) {
|
|
319
|
+
console.warn(`${MSG_NAME}${String(p)}`);
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
this._data.read(p) !== H && this._data.pub(p, H);
|
|
323
|
+
}
|
|
324
|
+
setMultipleValues(p) {
|
|
325
|
+
for (let [H, U] of Object.entries(p)) this.setValue(H, U);
|
|
326
|
+
}
|
|
327
|
+
getValue(p) {
|
|
328
|
+
return this._data.has(p) || console.warn(`${MSG_NAME}${String(p)}`), this._data.read(p);
|
|
329
|
+
}
|
|
330
|
+
subscribe(p, H) {
|
|
331
|
+
return this._data.sub(p, H);
|
|
332
|
+
}
|
|
333
|
+
destroy() {
|
|
334
|
+
PubSub.deleteCtx(this._ctxId);
|
|
335
|
+
}
|
|
336
|
+
}, TypedCollection = class p {
|
|
337
|
+
static {
|
|
338
|
+
this._destroyDelayMs = 1e4;
|
|
339
|
+
}
|
|
340
|
+
constructor(p) {
|
|
341
|
+
this._subsMap = Object.create(null), this._propertyObservers = /* @__PURE__ */ new Set(), this._collectionObservers = /* @__PURE__ */ new Set(), this._items = /* @__PURE__ */ new Set(), this._removed = /* @__PURE__ */ new Set(), this._added = /* @__PURE__ */ new Set(), this._markedToDestroy = /* @__PURE__ */ new Set(), this._initialValue = p.initialValue, this._ctxId = UID.generateFastUid(), this._data = PubSub.registerCtx({}, this._ctxId), this._watchList = p.watchList || [];
|
|
342
|
+
let H = Object.create(null);
|
|
343
|
+
this._notifyObservers = (p, U) => {
|
|
344
|
+
this._observeTimeout && window.clearTimeout(this._observeTimeout), H[p] || (H[p] = /* @__PURE__ */ new Set()), H[p].add(U), this._observeTimeout = window.setTimeout(() => {
|
|
345
|
+
Object.keys(H).length !== 0 && (this._propertyObservers.forEach((p) => {
|
|
346
|
+
p({ ...H });
|
|
347
|
+
}), H = Object.create(null));
|
|
348
|
+
}), this._scheduleDestroyMarkedItems();
|
|
349
|
+
}, p.handler && this.observeCollection(p.handler);
|
|
350
|
+
}
|
|
351
|
+
_notify() {
|
|
352
|
+
this._notifyTimeout && window.clearTimeout(this._notifyTimeout), this._notifyTimeout = window.setTimeout(() => {
|
|
353
|
+
let p = new Set(this._added), H = new Set(this._removed);
|
|
354
|
+
this._added.clear(), this._removed.clear();
|
|
355
|
+
for (let U of this._collectionObservers) U?.([...this._items], p, H);
|
|
356
|
+
this._scheduleDestroyMarkedItems();
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
_scheduleDestroyMarkedItems() {
|
|
360
|
+
this._markedToDestroy.size !== 0 && (this._destroyTimeout && window.clearTimeout(this._destroyTimeout), this._destroyTimeout = window.setTimeout(() => {
|
|
361
|
+
let p = [...this._markedToDestroy];
|
|
362
|
+
this._markedToDestroy.clear();
|
|
363
|
+
for (let H of p) H.destroy();
|
|
364
|
+
}, p._destroyDelayMs));
|
|
365
|
+
}
|
|
366
|
+
observeCollection(p) {
|
|
367
|
+
return this._collectionObservers.add(p), this._items.size > 0 && this._notify(), () => {
|
|
368
|
+
this.unobserveCollection(p);
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
unobserveCollection(p) {
|
|
372
|
+
this._collectionObservers.delete(p);
|
|
373
|
+
}
|
|
374
|
+
add(p) {
|
|
375
|
+
let H = new TypedData(this._initialValue);
|
|
376
|
+
for (let [U, W] of Object.entries(p)) H.setValue(U, W);
|
|
377
|
+
return this._items.add(H.uid), this._notify(), this._data.add(H.uid, H), this._added.add(H), this._watchList.forEach((p) => {
|
|
378
|
+
this._subsMap[H.uid] || (this._subsMap[H.uid] = []), this._subsMap[H.uid]?.push(H.subscribe(p, () => {
|
|
379
|
+
this._notifyObservers(p, H.uid);
|
|
380
|
+
}));
|
|
381
|
+
}), H.uid;
|
|
382
|
+
}
|
|
383
|
+
hasItem(p) {
|
|
384
|
+
return this._items.has(p);
|
|
385
|
+
}
|
|
386
|
+
read(p) {
|
|
387
|
+
return this._data.read(p) ?? null;
|
|
388
|
+
}
|
|
389
|
+
readProp(p, H) {
|
|
390
|
+
let U = this.read(p);
|
|
391
|
+
if (!U) throw Error(`TypedCollection#readProp: Item with id ${p} not found`);
|
|
392
|
+
return U.getValue(H);
|
|
393
|
+
}
|
|
394
|
+
publishProp(p, H, U) {
|
|
395
|
+
let W = this.read(p);
|
|
396
|
+
if (!W) throw Error(`TypedCollection#publishProp: Item with id ${p} not found`);
|
|
397
|
+
W.setValue(H, U);
|
|
398
|
+
}
|
|
399
|
+
remove(p) {
|
|
400
|
+
let H = this.read(p);
|
|
401
|
+
H && (this._removed.add(H), this._markedToDestroy.add(H)), this._items.delete(p), this._notify(), this._data.pub(p, void 0), this._subsMap[p]?.forEach((p) => {
|
|
402
|
+
p();
|
|
403
|
+
}), delete this._subsMap[p];
|
|
404
|
+
}
|
|
405
|
+
clearAll() {
|
|
406
|
+
this._items.forEach((p) => {
|
|
407
|
+
this.remove(p);
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
observeProperties(p) {
|
|
411
|
+
return this._propertyObservers.add(p), () => {
|
|
412
|
+
this.unobserveProperties(p);
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
unobserveProperties(p) {
|
|
416
|
+
this._propertyObservers.delete(p);
|
|
417
|
+
}
|
|
418
|
+
findItems(p) {
|
|
419
|
+
let H = [];
|
|
420
|
+
return this._items.forEach((U) => {
|
|
421
|
+
let W = this.read(U);
|
|
422
|
+
W && p(W) && H.push(U);
|
|
423
|
+
}), H;
|
|
424
|
+
}
|
|
425
|
+
items() {
|
|
426
|
+
return [...this._items];
|
|
427
|
+
}
|
|
428
|
+
get size() {
|
|
429
|
+
return this._items.size;
|
|
430
|
+
}
|
|
431
|
+
destroy() {
|
|
432
|
+
this._observeTimeout && window.clearTimeout(this._observeTimeout), this._notifyTimeout && window.clearTimeout(this._notifyTimeout), this._destroyTimeout && window.clearTimeout(this._destroyTimeout);
|
|
433
|
+
for (let p of this._markedToDestroy) p.destroy();
|
|
434
|
+
this._markedToDestroy.clear(), PubSub.deleteCtx(this._ctxId), this._propertyObservers = /* @__PURE__ */ new Set(), this._collectionObservers = /* @__PURE__ */ new Set();
|
|
435
|
+
for (let p of Object.keys(this._subsMap)) this._subsMap[p]?.forEach((p) => {
|
|
436
|
+
p();
|
|
437
|
+
}), delete this._subsMap[p];
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
const calcCameraModes = (p) => ({
|
|
441
|
+
isVideoRecordingEnabled: deserializeCsv(p.cameraModes).includes(CameraSourceTypes.VIDEO),
|
|
442
|
+
isPhotoEnabled: deserializeCsv(p.cameraModes).includes(CameraSourceTypes.PHOTO)
|
|
443
|
+
}), findBlockInCtx = (p, H) => {
|
|
444
|
+
for (let U of p) if (H(U)) return U;
|
|
445
|
+
}, hasBlockInCtx = (p, H) => {
|
|
446
|
+
for (let U of p) if (H(U)) return !0;
|
|
447
|
+
return !1;
|
|
448
|
+
};
|
|
449
|
+
function applyStyles(p, H) {
|
|
450
|
+
for (let U in H) U.includes("-") ? p.style.setProperty(U, String(H[U])) : p.style[U] = String(H[U]);
|
|
451
|
+
}
|
|
452
|
+
var cdnUrlRegex = RegExp("^/?([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})(?:/(-/(?:[^/]+/)+)?([^/]*))?$", "i");
|
|
453
|
+
const parseCdnUrl = ({ url: p, cdnBase: H }) => {
|
|
454
|
+
let U = new URL(H), W = new URL(DEFAULT_CDN_CNAME), G = new URL(p);
|
|
455
|
+
if (U.host !== G.host && W.host !== G.host) return null;
|
|
456
|
+
let K = cdnUrlRegex.exec(G.pathname);
|
|
457
|
+
if (!K) return null;
|
|
458
|
+
let [, q, J, Y] = K;
|
|
459
|
+
return q ? {
|
|
460
|
+
uuid: q,
|
|
461
|
+
cdnUrlModifiers: J || "",
|
|
462
|
+
filename: Y || null
|
|
463
|
+
} : null;
|
|
464
|
+
}, getOutputData = (p) => p.uploadCollection.items().map((H) => p.api.getOutputItem(H));
|
|
465
|
+
function memoize(p) {
|
|
466
|
+
let H = /* @__PURE__ */ new Map();
|
|
467
|
+
return (...U) => {
|
|
468
|
+
let W = JSON.stringify(U);
|
|
469
|
+
if (H.has(W)) return H.get(W);
|
|
470
|
+
let G = p(...U);
|
|
471
|
+
return H.set(W, G), G;
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
function createAsyncAssertWrapper(p) {
|
|
475
|
+
let U = !1;
|
|
476
|
+
return setTimeout(() => {
|
|
477
|
+
U = !0;
|
|
478
|
+
}, 0), (W) => ((...G) => (U && warnOnce(p), W(...G)));
|
|
479
|
+
}
|
|
480
|
+
function buildOutputCollectionState(p) {
|
|
481
|
+
let H = {}, U = p.ctx, W = {
|
|
482
|
+
progress: () => U.read("*commonProgress"),
|
|
483
|
+
errors: () => U.read("*collectionErrors"),
|
|
484
|
+
group: () => U.read("*groupInfo"),
|
|
485
|
+
totalCount: () => p.uploadCollection.size,
|
|
486
|
+
failedCount: () => H.failedEntries.length,
|
|
487
|
+
successCount: () => H.successEntries.length,
|
|
488
|
+
uploadingCount: () => H.uploadingEntries.length,
|
|
489
|
+
status: () => H.isFailed ? "failed" : H.isUploading ? "uploading" : H.isSuccess ? "success" : "idle",
|
|
490
|
+
isSuccess: () => H.allEntries.length > 0 && H.errors.length === 0 && H.successEntries.length === H.allEntries.length,
|
|
491
|
+
isUploading: () => H.allEntries.some((p) => p.status === "uploading"),
|
|
492
|
+
isFailed: () => H.errors.length > 0 || H.failedEntries.length > 0,
|
|
493
|
+
allEntries: () => getOutputData(p),
|
|
494
|
+
successEntries: () => H.allEntries.filter((p) => p.status === "success"),
|
|
495
|
+
failedEntries: () => H.allEntries.filter((p) => p.status === "failed"),
|
|
496
|
+
uploadingEntries: () => H.allEntries.filter((p) => p.status === "uploading"),
|
|
497
|
+
idleEntries: () => H.allEntries.filter((p) => p.status === "idle")
|
|
498
|
+
}, G = createAsyncAssertWrapper("You're trying to access the OutputCollectionState asynchronously. In this case, the data you retrieve will be newer than it was when the OutputCollectionState was created or when the event was dispatched. If you want to retain the state at a specific moment in time, you should use the spread operator like this: `{...outputCollectionState}` or `{...e.detail}`");
|
|
499
|
+
for (let [p, U] of Object.entries(W)) {
|
|
500
|
+
let W = p, K = memoize(G(U));
|
|
501
|
+
Object.defineProperty(H, W, {
|
|
502
|
+
get: K,
|
|
503
|
+
enumerable: !0
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
return H;
|
|
507
|
+
}
|
|
508
|
+
var UploaderPublicApi = class extends SharedInstance {
|
|
509
|
+
constructor(...p) {
|
|
510
|
+
super(...p), this._l10n = createL10n(() => this._ctx), this.addFileFromUrl = (p, { silent: H, fileName: U, source: W } = {}) => {
|
|
511
|
+
let G = this._uploadCollection.add({
|
|
512
|
+
externalUrl: p,
|
|
513
|
+
fileName: U ?? null,
|
|
514
|
+
silent: H ?? !1,
|
|
515
|
+
source: W ?? UploadSource.API
|
|
516
|
+
});
|
|
517
|
+
return this.getOutputItem(G);
|
|
518
|
+
}, this.addFileFromUuid = (p, { silent: H, fileName: U, source: W } = {}) => {
|
|
519
|
+
let G = this._uploadCollection.add({
|
|
520
|
+
uuid: p,
|
|
521
|
+
fileName: U ?? null,
|
|
522
|
+
silent: H ?? !1,
|
|
523
|
+
source: W ?? UploadSource.API
|
|
524
|
+
});
|
|
525
|
+
return this.getOutputItem(G);
|
|
526
|
+
}, this.addFileFromCdnUrl = (p, { silent: H, fileName: U, source: W } = {}) => {
|
|
527
|
+
let G = parseCdnUrl({
|
|
528
|
+
url: p,
|
|
529
|
+
cdnBase: this.cfg.cdnCname
|
|
530
|
+
});
|
|
531
|
+
if (!G) throw Error("Invalid CDN URL");
|
|
532
|
+
let K = this._uploadCollection.add({
|
|
533
|
+
uuid: G.uuid,
|
|
534
|
+
cdnUrl: p,
|
|
535
|
+
cdnUrlModifiers: G.cdnUrlModifiers,
|
|
536
|
+
fileName: U ?? G.filename ?? null,
|
|
537
|
+
silent: H ?? !1,
|
|
538
|
+
source: W ?? UploadSource.API
|
|
539
|
+
});
|
|
540
|
+
return this.getOutputItem(K);
|
|
541
|
+
}, this.addFileFromObject = (p, { silent: H, fileName: U, source: W, fullPath: G } = {}) => {
|
|
542
|
+
let K = this._uploadCollection.add({
|
|
543
|
+
file: p,
|
|
544
|
+
isImage: fileIsImage(p),
|
|
545
|
+
mimeType: p.type,
|
|
546
|
+
fileName: U ?? p.name,
|
|
547
|
+
fileSize: p.size,
|
|
548
|
+
silent: H ?? !1,
|
|
549
|
+
source: W ?? UploadSource.API,
|
|
550
|
+
fullPath: G ?? null
|
|
551
|
+
});
|
|
552
|
+
return this.getOutputItem(K);
|
|
553
|
+
}, this.removeFileByInternalId = (p) => {
|
|
554
|
+
if (!this._uploadCollection.read(p)) throw Error(`File with internalId ${p} not found`);
|
|
555
|
+
this._uploadCollection.remove(p);
|
|
556
|
+
}, this.uploadAll = () => {
|
|
557
|
+
let p = this._uploadCollection.items().filter((p) => {
|
|
558
|
+
let H = this._uploadCollection.read(p);
|
|
559
|
+
return H ? !H.getValue("isRemoved") && !H.getValue("isUploading") && !H.getValue("fileInfo") && H.getValue("errors").length === 0 && !H.getValue("isValidationPending") && !H.getValue("isQueuedForValidation") : !1;
|
|
560
|
+
});
|
|
561
|
+
p.length !== 0 && (this._ctx.pub("*uploadTrigger", new Set(p)), this._sharedInstancesBag.eventEmitter.emit(EventType.COMMON_UPLOAD_START, this.getOutputCollectionState()));
|
|
562
|
+
}, this.openSystemDialog = (p = {}) => {
|
|
563
|
+
let H = serializeCsv(mergeFileTypes([this.cfg.accept ?? "", ...this.cfg.imgOnly ? IMAGE_ACCEPT_LIST : []])), U = "uploadcare-file-input", W = document.createElement("input");
|
|
564
|
+
if (W.setAttribute(U, ""), applyStyles(W, {
|
|
565
|
+
opacity: 0,
|
|
566
|
+
height: 0,
|
|
567
|
+
width: 0,
|
|
568
|
+
visibility: "hidden",
|
|
569
|
+
position: "absolute",
|
|
570
|
+
top: 0,
|
|
571
|
+
left: 0
|
|
572
|
+
}), W.type = "file", W.multiple = this.cfg.multiple, p.captureCamera) {
|
|
573
|
+
W.capture = this.cfg.cameraCapture;
|
|
574
|
+
let { isPhotoEnabled: H, isVideoRecordingEnabled: U } = calcCameraModes(this.cfg);
|
|
575
|
+
p.modeCamera === CameraSourceTypes.PHOTO && H ? W.accept = BASIC_IMAGE_WILDCARD : p.modeCamera === CameraSourceTypes.VIDEO && U ? W.accept = "video/*" : W.accept = [BASIC_IMAGE_WILDCARD, U && "video/*"].filter(Boolean).join(",");
|
|
576
|
+
} else W.accept = H;
|
|
577
|
+
W.addEventListener("change", () => {
|
|
578
|
+
W.files && ([...W.files].forEach((H) => {
|
|
579
|
+
this.addFileFromObject(H, { source: p.captureCamera ? UploadSource.CAMERA : UploadSource.LOCAL });
|
|
580
|
+
}), this._ctx.pub("*currentActivity", ACTIVITY_TYPES.UPLOAD_LIST), this._sharedInstancesBag.modalManager?.open(ACTIVITY_TYPES.UPLOAD_LIST), W.remove());
|
|
581
|
+
}, { once: !0 }), document.querySelectorAll(`[${U}]`).forEach((p) => {
|
|
582
|
+
p.remove();
|
|
583
|
+
}), document.body.appendChild(W), W.dispatchEvent(new MouseEvent("click"));
|
|
584
|
+
}, this.initFlow = (p = !1) => {
|
|
585
|
+
if (this._uploadCollection.size > 0 && !p) this._ctx.pub("*currentActivity", ACTIVITY_TYPES.UPLOAD_LIST), this._sharedInstancesBag.modalManager?.open(ACTIVITY_TYPES.UPLOAD_LIST);
|
|
586
|
+
else if (this._sourceList?.length === 1) {
|
|
587
|
+
let p = this._sourceList[0];
|
|
588
|
+
if (p === "local") {
|
|
589
|
+
this._ctx.pub("*currentActivity", ACTIVITY_TYPES.UPLOAD_LIST), this.openSystemDialog();
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
if (p === "camera" && browserFeatures.htmlMediaCapture) {
|
|
593
|
+
let { isPhotoEnabled: p, isVideoRecordingEnabled: H } = calcCameraModes(this.cfg);
|
|
594
|
+
if (p && H) {
|
|
595
|
+
this._ctx.pub("*currentActivity", ACTIVITY_TYPES.START_FROM);
|
|
596
|
+
return;
|
|
597
|
+
} else if (p || H) {
|
|
598
|
+
this.openSystemDialog({
|
|
599
|
+
captureCamera: !0,
|
|
600
|
+
modeCamera: p ? CameraSourceTypes.PHOTO : CameraSourceTypes.VIDEO
|
|
601
|
+
});
|
|
602
|
+
return;
|
|
603
|
+
} else this.openSystemDialog({
|
|
604
|
+
captureCamera: !0,
|
|
605
|
+
modeCamera: CameraSourceTypes.PHOTO
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
setTimeout(() => {
|
|
609
|
+
if (p !== this._sourceList[0]) return;
|
|
610
|
+
let H = this._sharedInstancesBag.blocksRegistry;
|
|
611
|
+
findBlockInCtx(H, (H) => "type" in H && H.type === p)?.activate();
|
|
612
|
+
}, 0), this._ctx.read("*currentActivity") && this._sharedInstancesBag.modalManager?.open(this._ctx.read("*currentActivity"));
|
|
613
|
+
} else this._ctx.pub("*currentActivity", ACTIVITY_TYPES.START_FROM), this._sharedInstancesBag.modalManager?.open(ACTIVITY_TYPES.START_FROM);
|
|
614
|
+
}, this.doneFlow = () => {
|
|
615
|
+
let p = findBlockInCtx(this._sharedInstancesBag.blocksRegistry, (p) => "doneActivity" in p);
|
|
616
|
+
p && (this._ctx.pub("*currentActivity", p.doneActivity), this._ctx.pub("*history", p.doneActivity ? [p.doneActivity] : []), this._ctx.read("*currentActivity") || this._sharedInstancesBag.modalManager?.closeAll());
|
|
617
|
+
}, this.setCurrentActivity = (p, ...H) => {
|
|
618
|
+
setTimeout(() => {
|
|
619
|
+
if (hasBlockInCtx(this._sharedInstancesBag.blocksRegistry, (H) => H.activityType === p)) {
|
|
620
|
+
this._ctx.pub("*currentActivityParams", H[0] ?? {}), this._ctx.pub("*currentActivity", p);
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
console.warn(`Activity type "${p}" not found in the context`);
|
|
624
|
+
});
|
|
625
|
+
}, this.getCurrentActivity = () => this._ctx.read("*currentActivity"), this.setModalState = (p) => {
|
|
626
|
+
setTimeout(() => {
|
|
627
|
+
if (p && !this._ctx.read("*currentActivity")) {
|
|
628
|
+
console.warn("Can't open modal without current activity. Please use \"setCurrentActivity\" method first.");
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
p ? this._sharedInstancesBag.modalManager?.open(this._ctx.read("*currentActivity")) : (this._sharedInstancesBag.modalManager?.close(this._ctx.read("*currentActivity")), this._ctx.pub("*currentActivity", null));
|
|
632
|
+
});
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
get _uploadCollection() {
|
|
636
|
+
return this._sharedInstancesBag.uploadCollection;
|
|
637
|
+
}
|
|
638
|
+
get cfg() {
|
|
639
|
+
return this._cfg;
|
|
640
|
+
}
|
|
641
|
+
get l10n() {
|
|
642
|
+
return this._l10n;
|
|
643
|
+
}
|
|
644
|
+
removeAllFiles() {
|
|
645
|
+
this._uploadCollection.clearAll();
|
|
646
|
+
}
|
|
647
|
+
getOutputItem(p) {
|
|
648
|
+
let H = PubSub.getCtx(p);
|
|
649
|
+
if (!H) throw Error(`UploaderPublicApi#getOutputItem: Entry with ID "${p}" not found in the upload collection`);
|
|
650
|
+
let U = H.store, W = U.fileInfo, G = U.isRemoved ? "removed" : U.errors.length > 0 ? "failed" : U.fileInfo ? "success" : U.isUploading ? "uploading" : "idle";
|
|
651
|
+
return {
|
|
652
|
+
uuid: W?.uuid ?? U.uuid ?? null,
|
|
653
|
+
internalId: p,
|
|
654
|
+
name: W?.originalFilename ?? U.fileName,
|
|
655
|
+
size: W?.size ?? U.fileSize,
|
|
656
|
+
isImage: W?.isImage ?? U.isImage,
|
|
657
|
+
mimeType: W?.mimeType ?? U.mimeType,
|
|
658
|
+
file: U.file,
|
|
659
|
+
externalUrl: U.externalUrl,
|
|
660
|
+
cdnUrlModifiers: U.cdnUrlModifiers,
|
|
661
|
+
cdnUrl: U.cdnUrl ?? W?.cdnUrl ?? null,
|
|
662
|
+
fullPath: U.fullPath,
|
|
663
|
+
uploadProgress: U.uploadProgress,
|
|
664
|
+
fileInfo: W ?? null,
|
|
665
|
+
metadata: U.metadata ?? W?.metadata ?? null,
|
|
666
|
+
isSuccess: G === "success",
|
|
667
|
+
isUploading: G === "uploading",
|
|
668
|
+
isFailed: G === "failed",
|
|
669
|
+
isRemoved: G === "removed",
|
|
670
|
+
isValidationPending: U.isValidationPending,
|
|
671
|
+
errors: U.errors,
|
|
672
|
+
status: G,
|
|
673
|
+
source: U?.source
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
getOutputCollectionState() {
|
|
677
|
+
return buildOutputCollectionState(this._sharedInstancesBag);
|
|
678
|
+
}
|
|
679
|
+
get _sourceList() {
|
|
680
|
+
let p = [];
|
|
681
|
+
return this.cfg.sourceList && (p = stringToArray(this.cfg.sourceList)), p;
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
const initialUploadEntryData = {
|
|
685
|
+
file: null,
|
|
686
|
+
externalUrl: null,
|
|
687
|
+
fileName: null,
|
|
688
|
+
fileSize: null,
|
|
689
|
+
lastModified: Date.now(),
|
|
690
|
+
uploadProgress: 0,
|
|
691
|
+
uuid: null,
|
|
692
|
+
isImage: !1,
|
|
693
|
+
mimeType: null,
|
|
694
|
+
ctxName: null,
|
|
695
|
+
cdnUrl: null,
|
|
696
|
+
cdnUrlModifiers: null,
|
|
697
|
+
fileInfo: null,
|
|
698
|
+
isUploading: !1,
|
|
699
|
+
abortController: null,
|
|
700
|
+
thumbUrl: null,
|
|
701
|
+
silent: !1,
|
|
702
|
+
source: null,
|
|
703
|
+
fullPath: null,
|
|
704
|
+
metadata: null,
|
|
705
|
+
errors: [],
|
|
706
|
+
uploadError: null,
|
|
707
|
+
isRemoved: !1,
|
|
708
|
+
isQueuedForUploading: !1,
|
|
709
|
+
isValidationPending: !1,
|
|
710
|
+
isQueuedForValidation: !1
|
|
711
|
+
};
|
|
712
|
+
function customUserAgent(p) {
|
|
713
|
+
return getUserAgent$1({
|
|
714
|
+
...p,
|
|
715
|
+
libraryName: PACKAGE_NAME,
|
|
716
|
+
libraryVersion: PACKAGE_VERSION
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
var ACTIVE_ATTR = "active", ACTIVE_PROP = "___ACTIVITY_IS_ACTIVE___", LitActivityBlock = class p extends LitBlock {
|
|
720
|
+
constructor(...p) {
|
|
721
|
+
super(...p), this.historyTracked = !1, this.init$ = activityBlockCtx(this), this._debouncedHistoryFlush = debounce(this._historyFlush.bind(this), 10);
|
|
722
|
+
}
|
|
723
|
+
_deactivate() {
|
|
724
|
+
let H = p._activityCallbacks.get(this);
|
|
725
|
+
this[ACTIVE_PROP] = !1, this.removeAttribute(ACTIVE_ATTR), H?.deactivateCallback?.();
|
|
726
|
+
}
|
|
727
|
+
_activate() {
|
|
728
|
+
let H = p._activityCallbacks.get(this);
|
|
729
|
+
this.$["*historyBack"] = this.historyBack.bind(this), this[ACTIVE_PROP] = !0, this.setAttribute(ACTIVE_ATTR, ""), H?.activateCallback?.(), this._debouncedHistoryFlush(), this.emit(EventType.ACTIVITY_CHANGE, { activity: this.activityType });
|
|
730
|
+
}
|
|
731
|
+
initCallback() {
|
|
732
|
+
super.initCallback(), this.activityType && (this.hasAttribute("activity") || this.setAttribute("activity", this.activityType), this.sub("*currentActivity", (p) => {
|
|
733
|
+
try {
|
|
734
|
+
this.activityType !== p && this[ACTIVE_PROP] ? this._deactivate() : this.activityType === p && !this[ACTIVE_PROP] && this._activate();
|
|
735
|
+
} catch (p) {
|
|
736
|
+
this.telemetryManager.sendEventError(p, `activity "${this.activityType}"`), console.error(`Error in activity "${this.activityType}". `, p);
|
|
737
|
+
let H = this.$["*history"][this.$["*history"].length - 1];
|
|
738
|
+
this.$["*currentActivity"] = H ?? null;
|
|
739
|
+
}
|
|
740
|
+
p || (this.$["*history"] = []);
|
|
741
|
+
}));
|
|
742
|
+
}
|
|
743
|
+
_historyFlush() {
|
|
744
|
+
let p = this.$["*history"];
|
|
745
|
+
p && (p.length > 10 && (p = p.slice(p.length - 11, p.length - 1)), this.historyTracked && p[p.length - 1] !== this.activityType && p.push(this.activityType), this.$["*history"] = p);
|
|
746
|
+
}
|
|
747
|
+
_isActivityRegistered() {
|
|
748
|
+
return !!this.activityType && p._activityCallbacks.has(this);
|
|
749
|
+
}
|
|
750
|
+
static {
|
|
751
|
+
this._activityCallbacks = /* @__PURE__ */ new Map();
|
|
752
|
+
}
|
|
753
|
+
get isActivityActive() {
|
|
754
|
+
return !!this[ACTIVE_PROP];
|
|
755
|
+
}
|
|
756
|
+
get couldOpenActivity() {
|
|
757
|
+
return !0;
|
|
758
|
+
}
|
|
759
|
+
registerActivity(H, U = {}) {
|
|
760
|
+
let { onActivate: W, onDeactivate: G } = U;
|
|
761
|
+
p._activityCallbacks.set(this, {
|
|
762
|
+
activateCallback: W,
|
|
763
|
+
deactivateCallback: G
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
_unregisterActivity() {
|
|
767
|
+
this.isActivityActive && this._deactivate(), p._activityCallbacks.delete(this);
|
|
768
|
+
}
|
|
769
|
+
disconnectedCallback() {
|
|
770
|
+
super.disconnectedCallback(), this._isActivityRegistered() && this._unregisterActivity();
|
|
771
|
+
let H = this.$["*currentActivity"];
|
|
772
|
+
this.blocksRegistry && ([...this.blocksRegistry].find((U) => U instanceof p && U.activityType === H) || (this.$["*currentActivity"] = null, this.modalManager?.closeAll()));
|
|
773
|
+
}
|
|
774
|
+
get activityParams() {
|
|
775
|
+
return this.$["*currentActivityParams"];
|
|
776
|
+
}
|
|
777
|
+
get initActivity() {
|
|
778
|
+
return this.getCssData("--cfg-init-activity") ?? null;
|
|
779
|
+
}
|
|
780
|
+
get doneActivity() {
|
|
781
|
+
return this.getCssData("--cfg-done-activity") ?? null;
|
|
782
|
+
}
|
|
783
|
+
historyBack() {
|
|
784
|
+
let p = this.$["*history"];
|
|
785
|
+
if (p) {
|
|
786
|
+
let H = p.pop();
|
|
787
|
+
for (; H === this.activityType;) H = p.pop();
|
|
788
|
+
let U = !!H;
|
|
789
|
+
H && (U = [...this.blocksRegistry].find((p) => p.activityType === H)?.couldOpenActivity ?? !1), H = U ? H : null, this.$["*currentActivity"] = H ?? null, H && this.modalManager?.open(H), this.$["*history"] = p, H || this.modalManager?.closeAll();
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
LitActivityBlock.activities = ACTIVITY_TYPES;
|
|
794
|
+
var LitUploaderBlock = class p extends LitActivityBlock {
|
|
795
|
+
constructor(...p) {
|
|
796
|
+
super(...p), this.couldBeCtxOwner = !1, this._isCtxOwner = !1, this.init$ = uploaderBlockCtx(this), this._flushOutputItems = debounce(async () => {
|
|
797
|
+
if (this.getOutputData().length !== this.uploadCollection.size) return;
|
|
798
|
+
let p = this.api.getOutputCollectionState();
|
|
799
|
+
this.$["*collectionState"] = p, this.emit(EventType.CHANGE, () => this.api.getOutputCollectionState(), { debounce: !0 }), this.cfg.groupOutput && p.totalCount > 0 && p.status === "success" && this._createGroup(p);
|
|
800
|
+
}, 300), this._handleCollectionUpdate = (p, H, U) => {
|
|
801
|
+
if (this.isConnected) {
|
|
802
|
+
(H.size || U.size) && (this.$["*groupInfo"] = null), this.validationManager.runFileValidators("add", [...H].map((p) => p.uid));
|
|
803
|
+
for (let p of H) p.getValue("silent") || this.emit(EventType.FILE_ADDED, this.api.getOutputItem(p.uid));
|
|
804
|
+
this.validationManager.runCollectionValidators();
|
|
805
|
+
for (let p of U) {
|
|
806
|
+
this.$["*uploadTrigger"].delete(p.uid), this.validationManager.cleanupValidationForEntry(p), p.getValue("abortController")?.abort(), p.setMultipleValues({
|
|
807
|
+
isRemoved: !0,
|
|
808
|
+
abortController: null,
|
|
809
|
+
isUploading: !1,
|
|
810
|
+
uploadProgress: 0
|
|
811
|
+
});
|
|
812
|
+
let H = p?.getValue("thumbUrl");
|
|
813
|
+
H && URL.revokeObjectURL(H), this.emit(EventType.FILE_REMOVED, this.api.getOutputItem(p.uid));
|
|
814
|
+
}
|
|
815
|
+
this.$["*uploadList"] = p.map((p) => ({ uid: p })), this._flushCommonUploadProgress(), this._flushOutputItems();
|
|
816
|
+
}
|
|
817
|
+
}, this._handleCollectionPropertiesUpdate = (p) => {
|
|
818
|
+
if (!this.isConnected) return;
|
|
819
|
+
this._flushOutputItems();
|
|
820
|
+
let H = this.uploadCollection, U = [...new Set(Object.entries(p).filter(([p]) => [
|
|
821
|
+
"uploadError",
|
|
822
|
+
"fileInfo",
|
|
823
|
+
"cdnUrl",
|
|
824
|
+
"cdnUrlModifiers"
|
|
825
|
+
].includes(p)).flatMap(([, p]) => [...p]))];
|
|
826
|
+
if (U.length > 0 && setTimeout(() => {
|
|
827
|
+
if (!this.isConnected) return;
|
|
828
|
+
let H = U.filter((H) => p.fileInfo?.has(H) && !!PubSub.getCtx(H)?.store.fileInfo);
|
|
829
|
+
H.length > 0 && this.validationManager.runFileValidators("upload", H), this.validationManager.runFileValidators("change", U);
|
|
830
|
+
}), p.uploadProgress) {
|
|
831
|
+
for (let H of p.uploadProgress) {
|
|
832
|
+
let p = PubSub.getCtx(H);
|
|
833
|
+
if (!p) continue;
|
|
834
|
+
let { isUploading: U, silent: G } = p.store;
|
|
835
|
+
U && !G && this.emit(EventType.FILE_UPLOAD_PROGRESS, this.api.getOutputItem(H));
|
|
836
|
+
}
|
|
837
|
+
this._flushCommonUploadProgress();
|
|
838
|
+
}
|
|
839
|
+
if (p.isUploading) for (let H of p.isUploading) {
|
|
840
|
+
let p = PubSub.getCtx(H);
|
|
841
|
+
if (!p) continue;
|
|
842
|
+
let { isUploading: U, silent: G } = p.store;
|
|
843
|
+
U && !G && this.emit(EventType.FILE_UPLOAD_START, this.api.getOutputItem(H));
|
|
844
|
+
}
|
|
845
|
+
if (p.fileInfo) {
|
|
846
|
+
for (let H of p.fileInfo) {
|
|
847
|
+
let p = PubSub.getCtx(H);
|
|
848
|
+
if (!p) continue;
|
|
849
|
+
let { fileInfo: U, silent: G } = p.store;
|
|
850
|
+
U && !G && this.emit(EventType.FILE_UPLOAD_SUCCESS, this.api.getOutputItem(H));
|
|
851
|
+
}
|
|
852
|
+
this.cfg.cropPreset && this._setInitialCrop(), this.cfg.cloudImageEditorAutoOpen && this._openCloudImageEditor();
|
|
853
|
+
}
|
|
854
|
+
if (p.errors) {
|
|
855
|
+
this.validationManager.runCollectionValidators();
|
|
856
|
+
for (let H of p.errors) {
|
|
857
|
+
let p = PubSub.getCtx(H);
|
|
858
|
+
if (!p) continue;
|
|
859
|
+
let { errors: U } = p.store;
|
|
860
|
+
U.length > 0 && (this.emit(EventType.FILE_UPLOAD_FAILED, this.api.getOutputItem(H)), this.emit(EventType.COMMON_UPLOAD_FAILED, () => this.api.getOutputCollectionState(), { debounce: !0 }));
|
|
861
|
+
}
|
|
862
|
+
let U = H.findItems((p) => !!p.getValue("fileInfo")), G = H.findItems((p) => p.getValue("errors").length > 0);
|
|
863
|
+
H.size > 0 && G.length === 0 && H.size === U.length && this.$["*collectionErrors"].length === 0 && this.emit(EventType.COMMON_UPLOAD_SUCCESS, this.api.getOutputCollectionState());
|
|
864
|
+
}
|
|
865
|
+
p.cdnUrl && ([...p.cdnUrl].filter((p) => !!this.uploadCollection.read(p)?.getValue("cdnUrl")).forEach((p) => {
|
|
866
|
+
this.emit(EventType.FILE_URL_CHANGED, this.api.getOutputItem(p));
|
|
867
|
+
}), this.$["*groupInfo"] = null);
|
|
868
|
+
}, this._flushCommonUploadProgress = () => {
|
|
869
|
+
let p = 0, H = [...this.$["*uploadTrigger"]].filter((p) => !!this.uploadCollection.read(p));
|
|
870
|
+
H.forEach((H) => {
|
|
871
|
+
let U = this.uploadCollection.readProp(H, "uploadProgress");
|
|
872
|
+
typeof U == "number" && (p += U);
|
|
873
|
+
});
|
|
874
|
+
let U = H.length ? Math.round(p / H.length) : 0;
|
|
875
|
+
this.$["*commonProgress"] !== U && (this.$["*commonProgress"] = U, this.emit(EventType.COMMON_UPLOAD_PROGRESS, this.api.getOutputCollectionState()));
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
get _hasCtxOwner() {
|
|
879
|
+
return this.hasBlockInCtx((H) => H instanceof p ? H._isCtxOwner && H.isConnected && H !== this : !1);
|
|
880
|
+
}
|
|
881
|
+
initCallback() {
|
|
882
|
+
super.initCallback(), this._addSharedContextInstance("*uploadCollection", () => new TypedCollection({
|
|
883
|
+
initialValue: initialUploadEntryData,
|
|
884
|
+
watchList: [
|
|
885
|
+
"uploadProgress",
|
|
886
|
+
"uploadError",
|
|
887
|
+
"fileInfo",
|
|
888
|
+
"errors",
|
|
889
|
+
"cdnUrl",
|
|
890
|
+
"isUploading",
|
|
891
|
+
"isValidationPending"
|
|
892
|
+
]
|
|
893
|
+
})), this._addSharedContextInstance("*secureUploadsManager", (p) => new SecureUploadsManager(p)), this._addSharedContextInstance("*validationManager", (p) => new ValidationManager(p)), this._addSharedContextInstance("*publicApi", (p) => new UploaderPublicApi(p)), !this._hasCtxOwner && this.couldBeCtxOwner && this._initCtxOwner();
|
|
894
|
+
}
|
|
895
|
+
getAPI() {
|
|
896
|
+
return this.api;
|
|
897
|
+
}
|
|
898
|
+
get validationManager() {
|
|
899
|
+
return this._getSharedContextInstance("*validationManager");
|
|
900
|
+
}
|
|
901
|
+
get api() {
|
|
902
|
+
return this._getSharedContextInstance("*publicApi");
|
|
903
|
+
}
|
|
904
|
+
get uploadCollection() {
|
|
905
|
+
return this._getSharedContextInstance("*uploadCollection");
|
|
906
|
+
}
|
|
907
|
+
get secureUploadsManager() {
|
|
908
|
+
return this._getSharedContextInstance("*secureUploadsManager");
|
|
909
|
+
}
|
|
910
|
+
disconnectedCallback() {
|
|
911
|
+
super.disconnectedCallback(), this._isCtxOwner && this._unobserveUploadCollection(), this._flushOutputItems.cancel();
|
|
912
|
+
}
|
|
913
|
+
connectedCallback() {
|
|
914
|
+
super.connectedCallback(), this._isCtxOwner && this._observeUploadCollection();
|
|
915
|
+
}
|
|
916
|
+
_initCtxOwner() {
|
|
917
|
+
this._isCtxOwner = !0, this._observeUploadCollection(), this.subConfigValue("maxConcurrentRequests", (p) => {
|
|
918
|
+
this.$["*uploadQueue"].concurrency = Number(p) || 1;
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
_observeUploadCollection() {
|
|
922
|
+
this._unobserveUploadCollection(), this._unobserveCollection = this.uploadCollection.observeCollection(this._handleCollectionUpdate), this._unobserveCollectionProperties = this.uploadCollection.observeProperties(this._handleCollectionPropertiesUpdate);
|
|
923
|
+
}
|
|
924
|
+
_unobserveUploadCollection() {
|
|
925
|
+
this._unobserveCollectionProperties?.(), this._unobserveCollection?.(), this._unobserveCollectionProperties = void 0, this._unobserveCollection = void 0;
|
|
926
|
+
}
|
|
927
|
+
async _createGroup(p) {
|
|
928
|
+
let H = await this.getUploadClientOptions(), U = p.allEntries.map((p) => p.uuid + (p.cdnUrlModifiers ? `/${p.cdnUrlModifiers}` : "")), G = new AbortController(), K = await uploadFileGroup(U, {
|
|
929
|
+
...H,
|
|
930
|
+
signal: G.signal
|
|
931
|
+
});
|
|
932
|
+
if (this.$["*collectionState"] !== p) {
|
|
933
|
+
G.abort();
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
this.$["*groupInfo"] = K;
|
|
937
|
+
let q = this.api.getOutputCollectionState();
|
|
938
|
+
this.emit(EventType.GROUP_CREATED, q), this.emit(EventType.CHANGE, () => this.api.getOutputCollectionState(), { debounce: !0 }), this.$["*collectionState"] = q;
|
|
939
|
+
}
|
|
940
|
+
_openCloudImageEditor() {
|
|
941
|
+
let [p] = this.uploadCollection.findItems((p) => !!p.getValue("fileInfo") && p.getValue("isImage")).map((p) => this.uploadCollection.read(p));
|
|
942
|
+
p && this.uploadCollection.size === 1 && this.cfg.useCloudImageEditor && this.hasBlockInCtx((p) => p.activityType === LitActivityBlock.activities.CLOUD_IMG_EDIT) && (this.$["*currentActivityParams"] = { internalId: p.uid }, this.$["*currentActivity"] = LitActivityBlock.activities.CLOUD_IMG_EDIT, this.modalManager?.open(LitActivityBlock.activities.CLOUD_IMG_EDIT));
|
|
943
|
+
}
|
|
944
|
+
_setInitialCrop() {
|
|
945
|
+
let p = parseCropPreset(this.cfg.cropPreset);
|
|
946
|
+
if (p) {
|
|
947
|
+
let [H] = p, U = this.uploadCollection.findItems((p) => !!p.getValue("fileInfo") && p.getValue("isImage") && !p.getValue("cdnUrlModifiers")?.includes("/crop/")).map((p) => this.uploadCollection.read(p)).filter(Boolean);
|
|
948
|
+
for (let p of U) {
|
|
949
|
+
let U = p.getValue("fileInfo");
|
|
950
|
+
if (!U || !U.imageInfo) {
|
|
951
|
+
console.warn("Failed to get image info for entry", p.uid);
|
|
952
|
+
continue;
|
|
953
|
+
}
|
|
954
|
+
let { width: W, height: G } = U.imageInfo, K = calculateMaxCenteredCropFrame(W, G, typeof H?.width == "number" && typeof H?.height == "number" && H.width > 0 && H.height > 0 ? H.width / H.height : 1), q = createCdnUrlModifiers(`crop/${K.width}x${K.height}/${K.x},${K.y}`, "preview"), J = p.getValue("cdnUrl");
|
|
955
|
+
if (!J) {
|
|
956
|
+
console.warn("Failed to get cdnUrl for entry", p.uid);
|
|
957
|
+
continue;
|
|
958
|
+
}
|
|
959
|
+
p.setMultipleValues({
|
|
960
|
+
cdnUrlModifiers: q,
|
|
961
|
+
cdnUrl: createCdnUrl(J, q)
|
|
962
|
+
}), this.uploadCollection.size === 1 && this.cfg.useCloudImageEditor && this.hasBlockInCtx((p) => p.activityType === LitActivityBlock.activities.CLOUD_IMG_EDIT) && (this.$["*currentActivityParams"] = { internalId: p.uid }, this.$["*currentActivity"] = LitActivityBlock.activities.CLOUD_IMG_EDIT, this.modalManager?.open(LitActivityBlock.activities.CLOUD_IMG_EDIT));
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
async getMetadataFor(p) {
|
|
967
|
+
let H = this.cfg.metadata || void 0;
|
|
968
|
+
return typeof H == "function" ? await H(this.api.getOutputItem(p)) : H;
|
|
969
|
+
}
|
|
970
|
+
async getUploadClientOptions() {
|
|
971
|
+
let p = await this.secureUploadsManager.getSecureToken().catch(() => null);
|
|
972
|
+
return {
|
|
973
|
+
store: this.cfg.store,
|
|
974
|
+
publicKey: this.cfg.pubkey,
|
|
975
|
+
baseCDN: this.cfg.cdnCname,
|
|
976
|
+
baseURL: this.cfg.baseUrl,
|
|
977
|
+
userAgent: customUserAgent,
|
|
978
|
+
integration: this.cfg.userAgentIntegration,
|
|
979
|
+
secureSignature: p?.secureSignature,
|
|
980
|
+
secureExpire: p?.secureExpire,
|
|
981
|
+
retryThrottledRequestMaxTimes: this.cfg.retryThrottledRequestMaxTimes,
|
|
982
|
+
retryNetworkErrorMaxTimes: this.cfg.retryNetworkErrorMaxTimes,
|
|
983
|
+
multipartMinFileSize: this.cfg.multipartMinFileSize,
|
|
984
|
+
multipartChunkSize: this.cfg.multipartChunkSize,
|
|
985
|
+
maxConcurrentRequests: this.cfg.multipartMaxConcurrentRequests,
|
|
986
|
+
multipartMaxAttempts: this.cfg.multipartMaxAttempts,
|
|
987
|
+
checkForUrlDuplicates: !!this.cfg.checkForUrlDuplicates,
|
|
988
|
+
saveUrlForRecurrentUploads: !!this.cfg.saveUrlForRecurrentUploads
|
|
989
|
+
};
|
|
990
|
+
}
|
|
991
|
+
getOutputData() {
|
|
992
|
+
return getOutputData(this._sharedInstancesBag);
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
LitUploaderBlock.extSrcList = Object.freeze({ ...ExternalUploadSource }), LitUploaderBlock.sourceTypes = Object.freeze({ ...UploadSource });
|
|
996
|
+
export { LitActivityBlock as n, applyStyles as r, LitUploaderBlock as t };
|