@openedx/frontend-base 1.0.0-alpha.12 → 1.0.0-alpha.13
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/{index.ts → dist/index.d.ts} +0 -3
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/analytics/MockAnalyticsService.d.ts +50 -0
- package/dist/runtime/analytics/MockAnalyticsService.js +64 -0
- package/dist/runtime/analytics/MockAnalyticsService.js.map +1 -0
- package/dist/runtime/analytics/SegmentAnalyticsService.d.ts +64 -0
- package/dist/runtime/analytics/SegmentAnalyticsService.js +218 -0
- package/dist/runtime/analytics/SegmentAnalyticsService.js.map +1 -0
- package/dist/runtime/analytics/index.d.ts +3 -0
- package/dist/runtime/analytics/index.js +4 -0
- package/dist/runtime/analytics/index.js.map +1 -0
- package/dist/runtime/analytics/interface.d.ts +53 -0
- package/{runtime → dist/runtime}/analytics/interface.js +26 -38
- package/dist/runtime/analytics/interface.js.map +1 -0
- package/dist/runtime/auth/AxiosCsrfTokenService.d.ts +10 -0
- package/dist/runtime/auth/AxiosCsrfTokenService.js +64 -0
- package/dist/runtime/auth/AxiosCsrfTokenService.js.map +1 -0
- package/dist/runtime/auth/AxiosJwtAuthService.d.ts +182 -0
- package/dist/runtime/auth/AxiosJwtAuthService.js +339 -0
- package/dist/runtime/auth/AxiosJwtAuthService.js.map +1 -0
- package/dist/runtime/auth/AxiosJwtTokenService.d.ts +16 -0
- package/dist/runtime/auth/AxiosJwtTokenService.js +130 -0
- package/dist/runtime/auth/AxiosJwtTokenService.js.map +1 -0
- package/dist/runtime/auth/LocalForageCache.d.ts +7 -0
- package/dist/runtime/auth/LocalForageCache.js +78 -0
- package/dist/runtime/auth/LocalForageCache.js.map +1 -0
- package/dist/runtime/auth/MockAuthService.d.ts +209 -0
- package/dist/runtime/auth/MockAuthService.js +256 -0
- package/dist/runtime/auth/MockAuthService.js.map +1 -0
- package/dist/runtime/auth/index.d.ts +3 -0
- package/dist/runtime/auth/index.js +4 -0
- package/dist/runtime/auth/index.js.map +1 -0
- package/dist/runtime/auth/interceptors/createCsrfTokenProviderInterceptor.d.ts +2 -0
- package/dist/runtime/auth/interceptors/createCsrfTokenProviderInterceptor.js +42 -0
- package/dist/runtime/auth/interceptors/createCsrfTokenProviderInterceptor.js.map +1 -0
- package/dist/runtime/auth/interceptors/createJwtTokenProviderInterceptor.d.ts +2 -0
- package/dist/runtime/auth/interceptors/createJwtTokenProviderInterceptor.js +40 -0
- package/dist/runtime/auth/interceptors/createJwtTokenProviderInterceptor.js.map +1 -0
- package/dist/runtime/auth/interceptors/createProcessAxiosRequestErrorInterceptor.d.ts +2 -0
- package/dist/runtime/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js +26 -0
- package/dist/runtime/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js.map +1 -0
- package/dist/runtime/auth/interceptors/createRetryInterceptor.d.ts +3 -0
- package/dist/runtime/auth/interceptors/createRetryInterceptor.js +67 -0
- package/dist/runtime/auth/interceptors/createRetryInterceptor.js.map +1 -0
- package/dist/runtime/auth/interface.d.ts +133 -0
- package/{runtime → dist/runtime}/auth/interface.js +65 -72
- package/dist/runtime/auth/interface.js.map +1 -0
- package/dist/runtime/auth/utils.d.ts +13 -0
- package/dist/runtime/auth/utils.js +66 -0
- package/dist/runtime/auth/utils.js.map +1 -0
- package/dist/runtime/babel.config.d.ts +2 -0
- package/{shell → dist/runtime}/babel.config.js +2 -1
- package/dist/runtime/babel.config.js.map +1 -0
- package/{runtime/config/index.ts → dist/runtime/config/index.d.ts} +28 -123
- package/dist/runtime/config/index.js +323 -0
- package/dist/runtime/config/index.js.map +1 -0
- package/dist/runtime/constants.d.ts +57 -0
- package/{runtime/constants.ts → dist/runtime/constants.js} +1 -11
- package/dist/runtime/constants.js.map +1 -0
- package/dist/runtime/i18n/index.d.ts +3 -0
- package/{runtime → dist/runtime}/i18n/index.js +4 -44
- package/dist/runtime/i18n/index.js.map +1 -0
- package/dist/runtime/i18n/injectIntlWithShim.d.ts +11 -0
- package/dist/runtime/i18n/injectIntlWithShim.js +45 -0
- package/dist/runtime/i18n/injectIntlWithShim.js.map +1 -0
- package/dist/runtime/i18n/lib.d.ts +119 -0
- package/dist/runtime/i18n/lib.js +236 -0
- package/dist/runtime/i18n/lib.js.map +1 -0
- package/dist/runtime/index.d.ts +13 -0
- package/dist/runtime/index.js +14 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/initialize.d.ts +91 -0
- package/dist/runtime/initialize.js +312 -0
- package/dist/runtime/initialize.js.map +1 -0
- package/dist/runtime/jest.config.d.ts +17 -0
- package/dist/runtime/jest.config.js +35 -0
- package/dist/runtime/jest.config.js.map +1 -0
- package/dist/runtime/logging/MockLoggingService.d.ts +28 -0
- package/dist/runtime/logging/MockLoggingService.js +31 -0
- package/dist/runtime/logging/MockLoggingService.js.map +1 -0
- package/dist/runtime/logging/NewRelicLoggingService.d.ts +67 -0
- package/dist/runtime/logging/NewRelicLoggingService.js +175 -0
- package/dist/runtime/logging/NewRelicLoggingService.js.map +1 -0
- package/{runtime/logging/index.ts → dist/runtime/logging/index.d.ts} +1 -7
- package/dist/runtime/logging/index.js +4 -0
- package/dist/runtime/logging/index.js.map +1 -0
- package/dist/runtime/logging/interface.d.ts +38 -0
- package/{runtime → dist/runtime}/logging/interface.js +16 -26
- package/dist/runtime/logging/interface.js.map +1 -0
- package/dist/runtime/logging/types.d.ts +4 -0
- package/dist/runtime/logging/types.js +2 -0
- package/dist/runtime/logging/types.js.map +1 -0
- package/dist/runtime/react/AuthenticatedPageRoute.d.ts +28 -0
- package/{runtime/react/AuthenticatedPageRoute.jsx → dist/runtime/react/AuthenticatedPageRoute.js} +11 -18
- package/dist/runtime/react/AuthenticatedPageRoute.js.map +1 -0
- package/dist/runtime/react/CombinedAppProvider.d.ts +6 -0
- package/dist/runtime/react/CombinedAppProvider.js +24 -0
- package/dist/runtime/react/CombinedAppProvider.js.map +1 -0
- package/dist/runtime/react/CurrentAppContext.d.ts +20 -0
- package/{runtime/react/CurrentAppContext.tsx → dist/runtime/react/CurrentAppContext.js} +3 -7
- package/dist/runtime/react/CurrentAppContext.js.map +1 -0
- package/dist/runtime/react/CurrentAppProvider.d.ts +23 -0
- package/dist/runtime/react/CurrentAppProvider.js +33 -0
- package/dist/runtime/react/CurrentAppProvider.js.map +1 -0
- package/dist/runtime/react/Divider.d.ts +1 -0
- package/dist/runtime/react/Divider.js +5 -0
- package/dist/runtime/react/Divider.js.map +1 -0
- package/dist/runtime/react/ErrorBoundary.d.ts +32 -0
- package/dist/runtime/react/ErrorBoundary.js +40 -0
- package/dist/runtime/react/ErrorBoundary.js.map +1 -0
- package/dist/runtime/react/ErrorPage.d.ts +17 -0
- package/dist/runtime/react/ErrorPage.js +29 -0
- package/dist/runtime/react/ErrorPage.js.map +1 -0
- package/dist/runtime/react/LoginRedirect.d.ts +8 -0
- package/{runtime/react/LoginRedirect.jsx → dist/runtime/react/LoginRedirect.js} +5 -5
- package/dist/runtime/react/LoginRedirect.js.map +1 -0
- package/dist/runtime/react/PageWrap.d.ts +8 -0
- package/{runtime/react/PageWrap.jsx → dist/runtime/react/PageWrap.js} +7 -10
- package/dist/runtime/react/PageWrap.js.map +1 -0
- package/dist/runtime/react/SiteContext.d.ts +24 -0
- package/{runtime/react/SiteContext.tsx → dist/runtime/react/SiteContext.js} +5 -11
- package/dist/runtime/react/SiteContext.js.map +1 -0
- package/dist/runtime/react/SiteProvider.d.ts +29 -0
- package/dist/runtime/react/SiteProvider.js +69 -0
- package/dist/runtime/react/SiteProvider.js.map +1 -0
- package/dist/runtime/react/constants.d.ts +3 -0
- package/{runtime/react/constants.ts → dist/runtime/react/constants.js} +1 -0
- package/dist/runtime/react/constants.js.map +1 -0
- package/{runtime/react/hooks/index.ts → dist/runtime/react/hooks/index.d.ts} +0 -1
- package/dist/runtime/react/hooks/index.js +8 -0
- package/dist/runtime/react/hooks/index.js.map +1 -0
- package/dist/runtime/react/hooks/theme/index.js +3 -0
- package/dist/runtime/react/hooks/theme/index.js.map +1 -0
- package/dist/runtime/react/hooks/theme/useTheme.d.ts +35 -0
- package/dist/runtime/react/hooks/theme/useTheme.js +153 -0
- package/dist/runtime/react/hooks/theme/useTheme.js.map +1 -0
- package/dist/runtime/react/hooks/theme/useThemeConfig.d.ts +16 -0
- package/{runtime/react/hooks/theme/useThemeConfig.ts → dist/runtime/react/hooks/theme/useThemeConfig.js} +11 -16
- package/dist/runtime/react/hooks/theme/useThemeConfig.js.map +1 -0
- package/dist/runtime/react/hooks/theme/useThemeCore.d.ts +10 -0
- package/dist/runtime/react/hooks/theme/useThemeCore.js +40 -0
- package/dist/runtime/react/hooks/theme/useThemeCore.js.map +1 -0
- package/dist/runtime/react/hooks/theme/useThemeVariants.d.ts +17 -0
- package/dist/runtime/react/hooks/theme/useThemeVariants.js +90 -0
- package/dist/runtime/react/hooks/theme/useThemeVariants.js.map +1 -0
- package/dist/runtime/react/hooks/theme/useTrackColorSchemeChoice.d.ts +8 -0
- package/dist/runtime/react/hooks/theme/useTrackColorSchemeChoice.js +30 -0
- package/dist/runtime/react/hooks/theme/useTrackColorSchemeChoice.js.map +1 -0
- package/dist/runtime/react/hooks/theme/utils.d.ts +6 -0
- package/{runtime/react/hooks/theme/utils.ts → dist/runtime/react/hooks/theme/utils.js} +4 -4
- package/dist/runtime/react/hooks/theme/utils.js.map +1 -0
- package/dist/runtime/react/hooks/useActiveRoles.d.ts +2 -0
- package/{runtime/react/hooks/useActiveRoles.ts → dist/runtime/react/hooks/useActiveRoles.js} +6 -8
- package/dist/runtime/react/hooks/useActiveRoles.js.map +1 -0
- package/dist/runtime/react/hooks/useActiveRouteRoleWatcher.d.ts +2 -0
- package/dist/runtime/react/hooks/useActiveRouteRoleWatcher.js +26 -0
- package/dist/runtime/react/hooks/useActiveRouteRoleWatcher.js.map +1 -0
- package/dist/runtime/react/hooks/useAppConfig.d.ts +2 -0
- package/{runtime/react/hooks/useAppConfig.ts → dist/runtime/react/hooks/useAppConfig.js} +3 -4
- package/dist/runtime/react/hooks/useAppConfig.js.map +1 -0
- package/dist/runtime/react/hooks/useAuthenticatedUser.d.ts +2 -0
- package/{runtime/react/hooks/useAuthenticatedUser.ts → dist/runtime/react/hooks/useAuthenticatedUser.js} +3 -4
- package/dist/runtime/react/hooks/useAuthenticatedUser.js.map +1 -0
- package/dist/runtime/react/hooks/useSiteConfig.d.ts +2 -0
- package/{runtime/react/hooks/useSiteConfig.ts → dist/runtime/react/hooks/useSiteConfig.js} +3 -4
- package/dist/runtime/react/hooks/useSiteConfig.js.map +1 -0
- package/dist/runtime/react/hooks/useSiteEvent.d.ts +12 -0
- package/{runtime/react/hooks/useSiteEvent.ts → dist/runtime/react/hooks/useSiteEvent.js} +7 -9
- package/dist/runtime/react/hooks/useSiteEvent.js.map +1 -0
- package/{runtime/react/index.ts → dist/runtime/react/index.d.ts} +0 -1
- package/dist/runtime/react/index.js +19 -0
- package/dist/runtime/react/index.js.map +1 -0
- package/dist/runtime/react/reducers.d.ts +11 -0
- package/dist/runtime/react/reducers.js +28 -0
- package/dist/runtime/react/reducers.js.map +1 -0
- package/dist/runtime/routing/index.js +2 -0
- package/dist/runtime/routing/index.js.map +1 -0
- package/dist/runtime/routing/utils.d.ts +4 -0
- package/dist/runtime/routing/utils.js +28 -0
- package/dist/runtime/routing/utils.js.map +1 -0
- package/dist/runtime/scripts/GoogleAnalyticsLoader.d.ts +12 -0
- package/dist/runtime/scripts/GoogleAnalyticsLoader.js +49 -0
- package/dist/runtime/scripts/GoogleAnalyticsLoader.js.map +1 -0
- package/dist/runtime/scripts/index.js +2 -0
- package/dist/runtime/scripts/index.js.map +1 -0
- package/dist/runtime/setupTest.d.ts +1 -0
- package/{runtime → dist/runtime}/setupTest.js +6 -8
- package/dist/runtime/setupTest.js.map +1 -0
- package/dist/runtime/slots/Slot.d.ts +9 -0
- package/dist/runtime/slots/Slot.js +30 -0
- package/dist/runtime/slots/Slot.js.map +1 -0
- package/dist/runtime/slots/SlotContext.d.ts +7 -0
- package/dist/runtime/slots/SlotContext.js +7 -0
- package/dist/runtime/slots/SlotContext.js.map +1 -0
- package/dist/runtime/slots/hooks.d.ts +12 -0
- package/dist/runtime/slots/hooks.js +29 -0
- package/dist/runtime/slots/hooks.js.map +1 -0
- package/dist/runtime/slots/index.js +7 -0
- package/dist/runtime/slots/index.js.map +1 -0
- package/dist/runtime/slots/layout/DefaultSlotLayout.d.ts +1 -0
- package/dist/runtime/slots/layout/DefaultSlotLayout.js +7 -0
- package/dist/runtime/slots/layout/DefaultSlotLayout.js.map +1 -0
- package/dist/runtime/slots/layout/hooks.d.ts +10 -0
- package/dist/runtime/slots/layout/hooks.js +57 -0
- package/dist/runtime/slots/layout/hooks.js.map +1 -0
- package/dist/runtime/slots/layout/index.js +5 -0
- package/dist/runtime/slots/layout/index.js.map +1 -0
- package/{runtime/slots/layout/types.ts → dist/runtime/slots/layout/types.d.ts} +10 -25
- package/dist/runtime/slots/layout/types.js +12 -0
- package/dist/runtime/slots/layout/types.js.map +1 -0
- package/dist/runtime/slots/layout/utils.d.ts +5 -0
- package/dist/runtime/slots/layout/utils.js +11 -0
- package/dist/runtime/slots/layout/utils.js.map +1 -0
- package/{runtime/slots/types.ts → dist/runtime/slots/types.d.ts} +6 -12
- package/dist/runtime/slots/types.js +7 -0
- package/dist/runtime/slots/types.js.map +1 -0
- package/dist/runtime/slots/utils.d.ts +3 -0
- package/dist/runtime/slots/utils.js +66 -0
- package/dist/runtime/slots/utils.js.map +1 -0
- package/dist/runtime/slots/widget/WidgetContext.d.ts +6 -0
- package/dist/runtime/slots/widget/WidgetContext.js +8 -0
- package/dist/runtime/slots/widget/WidgetContext.js.map +1 -0
- package/dist/runtime/slots/widget/WidgetProvider.d.ts +9 -0
- package/dist/runtime/slots/widget/WidgetProvider.js +18 -0
- package/dist/runtime/slots/widget/WidgetProvider.js.map +1 -0
- package/dist/runtime/slots/widget/hooks.d.ts +13 -0
- package/dist/runtime/slots/widget/hooks.js +104 -0
- package/dist/runtime/slots/widget/hooks.js.map +1 -0
- package/dist/runtime/slots/widget/iframe/IFrameContentWrapper.d.ts +10 -0
- package/dist/runtime/slots/widget/iframe/IFrameContentWrapper.js +42 -0
- package/dist/runtime/slots/widget/iframe/IFrameContentWrapper.js.map +1 -0
- package/dist/runtime/slots/widget/iframe/IFrameContentWrapper.messages.d.ts +13 -0
- package/dist/runtime/slots/widget/iframe/IFrameContentWrapper.messages.js +15 -0
- package/dist/runtime/slots/widget/iframe/IFrameContentWrapper.messages.js.map +1 -0
- package/dist/runtime/slots/widget/iframe/IFrameWidget.d.ts +6 -0
- package/dist/runtime/slots/widget/iframe/IFrameWidget.js +32 -0
- package/dist/runtime/slots/widget/iframe/IFrameWidget.js.map +1 -0
- package/dist/runtime/slots/widget/iframe/constants.d.ts +15 -0
- package/{runtime/slots/widget/iframe/constants.ts → dist/runtime/slots/widget/iframe/constants.js} +2 -4
- package/dist/runtime/slots/widget/iframe/constants.js.map +1 -0
- package/dist/runtime/slots/widget/iframe/hooks.d.ts +64 -0
- package/dist/runtime/slots/widget/iframe/hooks.js +144 -0
- package/dist/runtime/slots/widget/iframe/hooks.js.map +1 -0
- package/{runtime/slots/widget/iframe/index.ts → dist/runtime/slots/widget/iframe/index.d.ts} +1 -4
- package/dist/runtime/slots/widget/iframe/index.js +3 -0
- package/dist/runtime/slots/widget/iframe/index.js.map +1 -0
- package/{runtime/slots/widget/iframe/types.ts → dist/runtime/slots/widget/iframe/types.d.ts} +2 -4
- package/dist/runtime/slots/widget/iframe/types.js +3 -0
- package/dist/runtime/slots/widget/iframe/types.js.map +1 -0
- package/dist/runtime/slots/widget/index.js +6 -0
- package/dist/runtime/slots/widget/index.js.map +1 -0
- package/{runtime/slots/widget/types.ts → dist/runtime/slots/widget/types.d.ts} +50 -84
- package/dist/runtime/slots/widget/types.js +41 -0
- package/dist/runtime/slots/widget/types.js.map +1 -0
- package/dist/runtime/slots/widget/utils.d.ts +22 -0
- package/dist/runtime/slots/widget/utils.js +166 -0
- package/dist/runtime/slots/widget/utils.js.map +1 -0
- package/{runtime/subscriptions.ts → dist/runtime/subscriptions.d.ts} +5 -41
- package/dist/runtime/subscriptions.js +48 -0
- package/dist/runtime/subscriptions.js.map +1 -0
- package/{runtime/testing/index.ts → dist/runtime/testing/index.d.ts} +0 -1
- package/dist/runtime/testing/index.js +9 -0
- package/dist/runtime/testing/index.js.map +1 -0
- package/dist/runtime/testing/initializeMockApp.d.ts +46 -0
- package/{runtime/testing/initializeMockApp.ts → dist/runtime/testing/initializeMockApp.js} +26 -41
- package/dist/runtime/testing/initializeMockApp.js.map +1 -0
- package/dist/runtime/testing/mockMessages.d.ts +22 -0
- package/dist/runtime/testing/mockMessages.js +23 -0
- package/dist/runtime/testing/mockMessages.js.map +1 -0
- package/dist/runtime/utils.d.ts +95 -0
- package/{runtime → dist/runtime}/utils.js +55 -70
- package/dist/runtime/utils.js.map +1 -0
- package/dist/shell/DefaultLayout.d.ts +1 -0
- package/dist/shell/DefaultLayout.js +7 -0
- package/dist/shell/DefaultLayout.js.map +1 -0
- package/dist/shell/DefaultMain.d.ts +1 -0
- package/dist/shell/DefaultMain.js +6 -0
- package/dist/shell/DefaultMain.js.map +1 -0
- package/dist/shell/Logo.d.ts +6 -0
- package/dist/shell/Logo.js +11 -0
- package/dist/shell/Logo.js.map +1 -0
- package/dist/shell/Shell.d.ts +1 -0
- package/dist/shell/Shell.js +10 -0
- package/dist/shell/Shell.js.map +1 -0
- package/dist/shell/Shell.messages.d.ts +58 -0
- package/dist/shell/Shell.messages.js +60 -0
- package/dist/shell/Shell.messages.js.map +1 -0
- package/dist/shell/app.d.ts +3 -0
- package/dist/shell/app.js +35 -0
- package/dist/shell/app.js.map +1 -0
- package/dist/shell/babel.config.d.ts +2 -0
- package/{runtime → dist/shell}/babel.config.js +2 -1
- package/dist/shell/babel.config.js.map +1 -0
- package/dist/shell/dev/devFooter/app.d.ts +3 -0
- package/dist/shell/dev/devFooter/app.js +36 -0
- package/dist/shell/dev/devFooter/app.js.map +1 -0
- package/dist/shell/dev/devFooter/index.js +2 -0
- package/dist/shell/dev/devFooter/index.js.map +1 -0
- package/dist/shell/dev/devHeader/BarContext.d.ts +7 -0
- package/dist/shell/dev/devHeader/BarContext.js +8 -0
- package/dist/shell/dev/devHeader/BarContext.js.map +1 -0
- package/dist/shell/dev/devHeader/BarLink.d.ts +1 -0
- package/dist/shell/dev/devHeader/BarLink.js +10 -0
- package/dist/shell/dev/devHeader/BarLink.js.map +1 -0
- package/dist/shell/dev/devHeader/BarProvider.d.ts +6 -0
- package/dist/shell/dev/devHeader/BarProvider.js +16 -0
- package/dist/shell/dev/devHeader/BarProvider.js.map +1 -0
- package/dist/shell/dev/devHeader/CoursesLink.d.ts +1 -0
- package/dist/shell/dev/devHeader/CoursesLink.js +10 -0
- package/dist/shell/dev/devHeader/CoursesLink.js.map +1 -0
- package/dist/shell/dev/devHeader/FooContext.d.ts +7 -0
- package/dist/shell/dev/devHeader/FooContext.js +8 -0
- package/dist/shell/dev/devHeader/FooContext.js.map +1 -0
- package/dist/shell/dev/devHeader/FooLink.d.ts +1 -0
- package/dist/shell/dev/devHeader/FooLink.js +10 -0
- package/dist/shell/dev/devHeader/FooLink.js.map +1 -0
- package/dist/shell/dev/devHeader/FooProvider.d.ts +6 -0
- package/dist/shell/dev/devHeader/FooProvider.js +16 -0
- package/dist/shell/dev/devHeader/FooProvider.js.map +1 -0
- package/dist/shell/dev/devHeader/app.d.ts +3 -0
- package/dist/shell/dev/devHeader/app.js +34 -0
- package/dist/shell/dev/devHeader/app.js.map +1 -0
- package/dist/shell/dev/devHeader/index.js +2 -0
- package/dist/shell/dev/devHeader/index.js.map +1 -0
- package/dist/shell/dev/devHeader/providers.d.ts +3 -0
- package/dist/shell/dev/devHeader/providers.js +8 -0
- package/dist/shell/dev/devHeader/providers.js.map +1 -0
- package/dist/shell/dev/devHome/HomePage.d.ts +1 -0
- package/dist/shell/dev/devHome/HomePage.js +13 -0
- package/dist/shell/dev/devHome/HomePage.js.map +1 -0
- package/dist/shell/dev/devHome/app.d.ts +3 -0
- package/dist/shell/dev/devHome/app.js +16 -0
- package/dist/shell/dev/devHome/app.js.map +1 -0
- package/dist/shell/dev/devHome/i18n/index.d.ts +27 -0
- package/dist/shell/dev/devHome/i18n/index.js +28 -0
- package/dist/shell/dev/devHome/i18n/index.js.map +1 -0
- package/dist/shell/dev/devHome/index.js +2 -0
- package/dist/shell/dev/devHome/index.js.map +1 -0
- package/dist/shell/dev/devHome/messages.d.ts +8 -0
- package/dist/shell/dev/devHome/messages.js +10 -0
- package/dist/shell/dev/devHome/messages.js.map +1 -0
- package/dist/shell/dev/devUser/app.d.ts +3 -0
- package/dist/shell/dev/devUser/app.js +22 -0
- package/dist/shell/dev/devUser/app.js.map +1 -0
- package/dist/shell/dev/devUser/index.js +2 -0
- package/dist/shell/dev/devUser/index.js.map +1 -0
- package/dist/shell/dev/index.js +6 -0
- package/dist/shell/dev/index.js.map +1 -0
- package/dist/shell/dev/slotShowcase/HorizontalSlotLayout.d.ts +1 -0
- package/dist/shell/dev/slotShowcase/HorizontalSlotLayout.js +7 -0
- package/dist/shell/dev/slotShowcase/HorizontalSlotLayout.js.map +1 -0
- package/dist/shell/dev/slotShowcase/LayoutWithOptions.d.ts +1 -0
- package/dist/shell/dev/slotShowcase/LayoutWithOptions.js +9 -0
- package/dist/shell/dev/slotShowcase/LayoutWithOptions.js.map +1 -0
- package/dist/shell/dev/slotShowcase/SlotShowcasePage.d.ts +1 -0
- package/dist/shell/dev/slotShowcase/SlotShowcasePage.js +8 -0
- package/dist/shell/dev/slotShowcase/SlotShowcasePage.js.map +1 -0
- package/dist/shell/dev/slotShowcase/WidgetWithOptions.d.ts +1 -0
- package/dist/shell/dev/slotShowcase/WidgetWithOptions.js +8 -0
- package/dist/shell/dev/slotShowcase/WidgetWithOptions.js.map +1 -0
- package/dist/shell/dev/slotShowcase/app.d.ts +3 -0
- package/dist/shell/dev/slotShowcase/app.js +336 -0
- package/dist/shell/dev/slotShowcase/app.js.map +1 -0
- package/dist/shell/dev/slotShowcase/index.js +2 -0
- package/dist/shell/dev/slotShowcase/index.js.map +1 -0
- package/dist/shell/footer/CenterLinks.d.ts +1 -0
- package/dist/shell/footer/CenterLinks.js +7 -0
- package/dist/shell/footer/CenterLinks.js.map +1 -0
- package/dist/shell/footer/CopyrightNotice.d.ts +10 -0
- package/dist/shell/footer/CopyrightNotice.js +10 -0
- package/dist/shell/footer/CopyrightNotice.js.map +1 -0
- package/dist/shell/footer/Footer.d.ts +1 -0
- package/dist/shell/footer/Footer.js +12 -0
- package/dist/shell/footer/Footer.js.map +1 -0
- package/dist/shell/footer/LabeledLinkColumn.d.ts +1 -0
- package/dist/shell/footer/LabeledLinkColumn.js +11 -0
- package/dist/shell/footer/LabeledLinkColumn.js.map +1 -0
- package/dist/shell/footer/LanguageMenu.d.ts +1 -0
- package/dist/shell/footer/LanguageMenu.js +16 -0
- package/dist/shell/footer/LanguageMenu.js.map +1 -0
- package/dist/shell/footer/LanguageMenuItem.d.ts +8 -0
- package/dist/shell/footer/LanguageMenuItem.js +11 -0
- package/dist/shell/footer/LanguageMenuItem.js.map +1 -0
- package/dist/shell/footer/LeftLinks.d.ts +1 -0
- package/dist/shell/footer/LeftLinks.js +7 -0
- package/dist/shell/footer/LeftLinks.js.map +1 -0
- package/dist/shell/footer/LegalNotices.d.ts +1 -0
- package/dist/shell/footer/LegalNotices.js +10 -0
- package/dist/shell/footer/LegalNotices.js.map +1 -0
- package/dist/shell/footer/PoweredBy.d.ts +1 -0
- package/dist/shell/footer/PoweredBy.js +9 -0
- package/dist/shell/footer/PoweredBy.js.map +1 -0
- package/dist/shell/footer/RevealLinks.d.ts +1 -0
- package/dist/shell/footer/RevealLinks.js +16 -0
- package/dist/shell/footer/RevealLinks.js.map +1 -0
- package/dist/shell/footer/RightLinks.d.ts +1 -0
- package/dist/shell/footer/RightLinks.js +7 -0
- package/dist/shell/footer/RightLinks.js.map +1 -0
- package/dist/shell/footer/app.d.ts +3 -0
- package/dist/shell/footer/app.js +59 -0
- package/dist/shell/footer/app.js.map +1 -0
- package/dist/shell/footer/data/api.d.ts +1 -0
- package/dist/shell/footer/data/api.js +45 -0
- package/dist/shell/footer/data/api.js.map +1 -0
- package/dist/shell/footer/index.js +3 -0
- package/dist/shell/footer/index.js.map +1 -0
- package/dist/shell/header/AuthenticatedMenu.d.ts +5 -0
- package/dist/shell/header/AuthenticatedMenu.js +13 -0
- package/dist/shell/header/AuthenticatedMenu.js.map +1 -0
- package/dist/shell/header/Header.d.ts +1 -0
- package/dist/shell/header/Header.js +8 -0
- package/dist/shell/header/Header.js.map +1 -0
- package/dist/shell/header/anonymous-menu/AnonymousMenu.d.ts +5 -0
- package/dist/shell/header/anonymous-menu/AnonymousMenu.js +7 -0
- package/dist/shell/header/anonymous-menu/AnonymousMenu.js.map +1 -0
- package/dist/shell/header/anonymous-menu/LoginButton.d.ts +3 -0
- package/dist/shell/header/anonymous-menu/LoginButton.js +22 -0
- package/dist/shell/header/anonymous-menu/LoginButton.js.map +1 -0
- package/dist/shell/header/anonymous-menu/RegisterButton.d.ts +3 -0
- package/dist/shell/header/anonymous-menu/RegisterButton.js +22 -0
- package/dist/shell/header/anonymous-menu/RegisterButton.js.map +1 -0
- package/dist/shell/header/app.d.ts +3 -0
- package/dist/shell/header/app.js +119 -0
- package/dist/shell/header/app.js.map +1 -0
- package/dist/shell/header/desktop/DesktopLayout.d.ts +1 -0
- package/dist/shell/header/desktop/DesktopLayout.js +9 -0
- package/dist/shell/header/desktop/DesktopLayout.js.map +1 -0
- package/dist/shell/header/desktop/PrimaryNavLinks.d.ts +1 -0
- package/dist/shell/header/desktop/PrimaryNavLinks.js +7 -0
- package/dist/shell/header/desktop/PrimaryNavLinks.js.map +1 -0
- package/dist/shell/header/desktop/SecondaryNavLinks.d.ts +1 -0
- package/dist/shell/header/desktop/SecondaryNavLinks.js +7 -0
- package/dist/shell/header/desktop/SecondaryNavLinks.js.map +1 -0
- package/dist/shell/header/index.js +3 -0
- package/dist/shell/header/index.js.map +1 -0
- package/dist/shell/header/mobile/MobileLayout.d.ts +1 -0
- package/dist/shell/header/mobile/MobileLayout.js +17 -0
- package/dist/shell/header/mobile/MobileLayout.js.map +1 -0
- package/dist/shell/header/mobile/MobileNavLinks.d.ts +1 -0
- package/dist/shell/header/mobile/MobileNavLinks.js +7 -0
- package/dist/shell/header/mobile/MobileNavLinks.js.map +1 -0
- package/dist/shell/i18n/index.d.ts +25 -0
- package/dist/shell/i18n/index.js +26 -0
- package/dist/shell/i18n/index.js.map +1 -0
- package/dist/shell/index.js +8 -0
- package/dist/shell/index.js.map +1 -0
- package/dist/shell/jest.config.d.ts +16 -0
- package/{tools/dist/jest → dist/shell}/jest.config.js +13 -11
- package/dist/shell/jest.config.js.map +1 -0
- package/dist/shell/menus/LinkMenuItem.d.ts +9 -0
- package/dist/shell/menus/LinkMenuItem.js +36 -0
- package/dist/shell/menus/LinkMenuItem.js.map +1 -0
- package/dist/shell/menus/NavDropdownMenuSlot.d.ts +7 -0
- package/dist/shell/menus/NavDropdownMenuSlot.js +14 -0
- package/dist/shell/menus/NavDropdownMenuSlot.js.map +1 -0
- package/dist/shell/menus/ProfileLinkMenuItem.d.ts +8 -0
- package/dist/shell/menus/ProfileLinkMenuItem.js +16 -0
- package/dist/shell/menus/ProfileLinkMenuItem.js.map +1 -0
- package/dist/shell/menus/data/utils.d.ts +4 -0
- package/dist/shell/menus/data/utils.js +13 -0
- package/dist/shell/menus/data/utils.js.map +1 -0
- package/dist/shell/router/createRouter.d.ts +1 -0
- package/{shell/router/createRouter.ts → dist/shell/router/createRouter.js} +9 -11
- package/dist/shell/router/createRouter.js.map +1 -0
- package/dist/shell/router/getAppRoutes.d.ts +2 -0
- package/dist/shell/router/getAppRoutes.js +14 -0
- package/dist/shell/router/getAppRoutes.js.map +1 -0
- package/dist/shell/setupTest.d.ts +1 -0
- package/{shell → dist/shell}/setupTest.js +6 -7
- package/dist/shell/setupTest.js.map +1 -0
- package/dist/shell/site.config.dev.d.ts +4 -0
- package/dist/shell/site.config.dev.js +43 -0
- package/dist/shell/site.config.dev.js.map +1 -0
- package/dist/shell/site.d.ts +1 -0
- package/dist/shell/site.js +35 -0
- package/dist/shell/site.js.map +1 -0
- package/dist/tools/babel/babel.config.d.ts +12 -0
- package/dist/tools/cli/commands/serve.d.ts +1 -0
- package/dist/tools/cli/intl-imports.d.ts +7 -0
- package/dist/tools/cli/intl-imports.test.d.ts +1 -0
- package/dist/tools/cli/openedx.d.ts +2 -0
- package/{tools/dist → dist/tools}/cli/openedx.js +1 -1
- package/dist/tools/cli/transifex-utils.d.ts +2 -0
- package/dist/tools/cli/utils/ensureConfigFilenameOption.d.ts +2 -0
- package/dist/tools/cli/utils/formatter.d.ts +1 -0
- package/dist/tools/cli/utils/getResolvedConfigPath.d.ts +2 -0
- package/dist/tools/cli/utils/prettyPrintTitle.d.ts +1 -0
- package/dist/tools/cli/utils/printUsage.d.ts +1 -0
- package/dist/tools/config-helpers/createConfig.d.ts +2 -0
- package/dist/tools/config-helpers/createLintConfig.d.ts +2 -0
- package/dist/tools/config-helpers/getBaseConfig.d.ts +2 -0
- package/dist/tools/defaultConfigPaths.d.ts +8 -0
- package/dist/tools/eslint/base.eslint.config.d.ts +3 -0
- package/dist/tools/eslint.config.d.ts +3 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/jest/jest.config.d.ts +15 -0
- package/dist/tools/jest.config.d.ts +8 -0
- package/dist/tools/types.d.ts +18 -0
- package/{tools/dist → dist/tools}/typescript/tsconfig.json +2 -1
- package/dist/tools/webpack/common-config/all/getCodeRules.d.ts +2 -0
- package/dist/tools/webpack/common-config/all/getFileLoaderRules.d.ts +11 -0
- package/dist/tools/webpack/common-config/all/getImageMinimizer.d.ts +5 -0
- package/dist/tools/webpack/common-config/all/getStylesheetRule.d.ts +8 -0
- package/dist/tools/webpack/common-config/dev/getDevServer.d.ts +2 -0
- package/dist/tools/webpack/common-config/index.d.ts +6 -0
- package/dist/tools/webpack/common-config/site/getHtmlWebpackPlugin.d.ts +2 -0
- package/dist/tools/webpack/plugins/html-webpack-new-relic-plugin/HtmlWebpackNewRelicPlugin.d.ts +18 -0
- package/dist/tools/webpack/plugins/html-webpack-new-relic-plugin/index.d.ts +2 -0
- package/dist/tools/webpack/plugins/html-webpack-new-relic-plugin/test/HtmlWebpackNewRelicPlugin.test.d.ts +1 -0
- package/dist/tools/webpack/plugins/html-webpack-new-relic-plugin/test/fixtures/entry.d.ts +1 -0
- package/dist/tools/webpack/utils/getPublicPath.d.ts +1 -0
- package/dist/tools/webpack/utils/getResolvedSiteConfigPath.d.ts +1 -0
- package/dist/tools/webpack/webpack.config.build.d.ts +3 -0
- package/{config → dist/tools}/webpack/webpack.config.build.js +8 -5
- package/dist/tools/webpack/webpack.config.dev.d.ts +3 -0
- package/{tools/dist → dist/tools}/webpack/webpack.config.dev.js +8 -5
- package/dist/tools/webpack/webpack.config.dev.shell.d.ts +3 -0
- package/{tools/dist → dist/tools}/webpack/webpack.config.dev.shell.js +0 -4
- package/dist/types.d.ts +82 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/package.json +21 -16
- package/config/tsconfig.json +0 -32
- package/config/webpack/common-config/all/getIgnoreWarnings.js +0 -14
- package/config/webpack/utils/getLocalAliases.js +0 -65
- package/config/webpack/webpack.config.dev.js +0 -70
- package/config/webpack/webpack.config.dev.shell.js +0 -104
- package/runtime/__mocks__/file.js +0 -1
- package/runtime/__mocks__/svg.js +0 -1
- package/runtime/__mocks__/universal-cookie.js +0 -6
- package/runtime/analytics/MockAnalyticsService.js +0 -71
- package/runtime/analytics/SegmentAnalyticsService.js +0 -243
- package/runtime/analytics/index.ts +0 -12
- package/runtime/analytics/interface.test.js +0 -242
- package/runtime/auth/AxiosCsrfTokenService.js +0 -60
- package/runtime/auth/AxiosJwtAuthService.js +0 -363
- package/runtime/auth/AxiosJwtAuthService.test.jsx +0 -1076
- package/runtime/auth/AxiosJwtTokenService.js +0 -134
- package/runtime/auth/LocalForageCache.js +0 -76
- package/runtime/auth/MockAuthService.js +0 -278
- package/runtime/auth/index.ts +0 -19
- package/runtime/auth/interceptors/createCsrfTokenProviderInterceptor.js +0 -36
- package/runtime/auth/interceptors/createJwtTokenProviderInterceptor.js +0 -37
- package/runtime/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js +0 -20
- package/runtime/auth/interceptors/createRetryInterceptor.js +0 -74
- package/runtime/auth/interceptors/createRetryInterceptor.test.js +0 -23
- package/runtime/auth/utils.js +0 -105
- package/runtime/config/getExternalLinkUrl.test.js +0 -76
- package/runtime/i18n/injectIntlWithShim.jsx +0 -48
- package/runtime/i18n/lib.test.js +0 -230
- package/runtime/i18n/lib.ts +0 -272
- package/runtime/index.ts +0 -139
- package/runtime/initialize.async.function.config.test.js +0 -43
- package/runtime/initialize.const.config.test.js +0 -41
- package/runtime/initialize.function.config.test.js +0 -41
- package/runtime/initialize.js +0 -352
- package/runtime/initialize.test.js +0 -356
- package/runtime/jest.config.js +0 -33
- package/runtime/logging/MockLoggingService.js +0 -31
- package/runtime/logging/NewRelicLoggingService.js +0 -184
- package/runtime/logging/NewRelicLoggingService.test.js +0 -214
- package/runtime/logging/types.ts +0 -4
- package/runtime/react/AuthenticatedPageRoute.test.jsx +0 -135
- package/runtime/react/CombinedAppProvider.tsx +0 -46
- package/runtime/react/CurrentAppProvider.tsx +0 -46
- package/runtime/react/Divider.tsx +0 -5
- package/runtime/react/ErrorBoundary.jsx +0 -47
- package/runtime/react/ErrorBoundary.test.jsx +0 -83
- package/runtime/react/ErrorPage.jsx +0 -72
- package/runtime/react/SiteProvider.test.jsx +0 -66
- package/runtime/react/SiteProvider.tsx +0 -101
- package/runtime/react/hooks/theme/useTheme.test.ts +0 -221
- package/runtime/react/hooks/theme/useTheme.ts +0 -179
- package/runtime/react/hooks/theme/useThemeConfig.test.ts +0 -107
- package/runtime/react/hooks/theme/useThemeCore.test.ts +0 -65
- package/runtime/react/hooks/theme/useThemeCore.ts +0 -52
- package/runtime/react/hooks/theme/useThemeVariants.test.ts +0 -97
- package/runtime/react/hooks/theme/useThemeVariants.ts +0 -116
- package/runtime/react/hooks/theme/useTrackColorSchemeChoice.test.ts +0 -54
- package/runtime/react/hooks/theme/useTrackColorSchemeChoice.ts +0 -30
- package/runtime/react/hooks/useActiveRouteRoleWatcher.ts +0 -31
- package/runtime/react/hooks/useAuthenticatedUser.test.tsx +0 -41
- package/runtime/react/hooks/useSiteConfig.test.tsx +0 -13
- package/runtime/react/reducers.ts +0 -40
- package/runtime/routing/utils.test.ts +0 -7
- package/runtime/routing/utils.ts +0 -34
- package/runtime/scripts/GoogleAnalyticsLoader.test.ts +0 -77
- package/runtime/scripts/GoogleAnalyticsLoader.ts +0 -59
- package/runtime/site.config.test.tsx +0 -33
- package/runtime/slots/Slot.test.tsx +0 -40
- package/runtime/slots/Slot.tsx +0 -32
- package/runtime/slots/SlotContext.tsx +0 -8
- package/runtime/slots/hooks.ts +0 -35
- package/runtime/slots/layout/DefaultSlotLayout.test.tsx +0 -31
- package/runtime/slots/layout/DefaultSlotLayout.tsx +0 -9
- package/runtime/slots/layout/hooks.test.tsx +0 -178
- package/runtime/slots/layout/hooks.ts +0 -65
- package/runtime/slots/layout/utils.test.ts +0 -67
- package/runtime/slots/layout/utils.ts +0 -14
- package/runtime/slots/utils.test.ts +0 -64
- package/runtime/slots/utils.ts +0 -78
- package/runtime/slots/widget/WidgetContext.tsx +0 -9
- package/runtime/slots/widget/WidgetProvider.tsx +0 -30
- package/runtime/slots/widget/hooks.ts +0 -105
- package/runtime/slots/widget/iframe/IFrameContentWrapper.messages.tsx +0 -16
- package/runtime/slots/widget/iframe/IFrameContentWrapper.tsx +0 -84
- package/runtime/slots/widget/iframe/IFrameWidget.tsx +0 -59
- package/runtime/slots/widget/iframe/hooks.ts +0 -179
- package/runtime/slots/widget/utils.tsx +0 -201
- package/runtime/testing/initializeMockApp.test.ts +0 -66
- package/runtime/testing/mockMessages.ts +0 -23
- package/runtime/utils.test.js +0 -116
- package/shell/DefaultLayout.tsx +0 -18
- package/shell/DefaultMain.tsx +0 -7
- package/shell/Logo.test.tsx +0 -32
- package/shell/Logo.tsx +0 -28
- package/shell/Shell.messages.ts +0 -61
- package/shell/Shell.tsx +0 -18
- package/shell/__mocks__/file.js +0 -1
- package/shell/__mocks__/svg.js +0 -1
- package/shell/__mocks__/universal-cookie.js +0 -6
- package/shell/app.ts +0 -38
- package/shell/dev/devFooter/app.tsx +0 -43
- package/shell/dev/devHeader/BarContext.tsx +0 -13
- package/shell/dev/devHeader/BarLink.tsx +0 -16
- package/shell/dev/devHeader/BarProvider.tsx +0 -25
- package/shell/dev/devHeader/CoursesLink.tsx +0 -16
- package/shell/dev/devHeader/FooContext.tsx +0 -13
- package/shell/dev/devHeader/FooLink.tsx +0 -16
- package/shell/dev/devHeader/FooProvider.tsx +0 -25
- package/shell/dev/devHeader/app.tsx +0 -53
- package/shell/dev/devHeader/providers.tsx +0 -11
- package/shell/dev/devHome/HomePage.tsx +0 -28
- package/shell/dev/devHome/app.ts +0 -18
- package/shell/dev/devHome/i18n/index.ts +0 -27
- package/shell/dev/devHome/messages.ts +0 -11
- package/shell/dev/devUser/app.tsx +0 -24
- package/shell/dev/slotShowcase/HorizontalSlotLayout.tsx +0 -11
- package/shell/dev/slotShowcase/LayoutWithOptions.tsx +0 -17
- package/shell/dev/slotShowcase/SlotShowcasePage.tsx +0 -66
- package/shell/dev/slotShowcase/WidgetWithOptions.tsx +0 -11
- package/shell/dev/slotShowcase/app.tsx +0 -373
- package/shell/footer/CenterLinks.tsx +0 -11
- package/shell/footer/CopyrightNotice.tsx +0 -36
- package/shell/footer/Footer.tsx +0 -34
- package/shell/footer/LabeledLinkColumn.tsx +0 -19
- package/shell/footer/LanguageMenu.tsx +0 -35
- package/shell/footer/LanguageMenuItem.tsx +0 -23
- package/shell/footer/LeftLinks.tsx +0 -11
- package/shell/footer/LegalNotices.tsx +0 -17
- package/shell/footer/PoweredBy.tsx +0 -17
- package/shell/footer/RevealLinks.tsx +0 -43
- package/shell/footer/RightLinks.tsx +0 -11
- package/shell/footer/app.tsx +0 -73
- package/shell/footer/data/api.ts +0 -48
- package/shell/header/AuthenticatedMenu.tsx +0 -32
- package/shell/header/Header.tsx +0 -17
- package/shell/header/anonymous-menu/AnonymousMenu.tsx +0 -14
- package/shell/header/anonymous-menu/LoginButton.tsx +0 -14
- package/shell/header/anonymous-menu/RegisterButton.tsx +0 -15
- package/shell/header/app.tsx +0 -142
- package/shell/header/desktop/DesktopLayout.tsx +0 -22
- package/shell/header/desktop/PrimaryNavLinks.tsx +0 -10
- package/shell/header/desktop/SecondaryNavLinks.tsx +0 -10
- package/shell/header/mobile/MobileLayout.tsx +0 -47
- package/shell/header/mobile/MobileNavLinks.tsx +0 -10
- package/shell/i18n/index.ts +0 -25
- package/shell/jest.config.js +0 -31
- package/shell/menus/LinkMenuItem.tsx +0 -64
- package/shell/menus/NavDropdownMenuSlot.tsx +0 -29
- package/shell/menus/ProfileLinkMenuItem.tsx +0 -33
- package/shell/menus/data/utils.ts +0 -19
- package/shell/public/index.html +0 -10
- package/shell/router/createRouter.test.tsx +0 -50
- package/shell/router/getAppRoutes.test.tsx +0 -59
- package/shell/router/getAppRoutes.ts +0 -21
- package/shell/site.config.dev.tsx +0 -49
- package/shell/site.config.test.tsx +0 -16
- package/shell/site.tsx +0 -41
- package/tools/dist/babel/babel.config.js +0 -28
- package/tools/dist/config-helpers/createConfig.js +0 -13
- package/tools/dist/config-helpers/createLintConfig.js +0 -16
- package/tools/dist/config-helpers/getBaseConfig.js +0 -12
- package/tools/dist/defaultConfigPaths.js +0 -35
- package/tools/dist/eslint/base.eslint.config.js +0 -113
- package/tools/dist/index.js +0 -12
- package/tools/dist/types.js +0 -23
- package/tools/dist/webpack/common-config/all/getCodeRules.js +0 -52
- package/tools/dist/webpack/common-config/all/getFileLoaderRules.js +0 -26
- package/tools/dist/webpack/common-config/all/getIgnoreWarnings.js +0 -14
- package/tools/dist/webpack/common-config/all/getImageMinimizer.js +0 -25
- package/tools/dist/webpack/common-config/all/getStylesheetRule.js +0 -112
- package/tools/dist/webpack/common-config/dev/getDevServer.js +0 -38
- package/tools/dist/webpack/common-config/index.js +0 -18
- package/tools/dist/webpack/common-config/site/getHtmlWebpackPlugin.js +0 -16
- package/tools/dist/webpack/plugins/html-webpack-new-relic-plugin/HtmlWebpackNewRelicPlugin.js +0 -91
- package/tools/dist/webpack/plugins/html-webpack-new-relic-plugin/index.js +0 -7
- package/tools/dist/webpack/plugins/html-webpack-new-relic-plugin/test/HtmlWebpackNewRelicPlugin.test.js +0 -66
- package/tools/dist/webpack/plugins/html-webpack-new-relic-plugin/test/fixtures/entry.js +0 -3
- package/tools/dist/webpack/utils/getLocalAliases.js +0 -65
- package/tools/dist/webpack/utils/getPublicPath.js +0 -6
- package/tools/dist/webpack/utils/getResolvedSiteConfigPath.js +0 -32
- package/tools/dist/webpack/webpack.config.build.js +0 -70
- package/types.ts +0 -119
- /package/{runtime/react/hooks/theme/index.ts → dist/runtime/react/hooks/theme/index.d.ts} +0 -0
- /package/{runtime/routing/index.ts → dist/runtime/routing/index.d.ts} +0 -0
- /package/{runtime/scripts/index.ts → dist/runtime/scripts/index.d.ts} +0 -0
- /package/{runtime/slots/index.ts → dist/runtime/slots/index.d.ts} +0 -0
- /package/{runtime/slots/layout/index.ts → dist/runtime/slots/layout/index.d.ts} +0 -0
- /package/{runtime/slots/widget/index.ts → dist/runtime/slots/widget/index.d.ts} +0 -0
- /package/{shell → dist/shell}/app.scss +0 -0
- /package/{shell/dev/devFooter/index.ts → dist/shell/dev/devFooter/index.d.ts} +0 -0
- /package/{shell/dev/devHeader/index.ts → dist/shell/dev/devHeader/index.d.ts} +0 -0
- /package/{shell/dev/devHome/index.ts → dist/shell/dev/devHome/index.d.ts} +0 -0
- /package/{shell/dev/devUser/index.ts → dist/shell/dev/devUser/index.d.ts} +0 -0
- /package/{shell/dev/index.ts → dist/shell/dev/index.d.ts} +0 -0
- /package/{shell/dev/slotShowcase/index.ts → dist/shell/dev/slotShowcase/index.d.ts} +0 -0
- /package/{shell/footer/index.ts → dist/shell/footer/index.d.ts} +0 -0
- /package/{shell/header/index.ts → dist/shell/header/index.d.ts} +0 -0
- /package/{shell/index.ts → dist/shell/index.d.ts} +0 -0
- /package/{config → dist/tools}/babel/babel.config.js +0 -0
- /package/{tools/dist → dist/tools}/cli/commands/serve.js +0 -0
- /package/{tools/dist → dist/tools}/cli/intl-imports.js +0 -0
- /package/{tools/dist → dist/tools}/cli/intl-imports.test.js +0 -0
- /package/{tools/dist → dist/tools}/cli/transifex-utils.js +0 -0
- /package/{tools/dist → dist/tools}/cli/utils/ensureConfigFilenameOption.js +0 -0
- /package/{tools/dist → dist/tools}/cli/utils/formatter.js +0 -0
- /package/{tools/dist → dist/tools}/cli/utils/getResolvedConfigPath.js +0 -0
- /package/{tools/dist → dist/tools}/cli/utils/prettyPrintTitle.js +0 -0
- /package/{tools/dist → dist/tools}/cli/utils/printUsage.js +0 -0
- /package/{config → dist/tools}/config-helpers/createConfig.js +0 -0
- /package/{config → dist/tools}/config-helpers/createLintConfig.js +0 -0
- /package/{config → dist/tools}/config-helpers/getBaseConfig.js +0 -0
- /package/{config → dist/tools}/defaultConfigPaths.js +0 -0
- /package/{config → dist/tools}/eslint/base.eslint.config.js +0 -0
- /package/{tools/dist → dist/tools}/eslint.config.js +0 -0
- /package/{config → dist/tools}/index.js +0 -0
- /package/{config → dist/tools}/jest/jest.config.js +0 -0
- /package/{tools/dist → dist/tools}/jest.config.js +0 -0
- /package/{config → dist/tools}/types.js +0 -0
- /package/{config → dist/tools}/webpack/common-config/all/getCodeRules.js +0 -0
- /package/{config → dist/tools}/webpack/common-config/all/getFileLoaderRules.js +0 -0
- /package/{config → dist/tools}/webpack/common-config/all/getImageMinimizer.js +0 -0
- /package/{config → dist/tools}/webpack/common-config/all/getStylesheetRule.js +0 -0
- /package/{config → dist/tools}/webpack/common-config/dev/getDevServer.js +0 -0
- /package/{config → dist/tools}/webpack/common-config/index.js +0 -0
- /package/{config → dist/tools}/webpack/common-config/site/getHtmlWebpackPlugin.js +0 -0
- /package/{config → dist/tools}/webpack/plugins/html-webpack-new-relic-plugin/HtmlWebpackNewRelicPlugin.js +0 -0
- /package/{config → dist/tools}/webpack/plugins/html-webpack-new-relic-plugin/index.js +0 -0
- /package/{config → dist/tools}/webpack/plugins/html-webpack-new-relic-plugin/test/HtmlWebpackNewRelicPlugin.test.js +0 -0
- /package/{config → dist/tools}/webpack/plugins/html-webpack-new-relic-plugin/test/fixtures/entry.js +0 -0
- /package/{config → dist/tools}/webpack/utils/getPublicPath.js +0 -0
- /package/{config → dist/tools}/webpack/utils/getResolvedSiteConfigPath.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTheme.js","sourceRoot":"","sources":["../../../../../runtime/react/hooks/theme/useTheme.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n useCallback, useEffect, useReducer, useState,\n} from 'react';\n\nimport { SELECTED_THEME_VARIANT_KEY } from '../../constants';\nimport { logError } from '../../../logging';\nimport { themeActions, themeReducer } from '../../reducers';\nimport { ThemeVariants, ThemeDefaults } from '../../../../types';\nimport { isEmptyObject } from './utils';\n\nimport useThemeCore from './useThemeCore';\nimport useThemeConfig from './useThemeConfig';\nimport useThemeVariants from './useThemeVariants';\n\n/**\n* Finds the default theme variant from the given theme variants object. If no default theme exists, the light theme\n* variant is returned as a fallback.\n*\n* It prioritizes:\n* 1. A persisted theme variant from localStorage.\n* 2. A system preference (`prefers-color-scheme`).\n* 3. The configured default theme variant.\n*\n* Returns the default theme variant, or `undefined` if no valid theme variant is found.\n*/\nexport const getDefaultThemeVariant = (themeVariants: ThemeVariants | undefined, themeDefaults: ThemeDefaults = {}) => {\n if (!themeVariants) {\n return undefined;\n }\n\n const themeVariantKeys = Object.keys(themeVariants);\n\n // If there is only one theme variant, return it since it's the only one that may be used.\n if (themeVariantKeys.length === 1) {\n const themeVariantKey = themeVariantKeys[0];\n return {\n name: themeVariantKey,\n metadata: themeVariants[themeVariantKey],\n };\n }\n\n // Prioritize persisted localStorage theme variant preference.\n const persistedSelectedThemeVariant = localStorage.getItem(SELECTED_THEME_VARIANT_KEY);\n if (persistedSelectedThemeVariant && themeVariants[persistedSelectedThemeVariant]) {\n return {\n name: persistedSelectedThemeVariant,\n metadata: themeVariants[persistedSelectedThemeVariant],\n };\n }\n\n // Then, detect system preference via `prefers-color-scheme` media query and use\n // the default dark theme variant, if one exists.\n const hasDarkSystemPreference = !!window.matchMedia?.('(prefers-color-scheme: dark)')?.matches;\n const defaultDarkThemeVariant = themeDefaults.dark ?? 'dark';\n const darkThemeVariantMetadata = themeVariants[defaultDarkThemeVariant];\n\n if (hasDarkSystemPreference && defaultDarkThemeVariant && darkThemeVariantMetadata) {\n return {\n name: defaultDarkThemeVariant,\n metadata: darkThemeVariantMetadata,\n };\n }\n\n const defaultLightThemeVariant = themeDefaults.light ?? 'light';\n const lightThemeVariantMetadata = themeVariants[defaultLightThemeVariant];\n\n // Handle edge case where the default light theme variant is not configured or provided.\n if (!lightThemeVariantMetadata) {\n return undefined;\n }\n\n // Otherwise, fallback to using the default light theme variant as configured.\n return {\n name: defaultLightThemeVariant,\n metadata: lightThemeVariantMetadata,\n };\n};\n\n/**\n * A custom React hook that manages the application's theme state and injects the appropriate CSS for the theme core\n * and theme variants (e.g., light and dark modes) into the HTML document. It handles dynamically loading the theme\n * CSS based on the current theme variant, and ensures that the theme variant's CSS is preloaded for runtime theme\n * switching. This is done using \"alternate\" stylesheets. That is, the browser will download the CSS for the\n * non-current theme variants with a lower priority than the current one.\n *\n * The hook also responds to system theme preference changes (e.g., via the `prefers-color-scheme` media query),\n * and can automatically switch the theme based on the system's dark mode or light mode preference.\n *\n * * @example\n * const [themeState, dispatch] = useTheme();\n * console.log(themeState.isThemeLoaded); // true when the theme has been successfully loaded.\n *\n * // Dispatch an action to change the theme variant\n * dispatch(themeActions.setThemeVariant('dark'));\n */\nconst useTheme = () => {\n const themeConfig = useThemeConfig();\n const {\n core: themeCore,\n defaults: themeVariantDefaults,\n variants: themeVariants,\n } = themeConfig;\n const initialThemeState = {\n isThemeLoaded: false,\n themeVariant: getDefaultThemeVariant(themeVariants, themeVariantDefaults)?.name,\n };\n const [themeState, dispatch] = useReducer(themeReducer, initialThemeState);\n\n const [isThemeCoreLoaded, setIsThemeCoreLoaded] = useState(false);\n const onLoadThemeCore = useCallback(() => {\n setIsThemeCoreLoaded(true);\n }, []);\n\n const [hasLoadedThemeVariants, setHasLoadedThemeVariants] = useState(false);\n const onLoadThemeVariants = useCallback(() => {\n setHasLoadedThemeVariants(true);\n }, []);\n\n // load the theme's core CSS\n useThemeCore({\n themeCore,\n onComplete: onLoadThemeCore,\n });\n\n // respond to system preference changes with regard to `prefers-color-scheme: dark`.\n const handleDarkModeSystemPreferenceChange = useCallback((prefersDarkMode: boolean) => {\n // Ignore system preference change if the theme variant is already set in localStorage.\n if (localStorage.getItem(SELECTED_THEME_VARIANT_KEY)) {\n return;\n }\n\n if (prefersDarkMode && themeVariantDefaults?.dark) {\n dispatch(themeActions.setThemeVariant(themeVariantDefaults.dark));\n } else if (!prefersDarkMode && themeVariantDefaults?.light) {\n dispatch(themeActions.setThemeVariant(themeVariantDefaults.light));\n } else {\n logError(`Could not set theme variant based on system preference (prefers dark mode: ${prefersDarkMode})`);\n }\n }, [themeVariantDefaults]);\n\n // load the theme variant(s) CSS\n useThemeVariants({\n themeVariants,\n onComplete: onLoadThemeVariants,\n currentThemeVariant: themeState.themeVariant,\n onDarkModeSystemPreferenceChange: handleDarkModeSystemPreferenceChange,\n });\n\n useEffect(() => {\n // theme is already loaded, do nothing\n if (themeState.isThemeLoaded) {\n return;\n }\n\n const hasThemeConfig = (themeCore?.url && !isEmptyObject(themeVariants));\n if (!hasThemeConfig) {\n // no theme URLs to load, set loading to false.\n dispatch(themeActions.setThemeLoaded(true));\n }\n\n // Return early if neither the core theme CSS nor any theme variant CSS is loaded.\n if (!isThemeCoreLoaded || !hasLoadedThemeVariants) {\n return;\n }\n\n // All application theme URLs are loaded\n dispatch(themeActions.setThemeLoaded(true));\n }, [\n themeState.isThemeLoaded,\n isThemeCoreLoaded,\n hasLoadedThemeVariants,\n themeCore?.url,\n themeVariants,\n ]);\n\n return [themeState, dispatch];\n};\n\nexport default useTheme;\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Theme } from '../../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Custom React hook that retrieves the theme configuration.
|
|
4
|
+
*
|
|
5
|
+
* Configuration is considered entirely invalid if it doesn't define at least one variant, including core.
|
|
6
|
+
*
|
|
7
|
+
* Example:
|
|
8
|
+
*
|
|
9
|
+
* const themeConfig = useThemeConfig();
|
|
10
|
+
* if (themeConfig) {
|
|
11
|
+
* console.log(themeConfig.core.url); // Outputs the URL of theme's core CSS
|
|
12
|
+
* console.log(themeConfig.variants['dark'].url); // Outputs the URL of the theme's dark variant CSS
|
|
13
|
+
* }
|
|
14
|
+
*/
|
|
15
|
+
declare const useThemeConfig: () => Theme;
|
|
16
|
+
export default useThemeConfig;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Theme } from '../../../../types';
|
|
4
2
|
import { getSiteConfig } from '../../../config';
|
|
5
3
|
import { isEmptyObject } from './utils';
|
|
6
|
-
|
|
7
4
|
/**
|
|
8
5
|
* Custom React hook that retrieves the theme configuration.
|
|
9
6
|
*
|
|
@@ -17,18 +14,16 @@ import { isEmptyObject } from './utils';
|
|
|
17
14
|
* console.log(themeConfig.variants['dark'].url); // Outputs the URL of the theme's dark variant CSS
|
|
18
15
|
* }
|
|
19
16
|
*/
|
|
20
|
-
const useThemeConfig = ()
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
variants: theme.variants,
|
|
31
|
-
};
|
|
17
|
+
const useThemeConfig = () => useMemo(() => {
|
|
18
|
+
const { theme } = getSiteConfig();
|
|
19
|
+
if (!theme || (isEmptyObject(theme.core) && isEmptyObject(theme.variants))) {
|
|
20
|
+
return {};
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
core: theme.core,
|
|
24
|
+
defaults: theme.defaults,
|
|
25
|
+
variants: theme.variants,
|
|
26
|
+
};
|
|
32
27
|
}, []);
|
|
33
|
-
|
|
34
28
|
export default useThemeConfig;
|
|
29
|
+
//# sourceMappingURL=useThemeConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThemeConfig.js","sourceRoot":"","sources":["../../../../../runtime/react/hooks/theme/useThemeConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGhC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC;;;;;;;;;;;;GAYG;AACH,MAAM,cAAc,GAAG,GAAU,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;IAC/C,MAAM,EAAE,KAAK,EAAE,GAAG,aAAa,EAAE,CAAC;IAElC,IAAI,CAAC,KAAK,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;QAC3E,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC;AACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AAEP,eAAe,cAAc,CAAC","sourcesContent":["import { useMemo } from 'react';\n\nimport { Theme } from '../../../../types';\nimport { getSiteConfig } from '../../../config';\nimport { isEmptyObject } from './utils';\n\n/**\n * Custom React hook that retrieves the theme configuration.\n *\n * Configuration is considered entirely invalid if it doesn't define at least one variant, including core.\n *\n * Example:\n *\n * const themeConfig = useThemeConfig();\n * if (themeConfig) {\n * console.log(themeConfig.core.url); // Outputs the URL of theme's core CSS\n * console.log(themeConfig.variants['dark'].url); // Outputs the URL of the theme's dark variant CSS\n * }\n */\nconst useThemeConfig = (): Theme => useMemo(() => {\n const { theme } = getSiteConfig();\n\n if (!theme || (isEmptyObject(theme.core) && isEmptyObject(theme.variants))) {\n return {};\n }\n\n return {\n core: theme.core,\n defaults: theme.defaults,\n variants: theme.variants,\n };\n}, []);\n\nexport default useThemeConfig;\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom React hook that manages the loading and updating of a theme's core
|
|
3
|
+
* CSS, ensuring the theme's core CSS is added to the document `<head>` as a
|
|
4
|
+
* `<link>` element.
|
|
5
|
+
*/
|
|
6
|
+
declare const useThemeCore: ({ themeCore, onComplete, }: {
|
|
7
|
+
themeCore: any;
|
|
8
|
+
onComplete: any;
|
|
9
|
+
}) => void;
|
|
10
|
+
export default useThemeCore;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { logError } from '../../../logging';
|
|
3
|
+
import { removeExistingLinks } from './utils';
|
|
4
|
+
/**
|
|
5
|
+
* Custom React hook that manages the loading and updating of a theme's core
|
|
6
|
+
* CSS, ensuring the theme's core CSS is added to the document `<head>` as a
|
|
7
|
+
* `<link>` element.
|
|
8
|
+
*/
|
|
9
|
+
const useThemeCore = ({ themeCore, onComplete, }) => {
|
|
10
|
+
const [isThemeCoreComplete, setIsThemeCoreComplete] = useState(false);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (isThemeCoreComplete) {
|
|
13
|
+
onComplete();
|
|
14
|
+
}
|
|
15
|
+
}, [isThemeCoreComplete, onComplete]);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
// If there is no theme core config, do nothing.
|
|
18
|
+
if (!(themeCore === null || themeCore === void 0 ? void 0 : themeCore.url)) {
|
|
19
|
+
setIsThemeCoreComplete(true);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const themeCoreLink = document.createElement('link');
|
|
23
|
+
themeCoreLink.href = themeCore.url;
|
|
24
|
+
themeCoreLink.rel = 'stylesheet';
|
|
25
|
+
themeCoreLink.dataset.themeCore = 'true';
|
|
26
|
+
themeCoreLink.onload = () => {
|
|
27
|
+
setIsThemeCoreComplete(true);
|
|
28
|
+
};
|
|
29
|
+
themeCoreLink.onerror = () => {
|
|
30
|
+
setIsThemeCoreComplete(true);
|
|
31
|
+
const otherExistingLinks = document.head.querySelectorAll('link[data-theme-core="true"]');
|
|
32
|
+
removeExistingLinks(otherExistingLinks);
|
|
33
|
+
logError(`Failed to load core theme CSS from ${themeCore.url}. Aborting.`);
|
|
34
|
+
return;
|
|
35
|
+
};
|
|
36
|
+
document.head.insertAdjacentElement('beforeend', themeCoreLink);
|
|
37
|
+
}, [themeCore === null || themeCore === void 0 ? void 0 : themeCore.url, onComplete]);
|
|
38
|
+
};
|
|
39
|
+
export default useThemeCore;
|
|
40
|
+
//# sourceMappingURL=useThemeCore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThemeCore.js","sourceRoot":"","sources":["../../../../../runtime/react/hooks/theme/useThemeCore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;GAIG;AACH,MAAM,YAAY,GAAG,CAAC,EACpB,SAAS,EACT,UAAU,GACX,EAAE,EAAE;IACH,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEtE,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,mBAAmB,EAAE,CAAC;YACxB,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC,EAAE,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC,CAAC;IAEtC,SAAS,CAAC,GAAG,EAAE;QACb,gDAAgD;QAChD,IAAI,CAAC,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,GAAG,CAAA,EAAE,CAAC;YACpB,sBAAsB,CAAC,IAAI,CAAC,CAAC;YAC7B,OAAO;QACT,CAAC;QAED,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACrD,aAAa,CAAC,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC;QACnC,aAAa,CAAC,GAAG,GAAG,YAAY,CAAC;QACjC,aAAa,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC;QACzC,aAAa,CAAC,MAAM,GAAG,GAAG,EAAE;YAC1B,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC,CAAC;QACF,aAAa,CAAC,OAAO,GAAG,GAAG,EAAE;YAC3B,sBAAsB,CAAC,IAAI,CAAC,CAAC;YAC7B,MAAM,kBAAkB,GAAG,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,8BAA8B,CAAC,CAAC;YAC1F,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;YACxC,QAAQ,CAAC,sCAAsC,SAAS,CAAC,GAAG,aAAa,CAAC,CAAC;YAC3E,OAAO;QACT,CAAC,CAAC;QAEF,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CACjC,WAAW,EACX,aAAa,CACd,CAAC;IACJ,CAAC,EAAE,CAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { logError } from '../../../logging';\nimport { removeExistingLinks } from './utils';\n\n/**\n * Custom React hook that manages the loading and updating of a theme's core\n * CSS, ensuring the theme's core CSS is added to the document `<head>` as a\n * `<link>` element.\n */\nconst useThemeCore = ({\n themeCore,\n onComplete,\n}) => {\n const [isThemeCoreComplete, setIsThemeCoreComplete] = useState(false);\n\n useEffect(() => {\n if (isThemeCoreComplete) {\n onComplete();\n }\n }, [isThemeCoreComplete, onComplete]);\n\n useEffect(() => {\n // If there is no theme core config, do nothing.\n if (!themeCore?.url) {\n setIsThemeCoreComplete(true);\n return;\n }\n\n const themeCoreLink = document.createElement('link');\n themeCoreLink.href = themeCore.url;\n themeCoreLink.rel = 'stylesheet';\n themeCoreLink.dataset.themeCore = 'true';\n themeCoreLink.onload = () => {\n setIsThemeCoreComplete(true);\n };\n themeCoreLink.onerror = () => {\n setIsThemeCoreComplete(true);\n const otherExistingLinks = document.head.querySelectorAll('link[data-theme-core=\"true\"]');\n removeExistingLinks(otherExistingLinks);\n logError(`Failed to load core theme CSS from ${themeCore.url}. Aborting.`);\n return;\n };\n\n document.head.insertAdjacentElement(\n 'beforeend',\n themeCoreLink,\n );\n }, [themeCore?.url, onComplete]);\n};\n\nexport default useThemeCore;\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ThemeVariants } from '../../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* A custom React hook that manages the loading of theme variant CSS files dynamically.
|
|
4
|
+
* Adds/updates a `<link>` element in the HTML document to load each theme variant's CSS, setting the
|
|
5
|
+
* non-current theme variants as "alternate" stylesheets. That is, the browser will download
|
|
6
|
+
* the CSS for the non-current theme variants, but at a lower priority than the current one.
|
|
7
|
+
* This ensures that if the theme variant is changed at runtime, the new theme's CSS will already be loaded.
|
|
8
|
+
*
|
|
9
|
+
* The hook also listens for changes in the system's preference and triggers the provided callback accordingly.
|
|
10
|
+
*/
|
|
11
|
+
declare const useThemeVariants: ({ themeVariants, currentThemeVariant, onComplete, onDarkModeSystemPreferenceChange, }: {
|
|
12
|
+
themeVariants: ThemeVariants | undefined;
|
|
13
|
+
currentThemeVariant: string;
|
|
14
|
+
onComplete: () => void;
|
|
15
|
+
onDarkModeSystemPreferenceChange: (prefersDarkMode: boolean) => void;
|
|
16
|
+
}) => void;
|
|
17
|
+
export default useThemeVariants;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { logError } from '../../../logging';
|
|
3
|
+
/**
|
|
4
|
+
* A custom React hook that manages the loading of theme variant CSS files dynamically.
|
|
5
|
+
* Adds/updates a `<link>` element in the HTML document to load each theme variant's CSS, setting the
|
|
6
|
+
* non-current theme variants as "alternate" stylesheets. That is, the browser will download
|
|
7
|
+
* the CSS for the non-current theme variants, but at a lower priority than the current one.
|
|
8
|
+
* This ensures that if the theme variant is changed at runtime, the new theme's CSS will already be loaded.
|
|
9
|
+
*
|
|
10
|
+
* The hook also listens for changes in the system's preference and triggers the provided callback accordingly.
|
|
11
|
+
*/
|
|
12
|
+
const useThemeVariants = ({ themeVariants, currentThemeVariant, onComplete, onDarkModeSystemPreferenceChange, }) => {
|
|
13
|
+
const [isThemeVariantComplete, setIsThemeVariantComplete] = useState(false);
|
|
14
|
+
// Effect hook that listens for changes in the system's dark mode preference.
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
var _a;
|
|
17
|
+
const changeColorScheme = (colorSchemeQuery) => {
|
|
18
|
+
onDarkModeSystemPreferenceChange(colorSchemeQuery.matches);
|
|
19
|
+
};
|
|
20
|
+
const colorSchemeQuery = (_a = window.matchMedia) === null || _a === void 0 ? void 0 : _a.call(window, '(prefers-color-scheme: dark)');
|
|
21
|
+
if (colorSchemeQuery) {
|
|
22
|
+
colorSchemeQuery.addEventListener('change', changeColorScheme);
|
|
23
|
+
}
|
|
24
|
+
return () => {
|
|
25
|
+
if (colorSchemeQuery) {
|
|
26
|
+
colorSchemeQuery.removeEventListener('change', changeColorScheme);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}, [onDarkModeSystemPreferenceChange]);
|
|
30
|
+
// Effect hook to set the theme current variant on the HTML element.
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
var _a;
|
|
33
|
+
if (currentThemeVariant && (themeVariants === null || themeVariants === void 0 ? void 0 : themeVariants[currentThemeVariant])) {
|
|
34
|
+
const htmlDataThemeVariantAttr = 'data-theme-variant';
|
|
35
|
+
(_a = document.querySelector('html')) === null || _a === void 0 ? void 0 : _a.setAttribute(htmlDataThemeVariantAttr, currentThemeVariant);
|
|
36
|
+
return () => {
|
|
37
|
+
var _a;
|
|
38
|
+
(_a = document.querySelector('html')) === null || _a === void 0 ? void 0 : _a.removeAttribute(htmlDataThemeVariantAttr);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return () => { }; // Cleanup: no action needed when theme variant is not set
|
|
42
|
+
}, [themeVariants, currentThemeVariant]);
|
|
43
|
+
// Effect hook that calls `onComplete` when brand theme variant processing is complete.
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (isThemeVariantComplete) {
|
|
46
|
+
onComplete();
|
|
47
|
+
}
|
|
48
|
+
}, [isThemeVariantComplete, onComplete]);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (!themeVariants) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Determines the value for the `rel` attribute for a given theme variant based
|
|
55
|
+
* on if its the currently applied variant.
|
|
56
|
+
*/
|
|
57
|
+
const getActiveOrAlternateRel = (themeVariant) => (currentThemeVariant === themeVariant ? 'stylesheet' : 'alternate stylesheet');
|
|
58
|
+
// Iterate over each theme variant URLs and inject them into the HTML document, if each doesn't already exist.
|
|
59
|
+
Object.entries(themeVariants).forEach(([themeVariant, { url }]) => {
|
|
60
|
+
// If the config for the theme variant does not have a URL, set the variant to complete and continue.
|
|
61
|
+
if (!url) {
|
|
62
|
+
setIsThemeVariantComplete(true);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const existingThemeVariantLink = document.head.querySelector(`link[href='${url}']`);
|
|
66
|
+
if (existingThemeVariantLink) {
|
|
67
|
+
existingThemeVariantLink.rel = getActiveOrAlternateRel(themeVariant);
|
|
68
|
+
existingThemeVariantLink.dataset.themeVariant = themeVariant;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const themeVariantLink = document.createElement('link');
|
|
72
|
+
themeVariantLink.href = url;
|
|
73
|
+
themeVariantLink.rel = getActiveOrAlternateRel(themeVariant);
|
|
74
|
+
themeVariantLink.dataset.themeVariant = themeVariant;
|
|
75
|
+
themeVariantLink.onload = () => {
|
|
76
|
+
if (themeVariant === currentThemeVariant) {
|
|
77
|
+
setIsThemeVariantComplete(true);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
themeVariantLink.onerror = () => {
|
|
81
|
+
logError(`Failed to load theme variant (${themeVariant}) CSS from ${url}. Aborting.`);
|
|
82
|
+
setIsThemeVariantComplete(true);
|
|
83
|
+
};
|
|
84
|
+
document.head.insertAdjacentElement('beforeend', themeVariantLink);
|
|
85
|
+
setIsThemeVariantComplete(true);
|
|
86
|
+
});
|
|
87
|
+
}, [themeVariants, currentThemeVariant, onComplete]);
|
|
88
|
+
};
|
|
89
|
+
export default useThemeVariants;
|
|
90
|
+
//# sourceMappingURL=useThemeVariants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThemeVariants.js","sourceRoot":"","sources":["../../../../../runtime/react/hooks/theme/useThemeVariants.ts"],"names":[],"mappings":"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","sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { logError } from '../../../logging';\n\nimport { ThemeVariants } from '../../../../types';\n\n/**\n * A custom React hook that manages the loading of theme variant CSS files dynamically.\n * Adds/updates a `<link>` element in the HTML document to load each theme variant's CSS, setting the\n * non-current theme variants as \"alternate\" stylesheets. That is, the browser will download\n * the CSS for the non-current theme variants, but at a lower priority than the current one.\n * This ensures that if the theme variant is changed at runtime, the new theme's CSS will already be loaded.\n *\n * The hook also listens for changes in the system's preference and triggers the provided callback accordingly.\n */\nconst useThemeVariants = ({\n themeVariants,\n currentThemeVariant,\n onComplete,\n onDarkModeSystemPreferenceChange,\n}: {\n themeVariants: ThemeVariants | undefined,\n currentThemeVariant: string,\n onComplete: () => void,\n onDarkModeSystemPreferenceChange: (prefersDarkMode: boolean) => void,\n}) => {\n const [isThemeVariantComplete, setIsThemeVariantComplete] = useState(false);\n\n // Effect hook that listens for changes in the system's dark mode preference.\n useEffect(() => {\n const changeColorScheme = (colorSchemeQuery) => {\n onDarkModeSystemPreferenceChange(colorSchemeQuery.matches);\n };\n const colorSchemeQuery = window.matchMedia?.('(prefers-color-scheme: dark)');\n if (colorSchemeQuery) {\n colorSchemeQuery.addEventListener('change', changeColorScheme);\n }\n return () => {\n if (colorSchemeQuery) {\n colorSchemeQuery.removeEventListener('change', changeColorScheme);\n }\n };\n }, [onDarkModeSystemPreferenceChange]);\n\n // Effect hook to set the theme current variant on the HTML element.\n useEffect(() => {\n if (currentThemeVariant && themeVariants?.[currentThemeVariant]) {\n const htmlDataThemeVariantAttr = 'data-theme-variant';\n document.querySelector('html')?.setAttribute(htmlDataThemeVariantAttr, currentThemeVariant);\n return () => {\n document.querySelector('html')?.removeAttribute(htmlDataThemeVariantAttr);\n };\n }\n return () => { }; // Cleanup: no action needed when theme variant is not set\n }, [themeVariants, currentThemeVariant]);\n\n // Effect hook that calls `onComplete` when brand theme variant processing is complete.\n useEffect(() => {\n if (isThemeVariantComplete) {\n onComplete();\n }\n }, [isThemeVariantComplete, onComplete]);\n\n useEffect(() => {\n if (!themeVariants) {\n return;\n }\n\n /**\n * Determines the value for the `rel` attribute for a given theme variant based\n * on if its the currently applied variant.\n */\n const getActiveOrAlternateRel = (themeVariant: string): string => (currentThemeVariant === themeVariant ? 'stylesheet' : 'alternate stylesheet');\n\n // Iterate over each theme variant URLs and inject them into the HTML document, if each doesn't already exist.\n Object.entries(themeVariants).forEach(([themeVariant, { url }]) => {\n // If the config for the theme variant does not have a URL, set the variant to complete and continue.\n if (!url) {\n setIsThemeVariantComplete(true);\n return;\n }\n\n const existingThemeVariantLink: HTMLAnchorElement | null = document.head.querySelector(`link[href='${url}']`);\n if (existingThemeVariantLink) {\n existingThemeVariantLink.rel = getActiveOrAlternateRel(themeVariant);\n existingThemeVariantLink.dataset.themeVariant = themeVariant;\n return;\n }\n\n const themeVariantLink = document.createElement('link');\n themeVariantLink.href = url;\n themeVariantLink.rel = getActiveOrAlternateRel(themeVariant);\n themeVariantLink.dataset.themeVariant = themeVariant;\n\n themeVariantLink.onload = () => {\n if (themeVariant === currentThemeVariant) {\n setIsThemeVariantComplete(true);\n }\n };\n\n themeVariantLink.onerror = () => {\n logError(`Failed to load theme variant (${themeVariant}) CSS from ${url}. Aborting.`);\n setIsThemeVariantComplete(true);\n };\n\n document.head.insertAdjacentElement(\n 'beforeend',\n themeVariantLink,\n );\n\n setIsThemeVariantComplete(true);\n });\n }, [themeVariants, currentThemeVariant, onComplete]);\n};\n\nexport default useThemeVariants;\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A React hook that tracks user's preferred color scheme (light or dark) and sends respective
|
|
3
|
+
* event to the tracking service.
|
|
4
|
+
*
|
|
5
|
+
* @memberof module:React
|
|
6
|
+
*/
|
|
7
|
+
declare const useTrackColorSchemeChoice: () => void;
|
|
8
|
+
export default useTrackColorSchemeChoice;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { sendTrackEvent } from '../../../analytics';
|
|
3
|
+
/**
|
|
4
|
+
* A React hook that tracks user's preferred color scheme (light or dark) and sends respective
|
|
5
|
+
* event to the tracking service.
|
|
6
|
+
*
|
|
7
|
+
* @memberof module:React
|
|
8
|
+
*/
|
|
9
|
+
const useTrackColorSchemeChoice = () => {
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
var _a;
|
|
12
|
+
const trackColorSchemeChoice = ({ matches }) => {
|
|
13
|
+
const preferredColorScheme = matches ? 'dark' : 'light';
|
|
14
|
+
sendTrackEvent('openedx.ui.frontend-base.prefers-color-scheme.selected', { preferredColorScheme });
|
|
15
|
+
};
|
|
16
|
+
const colorSchemeQuery = (_a = window.matchMedia) === null || _a === void 0 ? void 0 : _a.call(window, '(prefers-color-scheme: dark)');
|
|
17
|
+
if (colorSchemeQuery) {
|
|
18
|
+
// send user's initial choice
|
|
19
|
+
trackColorSchemeChoice(colorSchemeQuery);
|
|
20
|
+
colorSchemeQuery.addEventListener('change', trackColorSchemeChoice);
|
|
21
|
+
}
|
|
22
|
+
return () => {
|
|
23
|
+
if (colorSchemeQuery) {
|
|
24
|
+
colorSchemeQuery.removeEventListener('change', trackColorSchemeChoice);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}, []);
|
|
28
|
+
};
|
|
29
|
+
export default useTrackColorSchemeChoice;
|
|
30
|
+
//# sourceMappingURL=useTrackColorSchemeChoice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTrackColorSchemeChoice.js","sourceRoot":"","sources":["../../../../../runtime/react/hooks/theme/useTrackColorSchemeChoice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,yBAAyB,GAAG,GAAG,EAAE;IACrC,SAAS,CAAC,GAAG,EAAE;;QACb,MAAM,sBAAsB,GAAG,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;YAC7C,MAAM,oBAAoB,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;YACxD,cAAc,CAAC,wDAAwD,EAAE,EAAE,oBAAoB,EAAE,CAAC,CAAC;QACrG,CAAC,CAAC;QACF,MAAM,gBAAgB,GAAG,MAAA,MAAM,CAAC,UAAU,uDAAG,8BAA8B,CAAC,CAAC;QAC7E,IAAI,gBAAgB,EAAE,CAAC;YACrB,6BAA6B;YAC7B,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;YACzC,gBAAgB,CAAC,gBAAgB,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC;QACtE,CAAC;QACD,OAAO,GAAG,EAAE;YACV,IAAI,gBAAgB,EAAE,CAAC;gBACrB,gBAAgB,CAAC,mBAAmB,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC;YACzE,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC,CAAC;AAEF,eAAe,yBAAyB,CAAC","sourcesContent":["import { useEffect } from 'react';\nimport { sendTrackEvent } from '../../../analytics';\n\n/**\n * A React hook that tracks user's preferred color scheme (light or dark) and sends respective\n * event to the tracking service.\n *\n * @memberof module:React\n */\nconst useTrackColorSchemeChoice = () => {\n useEffect(() => {\n const trackColorSchemeChoice = ({ matches }) => {\n const preferredColorScheme = matches ? 'dark' : 'light';\n sendTrackEvent('openedx.ui.frontend-base.prefers-color-scheme.selected', { preferredColorScheme });\n };\n const colorSchemeQuery = window.matchMedia?.('(prefers-color-scheme: dark)');\n if (colorSchemeQuery) {\n // send user's initial choice\n trackColorSchemeChoice(colorSchemeQuery);\n colorSchemeQuery.addEventListener('change', trackColorSchemeChoice);\n }\n return () => {\n if (colorSchemeQuery) {\n colorSchemeQuery.removeEventListener('change', trackColorSchemeChoice);\n }\n };\n }, []);\n};\n\nexport default useTrackColorSchemeChoice;\n"]}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* @param {HTMLLinkElement[]} existingLinks
|
|
4
4
|
*/
|
|
5
5
|
export const removeExistingLinks = (existingLinks) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
existingLinks.forEach((link) => {
|
|
7
|
+
link.remove();
|
|
8
|
+
});
|
|
9
9
|
};
|
|
10
|
-
|
|
11
10
|
export const isEmptyObject = (obj) => !obj || Object.keys(obj).length === 0;
|
|
11
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../runtime/react/hooks/theme/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,aAAa,EAAE,EAAE;IACnD,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC7B,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC","sourcesContent":["/**\n * Iterates through each given `<link>` element and removes it from the DOM.\n * @param {HTMLLinkElement[]} existingLinks\n */\nexport const removeExistingLinks = (existingLinks) => {\n existingLinks.forEach((link) => {\n link.remove();\n });\n};\n\nexport const isEmptyObject = (obj) => !obj || Object.keys(obj).length === 0;\n"]}
|
package/{runtime/react/hooks/useActiveRoles.ts → dist/runtime/react/hooks/useActiveRoles.js}
RENAMED
|
@@ -2,14 +2,12 @@ import { useState } from 'react';
|
|
|
2
2
|
import { getActiveRoles } from '../../config';
|
|
3
3
|
import { ACTIVE_ROLES_CHANGED } from '../../constants';
|
|
4
4
|
import useSiteEvent from './useSiteEvent';
|
|
5
|
-
|
|
6
5
|
const useActiveRoles = () => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return roles;
|
|
6
|
+
const [roles, setRoles] = useState(getActiveRoles());
|
|
7
|
+
useSiteEvent(ACTIVE_ROLES_CHANGED, () => {
|
|
8
|
+
setRoles(getActiveRoles());
|
|
9
|
+
});
|
|
10
|
+
return roles;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
export default useActiveRoles;
|
|
13
|
+
//# sourceMappingURL=useActiveRoles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useActiveRoles.js","sourceRoot":"","sources":["../../../../runtime/react/hooks/useActiveRoles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,MAAM,cAAc,GAAG,GAAG,EAAE;IAC1B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAW,cAAc,EAAE,CAAC,CAAC;IAC/D,YAAY,CAAC,oBAAoB,EAAE,GAAG,EAAE;QACtC,QAAQ,CAAC,cAAc,EAAE,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { useState } from 'react';\nimport { getActiveRoles } from '../../config';\nimport { ACTIVE_ROLES_CHANGED } from '../../constants';\nimport useSiteEvent from './useSiteEvent';\n\nconst useActiveRoles = () => {\n const [roles, setRoles] = useState<string[]>(getActiveRoles());\n useSiteEvent(ACTIVE_ROLES_CHANGED, () => {\n setRoles(getActiveRoles());\n });\n\n return roles;\n};\n\nexport default useActiveRoles;\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useCallback, useEffect } from 'react';
|
|
2
|
+
import { useMatches } from 'react-router';
|
|
3
|
+
import { setActiveRouteRoles } from '../../config';
|
|
4
|
+
import { isRoleRouteObject } from '../../routing';
|
|
5
|
+
const useActiveRouteRoleWatcher = () => {
|
|
6
|
+
const matches = useMatches();
|
|
7
|
+
// We create this callback so we can use it right away to populate the default state value.
|
|
8
|
+
const findActiveRouteRoles = useCallback(() => {
|
|
9
|
+
// Starts with the widget roles and adds the others in.
|
|
10
|
+
const roles = [];
|
|
11
|
+
// Route roles
|
|
12
|
+
for (const match of matches) {
|
|
13
|
+
if (isRoleRouteObject(match)) {
|
|
14
|
+
if (!roles.includes(match.handle.role)) {
|
|
15
|
+
roles.push(match.handle.role);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return roles;
|
|
20
|
+
}, [matches]);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
setActiveRouteRoles(findActiveRouteRoles());
|
|
23
|
+
}, [matches, findActiveRouteRoles]);
|
|
24
|
+
};
|
|
25
|
+
export default useActiveRouteRoleWatcher;
|
|
26
|
+
//# sourceMappingURL=useActiveRouteRoleWatcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useActiveRouteRoleWatcher.js","sourceRoot":"","sources":["../../../../runtime/react/hooks/useActiveRouteRoleWatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,yBAAyB,GAAG,GAAG,EAAE;IACrC,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAE7B,2FAA2F;IAC3F,MAAM,oBAAoB,GAAG,WAAW,CAAC,GAAG,EAAE;QAC5C,uDAAuD;QACvD,MAAM,KAAK,GAAa,EAAE,CAAC;QAE3B,cAAc;QACd,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7B,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;oBACvC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBAChC,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,SAAS,CAAC,GAAG,EAAE;QACb,mBAAmB,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC9C,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,eAAe,yBAAyB,CAAC","sourcesContent":["import { useCallback, useEffect } from 'react';\nimport { useMatches } from 'react-router';\nimport { setActiveRouteRoles } from '../../config';\nimport { isRoleRouteObject } from '../../routing';\n\nconst useActiveRouteRoleWatcher = () => {\n const matches = useMatches();\n\n // We create this callback so we can use it right away to populate the default state value.\n const findActiveRouteRoles = useCallback(() => {\n // Starts with the widget roles and adds the others in.\n const roles: string[] = [];\n\n // Route roles\n for (const match of matches) {\n if (isRoleRouteObject(match)) {\n if (!roles.includes(match.handle.role)) {\n roles.push(match.handle.role);\n }\n }\n }\n\n return roles;\n }, [matches]);\n\n useEffect(() => {\n setActiveRouteRoles(findActiveRouteRoles());\n }, [matches, findActiveRouteRoles]);\n};\n\nexport default useActiveRouteRoleWatcher;\n"]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
import CurrentAppContext from '../CurrentAppContext';
|
|
3
|
-
|
|
4
3
|
const useAppConfig = () => {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const { appConfig } = useContext(CurrentAppContext);
|
|
5
|
+
return appConfig;
|
|
7
6
|
};
|
|
8
|
-
|
|
9
7
|
export default useAppConfig;
|
|
8
|
+
//# sourceMappingURL=useAppConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAppConfig.js","sourceRoot":"","sources":["../../../../runtime/react/hooks/useAppConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AAErD,MAAM,YAAY,GAAG,GAAG,EAAE;IACxB,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IACpD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { useContext } from 'react';\nimport CurrentAppContext from '../CurrentAppContext';\n\nconst useAppConfig = () => {\n const { appConfig } = useContext(CurrentAppContext);\n return appConfig;\n};\n\nexport default useAppConfig;\n"]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
import SiteContext from '../SiteContext';
|
|
3
|
-
|
|
4
3
|
const useAuthenticatedUser = () => {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const { authenticatedUser } = useContext(SiteContext);
|
|
5
|
+
return authenticatedUser;
|
|
7
6
|
};
|
|
8
|
-
|
|
9
7
|
export default useAuthenticatedUser;
|
|
8
|
+
//# sourceMappingURL=useAuthenticatedUser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAuthenticatedUser.js","sourceRoot":"","sources":["../../../../runtime/react/hooks/useAuthenticatedUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAEzC,MAAM,oBAAoB,GAAG,GAAG,EAAE;IAChC,MAAM,EAAE,iBAAiB,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IACtD,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC","sourcesContent":["import { useContext } from 'react';\nimport SiteContext from '../SiteContext';\n\nconst useAuthenticatedUser = () => {\n const { authenticatedUser } = useContext(SiteContext);\n return authenticatedUser;\n};\n\nexport default useAuthenticatedUser;\n"]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
import SiteContext from '../SiteContext';
|
|
3
|
-
|
|
4
3
|
const useSiteConfig = () => {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const { siteConfig } = useContext(SiteContext);
|
|
5
|
+
return siteConfig;
|
|
7
6
|
};
|
|
8
|
-
|
|
9
7
|
export default useSiteConfig;
|
|
8
|
+
//# sourceMappingURL=useSiteConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSiteConfig.js","sourceRoot":"","sources":["../../../../runtime/react/hooks/useSiteConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAEzC,MAAM,aAAa,GAAG,GAAG,EAAE;IACzB,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IAC/C,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { useContext } from 'react';\nimport SiteContext from '../SiteContext';\n\nconst useSiteConfig = () => {\n const { siteConfig } = useContext(SiteContext);\n return siteConfig;\n};\n\nexport default useSiteConfig;\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A React hook that allows functional components to subscribe to application events. This should
|
|
3
|
+
* be used sparingly - for the most part, Context should be used higher-up in the application to
|
|
4
|
+
* provide necessary data to a given component, rather than utilizing a non-React-like Pub/Sub
|
|
5
|
+
* mechanism.
|
|
6
|
+
*
|
|
7
|
+
* @memberof module:React
|
|
8
|
+
* @param {string} type
|
|
9
|
+
* @param {function} callback
|
|
10
|
+
*/
|
|
11
|
+
declare const useSiteEvent: (type: any, callback: any) => void;
|
|
12
|
+
export default useSiteEvent;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { subscribe, unsubscribe } from '../../subscriptions';
|
|
3
|
-
|
|
4
3
|
/**
|
|
5
4
|
* A React hook that allows functional components to subscribe to application events. This should
|
|
6
5
|
* be used sparingly - for the most part, Context should be used higher-up in the application to
|
|
@@ -12,13 +11,12 @@ import { subscribe, unsubscribe } from '../../subscriptions';
|
|
|
12
11
|
* @param {function} callback
|
|
13
12
|
*/
|
|
14
13
|
const useSiteEvent = (type, callback) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
}, [callback, type]);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
subscribe(type, callback);
|
|
16
|
+
return () => {
|
|
17
|
+
unsubscribe(type, callback);
|
|
18
|
+
};
|
|
19
|
+
}, [callback, type]);
|
|
22
20
|
};
|
|
23
|
-
|
|
24
21
|
export default useSiteEvent;
|
|
22
|
+
//# sourceMappingURL=useSiteEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSiteEvent.js","sourceRoot":"","sources":["../../../../runtime/react/hooks/useSiteEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;;;;;;;GASG;AACH,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE;IACtC,SAAS,CAAC,GAAG,EAAE;QACb,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAE1B,OAAO,GAAG,EAAE;YACV,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC9B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;AACvB,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { useEffect } from 'react';\nimport { subscribe, unsubscribe } from '../../subscriptions';\n\n/**\n * A React hook that allows functional components to subscribe to application events. This should\n * be used sparingly - for the most part, Context should be used higher-up in the application to\n * provide necessary data to a given component, rather than utilizing a non-React-like Pub/Sub\n * mechanism.\n *\n * @memberof module:React\n * @param {string} type\n * @param {function} callback\n */\nconst useSiteEvent = (type, callback) => {\n useEffect(() => {\n subscribe(type, callback);\n\n return () => {\n unsubscribe(type, callback);\n };\n }, [callback, type]);\n};\n\nexport default useSiteEvent;\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #### Import members from **@openedx/frontend-base** React
|
|
3
|
+
* The React module provides a variety of React components, hooks, and contexts for use in an
|
|
4
|
+
* application.
|
|
5
|
+
*
|
|
6
|
+
* @module React
|
|
7
|
+
*/
|
|
8
|
+
export { default as CurrentAppContext } from './CurrentAppContext';
|
|
9
|
+
export { default as CurrentAppProvider } from './CurrentAppProvider';
|
|
10
|
+
export { default as SiteContext } from './SiteContext';
|
|
11
|
+
export { default as SiteProvider } from './SiteProvider';
|
|
12
|
+
export { default as AuthenticatedPageRoute } from './AuthenticatedPageRoute';
|
|
13
|
+
export { default as Divider } from './Divider';
|
|
14
|
+
export { default as ErrorBoundary } from './ErrorBoundary';
|
|
15
|
+
export { default as ErrorPage } from './ErrorPage';
|
|
16
|
+
export { useSiteEvent, useAuthenticatedUser, useSiteConfig, useAppConfig } from './hooks';
|
|
17
|
+
export { default as LoginRedirect } from './LoginRedirect';
|
|
18
|
+
export { default as PageWrap } from './PageWrap';
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../runtime/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC","sourcesContent":["/**\n * #### Import members from **@openedx/frontend-base** React\n * The React module provides a variety of React components, hooks, and contexts for use in an\n * application.\n *\n * @module React\n */\n\nexport { default as CurrentAppContext } from './CurrentAppContext';\nexport { default as CurrentAppProvider } from './CurrentAppProvider';\nexport { default as SiteContext } from './SiteContext';\nexport { default as SiteProvider } from './SiteProvider';\nexport { default as AuthenticatedPageRoute } from './AuthenticatedPageRoute';\nexport { default as Divider } from './Divider';\nexport { default as ErrorBoundary } from './ErrorBoundary';\nexport { default as ErrorPage } from './ErrorPage';\nexport { useSiteEvent, useAuthenticatedUser, useSiteConfig, useAppConfig } from './hooks';\nexport { default as LoginRedirect } from './LoginRedirect';\nexport { default as PageWrap } from './PageWrap';\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function themeReducer(state: any, action: any): any;
|
|
2
|
+
export declare const themeActions: {
|
|
3
|
+
setThemeVariant: (payload: any) => {
|
|
4
|
+
type: string;
|
|
5
|
+
payload: any;
|
|
6
|
+
};
|
|
7
|
+
setThemeLoaded: (payload: any) => {
|
|
8
|
+
type: string;
|
|
9
|
+
payload: any;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SET_THEME_VARIANT, SET_IS_THEME_LOADED, } from './constants';
|
|
2
|
+
export function themeReducer(state, action) {
|
|
3
|
+
switch (action.type) {
|
|
4
|
+
case SET_THEME_VARIANT: {
|
|
5
|
+
const requestedThemeVariant = action.payload;
|
|
6
|
+
return Object.assign(Object.assign({}, state), { themeVariant: requestedThemeVariant });
|
|
7
|
+
}
|
|
8
|
+
case SET_IS_THEME_LOADED: {
|
|
9
|
+
const requestedIsThemeLoaded = action.payload;
|
|
10
|
+
return Object.assign(Object.assign({}, state), { isThemeLoaded: requestedIsThemeLoaded });
|
|
11
|
+
}
|
|
12
|
+
default:
|
|
13
|
+
return state;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const setThemeVariant = (payload) => ({
|
|
17
|
+
type: SET_THEME_VARIANT,
|
|
18
|
+
payload,
|
|
19
|
+
});
|
|
20
|
+
const setThemeLoaded = (payload) => ({
|
|
21
|
+
type: SET_IS_THEME_LOADED,
|
|
22
|
+
payload,
|
|
23
|
+
});
|
|
24
|
+
export const themeActions = {
|
|
25
|
+
setThemeVariant,
|
|
26
|
+
setThemeLoaded,
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=reducers.js.map
|