@openedx/frontend-base 1.0.0-alpha.9 → 1.0.0
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/README.md +27 -0
- package/dist/index.d.ts +4 -0
- 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/dist/runtime/analytics/interface.js +133 -0
- 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/dist/runtime/auth/interface.js +302 -0
- 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/dist/runtime/babel.config.js +4 -0
- package/dist/runtime/babel.config.js.map +1 -0
- package/dist/runtime/config/index.d.ts +216 -0
- package/dist/runtime/config/index.js +428 -0
- package/dist/runtime/config/index.js.map +1 -0
- package/dist/runtime/constants.d.ts +57 -0
- package/dist/runtime/constants.js +58 -0
- package/dist/runtime/constants.js.map +1 -0
- package/dist/runtime/i18n/index.d.ts +3 -0
- package/dist/runtime/i18n/index.js +78 -0
- 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 +113 -0
- package/dist/runtime/i18n/lib.js +223 -0
- package/dist/runtime/i18n/lib.js.map +1 -0
- package/dist/runtime/index.d.ts +14 -0
- package/dist/runtime/index.js +15 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/initialize.d.ts +87 -0
- package/dist/runtime/initialize.js +305 -0
- package/dist/runtime/initialize.js.map +1 -0
- package/dist/runtime/jest.config.d.ts +16 -0
- package/dist/runtime/jest.config.js +34 -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/dist/runtime/logging/index.d.ts +3 -0
- 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/dist/runtime/logging/interface.js +99 -0
- 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 +30 -0
- package/dist/runtime/react/AuthenticatedPageRoute.js +38 -0
- package/dist/runtime/react/AuthenticatedPageRoute.js.map +1 -0
- package/dist/runtime/react/CombinedAppProvider.d.ts +6 -0
- package/dist/runtime/react/CombinedAppProvider.js +20 -0
- package/dist/runtime/react/CombinedAppProvider.js.map +1 -0
- package/dist/runtime/react/CurrentAppContext.d.ts +20 -0
- package/dist/runtime/react/CurrentAppContext.js +21 -0
- 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/dist/runtime/react/LoginRedirect.js +16 -0
- package/dist/runtime/react/LoginRedirect.js.map +1 -0
- package/dist/runtime/react/NotFoundPage.d.ts +2 -0
- package/dist/runtime/react/NotFoundPage.js +14 -0
- package/dist/runtime/react/NotFoundPage.js.map +1 -0
- package/dist/runtime/react/PageWrap.d.ts +8 -0
- package/dist/runtime/react/PageWrap.js +21 -0
- package/dist/runtime/react/PageWrap.js.map +1 -0
- package/dist/runtime/react/SiteContext.d.ts +24 -0
- package/dist/runtime/react/SiteContext.js +26 -0
- 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/dist/runtime/react/constants.js +4 -0
- package/dist/runtime/react/constants.js.map +1 -0
- package/dist/runtime/react/hooks/index.d.ts +7 -0
- 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/dist/runtime/react/hooks/theme/useThemeConfig.js +29 -0
- 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 +48 -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/dist/runtime/react/hooks/theme/utils.js +11 -0
- package/dist/runtime/react/hooks/theme/utils.js.map +1 -0
- package/dist/runtime/react/hooks/useActiveRoles.d.ts +2 -0
- package/dist/runtime/react/hooks/useActiveRoles.js +16 -0
- 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 +22 -0
- package/dist/runtime/react/hooks/useActiveRouteRoleWatcher.js.map +1 -0
- package/dist/runtime/react/hooks/useAppConfig.d.ts +2 -0
- package/dist/runtime/react/hooks/useAppConfig.js +8 -0
- package/dist/runtime/react/hooks/useAppConfig.js.map +1 -0
- package/dist/runtime/react/hooks/useAuthenticatedUser.d.ts +2 -0
- package/dist/runtime/react/hooks/useAuthenticatedUser.js +8 -0
- package/dist/runtime/react/hooks/useAuthenticatedUser.js.map +1 -0
- package/dist/runtime/react/hooks/useSiteConfig.d.ts +2 -0
- package/dist/runtime/react/hooks/useSiteConfig.js +8 -0
- package/dist/runtime/react/hooks/useSiteConfig.js.map +1 -0
- package/dist/runtime/react/hooks/useSiteEvent.d.ts +12 -0
- package/dist/runtime/react/hooks/useSiteEvent.js +22 -0
- package/dist/runtime/react/hooks/useSiteEvent.js.map +1 -0
- package/dist/runtime/react/index.d.ts +19 -0
- package/dist/runtime/react/index.js +20 -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/authenticatedLoader.d.ts +2 -0
- package/dist/runtime/routing/authenticatedLoader.js +27 -0
- package/dist/runtime/routing/authenticatedLoader.js.map +1 -0
- package/dist/runtime/routing/index.d.ts +2 -0
- package/dist/runtime/routing/index.js +3 -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 +43 -0
- package/dist/runtime/routing/utils.js.map +1 -0
- package/dist/runtime/scripts/index.d.ts +1 -0
- package/dist/runtime/scripts/index.js +14 -0
- package/dist/runtime/scripts/index.js.map +1 -0
- package/dist/runtime/setupTest.d.ts +1 -0
- package/dist/runtime/setupTest.js +12 -0
- package/dist/runtime/setupTest.js.map +1 -0
- package/dist/runtime/slots/Slot.d.ts +11 -0
- package/dist/runtime/slots/Slot.js +37 -0
- package/dist/runtime/slots/Slot.js.map +1 -0
- package/dist/runtime/slots/SlotContext.d.ts +8 -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 +11 -0
- package/dist/runtime/slots/hooks.js +19 -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 +9 -0
- package/dist/runtime/slots/layout/hooks.js +52 -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/dist/runtime/slots/layout/types.d.ts +30 -0
- 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/dist/runtime/slots/types.d.ts +18 -0
- 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 +65 -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 +12 -0
- package/dist/runtime/slots/widget/hooks.js +84 -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/dist/runtime/slots/widget/iframe/constants.js +17 -0
- 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/dist/runtime/slots/widget/iframe/index.d.ts +3 -0
- package/dist/runtime/slots/widget/iframe/index.js +3 -0
- package/dist/runtime/slots/widget/iframe/index.js.map +1 -0
- package/dist/runtime/slots/widget/iframe/types.d.ts +5 -0
- 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/dist/runtime/slots/widget/types.d.ts +108 -0
- 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 +181 -0
- package/dist/runtime/slots/widget/utils.js.map +1 -0
- package/dist/runtime/subscriptions.d.ts +24 -0
- package/dist/runtime/subscriptions.js +48 -0
- package/dist/runtime/subscriptions.js.map +1 -0
- package/dist/runtime/testing/index.d.ts +8 -0
- 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/dist/runtime/testing/initializeMockApp.js +71 -0
- 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/dist/runtime/utils.js +163 -0
- 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 +16 -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 +63 -0
- package/dist/shell/Shell.messages.js +65 -0
- package/dist/shell/Shell.messages.js.map +1 -0
- package/dist/shell/app.d.ts +3 -0
- package/dist/shell/app.js +43 -0
- package/dist/shell/app.js.map +1 -0
- package/dist/shell/babel.config.d.ts +2 -0
- package/dist/shell/babel.config.js +4 -0
- package/dist/shell/babel.config.js.map +1 -0
- package/dist/shell/constants.d.ts +2 -0
- package/dist/shell/constants.js +3 -0
- package/dist/shell/constants.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 +14 -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 +15 -0
- package/dist/shell/dev/devHome/app.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/index.d.ts +4 -0
- package/dist/shell/dev/index.js +5 -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 +8 -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/SlotShowcase.scss +50 -0
- package/dist/shell/dev/slotShowcase/SlotShowcasePage.d.ts +2 -0
- package/dist/shell/dev/slotShowcase/SlotShowcasePage.js +17 -0
- package/dist/shell/dev/slotShowcase/SlotShowcasePage.js.map +1 -0
- package/dist/shell/dev/slotShowcase/ToggleByRoleLayout.d.ts +1 -0
- package/dist/shell/dev/slotShowcase/ToggleByRoleLayout.js +11 -0
- package/dist/shell/dev/slotShowcase/ToggleByRoleLayout.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 +372 -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/DesktopFooterLayout.d.ts +1 -0
- package/dist/shell/footer/DesktopFooterLayout.js +12 -0
- package/dist/shell/footer/DesktopFooterLayout.js.map +1 -0
- package/dist/shell/footer/Footer.d.ts +1 -0
- package/dist/shell/footer/Footer.js +6 -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 +67 -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 +9 -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/HelpButton.d.ts +5 -0
- package/dist/shell/header/HelpButton.js +10 -0
- package/dist/shell/header/HelpButton.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 +4 -0
- package/dist/shell/header/app.js +157 -0
- package/dist/shell/header/app.js.map +1 -0
- package/dist/shell/header/app.scss +20 -0
- package/dist/shell/header/constants.d.ts +3 -0
- package/dist/shell/header/constants.js +4 -0
- package/dist/shell/header/constants.js.map +1 -0
- package/dist/shell/header/course-bar/data/service.d.ts +11 -0
- package/dist/shell/header/course-bar/data/service.js +49 -0
- package/dist/shell/header/course-bar/data/service.js.map +1 -0
- package/dist/shell/header/course-bar/masquerade/MasqueradeBar.d.ts +1 -0
- package/dist/shell/header/course-bar/masquerade/MasqueradeBar.js +22 -0
- package/dist/shell/header/course-bar/masquerade/MasqueradeBar.js.map +1 -0
- package/dist/shell/header/course-bar/masquerade/MasqueradeContext.d.ts +3 -0
- package/dist/shell/header/course-bar/masquerade/MasqueradeContext.js +10 -0
- package/dist/shell/header/course-bar/masquerade/MasqueradeContext.js.map +1 -0
- package/dist/shell/header/course-bar/masquerade/StudioLink.d.ts +6 -0
- package/dist/shell/header/course-bar/masquerade/StudioLink.js +27 -0
- package/dist/shell/header/course-bar/masquerade/StudioLink.js.map +1 -0
- package/dist/shell/header/course-bar/masquerade/data/api.d.ts +29 -0
- package/dist/shell/header/course-bar/masquerade/data/api.js +33 -0
- package/dist/shell/header/course-bar/masquerade/data/api.js.map +1 -0
- package/dist/shell/header/course-bar/masquerade/hooks.d.ts +20 -0
- package/dist/shell/header/course-bar/masquerade/hooks.js +203 -0
- package/dist/shell/header/course-bar/masquerade/hooks.js.map +1 -0
- package/dist/shell/header/course-bar/masquerade/index.d.ts +1 -0
- package/dist/shell/header/course-bar/masquerade/index.js +2 -0
- package/dist/shell/header/course-bar/masquerade/index.js.map +1 -0
- package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeUserNameInput.d.ts +7 -0
- package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeUserNameInput.js +18 -0
- package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeUserNameInput.js.map +1 -0
- package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeWidget.d.ts +1 -0
- package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeWidget.js +16 -0
- package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeWidget.js.map +1 -0
- package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeWidgetOption.d.ts +6 -0
- package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeWidgetOption.js +18 -0
- package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeWidgetOption.js.map +1 -0
- package/dist/shell/header/course-bar/masquerade/masquerade-widget/index.d.ts +2 -0
- package/dist/shell/header/course-bar/masquerade/masquerade-widget/index.js +3 -0
- package/dist/shell/header/course-bar/masquerade/masquerade-widget/index.js.map +1 -0
- package/dist/shell/header/course-bar/masquerade/masquerade-widget/messages.d.ts +28 -0
- package/dist/shell/header/course-bar/masquerade/masquerade-widget/messages.js +30 -0
- package/dist/shell/header/course-bar/masquerade/masquerade-widget/messages.js.map +1 -0
- package/dist/shell/header/course-bar/masquerade/messages.d.ts +28 -0
- package/dist/shell/header/course-bar/masquerade/messages.js +30 -0
- package/dist/shell/header/course-bar/masquerade/messages.js.map +1 -0
- package/dist/shell/header/course-bar/navigation/CourseTabsNavigation.d.ts +3 -0
- package/dist/shell/header/course-bar/navigation/CourseTabsNavigation.js +39 -0
- package/dist/shell/header/course-bar/navigation/CourseTabsNavigation.js.map +1 -0
- package/dist/shell/header/course-bar/navigation/course-tabs-navigation.scss +7 -0
- package/dist/shell/header/course-bar/navigation/messages.d.ts +8 -0
- package/dist/shell/header/course-bar/navigation/messages.js +10 -0
- package/dist/shell/header/course-bar/navigation/messages.js.map +1 -0
- package/dist/shell/header/course-bar/utils.d.ts +3 -0
- package/dist/shell/header/course-bar/utils.js +54 -0
- package/dist/shell/header/course-bar/utils.js.map +1 -0
- package/dist/shell/header/desktop/DesktopLayout.d.ts +1 -0
- package/dist/shell/header/desktop/DesktopLayout.js +10 -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/helpButtonSlotOperation.d.ts +6 -0
- package/dist/shell/header/helpButtonSlotOperation.js +14 -0
- package/dist/shell/header/helpButtonSlotOperation.js.map +1 -0
- package/dist/shell/header/index.d.ts +5 -0
- package/dist/shell/header/index.js +6 -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/index.d.ts +8 -0
- package/dist/shell/index.js +9 -0
- package/dist/shell/index.js.map +1 -0
- package/dist/shell/jest.config.d.ts +15 -0
- package/dist/shell/jest.config.js +32 -0
- package/dist/shell/jest.config.js.map +1 -0
- package/dist/shell/layer-order.scss +1 -0
- package/dist/shell/menus/LinkMenuItem.d.ts +9 -0
- package/dist/shell/menus/LinkMenuItem.js +38 -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/dist/shell/router/createRouter.js +26 -0
- package/dist/shell/router/createRouter.js.map +1 -0
- package/dist/shell/router/getAppRoutes.d.ts +2 -0
- package/dist/shell/router/getAppRoutes.js +27 -0
- package/dist/shell/router/getAppRoutes.js.map +1 -0
- package/dist/shell/setupTest.d.ts +1 -0
- package/dist/shell/setupTest.js +12 -0
- 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 +45 -0
- package/dist/shell/site.js.map +1 -0
- package/dist/shell/style.d.ts +3 -0
- package/dist/shell/style.js +10 -0
- package/dist/shell/style.js.map +1 -0
- package/dist/shell/style.scss +147 -0
- package/dist/tools/babel/babel.config.d.ts +12 -0
- package/dist/tools/babel.config.d.ts +2 -0
- package/dist/tools/babel.config.js +3 -0
- package/dist/tools/cli/commands/serve.d.ts +1 -0
- package/dist/tools/cli/commands/translations.d.ts +2 -0
- package/dist/tools/cli/commands/translations.js +20 -0
- package/dist/tools/cli/openedx.d.ts +2 -0
- package/dist/tools/cli/openedx.js +111 -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/formatter.js +3 -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/cli/utils/printUsage.js +47 -0
- package/dist/tools/cli/utils/translations/index.d.ts +2 -0
- package/dist/tools/cli/utils/translations/index.js +7 -0
- package/dist/tools/cli/utils/translations/messagesObject.d.ts +26 -0
- package/dist/tools/cli/utils/translations/messagesObject.js +66 -0
- package/dist/tools/cli/utils/translations/prepare.d.ts +5 -0
- package/dist/tools/cli/utils/translations/prepare.js +98 -0
- package/dist/tools/cli/utils/translations/pull.d.ts +6 -0
- package/dist/tools/cli/utils/translations/pull.js +102 -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/base.eslint.config.js +114 -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 +14 -0
- package/dist/tools/jest.config.d.ts +8 -0
- package/dist/tools/types.d.ts +20 -0
- package/dist/tools/types.js +25 -0
- package/dist/tools/typescript/tsconfig.json +33 -0
- 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 +12 -0
- package/dist/tools/webpack/common-config/all/getStylesheetRule.js +150 -0
- package/dist/tools/webpack/common-config/all/postcssWrapLayer.d.ts +4 -0
- package/dist/tools/webpack/common-config/all/postcssWrapLayer.js +32 -0
- package/dist/tools/webpack/common-config/dev/getDevServer.d.ts +2 -0
- package/dist/tools/webpack/common-config/dev/getDevServer.js +36 -0
- package/dist/tools/webpack/common-config/index.d.ts +7 -0
- package/dist/tools/webpack/common-config/index.js +20 -0
- package/dist/tools/webpack/common-config/site/getHtmlWebpackPlugin.d.ts +2 -0
- package/dist/tools/webpack/common-config/site/getHtmlWebpackPlugin.js +24 -0
- package/dist/tools/webpack/common-config/site/getI18nMessagesFallbackPlugin/emptyI18n.d.ts +2 -0
- package/dist/tools/webpack/common-config/site/getI18nMessagesFallbackPlugin/emptyI18n.js +3 -0
- package/dist/tools/webpack/common-config/site/getI18nMessagesFallbackPlugin/index.d.ts +2 -0
- package/dist/tools/webpack/common-config/site/getI18nMessagesFallbackPlugin/index.js +26 -0
- package/dist/tools/webpack/plugins/html-webpack-new-relic-plugin/HtmlWebpackNewRelicPlugin.d.ts +16 -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/fixtures/entry.d.ts +1 -0
- package/dist/tools/webpack/utils/getPublicPath.d.ts +1 -0
- package/dist/tools/webpack/utils/getPublicPath.js +6 -0
- package/dist/tools/webpack/utils/getResolvedSiteConfigPath.d.ts +1 -0
- package/dist/tools/webpack/utils/getResolvedSiteI18nPath.d.ts +1 -0
- package/dist/tools/webpack/utils/getResolvedSiteI18nPath.js +25 -0
- package/dist/tools/webpack/webpack.config.build.d.ts +3 -0
- package/dist/tools/webpack/webpack.config.build.js +78 -0
- package/dist/tools/webpack/webpack.config.dev.d.ts +3 -0
- package/dist/tools/webpack/webpack.config.dev.js +78 -0
- package/dist/tools/webpack/webpack.config.dev.shell.d.ts +3 -0
- package/dist/tools/webpack/webpack.config.dev.shell.js +105 -0
- package/dist/types.d.ts +93 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/package.json +45 -32
- package/config/eslint/base.eslint.config.js +0 -113
- package/config/tsconfig.json +0 -32
- package/config/types.js +0 -23
- package/config/webpack/common-config/all/getIgnoreWarnings.js +0 -14
- package/config/webpack/common-config/all/getStylesheetRule.js +0 -112
- package/config/webpack/common-config/dev/getDevServer.js +0 -38
- package/config/webpack/common-config/index.js +0 -18
- package/config/webpack/common-config/site/getHtmlWebpackPlugin.js +0 -16
- package/config/webpack/plugins/html-webpack-new-relic-plugin/test/HtmlWebpackNewRelicPlugin.test.js +0 -66
- package/config/webpack/utils/getLocalAliases.js +0 -65
- package/config/webpack/utils/getPublicPath.js +0 -6
- package/config/webpack/webpack.config.build.js +0 -69
- package/config/webpack/webpack.config.dev.js +0 -69
- package/config/webpack/webpack.config.dev.shell.js +0 -103
- package/index.ts +0 -7
- 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.js +0 -145
- 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/interface.js +0 -309
- package/runtime/auth/utils.js +0 -105
- package/runtime/babel.config.js +0 -3
- package/runtime/config/getExternalLinkUrl.test.js +0 -76
- package/runtime/config/index.ts +0 -294
- package/runtime/constants.ts +0 -68
- package/runtime/i18n/index.js +0 -118
- 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/index.ts +0 -9
- package/runtime/logging/interface.js +0 -109
- package/runtime/logging/types.ts +0 -4
- package/runtime/react/AuthenticatedPageRoute.jsx +0 -43
- package/runtime/react/AuthenticatedPageRoute.test.jsx +0 -135
- package/runtime/react/CombinedAppProvider.tsx +0 -46
- package/runtime/react/CurrentAppContext.tsx +0 -25
- 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/LoginRedirect.jsx +0 -16
- package/runtime/react/PageWrap.jsx +0 -24
- package/runtime/react/SiteContext.tsx +0 -32
- package/runtime/react/SiteProvider.test.jsx +0 -66
- package/runtime/react/SiteProvider.tsx +0 -101
- package/runtime/react/constants.ts +0 -3
- package/runtime/react/hooks/index.ts +0 -8
- 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/useThemeConfig.ts +0 -34
- 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/theme/utils.ts +0 -11
- package/runtime/react/hooks/useActiveRoles.ts +0 -15
- package/runtime/react/hooks/useActiveRouteRoleWatcher.ts +0 -31
- package/runtime/react/hooks/useAppConfig.ts +0 -9
- package/runtime/react/hooks/useAuthenticatedUser.test.tsx +0 -41
- package/runtime/react/hooks/useAuthenticatedUser.ts +0 -9
- package/runtime/react/hooks/useSiteConfig.test.tsx +0 -13
- package/runtime/react/hooks/useSiteConfig.ts +0 -9
- package/runtime/react/hooks/useSiteEvent.ts +0 -24
- package/runtime/react/index.ts +0 -19
- package/runtime/react/reducers.ts +0 -40
- package/runtime/routing/index.ts +0 -1
- 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/scripts/index.ts +0 -1
- package/runtime/setupTest.js +0 -14
- 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/types.ts +0 -45
- package/runtime/slots/layout/utils.test.ts +0 -67
- package/runtime/slots/layout/utils.ts +0 -14
- package/runtime/slots/types.ts +0 -24
- 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/constants.ts +0 -19
- package/runtime/slots/widget/iframe/hooks.ts +0 -179
- package/runtime/slots/widget/iframe/index.ts +0 -6
- package/runtime/slots/widget/iframe/types.ts +0 -7
- package/runtime/slots/widget/types.ts +0 -134
- package/runtime/slots/widget/utils.tsx +0 -201
- package/runtime/subscriptions.ts +0 -60
- package/runtime/testing/index.ts +0 -9
- package/runtime/testing/initializeMockApp.test.ts +0 -66
- package/runtime/testing/initializeMockApp.ts +0 -86
- package/runtime/testing/mockMessages.ts +0 -23
- package/runtime/utils.js +0 -178
- 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.scss +0 -150
- package/shell/app.ts +0 -38
- package/shell/babel.config.js +0 -3
- 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/devUser/index.ts +0 -1
- package/shell/dev/index.ts +0 -5
- 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/index.ts +0 -2
- 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/index.ts +0 -7
- 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/createRouter.ts +0 -17
- package/shell/router/getAppRoutes.test.tsx +0 -59
- package/shell/router/getAppRoutes.ts +0 -21
- package/shell/setupTest.js +0 -13
- 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/cli/intl-imports.js +0 -233
- package/tools/dist/cli/intl-imports.test.js +0 -146
- package/tools/dist/cli/openedx.js +0 -86
- package/tools/dist/cli/transifex-utils.js +0 -68
- package/tools/dist/cli/utils/formatter.js +0 -10
- package/tools/dist/cli/utils/printUsage.js +0 -39
- 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/jest/jest.config.js +0 -30
- package/tools/dist/types.js +0 -23
- package/tools/dist/typescript/tsconfig.json +0 -32
- 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 -69
- package/tools/dist/webpack/webpack.config.dev.js +0 -69
- package/tools/dist/webpack/webpack.config.dev.shell.js +0 -103
- package/types.ts +0 -119
- /package/{runtime/react/hooks/theme/index.ts → dist/runtime/react/hooks/theme/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/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/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/{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/utils/ensureConfigFilenameOption.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/{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/{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}/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/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/fixtures/entry.js +0 -0
- /package/{config → dist/tools}/webpack/utils/getResolvedSiteConfigPath.js +0 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { useCallback, useEffect, useReducer, useState, } from 'react';
|
|
2
|
+
import { SELECTED_THEME_VARIANT_KEY } from '../../constants';
|
|
3
|
+
import { logError } from '../../../logging';
|
|
4
|
+
import { themeActions, themeReducer } from '../../reducers';
|
|
5
|
+
import { isEmptyObject } from './utils';
|
|
6
|
+
import useThemeCore from './useThemeCore';
|
|
7
|
+
import useThemeConfig from './useThemeConfig';
|
|
8
|
+
import useThemeVariants from './useThemeVariants';
|
|
9
|
+
/**
|
|
10
|
+
* Finds the default theme variant from the given theme variants object. If no default theme exists, the light theme
|
|
11
|
+
* variant is returned as a fallback.
|
|
12
|
+
*
|
|
13
|
+
* It prioritizes:
|
|
14
|
+
* 1. A persisted theme variant from localStorage.
|
|
15
|
+
* 2. A system preference (`prefers-color-scheme`).
|
|
16
|
+
* 3. The configured default theme variant.
|
|
17
|
+
*
|
|
18
|
+
* Returns the default theme variant, or `undefined` if no valid theme variant is found.
|
|
19
|
+
*/
|
|
20
|
+
export const getDefaultThemeVariant = (themeVariants, themeDefaults = {}) => {
|
|
21
|
+
var _a, _b, _c, _d;
|
|
22
|
+
if (!themeVariants) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
const themeVariantKeys = Object.keys(themeVariants);
|
|
26
|
+
// If there is only one theme variant, return it since it's the only one that may be used.
|
|
27
|
+
if (themeVariantKeys.length === 1) {
|
|
28
|
+
const themeVariantKey = themeVariantKeys[0];
|
|
29
|
+
return {
|
|
30
|
+
name: themeVariantKey,
|
|
31
|
+
metadata: themeVariants[themeVariantKey],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
// Prioritize persisted localStorage theme variant preference.
|
|
35
|
+
const persistedSelectedThemeVariant = localStorage.getItem(SELECTED_THEME_VARIANT_KEY);
|
|
36
|
+
if (persistedSelectedThemeVariant && themeVariants[persistedSelectedThemeVariant]) {
|
|
37
|
+
return {
|
|
38
|
+
name: persistedSelectedThemeVariant,
|
|
39
|
+
metadata: themeVariants[persistedSelectedThemeVariant],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
// Then, detect system preference via `prefers-color-scheme` media query and use
|
|
43
|
+
// the default dark theme variant, if one exists.
|
|
44
|
+
const hasDarkSystemPreference = !!((_b = (_a = window.matchMedia) === null || _a === void 0 ? void 0 : _a.call(window, '(prefers-color-scheme: dark)')) === null || _b === void 0 ? void 0 : _b.matches);
|
|
45
|
+
const defaultDarkThemeVariant = (_c = themeDefaults.dark) !== null && _c !== void 0 ? _c : 'dark';
|
|
46
|
+
const darkThemeVariantMetadata = themeVariants[defaultDarkThemeVariant];
|
|
47
|
+
if (hasDarkSystemPreference && defaultDarkThemeVariant && darkThemeVariantMetadata) {
|
|
48
|
+
return {
|
|
49
|
+
name: defaultDarkThemeVariant,
|
|
50
|
+
metadata: darkThemeVariantMetadata,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const defaultLightThemeVariant = (_d = themeDefaults.light) !== null && _d !== void 0 ? _d : 'light';
|
|
54
|
+
const lightThemeVariantMetadata = themeVariants[defaultLightThemeVariant];
|
|
55
|
+
// Handle edge case where the default light theme variant is not configured or provided.
|
|
56
|
+
if (!lightThemeVariantMetadata) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
// Otherwise, fallback to using the default light theme variant as configured.
|
|
60
|
+
return {
|
|
61
|
+
name: defaultLightThemeVariant,
|
|
62
|
+
metadata: lightThemeVariantMetadata,
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* A custom React hook that manages the application's theme state and injects the appropriate CSS for the theme core
|
|
67
|
+
* and theme variants (e.g., light and dark modes) into the HTML document. It handles dynamically loading the theme
|
|
68
|
+
* CSS based on the current theme variant, and ensures that the theme variant's CSS is preloaded for runtime theme
|
|
69
|
+
* switching. This is done using "alternate" stylesheets. That is, the browser will download the CSS for the
|
|
70
|
+
* non-current theme variants with a lower priority than the current one.
|
|
71
|
+
*
|
|
72
|
+
* The hook also responds to system theme preference changes (e.g., via the `prefers-color-scheme` media query),
|
|
73
|
+
* and can automatically switch the theme based on the system's dark mode or light mode preference.
|
|
74
|
+
*
|
|
75
|
+
* * @example
|
|
76
|
+
* const [themeState, dispatch] = useTheme();
|
|
77
|
+
* console.log(themeState.isThemeLoaded); // true when the theme has been successfully loaded.
|
|
78
|
+
*
|
|
79
|
+
* // Dispatch an action to change the theme variant
|
|
80
|
+
* dispatch(themeActions.setThemeVariant('dark'));
|
|
81
|
+
*/
|
|
82
|
+
const useTheme = () => {
|
|
83
|
+
var _a;
|
|
84
|
+
const themeConfig = useThemeConfig();
|
|
85
|
+
const { core: themeCore, defaults: themeVariantDefaults, variants: themeVariants, } = themeConfig;
|
|
86
|
+
const initialThemeState = {
|
|
87
|
+
isThemeLoaded: false,
|
|
88
|
+
themeVariant: (_a = getDefaultThemeVariant(themeVariants, themeVariantDefaults)) === null || _a === void 0 ? void 0 : _a.name,
|
|
89
|
+
};
|
|
90
|
+
const [themeState, dispatch] = useReducer(themeReducer, initialThemeState);
|
|
91
|
+
const [isThemeCoreLoaded, setIsThemeCoreLoaded] = useState(false);
|
|
92
|
+
const onLoadThemeCore = useCallback(() => {
|
|
93
|
+
setIsThemeCoreLoaded(true);
|
|
94
|
+
}, []);
|
|
95
|
+
const [hasLoadedThemeVariants, setHasLoadedThemeVariants] = useState(false);
|
|
96
|
+
const onLoadThemeVariants = useCallback(() => {
|
|
97
|
+
setHasLoadedThemeVariants(true);
|
|
98
|
+
}, []);
|
|
99
|
+
// load the theme's core CSS
|
|
100
|
+
useThemeCore({
|
|
101
|
+
themeCore,
|
|
102
|
+
onComplete: onLoadThemeCore,
|
|
103
|
+
});
|
|
104
|
+
// respond to system preference changes with regard to `prefers-color-scheme: dark`.
|
|
105
|
+
const handleDarkModeSystemPreferenceChange = useCallback((prefersDarkMode) => {
|
|
106
|
+
// Ignore system preference change if the theme variant is already set in localStorage.
|
|
107
|
+
if (localStorage.getItem(SELECTED_THEME_VARIANT_KEY)) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (prefersDarkMode && (themeVariantDefaults === null || themeVariantDefaults === void 0 ? void 0 : themeVariantDefaults.dark)) {
|
|
111
|
+
dispatch(themeActions.setThemeVariant(themeVariantDefaults.dark));
|
|
112
|
+
}
|
|
113
|
+
else if (!prefersDarkMode && (themeVariantDefaults === null || themeVariantDefaults === void 0 ? void 0 : themeVariantDefaults.light)) {
|
|
114
|
+
dispatch(themeActions.setThemeVariant(themeVariantDefaults.light));
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
logError(`Could not set theme variant based on system preference (prefers dark mode: ${prefersDarkMode})`);
|
|
118
|
+
}
|
|
119
|
+
}, [themeVariantDefaults]);
|
|
120
|
+
// load the theme variant(s) CSS
|
|
121
|
+
useThemeVariants({
|
|
122
|
+
themeVariants,
|
|
123
|
+
onComplete: onLoadThemeVariants,
|
|
124
|
+
currentThemeVariant: themeState.themeVariant,
|
|
125
|
+
onDarkModeSystemPreferenceChange: handleDarkModeSystemPreferenceChange,
|
|
126
|
+
});
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
// theme is already loaded, do nothing
|
|
129
|
+
if (themeState.isThemeLoaded) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const hasThemeConfig = ((themeCore === null || themeCore === void 0 ? void 0 : themeCore.url) && !isEmptyObject(themeVariants));
|
|
133
|
+
if (!hasThemeConfig) {
|
|
134
|
+
// no theme URLs to load, set loading to false.
|
|
135
|
+
dispatch(themeActions.setThemeLoaded(true));
|
|
136
|
+
}
|
|
137
|
+
// Return early if neither the core theme CSS nor any theme variant CSS is loaded.
|
|
138
|
+
if (!isThemeCoreLoaded || !hasLoadedThemeVariants) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
// All application theme URLs are loaded
|
|
142
|
+
dispatch(themeActions.setThemeLoaded(true));
|
|
143
|
+
}, [
|
|
144
|
+
themeState.isThemeLoaded,
|
|
145
|
+
isThemeCoreLoaded,
|
|
146
|
+
hasLoadedThemeVariants,
|
|
147
|
+
themeCore === null || themeCore === void 0 ? void 0 : themeCore.url,
|
|
148
|
+
themeVariants,
|
|
149
|
+
]);
|
|
150
|
+
return [themeState, dispatch];
|
|
151
|
+
};
|
|
152
|
+
export default useTheme;
|
|
153
|
+
//# sourceMappingURL=useTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTheme.js","sourceRoot":"","sources":["../../../../../runtime/react/hooks/theme/useTheme.ts"],"names":[],"mappings":"AAAA,OAAO,E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oC;KACvE,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,sCAAsC;QACtC,IAAI,UAAU,CAAC,aAAa,EAAE,CAAC;YAC7B,OAAO;QACT,CAAC;QAED,MAAM,cAAc,GAAG,CAAC,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,GAAG,KAAI,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC;QACzE,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,+CAA+C;YAC/C,QAAQ,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9C,CAAC;QAED,kFAAkF;QAClF,IAAI,CAAC,iBAAiB,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAClD,OAAO;QACT,CAAC;QAED,wCAAwC;QACxC,QAAQ,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9C,CAAC,EAAE;QACD,UAAU,CAAC,aAAa;QACxB,iBAAiB;QACjB,sBAAsB;QACtB,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,GAAG;QACd,aAAa;KACd,CAAC,CAAC;IAEH,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC","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;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { getSiteConfig } from '../../../config';
|
|
3
|
+
import { isEmptyObject } from './utils';
|
|
4
|
+
/**
|
|
5
|
+
* Custom React hook that retrieves the theme configuration.
|
|
6
|
+
*
|
|
7
|
+
* Configuration is considered entirely invalid if it doesn't define at least one variant, including core.
|
|
8
|
+
*
|
|
9
|
+
* Example:
|
|
10
|
+
*
|
|
11
|
+
* const themeConfig = useThemeConfig();
|
|
12
|
+
* if (themeConfig) {
|
|
13
|
+
* console.log(themeConfig.core.url); // Outputs the URL of theme's core CSS
|
|
14
|
+
* console.log(themeConfig.variants['dark'].url); // Outputs the URL of the theme's dark variant CSS
|
|
15
|
+
* }
|
|
16
|
+
*/
|
|
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
|
+
};
|
|
27
|
+
}, []);
|
|
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,48 @@
|
|
|
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 existingThemeCoreLink = document.head.querySelector('link[data-theme-core="true"]');
|
|
23
|
+
if (existingThemeCoreLink) {
|
|
24
|
+
if (existingThemeCoreLink.getAttribute('href') === themeCore.url) {
|
|
25
|
+
setIsThemeCoreComplete(true);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
existingThemeCoreLink.remove();
|
|
29
|
+
}
|
|
30
|
+
const themeCoreLink = document.createElement('link');
|
|
31
|
+
themeCoreLink.href = themeCore.url;
|
|
32
|
+
themeCoreLink.rel = 'stylesheet';
|
|
33
|
+
themeCoreLink.dataset.themeCore = 'true';
|
|
34
|
+
themeCoreLink.onload = () => {
|
|
35
|
+
setIsThemeCoreComplete(true);
|
|
36
|
+
};
|
|
37
|
+
themeCoreLink.onerror = () => {
|
|
38
|
+
setIsThemeCoreComplete(true);
|
|
39
|
+
const otherExistingLinks = document.head.querySelectorAll('link[data-theme-core="true"]');
|
|
40
|
+
removeExistingLinks(otherExistingLinks);
|
|
41
|
+
logError(`Failed to load core theme CSS from ${themeCore.url}. Aborting.`);
|
|
42
|
+
return;
|
|
43
|
+
};
|
|
44
|
+
document.head.insertAdjacentElement('beforeend', themeCoreLink);
|
|
45
|
+
}, [themeCore === null || themeCore === void 0 ? void 0 : themeCore.url, onComplete]);
|
|
46
|
+
};
|
|
47
|
+
export default useThemeCore;
|
|
48
|
+
//# sourceMappingURL=useThemeCore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThem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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 existingThemeCoreLink: HTMLLinkElement | null = document.head.querySelector('link[data-theme-core=\"true\"]');\n if (existingThemeCoreLink) {\n if (existingThemeCoreLink.getAttribute('href') === themeCore.url) {\n setIsThemeCoreComplete(true);\n return;\n }\n existingThemeCoreLink.remove();\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":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI5C;;;;;;;;GAQG;AACH,MAAM,gBAAgB,GAAG,CAAC,EACxB,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,gCAAgC,GAMjC,EAAE,EAAE;IACH,MAAM,CAAC,sBAAsB,EAAE,yBAAyB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE5E,6EAA6E;IAC7E,SAAS,CAAC,GAAG,EAAE;;QACb,MAAM,iBAAiB,GAAG,CAAC,gBAAgB,EAAE,EAAE;YAC7C,gCAAgC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAC7D,CAAC,CAAC;QACF,MAAM,gBAAgB,GAAG,MAAA,MAAM,CAAC,UAAU,uDAAG,8BAA8B,CAAC,CAAC;QAC7E,IAAI,gBAAgB,EAAE,CAAC;YACrB,g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AClC,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,aAAa,EAAE,mBAAmB,EAAE,UAAU,CAAC,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC","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"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Iterates through each given `<link>` element and removes it from the DOM.
|
|
3
|
+
* @param {HTMLLinkElement[]} existingLinks
|
|
4
|
+
*/
|
|
5
|
+
export const removeExistingLinks = (existingLinks) => {
|
|
6
|
+
existingLinks.forEach((link) => {
|
|
7
|
+
link.remove();
|
|
8
|
+
});
|
|
9
|
+
};
|
|
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"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { getActiveRoles } from '../../config';
|
|
3
|
+
import { ACTIVE_ROLES_CHANGED } from '../../constants';
|
|
4
|
+
import useSiteEvent from './useSiteEvent';
|
|
5
|
+
const useActiveRoles = () => {
|
|
6
|
+
const [roles, setRoles] = useState(getActiveRoles());
|
|
7
|
+
/* Stabilize the callback so useSiteEvent doesn't unsubscribe + resubscribe on every render.
|
|
8
|
+
Every Slot in the tree subscribes via this hook, so the churn would be tree-wide. */
|
|
9
|
+
const onChange = useCallback(() => {
|
|
10
|
+
setRoles(getActiveRoles());
|
|
11
|
+
}, []);
|
|
12
|
+
useSiteEvent(ACTIVE_ROLES_CHANGED, onChange);
|
|
13
|
+
return roles;
|
|
14
|
+
};
|
|
15
|
+
export default useActiveRoles;
|
|
16
|
+
//# 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,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,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;2FACuF;IACvF,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE;QAChC,QAAQ,CAAC,cAAc,EAAE,CAAC,CAAC;IAC7B,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,YAAY,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;IAE7C,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { useCallback, 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 /* Stabilize the callback so useSiteEvent doesn't unsubscribe + resubscribe on every render.\n Every Slot in the tree subscribes via this hook, so the churn would be tree-wide. */\n const onChange = useCallback(() => {\n setRoles(getActiveRoles());\n }, []);\n useSiteEvent(ACTIVE_ROLES_CHANGED, onChange);\n\n return roles;\n};\n\nexport default useActiveRoles;\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { 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
|
+
useEffect(() => {
|
|
8
|
+
const roles = [];
|
|
9
|
+
for (const match of matches) {
|
|
10
|
+
if (isRoleRouteObject(match)) {
|
|
11
|
+
for (const role of match.handle.roles) {
|
|
12
|
+
if (!roles.includes(role)) {
|
|
13
|
+
roles.push(role);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
setActiveRouteRoles(roles);
|
|
19
|
+
}, [matches]);
|
|
20
|
+
};
|
|
21
|
+
export default useActiveRouteRoleWatcher;
|
|
22
|
+
//# 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,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,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,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;oBACtC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;wBAC1B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBACnB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAChB,CAAC,CAAC;AAEF,eAAe,yBAAyB,CAAC","sourcesContent":["import { 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 useEffect(() => {\n const roles: string[] = [];\n for (const match of matches) {\n if (isRoleRouteObject(match)) {\n for (const role of match.handle.roles) {\n if (!roles.includes(role)) {\n roles.push(role);\n }\n }\n }\n }\n setActiveRouteRoles(roles);\n }, [matches]);\n};\n\nexport default useActiveRouteRoleWatcher;\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import CurrentAppContext from '../CurrentAppContext';
|
|
3
|
+
const useAppConfig = () => {
|
|
4
|
+
const { appConfig } = useContext(CurrentAppContext);
|
|
5
|
+
return appConfig;
|
|
6
|
+
};
|
|
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"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import SiteContext from '../SiteContext';
|
|
3
|
+
const useAuthenticatedUser = () => {
|
|
4
|
+
const { authenticatedUser } = useContext(SiteContext);
|
|
5
|
+
return authenticatedUser;
|
|
6
|
+
};
|
|
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"]}
|
|
@@ -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"]}
|