@verdaccio/ui-components 5.0.0-next-9.0 → 5.0.0-next-9.2
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/build/Theme/ResetStyles.js +28 -47
- package/build/Theme/ResetStyles.js.map +1 -1
- package/build/Theme/StyleBaseline.js +9 -14
- package/build/Theme/StyleBaseline.js.map +1 -1
- package/build/Theme/ThemeProvider.js +31 -56
- package/build/Theme/ThemeProvider.js.map +1 -1
- package/build/Theme/colors.js +15 -18
- package/build/Theme/colors.js.map +1 -1
- package/build/Theme/index.js +5 -58
- package/build/Theme/modes.js +25 -38
- package/build/Theme/modes.js.map +1 -1
- package/build/Theme/theme.js +18 -31
- package/build/Theme/theme.js.map +1 -1
- package/build/Theme/tokens.js +28 -33
- package/build/Theme/tokens.js.map +1 -1
- package/build/_virtual/_rolldown/runtime.js +11 -0
- package/build/api/use-data-mutation.js +38 -95
- package/build/api/use-data-mutation.js.map +1 -1
- package/build/api/use-data.js +17 -33
- package/build/api/use-data.js.map +1 -1
- package/build/components/ActionBar/ActionBar.js +45 -86
- package/build/components/ActionBar/ActionBar.js.map +1 -1
- package/build/components/ActionBar/ActionBarAction.js +79 -107
- package/build/components/ActionBar/ActionBarAction.js.map +1 -1
- package/build/components/ActionBar/index.js +1 -14
- package/build/components/AppRoute/AppRoute.js +65 -87
- package/build/components/AppRoute/AppRoute.js.map +1 -1
- package/build/components/Author/Author.js +30 -41
- package/build/components/Author/Author.js.map +1 -1
- package/build/components/Author/index.js +1 -14
- package/build/components/Author/styles.js +21 -31
- package/build/components/Author/styles.js.map +1 -1
- package/build/components/CopyClipboard/CopyToClipBoard.js +52 -67
- package/build/components/CopyClipboard/CopyToClipBoard.js.map +1 -1
- package/build/components/CopyClipboard/index.js +2 -21
- package/build/components/CopyClipboard/utils.d.ts +1 -1
- package/build/components/CopyClipboard/utils.js +6 -13
- package/build/components/CopyClipboard/utils.js.map +1 -1
- package/build/components/Dependencies/Dependencies.js +36 -80
- package/build/components/Dependencies/Dependencies.js.map +1 -1
- package/build/components/Dependencies/DependencyBlock.d.ts +3 -3
- package/build/components/Dependencies/DependencyBlock.js +62 -108
- package/build/components/Dependencies/DependencyBlock.js.map +1 -1
- package/build/components/Dependencies/index.js +2 -14
- package/build/components/Dependencies/utits.js +6 -8
- package/build/components/Dependencies/utits.js.map +1 -1
- package/build/components/Deprecated/Deprecated.js +14 -23
- package/build/components/Deprecated/Deprecated.js.map +1 -1
- package/build/components/Deprecated/index.js +1 -14
- package/build/components/Developers/DeveloperType.js +6 -10
- package/build/components/Developers/DeveloperType.js.map +1 -1
- package/build/components/Developers/Developers.js +57 -98
- package/build/components/Developers/Developers.js.map +1 -1
- package/build/components/Developers/Title.js +29 -39
- package/build/components/Developers/Title.js.map +1 -1
- package/build/components/Developers/get-unique-developer-values.js +6 -22
- package/build/components/Developers/get-unique-developer-values.js.map +1 -1
- package/build/components/Developers/index.js +2 -21
- package/build/components/Distribution/Dist.js +38 -44
- package/build/components/Distribution/Dist.js.map +1 -1
- package/build/components/Distribution/index.js +1 -14
- package/build/components/Distribution/styles.js +33 -44
- package/build/components/Distribution/styles.js.map +1 -1
- package/build/components/Engines/Engines.js +66 -88
- package/build/components/Engines/Engines.js.map +1 -1
- package/build/components/Engines/index.js +1 -14
- package/build/components/Engines/styles.js +24 -32
- package/build/components/Engines/styles.js.map +1 -1
- package/build/components/ErrorBoundary/ErrorBoundary.js +27 -66
- package/build/components/ErrorBoundary/ErrorBoundary.js.map +1 -1
- package/build/components/ErrorBoundary/index.js +1 -14
- package/build/components/Forbidden/Forbidden.js +62 -71
- package/build/components/Forbidden/Forbidden.js.map +1 -1
- package/build/components/Forbidden/index.js +1 -14
- package/build/components/FundButton/FundButton.js +52 -73
- package/build/components/FundButton/FundButton.js.map +1 -1
- package/build/components/FundButton/index.js +1 -14
- package/build/components/HeaderInfoDialog/HeaderInfoDialog.js +62 -88
- package/build/components/HeaderInfoDialog/HeaderInfoDialog.js.map +1 -1
- package/build/components/HeaderInfoDialog/index.js +1 -14
- package/build/components/Heading/Heading.d.ts +1 -1
- package/build/components/Heading/Heading.js +13 -23
- package/build/components/Heading/Heading.js.map +1 -1
- package/build/components/Heading/index.js +1 -14
- package/build/components/Help/Help.js +55 -55
- package/build/components/Help/Help.js.map +1 -1
- package/build/components/Help/index.js +1 -14
- package/build/components/Help/styles.js +17 -20
- package/build/components/Help/styles.js.map +1 -1
- package/build/components/Icons/DevsIcons/CommonJS2.js +16 -0
- package/build/components/Icons/DevsIcons/CommonJS2.js.map +1 -0
- package/build/components/Icons/DevsIcons/ES6Module2.js +16 -0
- package/build/components/Icons/DevsIcons/ES6Module2.js.map +1 -0
- package/build/components/Icons/DevsIcons/Git2.js +16 -0
- package/build/components/Icons/DevsIcons/Git2.js.map +1 -0
- package/build/components/Icons/DevsIcons/NodeJS2.js +16 -0
- package/build/components/Icons/DevsIcons/NodeJS2.js.map +1 -0
- package/build/components/Icons/DevsIcons/TypeScript2.js +16 -0
- package/build/components/Icons/DevsIcons/TypeScript2.js.map +1 -0
- package/build/components/Icons/DevsIcons/commonjs.js +6 -0
- package/build/components/Icons/DevsIcons/commonjs.js.map +1 -0
- package/build/components/Icons/DevsIcons/es6module.js +6 -0
- package/build/components/Icons/DevsIcons/es6module.js.map +1 -0
- package/build/components/Icons/DevsIcons/git.js +6 -0
- package/build/components/Icons/DevsIcons/git.js.map +1 -0
- package/build/components/Icons/DevsIcons/index.js +5 -41
- package/build/components/Icons/DevsIcons/nodejs.js +6 -0
- package/build/components/Icons/DevsIcons/nodejs.js.map +1 -0
- package/build/components/Icons/DevsIcons/typescript.js +6 -0
- package/build/components/Icons/DevsIcons/typescript.js.map +1 -0
- package/build/components/Icons/Earth.js +39 -42
- package/build/components/Icons/Earth.js.map +1 -1
- package/build/components/Icons/FileBinary.js +15 -24
- package/build/components/Icons/FileBinary.js.map +1 -1
- package/build/components/Icons/Law.js +18 -25
- package/build/components/Icons/Law.js.map +1 -1
- package/build/components/Icons/License.js +15 -26
- package/build/components/Icons/License.js.map +1 -1
- package/build/components/Icons/Managers/Npm2.js +16 -0
- package/build/components/Icons/Managers/Npm2.js.map +1 -0
- package/build/components/Icons/Managers/Pnpm2.js +16 -0
- package/build/components/Icons/Managers/Pnpm2.js.map +1 -0
- package/build/components/Icons/Managers/Yarn2.js +16 -0
- package/build/components/Icons/Managers/Yarn2.js.map +1 -0
- package/build/components/Icons/Managers/index.js +3 -27
- package/build/components/Icons/Managers/npm.js +6 -0
- package/build/components/Icons/Managers/npm.js.map +1 -0
- package/build/components/Icons/Managers/pnpm.js +6 -0
- package/build/components/Icons/Managers/pnpm.js.map +1 -0
- package/build/components/Icons/Managers/yarn.js +6 -0
- package/build/components/Icons/Managers/yarn.js.map +1 -0
- package/build/components/Icons/SvgIcon.d.ts +2 -6
- package/build/components/Icons/SvgIcon.js +24 -53
- package/build/components/Icons/SvgIcon.js.map +1 -1
- package/build/components/Icons/Time.js +22 -29
- package/build/components/Icons/Time.js.map +1 -1
- package/build/components/Icons/Version.js +20 -27
- package/build/components/Icons/Version.js.map +1 -1
- package/build/components/Icons/index.js +36 -78
- package/build/components/Icons/index.js.map +1 -1
- package/build/components/Install/Install.js +58 -74
- package/build/components/Install/Install.js.map +1 -1
- package/build/components/Install/InstallListItem.js +91 -120
- package/build/components/Install/InstallListItem.js.map +1 -1
- package/build/components/Install/index.js +1 -14
- package/build/components/Keywords/KeywordListItems.js +25 -34
- package/build/components/Keywords/KeywordListItems.js.map +1 -1
- package/build/components/Keywords/Keywords.js +25 -35
- package/build/components/Keywords/Keywords.js.map +1 -1
- package/build/components/Keywords/index.js +1 -14
- package/build/components/Label/Label.js +18 -37
- package/build/components/Label/Label.js.map +1 -1
- package/build/components/Label/index.js +1 -14
- package/build/components/Link/Link.d.ts +3 -1
- package/build/components/Link/Link.js +32 -40
- package/build/components/Link/Link.js.map +1 -1
- package/build/components/Link/index.js +1 -14
- package/build/components/LinkExternal/LinkExternal.d.ts +3 -1
- package/build/components/LinkExternal/LinkExternal.js +19 -30
- package/build/components/LinkExternal/LinkExternal.js.map +1 -1
- package/build/components/LinkExternal/index.js +1 -14
- package/build/components/Loading/Loading.js +14 -20
- package/build/components/Loading/Loading.js.map +1 -1
- package/build/components/Loading/Spinner/Spinner.js +28 -57
- package/build/components/Loading/Spinner/Spinner.js.map +1 -1
- package/build/components/Loading/Spinner/index.js +1 -14
- package/build/components/Loading/index.js +1 -14
- package/build/components/Loading/styles.d.ts +5 -5
- package/build/components/Loading/styles.js +26 -35
- package/build/components/Loading/styles.js.map +1 -1
- package/build/components/LoginDialog/LoginDialog.js +28 -39
- package/build/components/LoginDialog/LoginDialog.js.map +1 -1
- package/build/components/LoginDialog/LoginDialogCloseButton.js +27 -39
- package/build/components/LoginDialog/LoginDialogCloseButton.js.map +1 -1
- package/build/components/LoginDialog/LoginDialogForm.js +17 -26
- package/build/components/LoginDialog/LoginDialogForm.js.map +1 -1
- package/build/components/LoginDialog/LoginDialogFormError.js +30 -51
- package/build/components/LoginDialog/LoginDialogFormError.js.map +1 -1
- package/build/components/LoginDialog/index.js +1 -14
- package/build/components/LoginForm/Login.js +64 -85
- package/build/components/LoginForm/Login.js.map +1 -1
- package/build/components/LoginForm/PasswordField.js +31 -49
- package/build/components/LoginForm/PasswordField.js.map +1 -1
- package/build/components/LoginForm/UsernameField.js +29 -47
- package/build/components/LoginForm/UsernameField.js.map +1 -1
- package/build/components/LoginForm/styles.js +48 -58
- package/build/components/LoginForm/styles.js.map +1 -1
- package/build/components/LoginForm/useLoginForm.js +32 -64
- package/build/components/LoginForm/useLoginForm.js.map +1 -1
- package/build/components/Logo/Logo.js +66 -87
- package/build/components/Logo/Logo.js.map +1 -1
- package/build/components/Logo/img/logo-black-and-white.js +6 -0
- package/build/components/Logo/img/logo-black-and-white.js.map +1 -0
- package/build/components/Logo/img/logo.js +6 -0
- package/build/components/Logo/img/logo.js.map +1 -0
- package/build/components/Logo/index.js +1 -14
- package/build/components/MenuItem/MenuItem.d.ts +1 -1
- package/build/components/MenuItem/MenuItem.js +25 -39
- package/build/components/MenuItem/MenuItem.js.map +1 -1
- package/build/components/MenuItem/index.js +1 -14
- package/build/components/NoItems/NoItems.js +14 -24
- package/build/components/NoItems/NoItems.js.map +1 -1
- package/build/components/NoItems/index.js +1 -14
- package/build/components/NotFound/NotFound.js +63 -72
- package/build/components/NotFound/NotFound.js.map +1 -1
- package/build/components/NotFound/index.js +1 -14
- package/build/components/Package/Package.js +163 -230
- package/build/components/Package/Package.js.map +1 -1
- package/build/components/Package/index.js +1 -14
- package/build/components/Package/styles.d.ts +18 -18
- package/build/components/Package/styles.js +122 -185
- package/build/components/Package/styles.js.map +1 -1
- package/build/components/PackageList/PackageList.js +63 -92
- package/build/components/PackageList/PackageList.js.map +1 -1
- package/build/components/PackageList/index.js +1 -14
- package/build/components/Person/Person.js +36 -46
- package/build/components/Person/Person.js.map +1 -1
- package/build/components/Person/PersonTooltip.js +24 -21
- package/build/components/Person/PersonTooltip.js.map +1 -1
- package/build/components/Person/index.js +1 -14
- package/build/components/Person/utils.js +11 -14
- package/build/components/Person/utils.js.map +1 -1
- package/build/components/RawViewer/RawViewer.js +53 -64
- package/build/components/RawViewer/RawViewer.js.map +1 -1
- package/build/components/RawViewer/index.js +1 -14
- package/build/components/Readme/Readme.d.ts +2 -0
- package/build/components/Readme/Readme.js +40 -56
- package/build/components/Readme/Readme.js.map +1 -1
- package/build/components/Readme/index.js +1 -14
- package/build/components/Readme/utils.js +22 -27
- package/build/components/Readme/utils.js.map +1 -1
- package/build/components/RegistryInfoDialog/RegistryInfoDialog.js +30 -34
- package/build/components/RegistryInfoDialog/RegistryInfoDialog.js.map +1 -1
- package/build/components/RegistryInfoDialog/index.js +1 -14
- package/build/components/RegistryInfoDialog/styles.d.ts +5 -5
- package/build/components/RegistryInfoDialog/styles.js +22 -47
- package/build/components/RegistryInfoDialog/styles.js.map +1 -1
- package/build/components/Repository/Repository.js +79 -101
- package/build/components/Repository/Repository.js.map +1 -1
- package/build/components/Repository/index.js +1 -14
- package/build/components/Search/AutoComplete/AutoComplete.js +33 -76
- package/build/components/Search/AutoComplete/AutoComplete.js.map +1 -1
- package/build/components/Search/AutoComplete/index.js +1 -14
- package/build/components/Search/AutoComplete/styles.d.ts +2 -2
- package/build/components/Search/AutoComplete/styles.js +16 -19
- package/build/components/Search/AutoComplete/styles.js.map +1 -1
- package/build/components/Search/Search.js +91 -176
- package/build/components/Search/Search.js.map +1 -1
- package/build/components/Search/SearchItem.d.ts +3 -3
- package/build/components/Search/SearchItem.js +102 -144
- package/build/components/Search/SearchItem.js.map +1 -1
- package/build/components/Search/index.js +1 -14
- package/build/components/Search/styles.d.ts +2 -2
- package/build/components/Search/styles.js +29 -56
- package/build/components/Search/styles.js.map +1 -1
- package/build/components/Search/utils.js +13 -20
- package/build/components/Search/utils.js.map +1 -1
- package/build/components/SettingsMenu/SettingsMenu.js +94 -108
- package/build/components/SettingsMenu/SettingsMenu.js.map +1 -1
- package/build/components/SettingsMenu/index.js +1 -14
- package/build/components/SideBarTitle/SideBarTitle.js +65 -99
- package/build/components/SideBarTitle/SideBarTitle.js.map +1 -1
- package/build/components/SideBarTitle/index.js +1 -14
- package/build/components/SideBarTitle/utils.js +10 -16
- package/build/components/SideBarTitle/utils.js.map +1 -1
- package/build/components/UpLinks/UpLinks.js +57 -68
- package/build/components/UpLinks/UpLinks.js.map +1 -1
- package/build/components/UpLinks/UplinkLink.js +17 -19
- package/build/components/UpLinks/UplinkLink.js.map +1 -1
- package/build/components/UpLinks/index.js +2 -14
- package/build/components/UpLinks/styles.d.ts +5 -5
- package/build/components/UpLinks/styles.js +27 -48
- package/build/components/UpLinks/styles.js.map +1 -1
- package/build/components/Versions/HistoryList.js +59 -75
- package/build/components/Versions/HistoryList.js.map +1 -1
- package/build/components/Versions/TagList.js +29 -35
- package/build/components/Versions/TagList.js.map +1 -1
- package/build/components/Versions/Versions.js +76 -121
- package/build/components/Versions/Versions.js.map +1 -1
- package/build/components/Versions/index.js +2 -14
- package/build/components/Versions/styles.d.ts +5 -5
- package/build/components/Versions/styles.js +23 -37
- package/build/components/Versions/styles.js.map +1 -1
- package/build/configuration.js +20 -20
- package/build/configuration.js.map +1 -1
- package/build/dark-logo.png +0 -0
- package/build/favicon.ico +0 -0
- package/build/hooks/index.js +2 -21
- package/build/hooks/useLocalStorage.js +22 -59
- package/build/hooks/useLocalStorage.js.map +1 -1
- package/build/hooks/useOnClickOutside.js +14 -30
- package/build/hooks/useOnClickOutside.js.map +1 -1
- package/build/index.js +118 -483
- package/build/layouts/Security/Dialog.js +17 -25
- package/build/layouts/Security/Dialog.js.map +1 -1
- package/build/layouts/Version/Version.js +28 -28
- package/build/layouts/Version/Version.js.map +1 -1
- package/build/layouts/Version/index.js +1 -14
- package/build/mockServiceWorker.js +335 -0
- package/build/pages/Front/Home.js +6 -7
- package/build/pages/Front/Home.js.map +1 -1
- package/build/pages/Front/index.js +2 -14
- package/build/pages/Security/AddUser.js +6 -7
- package/build/pages/Security/AddUser.js.map +1 -1
- package/build/pages/Security/ChangePassword.js +6 -7
- package/build/pages/Security/ChangePassword.js.map +1 -1
- package/build/pages/Security/Login.js +6 -7
- package/build/pages/Security/Login.js.map +1 -1
- package/build/pages/Security/Success.js +6 -7
- package/build/pages/Security/Success.js.map +1 -1
- package/build/pages/Security/index.js +4 -35
- package/build/pages/Version/Version.js +16 -30
- package/build/pages/Version/Version.js.map +1 -1
- package/build/pages/Version/index.js +2 -14
- package/build/providers/AppConfigurationProvider/AppConfigurationProvider.js +51 -72
- package/build/providers/AppConfigurationProvider/AppConfigurationProvider.js.map +1 -1
- package/build/providers/AppConfigurationProvider/index.js +1 -19
- package/build/providers/AuthProvider/AuthProvider.js +37 -100
- package/build/providers/AuthProvider/AuthProvider.js.map +1 -1
- package/build/providers/AuthProvider/index.js +1 -17
- package/build/providers/AuthProvider/utils.js +19 -24
- package/build/providers/AuthProvider/utils.js.map +1 -1
- package/build/providers/DownloadProvider/DownloadProvider.js +29 -71
- package/build/providers/DownloadProvider/DownloadProvider.js.map +1 -1
- package/build/providers/DownloadProvider/index.js +1 -19
- package/build/providers/ManifestsProvider/ManifestsProvider.js +20 -31
- package/build/providers/ManifestsProvider/ManifestsProvider.js.map +1 -1
- package/build/providers/ManifestsProvider/index.js +1 -21
- package/build/providers/PersistenceSettingProvider/PersistenceSettingProvider.js +22 -50
- package/build/providers/PersistenceSettingProvider/PersistenceSettingProvider.js.map +1 -1
- package/build/providers/PersistenceSettingProvider/index.js +1 -19
- package/build/providers/SearchProvider/SearchProvider.js +45 -95
- package/build/providers/SearchProvider/SearchProvider.js.map +1 -1
- package/build/providers/SearchProvider/index.js +1 -25
- package/build/providers/TranslatorProvider/TranslatorProvider.js +33 -71
- package/build/providers/TranslatorProvider/TranslatorProvider.js.map +1 -1
- package/build/providers/TranslatorProvider/index.js +1 -21
- package/build/providers/VersionProvider/VersionProvider.js +42 -57
- package/build/providers/VersionProvider/VersionProvider.js.map +1 -1
- package/build/providers/VersionProvider/index.js +1 -21
- package/build/providers/index.js +16 -94
- package/build/sections/Detail/ContainerContent.js +24 -63
- package/build/sections/Detail/ContainerContent.js.map +1 -1
- package/build/sections/Detail/Detail.js +39 -62
- package/build/sections/Detail/Detail.js.map +1 -1
- package/build/sections/Detail/ReadmeSection.js +8 -18
- package/build/sections/Detail/ReadmeSection.js.map +1 -1
- package/build/sections/Detail/Tabs.js +52 -54
- package/build/sections/Detail/Tabs.js.map +1 -1
- package/build/sections/Detail/index.js +1 -14
- package/build/sections/Footer/Footer.js +94 -137
- package/build/sections/Footer/Footer.js.map +1 -1
- package/build/sections/Footer/index.js +1 -14
- package/build/sections/Footer/styles.d.ts +16 -16
- package/build/sections/Footer/styles.js +58 -89
- package/build/sections/Footer/styles.js.map +1 -1
- package/build/sections/Header/Header.js +89 -144
- package/build/sections/Header/Header.js.map +1 -1
- package/build/sections/Header/HeaderGreetings.js +17 -21
- package/build/sections/Header/HeaderGreetings.js.map +1 -1
- package/build/sections/Header/HeaderLeft.js +31 -32
- package/build/sections/Header/HeaderLeft.js.map +1 -1
- package/build/sections/Header/HeaderMenu.js +43 -50
- package/build/sections/Header/HeaderMenu.js.map +1 -1
- package/build/sections/Header/HeaderRight.js +76 -119
- package/build/sections/Header/HeaderRight.js.map +1 -1
- package/build/sections/Header/HeaderSettingsDialog.js +91 -107
- package/build/sections/Header/HeaderSettingsDialog.js.map +1 -1
- package/build/sections/Header/HeaderToolTip.js +10 -17
- package/build/sections/Header/HeaderToolTip.js.map +1 -1
- package/build/sections/Header/HeaderToolTipIcon.d.ts +1 -1
- package/build/sections/Header/HeaderToolTipIcon.js +56 -63
- package/build/sections/Header/HeaderToolTipIcon.js.map +1 -1
- package/build/sections/Header/LanguageSwitch.js +81 -128
- package/build/sections/Header/LanguageSwitch.js.map +1 -1
- package/build/sections/Header/RegistryInfoContent/RegistryInfoContent.d.ts +6 -6
- package/build/sections/Header/RegistryInfoContent/RegistryInfoContent.js +171 -166
- package/build/sections/Header/RegistryInfoContent/RegistryInfoContent.js.map +1 -1
- package/build/sections/Header/RegistryInfoContent/index.js +1 -14
- package/build/sections/Header/RegistryInfoContent/styles.d.ts +6 -6
- package/build/sections/Header/RegistryInfoContent/styles.js +17 -30
- package/build/sections/Header/RegistryInfoContent/styles.js.map +1 -1
- package/build/sections/Header/index.js +1 -14
- package/build/sections/Header/styles.d.ts +10 -10
- package/build/sections/Header/styles.js +109 -146
- package/build/sections/Header/styles.js.map +1 -1
- package/build/sections/Home/Home.js +17 -21
- package/build/sections/Home/Home.js.map +1 -1
- package/build/sections/Home/index.js +1 -14
- package/build/sections/Security/AddUser.js +116 -179
- package/build/sections/Security/AddUser.js.map +1 -1
- package/build/sections/Security/ChangePassword.js +111 -169
- package/build/sections/Security/ChangePassword.js.map +1 -1
- package/build/sections/Security/Login.js +78 -142
- package/build/sections/Security/Login.js.map +1 -1
- package/build/sections/Security/Success.js +40 -50
- package/build/sections/Security/Success.js.map +1 -1
- package/build/sections/Security/index.js +4 -35
- package/build/sections/Security/styles.js +25 -38
- package/build/sections/Security/styles.js.map +1 -1
- package/build/sections/Security/utils.js +14 -57
- package/build/sections/Security/utils.js.map +1 -1
- package/build/sections/SideBar/Sidebar.js +85 -90
- package/build/sections/SideBar/Sidebar.js.map +1 -1
- package/build/sections/SideBar/index.js +1 -14
- package/build/sections/index.js +4 -21
- package/build/store/api.js +57 -116
- package/build/store/api.js.map +1 -1
- package/build/store/index.js +1 -14
- package/build/store/routes.js +6 -20
- package/build/store/routes.js.map +1 -1
- package/build/store/storage.js +19 -30
- package/build/store/storage.js.map +1 -1
- package/build/store/utils.js +7 -12
- package/build/store/utils.js.map +1 -1
- package/build/ui-components.css +2 -0
- package/build/utils/cli-utils.d.ts +1 -1
- package/build/utils/cli-utils.js +21 -36
- package/build/utils/cli-utils.js.map +1 -1
- package/build/utils/index.js +6 -75
- package/build/utils/loadable.js +12 -25
- package/build/utils/loadable.js.map +1 -1
- package/build/utils/routes.js +8 -31
- package/build/utils/routes.js.map +1 -1
- package/build/utils/schemas.js +15 -27
- package/build/utils/schemas.js.map +1 -1
- package/build/utils/token.js +20 -40
- package/build/utils/token.js.map +1 -1
- package/build/utils/url.js +45 -73
- package/build/utils/url.js.map +1 -1
- package/build/utils/utils.js +55 -111
- package/build/utils/utils.js.map +1 -1
- package/package.json +17 -12
- package/build/AppTest/AppRoute.js +0 -14
- package/build/AppTest/AppRoute.js.map +0 -1
- package/build/Theme/index.js.map +0 -1
- package/build/components/ActionBar/index.js.map +0 -1
- package/build/components/Author/index.js.map +0 -1
- package/build/components/CopyClipboard/index.js.map +0 -1
- package/build/components/Dependencies/index.js.map +0 -1
- package/build/components/Dependencies/types.js +0 -6
- package/build/components/Dependencies/types.js.map +0 -1
- package/build/components/Deprecated/index.js.map +0 -1
- package/build/components/Developers/index.js.map +0 -1
- package/build/components/Distribution/index.js.map +0 -1
- package/build/components/Engines/index.js.map +0 -1
- package/build/components/ErrorBoundary/index.js.map +0 -1
- package/build/components/Forbidden/index.js.map +0 -1
- package/build/components/FundButton/index.js.map +0 -1
- package/build/components/HeaderInfoDialog/index.js.map +0 -1
- package/build/components/Heading/index.js.map +0 -1
- package/build/components/Help/index.js.map +0 -1
- package/build/components/Icons/DevsIcons/CommonJS.js +0 -18
- package/build/components/Icons/DevsIcons/CommonJS.js.map +0 -1
- package/build/components/Icons/DevsIcons/ES6Module.js +0 -18
- package/build/components/Icons/DevsIcons/ES6Module.js.map +0 -1
- package/build/components/Icons/DevsIcons/Git.js +0 -18
- package/build/components/Icons/DevsIcons/Git.js.map +0 -1
- package/build/components/Icons/DevsIcons/NodeJS.js +0 -18
- package/build/components/Icons/DevsIcons/NodeJS.js.map +0 -1
- package/build/components/Icons/DevsIcons/TypeScript.js +0 -18
- package/build/components/Icons/DevsIcons/TypeScript.js.map +0 -1
- package/build/components/Icons/DevsIcons/commonjs.svg +0 -4
- package/build/components/Icons/DevsIcons/es6module.svg +0 -4
- package/build/components/Icons/DevsIcons/git.svg +0 -4
- package/build/components/Icons/DevsIcons/index.js.map +0 -1
- package/build/components/Icons/DevsIcons/nodejs.svg +0 -6
- package/build/components/Icons/DevsIcons/typescript.svg +0 -4
- package/build/components/Icons/Managers/Npm.js +0 -18
- package/build/components/Icons/Managers/Npm.js.map +0 -1
- package/build/components/Icons/Managers/Pnpm.js +0 -18
- package/build/components/Icons/Managers/Pnpm.js.map +0 -1
- package/build/components/Icons/Managers/Yarn.js +0 -18
- package/build/components/Icons/Managers/Yarn.js.map +0 -1
- package/build/components/Icons/Managers/index.js.map +0 -1
- package/build/components/Icons/Managers/npm.svg +0 -15
- package/build/components/Icons/Managers/pnpm.svg +0 -1
- package/build/components/Icons/Managers/yarn.svg +0 -1
- package/build/components/Install/index.js.map +0 -1
- package/build/components/Keywords/index.js.map +0 -1
- package/build/components/Label/index.js.map +0 -1
- package/build/components/Link/index.js.map +0 -1
- package/build/components/LinkExternal/index.js.map +0 -1
- package/build/components/Loading/Spinner/index.js.map +0 -1
- package/build/components/Loading/index.js.map +0 -1
- package/build/components/LoginDialog/index.js.map +0 -1
- package/build/components/Logo/img/logo-black-and-white.svg +0 -1
- package/build/components/Logo/img/logo.svg +0 -1
- package/build/components/Logo/index.js.map +0 -1
- package/build/components/MenuItem/index.js.map +0 -1
- package/build/components/NoItems/index.js.map +0 -1
- package/build/components/NotFound/img/package.svg +0 -1
- package/build/components/NotFound/index.js.map +0 -1
- package/build/components/Package/index.js.map +0 -1
- package/build/components/PackageList/index.js.map +0 -1
- package/build/components/Person/index.js.map +0 -1
- package/build/components/RawViewer/index.js.map +0 -1
- package/build/components/Readme/github-markdown.css +0 -1198
- package/build/components/Readme/index.js.map +0 -1
- package/build/components/Readme/types.js +0 -6
- package/build/components/Readme/types.js.map +0 -1
- package/build/components/RegistryInfoDialog/index.js.map +0 -1
- package/build/components/RegistryInfoDialog/types.js +0 -6
- package/build/components/RegistryInfoDialog/types.js.map +0 -1
- package/build/components/Repository/index.js.map +0 -1
- package/build/components/Search/AutoComplete/index.js.map +0 -1
- package/build/components/Search/index.js.map +0 -1
- package/build/components/SettingsMenu/index.js.map +0 -1
- package/build/components/SideBarTitle/index.js.map +0 -1
- package/build/components/UnAuthorized/UnAuthorized.js +0 -75
- package/build/components/UnAuthorized/UnAuthorized.js.map +0 -1
- package/build/components/UnAuthorized/index.js +0 -14
- package/build/components/UnAuthorized/index.js.map +0 -1
- package/build/components/UpLinks/index.js.map +0 -1
- package/build/components/Versions/index.js.map +0 -1
- package/build/components/Versions/types.js +0 -6
- package/build/components/Versions/types.js.map +0 -1
- package/build/hooks/index.js.map +0 -1
- package/build/index.js.map +0 -1
- package/build/layouts/Version/index.js.map +0 -1
- package/build/pages/Front/index.js.map +0 -1
- package/build/pages/Security/index.js.map +0 -1
- package/build/pages/Version/index.js.map +0 -1
- package/build/providers/AppConfigurationProvider/index.js.map +0 -1
- package/build/providers/AuthProvider/index.js.map +0 -1
- package/build/providers/AuthProvider/types.js +0 -6
- package/build/providers/AuthProvider/types.js.map +0 -1
- package/build/providers/DownloadProvider/index.js.map +0 -1
- package/build/providers/ManifestsProvider/README.md +0 -22
- package/build/providers/ManifestsProvider/index.js.map +0 -1
- package/build/providers/PersistenceSettingProvider/index.js.map +0 -1
- package/build/providers/SearchProvider/index.js.map +0 -1
- package/build/providers/TranslatorProvider/index.js.map +0 -1
- package/build/providers/VersionProvider/README.md +0 -22
- package/build/providers/VersionProvider/index.js.map +0 -1
- package/build/providers/index.js.map +0 -1
- package/build/routes/SecurityRoutes.js +0 -36
- package/build/routes/SecurityRoutes.js.map +0 -1
- package/build/sections/Detail/index.js.map +0 -1
- package/build/sections/Footer/index.js.map +0 -1
- package/build/sections/Header/RegistryInfoContent/index.js.map +0 -1
- package/build/sections/Header/index.js.map +0 -1
- package/build/sections/Home/index.js.map +0 -1
- package/build/sections/Security/index.js.map +0 -1
- package/build/sections/SideBar/index.js.map +0 -1
- package/build/sections/index.js.map +0 -1
- package/build/store/index.js.map +0 -1
- package/build/test/i18n-config.js +0 -26
- package/build/test/i18n-config.js.map +0 -1
- package/build/test/test-react-testing-library.js +0 -147
- package/build/test/test-react-testing-library.js.map +0 -1
- package/build/types/external-modules.d.js +0 -2
- package/build/types/external-modules.d.js.map +0 -1
- package/build/types/index.js +0 -6
- package/build/types/index.js.map +0 -1
- package/build/types/packageMeta.js +0 -6
- package/build/types/packageMeta.js.map +0 -1
- package/build/utils/index.js.map +0 -1
- package/build/utils/token-generate.js +0 -44
- package/build/utils/token-generate.js.map +0 -1
|
@@ -1,76 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
showFooter: true,
|
|
28
|
-
showSearch: true,
|
|
29
|
-
showRaw: true,
|
|
30
|
-
showDownloadTarball: true,
|
|
31
|
-
showUplinks: true,
|
|
32
|
-
hideDeprecatedVersions: false,
|
|
33
|
-
title: 'Verdaccio'
|
|
1
|
+
import { PRIMARY_COLOR as e } from "../../Theme/colors.js";
|
|
2
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as n, useContext as r, useMemo as i } from "react";
|
|
4
|
+
//#region src/providers/AppConfigurationProvider/AppConfigurationProvider.tsx
|
|
5
|
+
var a = {
|
|
6
|
+
primaryColor: e,
|
|
7
|
+
pkgManagers: [
|
|
8
|
+
"yarn",
|
|
9
|
+
"pnpm",
|
|
10
|
+
"npm"
|
|
11
|
+
],
|
|
12
|
+
scope: "",
|
|
13
|
+
base: "",
|
|
14
|
+
flags: {},
|
|
15
|
+
login: !0,
|
|
16
|
+
url_prefix: "",
|
|
17
|
+
showInfo: !0,
|
|
18
|
+
showSettings: !0,
|
|
19
|
+
showThemeSwitch: !0,
|
|
20
|
+
showFooter: !0,
|
|
21
|
+
showSearch: !0,
|
|
22
|
+
showRaw: !0,
|
|
23
|
+
showDownloadTarball: !0,
|
|
24
|
+
showUplinks: !0,
|
|
25
|
+
hideDeprecatedVersions: !1,
|
|
26
|
+
title: "Verdaccio"
|
|
34
27
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// Logic cleanup: Ensure primaryColor is never empty/null
|
|
48
|
-
if (!uiConfiguration.primaryColor) {
|
|
49
|
-
uiConfiguration.primaryColor = _colors.PRIMARY_COLOR;
|
|
50
|
-
}
|
|
51
|
-
return uiConfiguration;
|
|
28
|
+
function o(t = {}) {
|
|
29
|
+
let n = window?.__VERDACCIO_BASENAME_UI_OPTIONS || {}, r = {
|
|
30
|
+
...a,
|
|
31
|
+
...n,
|
|
32
|
+
...t,
|
|
33
|
+
flags: {
|
|
34
|
+
...a.flags,
|
|
35
|
+
...n.flags,
|
|
36
|
+
...t.flags
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
return r.primaryColor ||= e, r;
|
|
52
40
|
}
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
};
|
|
64
|
-
}, [overrideConfig]);
|
|
65
|
-
return /*#__PURE__*/_react["default"].createElement(AppConfigurationContext.Provider, {
|
|
66
|
-
value: value
|
|
67
|
-
}, children);
|
|
68
|
-
};
|
|
69
|
-
var useConfig = exports.useConfig = function useConfig() {
|
|
70
|
-
var ctx = (0, _react.useContext)(AppConfigurationContext);
|
|
71
|
-
if (!ctx) {
|
|
72
|
-
throw new Error('useConfig must be used within AppConfigurationProvider');
|
|
73
|
-
}
|
|
74
|
-
return ctx;
|
|
41
|
+
var s = n(void 0), c = ({ children: e, overrideConfig: n = {} }) => {
|
|
42
|
+
let r = i(() => ({ configOptions: o(n) }), [n]);
|
|
43
|
+
return /* @__PURE__ */ t(s.Provider, {
|
|
44
|
+
value: r,
|
|
45
|
+
children: e
|
|
46
|
+
});
|
|
47
|
+
}, l = () => {
|
|
48
|
+
let e = r(s);
|
|
49
|
+
if (!e) throw Error("useConfig must be used within AppConfigurationProvider");
|
|
50
|
+
return e;
|
|
75
51
|
};
|
|
52
|
+
//#endregion
|
|
53
|
+
export { c as AppConfigurationProvider, l as useConfig };
|
|
54
|
+
|
|
76
55
|
//# sourceMappingURL=AppConfigurationProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppConfigurationProvider.js","names":["
|
|
1
|
+
{"version":3,"file":"AppConfigurationProvider.js","names":["FunctionComponent","ReactNode","React","createContext","useContext","useMemo","TemplateUIOptions","PRIMARY_COLOR","ConfigProviderProps","configOptions","AppConfigurationProviderProps","children","overrideConfig","Partial","DEFAULT_OPTIONS","primaryColor","pkgManagers","scope","base","flags","login","url_prefix","showInfo","showSettings","showThemeSwitch","showFooter","showSearch","showRaw","showDownloadTarball","showUplinks","hideDeprecatedVersions","title","getConfiguration","overrides","windowOptions","window","__VERDACCIO_BASENAME_UI_OPTIONS","uiConfiguration","AppConfigurationContext","undefined","AppConfigurationProvider","value","useConfig","ctx","Error"],"sources":["../../../src/providers/AppConfigurationProvider/AppConfigurationProvider.tsx"],"sourcesContent":["import type { FunctionComponent, ReactNode } from 'react';\nimport React, { createContext, useContext, useMemo } from 'react';\n\nimport type { TemplateUIOptions } from '@verdaccio/types';\n\nimport { PRIMARY_COLOR } from '../../Theme/colors';\n\ntype ConfigProviderProps = {\n configOptions: TemplateUIOptions;\n};\n\ninterface AppConfigurationProviderProps {\n children: ReactNode;\n // Allows passing overrides like { flags: { myFlag: true } }\n overrideConfig?: Partial<TemplateUIOptions>;\n}\n\nconst DEFAULT_OPTIONS: TemplateUIOptions = {\n primaryColor: PRIMARY_COLOR,\n pkgManagers: ['yarn', 'pnpm', 'npm'],\n scope: '',\n base: '',\n flags: {},\n login: true,\n url_prefix: '',\n showInfo: true,\n showSettings: true,\n showThemeSwitch: true,\n showFooter: true,\n showSearch: true,\n showRaw: true,\n showDownloadTarball: true,\n showUplinks: true,\n hideDeprecatedVersions: false,\n title: 'Verdaccio',\n};\n\n/**\n * Merges defaults, window globals, and optional local overrides.\n */\nfunction getConfiguration(overrides: Partial<TemplateUIOptions> = {}): TemplateUIOptions {\n const windowOptions = window?.__VERDACCIO_BASENAME_UI_OPTIONS || {};\n\n const uiConfiguration = {\n ...DEFAULT_OPTIONS,\n ...windowOptions,\n ...overrides,\n flags: {\n ...DEFAULT_OPTIONS.flags,\n ...windowOptions.flags,\n ...overrides.flags,\n },\n };\n\n // Logic cleanup: Ensure primaryColor is never empty/null\n if (!uiConfiguration.primaryColor) {\n uiConfiguration.primaryColor = PRIMARY_COLOR;\n }\n\n return uiConfiguration;\n}\n\nconst AppConfigurationContext = createContext<ConfigProviderProps | undefined>(undefined);\n\nconst AppConfigurationProvider: FunctionComponent<AppConfigurationProviderProps> = ({\n children,\n overrideConfig = {},\n}) => {\n // We include overrideConfig in the dependency array so if the prop\n // changes, the configuration updates accordingly.\n const value = useMemo(\n () => ({\n configOptions: getConfiguration(overrideConfig),\n }),\n [overrideConfig]\n );\n\n return (\n <AppConfigurationContext.Provider value={value}>{children}</AppConfigurationContext.Provider>\n );\n};\n\nexport { AppConfigurationProvider };\n\nexport const useConfig = () => {\n const ctx = useContext(AppConfigurationContext);\n if (!ctx) {\n throw new Error('useConfig must be used within AppConfigurationProvider');\n }\n return ctx;\n};\n"],"mappings":";;;;AAiBA,IAAMc,IAAqC;CACzCC,cAAcR;CACdS,aAAa;EAAC;EAAQ;EAAQ;EAAM;CACpCC,OAAO;CACPC,MAAM;CACNC,OAAO,EAAE;CACTC,OAAO;CACPC,YAAY;CACZC,UAAU;CACVC,cAAc;CACdC,iBAAiB;CACjBC,YAAY;CACZC,YAAY;CACZC,SAAS;CACTC,qBAAqB;CACrBC,aAAa;CACbC,wBAAwB;CACxBC,OAAO;CACR;AAKD,SAASC,EAAiBC,IAAwC,EAAE,EAAqB;CACvF,IAAMC,IAAgBC,QAAQC,mCAAmC,EAAE,EAE7DC,IAAkB;EACtB,GAAGvB;EACH,GAAGoB;EACH,GAAGD;EACHd,OAAO;GACL,GAAGL,EAAgBK;GACnB,GAAGe,EAAcf;GACjB,GAAGc,EAAUd;GACf;EACD;AAOD,QAJA,AACEkB,EAAgBtB,iBAAeR,GAG1B8B;;AAGT,IAAMC,IAA0BnC,EAA+CoC,KAAAA,EAAU,EAEnFC,KAA8E,EAClF7B,aACAC,oBAAiB,EAAC,OACd;CAGJ,IAAM6B,IAAQpC,SACL,EACLI,eAAeuB,EAAiBpB,EAAc,EAC/C,GACD,CAACA,EACH,CAAC;AAED,QACE,kBAAC,EAAwB,UAAzB;EAAyC6B;EAAQ9B;EAA4C,CAAA;GAMpF+B,UAAkB;CAC7B,IAAMC,IAAMvC,EAAWkC,EAAwB;AAC/C,KAAI,CAACK,EACH,OAAUC,MAAM,yDAAyD;AAE3E,QAAOD"}
|
|
@@ -1,19 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "AppConfigurationProvider", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _AppConfigurationProvider.AppConfigurationProvider;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "useConfig", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _AppConfigurationProvider.useConfig;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
var _AppConfigurationProvider = require("./AppConfigurationProvider");
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import "./AppConfigurationProvider.js";
|
|
@@ -1,102 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
import { clearAuth as e, saveAuth as t } from "../../store/storage.js";
|
|
2
|
+
import { getConfiguration as n } from "../../configuration.js";
|
|
3
|
+
import { APIRoute as r } from "../../store/routes.js";
|
|
4
|
+
import { stripTrailingSlash as i } from "../../store/utils.js";
|
|
5
|
+
import { useDataMutation as a } from "../../api/use-data-mutation.js";
|
|
6
|
+
import { getDefaultUserState as o } from "./utils.js";
|
|
7
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
8
|
+
import c, { createContext as l, useContext as u, useEffect as d } from "react";
|
|
9
|
+
//#region src/providers/AuthProvider/AuthProvider.tsx
|
|
10
|
+
var f = l({
|
|
11
|
+
userState: {
|
|
12
|
+
token: null,
|
|
13
|
+
username: null
|
|
14
|
+
},
|
|
15
|
+
setUserState: () => {},
|
|
16
|
+
handleLogin: async () => {},
|
|
17
|
+
logOutUser: () => {}
|
|
18
|
+
}), p = i(n().base), m = ({ children: n }) => {
|
|
19
|
+
let [i, l] = c.useState(o()), { data: u, isMutating: m, trigger: h } = a(p, r.LOGIN, "POST");
|
|
20
|
+
return d(() => {
|
|
21
|
+
u && !m && (l(u), u.username && u.token && t(u.username, u.token));
|
|
22
|
+
}, [u, m]), /* @__PURE__ */ s(f.Provider, {
|
|
23
|
+
value: {
|
|
24
|
+
handleLogin: async (e) => {
|
|
25
|
+
await h(e);
|
|
26
|
+
},
|
|
27
|
+
userState: i,
|
|
28
|
+
logOutUser: () => {
|
|
29
|
+
l(o()), e(), window.location?.reload();
|
|
30
|
+
},
|
|
31
|
+
setUserState: l
|
|
32
|
+
},
|
|
33
|
+
children: n
|
|
34
|
+
});
|
|
35
|
+
}, h = () => u(f);
|
|
36
|
+
//#endregion
|
|
37
|
+
export { f as AuthContext, m as AuthProvider, h as useAuth };
|
|
2
38
|
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.useAuth = exports.AuthProvider = exports.AuthContext = void 0;
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _useDataMutation2 = require("../../api/use-data-mutation");
|
|
10
|
-
var _configuration = require("../../configuration");
|
|
11
|
-
var _routes = require("../../store/routes");
|
|
12
|
-
var _storage = require("../../store/storage");
|
|
13
|
-
var _utils = require("../../store/utils");
|
|
14
|
-
var _utils2 = require("./utils");
|
|
15
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
16
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
17
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
18
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
19
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
20
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
21
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
22
|
-
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
23
|
-
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
24
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
25
|
-
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
26
|
-
var AuthContext = exports.AuthContext = /*#__PURE__*/(0, _react.createContext)({
|
|
27
|
-
userState: {
|
|
28
|
-
token: null,
|
|
29
|
-
username: null
|
|
30
|
-
},
|
|
31
|
-
setUserState: function setUserState() {},
|
|
32
|
-
handleLogin: function () {
|
|
33
|
-
var _handleLogin = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
34
|
-
return _regenerator().w(function (_context) {
|
|
35
|
-
while (1) switch (_context.n) {
|
|
36
|
-
case 0:
|
|
37
|
-
return _context.a(2);
|
|
38
|
-
}
|
|
39
|
-
}, _callee);
|
|
40
|
-
}));
|
|
41
|
-
function handleLogin() {
|
|
42
|
-
return _handleLogin.apply(this, arguments);
|
|
43
|
-
}
|
|
44
|
-
return handleLogin;
|
|
45
|
-
}(),
|
|
46
|
-
logOutUser: function logOutUser() {}
|
|
47
|
-
});
|
|
48
|
-
var configuration = (0, _configuration.getConfiguration)();
|
|
49
|
-
var basePath = (0, _utils.stripTrailingSlash)(configuration.base);
|
|
50
|
-
var AuthProvider = exports.AuthProvider = function AuthProvider(_ref) {
|
|
51
|
-
var children = _ref.children;
|
|
52
|
-
var _React$useState = _react["default"].useState((0, _utils2.getDefaultUserState)()),
|
|
53
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
54
|
-
userState = _React$useState2[0],
|
|
55
|
-
setUserState = _React$useState2[1];
|
|
56
|
-
var _useDataMutation = (0, _useDataMutation2.useDataMutation)(basePath, _routes.APIRoute.LOGIN, 'POST'),
|
|
57
|
-
data = _useDataMutation.data,
|
|
58
|
-
isMutating = _useDataMutation.isMutating,
|
|
59
|
-
trigger = _useDataMutation.trigger;
|
|
60
|
-
var handleLogin = /*#__PURE__*/function () {
|
|
61
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(body) {
|
|
62
|
-
return _regenerator().w(function (_context2) {
|
|
63
|
-
while (1) switch (_context2.n) {
|
|
64
|
-
case 0:
|
|
65
|
-
_context2.n = 1;
|
|
66
|
-
return trigger(body);
|
|
67
|
-
case 1:
|
|
68
|
-
return _context2.a(2);
|
|
69
|
-
}
|
|
70
|
-
}, _callee2);
|
|
71
|
-
}));
|
|
72
|
-
return function handleLogin(_x) {
|
|
73
|
-
return _ref2.apply(this, arguments);
|
|
74
|
-
};
|
|
75
|
-
}();
|
|
76
|
-
var logOutUser = function logOutUser() {
|
|
77
|
-
var _window$location;
|
|
78
|
-
setUserState((0, _utils2.getDefaultUserState)());
|
|
79
|
-
(0, _storage.clearAuth)();
|
|
80
|
-
(_window$location = window.location) === null || _window$location === void 0 || _window$location.reload();
|
|
81
|
-
};
|
|
82
|
-
(0, _react.useEffect)(function () {
|
|
83
|
-
if (data && !isMutating) {
|
|
84
|
-
setUserState(data);
|
|
85
|
-
if (data.username && data.token) {
|
|
86
|
-
(0, _storage.saveAuth)(data.username, data.token);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}, [data, isMutating]);
|
|
90
|
-
return /*#__PURE__*/_react["default"].createElement(AuthContext.Provider, {
|
|
91
|
-
value: {
|
|
92
|
-
handleLogin: handleLogin,
|
|
93
|
-
userState: userState,
|
|
94
|
-
logOutUser: logOutUser,
|
|
95
|
-
setUserState: setUserState
|
|
96
|
-
}
|
|
97
|
-
}, children);
|
|
98
|
-
};
|
|
99
|
-
var useAuth = exports.useAuth = function useAuth() {
|
|
100
|
-
return (0, _react.useContext)(AuthContext);
|
|
101
|
-
};
|
|
102
39
|
//# sourceMappingURL=AuthProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthProvider.js","names":["_react","_interopRequireWildcard","require","_useDataMutation2","_configuration","_routes","_storage","_utils","_utils2","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_slicedToArray","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","a","_arrayLikeToArray","toString","slice","constructor","name","Array","from","test","length","l","Symbol","iterator","u","next","done","push","value","isArray","_regenerator","toStringTag","c","prototype","Generator","create","_regeneratorDefine2","p","y","G","v","d","bind","GeneratorFunction","GeneratorFunctionPrototype","getPrototypeOf","setPrototypeOf","displayName","w","m","_regeneratorDefine","_invoke","enumerable","configurable","writable","asyncGeneratorStep","Promise","resolve","then","_asyncToGenerator","arguments","apply","_next","_throw","AuthContext","exports","createContext","userState","token","username","setUserState","handleLogin","_handleLogin","_callee","_context","logOutUser","configuration","getConfiguration","basePath","stripTrailingSlash","base","AuthProvider","_ref","children","_React$useState","React","useState","getDefaultUserState","_React$useState2","_useDataMutation","useDataMutation","APIRoute","LOGIN","data","isMutating","trigger","_ref2","_callee2","body","_context2","_x","_window$location","clearAuth","window","location","reload","useEffect","saveAuth","createElement","Provider","useAuth","useContext"],"sources":["../../../src/providers/AuthProvider/AuthProvider.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { createContext, useContext, useEffect } from 'react';\n\nimport { useDataMutation } from '../../api/use-data-mutation';\nimport { getConfiguration } from '../../configuration';\nimport { APIRoute } from '../../store/routes';\nimport { clearAuth, saveAuth } from '../../store/storage';\nimport { stripTrailingSlash } from '../../store/utils';\nimport type { LoginBody } from './types';\nimport { getDefaultUserState } from './utils';\n\ninterface AuthContextProps {\n handleLogin: (body: { username: string; password: string }) => Promise<any>;\n setUserState: React.Dispatch<React.SetStateAction<LoginBody>>;\n logOutUser: () => void;\n userState: LoginBody;\n}\n\nexport const AuthContext = createContext<Partial<AuthContextProps>>({\n userState: { token: null, username: null },\n setUserState: () => {},\n handleLogin: async () => {},\n logOutUser: () => {},\n});\n\nconst configuration = getConfiguration();\nconst basePath = stripTrailingSlash(configuration.base);\n\nconst AuthProvider: React.FC<{ children: ReactElement }> = ({ children }) => {\n const [userState, setUserState] = React.useState<LoginBody>(getDefaultUserState());\n const { data, isMutating, trigger } = useDataMutation<LoginBody>(\n basePath,\n APIRoute.LOGIN,\n 'POST'\n );\n\n const handleLogin = async (body: { username: string; password: string }) => {\n await trigger(body);\n };\n\n const logOutUser = () => {\n setUserState(getDefaultUserState());\n clearAuth();\n window.location?.reload();\n };\n\n useEffect(() => {\n if (data && !isMutating) {\n setUserState(data as LoginBody);\n if (data.username && data.token) {\n saveAuth(data.username, data.token);\n }\n }\n }, [data, isMutating]);\n\n return (\n <AuthContext.Provider\n value={{\n handleLogin,\n userState,\n logOutUser,\n setUserState,\n }}\n >\n {children}\n </AuthContext.Provider>\n );\n};\n\nexport { AuthProvider };\n\nexport const useAuth = () => useContext(AuthContext);\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAEA,IAAAM,OAAA,GAAAN,OAAA;AAA8C,SAAAD,wBAAAQ,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAV,uBAAA,YAAAA,wBAAAQ,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,mBAAAT,CAAA,iBAAAA,CAAA,gBAAAU,OAAA,CAAAV,CAAA,0BAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,cAAAM,EAAA,IAAAd,CAAA,gBAAAc,EAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,EAAA,OAAAP,CAAA,IAAAD,CAAA,GAAAW,MAAA,CAAAC,cAAA,KAA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MAAM,CAACC,QAAQ,cAAAH,gBAAA,eAAfA,gBAAA,CAAiBI,MAAM,CAAC,CAAC;EAC3B,CAAC;EAED,IAAAC,gBAAS,EAAC,YAAM;IACd,IAAIb,IAAI,IAAI,CAACC,UAAU,EAAE;MACvBxB,YAAY,CAACuB,IAAiB,CAAC;MAC/B,IAAIA,IAAI,CAACxB,QAAQ,IAAIwB,IAAI,CAACzB,KAAK,EAAE;QAC/B,IAAAuC,iBAAQ,EAACd,IAAI,CAACxB,QAAQ,EAAEwB,IAAI,CAACzB,KAAK,CAAC;MACrC;IACF;EACF,CAAC,EAAE,CAACyB,IAAI,EAAEC,UAAU,CAAC,CAAC;EAEtB,oBACEtH,MAAA,YAAAoI,aAAA,CAAC5C,WAAW,CAAC6C,QAAQ;IACnBjF,KAAK,EAAE;MACL2C,WAAW,EAAXA,WAAW;MACXJ,SAAS,EAATA,SAAS;MACTQ,UAAU,EAAVA,UAAU;MACVL,YAAY,EAAZA;IACF;EAAE,GAEDa,QACmB,CAAC;AAE3B,CAAC;AAIM,IAAM2B,OAAO,GAAA7C,OAAA,CAAA6C,OAAA,GAAG,SAAVA,OAAOA,CAAA;EAAA,OAAS,IAAAC,iBAAU,EAAC/C,WAAW,CAAC;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"AuthProvider.js","names":["ReactElement","React","createContext","useContext","useEffect","useDataMutation","getConfiguration","APIRoute","clearAuth","saveAuth","stripTrailingSlash","LoginBody","getDefaultUserState","AuthContextProps","handleLogin","body","username","password","Promise","setUserState","Dispatch","SetStateAction","logOutUser","userState","AuthContext","Partial","token","configuration","basePath","base","AuthProvider","FC","children","useState","data","isMutating","trigger","LOGIN","window","location","reload","useAuth"],"sources":["../../../src/providers/AuthProvider/AuthProvider.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { createContext, useContext, useEffect } from 'react';\n\nimport { useDataMutation } from '../../api/use-data-mutation';\nimport { getConfiguration } from '../../configuration';\nimport { APIRoute } from '../../store/routes';\nimport { clearAuth, saveAuth } from '../../store/storage';\nimport { stripTrailingSlash } from '../../store/utils';\nimport type { LoginBody } from './types';\nimport { getDefaultUserState } from './utils';\n\ninterface AuthContextProps {\n handleLogin: (body: { username: string; password: string }) => Promise<any>;\n setUserState: React.Dispatch<React.SetStateAction<LoginBody>>;\n logOutUser: () => void;\n userState: LoginBody;\n}\n\nexport const AuthContext = createContext<Partial<AuthContextProps>>({\n userState: { token: null, username: null },\n setUserState: () => {},\n handleLogin: async () => {},\n logOutUser: () => {},\n});\n\nconst configuration = getConfiguration();\nconst basePath = stripTrailingSlash(configuration.base);\n\nconst AuthProvider: React.FC<{ children: ReactElement }> = ({ children }) => {\n const [userState, setUserState] = React.useState<LoginBody>(getDefaultUserState());\n const { data, isMutating, trigger } = useDataMutation<LoginBody>(\n basePath,\n APIRoute.LOGIN,\n 'POST'\n );\n\n const handleLogin = async (body: { username: string; password: string }) => {\n await trigger(body);\n };\n\n const logOutUser = () => {\n setUserState(getDefaultUserState());\n clearAuth();\n window.location?.reload();\n };\n\n useEffect(() => {\n if (data && !isMutating) {\n setUserState(data as LoginBody);\n if (data.username && data.token) {\n saveAuth(data.username, data.token);\n }\n }\n }, [data, isMutating]);\n\n return (\n <AuthContext.Provider\n value={{\n handleLogin,\n userState,\n logOutUser,\n setUserState,\n }}\n >\n {children}\n </AuthContext.Provider>\n );\n};\n\nexport { AuthProvider };\n\nexport const useAuth = () => useContext(AuthContext);\n"],"mappings":";;;;;;;;;AAkBA,IAAawB,IAActB,EAAyC;CAClEqB,WAAW;EAAEG,OAAO;EAAMV,UAAU;EAAM;CAC1CG,oBAAoB;CACpBL,aAAa,YAAY;CACzBQ,kBAAkB;CACnB,CAAC,EAGIM,IAAWlB,EADKJ,GAAkB,CACUuB,KAAK,EAEjDC,KAAsD,EAAEE,kBAAe;CAC3E,IAAM,CAACT,GAAWJ,KAAgBlB,EAAMgC,SAAoBrB,GAAqB,CAAC,EAC5E,EAAEsB,SAAMC,eAAYC,eAAY/B,EACpCuB,GACArB,EAAS8B,OACT,OACD;AAqBD,QATAjC,QAAgB;AACd,EAAI8B,KAAQ,CAACC,MACXhB,EAAae,EAAkB,EAC3BA,EAAKlB,YAAYkB,EAAKR,SACxBjB,EAASyB,EAAKlB,UAAUkB,EAAKR,MAAM;IAGtC,CAACQ,GAAMC,EAAW,CAAC,EAGpB,kBAAC,EAAY,UAAb;EACE,OAAO;GACLrB,aAtBc,OAAOC,MAAiD;AAC1E,UAAMqB,EAAQrB,EAAK;;GAsBfQ;GACAD,kBApBmB;AAGvBgB,IAFAnB,EAAaP,GAAqB,CAAC,EACnCJ,GAAW,EACX8B,OAAOC,UAAUC,QAAQ;;GAkBrBrB;GACD;EAEAa;EACoB,CAAA;GAMdS,UAAgBtC,EAAWqB,EAAY"}
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _AuthProvider = require("./AuthProvider");
|
|
7
|
-
Object.keys(_AuthProvider).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _AuthProvider[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function get() {
|
|
13
|
-
return _AuthProvider[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import "./AuthProvider.js";
|
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return (0, _utils.isTokenExpire)(token) ? {
|
|
15
|
-
token: null,
|
|
16
|
-
username: null
|
|
17
|
-
} : {
|
|
18
|
-
token: token,
|
|
19
|
-
username: username
|
|
20
|
-
};
|
|
1
|
+
import { isTokenExpire as e } from "../../utils/token.js";
|
|
2
|
+
import "../../utils/index.js";
|
|
3
|
+
import { getAuth as t } from "../../store/storage.js";
|
|
4
|
+
//#region src/providers/AuthProvider/utils.ts
|
|
5
|
+
function n() {
|
|
6
|
+
let { token: n, username: r } = t();
|
|
7
|
+
return e(n) ? {
|
|
8
|
+
token: null,
|
|
9
|
+
username: null
|
|
10
|
+
} : {
|
|
11
|
+
token: n,
|
|
12
|
+
username: r
|
|
13
|
+
};
|
|
21
14
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return new Error(message);
|
|
15
|
+
function r(e) {
|
|
16
|
+
let t = e?.info?.message || e?.response?.data?.message || e?.message || "Authentication failed";
|
|
17
|
+
return Error(t);
|
|
26
18
|
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { n as getDefaultUserState, r as normalizeAuthError };
|
|
21
|
+
|
|
27
22
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["
|
|
1
|
+
{"version":3,"file":"utils.js","names":["getAuth","isTokenExpire","LoginBody","getDefaultUserState","token","username","normalizeAuthError","err","Error","message","info","response","data"],"sources":["../../../src/providers/AuthProvider/utils.ts"],"sourcesContent":["import { getAuth } from '../../store/storage';\nimport { isTokenExpire } from '../../utils';\nimport type { LoginBody } from './types';\n\nexport function getDefaultUserState(): LoginBody {\n const { token, username } = getAuth();\n return isTokenExpire(token) ? { token: null, username: null } : { token, username };\n}\n\nexport function normalizeAuthError(err: any): Error {\n const message =\n err?.info?.message || err?.response?.data?.message || err?.message || 'Authentication failed';\n\n return new Error(message);\n}\n"],"mappings":";;;;AAIA,SAAgBG,IAAiC;CAC/C,IAAM,EAAEC,UAAOC,gBAAaL,GAAS;AACrC,QAAOC,EAAcG,EAAM,GAAG;EAAEA,OAAO;EAAMC,UAAU;EAAM,GAAG;EAAED;EAAOC;EAAU;;AAGrF,SAAgBC,EAAmBC,GAAiB;CAClD,IAAME,IACJF,GAAKG,MAAMD,WAAWF,GAAKI,UAAUC,MAAMH,WAAWF,GAAKE,WAAW;AAExE,QAAWD,MAAMC,EAAQ"}
|
|
@@ -1,73 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
case 0:
|
|
28
|
-
link = _ref2.link;
|
|
29
|
-
_context.p = 1;
|
|
30
|
-
_context.n = 2;
|
|
31
|
-
return download({
|
|
32
|
-
link: link
|
|
33
|
-
});
|
|
34
|
-
case 2:
|
|
35
|
-
fileStream = _context.v;
|
|
36
|
-
if (fileStream) {
|
|
37
|
-
_context.n = 3;
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
return _context.a(2);
|
|
41
|
-
case 3:
|
|
42
|
-
fileName = (0, _url.extractFileName)(link);
|
|
43
|
-
(0, _url.downloadFile)(fileStream, fileName);
|
|
44
|
-
_context.n = 5;
|
|
45
|
-
break;
|
|
46
|
-
case 4:
|
|
47
|
-
_context.p = 4;
|
|
48
|
-
_t = _context.v;
|
|
49
|
-
console.error('Error during tarball download:', _t);
|
|
50
|
-
case 5:
|
|
51
|
-
return _context.a(2);
|
|
52
|
-
}
|
|
53
|
-
}, _callee, null, [[1, 4]]);
|
|
54
|
-
}));
|
|
55
|
-
return function (_x) {
|
|
56
|
-
return _ref3.apply(this, arguments);
|
|
57
|
-
};
|
|
58
|
-
}(), [download]);
|
|
59
|
-
return /*#__PURE__*/_react["default"].createElement(DownloadContext.Provider, {
|
|
60
|
-
value: {
|
|
61
|
-
downloadTarball: downloadTarball,
|
|
62
|
-
isDownloading: isDownloading
|
|
63
|
-
}
|
|
64
|
-
}, children);
|
|
65
|
-
};
|
|
66
|
-
var useDownload = exports.useDownload = function useDownload() {
|
|
67
|
-
var context = (0, _react.useContext)(DownloadContext);
|
|
68
|
-
if (!context) {
|
|
69
|
-
throw new Error('useDownload must be used within a DownloadProvider');
|
|
70
|
-
}
|
|
71
|
-
return context;
|
|
1
|
+
import { downloadFile as e, extractFileName as t } from "../../utils/url.js";
|
|
2
|
+
import { useTarballDownload as n } from "../../api/use-data-mutation.js";
|
|
3
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
4
|
+
import { createContext as i, useCallback as a, useContext as o } from "react";
|
|
5
|
+
//#region src/providers/DownloadProvider/DownloadProvider.tsx
|
|
6
|
+
var s = i(void 0), c = ({ children: i }) => {
|
|
7
|
+
let { download: o, isDownloading: c } = n(), l = a(async ({ link: n }) => {
|
|
8
|
+
try {
|
|
9
|
+
let r = await o({ link: n });
|
|
10
|
+
if (!r) return;
|
|
11
|
+
e(r, t(n));
|
|
12
|
+
} catch (e) {
|
|
13
|
+
console.error("Error during tarball download:", e);
|
|
14
|
+
}
|
|
15
|
+
}, [o]);
|
|
16
|
+
return /* @__PURE__ */ r(s.Provider, {
|
|
17
|
+
value: {
|
|
18
|
+
downloadTarball: l,
|
|
19
|
+
isDownloading: c
|
|
20
|
+
},
|
|
21
|
+
children: i
|
|
22
|
+
});
|
|
23
|
+
}, l = () => {
|
|
24
|
+
let e = o(s);
|
|
25
|
+
if (!e) throw Error("useDownload must be used within a DownloadProvider");
|
|
26
|
+
return e;
|
|
72
27
|
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { c as DownloadProvider, l as useDownload };
|
|
30
|
+
|
|
73
31
|
//# sourceMappingURL=DownloadProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DownloadProvider.js","names":["
|
|
1
|
+
{"version":3,"file":"DownloadProvider.js","names":["ReactNode","React","createContext","useCallback","useContext","useTarballDownload","downloadFile","extractFileName","DownloadContextProps","downloadTarball","args","link","Promise","isDownloading","DownloadContext","undefined","DownloadProvider","FC","children","download","fileStream","fileName","error","console","useDownload","context","Error"],"sources":["../../../src/providers/DownloadProvider/DownloadProvider.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport React, { createContext, useCallback, useContext } from 'react';\n\nimport { useTarballDownload } from '../../api/use-data-mutation';\nimport { downloadFile, extractFileName } from '../../utils/url';\n\nexport interface DownloadContextProps {\n downloadTarball: (args: { link: string }) => Promise<void>;\n isDownloading: boolean;\n}\n\nexport const DownloadContext = createContext<DownloadContextProps | undefined>(undefined);\n\nexport const DownloadProvider: React.FC<{ children: ReactNode }> = ({ children }) => {\n const { download, isDownloading } = useTarballDownload();\n\n const downloadTarball = useCallback(\n async ({ link }: { link: string }) => {\n try {\n const fileStream = await download({ link });\n if (!fileStream) return;\n\n const fileName = extractFileName(link);\n downloadFile(fileStream, fileName);\n } catch (error) {\n console.error('Error during tarball download:', error);\n }\n },\n [download]\n );\n\n return (\n <DownloadContext.Provider value={{ downloadTarball, isDownloading }}>\n {children}\n </DownloadContext.Provider>\n );\n};\n\nexport const useDownload = () => {\n const context = useContext(DownloadContext);\n if (!context) {\n throw new Error('useDownload must be used within a DownloadProvider');\n }\n return context;\n};\n"],"mappings":";;;;;AAWA,IAAac,IAAkBZ,EAAgDa,KAAAA,EAAU,EAE5EC,KAAuD,EAAEE,kBAAe;CACnF,IAAM,EAAEC,aAAUN,qBAAkBR,GAAoB,EAElDI,IAAkBN,EACtB,OAAO,EAAEQ,cAA6B;AACpC,MAAI;GACF,IAAMS,IAAa,MAAMD,EAAS,EAAER,SAAM,CAAC;AAC3C,OAAI,CAACS,EAAY;AAGjBd,KAAac,GADIb,EAAgBI,EAAK,CACJ;WAC3BW,GAAO;AACdC,WAAQD,MAAM,kCAAkCA,EAAM;;IAG1D,CAACH,EACH,CAAC;AAED,QACE,kBAAC,EAAgB,UAAjB;EAA0B,OAAO;GAAEV;GAAiBI;GAAe;EAChEK;EACwB,CAAA;GAIlBM,UAAoB;CAC/B,IAAMC,IAAUrB,EAAWU,EAAgB;AAC3C,KAAI,CAACW,EACH,OAAUC,MAAM,qDAAqD;AAEvE,QAAOD"}
|