@webiny/app 6.0.0-beta.0 → 6.0.0-rc.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/App.d.ts +6 -13
- package/App.js +70 -83
- package/App.js.map +1 -1
- package/AppContainer.d.ts +23 -0
- package/AppContainer.js +9 -0
- package/AppContainer.js.map +1 -0
- package/README.md +7 -15
- package/apollo-client/InMemoryCache.d.ts +3 -2
- package/apollo-client/InMemoryCache.js +16 -48
- package/apollo-client/InMemoryCache.js.map +1 -1
- package/apollo-client/IntrospectionFragmentMatcher.d.ts +2 -2
- package/apollo-client/IntrospectionFragmentMatcher.js +33 -50
- package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -1
- package/components/Image.d.ts +1 -2
- package/components/Image.js +11 -19
- package/components/Image.js.map +1 -1
- package/components/index.d.ts +1 -2
- package/components/index.js +1 -19
- package/components/index.js.map +1 -1
- package/config/RouterConfig/Route.d.ts +29 -0
- package/config/RouterConfig/Route.js +33 -0
- package/config/RouterConfig/Route.js.map +1 -0
- package/config/RouterConfig.d.ts +31 -0
- package/config/RouterConfig.js +18 -0
- package/config/RouterConfig.js.map +1 -0
- package/config.d.ts +1 -1
- package/config.js +7 -13
- package/config.js.map +1 -1
- package/contexts/Ui/index.d.ts +2 -2
- package/contexts/Ui/index.js +28 -52
- package/contexts/Ui/index.js.map +1 -1
- package/core/DebounceRender.js +13 -24
- package/core/DebounceRender.js.map +1 -1
- package/core/Plugin.d.ts +1 -1
- package/core/Plugin.js +11 -19
- package/core/Plugin.js.map +1 -1
- package/core/Plugins.d.ts +1 -1
- package/core/Plugins.js +20 -25
- package/core/Plugins.js.map +1 -1
- package/core/Provider.d.ts +1 -1
- package/core/Provider.js +9 -13
- package/core/Provider.js.map +1 -1
- package/core/Routes.d.ts +2 -1
- package/core/Routes.js +13 -23
- package/core/Routes.js.map +1 -1
- package/core/createProvider.d.ts +7 -3
- package/core/createProvider.js +3 -9
- package/core/createProvider.js.map +1 -1
- package/core/createProviderPlugin.d.ts +1 -1
- package/core/createProviderPlugin.js +4 -10
- package/core/createProviderPlugin.js.map +1 -1
- package/errors/AuthenticationErrorEvent.d.ts +9 -0
- package/errors/AuthenticationErrorEvent.js +10 -0
- package/errors/AuthenticationErrorEvent.js.map +1 -0
- package/errors/NetworkErrorEvent.d.ts +15 -0
- package/errors/NetworkErrorEvent.js +10 -0
- package/errors/NetworkErrorEvent.js.map +1 -0
- package/errors/abstractions.d.ts +12 -0
- package/errors/abstractions.js +5 -0
- package/errors/abstractions.js.map +1 -0
- package/errors/index.d.ts +6 -0
- package/errors/index.js +6 -0
- package/errors/index.js.map +1 -0
- package/exports/admin/envConfig.d.ts +1 -0
- package/exports/admin/envConfig.js +3 -0
- package/exports/admin/envConfig.js.map +1 -0
- package/exports/admin/graphqlClient.d.ts +1 -0
- package/exports/admin/graphqlClient.js +3 -0
- package/exports/admin/graphqlClient.js.map +1 -0
- package/exports/admin/localStorage.d.ts +2 -0
- package/exports/admin/localStorage.js +4 -0
- package/exports/admin/localStorage.js.map +1 -0
- package/exports/admin/router.d.ts +4 -0
- package/exports/admin/router.js +6 -0
- package/exports/admin/router.js.map +1 -0
- package/exports/admin/security.d.ts +1 -0
- package/exports/admin/security.js +3 -0
- package/exports/admin/security.js.map +1 -0
- package/exports/admin.d.ts +6 -0
- package/exports/admin.js +8 -0
- package/exports/admin.js.map +1 -0
- package/features/envConfig/EnvConfig.d.ts +6 -0
- package/features/envConfig/EnvConfig.js +14 -0
- package/features/envConfig/EnvConfig.js.map +1 -0
- package/features/envConfig/abstractions.d.ts +27 -0
- package/features/envConfig/abstractions.js +4 -0
- package/features/envConfig/abstractions.js.map +1 -0
- package/features/envConfig/feature.d.ts +17 -0
- package/features/envConfig/feature.js +14 -0
- package/features/envConfig/feature.js.map +1 -0
- package/features/envConfig/index.d.ts +1 -0
- package/features/envConfig/index.js +3 -0
- package/features/envConfig/index.js.map +1 -0
- package/features/eventPublisher/EventPublisher.d.ts +8 -0
- package/features/eventPublisher/EventPublisher.js +27 -0
- package/features/eventPublisher/EventPublisher.js.map +1 -0
- package/features/eventPublisher/abstractions.d.ts +18 -0
- package/features/eventPublisher/abstractions.js +14 -0
- package/features/eventPublisher/abstractions.js.map +1 -0
- package/features/eventPublisher/feature.d.ts +1 -0
- package/features/eventPublisher/feature.js +11 -0
- package/features/eventPublisher/feature.js.map +1 -0
- package/features/eventPublisher/index.d.ts +3 -0
- package/features/eventPublisher/index.js +4 -0
- package/features/eventPublisher/index.js.map +1 -0
- package/features/graphqlClient/AuthenticationErrorPublishing.d.ts +13 -0
- package/features/graphqlClient/AuthenticationErrorPublishing.js +35 -0
- package/features/graphqlClient/AuthenticationErrorPublishing.js.map +1 -0
- package/features/graphqlClient/BatchingGraphQLClient.d.ts +18 -0
- package/features/graphqlClient/BatchingGraphQLClient.js +164 -0
- package/features/graphqlClient/BatchingGraphQLClient.js.map +1 -0
- package/features/graphqlClient/FetchGraphQLClient.d.ts +10 -0
- package/features/graphqlClient/FetchGraphQLClient.js +62 -0
- package/features/graphqlClient/FetchGraphQLClient.js.map +1 -0
- package/features/graphqlClient/NetworkErrorPublishing.d.ts +14 -0
- package/features/graphqlClient/NetworkErrorPublishing.js +55 -0
- package/features/graphqlClient/NetworkErrorPublishing.js.map +1 -0
- package/features/graphqlClient/RequestValue.d.ts +20 -0
- package/features/graphqlClient/RequestValue.js +42 -0
- package/features/graphqlClient/RequestValue.js.map +1 -0
- package/features/graphqlClient/RetryGraphQLClient.d.ts +18 -0
- package/features/graphqlClient/RetryGraphQLClient.js +54 -0
- package/features/graphqlClient/RetryGraphQLClient.js.map +1 -0
- package/features/graphqlClient/__tests__/GraphQLClient.test.d.ts +1 -0
- package/features/graphqlClient/__tests__/GraphQLClient.test.js +350 -0
- package/features/graphqlClient/__tests__/GraphQLClient.test.js.map +1 -0
- package/features/graphqlClient/abstractions.d.ts +17 -0
- package/features/graphqlClient/abstractions.js +4 -0
- package/features/graphqlClient/abstractions.js.map +1 -0
- package/features/graphqlClient/feature.d.ts +6 -0
- package/features/graphqlClient/feature.js +31 -0
- package/features/graphqlClient/feature.js.map +1 -0
- package/features/graphqlClient/index.d.ts +1 -0
- package/features/graphqlClient/index.js +3 -0
- package/features/graphqlClient/index.js.map +1 -0
- package/features/graphqlClient/types.d.ts +5 -0
- package/features/graphqlClient/types.js +3 -0
- package/features/graphqlClient/types.js.map +1 -0
- package/features/localStorage/BrowserLocalStorageGateway.d.ts +9 -0
- package/features/localStorage/BrowserLocalStorageGateway.js +68 -0
- package/features/localStorage/BrowserLocalStorageGateway.js.map +1 -0
- package/features/localStorage/LocalStorage.d.ts +12 -0
- package/features/localStorage/LocalStorage.js +31 -0
- package/features/localStorage/LocalStorage.js.map +1 -0
- package/features/localStorage/LocalStorageRepository.d.ts +20 -0
- package/features/localStorage/LocalStorageRepository.js +95 -0
- package/features/localStorage/LocalStorageRepository.js.map +1 -0
- package/features/localStorage/abstractions.d.ts +48 -0
- package/features/localStorage/abstractions.js +19 -0
- package/features/localStorage/abstractions.js.map +1 -0
- package/features/localStorage/feature.d.ts +12 -0
- package/features/localStorage/feature.js +34 -0
- package/features/localStorage/feature.js.map +1 -0
- package/features/localStorage/index.d.ts +1 -0
- package/features/localStorage/index.js +3 -0
- package/features/localStorage/index.js.map +1 -0
- package/features/router/HistoryRouterGateway.d.ts +18 -0
- package/features/router/HistoryRouterGateway.js +82 -0
- package/features/router/HistoryRouterGateway.js.map +1 -0
- package/features/router/HistoryRouterGateway.test.d.ts +1 -0
- package/features/router/HistoryRouterGateway.test.js +204 -0
- package/features/router/HistoryRouterGateway.test.js.map +1 -0
- package/features/router/Route.d.ts +19 -0
- package/features/router/Route.js +59 -0
- package/features/router/Route.js.map +1 -0
- package/features/router/RouteUrl.d.ts +85 -0
- package/features/router/RouteUrl.js +232 -0
- package/features/router/RouteUrl.js.map +1 -0
- package/features/router/Router.d.ts +45 -0
- package/features/router/Router.js +129 -0
- package/features/router/Router.js.map +1 -0
- package/features/router/RouterPresenter.d.ts +17 -0
- package/features/router/RouterPresenter.js +45 -0
- package/features/router/RouterPresenter.js.map +1 -0
- package/features/router/RouterRepository.d.ts +21 -0
- package/features/router/RouterRepository.js +71 -0
- package/features/router/RouterRepository.js.map +1 -0
- package/features/router/RouterRepository.test.d.ts +1 -0
- package/features/router/RouterRepository.test.js +154 -0
- package/features/router/RouterRepository.test.js.map +1 -0
- package/features/router/abstractions.d.ts +68 -0
- package/features/router/abstractions.js +15 -0
- package/features/router/abstractions.js.map +1 -0
- package/features/router/feature.d.ts +4 -0
- package/features/router/feature.js +18 -0
- package/features/router/feature.js.map +1 -0
- package/features/router/index.d.ts +1 -0
- package/features/router/index.js +3 -0
- package/features/router/index.js.map +1 -0
- package/helpers/InterfaceGenerator/date.d.ts +15 -0
- package/helpers/InterfaceGenerator/date.js +3 -0
- package/helpers/InterfaceGenerator/date.js.map +1 -0
- package/helpers/InterfaceGenerator/id.d.ts +23 -0
- package/helpers/InterfaceGenerator/id.js +3 -0
- package/helpers/InterfaceGenerator/id.js.map +1 -0
- package/helpers/InterfaceGenerator/identity.d.ts +10 -0
- package/helpers/InterfaceGenerator/identity.js +3 -0
- package/helpers/InterfaceGenerator/identity.js.map +1 -0
- package/helpers/InterfaceGenerator/index.d.ts +5 -0
- package/helpers/InterfaceGenerator/index.js +3 -0
- package/helpers/InterfaceGenerator/index.js.map +1 -0
- package/helpers/InterfaceGenerator/numeric.d.ts +12 -0
- package/helpers/InterfaceGenerator/numeric.js +3 -0
- package/helpers/InterfaceGenerator/numeric.js.map +1 -0
- package/helpers/InterfaceGenerator/truthful.d.ts +7 -0
- package/helpers/InterfaceGenerator/truthful.js +3 -0
- package/helpers/InterfaceGenerator/truthful.js.map +1 -0
- package/hooks/useAutocomplete/index.d.ts +1 -1
- package/hooks/useAutocomplete/index.js +1 -12
- package/hooks/useAutocomplete/index.js.map +1 -1
- package/hooks/useAutocomplete/useAutocomplete.d.ts +1 -1
- package/hooks/useAutocomplete/useAutocomplete.js +6 -16
- package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
- package/hooks/useDataList/functions/getData.js +2 -11
- package/hooks/useDataList/functions/getData.js.map +1 -1
- package/hooks/useDataList/functions/getError.js +2 -11
- package/hooks/useDataList/functions/getError.js.map +1 -1
- package/hooks/useDataList/functions/getMeta.js +2 -11
- package/hooks/useDataList/functions/getMeta.js.map +1 -1
- package/hooks/useDataList/functions/index.d.ts +3 -3
- package/hooks/useDataList/functions/index.js +3 -27
- package/hooks/useDataList/functions/index.js.map +1 -1
- package/hooks/useDataList/functions/searchDataByKey.js +4 -10
- package/hooks/useDataList/functions/searchDataByKey.js.map +1 -1
- package/hooks/useDataList/index.d.ts +1 -1
- package/hooks/useDataList/index.js +1 -12
- package/hooks/useDataList/index.js.map +1 -1
- package/hooks/useDataList/useDataList.d.ts +2 -3
- package/hooks/useDataList/useDataList.js +74 -94
- package/hooks/useDataList/useDataList.js.map +1 -1
- package/hooks/useDataList/utils/index.d.ts +1 -2
- package/hooks/useDataList/utils/index.js +1 -20
- package/hooks/useDataList/utils/index.js.map +1 -1
- package/hooks/useDataList/utils/prepareLoadListParams.js +10 -16
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
- package/hooks/useHandler.js +7 -12
- package/hooks/useHandler.js.map +1 -1
- package/hooks/useHandlers.d.ts +3 -3
- package/hooks/useHandlers.js +11 -17
- package/hooks/useHandlers.js.map +1 -1
- package/hooks/useRegisterLegacyPlugin.d.ts +2 -0
- package/hooks/useRegisterLegacyPlugin.js +11 -0
- package/hooks/useRegisterLegacyPlugin.js.map +1 -0
- package/hooks/useUi.d.ts +1 -1
- package/hooks/useUi.js +4 -10
- package/hooks/useUi.js.map +1 -1
- package/i18n/i18n.js +5 -13
- package/i18n/i18n.js.map +1 -1
- package/i18n/index.d.ts +1 -1
- package/i18n/index.js +1 -13
- package/i18n/index.js.map +1 -1
- package/index.d.ts +23 -14
- package/index.js +25 -165
- package/index.js.map +1 -1
- package/package.json +26 -29
- package/plugins/AddQuerySelectionPlugin.d.ts +2 -2
- package/plugins/AddQuerySelectionPlugin.js +61 -107
- package/plugins/AddQuerySelectionPlugin.js.map +1 -1
- package/plugins/ApolloCacheObjectIdPlugin.js +12 -31
- package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -1
- package/plugins/ApolloDynamicLink.d.ts +3 -2
- package/plugins/ApolloDynamicLink.js +19 -46
- package/plugins/ApolloDynamicLink.js.map +1 -1
- package/plugins/ApolloLinkPlugin.d.ts +1 -1
- package/plugins/ApolloLinkPlugin.js +18 -37
- package/plugins/ApolloLinkPlugin.js.map +1 -1
- package/plugins/ConsoleLinkPlugin.d.ts +1 -1
- package/plugins/ConsoleLinkPlugin.js +20 -41
- package/plugins/ConsoleLinkPlugin.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts +8 -13
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +35 -58
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.d.ts +14 -0
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js +31 -0
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.d.ts +2 -0
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js +31 -0
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +4 -5
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +68 -12
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/Typography.d.ts +8 -0
- package/plugins/NetworkErrorLinkPlugin/Typography.js +18 -0
- package/plugins/NetworkErrorLinkPlugin/Typography.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.d.ts +3 -3
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +10 -20
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin.d.ts +4 -1
- package/plugins/NetworkErrorLinkPlugin.js +60 -37
- package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
- package/plugins/OmitTypenameLinkPlugin.d.ts +1 -1
- package/plugins/OmitTypenameLinkPlugin.js +11 -30
- package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
- package/plugins/TenantHeaderLinkPlugin.d.ts +3 -3
- package/plugins/TenantHeaderLinkPlugin.js +29 -48
- package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
- package/plugins/components/Image.d.ts +6 -0
- package/plugins/components/Image.js +19 -0
- package/plugins/components/Image.js.map +1 -0
- package/plugins/image.d.ts +1 -1
- package/plugins/image.js +46 -53
- package/plugins/image.js.map +1 -1
- package/plugins/index.d.ts +5 -5
- package/plugins/index.js +31 -53
- package/plugins/index.js.map +1 -1
- package/presentation/localStorage/index.d.ts +3 -0
- package/presentation/localStorage/index.js +5 -0
- package/presentation/localStorage/index.js.map +1 -0
- package/presentation/localStorage/useLocalStorage.d.ts +6 -0
- package/presentation/localStorage/useLocalStorage.js +21 -0
- package/presentation/localStorage/useLocalStorage.js.map +1 -0
- package/presentation/localStorage/useLocalStorageValue.d.ts +1 -0
- package/presentation/localStorage/useLocalStorageValue.js +20 -0
- package/presentation/localStorage/useLocalStorageValue.js.map +1 -0
- package/presentation/localStorage/useLocalStorageValues.d.ts +5 -0
- package/presentation/localStorage/useLocalStorageValues.js +39 -0
- package/presentation/localStorage/useLocalStorageValues.js.map +1 -0
- package/presentation/router/RouteElementRegistry.d.ts +14 -0
- package/presentation/router/RouteElementRegistry.js +32 -0
- package/presentation/router/RouteElementRegistry.js.map +1 -0
- package/presentation/router/abstractions.d.ts +13 -0
- package/presentation/router/abstractions.js +4 -0
- package/presentation/router/abstractions.js.map +1 -0
- package/presentation/router/components/RouteContent.d.ts +2 -0
- package/presentation/router/components/RouteContent.js +17 -0
- package/presentation/router/components/RouteContent.js.map +1 -0
- package/presentation/router/components/RouteLink.d.ts +50 -0
- package/presentation/router/components/RouteLink.js +22 -0
- package/presentation/router/components/RouteLink.js.map +1 -0
- package/presentation/router/components/SimpleLink.d.ts +44 -0
- package/presentation/router/components/SimpleLink.js +30 -0
- package/presentation/router/components/SimpleLink.js.map +1 -0
- package/presentation/router/hooks/useRoute.d.ts +6 -0
- package/presentation/router/hooks/useRoute.js +30 -0
- package/presentation/router/hooks/useRoute.js.map +1 -0
- package/presentation/router/hooks/useRouter.d.ts +7 -0
- package/presentation/router/hooks/useRouter.js +26 -0
- package/presentation/router/hooks/useRouter.js.map +1 -0
- package/presentation/router/index.d.ts +4 -0
- package/presentation/router/index.js +5 -0
- package/presentation/router/index.js.map +1 -0
- package/presentation/router/types.d.ts +5 -0
- package/presentation/router/types.js +3 -0
- package/presentation/router/types.js.map +1 -0
- package/react-butterfiles/Files.d.ts +69 -0
- package/react-butterfiles/Files.js +227 -0
- package/react-butterfiles/Files.js.map +1 -0
- package/react-butterfiles/file.todo +1 -0
- package/react-butterfiles/index.d.ts +2 -0
- package/react-butterfiles/index.js +4 -0
- package/react-butterfiles/index.js.map +1 -0
- package/react-butterfiles/utils/generateId.d.ts +1 -0
- package/react-butterfiles/utils/generateId.js +5 -0
- package/react-butterfiles/utils/generateId.js.map +1 -0
- package/react-butterfiles/utils/readFileContent.d.ts +1 -0
- package/react-butterfiles/utils/readFileContent.js +15 -0
- package/react-butterfiles/utils/readFileContent.js.map +1 -0
- package/renderApp.d.ts +1 -1
- package/renderApp.js +4 -11
- package/renderApp.js.map +1 -1
- package/router.d.ts +5 -0
- package/router.js +8 -0
- package/router.js.map +1 -0
- package/shared/di/DiContainerProvider.d.ts +8 -0
- package/shared/di/DiContainerProvider.js +17 -0
- package/shared/di/DiContainerProvider.js.map +1 -0
- package/shared/di/createFeature.d.ts +11 -0
- package/shared/di/createFeature.js +11 -0
- package/shared/di/createFeature.js.map +1 -0
- package/shared/di/useFeature.d.ts +2 -0
- package/shared/di/useFeature.js +18 -0
- package/shared/di/useFeature.js.map +1 -0
- package/types.d.ts +16 -13
- package/types.js +1 -12
- package/types.js.map +1 -1
- package/utils/createGenericContext.d.ts +13 -0
- package/utils/createGenericContext.js +25 -0
- package/utils/createGenericContext.js.map +1 -0
- package/utils/createHashing.d.ts +2 -0
- package/utils/createHashing.js +18 -0
- package/utils/createHashing.js.map +1 -0
- package/utils/index.d.ts +2 -8
- package/utils/index.js +2 -93
- package/utils/index.js.map +1 -1
- package/utils/legacyPluginToReactComponent.d.ts +7 -0
- package/utils/legacyPluginToReactComponent.js +14 -0
- package/utils/legacyPluginToReactComponent.js.map +1 -0
- package/components/Routes.d.ts +0 -2
- package/components/Routes.js +0 -46
- package/components/Routes.js.map +0 -1
- package/components/View.d.ts +0 -8
- package/components/View.js +0 -31
- package/components/View.js.map +0 -1
- package/core/AddRoute.d.ts +0 -17
- package/core/AddRoute.js +0 -21
- package/core/AddRoute.js.map +0 -1
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.d.ts +0 -14
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +0 -30
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +0 -1
- package/hooks/useDataList/utils/types.d.ts +0 -40
- package/hooks/useDataList/utils/types.js +0 -7
- package/hooks/useDataList/utils/types.js.map +0 -1
- package/plugins/LocaleHeaderLinkPlugin.d.ts +0 -10
- package/plugins/LocaleHeaderLinkPlugin.js +0 -49
- package/plugins/LocaleHeaderLinkPlugin.js.map +0 -1
- package/plugins/RoutePlugin.d.ts +0 -12
- package/plugins/RoutePlugin.js +0 -35
- package/plugins/RoutePlugin.js.map +0 -1
- package/plugins/ViewPlugin.d.ts +0 -14
- package/plugins/ViewPlugin.js +0 -40
- package/plugins/ViewPlugin.js.map +0 -1
- package/utils/getApiUrl.d.ts +0 -1
- package/utils/getApiUrl.js +0 -12
- package/utils/getApiUrl.js.map +0 -1
- package/utils/getGqlApiUrl.d.ts +0 -1
- package/utils/getGqlApiUrl.js +0 -12
- package/utils/getGqlApiUrl.js.map +0 -1
- package/utils/getHeadlessCmsGqlApiUrl.d.ts +0 -5
- package/utils/getHeadlessCmsGqlApiUrl.js +0 -18
- package/utils/getHeadlessCmsGqlApiUrl.js.map +0 -1
- package/utils/getLocaleCode.d.ts +0 -6
- package/utils/getLocaleCode.js +0 -43
- package/utils/getLocaleCode.js.map +0 -1
- package/utils/getPrerenderId.d.ts +0 -6
- package/utils/getPrerenderId.js +0 -11
- package/utils/getPrerenderId.js.map +0 -1
- package/utils/getTenantId.d.ts +0 -6
- package/utils/getTenantId.js +0 -35
- package/utils/getTenantId.js.map +0 -1
- package/utils/isLocalhost.d.ts +0 -1
- package/utils/isLocalhost.js +0 -15
- package/utils/isLocalhost.js.map +0 -1
- package/utils/isPrerendering.d.ts +0 -1
- package/utils/isPrerendering.js +0 -11
- package/utils/isPrerendering.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["BrowserLocalStorageGateway","get","key","value","window","localStorage","getItem","JSON","parse","set","serialized","stringify","setItem","dispatchEvent","CustomEvent","detail","action","remove","removeItem","clear","getAll","result","i","length","val","subscribe","listener","handler","ev","StorageEvent","addEventListener","removeEventListener"],"sources":["BrowserLocalStorageGateway.ts"],"sourcesContent":["import { ILocalStorageGateway } from \"./abstractions.js\";\n\nexport class BrowserLocalStorageGateway implements ILocalStorageGateway {\n get<T = string>(key: string): T | null {\n const value = window.localStorage.getItem(key);\n try {\n return value ? (JSON.parse(value) as T) : null;\n } catch {\n return value as unknown as T;\n }\n }\n\n set<T = string>(key: string, value: T): void {\n const serialized = typeof value === \"string\" ? value : JSON.stringify(value);\n window.localStorage.setItem(key, serialized);\n\n // Dispatch local event so same-tab listeners are notified.\n window.dispatchEvent(\n new CustomEvent(\"localstorage:changed\", {\n detail: { key, value, action: \"set\" }\n })\n );\n }\n\n remove(key: string): void {\n window.localStorage.removeItem(key);\n window.dispatchEvent(\n new CustomEvent(\"localstorage:changed\", {\n detail: { key, action: \"remove\" }\n })\n );\n }\n\n clear(): void {\n window.localStorage.clear();\n window.dispatchEvent(\n new CustomEvent(\"localstorage:changed\", {\n detail: { action: \"clear\" }\n })\n );\n }\n\n getAll(): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (let i = 0; i < window.localStorage.length; i++) {\n const key = window.localStorage.key(i)!;\n const val = this.get(key);\n if (val !== null) {\n result[key] = val;\n }\n }\n return result;\n }\n\n // Subscribe to changes (cross-tab + same-tab)\n subscribe(listener: (event: StorageEvent | CustomEvent) => void): () => void {\n const handler = (ev: Event) => {\n if (ev instanceof StorageEvent || ev instanceof CustomEvent) {\n listener(ev);\n }\n };\n window.addEventListener(\"storage\", handler);\n window.addEventListener(\"localstorage:changed\", handler as any);\n\n return () => {\n window.removeEventListener(\"storage\", handler);\n window.removeEventListener(\"localstorage:changed\", handler as any);\n };\n }\n}\n"],"mappings":"AAEA,OAAO,MAAMA,0BAA0B,CAAiC;EACpEC,GAAGA,CAAaC,GAAW,EAAY;IACnC,MAAMC,KAAK,GAAGC,MAAM,CAACC,YAAY,CAACC,OAAO,CAACJ,GAAG,CAAC;IAC9C,IAAI;MACA,OAAOC,KAAK,GAAII,IAAI,CAACC,KAAK,CAACL,KAAK,CAAC,GAAS,IAAI;IAClD,CAAC,CAAC,MAAM;MACJ,OAAOA,KAAK;IAChB;EACJ;EAEAM,GAAGA,CAAaP,GAAW,EAAEC,KAAQ,EAAQ;IACzC,MAAMO,UAAU,GAAG,OAAOP,KAAK,KAAK,QAAQ,GAAGA,KAAK,GAAGI,IAAI,CAACI,SAAS,CAACR,KAAK,CAAC;IAC5EC,MAAM,CAACC,YAAY,CAACO,OAAO,CAACV,GAAG,EAAEQ,UAAU,CAAC;;IAE5C;IACAN,MAAM,CAACS,aAAa,CAChB,IAAIC,WAAW,CA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AAgB,CAAC,SAAS,EAAEH,OAAO,CAAC;IAC3CvB,MAAM,CAAC0B,gBAAgB,CAAC,sBAAsB,EAAEH,OAAc,CAAC;IAE/D,OAAO,MAAM;MACTvB,MAAM,CAAC2B,mBAAmB,CAAC,SAAS,EAAEJ,OAAO,CAAC;MAC9CvB,MAAM,CAAC2B,mBAAmB,CAAC,sBAAsB,EAAEJ,OAAc,CAAC;IACtE,CAAC;EACL;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LocalStorage as LocalStorageAbstraction, LocalStorageRepository } from "./abstractions.js";
|
|
2
|
+
declare class LocalStorageImpl implements LocalStorageAbstraction.Interface {
|
|
3
|
+
private readonly repo;
|
|
4
|
+
constructor(repo: LocalStorageRepository.Interface);
|
|
5
|
+
get<T = string>(key: string): T | undefined;
|
|
6
|
+
set<T = string>(key: string, value: T): void;
|
|
7
|
+
remove(key: string): void;
|
|
8
|
+
clear(): void;
|
|
9
|
+
keys(): string[];
|
|
10
|
+
}
|
|
11
|
+
export declare const LocalStorage: import("@webiny/di").Implementation<typeof LocalStorageImpl>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { makeAutoObservable } from "mobx";
|
|
2
|
+
import { LocalStorage as LocalStorageAbstraction, LocalStorageRepository } from "./abstractions.js";
|
|
3
|
+
import { createImplementation } from "@webiny/di";
|
|
4
|
+
class LocalStorageImpl {
|
|
5
|
+
constructor(repo) {
|
|
6
|
+
this.repo = repo;
|
|
7
|
+
makeAutoObservable(this);
|
|
8
|
+
}
|
|
9
|
+
get(key) {
|
|
10
|
+
return this.repo.get(key);
|
|
11
|
+
}
|
|
12
|
+
set(key, value) {
|
|
13
|
+
this.repo.set(key, value);
|
|
14
|
+
}
|
|
15
|
+
remove(key) {
|
|
16
|
+
this.repo.remove(key);
|
|
17
|
+
}
|
|
18
|
+
clear() {
|
|
19
|
+
this.repo.clear();
|
|
20
|
+
}
|
|
21
|
+
keys() {
|
|
22
|
+
return this.repo.keys();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export const LocalStorage = createImplementation({
|
|
26
|
+
abstraction: LocalStorageAbstraction,
|
|
27
|
+
implementation: LocalStorageImpl,
|
|
28
|
+
dependencies: [LocalStorageRepository]
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=LocalStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["makeAutoObservable","LocalStorage","LocalStorageAbstraction","LocalStorageRepository","createImplementation","LocalStorageImpl","constructor","repo","get","key","set","value","remove","clear","keys","abstraction","implementation","dependencies"],"sources":["LocalStorage.ts"],"sourcesContent":["import { makeAutoObservable } from \"mobx\";\nimport { LocalStorage as LocalStorageAbstraction, LocalStorageRepository } from \"./abstractions.js\";\nimport { createImplementation } from \"@webiny/di\";\n\nclass LocalStorageImpl implements LocalStorageAbstraction.Interface {\n constructor(private readonly repo: LocalStorageRepository.Interface) {\n makeAutoObservable(this);\n }\n\n get<T = string>(key: string) {\n return this.repo.get<T>(key);\n }\n set<T = string>(key: string, value: T) {\n this.repo.set(key, value);\n }\n remove(key: string) {\n this.repo.remove(key);\n }\n clear() {\n this.repo.clear();\n }\n keys() {\n return this.repo.keys();\n }\n}\n\nexport const LocalStorage = createImplementation({\n abstraction: LocalStorageAbstraction,\n implementation: LocalStorageImpl,\n dependencies: [LocalStorageRepository]\n});\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,MAAM;AACzC,SAASC,YAAY,IAAIC,uBAAuB,EAAEC,sBAAsB;AACxE,SAASC,oBAAoB,QAAQ,YAAY;AAEjD,MAAMC,gBAAgB,CAA8C;EAChEC,WAAWA,CAAkBC,IAAsC,EAAE;IAAA,KAAxCA,IAAsC,GAAtCA,IAAsC;IAC/DP,kBAAkB,CAAC,IAAI,CAAC;EAC5B;EAEAQ,GAAGA,CAAaC,GAAW,EAAE;IACzB,OAAO,IAAI,CAACF,IAAI,CAACC,GAAG,CAAIC,GAAG,CAAC;EAChC;EACAC,GAAGA,CAAaD,GAAW,EAAEE,KAAQ,EAAE;IACnC,IAAI,CAACJ,IAAI,CAACG,GAAG,CAACD,GAAG,EAAEE,KAAK,CAAC;EAC7B;EACAC,MAAMA,CAACH,GAAW,EAAE;IAChB,IAAI,CAACF,IAAI,CAACK,MAAM,CAACH,GAAG,CAAC;EACzB;EACAI,KAAKA,CAAA,EAAG;IACJ,IAAI,CAACN,IAAI,CAACM,KAAK,CAAC,CAAC;EACrB;EACAC,IAAIA,CAAA,EAAG;IACH,OAAO,IAAI,CAACP,IAAI,CAACO,IAAI,CAAC,CAAC;EAC3B;AACJ;AAEA,OAAO,MAAMb,YAAY,GAAGG,oBAAoB,CAAC;EAC7CW,WAAW,EAAEb,uBAAuB;EACpCc,cAAc,EAAEX,gBAAgB;EAChCY,YAAY,EAAE,CAACd,sBAAsB;AACzC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LocalStorageRepository as LocalStorageRepositoryAbstraction, LocalStorageConfig, LocalStorageGateway } from "./abstractions.js";
|
|
2
|
+
export declare class LocalStorageRepositoryImpl implements LocalStorageRepositoryAbstraction.Interface {
|
|
3
|
+
private gateway;
|
|
4
|
+
private readonly prefix;
|
|
5
|
+
private store;
|
|
6
|
+
private unsubscribe?;
|
|
7
|
+
constructor(gateway: LocalStorageGateway.Interface, config: LocalStorageConfig.Interface);
|
|
8
|
+
private withPrefix;
|
|
9
|
+
private stripPrefix;
|
|
10
|
+
private bootstrap;
|
|
11
|
+
private subscribeToChanges;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
has(key: string): boolean;
|
|
14
|
+
get<T = string>(key: string): T | undefined;
|
|
15
|
+
set<T = string>(key: string, value: T): void;
|
|
16
|
+
remove(key: string): void;
|
|
17
|
+
clear(): void;
|
|
18
|
+
keys(): string[];
|
|
19
|
+
}
|
|
20
|
+
export declare const LocalStorageRepository: import("@webiny/di").Implementation<typeof LocalStorageRepositoryImpl>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { makeAutoObservable, runInAction } from "mobx";
|
|
2
|
+
import { LocalStorageRepository as LocalStorageRepositoryAbstraction, LocalStorageConfig, LocalStorageGateway } from "./abstractions.js";
|
|
3
|
+
import { createImplementation } from "@webiny/di";
|
|
4
|
+
export class LocalStorageRepositoryImpl {
|
|
5
|
+
store = new Map();
|
|
6
|
+
constructor(gateway, config) {
|
|
7
|
+
this.gateway = gateway;
|
|
8
|
+
this.prefix = config.prefix || "";
|
|
9
|
+
makeAutoObservable(this);
|
|
10
|
+
this.bootstrap();
|
|
11
|
+
this.subscribeToChanges();
|
|
12
|
+
}
|
|
13
|
+
withPrefix(key) {
|
|
14
|
+
return this.prefix ? `${this.prefix}:${key}` : key;
|
|
15
|
+
}
|
|
16
|
+
stripPrefix(key) {
|
|
17
|
+
return this.prefix ? key.replace(new RegExp(`^${this.prefix}:`), "") : key;
|
|
18
|
+
}
|
|
19
|
+
bootstrap() {
|
|
20
|
+
const all = this.gateway.getAll();
|
|
21
|
+
for (const [key, value] of Object.entries(all)) {
|
|
22
|
+
if (!this.prefix || key.startsWith(this.prefix + ":")) {
|
|
23
|
+
this.store.set(this.stripPrefix(key), value);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
subscribeToChanges() {
|
|
28
|
+
this.unsubscribe = this.gateway.subscribe(ev => {
|
|
29
|
+
runInAction(() => {
|
|
30
|
+
if (ev instanceof StorageEvent && ev.key) {
|
|
31
|
+
if (!this.prefix || ev.key.startsWith(this.prefix + ":")) {
|
|
32
|
+
const cleanKey = this.stripPrefix(ev.key);
|
|
33
|
+
if (ev.newValue !== null) {
|
|
34
|
+
try {
|
|
35
|
+
this.store.set(cleanKey, JSON.parse(ev.newValue));
|
|
36
|
+
} catch {
|
|
37
|
+
this.store.set(cleanKey, ev.newValue);
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
this.store.delete(cleanKey);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (ev instanceof CustomEvent) {
|
|
45
|
+
const {
|
|
46
|
+
key,
|
|
47
|
+
value,
|
|
48
|
+
action
|
|
49
|
+
} = ev.detail;
|
|
50
|
+
if (!this.prefix || key.startsWith(this.prefix + ":")) {
|
|
51
|
+
const cleanKey = this.stripPrefix(key);
|
|
52
|
+
if (action === "set") {
|
|
53
|
+
this.store.set(cleanKey, value);
|
|
54
|
+
}
|
|
55
|
+
if (action === "remove") {
|
|
56
|
+
this.store.delete(cleanKey);
|
|
57
|
+
}
|
|
58
|
+
if (action === "clear") {
|
|
59
|
+
this.store.clear();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
destroy() {
|
|
67
|
+
this.unsubscribe?.();
|
|
68
|
+
}
|
|
69
|
+
has(key) {
|
|
70
|
+
return this.store.has(key);
|
|
71
|
+
}
|
|
72
|
+
get(key) {
|
|
73
|
+
return this.store.get(key);
|
|
74
|
+
}
|
|
75
|
+
set(key, value) {
|
|
76
|
+
this.gateway.set(this.withPrefix(key), value);
|
|
77
|
+
}
|
|
78
|
+
remove(key) {
|
|
79
|
+
this.gateway.remove(this.withPrefix(key));
|
|
80
|
+
}
|
|
81
|
+
clear() {
|
|
82
|
+
this.gateway.clear();
|
|
83
|
+
this.store.clear();
|
|
84
|
+
}
|
|
85
|
+
keys() {
|
|
86
|
+
return Array.from(this.store.keys());
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export const LocalStorageRepository = createImplementation({
|
|
90
|
+
abstraction: LocalStorageRepositoryAbstraction,
|
|
91
|
+
implementation: LocalStorageRepositoryImpl,
|
|
92
|
+
dependencies: [LocalStorageGateway, LocalStorageConfig]
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
//# sourceMappingURL=LocalStorageRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["makeAutoObservable","runInAction","LocalStorageRepository","LocalStorageRepositoryAbstraction","LocalStorageConfig","LocalStorageGateway","createImplementation","LocalStorageRepositoryImpl","store","Map","constructor","gateway","config","prefix","bootstrap","subscribeToChanges","withPrefix","key","stripPrefix","replace","RegExp","all","getAll","value","Object","entries","startsWith","set","unsubscribe","subscribe","ev","StorageEvent","cleanKey","newValue","JSON","parse","delete","CustomEvent","action","detail","clear","destroy","has","get","remove","keys","Array","from","abstraction","implementation","dependencies"],"sources":["LocalStorageRepository.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from \"mobx\";\nimport {\n LocalStorageRepository as LocalStorageRepositoryAbstraction,\n LocalStorageConfig,\n LocalStorageGateway\n} from \"./abstractions.js\";\nimport { createImplementation } from \"@webiny/di\";\n\nexport class LocalStorageRepositoryImpl implements LocalStorageRepositoryAbstraction.Interface {\n private readonly prefix: string;\n private store = new Map<string, unknown>();\n private unsubscribe?: () => void;\n\n constructor(\n private gateway: LocalStorageGateway.Interface,\n config: LocalStorageConfig.Interface\n ) {\n this.prefix = config.prefix || \"\";\n makeAutoObservable(this);\n\n this.bootstrap();\n this.subscribeToChanges();\n }\n\n private withPrefix(key: string): string {\n return this.prefix ? `${this.prefix}:${key}` : key;\n }\n\n private stripPrefix(key: string): string {\n return this.prefix ? key.replace(new RegExp(`^${this.prefix}:`), \"\") : key;\n }\n\n private bootstrap() {\n const all = this.gateway.getAll();\n for (const [key, value] of Object.entries(all)) {\n if (!this.prefix || key.startsWith(this.prefix + \":\")) {\n this.store.set(this.stripPrefix(key), value);\n }\n }\n }\n\n private subscribeToChanges() {\n this.unsubscribe = this.gateway.subscribe(ev => {\n runInAction(() => {\n if (ev instanceof StorageEvent && ev.key) {\n if (!this.prefix || ev.key.startsWith(this.prefix + \":\")) {\n const cleanKey = this.stripPrefix(ev.key);\n if (ev.newValue !== null) {\n try {\n this.store.set(cleanKey, JSON.parse(ev.newValue));\n } catch {\n this.store.set(cleanKey, ev.newValue);\n }\n } else {\n this.store.delete(cleanKey);\n }\n }\n }\n if (ev instanceof CustomEvent) {\n const { key, value, action } = ev.detail;\n if (!this.prefix || key.startsWith(this.prefix + \":\")) {\n const cleanKey = this.stripPrefix(key);\n if (action === \"set\") {\n this.store.set(cleanKey, value);\n }\n if (action === \"remove\") {\n this.store.delete(cleanKey);\n }\n if (action === \"clear\") {\n this.store.clear();\n }\n }\n }\n });\n });\n }\n\n destroy() {\n this.unsubscribe?.();\n }\n\n has(key: string) {\n return this.store.has(key);\n }\n get<T = string>(key: string) {\n return this.store.get(key) as T | undefined;\n }\n set<T = string>(key: string, value: T) {\n this.gateway.set(this.withPrefix(key), value);\n }\n remove(key: string) {\n this.gateway.remove(this.withPrefix(key));\n }\n clear() {\n this.gateway.clear();\n this.store.clear();\n }\n keys(): string[] {\n return Array.from(this.store.keys());\n }\n}\n\nexport const LocalStorageRepository = createImplementation({\n abstraction: LocalStorageRepositoryAbstraction,\n implementation: LocalStorageRepositoryImpl,\n dependencies: [LocalStorageGateway, LocalStorageConfig]\n});\n"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,WAAW,QAAQ,MAAM;AACtD,SACIC,sBAAsB,IAAIC,iCAAiC,EAC3DC,kBAAkB,EAClBC,mBAAmB;AAEvB,SAASC,oBAAoB,QAAQ,YAAY;AAEjD,OAAO,MAAMC,0BAA0B,CAAwD;EAEnFC,KAAK,GAAG,IAAIC,GAAG,CAAkB,CAAC;EAG1CC,WAAWA,CACCC,OAAsC,EAC9CC,MAAoC,EACtC;IAAA,KAFUD,OAAsC,GAAtCA,OAAsC;IAG9C,IAAI,CAACE,MAAM,GAAGD,MAAM,CAACC,MAAM,IAAI,EAAE;IACjCb,kBAAkB,CAAC,IAAI,CAAC;IAExB,IAAI,CAACc,SAAS,CAAC,CAAC;IAChB,IAAI,CAACC,kBAAkB,CAAC,CAAC;EAC7B;EAEQC,UAAUA,CAACC,GAAW,EAAU;IACpC,OAAO,IAA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;IACnC,IAAI,CAACZ,OAAO,CAACgB,GAAG,CAAC,IAAI,CAACX,UAAU,CAACC,GAAG,CAAC,EAAEM,KAAK,CAAC;EACjD;EACAqB,MAAMA,CAAC3B,GAAW,EAAE;IAChB,IAAI,CAACN,OAAO,CAACiC,MAAM,CAAC,IAAI,CAAC5B,UAAU,CAACC,GAAG,CAAC,CAAC;EAC7C;EACAuB,KAAKA,CAAA,EAAG;IACJ,IAAI,CAAC7B,OAAO,CAAC6B,KAAK,CAAC,CAAC;IACpB,IAAI,CAAChC,KAAK,CAACgC,KAAK,CAAC,CAAC;EACtB;EACAK,IAAIA,CAAA,EAAa;IACb,OAAOC,KAAK,CAACC,IAAI,CAAC,IAAI,CAACvC,KAAK,CAACqC,IAAI,CAAC,CAAC,CAAC;EACxC;AACJ;AAEA,OAAO,MAAM3C,sBAAsB,GAAGI,oBAAoB,CAAC;EACvD0C,WAAW,EAAE7C,iCAAiC;EAC9C8C,cAAc,EAAE1C,0BAA0B;EAC1C2C,YAAY,EAAE,CAAC7C,mBAAmB,EAAED,kBAAkB;AAC1D,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Abstraction } from "@webiny/di";
|
|
2
|
+
/** Gateway: raw IO into localStorage (or other storage). */
|
|
3
|
+
export interface ILocalStorageGateway {
|
|
4
|
+
get<T = string>(key: string): T | null;
|
|
5
|
+
set<T = string>(key: string, value: T): void;
|
|
6
|
+
remove(key: string): void;
|
|
7
|
+
clear(): void;
|
|
8
|
+
getAll(): Record<string, unknown>;
|
|
9
|
+
subscribe(listener: (event: StorageEvent | CustomEvent) => void): () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const LocalStorageGateway: Abstraction<ILocalStorageGateway>;
|
|
12
|
+
export declare namespace LocalStorageGateway {
|
|
13
|
+
type Interface = ILocalStorageGateway;
|
|
14
|
+
}
|
|
15
|
+
/** Repository: reactive state (MobX), synchronized with gateway. */
|
|
16
|
+
export interface ILocalStorageRepository {
|
|
17
|
+
has(key: string): boolean;
|
|
18
|
+
get<T = string>(key: string): T | undefined;
|
|
19
|
+
set<T = string>(key: string, value: T): void;
|
|
20
|
+
remove(key: string): void;
|
|
21
|
+
clear(): void;
|
|
22
|
+
keys(): string[];
|
|
23
|
+
destroy(): void;
|
|
24
|
+
}
|
|
25
|
+
export declare const LocalStorageRepository: Abstraction<ILocalStorageRepository>;
|
|
26
|
+
export declare namespace LocalStorageRepository {
|
|
27
|
+
type Interface = ILocalStorageRepository;
|
|
28
|
+
}
|
|
29
|
+
/** Config: configure key prefixes, etc. */
|
|
30
|
+
export interface ILocalStorageConfig {
|
|
31
|
+
prefix?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare const LocalStorageConfig: Abstraction<ILocalStorageConfig>;
|
|
34
|
+
export declare namespace LocalStorageConfig {
|
|
35
|
+
type Interface = ILocalStorageConfig;
|
|
36
|
+
}
|
|
37
|
+
/** Service: thin façade, delegates to repository for consumers. */
|
|
38
|
+
export interface ILocalStorage {
|
|
39
|
+
get<T = string>(key: string): T | undefined;
|
|
40
|
+
set<T = string>(key: string, value: T): void;
|
|
41
|
+
remove(key: string): void;
|
|
42
|
+
clear(): void;
|
|
43
|
+
keys(): string[];
|
|
44
|
+
}
|
|
45
|
+
export declare const LocalStorage: Abstraction<ILocalStorage>;
|
|
46
|
+
export declare namespace LocalStorage {
|
|
47
|
+
type Interface = ILocalStorage;
|
|
48
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Abstraction } from "@webiny/di";
|
|
2
|
+
|
|
3
|
+
/** Gateway: raw IO into localStorage (or other storage). */
|
|
4
|
+
|
|
5
|
+
export const LocalStorageGateway = new Abstraction("LocalStorageGateway");
|
|
6
|
+
|
|
7
|
+
/** Repository: reactive state (MobX), synchronized with gateway. */
|
|
8
|
+
|
|
9
|
+
export const LocalStorageRepository = new Abstraction("LocalStorageRepository");
|
|
10
|
+
|
|
11
|
+
/** Config: configure key prefixes, etc. */
|
|
12
|
+
|
|
13
|
+
export const LocalStorageConfig = new Abstraction("LocalStorageConfig");
|
|
14
|
+
|
|
15
|
+
/** Service: thin façade, delegates to repository for consumers. */
|
|
16
|
+
|
|
17
|
+
export const LocalStorage = new Abstraction("LocalStorage");
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Abstraction","LocalStorageGateway","LocalStorageRepository","LocalStorageConfig","LocalStorage"],"sources":["abstractions.ts"],"sourcesContent":["import { Abstraction } from \"@webiny/di\";\n\n/** Gateway: raw IO into localStorage (or other storage). */\nexport interface ILocalStorageGateway {\n get<T = string>(key: string): T | null;\n set<T = string>(key: string, value: T): void;\n remove(key: string): void;\n clear(): void;\n getAll(): Record<string, unknown>;\n subscribe(listener: (event: StorageEvent | CustomEvent) => void): () => void;\n}\n\nexport const LocalStorageGateway = new Abstraction<ILocalStorageGateway>(\"LocalStorageGateway\");\n\nexport namespace LocalStorageGateway {\n export type Interface = ILocalStorageGateway;\n}\n\n/** Repository: reactive state (MobX), synchronized with gateway. */\nexport interface ILocalStorageRepository {\n has(key: string): boolean;\n get<T = string>(key: string): T | undefined;\n set<T = string>(key: string, value: T): void;\n remove(key: string): void;\n clear(): void;\n keys(): string[];\n destroy(): void;\n}\n\nexport const LocalStorageRepository = new Abstraction<ILocalStorageRepository>(\n \"LocalStorageRepository\"\n);\n\nexport namespace LocalStorageRepository {\n export type Interface = ILocalStorageRepository;\n}\n\n/** Config: configure key prefixes, etc. */\nexport interface ILocalStorageConfig {\n prefix?: string;\n}\n\nexport const LocalStorageConfig = new Abstraction<ILocalStorageConfig>(\"LocalStorageConfig\");\n\nexport namespace LocalStorageConfig {\n export type Interface = ILocalStorageConfig;\n}\n\n/** Service: thin façade, delegates to repository for consumers. */\nexport interface ILocalStorage {\n get<T = string>(key: string): T | undefined;\n set<T = string>(key: string, value: T): void;\n remove(key: string): void;\n clear(): void;\n keys(): string[];\n}\n\nexport const LocalStorage = new Abstraction<ILocalStorage>(\"LocalStorage\");\n\nexport namespace LocalStorage {\n export type Interface = ILocalStorage;\n}\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,YAAY;;AAExC;;AAUA,OAAO,MAAMC,mBAAmB,GAAG,IAAID,WAAW,CAAuB,qBAAqB,CAAC;;AAM/F;;AAWA,OAAO,MAAME,sBAAsB,GAAG,IAAIF,WAAW,CACjD,wBACJ,CAAC;;AAMD;;AAKA,OAAO,MAAMG,kBAAkB,GAAG,IAAIH,WAAW,CAAsB,oBAAoB,CAAC;;AAM5F;;AASA,OAAO,MAAMI,YAAY,GAAG,IAAIJ,WAAW,CAAgB,cAAc,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LocalStorageFeature wires together:
|
|
3
|
+
* - BrowserLocalStorageGateway (default gateway)
|
|
4
|
+
* - LocalStorageRepository (reactive MobX mirror)
|
|
5
|
+
* - LocalStorage (thin consumer-facing facade)
|
|
6
|
+
*/
|
|
7
|
+
export declare const LocalStorageFeature: import("~/shared/di/createFeature.js").FeatureDefinition<{
|
|
8
|
+
localStorageService: import("./abstractions.js").ILocalStorage;
|
|
9
|
+
localStorageConfig: import("./abstractions.js").ILocalStorageConfig;
|
|
10
|
+
}, [config?: {
|
|
11
|
+
prefix?: string;
|
|
12
|
+
} | undefined]>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { LocalStorageConfig, LocalStorageGateway, LocalStorage as Abstraction } from "./abstractions.js";
|
|
2
|
+
import { BrowserLocalStorageGateway } from "./BrowserLocalStorageGateway.js";
|
|
3
|
+
import { LocalStorageRepository } from "./LocalStorageRepository.js";
|
|
4
|
+
import { LocalStorage } from "./LocalStorage.js";
|
|
5
|
+
import { createFeature } from "../../shared/di/createFeature.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* LocalStorageFeature wires together:
|
|
9
|
+
* - BrowserLocalStorageGateway (default gateway)
|
|
10
|
+
* - LocalStorageRepository (reactive MobX mirror)
|
|
11
|
+
* - LocalStorage (thin consumer-facing facade)
|
|
12
|
+
*/
|
|
13
|
+
export const LocalStorageFeature = createFeature({
|
|
14
|
+
name: "LocalStorage",
|
|
15
|
+
register(container, config = {}) {
|
|
16
|
+
// Register config (tenant prefix, etc.)
|
|
17
|
+
container.registerInstance(LocalStorageConfig, config);
|
|
18
|
+
|
|
19
|
+
// Gateway: browser localStorage
|
|
20
|
+
container.registerInstance(LocalStorageGateway, new BrowserLocalStorageGateway());
|
|
21
|
+
|
|
22
|
+
// Repository & Service
|
|
23
|
+
container.register(LocalStorageRepository).inSingletonScope();
|
|
24
|
+
container.register(LocalStorage).inSingletonScope();
|
|
25
|
+
},
|
|
26
|
+
resolve(container) {
|
|
27
|
+
return {
|
|
28
|
+
localStorageService: container.resolve(Abstraction),
|
|
29
|
+
localStorageConfig: container.resolve(LocalStorageConfig)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["LocalStorageConfig","LocalStorageGateway","LocalStorage","Abstraction","BrowserLocalStorageGateway","LocalStorageRepository","createFeature","LocalStorageFeature","name","register","container","config","registerInstance","inSingletonScope","resolve","localStorageService","localStorageConfig"],"sources":["feature.ts"],"sourcesContent":["import {\n LocalStorageConfig,\n LocalStorageGateway,\n LocalStorage as Abstraction\n} from \"./abstractions.js\";\nimport { BrowserLocalStorageGateway } from \"./BrowserLocalStorageGateway.js\";\nimport { LocalStorageRepository } from \"./LocalStorageRepository.js\";\nimport { LocalStorage } from \"./LocalStorage.js\";\nimport { createFeature } from \"~/shared/di/createFeature.js\";\n\n/**\n * LocalStorageFeature wires together:\n * - BrowserLocalStorageGateway (default gateway)\n * - LocalStorageRepository (reactive MobX mirror)\n * - LocalStorage (thin consumer-facing facade)\n */\nexport const LocalStorageFeature = createFeature({\n name: \"LocalStorage\",\n register(container, config: { prefix?: string } = {}) {\n // Register config (tenant prefix, etc.)\n container.registerInstance(LocalStorageConfig, config);\n\n // Gateway: browser localStorage\n container.registerInstance(LocalStorageGateway, new BrowserLocalStorageGateway());\n\n // Repository & Service\n container.register(LocalStorageRepository).inSingletonScope();\n container.register(LocalStorage).inSingletonScope();\n },\n resolve(container) {\n return {\n localStorageService: container.resolve(Abstraction),\n localStorageConfig: container.resolve(LocalStorageConfig)\n };\n }\n});\n"],"mappings":"AAAA,SACIA,kBAAkB,EAClBC,mBAAmB,EACnBC,YAAY,IAAIC,WAAW;AAE/B,SAASC,0BAA0B;AACnC,SAASC,sBAAsB;AAC/B,SAASH,YAAY;AACrB,SAASI,aAAa;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,GAAGD,aAAa,CAAC;EAC7CE,IAAI,EAAE,cAAc;EACpBC,QAAQA,CAACC,SAAS,EAAEC,MAA2B,GAAG,CAAC,CAAC,EAAE;IAClD;IACAD,SAAS,CAACE,gBAAgB,CAACZ,kBAAkB,EAAEW,MAAM,CAAC;;IAEtD;IACAD,SAAS,CAACE,gBAAgB,CAACX,mBAAmB,EAAE,IAAIG,0BAA0B,CAAC,CAAC,CAAC;;IAEjF;IACAM,SAAS,CAACD,QAAQ,CAACJ,sBAAsB,CAAC,CAACQ,gBAAgB,CAAC,CAAC;IAC7DH,SAAS,CAACD,QAAQ,CAACP,YAAY,CAAC,CAACW,gBAAgB,CAAC,CAAC;EACvD,CAAC;EACDC,OAAOA,CAACJ,SAAS,EAAE;IACf,OAAO;MACHK,mBAAmB,EAAEL,SAAS,CAACI,OAAO,CAACX,WAAW,CAAC;MACnDa,kBAAkB,EAAEN,SAAS,CAACI,OAAO,CAACd,kBAAkB;IAC5D,CAAC;EACL;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LocalStorage, LocalStorageGateway, LocalStorageRepository, LocalStorageConfig } from "./abstractions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["LocalStorage","LocalStorageGateway","LocalStorageRepository","LocalStorageConfig"],"sources":["index.ts"],"sourcesContent":["export {\n LocalStorage,\n LocalStorageGateway,\n LocalStorageRepository,\n LocalStorageConfig\n} from \"./abstractions.js\";\n"],"mappings":"AAAA,SACIA,YAAY,EACZC,mBAAmB,EACnBC,sBAAsB,EACtBC,kBAAkB","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { History } from "history";
|
|
3
|
+
import type { RouteDefinition, OnRouteExit } from "./abstractions.js";
|
|
4
|
+
import { RouterGateway } from "./abstractions.js";
|
|
5
|
+
export declare class HistoryRouterGateway implements RouterGateway.Interface {
|
|
6
|
+
private readonly history;
|
|
7
|
+
private readonly router;
|
|
8
|
+
private stopListening;
|
|
9
|
+
private unblock;
|
|
10
|
+
constructor(history: History, baseUrl: string);
|
|
11
|
+
onRouteExit(cb: OnRouteExit): void;
|
|
12
|
+
goToRoute(name: string, params: z.ZodTypeAny): void;
|
|
13
|
+
setRoutes(routes: RouteDefinition[]): void;
|
|
14
|
+
destroy(): void;
|
|
15
|
+
pushState(url: string): void;
|
|
16
|
+
private resolvePathname;
|
|
17
|
+
private guardRouteExit;
|
|
18
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { RouteUrl } from "./RouteUrl.js";
|
|
2
|
+
import { Router } from "./Router.js";
|
|
3
|
+
export class HistoryRouterGateway {
|
|
4
|
+
constructor(history, baseUrl) {
|
|
5
|
+
this.history = history;
|
|
6
|
+
this.router = new Router(baseUrl);
|
|
7
|
+
this.stopListening = history.listen(async ({
|
|
8
|
+
location
|
|
9
|
+
}) => {
|
|
10
|
+
const queryParams = Object.fromEntries(new URLSearchParams(location.search).entries());
|
|
11
|
+
this.resolvePathname(location.pathname, queryParams);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
onRouteExit(cb) {
|
|
15
|
+
this.guardRouteExit(cb);
|
|
16
|
+
}
|
|
17
|
+
goToRoute(name, params) {
|
|
18
|
+
const route = this.router.findRoute(name);
|
|
19
|
+
if (!route) {
|
|
20
|
+
console.warn(`Route "${name}" not found.`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const baseUrl = this.router.getBaseUrl();
|
|
24
|
+
this.history.push(RouteUrl.fromPattern(route.path, params, baseUrl));
|
|
25
|
+
}
|
|
26
|
+
setRoutes(routes) {
|
|
27
|
+
this.router.setRoutes(routes);
|
|
28
|
+
const queryParams = Object.fromEntries(new URLSearchParams(this.history.location.search).entries());
|
|
29
|
+
const currentPathname = this.history.location.pathname;
|
|
30
|
+
this.resolvePathname(currentPathname, queryParams);
|
|
31
|
+
}
|
|
32
|
+
destroy() {
|
|
33
|
+
this.stopListening();
|
|
34
|
+
this.unblock && this.unblock();
|
|
35
|
+
}
|
|
36
|
+
pushState(url) {
|
|
37
|
+
this.history.push(url);
|
|
38
|
+
}
|
|
39
|
+
async resolvePathname(pathname, queryParams) {
|
|
40
|
+
const result = this.router.resolve(pathname, queryParams);
|
|
41
|
+
if (!result) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const {
|
|
45
|
+
matchedRoute,
|
|
46
|
+
onMatch
|
|
47
|
+
} = result;
|
|
48
|
+
onMatch(matchedRoute);
|
|
49
|
+
}
|
|
50
|
+
guardRouteExit(onRouteExit) {
|
|
51
|
+
if (this.unblock) {
|
|
52
|
+
// Remove existing blocker before installing a new one.
|
|
53
|
+
this.unblock();
|
|
54
|
+
}
|
|
55
|
+
this.unblock = this.history.block(tx => {
|
|
56
|
+
let resolved = false;
|
|
57
|
+
onRouteExit({
|
|
58
|
+
continue: () => {
|
|
59
|
+
if (!resolved) {
|
|
60
|
+
resolved = true;
|
|
61
|
+
// We need to unblock the transition before retying.
|
|
62
|
+
if (this.unblock) {
|
|
63
|
+
this.unblock();
|
|
64
|
+
this.unblock = undefined;
|
|
65
|
+
}
|
|
66
|
+
// Perform transition.
|
|
67
|
+
tx.retry();
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
cancel: () => {
|
|
71
|
+
resolved = true;
|
|
72
|
+
// Do nothing.
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Block the transition until `continue` is called.
|
|
77
|
+
return false;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=HistoryRouterGateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["RouteUrl","Router","HistoryRouterGateway","constructor","history","baseUrl","router","stopListening","listen","location","queryParams","Object","fromEntries","URLSearchParams","search","entries","resolvePathname","pathname","onRouteExit","cb","guardRouteExit","goToRoute","name","params","route","findRoute","console","warn","getBaseUrl","push","fromPattern","path","setRoutes","routes","currentPathname","destroy","unblock","pushState","url","result","resolve","matchedRoute","onMatch","block","tx","resolved","continue","undefined","retry","cancel"],"sources":["HistoryRouterGateway.ts"],"sourcesContent":["import type { z } from \"zod\";\nimport type { History } from \"history\";\nimport type { RouteDefinition, OnRouteExit } from \"./abstractions.js\";\nimport { RouterGateway } from \"./abstractions.js\";\nimport { RouteUrl } from \"./RouteUrl.js\";\nimport { Router } from \"./Router.js\";\n\nexport class HistoryRouterGateway implements RouterGateway.Interface {\n private readonly history: History;\n private readonly router: Router;\n private stopListening: () => void;\n private unblock: (() => void) | undefined;\n\n constructor(history: History, baseUrl: string) {\n this.history = history;\n this.router = new Router(baseUrl);\n\n this.stopListening = history.listen(async ({ location }) => {\n const queryParams = Object.fromEntries(new URLSearchParams(location.search).entries());\n this.resolvePathname(location.pathname, queryParams);\n });\n }\n\n onRouteExit(cb: OnRouteExit): void {\n this.guardRouteExit(cb);\n }\n\n goToRoute(name: string, params: z.ZodTypeAny): void {\n const route = this.router.findRoute(name);\n if (!route) {\n console.warn(`Route \"${name}\" not found.`);\n return;\n }\n\n const baseUrl = this.router.getBaseUrl();\n this.history.push(RouteUrl.fromPattern(route.path, params, baseUrl));\n }\n\n setRoutes(routes: RouteDefinition[]) {\n this.router.setRoutes(routes);\n\n const queryParams = Object.fromEntries(\n new URLSearchParams(this.history.location.search).entries()\n );\n const currentPathname = this.history.location.pathname;\n this.resolvePathname(currentPathname, queryParams);\n }\n\n destroy(): void {\n this.stopListening();\n this.unblock && this.unblock();\n }\n\n pushState(url: string): void {\n this.history.push(url);\n }\n\n private async resolvePathname(pathname: string, queryParams?: Record<string, unknown>) {\n const result = this.router.resolve(pathname, queryParams);\n if (!result) {\n return;\n }\n\n const { matchedRoute, onMatch } = result;\n\n onMatch(matchedRoute);\n }\n\n private guardRouteExit(onRouteExit: OnRouteExit): void {\n if (this.unblock) {\n // Remove existing blocker before installing a new one.\n this.unblock();\n }\n\n this.unblock = this.history.block(tx => {\n let resolved = false;\n\n onRouteExit({\n continue: () => {\n if (!resolved) {\n resolved = true;\n // We need to unblock the transition before retying.\n if (this.unblock) {\n this.unblock();\n this.unblock = undefined;\n }\n // Perform transition.\n tx.retry();\n }\n },\n cancel: () => {\n resolved = true;\n // Do nothing.\n }\n });\n\n // Block the transition until `continue` is called.\n return false;\n });\n }\n}\n"],"mappings":"AAIA,SAASA,QAAQ;AACjB,SAASC,MAAM;AAEf,OAAO,MAAMC,oBAAoB,CAAoC;EAMjEC,WAAWA,CAACC,OAAgB,EAAEC,OAAe,EAAE;IAC3C,IAAI,CAACD,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACE,MAAM,GAAG,IAAIL,MAAM,CAACI,OAAO,CAAC;IAEjC,IAAI,CAACE,aAAa,GAAGH,OAAO,CAACI,MAAM,CAAC,OAAO;MAAEC;IAAS,CAAC,KAAK;MACxD,MAAMC,WAAW,GAAGC,MAAM,CAACC,WAAW,CAAC,IAAIC,eAAe,CAACJ,QAAQ,CAACK,MAAM,CAAC,CAACC,OAAO,CAAC,CAAC,CAAC;MAC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