@webiny/app 6.3.0-beta.4 → 6.4.0-beta.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.js +70 -77
- package/App.js.map +1 -1
- package/AppContainer.js +3 -6
- package/AppContainer.js.map +1 -1
- package/apollo-client/InMemoryCache.js +11 -13
- package/apollo-client/InMemoryCache.js.map +1 -1
- package/apollo-client/IntrospectionFragmentMatcher.js +26 -38
- package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -1
- package/components/Image.js +11 -17
- package/components/Image.js.map +1 -1
- package/components/index.js +0 -2
- package/config/RouterConfig/Route.js +23 -28
- package/config/RouterConfig/Route.js.map +1 -1
- package/config/RouterConfig.js +11 -10
- package/config/RouterConfig.js.map +1 -1
- package/config.js +19 -20
- package/config.js.map +1 -1
- package/contexts/Ui/index.js +26 -28
- package/contexts/Ui/index.js.map +1 -1
- package/core/Plugin.js +7 -9
- package/core/Plugin.js.map +1 -1
- package/core/Plugins.js +15 -34
- package/core/Plugins.js.map +1 -1
- package/core/Provider.js +5 -13
- package/core/Provider.js.map +1 -1
- package/core/createProvider.js +3 -6
- package/core/createProvider.js.map +1 -1
- package/core/createProviderPlugin.js +8 -13
- package/core/createProviderPlugin.js.map +1 -1
- package/errors/AuthenticationErrorEvent.js +8 -5
- package/errors/AuthenticationErrorEvent.js.map +1 -1
- package/errors/NetworkErrorEvent.js +8 -5
- package/errors/NetworkErrorEvent.js.map +1 -1
- package/errors/abstractions.js +3 -2
- package/errors/abstractions.js.map +1 -1
- package/errors/index.js +1 -4
- package/exports/admin/env-config.js +0 -2
- package/exports/admin/graphql-client.js +0 -2
- package/exports/admin/local-storage.js +0 -2
- package/exports/admin/router.js +0 -2
- package/exports/admin/security.js +0 -2
- package/exports/admin.js +0 -2
- package/features/envConfig/EnvConfig.js +12 -13
- package/features/envConfig/EnvConfig.js.map +1 -1
- package/features/envConfig/abstractions.js +2 -1
- package/features/envConfig/abstractions.js.map +1 -1
- package/features/envConfig/feature.js +9 -8
- package/features/envConfig/feature.js.map +1 -1
- package/features/envConfig/index.js +0 -2
- package/features/eventPublisher/EventPublisher.js +13 -21
- package/features/eventPublisher/EventPublisher.js.map +1 -1
- package/features/eventPublisher/abstractions.js +7 -9
- package/features/eventPublisher/abstractions.js.map +1 -1
- package/features/eventPublisher/feature.js +13 -12
- package/features/eventPublisher/feature.js.map +1 -1
- package/features/eventPublisher/index.js +1 -3
- package/features/graphqlClient/AuthenticationErrorPublishing.js +26 -26
- package/features/graphqlClient/AuthenticationErrorPublishing.js.map +1 -1
- package/features/graphqlClient/BatchingGraphQLClient.js +104 -149
- package/features/graphqlClient/BatchingGraphQLClient.js.map +1 -1
- package/features/graphqlClient/FetchGraphQLClient.js +41 -48
- package/features/graphqlClient/FetchGraphQLClient.js.map +1 -1
- package/features/graphqlClient/NetworkErrorPublishing.js +35 -42
- package/features/graphqlClient/NetworkErrorPublishing.js.map +1 -1
- package/features/graphqlClient/RequestValue.js +42 -41
- package/features/graphqlClient/RequestValue.js.map +1 -1
- package/features/graphqlClient/RetryGraphQLClient.js +36 -45
- package/features/graphqlClient/RetryGraphQLClient.js.map +1 -1
- package/features/graphqlClient/__tests__/GraphQLClient.test.js +383 -356
- package/features/graphqlClient/__tests__/GraphQLClient.test.js.map +1 -1
- package/features/graphqlClient/abstractions.js +2 -1
- package/features/graphqlClient/abstractions.js.map +1 -1
- package/features/graphqlClient/feature.js +14 -20
- package/features/graphqlClient/feature.js.map +1 -1
- package/features/graphqlClient/index.js +0 -2
- package/features/graphqlClient/types.js +0 -3
- package/features/localStorage/BrowserLocalStorageGateway.js +56 -63
- package/features/localStorage/BrowserLocalStorageGateway.js.map +1 -1
- package/features/localStorage/LocalStorage.js +27 -24
- package/features/localStorage/LocalStorage.js.map +1 -1
- package/features/localStorage/LocalStorageRepository.js +75 -88
- package/features/localStorage/LocalStorageRepository.js.map +1 -1
- package/features/localStorage/abstractions.js +5 -16
- package/features/localStorage/abstractions.js.map +1 -1
- package/features/localStorage/feature.js +17 -28
- package/features/localStorage/feature.js.map +1 -1
- package/features/localStorage/index.js +1 -3
- package/features/mainGraphQLClient/MainGraphQLClient.js +18 -14
- package/features/mainGraphQLClient/MainGraphQLClient.js.map +1 -1
- package/features/mainGraphQLClient/abstractions.js +2 -1
- package/features/mainGraphQLClient/abstractions.js.map +1 -1
- package/features/mainGraphQLClient/feature.js +11 -10
- package/features/mainGraphQLClient/feature.js.map +1 -1
- package/features/mainGraphQLClient/index.js +0 -2
- package/features/router/HistoryRouterGateway.js +75 -105
- package/features/router/HistoryRouterGateway.js.map +1 -1
- package/features/router/HistoryRouterGateway.test.js +184 -193
- package/features/router/HistoryRouterGateway.test.js.map +1 -1
- package/features/router/Route.js +38 -54
- package/features/router/Route.js.map +1 -1
- package/features/router/RouteUrl.js +84 -217
- package/features/router/RouteUrl.js.map +1 -1
- package/features/router/Router.js +67 -124
- package/features/router/Router.js.map +1 -1
- package/features/router/RouterPresenter.js +44 -49
- package/features/router/RouterPresenter.js.map +1 -1
- package/features/router/RouterRepository.js +103 -111
- package/features/router/RouterRepository.js.map +1 -1
- package/features/router/RouterRepository.test.js +119 -150
- package/features/router/RouterRepository.test.js.map +1 -1
- package/features/router/abstractions.js +4 -14
- package/features/router/abstractions.js.map +1 -1
- package/features/router/feature.js +13 -12
- package/features/router/feature.js.map +1 -1
- package/features/router/index.js +1 -3
- package/helpers/InterfaceGenerator/date.js +0 -3
- package/helpers/InterfaceGenerator/id.js +0 -3
- package/helpers/InterfaceGenerator/identity.js +0 -3
- package/helpers/InterfaceGenerator/index.js +0 -3
- package/helpers/InterfaceGenerator/numeric.js +0 -3
- package/helpers/InterfaceGenerator/truthful.js +0 -3
- package/hooks/useAutocomplete/index.js +0 -2
- package/hooks/useAutocomplete/useAutocomplete.js +12 -15
- package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
- package/hooks/useDataList/functions/getData.js +2 -1
- package/hooks/useDataList/functions/getData.js.map +1 -1
- package/hooks/useDataList/functions/getError.js +2 -1
- package/hooks/useDataList/functions/getError.js.map +1 -1
- package/hooks/useDataList/functions/getMeta.js +2 -1
- package/hooks/useDataList/functions/getMeta.js.map +1 -1
- package/hooks/useDataList/functions/index.js +0 -2
- package/hooks/useDataList/functions/searchDataByKey.js +9 -14
- package/hooks/useDataList/functions/searchDataByKey.js.map +1 -1
- package/hooks/useDataList/index.js +0 -2
- package/hooks/useDataList/useDataList.js +131 -152
- package/hooks/useDataList/useDataList.js.map +1 -1
- package/hooks/useDataList/utils/index.js +0 -2
- package/hooks/useDataList/utils/prepareLoadListParams.js +25 -34
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
- package/hooks/useHandler.js +12 -16
- package/hooks/useHandler.js.map +1 -1
- package/hooks/useHandlers.js +18 -20
- package/hooks/useHandlers.js.map +1 -1
- package/hooks/useRegisterLegacyPlugin.js +7 -6
- package/hooks/useRegisterLegacyPlugin.js.map +1 -1
- package/hooks/useUi.js +2 -3
- package/hooks/useUi.js.map +1 -1
- package/i18n/i18n.js +8 -4
- package/i18n/i18n.js.map +1 -1
- package/i18n/index.js +0 -2
- package/index.js +6 -11
- package/package.json +13 -13
- package/plugins/AddQuerySelectionPlugin.js +36 -61
- package/plugins/AddQuerySelectionPlugin.js.map +1 -1
- package/plugins/ApolloCacheObjectIdPlugin.js +12 -11
- package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -1
- package/plugins/ApolloDynamicLink.js +20 -22
- package/plugins/ApolloDynamicLink.js.map +1 -1
- package/plugins/ApolloLinkPlugin.js +16 -15
- package/plugins/ApolloLinkPlugin.js.map +1 -1
- package/plugins/ConsoleLinkPlugin.js +19 -21
- package/plugins/ConsoleLinkPlugin.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +39 -45
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js +18 -22
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js +21 -29
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +6 -15
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/Typography.js +9 -14
- package/plugins/NetworkErrorLinkPlugin/Typography.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js +19 -0
- package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +11 -18
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin.js +41 -58
- package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
- package/plugins/OmitTypenameLinkPlugin.js +9 -14
- package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
- package/plugins/TenantHeaderLinkPlugin.js +23 -32
- package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
- package/plugins/components/Image.js +8 -15
- package/plugins/components/Image.js.map +1 -1
- package/plugins/image.js +94 -133
- package/plugins/image.js.map +1 -1
- package/plugins/index.js +35 -59
- package/plugins/index.js.map +1 -1
- package/presentation/envConfig/useEnvConfig.js +4 -8
- package/presentation/envConfig/useEnvConfig.js.map +1 -1
- package/presentation/localStorage/index.js +0 -2
- package/presentation/localStorage/useLocalStorage.js +10 -16
- package/presentation/localStorage/useLocalStorage.js.map +1 -1
- package/presentation/localStorage/useLocalStorageValue.js +15 -13
- package/presentation/localStorage/useLocalStorageValue.js.map +1 -1
- package/presentation/localStorage/useLocalStorageValues.js +23 -30
- package/presentation/localStorage/useLocalStorageValues.js.map +1 -1
- package/presentation/router/RouteElementRegistry.js +22 -25
- package/presentation/router/RouteElementRegistry.js.map +1 -1
- package/presentation/router/abstractions.js +2 -1
- package/presentation/router/abstractions.js.map +1 -1
- package/presentation/router/components/Redirect.js +8 -10
- package/presentation/router/components/Redirect.js.map +1 -1
- package/presentation/router/components/RouteContent.js +14 -17
- package/presentation/router/components/RouteContent.js.map +1 -1
- package/presentation/router/components/RouteLink.js +11 -16
- package/presentation/router/components/RouteLink.js.map +1 -1
- package/presentation/router/components/SimpleLink.js +18 -24
- package/presentation/router/components/SimpleLink.js.map +1 -1
- package/presentation/router/hooks/useRoute.js +15 -23
- package/presentation/router/hooks/useRoute.js.map +1 -1
- package/presentation/router/hooks/useRouter.js +22 -23
- package/presentation/router/hooks/useRouter.js.map +1 -1
- package/presentation/router/index.js +0 -2
- package/presentation/router/types.js +0 -3
- package/react-butterfiles/Files.js +148 -217
- package/react-butterfiles/Files.js.map +1 -1
- package/react-butterfiles/index.js +2 -1
- package/react-butterfiles/index.js.map +1 -1
- package/react-butterfiles/utils/generateId.js +2 -3
- package/react-butterfiles/utils/generateId.js.map +1 -1
- package/react-butterfiles/utils/readFileContent.js +9 -13
- package/react-butterfiles/utils/readFileContent.js.map +1 -1
- package/renderApp.js +7 -6
- package/renderApp.js.map +1 -1
- package/router.js +0 -3
- package/rslib-runtime.js +14 -0
- package/rslib-runtime.js.map +1 -0
- package/shared/di/DiContainerProvider.js +8 -12
- package/shared/di/DiContainerProvider.js.map +1 -1
- package/shared/di/createFeature.js +7 -8
- package/shared/di/createFeature.js.map +1 -1
- package/shared/di/useFeature.js +7 -3
- package/shared/di/useFeature.js.map +1 -1
- package/static/svg/close_24px.33adaadc.svg +1 -0
- package/types.js +0 -3
- package/utils/createGenericContext.js +17 -21
- package/utils/createGenericContext.js.map +1 -1
- package/utils/createHashing.js +13 -16
- package/utils/createHashing.js.map +1 -1
- package/utils/index.js +0 -2
- package/utils/legacyPluginToReactComponent.js +11 -10
- package/utils/legacyPluginToReactComponent.js.map +1 -1
- package/components/index.js.map +0 -1
- package/errors/index.js.map +0 -1
- package/exports/admin/env-config.js.map +0 -1
- package/exports/admin/graphql-client.js.map +0 -1
- package/exports/admin/local-storage.js.map +0 -1
- package/exports/admin/router.js.map +0 -1
- package/exports/admin/security.js.map +0 -1
- package/exports/admin.js.map +0 -1
- package/features/envConfig/index.js.map +0 -1
- package/features/eventPublisher/index.js.map +0 -1
- package/features/graphqlClient/index.js.map +0 -1
- package/features/graphqlClient/types.js.map +0 -1
- package/features/localStorage/index.js.map +0 -1
- package/features/mainGraphQLClient/index.js.map +0 -1
- package/features/router/index.js.map +0 -1
- package/helpers/InterfaceGenerator/date.js.map +0 -1
- package/helpers/InterfaceGenerator/id.js.map +0 -1
- package/helpers/InterfaceGenerator/identity.js.map +0 -1
- package/helpers/InterfaceGenerator/index.js.map +0 -1
- package/helpers/InterfaceGenerator/numeric.js.map +0 -1
- package/helpers/InterfaceGenerator/truthful.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/i18n/index.js.map +0 -1
- package/index.js.map +0 -1
- package/presentation/localStorage/index.js.map +0 -1
- package/presentation/router/index.js.map +0 -1
- package/presentation/router/types.js.map +0 -1
- package/router.js.map +0 -1
- package/types.js.map +0 -1
- package/utils/index.js.map +0 -1
package/App.js
CHANGED
|
@@ -1,89 +1,82 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import react, { Fragment, createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { CompositionProvider, compose } from "@webiny/react-composition";
|
|
3
3
|
import { PluginsProvider } from "./core/Plugins.js";
|
|
4
4
|
import { RouterWithConfig, useRouterConfig } from "./config/RouterConfig.js";
|
|
5
5
|
import { AppContainer } from "./AppContainer.js";
|
|
6
6
|
import { RouteContent } from "./presentation/router/components/RouteContent.js";
|
|
7
7
|
import { useRouter } from "./router.js";
|
|
8
|
-
const AppContext = /*#__PURE__*/createContext(
|
|
8
|
+
const AppContext = /*#__PURE__*/ createContext(void 0);
|
|
9
9
|
AppContext.displayName = "AppContext";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
return 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;
|
|
16
14
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
children
|
|
22
|
-
}) => {
|
|
23
|
-
const [state, setState] = useState({
|
|
24
|
-
plugins,
|
|
25
|
-
providers
|
|
26
|
-
});
|
|
27
|
-
const addProvider = useCallback(component => {
|
|
28
|
-
setState(state => {
|
|
29
|
-
if (state.providers.findIndex(m => m === component) > -1) {
|
|
30
|
-
return state;
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
...state,
|
|
34
|
-
providers: [...state.providers, component]
|
|
35
|
-
};
|
|
15
|
+
const AppBase = /*#__PURE__*/ react.memo(({ routes = [], plugins = [], providers = [], children })=>{
|
|
16
|
+
const [state, setState] = useState({
|
|
17
|
+
plugins,
|
|
18
|
+
providers
|
|
36
19
|
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
addPlugin
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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)))));
|
|
76
72
|
});
|
|
77
73
|
AppBase.displayName = "AppBase";
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
decorators: decorators
|
|
86
|
-
}, props)));
|
|
87
|
-
};
|
|
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 };
|
|
88
81
|
|
|
89
82
|
//# sourceMappingURL=App.js.map
|
package/App.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
package/AppContainer.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import react from "react";
|
|
2
2
|
import { makeDecoratable } from "@webiny/react-composition";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}) => {
|
|
6
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
7
|
-
});
|
|
3
|
+
const AppContainer = makeDecoratable("AppContainer", ({ children })=>/*#__PURE__*/ react.createElement(react.Fragment, null, children));
|
|
4
|
+
export { AppContainer };
|
|
8
5
|
|
|
9
6
|
//# sourceMappingURL=AppContainer.js.map
|
package/AppContainer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { InMemoryCache
|
|
1
|
+
import { InMemoryCache } from "apollo-cache-inmemory";
|
|
2
2
|
import { plugins } from "@webiny/plugins";
|
|
3
3
|
import { AddQuerySelectionPlugin } from "../plugins/AddQuerySelectionPlugin.js";
|
|
4
4
|
import { ApolloLinkPlugin } from "../plugins/ApolloLinkPlugin.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
pl.addSelectionToQuery(operationName, document);
|
|
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);
|
|
15
14
|
}
|
|
16
|
-
return super.transformDocument(document);
|
|
17
|
-
}
|
|
18
15
|
}
|
|
16
|
+
export { InMemoryCache_InMemoryCache as InMemoryCache };
|
|
19
17
|
|
|
20
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"}
|
|
@@ -1,45 +1,33 @@
|
|
|
1
1
|
import { invariant } from "ts-invariant";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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;
|
|
20
22
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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;
|
|
27
29
|
}
|
|
28
|
-
const implementingTypes = this.possibleTypesMap[typeCondition];
|
|
29
|
-
if (__typename && implementingTypes && implementingTypes.indexOf(__typename) > -1) {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
parseIntrospectionResult(introspectionResultData) {
|
|
35
|
-
const typeMap = {};
|
|
36
|
-
introspectionResultData.__schema.types.forEach(type => {
|
|
37
|
-
if (type.kind === "UNION" || type.kind === "INTERFACE") {
|
|
38
|
-
typeMap[type.name] = type.possibleTypes.map(implementingType => implementingType.name);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
return typeMap;
|
|
42
|
-
}
|
|
43
30
|
}
|
|
31
|
+
export { IntrospectionFragmentMatcher };
|
|
44
32
|
|
|
45
33
|
//# sourceMappingURL=IntrospectionFragmentMatcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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.js
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
import invariant from "invariant";
|
|
2
2
|
import { plugins } from "@webiny/plugins";
|
|
3
3
|
import get from "lodash/get.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
invariant(preset, `Transform preset "${presetName}" not found.`);
|
|
15
|
-
props.transform = preset;
|
|
16
|
-
}
|
|
17
|
-
if (props.transform) {
|
|
18
|
-
props.src = plugin.getImageSrc(props);
|
|
19
|
-
}
|
|
20
|
-
return plugin.render(props);
|
|
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);
|
|
21
14
|
};
|
|
15
|
+
export { Image };
|
|
22
16
|
|
|
23
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.js
CHANGED
|
@@ -1,33 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import react from "react";
|
|
2
2
|
import { makeDecoratable } from "@webiny/react-composition";
|
|
3
3
|
import { Property, useIdGenerator } from "@webiny/react-properties";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
value: route
|
|
26
|
-
}), /*#__PURE__*/React.createElement(Property, {
|
|
27
|
-
id: getId(name, "element"),
|
|
28
|
-
name: "element",
|
|
29
|
-
value: element
|
|
30
|
-
}));
|
|
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
|
+
}));
|
|
31
25
|
});
|
|
26
|
+
export { Route };
|
|
32
27
|
|
|
33
28
|
//# sourceMappingURL=Route.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
package/config/RouterConfig.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { createConfigurableComponent } from "@webiny/react-properties";
|
|
2
2
|
import { Route } from "./RouterConfig/Route.js";
|
|
3
3
|
const base = createConfigurableComponent("RouterConfig");
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const RouterWithConfig = Object.assign(base.WithConfig, {
|
|
5
|
+
displayName: "RouterWithConfig"
|
|
6
6
|
});
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const useRouterConfig = ()=>{
|
|
8
|
+
const baseConfig = base.useConfig();
|
|
9
|
+
return {
|
|
10
|
+
routes: baseConfig.routes ?? []
|
|
11
|
+
};
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const RouterConfig = Object.assign(base.Config, {
|
|
14
|
+
Route: Route,
|
|
15
|
+
useRouterConfig: useRouterConfig
|
|
16
16
|
});
|
|
17
|
+
export { RouterConfig, RouterWithConfig, useRouterConfig };
|
|
17
18
|
|
|
18
19
|
//# sourceMappingURL=RouterConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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.js
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
const deepFreeze = obj
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
});
|
|
7
|
-
return Object.freeze(obj);
|
|
1
|
+
const deepFreeze = (obj)=>{
|
|
2
|
+
Object.keys(obj).forEach((prop)=>{
|
|
3
|
+
if ("object" == typeof obj[prop] && !Object.isFrozen(obj[prop])) deepFreeze(obj[prop]);
|
|
4
|
+
});
|
|
5
|
+
return Object.freeze(obj);
|
|
8
6
|
};
|
|
9
7
|
function createConfig() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
let _config = {};
|
|
9
|
+
return {
|
|
10
|
+
set (config) {
|
|
11
|
+
_config = deepFreeze(config);
|
|
12
|
+
},
|
|
13
|
+
get () {
|
|
14
|
+
return _config;
|
|
15
|
+
},
|
|
16
|
+
getKey (key, defaultValue) {
|
|
17
|
+
return key in _config ? _config[key] : defaultValue;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
22
20
|
}
|
|
23
|
-
|
|
21
|
+
const config_config = createConfig();
|
|
22
|
+
export { config_config as config };
|
|
24
23
|
|
|
25
24
|
//# sourceMappingURL=config.js.map
|