@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.
Files changed (276) hide show
  1. package/App.js +70 -77
  2. package/App.js.map +1 -1
  3. package/AppContainer.js +3 -6
  4. package/AppContainer.js.map +1 -1
  5. package/apollo-client/InMemoryCache.js +11 -13
  6. package/apollo-client/InMemoryCache.js.map +1 -1
  7. package/apollo-client/IntrospectionFragmentMatcher.js +26 -38
  8. package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -1
  9. package/components/Image.js +11 -17
  10. package/components/Image.js.map +1 -1
  11. package/components/index.js +0 -2
  12. package/config/RouterConfig/Route.js +23 -28
  13. package/config/RouterConfig/Route.js.map +1 -1
  14. package/config/RouterConfig.js +11 -10
  15. package/config/RouterConfig.js.map +1 -1
  16. package/config.js +19 -20
  17. package/config.js.map +1 -1
  18. package/contexts/Ui/index.js +26 -28
  19. package/contexts/Ui/index.js.map +1 -1
  20. package/core/Plugin.js +7 -9
  21. package/core/Plugin.js.map +1 -1
  22. package/core/Plugins.js +15 -34
  23. package/core/Plugins.js.map +1 -1
  24. package/core/Provider.js +5 -13
  25. package/core/Provider.js.map +1 -1
  26. package/core/createProvider.js +3 -6
  27. package/core/createProvider.js.map +1 -1
  28. package/core/createProviderPlugin.js +8 -13
  29. package/core/createProviderPlugin.js.map +1 -1
  30. package/errors/AuthenticationErrorEvent.js +8 -5
  31. package/errors/AuthenticationErrorEvent.js.map +1 -1
  32. package/errors/NetworkErrorEvent.js +8 -5
  33. package/errors/NetworkErrorEvent.js.map +1 -1
  34. package/errors/abstractions.js +3 -2
  35. package/errors/abstractions.js.map +1 -1
  36. package/errors/index.js +1 -4
  37. package/exports/admin/env-config.js +0 -2
  38. package/exports/admin/graphql-client.js +0 -2
  39. package/exports/admin/local-storage.js +0 -2
  40. package/exports/admin/router.js +0 -2
  41. package/exports/admin/security.js +0 -2
  42. package/exports/admin.js +0 -2
  43. package/features/envConfig/EnvConfig.js +12 -13
  44. package/features/envConfig/EnvConfig.js.map +1 -1
  45. package/features/envConfig/abstractions.js +2 -1
  46. package/features/envConfig/abstractions.js.map +1 -1
  47. package/features/envConfig/feature.js +9 -8
  48. package/features/envConfig/feature.js.map +1 -1
  49. package/features/envConfig/index.js +0 -2
  50. package/features/eventPublisher/EventPublisher.js +13 -21
  51. package/features/eventPublisher/EventPublisher.js.map +1 -1
  52. package/features/eventPublisher/abstractions.js +7 -9
  53. package/features/eventPublisher/abstractions.js.map +1 -1
  54. package/features/eventPublisher/feature.js +13 -12
  55. package/features/eventPublisher/feature.js.map +1 -1
  56. package/features/eventPublisher/index.js +1 -3
  57. package/features/graphqlClient/AuthenticationErrorPublishing.js +26 -26
  58. package/features/graphqlClient/AuthenticationErrorPublishing.js.map +1 -1
  59. package/features/graphqlClient/BatchingGraphQLClient.js +104 -149
  60. package/features/graphqlClient/BatchingGraphQLClient.js.map +1 -1
  61. package/features/graphqlClient/FetchGraphQLClient.js +41 -48
  62. package/features/graphqlClient/FetchGraphQLClient.js.map +1 -1
  63. package/features/graphqlClient/NetworkErrorPublishing.js +35 -42
  64. package/features/graphqlClient/NetworkErrorPublishing.js.map +1 -1
  65. package/features/graphqlClient/RequestValue.js +42 -41
  66. package/features/graphqlClient/RequestValue.js.map +1 -1
  67. package/features/graphqlClient/RetryGraphQLClient.js +36 -45
  68. package/features/graphqlClient/RetryGraphQLClient.js.map +1 -1
  69. package/features/graphqlClient/__tests__/GraphQLClient.test.js +383 -356
  70. package/features/graphqlClient/__tests__/GraphQLClient.test.js.map +1 -1
  71. package/features/graphqlClient/abstractions.js +2 -1
  72. package/features/graphqlClient/abstractions.js.map +1 -1
  73. package/features/graphqlClient/feature.js +14 -20
  74. package/features/graphqlClient/feature.js.map +1 -1
  75. package/features/graphqlClient/index.js +0 -2
  76. package/features/graphqlClient/types.js +0 -3
  77. package/features/localStorage/BrowserLocalStorageGateway.js +56 -63
  78. package/features/localStorage/BrowserLocalStorageGateway.js.map +1 -1
  79. package/features/localStorage/LocalStorage.js +27 -24
  80. package/features/localStorage/LocalStorage.js.map +1 -1
  81. package/features/localStorage/LocalStorageRepository.js +75 -88
  82. package/features/localStorage/LocalStorageRepository.js.map +1 -1
  83. package/features/localStorage/abstractions.js +5 -16
  84. package/features/localStorage/abstractions.js.map +1 -1
  85. package/features/localStorage/feature.js +17 -28
  86. package/features/localStorage/feature.js.map +1 -1
  87. package/features/localStorage/index.js +1 -3
  88. package/features/mainGraphQLClient/MainGraphQLClient.js +18 -14
  89. package/features/mainGraphQLClient/MainGraphQLClient.js.map +1 -1
  90. package/features/mainGraphQLClient/abstractions.js +2 -1
  91. package/features/mainGraphQLClient/abstractions.js.map +1 -1
  92. package/features/mainGraphQLClient/feature.js +11 -10
  93. package/features/mainGraphQLClient/feature.js.map +1 -1
  94. package/features/mainGraphQLClient/index.js +0 -2
  95. package/features/router/HistoryRouterGateway.js +75 -105
  96. package/features/router/HistoryRouterGateway.js.map +1 -1
  97. package/features/router/HistoryRouterGateway.test.js +184 -193
  98. package/features/router/HistoryRouterGateway.test.js.map +1 -1
  99. package/features/router/Route.js +38 -54
  100. package/features/router/Route.js.map +1 -1
  101. package/features/router/RouteUrl.js +84 -217
  102. package/features/router/RouteUrl.js.map +1 -1
  103. package/features/router/Router.js +67 -124
  104. package/features/router/Router.js.map +1 -1
  105. package/features/router/RouterPresenter.js +44 -49
  106. package/features/router/RouterPresenter.js.map +1 -1
  107. package/features/router/RouterRepository.js +103 -111
  108. package/features/router/RouterRepository.js.map +1 -1
  109. package/features/router/RouterRepository.test.js +119 -150
  110. package/features/router/RouterRepository.test.js.map +1 -1
  111. package/features/router/abstractions.js +4 -14
  112. package/features/router/abstractions.js.map +1 -1
  113. package/features/router/feature.js +13 -12
  114. package/features/router/feature.js.map +1 -1
  115. package/features/router/index.js +1 -3
  116. package/helpers/InterfaceGenerator/date.js +0 -3
  117. package/helpers/InterfaceGenerator/id.js +0 -3
  118. package/helpers/InterfaceGenerator/identity.js +0 -3
  119. package/helpers/InterfaceGenerator/index.js +0 -3
  120. package/helpers/InterfaceGenerator/numeric.js +0 -3
  121. package/helpers/InterfaceGenerator/truthful.js +0 -3
  122. package/hooks/useAutocomplete/index.js +0 -2
  123. package/hooks/useAutocomplete/useAutocomplete.js +12 -15
  124. package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
  125. package/hooks/useDataList/functions/getData.js +2 -1
  126. package/hooks/useDataList/functions/getData.js.map +1 -1
  127. package/hooks/useDataList/functions/getError.js +2 -1
  128. package/hooks/useDataList/functions/getError.js.map +1 -1
  129. package/hooks/useDataList/functions/getMeta.js +2 -1
  130. package/hooks/useDataList/functions/getMeta.js.map +1 -1
  131. package/hooks/useDataList/functions/index.js +0 -2
  132. package/hooks/useDataList/functions/searchDataByKey.js +9 -14
  133. package/hooks/useDataList/functions/searchDataByKey.js.map +1 -1
  134. package/hooks/useDataList/index.js +0 -2
  135. package/hooks/useDataList/useDataList.js +131 -152
  136. package/hooks/useDataList/useDataList.js.map +1 -1
  137. package/hooks/useDataList/utils/index.js +0 -2
  138. package/hooks/useDataList/utils/prepareLoadListParams.js +25 -34
  139. package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
  140. package/hooks/useHandler.js +12 -16
  141. package/hooks/useHandler.js.map +1 -1
  142. package/hooks/useHandlers.js +18 -20
  143. package/hooks/useHandlers.js.map +1 -1
  144. package/hooks/useRegisterLegacyPlugin.js +7 -6
  145. package/hooks/useRegisterLegacyPlugin.js.map +1 -1
  146. package/hooks/useUi.js +2 -3
  147. package/hooks/useUi.js.map +1 -1
  148. package/i18n/i18n.js +8 -4
  149. package/i18n/i18n.js.map +1 -1
  150. package/i18n/index.js +0 -2
  151. package/index.js +6 -11
  152. package/package.json +13 -13
  153. package/plugins/AddQuerySelectionPlugin.js +36 -61
  154. package/plugins/AddQuerySelectionPlugin.js.map +1 -1
  155. package/plugins/ApolloCacheObjectIdPlugin.js +12 -11
  156. package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -1
  157. package/plugins/ApolloDynamicLink.js +20 -22
  158. package/plugins/ApolloDynamicLink.js.map +1 -1
  159. package/plugins/ApolloLinkPlugin.js +16 -15
  160. package/plugins/ApolloLinkPlugin.js.map +1 -1
  161. package/plugins/ConsoleLinkPlugin.js +19 -21
  162. package/plugins/ConsoleLinkPlugin.js.map +1 -1
  163. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +39 -45
  164. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
  165. package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js +18 -22
  166. package/plugins/NetworkErrorLinkPlugin/GqlErrorOverlay.js.map +1 -1
  167. package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js +21 -29
  168. package/plugins/NetworkErrorLinkPlugin/LocalAwsLambdaTimeoutMessage.js.map +1 -1
  169. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +6 -15
  170. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
  171. package/plugins/NetworkErrorLinkPlugin/Typography.js +9 -14
  172. package/plugins/NetworkErrorLinkPlugin/Typography.js.map +1 -1
  173. package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js +19 -0
  174. package/plugins/NetworkErrorLinkPlugin/assets/close_24px.js.map +1 -0
  175. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +11 -18
  176. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
  177. package/plugins/NetworkErrorLinkPlugin.js +41 -58
  178. package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
  179. package/plugins/OmitTypenameLinkPlugin.js +9 -14
  180. package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
  181. package/plugins/TenantHeaderLinkPlugin.js +23 -32
  182. package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
  183. package/plugins/components/Image.js +8 -15
  184. package/plugins/components/Image.js.map +1 -1
  185. package/plugins/image.js +94 -133
  186. package/plugins/image.js.map +1 -1
  187. package/plugins/index.js +35 -59
  188. package/plugins/index.js.map +1 -1
  189. package/presentation/envConfig/useEnvConfig.js +4 -8
  190. package/presentation/envConfig/useEnvConfig.js.map +1 -1
  191. package/presentation/localStorage/index.js +0 -2
  192. package/presentation/localStorage/useLocalStorage.js +10 -16
  193. package/presentation/localStorage/useLocalStorage.js.map +1 -1
  194. package/presentation/localStorage/useLocalStorageValue.js +15 -13
  195. package/presentation/localStorage/useLocalStorageValue.js.map +1 -1
  196. package/presentation/localStorage/useLocalStorageValues.js +23 -30
  197. package/presentation/localStorage/useLocalStorageValues.js.map +1 -1
  198. package/presentation/router/RouteElementRegistry.js +22 -25
  199. package/presentation/router/RouteElementRegistry.js.map +1 -1
  200. package/presentation/router/abstractions.js +2 -1
  201. package/presentation/router/abstractions.js.map +1 -1
  202. package/presentation/router/components/Redirect.js +8 -10
  203. package/presentation/router/components/Redirect.js.map +1 -1
  204. package/presentation/router/components/RouteContent.js +14 -17
  205. package/presentation/router/components/RouteContent.js.map +1 -1
  206. package/presentation/router/components/RouteLink.js +11 -16
  207. package/presentation/router/components/RouteLink.js.map +1 -1
  208. package/presentation/router/components/SimpleLink.js +18 -24
  209. package/presentation/router/components/SimpleLink.js.map +1 -1
  210. package/presentation/router/hooks/useRoute.js +15 -23
  211. package/presentation/router/hooks/useRoute.js.map +1 -1
  212. package/presentation/router/hooks/useRouter.js +22 -23
  213. package/presentation/router/hooks/useRouter.js.map +1 -1
  214. package/presentation/router/index.js +0 -2
  215. package/presentation/router/types.js +0 -3
  216. package/react-butterfiles/Files.js +148 -217
  217. package/react-butterfiles/Files.js.map +1 -1
  218. package/react-butterfiles/index.js +2 -1
  219. package/react-butterfiles/index.js.map +1 -1
  220. package/react-butterfiles/utils/generateId.js +2 -3
  221. package/react-butterfiles/utils/generateId.js.map +1 -1
  222. package/react-butterfiles/utils/readFileContent.js +9 -13
  223. package/react-butterfiles/utils/readFileContent.js.map +1 -1
  224. package/renderApp.js +7 -6
  225. package/renderApp.js.map +1 -1
  226. package/router.js +0 -3
  227. package/rslib-runtime.js +14 -0
  228. package/rslib-runtime.js.map +1 -0
  229. package/shared/di/DiContainerProvider.js +8 -12
  230. package/shared/di/DiContainerProvider.js.map +1 -1
  231. package/shared/di/createFeature.js +7 -8
  232. package/shared/di/createFeature.js.map +1 -1
  233. package/shared/di/useFeature.js +7 -3
  234. package/shared/di/useFeature.js.map +1 -1
  235. package/static/svg/close_24px.33adaadc.svg +1 -0
  236. package/types.js +0 -3
  237. package/utils/createGenericContext.js +17 -21
  238. package/utils/createGenericContext.js.map +1 -1
  239. package/utils/createHashing.js +13 -16
  240. package/utils/createHashing.js.map +1 -1
  241. package/utils/index.js +0 -2
  242. package/utils/legacyPluginToReactComponent.js +11 -10
  243. package/utils/legacyPluginToReactComponent.js.map +1 -1
  244. package/components/index.js.map +0 -1
  245. package/errors/index.js.map +0 -1
  246. package/exports/admin/env-config.js.map +0 -1
  247. package/exports/admin/graphql-client.js.map +0 -1
  248. package/exports/admin/local-storage.js.map +0 -1
  249. package/exports/admin/router.js.map +0 -1
  250. package/exports/admin/security.js.map +0 -1
  251. package/exports/admin.js.map +0 -1
  252. package/features/envConfig/index.js.map +0 -1
  253. package/features/eventPublisher/index.js.map +0 -1
  254. package/features/graphqlClient/index.js.map +0 -1
  255. package/features/graphqlClient/types.js.map +0 -1
  256. package/features/localStorage/index.js.map +0 -1
  257. package/features/mainGraphQLClient/index.js.map +0 -1
  258. package/features/router/index.js.map +0 -1
  259. package/helpers/InterfaceGenerator/date.js.map +0 -1
  260. package/helpers/InterfaceGenerator/id.js.map +0 -1
  261. package/helpers/InterfaceGenerator/identity.js.map +0 -1
  262. package/helpers/InterfaceGenerator/index.js.map +0 -1
  263. package/helpers/InterfaceGenerator/numeric.js.map +0 -1
  264. package/helpers/InterfaceGenerator/truthful.js.map +0 -1
  265. package/hooks/useAutocomplete/index.js.map +0 -1
  266. package/hooks/useDataList/functions/index.js.map +0 -1
  267. package/hooks/useDataList/index.js.map +0 -1
  268. package/hooks/useDataList/utils/index.js.map +0 -1
  269. package/i18n/index.js.map +0 -1
  270. package/index.js.map +0 -1
  271. package/presentation/localStorage/index.js.map +0 -1
  272. package/presentation/router/index.js.map +0 -1
  273. package/presentation/router/types.js.map +0 -1
  274. package/router.js.map +0 -1
  275. package/types.js.map +0 -1
  276. 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 { RouterRepository, RouterPresenter as Abstraction } from "./abstractions.js";
3
+ import { RouterPresenter, RouterRepository } from "./abstractions.js";
4
4
  class RouterPresenterImpl {
5
- constructor(routerRepository) {
6
- this.routerRepository = routerRepository;
7
- makeAutoObservable(this);
8
- }
9
- get vm() {
10
- return {
11
- currentRoute: toJS(this.routerRepository.getMatchedRoute())
12
- };
13
- }
14
- bootstrap = routes => {
15
- this.routerRepository.registerRoutes(routes);
16
- };
17
- goToRoute = (route, params) => {
18
- this.routerRepository.goToRoute(route, params);
19
- };
20
- setRouteParams = cb => {
21
- const currentRoute = this.routerRepository.getCurrentRoute();
22
- if (!currentRoute) {
23
- return;
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
- export const RouterPresenter = createImplementation({
52
- abstraction: Abstraction,
53
- implementation: RouterPresenterImpl,
54
- dependencies: [RouterRepository]
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,"names":["makeAutoObservable","toJS","createImplementation","RouterRepository","RouterPresenter","Abstraction","RouterPresenterImpl","constructor","routerRepository","vm","currentRoute","getMatchedRoute","bootstrap","routes","registerRoutes","goToRoute","route","params","setRouteParams","cb","getCurrentRoute","matchedRoute","newParams","getLink","addTransitionGuard","config","addGuard","isTransitionBlocked","isBlocked","unblockTransition","unblock","confirmTransition","cancelTransition","destroy","abstraction","implementation","dependencies"],"sources":["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"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,IAAI,QAAQ,MAAM;AAC/C,SAASC,oBAAoB,QAAQ,YAAY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C,OAAO,IAAI,CAACnB,gBAAgB,CAACoB,SAAS,CAAC,CAAC;EAC5C,CAAC;EAEDC,iBAAiB,GAAGA,CAAA,KAAY;IAC5B,IAAI,CAACrB,gBAAgB,CAACsB,OAAO,CAAC,CAAC;EACnC,CAAC;EAEDC,iBAAiB,GAAGA,CAAA,KAAY;IAC5B,IAAI,CAACvB,gBAAgB,CAACuB,iBAAiB,CAAC,CAAC;EAC7C,CAAC;EAEDC,gBAAgB,GAAGA,CAAA,KAAY;IAC3B,IAAI,CAACxB,gBAAgB,CAACwB,gBAAgB,CAAC,CAAC;EAC5C,CAAC;EAEDC,OAAO,GAAGA,CAAA,KAAM;IACZ,IAAI,CAACzB,gBAAgB,CAACyB,OAAO,CAAC,CAAC;EACnC,CAAC;AACL;AAEA,OAAO,MAAM7B,eAAe,GAAGF,oBAAoB,CAAC;EAChDgC,WAAW,EAAE7B,WAAW;EACxB8B,cAAc,EAAE7B,mBAAmB;EACnC8B,YAAY,EAAE,CAACjC,gBAAgB;AACnC,CAAC,CAAC","ignoreList":[]}
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
- name: "__init__",
6
- path: "",
7
- pathname: "",
8
- params: {}
5
+ name: "__init__",
6
+ path: "",
7
+ pathname: "",
8
+ params: {}
9
9
  };
10
10
  class RouterRepositoryImpl {
11
- currentRoute = INIT_ROUTE;
12
- routes = [];
13
- forceUnblocked = false;
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
- }, 0);
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
- confirmTransition() {
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
- cancelTransition() {
88
- if (this.pendingTransition) {
89
- this.pendingTransition.cancel();
90
- this.pendingTransition = undefined;
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
- destroy() {
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
- export const RouterRepository = Abstractions.RouterRepository.createImplementation({
121
- implementation: RouterRepositoryImpl,
122
- dependencies: [Abstractions.RouterGateway]
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,"names":["makeAutoObservable","runInAction","Abstractions","RouteUrl","INIT_ROUTE","name","path","pathname","params","RouterRepositoryImpl","currentRoute","routes","forceUnblocked","guardDisposers","Map","constructor","gateway","pendingTransition","getMatchedRoute","undefined","getCurrentRoute","find","route","registerRoutes","routesWithAction","map","routeWithAction","setRoutes","getLink","fromPattern","goToRoute","addGuard","config","gatewayGuard","guard","onBlocked","controller","disposeGatewayGuard","dispose","delete","set","isBlocked","unblock","tx","continue","setTimeout","confirmTransition","cancelTransition","cancel","destroy","onMatch","transitionToRoute","bind","matchedRoute","getRouteByName","parse","Object","assign","existingRoute","RouterRepository","createImplementation","implementation","dependencies","RouterGateway"],"sources":["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: RouterR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G2C,YAAY;QACf7C;MACJ,CAAC,CAAC;IACN,CAAC,CAAC;EACN;EAEQ8C,cAAcA,CAACjD,IAAY,EAAE;IACjC,OAAO,IAAI,CAACM,MAAM,CAACU,IAAI,CAACqC,aAAa,IAAIA,aAAa,CAACrD,IAAI,KAAKA,IAAI,CAAC;EACzE;AACJ;AAEA,OAAO,MAAMsD,gBAAgB,GAAGzD,YAAY,CAACyD,gBAAgB,CAACC,oBAAoB,CAAC;EAC/EC,cAAc,EAAEpD,oBAAoB;EACpCqD,YAAY,EAAE,CAAC5D,YAAY,CAAC6D,aAAa;AAC7C,CAAC,CAAC","ignoreList":[]}
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":";;;AAYA,MAAMA,aAAa;IAAE,MAAM;IAAY,MAAM;IAAI,UAAU;IAAI,QAAQ,CAAC;AAAE;AAE1E,MAAMC;IAQF,YAAYC,OAA6C,CAAE;aANnD,YAAY,GAAiBF;aAC7B,MAAM,GAAiB,EAAE;aAEzB,cAAc,GAAG;aACjB,cAAc,GAAG,IAAIG;aAmB7B,cAAc,GAAG,CAACC;YACd,IAAI,CAAC,MAAM,GAAGA;YACd,MAAMC,mBAAmBD,OAAO,GAAG,CAAkB,IAAI,CAAC,eAAe;YAEzE,IAAI,CAAC,OAAO,CAAC,SAAS,CAACC;QAC3B;aAkFQ,eAAe,GAAG,CAACC,QAChB;gBACH,MAAMA,MAAM,IAAI;gBAChB,MAAMA,MAAM,IAAI;gBAChB,SAAS,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI;YAC7C;QA5GA,IAAI,CAAC,OAAO,GAAGJ;QAEfK,mBAAmB,IAAI,EAAE;YACrB,mBAAmB;YACnB,gBAAgB;QACpB;IACJ;IAEA,kBAAkB;QACd,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,KAAKP,WA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