@webiny/app 0.0.0-ee-vpcs.549378cf03

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 (154) hide show
  1. package/App.d.ts +24 -0
  2. package/App.js +116 -0
  3. package/App.js.map +1 -0
  4. package/LICENSE +21 -0
  5. package/README.md +19 -0
  6. package/apollo-client/InMemoryCache.d.ts +7 -0
  7. package/apollo-client/InMemoryCache.js +79 -0
  8. package/apollo-client/InMemoryCache.js.map +1 -0
  9. package/components/Image.d.ts +3 -0
  10. package/components/Image.js +43 -0
  11. package/components/Image.js.map +1 -0
  12. package/components/Routes.d.ts +2 -0
  13. package/components/Routes.js +51 -0
  14. package/components/Routes.js.map +1 -0
  15. package/components/View.d.ts +8 -0
  16. package/components/View.js +41 -0
  17. package/components/View.js.map +1 -0
  18. package/components/index.d.ts +2 -0
  19. package/components/index.js +21 -0
  20. package/components/index.js.map +1 -0
  21. package/config.d.ts +8 -0
  22. package/config.js +33 -0
  23. package/config.js.map +1 -0
  24. package/contexts/Ui/index.d.ts +24 -0
  25. package/contexts/Ui/index.js +81 -0
  26. package/contexts/Ui/index.js.map +1 -0
  27. package/core/AddRoute.d.ts +3 -0
  28. package/core/AddRoute.js +26 -0
  29. package/core/AddRoute.js.map +1 -0
  30. package/core/DebounceRender.d.ts +11 -0
  31. package/core/DebounceRender.js +51 -0
  32. package/core/DebounceRender.js.map +1 -0
  33. package/core/Plugins.d.ts +8 -0
  34. package/core/Plugins.js +52 -0
  35. package/core/Plugins.js.map +1 -0
  36. package/core/Provider.d.ts +9 -0
  37. package/core/Provider.js +27 -0
  38. package/core/Provider.js.map +1 -0
  39. package/core/Routes.d.ts +6 -0
  40. package/core/Routes.js +49 -0
  41. package/core/Routes.js.map +1 -0
  42. package/core/createProviderPlugin.d.ts +8 -0
  43. package/core/createProviderPlugin.js +25 -0
  44. package/core/createProviderPlugin.js.map +1 -0
  45. package/hooks/useAutocomplete/index.d.ts +1 -0
  46. package/hooks/useAutocomplete/index.js +13 -0
  47. package/hooks/useAutocomplete/index.js.map +1 -0
  48. package/hooks/useAutocomplete/useAutocomplete.d.ts +11 -0
  49. package/hooks/useAutocomplete/useAutocomplete.js +38 -0
  50. package/hooks/useAutocomplete/useAutocomplete.js.map +1 -0
  51. package/hooks/useDataList/functions/getData.d.ts +2 -0
  52. package/hooks/useDataList/functions/getData.js +16 -0
  53. package/hooks/useDataList/functions/getData.js.map +1 -0
  54. package/hooks/useDataList/functions/getError.d.ts +2 -0
  55. package/hooks/useDataList/functions/getError.js +16 -0
  56. package/hooks/useDataList/functions/getError.js.map +1 -0
  57. package/hooks/useDataList/functions/getMeta.d.ts +2 -0
  58. package/hooks/useDataList/functions/getMeta.js +16 -0
  59. package/hooks/useDataList/functions/getMeta.js.map +1 -0
  60. package/hooks/useDataList/functions/index.d.ts +3 -0
  61. package/hooks/useDataList/functions/index.js +31 -0
  62. package/hooks/useDataList/functions/index.js.map +1 -0
  63. package/hooks/useDataList/functions/searchDataByKey.d.ts +2 -0
  64. package/hooks/useDataList/functions/searchDataByKey.js +29 -0
  65. package/hooks/useDataList/functions/searchDataByKey.js.map +1 -0
  66. package/hooks/useDataList/index.d.ts +1 -0
  67. package/hooks/useDataList/index.js +13 -0
  68. package/hooks/useDataList/index.js.map +1 -0
  69. package/hooks/useDataList/useDataList.d.ts +36 -0
  70. package/hooks/useDataList/useDataList.js +208 -0
  71. package/hooks/useDataList/useDataList.js.map +1 -0
  72. package/hooks/useDataList/utils/index.d.ts +2 -0
  73. package/hooks/useDataList/utils/index.js +23 -0
  74. package/hooks/useDataList/utils/index.js.map +1 -0
  75. package/hooks/useDataList/utils/prepareLoadListParams.d.ts +11 -0
  76. package/hooks/useDataList/utils/prepareLoadListParams.js +48 -0
  77. package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -0
  78. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.d.ts +14 -0
  79. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +31 -0
  80. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +1 -0
  81. package/hooks/useDataList/utils/types.d.ts +34 -0
  82. package/hooks/useDataList/utils/types.js +5 -0
  83. package/hooks/useDataList/utils/types.js.map +1 -0
  84. package/hooks/useHandler.d.ts +11 -0
  85. package/hooks/useHandler.js +20 -0
  86. package/hooks/useHandler.js.map +1 -0
  87. package/hooks/useHandlers.d.ts +11 -0
  88. package/hooks/useHandlers.js +30 -0
  89. package/hooks/useHandlers.js.map +1 -0
  90. package/hooks/useUi.d.ts +2 -0
  91. package/hooks/useUi.js +16 -0
  92. package/hooks/useUi.js.map +1 -0
  93. package/i18n/i18n.d.ts +2 -0
  94. package/i18n/i18n.js +21 -0
  95. package/i18n/i18n.js.map +1 -0
  96. package/i18n/index.d.ts +1 -0
  97. package/i18n/index.js +15 -0
  98. package/i18n/index.js.map +1 -0
  99. package/index.d.ts +13 -0
  100. package/index.js +141 -0
  101. package/index.js.map +1 -0
  102. package/package.json +78 -0
  103. package/plugins/AddQuerySelectionPlugin.d.ts +15 -0
  104. package/plugins/AddQuerySelectionPlugin.js +132 -0
  105. package/plugins/AddQuerySelectionPlugin.js.map +1 -0
  106. package/plugins/ApolloCacheObjectIdPlugin.d.ts +15 -0
  107. package/plugins/ApolloCacheObjectIdPlugin.js +53 -0
  108. package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -0
  109. package/plugins/ApolloDynamicLink.d.ts +6 -0
  110. package/plugins/ApolloDynamicLink.js +83 -0
  111. package/plugins/ApolloDynamicLink.js.map +1 -0
  112. package/plugins/ApolloLinkPlugin.d.ts +13 -0
  113. package/plugins/ApolloLinkPlugin.js +63 -0
  114. package/plugins/ApolloLinkPlugin.js.map +1 -0
  115. package/plugins/ConsoleLinkPlugin.d.ts +8 -0
  116. package/plugins/ConsoleLinkPlugin.js +63 -0
  117. package/plugins/ConsoleLinkPlugin.js.map +1 -0
  118. package/plugins/LocaleHeaderLinkPlugin.d.ts +15 -0
  119. package/plugins/LocaleHeaderLinkPlugin.js +77 -0
  120. package/plugins/LocaleHeaderLinkPlugin.js.map +1 -0
  121. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts +14 -0
  122. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +97 -0
  123. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -0
  124. package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +5 -0
  125. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +21 -0
  126. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -0
  127. package/plugins/NetworkErrorLinkPlugin/assets/close_24px.svg +1 -0
  128. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.d.ts +7 -0
  129. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +38 -0
  130. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -0
  131. package/plugins/NetworkErrorLinkPlugin.d.ts +7 -0
  132. package/plugins/NetworkErrorLinkPlugin.js +65 -0
  133. package/plugins/NetworkErrorLinkPlugin.js.map +1 -0
  134. package/plugins/OmitTypenameLinkPlugin.d.ts +8 -0
  135. package/plugins/OmitTypenameLinkPlugin.js +55 -0
  136. package/plugins/OmitTypenameLinkPlugin.js.map +1 -0
  137. package/plugins/RoutePlugin.d.ts +12 -0
  138. package/plugins/RoutePlugin.js +53 -0
  139. package/plugins/RoutePlugin.js.map +1 -0
  140. package/plugins/TenantHeaderLinkPlugin.d.ts +15 -0
  141. package/plugins/TenantHeaderLinkPlugin.js +85 -0
  142. package/plugins/TenantHeaderLinkPlugin.js.map +1 -0
  143. package/plugins/ViewPlugin.d.ts +14 -0
  144. package/plugins/ViewPlugin.js +58 -0
  145. package/plugins/ViewPlugin.js.map +1 -0
  146. package/plugins/image.d.ts +3 -0
  147. package/plugins/image.js +184 -0
  148. package/plugins/image.js.map +1 -0
  149. package/plugins/index.d.ts +20 -0
  150. package/plugins/index.js +110 -0
  151. package/plugins/index.js.map +1 -0
  152. package/types.d.ts +70 -0
  153. package/types.js +13 -0
  154. package/types.js.map +1 -0
package/App.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ import React, { ReactElement } from "react";
2
+ import { RouteProps } from "@webiny/react-router";
3
+ import { HigherOrderComponent } from "@webiny/react-composition";
4
+ interface State {
5
+ routes: Record<string, ReactElement<RouteProps>>;
6
+ plugins: JSX.Element[];
7
+ providers: HigherOrderComponent[];
8
+ }
9
+ interface AppContext extends State {
10
+ addRoute(route: JSX.Element): void;
11
+ addProvider(hoc: HigherOrderComponent): void;
12
+ addPlugin(plugin: React.ReactNode): void;
13
+ }
14
+ declare const AppContext: React.Context<AppContext | undefined>;
15
+ export declare const useApp: () => AppContext;
16
+ export interface AppProps {
17
+ debounceRender?: number;
18
+ children?: React.ReactNode | React.ReactNode[];
19
+ }
20
+ export declare const App: {
21
+ ({ debounceRender, children }: AppProps): JSX.Element;
22
+ displayName: string;
23
+ };
24
+ export {};
package/App.js ADDED
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+
5
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.useApp = exports.App = void 0;
11
+
12
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
+
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
+
16
+ var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
17
+
18
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
19
+
20
+ var _react = _interopRequireWildcard(require("react"));
21
+
22
+ var _reactRouter = require("@webiny/react-router");
23
+
24
+ var _reactComposition = require("@webiny/react-composition");
25
+
26
+ var _Routes = require("./core/Routes");
27
+
28
+ var _DebounceRender = require("./core/DebounceRender");
29
+
30
+ var _Plugins = require("./core/Plugins");
31
+
32
+ var AppContext = /*#__PURE__*/(0, _react.createContext)(undefined);
33
+ AppContext.displayName = "AppContext";
34
+
35
+ var useApp = function useApp() {
36
+ var appContext = (0, _react.useContext)(AppContext);
37
+
38
+ if (!appContext) {
39
+ throw Error("AppContext provider was not found. Are you using the \"useApp()\" hook in the right place?");
40
+ }
41
+
42
+ return appContext;
43
+ };
44
+
45
+ exports.useApp = useApp;
46
+
47
+ var App = function App(_ref) {
48
+ var _ref$debounceRender = _ref.debounceRender,
49
+ debounceRender = _ref$debounceRender === void 0 ? 50 : _ref$debounceRender,
50
+ children = _ref.children;
51
+
52
+ var _useState = (0, _react.useState)({
53
+ routes: {},
54
+ plugins: [],
55
+ providers: []
56
+ }),
57
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
58
+ state = _useState2[0],
59
+ setState = _useState2[1];
60
+
61
+ var addRoute = (0, _react.useCallback)(function (route) {
62
+ setState(function (state) {
63
+ return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, state), {}, {
64
+ routes: (0, _objectSpread3.default)((0, _objectSpread3.default)({}, state.routes), {}, (0, _defineProperty2.default)({}, route.props.path, route))
65
+ });
66
+ });
67
+ }, []);
68
+ var addProvider = (0, _react.useCallback)(function (component) {
69
+ setState(function (state) {
70
+ if (state.providers.findIndex(function (m) {
71
+ return m === component;
72
+ }) > -1) {
73
+ return state;
74
+ }
75
+
76
+ return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, state), {}, {
77
+ providers: [].concat((0, _toConsumableArray2.default)(state.providers), [component])
78
+ });
79
+ });
80
+ }, []);
81
+ var addPlugin = (0, _react.useCallback)(function (element) {
82
+ setState(function (state) {
83
+ return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, state), {}, {
84
+ plugins: [].concat((0, _toConsumableArray2.default)(state.plugins), [element])
85
+ });
86
+ });
87
+ }, []);
88
+ var appContext = (0, _react.useMemo)(function () {
89
+ return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, state), {}, {
90
+ addRoute: addRoute,
91
+ addProvider: addProvider,
92
+ addPlugin: addPlugin
93
+ });
94
+ }, [state]);
95
+ var AppRouter = (0, _react.useMemo)(function () {
96
+ return function AppRouter() {
97
+ var routes = Object.values(state.routes);
98
+ return /*#__PURE__*/_react.default.createElement(_Routes.Routes, {
99
+ key: routes.length,
100
+ routes: routes
101
+ });
102
+ };
103
+ }, [state.routes]);
104
+ var Providers = (0, _react.useMemo)(function () {
105
+ return _reactComposition.compose.apply(void 0, (0, _toConsumableArray2.default)(state.providers || []))(_DebounceRender.DebounceRender);
106
+ }, [state.providers]);
107
+ Providers.displayName = "Providers";
108
+ return /*#__PURE__*/_react.default.createElement(AppContext.Provider, {
109
+ value: appContext
110
+ }, /*#__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, {
111
+ wait: debounceRender
112
+ }, /*#__PURE__*/_react.default.createElement(AppRouter, null))))));
113
+ };
114
+
115
+ exports.App = App;
116
+ App.displayName = "App";
package/App.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["AppContext","createContext","undefined","displayName","useApp","appContext","useContext","Error","App","debounceRender","children","useState","routes","plugins","providers","state","setState","addRoute","useCallback","route","props","path","addProvider","component","findIndex","m","addPlugin","element","useMemo","AppRouter","Object","values","length","Providers","compose","DebounceRender"],"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 } 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\ninterface State {\n routes: Record<string, ReactElement<RouteProps>>;\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 children?: React.ReactNode | React.ReactNode[];\n}\n\nexport const App = ({ debounceRender = 50, children }: AppProps) => {\n const [state, setState] = useState<State>({\n routes: {},\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 () =>\n function AppRouter() {\n const routes = Object.values(state.routes);\n return <SortRoutes key={routes.length} routes={routes} />;\n },\n [state.routes]\n );\n\n const Providers = useMemo(\n () => compose(...(state.providers || []))(DebounceRender),\n [state.providers]\n );\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;;AAcA,IAAMA,UAAU,gBAAG,IAAAC,oBAAA,EAAsCC,SAAtC,CAAnB;AAEAF,UAAU,CAACG,WAAX,GAAyB,YAAzB;;AAEO,IAAMC,MAAM,GAAG,SAATA,MAAS,GAAM;EACxB,IAAMC,UAAU,GAAG,IAAAC,iBAAA,EAAWN,UAAX,CAAnB;;EACA,IAAI,CAACK,UAAL,EAAiB;IACb,MAAME,KAAK,8FAAX;EAGH;;EACD,OAAOF,UAAP;AACH,CARM;;;;AAeA,IAAMG,GAAG,GAAG,SAANA,GAAM,OAAiD;EAAA,+BAA9CC,cAA8C;EAAA,IAA9CA,cAA8C,oCAA7B,EAA6B;EAAA,IAAzBC,QAAyB,QAAzBA,QAAyB;;EAChE,gBAA0B,IAAAC,eAAA,EAAgB;IACtCC,MAAM,EAAE,EAD8B;IAEtCC,OAAO,EAAE,EAF6B;IAGtCC,SAAS,EAAE;EAH2B,CAAhB,CAA1B;EAAA;EAAA,IAAOC,KAAP;EAAA,IAAcC,QAAd;;EAMA,IAAMC,QAAQ,GAAG,IAAAC,kBAAA,EAAY,UAACC,KAAD,EAAiD;IAC1EH,QAAQ,CAAC,UAAAD,KAAK,EAAI;MACd,mEACOA,KADP;QAEIH,MAAM,8DAAOG,KAAK,CAACH,MAAb,yCAAsBO,KAAK,CAACC,KAAN,CAAYC,IAAlC,EAAmDF,KAAnD;MAFV;IAIH,CALO,CAAR;EAMH,CAPgB,EAOd,EAPc,CAAjB;EASA,IAAMG,WAAW,GAAG,IAAAJ,kBAAA,EAAY,UAAAK,SAAS,EAAI;IACzCP,QAAQ,CAAC,UAAAD,KAAK,EAAI;MACd,IAAIA,KAAK,CAACD,SAAN,CAAgBU,SAAhB,CAA0B,UAAAC,CAAC;QAAA,OAAIA,CAAC,KAAKF,SAAV;MAAA,CAA3B,IAAkD,CAAC,CAAvD,EAA0D;QACtD,OAAOR,KAAP;MACH;;MAED,mEACOA,KADP;QAEID,SAAS,6CAAMC,KAAK,CAACD,SAAZ,IAAuBS,SAAvB;MAFb;IAIH,CATO,CAAR;EAUH,CAXmB,EAWjB,EAXiB,CAApB;EAaA,IAAMG,SAAS,GAAG,IAAAR,kBAAA,EAAY,UAAAS,OAAO,EAAI;IACrCX,QAAQ,CAAC,UAAAD,KAAK,EAAI;MACd,mEACOA,KADP;QAEIF,OAAO,6CAAME,KAAK,CAACF,OAAZ,IAAqBc,OAArB;MAFX;IAIH,CALO,CAAR;EAMH,CAPiB,EAOf,EAPe,CAAlB;EASA,IAAMtB,UAAU,GAAG,IAAAuB,cAAA,EACf;IAAA,mEACOb,KADP;MAEIE,QAAQ,EAARA,QAFJ;MAGIK,WAAW,EAAXA,WAHJ;MAIII,SAAS,EAATA;IAJJ;EAAA,CADe,EAOf,CAACX,KAAD,CAPe,CAAnB;EAUA,IAAMc,SAAS,GAAG,IAAAD,cAAA,EACd;IAAA,OACI,SAASC,SAAT,GAAqB;MACjB,IAAMjB,MAAM,GAAGkB,MAAM,CAACC,MAAP,CAAchB,KAAK,CAACH,MAApB,CAAf;MACA,oBAAO,6BAAC,cAAD;QAAY,GAAG,EAAEA,MAAM,CAACoB,MAAxB;QAAgC,MAAM,EAAEpB;MAAxC,EAAP;IACH,CAJL;EAAA,CADc,EAMd,CAACG,KAAK,CAACH,MAAP,CANc,CAAlB;EASA,IAAMqB,SAAS,GAAG,IAAAL,cAAA,EACd;IAAA,OAAMM,yBAAA,gDAAYnB,KAAK,CAACD,SAAN,IAAmB,EAA/B,GAAoCqB,8BAApC,CAAN;EAAA,CADc,EAEd,CAACpB,KAAK,CAACD,SAAP,CAFc,CAAlB;EAKAmB,SAAS,CAAC9B,WAAV,GAAwB,WAAxB;EAEA,oBACI,6BAAC,UAAD,CAAY,QAAZ;IAAqB,KAAK,EAAEE;EAA5B,gBACI,6BAAC,qCAAD,QACKK,QADL,eAEI,6BAAC,0BAAD,qBACI,6BAAC,SAAD,qBACI,6BAAC,wBAAD,QAAkBK,KAAK,CAACF,OAAxB,CADJ,eAEI,6BAAC,8BAAD;IAAgB,IAAI,EAAEJ;EAAtB,gBACI,6BAAC,SAAD,OADJ,CAFJ,CADJ,CAFJ,CADJ,CADJ;AAeH,CA/EM;;;AAiFPD,GAAG,CAACL,WAAJ,GAAkB,KAAlB"}
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Webiny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # @webiny/app
2
+ [![](https://img.shields.io/npm/dw/@webiny/app.svg)](https://www.npmjs.com/package/@webiny/app)
3
+ [![](https://img.shields.io/npm/v/@webiny/app.svg)](https://www.npmjs.com/package/@webiny/app)
4
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
5
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
6
+
7
+ The base package for building Webiny and React powered web apps.
8
+
9
+ For more information, please visit [the official docs](https://docs.webiny.com/docs/webiny/introduction).
10
+
11
+ ## Install
12
+ ```
13
+ npm install --save @webiny/app
14
+ ```
15
+
16
+ Or if you prefer yarn:
17
+ ```
18
+ yarn add @webiny/app
19
+ ```
@@ -0,0 +1,7 @@
1
+ import { InMemoryCache as BaseInMemoryCache, InMemoryCacheConfig } from "apollo-cache-inmemory";
2
+ import { DocumentNode } from "graphql";
3
+ export declare class InMemoryCache extends BaseInMemoryCache {
4
+ private readonly transformPlugins;
5
+ constructor(config?: InMemoryCacheConfig);
6
+ transformDocument(document: DocumentNode): DocumentNode;
7
+ }
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.InMemoryCache = void 0;
9
+
10
+ var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
11
+
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
14
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
+
16
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
+
18
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
19
+
20
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
+
22
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
23
+
24
+ var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
25
+
26
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
27
+
28
+ var _apolloCacheInmemory = require("apollo-cache-inmemory");
29
+
30
+ var _plugins = require("@webiny/plugins");
31
+
32
+ var _AddQuerySelectionPlugin = require("../plugins/AddQuerySelectionPlugin");
33
+
34
+ var _ApolloLinkPlugin = require("../plugins/ApolloLinkPlugin");
35
+
36
+ var InMemoryCache = /*#__PURE__*/function (_BaseInMemoryCache) {
37
+ (0, _inherits2.default)(InMemoryCache, _BaseInMemoryCache);
38
+
39
+ var _super = (0, _createSuper2.default)(InMemoryCache);
40
+
41
+ function InMemoryCache(config) {
42
+ var _this;
43
+
44
+ (0, _classCallCheck2.default)(this, InMemoryCache);
45
+ _this = _super.call(this, config);
46
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "transformPlugins", void 0);
47
+ _this.transformPlugins = _plugins.plugins.byType(_ApolloLinkPlugin.ApolloLinkPlugin.type).filter(function (pl) {
48
+ return pl instanceof _AddQuerySelectionPlugin.AddQuerySelectionPlugin;
49
+ });
50
+ return _this;
51
+ }
52
+
53
+ (0, _createClass2.default)(InMemoryCache, [{
54
+ key: "transformDocument",
55
+ value: function transformDocument(document) {
56
+ // @ts-ignore
57
+ var operationName = document.definitions[0].name.value;
58
+
59
+ var _iterator = (0, _createForOfIteratorHelper2.default)(this.transformPlugins),
60
+ _step;
61
+
62
+ try {
63
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
64
+ var pl = _step.value;
65
+ pl.addSelectionToQuery(operationName, document);
66
+ }
67
+ } catch (err) {
68
+ _iterator.e(err);
69
+ } finally {
70
+ _iterator.f();
71
+ }
72
+
73
+ return (0, _get2.default)((0, _getPrototypeOf2.default)(InMemoryCache.prototype), "transformDocument", this).call(this, document);
74
+ }
75
+ }]);
76
+ return InMemoryCache;
77
+ }(_apolloCacheInmemory.InMemoryCache);
78
+
79
+ exports.InMemoryCache = InMemoryCache;
@@ -0,0 +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"}
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ import { ImageProps } from "../types";
3
+ export declare const Image: React.FC<ImageProps>;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.Image = void 0;
9
+
10
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
+
12
+ var _get2 = _interopRequireDefault(require("lodash/get"));
13
+
14
+ var _invariant = _interopRequireDefault(require("invariant"));
15
+
16
+ var _plugins = require("@webiny/plugins");
17
+
18
+ var _excluded = ["preset"];
19
+
20
+ var Image = function Image(_ref) {
21
+ var presetName = _ref.preset,
22
+ props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
23
+
24
+ var plugin = _plugins.plugins.byName("image-component");
25
+
26
+ if (!plugin) {
27
+ throw new Error("Image component plugin (type \"image-component\") not defined.");
28
+ }
29
+
30
+ if (presetName) {
31
+ var preset = (0, _get2.default)(plugin, "presets.".concat(presetName));
32
+ (0, _invariant.default)(preset, "Transform preset \"".concat(presetName, "\" not found."));
33
+ props.transform = preset;
34
+ }
35
+
36
+ if (props.transform) {
37
+ props.src = plugin.getImageSrc(props);
38
+ }
39
+
40
+ return plugin.render(props);
41
+ };
42
+
43
+ exports.Image = Image;
@@ -0,0 +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"}
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const Routes: () => JSX.Element;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.Routes = void 0;
9
+
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+
12
+ var _react = _interopRequireDefault(require("react"));
13
+
14
+ var _plugins = require("@webiny/plugins");
15
+
16
+ var _reactRouter = require("@webiny/react-router");
17
+
18
+ // This file is necessary only for backwards compatibility.
19
+ // We'll remove this once the legacy rendering engine is removed.
20
+ var Routes = function Routes() {
21
+ // We cannot call `sort` on the array returned by the `plugins.byType` call - it is read-only.
22
+ var routes = (0, _toConsumableArray2.default)(_plugins.plugins.byType("route")).sort(function (a, b) {
23
+ var pathA = a.route.props.path || "*";
24
+ var pathB = b.route.props.path || "*"; // This will sort paths at the very bottom of the list
25
+
26
+ if (pathA === "/" && pathB === "*") {
27
+ return -1;
28
+ } // This will push * and / to the bottom of the list
29
+
30
+
31
+ if (pathA === "*" || pathA === "/") {
32
+ return 1;
33
+ } // This will push * and / to the bottom of the list
34
+
35
+
36
+ if (["*", "/"].includes(pathB)) {
37
+ return -1;
38
+ }
39
+
40
+ return 0;
41
+ });
42
+ return /*#__PURE__*/_react.default.createElement(_reactRouter.Routes, null, routes.map(function (_ref) {
43
+ var route = _ref.route,
44
+ name = _ref.name;
45
+ return /*#__PURE__*/_react.default.cloneElement(route, {
46
+ key: name
47
+ });
48
+ }));
49
+ };
50
+
51
+ exports.Routes = Routes;
@@ -0,0 +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"}
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ interface Props {
3
+ name: string;
4
+ props?: Record<string, any>;
5
+ children?: React.ReactNode;
6
+ }
7
+ export declare const View: ({ name, children, props }: Props) => JSX.Element;
8
+ export {};
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+
5
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.View = void 0;
11
+
12
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
13
+
14
+ var _react = _interopRequireWildcard(require("react"));
15
+
16
+ var _plugins = require("@webiny/plugins");
17
+
18
+ var _ViewPlugin = require("../plugins/ViewPlugin");
19
+
20
+ var View = function View(_ref) {
21
+ var name = _ref.name,
22
+ children = _ref.children,
23
+ _ref$props = _ref.props,
24
+ props = _ref$props === void 0 ? {} : _ref$props;
25
+
26
+ var viewPlugins = _plugins.plugins.byType(_ViewPlugin.ViewPlugin.type).filter(function (pl) {
27
+ return pl.key === name;
28
+ });
29
+
30
+ if (viewPlugins.length) {
31
+ children = viewPlugins.reduce(function (el, pl) {
32
+ return pl.render((0, _objectSpread2.default)({
33
+ children: el
34
+ }, props));
35
+ }, children);
36
+ }
37
+
38
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, children || null);
39
+ };
40
+
41
+ exports.View = View;
@@ -0,0 +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"}
@@ -0,0 +1,2 @@
1
+ export { Image } from "./Image";
2
+ export { Routes } from "./Routes";
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Image", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _Image.Image;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "Routes", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _Routes.Routes;
16
+ }
17
+ });
18
+
19
+ var _Image = require("./Image");
20
+
21
+ var _Routes = require("./Routes");
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { Image } from \"./Image\";\nexport { Routes } from \"./Routes\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AACA"}
package/config.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export declare type Config = Record<string, any>;
2
+ interface AppConfig {
3
+ set(config: Config): void;
4
+ get(): Config;
5
+ getKey<T = string>(key: string, defaultValue: T): T;
6
+ }
7
+ export declare const config: AppConfig;
8
+ export {};
package/config.js ADDED
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.config = void 0;
7
+
8
+ var deepFreeze = function deepFreeze(obj) {
9
+ Object.keys(obj).forEach(function (prop) {
10
+ if (typeof obj[prop] === "object" && !Object.isFrozen(obj[prop])) {
11
+ deepFreeze(obj[prop]);
12
+ }
13
+ });
14
+ return Object.freeze(obj);
15
+ };
16
+
17
+ function createConfig() {
18
+ var _config = {};
19
+ return {
20
+ set: function set(config) {
21
+ _config = deepFreeze(config);
22
+ },
23
+ get: function get() {
24
+ return _config;
25
+ },
26
+ getKey: function getKey(key, defaultValue) {
27
+ return key in _config ? _config[key] : defaultValue;
28
+ }
29
+ };
30
+ }
31
+
32
+ var config = createConfig();
33
+ exports.config = config;
package/config.js.map ADDED
@@ -0,0 +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"}
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ export declare const UiContext: React.Context<{}>;
3
+ declare type Props = {};
4
+ declare type State = {
5
+ ui: {
6
+ [key: string]: any;
7
+ };
8
+ };
9
+ interface UiData {
10
+ [key: string]: any;
11
+ }
12
+ interface UiDataSetter {
13
+ (ui: UiData): UiData;
14
+ }
15
+ export interface UiContextValue {
16
+ setState: (setter: UiDataSetter) => void;
17
+ [key: string]: any;
18
+ }
19
+ export declare class UiProvider extends React.Component<Props, State> {
20
+ state: State;
21
+ private readonly setData;
22
+ render(): JSX.Element;
23
+ }
24
+ export {};
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.UiProvider = exports.UiContext = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
14
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
+
16
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
+
18
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
+
20
+ var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
21
+
22
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
+
24
+ var _react = _interopRequireDefault(require("react"));
25
+
26
+ var _plugins = require("@webiny/plugins");
27
+
28
+ var UiContext = /*#__PURE__*/_react.default.createContext({});
29
+
30
+ exports.UiContext = UiContext;
31
+
32
+ var UiProvider = /*#__PURE__*/function (_React$Component) {
33
+ (0, _inherits2.default)(UiProvider, _React$Component);
34
+
35
+ var _super = (0, _createSuper2.default)(UiProvider);
36
+
37
+ function UiProvider() {
38
+ var _this;
39
+
40
+ (0, _classCallCheck2.default)(this, UiProvider);
41
+
42
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
43
+ args[_key] = arguments[_key];
44
+ }
45
+
46
+ _this = _super.call.apply(_super, [this].concat(args));
47
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
48
+ ui: {}
49
+ });
50
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setData", function (setter) {
51
+ return _this.setState(function (state) {
52
+ return {
53
+ ui: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state.ui), setter(state.ui))
54
+ };
55
+ });
56
+ });
57
+ return _this;
58
+ }
59
+
60
+ (0, _createClass2.default)(UiProvider, [{
61
+ key: "render",
62
+ value: function render() {
63
+ var value = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.state.ui), {}, {
64
+ setState: this.setData
65
+ });
66
+
67
+ var uiStatePlugins = _plugins.plugins.byType("ui-state");
68
+
69
+ return /*#__PURE__*/_react.default.createElement(UiContext.Provider, {
70
+ value: value
71
+ }, uiStatePlugins.map(function (pl) {
72
+ return /*#__PURE__*/_react.default.cloneElement(pl.render(), {
73
+ key: pl.name
74
+ });
75
+ }), this.props.children);
76
+ }
77
+ }]);
78
+ return UiProvider;
79
+ }(_react.default.Component);
80
+
81
+ exports.UiProvider = UiProvider;