@webiny/app 6.0.0-rc.3 → 6.0.0-rc.4
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 +2 -1
- package/App.js +6 -3
- package/App.js.map +1 -1
- package/exports/admin/{envConfig.js → env-config.js} +1 -1
- package/exports/admin/env-config.js.map +1 -0
- package/exports/admin/{graphqlClient.js → graphql-client.js} +1 -1
- package/exports/admin/graphql-client.js.map +1 -0
- package/exports/admin/{localStorage.js → local-storage.js} +1 -1
- package/exports/admin/local-storage.js.map +1 -0
- package/exports/admin/router.d.ts +1 -0
- package/exports/admin/router.js +1 -0
- package/exports/admin/router.js.map +1 -1
- package/package.json +9 -9
- package/presentation/router/components/Redirect.d.ts +14 -0
- package/presentation/router/components/Redirect.js +15 -0
- package/presentation/router/components/Redirect.js.map +1 -0
- package/core/Routes.d.ts +0 -7
- package/core/Routes.js +0 -33
- package/core/Routes.js.map +0 -1
- package/exports/admin/envConfig.js.map +0 -1
- package/exports/admin/graphqlClient.js.map +0 -1
- package/exports/admin/localStorage.js.map +0 -1
- /package/exports/admin/{envConfig.d.ts → env-config.d.ts} +0 -0
- /package/exports/admin/{graphqlClient.d.ts → graphql-client.d.ts} +0 -0
- /package/exports/admin/{localStorage.d.ts → local-storage.d.ts} +0 -0
package/App.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ declare const AppContext: React.Context<AppContext | undefined>;
|
|
|
12
12
|
export declare const useApp: () => AppContext;
|
|
13
13
|
export interface AppProps {
|
|
14
14
|
routes?: Array<any>;
|
|
15
|
+
plugins?: any[];
|
|
15
16
|
providers?: Array<Decorator<GenericComponent<ProviderProps>>>;
|
|
16
17
|
decorators?: DecoratorsCollection;
|
|
17
18
|
children?: React.ReactNode | React.ReactNode[];
|
|
@@ -19,6 +20,6 @@ export interface AppProps {
|
|
|
19
20
|
interface ProviderProps {
|
|
20
21
|
children: React.ReactNode;
|
|
21
22
|
}
|
|
22
|
-
export declare const AppBase: React.MemoExoticComponent<({ routes, providers, children }: AppProps) => React.JSX.Element>;
|
|
23
|
+
export declare const AppBase: React.MemoExoticComponent<({ routes, plugins, providers, children }: AppProps) => React.JSX.Element>;
|
|
23
24
|
export declare const App: ({ decorators, ...props }: AppProps) => React.JSX.Element;
|
|
24
25
|
export {};
|
package/App.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
1
|
+
import React, { createContext, Fragment, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
2
2
|
import { compose, CompositionProvider } from "@webiny/react-composition";
|
|
3
3
|
import { PluginsProvider } from "./core/Plugins.js";
|
|
4
4
|
import { RouterWithConfig, useRouterConfig } from "./config/RouterConfig.js";
|
|
@@ -16,11 +16,12 @@ export const useApp = () => {
|
|
|
16
16
|
};
|
|
17
17
|
export const AppBase = /*#__PURE__*/React.memo(({
|
|
18
18
|
routes = [],
|
|
19
|
+
plugins = [],
|
|
19
20
|
providers = [],
|
|
20
21
|
children
|
|
21
22
|
}) => {
|
|
22
23
|
const [state, setState] = useState({
|
|
23
|
-
plugins
|
|
24
|
+
plugins,
|
|
24
25
|
providers
|
|
25
26
|
});
|
|
26
27
|
const addProvider = useCallback(component => {
|
|
@@ -69,7 +70,9 @@ export const AppBase = /*#__PURE__*/React.memo(({
|
|
|
69
70
|
Providers.displayName = "Providers";
|
|
70
71
|
return /*#__PURE__*/React.createElement(AppContext.Provider, {
|
|
71
72
|
value: appContext
|
|
72
|
-
}, children, /*#__PURE__*/React.createElement(AppContainer, null, /*#__PURE__*/React.createElement(Providers, null, /*#__PURE__*/React.createElement(PluginsProvider, null, state.plugins
|
|
73
|
+
}, children, /*#__PURE__*/React.createElement(AppContainer, null, /*#__PURE__*/React.createElement(Providers, null, /*#__PURE__*/React.createElement(PluginsProvider, null, state.plugins.map((plugin, index) => /*#__PURE__*/React.createElement(Fragment, {
|
|
74
|
+
key: index
|
|
75
|
+
}, plugin))), /*#__PURE__*/React.createElement(RouterWithConfig, null, /*#__PURE__*/React.createElement(AppRouter, null), /*#__PURE__*/React.createElement(RouteContent, null)))));
|
|
73
76
|
});
|
|
74
77
|
AppBase.displayName = "AppBase";
|
|
75
78
|
export const App = ({
|
package/App.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","createContext","useCallback","useContext","useEffect","useMemo","useState","compose","CompositionProvider","PluginsProvider","RouterWithConfig","useRouterConfig","AppContainer","RouteContent","useRouter","AppContext","undefined","displayName","useApp","appContext","Error","AppBase","memo","routes","providers","children","state","setState","
|
|
1
|
+
{"version":3,"names":["React","createContext","Fragment","useCallback","useContext","useEffect","useMemo","useState","compose","CompositionProvider","PluginsProvider","RouterWithConfig","useRouterConfig","AppContainer","RouteContent","useRouter","AppContext","undefined","displayName","useApp","appContext","Error","AppBase","memo","routes","plugins","providers","children","state","setState","addProvider","component","findIndex","m","addPlugin","element","AppRouter","router","routerConfig","routesFromConfig","combinedRoutes","setRoutes","length","Providers","createElement","Provider","value","map","plugin","index","key","App","decorators","props","Object","assign"],"sources":["App.tsx"],"sourcesContent":["import React, {\n createContext,\n Fragment,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState\n} from \"react\";\nimport {\n compose,\n CompositionProvider,\n Decorator,\n DecoratorsCollection,\n GenericComponent\n} from \"@webiny/react-composition\";\nimport { PluginsProvider } from \"./core/Plugins.js\";\nimport { RouterWithConfig, useRouterConfig } from \"./config/RouterConfig.js\";\nimport { AppContainer } from \"./AppContainer.js\";\nimport { RouteContent } from \"~/presentation/router/components/RouteContent.js\";\nimport { useRouter } from \"~/router.js\";\n\ninterface State {\n plugins: JSX.Element[];\n providers: Decorator<GenericComponent<ProviderProps>>[];\n}\n\ninterface AppContext extends State {\n addProvider(hoc: Decorator<GenericComponent<ProviderProps>>): void;\n addPlugin(plugin: React.ReactNode): void;\n}\n\nconst AppContext = createContext<AppContext | undefined>(undefined);\n\nAppContext.displayName = \"AppContext\";\n\nexport const useApp = () => {\n const appContext = useContext(AppContext);\n if (!appContext) {\n throw Error(\n `AppContext provider was not found. Are you using the \"useApp()\" hook in the right place?`\n );\n }\n return appContext;\n};\n\nexport interface AppProps {\n routes?: Array<any>;\n plugins?: any[];\n providers?: Array<Decorator<GenericComponent<ProviderProps>>>;\n decorators?: DecoratorsCollection;\n children?: React.ReactNode | React.ReactNode[];\n}\n\ninterface ProviderProps {\n children: React.ReactNode;\n}\n\ntype ComponentWithChildren = React.ComponentType<{ children?: React.ReactNode }>;\n\nexport const AppBase = React.memo(\n ({ routes = [], plugins = [], providers = [], children }: AppProps) => {\n const [state, setState] = useState<State>({\n plugins,\n providers\n });\n\n const addProvider = useCallback((component: Decorator<any>) => {\n setState(state => {\n if (state.providers.findIndex(m => m === component) > -1) {\n return state;\n }\n\n return {\n ...state,\n providers: [...state.providers, component]\n };\n });\n }, []);\n\n const addPlugin = useCallback((element: JSX.Element) => {\n setState(state => {\n return {\n ...state,\n plugins: [...state.plugins, element]\n };\n });\n }, []);\n\n const appContext = useMemo(\n () => ({\n ...state,\n addProvider,\n addPlugin\n }),\n [state]\n );\n\n const AppRouter = useMemo(() => {\n return function AppRouter() {\n const router = useRouter();\n const routerConfig = useRouterConfig();\n const routesFromConfig = routerConfig.routes;\n const combinedRoutes = [...routes, ...routesFromConfig];\n\n useEffect(() => {\n router.setRoutes(combinedRoutes);\n }, [combinedRoutes.length]);\n\n return null;\n };\n }, []);\n\n const Providers = useMemo(() => {\n return React.memo(\n compose(...(state.providers || []))(({ children }: ProviderProps) => {\n return <>{children}</>;\n })\n );\n }, [state.providers.length]) as ComponentWithChildren;\n\n Providers.displayName = \"Providers\";\n\n return (\n <AppContext.Provider value={appContext}>\n {children}\n <AppContainer>\n <Providers>\n <PluginsProvider>\n {state.plugins.map((plugin, index) => (\n <Fragment key={index}>{plugin}</Fragment>\n ))}\n </PluginsProvider>\n <RouterWithConfig>\n <AppRouter />\n <RouteContent />\n </RouterWithConfig>\n </Providers>\n </AppContainer>\n </AppContext.Provider>\n );\n }\n);\n\nAppBase.displayName = \"AppBase\";\n\nexport const App = ({ decorators, ...props }: AppProps) => {\n return (\n <CompositionProvider decorators={decorators}>\n <AppBase decorators={decorators} {...props} />\n </CompositionProvider>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IACRC,aAAa,EACbC,QAAQ,EACRC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,QAAQ,QACL,OAAO;AACd,SACIC,OAAO,EACPC,mBAAmB,QAIhB,2BAA2B;AAClC,SAASC,eAAe;AACxB,SAASC,gBAAgB,EAAEC,eAAe;AAC1C,SAASC,YAAY;AACrB,SAASC,YAAY;AACrB,SAASC,SAAS;AAYlB,MAAMC,UAAU,gBAAGf,aAAa,CAAyBgB,SAAS,CAAC;AAEnED,UAAU,CAACE,WAAW,GAAG,YAAY;AAErC,OAAO,MAAMC,MAAM,GAAGA,CAAA,KAAM;EACxB,MAAMC,UAAU,GAAGhB,UAAU,CAACY,UAAU,CAAC;EACzC,IAAI,CAACI,UAAU,EAAE;IACb,MAAMC,KAAK,CACP,0FACJ,CAAC;EACL;EACA,OAAOD,UAAU;AACrB,CAAC;AAgBD,OAAO,MAAME,OAAO,gBAAGtB,KAAK,CAACuB,IAAI,CAC7B,CAAC;EAAEC,MAAM,GAAG,EAAE;EAAEC,OAAO,GAAG,EAAE;EAAEC,SAAS,GAAG,EAAE;EAAEC;AAAmB,CAAC,KAAK;EACnE,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGtB,QAAQ,CAAQ;IACtCkB,OAAO;IACPC;EACJ,CAAC,CAAC;EAEF,MAAMI,WAAW,GAAG3B,WAAW,CAAE4B,SAAyB,IAAK;IAC3DF,QAAQ,CAACD,KAAK,IAAI;MACd,IAAIA,KAAK,CAACF,SAAS,CAACM,SAAS,CAACC,CAAC,IAAIA,CAAC,KAAKF,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE;QAC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{ EnvConfig } from \"~/features/envConfig/index.js\";\n"],"mappings":"AAAA,SAASA,SAAS","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["GraphQLClient"],"sources":["graphql-client.ts"],"sourcesContent":["export { GraphQLClient } from \"~/features/graphqlClient/abstractions.js\";\n"],"mappings":"AAAA,SAASA,aAAa","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { LocalStorage } from "../../features/localStorage/abstractions.js";
|
|
2
2
|
export { useLocalStorage, useLocalStorageValue, useLocalStorageValues } from "../../presentation/localStorage/index.js";
|
|
3
3
|
|
|
4
|
-
//# sourceMappingURL=
|
|
4
|
+
//# sourceMappingURL=local-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["LocalStorage","useLocalStorage","useLocalStorageValue","useLocalStorageValues"],"sources":["local-storage.ts"],"sourcesContent":["export { LocalStorage } from \"~/features/localStorage/abstractions.js\";\nexport {\n useLocalStorage,\n useLocalStorageValue,\n useLocalStorageValues\n} from \"~/presentation/localStorage/index.js\";\n"],"mappings":"AAAA,SAASA,YAAY;AACrB,SACIC,eAAe,EACfC,oBAAoB,EACpBC,qBAAqB","ignoreList":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Route } from "../../features/router/Route.js";
|
|
2
2
|
export { RouteLinkComponent } from "../../presentation/router/components/RouteLink.js";
|
|
3
3
|
export { LinkComponent } from "../../presentation/router/components/SimpleLink.js";
|
|
4
|
+
export { RedirectComponent } from "../../presentation/router/components/Redirect.js";
|
|
4
5
|
export { useRoute, useRouter } from "../../presentation/router/index.js";
|
package/exports/admin/router.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { Route } from "../../features/router/Route.js";
|
|
2
2
|
export { RouteLinkComponent } from "../../presentation/router/components/RouteLink.js";
|
|
3
3
|
export { LinkComponent } from "../../presentation/router/components/SimpleLink.js";
|
|
4
|
+
export { RedirectComponent } from "../../presentation/router/components/Redirect.js";
|
|
4
5
|
export { useRoute, useRouter } from "../../presentation/router/index.js";
|
|
5
6
|
|
|
6
7
|
//# sourceMappingURL=router.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Route","RouteLinkComponent","LinkComponent","useRoute","useRouter"],"sources":["router.ts"],"sourcesContent":["export { Route } from \"~/features/router/Route.js\";\nexport { RouteLinkComponent } from \"~/presentation/router/components/RouteLink.js\";\nexport { LinkComponent } from \"~/presentation/router/components/SimpleLink.js\";\nexport { useRoute, useRouter } from \"~/presentation/router/index.js\";\n"],"mappings":"AAAA,SAASA,KAAK;AACd,SAASC,kBAAkB;AAC3B,SAASC,aAAa;AACtB,SAASC,QAAQ,EAAEC,SAAS","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Route","RouteLinkComponent","LinkComponent","RedirectComponent","useRoute","useRouter"],"sources":["router.ts"],"sourcesContent":["export { Route } from \"~/features/router/Route.js\";\nexport { RouteLinkComponent } from \"~/presentation/router/components/RouteLink.js\";\nexport { LinkComponent } from \"~/presentation/router/components/SimpleLink.js\";\nexport { RedirectComponent } from \"~/presentation/router/components/Redirect.js\";\nexport { useRoute, useRouter } from \"~/presentation/router/index.js\";\n"],"mappings":"AAAA,SAASA,KAAK;AACd,SAASC,kBAAkB;AAC3B,SAASC,aAAa;AACtB,SAASC,iBAAiB;AAC1B,SAASC,QAAQ,EAAEC,SAAS","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app",
|
|
3
|
-
"version": "6.0.0-rc.
|
|
3
|
+
"version": "6.0.0-rc.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"@emotion/styled": "11.10.6",
|
|
20
20
|
"@types/react": "18.2.79",
|
|
21
21
|
"@webiny/di": "0.2.3",
|
|
22
|
-
"@webiny/feature": "6.0.0-rc.
|
|
23
|
-
"@webiny/i18n": "6.0.0-rc.
|
|
24
|
-
"@webiny/i18n-react": "6.0.0-rc.
|
|
25
|
-
"@webiny/plugins": "6.0.0-rc.
|
|
26
|
-
"@webiny/react-composition": "6.0.0-rc.
|
|
27
|
-
"@webiny/react-properties": "6.0.0-rc.
|
|
22
|
+
"@webiny/feature": "6.0.0-rc.4",
|
|
23
|
+
"@webiny/i18n": "6.0.0-rc.4",
|
|
24
|
+
"@webiny/i18n-react": "6.0.0-rc.4",
|
|
25
|
+
"@webiny/plugins": "6.0.0-rc.4",
|
|
26
|
+
"@webiny/react-composition": "6.0.0-rc.4",
|
|
27
|
+
"@webiny/react-properties": "6.0.0-rc.4",
|
|
28
28
|
"apollo-cache": "1.3.5",
|
|
29
29
|
"apollo-cache-inmemory": "1.6.6",
|
|
30
30
|
"apollo-client": "2.6.10",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/lodash": "4.17.24",
|
|
53
53
|
"@types/warning": "3.0.3",
|
|
54
|
-
"@webiny/build-tools": "6.0.0-rc.
|
|
54
|
+
"@webiny/build-tools": "6.0.0-rc.4",
|
|
55
55
|
"rimraf": "6.1.3",
|
|
56
56
|
"type-fest": "5.4.4",
|
|
57
57
|
"typescript": "5.9.3",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
]
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "e2758ee1cfa3b9a7152e9bb995a90ccabd33266f"
|
|
72
72
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Route, RouteParamsDefinition, RouteParamsInfer } from "../../../features/router/Route.js";
|
|
2
|
+
import type { RequiredKeysOf } from "type-fest";
|
|
3
|
+
export type RedirectProps<TParams extends RouteParamsDefinition | undefined> = [
|
|
4
|
+
TParams extends RouteParamsDefinition ? RequiredKeysOf<RouteParamsInfer<TParams>> extends never ? {
|
|
5
|
+
route: Route<TParams>;
|
|
6
|
+
params?: RouteParamsInfer<TParams>;
|
|
7
|
+
} : {
|
|
8
|
+
route: Route<TParams>;
|
|
9
|
+
params: RouteParamsInfer<TParams>;
|
|
10
|
+
} : {
|
|
11
|
+
route: Route<TParams>;
|
|
12
|
+
}
|
|
13
|
+
][0];
|
|
14
|
+
export declare const RedirectComponent: <TParams extends RouteParamsDefinition | undefined>(props: RedirectProps<TParams>) => null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { useRouter } from "../../../router.js";
|
|
3
|
+
export const RedirectComponent = props => {
|
|
4
|
+
const router = useRouter();
|
|
5
|
+
const {
|
|
6
|
+
route,
|
|
7
|
+
...rest
|
|
8
|
+
} = props;
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
router.goToRoute(route, rest.params);
|
|
11
|
+
}, []);
|
|
12
|
+
return null;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=Redirect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useRouter","RedirectComponent","props","router","route","rest","goToRoute","params"],"sources":["Redirect.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport type { Route, RouteParamsDefinition, RouteParamsInfer } from \"~/features/router/Route.js\";\nimport { useRouter } from \"~/router.js\";\nimport type { RequiredKeysOf } from \"type-fest\";\n\nexport type RedirectProps<TParams extends RouteParamsDefinition | undefined> = [\n TParams extends RouteParamsDefinition\n ? RequiredKeysOf<RouteParamsInfer<TParams>> extends never\n ? { route: Route<TParams>; params?: RouteParamsInfer<TParams> }\n : { route: Route<TParams>; params: RouteParamsInfer<TParams> }\n : { route: Route<TParams> }\n][0];\n\nexport const RedirectComponent = <TParams extends RouteParamsDefinition | undefined>(\n props: RedirectProps<TParams>\n) => {\n const router = useRouter();\n const { route, ...rest } = props as any;\n\n useEffect(() => {\n router.goToRoute(route, rest.params);\n }, []);\n\n return null;\n};\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,SAASC,SAAS;AAWlB,OAAO,MAAMC,iBAAiB,GAC1BC,KAA6B,IAC5B;EACD,MAAMC,MAAM,GAAGH,SAAS,CAAC,CAAC;EAC1B,MAAM;IAAEI,KAAK;IAAE,GAAGC;EAAK,CAAC,GAAGH,KAAY;EAEvCH,SAAS,CAAC,MAAM;IACZI,MAAM,CAACG,SAAS,CAACF,KAAK,EAAEC,IAAI,CAACE,MAAM,CAAC;EACxC,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
|
package/core/Routes.d.ts
DELETED
package/core/Routes.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { useRouter } from "../router.js";
|
|
3
|
-
import { RouteContent } from "../presentation/router/components/RouteContent.js";
|
|
4
|
-
export const Routes = props => {
|
|
5
|
-
const {
|
|
6
|
-
setRoutes
|
|
7
|
-
} = useRouter();
|
|
8
|
-
const routes = props.routes.sort((a, b) => {
|
|
9
|
-
const pathA = a.route.path || "*";
|
|
10
|
-
const pathB = b.route.path || "*";
|
|
11
|
-
|
|
12
|
-
// This will sort paths at the very bottom of the list
|
|
13
|
-
if (pathA === "/" && pathB === "*") {
|
|
14
|
-
return -1;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// This will push * and / to the bottom of the list
|
|
18
|
-
if (pathA === "*" || pathA === "/") {
|
|
19
|
-
return 1;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// This will push * and / to the bottom of the list
|
|
23
|
-
if (["*", "/"].includes(pathB)) {
|
|
24
|
-
return -1;
|
|
25
|
-
}
|
|
26
|
-
return 0;
|
|
27
|
-
});
|
|
28
|
-
console.log("Call to setRoutes");
|
|
29
|
-
setRoutes(routes);
|
|
30
|
-
return /*#__PURE__*/React.createElement(RouteContent, null);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
//# sourceMappingURL=Routes.js.map
|
package/core/Routes.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","useRouter","RouteContent","Routes","props","setRoutes","routes","sort","a","b","pathA","route","path","pathB","includes","console","log","createElement"],"sources":["Routes.tsx"],"sourcesContent":["import React from \"react\";\nimport { useRouter } from \"~/router.js\";\nimport type { ReactRoute } from \"~/presentation/router/index.js\";\nimport { RouteContent } from \"~/presentation/router/components/RouteContent.js\";\n\ninterface RoutesProps {\n routes: ReactRoute[];\n}\n\nexport const Routes = (props: RoutesProps) => {\n const { setRoutes } = useRouter();\n\n const routes = props.routes.sort((a, b) => {\n const pathA: string = a.route.path || \"*\";\n const pathB: string = b.route.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 console.log(\"Call to setRoutes\");\n setRoutes(routes);\n\n return <RouteContent />;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS;AAElB,SAASC,YAAY;AAMrB,OAAO,MAAMC,MAAM,GAAIC,KAAkB,IAAK;EAC1C,MAAM;IAAEC;EAAU,CAAC,GAAGJ,SAAS,CAAC,CAAC;EAEjC,MAAMK,MAAM,GAAGF,KAAK,CAACE,MAAM,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAK;IACvC,MAAMC,KAAa,GAAGF,CAAC,CAACG,KAAK,CAACC,IAAI,IAAI,GAAG;IACzC,MAAMC,KAAa,GAAGJ,CAAC,CAACE,KAAK,CAACC,IAAI,IAAI,GAAG;;IAEzC;IACA,IAAIF,KAAK,KAAK,GAAG,IAAIG,KAAK,KAAK,GAAG,EAAE;MAChC,OAAO,CAAC,CAAC;IACb;;IAEA;IACA,IAAIH,KAAK,KAAK,GAAG,IAAIA,KAAK,KAAK,GAAG,EAAE;MAChC,OAAO,CAAC;IACZ;;IAEA;IACA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAACI,QAAQ,CAACD,KAAK,CAAC,EAAE;MAC5B,OAAO,CAAC,CAAC;IACb;IAEA,OAAO,CAAC;EACZ,CAAC,CAAC;EAEFE,OAAO,CAACC,GAAG,CAAC,mBAAmB,CAAC;EAChCX,SAAS,CAACC,MAAM,CAAC;EAEjB,oBAAON,KAAA,CAAAiB,aAAA,CAACf,YAAY,MAAE,CAAC;AAC3B,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["EnvConfig"],"sources":["envConfig.ts"],"sourcesContent":["export { EnvConfig } from \"~/features/envConfig/index.js\";\n"],"mappings":"AAAA,SAASA,SAAS","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["GraphQLClient"],"sources":["graphqlClient.ts"],"sourcesContent":["export { GraphQLClient } from \"~/features/graphqlClient/abstractions.js\";\n"],"mappings":"AAAA,SAASA,aAAa","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["LocalStorage","useLocalStorage","useLocalStorageValue","useLocalStorageValues"],"sources":["localStorage.ts"],"sourcesContent":["export { LocalStorage } from \"~/features/localStorage/abstractions.js\";\nexport {\n useLocalStorage,\n useLocalStorageValue,\n useLocalStorageValues\n} from \"~/presentation/localStorage/index.js\";\n"],"mappings":"AAAA,SAASA,YAAY;AACrB,SACIC,eAAe,EACfC,oBAAoB,EACpBC,qBAAqB","ignoreList":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|