@webiny/app 5.34.8 → 5.35.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 (140) hide show
  1. package/App.js +15 -37
  2. package/App.js.map +1 -1
  3. package/apollo-client/InMemoryCache.js +1 -24
  4. package/apollo-client/InMemoryCache.js.map +1 -1
  5. package/components/Image.js +1 -14
  6. package/components/Image.js.map +1 -1
  7. package/components/Routes.js +8 -14
  8. package/components/Routes.js.map +1 -1
  9. package/components/View.js +3 -14
  10. package/components/View.js.map +1 -1
  11. package/components/index.js +0 -2
  12. package/components/index.js.map +1 -1
  13. package/config.js +0 -3
  14. package/config.js.map +1 -1
  15. package/contexts/Ui/index.js +0 -22
  16. package/contexts/Ui/index.js.map +1 -1
  17. package/core/AddRoute.js +1 -8
  18. package/core/AddRoute.js.map +1 -1
  19. package/core/DebounceRender.js +5 -15
  20. package/core/DebounceRender.js.map +1 -1
  21. package/core/Plugin.d.ts +8 -0
  22. package/core/Plugin.js +21 -0
  23. package/core/Plugin.js.map +1 -0
  24. package/core/Plugins.d.ts +4 -0
  25. package/core/Plugins.js +6 -13
  26. package/core/Plugins.js.map +1 -1
  27. package/core/Provider.js +1 -7
  28. package/core/Provider.js.map +1 -1
  29. package/core/Routes.js +6 -13
  30. package/core/Routes.js.map +1 -1
  31. package/core/createProvider.d.ts +6 -0
  32. package/core/createProvider.js +13 -0
  33. package/core/createProvider.js.map +1 -0
  34. package/core/createProviderPlugin.d.ts +0 -1
  35. package/core/createProviderPlugin.js +1 -12
  36. package/core/createProviderPlugin.js.map +1 -1
  37. package/hooks/useAutocomplete/index.js +0 -1
  38. package/hooks/useAutocomplete/index.js.map +1 -1
  39. package/hooks/useAutocomplete/useAutocomplete.js +0 -9
  40. package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
  41. package/hooks/useDataList/functions/getData.js +0 -4
  42. package/hooks/useDataList/functions/getData.js.map +1 -1
  43. package/hooks/useDataList/functions/getError.js +0 -4
  44. package/hooks/useDataList/functions/getError.js.map +1 -1
  45. package/hooks/useDataList/functions/getMeta.js +0 -4
  46. package/hooks/useDataList/functions/getMeta.js.map +1 -1
  47. package/hooks/useDataList/functions/index.js +0 -4
  48. package/hooks/useDataList/functions/index.js.map +1 -1
  49. package/hooks/useDataList/functions/searchDataByKey.js +0 -6
  50. package/hooks/useDataList/functions/searchDataByKey.js.map +1 -1
  51. package/hooks/useDataList/index.js +0 -1
  52. package/hooks/useDataList/index.js.map +1 -1
  53. package/hooks/useDataList/useDataList.js +6 -32
  54. package/hooks/useDataList/useDataList.js.map +1 -1
  55. package/hooks/useDataList/utils/index.js +0 -3
  56. package/hooks/useDataList/utils/index.js.map +1 -1
  57. package/hooks/useDataList/utils/prepareLoadListParams.js +0 -10
  58. package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
  59. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +1 -3
  60. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +1 -1
  61. package/hooks/useHandler.js +0 -2
  62. package/hooks/useHandler.js.map +1 -1
  63. package/hooks/useHandlers.js +0 -3
  64. package/hooks/useHandlers.js.map +1 -1
  65. package/hooks/useUi.js +0 -4
  66. package/hooks/useUi.js.map +1 -1
  67. package/i18n/i18n.js +0 -7
  68. package/i18n/i18n.js.map +1 -1
  69. package/i18n/index.js +0 -2
  70. package/i18n/index.js.map +1 -1
  71. package/index.d.ts +2 -0
  72. package/index.js +24 -18
  73. package/index.js.map +1 -1
  74. package/package.json +12 -12
  75. package/plugins/AddQuerySelectionPlugin.d.ts +8 -1
  76. package/plugins/AddQuerySelectionPlugin.js +31 -41
  77. package/plugins/AddQuerySelectionPlugin.js.map +1 -1
  78. package/plugins/ApolloCacheObjectIdPlugin.js +0 -15
  79. package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -1
  80. package/plugins/ApolloDynamicLink.js +0 -23
  81. package/plugins/ApolloDynamicLink.js.map +1 -1
  82. package/plugins/ApolloLinkPlugin.js +0 -17
  83. package/plugins/ApolloLinkPlugin.js.map +1 -1
  84. package/plugins/ConsoleLinkPlugin.js +0 -15
  85. package/plugins/ConsoleLinkPlugin.js.map +1 -1
  86. package/plugins/LocaleHeaderLinkPlugin.d.ts +0 -5
  87. package/plugins/LocaleHeaderLinkPlugin.js +2 -26
  88. package/plugins/LocaleHeaderLinkPlugin.js.map +1 -1
  89. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +5 -25
  90. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
  91. package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +9 -3
  92. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +0 -3
  93. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
  94. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +8 -15
  95. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
  96. package/plugins/NetworkErrorLinkPlugin.js +3 -20
  97. package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
  98. package/plugins/OmitTypenameLinkPlugin.js +1 -15
  99. package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
  100. package/plugins/RoutePlugin.js +0 -15
  101. package/plugins/RoutePlugin.js.map +1 -1
  102. package/plugins/TenantHeaderLinkPlugin.d.ts +0 -5
  103. package/plugins/TenantHeaderLinkPlugin.js +2 -27
  104. package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
  105. package/plugins/ViewPlugin.js +0 -15
  106. package/plugins/ViewPlugin.js.map +1 -1
  107. package/plugins/image.js +12 -45
  108. package/plugins/image.js.map +1 -1
  109. package/plugins/index.js +12 -33
  110. package/plugins/index.js.map +1 -1
  111. package/types.d.ts +4 -2
  112. package/types.js +0 -1
  113. package/types.js.map +1 -1
  114. package/utils/getApiUrl.d.ts +1 -0
  115. package/utils/getApiUrl.js +11 -0
  116. package/utils/getApiUrl.js.map +1 -0
  117. package/utils/getGqlApiUrl.d.ts +1 -0
  118. package/utils/getGqlApiUrl.js +11 -0
  119. package/utils/getGqlApiUrl.js.map +1 -0
  120. package/utils/getHeadlessCmsGqlApiUrl.d.ts +5 -0
  121. package/utils/getHeadlessCmsGqlApiUrl.js +17 -0
  122. package/utils/getHeadlessCmsGqlApiUrl.js.map +1 -0
  123. package/utils/getLocaleCode.d.ts +6 -0
  124. package/utils/getLocaleCode.js +42 -0
  125. package/utils/getLocaleCode.js.map +1 -0
  126. package/utils/getPrerenderId.d.ts +6 -0
  127. package/utils/getPrerenderId.js +10 -0
  128. package/utils/getPrerenderId.js.map +1 -0
  129. package/utils/getTenantId.d.ts +6 -0
  130. package/utils/getTenantId.js +34 -0
  131. package/utils/getTenantId.js.map +1 -0
  132. package/utils/index.d.ts +8 -0
  133. package/utils/index.js +93 -0
  134. package/utils/index.js.map +1 -0
  135. package/utils/isLocalhost.d.ts +1 -0
  136. package/utils/isLocalhost.js +14 -0
  137. package/utils/isLocalhost.js.map +1 -0
  138. package/utils/isPrerendering.d.ts +1 -0
  139. package/utils/isPrerendering.js +10 -0
  140. package/utils/isPrerendering.js.map +1 -0
package/App.js CHANGED
@@ -1,69 +1,49 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
-
5
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports.useApp = exports.App = void 0;
11
-
12
9
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
-
14
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
-
16
11
  var _objectSpread4 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
17
-
18
12
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
19
-
20
13
  var _react = _interopRequireWildcard(require("react"));
21
-
22
14
  var _reactRouter = require("@webiny/react-router");
23
-
24
15
  var _reactComposition = require("@webiny/react-composition");
25
-
26
16
  var _Routes = require("./core/Routes");
27
-
28
17
  var _DebounceRender = require("./core/DebounceRender");
29
-
30
18
  var _Plugins = require("./core/Plugins");
31
-
32
19
  var AppContext = /*#__PURE__*/(0, _react.createContext)(undefined);
33
20
  AppContext.displayName = "AppContext";
34
-
35
21
  var useApp = function useApp() {
36
22
  var appContext = (0, _react.useContext)(AppContext);
37
-
38
23
  if (!appContext) {
39
24
  throw Error("AppContext provider was not found. Are you using the \"useApp()\" hook in the right place?");
40
25
  }
41
-
42
26
  return appContext;
43
27
  };
44
-
45
28
  exports.useApp = useApp;
46
-
47
29
  var App = function App(_ref) {
48
30
  var _ref$debounceRender = _ref.debounceRender,
49
- debounceRender = _ref$debounceRender === void 0 ? 50 : _ref$debounceRender,
50
- _ref$routes = _ref.routes,
51
- routes = _ref$routes === void 0 ? [] : _ref$routes,
52
- _ref$providers = _ref.providers,
53
- providers = _ref$providers === void 0 ? [] : _ref$providers,
54
- children = _ref.children;
55
-
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;
56
37
  var _useState = (0, _react.useState)({
57
- routes: routes.reduce(function (acc, item) {
58
- return (0, _objectSpread4.default)((0, _objectSpread4.default)({}, acc), {}, (0, _defineProperty2.default)({}, item.path, /*#__PURE__*/_react.default.createElement(_reactRouter.Route, item)));
59
- }, {}),
60
- plugins: [],
61
- providers: providers
62
- }),
63
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
64
- state = _useState2[0],
65
- setState = _useState2[1];
66
-
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];
67
47
  var addRoute = (0, _react.useCallback)(function (route) {
68
48
  setState(function (state) {
69
49
  return (0, _objectSpread4.default)((0, _objectSpread4.default)({}, state), {}, {
@@ -78,7 +58,6 @@ var App = function App(_ref) {
78
58
  }) > -1) {
79
59
  return state;
80
60
  }
81
-
82
61
  return (0, _objectSpread4.default)((0, _objectSpread4.default)({}, state), {}, {
83
62
  providers: [].concat((0, _toConsumableArray2.default)(state.providers), [component])
84
63
  });
@@ -122,6 +101,5 @@ var App = function App(_ref) {
122
101
  wait: debounceRender
123
102
  }, /*#__PURE__*/_react.default.createElement(AppRouter, null))))));
124
103
  };
125
-
126
104
  exports.App = App;
127
105
  App.displayName = "App";
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":"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"}
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":"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"}
@@ -1,46 +1,28 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.InMemoryCache = void 0;
9
-
10
8
  var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
11
-
12
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
11
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
-
18
12
  var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
19
-
20
13
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
-
22
14
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
23
-
24
15
  var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
25
-
26
16
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
27
-
28
17
  var _apolloCacheInmemory = require("apollo-cache-inmemory");
29
-
30
18
  var _plugins = require("@webiny/plugins");
31
-
32
19
  var _AddQuerySelectionPlugin = require("../plugins/AddQuerySelectionPlugin");
33
-
34
20
  var _ApolloLinkPlugin = require("../plugins/ApolloLinkPlugin");
35
-
36
21
  var InMemoryCache = /*#__PURE__*/function (_BaseInMemoryCache) {
37
22
  (0, _inherits2.default)(InMemoryCache, _BaseInMemoryCache);
38
-
39
23
  var _super = (0, _createSuper2.default)(InMemoryCache);
40
-
41
24
  function InMemoryCache(config) {
42
25
  var _this;
43
-
44
26
  (0, _classCallCheck2.default)(this, InMemoryCache);
45
27
  _this = _super.call(this, config);
46
28
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "transformPlugins", void 0);
@@ -49,16 +31,13 @@ var InMemoryCache = /*#__PURE__*/function (_BaseInMemoryCache) {
49
31
  });
50
32
  return _this;
51
33
  }
52
-
53
34
  (0, _createClass2.default)(InMemoryCache, [{
54
35
  key: "transformDocument",
55
36
  value: function transformDocument(document) {
56
37
  // @ts-ignore
57
38
  var operationName = document.definitions[0].name.value;
58
-
59
39
  var _iterator = (0, _createForOfIteratorHelper2.default)(this.transformPlugins),
60
- _step;
61
-
40
+ _step;
62
41
  try {
63
42
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
64
43
  var pl = _step.value;
@@ -69,11 +48,9 @@ var InMemoryCache = /*#__PURE__*/function (_BaseInMemoryCache) {
69
48
  } finally {
70
49
  _iterator.f();
71
50
  }
72
-
73
51
  return (0, _get2.default)((0, _getPrototypeOf2.default)(InMemoryCache.prototype), "transformDocument", this).call(this, document);
74
52
  }
75
53
  }]);
76
54
  return InMemoryCache;
77
55
  }(_apolloCacheInmemory.InMemoryCache);
78
-
79
56
  exports.InMemoryCache = InMemoryCache;
@@ -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;;IAEaA,a;;;;;EAGT,uBAAYC,MAAZ,EAA0C;IAAA;;IAAA;IACtC,0BAAMA,MAAN;IADsC;IAGtC,MAAKC,gBAAL,GAAwBC,gBAAA,CACnBC,MADmB,CACaC,kCAAA,CAAiBC,IAD9B,EAEnBC,MAFmB,CAEZ,UAAAC,EAAE;MAAA,OAAIA,EAAE,YAAYC,gDAAlB;IAAA,CAFU,CAAxB;IAHsC;EAMzC;;;;WAED,2BAAkCC,QAAlC,EAAwE;MACpE;MACA,IAAMC,aAAa,GAAGD,QAAQ,CAACE,WAAT,CAAqB,CAArB,EAAwBC,IAAxB,CAA6BC,KAAnD;;MAFoE,yDAInD,KAAKZ,gBAJ8C;MAAA;;MAAA;QAIpE,oDAAwC;UAAA,IAA7BM,EAA6B;UACpCA,EAAE,CAACO,mBAAH,CAAuBJ,aAAvB,EAAsCD,QAAtC;QACH;MANmE;QAAA;MAAA;QAAA;MAAA;;MAQpE,wHAA+BA,QAA/B;IACH;;;EApB8BM,kC"}
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,43 +1,30 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.Image = void 0;
9
-
10
8
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
-
12
9
  var _get2 = _interopRequireDefault(require("lodash/get"));
13
-
14
10
  var _invariant = _interopRequireDefault(require("invariant"));
15
-
16
11
  var _plugins = require("@webiny/plugins");
17
-
18
12
  var _excluded = ["preset"];
19
-
20
13
  var Image = function Image(_ref) {
21
14
  var presetName = _ref.preset,
22
- props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
23
-
15
+ props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
24
16
  var plugin = _plugins.plugins.byName("image-component");
25
-
26
17
  if (!plugin) {
27
18
  throw new Error("Image component plugin (type \"image-component\") not defined.");
28
19
  }
29
-
30
20
  if (presetName) {
31
21
  var preset = (0, _get2.default)(plugin, "presets.".concat(presetName));
32
22
  (0, _invariant.default)(preset, "Transform preset \"".concat(presetName, "\" not found."));
33
23
  props.transform = preset;
34
24
  }
35
-
36
25
  if (props.transform) {
37
26
  props.src = plugin.getImageSrc(props);
38
27
  }
39
-
40
28
  return plugin.render(props);
41
29
  };
42
-
43
30
  exports.Image = Image;
@@ -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;;;;AAIO,IAAMA,KAA2B,GAAG,SAA9BA,KAA8B,OAAsC;EAAA,IAA3BC,UAA2B,QAAnCC,MAAmC;EAAA,IAAZC,KAAY;;EAC7E,IAAMC,MAAM,GAAGC,gBAAA,CAAQC,MAAR,CAAqC,iBAArC,CAAf;;EACA,IAAI,CAACF,MAAL,EAAa;IACT,MAAM,IAAIG,KAAJ,kEAAN;EACH;;EAED,IAAIN,UAAJ,EAAgB;IACZ,IAAMC,MAAM,GAAG,mBAAIE,MAAJ,oBAAuBH,UAAvB,EAAf;IACA,IAAAO,kBAAA,EAAUN,MAAV,+BAAuCD,UAAvC;IACAE,KAAK,CAACM,SAAN,GAAkBP,MAAlB;EACH;;EAED,IAAIC,KAAK,CAACM,SAAV,EAAqB;IACjBN,KAAK,CAACO,GAAN,GAAYN,MAAM,CAACO,WAAP,CAAmBR,KAAnB,CAAZ;EACH;;EAED,OAAOC,MAAM,CAACQ,MAAP,CAAcT,KAAd,CAAP;AACH,CAjBM"}
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,51 +1,45 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.Routes = void 0;
9
-
10
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
-
12
9
  var _react = _interopRequireDefault(require("react"));
13
-
14
10
  var _plugins = require("@webiny/plugins");
15
-
16
11
  var _reactRouter = require("@webiny/react-router");
17
-
18
12
  // This file is necessary only for backwards compatibility.
19
13
  // We'll remove this once the legacy rendering engine is removed.
14
+
20
15
  var Routes = function Routes() {
21
16
  // We cannot call `sort` on the array returned by the `plugins.byType` call - it is read-only.
22
17
  var routes = (0, _toConsumableArray2.default)(_plugins.plugins.byType("route")).sort(function (a, b) {
23
18
  var pathA = a.route.props.path || "*";
24
- var pathB = b.route.props.path || "*"; // This will sort paths at the very bottom of the list
19
+ var pathB = b.route.props.path || "*";
25
20
 
21
+ // This will sort paths at the very bottom of the list
26
22
  if (pathA === "/" && pathB === "*") {
27
23
  return -1;
28
- } // This will push * and / to the bottom of the list
29
-
24
+ }
30
25
 
26
+ // This will push * and / to the bottom of the list
31
27
  if (pathA === "*" || pathA === "/") {
32
28
  return 1;
33
- } // This will push * and / to the bottom of the list
34
-
29
+ }
35
30
 
31
+ // This will push * and / to the bottom of the list
36
32
  if (["*", "/"].includes(pathB)) {
37
33
  return -1;
38
34
  }
39
-
40
35
  return 0;
41
36
  });
42
37
  return /*#__PURE__*/_react.default.createElement(_reactRouter.Routes, null, routes.map(function (_ref) {
43
38
  var route = _ref.route,
44
- name = _ref.name;
39
+ name = _ref.name;
45
40
  return /*#__PURE__*/_react.default.cloneElement(route, {
46
41
  key: name
47
42
  });
48
43
  }));
49
44
  };
50
-
51
45
  exports.Routes = Routes;
@@ -1 +1 @@
1
- {"version":3,"names":["Routes","routes","plugins","byType","sort","a","b","pathA","route","props","path","pathB","includes","map","name","React","cloneElement","key"],"sources":["Routes.tsx"],"sourcesContent":["// This file is necessary only for backwards compatibility.\n// We'll remove this once the legacy rendering engine is removed.\nimport React from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { Routes as ReactRouterRoutes } from \"@webiny/react-router\";\nimport { RoutePlugin } from \"../types\";\n\nexport const Routes = () => {\n // We cannot call `sort` on the array returned by the `plugins.byType` call - it is read-only.\n const routes = [...plugins.byType<RoutePlugin>(\"route\")].sort((a, b) => {\n const pathA = a.route.props.path || \"*\";\n const pathB = b.route.props.path || \"*\";\n\n // This will sort paths at the very bottom of the list\n if (pathA === \"/\" && pathB === \"*\") {\n return -1;\n }\n\n // This will push * and / to the bottom of the list\n if (pathA === \"*\" || pathA === \"/\") {\n return 1;\n }\n\n // This will push * and / to the bottom of the list\n if ([\"*\", \"/\"].includes(pathB)) {\n return -1;\n }\n\n return 0;\n });\n\n return (\n <ReactRouterRoutes>\n {routes.map(({ route, name }) => React.cloneElement(route, { key: name }))}\n </ReactRouterRoutes>\n );\n};\n"],"mappings":";;;;;;;;;;;AAEA;;AACA;;AACA;;AAJA;AACA;AAMO,IAAMA,MAAM,GAAG,SAATA,MAAS,GAAM;EACxB;EACA,IAAMC,MAAM,GAAG,iCAAIC,gBAAA,CAAQC,MAAR,CAA4B,OAA5B,CAAJ,EAA0CC,IAA1C,CAA+C,UAACC,CAAD,EAAIC,CAAJ,EAAU;IACpE,IAAMC,KAAK,GAAGF,CAAC,CAACG,KAAF,CAAQC,KAAR,CAAcC,IAAd,IAAsB,GAApC;IACA,IAAMC,KAAK,GAAGL,CAAC,CAACE,KAAF,CAAQC,KAAR,CAAcC,IAAd,IAAsB,GAApC,CAFoE,CAIpE;;IACA,IAAIH,KAAK,KAAK,GAAV,IAAiBI,KAAK,KAAK,GAA/B,EAAoC;MAChC,OAAO,CAAC,CAAR;IACH,CAPmE,CASpE;;;IACA,IAAIJ,KAAK,KAAK,GAAV,IAAiBA,KAAK,KAAK,GAA/B,EAAoC;MAChC,OAAO,CAAP;IACH,CAZmE,CAcpE;;;IACA,IAAI,CAAC,GAAD,EAAM,GAAN,EAAWK,QAAX,CAAoBD,KAApB,CAAJ,EAAgC;MAC5B,OAAO,CAAC,CAAR;IACH;;IAED,OAAO,CAAP;EACH,CApBc,CAAf;EAsBA,oBACI,6BAAC,mBAAD,QACKV,MAAM,CAACY,GAAP,CAAW;IAAA,IAAGL,KAAH,QAAGA,KAAH;IAAA,IAAUM,IAAV,QAAUA,IAAV;IAAA,oBAAqBC,cAAA,CAAMC,YAAN,CAAmBR,KAAnB,EAA0B;MAAES,GAAG,EAAEH;IAAP,CAA1B,CAArB;EAAA,CAAX,CADL,CADJ;AAKH,CA7BM"}
1
+ {"version":3,"names":["Routes","routes","plugins","byType","sort","a","b","pathA","route","props","path","pathB","includes","map","name","React","cloneElement","key"],"sources":["Routes.tsx"],"sourcesContent":["// This file is necessary only for backwards compatibility.\n// We'll remove this once the legacy rendering engine is removed.\nimport React from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { Routes as ReactRouterRoutes } from \"@webiny/react-router\";\nimport { RoutePlugin } from \"../types\";\n\nexport const Routes = () => {\n // We cannot call `sort` on the array returned by the `plugins.byType` call - it is read-only.\n const routes = [...plugins.byType<RoutePlugin>(\"route\")].sort((a, b) => {\n const pathA = a.route.props.path || \"*\";\n const pathB = b.route.props.path || \"*\";\n\n // This will sort paths at the very bottom of the list\n if (pathA === \"/\" && pathB === \"*\") {\n return -1;\n }\n\n // This will push * and / to the bottom of the list\n if (pathA === \"*\" || pathA === \"/\") {\n return 1;\n }\n\n // This will push * and / to the bottom of the list\n if ([\"*\", \"/\"].includes(pathB)) {\n return -1;\n }\n\n return 0;\n });\n\n return (\n <ReactRouterRoutes>\n {routes.map(({ route, name }) => React.cloneElement(route, { key: name }))}\n </ReactRouterRoutes>\n );\n};\n"],"mappings":";;;;;;;;AAEA;AACA;AACA;AAJA;AACA;;AAMO,IAAMA,MAAM,GAAG,SAATA,MAAM,GAAS;EACxB;EACA,IAAMC,MAAM,GAAG,iCAAIC,gBAAO,CAACC,MAAM,CAAc,OAAO,CAAC,EAAEC,IAAI,CAAC,UAACC,CAAC,EAAEC,CAAC,EAAK;IACpE,IAAMC,KAAK,GAAGF,CAAC,CAACG,KAAK,CAACC,KAAK,CAACC,IAAI,IAAI,GAAG;IACvC,IAAMC,KAAK,GAAGL,CAAC,CAACE,KAAK,CAACC,KAAK,CAACC,IAAI,IAAI,GAAG;;IAEvC;IACA,IAAIH,KAAK,KAAK,GAAG,IAAII,KAAK,KAAK,GAAG,EAAE;MAChC,OAAO,CAAC,CAAC;IACb;;IAEA;IACA,IAAIJ,KAAK,KAAK,GAAG,IAAIA,KAAK,KAAK,GAAG,EAAE;MAChC,OAAO,CAAC;IACZ;;IAEA;IACA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAACK,QAAQ,CAACD,KAAK,CAAC,EAAE;MAC5B,OAAO,CAAC,CAAC;IACb;IAEA,OAAO,CAAC;EACZ,CAAC,CAAC;EAEF,oBACI,6BAAC,mBAAiB,QACbV,MAAM,CAACY,GAAG,CAAC;IAAA,IAAGL,KAAK,QAALA,KAAK;MAAEM,IAAI,QAAJA,IAAI;IAAA,oBAAOC,cAAK,CAACC,YAAY,CAACR,KAAK,EAAE;MAAES,GAAG,EAAEH;IAAK,CAAC,CAAC;EAAA,EAAC,CAC1D;AAE5B,CAAC;AAAC"}
@@ -1,32 +1,23 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
-
5
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports.View = void 0;
11
-
12
9
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
13
-
14
10
  var _react = _interopRequireWildcard(require("react"));
15
-
16
11
  var _plugins = require("@webiny/plugins");
17
-
18
12
  var _ViewPlugin = require("../plugins/ViewPlugin");
19
-
20
13
  var View = function View(_ref) {
21
14
  var name = _ref.name,
22
- children = _ref.children,
23
- _ref$props = _ref.props,
24
- props = _ref$props === void 0 ? {} : _ref$props;
25
-
15
+ children = _ref.children,
16
+ _ref$props = _ref.props,
17
+ props = _ref$props === void 0 ? {} : _ref$props;
26
18
  var viewPlugins = _plugins.plugins.byType(_ViewPlugin.ViewPlugin.type).filter(function (pl) {
27
19
  return pl.key === name;
28
20
  });
29
-
30
21
  if (viewPlugins.length) {
31
22
  children = viewPlugins.reduce(function (el, pl) {
32
23
  return pl.render((0, _objectSpread2.default)({
@@ -34,8 +25,6 @@ var View = function View(_ref) {
34
25
  }, props));
35
26
  }, children);
36
27
  }
37
-
38
28
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, children || null);
39
29
  };
40
-
41
30
  exports.View = View;
@@ -1 +1 @@
1
- {"version":3,"names":["View","name","children","props","viewPlugins","plugins","byType","ViewPlugin","type","filter","pl","key","length","reduce","el","render"],"sources":["View.tsx"],"sourcesContent":["import React, { Fragment } from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { ViewPlugin } from \"../plugins/ViewPlugin\";\n\ninterface Props {\n name: string;\n props?: Record<string, any>;\n children?: React.ReactNode;\n}\n\nexport const View = ({ name, children, props = {} }: Props) => {\n const viewPlugins = plugins.byType<ViewPlugin>(ViewPlugin.type).filter(pl => pl.key === name);\n\n if (viewPlugins.length) {\n children = viewPlugins.reduce((el, pl) => pl.render({ children: el, ...props }), children);\n }\n\n return <Fragment>{children || null}</Fragment>;\n};\n"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAQO,IAAMA,IAAI,GAAG,SAAPA,IAAO,OAA2C;EAAA,IAAxCC,IAAwC,QAAxCA,IAAwC;EAAA,IAAlCC,QAAkC,QAAlCA,QAAkC;EAAA,sBAAxBC,KAAwB;EAAA,IAAxBA,KAAwB,2BAAhB,EAAgB;;EAC3D,IAAMC,WAAW,GAAGC,gBAAA,CAAQC,MAAR,CAA2BC,sBAAA,CAAWC,IAAtC,EAA4CC,MAA5C,CAAmD,UAAAC,EAAE;IAAA,OAAIA,EAAE,CAACC,GAAH,KAAWV,IAAf;EAAA,CAArD,CAApB;;EAEA,IAAIG,WAAW,CAACQ,MAAhB,EAAwB;IACpBV,QAAQ,GAAGE,WAAW,CAACS,MAAZ,CAAmB,UAACC,EAAD,EAAKJ,EAAL;MAAA,OAAYA,EAAE,CAACK,MAAH;QAAYb,QAAQ,EAAEY;MAAtB,GAA6BX,KAA7B,EAAZ;IAAA,CAAnB,EAAsED,QAAtE,CAAX;EACH;;EAED,oBAAO,6BAAC,eAAD,QAAWA,QAAQ,IAAI,IAAvB,CAAP;AACH,CARM"}
1
+ {"version":3,"names":["View","name","children","props","viewPlugins","plugins","byType","ViewPlugin","type","filter","pl","key","length","reduce","el","render"],"sources":["View.tsx"],"sourcesContent":["import React, { Fragment } from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { ViewPlugin } from \"../plugins/ViewPlugin\";\n\ninterface Props {\n name: string;\n props?: Record<string, any>;\n children?: React.ReactNode;\n}\n\nexport const View = ({ name, children, props = {} }: Props) => {\n const viewPlugins = plugins.byType<ViewPlugin>(ViewPlugin.type).filter(pl => pl.key === name);\n\n if (viewPlugins.length) {\n children = viewPlugins.reduce((el, pl) => pl.render({ children: el, ...props }), children);\n }\n\n return <Fragment>{children || null}</Fragment>;\n};\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AAQO,IAAMA,IAAI,GAAG,SAAPA,IAAI,OAA8C;EAAA,IAAxCC,IAAI,QAAJA,IAAI;IAAEC,QAAQ,QAARA,QAAQ;IAAA,kBAAEC,KAAK;IAALA,KAAK,2BAAG,CAAC,CAAC;EAC7C,IAAMC,WAAW,GAAGC,gBAAO,CAACC,MAAM,CAAaC,sBAAU,CAACC,IAAI,CAAC,CAACC,MAAM,CAAC,UAAAC,EAAE;IAAA,OAAIA,EAAE,CAACC,GAAG,KAAKV,IAAI;EAAA,EAAC;EAE7F,IAAIG,WAAW,CAACQ,MAAM,EAAE;IACpBV,QAAQ,GAAGE,WAAW,CAACS,MAAM,CAAC,UAACC,EAAE,EAAEJ,EAAE;MAAA,OAAKA,EAAE,CAACK,MAAM;QAAGb,QAAQ,EAAEY;MAAE,GAAKX,KAAK,EAAG;IAAA,GAAED,QAAQ,CAAC;EAC9F;EAEA,oBAAO,6BAAC,eAAQ,QAAEA,QAAQ,IAAI,IAAI,CAAY;AAClD,CAAC;AAAC"}
@@ -15,7 +15,5 @@ Object.defineProperty(exports, "Routes", {
15
15
  return _Routes.Routes;
16
16
  }
17
17
  });
18
-
19
18
  var _Image = require("./Image");
20
-
21
19
  var _Routes = require("./Routes");
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { Image } from \"./Image\";\nexport { Routes } from \"./Routes\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AACA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { Image } from \"./Image\";\nexport { Routes } from \"./Routes\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA"}
package/config.js CHANGED
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.config = void 0;
7
-
8
7
  var deepFreeze = function deepFreeze(obj) {
9
8
  Object.keys(obj).forEach(function (prop) {
10
9
  if (typeof obj[prop] === "object" && !Object.isFrozen(obj[prop])) {
@@ -13,7 +12,6 @@ var deepFreeze = function deepFreeze(obj) {
13
12
  });
14
13
  return Object.freeze(obj);
15
14
  };
16
-
17
15
  function createConfig() {
18
16
  var _config = {};
19
17
  return {
@@ -28,6 +26,5 @@ function createConfig() {
28
26
  }
29
27
  };
30
28
  }
31
-
32
29
  var config = createConfig();
33
30
  exports.config = config;
package/config.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["deepFreeze","obj","Object","keys","forEach","prop","isFrozen","freeze","createConfig","_config","set","config","get","getKey","key","defaultValue"],"sources":["config.ts"],"sourcesContent":["export type Config = Record<string, any>;\n\ninterface AppConfig {\n set(config: Config): void;\n get(): Config;\n getKey<T = string>(key: string, defaultValue: T): T;\n}\n\nconst deepFreeze = (obj: Record<string, any>): Record<string, any> => {\n Object.keys(obj).forEach(prop => {\n if (typeof obj[prop] === \"object\" && !Object.isFrozen(obj[prop])) {\n deepFreeze(obj[prop]);\n }\n });\n return Object.freeze(obj);\n};\n\nfunction createConfig(): AppConfig {\n let _config: Record<string, any> = {};\n\n return {\n set(config: Config) {\n _config = deepFreeze(config);\n },\n get() {\n return _config;\n },\n getKey(key, defaultValue) {\n return key in _config ? _config[key] : defaultValue;\n }\n };\n}\n\nexport const config = createConfig();\n"],"mappings":";;;;;;;AAQA,IAAMA,UAAU,GAAG,SAAbA,UAAa,CAACC,GAAD,EAAmD;EAClEC,MAAM,CAACC,IAAP,CAAYF,GAAZ,EAAiBG,OAAjB,CAAyB,UAAAC,IAAI,EAAI;IAC7B,IAAI,OAAOJ,GAAG,CAACI,IAAD,CAAV,KAAqB,QAArB,IAAiC,CAACH,MAAM,CAACI,QAAP,CAAgBL,GAAG,CAACI,IAAD,CAAnB,CAAtC,EAAkE;MAC9DL,UAAU,CAACC,GAAG,CAACI,IAAD,CAAJ,CAAV;IACH;EACJ,CAJD;EAKA,OAAOH,MAAM,CAACK,MAAP,CAAcN,GAAd,CAAP;AACH,CAPD;;AASA,SAASO,YAAT,GAAmC;EAC/B,IAAIC,OAA4B,GAAG,EAAnC;EAEA,OAAO;IACHC,GADG,eACCC,MADD,EACiB;MAChBF,OAAO,GAAGT,UAAU,CAACW,MAAD,CAApB;IACH,CAHE;IAIHC,GAJG,iBAIG;MACF,OAAOH,OAAP;IACH,CANE;IAOHI,MAPG,kBAOIC,GAPJ,EAOSC,YAPT,EAOuB;MACtB,OAAOD,GAAG,IAAIL,OAAP,GAAiBA,OAAO,CAACK,GAAD,CAAxB,GAAgCC,YAAvC;IACH;EATE,CAAP;AAWH;;AAEM,IAAMJ,MAAM,GAAGH,YAAY,EAA3B"}
1
+ {"version":3,"names":["deepFreeze","obj","Object","keys","forEach","prop","isFrozen","freeze","createConfig","_config","set","config","get","getKey","key","defaultValue"],"sources":["config.ts"],"sourcesContent":["export type Config = Record<string, any>;\n\ninterface AppConfig {\n set(config: Config): void;\n get(): Config;\n getKey<T = string>(key: string, defaultValue: T): T;\n}\n\nconst deepFreeze = (obj: Record<string, any>): Record<string, any> => {\n Object.keys(obj).forEach(prop => {\n if (typeof obj[prop] === \"object\" && !Object.isFrozen(obj[prop])) {\n deepFreeze(obj[prop]);\n }\n });\n return Object.freeze(obj);\n};\n\nfunction createConfig(): AppConfig {\n let _config: Record<string, any> = {};\n\n return {\n set(config: Config) {\n _config = deepFreeze(config);\n },\n get() {\n return _config;\n },\n getKey(key, defaultValue) {\n return key in _config ? _config[key] : defaultValue;\n }\n };\n}\n\nexport const config = createConfig();\n"],"mappings":";;;;;;AAQA,IAAMA,UAAU,GAAG,SAAbA,UAAU,CAAIC,GAAwB,EAA0B;EAClEC,MAAM,CAACC,IAAI,CAACF,GAAG,CAAC,CAACG,OAAO,CAAC,UAAAC,IAAI,EAAI;IAC7B,IAAI,OAAOJ,GAAG,CAACI,IAAI,CAAC,KAAK,QAAQ,IAAI,CAACH,MAAM,CAACI,QAAQ,CAACL,GAAG,CAACI,IAAI,CAAC,CAAC,EAAE;MAC9DL,UAAU,CAACC,GAAG,CAACI,IAAI,CAAC,CAAC;IACzB;EACJ,CAAC,CAAC;EACF,OAAOH,MAAM,CAACK,MAAM,CAACN,GAAG,CAAC;AAC7B,CAAC;AAED,SAASO,YAAY,GAAc;EAC/B,IAAIC,OAA4B,GAAG,CAAC,CAAC;EAErC,OAAO;IACHC,GAAG,eAACC,MAAc,EAAE;MAChBF,OAAO,GAAGT,UAAU,CAACW,MAAM,CAAC;IAChC,CAAC;IACDC,GAAG,iBAAG;MACF,OAAOH,OAAO;IAClB,CAAC;IACDI,MAAM,kBAACC,GAAG,EAAEC,YAAY,EAAE;MACtB,OAAOD,GAAG,IAAIL,OAAO,GAAGA,OAAO,CAACK,GAAG,CAAC,GAAGC,YAAY;IACvD;EACJ,CAAC;AACL;AAEO,IAAMJ,MAAM,GAAGH,YAAY,EAAE;AAAC"}
@@ -1,48 +1,30 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.UiProvider = exports.UiContext = void 0;
9
-
10
8
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
-
12
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
11
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
-
18
12
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
-
20
13
  var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
21
-
22
14
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
-
24
15
  var _react = _interopRequireDefault(require("react"));
25
-
26
16
  var _plugins = require("@webiny/plugins");
27
-
28
17
  var UiContext = /*#__PURE__*/_react.default.createContext({});
29
-
30
18
  exports.UiContext = UiContext;
31
-
32
19
  var UiProvider = /*#__PURE__*/function (_React$Component) {
33
20
  (0, _inherits2.default)(UiProvider, _React$Component);
34
-
35
21
  var _super = (0, _createSuper2.default)(UiProvider);
36
-
37
22
  function UiProvider() {
38
23
  var _this;
39
-
40
24
  (0, _classCallCheck2.default)(this, UiProvider);
41
-
42
25
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
43
26
  args[_key] = arguments[_key];
44
27
  }
45
-
46
28
  _this = _super.call.apply(_super, [this].concat(args));
47
29
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
48
30
  ui: {}
@@ -56,16 +38,13 @@ var UiProvider = /*#__PURE__*/function (_React$Component) {
56
38
  });
57
39
  return _this;
58
40
  }
59
-
60
41
  (0, _createClass2.default)(UiProvider, [{
61
42
  key: "render",
62
43
  value: function render() {
63
44
  var value = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.state.ui), {}, {
64
45
  setState: this.setData
65
46
  });
66
-
67
47
  var uiStatePlugins = _plugins.plugins.byType("ui-state");
68
-
69
48
  return /*#__PURE__*/_react.default.createElement(UiContext.Provider, {
70
49
  value: value
71
50
  }, uiStatePlugins.map(function (pl) {
@@ -77,5 +56,4 @@ var UiProvider = /*#__PURE__*/function (_React$Component) {
77
56
  }]);
78
57
  return UiProvider;
79
58
  }(_react.default.Component);
80
-
81
59
  exports.UiProvider = UiProvider;
@@ -1 +1 @@
1
- {"version":3,"names":["UiContext","React","createContext","UiProvider","ui","setter","setState","state","value","setData","uiStatePlugins","plugins","byType","map","pl","cloneElement","render","key","name","props","children","Component"],"sources":["index.tsx"],"sourcesContent":["import React from \"react\";\nimport { UiStatePlugin } from \"~/types\";\nimport { plugins } from \"@webiny/plugins\";\n\nexport const UiContext = React.createContext({});\n\ntype Props = {};\n\ntype State = {\n ui: { [key: string]: any };\n};\n\ninterface UiData {\n [key: string]: any;\n}\n\ninterface UiDataSetter {\n (ui: UiData): UiData;\n}\n\nexport interface UiContextValue {\n setState: (setter: UiDataSetter) => void;\n [key: string]: any;\n}\n\nexport class UiProvider extends React.Component<Props, State> {\n public override state: State = {\n ui: {}\n };\n\n private readonly setData = (setter: Function): void => {\n return this.setState((state: State) => {\n return { ui: { ...state.ui, ...setter(state.ui) } };\n });\n };\n\n public override render() {\n const value: UiContextValue = { ...this.state.ui, setState: this.setData };\n const uiStatePlugins = plugins.byType<UiStatePlugin>(\"ui-state\");\n return (\n <UiContext.Provider value={value}>\n {uiStatePlugins.map(pl => React.cloneElement(pl.render(), { key: pl.name }))}\n {this.props.children}\n </UiContext.Provider>\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AAEO,IAAMA,SAAS,gBAAGC,cAAA,CAAMC,aAAN,CAAoB,EAApB,CAAlB;;;;IAqBMC,U;;;;;;;;;;;;;;;wFACsB;MAC3BC,EAAE,EAAE;IADuB,C;0FAIJ,UAACC,MAAD,EAA4B;MACnD,OAAO,MAAKC,QAAL,CAAc,UAACC,KAAD,EAAkB;QACnC,OAAO;UAAEH,EAAE,8DAAOG,KAAK,CAACH,EAAb,GAAoBC,MAAM,CAACE,KAAK,CAACH,EAAP,CAA1B;QAAJ,CAAP;MACH,CAFM,CAAP;IAGH,C;;;;;;WAED,kBAAyB;MACrB,IAAMI,KAAqB,+DAAQ,KAAKD,KAAL,CAAWH,EAAnB;QAAuBE,QAAQ,EAAE,KAAKG;MAAtC,EAA3B;;MACA,IAAMC,cAAc,GAAGC,gBAAA,CAAQC,MAAR,CAA8B,UAA9B,CAAvB;;MACA,oBACI,6BAAC,SAAD,CAAW,QAAX;QAAoB,KAAK,EAAEJ;MAA3B,GACKE,cAAc,CAACG,GAAf,CAAmB,UAAAC,EAAE;QAAA,oBAAIb,cAAA,CAAMc,YAAN,CAAmBD,EAAE,CAACE,MAAH,EAAnB,EAAgC;UAAEC,GAAG,EAAEH,EAAE,CAACI;QAAV,CAAhC,CAAJ;MAAA,CAArB,CADL,EAEK,KAAKC,KAAL,CAAWC,QAFhB,CADJ;IAMH;;;EApB2BnB,cAAA,CAAMoB,S"}
1
+ {"version":3,"names":["UiContext","React","createContext","UiProvider","ui","setter","setState","state","value","setData","uiStatePlugins","plugins","byType","map","pl","cloneElement","render","key","name","props","children","Component"],"sources":["index.tsx"],"sourcesContent":["import React from \"react\";\nimport { UiStatePlugin } from \"~/types\";\nimport { plugins } from \"@webiny/plugins\";\n\nexport const UiContext = React.createContext({});\n\ntype Props = {};\n\ntype State = {\n ui: { [key: string]: any };\n};\n\ninterface UiData {\n [key: string]: any;\n}\n\ninterface UiDataSetter {\n (ui: UiData): UiData;\n}\n\nexport interface UiContextValue {\n setState: (setter: UiDataSetter) => void;\n [key: string]: any;\n}\n\nexport class UiProvider extends React.Component<Props, State> {\n public override state: State = {\n ui: {}\n };\n\n private readonly setData = (setter: Function): void => {\n return this.setState((state: State) => {\n return { ui: { ...state.ui, ...setter(state.ui) } };\n });\n };\n\n public override render() {\n const value: UiContextValue = { ...this.state.ui, setState: this.setData };\n const uiStatePlugins = plugins.byType<UiStatePlugin>(\"ui-state\");\n return (\n <UiContext.Provider value={value}>\n {uiStatePlugins.map(pl => React.cloneElement(pl.render(), { key: pl.name }))}\n {this.props.children}\n </UiContext.Provider>\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAEA;AAEO,IAAMA,SAAS,gBAAGC,cAAK,CAACC,aAAa,CAAC,CAAC,CAAC,CAAC;AAAC;AAAA,IAqBpCC,UAAU;EAAA;EAAA;EAAA;IAAA;IAAA;IAAA;MAAA;IAAA;IAAA;IAAA,oFACY;MAC3BC,EAAE,EAAE,CAAC;IACT,CAAC;IAAA,sFAE0B,UAACC,MAAgB,EAAW;MACnD,OAAO,MAAKC,QAAQ,CAAC,UAACC,KAAY,EAAK;QACnC,OAAO;UAAEH,EAAE,8DAAOG,KAAK,CAACH,EAAE,GAAKC,MAAM,CAACE,KAAK,CAACH,EAAE,CAAC;QAAG,CAAC;MACvD,CAAC,CAAC;IACN,CAAC;IAAA;EAAA;EAAA;IAAA;IAAA,OAED,kBAAyB;MACrB,IAAMI,KAAqB,+DAAQ,IAAI,CAACD,KAAK,CAACH,EAAE;QAAEE,QAAQ,EAAE,IAAI,CAACG;MAAO,EAAE;MAC1E,IAAMC,cAAc,GAAGC,gBAAO,CAACC,MAAM,CAAgB,UAAU,CAAC;MAChE,oBACI,6BAAC,SAAS,CAAC,QAAQ;QAAC,KAAK,EAAEJ;MAAM,GAC5BE,cAAc,CAACG,GAAG,CAAC,UAAAC,EAAE;QAAA,oBAAIb,cAAK,CAACc,YAAY,CAACD,EAAE,CAACE,MAAM,EAAE,EAAE;UAAEC,GAAG,EAAEH,EAAE,CAACI;QAAK,CAAC,CAAC;MAAA,EAAC,EAC3E,IAAI,CAACC,KAAK,CAACC,QAAQ,CACH;IAE7B;EAAC;EAAA;AAAA,EApB2BnB,cAAK,CAACoB,SAAS;AAAA"}
package/core/AddRoute.js CHANGED
@@ -1,26 +1,19 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.AddRoute = void 0;
9
-
10
8
  var _react = _interopRequireWildcard(require("react"));
11
-
12
9
  var _App = require("../App");
13
-
14
10
  var _reactRouter = require("@webiny/react-router");
15
-
16
11
  var AddRoute = function AddRoute(props) {
17
12
  var _useApp = (0, _App.useApp)(),
18
- addRoute = _useApp.addRoute;
19
-
13
+ addRoute = _useApp.addRoute;
20
14
  (0, _react.useEffect)(function () {
21
15
  addRoute( /*#__PURE__*/_react.default.createElement(_reactRouter.Route, props));
22
16
  }, []);
23
17
  return null;
24
18
  };
25
-
26
19
  exports.AddRoute = AddRoute;
@@ -1 +1 @@
1
- {"version":3,"names":["AddRoute","props","useApp","addRoute","useEffect"],"sources":["AddRoute.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\nimport { useApp } from \"~/App\";\nimport { Route, RouteProps } from \"@webiny/react-router\";\n\nexport const AddRoute: React.FC<RouteProps> = props => {\n const { addRoute } = useApp();\n\n useEffect(() => {\n addRoute(<Route {...props} />);\n }, []);\n\n return null;\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEO,IAAMA,QAA8B,GAAG,SAAjCA,QAAiC,CAAAC,KAAK,EAAI;EACnD,cAAqB,IAAAC,WAAA,GAArB;EAAA,IAAQC,QAAR,WAAQA,QAAR;;EAEA,IAAAC,gBAAA,EAAU,YAAM;IACZD,QAAQ,eAAC,6BAAC,kBAAD,EAAWF,KAAX,CAAD,CAAR;EACH,CAFD,EAEG,EAFH;EAIA,OAAO,IAAP;AACH,CARM"}
1
+ {"version":3,"names":["AddRoute","props","useApp","addRoute","useEffect"],"sources":["AddRoute.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\nimport { useApp } from \"~/App\";\nimport { Route, RouteProps } from \"@webiny/react-router\";\n\nexport const AddRoute: React.FC<RouteProps> = props => {\n const { addRoute } = useApp();\n\n useEffect(() => {\n addRoute(<Route {...props} />);\n }, []);\n\n return null;\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAEO,IAAMA,QAA8B,GAAG,SAAjCA,QAA8B,CAAGC,KAAK,EAAI;EACnD,cAAqB,IAAAC,WAAM,GAAE;IAArBC,QAAQ,WAARA,QAAQ;EAEhB,IAAAC,gBAAS,EAAC,YAAM;IACZD,QAAQ,eAAC,6BAAC,kBAAK,EAAKF,KAAK,CAAI,CAAC;EAClC,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO,IAAI;AACf,CAAC;AAAC"}