@webiny/app 6.3.0 → 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
|
@@ -1,57 +1,52 @@
|
|
|
1
1
|
import { makeAutoObservable, toJS } from "mobx";
|
|
2
2
|
import { createImplementation } from "@webiny/di";
|
|
3
|
-
import {
|
|
3
|
+
import { RouterPresenter, RouterRepository } from "./abstractions.js";
|
|
4
4
|
class RouterPresenterImpl {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
constructor(routerRepository){
|
|
6
|
+
this.bootstrap = (routes)=>{
|
|
7
|
+
this.routerRepository.registerRoutes(routes);
|
|
8
|
+
};
|
|
9
|
+
this.goToRoute = (route, params)=>{
|
|
10
|
+
this.routerRepository.goToRoute(route, params);
|
|
11
|
+
};
|
|
12
|
+
this.setRouteParams = (cb)=>{
|
|
13
|
+
const currentRoute = this.routerRepository.getCurrentRoute();
|
|
14
|
+
if (!currentRoute) return;
|
|
15
|
+
const matchedRoute = this.routerRepository.getMatchedRoute();
|
|
16
|
+
const newParams = cb(matchedRoute?.params ?? {});
|
|
17
|
+
this.goToRoute(currentRoute, newParams);
|
|
18
|
+
};
|
|
19
|
+
this.getLink = (route, params)=>this.routerRepository.getLink(route, params);
|
|
20
|
+
this.addTransitionGuard = (config)=>this.routerRepository.addGuard(config);
|
|
21
|
+
this.isTransitionBlocked = ()=>this.routerRepository.isBlocked();
|
|
22
|
+
this.unblockTransition = ()=>{
|
|
23
|
+
this.routerRepository.unblock();
|
|
24
|
+
};
|
|
25
|
+
this.confirmTransition = ()=>{
|
|
26
|
+
this.routerRepository.confirmTransition();
|
|
27
|
+
};
|
|
28
|
+
this.cancelTransition = ()=>{
|
|
29
|
+
this.routerRepository.cancelTransition();
|
|
30
|
+
};
|
|
31
|
+
this.destroy = ()=>{
|
|
32
|
+
this.routerRepository.destroy();
|
|
33
|
+
};
|
|
34
|
+
this.routerRepository = routerRepository;
|
|
35
|
+
makeAutoObservable(this);
|
|
36
|
+
}
|
|
37
|
+
get vm() {
|
|
38
|
+
return {
|
|
39
|
+
currentRoute: toJS(this.routerRepository.getMatchedRoute())
|
|
40
|
+
};
|
|
24
41
|
}
|
|
25
|
-
const matchedRoute = this.routerRepository.getMatchedRoute();
|
|
26
|
-
const newParams = cb(matchedRoute?.params ?? {});
|
|
27
|
-
this.goToRoute(currentRoute, newParams);
|
|
28
|
-
};
|
|
29
|
-
getLink = (route, params) => {
|
|
30
|
-
return this.routerRepository.getLink(route, params);
|
|
31
|
-
};
|
|
32
|
-
addTransitionGuard = config => {
|
|
33
|
-
return this.routerRepository.addGuard(config);
|
|
34
|
-
};
|
|
35
|
-
isTransitionBlocked = () => {
|
|
36
|
-
return this.routerRepository.isBlocked();
|
|
37
|
-
};
|
|
38
|
-
unblockTransition = () => {
|
|
39
|
-
this.routerRepository.unblock();
|
|
40
|
-
};
|
|
41
|
-
confirmTransition = () => {
|
|
42
|
-
this.routerRepository.confirmTransition();
|
|
43
|
-
};
|
|
44
|
-
cancelTransition = () => {
|
|
45
|
-
this.routerRepository.cancelTransition();
|
|
46
|
-
};
|
|
47
|
-
destroy = () => {
|
|
48
|
-
this.routerRepository.destroy();
|
|
49
|
-
};
|
|
50
42
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
43
|
+
const RouterPresenter_RouterPresenter = createImplementation({
|
|
44
|
+
abstraction: RouterPresenter,
|
|
45
|
+
implementation: RouterPresenterImpl,
|
|
46
|
+
dependencies: [
|
|
47
|
+
RouterRepository
|
|
48
|
+
]
|
|
55
49
|
});
|
|
50
|
+
export { RouterPresenter_RouterPresenter as RouterPresenter };
|
|
56
51
|
|
|
57
52
|
//# sourceMappingURL=RouterPresenter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/router/RouterPresenter.js","sources":["../../../src/features/router/RouterPresenter.ts"],"sourcesContent":["import { makeAutoObservable, toJS } from \"mobx\";\nimport { createImplementation } from \"@webiny/di\";\nimport { Route } from \"./Route.js\";\nimport {\n RouterRepository,\n RouterPresenter as Abstraction,\n type RouteTransitionGuardConfig,\n type GuardDisposer\n} from \"./abstractions.js\";\n\nclass RouterPresenterImpl implements Abstraction.Interface {\n private routerRepository: RouterRepository.Interface;\n\n constructor(routerRepository: RouterRepository.Interface) {\n this.routerRepository = routerRepository;\n\n makeAutoObservable(this);\n }\n\n get vm() {\n return {\n currentRoute: toJS(this.routerRepository.getMatchedRoute())\n };\n }\n\n bootstrap = (routes: Route[]) => {\n this.routerRepository.registerRoutes(routes);\n };\n\n goToRoute = (route: any, params?: any) => {\n this.routerRepository.goToRoute(route, params);\n };\n\n setRouteParams = (cb: any) => {\n const currentRoute = this.routerRepository.getCurrentRoute();\n if (!currentRoute) {\n return;\n }\n\n const matchedRoute = this.routerRepository.getMatchedRoute();\n const newParams = cb(matchedRoute?.params ?? {});\n this.goToRoute(currentRoute, newParams);\n };\n\n getLink = (route: any, params?: any) => {\n return this.routerRepository.getLink(route, params);\n };\n\n addTransitionGuard = (config: RouteTransitionGuardConfig): GuardDisposer => {\n return this.routerRepository.addGuard(config);\n };\n\n isTransitionBlocked = (): boolean => {\n return this.routerRepository.isBlocked();\n };\n\n unblockTransition = (): void => {\n this.routerRepository.unblock();\n };\n\n confirmTransition = (): void => {\n this.routerRepository.confirmTransition();\n };\n\n cancelTransition = (): void => {\n this.routerRepository.cancelTransition();\n };\n\n destroy = () => {\n this.routerRepository.destroy();\n };\n}\n\nexport const RouterPresenter = createImplementation({\n abstraction: Abstraction,\n implementation: RouterPresenterImpl,\n dependencies: [RouterRepository]\n});\n"],"names":["RouterPresenterImpl","routerRepository","routes","route","params","cb","currentRoute","matchedRoute","newParams","config","makeAutoObservable","toJS","RouterPresenter","createImplementation","Abstraction","RouterRepository"],"mappings":";;;AAUA,MAAMA;IAGF,YAAYC,gBAA4C,CAAE;aAY1D,SAAS,GAAG,CAACC;YACT,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAACA;QACzC;aAEA,SAAS,GAAG,CAACC,OAAYC;YACrB,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAACD,OAAOC;QAC3C;aAEA,cAAc,GAAG,CAACC;YACd,MAAMC,eAAe,IAAI,CAAC,gBAAgB,CAAC,eAAe;YAC1D,IAAI,CAACA,cACD;YAGJ,MAAMC,eAAe,IAAI,CAAC,gBAAgB,CAAC,eAAe;YAC1D,MAAMC,YAAYH,GAAGE,cAAc,UAAU,CAAC;YAC9C,IAAI,CAAC,SAAS,CAACD,cAAcE;QACjC;aAEA,OAAO,GAAG,CAACL,OAAYC,SACZ,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAACD,OAAOC;aAGhD,kBAAkB,GAAG,CAACK,SACX,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAACA;aAG1C,mBAAmB,GAAG,IACX,IAAI,CAAC,gBAAgB,CAAC,SAAS;aAG1C,iBAAiB,GAAG;YAChB,IAAI,CAAC,gBAAgB,CAAC,OAAO;QACjC;aAEA,iBAAiB,GAAG;YAChB,IAAI,CAAC,gBAAgB,CAAC,iBAAiB;QAC3C;aAEA,gBAAgB,GAAG;YACf,IAAI,CAAC,gBAAgB,CAAC,gBAAgB;QAC1C;aAEA,OAAO,GAAG;YACN,IAAI,CAAC,gBAAgB,CAAC,OAAO;QACjC;QAxDI,IAAI,CAAC,gBAAgB,GAAGR;QAExBS,mBAAmB,IAAI;IAC3B;IAEA,IAAI,KAAK;QACL,OAAO;YACH,cAAcC,KAAK,IAAI,CAAC,gBAAgB,CAAC,eAAe;QAC5D;IACJ;AAgDJ;AAEO,MAAMC,kCAAkBC,qBAAqB;IAChD,aAAaC;IACb,gBAAgBd;IAChB,cAAc;QAACe;KAAiB;AACpC"}
|
|
@@ -1,125 +1,117 @@
|
|
|
1
1
|
import { makeAutoObservable, runInAction } from "mobx";
|
|
2
|
-
import * as Abstractions from "./abstractions.js";
|
|
3
2
|
import { RouteUrl } from "./RouteUrl.js";
|
|
3
|
+
import * as __rspack_external__abstractions_js_decaaf32 from "./abstractions.js";
|
|
4
4
|
const INIT_ROUTE = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
name: "__init__",
|
|
6
|
+
path: "",
|
|
7
|
+
pathname: "",
|
|
8
|
+
params: {}
|
|
9
9
|
};
|
|
10
10
|
class RouterRepositoryImpl {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
guardDisposers = new Map();
|
|
15
|
-
constructor(gateway) {
|
|
16
|
-
this.gateway = gateway;
|
|
17
|
-
makeAutoObservable(this, {
|
|
18
|
-
pendingTransition: false,
|
|
19
|
-
forceUnblocked: false
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
getMatchedRoute() {
|
|
23
|
-
return this.currentRoute.name !== INIT_ROUTE.name ? this.currentRoute : undefined;
|
|
24
|
-
}
|
|
25
|
-
getCurrentRoute() {
|
|
26
|
-
return this.routes.find(route => route.name === this.currentRoute.name);
|
|
27
|
-
}
|
|
28
|
-
registerRoutes = routes => {
|
|
29
|
-
this.routes = routes;
|
|
30
|
-
const routesWithAction = routes.map(this.routeWithAction);
|
|
31
|
-
this.gateway.setRoutes(routesWithAction);
|
|
32
|
-
};
|
|
33
|
-
getLink(route, params) {
|
|
34
|
-
return RouteUrl.fromPattern(route.path, params);
|
|
35
|
-
}
|
|
36
|
-
goToRoute(route, params) {
|
|
37
|
-
this.gateway.goToRoute(route.name, params);
|
|
38
|
-
}
|
|
39
|
-
addGuard(config) {
|
|
40
|
-
const gatewayGuard = {
|
|
41
|
-
guard: () => {
|
|
42
|
-
if (this.forceUnblocked) {
|
|
43
|
-
this.forceUnblocked = false;
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
return config.guard();
|
|
47
|
-
},
|
|
48
|
-
onBlocked: controller => {
|
|
49
|
-
this.pendingTransition = controller;
|
|
50
|
-
config.onBlocked(controller);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const disposeGatewayGuard = this.gateway.addGuard(gatewayGuard);
|
|
54
|
-
const dispose = () => {
|
|
55
|
-
this.guardDisposers.delete(config);
|
|
56
|
-
disposeGatewayGuard();
|
|
57
|
-
};
|
|
58
|
-
this.guardDisposers.set(config, dispose);
|
|
59
|
-
return dispose;
|
|
60
|
-
}
|
|
61
|
-
isBlocked() {
|
|
62
|
-
return this.pendingTransition !== undefined;
|
|
63
|
-
}
|
|
64
|
-
unblock() {
|
|
65
|
-
this.forceUnblocked = true;
|
|
66
|
-
if (this.pendingTransition) {
|
|
67
|
-
this.forceUnblocked = false;
|
|
68
|
-
const tx = this.pendingTransition;
|
|
69
|
-
this.pendingTransition = undefined;
|
|
70
|
-
tx.continue();
|
|
71
|
-
} else {
|
|
72
|
-
// No pending transition — expire the flag after the current
|
|
73
|
-
// call stack so it only covers synchronous navigations that
|
|
74
|
-
// follow immediately (e.g. router.goToRoute on the next line).
|
|
75
|
-
setTimeout(() => {
|
|
11
|
+
constructor(gateway){
|
|
12
|
+
this.currentRoute = INIT_ROUTE;
|
|
13
|
+
this.routes = [];
|
|
76
14
|
this.forceUnblocked = false;
|
|
77
|
-
|
|
15
|
+
this.guardDisposers = new Map();
|
|
16
|
+
this.registerRoutes = (routes)=>{
|
|
17
|
+
this.routes = routes;
|
|
18
|
+
const routesWithAction = routes.map(this.routeWithAction);
|
|
19
|
+
this.gateway.setRoutes(routesWithAction);
|
|
20
|
+
};
|
|
21
|
+
this.routeWithAction = (route)=>({
|
|
22
|
+
name: route.name,
|
|
23
|
+
path: route.path,
|
|
24
|
+
onMatch: this.transitionToRoute.bind(this)
|
|
25
|
+
});
|
|
26
|
+
this.gateway = gateway;
|
|
27
|
+
makeAutoObservable(this, {
|
|
28
|
+
pendingTransition: false,
|
|
29
|
+
forceUnblocked: false
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
getMatchedRoute() {
|
|
33
|
+
return this.currentRoute.name !== INIT_ROUTE.name ? this.currentRoute : void 0;
|
|
34
|
+
}
|
|
35
|
+
getCurrentRoute() {
|
|
36
|
+
return this.routes.find((route)=>route.name === this.currentRoute.name);
|
|
37
|
+
}
|
|
38
|
+
getLink(route, params) {
|
|
39
|
+
return RouteUrl.fromPattern(route.path, params);
|
|
40
|
+
}
|
|
41
|
+
goToRoute(route, params) {
|
|
42
|
+
this.gateway.goToRoute(route.name, params);
|
|
43
|
+
}
|
|
44
|
+
addGuard(config) {
|
|
45
|
+
const gatewayGuard = {
|
|
46
|
+
guard: ()=>{
|
|
47
|
+
if (this.forceUnblocked) {
|
|
48
|
+
this.forceUnblocked = false;
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return config.guard();
|
|
52
|
+
},
|
|
53
|
+
onBlocked: (controller)=>{
|
|
54
|
+
this.pendingTransition = controller;
|
|
55
|
+
config.onBlocked(controller);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const disposeGatewayGuard = this.gateway.addGuard(gatewayGuard);
|
|
59
|
+
const dispose = ()=>{
|
|
60
|
+
this.guardDisposers.delete(config);
|
|
61
|
+
disposeGatewayGuard();
|
|
62
|
+
};
|
|
63
|
+
this.guardDisposers.set(config, dispose);
|
|
64
|
+
return dispose;
|
|
65
|
+
}
|
|
66
|
+
isBlocked() {
|
|
67
|
+
return void 0 !== this.pendingTransition;
|
|
68
|
+
}
|
|
69
|
+
unblock() {
|
|
70
|
+
this.forceUnblocked = true;
|
|
71
|
+
if (this.pendingTransition) {
|
|
72
|
+
this.forceUnblocked = false;
|
|
73
|
+
const tx = this.pendingTransition;
|
|
74
|
+
this.pendingTransition = void 0;
|
|
75
|
+
tx.continue();
|
|
76
|
+
} else setTimeout(()=>{
|
|
77
|
+
this.forceUnblocked = false;
|
|
78
|
+
}, 0);
|
|
79
|
+
}
|
|
80
|
+
confirmTransition() {
|
|
81
|
+
const tx = this.pendingTransition;
|
|
82
|
+
this.pendingTransition = void 0;
|
|
83
|
+
if (tx) tx.continue();
|
|
84
|
+
}
|
|
85
|
+
cancelTransition() {
|
|
86
|
+
if (this.pendingTransition) {
|
|
87
|
+
this.pendingTransition.cancel();
|
|
88
|
+
this.pendingTransition = void 0;
|
|
89
|
+
}
|
|
78
90
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const tx = this.pendingTransition;
|
|
82
|
-
this.pendingTransition = undefined;
|
|
83
|
-
if (tx) {
|
|
84
|
-
tx.continue();
|
|
91
|
+
destroy() {
|
|
92
|
+
this.gateway.destroy();
|
|
85
93
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
94
|
+
async transitionToRoute(matchedRoute) {
|
|
95
|
+
const route = this.getRouteByName(matchedRoute.name);
|
|
96
|
+
if (!route) return;
|
|
97
|
+
const params = "function" == typeof route.params?.parse ? route.params.parse(matchedRoute.params) : matchedRoute.params;
|
|
98
|
+
runInAction(()=>{
|
|
99
|
+
Object.assign(this.currentRoute, {
|
|
100
|
+
...matchedRoute,
|
|
101
|
+
params
|
|
102
|
+
});
|
|
103
|
+
});
|
|
91
104
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.gateway.destroy();
|
|
95
|
-
}
|
|
96
|
-
routeWithAction = route => {
|
|
97
|
-
return {
|
|
98
|
-
name: route.name,
|
|
99
|
-
path: route.path,
|
|
100
|
-
onMatch: this.transitionToRoute.bind(this)
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
async transitionToRoute(matchedRoute) {
|
|
104
|
-
const route = this.getRouteByName(matchedRoute.name);
|
|
105
|
-
if (!route) {
|
|
106
|
-
return;
|
|
105
|
+
getRouteByName(name) {
|
|
106
|
+
return this.routes.find((existingRoute)=>existingRoute.name === name);
|
|
107
107
|
}
|
|
108
|
-
const params = typeof route.params?.parse === "function" ? route.params.parse(matchedRoute.params) : matchedRoute.params;
|
|
109
|
-
runInAction(() => {
|
|
110
|
-
Object.assign(this.currentRoute, {
|
|
111
|
-
...matchedRoute,
|
|
112
|
-
params
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
getRouteByName(name) {
|
|
117
|
-
return this.routes.find(existingRoute => existingRoute.name === name);
|
|
118
|
-
}
|
|
119
108
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
109
|
+
const RouterRepository = __rspack_external__abstractions_js_decaaf32.RouterRepository.createImplementation({
|
|
110
|
+
implementation: RouterRepositoryImpl,
|
|
111
|
+
dependencies: [
|
|
112
|
+
__rspack_external__abstractions_js_decaaf32.RouterGateway
|
|
113
|
+
]
|
|
123
114
|
});
|
|
115
|
+
export { RouterRepository };
|
|
124
116
|
|
|
125
117
|
//# sourceMappingURL=RouterRepository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/router/RouterRepository.js","sources":["../../../src/features/router/RouterRepository.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from \"mobx\";\nimport type {\n MatchedRoute,\n RouteDefinition,\n RouteTransitionGuardConfig,\n GuardDisposer,\n TransitionController\n} from \"./abstractions.js\";\nimport * as Abstractions from \"./abstractions.js\";\nimport { Route, RouteParamsDefinition, RouteParamsInfer } from \"./Route.js\";\nimport { RouteUrl } from \"./RouteUrl.js\";\n\nconst INIT_ROUTE = { name: \"__init__\", path: \"\", pathname: \"\", params: {} };\n\nclass RouterRepositoryImpl implements Abstractions.RouterRepository.Interface {\n private gateway: Abstractions.RouterGateway.Interface;\n private currentRoute: MatchedRoute = INIT_ROUTE;\n private routes: Route<any>[] = [];\n private pendingTransition: TransitionController | undefined;\n private forceUnblocked = false;\n private guardDisposers = new Map<RouteTransitionGuardConfig, GuardDisposer>();\n\n constructor(gateway: Abstractions.RouterGateway.Interface) {\n this.gateway = gateway;\n\n makeAutoObservable(this, {\n pendingTransition: false,\n forceUnblocked: false\n } as any);\n }\n\n getMatchedRoute() {\n return this.currentRoute.name !== INIT_ROUTE.name ? this.currentRoute : undefined;\n }\n\n getCurrentRoute(): Route<any> | undefined {\n return this.routes.find(route => route.name === this.currentRoute.name);\n }\n\n registerRoutes = (routes: Route[]) => {\n this.routes = routes;\n const routesWithAction = routes.map<RouteDefinition>(this.routeWithAction);\n\n this.gateway.setRoutes(routesWithAction);\n };\n\n getLink<TParams extends RouteParamsDefinition | undefined>(\n route: Route<TParams>,\n params?: TParams extends RouteParamsDefinition ? RouteParamsInfer<TParams> : undefined\n ): string {\n return RouteUrl.fromPattern(route.path, params);\n }\n\n goToRoute<TParams extends RouteParamsDefinition | undefined>(\n route: Route<TParams>,\n params: TParams extends RouteParamsDefinition ? RouteParamsInfer<TParams> : undefined\n ): void {\n this.gateway.goToRoute(route.name, params);\n }\n\n addGuard(config: RouteTransitionGuardConfig): GuardDisposer {\n const gatewayGuard: RouteTransitionGuardConfig = {\n guard: () => {\n if (this.forceUnblocked) {\n this.forceUnblocked = false;\n return false;\n }\n return config.guard();\n },\n onBlocked: (controller: TransitionController) => {\n this.pendingTransition = controller;\n config.onBlocked(controller);\n }\n };\n\n const disposeGatewayGuard = this.gateway.addGuard(gatewayGuard);\n\n const dispose = () => {\n this.guardDisposers.delete(config);\n disposeGatewayGuard();\n };\n\n this.guardDisposers.set(config, dispose);\n return dispose;\n }\n\n isBlocked(): boolean {\n return this.pendingTransition !== undefined;\n }\n\n unblock(): void {\n this.forceUnblocked = true;\n if (this.pendingTransition) {\n this.forceUnblocked = false;\n const tx = this.pendingTransition;\n this.pendingTransition = undefined;\n tx.continue();\n } else {\n // No pending transition — expire the flag after the current\n // call stack so it only covers synchronous navigations that\n // follow immediately (e.g. router.goToRoute on the next line).\n setTimeout(() => {\n this.forceUnblocked = false;\n }, 0);\n }\n }\n\n confirmTransition(): void {\n const tx = this.pendingTransition;\n this.pendingTransition = undefined;\n if (tx) {\n tx.continue();\n }\n }\n\n cancelTransition(): void {\n if (this.pendingTransition) {\n this.pendingTransition.cancel();\n this.pendingTransition = undefined;\n }\n }\n\n destroy() {\n this.gateway.destroy();\n }\n\n private routeWithAction = (route: Route<any>) => {\n return {\n name: route.name,\n path: route.path,\n onMatch: this.transitionToRoute.bind(this)\n };\n };\n\n private async transitionToRoute(matchedRoute: MatchedRoute) {\n const route = this.getRouteByName(matchedRoute.name);\n if (!route) {\n return;\n }\n\n const params =\n typeof route.params?.parse === \"function\"\n ? route.params.parse(matchedRoute.params)\n : matchedRoute.params;\n\n runInAction(() => {\n Object.assign(this.currentRoute, {\n ...matchedRoute,\n params\n });\n });\n }\n\n private getRouteByName(name: string) {\n return this.routes.find(existingRoute => existingRoute.name === name);\n }\n}\n\nexport const RouterRepository = Abstractions.RouterRepository.createImplementation({\n implementation: RouterRepositoryImpl,\n dependencies: [Abstractions.RouterGateway]\n});\n"],"names":["INIT_ROUTE","RouterRepositoryImpl","gateway","Map","routes","routesWithAction","route","makeAutoObservable","undefined","params","RouteUrl","config","gatewayGuard","controller","disposeGatewayGuard","dispose","tx","setTimeout","matchedRoute","runInAction","Object","name","existingRoute","RouterRepository","Abstractions"],"mappings":"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"}
|