@webiny/app 0.0.0-unstable.df6d94b531 → 0.0.0-unstable.e0bfc55d5a

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 (198) hide show
  1. package/App.d.ts +12 -15
  2. package/App.js +72 -82
  3. package/App.js.map +1 -1
  4. package/AppContainer.d.ts +23 -0
  5. package/AppContainer.js +9 -0
  6. package/AppContainer.js.map +1 -0
  7. package/apollo-client/InMemoryCache.d.ts +3 -2
  8. package/apollo-client/InMemoryCache.js +18 -54
  9. package/apollo-client/InMemoryCache.js.map +1 -1
  10. package/apollo-client/IntrospectionFragmentMatcher.d.ts +11 -0
  11. package/apollo-client/IntrospectionFragmentMatcher.js +45 -0
  12. package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -0
  13. package/components/Image.d.ts +3 -3
  14. package/components/Image.js +13 -20
  15. package/components/Image.js.map +1 -1
  16. package/components/Routes.d.ts +2 -2
  17. package/components/Routes.js +15 -24
  18. package/components/Routes.js.map +1 -1
  19. package/components/View.d.ts +1 -1
  20. package/components/View.js +16 -27
  21. package/components/View.js.map +1 -1
  22. package/components/index.js +3 -18
  23. package/components/index.js.map +1 -1
  24. package/config/RouterConfig/Route.d.ts +30 -0
  25. package/config/RouterConfig/Route.js +42 -0
  26. package/config/RouterConfig/Route.js.map +1 -0
  27. package/config/RouterConfig.d.ts +32 -0
  28. package/config/RouterConfig.js +18 -0
  29. package/config/RouterConfig.js.map +1 -0
  30. package/config.d.ts +1 -1
  31. package/config.js +9 -14
  32. package/config.js.map +1 -1
  33. package/contexts/Ui/index.d.ts +4 -4
  34. package/contexts/Ui/index.js +30 -57
  35. package/contexts/Ui/index.js.map +1 -1
  36. package/core/DebounceRender.d.ts +2 -1
  37. package/core/DebounceRender.js +15 -25
  38. package/core/DebounceRender.js.map +1 -1
  39. package/core/Plugin.d.ts +2 -2
  40. package/core/Plugin.js +13 -20
  41. package/core/Plugin.js.map +1 -1
  42. package/core/Plugins.d.ts +5 -2
  43. package/core/Plugins.js +21 -27
  44. package/core/Plugins.js.map +1 -1
  45. package/core/Provider.d.ts +3 -4
  46. package/core/Provider.js +11 -14
  47. package/core/Provider.js.map +1 -1
  48. package/core/Routes.d.ts +1 -1
  49. package/core/Routes.js +16 -24
  50. package/core/Routes.js.map +1 -1
  51. package/core/createProvider.d.ts +7 -3
  52. package/core/createProvider.js +6 -10
  53. package/core/createProvider.js.map +1 -1
  54. package/core/createProviderPlugin.d.ts +2 -2
  55. package/core/createProviderPlugin.js +8 -12
  56. package/core/createProviderPlugin.js.map +1 -1
  57. package/hooks/useAutocomplete/index.js +2 -11
  58. package/hooks/useAutocomplete/index.js.map +1 -1
  59. package/hooks/useAutocomplete/useAutocomplete.d.ts +1 -1
  60. package/hooks/useAutocomplete/useAutocomplete.js +11 -17
  61. package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
  62. package/hooks/useDataList/functions/getData.js +3 -11
  63. package/hooks/useDataList/functions/getData.js.map +1 -1
  64. package/hooks/useDataList/functions/getError.js +3 -11
  65. package/hooks/useDataList/functions/getError.js.map +1 -1
  66. package/hooks/useDataList/functions/getMeta.js +3 -11
  67. package/hooks/useDataList/functions/getMeta.js.map +1 -1
  68. package/hooks/useDataList/functions/index.js +4 -26
  69. package/hooks/useDataList/functions/index.js.map +1 -1
  70. package/hooks/useDataList/functions/searchDataByKey.js +6 -11
  71. package/hooks/useDataList/functions/searchDataByKey.js.map +1 -1
  72. package/hooks/useDataList/index.js +2 -11
  73. package/hooks/useDataList/index.js.map +1 -1
  74. package/hooks/useDataList/useDataList.d.ts +2 -2
  75. package/hooks/useDataList/useDataList.js +80 -79
  76. package/hooks/useDataList/useDataList.js.map +1 -1
  77. package/hooks/useDataList/utils/index.js +3 -19
  78. package/hooks/useDataList/utils/index.js.map +1 -1
  79. package/hooks/useDataList/utils/prepareLoadListParams.d.ts +1 -2
  80. package/hooks/useDataList/utils/prepareLoadListParams.js +34 -34
  81. package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
  82. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +12 -15
  83. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +1 -1
  84. package/hooks/useDataList/utils/types.d.ts +21 -15
  85. package/hooks/useDataList/utils/types.js +2 -4
  86. package/hooks/useDataList/utils/types.js.map +1 -1
  87. package/hooks/useHandler.js +14 -13
  88. package/hooks/useHandler.js.map +1 -1
  89. package/hooks/useHandlers.d.ts +3 -3
  90. package/hooks/useHandlers.js +14 -18
  91. package/hooks/useHandlers.js.map +1 -1
  92. package/hooks/useRegisterLegacyPlugin.d.ts +2 -0
  93. package/hooks/useRegisterLegacyPlugin.js +11 -0
  94. package/hooks/useRegisterLegacyPlugin.js.map +1 -0
  95. package/hooks/useUi.d.ts +1 -1
  96. package/hooks/useUi.js +6 -11
  97. package/hooks/useUi.js.map +1 -1
  98. package/i18n/i18n.js +6 -13
  99. package/i18n/i18n.js.map +1 -1
  100. package/i18n/index.js +2 -12
  101. package/i18n/index.js.map +1 -1
  102. package/index.d.ts +4 -2
  103. package/index.js +19 -146
  104. package/index.js.map +1 -1
  105. package/package.json +24 -32
  106. package/plugins/AddQuerySelectionPlugin.d.ts +1 -1
  107. package/plugins/AddQuerySelectionPlugin.js +63 -113
  108. package/plugins/AddQuerySelectionPlugin.js.map +1 -1
  109. package/plugins/ApolloCacheObjectIdPlugin.js +14 -36
  110. package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -1
  111. package/plugins/ApolloDynamicLink.d.ts +3 -2
  112. package/plugins/ApolloDynamicLink.js +21 -50
  113. package/plugins/ApolloDynamicLink.js.map +1 -1
  114. package/plugins/ApolloLinkPlugin.d.ts +1 -1
  115. package/plugins/ApolloLinkPlugin.js +20 -44
  116. package/plugins/ApolloLinkPlugin.js.map +1 -1
  117. package/plugins/ConsoleLinkPlugin.js +22 -44
  118. package/plugins/ConsoleLinkPlugin.js.map +1 -1
  119. package/plugins/LocaleHeaderLinkPlugin.d.ts +1 -1
  120. package/plugins/LocaleHeaderLinkPlugin.js +25 -46
  121. package/plugins/LocaleHeaderLinkPlugin.js.map +1 -1
  122. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts +1 -1
  123. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +41 -52
  124. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
  125. package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +2 -4
  126. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +76 -16
  127. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
  128. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.d.ts +1 -1
  129. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +18 -18
  130. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
  131. package/plugins/NetworkErrorLinkPlugin.js +24 -42
  132. package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
  133. package/plugins/OmitTypenameLinkPlugin.js +13 -33
  134. package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
  135. package/plugins/RoutePlugin.d.ts +1 -1
  136. package/plugins/RoutePlugin.js +14 -36
  137. package/plugins/RoutePlugin.js.map +1 -1
  138. package/plugins/TenantHeaderLinkPlugin.d.ts +1 -1
  139. package/plugins/TenantHeaderLinkPlugin.js +32 -53
  140. package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
  141. package/plugins/ViewPlugin.d.ts +1 -1
  142. package/plugins/ViewPlugin.js +17 -41
  143. package/plugins/ViewPlugin.js.map +1 -1
  144. package/plugins/image.d.ts +1 -1
  145. package/plugins/image.js +48 -54
  146. package/plugins/image.js.map +1 -1
  147. package/plugins/index.d.ts +3 -3
  148. package/plugins/index.js +35 -58
  149. package/plugins/index.js.map +1 -1
  150. package/react-butterfiles/Files.d.ts +69 -0
  151. package/react-butterfiles/Files.js +227 -0
  152. package/react-butterfiles/Files.js.map +1 -0
  153. package/react-butterfiles/index.d.ts +2 -0
  154. package/react-butterfiles/index.js +4 -0
  155. package/react-butterfiles/index.js.map +1 -0
  156. package/react-butterfiles/utils/generateId.d.ts +1 -0
  157. package/react-butterfiles/utils/generateId.js +5 -0
  158. package/react-butterfiles/utils/generateId.js.map +1 -0
  159. package/react-butterfiles/utils/readFileContent.d.ts +1 -0
  160. package/react-butterfiles/utils/readFileContent.js +15 -0
  161. package/react-butterfiles/utils/readFileContent.js.map +1 -0
  162. package/renderApp.d.ts +2 -0
  163. package/renderApp.js +9 -0
  164. package/renderApp.js.map +1 -0
  165. package/types.d.ts +24 -29
  166. package/types.js +13 -11
  167. package/types.js.map +1 -1
  168. package/utils/createGenericContext.d.ts +13 -0
  169. package/utils/createGenericContext.js +25 -0
  170. package/utils/createGenericContext.js.map +1 -0
  171. package/utils/createHashing.d.ts +2 -0
  172. package/utils/createHashing.js +18 -0
  173. package/utils/createHashing.js.map +1 -0
  174. package/utils/getApiUrl.js +3 -9
  175. package/utils/getApiUrl.js.map +1 -1
  176. package/utils/getGqlApiUrl.js +5 -10
  177. package/utils/getGqlApiUrl.js.map +1 -1
  178. package/utils/getHeadlessCmsGqlApiUrl.js +9 -14
  179. package/utils/getHeadlessCmsGqlApiUrl.js.map +1 -1
  180. package/utils/getLocaleCode.js +8 -17
  181. package/utils/getLocaleCode.js.map +1 -1
  182. package/utils/getPrerenderId.js +3 -8
  183. package/utils/getPrerenderId.js.map +1 -1
  184. package/utils/getTenantId.js +21 -10
  185. package/utils/getTenantId.js.map +1 -1
  186. package/utils/index.d.ts +2 -0
  187. package/utils/index.js +11 -92
  188. package/utils/index.js.map +1 -1
  189. package/utils/isLocalhost.js +6 -13
  190. package/utils/isLocalhost.js.map +1 -1
  191. package/utils/isPrerendering.js +3 -8
  192. package/utils/isPrerendering.js.map +1 -1
  193. package/utils/legacyPluginToReactComponent.d.ts +7 -0
  194. package/utils/legacyPluginToReactComponent.js +14 -0
  195. package/utils/legacyPluginToReactComponent.js.map +1 -0
  196. package/core/AddRoute.d.ts +0 -3
  197. package/core/AddRoute.js +0 -19
  198. package/core/AddRoute.js.map +0 -1
package/App.d.ts CHANGED
@@ -1,17 +1,12 @@
1
- import React, { ReactElement } from "react";
2
- import { RouteProps } from "@webiny/react-router";
3
- import { HigherOrderComponent } from "@webiny/react-composition";
4
- declare type RoutesByPath = {
5
- [key: string]: ReactElement<RouteProps>;
6
- };
1
+ import React from "react";
2
+ import type { RouteProps } from "@webiny/react-router";
3
+ import type { GenericComponent, Decorator, DecoratorsCollection } from "@webiny/react-composition";
7
4
  interface State {
8
- routes: RoutesByPath;
9
5
  plugins: JSX.Element[];
10
- providers: HigherOrderComponent[];
6
+ providers: Decorator<GenericComponent<ProviderProps>>[];
11
7
  }
12
8
  interface AppContext extends State {
13
- addRoute(route: JSX.Element): void;
14
- addProvider(hoc: HigherOrderComponent): void;
9
+ addProvider(hoc: Decorator<GenericComponent<ProviderProps>>): void;
15
10
  addPlugin(plugin: React.ReactNode): void;
16
11
  }
17
12
  declare const AppContext: React.Context<AppContext | undefined>;
@@ -19,11 +14,13 @@ export declare const useApp: () => AppContext;
19
14
  export interface AppProps {
20
15
  debounceRender?: number;
21
16
  routes?: Array<RouteProps>;
22
- providers?: Array<HigherOrderComponent>;
17
+ providers?: Array<Decorator<GenericComponent<ProviderProps>>>;
18
+ decorators?: DecoratorsCollection;
23
19
  children?: React.ReactNode | React.ReactNode[];
24
20
  }
25
- export declare const App: {
26
- ({ debounceRender, routes, providers, children }: AppProps): JSX.Element;
27
- displayName: string;
28
- };
21
+ interface ProviderProps {
22
+ children: React.ReactNode;
23
+ }
24
+ export declare const AppBase: ({ debounceRender, routes, providers, children }: AppProps) => React.JSX.Element;
25
+ export declare const App: ({ decorators, ...props }: AppProps) => React.JSX.Element;
29
26
  export {};
package/App.js CHANGED
@@ -1,105 +1,95 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.useApp = exports.App = void 0;
9
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
- var _objectSpread4 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
12
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
- var _react = _interopRequireWildcard(require("react"));
14
- var _reactRouter = require("@webiny/react-router");
15
- var _reactComposition = require("@webiny/react-composition");
16
- var _Routes = require("./core/Routes");
17
- var _DebounceRender = require("./core/DebounceRender");
18
- var _Plugins = require("./core/Plugins");
19
- var AppContext = /*#__PURE__*/(0, _react.createContext)(undefined);
1
+ import React, { createContext, useContext, useMemo, useState, useCallback } from "react";
2
+ import { BrowserRouter, Route } from "@webiny/react-router";
3
+ import { CompositionProvider, compose } from "@webiny/react-composition";
4
+ import { Routes as SortRoutes } from "./core/Routes";
5
+ import { DebounceRender } from "./core/DebounceRender";
6
+ import { PluginsProvider } from "./core/Plugins";
7
+ import { RouterWithConfig, useRouterConfig } from "./config/RouterConfig";
8
+ import { AppContainer } from "./AppContainer";
9
+ const AppContext = /*#__PURE__*/createContext(undefined);
20
10
  AppContext.displayName = "AppContext";
21
- var useApp = function useApp() {
22
- var appContext = (0, _react.useContext)(AppContext);
11
+ export const useApp = () => {
12
+ const appContext = useContext(AppContext);
23
13
  if (!appContext) {
24
- throw Error("AppContext provider was not found. Are you using the \"useApp()\" hook in the right place?");
14
+ throw Error(`AppContext provider was not found. Are you using the "useApp()" hook in the right place?`);
25
15
  }
26
16
  return appContext;
27
17
  };
28
- exports.useApp = useApp;
29
- var App = function App(_ref) {
30
- var _ref$debounceRender = _ref.debounceRender,
31
- debounceRender = _ref$debounceRender === void 0 ? 50 : _ref$debounceRender,
32
- _ref$routes = _ref.routes,
33
- routes = _ref$routes === void 0 ? [] : _ref$routes,
34
- _ref$providers = _ref.providers,
35
- providers = _ref$providers === void 0 ? [] : _ref$providers,
36
- children = _ref.children;
37
- var _useState = (0, _react.useState)({
38
- routes: routes.reduce(function (acc, item) {
39
- return (0, _objectSpread4.default)((0, _objectSpread4.default)({}, acc), {}, (0, _defineProperty2.default)({}, item.path, /*#__PURE__*/_react.default.createElement(_reactRouter.Route, item)));
40
- }, {}),
41
- plugins: [],
42
- providers: providers
43
- }),
44
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
45
- state = _useState2[0],
46
- setState = _useState2[1];
47
- var addRoute = (0, _react.useCallback)(function (route) {
48
- setState(function (state) {
49
- return (0, _objectSpread4.default)((0, _objectSpread4.default)({}, state), {}, {
50
- routes: (0, _objectSpread4.default)((0, _objectSpread4.default)({}, state.routes), {}, (0, _defineProperty2.default)({}, route.props.path, route))
51
- });
52
- });
53
- }, []);
54
- var addProvider = (0, _react.useCallback)(function (component) {
55
- setState(function (state) {
56
- if (state.providers.findIndex(function (m) {
57
- return m === component;
58
- }) > -1) {
18
+ export const AppBase = ({
19
+ debounceRender = 50,
20
+ routes = [],
21
+ providers = [],
22
+ children
23
+ }) => {
24
+ const [state, setState] = useState({
25
+ plugins: [],
26
+ providers
27
+ });
28
+ const addProvider = useCallback(component => {
29
+ setState(state => {
30
+ if (state.providers.findIndex(m => m === component) > -1) {
59
31
  return state;
60
32
  }
61
- return (0, _objectSpread4.default)((0, _objectSpread4.default)({}, state), {}, {
62
- providers: [].concat((0, _toConsumableArray2.default)(state.providers), [component])
63
- });
33
+ return {
34
+ ...state,
35
+ providers: [...state.providers, component]
36
+ };
64
37
  });
65
38
  }, []);
66
- var addPlugin = (0, _react.useCallback)(function (element) {
67
- setState(function (state) {
68
- return (0, _objectSpread4.default)((0, _objectSpread4.default)({}, state), {}, {
69
- plugins: [].concat((0, _toConsumableArray2.default)(state.plugins), [element])
70
- });
39
+ const addPlugin = useCallback(element => {
40
+ setState(state => {
41
+ return {
42
+ ...state,
43
+ plugins: [...state.plugins, element]
44
+ };
71
45
  });
72
46
  }, []);
73
- var appContext = (0, _react.useMemo)(function () {
74
- return (0, _objectSpread4.default)((0, _objectSpread4.default)({}, state), {}, {
75
- addRoute: addRoute,
76
- addProvider: addProvider,
77
- addPlugin: addPlugin
78
- });
79
- }, [state]);
80
- var AppRouter = (0, _react.useMemo)(function () {
47
+ const appContext = useMemo(() => ({
48
+ ...state,
49
+ addProvider,
50
+ addPlugin
51
+ }), [state]);
52
+ const AppRouter = useMemo(() => {
81
53
  return function AppRouter() {
82
- var routes = Object.values(state.routes);
83
- return /*#__PURE__*/_react.default.createElement(_Routes.Routes, {
54
+ const routerConfig = useRouterConfig();
55
+ const combinedRoutes = [...routes, ...routerConfig.routes].map(r => {
56
+ return /*#__PURE__*/React.createElement(Route, {
57
+ path: r.path,
58
+ element: r.element,
59
+ key: r.path
60
+ });
61
+ });
62
+ return /*#__PURE__*/React.createElement(SortRoutes, {
84
63
  key: routes.length,
85
- routes: routes
64
+ routes: combinedRoutes
86
65
  });
87
66
  };
88
- }, [state.routes]);
89
- var Providers = (0, _react.useMemo)(function () {
90
- return _reactComposition.compose.apply(void 0, (0, _toConsumableArray2.default)(state.providers || []))(function (_ref2) {
91
- var children = _ref2.children;
92
- return /*#__PURE__*/_react.default.createElement(_DebounceRender.DebounceRender, {
67
+ }, [routes]);
68
+ const Providers = useMemo(() => {
69
+ return compose(...(state.providers || []))(({
70
+ children
71
+ }) => {
72
+ return /*#__PURE__*/React.createElement(DebounceRender, {
93
73
  wait: debounceRender
94
74
  }, children);
95
75
  });
96
76
  }, [state.providers.length]);
97
77
  Providers.displayName = "Providers";
98
- return /*#__PURE__*/_react.default.createElement(AppContext.Provider, {
78
+ return /*#__PURE__*/React.createElement(AppContext.Provider, {
99
79
  value: appContext
100
- }, /*#__PURE__*/_react.default.createElement(_reactComposition.CompositionProvider, null, children, /*#__PURE__*/_react.default.createElement(_reactRouter.BrowserRouter, null, /*#__PURE__*/_react.default.createElement(Providers, null, /*#__PURE__*/_react.default.createElement(_Plugins.PluginsProvider, null, state.plugins), /*#__PURE__*/_react.default.createElement(_DebounceRender.DebounceRender, {
80
+ }, children, /*#__PURE__*/React.createElement(AppContainer, null, /*#__PURE__*/React.createElement(BrowserRouter, null, /*#__PURE__*/React.createElement(Providers, null, /*#__PURE__*/React.createElement(PluginsProvider, null, state.plugins), /*#__PURE__*/React.createElement(DebounceRender, {
101
81
  wait: debounceRender
102
- }, /*#__PURE__*/_react.default.createElement(AppRouter, null))))));
82
+ }, /*#__PURE__*/React.createElement(RouterWithConfig, null, /*#__PURE__*/React.createElement(AppRouter, null)))))));
103
83
  };
104
- exports.App = App;
105
- App.displayName = "App";
84
+ export const App = ({
85
+ decorators,
86
+ ...props
87
+ }) => {
88
+ return /*#__PURE__*/React.createElement(CompositionProvider, {
89
+ decorators: decorators
90
+ }, /*#__PURE__*/React.createElement(AppBase, Object.assign({
91
+ decorators: decorators
92
+ }, props)));
93
+ };
94
+
95
+ //# sourceMappingURL=App.js.map
package/App.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["AppContext","createContext","undefined","displayName","useApp","appContext","useContext","Error","App","debounceRender","routes","providers","children","useState","reduce","acc","item","path","plugins","state","setState","addRoute","useCallback","route","props","addProvider","component","findIndex","m","addPlugin","element","useMemo","AppRouter","Object","values","length","Providers","compose"],"sources":["App.tsx"],"sourcesContent":["import React, {\n createContext,\n useContext,\n useMemo,\n useState,\n useCallback,\n FunctionComponentElement,\n ReactElement\n} from \"react\";\nimport { BrowserRouter, RouteProps, Route } from \"@webiny/react-router\";\nimport { compose, HigherOrderComponent, CompositionProvider } from \"@webiny/react-composition\";\nimport { Routes as SortRoutes } from \"./core/Routes\";\nimport { DebounceRender } from \"./core/DebounceRender\";\nimport { PluginsProvider } from \"./core/Plugins\";\n\ntype RoutesByPath = {\n [key: string]: ReactElement<RouteProps>;\n};\n\ninterface State {\n routes: RoutesByPath;\n plugins: JSX.Element[];\n providers: HigherOrderComponent[];\n}\n\ninterface AppContext extends State {\n addRoute(route: JSX.Element): void;\n addProvider(hoc: HigherOrderComponent): 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 debounceRender?: number;\n routes?: Array<RouteProps>;\n providers?: Array<HigherOrderComponent>;\n children?: React.ReactNode | React.ReactNode[];\n}\n\nexport const App = ({ debounceRender = 50, routes = [], providers = [], children }: AppProps) => {\n const [state, setState] = useState<State>({\n routes: routes.reduce<RoutesByPath>((acc, item) => {\n return { ...acc, [item.path as string]: <Route {...item} /> };\n }, {}),\n plugins: [],\n providers\n });\n\n const addRoute = useCallback((route: FunctionComponentElement<RouteProps>) => {\n setState(state => {\n return {\n ...state,\n routes: { ...state.routes, [route.props.path as string]: route }\n };\n });\n }, []);\n\n const addProvider = useCallback(component => {\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 => {\n setState(state => {\n return {\n ...state,\n plugins: [...state.plugins, element]\n };\n });\n }, []);\n\n const appContext = useMemo(\n () => ({\n ...state,\n addRoute,\n addProvider,\n addPlugin\n }),\n [state]\n );\n\n const AppRouter = useMemo(() => {\n return function AppRouter() {\n const routes = Object.values(state.routes);\n return <SortRoutes key={routes.length} routes={routes} />;\n };\n }, [state.routes]);\n\n const Providers = useMemo(() => {\n return compose(...(state.providers || []))(({ children }: any) => (\n <DebounceRender wait={debounceRender}>{children}</DebounceRender>\n ));\n }, [state.providers.length]);\n\n Providers.displayName = \"Providers\";\n\n return (\n <AppContext.Provider value={appContext}>\n <CompositionProvider>\n {children}\n <BrowserRouter>\n <Providers>\n <PluginsProvider>{state.plugins}</PluginsProvider>\n <DebounceRender wait={debounceRender}>\n <AppRouter />\n </DebounceRender>\n </Providers>\n </BrowserRouter>\n </CompositionProvider>\n </AppContext.Provider>\n );\n};\n\nApp.displayName = \"App\";\n"],"mappings":";;;;;;;;;;;;AAAA;AASA;AACA;AACA;AACA;AACA;AAkBA,IAAMA,UAAU,gBAAG,IAAAC,oBAAa,EAAyBC,SAAS,CAAC;AAEnEF,UAAU,CAACG,WAAW,GAAG,YAAY;AAE9B,IAAMC,MAAM,GAAG,SAATA,MAAM,GAAS;EACxB,IAAMC,UAAU,GAAG,IAAAC,iBAAU,EAACN,UAAU,CAAC;EACzC,IAAI,CAACK,UAAU,EAAE;IACb,MAAME,KAAK,8FAEV;EACL;EACA,OAAOF,UAAU;AACrB,CAAC;AAAC;AASK,IAAMG,GAAG,GAAG,SAANA,GAAG,OAAiF;EAAA,+BAA3EC,cAAc;IAAdA,cAAc,oCAAG,EAAE;IAAA,mBAAEC,MAAM;IAANA,MAAM,4BAAG,EAAE;IAAA,sBAAEC,SAAS;IAATA,SAAS,+BAAG,EAAE;IAAEC,QAAQ,QAARA,QAAQ;EAC5E,gBAA0B,IAAAC,eAAQ,EAAQ;MACtCH,MAAM,EAAEA,MAAM,CAACI,MAAM,CAAe,UAACC,GAAG,EAAEC,IAAI,EAAK;QAC/C,mEAAYD,GAAG,yCAAGC,IAAI,CAACC,IAAI,eAAa,6BAAC,kBAAK,EAAKD,IAAI,CAAI;MAC/D,CAAC,EAAE,CAAC,CAAC,CAAC;MACNE,OAAO,EAAE,EAAE;MACXP,SAAS,EAATA;IACJ,CAAC,CAAC;IAAA;IANKQ,KAAK;IAAEC,QAAQ;EAQtB,IAAMC,QAAQ,GAAG,IAAAC,kBAAW,EAAC,UAACC,KAA2C,EAAK;IAC1EH,QAAQ,CAAC,UAAAD,KAAK,EAAI;MACd,mEACOA,KAAK;QACRT,MAAM,8DAAOS,KAAK,CAACT,MAAM,yCAAGa,KA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,GAAG,IAAAL,cAAO,EAAC,YAAM;IAC5B,OAAOM,yBAAO,gDAAKlB,KAAK,CAACR,SAAS,IAAI,EAAE,EAAE,CAAC;MAAA,IAAGC,QAAQ,SAARA,QAAQ;MAAA,oBAClD,6BAAC,8BAAc;QAAC,IAAI,EAAEH;MAAe,GAAEG,QAAQ,CAAkB;IAAA,CACpE,CAAC;EACN,CAAC,EAAE,CAACO,KAAK,CAACR,SAAS,CAACwB,MAAM,CAAC,CAAC;EAE5BC,SAAS,CAACjC,WAAW,GAAG,WAAW;EAEnC,oBACI,6BAAC,UAAU,CAAC,QAAQ;IAAC,KAAK,EAAEE;EAAW,gBACnC,6BAAC,qCAAmB,QACfO,QAAQ,eACT,6BAAC,0BAAa,qBACV,6BAAC,SAAS,qBACN,6BAAC,wBAAe,QAAEO,KAAK,CAACD,OAAO,CAAmB,eAClD,6BAAC,8BAAc;IAAC,IAAI,EAAET;EAAe,gBACjC,6BAAC,SAAS,OAAG,CACA,CACT,CACA,CACE,CACJ;AAE9B,CAAC;AAAC;AAEFD,GAAG,CAACL,WAAW,GAAG,KAAK"}
1
+ {"version":3,"names":["React","createContext","useContext","useMemo","useState","useCallback","BrowserRouter","Route","CompositionProvider","compose","Routes","SortRoutes","DebounceRender","PluginsProvider","RouterWithConfig","useRouterConfig","AppContainer","AppContext","undefined","displayName","useApp","appContext","Error","AppBase","debounceRender","routes","providers","children","state","setState","plugins","addProvider","component","findIndex","m","addPlugin","element","AppRouter","routerConfig","combinedRoutes","map","r","createElement","path","key","length","Providers","wait","Provider","value","App","decorators","props","Object","assign"],"sources":["App.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo, useState, useCallback } from \"react\";\nimport type { RouteProps } from \"@webiny/react-router\";\nimport { BrowserRouter, Route } from \"@webiny/react-router\";\nimport type { GenericComponent, Decorator, DecoratorsCollection } from \"@webiny/react-composition\";\nimport { CompositionProvider, compose } from \"@webiny/react-composition\";\nimport { Routes as SortRoutes } from \"./core/Routes\";\nimport { DebounceRender } from \"./core/DebounceRender\";\nimport { PluginsProvider } from \"./core/Plugins\";\nimport { RouterWithConfig, useRouterConfig } from \"./config/RouterConfig\";\nimport { AppContainer } from \"./AppContainer\";\n\ninterface State {\n plugins: JSX.Element[];\n providers: Decorator<GenericComponent<ProviderProps>>[];\n}\n\ninterface AppContext extends State {\n addProvider(hoc: Decorator<GenericComponent<ProviderProps>>): void;\n\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 debounceRender?: number;\n routes?: Array<RouteProps>;\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 = ({\n debounceRender = 50,\n routes = [],\n providers = [],\n children\n}: 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: 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 routerConfig = useRouterConfig();\n const combinedRoutes = [...routes, ...routerConfig.routes].map(r => {\n return <Route path={r.path} element={r.element} key={r.path} />;\n });\n\n return <SortRoutes key={routes.length} routes={combinedRoutes} />;\n };\n }, [routes]);\n\n const Providers = useMemo(() => {\n return compose(...(state.providers || []))(({ children }: ProviderProps) => {\n return <DebounceRender wait={debounceRender}>{children}</DebounceRender>;\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 <BrowserRouter>\n <Providers>\n <PluginsProvider>{state.plugins}</PluginsProvider>\n <DebounceRender wait={debounceRender}>\n <RouterWithConfig>\n <AppRouter />\n </RouterWithConfig>\n </DebounceRender>\n </Providers>\n </BrowserRouter>\n </AppContainer>\n </AppContext.Provider>\n );\n};\n\nexport const App = ({ decorators, ...props }: AppProps) => {\n return (\n <CompositionProvider decorators={decorators}>\n <AppBase decorators={decorators} {...props} />\n </CompositionProvider>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,UAAU,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,WAAW,QAAQ,OAAO;AAExF,SAASC,aAAa,EAAEC,KAAK,QAAQ,sBAAsB;AAE3D,SAASC,mBAAmB,EAAEC,OAAO,QAAQ,2BAA2B;AACxE,SAASC,MAAM,IAAIC,UAAU;AAC7B,SAASC,cAAc;AACvB,SAASC,eAAe;AACxB,SAASC,gBAAgB,EAAEC,eAAe;AAC1C,SAASC,YAAY;AAarB,MAAMC,UAAU,gBAAGhB,aAAa,CAAyBiB,SAAS,CAAC;AAEnED,UAAU,CAACE,WAAW,GAAG,YAAY;AAErC,OAAO,MAAMC,MAAM,GAAGA,CAAA,KAAM;EACxB,MAAMC,UAAU,GAAGnB,UAAU,CAACe,UAAU,CAAC;EACzC,IAAI,CAACI,UAAU,EAAE;IACb,MAAMC,KAAK,CACP,0FACJ,CAAC;EACL;EACA,OAAOD,UAAU;AACrB,CAAC;AAgBD,OAAO,MAAME,OAAO,GAAGA,CAAC;EACpBC,cAAc,GAAG,EAAE;EACnBC,MAAM,GAAG,EAAE;EACXC,SAAS,GAAG,EAAE;EACdC;A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AAAgB,CAAC,KAAK;EACvD,oBACIpD,KAAA,CAAA0C,aAAA,CAAClC,mBAAmB;IAAC2C,UAAU,EAAEA;EAAW,gBACxCnD,KAAA,CAAA0C,aAAA,CAACnB,OAAO,EAAA8B,MAAA,CAAAC,MAAA;IAACH,UAAU,EAAEA;EAAW,GAAKC,KAAK,CAAG,CAC5B,CAAC;AAE9B,CAAC","ignoreList":[]}
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+ export interface AppContentProps {
3
+ children: React.ReactNode;
4
+ }
5
+ export declare const AppContainer: (({ children }: AppContentProps) => React.JSX.Element) & {
6
+ original: ({ children }: AppContentProps) => React.JSX.Element;
7
+ originalName: string;
8
+ displayName: string;
9
+ } & {
10
+ original: (({ children }: AppContentProps) => React.JSX.Element) & {
11
+ original: ({ children }: AppContentProps) => React.JSX.Element;
12
+ originalName: string;
13
+ displayName: string;
14
+ };
15
+ originalName: string;
16
+ displayName: string;
17
+ } & {
18
+ createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<(({ children }: AppContentProps) => React.JSX.Element) & {
19
+ original: ({ children }: AppContentProps) => React.JSX.Element;
20
+ originalName: string;
21
+ displayName: string;
22
+ }>) => (props: unknown) => React.JSX.Element;
23
+ };
@@ -0,0 +1,9 @@
1
+ import React from "react";
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
+ });
8
+
9
+ //# sourceMappingURL=AppContainer.js.map
@@ -0,0 +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,5 +1,6 @@
1
- import { InMemoryCache as BaseInMemoryCache, InMemoryCacheConfig } from "apollo-cache-inmemory";
2
- import { DocumentNode } from "graphql";
1
+ import type { InMemoryCacheConfig } from "apollo-cache-inmemory";
2
+ import { InMemoryCache as BaseInMemoryCache } from "apollo-cache-inmemory";
3
+ import type { DocumentNode } from "graphql";
3
4
  export declare class InMemoryCache extends BaseInMemoryCache {
4
5
  private readonly transformPlugins;
5
6
  constructor(config?: InMemoryCacheConfig);
@@ -1,56 +1,20 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.InMemoryCache = void 0;
8
- var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
12
- var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
13
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
- var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
16
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
- var _apolloCacheInmemory = require("apollo-cache-inmemory");
18
- var _plugins = require("@webiny/plugins");
19
- var _AddQuerySelectionPlugin = require("../plugins/AddQuerySelectionPlugin");
20
- var _ApolloLinkPlugin = require("../plugins/ApolloLinkPlugin");
21
- var InMemoryCache = /*#__PURE__*/function (_BaseInMemoryCache) {
22
- (0, _inherits2.default)(InMemoryCache, _BaseInMemoryCache);
23
- var _super = (0, _createSuper2.default)(InMemoryCache);
24
- function InMemoryCache(config) {
25
- var _this;
26
- (0, _classCallCheck2.default)(this, InMemoryCache);
27
- _this = _super.call(this, config);
28
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "transformPlugins", void 0);
29
- _this.transformPlugins = _plugins.plugins.byType(_ApolloLinkPlugin.ApolloLinkPlugin.type).filter(function (pl) {
30
- return pl instanceof _AddQuerySelectionPlugin.AddQuerySelectionPlugin;
31
- });
32
- return _this;
1
+ import { InMemoryCache as BaseInMemoryCache } from "apollo-cache-inmemory";
2
+ import { plugins } from "@webiny/plugins";
3
+ import { AddQuerySelectionPlugin } from "../plugins/AddQuerySelectionPlugin";
4
+ import { ApolloLinkPlugin } from "../plugins/ApolloLinkPlugin";
5
+ export class InMemoryCache extends BaseInMemoryCache {
6
+ constructor(config) {
7
+ super(config);
8
+ this.transformPlugins = plugins.byType(ApolloLinkPlugin.type).filter(pl => pl instanceof AddQuerySelectionPlugin);
33
9
  }
34
- (0, _createClass2.default)(InMemoryCache, [{
35
- key: "transformDocument",
36
- value: function transformDocument(document) {
37
- // @ts-ignore
38
- var operationName = document.definitions[0].name.value;
39
- var _iterator = (0, _createForOfIteratorHelper2.default)(this.transformPlugins),
40
- _step;
41
- try {
42
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
43
- var pl = _step.value;
44
- pl.addSelectionToQuery(operationName, document);
45
- }
46
- } catch (err) {
47
- _iterator.e(err);
48
- } finally {
49
- _iterator.f();
50
- }
51
- return (0, _get2.default)((0, _getPrototypeOf2.default)(InMemoryCache.prototype), "transformDocument", this).call(this, document);
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);
52
15
  }
53
- }]);
54
- return InMemoryCache;
55
- }(_apolloCacheInmemory.InMemoryCache);
56
- exports.InMemoryCache = InMemoryCache;
16
+ return super.transformDocument(document);
17
+ }
18
+ }
19
+
20
+ //# sourceMappingURL=InMemoryCache.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["InMemoryCache","config","transformPlugins","plugins","byType","ApolloLinkPlugin","type","filter","pl","AddQuerySelectionPlugin","document","operationName","definitions","name","value","addSelectionToQuery","BaseInMemoryCache"],"sources":["InMemoryCache.ts"],"sourcesContent":["import { InMemoryCache as BaseInMemoryCache, InMemoryCacheConfig } from \"apollo-cache-inmemory\";\nimport { DocumentNode } from \"graphql\";\nimport { plugins } from \"@webiny/plugins\";\nimport { AddQuerySelectionPlugin } from \"../plugins/AddQuerySelectionPlugin\";\nimport { ApolloLinkPlugin } from \"../plugins/ApolloLinkPlugin\";\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-ignore\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":";;;;;;;;;;;;;;;;AAAA;AAEA;AACA;AACA;AAA+D,IAElDA,aAAa;EAAA;EAAA;EAGtB,uBAAYC,MAA4B,EAAE;IAAA;IAAA;IACtC,0BAAMA,MAAM;IAAE;IAEd,MAAKC,gBAAgB,GAAGC,gBAAO,CAC1BC,MAAM,CAA0BC,kCAAgB,CAACC,IAAI,CAAC,CACtDC,MAAM,CAAC,UAAAC,EAAE;MAAA,OAAIA,EAAE,YAAYC,gDAAuB;IAAA,EAAC;IAAC;EAC7D;EAAC;IAAA;IAAA,OAED,2BAAkCC,QAAsB,EAAgB;MACpE;MACA,IAAMC,aAAa,GAAGD,QAAQ,CAACE,WAAW,CAAC,CAAC,CAAC,CAACC,IAAI,CAACC,KAAK;MAAC,yDAExC,IAAI,CAACZ,gBAAgB;QAAA;MAAA;QAAtC,oDAAwC;UAAA,IAA7BM,EAAE;UACTA,EAAE,CAACO,mBAAmB,CAACJ,aAAa,EAAED,QAAQ,CAAC;QACnD;MAAC;QAAA;MAAA;QAAA;MAAA;MAED,wHAA+BA,QAAQ;IAC3C;EAAC;EAAA;AAAA,EApB8BM,kCAAiB;AAAA"}
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\";\nimport { ApolloLinkPlugin } from \"../plugins/ApolloLinkPlugin\";\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":[]}
@@ -0,0 +1,11 @@
1
+ import type { IdValue } from "apollo-utilities";
2
+ import type { ReadStoreContext, FragmentMatcherInterface, IntrospectionResultData } from "apollo-cache-inmemory";
3
+ export declare class IntrospectionFragmentMatcher implements FragmentMatcherInterface {
4
+ private readonly isReady;
5
+ private readonly possibleTypesMap;
6
+ constructor(options?: {
7
+ introspectionQueryResultData?: IntrospectionResultData;
8
+ });
9
+ match(idValue: IdValue, typeCondition: string, context: ReadStoreContext): boolean;
10
+ private parseIntrospectionResult;
11
+ }
@@ -0,0 +1,45 @@
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;
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;
20
+ }
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;
27
+ }
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
+ }
44
+
45
+ //# sourceMappingURL=IntrospectionFragmentMatcher.js.map
@@ -0,0 +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,G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,CAACC,GAAG,CACvCC,gBAAgB,IAAIA,gBAAgB,CAACH,IACzC,CAAC;MACL;IACJ,CAAC,CAAC;IACF,OAAON,OAAO;EAClB;AACJ","ignoreList":[]}
@@ -1,3 +1,3 @@
1
- import * as React from "react";
2
- import { ImageProps } from "../types";
3
- export declare const Image: React.FC<ImageProps>;
1
+ /// <reference types="react" />
2
+ import type { ImageProps } from "../types";
3
+ export declare const Image: ({ preset: presetName, ...props }: ImageProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
@@ -1,25 +1,17 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.Image = void 0;
8
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
9
- var _get2 = _interopRequireDefault(require("lodash/get"));
10
- var _invariant = _interopRequireDefault(require("invariant"));
11
- var _plugins = require("@webiny/plugins");
12
- var _excluded = ["preset"];
13
- var Image = function Image(_ref) {
14
- var presetName = _ref.preset,
15
- props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
16
- var plugin = _plugins.plugins.byName("image-component");
1
+ import invariant from "invariant";
2
+ import { plugins } from "@webiny/plugins";
3
+ import get from "lodash/get";
4
+ export const Image = ({
5
+ preset: presetName,
6
+ ...props
7
+ }) => {
8
+ const plugin = plugins.byName("image-component");
17
9
  if (!plugin) {
18
- throw new Error("Image component plugin (type \"image-component\") not defined.");
10
+ throw new Error(`Image component plugin (type "image-component") not defined.`);
19
11
  }
20
12
  if (presetName) {
21
- var preset = (0, _get2.default)(plugin, "presets.".concat(presetName));
22
- (0, _invariant.default)(preset, "Transform preset \"".concat(presetName, "\" not found."));
13
+ const preset = get(plugin, `presets.${presetName}`);
14
+ invariant(preset, `Transform preset "${presetName}" not found.`);
23
15
  props.transform = preset;
24
16
  }
25
17
  if (props.transform) {
@@ -27,4 +19,5 @@ var Image = function Image(_ref) {
27
19
  }
28
20
  return plugin.render(props);
29
21
  };
30
- exports.Image = Image;
22
+
23
+ //# sourceMappingURL=Image.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Image","presetName","preset","props","plugin","plugins","byName","Error","invariant","transform","src","getImageSrc","render"],"sources":["Image.tsx"],"sourcesContent":["import * as React from \"react\";\nimport invariant from \"invariant\";\nimport { plugins } from \"@webiny/plugins\";\nimport { get } from \"lodash\";\nimport { ImageComponentPlugin, ImageProps } from \"~/types\";\n\nexport const Image: React.FC<ImageProps> = ({ preset: presetName, ...props }) => {\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":";;;;;;;;;AACA;AACA;AAA0C;AAInC,IAAMA,KAA2B,GAAG,SAA9BA,KAA2B,OAAyC;EAAA,IAA3BC,UAAU,QAAlBC,MAAM;IAAiBC,KAAK;EACtE,IAAMC,MAAM,GAAGC,gBAAO,CAACC,MAAM,CAAuB,iBAAiB,CAAC;EACtE,IAAI,CAACF,MAAM,EAAE;IACT,MAAM,IAAIG,KAAK,kEAAgE;EACnF;EAEA,IAAIN,UAAU,EAAE;IACZ,IAAMC,MAAM,GAAG,mBAAIE,MAAM,oBAAaH,UAAU,EAAG;IACnD,IAAAO,kBAAS,EAACN,MAAM,+BAAuBD,UAAU,mBAAe;IAChEE,KAAK,CAACM,SAAS,GAAGP,MAAM;EAC5B;EAEA,IAAIC,KAAK,CAACM,SAAS,EAAE;IACjBN,KAAK,CAACO,GAAG,GAAGN,MAAM,CAACO,WAAW,CAACR,KAAK,CAAC;EACzC;EAEA,OAAOC,MAAM,CAACQ,MAAM,CAACT,KAAK,CAAC;AAC/B,CAAC;AAAC"}
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\";\nimport type { ImageComponentPlugin, ImageProps } from \"~/types\";\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,YAAY;AAG5B,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,2 +1,2 @@
1
- /// <reference types="react" />
2
- export declare const Routes: () => JSX.Element;
1
+ import React from "react";
2
+ export declare const Routes: () => React.JSX.Element;
@@ -1,22 +1,13 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.Routes = void 0;
8
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
- var _react = _interopRequireDefault(require("react"));
10
- var _plugins = require("@webiny/plugins");
11
- var _reactRouter = require("@webiny/react-router");
12
1
  // This file is necessary only for backwards compatibility.
13
2
  // We'll remove this once the legacy rendering engine is removed.
14
-
15
- var Routes = function Routes() {
3
+ import React from "react";
4
+ import { plugins } from "@webiny/plugins";
5
+ import { Routes as ReactRouterRoutes } from "@webiny/react-router";
6
+ export const Routes = () => {
16
7
  // We cannot call `sort` on the array returned by the `plugins.byType` call - it is read-only.
17
- var routes = (0, _toConsumableArray2.default)(_plugins.plugins.byType("route")).sort(function (a, b) {
18
- var pathA = a.route.props.path || "*";
19
- var pathB = b.route.props.path || "*";
8
+ const routes = [...plugins.byType("route")].sort((a, b) => {
9
+ const pathA = a.route.props.path || "*";
10
+ const pathB = b.route.props.path || "*";
20
11
 
21
12
  // This will sort paths at the very bottom of the list
22
13
  if (pathA === "/" && pathB === "*") {
@@ -34,12 +25,12 @@ var Routes = function Routes() {
34
25
  }
35
26
  return 0;
36
27
  });
37
- return /*#__PURE__*/_react.default.createElement(_reactRouter.Routes, null, routes.map(function (_ref) {
38
- var route = _ref.route,
39
- name = _ref.name;
40
- return /*#__PURE__*/_react.default.cloneElement(route, {
41
- key: name
42
- });
43
- }));
28
+ return /*#__PURE__*/React.createElement(ReactRouterRoutes, null, routes.map(({
29
+ route,
30
+ name
31
+ }) => /*#__PURE__*/React.cloneElement(route, {
32
+ key: name
33
+ })));
44
34
  };
45
- exports.Routes = Routes;
35
+
36
+ //# sourceMappingURL=Routes.js.map