@webiny/app 6.3.0 → 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.
Files changed (276) hide show
  1. package/App.js +70 -77
  2. package/App.js.map +1 -1
  3. package/AppContainer.js +3 -6
  4. package/AppContainer.js.map +1 -1
  5. package/apollo-client/InMemoryCache.js +11 -13
  6. package/apollo-client/InMemoryCache.js.map +1 -1
  7. package/apollo-client/IntrospectionFragmentMatcher.js +26 -38
  8. package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -1
  9. package/components/Image.js +11 -17
  10. package/components/Image.js.map +1 -1
  11. package/components/index.js +0 -2
  12. package/config/RouterConfig/Route.js +23 -28
  13. package/config/RouterConfig/Route.js.map +1 -1
  14. package/config/RouterConfig.js +11 -10
  15. package/config/RouterConfig.js.map +1 -1
  16. package/config.js +19 -20
  17. package/config.js.map +1 -1
  18. package/contexts/Ui/index.js +26 -28
  19. package/contexts/Ui/index.js.map +1 -1
  20. package/core/Plugin.js +7 -9
  21. package/core/Plugin.js.map +1 -1
  22. package/core/Plugins.js +15 -34
  23. package/core/Plugins.js.map +1 -1
  24. package/core/Provider.js +5 -13
  25. package/core/Provider.js.map +1 -1
  26. package/core/createProvider.js +3 -6
  27. package/core/createProvider.js.map +1 -1
  28. package/core/createProviderPlugin.js +8 -13
  29. package/core/createProviderPlugin.js.map +1 -1
  30. package/errors/AuthenticationErrorEvent.js +8 -5
  31. package/errors/AuthenticationErrorEvent.js.map +1 -1
  32. package/errors/NetworkErrorEvent.js +8 -5
  33. package/errors/NetworkErrorEvent.js.map +1 -1
  34. package/errors/abstractions.js +3 -2
  35. package/errors/abstractions.js.map +1 -1
  36. package/errors/index.js +1 -4
  37. package/exports/admin/env-config.js +0 -2
  38. package/exports/admin/graphql-client.js +0 -2
  39. package/exports/admin/local-storage.js +0 -2
  40. package/exports/admin/router.js +0 -2
  41. package/exports/admin/security.js +0 -2
  42. package/exports/admin.js +0 -2
  43. package/features/envConfig/EnvConfig.js +12 -13
  44. package/features/envConfig/EnvConfig.js.map +1 -1
  45. package/features/envConfig/abstractions.js +2 -1
  46. package/features/envConfig/abstractions.js.map +1 -1
  47. package/features/envConfig/feature.js +9 -8
  48. package/features/envConfig/feature.js.map +1 -1
  49. package/features/envConfig/index.js +0 -2
  50. package/features/eventPublisher/EventPublisher.js +13 -21
  51. package/features/eventPublisher/EventPublisher.js.map +1 -1
  52. package/features/eventPublisher/abstractions.js +7 -9
  53. package/features/eventPublisher/abstractions.js.map +1 -1
  54. package/features/eventPublisher/feature.js +13 -12
  55. package/features/eventPublisher/feature.js.map +1 -1
  56. package/features/eventPublisher/index.js +1 -3
  57. package/features/graphqlClient/AuthenticationErrorPublishing.js +26 -26
  58. package/features/graphqlClient/AuthenticationErrorPublishing.js.map +1 -1
  59. package/features/graphqlClient/BatchingGraphQLClient.js +104 -149
  60. package/features/graphqlClient/BatchingGraphQLClient.js.map +1 -1
  61. package/features/graphqlClient/FetchGraphQLClient.js +41 -48
  62. package/features/graphqlClient/FetchGraphQLClient.js.map +1 -1
  63. package/features/graphqlClient/NetworkErrorPublishing.js +35 -42
  64. package/features/graphqlClient/NetworkErrorPublishing.js.map +1 -1
  65. package/features/graphqlClient/RequestValue.js +42 -41
  66. package/features/graphqlClient/RequestValue.js.map +1 -1
  67. package/features/graphqlClient/RetryGraphQLClient.js +36 -45
  68. package/features/graphqlClient/RetryGraphQLClient.js.map +1 -1
  69. package/features/graphqlClient/__tests__/GraphQLClient.test.js +383 -356
  70. package/features/graphqlClient/__tests__/GraphQLClient.test.js.map +1 -1
  71. package/features/graphqlClient/abstractions.js +2 -1
  72. package/features/graphqlClient/abstractions.js.map +1 -1
  73. package/features/graphqlClient/feature.js +14 -20
  74. package/features/graphqlClient/feature.js.map +1 -1
  75. package/features/graphqlClient/index.js +0 -2
  76. package/features/graphqlClient/types.js +0 -3
  77. package/features/localStorage/BrowserLocalStorageGateway.js +56 -63
  78. package/features/localStorage/BrowserLocalStorageGateway.js.map +1 -1
  79. package/features/localStorage/LocalStorage.js +27 -24
  80. package/features/localStorage/LocalStorage.js.map +1 -1
  81. package/features/localStorage/LocalStorageRepository.js +75 -88
  82. package/features/localStorage/LocalStorageRepository.js.map +1 -1
  83. package/features/localStorage/abstractions.js +5 -16
  84. package/features/localStorage/abstractions.js.map +1 -1
  85. package/features/localStorage/feature.js +17 -28
  86. package/features/localStorage/feature.js.map +1 -1
  87. package/features/localStorage/index.js +1 -3
  88. package/features/mainGraphQLClient/MainGraphQLClient.js +18 -14
  89. package/features/mainGraphQLClient/MainGraphQLClient.js.map +1 -1
  90. package/features/mainGraphQLClient/abstractions.js +2 -1
  91. package/features/mainGraphQLClient/abstractions.js.map +1 -1
  92. package/features/mainGraphQLClient/feature.js +11 -10
  93. package/features/mainGraphQLClient/feature.js.map +1 -1
  94. package/features/mainGraphQLClient/index.js +0 -2
  95. package/features/router/HistoryRouterGateway.js +75 -105
  96. package/features/router/HistoryRouterGateway.js.map +1 -1
  97. package/features/router/HistoryRouterGateway.test.js +184 -193
  98. package/features/router/HistoryRouterGateway.test.js.map +1 -1
  99. package/features/router/Route.js +38 -54
  100. package/features/router/Route.js.map +1 -1
  101. package/features/router/RouteUrl.js +84 -217
  102. package/features/router/RouteUrl.js.map +1 -1
  103. package/features/router/Router.js +67 -124
  104. package/features/router/Router.js.map +1 -1
  105. package/features/router/RouterPresenter.js +44 -49
  106. package/features/router/RouterPresenter.js.map +1 -1
  107. package/features/router/RouterRepository.js +103 -111
  108. package/features/router/RouterRepository.js.map +1 -1
  109. package/features/router/RouterRepository.test.js +119 -150
  110. package/features/router/RouterRepository.test.js.map +1 -1
  111. package/features/router/abstractions.js +4 -14
  112. package/features/router/abstractions.js.map +1 -1
  113. package/features/router/feature.js +13 -12
  114. package/features/router/feature.js.map +1 -1
  115. package/features/router/index.js +1 -3
  116. package/helpers/InterfaceGenerator/date.js +0 -3
  117. package/helpers/InterfaceGenerator/id.js +0 -3
  118. package/helpers/InterfaceGenerator/identity.js +0 -3
  119. package/helpers/InterfaceGenerator/index.js +0 -3
  120. package/helpers/InterfaceGenerator/numeric.js +0 -3
  121. package/helpers/InterfaceGenerator/truthful.js +0 -3
  122. package/hooks/useAutocomplete/index.js +0 -2
  123. package/hooks/useAutocomplete/useAutocomplete.js +12 -15
  124. package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
  125. package/hooks/useDataList/functions/getData.js +2 -1
  126. package/hooks/useDataList/functions/getData.js.map +1 -1
  127. package/hooks/useDataList/functions/getError.js +2 -1
  128. package/hooks/useDataList/functions/getError.js.map +1 -1
  129. package/hooks/useDataList/functions/getMeta.js +2 -1
  130. package/hooks/useDataList/functions/getMeta.js.map +1 -1
  131. package/hooks/useDataList/functions/index.js +0 -2
  132. package/hooks/useDataList/functions/searchDataByKey.js +9 -14
  133. package/hooks/useDataList/functions/searchDataByKey.js.map +1 -1
  134. package/hooks/useDataList/index.js +0 -2
  135. package/hooks/useDataList/useDataList.js +131 -152
  136. package/hooks/useDataList/useDataList.js.map +1 -1
  137. package/hooks/useDataList/utils/index.js +0 -2
  138. package/hooks/useDataList/utils/prepareLoadListParams.js +25 -34
  139. package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
  140. package/hooks/useHandler.js +12 -16
  141. package/hooks/useHandler.js.map +1 -1
  142. package/hooks/useHandlers.js +18 -20
  143. package/hooks/useHandlers.js.map +1 -1
  144. package/hooks/useRegisterLegacyPlugin.js +7 -6
  145. package/hooks/useRegisterLegacyPlugin.js.map +1 -1
  146. package/hooks/useUi.js +2 -3
  147. package/hooks/useUi.js.map +1 -1
  148. package/i18n/i18n.js +8 -4
  149. package/i18n/i18n.js.map +1 -1
  150. package/i18n/index.js +0 -2
  151. package/index.js +6 -11
  152. package/package.json +13 -13
  153. package/plugins/AddQuerySelectionPlugin.js +36 -61
  154. package/plugins/AddQuerySelectionPlugin.js.map +1 -1
  155. package/plugins/ApolloCacheObjectIdPlugin.js +12 -11
  156. package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -1
  157. package/plugins/ApolloDynamicLink.js +20 -22
  158. package/plugins/ApolloDynamicLink.js.map +1 -1
  159. package/plugins/ApolloLinkPlugin.js +16 -15
  160. package/plugins/ApolloLinkPlugin.js.map +1 -1
  161. package/plugins/ConsoleLinkPlugin.js +19 -21
  162. package/plugins/ConsoleLinkPlugin.js.map +1 -1
  163. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +39 -45
  164. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
  165. package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js +18 -22
  166. package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js.map +1 -1
  167. package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js +21 -29
  168. package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js.map +1 -1
  169. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +6 -15
  170. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
  171. package/plugins/NetworkErrorLinkPlugin/Typography.js +9 -14
  172. package/plugins/NetworkErrorLinkPlugin/Typography.js.map +1 -1
  173. package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js +19 -0
  174. package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js.map +1 -0
  175. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +11 -18
  176. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
  177. package/plugins/NetworkErrorLinkPlugin.js +41 -58
  178. package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
  179. package/plugins/OmitTypenameLinkPlugin.js +9 -14
  180. package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
  181. package/plugins/TenantHeaderLinkPlugin.js +23 -32
  182. package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
  183. package/plugins/components/Image.js +8 -15
  184. package/plugins/components/Image.js.map +1 -1
  185. package/plugins/image.js +94 -133
  186. package/plugins/image.js.map +1 -1
  187. package/plugins/index.js +35 -59
  188. package/plugins/index.js.map +1 -1
  189. package/presentation/envConfig/useEnvConfig.js +4 -8
  190. package/presentation/envConfig/useEnvConfig.js.map +1 -1
  191. package/presentation/localStorage/index.js +0 -2
  192. package/presentation/localStorage/useLocalStorage.js +10 -16
  193. package/presentation/localStorage/useLocalStorage.js.map +1 -1
  194. package/presentation/localStorage/useLocalStorageValue.js +15 -13
  195. package/presentation/localStorage/useLocalStorageValue.js.map +1 -1
  196. package/presentation/localStorage/useLocalStorageValues.js +23 -30
  197. package/presentation/localStorage/useLocalStorageValues.js.map +1 -1
  198. package/presentation/router/RouteElementRegistry.js +22 -25
  199. package/presentation/router/RouteElementRegistry.js.map +1 -1
  200. package/presentation/router/abstractions.js +2 -1
  201. package/presentation/router/abstractions.js.map +1 -1
  202. package/presentation/router/components/Redirect.js +8 -10
  203. package/presentation/router/components/Redirect.js.map +1 -1
  204. package/presentation/router/components/RouteContent.js +14 -17
  205. package/presentation/router/components/RouteContent.js.map +1 -1
  206. package/presentation/router/components/RouteLink.js +11 -16
  207. package/presentation/router/components/RouteLink.js.map +1 -1
  208. package/presentation/router/components/SimpleLink.js +18 -24
  209. package/presentation/router/components/SimpleLink.js.map +1 -1
  210. package/presentation/router/hooks/useRoute.js +15 -23
  211. package/presentation/router/hooks/useRoute.js.map +1 -1
  212. package/presentation/router/hooks/useRouter.js +22 -23
  213. package/presentation/router/hooks/useRouter.js.map +1 -1
  214. package/presentation/router/index.js +0 -2
  215. package/presentation/router/types.js +0 -3
  216. package/react-butterfiles/Files.js +148 -217
  217. package/react-butterfiles/Files.js.map +1 -1
  218. package/react-butterfiles/index.js +2 -1
  219. package/react-butterfiles/index.js.map +1 -1
  220. package/react-butterfiles/utils/generateId.js +2 -3
  221. package/react-butterfiles/utils/generateId.js.map +1 -1
  222. package/react-butterfiles/utils/readFileContent.js +9 -13
  223. package/react-butterfiles/utils/readFileContent.js.map +1 -1
  224. package/renderApp.js +7 -6
  225. package/renderApp.js.map +1 -1
  226. package/router.js +0 -3
  227. package/rslib-runtime.js +14 -0
  228. package/rslib-runtime.js.map +1 -0
  229. package/shared/di/DiContainerProvider.js +8 -12
  230. package/shared/di/DiContainerProvider.js.map +1 -1
  231. package/shared/di/createFeature.js +7 -8
  232. package/shared/di/createFeature.js.map +1 -1
  233. package/shared/di/useFeature.js +7 -3
  234. package/shared/di/useFeature.js.map +1 -1
  235. package/static/svg/close_24px.33adaadc.svg +1 -0
  236. package/types.js +0 -3
  237. package/utils/createGenericContext.js +17 -21
  238. package/utils/createGenericContext.js.map +1 -1
  239. package/utils/createHashing.js +13 -16
  240. package/utils/createHashing.js.map +1 -1
  241. package/utils/index.js +0 -2
  242. package/utils/legacyPluginToReactComponent.js +11 -10
  243. package/utils/legacyPluginToReactComponent.js.map +1 -1
  244. package/components/index.js.map +0 -1
  245. package/errors/index.js.map +0 -1
  246. package/exports/admin/env-config.js.map +0 -1
  247. package/exports/admin/graphql-client.js.map +0 -1
  248. package/exports/admin/local-storage.js.map +0 -1
  249. package/exports/admin/router.js.map +0 -1
  250. package/exports/admin/security.js.map +0 -1
  251. package/exports/admin.js.map +0 -1
  252. package/features/envConfig/index.js.map +0 -1
  253. package/features/eventPublisher/index.js.map +0 -1
  254. package/features/graphqlClient/index.js.map +0 -1
  255. package/features/graphqlClient/types.js.map +0 -1
  256. package/features/localStorage/index.js.map +0 -1
  257. package/features/mainGraphQLClient/index.js.map +0 -1
  258. package/features/router/index.js.map +0 -1
  259. package/helpers/InterfaceGenerator/date.js.map +0 -1
  260. package/helpers/InterfaceGenerator/id.js.map +0 -1
  261. package/helpers/InterfaceGenerator/identity.js.map +0 -1
  262. package/helpers/InterfaceGenerator/index.js.map +0 -1
  263. package/helpers/InterfaceGenerator/numeric.js.map +0 -1
  264. package/helpers/InterfaceGenerator/truthful.js.map +0 -1
  265. package/hooks/useAutocomplete/index.js.map +0 -1
  266. package/hooks/useDataList/functions/index.js.map +0 -1
  267. package/hooks/useDataList/index.js.map +0 -1
  268. package/hooks/useDataList/utils/index.js.map +0 -1
  269. package/i18n/index.js.map +0 -1
  270. package/index.js.map +0 -1
  271. package/presentation/localStorage/index.js.map +0 -1
  272. package/presentation/router/index.js.map +0 -1
  273. package/presentation/router/types.js.map +0 -1
  274. package/router.js.map +0 -1
  275. package/types.js.map +0 -1
  276. package/utils/index.js.map +0 -1
package/App.js CHANGED
@@ -1,89 +1,82 @@
1
- import React, { createContext, Fragment, useCallback, useContext, useEffect, useMemo, useState } from "react";
2
- import { compose, CompositionProvider } from "@webiny/react-composition";
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(undefined);
8
+ const AppContext = /*#__PURE__*/ createContext(void 0);
9
9
  AppContext.displayName = "AppContext";
10
- export const useApp = () => {
11
- const appContext = useContext(AppContext);
12
- if (!appContext) {
13
- throw Error(`AppContext provider was not found. Are you using the "useApp()" hook in the right place?`);
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
- export const AppBase = /*#__PURE__*/React.memo(({
18
- routes = [],
19
- plugins = [],
20
- providers = [],
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
- const addPlugin = useCallback(element => {
39
- setState(state => {
40
- return {
41
- ...state,
42
- plugins: [...state.plugins, element]
43
- };
44
- });
45
- }, []);
46
- const appContext = useMemo(() => ({
47
- ...state,
48
- addProvider,
49
- addPlugin
50
- }), [state]);
51
- const AppRouter = useMemo(() => {
52
- return function AppRouter() {
53
- const router = useRouter();
54
- const routerConfig = useRouterConfig();
55
- const routesFromConfig = routerConfig.routes;
56
- const combinedRoutes = [...routes, ...routesFromConfig];
57
- useEffect(() => {
58
- router.setRoutes(combinedRoutes);
59
- }, [combinedRoutes.length]);
60
- return null;
61
- };
62
- }, []);
63
- const Providers = useMemo(() => {
64
- return /*#__PURE__*/React.memo(compose(...(state.providers || []))(({
65
- children
66
- }) => {
67
- return /*#__PURE__*/React.createElement(React.Fragment, null, children);
68
- }));
69
- }, [state.providers.length]);
70
- Providers.displayName = "Providers";
71
- return /*#__PURE__*/React.createElement(AppContext.Provider, {
72
- value: appContext
73
- }, 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, {
74
- key: index
75
- }, plugin))), /*#__PURE__*/React.createElement(RouterWithConfig, null, /*#__PURE__*/React.createElement(AppRouter, null), /*#__PURE__*/React.createElement(RouteContent, null)))));
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
- export const App = ({
79
- decorators,
80
- ...props
81
- }) => {
82
- return /*#__PURE__*/React.createElement(CompositionProvider, {
83
- decorators: decorators
84
- }, /*#__PURE__*/React.createElement(AppBase, Object.assign({
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,"names":["React","createContext","Fragment","useCallback","useContext","useEffect","useMemo","useState","compose","CompositionProvider","PluginsProvider","RouterWithConfig","useRouterConfig","AppContainer","RouteContent","useRouter","AppContext","undefined","displayName","useApp","appContext","Error","AppBase","memo","routes","plugins","providers","children","state","setState","addProvider","component","findIndex","m","addPlugin","element","AppRouter","router","routerConfig","routesFromConfig","combinedRoutes","setRoutes","length","Providers","createElement","Provider","value","map","plugin","index","key","App","decorators","props","Object","assign"],"sources":["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"],"mappings":"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","ignoreList":[]}
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 React from "react";
1
+ import react from "react";
2
2
  import { makeDecoratable } from "@webiny/react-composition";
3
- export const AppContainer = makeDecoratable("AppContainer", ({
4
- children
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
@@ -1 +1 @@
1
- {"version":3,"names":["React","makeDecoratable","AppContainer","children","createElement","Fragment"],"sources":["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"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,eAAe,QAAQ,2BAA2B;AAM3D,OAAO,MAAMC,YAAY,GAAGD,eAAe,CAAC,cAAc,EAAE,CAAC;EAAEE;AAA0B,CAAC,KAAK;EAC3F,oBAAOH,KAAA,CAAAI,aAAA,CAAAJ,KAAA,CAAAK,QAAA,QAAGF,QAAW,CAAC;AAC1B,CAAC,CAAC","ignoreList":[]}
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 as BaseInMemoryCache } from "apollo-cache-inmemory";
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
- export class InMemoryCache extends BaseInMemoryCache {
6
- constructor(config) {
7
- super(config);
8
- this.transformPlugins = plugins.byType(ApolloLinkPlugin.type).filter(pl => pl instanceof AddQuerySelectionPlugin);
9
- }
10
- transformDocument(document) {
11
- // @ts-expect-error
12
- const operationName = document.definitions[0].name.value;
13
- for (const pl of this.transformPlugins) {
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,"names":["InMemoryCache","BaseInMemoryCache","plugins","AddQuerySelectionPlugin","ApolloLinkPlugin","constructor","config","transformPlugins","byType","type","filter","pl","transformDocument","document","operationName","definitions","name","value","addSelectionToQuery"],"sources":["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"],"mappings":"AACA,SAASA,aAAa,IAAIC,iBAAiB,QAAQ,uBAAuB;AAE1E,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAASC,uBAAuB;AAChC,SAASC,gBAAgB;AAEzB,OAAO,MAAMJ,aAAa,SAASC,iBAAiB,CAAC;EAGjDI,WAAWA,CAACC,MAA4B,EAAE;IACtC,KAAK,CAACA,MAAM,CAAC;IAEb,IAAI,CAACC,gBAAgB,GAAGL,OAAO,CAC1BM,MAAM,CAA0BJ,gBAAgB,CAACK,IAAI,CAAC,CACtDC,MAAM,CAACC,EAAE,IAAIA,EAAE,YAAYR,uBAAuB,CAAC;EAC5D;EAEgBS,iBAAiBA,CAACC,QAAsB,EAAgB;IACpE;IACA,MAAMC,aAAa,GAAGD,QAAQ,CAACE,WAAW,CAAC,CAAC,CAAC,CAACC,IAAI,CAACC,KAAK;IAExD,KAAK,MAAMN,EAAE,IAAI,IAAI,CAACJ,gBAAgB,EAAE;MACpCI,EAAE,CAACO,mBAAmB,CAACJ,aAAa,EAAED,QAAQ,CAAC;IACnD;IAEA,OAAO,KAAK,CAACD,iBAAiB,CAACC,QAAQ,CAAC;EAC5C;AACJ","ignoreList":[]}
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
- export class IntrospectionFragmentMatcher {
3
- possibleTypesMap = {};
4
- constructor(options) {
5
- if (options && options.introspectionQueryResultData) {
6
- this.possibleTypesMap = this.parseIntrospectionResult(options.introspectionQueryResultData);
7
- this.isReady = true;
8
- } else {
9
- this.isReady = false;
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
- this.match = this.match.bind(this);
12
- }
13
- match(idValue, typeCondition, context) {
14
- invariant(this.isReady, "FragmentMatcher.match() was called before FragmentMatcher.init()");
15
- const obj = context.store.get(idValue.id);
16
- const isRootQuery = idValue.id === "ROOT_QUERY";
17
- if (!obj) {
18
- // https://github.com/apollographql/apollo-client/pull/4620
19
- return isRootQuery;
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
- const {
22
- __typename = isRootQuery && "Query"
23
- } = obj;
24
- invariant(__typename, `Cannot match fragment because __typename property is missing: ${JSON.stringify(obj)}`);
25
- if (__typename === typeCondition) {
26
- return true;
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,"names":["invariant","IntrospectionFragmentMatcher","possibleTypesMap","constructor","options","introspectionQueryResultData","parseIntrospectionResult","isReady","match","bind","idValue","typeCondition","context","obj","store","get","id","isRootQuery","__typename","JSON","stringify","implementingTypes","indexOf","introspectionResultData","typeMap","__schema","types","forEach","type","kind","name","possibleTypes","map","implementingType"],"sources":["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"],"mappings":"AACA,SAASA,SAAS,QAAQ,cAAc;AASxC,OAAO,MAAMC,4BAA4B,CAAqC;EAEzDC,gBAAgB,GAAqB,CAAC,CAAC;EAExDC,WAAWA,CAACC,OAAoE,EAAE;IAC9E,IAAIA,OAAO,IAAIA,OAAO,CAACC,4BAA4B,EAAE;MACjD,IAAI,CAACH,gBAAgB,GAAG,IAAI,CAACI,wBAAwB,CACjDF,OAAO,CAACC,4BACZ,CAAC;MACD,IAAI,CAACE,OAAO,GAAG,IAAI;IACvB,CAAC,MAAM;MACH,IAAI,CAACA,OAAO,GAAG,KAAK;IACxB;IAEA,IAAI,CAACC,KAAK,GAAG,IAAI,CAACA,KAAK,CAACC,IAAI,CAAC,IAAI,CAAC;EACtC;EAEOD,KAAKA,CAACE,OAAgB,EAAEC,aAAqB,EAAEC,OAAyB,EAAE;IAC7EZ,SAAS,CAAC,IAAI,CAACO,OAAO,EAAE,kEAAkE,CAAC;IAE3F,MAAMM,GAAG,GAAGD,OAAO,CAACE,KAAK,CAACC,GAAG,CAACL,OAAO,CAACM,EAAE,CAAC;IACzC,MAAMC,WAAW,GAAGP,OAAO,CAACM,EAAE,KAAK,YAAY;IAE/C,IAAI,CAACH,GAAG,EAAE;MACN;MACA,OAAOI,WAAW;IACtB;IAEA,MAAM;MAAEC,UAAU,GAAGD,WAAW,IAAI;IAAQ,CAAC,GAAGJ,GAAG;IAEnDb,SAAS,CACLkB,UAAU,EACV,iEAAiEC,IAAI,CAACC,SAAS,CAACP,GAAG,CAAC,EACxF,CAAC;IAED,IAAIK,UAAU,KAAKP,aAAa,EAAE;MAC9B,OAAO,IAAI;IACf;IAEA,MAAMU,iBAAiB,GAAG,IAAI,CAACnB,gBAAgB,CAACS,aAAa,CAAC;IAC9D,IAAIO,UAAU,IAAIG,iBAAiB,IAAIA,iBAAiB,CAACC,OAAO,CAACJ,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE;MAC/E,OAAO,IAAI;IACf;IAEA,OAAO,KAAK;EAChB;EAEQZ,wBAAwBA,CAC5BiB,uBAAgD,EAChC;IAChB,MAAMC,OAAyB,GAAG,CAAC,CAAC;IACpCD,uBAAuB,CAACE,QAAQ,CAACC,KAAK,CAACC,OAAO,CAACC,IAAI,IAAI;MACnD,IAAIA,IAAI,CAACC,IAAI,KAAK,OAAO,IAAID,IAAI,CAACC,IAAI,KAAK,WAAW,EAAE;QACpDL,OAAO,CAACI,IAAI,CAACE,IAAI,CAAC,GAAGF,IAAI,CAACG,aAAa,CAACC,GAAG,CACvCC,gBAAgB,IAAIA,gBAAgB,CAACH,IACzC,CAAC;MACL;IACJ,CAAC,CAAC;IACF,OAAON,OAAO;EAClB;AACJ","ignoreList":[]}
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"}
@@ -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
- export const Image = ({
5
- preset: presetName,
6
- ...props
7
- }) => {
8
- const plugin = plugins.byName("image-component");
9
- if (!plugin) {
10
- throw new Error(`Image component plugin (type "image-component") not defined.`);
11
- }
12
- if (presetName) {
13
- const preset = get(plugin, `presets.${presetName}`);
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
@@ -1 +1 @@
1
- {"version":3,"names":["invariant","plugins","get","Image","preset","presetName","props","plugin","byName","Error","transform","src","getImageSrc","render"],"sources":["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"],"mappings":"AAAA,OAAOA,SAAS,MAAM,WAAW;AACjC,SAASC,OAAO,QAAQ,iBAAiB;AACzC,OAAOC,GAAG,MAAM,eAAe;AAG/B,OAAO,MAAMC,KAAK,GAAGA,CAAC;EAAEC,MAAM,EAAEC,UAAU;EAAE,GAAGC;AAAkB,CAAC,KAAK;EACnE,MAAMC,MAAM,GAAGN,OAAO,CAACO,MAAM,CAAuB,iBAAiB,CAAC;EACtE,IAAI,CAACD,MAAM,EAAE;IACT,MAAM,IAAIE,KAAK,CAAC,8DAA8D,CAAC;EACnF;EAEA,IAAIJ,UAAU,EAAE;IACZ,MAAMD,MAAM,GAAGF,GAAG,CAACK,MAAM,EAAE,WAAWF,UAAU,EAAE,CAAC;IACnDL,SAAS,CAACI,MAAM,EAAE,qBAAqBC,UAAU,cAAc,CAAC;IAChEC,KAAK,CAACI,SAAS,GAAGN,MAAM;EAC5B;EAEA,IAAIE,KAAK,CAACI,SAAS,EAAE;IACjBJ,KAAK,CAACK,GAAG,GAAGJ,MAAM,CAACK,WAAW,CAACN,KAAK,CAAC;EACzC;EAEA,OAAOC,MAAM,CAACM,MAAM,CAACP,KAAK,CAAC;AAC/B,CAAC","ignoreList":[]}
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"}
@@ -1,3 +1 @@
1
1
  export { Image } from "./Image.js";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -1,33 +1,28 @@
1
- import React from "react";
1
+ import react from "react";
2
2
  import { makeDecoratable } from "@webiny/react-composition";
3
3
  import { Property, useIdGenerator } from "@webiny/react-properties";
4
- export const Route = makeDecoratable("Route", ({
5
- route,
6
- element,
7
- remove,
8
- before,
9
- after
10
- }) => {
11
- const name = route.name;
12
- const getId = useIdGenerator("Route");
13
- const placeAfter = after !== undefined ? getId(after) : undefined;
14
- const placeBefore = before !== undefined ? getId(before) : undefined;
15
- return /*#__PURE__*/React.createElement(Property, {
16
- id: getId(name),
17
- name: "routes",
18
- remove: remove,
19
- array: true,
20
- before: placeBefore,
21
- after: placeAfter
22
- }, /*#__PURE__*/React.createElement(Property, {
23
- id: getId(name, "route"),
24
- name: "route",
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,"names":["React","makeDecoratable","Property","useIdGenerator","Route","route","element","remove","before","after","name","getId","placeAfter","undefined","placeBefore","createElement","id","array","value"],"sources":["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"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,SAASC,QAAQ,EAAEC,cAAc,QAAQ,0BAA0B;AAanE,OAAO,MAAMC,KAAK,GAAGH,eAAe,CAChC,OAAO,EACP,CAAC;EAAEI,KAAK;EAAEC,OAAO;EAAEC,MAAM;EAAEC,MAAM;EAAEC;AAAkB,CAAC,KAAK;EACvD,MAAMC,IAAI,GAAGL,KAAK,CAACK,IAAI;EAEvB,MAAMC,KAAK,GAAGR,cAAc,CAAC,OAAO,CAAC;EAErC,MAAMS,UAAU,GAAGH,KAAK,KAAKI,SAAS,GAAGF,KAAK,CAACF,KAAK,CAAC,GAAGI,SAAS;EACjE,MAAMC,WAAW,GAAGN,MAAM,KAAKK,SAAS,GAAGF,KAAK,CAACH,MAAM,CAAC,GAAGK,SAAS;EAEpE,oBACIb,KAAA,CAAAe,aAAA,CAACb,QAAQ;IACLc,EAAE,EAAEL,KAAK,CAACD,IAAI,CAAE;IAChBA,IAAI,EAAE,QAAS;IACfH,MAAM,EAAEA,MAAO;IACfU,KAAK,EAAE,IAAK;IACZT,MAAM,EAAEM,WAAY;IACpBL,KAAK,EAAEG;EAAW,gBAElBZ,KAAA,CAAAe,aAAA,CAACb,QAAQ;IAACc,EAAE,EAAEL,KAAK,CAACD,IAAI,EAAE,OAAO,CAAE;IAACA,IAAI,EAAE,OAAQ;IAACQ,KAAK,EAAEb;EAAM,CAAE,CAAC,eACnEL,KAAA,CAAAe,aAAA,CAACb,QAAQ;IAACc,EAAE,EAAEL,KAAK,CAACD,IAAI,EAAE,SAAS,CAAE;IAACA,IAAI,EAAE,SAAU;IAACQ,KAAK,EAAEZ;EAAQ,CAAE,CAClE,CAAC;AAEnB,CACJ,CAAC","ignoreList":[]}
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"}
@@ -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
- export const RouterWithConfig = Object.assign(base.WithConfig, {
5
- displayName: "RouterWithConfig"
4
+ const RouterWithConfig = Object.assign(base.WithConfig, {
5
+ displayName: "RouterWithConfig"
6
6
  });
7
- export const useRouterConfig = () => {
8
- const baseConfig = base.useConfig();
9
- return {
10
- routes: baseConfig.routes ?? []
11
- };
7
+ const useRouterConfig = ()=>{
8
+ const baseConfig = base.useConfig();
9
+ return {
10
+ routes: baseConfig.routes ?? []
11
+ };
12
12
  };
13
- export const RouterConfig = Object.assign(base.Config, {
14
- Route,
15
- useRouterConfig
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,"names":["createConfigurableComponent","Route","base","RouterWithConfig","Object","assign","WithConfig","displayName","useRouterConfig","baseConfig","useConfig","routes","RouterConfig","Config"],"sources":["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"],"mappings":"AAAA,SAASA,2BAA2B,QAAQ,0BAA0B;AACtE,SAASC,KAAK;AAEd,MAAMC,IAAI,GAAGF,2BAA2B,CAAe,cAAc,CAAC;AAEtE,OAAO,MAAMG,gBAAgB,GAAGC,MAAM,CAACC,MAAM,CAACH,IAAI,CAACI,UAAU,EAAE;EAC3DC,WAAW,EAAE;AACjB,CAAC,CAAC;AAMF,OAAO,MAAMC,eAAe,GAAGA,CAAA,KAAM;EACjC,MAAMC,UAAU,GAAGP,IAAI,CAACQ,SAAS,CAAC,CAAC;EAEnC,OAAO;IACHC,MAAM,EAAEF,UAAU,CAACE,MAAM,IAAI;EACjC,CAAC;AACL,CAAC;AAED,OAAO,MAAMC,YAAY,GAAGR,MAAM,CAACC,MAAM,CAACH,IAAI,CAACW,MAAM,EAAE;EACnDZ,KAAK;EACLO;AACJ,CAAC,CAAC","ignoreList":[]}
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
- Object.keys(obj).forEach(prop => {
3
- if (typeof obj[prop] === "object" && !Object.isFrozen(obj[prop])) {
4
- deepFreeze(obj[prop]);
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
- let _config = {};
11
- return {
12
- set(config) {
13
- _config = deepFreeze(config);
14
- },
15
- get() {
16
- return _config;
17
- },
18
- getKey(key, defaultValue) {
19
- return key in _config ? _config[key] : defaultValue;
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
- export const config = createConfig();
21
+ const config_config = createConfig();
22
+ export { config_config as config };
24
23
 
25
24
  //# sourceMappingURL=config.js.map