@webiny/app 6.3.0-beta.4 → 6.4.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.
- package/App.js +70 -77
- package/App.js.map +1 -1
- package/AppContainer.js +3 -6
- package/AppContainer.js.map +1 -1
- package/apollo-client/InMemoryCache.js +11 -13
- package/apollo-client/InMemoryCache.js.map +1 -1
- package/apollo-client/IntrospectionFragmentMatcher.js +26 -38
- package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -1
- package/components/Image.js +11 -17
- package/components/Image.js.map +1 -1
- package/components/index.js +0 -2
- package/config/RouterConfig/Route.js +23 -28
- package/config/RouterConfig/Route.js.map +1 -1
- package/config/RouterConfig.js +11 -10
- package/config/RouterConfig.js.map +1 -1
- package/config.js +19 -20
- package/config.js.map +1 -1
- package/contexts/Ui/index.js +26 -28
- package/contexts/Ui/index.js.map +1 -1
- package/core/Plugin.js +7 -9
- package/core/Plugin.js.map +1 -1
- package/core/Plugins.js +15 -34
- package/core/Plugins.js.map +1 -1
- package/core/Provider.js +5 -13
- package/core/Provider.js.map +1 -1
- package/core/createProvider.js +3 -6
- package/core/createProvider.js.map +1 -1
- package/core/createProviderPlugin.js +8 -13
- package/core/createProviderPlugin.js.map +1 -1
- package/errors/AuthenticationErrorEvent.js +8 -5
- package/errors/AuthenticationErrorEvent.js.map +1 -1
- package/errors/NetworkErrorEvent.js +8 -5
- package/errors/NetworkErrorEvent.js.map +1 -1
- package/errors/abstractions.js +3 -2
- package/errors/abstractions.js.map +1 -1
- package/errors/index.js +1 -4
- package/exports/admin/env-config.js +0 -2
- package/exports/admin/graphql-client.js +0 -2
- package/exports/admin/local-storage.js +0 -2
- package/exports/admin/router.js +0 -2
- package/exports/admin/security.js +0 -2
- package/exports/admin.js +0 -2
- package/features/envConfig/EnvConfig.js +12 -13
- package/features/envConfig/EnvConfig.js.map +1 -1
- package/features/envConfig/abstractions.js +2 -1
- package/features/envConfig/abstractions.js.map +1 -1
- package/features/envConfig/feature.js +9 -8
- package/features/envConfig/feature.js.map +1 -1
- package/features/envConfig/index.js +0 -2
- package/features/eventPublisher/EventPublisher.js +13 -21
- package/features/eventPublisher/EventPublisher.js.map +1 -1
- package/features/eventPublisher/abstractions.js +7 -9
- package/features/eventPublisher/abstractions.js.map +1 -1
- package/features/eventPublisher/feature.js +13 -12
- package/features/eventPublisher/feature.js.map +1 -1
- package/features/eventPublisher/index.js +1 -3
- package/features/graphqlClient/AuthenticationErrorPublishing.js +26 -26
- package/features/graphqlClient/AuthenticationErrorPublishing.js.map +1 -1
- package/features/graphqlClient/BatchingGraphQLClient.js +104 -149
- package/features/graphqlClient/BatchingGraphQLClient.js.map +1 -1
- package/features/graphqlClient/FetchGraphQLClient.js +41 -48
- package/features/graphqlClient/FetchGraphQLClient.js.map +1 -1
- package/features/graphqlClient/NetworkErrorPublishing.js +35 -42
- package/features/graphqlClient/NetworkErrorPublishing.js.map +1 -1
- package/features/graphqlClient/RequestValue.js +42 -41
- package/features/graphqlClient/RequestValue.js.map +1 -1
- package/features/graphqlClient/RetryGraphQLClient.js +36 -45
- package/features/graphqlClient/RetryGraphQLClient.js.map +1 -1
- package/features/graphqlClient/__tests__/GraphQLClient.test.js +383 -356
- package/features/graphqlClient/__tests__/GraphQLClient.test.js.map +1 -1
- package/features/graphqlClient/abstractions.js +2 -1
- package/features/graphqlClient/abstractions.js.map +1 -1
- package/features/graphqlClient/feature.js +14 -20
- package/features/graphqlClient/feature.js.map +1 -1
- package/features/graphqlClient/index.js +0 -2
- package/features/graphqlClient/types.js +0 -3
- package/features/localStorage/BrowserLocalStorageGateway.js +56 -63
- package/features/localStorage/BrowserLocalStorageGateway.js.map +1 -1
- package/features/localStorage/LocalStorage.js +27 -24
- package/features/localStorage/LocalStorage.js.map +1 -1
- package/features/localStorage/LocalStorageRepository.js +75 -88
- package/features/localStorage/LocalStorageRepository.js.map +1 -1
- package/features/localStorage/abstractions.js +5 -16
- package/features/localStorage/abstractions.js.map +1 -1
- package/features/localStorage/feature.js +17 -28
- package/features/localStorage/feature.js.map +1 -1
- package/features/localStorage/index.js +1 -3
- package/features/mainGraphQLClient/MainGraphQLClient.js +18 -14
- package/features/mainGraphQLClient/MainGraphQLClient.js.map +1 -1
- package/features/mainGraphQLClient/abstractions.js +2 -1
- package/features/mainGraphQLClient/abstractions.js.map +1 -1
- package/features/mainGraphQLClient/feature.js +11 -10
- package/features/mainGraphQLClient/feature.js.map +1 -1
- package/features/mainGraphQLClient/index.js +0 -2
- package/features/router/HistoryRouterGateway.js +75 -105
- package/features/router/HistoryRouterGateway.js.map +1 -1
- package/features/router/HistoryRouterGateway.test.js +184 -193
- package/features/router/HistoryRouterGateway.test.js.map +1 -1
- package/features/router/Route.js +38 -54
- package/features/router/Route.js.map +1 -1
- package/features/router/RouteUrl.js +84 -217
- package/features/router/RouteUrl.js.map +1 -1
- package/features/router/Router.js +67 -124
- package/features/router/Router.js.map +1 -1
- package/features/router/RouterPresenter.js +44 -49
- package/features/router/RouterPresenter.js.map +1 -1
- package/features/router/RouterRepository.js +103 -111
- package/features/router/RouterRepository.js.map +1 -1
- package/features/router/RouterRepository.test.js +119 -150
- package/features/router/RouterRepository.test.js.map +1 -1
- package/features/router/abstractions.js +4 -14
- package/features/router/abstractions.js.map +1 -1
- package/features/router/feature.js +13 -12
- package/features/router/feature.js.map +1 -1
- package/features/router/index.js +1 -3
- package/helpers/InterfaceGenerator/date.js +0 -3
- package/helpers/InterfaceGenerator/id.js +0 -3
- package/helpers/InterfaceGenerator/identity.js +0 -3
- package/helpers/InterfaceGenerator/index.js +0 -3
- package/helpers/InterfaceGenerator/numeric.js +0 -3
- package/helpers/InterfaceGenerator/truthful.js +0 -3
- package/hooks/useAutocomplete/index.js +0 -2
- package/hooks/useAutocomplete/useAutocomplete.js +12 -15
- package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
- package/hooks/useDataList/functions/getData.js +2 -1
- package/hooks/useDataList/functions/getData.js.map +1 -1
- package/hooks/useDataList/functions/getError.js +2 -1
- package/hooks/useDataList/functions/getError.js.map +1 -1
- package/hooks/useDataList/functions/getMeta.js +2 -1
- package/hooks/useDataList/functions/getMeta.js.map +1 -1
- package/hooks/useDataList/functions/index.js +0 -2
- package/hooks/useDataList/functions/searchDataByKey.js +9 -14
- package/hooks/useDataList/functions/searchDataByKey.js.map +1 -1
- package/hooks/useDataList/index.js +0 -2
- package/hooks/useDataList/useDataList.js +131 -152
- package/hooks/useDataList/useDataList.js.map +1 -1
- package/hooks/useDataList/utils/index.js +0 -2
- package/hooks/useDataList/utils/prepareLoadListParams.js +25 -34
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
- package/hooks/useHandler.js +12 -16
- package/hooks/useHandler.js.map +1 -1
- package/hooks/useHandlers.js +18 -20
- package/hooks/useHandlers.js.map +1 -1
- package/hooks/useRegisterLegacyPlugin.js +7 -6
- package/hooks/useRegisterLegacyPlugin.js.map +1 -1
- package/hooks/useUi.js +2 -3
- package/hooks/useUi.js.map +1 -1
- package/i18n/i18n.js +8 -4
- package/i18n/i18n.js.map +1 -1
- package/i18n/index.js +0 -2
- package/index.js +6 -11
- package/package.json +13 -13
- package/plugins/AddQuerySelectionPlugin.js +36 -61
- package/plugins/AddQuerySelectionPlugin.js.map +1 -1
- package/plugins/ApolloCacheObjectIdPlugin.js +12 -11
- package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -1
- package/plugins/ApolloDynamicLink.js +20 -22
- package/plugins/ApolloDynamicLink.js.map +1 -1
- package/plugins/ApolloLinkPlugin.js +16 -15
- package/plugins/ApolloLinkPlugin.js.map +1 -1
- package/plugins/ConsoleLinkPlugin.js +19 -21
- package/plugins/ConsoleLinkPlugin.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +39 -45
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js +18 -22
- package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js +21 -29
- package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +6 -15
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/Typography.js +9 -14
- package/plugins/NetworkErrorLinkPlugin/Typography.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js +19 -0
- package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +11 -18
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
- package/plugins/NetworkErrorLinkPlugin.js +41 -58
- package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
- package/plugins/OmitTypenameLinkPlugin.js +9 -14
- package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
- package/plugins/TenantHeaderLinkPlugin.js +23 -32
- package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
- package/plugins/components/Image.js +8 -15
- package/plugins/components/Image.js.map +1 -1
- package/plugins/image.js +94 -133
- package/plugins/image.js.map +1 -1
- package/plugins/index.js +35 -59
- package/plugins/index.js.map +1 -1
- package/presentation/envConfig/useEnvConfig.js +4 -8
- package/presentation/envConfig/useEnvConfig.js.map +1 -1
- package/presentation/localStorage/index.js +0 -2
- package/presentation/localStorage/useLocalStorage.js +10 -16
- package/presentation/localStorage/useLocalStorage.js.map +1 -1
- package/presentation/localStorage/useLocalStorageValue.js +15 -13
- package/presentation/localStorage/useLocalStorageValue.js.map +1 -1
- package/presentation/localStorage/useLocalStorageValues.js +23 -30
- package/presentation/localStorage/useLocalStorageValues.js.map +1 -1
- package/presentation/router/RouteElementRegistry.js +22 -25
- package/presentation/router/RouteElementRegistry.js.map +1 -1
- package/presentation/router/abstractions.js +2 -1
- package/presentation/router/abstractions.js.map +1 -1
- package/presentation/router/components/Redirect.js +8 -10
- package/presentation/router/components/Redirect.js.map +1 -1
- package/presentation/router/components/RouteContent.js +14 -17
- package/presentation/router/components/RouteContent.js.map +1 -1
- package/presentation/router/components/RouteLink.js +11 -16
- package/presentation/router/components/RouteLink.js.map +1 -1
- package/presentation/router/components/SimpleLink.js +18 -24
- package/presentation/router/components/SimpleLink.js.map +1 -1
- package/presentation/router/hooks/useRoute.js +15 -23
- package/presentation/router/hooks/useRoute.js.map +1 -1
- package/presentation/router/hooks/useRouter.js +22 -23
- package/presentation/router/hooks/useRouter.js.map +1 -1
- package/presentation/router/index.js +0 -2
- package/presentation/router/types.js +0 -3
- package/react-butterfiles/Files.js +148 -217
- package/react-butterfiles/Files.js.map +1 -1
- package/react-butterfiles/index.js +2 -1
- package/react-butterfiles/index.js.map +1 -1
- package/react-butterfiles/utils/generateId.js +2 -3
- package/react-butterfiles/utils/generateId.js.map +1 -1
- package/react-butterfiles/utils/readFileContent.js +9 -13
- package/react-butterfiles/utils/readFileContent.js.map +1 -1
- package/renderApp.js +7 -6
- package/renderApp.js.map +1 -1
- package/router.js +0 -3
- package/rslib-runtime.js +14 -0
- package/rslib-runtime.js.map +1 -0
- package/shared/di/DiContainerProvider.js +8 -12
- package/shared/di/DiContainerProvider.js.map +1 -1
- package/shared/di/createFeature.js +7 -8
- package/shared/di/createFeature.js.map +1 -1
- package/shared/di/useFeature.js +7 -3
- package/shared/di/useFeature.js.map +1 -1
- package/static/svg/close_24px.33adaadc.svg +1 -0
- package/types.js +0 -3
- package/utils/createGenericContext.js +17 -21
- package/utils/createGenericContext.js.map +1 -1
- package/utils/createHashing.js +13 -16
- package/utils/createHashing.js.map +1 -1
- package/utils/index.js +0 -2
- package/utils/legacyPluginToReactComponent.js +11 -10
- package/utils/legacyPluginToReactComponent.js.map +1 -1
- package/components/index.js.map +0 -1
- package/errors/index.js.map +0 -1
- package/exports/admin/env-config.js.map +0 -1
- package/exports/admin/graphql-client.js.map +0 -1
- package/exports/admin/local-storage.js.map +0 -1
- package/exports/admin/router.js.map +0 -1
- package/exports/admin/security.js.map +0 -1
- package/exports/admin.js.map +0 -1
- package/features/envConfig/index.js.map +0 -1
- package/features/eventPublisher/index.js.map +0 -1
- package/features/graphqlClient/index.js.map +0 -1
- package/features/graphqlClient/types.js.map +0 -1
- package/features/localStorage/index.js.map +0 -1
- package/features/mainGraphQLClient/index.js.map +0 -1
- package/features/router/index.js.map +0 -1
- package/helpers/InterfaceGenerator/date.js.map +0 -1
- package/helpers/InterfaceGenerator/id.js.map +0 -1
- package/helpers/InterfaceGenerator/identity.js.map +0 -1
- package/helpers/InterfaceGenerator/index.js.map +0 -1
- package/helpers/InterfaceGenerator/numeric.js.map +0 -1
- package/helpers/InterfaceGenerator/truthful.js.map +0 -1
- package/hooks/useAutocomplete/index.js.map +0 -1
- package/hooks/useDataList/functions/index.js.map +0 -1
- package/hooks/useDataList/index.js.map +0 -1
- package/hooks/useDataList/utils/index.js.map +0 -1
- package/i18n/index.js.map +0 -1
- package/index.js.map +0 -1
- package/presentation/localStorage/index.js.map +0 -1
- package/presentation/router/index.js.map +0 -1
- package/presentation/router/types.js.map +0 -1
- package/router.js.map +0 -1
- package/types.js.map +0 -1
- package/utils/index.js.map +0 -1
|
@@ -3,37 +3,30 @@ import { autorun } from "mobx";
|
|
|
3
3
|
import isEqual from "lodash/isEqual.js";
|
|
4
4
|
import { LocalStorageFeature } from "../../features/localStorage/feature.js";
|
|
5
5
|
import { useFeature } from "../../shared/di/useFeature.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const {
|
|
13
|
-
localStorageService
|
|
14
|
-
} = useFeature(LocalStorageFeature);
|
|
15
|
-
const [values, setValues] = useState(() => {
|
|
16
|
-
const initial = {};
|
|
17
|
-
for (const key of keys) {
|
|
18
|
-
initial[key] = localStorageService.get(key);
|
|
19
|
-
}
|
|
20
|
-
return initial;
|
|
21
|
-
});
|
|
22
|
-
const valuesRef = useRef(values);
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
const dispose = autorun(() => {
|
|
25
|
-
const snapshot = {};
|
|
26
|
-
for (const key of keys) {
|
|
27
|
-
snapshot[key] = localStorageService.get(key);
|
|
28
|
-
}
|
|
29
|
-
if (!isEqual(snapshot, valuesRef.current)) {
|
|
30
|
-
setValues(snapshot);
|
|
31
|
-
valuesRef.current = snapshot;
|
|
32
|
-
}
|
|
6
|
+
function useLocalStorageValues(keys) {
|
|
7
|
+
const { localStorageService } = useFeature(LocalStorageFeature);
|
|
8
|
+
const [values, setValues] = useState(()=>{
|
|
9
|
+
const initial = {};
|
|
10
|
+
for (const key of keys)initial[key] = localStorageService.get(key);
|
|
11
|
+
return initial;
|
|
33
12
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
13
|
+
const valuesRef = useRef(values);
|
|
14
|
+
useEffect(()=>{
|
|
15
|
+
const dispose = autorun(()=>{
|
|
16
|
+
const snapshot = {};
|
|
17
|
+
for (const key of keys)snapshot[key] = localStorageService.get(key);
|
|
18
|
+
if (!isEqual(snapshot, valuesRef.current)) {
|
|
19
|
+
setValues(snapshot);
|
|
20
|
+
valuesRef.current = snapshot;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return ()=>dispose();
|
|
24
|
+
}, [
|
|
25
|
+
localStorageService,
|
|
26
|
+
keys.join(",")
|
|
27
|
+
]);
|
|
28
|
+
return values;
|
|
37
29
|
}
|
|
30
|
+
export { useLocalStorageValues };
|
|
38
31
|
|
|
39
32
|
//# sourceMappingURL=useLocalStorageValues.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"presentation/localStorage/useLocalStorageValues.js","sources":["../../../src/presentation/localStorage/useLocalStorageValues.ts"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport { autorun } from \"mobx\";\nimport isEqual from \"lodash/isEqual.js\";\nimport { LocalStorageFeature } from \"~/features/localStorage/feature.js\";\nimport { useFeature } from \"~/shared/di/useFeature.js\";\n\n/**\n * Observes multiple keys in LocalStorage and returns an object of { key: value }.\n * Re-renders when any of the observed keys change.\n */\nexport function useLocalStorageValues<T extends Record<string, any>>(\n keys: (keyof T & string)[]\n): Partial<T> {\n const { localStorageService } = useFeature(LocalStorageFeature);\n\n const [values, setValues] = useState<Partial<T>>(() => {\n const initial: Partial<T> = {};\n for (const key of keys) {\n initial[key] = localStorageService.get<any>(key);\n }\n return initial;\n });\n\n const valuesRef = useRef(values);\n\n useEffect(() => {\n const dispose = autorun(() => {\n const snapshot: Partial<T> = {};\n for (const key of keys) {\n snapshot[key] = localStorageService.get<any>(key);\n }\n\n if (!isEqual(snapshot, valuesRef.current)) {\n setValues(snapshot);\n valuesRef.current = snapshot;\n }\n });\n return () => dispose();\n }, [localStorageService, keys.join(\",\")]);\n\n return values;\n}\n"],"names":["useLocalStorageValues","keys","localStorageService","useFeature","LocalStorageFeature","values","setValues","useState","initial","key","valuesRef","useRef","useEffect","dispose","autorun","snapshot","isEqual"],"mappings":";;;;;AAUO,SAASA,sBACZC,IAA0B;IAE1B,MAAM,EAAEC,mBAAmB,EAAE,GAAGC,WAAWC;IAE3C,MAAM,CAACC,QAAQC,UAAU,GAAGC,SAAqB;QAC7C,MAAMC,UAAsB,CAAC;QAC7B,KAAK,MAAMC,OAAOR,KACdO,OAAO,CAACC,IAAI,GAAGP,oBAAoB,GAAG,CAAMO;QAEhD,OAAOD;IACX;IAEA,MAAME,YAAYC,OAAON;IAEzBO,UAAU;QACN,MAAMC,UAAUC,QAAQ;YACpB,MAAMC,WAAuB,CAAC;YAC9B,KAAK,MAAMN,OAAOR,KACdc,QAAQ,CAACN,IAAI,GAAGP,oBAAoB,GAAG,CAAMO;YAGjD,IAAI,CAACO,QAAQD,UAAUL,UAAU,OAAO,GAAG;gBACvCJ,UAAUS;gBACVL,UAAU,OAAO,GAAGK;YACxB;QACJ;QACA,OAAO,IAAMF;IACjB,GAAG;QAACX;QAAqBD,KAAK,IAAI,CAAC;KAAK;IAExC,OAAOI;AACX"}
|
|
@@ -1,32 +1,29 @@
|
|
|
1
1
|
import { createImplementation } from "@webiny/di";
|
|
2
2
|
import { RouteElementRegistry } from "./abstractions.js";
|
|
3
3
|
class RouteElementRegistryImplementation {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/** List all registered route names. */
|
|
22
|
-
list() {
|
|
23
|
-
return [...this.elements.keys()];
|
|
24
|
-
}
|
|
4
|
+
register(routeName, element) {
|
|
5
|
+
this.elements.set(routeName, element);
|
|
6
|
+
}
|
|
7
|
+
getElement(routeName) {
|
|
8
|
+
return this.elements.get(routeName) ?? null;
|
|
9
|
+
}
|
|
10
|
+
clear() {
|
|
11
|
+
this.elements.clear();
|
|
12
|
+
}
|
|
13
|
+
list() {
|
|
14
|
+
return [
|
|
15
|
+
...this.elements.keys()
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
constructor(){
|
|
19
|
+
this.elements = new Map();
|
|
20
|
+
}
|
|
25
21
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
const DefaultRouteElementRegistry = createImplementation({
|
|
23
|
+
implementation: RouteElementRegistryImplementation,
|
|
24
|
+
abstraction: RouteElementRegistry,
|
|
25
|
+
dependencies: []
|
|
30
26
|
});
|
|
27
|
+
export { DefaultRouteElementRegistry };
|
|
31
28
|
|
|
32
29
|
//# sourceMappingURL=RouteElementRegistry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"presentation/router/RouteElementRegistry.js","sources":["../../../src/presentation/router/RouteElementRegistry.ts"],"sourcesContent":["import React from \"react\";\nimport { createImplementation } from \"@webiny/di\";\nimport { RouteElementRegistry } from \"./abstractions.js\";\n\nclass RouteElementRegistryImplementation {\n private readonly elements = new Map<string, React.ReactNode>();\n\n /** Register a React element for a given route. */\n register(routeName: string, element: React.ReactNode): void {\n this.elements.set(routeName, element);\n }\n\n /** Get the element for a matched route by name. */\n getElement(routeName: string): React.ReactNode | null {\n return this.elements.get(routeName) ?? null;\n }\n\n /** Clear all registered elements. Useful in tests or hot reloads. */\n clear(): void {\n this.elements.clear();\n }\n\n /** List all registered route names. */\n list(): string[] {\n return [...this.elements.keys()];\n }\n}\n\nexport const DefaultRouteElementRegistry = createImplementation({\n implementation: RouteElementRegistryImplementation,\n abstraction: RouteElementRegistry,\n dependencies: []\n});\n"],"names":["RouteElementRegistryImplementation","routeName","element","Map","DefaultRouteElementRegistry","createImplementation","RouteElementRegistry"],"mappings":";;AAIA,MAAMA;IAIF,SAASC,SAAiB,EAAEC,OAAwB,EAAQ;QACxD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACD,WAAWC;IACjC;IAGA,WAAWD,SAAiB,EAA0B;QAClD,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACA,cAAc;IAC3C;IAGA,QAAc;QACV,IAAI,CAAC,QAAQ,CAAC,KAAK;IACvB;IAGA,OAAiB;QACb,OAAO;eAAI,IAAI,CAAC,QAAQ,CAAC,IAAI;SAAG;IACpC;;aApBiB,QAAQ,GAAG,IAAIE;;AAqBpC;AAEO,MAAMC,8BAA8BC,qBAAqB;IAC5D,gBAAgBL;IAChB,aAAaM;IACb,cAAc,EAAE;AACpB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Abstraction } from "@webiny/di";
|
|
2
|
-
|
|
2
|
+
const RouteElementRegistry = new Abstraction("RouteElementRegistry");
|
|
3
|
+
export { RouteElementRegistry };
|
|
3
4
|
|
|
4
5
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"presentation/router/abstractions.js","sources":["../../../src/presentation/router/abstractions.ts"],"sourcesContent":["import React from \"react\";\nimport { Abstraction } from \"@webiny/di\";\n\ninterface IRouteElementRegistry {\n register(name: string, element: React.ReactElement): void;\n getElement(routeName: string): React.ReactNode | null;\n clear(): void;\n list(): string[];\n}\n\nexport const RouteElementRegistry = new Abstraction<IRouteElementRegistry>(\"RouteElementRegistry\");\n\nexport namespace RouteElementRegistry {\n export type Interface = IRouteElementRegistry;\n}\n"],"names":["RouteElementRegistry","Abstraction"],"mappings":";AAUO,MAAMA,uBAAuB,IAAIC,YAAmC"}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
2
|
import { useRouter } from "../../../router.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
router.goToRoute(route, rest.params);
|
|
11
|
-
}, []);
|
|
12
|
-
return null;
|
|
3
|
+
const RedirectComponent = (props)=>{
|
|
4
|
+
const router = useRouter();
|
|
5
|
+
const { route, ...rest } = props;
|
|
6
|
+
useEffect(()=>{
|
|
7
|
+
router.goToRoute(route, rest.params);
|
|
8
|
+
}, []);
|
|
9
|
+
return null;
|
|
13
10
|
};
|
|
11
|
+
export { RedirectComponent };
|
|
14
12
|
|
|
15
13
|
//# sourceMappingURL=Redirect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"presentation/router/components/Redirect.js","sources":["../../../../src/presentation/router/components/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"],"names":["RedirectComponent","props","router","useRouter","route","rest","useEffect"],"mappings":";;AAaO,MAAMA,oBAAoB,CAC7BC;IAEA,MAAMC,SAASC;IACf,MAAM,EAAEC,KAAK,EAAE,GAAGC,MAAM,GAAGJ;IAE3BK,UAAU;QACNJ,OAAO,SAAS,CAACE,OAAOC,KAAK,MAAM;IACvC,GAAG,EAAE;IAEL,OAAO;AACX"}
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import react from "react";
|
|
2
2
|
import { DevToolsSection } from "@webiny/react-properties";
|
|
3
3
|
import { RouteElementRegistry, useRoute } from "../index.js";
|
|
4
4
|
import { useContainer } from "../../../shared/di/DiContainerProvider.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
group: "Router",
|
|
18
|
-
data: route,
|
|
19
|
-
views: "raw"
|
|
20
|
-
}), element ?? null);
|
|
5
|
+
const RouteContent = ()=>{
|
|
6
|
+
const { route } = useRoute();
|
|
7
|
+
const container = useContainer();
|
|
8
|
+
const elementRegistry = container.resolve(RouteElementRegistry);
|
|
9
|
+
if (!route) return null;
|
|
10
|
+
const element = elementRegistry.getElement(route.name);
|
|
11
|
+
return /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(DevToolsSection, {
|
|
12
|
+
name: "Current Route",
|
|
13
|
+
group: "Router",
|
|
14
|
+
data: route,
|
|
15
|
+
views: "raw"
|
|
16
|
+
}), element ?? null);
|
|
21
17
|
};
|
|
18
|
+
export { RouteContent };
|
|
22
19
|
|
|
23
20
|
//# sourceMappingURL=RouteContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"presentation/router/components/RouteContent.js","sources":["../../../../src/presentation/router/components/RouteContent.tsx"],"sourcesContent":["import React from \"react\";\nimport { DevToolsSection } from \"@webiny/react-properties\";\nimport { RouteElementRegistry, useRoute } from \"~/presentation/router/index.js\";\nimport { useContainer } from \"~/shared/di/DiContainerProvider.js\";\n\nexport const RouteContent = () => {\n const { route } = useRoute();\n const container = useContainer();\n const elementRegistry = container.resolve(RouteElementRegistry);\n\n if (!route) {\n return null;\n }\n\n const element = elementRegistry.getElement(route.name);\n\n return (\n <>\n <DevToolsSection name={\"Current Route\"} group={\"Router\"} data={route} views={\"raw\"} />\n {element ?? null}\n </>\n );\n};\n"],"names":["RouteContent","route","useRoute","container","useContainer","elementRegistry","RouteElementRegistry","element","DevToolsSection"],"mappings":";;;;AAKO,MAAMA,eAAe;IACxB,MAAM,EAAEC,KAAK,EAAE,GAAGC;IAClB,MAAMC,YAAYC;IAClB,MAAMC,kBAAkBF,UAAU,OAAO,CAACG;IAE1C,IAAI,CAACL,OACD,OAAO;IAGX,MAAMM,UAAUF,gBAAgB,UAAU,CAACJ,MAAM,IAAI;IAErD,OAAO,WAAP,GACI,wDACI,oBAACO,iBAAeA;QAAC,MAAM;QAAiB,OAAO;QAAU,MAAMP;QAAO,OAAO;QAC5EM,WAAW;AAGxB"}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import react from "react";
|
|
2
2
|
import { makeDecoratable } from "@webiny/react-composition";
|
|
3
3
|
import { SimpleLink } from "./SimpleLink.js";
|
|
4
4
|
import { useRouter } from "../../../router.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
...rest
|
|
14
|
-
} = props;
|
|
15
|
-
const href = rest.params ? router.getLink(route, rest.params) : router.getLink(route);
|
|
16
|
-
return /*#__PURE__*/React.createElement(SimpleLink, Object.assign({
|
|
17
|
-
to: href
|
|
18
|
-
}, rest), children);
|
|
5
|
+
const RouteLink = makeDecoratable("RouteLink", (props)=>{
|
|
6
|
+
const router = useRouter();
|
|
7
|
+
const { children, route, ...rest } = props;
|
|
8
|
+
const href = rest.params ? router.getLink(route, rest.params) : router.getLink(route);
|
|
9
|
+
return /*#__PURE__*/ react.createElement(SimpleLink, {
|
|
10
|
+
to: href,
|
|
11
|
+
...rest
|
|
12
|
+
}, children);
|
|
19
13
|
});
|
|
20
|
-
|
|
14
|
+
const RouteLinkComponent = RouteLink;
|
|
15
|
+
export { RouteLink, RouteLinkComponent };
|
|
21
16
|
|
|
22
17
|
//# sourceMappingURL=RouteLink.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"presentation/router/components/RouteLink.js","sources":["../../../../src/presentation/router/components/RouteLink.tsx"],"sourcesContent":["import React from \"react\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport type { Route, RouteParamsDefinition, RouteParamsInfer } from \"~/features/router/Route.js\";\nimport { SimpleLink } from \"./SimpleLink.js\";\nimport { useRouter } from \"~/router.js\";\n\ntype BaseAnchorAttributes = Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, \"href\">;\n\n// The props are generic over the Route's schema.\nexport type RouteLinkProps<TParams extends RouteParamsDefinition | undefined> = [\n TParams extends RouteParamsDefinition\n ? {\n route: Route<TParams>;\n params: RouteParamsInfer<TParams>;\n }\n : { route: Route<TParams> }\n][0] &\n BaseAnchorAttributes;\n\nexport const RouteLink = makeDecoratable(\n \"RouteLink\",\n <TParams extends RouteParamsDefinition | undefined>(props: RouteLinkProps<TParams>) => {\n const router = useRouter();\n\n const { children, route, ...rest } = props as any;\n\n const href = rest.params ? router.getLink(route!, rest.params) : router.getLink(route!);\n\n return (\n <SimpleLink to={href} {...rest}>\n {children}\n </SimpleLink>\n );\n }\n);\n\nexport const RouteLinkComponent = RouteLink;\n"],"names":["RouteLink","makeDecoratable","props","router","useRouter","children","route","rest","href","SimpleLink","RouteLinkComponent"],"mappings":";;;;AAmBO,MAAMA,YAAYC,gBACrB,aACA,CAAoDC;IAChD,MAAMC,SAASC;IAEf,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGC,MAAM,GAAGL;IAErC,MAAMM,OAAOD,KAAK,MAAM,GAAGJ,OAAO,OAAO,CAACG,OAAQC,KAAK,MAAM,IAAIJ,OAAO,OAAO,CAACG;IAEhF,OAAO,WAAP,GACI,oBAACG,YAAUA;QAAC,IAAID;QAAO,GAAGD,IAAI;OACzBF;AAGb;AAGG,MAAMK,qBAAqBV"}
|
|
@@ -1,30 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import react from "react";
|
|
2
2
|
import { makeDecoratable } from "@webiny/react-composition";
|
|
3
3
|
import { RouterGateway } from "../../../features/router/abstractions.js";
|
|
4
4
|
import { useContainer } from "../../../shared/di/DiContainerProvider.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const onClick = rest.onClick ?? handleClick;
|
|
21
|
-
return /*#__PURE__*/React.createElement("a", Object.assign({
|
|
22
|
-
href: to,
|
|
23
|
-
rel: "noreferrer noopener"
|
|
24
|
-
}, rest, {
|
|
25
|
-
onClick: onClick
|
|
26
|
-
}), children);
|
|
5
|
+
const SimpleLink = makeDecoratable("SimpleLink", ({ children, to, ...rest })=>{
|
|
6
|
+
const container = useContainer();
|
|
7
|
+
const routerGateway = container.resolve(RouterGateway);
|
|
8
|
+
const handleClick = (event)=>{
|
|
9
|
+
if (event.defaultPrevented || 0 !== event.button || event.metaKey || event.altKey || event.ctrlKey || event.shiftKey || "_blank" === rest.target) return;
|
|
10
|
+
event.preventDefault();
|
|
11
|
+
routerGateway.pushState(to);
|
|
12
|
+
};
|
|
13
|
+
const onClick = rest.onClick ?? handleClick;
|
|
14
|
+
return /*#__PURE__*/ react.createElement("a", {
|
|
15
|
+
href: to,
|
|
16
|
+
rel: "noreferrer noopener",
|
|
17
|
+
...rest,
|
|
18
|
+
onClick: onClick
|
|
19
|
+
}, children);
|
|
27
20
|
});
|
|
28
|
-
|
|
21
|
+
const LinkComponent = SimpleLink;
|
|
22
|
+
export { LinkComponent, SimpleLink };
|
|
29
23
|
|
|
30
24
|
//# sourceMappingURL=SimpleLink.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"presentation/router/components/SimpleLink.js","sources":["../../../../src/presentation/router/components/SimpleLink.tsx"],"sourcesContent":["import React from \"react\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport { RouterGateway } from \"~/features/router/abstractions.js\";\nimport { useContainer } from \"~/shared/di/DiContainerProvider.js\";\n\ntype BaseAnchorAttributes = Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, \"href\">;\n\nexport type SimpleLinkProps = BaseAnchorAttributes & {\n to: string;\n};\n\nexport const SimpleLink = makeDecoratable(\n \"SimpleLink\",\n ({ children, to, ...rest }: SimpleLinkProps) => {\n const container = useContainer();\n\n const routerGateway = container.resolve(RouterGateway);\n\n const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {\n // Respect cmd+click / ctrl+click / middle click → open in new tab\n if (\n event.defaultPrevented ||\n event.button !== 0 ||\n event.metaKey ||\n event.altKey ||\n event.ctrlKey ||\n event.shiftKey ||\n rest.target === \"_blank\"\n ) {\n return;\n }\n\n event.preventDefault();\n routerGateway.pushState(to);\n };\n\n const onClick = rest.onClick ?? handleClick;\n\n return (\n <a href={to} rel=\"noreferrer noopener\" {...rest} onClick={onClick}>\n {children}\n </a>\n );\n }\n);\n\nexport const LinkComponent = SimpleLink;\n"],"names":["SimpleLink","makeDecoratable","children","to","rest","container","useContainer","routerGateway","RouterGateway","handleClick","event","onClick","LinkComponent"],"mappings":";;;;AAWO,MAAMA,aAAaC,gBACtB,cACA,CAAC,EAAEC,QAAQ,EAAEC,EAAE,EAAE,GAAGC,MAAuB;IACvC,MAAMC,YAAYC;IAElB,MAAMC,gBAAgBF,UAAU,OAAO,CAACG;IAExC,MAAMC,cAAc,CAACC;QAEjB,IACIA,MAAM,gBAAgB,IACtBA,AAAiB,MAAjBA,MAAM,MAAM,IACZA,MAAM,OAAO,IACbA,MAAM,MAAM,IACZA,MAAM,OAAO,IACbA,MAAM,QAAQ,IACdN,AAAgB,aAAhBA,KAAK,MAAM,EAEX;QAGJM,MAAM,cAAc;QACpBH,cAAc,SAAS,CAACJ;IAC5B;IAEA,MAAMQ,UAAUP,KAAK,OAAO,IAAIK;IAEhC,OAAO,WAAP,GACI,oBAAC;QAAE,MAAMN;QAAI,KAAI;QAAuB,GAAGC,IAAI;QAAE,SAASO;OACrDT;AAGb;AAGG,MAAMU,gBAAgBZ"}
|
|
@@ -2,29 +2,21 @@ import { useEffect, useState } from "react";
|
|
|
2
2
|
import { autorun } from "mobx";
|
|
3
3
|
import { RouterFeature } from "../../../features/router/feature.js";
|
|
4
4
|
import { useFeature } from "../../../shared/di/useFeature.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
20
|
-
}, []);
|
|
21
|
-
|
|
22
|
-
// TODO: add validation (the requested route must match the current route)
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
route: currentRoute,
|
|
26
|
-
setRouteParams: presenter.setRouteParams.bind(presenter)
|
|
27
|
-
};
|
|
5
|
+
function useRoute(route) {
|
|
6
|
+
const { presenter } = useFeature(RouterFeature);
|
|
7
|
+
const [currentRoute, setCurrentRoute] = useState(presenter.vm.currentRoute);
|
|
8
|
+
useEffect(()=>{
|
|
9
|
+
autorun(()=>{
|
|
10
|
+
const route = presenter.vm.currentRoute;
|
|
11
|
+
if (!route) return;
|
|
12
|
+
setCurrentRoute(route);
|
|
13
|
+
});
|
|
14
|
+
}, []);
|
|
15
|
+
return {
|
|
16
|
+
route: currentRoute,
|
|
17
|
+
setRouteParams: presenter.setRouteParams.bind(presenter)
|
|
18
|
+
};
|
|
28
19
|
}
|
|
20
|
+
export { useRoute };
|
|
29
21
|
|
|
30
22
|
//# sourceMappingURL=useRoute.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"presentation/router/hooks/useRoute.js","sources":["../../../../src/presentation/router/hooks/useRoute.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { autorun } from \"mobx\";\nimport type { Route, RouteParamsDefinition, RouteParamsInfer } from \"~/features/router/Route.js\";\nimport { MatchedRoute } from \"~/features/router/abstractions.js\";\nimport { RouterFeature } from \"~/features/router/feature.js\";\nimport { useFeature } from \"~/shared/di/useFeature.js\";\n\nexport function useRoute<TParams extends RouteParamsDefinition | undefined = undefined>(\n // oxlint-disable-next-line typescript/no-unused-vars\n route?: Route<TParams>\n) {\n const { presenter } = useFeature(RouterFeature);\n const [currentRoute, setCurrentRoute] = useState<MatchedRoute | undefined>(\n presenter.vm.currentRoute\n );\n\n useEffect(() => {\n autorun(() => {\n const route = presenter.vm.currentRoute;\n\n if (!route) {\n return;\n }\n\n setCurrentRoute(route);\n });\n }, []);\n\n // TODO: add validation (the requested route must match the current route)\n\n return {\n route: currentRoute as MatchedRoute<\n TParams extends RouteParamsDefinition ? RouteParamsInfer<TParams> : undefined\n >,\n setRouteParams: presenter.setRouteParams.bind(presenter)\n };\n}\n"],"names":["useRoute","route","presenter","useFeature","RouterFeature","currentRoute","setCurrentRoute","useState","useEffect","autorun"],"mappings":";;;;AAOO,SAASA,SAEZC,KAAsB;IAEtB,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IACjC,MAAM,CAACC,cAAcC,gBAAgB,GAAGC,SACpCL,UAAU,EAAE,CAAC,YAAY;IAG7BM,UAAU;QACNC,QAAQ;YACJ,MAAMR,QAAQC,UAAU,EAAE,CAAC,YAAY;YAEvC,IAAI,CAACD,OACD;YAGJK,gBAAgBL;QACpB;IACJ,GAAG,EAAE;IAIL,OAAO;QACH,OAAOI;QAGP,gBAAgBH,UAAU,cAAc,CAAC,IAAI,CAACA;IAClD;AACJ"}
|
|
@@ -2,29 +2,28 @@ import { RouteElementRegistry } from "../index.js";
|
|
|
2
2
|
import { RouterFeature } from "../../../features/router/feature.js";
|
|
3
3
|
import { useFeature } from "../../../shared/di/useFeature.js";
|
|
4
4
|
import { useContainer } from "../../../shared/di/DiContainerProvider.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
};
|
|
5
|
+
const useRouter = ()=>{
|
|
6
|
+
const { presenter } = useFeature(RouterFeature);
|
|
7
|
+
const container = useContainer();
|
|
8
|
+
const registry = container.resolve(RouteElementRegistry);
|
|
9
|
+
return {
|
|
10
|
+
goToRoute: presenter.goToRoute.bind(presenter),
|
|
11
|
+
getLink: presenter.getLink.bind(presenter),
|
|
12
|
+
addTransitionGuard: presenter.addTransitionGuard.bind(presenter),
|
|
13
|
+
isTransitionBlocked: presenter.isTransitionBlocked.bind(presenter),
|
|
14
|
+
unblockTransition: presenter.unblockTransition.bind(presenter),
|
|
15
|
+
confirmTransition: presenter.confirmTransition.bind(presenter),
|
|
16
|
+
cancelTransition: presenter.cancelTransition.bind(presenter),
|
|
17
|
+
setRoutes: (routes)=>{
|
|
18
|
+
const cleanRoutes = [];
|
|
19
|
+
for (const route of routes){
|
|
20
|
+
cleanRoutes.push(route.route);
|
|
21
|
+
registry.register(route.route.name, route.element);
|
|
22
|
+
}
|
|
23
|
+
presenter.bootstrap(cleanRoutes);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
28
26
|
};
|
|
27
|
+
export { useRouter };
|
|
29
28
|
|
|
30
29
|
//# sourceMappingURL=useRouter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"presentation/router/hooks/useRouter.js","sources":["../../../../src/presentation/router/hooks/useRouter.ts"],"sourcesContent":["import { type ReactRoute, RouteElementRegistry } from \"~/presentation/router/index.js\";\nimport { RouterFeature } from \"~/features/router/feature.js\";\nimport { useFeature } from \"~/shared/di/useFeature.js\";\nimport { useContainer } from \"~/shared/di/DiContainerProvider.js\";\n\nexport const useRouter = () => {\n const { presenter } = useFeature(RouterFeature);\n const container = useContainer();\n const registry = container.resolve(RouteElementRegistry);\n\n return {\n goToRoute: presenter.goToRoute.bind(presenter),\n getLink: presenter.getLink.bind(presenter),\n addTransitionGuard: presenter.addTransitionGuard.bind(presenter),\n isTransitionBlocked: presenter.isTransitionBlocked.bind(presenter),\n unblockTransition: presenter.unblockTransition.bind(presenter),\n confirmTransition: presenter.confirmTransition.bind(presenter),\n cancelTransition: presenter.cancelTransition.bind(presenter),\n setRoutes: (routes: ReactRoute[]) => {\n const cleanRoutes = [];\n\n for (const route of routes) {\n cleanRoutes.push(route.route);\n registry.register(route.route.name, route.element);\n }\n\n presenter.bootstrap(cleanRoutes);\n }\n };\n};\n"],"names":["useRouter","presenter","useFeature","RouterFeature","container","useContainer","registry","RouteElementRegistry","routes","cleanRoutes","route"],"mappings":";;;;AAKO,MAAMA,YAAY;IACrB,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IACjC,MAAMC,YAAYC;IAClB,MAAMC,WAAWF,UAAU,OAAO,CAACG;IAEnC,OAAO;QACH,WAAWN,UAAU,SAAS,CAAC,IAAI,CAACA;QACpC,SAASA,UAAU,OAAO,CAAC,IAAI,CAACA;QAChC,oBAAoBA,UAAU,kBAAkB,CAAC,IAAI,CAACA;QACtD,qBAAqBA,UAAU,mBAAmB,CAAC,IAAI,CAACA;QACxD,mBAAmBA,UAAU,iBAAiB,CAAC,IAAI,CAACA;QACpD,mBAAmBA,UAAU,iBAAiB,CAAC,IAAI,CAACA;QACpD,kBAAkBA,UAAU,gBAAgB,CAAC,IAAI,CAACA;QAClD,WAAW,CAACO;YACR,MAAMC,cAAc,EAAE;YAEtB,KAAK,MAAMC,SAASF,OAAQ;gBACxBC,YAAY,IAAI,CAACC,MAAM,KAAK;gBAC5BJ,SAAS,QAAQ,CAACI,MAAM,KAAK,CAAC,IAAI,EAAEA,MAAM,OAAO;YACrD;YAEAT,UAAU,SAAS,CAACQ;QACxB;IACJ;AACJ"}
|