@zengenti/contensis-react-base 4.0.0-beta.9 → 4.0.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 (212) hide show
  1. package/README.md +14 -1
  2. package/cjs/{App-vZrUfVgQ.js → App-CNylISW7.js} +546 -104
  3. package/cjs/App-CNylISW7.js.map +1 -0
  4. package/cjs/{ChangePassword.container-ECjEXixF.js → ChangePassword.container-C4Du3Wb1.js} +57 -50
  5. package/cjs/ChangePassword.container-C4Du3Wb1.js.map +1 -0
  6. package/cjs/{SSRContext-DVj_QAC1.js → ContensisDeliveryApi-MfcvdfDR.js} +32 -74
  7. package/cjs/ContensisDeliveryApi-MfcvdfDR.js.map +1 -0
  8. package/cjs/CookieConstants-DfPiWCRZ.js +12 -0
  9. package/cjs/CookieConstants-DfPiWCRZ.js.map +1 -0
  10. package/{esm/CookieHelper.class-FTURFpz3.js → cjs/CookieHelper.class-Det3qfdU.js} +4 -6
  11. package/cjs/CookieHelper.class-Det3qfdU.js.map +1 -0
  12. package/cjs/{RouteLoader-D5Yg7EB5.js → RouteLoader-DJeM8cym.js} +17 -9
  13. package/cjs/RouteLoader-DJeM8cym.js.map +1 -0
  14. package/cjs/SSRContext-tMufQDHY.js +116 -0
  15. package/cjs/SSRContext-tMufQDHY.js.map +1 -0
  16. package/cjs/ToJs-BsWqWjdm.js +23 -0
  17. package/cjs/ToJs-BsWqWjdm.js.map +1 -0
  18. package/cjs/{VersionInfo-B_dKCubg.js → VersionInfo-zFPsvS8q.js} +3 -25
  19. package/cjs/VersionInfo-zFPsvS8q.js.map +1 -0
  20. package/cjs/client.js +63 -65
  21. package/cjs/client.js.map +1 -1
  22. package/cjs/contensis-react-base.js +208 -119
  23. package/cjs/contensis-react-base.js.map +1 -1
  24. package/cjs/i18n.js +75 -0
  25. package/cjs/i18n.js.map +1 -0
  26. package/cjs/{ToJs-C9jwV7YB.js → matchGroups-dqONU-vY.js} +2 -22
  27. package/cjs/matchGroups-dqONU-vY.js.map +1 -0
  28. package/cjs/redux.js +8 -6
  29. package/cjs/redux.js.map +1 -1
  30. package/cjs/routing.js +15 -7
  31. package/cjs/routing.js.map +1 -1
  32. package/cjs/{sagas-BVX4Ps1e.js → sagas-BCy9u6zA.js} +523 -375
  33. package/cjs/sagas-BCy9u6zA.js.map +1 -0
  34. package/cjs/search.js +54 -29
  35. package/cjs/search.js.map +1 -1
  36. package/cjs/{selectors-wCs5fHD4.js → selectors-BrxJ8-F8.js} +27 -6
  37. package/cjs/selectors-BrxJ8-F8.js.map +1 -0
  38. package/cjs/selectors-DAQR0uZa.js +18 -0
  39. package/cjs/selectors-DAQR0uZa.js.map +1 -0
  40. package/cjs/slice-5xJMH24n.js +69 -0
  41. package/cjs/slice-5xJMH24n.js.map +1 -0
  42. package/cjs/{store-D07FOXvM.js → store-B7SJs5Hf.js} +64 -5
  43. package/cjs/store-B7SJs5Hf.js.map +1 -0
  44. package/cjs/urls-DGZlAs0y.js +25 -0
  45. package/cjs/urls-DGZlAs0y.js.map +1 -0
  46. package/cjs/user.js +20 -17
  47. package/cjs/user.js.map +1 -1
  48. package/cjs/util-eOjxDjxF.js +148 -0
  49. package/cjs/util-eOjxDjxF.js.map +1 -0
  50. package/cjs/util.js +80 -22
  51. package/cjs/util.js.map +1 -1
  52. package/cjs/{version-CM-bJ62L.js → version-rFG9Y6_B.js} +2 -2
  53. package/cjs/{version-CM-bJ62L.js.map → version-rFG9Y6_B.js.map} +1 -1
  54. package/cjs/{version-B7XFkBhY.js → version-yjHMrfVz.js} +15 -16
  55. package/cjs/version-yjHMrfVz.js.map +1 -0
  56. package/esm/{App-DLZweVSp.js → App-Bvs7Km54.js} +507 -66
  57. package/esm/App-Bvs7Km54.js.map +1 -0
  58. package/esm/{ChangePassword.container-BgzIy8dA.js → ChangePassword.container-CUBtn82K.js} +19 -13
  59. package/esm/ChangePassword.container-CUBtn82K.js.map +1 -0
  60. package/esm/{SSRContext-BE8ElZ3X.js → ContensisDeliveryApi-LWYXevZ1.js} +30 -67
  61. package/esm/ContensisDeliveryApi-LWYXevZ1.js.map +1 -0
  62. package/esm/CookieConstants-DEmbwzYr.js +7 -0
  63. package/esm/CookieConstants-DEmbwzYr.js.map +1 -0
  64. package/{cjs/CookieHelper.class-C3Eqoze9.js → esm/CookieHelper.class-C6rTRl_1.js} +2 -14
  65. package/esm/CookieHelper.class-C6rTRl_1.js.map +1 -0
  66. package/esm/{RouteLoader-xeQBXywk.js → RouteLoader-CzrlySZf.js} +14 -6
  67. package/esm/RouteLoader-CzrlySZf.js.map +1 -0
  68. package/esm/SSRContext-Bxtg1KGv.js +106 -0
  69. package/esm/SSRContext-Bxtg1KGv.js.map +1 -0
  70. package/esm/ToJs-BnRRHk6f.js +17 -0
  71. package/esm/ToJs-BnRRHk6f.js.map +1 -0
  72. package/esm/{VersionInfo-Cno7K0OA.js → VersionInfo-By2ZCZOh.js} +4 -24
  73. package/esm/VersionInfo-By2ZCZOh.js.map +1 -0
  74. package/esm/client.js +63 -64
  75. package/esm/client.js.map +1 -1
  76. package/esm/contensis-react-base.js +201 -114
  77. package/esm/contensis-react-base.js.map +1 -1
  78. package/esm/i18n.js +64 -0
  79. package/esm/i18n.js.map +1 -0
  80. package/esm/{ToJs-CNzfvyxJ.js → matchGroups-_w8BwzCC.js} +3 -18
  81. package/esm/matchGroups-_w8BwzCC.js.map +1 -0
  82. package/esm/redux.js +11 -8
  83. package/esm/redux.js.map +1 -1
  84. package/esm/routing.js +14 -7
  85. package/esm/routing.js.map +1 -1
  86. package/esm/{sagas-JI51CS37.js → sagas-Fr9yRduO.js} +511 -362
  87. package/esm/sagas-Fr9yRduO.js.map +1 -0
  88. package/esm/search.js +73 -47
  89. package/esm/search.js.map +1 -1
  90. package/esm/{selectors-DO2ocdOp.js → selectors-8ROQrTd7.js} +25 -7
  91. package/esm/selectors-8ROQrTd7.js.map +1 -0
  92. package/esm/selectors-DcmvOeX2.js +10 -0
  93. package/esm/selectors-DcmvOeX2.js.map +1 -0
  94. package/esm/slice-C6JLQik8.js +63 -0
  95. package/esm/slice-C6JLQik8.js.map +1 -0
  96. package/esm/{store-3u0RzHZ0.js → store-B4IrBYHm.js} +64 -6
  97. package/esm/store-B4IrBYHm.js.map +1 -0
  98. package/esm/urls-tLxo_skx.js +22 -0
  99. package/esm/urls-tLxo_skx.js.map +1 -0
  100. package/esm/user.js +9 -6
  101. package/esm/user.js.map +1 -1
  102. package/esm/util-Bl2u6LpY.js +136 -0
  103. package/esm/util-Bl2u6LpY.js.map +1 -0
  104. package/esm/util.js +58 -14
  105. package/esm/util.js.map +1 -1
  106. package/esm/{version-wnf-TITV.js → version-BQAL8sQO.js} +2 -2
  107. package/esm/{version-wnf-TITV.js.map → version-BQAL8sQO.js.map} +1 -1
  108. package/esm/{version-BlsI7hX2.js → version-CA9Mdm3A.js} +16 -16
  109. package/esm/version-CA9Mdm3A.js.map +1 -0
  110. package/i18n/package.json +5 -0
  111. package/models/app/pages/VersionInfo/components/VersionInfo.d.ts +1 -1
  112. package/models/app/pages/VersionInfo/components/VersionInfo.styled.d.ts +1 -2
  113. package/models/i18n/index.d.ts +5 -0
  114. package/models/i18n/redux/sagas.d.ts +19 -0
  115. package/models/i18n/redux/selectors.d.ts +11 -0
  116. package/models/i18n/redux/slice.d.ts +198 -0
  117. package/models/i18n/routes.d.ts +8 -0
  118. package/models/i18n/useI18n.hook.d.ts +20 -0
  119. package/models/index.d.ts +1 -0
  120. package/models/models/AppState.d.ts +2 -0
  121. package/models/models/ContentTypeMapping.d.ts +6 -1
  122. package/models/models/EntryMapper.d.ts +2 -1
  123. package/models/models/Locales.d.ts +11 -0
  124. package/models/models/MatchedRoute.d.ts +5 -1
  125. package/models/models/RouteComponent.d.ts +0 -1
  126. package/models/models/RouteNode.d.ts +4 -2
  127. package/models/models/SSRContext.d.ts +4 -4
  128. package/models/models/StaticRoute.d.ts +12 -1
  129. package/models/models/WithEvents.d.ts +8 -0
  130. package/models/models/config/AppConfig.d.ts +2 -0
  131. package/models/models/config/I18n.d.ts +38 -0
  132. package/models/models/config/ServerConfig.d.ts +14 -0
  133. package/models/redux/index.d.ts +2 -1
  134. package/models/redux/sagas/index.d.ts +3 -1
  135. package/models/redux/sagas/injector.d.ts +13 -0
  136. package/models/redux/store/injectors/index.d.ts +26 -0
  137. package/models/redux/store/injectors/inject.d.ts +24 -0
  138. package/models/redux/store/injectors/util.d.ts +2 -0
  139. package/models/redux/store/store.d.ts +13 -4
  140. package/models/redux/util.d.ts +1 -1
  141. package/models/routing/components/RouteLoader.d.ts +3 -3
  142. package/models/routing/httpContext.d.ts +0 -1
  143. package/models/routing/index.d.ts +1 -0
  144. package/models/routing/redux/actions.d.ts +1 -1
  145. package/models/routing/redux/invokeSearch.d.ts +22 -0
  146. package/models/routing/redux/selectors.d.ts +47 -4
  147. package/models/routing/util/expressions.d.ts +1 -1
  148. package/models/routing/util/find-contenttype-mapping.d.ts +3 -1
  149. package/models/search/containers/withListing.d.ts +1 -1
  150. package/models/search/containers/withSearch.d.ts +1 -1
  151. package/models/search/models/Queries.d.ts +3 -5
  152. package/models/search/models/Search.d.ts +43 -13
  153. package/models/search/models/SearchActions.d.ts +61 -18
  154. package/models/search/models/SearchProps.d.ts +11 -10
  155. package/models/search/models/SearchState.d.ts +23 -2
  156. package/models/search/models/SearchUtil.d.ts +3 -3
  157. package/models/search/redux/getIn.d.ts +2 -2
  158. package/models/search/redux/reducers.d.ts +3 -4
  159. package/models/search/redux/sagas.d.ts +13 -14
  160. package/models/search/redux/schema.d.ts +3 -3
  161. package/models/search/redux/selectors.d.ts +64 -42
  162. package/models/search/redux/util.d.ts +10 -1
  163. package/models/search/search/ContensisDeliveryApi.d.ts +6 -26
  164. package/models/search/search/expressions.d.ts +6 -4
  165. package/models/search/search/util.d.ts +9 -7
  166. package/models/search/transformations/state-to-queryparams.mapper.d.ts +1 -1
  167. package/models/server/features/linkdepth-api/search.d.ts +1 -1
  168. package/models/server/features/response-handler/render-stream.d.ts +2 -4
  169. package/models/server/features/static-assets/index.d.ts +4 -3
  170. package/models/server/internalServer.d.ts +1 -2
  171. package/models/server/middleware/subsiteDebug.d.ts +11 -0
  172. package/models/server/root.d.ts +3 -0
  173. package/models/server/util/bundles.d.ts +9 -9
  174. package/models/server/util/jsx.d.ts +2 -14
  175. package/models/user/components.styled/Login.styled.d.ts +1 -1
  176. package/models/user/components.styled/LoginForm.styled.d.ts +1 -1
  177. package/models/user/hocs/withRegistration.d.ts +1 -1
  178. package/models/util/CachedDeliveryApi.d.ts +8 -2
  179. package/models/util/ContensisDeliveryApi.d.ts +2 -4
  180. package/models/util/NoSSR.d.ts +6 -0
  181. package/models/util/SSRContext.d.ts +3 -19
  182. package/models/util/donotuse_useHistory.d.ts +6 -0
  183. package/models/util/errors.d.ts +16 -0
  184. package/models/util/index.d.ts +7 -2
  185. package/models/util/subsite.d.ts +12 -0
  186. package/models/util/urls.d.ts +1 -2
  187. package/models/util/useIsClient.d.ts +6 -0
  188. package/package.json +37 -39
  189. package/cjs/App-vZrUfVgQ.js.map +0 -1
  190. package/cjs/ChangePassword.container-ECjEXixF.js.map +0 -1
  191. package/cjs/CookieHelper.class-C3Eqoze9.js.map +0 -1
  192. package/cjs/RouteLoader-D5Yg7EB5.js.map +0 -1
  193. package/cjs/SSRContext-DVj_QAC1.js.map +0 -1
  194. package/cjs/ToJs-C9jwV7YB.js.map +0 -1
  195. package/cjs/VersionInfo-B_dKCubg.js.map +0 -1
  196. package/cjs/sagas-BVX4Ps1e.js.map +0 -1
  197. package/cjs/selectors-wCs5fHD4.js.map +0 -1
  198. package/cjs/store-D07FOXvM.js.map +0 -1
  199. package/cjs/version-B7XFkBhY.js.map +0 -1
  200. package/esm/App-DLZweVSp.js.map +0 -1
  201. package/esm/ChangePassword.container-BgzIy8dA.js.map +0 -1
  202. package/esm/CookieHelper.class-FTURFpz3.js.map +0 -1
  203. package/esm/RouteLoader-xeQBXywk.js.map +0 -1
  204. package/esm/SSRContext-BE8ElZ3X.js.map +0 -1
  205. package/esm/ToJs-CNzfvyxJ.js.map +0 -1
  206. package/esm/VersionInfo-Cno7K0OA.js.map +0 -1
  207. package/esm/sagas-JI51CS37.js.map +0 -1
  208. package/esm/selectors-DO2ocdOp.js.map +0 -1
  209. package/esm/store-3u0RzHZ0.js.map +0 -1
  210. package/esm/version-BlsI7hX2.js.map +0 -1
  211. package/models/redux/store/injectors.d.ts +0 -31
  212. package/models/search/search/ToJs.d.ts +0 -4
@@ -1,21 +1,89 @@
1
1
  import { createBrowserHistory, createMemoryHistory } from 'history';
2
- import { takeEvery, select, put, call, all } from '@redux-saga/core/effects';
2
+ import { takeEvery, select, put, call, cancel, fork, take, cancelled, all } from '@redux-saga/core/effects';
3
3
  import * as log from 'loglevel';
4
- import { G as GET_NODE_TREE, b as SET_NODE_TREE, d as GET_NODE_TREE_ERROR } from './store-3u0RzHZ0.js';
5
- import { h as hasNavigationTree, i as injectRedux } from './version-BlsI7hX2.js';
4
+ import { error as error$1 } from 'loglevel';
5
+ import { G as GET_NODE_TREE, b as SET_NODE_TREE, d as GET_NODE_TREE_ERROR } from './store-B4IrBYHm.js';
6
+ import { h as hasNavigationTree, b as injectRedux } from './version-CA9Mdm3A.js';
6
7
  import to, { to as to$1 } from 'await-to-js';
7
- import { y as SET_NAVIGATION_PATH, x as SET_ROUTE, h as selectRouteEntry, C as selectCurrentNode, n as selectCurrentProject, z as UPDATE_LOADING_STATE, D as selectCurrentAncestors, E as selectCurrentSiblings, F as selectRouteEntryEntryId, G as selectRouteEntryLanguage, m as selectMappedEntry, A as SET_ENTRY, B as SET_ANCESTORS, w as SET_SIBLINGS, R as REGISTER_USER, H as REGISTER_USER_SUCCESS, I as REGISTER_USER_FAILED, J as queryParams, K as selectCurrentSearch, L as setRoute, M as REQUEST_USER_PASSWORD_RESET, N as RESET_USER_PASSWORD, O as CHANGE_USER_PASSWORD, P as REQUEST_USER_PASSWORD_RESET_SENDING, Q as REQUEST_USER_PASSWORD_RESET_SUCCESS, T as REQUEST_USER_PASSWORD_RESET_ERROR, V as RESET_USER_PASSWORD_SENDING, W as RESET_USER_PASSWORD_SUCCESS, X as RESET_USER_PASSWORD_ERROR, Y as CHANGE_USER_PASSWORD_ERROR, Z as CHANGE_USER_PASSWORD_SENDING, _ as CHANGE_USER_PASSWORD_SUCCESS } from './selectors-DO2ocdOp.js';
8
- import { s as selectVersionStatus } from './version-wnf-TITV.js';
9
- import { h as handleRequiresLoginSaga, L as LoginHelper, i as findContentTypeMapping, j as getManagementApiClient, k as loginSagas } from './ChangePassword.container-BgzIy8dA.js';
8
+ import { eventChannel } from 'redux-saga';
9
+ import { Query, Op } from 'contensis-delivery-api';
10
+ import { a as actions } from './slice-C6JLQik8.js';
11
+ import { o as selectCurrentPath, G as setRoute, K as selectRouteEntryAvailableLanguages, M as selectRouteEntryID, N as selectStaticRoute, y as SET_NAVIGATION_PATH, x as SET_ROUTE, j as selectRouteEntry, O as selectCurrentNode, f as selectCurrentProject, z as UPDATE_LOADING_STATE, P as selectCurrentAncestors, Q as selectCurrentSiblings, T as selectRouteEntryEntryId, W as selectRouteEntryLanguage, n as selectMappedEntry, A as SET_ENTRY, B as SET_ANCESTORS, w as SET_SIBLINGS, R as REGISTER_USER, X as REGISTER_USER_SUCCESS, Y as REGISTER_USER_FAILED, E as queryParams, F as selectCurrentSearch, H as REQUEST_USER_PASSWORD_RESET, I as RESET_USER_PASSWORD, J as CHANGE_USER_PASSWORD, Z as REQUEST_USER_PASSWORD_RESET_SENDING, _ as REQUEST_USER_PASSWORD_RESET_SUCCESS, $ as REQUEST_USER_PASSWORD_RESET_ERROR, a0 as RESET_USER_PASSWORD_SENDING, a1 as RESET_USER_PASSWORD_SUCCESS, a2 as RESET_USER_PASSWORD_ERROR, a3 as CHANGE_USER_PASSWORD_ERROR, a4 as CHANGE_USER_PASSWORD_SENDING, a5 as CHANGE_USER_PASSWORD_SUCCESS } from './selectors-8ROQrTd7.js';
12
+ import { s as selectVersionStatus } from './version-BQAL8sQO.js';
13
+ import { c as cachedSearch } from './ContensisDeliveryApi-LWYXevZ1.js';
10
14
  import React from 'react';
11
15
  import 'react-cookie';
12
16
  import 'react-redux';
17
+ import './VersionInfo-By2ZCZOh.js';
18
+ import 'react-helmet-async';
13
19
  import 'jsonpath-mapper';
14
- import { Op, Query } from 'contensis-delivery-api';
15
- import { l as selectClientCredentials } from './ToJs-CNzfvyxJ.js';
16
- import 'query-string';
17
20
  import 'react-router-dom';
18
- import { a as RouteLoader } from './RouteLoader-xeQBXywk.js';
21
+ import { s as selectCurrentLanguage, a as selectDictionary, c as selectLocaleRoutes, b as selectLocales, f as selectDictionaryResolver, d as selectPrimaryLanguage } from './selectors-DcmvOeX2.js';
22
+ import { h as handleRequiresLoginSaga, L as LoginHelper, i as findContentTypeMapping, j as getSearchOptions, k as getManagementApiClient, m as loginSagas } from './ChangePassword.container-CUBtn82K.js';
23
+ import './sagas-Fr9yRduO.js';
24
+ import 'reselect';
25
+ import 'immer';
26
+ import 'deep-equal';
27
+ import 'deepmerge';
28
+ import { r as routeParams } from './util-Bl2u6LpY.js';
29
+ import 'contensis-core-api';
30
+ import { l as selectClientCredentials } from './matchGroups-_w8BwzCC.js';
31
+ import { a as RouteLoader } from './RouteLoader-CzrlySZf.js';
32
+ import 'query-string';
33
+
34
+ const isApiError = e => !!e && typeof e === 'object' && 'status' in e && 'statusText' in e;
35
+ const isPlainError = e => !!e && typeof e === 'object' && 'message' in e && typeof e.message === 'string';
36
+ const logError = (prefix, e) => {
37
+ var _e$data;
38
+ const message = isApiError(e) ? `${prefix} ${e.status} "${((_e$data = e.data) === null || _e$data === void 0 ? void 0 : _e$data.message) || ''}" url: ${e.url || ''}` : isPlainError(e) ? `${prefix} "${(e === null || e === void 0 ? void 0 : e.message) || e}"${e !== null && e !== void 0 && e.stack ? `\n${e.stack}` : ''}` : `${prefix} "${e}"`;
39
+ error$1(message);
40
+ };
41
+ const shorten = (str, maxLength = 120, endWeight = 0.6) => {
42
+ if (!str || str.length <= maxLength) return str;
43
+ const charsToShow = maxLength - 3;
44
+ const back = Math.floor(charsToShow * endWeight);
45
+ const front = charsToShow - back;
46
+ return `${str.slice(0, front)}...${str.slice(str.length - back)}`;
47
+ };
48
+
49
+ const deparameterise = path => {
50
+ return path.replace(/\/:\w+\??/g, '');
51
+ };
52
+
53
+ /** Create static routes for routes with specified locales */
54
+ const createLocaleRoutes = routes => {
55
+ const localeRoutes = {};
56
+ for (const route of routes.StaticRoutes) {
57
+ // If the route has defined locales, create entries for each locale
58
+ if (route.i18n && route.path) {
59
+ for (const [language, path] of Object.entries(route.i18n)) {
60
+ // We already have a locale route, so just append the language and path
61
+ const deparameterisedPath = deparameterise(route.path);
62
+ const deparameterisedLocalePath = deparameterise(path);
63
+ if (localeRoutes[deparameterisedPath]) localeRoutes[deparameterisedPath][language] = deparameterisedLocalePath;
64
+ // Otherwise, create a new entry for this route path
65
+ else localeRoutes[deparameterisedPath] = {
66
+ [language]: deparameterisedLocalePath
67
+ };
68
+ if (deparameterise(route.path) !== deparameterisedLocalePath) {
69
+ // I think we are OK to mutate here as this is only run once on app init
70
+ // we can change this if needed later
71
+ routes.StaticRoutes.push({
72
+ ...route,
73
+ path,
74
+ // Add the path with any parameters included
75
+ language,
76
+ i18n: undefined
77
+ });
78
+ } else {
79
+ // Just set the language on the existing route instead of creating a duplicate
80
+ route.language = language;
81
+ }
82
+ }
83
+ }
84
+ }
85
+ return localeRoutes;
86
+ };
19
87
 
20
88
  // Create a history depending on the environment
21
89
  const selectedHistory = typeof window !== 'undefined' ? createBrowserHistory : createMemoryHistory;
@@ -29,12 +97,17 @@ function* ensureNodeTreeSaga(action) {
29
97
  language,
30
98
  project,
31
99
  versionStatus,
100
+ subsitePath,
32
101
  treeDepth
33
102
  } = action;
34
103
  const state = yield select();
35
104
  try {
36
105
  if (!hasNavigationTree(state)) {
37
- const nodes = yield api.getRootNode({
106
+ const nodes = subsitePath ? yield api.getNode({
107
+ path: subsitePath,
108
+ depth: treeDepth || 0,
109
+ language
110
+ }, project) : yield api.getRootNode({
38
111
  depth: treeDepth || 0,
39
112
  language
40
113
  }, versionStatus, project);
@@ -58,6 +131,238 @@ function* ensureNodeTreeSaga(action) {
58
131
  }
59
132
  }
60
133
 
134
+ const i18nSagas = [takeEvery(actions.INIT_LOCALES.type, getProjectLanguages), takeEvery(actions.UPDATE_LANGUAGE.type, updateLanguage), takeEvery(actions.SET_LANGUAGE.type, setLanguageRoute)];
135
+
136
+ /**
137
+ * Resolve the current route language based on the entry, node, static route or path
138
+ * Is called directly from the routing saga as soon as an entry or node has been fetched
139
+ */
140
+ function* resolveCurrentRouteLanguage({
141
+ entry,
142
+ node
143
+ }) {
144
+ var _entry$sys, _staticRoute$route;
145
+ const currentLanguage = yield select(selectCurrentLanguage);
146
+ const staticRoute = yield select(selectStaticRoute);
147
+ let nextLanguage = currentLanguage;
148
+ if (entry !== null && entry !== void 0 && (_entry$sys = entry.sys) !== null && _entry$sys !== void 0 && _entry$sys.language) nextLanguage = entry.sys.language;else if (node !== null && node !== void 0 && node.language) nextLanguage = node.language;else if (staticRoute !== null && staticRoute !== void 0 && (_staticRoute$route = staticRoute.route) !== null && _staticRoute$route !== void 0 && _staticRoute$route.language) nextLanguage = staticRoute.route.language;else {
149
+ var _currentPath$split$fi;
150
+ // attempt to infer language from the path
151
+ const currentPath = yield select(selectCurrentPath);
152
+
153
+ // path is normally lowercase
154
+ const firstPathSegment = (_currentPath$split$fi = currentPath.split('/').find(segment => segment.length)) === null || _currentPath$split$fi === void 0 ? void 0 : _currentPath$split$fi.toLowerCase();
155
+ const locales = yield select(selectLocales);
156
+ const matchedLanguage = Object.keys(locales).find(lang => lang.toLowerCase() === firstPathSegment);
157
+ // matched a supported language in the path
158
+ if (matchedLanguage) nextLanguage = matchedLanguage;else
159
+ // falling back to primary language
160
+ nextLanguage = yield select(selectPrimaryLanguage);
161
+ }
162
+ if (nextLanguage && nextLanguage !== currentLanguage) {
163
+ const dictionary = yield call(resolveDictionaryForLanguage, nextLanguage);
164
+ yield put(actions.SET_LANGUAGE({
165
+ language: nextLanguage,
166
+ dictionary
167
+ }));
168
+ }
169
+ }
170
+
171
+ /**
172
+ * Resolve the current dictionary for route language either using a supplied resolver
173
+ * function or directly derive from the locales stored in state
174
+ * Is called directly any time the language is changed
175
+ */
176
+ function* resolveDictionaryForLanguage(language) {
177
+ let dictionary = yield select(selectDictionary);
178
+ // try and resolve a dictionary for this language
179
+ const resolver = yield select(selectDictionaryResolver);
180
+ if (typeof resolver === 'function') {
181
+ try {
182
+ // dynamic import of dictionary file
183
+ const loadedDictionary = yield call(resolver, language);
184
+ dictionary = loadedDictionary;
185
+ } catch (error) {
186
+ console.error(`No dictionary resolved for language ${language}`, error);
187
+ }
188
+ } else {
189
+ // Load dictionary from locales in state
190
+ const locales = yield select(selectLocales);
191
+ if (locales && locales[language]) {
192
+ dictionary = locales[language];
193
+ }
194
+ }
195
+ return dictionary;
196
+ }
197
+
198
+ /**
199
+ * Side effects triggered from updating the language via dispatched action
200
+ * in language switching components, including resolving the next route,
201
+ * update the dictionary and subsequently redirect if needed
202
+ */
203
+ function* updateLanguage({
204
+ payload: {
205
+ language,
206
+ redirect,
207
+ fallbackPath
208
+ }
209
+ }) {
210
+ const currentLanguage = yield select(selectCurrentLanguage);
211
+ if (language === currentLanguage) {
212
+ // no change needed
213
+ return;
214
+ } else {
215
+ const dictionary = language !== currentLanguage ? yield call(resolveDictionaryForLanguage, language) : yield select(selectDictionary);
216
+ const uri = yield call(resolveNextLanguageRoute, {
217
+ language,
218
+ redirect,
219
+ fallbackPath
220
+ });
221
+ yield put(actions.SET_LANGUAGE({
222
+ language,
223
+ dictionary: dictionary != null ? dictionary : undefined,
224
+ redirect: redirect !== false ? uri : undefined
225
+ }));
226
+ }
227
+ }
228
+
229
+ /** Handle any route redirection after we have set the language */
230
+ function* setLanguageRoute({
231
+ payload
232
+ }) {
233
+ if (payload !== null && payload !== void 0 && payload.redirect) {
234
+ const currentPath = yield select(selectCurrentPath);
235
+ if (payload.redirect === currentPath) {
236
+ // already on the correct path, no need to redirect
237
+ return;
238
+ }
239
+ yield put(setRoute(payload.redirect));
240
+ }
241
+ }
242
+
243
+ /** Determine the correct route uri when the language changes */
244
+ function* resolveNextLanguageRoute({
245
+ language,
246
+ redirect,
247
+ fallbackPath
248
+ }) {
249
+ // have they supplied the route to go to?
250
+ if (typeof redirect === 'string') {
251
+ return redirect;
252
+ }
253
+
254
+ // is this an entry or a static route?
255
+ const availableLanguages = yield select(selectRouteEntryAvailableLanguages);
256
+ if (availableLanguages.find(l => l.toLowerCase() === language.toLowerCase())) {
257
+ // if entry, get the uri for this language variation from the api
258
+ const entryUri = yield call(getEntryUriForLanguage, {
259
+ entryId: yield select(selectRouteEntryID),
260
+ language
261
+ });
262
+ if (entryUri) {
263
+ return entryUri;
264
+ }
265
+ }
266
+
267
+ // if static route, get the uri from the routes config
268
+ const staticRouteUri = yield call(getStaticRouteUri, {
269
+ language
270
+ });
271
+ if (staticRouteUri) {
272
+ return staticRouteUri;
273
+ }
274
+
275
+ // if all else fails, fallback to the supplied fallback path or homepage
276
+ return fallbackPath || `/${language.toLowerCase()}`;
277
+ }
278
+
279
+ /** Check any current static route for a language variation we have stored in i18n.routes */
280
+ function* getStaticRouteUri({
281
+ language
282
+ }) {
283
+ const staticRoute = yield select(selectStaticRoute);
284
+ if (staticRoute !== null && staticRoute !== void 0 && staticRoute.route.path) {
285
+ var _Object$entries$find;
286
+ // Routes can have parameters such as `/:facet?` we need to deparameterise
287
+ // so we can check against our stored locale routes
288
+ const deparameterisedPath = deparameterise(staticRoute.route.path);
289
+ const localeRoutes = yield select(selectLocaleRoutes);
290
+ const originalPath = (_Object$entries$find = Object.entries(localeRoutes || {}).find(([, locales]) => Object.values(locales).includes(deparameterisedPath))) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0];
291
+ const routeLocales = localeRoutes[deparameterisedPath] || localeRoutes[originalPath || ''];
292
+ const routeUri = routeLocales === null || routeLocales === void 0 ? void 0 : routeLocales[language];
293
+ return routeUri;
294
+ }
295
+ }
296
+
297
+ /**
298
+ * Run when the app initiates locales, populating supported languages from the config
299
+ * or fetching from the project if not provided
300
+ */
301
+ function* getProjectLanguages({
302
+ payload
303
+ }) {
304
+ const stateLocales = yield select(selectLocales);
305
+ if (stateLocales && Object.keys(stateLocales).length > 0)
306
+ // Locales already set in state, no need to fetch again
307
+ return;
308
+ const locales = {};
309
+ let primaryLanguage = payload.primaryLanguage;
310
+ const supportedLanguages = [...(payload.supportedLanguages || [])];
311
+ if (supportedLanguages !== null && supportedLanguages !== void 0 && supportedLanguages.length) {
312
+ // If supported languages are provided in config, use these
313
+ for (const supportedLanguage of supportedLanguages) {
314
+ locales[supportedLanguage] = {};
315
+ }
316
+ } else {
317
+ // Fallback to getting languages from the project
318
+ const [error, project] = yield to(cachedSearch.getClient().project.get());
319
+ if (error) {
320
+ console.error('Problem fetching project languages:', error);
321
+ } else if (project) {
322
+ var _project$primaryLangu;
323
+ for (const supportedLanguage of project.supportedLanguages || []) {
324
+ locales[supportedLanguage] = {};
325
+ supportedLanguages.push(supportedLanguage);
326
+ }
327
+ // Set primary language from project if we have it
328
+ primaryLanguage = (_project$primaryLangu = project.primaryLanguage) != null ? _project$primaryLangu : primaryLanguage;
329
+ }
330
+ }
331
+ if (Object.keys(locales).length === 0) {
332
+ // Ensure at least the primary language is included
333
+ locales[payload.primaryLanguage] = {};
334
+ supportedLanguages.push(payload.primaryLanguage);
335
+ }
336
+
337
+ // Only commit if we have locales to set or we will end up in an infinite loop
338
+ if (Object.keys(locales).length) yield put(actions.SET_LOCALES({
339
+ ...payload,
340
+ primaryLanguage,
341
+ supportedLanguages,
342
+ locales
343
+ }));
344
+ }
345
+
346
+ /**
347
+ * Run a Delivery API query to get the uri for the chosen language variation of this entryId
348
+ * */
349
+ function* getEntryUriForLanguage({
350
+ entryId,
351
+ language
352
+ }) {
353
+ try {
354
+ const versionStatus = yield select(selectVersionStatus);
355
+ const query = new Query(Op.equalTo('sys.id', entryId), Op.equalTo('sys.language', language), Op.equalTo('sys.versionStatus', versionStatus));
356
+ query.fields = ['sys.uri'];
357
+ query.pageSize = 1;
358
+ const result = yield cachedSearch.search(query);
359
+ return result.items.length ? result.items[0].sys.uri : null;
360
+ } catch (error) {
361
+ console.error('Error fetching language variations:', error);
362
+ yield put(actions.GET_ENTRY_URI_ERROR(error));
363
+ }
364
+ }
365
+
61
366
  const sys = {
62
367
  versionStatus: 'sys.versionStatus'
63
368
  };
@@ -80,6 +385,88 @@ const routeEntryByFieldsQuery = (id, language = 'en-GB', contentTypeId = '', fie
80
385
  return query;
81
386
  };
82
387
 
388
+ function* reduxInjectorSaga(injectorFn) {
389
+ if (typeof injectorFn === 'function') {
390
+ const {
391
+ key,
392
+ reducer,
393
+ saga
394
+ } = yield injectorFn();
395
+ injectRedux({
396
+ key,
397
+ reducer,
398
+ saga
399
+ });
400
+ }
401
+ }
402
+
403
+ /**
404
+ * @description Asynchronously load and inject assets related to Search
405
+ */
406
+ const importSearchAssets = () => import('./search.js');
407
+
408
+ /**
409
+ * Invokes the Search saga if:
410
+ * - `searchOptions` is present on `staticRoute` or `contentTypeRoute`
411
+ * - `searchOptions` is provided by the consumer app
412
+ * - and path starts with one of `onPaths: ['/search']`
413
+ * - or a `facet` or `listingType` is present in provided `searchOptions`
414
+ *
415
+ * A `config` is required if we want to inject the redux reducer here, sagas are injected automatically
416
+ */
417
+ function* handleSearchSaga({
418
+ location,
419
+ params,
420
+ routeSearchOptions,
421
+ searchOptions,
422
+ ssr
423
+ }) {
424
+ // Merge supplied mappers with route-supplied mappers taking precedence
425
+ const mappers = {
426
+ results: e => e,
427
+ ...((searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.mappers) || {}),
428
+ ...((routeSearchOptions === null || routeSearchOptions === void 0 ? void 0 : routeSearchOptions.mappers) || {})
429
+ };
430
+
431
+ // Merge all other search options with route-supplied options taking precedence
432
+ const {
433
+ onPaths = ['/search'],
434
+ ...searchOpts
435
+ } = {
436
+ ...(routeSearchOptions || {}),
437
+ ...(searchOptions || {})
438
+ };
439
+
440
+ // Check do we meet conditions to run the search saga
441
+ const invokeSearch = onPaths.find(p => location.pathname.startsWith(p)) || searchOpts.composition || searchOpts.facet || searchOpts.listingType;
442
+
443
+ // An empty routeSearchOptions object can be used to import assets and load config for a minilist
444
+ const importAssets = routeSearchOptions;
445
+ if (importAssets || invokeSearch) {
446
+ // Async load search assets
447
+ const {
448
+ reducer,
449
+ sagas,
450
+ setRouteFilters
451
+ } = yield importSearchAssets();
452
+
453
+ // Inject search reducer and sagas
454
+ yield call(reduxInjectorSaga, async () => ({
455
+ key: 'search',
456
+ reducer: searchOpts.config && reducer(searchOpts.config),
457
+ saga: sagas
458
+ }));
459
+ if (invokeSearch) yield call(setRouteFilters, {
460
+ params,
461
+ ssr,
462
+ ...searchOpts,
463
+ mappers
464
+ });
465
+ }
466
+ }
467
+
468
+ const error = (e, message) => logError(`[routeSaga]${message ? ` ${message}` : ''}`, e);
469
+ let livePreviewTask = null;
83
470
  const routingSagas = [takeEvery(SET_NAVIGATION_PATH, getRouteSaga), takeEvery(SET_ROUTE, setRouteSaga)];
84
471
 
85
472
  /**
@@ -98,7 +485,7 @@ function* setRouteSaga(action) {
98
485
  function* getRouteSaga(action) {
99
486
  let entry = null;
100
487
  try {
101
- var _staticRoute$route, _staticRoute$route2, _staticRoute$route3, _staticRoute$route4, _appsays, _appsays2, _appsays3, _pathNode3, _pathNode4;
488
+ var _staticRoute$route, _staticRoute$route2, _staticRoute$route3, _staticRoute$route4, _appsays, _appsays2, _appsays3, _pathNode3, _pathNode4, _pathNode5;
102
489
  const {
103
490
  withEvents,
104
491
  routes: {
@@ -107,7 +494,8 @@ function* getRouteSaga(action) {
107
494
  staticRoute,
108
495
  // get api instance from ssr context that is connected to the specific request in ssr
109
496
  ssr: {
110
- api
497
+ api,
498
+ subsitePath
111
499
  }
112
500
  } = action;
113
501
 
@@ -124,7 +512,8 @@ function* getRouteSaga(action) {
124
512
  // These variables are the return values from
125
513
  // calls to withEvents.onRouteLoad and onRouteLoaded
126
514
  let appsays,
127
- requireLogin = false;
515
+ requireLogin = false,
516
+ searchOptions = false;
128
517
  if (withEvents && withEvents.onRouteLoad) {
129
518
  appsays = yield withEvents.onRouteLoad(action);
130
519
  }
@@ -145,11 +534,13 @@ function* getRouteSaga(action) {
145
534
  const routeEntry = selectRouteEntry(state, 'js');
146
535
  const routeNode = selectCurrentNode(state, 'js');
147
536
  const currentPath = action.path; //selectCurrentPath(state);
537
+ const contentPath = action.contentPath;
148
538
  const deliveryApiStatus = selectVersionStatus(state);
149
539
  const project = selectCurrentProject(state);
150
540
  // const isHome = currentPath === '/';
151
541
  const isPreview = currentPath && currentPath.startsWith('/preview/');
152
- const defaultLang = appsays && appsays.defaultLang || 'en-GB';
542
+ const currentLanguage = selectCurrentLanguage(state);
543
+ const defaultLang = appsays && appsays.defaultLang || currentLanguage || 'en-GB';
153
544
  if (!isPreview && ((_appsays2 = appsays) !== null && _appsays2 !== void 0 && _appsays2.customRouting || staticRoute && !staticRoute.route.fetchNode || routeEntry && action.statePath === action.path && ((_appsays3 = appsays) === null || _appsays3 === void 0 ? void 0 : _appsays3.refetchNode) !== true)) {
154
545
  var _staticRoute$route5;
155
546
  // To prevent erroneous 404s and wasted network calls, this covers
@@ -162,13 +553,6 @@ function* getRouteSaga(action) {
162
553
  entry: null
163
554
  };
164
555
  pathNode.entry = entry = routeEntry;
165
- //Do nothing, the entry is allready the right one.
166
- // yield put({
167
- // type: SET_ENTRY,
168
- // entry,
169
- // node: routeNode,
170
- // isLoading: false,
171
- // });
172
556
  yield put({
173
557
  type: UPDATE_LOADING_STATE,
174
558
  isLoading: false
@@ -189,7 +573,6 @@ function* getRouteSaga(action) {
189
573
  // for previewing entries as it gives a response of []
190
574
  // -- apparently it is not correct to request latest content
191
575
  // with Node API
192
-
193
576
  let previewEntry = yield api.getClient(deliveryApiStatus, project).entries.get({
194
577
  id: entryGuid,
195
578
  language,
@@ -212,11 +595,13 @@ function* getRouteSaga(action) {
212
595
  // Resolve the complete entry with the node if we are setting limits in a static route
213
596
  [nodeError, pathNode] = yield to(api.getNode({
214
597
  depth: 0,
215
- path: currentPath,
598
+ path: contentPath,
216
599
  entryFields: setStaticRouteLimits ? fields || '*' : setContentTypeLimits ? ['sys.contentTypeId', 'sys.id'] : '*',
217
600
  entryLinkDepth: setStaticRouteLimits && typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0,
218
601
  entryFieldLinkDepths: setStaticRouteLimits ? fieldLinkDepths : setContentTypeLimits ? undefined : entryFieldLinkDepths,
219
- language: defaultLang,
602
+ // language parameter is not used when resolving a node by path
603
+ // https://www.contensis.com/help-and-docs/apis/delivery-http/navigation/nodes/get-a-node-by-path
604
+ // language: defaultLang,
220
605
  versionStatus: deliveryApiStatus
221
606
  }, project));
222
607
  if (nodeError) {
@@ -283,25 +668,43 @@ function* getRouteSaga(action) {
283
668
  appsays,
284
669
  contentTypeMapping: contentTypeMapping || (staticRoute === null || staticRoute === void 0 || (_staticRoute$route6 = staticRoute.route) === null || _staticRoute$route6 === void 0 ? void 0 : _staticRoute$route6.fetchNode) || {},
285
670
  language: defaultLang,
286
- path: currentPath,
671
+ path: contentPath,
287
672
  pathNode,
288
673
  project,
674
+ subsitePath,
289
675
  versionStatus: deliveryApiStatus
290
676
  });
291
677
  if (children) pathNode.children = children;
292
678
  }
293
- const resolvedContentTypeMapping = findContentTypeMapping(ContentTypeMappings, (_pathNode3 = pathNode) === null || _pathNode3 === void 0 || (_pathNode3 = _pathNode3.entry) === null || _pathNode3 === void 0 || (_pathNode3 = _pathNode3.sys) === null || _pathNode3 === void 0 ? void 0 : _pathNode3.contentTypeId) || {};
679
+
680
+ // We initially listened for SET_ENTRY to complete before
681
+ // resolving the current route language, but this meant
682
+ // that the language change was not captured in time for the SSR response
683
+ yield call(resolveCurrentRouteLanguage, {
684
+ entry: (_pathNode3 = pathNode) === null || _pathNode3 === void 0 ? void 0 : _pathNode3.entry,
685
+ node: pathNode
686
+ });
687
+ const contentTypeRoute = findContentTypeMapping(ContentTypeMappings, (_pathNode4 = pathNode) === null || _pathNode4 === void 0 || (_pathNode4 = _pathNode4.entry) === null || _pathNode4 === void 0 || (_pathNode4 = _pathNode4.sys) === null || _pathNode4 === void 0 ? void 0 : _pathNode4.contentTypeId);
294
688
 
295
689
  // Inject redux { key, reducer, saga } provided by ContentTypeMapping
296
- if (resolvedContentTypeMapping.injectRedux) yield call(reduxInjectorSaga, resolvedContentTypeMapping.injectRedux);
690
+ if (contentTypeRoute !== null && contentTypeRoute !== void 0 && contentTypeRoute.injectRedux) yield call(reduxInjectorSaga, contentTypeRoute.injectRedux);
691
+
692
+ // Have we defined search options in the route configuration (for triggering search)
693
+ const routeSearchOptions = getSearchOptions(staticRoute, contentTypeRoute);
694
+ const params = routeParams(staticRoute, action.location);
297
695
  if (withEvents && withEvents.onRouteLoaded) {
298
696
  // Check if the app has provided a requireLogin boolean flag or groups array
299
697
  // in addition to checking if requireLogin is set in the route definition
698
+ // The app can provide an object to invoke the search saga
300
699
  ({
301
- requireLogin
700
+ requireLogin,
701
+ searchOptions
302
702
  } = (yield withEvents.onRouteLoaded({
303
703
  ...action,
304
- entry
704
+ contentTypeRoute,
705
+ entry,
706
+ params,
707
+ searchOptions: routeSearchOptions
305
708
  })) || {});
306
709
  }
307
710
  if (requireLogin !== false) {
@@ -312,22 +715,74 @@ function* getRouteSaga(action) {
312
715
  requireLogin
313
716
  });
314
717
  }
718
+ if (searchOptions || routeSearchOptions) yield call(handleSearchSaga, {
719
+ ...action,
720
+ params,
721
+ routeSearchOptions,
722
+ searchOptions
723
+ });
315
724
  if (!appsays || !appsays.preventScrollTop) {
316
725
  // Scroll into View
317
726
  if (typeof window !== 'undefined') window.scrollTo(0, 0);
318
727
  }
319
- if ((_pathNode4 = pathNode) !== null && _pathNode4 !== void 0 && (_pathNode4 = _pathNode4.entry) !== null && _pathNode4 !== void 0 && (_pathNode4 = _pathNode4.sys) !== null && _pathNode4 !== void 0 && _pathNode4.id) {
728
+ if ((_pathNode5 = pathNode) !== null && _pathNode5 !== void 0 && (_pathNode5 = _pathNode5.entry) !== null && _pathNode5 !== void 0 && (_pathNode5 = _pathNode5.sys) !== null && _pathNode5 !== void 0 && _pathNode5.id) {
320
729
  var _appsays4;
730
+ if (params.livePreview && typeof window !== 'undefined') {
731
+ if (livePreviewTask) yield cancel(livePreviewTask);
732
+ livePreviewTask = yield fork(watchLivePreviewSaga, {
733
+ ancestors,
734
+ appsays,
735
+ contentTypeRoute,
736
+ currentPath,
737
+ entry,
738
+ entryMapper,
739
+ pathNode,
740
+ siblings
741
+ });
742
+ }
321
743
  entry = pathNode.entry;
322
- yield call(setRouteEntry, currentPath, entry, pathNode, ancestors, siblings, entryMapper || resolvedContentTypeMapping.entryMapper, false, (_appsays4 = appsays) === null || _appsays4 === void 0 ? void 0 : _appsays4.refetchNode);
744
+ yield call(setRouteEntry, currentPath, entry, pathNode, ancestors, siblings, entryMapper || (contentTypeRoute === null || contentTypeRoute === void 0 ? void 0 : contentTypeRoute.entryMapper), false, (_appsays4 = appsays) === null || _appsays4 === void 0 ? void 0 : _appsays4.refetchNode);
323
745
  } else {
324
746
  if (staticRoute) yield call(setRouteEntry, currentPath, null, pathNode, ancestors, siblings);else yield call(do404);
325
747
  }
326
748
  } catch (e) {
327
- log.error(...['Error running route saga:', e, e.stack]);
749
+ error(e);
328
750
  yield call(do500, e);
329
751
  }
330
752
  }
753
+ function createLivePreviewChannel() {
754
+ return eventChannel(emit => {
755
+ const handler = e => {
756
+ var _e$data;
757
+ // console.log('Received message in live preview channel', e.data);
758
+ if (((_e$data = e.data) === null || _e$data === void 0 ? void 0 : _e$data.type) === 'LIVE_ENTRY_UPDATE') emit(e.data);
759
+ };
760
+ window.addEventListener('message', handler);
761
+ return () => window.removeEventListener('message', handler);
762
+ });
763
+ }
764
+ function* watchLivePreviewSaga(context) {
765
+ const channel = createLivePreviewChannel();
766
+ try {
767
+ while (true) {
768
+ var _context$contentTypeR;
769
+ const data = yield take(channel);
770
+ console.log('Handling live preview update', data);
771
+ const entry = yield select(selectRouteEntry);
772
+ yield call(setRouteEntry, context.currentPath, {
773
+ ...entry,
774
+ ...data.payload
775
+ }, context.pathNode, null,
776
+ // ancestors unchanged
777
+ null,
778
+ // siblings unchanged
779
+ context.entryMapper || ((_context$contentTypeR = context.contentTypeRoute) === null || _context$contentTypeR === void 0 ? void 0 : _context$contentTypeR.entryMapper), false, true // we need to remap the entry here
780
+ );
781
+ }
782
+ } finally {
783
+ if (yield cancelled()) channel.close();
784
+ }
785
+ }
331
786
  function* resolveCurrentNodeOrdinates(action) {
332
787
  const {
333
788
  api,
@@ -337,6 +792,7 @@ function* resolveCurrentNodeOrdinates(action) {
337
792
  path,
338
793
  pathNode,
339
794
  project,
795
+ subsitePath,
340
796
  versionStatus
341
797
  } = action;
342
798
  const apiCall = [() => null, () => null, () => null, () => null];
@@ -359,10 +815,11 @@ function* resolveCurrentNodeOrdinates(action) {
359
815
  return yield api.getAncestors({
360
816
  id: pathNode.id,
361
817
  language,
362
- versionStatus
818
+ versionStatus,
819
+ startLevel: (subsitePath || '').split('/').length
363
820
  }, project);
364
821
  } catch (ex) {
365
- log.info('Problem fetching ancestors', ex);
822
+ error(ex, 'Problem fetching ancestors');
366
823
  return [];
367
824
  }
368
825
  };
@@ -382,7 +839,7 @@ function* resolveCurrentNodeOrdinates(action) {
382
839
  versionStatus
383
840
  }, project);
384
841
  } catch (ex) {
385
- log.info('Problem fetching children', ex);
842
+ error(ex, 'Problem fetching children');
386
843
  return [];
387
844
  }
388
845
  };
@@ -401,7 +858,7 @@ function* resolveCurrentNodeOrdinates(action) {
401
858
  versionStatus
402
859
  }, project);
403
860
  } catch (ex) {
404
- log.info('Problem fetching siblings', ex);
861
+ error(ex, 'Problem fetching siblings');
405
862
  return [];
406
863
  }
407
864
  };
@@ -465,7 +922,7 @@ function* mapRouteEntry(entryMapper, node) {
465
922
  return mappedEntry;
466
923
  }
467
924
  } catch (e) {
468
- log.error(...['Error running entryMapper:', e, e.stack]);
925
+ error(e, 'Error in entryMapper:');
469
926
  throw e;
470
927
  }
471
928
  return;
@@ -500,20 +957,6 @@ function* do500(error) {
500
957
  statusCode: error && error.status ? error.status : 500
501
958
  });
502
959
  }
503
- function* reduxInjectorSaga(injectorFn) {
504
- if (typeof injectorFn === 'function') {
505
- const {
506
- key,
507
- reducer,
508
- saga
509
- } = yield injectorFn();
510
- injectRedux({
511
- key,
512
- reducer,
513
- saga
514
- });
515
- }
516
- }
517
960
 
518
961
  const registerSagas = [takeEvery(REGISTER_USER, registerSaga), takeEvery(REGISTER_USER_SUCCESS, redirectSaga)];
519
962
  function* registerSaga({
@@ -763,11 +1206,6 @@ function* changePasswordSaga(action) {
763
1206
  });
764
1207
  return;
765
1208
  }
766
-
767
- // // eslint-disable-next-line no-console
768
- // console.log(changePasswordObject);
769
- // // eslint-disable-next-line no-console
770
- // console.log(userCredentialsObject);
771
1209
  yield put({
772
1210
  type: CHANGE_USER_PASSWORD_SUCCESS
773
1211
  });
@@ -781,13 +1219,16 @@ function* changePasswordSaga(action) {
781
1219
 
782
1220
  const userSagas = [...loginSagas, ...registerSagas, ...resetPasswordSagas];
783
1221
 
784
- // index.js
785
- function rootSaga (featureSagas = []) {
786
- return function* rootSaga() {
787
- const subSagas = [...routingSagas, ...navigationSagas, ...userSagas];
788
- yield all([...subSagas, ...featureSagas]);
789
- };
790
- }
1222
+ var rootSaga = (featureSagas = []) => {
1223
+ return [...i18nSagas, ...routingSagas, ...navigationSagas, ...userSagas, ...featureSagas];
1224
+ };
1225
+
1226
+ // export default function (featureSagas: Effect[] = []) {
1227
+ // return function* rootSaga() {
1228
+ // const subSagas = [...routingSagas, ...navigationSagas, ...userSagas];
1229
+ // yield all([...subSagas, ...featureSagas]);
1230
+ // };
1231
+ // }
791
1232
 
792
1233
  const servers = SERVERS; /* global SERVERS */
793
1234
  const alias = servers.alias.toLowerCase();
@@ -832,5 +1273,5 @@ const AppRoot = props => {
832
1273
  return /*#__PURE__*/React.createElement(RouteLoader, props);
833
1274
  };
834
1275
 
835
- export { AppRoot as A, browserHistory as b, history as h, pickProject as p, rootSaga as r };
836
- //# sourceMappingURL=App-DLZweVSp.js.map
1276
+ export { AppRoot as A, browserHistory as b, createLocaleRoutes as c, history as h, pickProject as p, rootSaga as r, shorten as s };
1277
+ //# sourceMappingURL=App-Bvs7Km54.js.map