@webiny/app 5.41.4-beta.4 → 5.41.4-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App.d.ts +3 -2
- package/App.js +5 -1
- package/App.js.map +1 -1
- package/package.json +10 -10
package/App.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactElement } from "react";
|
|
2
2
|
import { RouteProps } from "@webiny/react-router";
|
|
3
|
-
import { GenericComponent, Decorator } from "@webiny/react-composition";
|
|
3
|
+
import { GenericComponent, Decorator, DecoratorsCollection } from "@webiny/react-composition";
|
|
4
4
|
type RoutesByPath = {
|
|
5
5
|
[key: string]: ReactElement<RouteProps>;
|
|
6
6
|
};
|
|
@@ -20,13 +20,14 @@ export interface AppProps {
|
|
|
20
20
|
debounceRender?: number;
|
|
21
21
|
routes?: Array<RouteProps>;
|
|
22
22
|
providers?: Array<Decorator<GenericComponent<ProviderProps>>>;
|
|
23
|
+
decorators?: DecoratorsCollection;
|
|
23
24
|
children?: React.ReactNode | React.ReactNode[];
|
|
24
25
|
}
|
|
25
26
|
interface ProviderProps {
|
|
26
27
|
children: React.ReactNode;
|
|
27
28
|
}
|
|
28
29
|
export declare const App: {
|
|
29
|
-
({ debounceRender, routes, providers, children }: AppProps): React.JSX.Element;
|
|
30
|
+
({ debounceRender, routes, providers, decorators, children }: AppProps): React.JSX.Element;
|
|
30
31
|
displayName: string;
|
|
31
32
|
};
|
|
32
33
|
export {};
|
package/App.js
CHANGED
|
@@ -32,6 +32,8 @@ var App = exports.App = function App(_ref) {
|
|
|
32
32
|
routes = _ref$routes === void 0 ? [] : _ref$routes,
|
|
33
33
|
_ref$providers = _ref.providers,
|
|
34
34
|
providers = _ref$providers === void 0 ? [] : _ref$providers,
|
|
35
|
+
_ref$decorators = _ref.decorators,
|
|
36
|
+
decorators = _ref$decorators === void 0 ? [] : _ref$decorators,
|
|
35
37
|
children = _ref.children;
|
|
36
38
|
var _useState = (0, _react.useState)({
|
|
37
39
|
routes: routes.reduce(function (acc, item) {
|
|
@@ -96,7 +98,9 @@ var App = exports.App = function App(_ref) {
|
|
|
96
98
|
Providers.displayName = "Providers";
|
|
97
99
|
return /*#__PURE__*/_react.default.createElement(AppContext.Provider, {
|
|
98
100
|
value: appContext
|
|
99
|
-
}, /*#__PURE__*/_react.default.createElement(_reactComposition.CompositionProvider,
|
|
101
|
+
}, /*#__PURE__*/_react.default.createElement(_reactComposition.CompositionProvider, {
|
|
102
|
+
decorators: decorators
|
|
103
|
+
}, 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, {
|
|
100
104
|
wait: debounceRender
|
|
101
105
|
}, /*#__PURE__*/_react.default.createElement(AppRouter, null))))));
|
|
102
106
|
};
|
package/App.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactRouter","_reactComposition","_Routes","_DebounceRender","_Plugins","AppContext","createContext","undefined","displayName","useApp","exports","appContext","useContext","Error","App","_ref","_ref$debounceRender","debounceRender","_ref$routes","routes","_ref$providers","providers","children","_useState","useState","reduce","acc","item","_objectSpread4","default","_defineProperty2","path","createElement","Route","plugins","_useState2","_slicedToArray2","state","setState","addRoute","useCallback","route","props","addProvider","component","findIndex","m","concat","_toConsumableArray2","addPlugin","element","useMemo","AppRouter","Object","values","Routes","key","length","Providers","compose","apply","_ref2","DebounceRender","wait","Provider","value","CompositionProvider","BrowserRouter","PluginsProvider"],"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 {\n CompositionProvider,\n GenericComponent,\n compose,\n Decorator,\n HigherOrderComponent\n} 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: Decorator<GenericComponent<ProviderProps>>[];\n}\n\ninterface AppContext extends State {\n addRoute(route: JSX.Element): void;\n addProvider(hoc: Decorator<GenericComponent<ProviderProps>>): void;\n addPlugin(plugin: React.ReactNode): void;\n}\n\nconst AppContext = createContext<AppContext | undefined>(undefined);\n\nAppContext.displayName = \"AppContext\";\n\nexport const useApp = () => {\n const appContext = useContext(AppContext);\n if (!appContext) {\n throw Error(\n `AppContext provider was not found. Are you using the \"useApp()\" hook in the right place?`\n );\n }\n return appContext;\n};\n\nexport interface AppProps {\n debounceRender?: number;\n routes?: Array<RouteProps>;\n providers?: Array<Decorator<GenericComponent<ProviderProps>>>;\n children?: React.ReactNode | React.ReactNode[];\n}\n\ninterface ProviderProps {\n children: React.ReactNode;\n}\n\ntype ComponentWithChildren = React.ComponentType<{ children?: React.ReactNode }>;\n\nexport const App = ({
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactRouter","_reactComposition","_Routes","_DebounceRender","_Plugins","AppContext","createContext","undefined","displayName","useApp","exports","appContext","useContext","Error","App","_ref","_ref$debounceRender","debounceRender","_ref$routes","routes","_ref$providers","providers","_ref$decorators","decorators","children","_useState","useState","reduce","acc","item","_objectSpread4","default","_defineProperty2","path","createElement","Route","plugins","_useState2","_slicedToArray2","state","setState","addRoute","useCallback","route","props","addProvider","component","findIndex","m","concat","_toConsumableArray2","addPlugin","element","useMemo","AppRouter","Object","values","Routes","key","length","Providers","compose","apply","_ref2","DebounceRender","wait","Provider","value","CompositionProvider","BrowserRouter","PluginsProvider"],"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 {\n CompositionProvider,\n GenericComponent,\n compose,\n Decorator,\n HigherOrderComponent,\n DecoratorsCollection\n} 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: Decorator<GenericComponent<ProviderProps>>[];\n}\n\ninterface AppContext extends State {\n addRoute(route: JSX.Element): void;\n addProvider(hoc: Decorator<GenericComponent<ProviderProps>>): void;\n addPlugin(plugin: React.ReactNode): void;\n}\n\nconst AppContext = createContext<AppContext | undefined>(undefined);\n\nAppContext.displayName = \"AppContext\";\n\nexport const useApp = () => {\n const appContext = useContext(AppContext);\n if (!appContext) {\n throw Error(\n `AppContext provider was not found. Are you using the \"useApp()\" hook in the right place?`\n );\n }\n return appContext;\n};\n\nexport interface AppProps {\n debounceRender?: number;\n routes?: Array<RouteProps>;\n providers?: Array<Decorator<GenericComponent<ProviderProps>>>;\n decorators?: DecoratorsCollection;\n children?: React.ReactNode | React.ReactNode[];\n}\n\ninterface ProviderProps {\n children: React.ReactNode;\n}\n\ntype ComponentWithChildren = React.ComponentType<{ children?: React.ReactNode }>;\n\nexport const App = ({\n debounceRender = 50,\n routes = [],\n providers = [],\n decorators = [],\n children\n}: 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: HigherOrderComponent<any, any>) => {\n setState(state => {\n if (state.providers.findIndex(m => m === component) > -1) {\n return state;\n }\n\n return {\n ...state,\n providers: [...state.providers, component]\n };\n });\n }, []);\n\n const addPlugin = useCallback((element: JSX.Element) => {\n setState(state => {\n return {\n ...state,\n plugins: [...state.plugins, element]\n };\n });\n }, []);\n\n const appContext = useMemo(\n () => ({\n ...state,\n 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 }: ProviderProps) => {\n return <DebounceRender wait={debounceRender}>{children}</DebounceRender>;\n });\n }, [state.providers.length]) as ComponentWithChildren;\n\n Providers.displayName = \"Providers\";\n\n return (\n <AppContext.Provider value={appContext}>\n <CompositionProvider decorators={decorators}>\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,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AASA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAQA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAkBA,IAAMM,UAAU,gBAAG,IAAAC,oBAAa,EAAyBC,SAAS,CAAC;AAEnEF,UAAU,CAACG,WAAW,GAAG,YAAY;AAE9B,IAAMC,MAAM,GAAAC,OAAA,CAAAD,MAAA,GAAG,SAATA,MAAMA,CAAA,EAAS;EACxB,IAAME,UAAU,GAAG,IAAAC,iBAAU,EAACP,UAAU,CAAC;EACzC,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3B,MAAA,CAAAkC,OAAA,CAAAG,aAAA,CAAClC,YAAA,CAAAqE,aAAa,qBACVxE,MAAA,CAAAkC,OAAA,CAAAG,aAAA,CAAC0B,SAAS,qBACN/D,MAAA,CAAAkC,OAAA,CAAAG,aAAA,CAAC9B,QAAA,CAAAkE,eAAe,QAAE/B,KAAK,CAACH,OAAyB,CAAC,eAClDvC,MAAA,CAAAkC,OAAA,CAAAG,aAAA,CAAC/B,eAAA,CAAA6D,cAAc;IAACC,IAAI,EAAEhD;EAAe,gBACjCpB,MAAA,CAAAkC,OAAA,CAAAG,aAAA,CAACoB,SAAS,MAAE,CACA,CACT,CACA,CACE,CACJ,CAAC;AAE9B,CAAC;AAEDxC,GAAG,CAACN,WAAW,GAAG,KAAK","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app",
|
|
3
|
-
"version": "5.41.4-beta.
|
|
3
|
+
"version": "5.41.4-beta.6",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
"@babel/runtime": "7.24.1",
|
|
19
19
|
"@emotion/styled": "11.10.6",
|
|
20
20
|
"@types/react": "18.2.79",
|
|
21
|
-
"@webiny/i18n": "5.41.4-beta.
|
|
22
|
-
"@webiny/i18n-react": "5.41.4-beta.
|
|
23
|
-
"@webiny/plugins": "5.41.4-beta.
|
|
24
|
-
"@webiny/react-composition": "5.41.4-beta.
|
|
25
|
-
"@webiny/react-router": "5.41.4-beta.
|
|
26
|
-
"@webiny/ui": "5.41.4-beta.
|
|
21
|
+
"@webiny/i18n": "5.41.4-beta.6",
|
|
22
|
+
"@webiny/i18n-react": "5.41.4-beta.6",
|
|
23
|
+
"@webiny/plugins": "5.41.4-beta.6",
|
|
24
|
+
"@webiny/react-composition": "5.41.4-beta.6",
|
|
25
|
+
"@webiny/react-router": "5.41.4-beta.6",
|
|
26
|
+
"@webiny/ui": "5.41.4-beta.6",
|
|
27
27
|
"apollo-cache": "1.3.5",
|
|
28
28
|
"apollo-cache-inmemory": "1.6.6",
|
|
29
29
|
"apollo-client": "2.6.10",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"@babel/preset-typescript": "7.24.1",
|
|
54
54
|
"@types/lodash": "4.14.195",
|
|
55
55
|
"@types/warning": "3.0.0",
|
|
56
|
-
"@webiny/cli": "5.41.4-beta.
|
|
57
|
-
"@webiny/project-utils": "5.41.4-beta.
|
|
56
|
+
"@webiny/cli": "5.41.4-beta.6",
|
|
57
|
+
"@webiny/project-utils": "5.41.4-beta.6",
|
|
58
58
|
"rimraf": "5.0.5",
|
|
59
59
|
"typescript": "4.9.5"
|
|
60
60
|
},
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
]
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "94922b33af59db5afe75127bb07443ce7f1448c4"
|
|
77
77
|
}
|