@webiny/app 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7be00a75a9
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 +25 -0
- package/App.js +82 -0
- package/App.js.map +1 -0
- package/AppContainer.d.ts +23 -0
- package/AppContainer.js +6 -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 -77
- package/apollo-client/InMemoryCache.js.map +1 -1
- package/apollo-client/IntrospectionFragmentMatcher.d.ts +11 -0
- package/apollo-client/IntrospectionFragmentMatcher.js +33 -0
- package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -0
- package/components/Image.d.ts +2 -3
- package/components/Image.js +15 -41
- package/components/Image.js.map +1 -1
- package/components/index.d.ts +1 -2
- package/components/index.js +1 -21
- package/config/RouterConfig/Route.d.ts +29 -0
- package/config/RouterConfig/Route.js +28 -0
- package/config/RouterConfig/Route.js.map +1 -0
- package/config/RouterConfig.d.ts +31 -0
- package/config/RouterConfig.js +19 -0
- package/config/RouterConfig.js.map +1 -0
- package/config.d.ts +1 -1
- package/config.js +20 -29
- package/config.js.map +1 -1
- package/contexts/Ui/index.d.ts +4 -8
- package/contexts/Ui/index.js +27 -89
- package/contexts/Ui/index.js.map +1 -1
- package/core/Plugin.d.ts +8 -0
- package/core/Plugin.js +12 -0
- package/core/Plugin.js.map +1 -0
- package/core/Plugins.d.ts +15 -0
- package/core/Plugins.js +21 -0
- package/core/Plugins.js.map +1 -0
- package/core/Provider.d.ts +8 -0
- package/core/Provider.js +10 -0
- package/core/Provider.js.map +1 -0
- package/core/createProvider.d.ts +10 -0
- package/core/createProvider.js +6 -0
- package/core/createProvider.js.map +1 -0
- package/core/createProviderPlugin.d.ts +8 -0
- package/core/createProviderPlugin.js +12 -0
- package/core/createProviderPlugin.js.map +1 -0
- package/errors/AuthenticationErrorEvent.d.ts +9 -0
- package/errors/AuthenticationErrorEvent.js +13 -0
- package/errors/AuthenticationErrorEvent.js.map +1 -0
- package/errors/NetworkErrorEvent.d.ts +15 -0
- package/errors/NetworkErrorEvent.js +13 -0
- package/errors/NetworkErrorEvent.js.map +1 -0
- package/errors/abstractions.d.ts +12 -0
- package/errors/abstractions.js +6 -0
- package/errors/abstractions.js.map +1 -0
- package/errors/index.d.ts +6 -0
- package/errors/index.js +3 -0
- package/exports/admin/env-config.d.ts +2 -0
- package/exports/admin/env-config.js +2 -0
- package/exports/admin/graphql-client.d.ts +1 -0
- package/exports/admin/graphql-client.js +1 -0
- package/exports/admin/local-storage.d.ts +2 -0
- package/exports/admin/local-storage.js +2 -0
- package/exports/admin/router.d.ts +5 -0
- package/exports/admin/router.js +5 -0
- package/exports/admin/security.d.ts +1 -0
- package/exports/admin/security.js +1 -0
- package/exports/admin.d.ts +7 -0
- package/exports/admin.js +7 -0
- package/features/envConfig/EnvConfig.d.ts +7 -0
- package/features/envConfig/EnvConfig.js +16 -0
- package/features/envConfig/EnvConfig.js.map +1 -0
- package/features/envConfig/abstractions.d.ts +28 -0
- package/features/envConfig/abstractions.js +5 -0
- package/features/envConfig/abstractions.js.map +1 -0
- package/features/envConfig/feature.d.ts +17 -0
- package/features/envConfig/feature.js +15 -0
- package/features/envConfig/feature.js.map +1 -0
- package/features/envConfig/index.d.ts +1 -0
- package/features/envConfig/index.js +1 -0
- package/features/eventPublisher/EventPublisher.d.ts +8 -0
- package/features/eventPublisher/EventPublisher.js +19 -0
- package/features/eventPublisher/EventPublisher.js.map +1 -0
- package/features/eventPublisher/abstractions.d.ts +18 -0
- package/features/eventPublisher/abstractions.js +12 -0
- package/features/eventPublisher/abstractions.js.map +1 -0
- package/features/eventPublisher/feature.d.ts +3 -0
- package/features/eventPublisher/feature.js +17 -0
- package/features/eventPublisher/feature.js.map +1 -0
- package/features/eventPublisher/index.d.ts +3 -0
- package/features/eventPublisher/index.js +2 -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 +16 -0
- package/features/graphqlClient/BatchingGraphQLClient.js +118 -0
- package/features/graphqlClient/BatchingGraphQLClient.js.map +1 -0
- package/features/graphqlClient/FetchGraphQLClient.d.ts +7 -0
- package/features/graphqlClient/FetchGraphQLClient.js +51 -0
- package/features/graphqlClient/FetchGraphQLClient.js.map +1 -0
- package/features/graphqlClient/NetworkErrorPublishing.d.ts +14 -0
- package/features/graphqlClient/NetworkErrorPublishing.js +48 -0
- package/features/graphqlClient/NetworkErrorPublishing.js.map +1 -0
- package/features/graphqlClient/RequestValue.d.ts +21 -0
- package/features/graphqlClient/RequestValue.js +46 -0
- package/features/graphqlClient/RequestValue.js.map +1 -0
- package/features/graphqlClient/RetryGraphQLClient.d.ts +18 -0
- package/features/graphqlClient/RetryGraphQLClient.js +45 -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 +397 -0
- package/features/graphqlClient/__tests__/GraphQLClient.test.js.map +1 -0
- package/features/graphqlClient/abstractions.d.ts +18 -0
- package/features/graphqlClient/abstractions.js +5 -0
- package/features/graphqlClient/abstractions.js.map +1 -0
- package/features/graphqlClient/feature.d.ts +6 -0
- package/features/graphqlClient/feature.js +25 -0
- package/features/graphqlClient/feature.js.map +1 -0
- package/features/graphqlClient/index.d.ts +1 -0
- package/features/graphqlClient/index.js +1 -0
- package/features/graphqlClient/types.d.ts +5 -0
- package/features/graphqlClient/types.js +0 -0
- package/features/localStorage/BrowserLocalStorageGateway.d.ts +9 -0
- package/features/localStorage/BrowserLocalStorageGateway.js +61 -0
- package/features/localStorage/BrowserLocalStorageGateway.js.map +1 -0
- package/features/localStorage/LocalStorage.d.ts +12 -0
- package/features/localStorage/LocalStorage.js +34 -0
- package/features/localStorage/LocalStorage.js.map +1 -0
- package/features/localStorage/LocalStorageRepository.d.ts +20 -0
- package/features/localStorage/LocalStorageRepository.js +82 -0
- package/features/localStorage/LocalStorageRepository.js.map +1 -0
- package/features/localStorage/abstractions.d.ts +48 -0
- package/features/localStorage/abstractions.js +8 -0
- package/features/localStorage/abstractions.js.map +1 -0
- package/features/localStorage/feature.d.ts +12 -0
- package/features/localStorage/feature.js +23 -0
- package/features/localStorage/feature.js.map +1 -0
- package/features/localStorage/index.d.ts +1 -0
- package/features/localStorage/index.js +1 -0
- package/features/mainGraphQLClient/MainGraphQLClient.d.ts +11 -0
- package/features/mainGraphQLClient/MainGraphQLClient.js +27 -0
- package/features/mainGraphQLClient/MainGraphQLClient.js.map +1 -0
- package/features/mainGraphQLClient/abstractions.d.ts +17 -0
- package/features/mainGraphQLClient/abstractions.js +5 -0
- package/features/mainGraphQLClient/abstractions.js.map +1 -0
- package/features/mainGraphQLClient/feature.d.ts +3 -0
- package/features/mainGraphQLClient/feature.js +17 -0
- package/features/mainGraphQLClient/feature.js.map +1 -0
- package/features/mainGraphQLClient/index.d.ts +1 -0
- package/features/mainGraphQLClient/index.js +1 -0
- package/features/router/HistoryRouterGateway.d.ts +22 -0
- package/features/router/HistoryRouterGateway.js +88 -0
- package/features/router/HistoryRouterGateway.js.map +1 -0
- package/features/router/HistoryRouterGateway.test.d.ts +1 -0
- package/features/router/HistoryRouterGateway.test.js +195 -0
- package/features/router/HistoryRouterGateway.test.js.map +1 -0
- package/features/router/Route.d.ts +19 -0
- package/features/router/Route.js +43 -0
- package/features/router/Route.js.map +1 -0
- package/features/router/RouteUrl.d.ts +85 -0
- package/features/router/RouteUrl.js +99 -0
- package/features/router/RouteUrl.js.map +1 -0
- package/features/router/Router.d.ts +45 -0
- package/features/router/Router.js +72 -0
- package/features/router/Router.js.map +1 -0
- package/features/router/RouterPresenter.d.ts +21 -0
- package/features/router/RouterPresenter.js +52 -0
- package/features/router/RouterPresenter.js.map +1 -0
- package/features/router/RouterRepository.d.ts +30 -0
- package/features/router/RouterRepository.js +117 -0
- package/features/router/RouterRepository.js.map +1 -0
- package/features/router/RouterRepository.test.d.ts +1 -0
- package/features/router/RouterRepository.test.js +138 -0
- package/features/router/RouterRepository.test.js.map +1 -0
- package/features/router/abstractions.d.ts +81 -0
- package/features/router/abstractions.js +7 -0
- package/features/router/abstractions.js.map +1 -0
- package/features/router/feature.d.ts +4 -0
- package/features/router/feature.js +19 -0
- package/features/router/feature.js.map +1 -0
- package/features/router/index.d.ts +2 -0
- package/features/router/index.js +1 -0
- package/helpers/InterfaceGenerator/date.d.ts +15 -0
- package/helpers/InterfaceGenerator/date.js +0 -0
- package/helpers/InterfaceGenerator/id.d.ts +23 -0
- package/helpers/InterfaceGenerator/id.js +0 -0
- package/helpers/InterfaceGenerator/identity.d.ts +10 -0
- package/helpers/InterfaceGenerator/identity.js +0 -0
- package/helpers/InterfaceGenerator/index.d.ts +5 -0
- package/helpers/InterfaceGenerator/index.js +0 -0
- package/helpers/InterfaceGenerator/numeric.d.ts +12 -0
- package/helpers/InterfaceGenerator/numeric.js +0 -0
- package/helpers/InterfaceGenerator/truthful.d.ts +7 -0
- package/helpers/InterfaceGenerator/truthful.js +0 -0
- package/hooks/useAutocomplete/index.d.ts +1 -1
- package/hooks/useAutocomplete/index.js +1 -13
- package/hooks/useAutocomplete/useAutocomplete.d.ts +1 -1
- package/hooks/useAutocomplete/useAutocomplete.js +15 -36
- package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
- package/hooks/useDataList/functions/getData.js +4 -15
- package/hooks/useDataList/functions/getData.js.map +1 -1
- package/hooks/useDataList/functions/getError.js +4 -15
- package/hooks/useDataList/functions/getError.js.map +1 -1
- package/hooks/useDataList/functions/getMeta.js +4 -15
- 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 -31
- package/hooks/useDataList/functions/searchDataByKey.js +10 -26
- package/hooks/useDataList/functions/searchDataByKey.js.map +1 -1
- package/hooks/useDataList/index.d.ts +1 -1
- package/hooks/useDataList/index.js +1 -13
- package/hooks/useDataList/useDataList.d.ts +2 -3
- package/hooks/useDataList/useDataList.js +139 -205
- package/hooks/useDataList/useDataList.js.map +1 -1
- package/hooks/useDataList/utils/index.d.ts +1 -2
- package/hooks/useDataList/utils/index.js +1 -23
- package/hooks/useDataList/utils/prepareLoadListParams.d.ts +1 -2
- package/hooks/useDataList/utils/prepareLoadListParams.js +26 -45
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
- package/hooks/useHandler.js +14 -19
- package/hooks/useHandler.js.map +1 -1
- package/hooks/useHandlers.d.ts +3 -3
- package/hooks/useHandlers.js +19 -28
- package/hooks/useHandlers.js.map +1 -1
- package/hooks/useRegisterLegacyPlugin.d.ts +2 -0
- package/hooks/useRegisterLegacyPlugin.js +12 -0
- package/hooks/useRegisterLegacyPlugin.js.map +1 -0
- package/hooks/useUi.d.ts +1 -1
- package/hooks/useUi.js +5 -15
- package/hooks/useUi.js.map +1 -1
- package/i18n/i18n.js +11 -21
- package/i18n/i18n.js.map +1 -1
- package/i18n/index.d.ts +1 -1
- package/i18n/index.js +1 -15
- package/index.d.ts +25 -4
- package/index.js +23 -37
- package/package.json +38 -38
- package/plugins/AddQuerySelectionPlugin.d.ts +10 -3
- package/plugins/AddQuerySelectionPlugin.js +43 -128
- package/plugins/AddQuerySelectionPlugin.js.map +1 -1
- package/plugins/ApolloCacheObjectIdPlugin.js +15 -51
- package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -1
- package/plugins/ApolloDynamicLink.d.ts +3 -2
- package/plugins/ApolloDynamicLink.js +24 -78
- package/plugins/ApolloDynamicLink.js.map +1 -1
- package/plugins/ApolloLinkPlugin.d.ts +1 -1
- package/plugins/ApolloLinkPlugin.js +21 -61
- package/plugins/ApolloLinkPlugin.js.map +1 -1
- package/plugins/ConsoleLinkPlugin.d.ts +1 -1
- package/plugins/ConsoleLinkPlugin.js +20 -59
- package/plugins/ConsoleLinkPlugin.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts +8 -13
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +47 -95
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.d.ts +14 -0
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js +27 -0
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.d.ts +2 -0
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js +23 -0
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +8 -5
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +68 -20
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/Typography.d.ts +8 -0
- package/plugins/NetworkErrorLinkPlugin/Typography.js +13 -0
- package/plugins/NetworkErrorLinkPlugin/Typography.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js +19 -0
- package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.d.ts +3 -3
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +13 -36
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin.d.ts +4 -1
- package/plugins/NetworkErrorLinkPlugin.js +51 -63
- package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
- package/plugins/OmitTypenameLinkPlugin.d.ts +1 -1
- package/plugins/OmitTypenameLinkPlugin.js +12 -51
- package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
- package/plugins/TenantHeaderLinkPlugin.d.ts +3 -8
- package/plugins/TenantHeaderLinkPlugin.js +25 -82
- package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
- package/plugins/components/Image.d.ts +6 -0
- package/plugins/components/Image.js +12 -0
- package/plugins/components/Image.js.map +1 -0
- package/plugins/image.d.ts +1 -1
- package/plugins/image.js +97 -175
- package/plugins/image.js.map +1 -1
- package/plugins/index.d.ts +5 -5
- package/plugins/index.js +38 -106
- package/plugins/index.js.map +1 -1
- package/presentation/envConfig/useEnvConfig.d.ts +6 -0
- package/presentation/envConfig/useEnvConfig.js +9 -0
- package/presentation/envConfig/useEnvConfig.js.map +1 -0
- package/presentation/localStorage/index.d.ts +3 -0
- package/presentation/localStorage/index.js +3 -0
- package/presentation/localStorage/useLocalStorage.d.ts +6 -0
- package/presentation/localStorage/useLocalStorage.js +15 -0
- package/presentation/localStorage/useLocalStorage.js.map +1 -0
- package/presentation/localStorage/useLocalStorageValue.d.ts +1 -0
- package/presentation/localStorage/useLocalStorageValue.js +22 -0
- package/presentation/localStorage/useLocalStorageValue.js.map +1 -0
- package/presentation/localStorage/useLocalStorageValues.d.ts +5 -0
- package/presentation/localStorage/useLocalStorageValues.js +32 -0
- package/presentation/localStorage/useLocalStorageValues.js.map +1 -0
- package/presentation/router/RouteElementRegistry.d.ts +14 -0
- package/presentation/router/RouteElementRegistry.js +29 -0
- package/presentation/router/RouteElementRegistry.js.map +1 -0
- package/presentation/router/abstractions.d.ts +13 -0
- package/presentation/router/abstractions.js +5 -0
- package/presentation/router/abstractions.js.map +1 -0
- package/presentation/router/components/Redirect.d.ts +14 -0
- package/presentation/router/components/Redirect.js +13 -0
- package/presentation/router/components/Redirect.js.map +1 -0
- package/presentation/router/components/RouteContent.d.ts +2 -0
- package/presentation/router/components/RouteContent.js +20 -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 +17 -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 +24 -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 +22 -0
- package/presentation/router/hooks/useRoute.js.map +1 -0
- package/presentation/router/hooks/useRouter.d.ts +11 -0
- package/presentation/router/hooks/useRouter.js +29 -0
- package/presentation/router/hooks/useRouter.js.map +1 -0
- package/presentation/router/index.d.ts +4 -0
- package/presentation/router/index.js +3 -0
- package/presentation/router/types.d.ts +5 -0
- package/presentation/router/types.js +0 -0
- package/renderApp.d.ts +2 -0
- package/renderApp.js +10 -0
- package/renderApp.js.map +1 -0
- package/router.d.ts +5 -0
- package/router.js +5 -0
- package/rslib-runtime.js +14 -0
- package/rslib-runtime.js.map +1 -0
- package/shared/di/DiContainerProvider.d.ts +8 -0
- package/shared/di/DiContainerProvider.js +13 -0
- package/shared/di/DiContainerProvider.js.map +1 -0
- package/shared/di/createFeature.d.ts +11 -0
- package/shared/di/createFeature.js +10 -0
- package/shared/di/createFeature.js.map +1 -0
- package/shared/di/useFeature.d.ts +2 -0
- package/shared/di/useFeature.js +12 -0
- package/shared/di/useFeature.js.map +1 -0
- package/static/svg/close_24px.33adaadc.svg +1 -0
- package/types.d.ts +30 -30
- package/types.js +0 -13
- package/utils/createGenericContext.d.ts +13 -0
- package/utils/createGenericContext.js +21 -0
- package/utils/createGenericContext.js.map +1 -0
- package/utils/createHashing.d.ts +2 -0
- package/utils/createHashing.js +15 -0
- package/utils/createHashing.js.map +1 -0
- package/utils/index.d.ts +2 -0
- package/utils/index.js +2 -0
- package/utils/legacyPluginToReactComponent.d.ts +7 -0
- package/utils/legacyPluginToReactComponent.js +15 -0
- package/utils/legacyPluginToReactComponent.js.map +1 -0
- package/components/Routes.d.ts +0 -2
- package/components/Routes.js +0 -49
- package/components/Routes.js.map +0 -1
- package/components/View.d.ts +0 -8
- package/components/View.js +0 -41
- package/components/View.js.map +0 -1
- package/components/index.js.map +0 -1
- package/hooks/useAutocomplete/index.js.map +0 -1
- package/hooks/useDataList/functions/index.js.map +0 -1
- package/hooks/useDataList/index.js.map +0 -1
- package/hooks/useDataList/utils/index.js.map +0 -1
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.d.ts +0 -14
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +0 -31
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +0 -1
- package/hooks/useDataList/utils/types.d.ts +0 -34
- package/hooks/useDataList/utils/types.js +0 -5
- package/hooks/useDataList/utils/types.js.map +0 -1
- package/i18n/index.js.map +0 -1
- package/index.js.map +0 -1
- package/plugins/LocaleHeaderLinkPlugin.d.ts +0 -15
- package/plugins/LocaleHeaderLinkPlugin.js +0 -77
- package/plugins/LocaleHeaderLinkPlugin.js.map +0 -1
- package/plugins/RoutePlugin.d.ts +0 -12
- package/plugins/RoutePlugin.js +0 -53
- package/plugins/RoutePlugin.js.map +0 -1
- package/plugins/ViewPlugin.d.ts +0 -14
- package/plugins/ViewPlugin.js +0 -58
- package/plugins/ViewPlugin.js.map +0 -1
- package/types.js.map +0 -1
package/App.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Decorator, DecoratorsCollection, GenericComponent } from "@webiny/react-composition";
|
|
3
|
+
interface State {
|
|
4
|
+
plugins: React.JSX.Element[];
|
|
5
|
+
providers: Decorator<GenericComponent<ProviderProps>>[];
|
|
6
|
+
}
|
|
7
|
+
interface AppContext extends State {
|
|
8
|
+
addProvider(hoc: Decorator<GenericComponent<ProviderProps>>): void;
|
|
9
|
+
addPlugin(plugin: React.ReactNode): void;
|
|
10
|
+
}
|
|
11
|
+
declare const AppContext: React.Context<AppContext | undefined>;
|
|
12
|
+
export declare const useApp: () => AppContext;
|
|
13
|
+
export interface AppProps {
|
|
14
|
+
routes?: Array<any>;
|
|
15
|
+
plugins?: any[];
|
|
16
|
+
providers?: Array<Decorator<GenericComponent<ProviderProps>>>;
|
|
17
|
+
decorators?: DecoratorsCollection;
|
|
18
|
+
children?: React.ReactNode | React.ReactNode[];
|
|
19
|
+
}
|
|
20
|
+
interface ProviderProps {
|
|
21
|
+
children: React.ReactNode;
|
|
22
|
+
}
|
|
23
|
+
export declare const AppBase: React.MemoExoticComponent<({ routes, plugins, providers, children }: AppProps) => React.JSX.Element>;
|
|
24
|
+
export declare const App: ({ decorators, ...props }: AppProps) => React.JSX.Element;
|
|
25
|
+
export {};
|
package/App.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import react, { Fragment, createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { CompositionProvider, compose } from "@webiny/react-composition";
|
|
3
|
+
import { PluginsProvider } from "./core/Plugins.js";
|
|
4
|
+
import { RouterWithConfig, useRouterConfig } from "./config/RouterConfig.js";
|
|
5
|
+
import { AppContainer } from "./AppContainer.js";
|
|
6
|
+
import { RouteContent } from "./presentation/router/components/RouteContent.js";
|
|
7
|
+
import { useRouter } from "./router.js";
|
|
8
|
+
const AppContext = /*#__PURE__*/ createContext(void 0);
|
|
9
|
+
AppContext.displayName = "AppContext";
|
|
10
|
+
const useApp = ()=>{
|
|
11
|
+
const appContext = useContext(AppContext);
|
|
12
|
+
if (!appContext) throw Error('AppContext provider was not found. Are you using the "useApp()" hook in the right place?');
|
|
13
|
+
return appContext;
|
|
14
|
+
};
|
|
15
|
+
const AppBase = /*#__PURE__*/ react.memo(({ routes = [], plugins = [], providers = [], children })=>{
|
|
16
|
+
const [state, setState] = useState({
|
|
17
|
+
plugins,
|
|
18
|
+
providers
|
|
19
|
+
});
|
|
20
|
+
const addProvider = useCallback((component)=>{
|
|
21
|
+
setState((state)=>{
|
|
22
|
+
if (state.providers.findIndex((m)=>m === component) > -1) return state;
|
|
23
|
+
return {
|
|
24
|
+
...state,
|
|
25
|
+
providers: [
|
|
26
|
+
...state.providers,
|
|
27
|
+
component
|
|
28
|
+
]
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
}, []);
|
|
32
|
+
const addPlugin = useCallback((element)=>{
|
|
33
|
+
setState((state)=>({
|
|
34
|
+
...state,
|
|
35
|
+
plugins: [
|
|
36
|
+
...state.plugins,
|
|
37
|
+
element
|
|
38
|
+
]
|
|
39
|
+
}));
|
|
40
|
+
}, []);
|
|
41
|
+
const appContext = useMemo(()=>({
|
|
42
|
+
...state,
|
|
43
|
+
addProvider,
|
|
44
|
+
addPlugin
|
|
45
|
+
}), [
|
|
46
|
+
state
|
|
47
|
+
]);
|
|
48
|
+
const AppRouter = useMemo(()=>function() {
|
|
49
|
+
const router = useRouter();
|
|
50
|
+
const routerConfig = useRouterConfig();
|
|
51
|
+
const routesFromConfig = routerConfig.routes;
|
|
52
|
+
const combinedRoutes = [
|
|
53
|
+
...routes,
|
|
54
|
+
...routesFromConfig
|
|
55
|
+
];
|
|
56
|
+
useEffect(()=>{
|
|
57
|
+
router.setRoutes(combinedRoutes);
|
|
58
|
+
}, [
|
|
59
|
+
combinedRoutes.length
|
|
60
|
+
]);
|
|
61
|
+
return null;
|
|
62
|
+
}, []);
|
|
63
|
+
const Providers = useMemo(()=>/*#__PURE__*/ react.memo(compose(...state.providers || [])(({ children })=>/*#__PURE__*/ react.createElement(react.Fragment, null, children))), [
|
|
64
|
+
state.providers.length
|
|
65
|
+
]);
|
|
66
|
+
Providers.displayName = "Providers";
|
|
67
|
+
return /*#__PURE__*/ react.createElement(AppContext.Provider, {
|
|
68
|
+
value: appContext
|
|
69
|
+
}, children, /*#__PURE__*/ react.createElement(AppContainer, null, /*#__PURE__*/ react.createElement(Providers, null, /*#__PURE__*/ react.createElement(PluginsProvider, null, state.plugins.map((plugin, index)=>/*#__PURE__*/ react.createElement(Fragment, {
|
|
70
|
+
key: index
|
|
71
|
+
}, plugin))), /*#__PURE__*/ react.createElement(RouterWithConfig, null, /*#__PURE__*/ react.createElement(AppRouter, null), /*#__PURE__*/ react.createElement(RouteContent, null)))));
|
|
72
|
+
});
|
|
73
|
+
AppBase.displayName = "AppBase";
|
|
74
|
+
const App = ({ decorators, ...props })=>/*#__PURE__*/ react.createElement(CompositionProvider, {
|
|
75
|
+
decorators: decorators
|
|
76
|
+
}, /*#__PURE__*/ react.createElement(AppBase, {
|
|
77
|
+
decorators: decorators,
|
|
78
|
+
...props
|
|
79
|
+
}));
|
|
80
|
+
export { App, AppBase, useApp };
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=App.js.map
|
package/App.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App.js","sources":["../src/App.tsx"],"sourcesContent":["import React, {\n createContext,\n Fragment,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState\n} from \"react\";\nimport {\n compose,\n CompositionProvider,\n Decorator,\n DecoratorsCollection,\n GenericComponent\n} from \"@webiny/react-composition\";\nimport { PluginsProvider } from \"./core/Plugins.js\";\nimport { RouterWithConfig, useRouterConfig } from \"./config/RouterConfig.js\";\nimport { AppContainer } from \"./AppContainer.js\";\nimport { RouteContent } from \"~/presentation/router/components/RouteContent.js\";\nimport { useRouter } from \"~/router.js\";\n\ninterface State {\n plugins: React.JSX.Element[];\n providers: Decorator<GenericComponent<ProviderProps>>[];\n}\n\ninterface AppContext extends State {\n addProvider(hoc: Decorator<GenericComponent<ProviderProps>>): void;\n addPlugin(plugin: React.ReactNode): void;\n}\n\nconst AppContext = createContext<AppContext | undefined>(undefined);\n\nAppContext.displayName = \"AppContext\";\n\nexport const useApp = () => {\n const appContext = useContext(AppContext);\n if (!appContext) {\n throw Error(\n `AppContext provider was not found. Are you using the \"useApp()\" hook in the right place?`\n );\n }\n return appContext;\n};\n\nexport interface AppProps {\n routes?: Array<any>;\n plugins?: any[];\n providers?: Array<Decorator<GenericComponent<ProviderProps>>>;\n decorators?: DecoratorsCollection;\n children?: React.ReactNode | React.ReactNode[];\n}\n\ninterface ProviderProps {\n children: React.ReactNode;\n}\n\ntype ComponentWithChildren = React.ComponentType<{ children?: React.ReactNode }>;\n\nexport const AppBase = React.memo(\n ({ routes = [], plugins = [], providers = [], children }: AppProps) => {\n const [state, setState] = useState<State>({\n plugins,\n providers\n });\n\n const addProvider = useCallback((component: Decorator<any>) => {\n setState(state => {\n if (state.providers.findIndex(m => m === component) > -1) {\n return state;\n }\n\n return {\n ...state,\n providers: [...state.providers, component]\n };\n });\n }, []);\n\n const addPlugin = useCallback((element: React.JSX.Element) => {\n setState(state => {\n return {\n ...state,\n plugins: [...state.plugins, element]\n };\n });\n }, []);\n\n const appContext = useMemo(\n () => ({\n ...state,\n addProvider,\n addPlugin\n }),\n [state]\n );\n\n const AppRouter = useMemo(() => {\n return function AppRouter() {\n const router = useRouter();\n const routerConfig = useRouterConfig();\n const routesFromConfig = routerConfig.routes;\n const combinedRoutes = [...routes, ...routesFromConfig];\n\n useEffect(() => {\n router.setRoutes(combinedRoutes);\n }, [combinedRoutes.length]);\n\n return null;\n };\n }, []);\n\n const Providers = useMemo(() => {\n return React.memo(\n compose(...(state.providers || []))(({ children }: ProviderProps) => {\n return <>{children}</>;\n })\n );\n }, [state.providers.length]) as ComponentWithChildren;\n\n Providers.displayName = \"Providers\";\n\n return (\n <AppContext.Provider value={appContext}>\n {children}\n <AppContainer>\n <Providers>\n <PluginsProvider>\n {state.plugins.map((plugin, index) => (\n <Fragment key={index}>{plugin}</Fragment>\n ))}\n </PluginsProvider>\n <RouterWithConfig>\n <AppRouter />\n <RouteContent />\n </RouterWithConfig>\n </Providers>\n </AppContainer>\n </AppContext.Provider>\n );\n }\n);\n\nAppBase.displayName = \"AppBase\";\n\nexport const App = ({ decorators, ...props }: AppProps) => {\n return (\n <CompositionProvider decorators={decorators}>\n <AppBase decorators={decorators} {...props} />\n </CompositionProvider>\n );\n};\n"],"names":["AppContext","createContext","undefined","useApp","appContext","useContext","Error","AppBase","React","routes","plugins","providers","children","state","setState","useState","addProvider","useCallback","component","m","addPlugin","element","useMemo","AppRouter","router","useRouter","routerConfig","useRouterConfig","routesFromConfig","combinedRoutes","useEffect","Providers","compose","AppContainer","PluginsProvider","plugin","index","Fragment","RouterWithConfig","RouteContent","App","decorators","props","CompositionProvider"],"mappings":";;;;;;;AAgCA,MAAMA,aAAa,WAAHA,GAAGC,cAAsCC;AAEzDF,WAAW,WAAW,GAAG;AAElB,MAAMG,SAAS;IAClB,MAAMC,aAAaC,WAAWL;IAC9B,IAAI,CAACI,YACD,MAAME,MACF;IAGR,OAAOF;AACX;AAgBO,MAAMG,UAAU,WAAHA,GAAGC,MAAAA,IAAU,CAC7B,CAAC,EAAEC,SAAS,EAAE,EAAEC,UAAU,EAAE,EAAEC,YAAY,EAAE,EAAEC,QAAQ,EAAY;IAC9D,MAAM,CAACC,OAAOC,SAAS,GAAGC,SAAgB;QACtCL;QACAC;IACJ;IAEA,MAAMK,cAAcC,YAAY,CAACC;QAC7BJ,SAASD,CAAAA;YACL,IAAIA,MAAM,SAAS,CAAC,SAAS,CAACM,CAAAA,IAAKA,MAAMD,aAAa,IAClD,OAAOL;YAGX,OAAO;gBACH,GAAGA,KAAK;gBACR,WAAW;uBAAIA,MAAM,SAAS;oBAAEK;iBAAU;YAC9C;QACJ;IACJ,GAAG,EAAE;IAEL,MAAME,YAAYH,YAAY,CAACI;QAC3BP,SAASD,CAAAA,QACE;gBACH,GAAGA,KAAK;gBACR,SAAS;uBAAIA,MAAM,OAAO;oBAAEQ;iBAAQ;YACxC;IAER,GAAG,EAAE;IAEL,MAAMjB,aAAakB,QACf,IAAO;YACH,GAAGT,KAAK;YACRG;YACAI;QACJ,IACA;QAACP;KAAM;IAGX,MAAMU,YAAYD,QAAQ,IACf;YACH,MAAME,SAASC;YACf,MAAMC,eAAeC;YACrB,MAAMC,mBAAmBF,aAAa,MAAM;YAC5C,MAAMG,iBAAiB;mBAAIpB;mBAAWmB;aAAiB;YAEvDE,UAAU;gBACNN,OAAO,SAAS,CAACK;YACrB,GAAG;gBAACA,eAAe,MAAM;aAAC;YAE1B,OAAO;QACX,GACD,EAAE;IAEL,MAAME,YAAYT,QAAQ,IACf,WAAP,GAAOd,MAAAA,IAAU,CACbwB,WAAYnB,MAAM,SAAS,IAAI,EAAE,EAAG,CAAC,EAAED,QAAQ,EAAiB,GACrD,WAAP,GAAO,0CAAGA,aAGnB;QAACC,MAAM,SAAS,CAAC,MAAM;KAAC;IAE3BkB,UAAU,WAAW,GAAG;IAExB,OAAO,WAAP,GACI,oBAAC/B,WAAW,QAAQ;QAAC,OAAOI;OACvBQ,UAAAA,WAAAA,GACD,oBAACqB,cAAYA,MAAAA,WAAAA,GACT,oBAACF,WAAAA,MAAAA,WAAAA,GACG,oBAACG,iBAAeA,MACXrB,MAAM,OAAO,CAAC,GAAG,CAAC,CAACsB,QAAQC,QAAAA,WAAAA,GACxB,oBAACC,UAAQA;YAAC,KAAKD;WAAQD,WAAAA,WAAAA,GAG/B,oBAACG,kBAAgBA,MAAAA,WAAAA,GACb,oBAACf,WAAAA,OAAAA,WAAAA,GACD,oBAACgB,cAAYA;AAMrC;AAGJhC,QAAQ,WAAW,GAAG;AAEf,MAAMiC,MAAM,CAAC,EAAEC,UAAU,EAAE,GAAGC,OAAiB,GAC3C,WAAP,GACI,oBAACC,qBAAmBA;QAAC,YAAYF;qBAC7B,oBAAClC,SAAOA;QAAC,YAAYkC;QAAa,GAAGC,KAAK"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface AppContentProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
export declare const AppContainer: (({ children }: AppContentProps) => React.JSX.Element) & {
|
|
6
|
+
original: ({ children }: AppContentProps) => React.JSX.Element;
|
|
7
|
+
originalName: string;
|
|
8
|
+
displayName: string;
|
|
9
|
+
} & {
|
|
10
|
+
original: (({ children }: AppContentProps) => React.JSX.Element) & {
|
|
11
|
+
original: ({ children }: AppContentProps) => React.JSX.Element;
|
|
12
|
+
originalName: string;
|
|
13
|
+
displayName: string;
|
|
14
|
+
};
|
|
15
|
+
originalName: string;
|
|
16
|
+
displayName: string;
|
|
17
|
+
} & {
|
|
18
|
+
createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<(({ children }: AppContentProps) => React.JSX.Element) & {
|
|
19
|
+
original: ({ children }: AppContentProps) => React.JSX.Element;
|
|
20
|
+
originalName: string;
|
|
21
|
+
displayName: string;
|
|
22
|
+
}>) => (props: unknown) => React.JSX.Element;
|
|
23
|
+
};
|
package/AppContainer.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { makeDecoratable } from "@webiny/react-composition";
|
|
3
|
+
const AppContainer = makeDecoratable("AppContainer", ({ children })=>/*#__PURE__*/ react.createElement(react.Fragment, null, children));
|
|
4
|
+
export { AppContainer };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=AppContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppContainer.js","sources":["../src/AppContainer.tsx"],"sourcesContent":["import React from \"react\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\n\nexport interface AppContentProps {\n children: React.ReactNode;\n}\n\nexport const AppContainer = makeDecoratable(\"AppContainer\", ({ children }: AppContentProps) => {\n return <>{children}</>;\n});\n"],"names":["AppContainer","makeDecoratable","children"],"mappings":";;AAOO,MAAMA,eAAeC,gBAAgB,gBAAgB,CAAC,EAAEC,QAAQ,EAAmB,GAC/E,WAAP,GAAO,0CAAGA"}
|
package/README.md
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
# @webiny/app
|
|
2
|
-
[](https://www.npmjs.com/package/@webiny/app)
|
|
3
|
-
[](https://www.npmjs.com/package/@webiny/app)
|
|
4
|
-
[](https://github.com/prettier/prettier)
|
|
5
|
-
[](http://makeapullrequest.com)
|
|
6
2
|
|
|
7
|
-
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Install
|
|
12
|
-
```
|
|
13
|
-
npm install --save @webiny/app
|
|
14
|
-
```
|
|
7
|
+
📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
15
8
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
```
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { InMemoryCacheConfig } from "apollo-cache-inmemory";
|
|
2
|
+
import { InMemoryCache as BaseInMemoryCache } from "apollo-cache-inmemory";
|
|
3
|
+
import type { DocumentNode } from "graphql";
|
|
3
4
|
export declare class InMemoryCache extends BaseInMemoryCache {
|
|
4
5
|
private readonly transformPlugins;
|
|
5
6
|
constructor(config?: InMemoryCacheConfig);
|
|
@@ -1,79 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
-
|
|
18
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
19
|
-
|
|
20
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
-
|
|
22
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
23
|
-
|
|
24
|
-
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
25
|
-
|
|
26
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
|
-
|
|
28
|
-
var _apolloCacheInmemory = require("apollo-cache-inmemory");
|
|
29
|
-
|
|
30
|
-
var _plugins = require("@webiny/plugins");
|
|
31
|
-
|
|
32
|
-
var _AddQuerySelectionPlugin = require("../plugins/AddQuerySelectionPlugin");
|
|
33
|
-
|
|
34
|
-
var _ApolloLinkPlugin = require("../plugins/ApolloLinkPlugin");
|
|
35
|
-
|
|
36
|
-
var InMemoryCache = /*#__PURE__*/function (_BaseInMemoryCache) {
|
|
37
|
-
(0, _inherits2.default)(InMemoryCache, _BaseInMemoryCache);
|
|
38
|
-
|
|
39
|
-
var _super = (0, _createSuper2.default)(InMemoryCache);
|
|
40
|
-
|
|
41
|
-
function InMemoryCache(config) {
|
|
42
|
-
var _this;
|
|
43
|
-
|
|
44
|
-
(0, _classCallCheck2.default)(this, InMemoryCache);
|
|
45
|
-
_this = _super.call(this, config);
|
|
46
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "transformPlugins", void 0);
|
|
47
|
-
_this.transformPlugins = _plugins.plugins.byType(_ApolloLinkPlugin.ApolloLinkPlugin.type).filter(function (pl) {
|
|
48
|
-
return pl instanceof _AddQuerySelectionPlugin.AddQuerySelectionPlugin;
|
|
49
|
-
});
|
|
50
|
-
return _this;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
(0, _createClass2.default)(InMemoryCache, [{
|
|
54
|
-
key: "transformDocument",
|
|
55
|
-
value: function transformDocument(document) {
|
|
56
|
-
// @ts-ignore
|
|
57
|
-
var operationName = document.definitions[0].name.value;
|
|
58
|
-
|
|
59
|
-
var _iterator = (0, _createForOfIteratorHelper2.default)(this.transformPlugins),
|
|
60
|
-
_step;
|
|
61
|
-
|
|
62
|
-
try {
|
|
63
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
64
|
-
var pl = _step.value;
|
|
65
|
-
pl.addSelectionToQuery(operationName, document);
|
|
66
|
-
}
|
|
67
|
-
} catch (err) {
|
|
68
|
-
_iterator.e(err);
|
|
69
|
-
} finally {
|
|
70
|
-
_iterator.f();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return (0, _get2.default)((0, _getPrototypeOf2.default)(InMemoryCache.prototype), "transformDocument", this).call(this, document);
|
|
1
|
+
import { InMemoryCache } from "apollo-cache-inmemory";
|
|
2
|
+
import { plugins } from "@webiny/plugins";
|
|
3
|
+
import { AddQuerySelectionPlugin } from "../plugins/AddQuerySelectionPlugin.js";
|
|
4
|
+
import { ApolloLinkPlugin } from "../plugins/ApolloLinkPlugin.js";
|
|
5
|
+
class InMemoryCache_InMemoryCache extends InMemoryCache {
|
|
6
|
+
constructor(config){
|
|
7
|
+
super(config);
|
|
8
|
+
this.transformPlugins = plugins.byType(ApolloLinkPlugin.type).filter((pl)=>pl instanceof AddQuerySelectionPlugin);
|
|
9
|
+
}
|
|
10
|
+
transformDocument(document) {
|
|
11
|
+
const operationName = document.definitions[0].name.value;
|
|
12
|
+
for (const pl of this.transformPlugins)pl.addSelectionToQuery(operationName, document);
|
|
13
|
+
return super.transformDocument(document);
|
|
74
14
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}(_apolloCacheInmemory.InMemoryCache);
|
|
15
|
+
}
|
|
16
|
+
export { InMemoryCache_InMemoryCache as InMemoryCache };
|
|
78
17
|
|
|
79
|
-
|
|
18
|
+
//# sourceMappingURL=InMemoryCache.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"apollo-client/InMemoryCache.js","sources":["../../src/apollo-client/InMemoryCache.ts"],"sourcesContent":["import type { InMemoryCacheConfig } from \"apollo-cache-inmemory\";\nimport { InMemoryCache as BaseInMemoryCache } from \"apollo-cache-inmemory\";\nimport type { DocumentNode } from \"graphql\";\nimport { plugins } from \"@webiny/plugins\";\nimport { AddQuerySelectionPlugin } from \"../plugins/AddQuerySelectionPlugin.js\";\nimport { ApolloLinkPlugin } from \"../plugins/ApolloLinkPlugin.js\";\n\nexport class InMemoryCache extends BaseInMemoryCache {\n private readonly transformPlugins: AddQuerySelectionPlugin[];\n\n constructor(config?: InMemoryCacheConfig) {\n super(config);\n\n this.transformPlugins = plugins\n .byType<AddQuerySelectionPlugin>(ApolloLinkPlugin.type)\n .filter(pl => pl instanceof AddQuerySelectionPlugin);\n }\n\n public override transformDocument(document: DocumentNode): DocumentNode {\n // @ts-expect-error\n const operationName = document.definitions[0].name.value;\n\n for (const pl of this.transformPlugins) {\n pl.addSelectionToQuery(operationName, document);\n }\n\n return super.transformDocument(document);\n }\n}\n"],"names":["InMemoryCache","BaseInMemoryCache","config","plugins","ApolloLinkPlugin","pl","AddQuerySelectionPlugin","document","operationName"],"mappings":";;;;AAOO,MAAMA,oCAAsBC;IAG/B,YAAYC,MAA4B,CAAE;QACtC,KAAK,CAACA;QAEN,IAAI,CAAC,gBAAgB,GAAGC,QAAAA,MACb,CAA0BC,iBAAiB,IAAI,EACrD,MAAM,CAACC,CAAAA,KAAMA,cAAcC;IACpC;IAEgB,kBAAkBC,QAAsB,EAAgB;QAEpE,MAAMC,gBAAgBD,SAAS,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK;QAExD,KAAK,MAAMF,MAAM,IAAI,CAAC,gBAAgB,CAClCA,GAAG,mBAAmB,CAACG,eAAeD;QAG1C,OAAO,KAAK,CAAC,kBAAkBA;IACnC;AACJ"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IdValue } from "apollo-utilities";
|
|
2
|
+
import type { ReadStoreContext, FragmentMatcherInterface, IntrospectionResultData } from "apollo-cache-inmemory";
|
|
3
|
+
export declare class IntrospectionFragmentMatcher implements FragmentMatcherInterface {
|
|
4
|
+
private readonly isReady;
|
|
5
|
+
private readonly possibleTypesMap;
|
|
6
|
+
constructor(options?: {
|
|
7
|
+
introspectionQueryResultData?: IntrospectionResultData;
|
|
8
|
+
});
|
|
9
|
+
match(idValue: IdValue, typeCondition: string, context: ReadStoreContext): boolean;
|
|
10
|
+
private parseIntrospectionResult;
|
|
11
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { invariant } from "ts-invariant";
|
|
2
|
+
class IntrospectionFragmentMatcher {
|
|
3
|
+
constructor(options){
|
|
4
|
+
this.possibleTypesMap = {};
|
|
5
|
+
if (options && options.introspectionQueryResultData) {
|
|
6
|
+
this.possibleTypesMap = this.parseIntrospectionResult(options.introspectionQueryResultData);
|
|
7
|
+
this.isReady = true;
|
|
8
|
+
} else this.isReady = false;
|
|
9
|
+
this.match = this.match.bind(this);
|
|
10
|
+
}
|
|
11
|
+
match(idValue, typeCondition, context) {
|
|
12
|
+
invariant(this.isReady, "FragmentMatcher.match() was called before FragmentMatcher.init()");
|
|
13
|
+
const obj = context.store.get(idValue.id);
|
|
14
|
+
const isRootQuery = "ROOT_QUERY" === idValue.id;
|
|
15
|
+
if (!obj) return isRootQuery;
|
|
16
|
+
const { __typename = isRootQuery && "Query" } = obj;
|
|
17
|
+
invariant(__typename, `Cannot match fragment because __typename property is missing: ${JSON.stringify(obj)}`);
|
|
18
|
+
if (__typename === typeCondition) return true;
|
|
19
|
+
const implementingTypes = this.possibleTypesMap[typeCondition];
|
|
20
|
+
if (__typename && implementingTypes && implementingTypes.indexOf(__typename) > -1) return true;
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
parseIntrospectionResult(introspectionResultData) {
|
|
24
|
+
const typeMap = {};
|
|
25
|
+
introspectionResultData.__schema.types.forEach((type)=>{
|
|
26
|
+
if ("UNION" === type.kind || "INTERFACE" === type.kind) typeMap[type.name] = type.possibleTypes.map((implementingType)=>implementingType.name);
|
|
27
|
+
});
|
|
28
|
+
return typeMap;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export { IntrospectionFragmentMatcher };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=IntrospectionFragmentMatcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apollo-client/IntrospectionFragmentMatcher.js","sources":["../../src/apollo-client/IntrospectionFragmentMatcher.ts"],"sourcesContent":["import type { IdValue } from \"apollo-utilities\";\nimport { invariant } from \"ts-invariant\";\n\nimport type {\n ReadStoreContext,\n FragmentMatcherInterface,\n PossibleTypesMap,\n IntrospectionResultData\n} from \"apollo-cache-inmemory\";\n\nexport class IntrospectionFragmentMatcher implements FragmentMatcherInterface {\n private readonly isReady: boolean;\n private readonly possibleTypesMap: PossibleTypesMap = {};\n\n constructor(options?: { introspectionQueryResultData?: IntrospectionResultData }) {\n if (options && options.introspectionQueryResultData) {\n this.possibleTypesMap = this.parseIntrospectionResult(\n options.introspectionQueryResultData\n );\n this.isReady = true;\n } else {\n this.isReady = false;\n }\n\n this.match = this.match.bind(this);\n }\n\n public match(idValue: IdValue, typeCondition: string, context: ReadStoreContext) {\n invariant(this.isReady, \"FragmentMatcher.match() was called before FragmentMatcher.init()\");\n\n const obj = context.store.get(idValue.id);\n const isRootQuery = idValue.id === \"ROOT_QUERY\";\n\n if (!obj) {\n // https://github.com/apollographql/apollo-client/pull/4620\n return isRootQuery;\n }\n\n const { __typename = isRootQuery && \"Query\" } = obj;\n\n invariant(\n __typename,\n `Cannot match fragment because __typename property is missing: ${JSON.stringify(obj)}`\n );\n\n if (__typename === typeCondition) {\n return true;\n }\n\n const implementingTypes = this.possibleTypesMap[typeCondition];\n if (__typename && implementingTypes && implementingTypes.indexOf(__typename) > -1) {\n return true;\n }\n\n return false;\n }\n\n private parseIntrospectionResult(\n introspectionResultData: IntrospectionResultData\n ): PossibleTypesMap {\n const typeMap: PossibleTypesMap = {};\n introspectionResultData.__schema.types.forEach(type => {\n if (type.kind === \"UNION\" || type.kind === \"INTERFACE\") {\n typeMap[type.name] = type.possibleTypes.map(\n implementingType => implementingType.name\n );\n }\n });\n return typeMap;\n }\n}\n"],"names":["IntrospectionFragmentMatcher","options","idValue","typeCondition","context","invariant","obj","isRootQuery","__typename","JSON","implementingTypes","introspectionResultData","typeMap","type","implementingType"],"mappings":";AAUO,MAAMA;IAIT,YAAYC,OAAoE,CAAE;aAFjE,gBAAgB,GAAqB,CAAC;QAGnD,IAAIA,WAAWA,QAAQ,4BAA4B,EAAE;YACjD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,wBAAwB,CACjDA,QAAQ,4BAA4B;YAExC,IAAI,CAAC,OAAO,GAAG;QACnB,OACI,IAAI,CAAC,OAAO,GAAG;QAGnB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI;IACrC;IAEO,MAAMC,OAAgB,EAAEC,aAAqB,EAAEC,OAAyB,EAAE;QAC7EC,UAAU,IAAI,CAAC,OAAO,EAAE;QAExB,MAAMC,MAAMF,QAAQ,KAAK,CAAC,GAAG,CAACF,QAAQ,EAAE;QACxC,MAAMK,cAAcL,AAAe,iBAAfA,QAAQ,EAAE;QAE9B,IAAI,CAACI,KAED,OAAOC;QAGX,MAAM,EAAEC,aAAaD,eAAe,OAAO,EAAE,GAAGD;QAEhDD,UACIG,YACA,CAAC,8DAA8D,EAAEC,KAAK,SAAS,CAACH,MAAM;QAG1F,IAAIE,eAAeL,eACf,OAAO;QAGX,MAAMO,oBAAoB,IAAI,CAAC,gBAAgB,CAACP,cAAc;QAC9D,IAAIK,cAAcE,qBAAqBA,kBAAkB,OAAO,CAACF,cAAc,IAC3E,OAAO;QAGX,OAAO;IACX;IAEQ,yBACJG,uBAAgD,EAChC;QAChB,MAAMC,UAA4B,CAAC;QACnCD,wBAAwB,QAAQ,CAAC,KAAK,CAAC,OAAO,CAACE,CAAAA;YAC3C,IAAIA,AAAc,YAAdA,KAAK,IAAI,IAAgBA,AAAc,gBAAdA,KAAK,IAAI,EAClCD,OAAO,CAACC,KAAK,IAAI,CAAC,GAAGA,KAAK,aAAa,CAAC,GAAG,CACvCC,CAAAA,mBAAoBA,iBAAiB,IAAI;QAGrD;QACA,OAAOF;IACX;AACJ"}
|
package/components/Image.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export declare const Image: React.FC<ImageProps>;
|
|
1
|
+
import type { ImageProps } from "../types.js";
|
|
2
|
+
export declare const Image: ({ preset: presetName, ...props }: ImageProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
package/components/Image.js
CHANGED
|
@@ -1,43 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _invariant = _interopRequireDefault(require("invariant"));
|
|
15
|
-
|
|
16
|
-
var _plugins = require("@webiny/plugins");
|
|
17
|
-
|
|
18
|
-
var _excluded = ["preset"];
|
|
19
|
-
|
|
20
|
-
var Image = function Image(_ref) {
|
|
21
|
-
var presetName = _ref.preset,
|
|
22
|
-
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
23
|
-
|
|
24
|
-
var plugin = _plugins.plugins.byName("image-component");
|
|
25
|
-
|
|
26
|
-
if (!plugin) {
|
|
27
|
-
throw new Error("Image component plugin (type \"image-component\") not defined.");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (presetName) {
|
|
31
|
-
var preset = (0, _get2.default)(plugin, "presets.".concat(presetName));
|
|
32
|
-
(0, _invariant.default)(preset, "Transform preset \"".concat(presetName, "\" not found."));
|
|
33
|
-
props.transform = preset;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (props.transform) {
|
|
37
|
-
props.src = plugin.getImageSrc(props);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return plugin.render(props);
|
|
1
|
+
import invariant from "invariant";
|
|
2
|
+
import { plugins } from "@webiny/plugins";
|
|
3
|
+
import get from "lodash/get.js";
|
|
4
|
+
const Image = ({ preset: presetName, ...props })=>{
|
|
5
|
+
const plugin = plugins.byName("image-component");
|
|
6
|
+
if (!plugin) throw new Error('Image component plugin (type "image-component") not defined.');
|
|
7
|
+
if (presetName) {
|
|
8
|
+
const preset = get(plugin, `presets.${presetName}`);
|
|
9
|
+
invariant(preset, `Transform preset "${presetName}" not found.`);
|
|
10
|
+
props.transform = preset;
|
|
11
|
+
}
|
|
12
|
+
if (props.transform) props.src = plugin.getImageSrc(props);
|
|
13
|
+
return plugin.render(props);
|
|
41
14
|
};
|
|
15
|
+
export { Image };
|
|
42
16
|
|
|
43
|
-
|
|
17
|
+
//# sourceMappingURL=Image.js.map
|
package/components/Image.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"components/Image.js","sources":["../../src/components/Image.tsx"],"sourcesContent":["import invariant from \"invariant\";\nimport { plugins } from \"@webiny/plugins\";\nimport get from \"lodash/get.js\";\nimport type { ImageComponentPlugin, ImageProps } from \"~/types.js\";\n\nexport const Image = ({ preset: presetName, ...props }: ImageProps) => {\n const plugin = plugins.byName<ImageComponentPlugin>(\"image-component\");\n if (!plugin) {\n throw new Error(`Image component plugin (type \"image-component\") not defined.`);\n }\n\n if (presetName) {\n const preset = get(plugin, `presets.${presetName}`);\n invariant(preset, `Transform preset \"${presetName}\" not found.`);\n props.transform = preset;\n }\n\n if (props.transform) {\n props.src = plugin.getImageSrc(props);\n }\n\n return plugin.render(props);\n};\n"],"names":["Image","presetName","props","plugin","plugins","Error","preset","get","invariant"],"mappings":";;;AAKO,MAAMA,QAAQ,CAAC,EAAE,QAAQC,UAAU,EAAE,GAAGC,OAAmB;IAC9D,MAAMC,SAASC,QAAQ,MAAM,CAAuB;IACpD,IAAI,CAACD,QACD,MAAM,IAAIE,MAAM;IAGpB,IAAIJ,YAAY;QACZ,MAAMK,SAASC,IAAIJ,QAAQ,CAAC,QAAQ,EAAEF,YAAY;QAClDO,UAAUF,QAAQ,CAAC,kBAAkB,EAAEL,WAAW,YAAY,CAAC;QAC/DC,MAAM,SAAS,GAAGI;IACtB;IAEA,IAAIJ,MAAM,SAAS,EACfA,MAAM,GAAG,GAAGC,OAAO,WAAW,CAACD;IAGnC,OAAOC,OAAO,MAAM,CAACD;AACzB"}
|
package/components/index.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { Image } from "./Image";
|
|
2
|
-
export { Routes } from "./Routes";
|
|
1
|
+
export { Image } from "./Image.js";
|
package/components/index.js
CHANGED
|
@@ -1,21 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "Image", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _Image.Image;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "Routes", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _Routes.Routes;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
var _Image = require("./Image");
|
|
20
|
-
|
|
21
|
-
var _Routes = require("./Routes");
|
|
1
|
+
export { Image } from "./Image.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Route as BaseRoute } from "../../router.js";
|
|
3
|
+
export interface RouteProps {
|
|
4
|
+
route: BaseRoute<any>;
|
|
5
|
+
element: React.ReactElement;
|
|
6
|
+
remove?: boolean;
|
|
7
|
+
before?: string;
|
|
8
|
+
after?: string;
|
|
9
|
+
}
|
|
10
|
+
export type RouteConfig = Pick<RouteProps, "route" | "element">;
|
|
11
|
+
export declare const Route: (({ route, element, remove, before, after }: RouteProps) => React.JSX.Element) & {
|
|
12
|
+
original: ({ route, element, remove, before, after }: RouteProps) => React.JSX.Element;
|
|
13
|
+
originalName: string;
|
|
14
|
+
displayName: string;
|
|
15
|
+
} & {
|
|
16
|
+
original: (({ route, element, remove, before, after }: RouteProps) => React.JSX.Element) & {
|
|
17
|
+
original: ({ route, element, remove, before, after }: RouteProps) => React.JSX.Element;
|
|
18
|
+
originalName: string;
|
|
19
|
+
displayName: string;
|
|
20
|
+
};
|
|
21
|
+
originalName: string;
|
|
22
|
+
displayName: string;
|
|
23
|
+
} & {
|
|
24
|
+
createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<(({ route, element, remove, before, after }: RouteProps) => React.JSX.Element) & {
|
|
25
|
+
original: ({ route, element, remove, before, after }: RouteProps) => React.JSX.Element;
|
|
26
|
+
originalName: string;
|
|
27
|
+
displayName: string;
|
|
28
|
+
}>) => (props: unknown) => React.JSX.Element;
|
|
29
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { makeDecoratable } from "@webiny/react-composition";
|
|
3
|
+
import { Property, useIdGenerator } from "@webiny/react-properties";
|
|
4
|
+
const Route = makeDecoratable("Route", ({ route, element, remove, before, after })=>{
|
|
5
|
+
const name = route.name;
|
|
6
|
+
const getId = useIdGenerator("Route");
|
|
7
|
+
const placeAfter = void 0 !== after ? getId(after) : void 0;
|
|
8
|
+
const placeBefore = void 0 !== before ? getId(before) : void 0;
|
|
9
|
+
return /*#__PURE__*/ react.createElement(Property, {
|
|
10
|
+
id: getId(name),
|
|
11
|
+
name: "routes",
|
|
12
|
+
remove: remove,
|
|
13
|
+
array: true,
|
|
14
|
+
before: placeBefore,
|
|
15
|
+
after: placeAfter
|
|
16
|
+
}, /*#__PURE__*/ react.createElement(Property, {
|
|
17
|
+
id: getId(name, "route"),
|
|
18
|
+
name: "route",
|
|
19
|
+
value: route
|
|
20
|
+
}), /*#__PURE__*/ react.createElement(Property, {
|
|
21
|
+
id: getId(name, "element"),
|
|
22
|
+
name: "element",
|
|
23
|
+
value: element
|
|
24
|
+
}));
|
|
25
|
+
});
|
|
26
|
+
export { Route };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=Route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config/RouterConfig/Route.js","sources":["../../../src/config/RouterConfig/Route.tsx"],"sourcesContent":["import React from \"react\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport { Property, useIdGenerator } from \"@webiny/react-properties\";\nimport type { Route as BaseRoute } from \"~/router.js\";\n\nexport interface RouteProps {\n route: BaseRoute<any>;\n element: React.ReactElement;\n remove?: boolean;\n before?: string;\n after?: string;\n}\n\nexport type RouteConfig = Pick<RouteProps, \"route\" | \"element\">;\n\nexport const Route = makeDecoratable(\n \"Route\",\n ({ route, element, remove, before, after }: RouteProps) => {\n const name = route.name;\n\n const getId = useIdGenerator(\"Route\");\n\n const placeAfter = after !== undefined ? getId(after) : undefined;\n const placeBefore = before !== undefined ? getId(before) : undefined;\n\n return (\n <Property\n id={getId(name)}\n name={\"routes\"}\n remove={remove}\n array={true}\n before={placeBefore}\n after={placeAfter}\n >\n <Property id={getId(name, \"route\")} name={\"route\"} value={route} />\n <Property id={getId(name, \"element\")} name={\"element\"} value={element} />\n </Property>\n );\n }\n);\n"],"names":["Route","makeDecoratable","route","element","remove","before","after","name","getId","useIdGenerator","placeAfter","undefined","placeBefore","Property"],"mappings":";;;AAeO,MAAMA,QAAQC,gBACjB,SACA,CAAC,EAAEC,KAAK,EAAEC,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAc;IAClD,MAAMC,OAAOL,MAAM,IAAI;IAEvB,MAAMM,QAAQC,eAAe;IAE7B,MAAMC,aAAaJ,AAAUK,WAAVL,QAAsBE,MAAMF,SAASK;IACxD,MAAMC,cAAcP,AAAWM,WAAXN,SAAuBG,MAAMH,UAAUM;IAE3D,OAAO,WAAP,GACI,oBAACE,UAAQA;QACL,IAAIL,MAAMD;QACV,MAAM;QACN,QAAQH;QACR,OAAO;QACP,QAAQQ;QACR,OAAOF;qBAEP,oBAACG,UAAQA;QAAC,IAAIL,MAAMD,MAAM;QAAU,MAAM;QAAS,OAAOL;sBAC1D,oBAACW,UAAQA;QAAC,IAAIL,MAAMD,MAAM;QAAY,MAAM;QAAW,OAAOJ;;AAG1E"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type RouteConfig } from "./RouterConfig/Route.js";
|
|
2
|
+
export declare const RouterWithConfig: (({ onProperties, children }: import("@webiny/react-properties").WithConfigProps) => React.JSX.Element) & {
|
|
3
|
+
displayName: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const useRouterConfig: () => {
|
|
6
|
+
routes: RouteConfig[];
|
|
7
|
+
};
|
|
8
|
+
export declare const RouterConfig: (({ priority, children }: import("@webiny/react-properties").ConfigProps) => React.JSX.Element) & {
|
|
9
|
+
Route: (({ route, element, remove, before, after }: import("./RouterConfig/Route.js").RouteProps) => import("react").JSX.Element) & {
|
|
10
|
+
original: ({ route, element, remove, before, after }: import("./RouterConfig/Route.js").RouteProps) => import("react").JSX.Element;
|
|
11
|
+
originalName: string;
|
|
12
|
+
displayName: string;
|
|
13
|
+
} & {
|
|
14
|
+
original: (({ route, element, remove, before, after }: import("./RouterConfig/Route.js").RouteProps) => import("react").JSX.Element) & {
|
|
15
|
+
original: ({ route, element, remove, before, after }: import("./RouterConfig/Route.js").RouteProps) => import("react").JSX.Element;
|
|
16
|
+
originalName: string;
|
|
17
|
+
displayName: string;
|
|
18
|
+
};
|
|
19
|
+
originalName: string;
|
|
20
|
+
displayName: string;
|
|
21
|
+
} & {
|
|
22
|
+
createDecorator: (decorator: import("@webiny/react-composition/types.js").ComponentDecorator<(({ route, element, remove, before, after }: import("./RouterConfig/Route.js").RouteProps) => import("react").JSX.Element) & {
|
|
23
|
+
original: ({ route, element, remove, before, after }: import("./RouterConfig/Route.js").RouteProps) => import("react").JSX.Element;
|
|
24
|
+
originalName: string;
|
|
25
|
+
displayName: string;
|
|
26
|
+
}>) => (props: unknown) => React.JSX.Element;
|
|
27
|
+
};
|
|
28
|
+
useRouterConfig: () => {
|
|
29
|
+
routes: RouteConfig[];
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createConfigurableComponent } from "@webiny/react-properties";
|
|
2
|
+
import { Route } from "./RouterConfig/Route.js";
|
|
3
|
+
const base = createConfigurableComponent("RouterConfig");
|
|
4
|
+
const RouterWithConfig = Object.assign(base.WithConfig, {
|
|
5
|
+
displayName: "RouterWithConfig"
|
|
6
|
+
});
|
|
7
|
+
const useRouterConfig = ()=>{
|
|
8
|
+
const baseConfig = base.useConfig();
|
|
9
|
+
return {
|
|
10
|
+
routes: baseConfig.routes ?? []
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const RouterConfig = Object.assign(base.Config, {
|
|
14
|
+
Route: Route,
|
|
15
|
+
useRouterConfig: useRouterConfig
|
|
16
|
+
});
|
|
17
|
+
export { RouterConfig, RouterWithConfig, useRouterConfig };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=RouterConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config/RouterConfig.js","sources":["../../src/config/RouterConfig.tsx"],"sourcesContent":["import { createConfigurableComponent } from \"@webiny/react-properties\";\nimport { Route, type RouteConfig } from \"./RouterConfig/Route.js\";\n\nconst base = createConfigurableComponent<RouterConfig>(\"RouterConfig\");\n\nexport const RouterWithConfig = Object.assign(base.WithConfig, {\n displayName: \"RouterWithConfig\"\n});\n\ninterface RouterConfig {\n routes: RouteConfig[];\n}\n\nexport const useRouterConfig = () => {\n const baseConfig = base.useConfig();\n\n return {\n routes: baseConfig.routes ?? []\n };\n};\n\nexport const RouterConfig = Object.assign(base.Config, {\n Route,\n useRouterConfig\n});\n"],"names":["base","createConfigurableComponent","RouterWithConfig","Object","useRouterConfig","baseConfig","RouterConfig","Route"],"mappings":";;AAGA,MAAMA,OAAOC,4BAA0C;AAEhD,MAAMC,mBAAmBC,OAAO,MAAM,CAACH,KAAK,UAAU,EAAE;IAC3D,aAAa;AACjB;AAMO,MAAMI,kBAAkB;IAC3B,MAAMC,aAAaL,KAAK,SAAS;IAEjC,OAAO;QACH,QAAQK,WAAW,MAAM,IAAI,EAAE;IACnC;AACJ;AAEO,MAAMC,eAAeH,OAAO,MAAM,CAACH,KAAK,MAAM,EAAE;IACnDO,OAAKA;IACLH,iBAAAA;AACJ"}
|
package/config.d.ts
CHANGED