@zengenti/contensis-react-base 4.0.0-beta.2 → 4.0.0-beta.20

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 (244) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +24 -478
  3. package/cjs/{App-b56aca04.js → App-C_1U2j24.js} +218 -236
  4. package/cjs/App-C_1U2j24.js.map +1 -0
  5. package/cjs/{ChangePassword.container-ae35785e.js → ChangePassword.container-H4i1yRi6.js} +240 -315
  6. package/cjs/ChangePassword.container-H4i1yRi6.js.map +1 -0
  7. package/cjs/{ContensisDeliveryApi-4fcf049d.js → ContensisDeliveryApi-lcZ45Kxx.js} +125 -118
  8. package/cjs/ContensisDeliveryApi-lcZ45Kxx.js.map +1 -0
  9. package/cjs/{CookieConstants-000427db.js → CookieConstants-DfPiWCRZ.js} +3 -1
  10. package/cjs/CookieConstants-DfPiWCRZ.js.map +1 -0
  11. package/cjs/CookieHelper.class-Det3qfdU.js +462 -0
  12. package/cjs/CookieHelper.class-Det3qfdU.js.map +1 -0
  13. package/cjs/{RouteLoader-c06dccd5.js → RouteLoader-CAkG-Y5y.js} +62 -74
  14. package/cjs/RouteLoader-CAkG-Y5y.js.map +1 -0
  15. package/cjs/SSRContext-ciyKagks.js +71 -0
  16. package/cjs/SSRContext-ciyKagks.js.map +1 -0
  17. package/cjs/ToJs-BsWqWjdm.js +23 -0
  18. package/cjs/ToJs-BsWqWjdm.js.map +1 -0
  19. package/cjs/VersionInfo-D0mF1vkY.js +204 -0
  20. package/cjs/VersionInfo-D0mF1vkY.js.map +1 -0
  21. package/cjs/{_commonjsHelpers-b3309d7b.js → _commonjsHelpers-BJu3ubxk.js} +1 -1
  22. package/cjs/_commonjsHelpers-BJu3ubxk.js.map +1 -0
  23. package/cjs/client.js +47 -71
  24. package/cjs/client.js.map +1 -1
  25. package/cjs/contensis-react-base.js +645 -3303
  26. package/cjs/contensis-react-base.js.map +1 -1
  27. package/cjs/{fromJSLeaveImmer-e74c673c.js → fromJSLeaveImmer-Blvlk4t2.js} +3 -7
  28. package/{esm/fromJSLeaveImmer-0114ffcf.js.map → cjs/fromJSLeaveImmer-Blvlk4t2.js.map} +1 -1
  29. package/cjs/{ToJs-a8d8f3f0.js → matchGroups-CNt2aNoC.js} +22 -96
  30. package/cjs/matchGroups-CNt2aNoC.js.map +1 -0
  31. package/cjs/redux.js +20 -20
  32. package/cjs/redux.js.map +1 -1
  33. package/cjs/routing.js +19 -7
  34. package/cjs/routing.js.map +1 -1
  35. package/cjs/sagas-CMBI1syl.js +5835 -0
  36. package/cjs/sagas-CMBI1syl.js.map +1 -0
  37. package/cjs/search.js +119 -321
  38. package/cjs/search.js.map +1 -1
  39. package/cjs/selectors-Bp_TrwG5.js +468 -0
  40. package/cjs/selectors-Bp_TrwG5.js.map +1 -0
  41. package/cjs/{version-34d91f68.js → store-CO5xslDu.js} +44 -114
  42. package/cjs/store-CO5xslDu.js.map +1 -0
  43. package/cjs/user.js +28 -33
  44. package/cjs/user.js.map +1 -1
  45. package/cjs/util-CTvFvplw.js +148 -0
  46. package/cjs/util-CTvFvplw.js.map +1 -0
  47. package/cjs/util.js +87 -215
  48. package/cjs/util.js.map +1 -1
  49. package/cjs/version-BolvQdgT.js +20 -0
  50. package/cjs/version-BolvQdgT.js.map +1 -0
  51. package/cjs/{version-a410c88e.js → version-DabwEeLw.js} +19 -22
  52. package/{esm/version-9f29becb.js.map → cjs/version-DabwEeLw.js.map} +1 -1
  53. package/esm/{App-83107d7e.js → App-DdEKwCTJ.js} +178 -196
  54. package/esm/App-DdEKwCTJ.js.map +1 -0
  55. package/esm/{ChangePassword.container-76fd5e9b.js → ChangePassword.container-BzycNMRX.js} +193 -250
  56. package/esm/ChangePassword.container-BzycNMRX.js.map +1 -0
  57. package/esm/{ContensisDeliveryApi-fe57a037.js → ContensisDeliveryApi-BgfEEyIk.js} +124 -119
  58. package/esm/ContensisDeliveryApi-BgfEEyIk.js.map +1 -0
  59. package/esm/{CookieConstants-3d3b6531.js → CookieConstants-DEmbwzYr.js} +3 -2
  60. package/esm/CookieConstants-DEmbwzYr.js.map +1 -0
  61. package/esm/CookieHelper.class-C6rTRl_1.js +459 -0
  62. package/esm/CookieHelper.class-C6rTRl_1.js.map +1 -0
  63. package/esm/{RouteLoader-29fd689a.js → RouteLoader-Bk6e6UV-.js} +46 -58
  64. package/esm/RouteLoader-Bk6e6UV-.js.map +1 -0
  65. package/esm/SSRContext-CXRqYy6B.js +63 -0
  66. package/esm/SSRContext-CXRqYy6B.js.map +1 -0
  67. package/esm/ToJs-BnRRHk6f.js +17 -0
  68. package/esm/ToJs-BnRRHk6f.js.map +1 -0
  69. package/esm/VersionInfo-j6NR0QJR.js +193 -0
  70. package/esm/VersionInfo-j6NR0QJR.js.map +1 -0
  71. package/esm/{_commonjsHelpers-1789f0cf.js → _commonjsHelpers-BFTU3MAI.js} +1 -1
  72. package/esm/_commonjsHelpers-BFTU3MAI.js.map +1 -0
  73. package/esm/client.js +39 -62
  74. package/esm/client.js.map +1 -1
  75. package/esm/contensis-react-base.js +616 -3272
  76. package/esm/contensis-react-base.js.map +1 -1
  77. package/esm/{fromJSLeaveImmer-0114ffcf.js → fromJSLeaveImmer-C_YACmOf.js} +2 -6
  78. package/{cjs/fromJSLeaveImmer-e74c673c.js.map → esm/fromJSLeaveImmer-C_YACmOf.js.map} +1 -1
  79. package/esm/{ToJs-df57f31d.js → matchGroups-Bq8QnqFx.js} +23 -91
  80. package/esm/matchGroups-Bq8QnqFx.js.map +1 -0
  81. package/esm/redux.js +11 -9
  82. package/esm/redux.js.map +1 -1
  83. package/esm/routing.js +18 -5
  84. package/esm/routing.js.map +1 -1
  85. package/esm/sagas-BFQ4tBq_.js +5743 -0
  86. package/esm/sagas-BFQ4tBq_.js.map +1 -0
  87. package/esm/search.js +124 -323
  88. package/esm/search.js.map +1 -1
  89. package/esm/selectors-CNC7sDxg.js +404 -0
  90. package/esm/selectors-CNC7sDxg.js.map +1 -0
  91. package/esm/{version-3d9911e2.js → store-CtDx5MLq.js} +38 -85
  92. package/esm/store-CtDx5MLq.js.map +1 -0
  93. package/esm/user.js +10 -13
  94. package/esm/user.js.map +1 -1
  95. package/esm/util-BC8LWRKL.js +136 -0
  96. package/esm/util-BC8LWRKL.js.map +1 -0
  97. package/esm/util.js +69 -201
  98. package/esm/util.js.map +1 -1
  99. package/esm/version-CaL4czqJ.js +15 -0
  100. package/esm/version-CaL4czqJ.js.map +1 -0
  101. package/esm/{version-9f29becb.js → version-CfABeHJA.js} +6 -9
  102. package/{cjs/version-a410c88e.js.map → esm/version-CfABeHJA.js.map} +1 -1
  103. package/models/app/App.d.ts +1 -1
  104. package/models/app/pages/VersionInfo/components/VersionInfo.d.ts +4 -1
  105. package/models/app/pages/VersionInfo/components/VersionInfo.styled.d.ts +1 -1
  106. package/models/client/client.d.ts +1 -1
  107. package/models/index.d.ts +1 -2
  108. package/models/models/AppRouteProps.d.ts +11 -0
  109. package/models/{redux/appstate.d.ts → models/AppState.d.ts} +3 -3
  110. package/models/models/ContentTypeMapping.d.ts +89 -0
  111. package/models/models/EntryMapper.d.ts +3 -0
  112. package/models/models/GetRouteActionArgs.d.ts +15 -0
  113. package/models/models/MatchedRoute.d.ts +8 -0
  114. package/models/models/ReduxInjector.d.ts +5 -0
  115. package/models/models/RequireLogin.d.ts +6 -0
  116. package/models/models/RouteComponent.d.ts +3 -0
  117. package/models/models/RouteComponentProps.d.ts +9 -0
  118. package/models/models/RouteLoaderProps.d.ts +9 -0
  119. package/models/models/RouteNode.d.ts +5 -0
  120. package/models/models/SSRContext.d.ts +32 -0
  121. package/models/models/StaticRoute.d.ts +61 -0
  122. package/models/models/WithEvents.d.ts +58 -0
  123. package/models/models/config/AppConfig.d.ts +13 -0
  124. package/models/{config.d.ts → models/config/ServerConfig.d.ts} +4 -12
  125. package/models/models/config/StateType.d.ts +2 -0
  126. package/models/models/config/index.d.ts +3 -0
  127. package/models/models/index.d.ts +16 -0
  128. package/models/redux/actions/index.d.ts +2 -2
  129. package/models/redux/sagas/navigation.d.ts +1 -3
  130. package/models/redux/selectors/index.d.ts +2 -2
  131. package/models/redux/store/injectors.d.ts +16 -4
  132. package/models/redux/store/store.d.ts +10 -4
  133. package/models/redux/types/index.d.ts +2 -2
  134. package/models/redux/types/navigation.d.ts +3 -3
  135. package/models/redux/types/version.d.ts +2 -2
  136. package/models/redux/util.d.ts +1 -1
  137. package/models/routing/components/Redirect.d.ts +1 -1
  138. package/models/routing/components/RouteLoader.d.ts +3 -3
  139. package/models/routing/components/StaticRouteLoader.d.ts +1 -1
  140. package/models/routing/components/Status.d.ts +1 -1
  141. package/models/routing/httpContext.d.ts +0 -1
  142. package/models/routing/index.d.ts +1 -0
  143. package/models/routing/redux/actions.d.ts +3 -4
  144. package/models/routing/redux/selectors.d.ts +44 -4
  145. package/models/routing/redux/types.d.ts +11 -11
  146. package/models/routing/util/expressions.d.ts +1 -1
  147. package/models/routing/util/find-contenttype-mapping.d.ts +1 -1
  148. package/models/routing/util/queries.d.ts +2 -2
  149. package/models/search/containers/withListing.d.ts +4 -1
  150. package/models/search/containers/withSearch.d.ts +4 -1
  151. package/models/search/models/Queries.d.ts +6 -6
  152. package/models/search/models/Search.d.ts +13 -4
  153. package/models/search/models/SearchActions.d.ts +29 -12
  154. package/models/search/models/SearchProps.d.ts +4 -10
  155. package/models/search/models/SearchState.d.ts +8 -2
  156. package/models/search/redux/getIn.d.ts +2 -2
  157. package/models/search/redux/reducers.d.ts +5 -261
  158. package/models/search/redux/sagas.d.ts +13 -14
  159. package/models/search/redux/schema.d.ts +2 -2
  160. package/models/search/redux/selectors.d.ts +10 -10
  161. package/models/search/redux/util.d.ts +9 -1
  162. package/models/search/search/ContensisDeliveryApi.d.ts +6 -26
  163. package/models/search/search/expressions.d.ts +3 -3
  164. package/models/search/search/util.d.ts +25 -8
  165. package/models/search/transformations/searchresult-to-state.mapper.d.ts +1 -2
  166. package/models/server/features/caching/cacheDuration.schema.d.ts +1 -0
  167. package/models/server/features/linkdepth-api/search.d.ts +2 -2
  168. package/models/server/features/response-handler/render-stream.d.ts +25 -0
  169. package/models/server/features/static-assets/index.d.ts +3 -3
  170. package/models/server/internalServer.d.ts +2 -3
  171. package/models/server/util/bundles.d.ts +10 -10
  172. package/models/server/util/headers.d.ts +1 -1
  173. package/models/server/util/html.d.ts +23 -0
  174. package/models/server/util/jsx.d.ts +42 -0
  175. package/models/server/webApp.d.ts +1 -1
  176. package/models/user/components/Login.d.ts +1 -1
  177. package/models/user/components/LoginForm.d.ts +6 -6
  178. package/models/user/components/LogoutForm.d.ts +4 -4
  179. package/models/user/components.styled/Login.styled.d.ts +1 -1
  180. package/models/user/components.styled/LoginForm.styled.d.ts +1 -1
  181. package/models/user/hocs/withLogin.d.ts +4 -4
  182. package/models/user/hocs/withRegistration.d.ts +6 -3
  183. package/models/user/hooks/useLogin.d.ts +4 -4
  184. package/models/user/redux/actions.d.ts +7 -6
  185. package/models/user/redux/sagas/index.d.ts +1 -1
  186. package/models/user/redux/sagas/login.d.ts +5 -17
  187. package/models/user/redux/selectors.d.ts +1 -2
  188. package/models/user/redux/types.d.ts +21 -21
  189. package/models/user/state.d.ts +12 -0
  190. package/models/user/transformations/mapClientCredentials.d.ts +3 -1
  191. package/models/user/util/ContensisManagementApi.d.ts +10 -9
  192. package/models/user/util/CookieConstants.d.ts +1 -0
  193. package/models/user/util/CookieHelper.class.d.ts +8 -4
  194. package/models/user/util/LoginHelper.class.d.ts +25 -37
  195. package/models/user/util/OidcUserManager.d.ts +1 -1
  196. package/models/user/util/matchGroups.d.ts +1 -1
  197. package/models/util/CachedDeliveryApi.d.ts +19 -12
  198. package/models/util/ContensisDeliveryApi.d.ts +11 -9
  199. package/models/util/NoSSR.d.ts +6 -0
  200. package/models/util/SSRContext.d.ts +24 -0
  201. package/models/util/donotuse_useHistory.d.ts +6 -0
  202. package/models/util/index.d.ts +5 -1
  203. package/models/util/json-mapper.d.ts +4 -5
  204. package/models/util/useIsClient.d.ts +6 -0
  205. package/package.json +75 -97
  206. package/cjs/App-b56aca04.js.map +0 -1
  207. package/cjs/ChangePassword.container-ae35785e.js.map +0 -1
  208. package/cjs/ContensisDeliveryApi-4fcf049d.js.map +0 -1
  209. package/cjs/CookieConstants-000427db.js.map +0 -1
  210. package/cjs/RouteLoader-c06dccd5.js.map +0 -1
  211. package/cjs/ToJs-a8d8f3f0.js.map +0 -1
  212. package/cjs/_commonjsHelpers-b3309d7b.js.map +0 -1
  213. package/cjs/forms.js +0 -5998
  214. package/cjs/forms.js.map +0 -1
  215. package/cjs/reducers-73a03ef4.js +0 -257
  216. package/cjs/reducers-73a03ef4.js.map +0 -1
  217. package/cjs/sagas-570f23ba.js +0 -2175
  218. package/cjs/sagas-570f23ba.js.map +0 -1
  219. package/cjs/selectors-14caa813.js +0 -228
  220. package/cjs/selectors-14caa813.js.map +0 -1
  221. package/cjs/urls-6fcaf4c6.js +0 -25
  222. package/cjs/urls-6fcaf4c6.js.map +0 -1
  223. package/cjs/version-34d91f68.js.map +0 -1
  224. package/esm/App-83107d7e.js.map +0 -1
  225. package/esm/ChangePassword.container-76fd5e9b.js.map +0 -1
  226. package/esm/ContensisDeliveryApi-fe57a037.js.map +0 -1
  227. package/esm/CookieConstants-3d3b6531.js.map +0 -1
  228. package/esm/RouteLoader-29fd689a.js.map +0 -1
  229. package/esm/ToJs-df57f31d.js.map +0 -1
  230. package/esm/_commonjsHelpers-1789f0cf.js.map +0 -1
  231. package/esm/forms.js +0 -5984
  232. package/esm/forms.js.map +0 -1
  233. package/esm/reducers-aa8cef1e.js +0 -234
  234. package/esm/reducers-aa8cef1e.js.map +0 -1
  235. package/esm/sagas-07e82e18.js +0 -2083
  236. package/esm/sagas-07e82e18.js.map +0 -1
  237. package/esm/selectors-691caf02.js +0 -186
  238. package/esm/selectors-691caf02.js.map +0 -1
  239. package/esm/urls-eac9a747.js +0 -22
  240. package/esm/urls-eac9a747.js.map +0 -1
  241. package/esm/version-3d9911e2.js.map +0 -1
  242. package/models/forms/index.d.ts +0 -1
  243. package/models/routing/routes.d.ts +0 -133
  244. package/models/search/search/ToJs.d.ts +0 -4
@@ -2,19 +2,19 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var ContensisDeliveryApi = require('./ContensisDeliveryApi-4fcf049d.js');
5
+ var ContensisDeliveryApi = require('./ContensisDeliveryApi-lcZ45Kxx.js');
6
6
  var contensisDeliveryApi = require('contensis-delivery-api');
7
- var React$1 = require('react');
7
+ var React = require('react');
8
8
  var reactRedux = require('react-redux');
9
- var sagas = require('./sagas-570f23ba.js');
10
9
  var mapJson = require('jsonpath-mapper');
10
+ var sagas = require('./sagas-CMBI1syl.js');
11
11
  require('reselect');
12
- require('deepmerge');
13
- require('query-string');
14
12
  require('immer');
15
13
  require('deep-equal');
14
+ require('deepmerge');
15
+ require('query-string');
16
16
  var contensisCoreApi = require('contensis-core-api');
17
- var urls = require('./urls-6fcaf4c6.js');
17
+ var VersionInfo = require('./VersionInfo-D0mF1vkY.js');
18
18
  require('isomorphic-fetch');
19
19
  var express = require('express');
20
20
  var http = require('http');
@@ -22,52 +22,56 @@ var httpProxy = require('http-proxy');
22
22
  var fs = require('fs');
23
23
  var path = require('path');
24
24
  var appRootPath = require('app-root-path');
25
- var server$3 = require('react-dom/server');
26
- var require$$1 = require('history');
27
- var require$$2 = require('react-router-dom');
25
+ var server$1 = require('react-dom/server');
26
+ var reactRouterDom = require('react-router-dom');
28
27
  var reactHelmet = require('react-helmet');
29
28
  var styled = require('styled-components');
30
29
  var serialize = require('serialize-javascript');
31
- var minifyCssString = require('minify-css-string');
32
- var server$2 = require('@loadable/server');
33
30
  var lodash = require('lodash');
34
- var _commonjsHelpers = require('./_commonjsHelpers-b3309d7b.js');
35
31
  var lodashClean = require('lodash-clean');
36
- var reactCookie = require('react-cookie');
32
+ var CookieHelper_class = require('./CookieHelper.class-Det3qfdU.js');
37
33
  var cookiesMiddleware = require('universal-cookie-express');
38
- var version = require('./version-34d91f68.js');
39
- var App = require('./App-b56aca04.js');
40
- var version$1 = require('./version-a410c88e.js');
41
- var RouteLoader = require('./RouteLoader-c06dccd5.js');
42
- var selectors = require('./selectors-14caa813.js');
34
+ var store = require('./store-CO5xslDu.js');
35
+ var App = require('./App-C_1U2j24.js');
36
+ var version = require('./version-DabwEeLw.js');
37
+ var selectors = require('./selectors-Bp_TrwG5.js');
38
+ var RouteLoader = require('./RouteLoader-CAkG-Y5y.js');
39
+ var stream = require('stream');
40
+ var server$2 = require('@loadable/server');
43
41
  var chalk = require('chalk');
44
- require('./CookieConstants-000427db.js');
42
+ var minifyCssString = require('minify-css-string');
43
+ var reactCookie = require('react-cookie');
44
+ var server$3 = require('react-router-dom/server');
45
+ var SSRContext = require('./SSRContext-ciyKagks.js');
46
+ require('./CookieConstants-DfPiWCRZ.js');
45
47
  require('loglevel');
46
48
  require('@redux-saga/core/effects');
49
+ require('./version-BolvQdgT.js');
50
+ require('./util-CTvFvplw.js');
51
+ require('./_commonjsHelpers-BJu3ubxk.js');
47
52
  require('redux');
48
53
  require('redux-thunk');
49
54
  require('redux-saga');
50
- require('redux-injectors');
51
- require('./reducers-73a03ef4.js');
55
+ require('redux-injectors-19');
56
+ require('history');
52
57
  require('await-to-js');
53
- require('./ChangePassword.container-ae35785e.js');
54
- require('./ToJs-a8d8f3f0.js');
58
+ require('./ChangePassword.container-H4i1yRi6.js');
59
+ require('./matchGroups-CNt2aNoC.js');
60
+ require('./ToJs-BsWqWjdm.js');
55
61
 
56
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
62
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
57
63
 
58
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React$1);
59
- var mapJson__default = /*#__PURE__*/_interopDefaultLegacy(mapJson);
60
- var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
61
- var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
62
- var httpProxy__default = /*#__PURE__*/_interopDefaultLegacy(httpProxy);
63
- var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
64
- var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
65
- var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
66
- var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
67
- var serialize__default = /*#__PURE__*/_interopDefaultLegacy(serialize);
68
- var minifyCssString__default = /*#__PURE__*/_interopDefaultLegacy(minifyCssString);
69
- var cookiesMiddleware__default = /*#__PURE__*/_interopDefaultLegacy(cookiesMiddleware);
70
- var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
64
+ var React__default = /*#__PURE__*/_interopDefault(React);
65
+ var mapJson__default = /*#__PURE__*/_interopDefault(mapJson);
66
+ var express__default = /*#__PURE__*/_interopDefault(express);
67
+ var http__default = /*#__PURE__*/_interopDefault(http);
68
+ var httpProxy__default = /*#__PURE__*/_interopDefault(httpProxy);
69
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
70
+ var path__default = /*#__PURE__*/_interopDefault(path);
71
+ var serialize__default = /*#__PURE__*/_interopDefault(serialize);
72
+ var cookiesMiddleware__default = /*#__PURE__*/_interopDefault(cookiesMiddleware);
73
+ var chalk__default = /*#__PURE__*/_interopDefault(chalk);
74
+ var minifyCssString__default = /*#__PURE__*/_interopDefault(minifyCssString);
71
75
 
72
76
  /**
73
77
  * Util class holds our search results helper boilerplate methods
@@ -76,27 +80,21 @@ class Util {
76
80
  static GetIds(entries, fieldId) {
77
81
  if (fieldId) {
78
82
  return entries === null || entries === void 0 ? void 0 : entries.map(e => {
79
- var _e$fieldId, _e$fieldId2, _e$fieldId2$sys;
80
-
81
- return Array.isArray(e === null || e === void 0 ? void 0 : e[fieldId]) ? e === null || e === void 0 ? void 0 : (_e$fieldId = e[fieldId]) === null || _e$fieldId === void 0 ? void 0 : _e$fieldId.map(f => {
83
+ var _e$fieldId, _e$fieldId2;
84
+ return Array.isArray(e === null || e === void 0 ? void 0 : e[fieldId]) ? e === null || e === void 0 || (_e$fieldId = e[fieldId]) === null || _e$fieldId === void 0 ? void 0 : _e$fieldId.map(f => {
82
85
  var _f$sys;
83
-
84
- return f === null || f === void 0 ? void 0 : (_f$sys = f.sys) === null || _f$sys === void 0 ? void 0 : _f$sys.id;
85
- }) : (e === null || e === void 0 ? void 0 : (_e$fieldId2 = e[fieldId]) === null || _e$fieldId2 === void 0 ? void 0 : (_e$fieldId2$sys = _e$fieldId2.sys) === null || _e$fieldId2$sys === void 0 ? void 0 : _e$fieldId2$sys.id) || '';
86
+ return f === null || f === void 0 || (_f$sys = f.sys) === null || _f$sys === void 0 ? void 0 : _f$sys.id;
87
+ }) : (e === null || e === void 0 || (_e$fieldId2 = e[fieldId]) === null || _e$fieldId2 === void 0 || (_e$fieldId2 = _e$fieldId2.sys) === null || _e$fieldId2 === void 0 ? void 0 : _e$fieldId2.id) || '';
86
88
  }).flat();
87
89
  }
88
-
89
90
  return entries === null || entries === void 0 ? void 0 : entries.map(e => {
90
91
  var _e$sys;
91
-
92
- return (e === null || e === void 0 ? void 0 : (_e$sys = e.sys) === null || _e$sys === void 0 ? void 0 : _e$sys.id) || '';
92
+ return (e === null || e === void 0 || (_e$sys = e.sys) === null || _e$sys === void 0 ? void 0 : _e$sys.id) || '';
93
93
  });
94
94
  }
95
-
96
95
  static GetItems(result) {
97
96
  return this.GetResults(result) ? result.items : [];
98
97
  }
99
-
100
98
  static GetResults(result) {
101
99
  if (result !== null && result !== void 0 && result.items) {
102
100
  return result;
@@ -104,20 +102,18 @@ class Util {
104
102
  return null;
105
103
  }
106
104
  }
107
-
108
105
  }
109
106
  const mergeResults = (results, parentResults, replaceContentTypeIds, linkFieldId) => results.map(r => {
110
107
  if (replaceContentTypeIds.some(c => c === r.sys.contentTypeId)) {
111
108
  const resolvedParent = parentResults === null || parentResults === void 0 ? void 0 : parentResults.find(e => {
112
109
  var _e$linkFieldId;
113
-
114
110
  return (_e$linkFieldId = e[linkFieldId]) === null || _e$linkFieldId === void 0 ? void 0 : _e$linkFieldId.some(l => {
115
111
  var _l$sys;
116
-
117
112
  return ((_l$sys = l.sys) === null || _l$sys === void 0 ? void 0 : _l$sys.id) === r.sys.id;
118
113
  });
119
114
  });
120
- if (resolvedParent) return { ...resolvedParent,
115
+ if (resolvedParent) return {
116
+ ...resolvedParent,
121
117
  ...r,
122
118
  entryTitle: resolvedParent.entryTitle,
123
119
  entryDescription: resolvedParent.entryDescription,
@@ -125,12 +121,9 @@ const mergeResults = (results, parentResults, replaceContentTypeIds, linkFieldId
125
121
  originalSys: r.sys
126
122
  };else return r;
127
123
  }
128
-
129
124
  return r;
130
125
  }).filter(r => r);
131
126
 
132
- /* eslint-disable no-console */
133
-
134
127
  /**
135
128
  * Builds our complete Delivery API Query object from a set of provided arguments
136
129
  * @param queryParams
@@ -155,13 +148,12 @@ const searchQuery = ({
155
148
  const expressions$1 = [...sagas.defaultExpressions(versionStatus), ...sagas.contentTypeIdExpression(contentTypeIds, webpageTemplates, assetTypes), ...sagas.customWhereExpressions(customWhere), ...sagas.filterExpressions(filters), ...sagas.filterExpressions(idFilters), ...((sharedFilters === null || sharedFilters === void 0 ? void 0 : sharedFilters.length) > 0 ? [contensisCoreApi.Op.or(...sagas.filterExpressions(sharedFilters, true))] : []), ...sagas.termExpressions(searchTerm || '', weightedSearchFields || [])];
156
149
  const query = new contensisCoreApi.Query(...expressions$1);
157
150
  query.orderBy = sagas.orderByExpression(orderBy || []);
158
-
159
151
  if (fields && fields.length > 0) {
160
152
  query.fields = fields;
161
- } // (query as any).includeArchived = true;
162
- // (query as any).includeDeleted = true;
163
-
153
+ }
164
154
 
155
+ // (query as any).includeArchived = true;
156
+ // (query as any).includeDeleted = true;
165
157
  query.pageIndex = pageIndex;
166
158
  query.pageSize = pageSize;
167
159
  return query;
@@ -184,7 +176,8 @@ const finalQuery = ({
184
176
  webpageTemplates,
185
177
  weightedSearchFields
186
178
  }, children) => {
187
- const expressions$1 = [...sagas.defaultExpressions(versionStatus), contensisCoreApi.Op.or(contensisCoreApi.Op.and(...sagas.contentTypeIdExpression(contentTypeIds, webpageTemplates, assetTypes), ...sagas.filterExpressions(filters), ...sagas.filterExpressions(idFilters || []), ...(sharedFilters !== null && sharedFilters !== void 0 && sharedFilters.length ? [contensisCoreApi.Op.or(...sagas.filterExpressions(sharedFilters || []) // Op.and(
179
+ const expressions$1 = [...sagas.defaultExpressions(versionStatus), contensisCoreApi.Op.or(contensisCoreApi.Op.and(...sagas.contentTypeIdExpression(contentTypeIds, webpageTemplates, assetTypes), ...sagas.filterExpressions(filters), ...sagas.filterExpressions(idFilters || []), ...(sharedFilters !== null && sharedFilters !== void 0 && sharedFilters.length ? [contensisCoreApi.Op.or(...sagas.filterExpressions(sharedFilters || [])
180
+ // Op.and(
188
181
  // ...sharedFilters.map(sf =>
189
182
  // Op.not(exp.fieldExpression(sf.key, true, 'exists')[0])
190
183
  // ),
@@ -193,17 +186,17 @@ const finalQuery = ({
193
186
  )] : [])), ...children.map(child => contensisCoreApi.Op.and(...sagas.contentTypeIdExpression(child.contentTypeIds, child.webpageTemplates, child.assetTypes), ...sagas.filterExpressions(child.sharedFilters || []), ...sagas.filterExpressions(child.idFilters || [])))), ...sagas.termExpressions(searchTerm || '', weightedSearchFields || [])];
194
187
  const query = new contensisCoreApi.Query(...expressions$1);
195
188
  query.orderBy = sagas.orderByExpression(orderBy || []);
196
-
197
189
  if (fields && fields.length > 0) {
198
190
  query.fields = fields;
199
- } // (query as any).includeArchived = true;
200
- // (query as any).includeDeleted = true;
201
-
191
+ }
202
192
 
193
+ // (query as any).includeArchived = true;
194
+ // (query as any).includeDeleted = true;
203
195
  query.pageIndex = pageIndex || 0;
204
196
  query.pageSize = pageSize;
205
197
  return query;
206
198
  };
199
+
207
200
  /**
208
201
  * Create a filter expression from a provided filters configuration object
209
202
  * and populate them based on the presence of that key in params, filter
@@ -212,13 +205,10 @@ const finalQuery = ({
212
205
  * @param params request.query object from Express middleware
213
206
  * @returns FilterExpression[] we can use to use with searchQuery function
214
207
  */
215
-
216
208
  const makeFilterExpressions = (f, params) => {
217
209
  const expressions = [];
218
-
219
210
  for (const [paramKey, filterConfig] of Object.entries(f)) {
220
211
  var _params$paramKey;
221
-
222
212
  const filterValues = (_params$paramKey = params[paramKey]) === null || _params$paramKey === void 0 ? void 0 : _params$paramKey.split(',');
223
213
  if (typeof filterValues !== 'undefined') expressions.push({
224
214
  key: typeof filterConfig === 'object' ? filterConfig.fieldId : filterConfig,
@@ -227,7 +217,6 @@ const makeFilterExpressions = (f, params) => {
227
217
  logicOperator: typeof filterConfig === 'object' && filterConfig.logicOperator ? filterConfig.logicOperator : 'or'
228
218
  });
229
219
  }
230
-
231
220
  return expressions;
232
221
  };
233
222
  const makeDerivedIdsFilterExpression = (prevFieldId, entries, ownIds = false, alwaysApplyFilter = false) => {
@@ -274,32 +263,18 @@ class QueryLevelResults {
274
263
  parent: _parent,
275
264
  debug = false
276
265
  }) {
277
- this.level = void 0;
278
- this.contentTypeIds = void 0;
279
- this.linkFieldIds = void 0;
280
- this.linkFields = void 0;
281
- this.filters = void 0;
282
- this.sharedFilters = void 0;
283
- this.returnEntries = void 0;
284
- this.resolveFirstParent = void 0;
285
266
  this.validatedLinks = [];
286
- this.parent = void 0;
287
267
  this.children = [];
288
- this.runFirstQuery = void 0;
289
- this.runFinalQuery = void 0;
290
268
  this.params = {};
291
- this.debug = void 0;
292
269
  this.firstQuery = new contensisDeliveryApi.Query();
293
270
  this.firstResults = {};
294
271
  this.finalQuery = new contensisDeliveryApi.Query();
295
272
  this.finalResults = {};
296
-
297
273
  this.AddChild = ({
298
274
  child
299
275
  }) => {
300
276
  this.children.push(child);
301
277
  };
302
-
303
278
  this.RunFirstQuery = async () => {
304
279
  const {
305
280
  firstQuery: query,
@@ -307,18 +282,17 @@ class QueryLevelResults {
307
282
  parent,
308
283
  runFirstQuery
309
284
  } = this;
310
-
311
285
  if (parent !== null && parent !== void 0 && parent.validatedLinks.length) {
312
286
  // add any idFilters derived from parent query results
313
287
  appendSearchQueryFilters(query, makeFilterExpressions(Object.fromEntries(parent.validatedLinks.map(vl => [vl.linkFieldId, {
314
288
  fieldId: `sys.id`
315
289
  }])), Object.fromEntries(parent.validatedLinks.map(vl => [vl.linkFieldId, vl.entryIds.join(',') || `no ids from parent ${parent.level}`]))));
316
290
  }
317
-
318
291
  if (runFirstQuery) {
319
292
  if (this.debug) console.log(`\nLevel ${this.level} - First query: \n${JSON.stringify(query.toJSON()).substring(0, 1000)}`);
320
- this.firstResults = await ContensisDeliveryApi.cachedSearch.searchUsingPost(query, 0, params.projectId); // mapResultsToValidatedLinks
293
+ this.firstResults = await ContensisDeliveryApi.cachedSearch.searchUsingPost(query, 0, params.projectId);
321
294
 
295
+ // mapResultsToValidatedLinks
322
296
  for (const linkFieldId of this.linkFieldIds) {
323
297
  this.validatedLinks.push({
324
298
  contentTypeId: this.linkFields[linkFieldId].contentTypeId || '',
@@ -328,7 +302,6 @@ class QueryLevelResults {
328
302
  }
329
303
  }
330
304
  };
331
-
332
305
  this.RunFinalQuery = async () => {
333
306
  const {
334
307
  level,
@@ -337,31 +310,29 @@ class QueryLevelResults {
337
310
  params,
338
311
  runFinalQuery
339
312
  } = this;
340
-
341
313
  if (!children.some(c => c.returnEntries)) {
342
- const firstChild = children === null || children === void 0 ? void 0 : children[0]; // add any idFilters derived from child query results
343
-
314
+ const firstChild = children === null || children === void 0 ? void 0 : children[0];
315
+ // add any idFilters derived from child query results
344
316
  if (firstChild) appendSearchQueryFilters(query, makeFilterExpressions(Object.fromEntries(firstChild.validatedLinks.map(vl => [vl.linkFieldId, {
345
317
  fieldId: `${vl.linkFieldId}.sys.id`
346
318
  }])), Object.fromEntries(firstChild.validatedLinks.map(vl => [vl.linkFieldId, vl.entryIds.join(',') || `no ids from child ${firstChild.level}`]))));
347
319
  }
348
-
349
320
  if (level === 0 && this.returnEntries) {
350
321
  // This is the final query to be run and response returned to the caller
351
322
  // Only this bit cares about linkDepth, fields and pagination parameters
352
323
  query.fields = JSON.parse(params.fields || '[]');
353
324
  query.pageSize = params.pageSize;
354
- query.pageIndex = params.pageIndex; // query.orderBy = params.orderBy;
325
+ query.pageIndex = params.pageIndex;
326
+ // query.orderBy = params.orderBy;
355
327
  }
356
-
357
328
  if (runFinalQuery) {
358
329
  if (this.debug) console.log(`\nLevel ${this.level} - Final query: \n${JSON.stringify(query.toJSON()).substring(0, 1000)}`);
359
330
  this.finalResults = await ContensisDeliveryApi.cachedSearch.searchUsingPost(query, Number(params.linkDepth) || 0, params.projectId);
360
- if (this.parent) this.parent.runFinalQuery = true; // mapResultsToValidatedLinks
331
+ if (this.parent) this.parent.runFinalQuery = true;
361
332
 
333
+ // mapResultsToValidatedLinks
362
334
  for (const linkFieldId of ((_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.linkFieldIds) || []) {
363
335
  var _this$parent, _this$parent2;
364
-
365
336
  this.validatedLinks.push({
366
337
  contentTypeId: ((_this$parent2 = this.parent) === null || _this$parent2 === void 0 ? void 0 : _this$parent2.linkFields[linkFieldId].contentTypeId) || '',
367
338
  linkFieldId,
@@ -370,17 +341,14 @@ class QueryLevelResults {
370
341
  }
371
342
  }
372
343
  };
373
-
374
344
  this.GetResultsEntries = () => {
375
345
  var _finalResults$items;
376
-
377
346
  const {
378
347
  finalResults,
379
348
  firstResults
380
349
  } = this;
381
350
  return finalResults !== null && finalResults !== void 0 && (_finalResults$items = finalResults.items) !== null && _finalResults$items !== void 0 && _finalResults$items.length ? finalResults.items : firstResults.items;
382
351
  };
383
-
384
352
  this.GetResults = () => {
385
353
  const {
386
354
  finalResults,
@@ -388,7 +356,6 @@ class QueryLevelResults {
388
356
  } = this;
389
357
  return typeof (finalResults === null || finalResults === void 0 ? void 0 : finalResults.totalCount) !== 'undefined' ? finalResults : firstResults;
390
358
  };
391
-
392
359
  this.level = _level;
393
360
  this.contentTypeIds = contentTypeIds;
394
361
  this.linkFields = linkFields;
@@ -425,11 +392,9 @@ class QueryLevelResults {
425
392
  versionStatus: _params.versionStatus
426
393
  });
427
394
  }
428
-
429
395
  }
430
396
 
431
397
  /* eslint-disable no-console */
432
-
433
398
  class LinkDepthSearchService {
434
399
  constructor({
435
400
  contentTypeId: _contentTypeId = '',
@@ -439,36 +404,27 @@ class LinkDepthSearchService {
439
404
  params: _params,
440
405
  debug = false
441
406
  }) {
442
- this.contentTypeIds = void 0;
443
- this.filters = void 0;
444
- this.sharedFilters = void 0;
445
- this.linkFields = void 0;
446
- this.params = void 0;
447
- this.debug = void 0;
448
- this.queryLevels = void 0;
449
-
450
407
  this.DoSearch = async () => {
451
408
  // Run queries "top-down" through each level of `linkField`
452
409
  for (const queryLevel of this.queryLevels) {
453
410
  await queryLevel.RunFirstQuery();
454
- } // Run queries "bottom-up" through each level of `linkField`
455
-
411
+ }
456
412
 
413
+ // Run queries "bottom-up" through each level of `linkField`
457
414
  for (const queryLevel of [...this.queryLevels].reverse()) {
458
415
  await queryLevel.RunFinalQuery();
459
- } // Run a final query that will aggregate the results from all levels
460
- // adding all levels to the query that have `returnEntries` set true
461
-
416
+ }
462
417
 
418
+ // Run a final query that will aggregate the results from all levels
419
+ // adding all levels to the query that have `returnEntries` set true
463
420
  return await this.RunFinalQueries();
464
421
  };
465
-
466
422
  this.RunFinalQueries = async () => {
467
- const finalQueryLevels = this.queryLevels.filter(ql => ql.level > 0 && ql.returnEntries || ql.level === 0 && ql.returnEntries !== false); // Decide if we need a further final query if any child level(s) have had `returnEntries` set to true
423
+ const finalQueryLevels = this.queryLevels.filter(ql => ql.level > 0 && ql.returnEntries || ql.level === 0 && ql.returnEntries !== false);
468
424
 
425
+ // Decide if we need a further final query if any child level(s) have had `returnEntries` set to true
469
426
  if (finalQueryLevels.length > 1 || finalQueryLevels.length === 1 && finalQueryLevels[0].level !== 0) {
470
427
  var _params$orderBy;
471
-
472
428
  // Build final query
473
429
  const {
474
430
  contentTypeIds,
@@ -483,9 +439,9 @@ class LinkDepthSearchService {
483
439
  }
484
440
  }, {
485
441
  [vl.linkFieldId]: vl.entryIds.join(',') || 'no results for filter'
486
- })).flat() || []; // This is the final query to be run and response returned to the caller
442
+ })).flat() || [];
443
+ // This is the final query to be run and response returned to the caller
487
444
  // Only this bit cares about linkDepth, fields and pagination parameters
488
-
489
445
  const query = finalQuery({
490
446
  contentTypeIds,
491
447
  filters: makeFilterExpressions(filters, params),
@@ -493,7 +449,6 @@ class LinkDepthSearchService {
493
449
  idFilters: derivedIdFilters,
494
450
  fields: params.fields ? [...JSON.parse(params.fields), ...finalQueryLevels.map(l => {
495
451
  var _l$parent;
496
-
497
452
  return ((_l$parent = l.parent) === null || _l$parent === void 0 ? void 0 : _l$parent.linkFieldIds) || [];
498
453
  }).flat()] : [],
499
454
  orderBy: (_params$orderBy = params.orderBy) === null || _params$orderBy === void 0 ? void 0 : _params$orderBy.split(','),
@@ -503,7 +458,6 @@ class LinkDepthSearchService {
503
458
  versionStatus: params.versionStatus
504
459
  }, (finalQueryLevels === null || finalQueryLevels === void 0 ? void 0 : finalQueryLevels[0].children.filter(ql => ql.returnEntries).map(ql => {
505
460
  var _ql$parent, _ql$parent2;
506
-
507
461
  const entriesAtLevel = ql.GetResultsEntries() || ((_ql$parent = ql.parent) === null || _ql$parent === void 0 ? void 0 : _ql$parent.GetResultsEntries());
508
462
  const previousIdsFilter = ql.returnEntries || !!ql.children.some(qc => qc.returnEntries) ? (_ql$parent2 = ql.parent) === null || _ql$parent2 === void 0 ? void 0 : _ql$parent2.linkFieldIds.map(fieldId => makeDerivedIdsFilterExpression(fieldId, entriesAtLevel, true, ql.runFinalQuery)).flat() : [];
509
463
  return {
@@ -514,29 +468,28 @@ class LinkDepthSearchService {
514
468
  };
515
469
  })) || []);
516
470
  if (this.debug) console.log(`\nFinal query: ${derivedIds.reduce((accumulator, object) => accumulator + object.entryIds.length, 0)} derived ids \n${JSON.stringify(query.toJSON()).substring(0, 1000)}`);
517
- const finalQueryResult = await ContensisDeliveryApi.cachedSearch.searchUsingPost(query, Number(params.linkDepth) || 0, params.projectId); // Resolve any parent entries
471
+ const finalQueryResult = await ContensisDeliveryApi.cachedSearch.searchUsingPost(query, Number(params.linkDepth) || 0, params.projectId);
472
+
473
+ // Resolve any parent entries
518
474
 
519
475
  const resolveParentLevels = finalQueryLevels.filter(ql => ql.resolveFirstParent);
520
476
  let entries = finalQueryResult.items;
521
-
522
477
  for (const resolveParents of resolveParentLevels) {
523
478
  var _resolveParents$paren, _resolveParents$paren2;
524
-
525
- entries = await resolveParentEntries(((_resolveParents$paren = resolveParents.parent) === null || _resolveParents$paren === void 0 ? void 0 : _resolveParents$paren.contentTypeIds) || [], resolveParents.contentTypeIds, ((_resolveParents$paren2 = resolveParents.parent) === null || _resolveParents$paren2 === void 0 ? void 0 : _resolveParents$paren2.linkFieldIds[0]) || 'unknown', finalQueryResult.items, // or entries?
479
+ entries = await resolveParentEntries(((_resolveParents$paren = resolveParents.parent) === null || _resolveParents$paren === void 0 ? void 0 : _resolveParents$paren.contentTypeIds) || [], resolveParents.contentTypeIds, ((_resolveParents$paren2 = resolveParents.parent) === null || _resolveParents$paren2 === void 0 ? void 0 : _resolveParents$paren2.linkFieldIds[0]) || 'unknown', finalQueryResult.items,
480
+ // or entries?
526
481
  this.params, this.debug);
527
482
  }
528
-
529
- return { ...finalQueryResult,
483
+ return {
484
+ ...finalQueryResult,
530
485
  items: entries
531
486
  };
532
487
  } else {
533
488
  var _this$queryLevels$fin;
534
-
535
489
  if (this.debug) console.log(`\nNo further queries required\n`);
536
490
  return (_this$queryLevels$fin = this.queryLevels.find(ql => ql.level === 0)) === null || _this$queryLevels$fin === void 0 ? void 0 : _this$queryLevels$fin.GetResults();
537
491
  }
538
492
  };
539
-
540
493
  this.InitQueryLevels = () => {
541
494
  const createChildQueryLevels = (linkFields, parentQueryLevel, level = 1) => {
542
495
  return Object.entries(linkFields).map(([, {
@@ -569,7 +522,6 @@ class LinkDepthSearchService {
569
522
  return [thisLevel, ...createChildQueryLevels(linkFields, thisLevel, level + 1)];
570
523
  }).flat();
571
524
  };
572
-
573
525
  const {
574
526
  contentTypeIds,
575
527
  filters,
@@ -590,17 +542,17 @@ class LinkDepthSearchService {
590
542
  params,
591
543
  debug: this.debug
592
544
  });
593
- const queryLevels = [firstLevel, ...createChildQueryLevels(linkFields, firstLevel)]; // return queryLevels;
545
+ const queryLevels = [firstLevel, ...createChildQueryLevels(linkFields, firstLevel)];
546
+ // return queryLevels;
547
+
594
548
  // If we are only returning entries from level 0
595
549
  // we can skip running the first query and finalQuery will suffice
596
-
597
550
  if (queryLevels.find(ql => ql.returnEntries && ql.level !== 0)) return queryLevels;else return queryLevels.map(ql => {
598
- ql.runFirstQuery = false; // ql.runFinalQuery = false;
599
-
551
+ ql.runFirstQuery = false;
552
+ // ql.runFinalQuery = false;
600
553
  return ql;
601
554
  });
602
555
  };
603
-
604
556
  this.contentTypeIds = Array.isArray(_contentTypeId) ? _contentTypeId : [_contentTypeId];
605
557
  this.filters = _filters;
606
558
  this.sharedFilters = _sharedFilters;
@@ -609,7 +561,6 @@ class LinkDepthSearchService {
609
561
  this.debug = debug;
610
562
  this.queryLevels = this.InitQueryLevels();
611
563
  }
612
-
613
564
  }
614
565
 
615
566
  /**
@@ -629,10 +580,9 @@ const makeLinkDepthApi = (app, middlewareConfig) => {
629
580
  if (!contentTypeId || !linkFields || !uri) return;
630
581
  app.get(uri, makeLinkDepthMiddleware(middlewareConfig));
631
582
  };
583
+
632
584
  /** Create a content type hierarchy from supplied config and produces
633
585
  * a RequestHandler function to serve our Express middleware */
634
-
635
-
636
586
  const makeLinkDepthMiddleware = ({
637
587
  contentTypeId,
638
588
  filters = {},
@@ -645,11 +595,12 @@ const makeLinkDepthMiddleware = ({
645
595
  const linkDepthMiddleware = async (req, res) => {
646
596
  try {
647
597
  // Short cache duration copied from canterbury project
648
- urls.setCachingHeaders(res, {
598
+ VersionInfo.setCachingHeaders(res, {
649
599
  cacheControl: 'private',
650
600
  surrogateControl: '10'
651
- }); // Gather all params from the request, we will use them at the right query levels later
601
+ });
652
602
 
603
+ // Gather all params from the request, we will use them at the right query levels later
653
604
  const params = Object.fromEntries([...Object.entries(req.params), ...Object.entries(req.query)].map(([k, v]) => [k, v === null || v === void 0 ? void 0 : v.toString()]));
654
605
  const result = await new LinkDepthSearchService({
655
606
  contentTypeId,
@@ -667,64 +618,50 @@ const makeLinkDepthMiddleware = ({
667
618
  res.json(error);
668
619
  }
669
620
  };
670
-
671
621
  return linkDepthMiddleware;
672
622
  } catch (error) {
673
623
  // This will be an error building the middleware
674
624
  // we can only serve what the error was as the request handler instead
675
625
  console.error(error);
676
-
677
626
  const errorMiddleware = async (req, res) => {
678
627
  res.statusCode = 500;
679
628
  res.json(JSON.stringify(error));
680
629
  };
681
-
682
630
  return errorMiddleware;
683
631
  }
684
632
  };
685
633
 
686
- const servers$1 = SERVERS;
687
- /* global SERVERS */
688
-
689
- const project = PROJECT;
690
- /* global PROJECT */
691
-
692
- const alias$1 = ALIAS;
693
- /* global ALIAS */
694
-
695
- const deliveryApiHostname = urls.url(alias$1, project).api;
696
- const assetProxy = httpProxy__default["default"].createProxyServer();
697
- const deliveryProxy = httpProxy__default["default"].createProxyServer();
698
-
634
+ const servers$1 = SERVERS; /* global SERVERS */
635
+ const project = PROJECT; /* global PROJECT */
636
+ const alias$1 = ALIAS; /* global ALIAS */
637
+ const deliveryApiHostname = VersionInfo.url(alias$1, project).api;
638
+ const assetProxy = httpProxy__default.default.createProxyServer();
639
+ const deliveryProxy = httpProxy__default.default.createProxyServer();
699
640
  const reverseProxies = (app, reverseProxyPaths = []) => {
700
641
  deliveryApiProxy(deliveryProxy, app);
701
- app.all(reverseProxyPaths, (req, res) => {
642
+ app.all(reverseProxyPaths.map(proxyPath =>
643
+ // Patch to update paths for express v5
644
+ proxyPath.endsWith('/*') ? `${proxyPath.slice(0, -2)}/{*splat}` : proxyPath), (req, res) => {
702
645
  const target = req.hostname.indexOf('preview-') || req.hostname.indexOf('preview.') || req.hostname === 'localhost' ? servers$1.previewIis || servers$1.iis : servers$1.iis;
703
646
  assetProxy.web(req, res, {
704
647
  target,
705
648
  changeOrigin: true
706
649
  });
707
650
  assetProxy.on('error', e => {
708
- /* eslint-disable no-console */
709
651
  console.log(`Proxy Request for ${req.path} HostName:${req.hostname} failed with ${e}`);
710
- /* eslint-enable no-console */
711
652
  });
712
653
  });
713
654
  };
714
-
715
655
  const deliveryApiProxy = (apiProxy, app) => {
716
656
  // This is just here to stop cors requests on localhost. In Production this is mapped using varnish.
717
- app.all(['/api/delivery/*', '/api/image/*'], (req, res) => {
718
- /* eslint-disable no-console */
657
+ app.all(['/api/delivery/{*splat}', '/api/forms/{*splat}', '/api/image/{*splat}', '/authenticate/{*splat}'], (req, res) => {
719
658
  console.log(`Proxying api request to ${servers$1.alias}`);
720
659
  apiProxy.web(req, res, {
721
660
  target: deliveryApiHostname,
722
661
  changeOrigin: true
723
662
  });
724
663
  apiProxy.on('error', e => {
725
- /* eslint-disable no-console */
726
664
  console.log(`Proxy request for ${req.path} HostName:${req.hostname} failed with ${e}`);
727
- /* eslint-enable no-console */
728
665
  });
729
666
  });
730
667
  };
@@ -735,12 +672,14 @@ const CacheDuration = {
735
672
  static: '31536000',
736
673
  // Believe it or not these two max ages are the same in runtime
737
674
  expressStatic: '31557600h' // Believe it or not these two max ages are the same in runtime
738
-
739
675
  };
740
676
  const getCacheDuration = (status = 200) => {
741
- if (status > 400) return CacheDuration[404];
677
+ if (status >= 400) return CacheDuration[404];
742
678
  return CacheDuration[200];
743
679
  };
680
+ const alias = ALIAS; /* global ALIAS */
681
+
682
+ const anyUpdateHeader = `${alias}_any-update`;
744
683
 
745
684
  const replaceStaticPath = (str, staticFolderPath = 'static') => str.replace(/static\//g, `${staticFolderPath}/`);
746
685
 
@@ -750,21 +689,18 @@ const bundleManipulationMiddleware = ({
750
689
  staticFolderPath,
751
690
  staticRoutePath
752
691
  }) => (req, res, next) => {
753
- const filename = path__default["default"].basename(req.path);
692
+ const filename = path__default.default.basename(encodeURI(req.path));
754
693
  const modernBundle = filename.endsWith('.mjs');
755
694
  const legacyBundle = filename.endsWith('.js');
756
-
757
695
  if ((legacyBundle || modernBundle) && filename.startsWith('runtime.')) {
758
- const jsRuntimeLocation = path__default["default"].resolve(appRootPath, `dist/${staticFolderPath}/${modernBundle ? 'modern/js' : 'legacy/js'}/${filename}`);
759
-
696
+ const jsRuntimeLocation = path__default.default.resolve(appRootPath, `dist/${staticFolderPath}/${modernBundle ? 'modern/js' : 'legacy/js'}/${filename}`);
760
697
  try {
761
- const jsRuntimeBundle = fs__default["default"].readFileSync(jsRuntimeLocation, 'utf8');
698
+ const jsRuntimeBundle = fs__default.default.readFileSync(jsRuntimeLocation, 'utf8');
762
699
  const modifiedBundle = replaceStaticPath(jsRuntimeBundle, staticRoutePath);
763
700
  if (maxage) res.set('Cache-Control', `public, max-age=${maxage}`);
764
701
  res.type('.js').send(modifiedBundle);
765
702
  return;
766
703
  } catch (readError) {
767
- // eslint-disable-next-line no-console
768
704
  console.log(`Unable to find js runtime bundle at '${jsRuntimeLocation}'`, readError);
769
705
  next();
770
706
  }
@@ -779,7 +715,6 @@ const bundleManipulationMiddleware = ({
779
715
  * @returns Response | next()
780
716
  * A middleware function to resolve /dist/static/startup.js under a supplied startupScriptFilename variable
781
717
  */
782
-
783
718
  const resolveStartupMiddleware = ({
784
719
  appRootPath,
785
720
  maxage,
@@ -788,18 +723,18 @@ const resolveStartupMiddleware = ({
788
723
  }) => async (req, res, next) => {
789
724
  if (startupScriptFilename !== 'startup.js' && req.path === `/${startupScriptFilename}`) {
790
725
  let startupFileLocation = '';
791
-
792
726
  try {
793
727
  const startupFilePaths = [`dist/static/startup.js`, `dist/${staticFolderPath}/startup.js`];
794
728
  let startupFilePath = '';
795
729
  startupFilePaths.forEach(async testPath => {
796
730
  try {
797
- fs__default["default"].accessSync(testPath);
731
+ fs__default.default.accessSync(testPath);
798
732
  startupFilePath = testPath;
799
- } catch (ex) {// Do nothing
733
+ } catch (ex) {
734
+ // Do nothing
800
735
  }
801
736
  });
802
- startupFileLocation = path__default["default"].resolve(appRootPath, startupFilePath);
737
+ startupFileLocation = path__default.default.resolve(appRootPath, startupFilePath);
803
738
  if (maxage) res.set('Cache-Control', `public, max-age=${maxage}`);
804
739
  res.sendFile(startupFileLocation);
805
740
  } catch (sendFileError) {
@@ -833,19 +768,15 @@ const staticAssets = (app, {
833
768
  maxage: CacheDuration.static,
834
769
  startupScriptFilename: scripts.startup || startupScriptFilename,
835
770
  staticFolderPath
836
- }), // eslint-disable-next-line import/no-named-as-default-member
837
- express__default["default"].static(`dist/${staticFolderPath}`, {
771
+ }), express__default.default.static(`dist/${staticFolderPath}`, {
838
772
  // these maxage values are different in config but the same in runtime,
839
773
  // this one is somehow converted and should end up being the same as CacheDuration.static
840
774
  maxAge: CacheDuration.expressStatic
841
775
  }));
842
776
  };
843
777
 
844
- const servers = SERVERS;
845
- /* global SERVERS */
846
-
847
- const projects = PROJECTS;
848
- /* global PROJECTS */
778
+ const servers = SERVERS; /* global SERVERS */
779
+ const projects = PROJECTS; /* global PROJECTS */
849
780
 
850
781
  const DisplayStartupConfiguration = config => {
851
782
  /* eslint-disable no-console */
@@ -862,2992 +793,225 @@ const DisplayStartupConfiguration = config => {
862
793
  /* eslint-enable no-console */
863
794
  };
864
795
 
865
- var server$1 = {};
796
+ var stringifyAttributes = (attributes = {}) => Object.entries(attributes).map(([key, value], idx) => `${idx !== 0 ? ' ' : ''}${key}${value ? `="${value}"` : ''}`).join(' ');
866
797
 
867
- Object.defineProperty(server$1, '__esModule', { value: true });
868
-
869
- var React = React__default["default"];
870
- var history = require$$1__default["default"];
871
- var reactRouterDom = require$$2__default["default"];
798
+ /* eslint-disable no-console */
872
799
 
873
800
  /**
874
- * A <Router> that may not transition to any other location. This is useful
875
- * on the server where there is no stateful UI.
801
+ * Web Application Response handler, sends a prepared express js response
802
+ * with the supplied content sending in the specified manner
803
+ * @param {response} request express js request object
804
+ * @param {response} response express js response object
805
+ * @param {string | object} content the content to send in the response body
806
+ * @param {"send" | "json" | "end"} send the response function to call e.g res.send() res.json() res.end()
876
807
  */
877
- function StaticRouter({
878
- basename,
879
- children,
880
- location: locationProp = "/"
881
- }) {
882
- if (typeof locationProp === "string") {
883
- locationProp = history.parsePath(locationProp);
884
- }
885
-
886
- let action = history.Action.Pop;
887
- let location = {
888
- pathname: locationProp.pathname || "/",
889
- search: locationProp.search || "",
890
- hash: locationProp.hash || "",
891
- state: locationProp.state || null,
892
- key: locationProp.key || "default"
893
- };
894
- let staticNavigator = {
895
- createHref(to) {
896
- return typeof to === "string" ? to : history.createPath(to);
897
- },
898
-
899
- push(to) {
900
- throw new Error(`You cannot use navigator.push() on the server because it is a stateless ` + `environment. This error was probably triggered when you did a ` + `\`navigate(${JSON.stringify(to)})\` somewhere in your app.`);
901
- },
808
+ const handleResponse = (request, response, content, send = 'send') => {
809
+ // console.log('---', response.statusCode, '---');
810
+ response[send](content);
811
+ };
902
812
 
903
- replace(to) {
904
- throw new Error(`You cannot use navigator.replace() on the server because it is a stateless ` + `environment. This error was probably triggered when you did a ` + `\`navigate(${JSON.stringify(to)}, { replace: true })\` somewhere ` + `in your app.`);
813
+ /**
814
+ * Render React JSX (and surrounding HTML document) via React's
815
+ * renderToPipeableStream method
816
+ * @param getContextHtml a function to produce the correct HTML template that surrounds the JSX "App" with all available document assets injected
817
+ * @param jsx the JSX to render via a streamed response
818
+ * @param response the express Response object
819
+ * @param stream all chunks are piped to this stream to add additional style elements to each streamed chunk
820
+ */
821
+ const renderStream = (getContextHtml, jsx, response, stream) => {
822
+ const {
823
+ abort,
824
+ pipe
825
+ } = server$1.renderToPipeableStream(jsx, {
826
+ onShellReady() {
827
+ const html = getContextHtml(false);
828
+ if (!html) {
829
+ // this means we have finished with the response already
830
+ abort();
831
+ } else {
832
+ const header = html.split('{{APP}}')[0];
833
+ response.setHeader('content-type', 'text/html; charset=utf-8');
834
+ stream.write(header);
835
+ pipe(stream);
836
+ }
905
837
  },
906
-
907
- go(delta) {
908
- throw new Error(`You cannot use navigator.go() on the server because it is a stateless ` + `environment. This error was probably triggered when you did a ` + `\`navigate(${delta})\` somewhere in your app.`);
838
+ onAllReady() {
839
+ const footer = getContextHtml(true).split('{{APP}}')[1];
840
+ stream.write(footer);
909
841
  },
910
-
911
- back() {
912
- throw new Error(`You cannot use navigator.back() on the server because it is a stateless ` + `environment.`);
842
+ onShellError(error) {
843
+ response.statusCode = 500;
844
+ response.setHeader('content-type', 'text/html; charset=utf-8');
845
+ response.send('<h1>Something went wrong</h1>');
846
+ console.error(`[renderToPipeableStream:onShellError]`, error);
913
847
  },
914
-
915
- forward() {
916
- throw new Error(`You cannot use navigator.forward() on the server because it is a stateless ` + `environment.`);
848
+ onError(error) {
849
+ console.error(`[renderToPipeableStream:onError]`, error);
917
850
  }
918
-
919
- };
920
- return /*#__PURE__*/React.createElement(reactRouterDom.Router, {
921
- basename: basename,
922
- children: children,
923
- location: location,
924
- navigationType: action,
925
- navigator: staticNavigator,
926
- static: true
927
851
  });
928
- }
929
-
930
- var StaticRouter_1 = server$1.StaticRouter = StaticRouter;
931
852
 
932
- /**
933
- * Removes all key-value entries from the list cache.
934
- *
935
- * @private
936
- * @name clear
937
- * @memberOf ListCache
938
- */
939
-
940
- function listCacheClear$1() {
941
- this.__data__ = [];
942
- this.size = 0;
943
- }
944
-
945
- var _listCacheClear = listCacheClear$1;
853
+ // Abandon and switch to client rendering if enough time passes.
854
+ // Try lowering this to see the client recover.
855
+ setTimeout(() => abort(), 30 * 1000);
856
+ stream === null || stream === void 0 || stream.pipe(response);
857
+ };
946
858
 
947
859
  /**
948
- * Performs a
949
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
950
- * comparison between two values to determine if they are equivalent.
951
- *
952
- * @static
953
- * @memberOf _
954
- * @since 4.0.0
955
- * @category Lang
956
- * @param {*} value The value to compare.
957
- * @param {*} other The other value to compare.
958
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
959
- * @example
960
- *
961
- * var object = { 'a': 1 };
962
- * var other = { 'a': 1 };
963
- *
964
- * _.eq(object, object);
965
- * // => true
966
- *
967
- * _.eq(object, other);
968
- * // => false
969
- *
970
- * _.eq('a', 'a');
971
- * // => true
972
- *
973
- * _.eq('a', Object('a'));
974
- * // => false
975
- *
976
- * _.eq(NaN, NaN);
977
- * // => true
978
- */
979
-
980
- function eq$2(value, other) {
981
- return value === other || (value !== value && other !== other);
982
- }
983
-
984
- var eq_1 = eq$2;
985
-
986
- var eq$1 = eq_1;
860
+ * Generate and add styled-components CSS to the streamed
861
+ * chunks of rendered HTML via renderToPipeableStream
862
+ *
863
+ * Workaround for Styled Components issue: React 18 Streaming SSR #3658
864
+ * https://github.com/styled-components/styled-components/issues/3658#issuecomment-2480721193
865
+ * credit: https://github.com/rurquia/styled-components-ssr-3658/blob/main/server/render.js
866
+ * @param sheet styled-components ServerStyleSheet
867
+ * @returns Transform Stream
868
+ */
869
+ const styledComponentsStream = sheet => {
870
+ const readerWriter = new stream.Transform({
871
+ objectMode: true,
872
+ transform(chunk, /* encoding */
873
+ _, callback) {
874
+ // Get the chunk and retrieve the sheet's CSS as an HTML chunk,
875
+ // then reset its rules so we get only new ones for the next chunk
876
+ const renderedHtml = typeof chunk === 'string' ? chunk : new TextDecoder().decode(chunk);
877
+ const styledCSS = sheet._emitSheetCSS();
878
+ const CLOSING_TAG_R = /<\/[a-z]*>/i;
879
+ sheet.instance.clearTag();
880
+
881
+ // prepend style html to chunk, unless the start of the chunk is a
882
+ // closing tag in which case append right after that
883
+ if (/<\/head>/.test(renderedHtml)) {
884
+ const replacedHtml = renderedHtml.replace('</head>', `${styledCSS}</head>`);
885
+ this.push(replacedHtml);
886
+ } else if (CLOSING_TAG_R.test(renderedHtml)) {
887
+ const execResult = CLOSING_TAG_R.exec(renderedHtml);
888
+ const endOfClosingTag = execResult.index + execResult.flat().length - 1;
889
+ const before = renderedHtml.slice(0, endOfClosingTag);
890
+ const after = renderedHtml.slice(endOfClosingTag);
891
+ this.push(before + styledCSS + after);
892
+ } else {
893
+ this.push(styledCSS + renderedHtml);
894
+ }
895
+ callback();
896
+ }
897
+ });
898
+ return readerWriter;
899
+ };
987
900
 
988
- /**
989
- * Gets the index at which the `key` is found in `array` of key-value pairs.
990
- *
991
- * @private
992
- * @param {Array} array The array to inspect.
993
- * @param {*} key The key to search for.
994
- * @returns {number} Returns the index of the matched value, else `-1`.
995
- */
996
- function assocIndexOf$4(array, key) {
997
- var length = array.length;
998
- while (length--) {
999
- if (eq$1(array[length][0], key)) {
1000
- return length;
901
+ const readFileSync = path => fs__default.default.readFileSync(path, 'utf8');
902
+ const loadableBundleData = ({
903
+ stats,
904
+ templates
905
+ }, staticRoutePath, build) => {
906
+ const bundle = {};
907
+ try {
908
+ bundle.stats = stats ? JSON.parse(readFileSync(stats.replace('/target', build ? `/${build}` : ''))) : null;
909
+ } catch (ex) {
910
+ // console.info(ex);
911
+ bundle.stats = null;
912
+ }
913
+ try {
914
+ bundle.templates = {
915
+ templateHTML: replaceStaticPath(readFileSync(templates.html.replace('/target', build ? `/${build}` : '')), staticRoutePath),
916
+ templateHTMLStatic: replaceStaticPath(readFileSync(templates.static.replace('/target', build ? `/${build}` : '')), staticRoutePath),
917
+ templateHTMLFragment: replaceStaticPath(readFileSync(templates.fragment.replace('/target', build ? `/${build}` : '')), staticRoutePath)
918
+ };
919
+ } catch (ex) {
920
+ // console.info(ex);
921
+ bundle.templates = null;
922
+ }
923
+ return bundle;
924
+ };
925
+ const loadableChunkExtractors = () => {
926
+ const commonLoadableExtractor = new server$2.ChunkExtractor({
927
+ stats: {}
928
+ });
929
+ try {
930
+ let modern;
931
+ let legacy;
932
+ try {
933
+ modern = new server$2.ChunkExtractor({
934
+ entrypoints: ['app'],
935
+ namespace: 'modern',
936
+ statsFile: path__default.default.resolve('dist/modern/loadable-stats.json')
937
+ });
938
+ } catch (e) {
939
+ console.info('@loadable/server modern ChunkExtractor not available');
1001
940
  }
941
+ try {
942
+ legacy = new server$2.ChunkExtractor({
943
+ entrypoints: ['app'],
944
+ namespace: 'legacy',
945
+ statsFile: path__default.default.resolve('dist/legacy/loadable-stats.json')
946
+ });
947
+ } catch (e) {
948
+ // legacy bundling deprecated in v4
949
+ // console.info('@loadable/server legacy ChunkExtractor not available');
950
+ }
951
+ commonLoadableExtractor.addChunk = chunk => {
952
+ var _modern, _legacy, _legacy2;
953
+ (_modern = modern) === null || _modern === void 0 || _modern.addChunk(chunk);
954
+ if (typeof ((_legacy = legacy) === null || _legacy === void 0 ? void 0 : _legacy.stats.assetsByChunkName[chunk]) !== 'undefined') (_legacy2 = legacy) === null || _legacy2 === void 0 || _legacy2.addChunk(chunk);
955
+ };
956
+ return {
957
+ commonLoadableExtractor,
958
+ modern,
959
+ legacy
960
+ };
961
+ } catch (e) {
962
+ console.info('@loadable/server no ChunkExtractor available');
963
+ return {
964
+ commonLoadableExtractor
965
+ };
1002
966
  }
1003
- return -1;
1004
- }
1005
-
1006
- var _assocIndexOf = assocIndexOf$4;
1007
-
1008
- var assocIndexOf$3 = _assocIndexOf;
967
+ };
968
+ const getBundleData = (config, staticRoutePath) => {
969
+ const bundleData = {
970
+ default: loadableBundleData(config, staticRoutePath),
971
+ legacy: loadableBundleData(config, staticRoutePath, 'legacy'),
972
+ modern: loadableBundleData(config, staticRoutePath, 'modern')
973
+ };
974
+ if (!bundleData.default || Object.keys(bundleData.default || {}).length === 0) bundleData.default = bundleData.legacy || bundleData.modern;
975
+ return bundleData;
976
+ };
1009
977
 
1010
- /** Used for built-in method references. */
1011
- var arrayProto = Array.prototype;
978
+ // export const buildBundleTags = (
979
+ // bundles,
980
+ // differentialBundles = false,
981
+ // staticRoutePath = 'static',
982
+ // attributes = ''
983
+ // ) => {
984
+ // // Take the bundles returned from Loadable.Capture
985
+ // const bundleTags = bundles
986
+ // .filter(b => b)
987
+ // .map(bundle => {
988
+ // if (bundle.publicPath.includes('/modern/'))
989
+ // return differentialBundles
990
+ // ? `<script ${attributes} type="module" src="${replaceStaticPath(
991
+ // bundle.publicPath,
992
+ // staticRoutePath
993
+ // )}"></script>`
994
+ // : null;
995
+ // return `<script ${attributes}${
996
+ // differentialBundles ? ' nomodule' : ''
997
+ // } src="${replaceStaticPath(
998
+ // bundle.publicPath,
999
+ // staticRoutePath
1000
+ // )}"></script>`;
1001
+ // })
1002
+ // .filter(f => f);
1012
1003
 
1013
- /** Built-in value references. */
1014
- var splice = arrayProto.splice;
1004
+ // return bundleTags;
1005
+ // };
1015
1006
 
1016
- /**
1017
- * Removes `key` and its value from the list cache.
1018
- *
1019
- * @private
1020
- * @name delete
1021
- * @memberOf ListCache
1022
- * @param {string} key The key of the value to remove.
1023
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1024
- */
1025
- function listCacheDelete$1(key) {
1026
- var data = this.__data__,
1027
- index = assocIndexOf$3(data, key);
1028
-
1029
- if (index < 0) {
1030
- return false;
1031
- }
1032
- var lastIndex = data.length - 1;
1033
- if (index == lastIndex) {
1034
- data.pop();
1035
- } else {
1036
- splice.call(data, index, 1);
1037
- }
1038
- --this.size;
1039
- return true;
1040
- }
1041
-
1042
- var _listCacheDelete = listCacheDelete$1;
1043
-
1044
- var assocIndexOf$2 = _assocIndexOf;
1045
-
1046
- /**
1047
- * Gets the list cache value for `key`.
1048
- *
1049
- * @private
1050
- * @name get
1051
- * @memberOf ListCache
1052
- * @param {string} key The key of the value to get.
1053
- * @returns {*} Returns the entry value.
1054
- */
1055
- function listCacheGet$1(key) {
1056
- var data = this.__data__,
1057
- index = assocIndexOf$2(data, key);
1058
-
1059
- return index < 0 ? undefined : data[index][1];
1060
- }
1061
-
1062
- var _listCacheGet = listCacheGet$1;
1063
-
1064
- var assocIndexOf$1 = _assocIndexOf;
1065
-
1066
- /**
1067
- * Checks if a list cache value for `key` exists.
1068
- *
1069
- * @private
1070
- * @name has
1071
- * @memberOf ListCache
1072
- * @param {string} key The key of the entry to check.
1073
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1074
- */
1075
- function listCacheHas$1(key) {
1076
- return assocIndexOf$1(this.__data__, key) > -1;
1077
- }
1078
-
1079
- var _listCacheHas = listCacheHas$1;
1080
-
1081
- var assocIndexOf = _assocIndexOf;
1082
-
1083
- /**
1084
- * Sets the list cache `key` to `value`.
1085
- *
1086
- * @private
1087
- * @name set
1088
- * @memberOf ListCache
1089
- * @param {string} key The key of the value to set.
1090
- * @param {*} value The value to set.
1091
- * @returns {Object} Returns the list cache instance.
1092
- */
1093
- function listCacheSet$1(key, value) {
1094
- var data = this.__data__,
1095
- index = assocIndexOf(data, key);
1096
-
1097
- if (index < 0) {
1098
- ++this.size;
1099
- data.push([key, value]);
1100
- } else {
1101
- data[index][1] = value;
1102
- }
1103
- return this;
1104
- }
1105
-
1106
- var _listCacheSet = listCacheSet$1;
1107
-
1108
- var listCacheClear = _listCacheClear,
1109
- listCacheDelete = _listCacheDelete,
1110
- listCacheGet = _listCacheGet,
1111
- listCacheHas = _listCacheHas,
1112
- listCacheSet = _listCacheSet;
1113
-
1114
- /**
1115
- * Creates an list cache object.
1116
- *
1117
- * @private
1118
- * @constructor
1119
- * @param {Array} [entries] The key-value pairs to cache.
1120
- */
1121
- function ListCache$4(entries) {
1122
- var index = -1,
1123
- length = entries == null ? 0 : entries.length;
1124
-
1125
- this.clear();
1126
- while (++index < length) {
1127
- var entry = entries[index];
1128
- this.set(entry[0], entry[1]);
1129
- }
1130
- }
1131
-
1132
- // Add methods to `ListCache`.
1133
- ListCache$4.prototype.clear = listCacheClear;
1134
- ListCache$4.prototype['delete'] = listCacheDelete;
1135
- ListCache$4.prototype.get = listCacheGet;
1136
- ListCache$4.prototype.has = listCacheHas;
1137
- ListCache$4.prototype.set = listCacheSet;
1138
-
1139
- var _ListCache = ListCache$4;
1140
-
1141
- var ListCache$3 = _ListCache;
1142
-
1143
- /**
1144
- * Removes all key-value entries from the stack.
1145
- *
1146
- * @private
1147
- * @name clear
1148
- * @memberOf Stack
1149
- */
1150
- function stackClear$1() {
1151
- this.__data__ = new ListCache$3;
1152
- this.size = 0;
1153
- }
1154
-
1155
- var _stackClear = stackClear$1;
1156
-
1157
- /**
1158
- * Removes `key` and its value from the stack.
1159
- *
1160
- * @private
1161
- * @name delete
1162
- * @memberOf Stack
1163
- * @param {string} key The key of the value to remove.
1164
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1165
- */
1166
-
1167
- function stackDelete$1(key) {
1168
- var data = this.__data__,
1169
- result = data['delete'](key);
1170
-
1171
- this.size = data.size;
1172
- return result;
1173
- }
1174
-
1175
- var _stackDelete = stackDelete$1;
1176
-
1177
- /**
1178
- * Gets the stack value for `key`.
1179
- *
1180
- * @private
1181
- * @name get
1182
- * @memberOf Stack
1183
- * @param {string} key The key of the value to get.
1184
- * @returns {*} Returns the entry value.
1185
- */
1186
-
1187
- function stackGet$1(key) {
1188
- return this.__data__.get(key);
1189
- }
1190
-
1191
- var _stackGet = stackGet$1;
1192
-
1193
- /**
1194
- * Checks if a stack value for `key` exists.
1195
- *
1196
- * @private
1197
- * @name has
1198
- * @memberOf Stack
1199
- * @param {string} key The key of the entry to check.
1200
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1201
- */
1202
-
1203
- function stackHas$1(key) {
1204
- return this.__data__.has(key);
1205
- }
1206
-
1207
- var _stackHas = stackHas$1;
1208
-
1209
- /** Detect free variable `global` from Node.js. */
1210
-
1211
- var freeGlobal$1 = typeof _commonjsHelpers.commonjsGlobal == 'object' && _commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.Object === Object && _commonjsHelpers.commonjsGlobal;
1212
-
1213
- var _freeGlobal = freeGlobal$1;
1214
-
1215
- var freeGlobal = _freeGlobal;
1216
-
1217
- /** Detect free variable `self`. */
1218
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
1219
-
1220
- /** Used as a reference to the global object. */
1221
- var root$8 = freeGlobal || freeSelf || Function('return this')();
1222
-
1223
- var _root = root$8;
1224
-
1225
- var root$7 = _root;
1226
-
1227
- /** Built-in value references. */
1228
- var Symbol$3 = root$7.Symbol;
1229
-
1230
- var _Symbol = Symbol$3;
1231
-
1232
- var Symbol$2 = _Symbol;
1233
-
1234
- /** Used for built-in method references. */
1235
- var objectProto$c = Object.prototype;
1236
-
1237
- /** Used to check objects for own properties. */
1238
- var hasOwnProperty$9 = objectProto$c.hasOwnProperty;
1239
-
1240
- /**
1241
- * Used to resolve the
1242
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1243
- * of values.
1244
- */
1245
- var nativeObjectToString$1 = objectProto$c.toString;
1246
-
1247
- /** Built-in value references. */
1248
- var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : undefined;
1249
-
1250
- /**
1251
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
1252
- *
1253
- * @private
1254
- * @param {*} value The value to query.
1255
- * @returns {string} Returns the raw `toStringTag`.
1256
- */
1257
- function getRawTag$1(value) {
1258
- var isOwn = hasOwnProperty$9.call(value, symToStringTag$1),
1259
- tag = value[symToStringTag$1];
1260
-
1261
- try {
1262
- value[symToStringTag$1] = undefined;
1263
- var unmasked = true;
1264
- } catch (e) {}
1265
-
1266
- var result = nativeObjectToString$1.call(value);
1267
- if (unmasked) {
1268
- if (isOwn) {
1269
- value[symToStringTag$1] = tag;
1270
- } else {
1271
- delete value[symToStringTag$1];
1272
- }
1273
- }
1274
- return result;
1275
- }
1276
-
1277
- var _getRawTag = getRawTag$1;
1278
-
1279
- /** Used for built-in method references. */
1280
-
1281
- var objectProto$b = Object.prototype;
1282
-
1283
- /**
1284
- * Used to resolve the
1285
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1286
- * of values.
1287
- */
1288
- var nativeObjectToString = objectProto$b.toString;
1289
-
1290
- /**
1291
- * Converts `value` to a string using `Object.prototype.toString`.
1292
- *
1293
- * @private
1294
- * @param {*} value The value to convert.
1295
- * @returns {string} Returns the converted string.
1296
- */
1297
- function objectToString$1(value) {
1298
- return nativeObjectToString.call(value);
1299
- }
1300
-
1301
- var _objectToString = objectToString$1;
1302
-
1303
- var Symbol$1 = _Symbol,
1304
- getRawTag = _getRawTag,
1305
- objectToString = _objectToString;
1306
-
1307
- /** `Object#toString` result references. */
1308
- var nullTag = '[object Null]',
1309
- undefinedTag = '[object Undefined]';
1310
-
1311
- /** Built-in value references. */
1312
- var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
1313
-
1314
- /**
1315
- * The base implementation of `getTag` without fallbacks for buggy environments.
1316
- *
1317
- * @private
1318
- * @param {*} value The value to query.
1319
- * @returns {string} Returns the `toStringTag`.
1320
- */
1321
- function baseGetTag$4(value) {
1322
- if (value == null) {
1323
- return value === undefined ? undefinedTag : nullTag;
1324
- }
1325
- return (symToStringTag && symToStringTag in Object(value))
1326
- ? getRawTag(value)
1327
- : objectToString(value);
1328
- }
1329
-
1330
- var _baseGetTag = baseGetTag$4;
1331
-
1332
- /**
1333
- * Checks if `value` is the
1334
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
1335
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
1336
- *
1337
- * @static
1338
- * @memberOf _
1339
- * @since 0.1.0
1340
- * @category Lang
1341
- * @param {*} value The value to check.
1342
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
1343
- * @example
1344
- *
1345
- * _.isObject({});
1346
- * // => true
1347
- *
1348
- * _.isObject([1, 2, 3]);
1349
- * // => true
1350
- *
1351
- * _.isObject(_.noop);
1352
- * // => true
1353
- *
1354
- * _.isObject(null);
1355
- * // => false
1356
- */
1357
-
1358
- function isObject$5(value) {
1359
- var type = typeof value;
1360
- return value != null && (type == 'object' || type == 'function');
1361
- }
1362
-
1363
- var isObject_1 = isObject$5;
1364
-
1365
- var baseGetTag$3 = _baseGetTag,
1366
- isObject$4 = isObject_1;
1367
-
1368
- /** `Object#toString` result references. */
1369
- var asyncTag = '[object AsyncFunction]',
1370
- funcTag$2 = '[object Function]',
1371
- genTag$1 = '[object GeneratorFunction]',
1372
- proxyTag = '[object Proxy]';
1373
-
1374
- /**
1375
- * Checks if `value` is classified as a `Function` object.
1376
- *
1377
- * @static
1378
- * @memberOf _
1379
- * @since 0.1.0
1380
- * @category Lang
1381
- * @param {*} value The value to check.
1382
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
1383
- * @example
1384
- *
1385
- * _.isFunction(_);
1386
- * // => true
1387
- *
1388
- * _.isFunction(/abc/);
1389
- * // => false
1390
- */
1391
- function isFunction$2(value) {
1392
- if (!isObject$4(value)) {
1393
- return false;
1394
- }
1395
- // The use of `Object#toString` avoids issues with the `typeof` operator
1396
- // in Safari 9 which returns 'object' for typed arrays and other constructors.
1397
- var tag = baseGetTag$3(value);
1398
- return tag == funcTag$2 || tag == genTag$1 || tag == asyncTag || tag == proxyTag;
1399
- }
1400
-
1401
- var isFunction_1 = isFunction$2;
1402
-
1403
- var root$6 = _root;
1404
-
1405
- /** Used to detect overreaching core-js shims. */
1406
- var coreJsData$1 = root$6['__core-js_shared__'];
1407
-
1408
- var _coreJsData = coreJsData$1;
1409
-
1410
- var coreJsData = _coreJsData;
1411
-
1412
- /** Used to detect methods masquerading as native. */
1413
- var maskSrcKey = (function() {
1414
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
1415
- return uid ? ('Symbol(src)_1.' + uid) : '';
1416
- }());
1417
-
1418
- /**
1419
- * Checks if `func` has its source masked.
1420
- *
1421
- * @private
1422
- * @param {Function} func The function to check.
1423
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
1424
- */
1425
- function isMasked$1(func) {
1426
- return !!maskSrcKey && (maskSrcKey in func);
1427
- }
1428
-
1429
- var _isMasked = isMasked$1;
1430
-
1431
- /** Used for built-in method references. */
1432
-
1433
- var funcProto$1 = Function.prototype;
1434
-
1435
- /** Used to resolve the decompiled source of functions. */
1436
- var funcToString$1 = funcProto$1.toString;
1437
-
1438
- /**
1439
- * Converts `func` to its source code.
1440
- *
1441
- * @private
1442
- * @param {Function} func The function to convert.
1443
- * @returns {string} Returns the source code.
1444
- */
1445
- function toSource$2(func) {
1446
- if (func != null) {
1447
- try {
1448
- return funcToString$1.call(func);
1449
- } catch (e) {}
1450
- try {
1451
- return (func + '');
1452
- } catch (e) {}
1453
- }
1454
- return '';
1455
- }
1456
-
1457
- var _toSource = toSource$2;
1458
-
1459
- var isFunction$1 = isFunction_1,
1460
- isMasked = _isMasked,
1461
- isObject$3 = isObject_1,
1462
- toSource$1 = _toSource;
1463
-
1464
- /**
1465
- * Used to match `RegExp`
1466
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
1467
- */
1468
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
1469
-
1470
- /** Used to detect host constructors (Safari). */
1471
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
1472
-
1473
- /** Used for built-in method references. */
1474
- var funcProto = Function.prototype,
1475
- objectProto$a = Object.prototype;
1476
-
1477
- /** Used to resolve the decompiled source of functions. */
1478
- var funcToString = funcProto.toString;
1479
-
1480
- /** Used to check objects for own properties. */
1481
- var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
1482
-
1483
- /** Used to detect if a method is native. */
1484
- var reIsNative = RegExp('^' +
1485
- funcToString.call(hasOwnProperty$8).replace(reRegExpChar, '\\$&')
1486
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
1487
- );
1488
-
1489
- /**
1490
- * The base implementation of `_.isNative` without bad shim checks.
1491
- *
1492
- * @private
1493
- * @param {*} value The value to check.
1494
- * @returns {boolean} Returns `true` if `value` is a native function,
1495
- * else `false`.
1496
- */
1497
- function baseIsNative$1(value) {
1498
- if (!isObject$3(value) || isMasked(value)) {
1499
- return false;
1500
- }
1501
- var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
1502
- return pattern.test(toSource$1(value));
1503
- }
1504
-
1505
- var _baseIsNative = baseIsNative$1;
1506
-
1507
- /**
1508
- * Gets the value at `key` of `object`.
1509
- *
1510
- * @private
1511
- * @param {Object} [object] The object to query.
1512
- * @param {string} key The key of the property to get.
1513
- * @returns {*} Returns the property value.
1514
- */
1515
-
1516
- function getValue$1(object, key) {
1517
- return object == null ? undefined : object[key];
1518
- }
1519
-
1520
- var _getValue = getValue$1;
1521
-
1522
- var baseIsNative = _baseIsNative,
1523
- getValue = _getValue;
1524
-
1525
- /**
1526
- * Gets the native function at `key` of `object`.
1527
- *
1528
- * @private
1529
- * @param {Object} object The object to query.
1530
- * @param {string} key The key of the method to get.
1531
- * @returns {*} Returns the function if it's native, else `undefined`.
1532
- */
1533
- function getNative$7(object, key) {
1534
- var value = getValue(object, key);
1535
- return baseIsNative(value) ? value : undefined;
1536
- }
1537
-
1538
- var _getNative = getNative$7;
1539
-
1540
- var getNative$6 = _getNative,
1541
- root$5 = _root;
1542
-
1543
- /* Built-in method references that are verified to be native. */
1544
- var Map$3 = getNative$6(root$5, 'Map');
1545
-
1546
- var _Map = Map$3;
1547
-
1548
- var getNative$5 = _getNative;
1549
-
1550
- /* Built-in method references that are verified to be native. */
1551
- var nativeCreate$4 = getNative$5(Object, 'create');
1552
-
1553
- var _nativeCreate = nativeCreate$4;
1554
-
1555
- var nativeCreate$3 = _nativeCreate;
1556
-
1557
- /**
1558
- * Removes all key-value entries from the hash.
1559
- *
1560
- * @private
1561
- * @name clear
1562
- * @memberOf Hash
1563
- */
1564
- function hashClear$1() {
1565
- this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
1566
- this.size = 0;
1567
- }
1568
-
1569
- var _hashClear = hashClear$1;
1570
-
1571
- /**
1572
- * Removes `key` and its value from the hash.
1573
- *
1574
- * @private
1575
- * @name delete
1576
- * @memberOf Hash
1577
- * @param {Object} hash The hash to modify.
1578
- * @param {string} key The key of the value to remove.
1579
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1580
- */
1581
-
1582
- function hashDelete$1(key) {
1583
- var result = this.has(key) && delete this.__data__[key];
1584
- this.size -= result ? 1 : 0;
1585
- return result;
1586
- }
1587
-
1588
- var _hashDelete = hashDelete$1;
1589
-
1590
- var nativeCreate$2 = _nativeCreate;
1591
-
1592
- /** Used to stand-in for `undefined` hash values. */
1593
- var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
1594
-
1595
- /** Used for built-in method references. */
1596
- var objectProto$9 = Object.prototype;
1597
-
1598
- /** Used to check objects for own properties. */
1599
- var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
1600
-
1601
- /**
1602
- * Gets the hash value for `key`.
1603
- *
1604
- * @private
1605
- * @name get
1606
- * @memberOf Hash
1607
- * @param {string} key The key of the value to get.
1608
- * @returns {*} Returns the entry value.
1609
- */
1610
- function hashGet$1(key) {
1611
- var data = this.__data__;
1612
- if (nativeCreate$2) {
1613
- var result = data[key];
1614
- return result === HASH_UNDEFINED$1 ? undefined : result;
1615
- }
1616
- return hasOwnProperty$7.call(data, key) ? data[key] : undefined;
1617
- }
1618
-
1619
- var _hashGet = hashGet$1;
1620
-
1621
- var nativeCreate$1 = _nativeCreate;
1622
-
1623
- /** Used for built-in method references. */
1624
- var objectProto$8 = Object.prototype;
1625
-
1626
- /** Used to check objects for own properties. */
1627
- var hasOwnProperty$6 = objectProto$8.hasOwnProperty;
1628
-
1629
- /**
1630
- * Checks if a hash value for `key` exists.
1631
- *
1632
- * @private
1633
- * @name has
1634
- * @memberOf Hash
1635
- * @param {string} key The key of the entry to check.
1636
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1637
- */
1638
- function hashHas$1(key) {
1639
- var data = this.__data__;
1640
- return nativeCreate$1 ? (data[key] !== undefined) : hasOwnProperty$6.call(data, key);
1641
- }
1642
-
1643
- var _hashHas = hashHas$1;
1644
-
1645
- var nativeCreate = _nativeCreate;
1646
-
1647
- /** Used to stand-in for `undefined` hash values. */
1648
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
1649
-
1650
- /**
1651
- * Sets the hash `key` to `value`.
1652
- *
1653
- * @private
1654
- * @name set
1655
- * @memberOf Hash
1656
- * @param {string} key The key of the value to set.
1657
- * @param {*} value The value to set.
1658
- * @returns {Object} Returns the hash instance.
1659
- */
1660
- function hashSet$1(key, value) {
1661
- var data = this.__data__;
1662
- this.size += this.has(key) ? 0 : 1;
1663
- data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
1664
- return this;
1665
- }
1666
-
1667
- var _hashSet = hashSet$1;
1668
-
1669
- var hashClear = _hashClear,
1670
- hashDelete = _hashDelete,
1671
- hashGet = _hashGet,
1672
- hashHas = _hashHas,
1673
- hashSet = _hashSet;
1674
-
1675
- /**
1676
- * Creates a hash object.
1677
- *
1678
- * @private
1679
- * @constructor
1680
- * @param {Array} [entries] The key-value pairs to cache.
1681
- */
1682
- function Hash$1(entries) {
1683
- var index = -1,
1684
- length = entries == null ? 0 : entries.length;
1685
-
1686
- this.clear();
1687
- while (++index < length) {
1688
- var entry = entries[index];
1689
- this.set(entry[0], entry[1]);
1690
- }
1691
- }
1692
-
1693
- // Add methods to `Hash`.
1694
- Hash$1.prototype.clear = hashClear;
1695
- Hash$1.prototype['delete'] = hashDelete;
1696
- Hash$1.prototype.get = hashGet;
1697
- Hash$1.prototype.has = hashHas;
1698
- Hash$1.prototype.set = hashSet;
1699
-
1700
- var _Hash = Hash$1;
1701
-
1702
- var Hash = _Hash,
1703
- ListCache$2 = _ListCache,
1704
- Map$2 = _Map;
1705
-
1706
- /**
1707
- * Removes all key-value entries from the map.
1708
- *
1709
- * @private
1710
- * @name clear
1711
- * @memberOf MapCache
1712
- */
1713
- function mapCacheClear$1() {
1714
- this.size = 0;
1715
- this.__data__ = {
1716
- 'hash': new Hash,
1717
- 'map': new (Map$2 || ListCache$2),
1718
- 'string': new Hash
1719
- };
1720
- }
1721
-
1722
- var _mapCacheClear = mapCacheClear$1;
1723
-
1724
- /**
1725
- * Checks if `value` is suitable for use as unique object key.
1726
- *
1727
- * @private
1728
- * @param {*} value The value to check.
1729
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1730
- */
1731
-
1732
- function isKeyable$1(value) {
1733
- var type = typeof value;
1734
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1735
- ? (value !== '__proto__')
1736
- : (value === null);
1737
- }
1738
-
1739
- var _isKeyable = isKeyable$1;
1740
-
1741
- var isKeyable = _isKeyable;
1742
-
1743
- /**
1744
- * Gets the data for `map`.
1745
- *
1746
- * @private
1747
- * @param {Object} map The map to query.
1748
- * @param {string} key The reference key.
1749
- * @returns {*} Returns the map data.
1750
- */
1751
- function getMapData$4(map, key) {
1752
- var data = map.__data__;
1753
- return isKeyable(key)
1754
- ? data[typeof key == 'string' ? 'string' : 'hash']
1755
- : data.map;
1756
- }
1757
-
1758
- var _getMapData = getMapData$4;
1759
-
1760
- var getMapData$3 = _getMapData;
1761
-
1762
- /**
1763
- * Removes `key` and its value from the map.
1764
- *
1765
- * @private
1766
- * @name delete
1767
- * @memberOf MapCache
1768
- * @param {string} key The key of the value to remove.
1769
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1770
- */
1771
- function mapCacheDelete$1(key) {
1772
- var result = getMapData$3(this, key)['delete'](key);
1773
- this.size -= result ? 1 : 0;
1774
- return result;
1775
- }
1776
-
1777
- var _mapCacheDelete = mapCacheDelete$1;
1778
-
1779
- var getMapData$2 = _getMapData;
1780
-
1781
- /**
1782
- * Gets the map value for `key`.
1783
- *
1784
- * @private
1785
- * @name get
1786
- * @memberOf MapCache
1787
- * @param {string} key The key of the value to get.
1788
- * @returns {*} Returns the entry value.
1789
- */
1790
- function mapCacheGet$1(key) {
1791
- return getMapData$2(this, key).get(key);
1792
- }
1793
-
1794
- var _mapCacheGet = mapCacheGet$1;
1795
-
1796
- var getMapData$1 = _getMapData;
1797
-
1798
- /**
1799
- * Checks if a map value for `key` exists.
1800
- *
1801
- * @private
1802
- * @name has
1803
- * @memberOf MapCache
1804
- * @param {string} key The key of the entry to check.
1805
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1806
- */
1807
- function mapCacheHas$1(key) {
1808
- return getMapData$1(this, key).has(key);
1809
- }
1810
-
1811
- var _mapCacheHas = mapCacheHas$1;
1812
-
1813
- var getMapData = _getMapData;
1814
-
1815
- /**
1816
- * Sets the map `key` to `value`.
1817
- *
1818
- * @private
1819
- * @name set
1820
- * @memberOf MapCache
1821
- * @param {string} key The key of the value to set.
1822
- * @param {*} value The value to set.
1823
- * @returns {Object} Returns the map cache instance.
1824
- */
1825
- function mapCacheSet$1(key, value) {
1826
- var data = getMapData(this, key),
1827
- size = data.size;
1828
-
1829
- data.set(key, value);
1830
- this.size += data.size == size ? 0 : 1;
1831
- return this;
1832
- }
1833
-
1834
- var _mapCacheSet = mapCacheSet$1;
1835
-
1836
- var mapCacheClear = _mapCacheClear,
1837
- mapCacheDelete = _mapCacheDelete,
1838
- mapCacheGet = _mapCacheGet,
1839
- mapCacheHas = _mapCacheHas,
1840
- mapCacheSet = _mapCacheSet;
1841
-
1842
- /**
1843
- * Creates a map cache object to store key-value pairs.
1844
- *
1845
- * @private
1846
- * @constructor
1847
- * @param {Array} [entries] The key-value pairs to cache.
1848
- */
1849
- function MapCache$1(entries) {
1850
- var index = -1,
1851
- length = entries == null ? 0 : entries.length;
1852
-
1853
- this.clear();
1854
- while (++index < length) {
1855
- var entry = entries[index];
1856
- this.set(entry[0], entry[1]);
1857
- }
1858
- }
1859
-
1860
- // Add methods to `MapCache`.
1861
- MapCache$1.prototype.clear = mapCacheClear;
1862
- MapCache$1.prototype['delete'] = mapCacheDelete;
1863
- MapCache$1.prototype.get = mapCacheGet;
1864
- MapCache$1.prototype.has = mapCacheHas;
1865
- MapCache$1.prototype.set = mapCacheSet;
1866
-
1867
- var _MapCache = MapCache$1;
1868
-
1869
- var ListCache$1 = _ListCache,
1870
- Map$1 = _Map,
1871
- MapCache = _MapCache;
1872
-
1873
- /** Used as the size to enable large array optimizations. */
1874
- var LARGE_ARRAY_SIZE = 200;
1875
-
1876
- /**
1877
- * Sets the stack `key` to `value`.
1878
- *
1879
- * @private
1880
- * @name set
1881
- * @memberOf Stack
1882
- * @param {string} key The key of the value to set.
1883
- * @param {*} value The value to set.
1884
- * @returns {Object} Returns the stack cache instance.
1885
- */
1886
- function stackSet$1(key, value) {
1887
- var data = this.__data__;
1888
- if (data instanceof ListCache$1) {
1889
- var pairs = data.__data__;
1890
- if (!Map$1 || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
1891
- pairs.push([key, value]);
1892
- this.size = ++data.size;
1893
- return this;
1894
- }
1895
- data = this.__data__ = new MapCache(pairs);
1896
- }
1897
- data.set(key, value);
1898
- this.size = data.size;
1899
- return this;
1900
- }
1901
-
1902
- var _stackSet = stackSet$1;
1903
-
1904
- var ListCache = _ListCache,
1905
- stackClear = _stackClear,
1906
- stackDelete = _stackDelete,
1907
- stackGet = _stackGet,
1908
- stackHas = _stackHas,
1909
- stackSet = _stackSet;
1910
-
1911
- /**
1912
- * Creates a stack cache object to store key-value pairs.
1913
- *
1914
- * @private
1915
- * @constructor
1916
- * @param {Array} [entries] The key-value pairs to cache.
1917
- */
1918
- function Stack$1(entries) {
1919
- var data = this.__data__ = new ListCache(entries);
1920
- this.size = data.size;
1921
- }
1922
-
1923
- // Add methods to `Stack`.
1924
- Stack$1.prototype.clear = stackClear;
1925
- Stack$1.prototype['delete'] = stackDelete;
1926
- Stack$1.prototype.get = stackGet;
1927
- Stack$1.prototype.has = stackHas;
1928
- Stack$1.prototype.set = stackSet;
1929
-
1930
- var _Stack = Stack$1;
1931
-
1932
- /**
1933
- * A specialized version of `_.forEach` for arrays without support for
1934
- * iteratee shorthands.
1935
- *
1936
- * @private
1937
- * @param {Array} [array] The array to iterate over.
1938
- * @param {Function} iteratee The function invoked per iteration.
1939
- * @returns {Array} Returns `array`.
1940
- */
1941
-
1942
- function arrayEach$1(array, iteratee) {
1943
- var index = -1,
1944
- length = array == null ? 0 : array.length;
1945
-
1946
- while (++index < length) {
1947
- if (iteratee(array[index], index, array) === false) {
1948
- break;
1949
- }
1950
- }
1951
- return array;
1952
- }
1953
-
1954
- var _arrayEach = arrayEach$1;
1955
-
1956
- var getNative$4 = _getNative;
1957
-
1958
- var defineProperty$1 = (function() {
1959
- try {
1960
- var func = getNative$4(Object, 'defineProperty');
1961
- func({}, '', {});
1962
- return func;
1963
- } catch (e) {}
1964
- }());
1965
-
1966
- var _defineProperty = defineProperty$1;
1967
-
1968
- var defineProperty = _defineProperty;
1969
-
1970
- /**
1971
- * The base implementation of `assignValue` and `assignMergeValue` without
1972
- * value checks.
1973
- *
1974
- * @private
1975
- * @param {Object} object The object to modify.
1976
- * @param {string} key The key of the property to assign.
1977
- * @param {*} value The value to assign.
1978
- */
1979
- function baseAssignValue$2(object, key, value) {
1980
- if (key == '__proto__' && defineProperty) {
1981
- defineProperty(object, key, {
1982
- 'configurable': true,
1983
- 'enumerable': true,
1984
- 'value': value,
1985
- 'writable': true
1986
- });
1987
- } else {
1988
- object[key] = value;
1989
- }
1990
- }
1991
-
1992
- var _baseAssignValue = baseAssignValue$2;
1993
-
1994
- var baseAssignValue$1 = _baseAssignValue,
1995
- eq = eq_1;
1996
-
1997
- /** Used for built-in method references. */
1998
- var objectProto$7 = Object.prototype;
1999
-
2000
- /** Used to check objects for own properties. */
2001
- var hasOwnProperty$5 = objectProto$7.hasOwnProperty;
2002
-
2003
- /**
2004
- * Assigns `value` to `key` of `object` if the existing value is not equivalent
2005
- * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2006
- * for equality comparisons.
2007
- *
2008
- * @private
2009
- * @param {Object} object The object to modify.
2010
- * @param {string} key The key of the property to assign.
2011
- * @param {*} value The value to assign.
2012
- */
2013
- function assignValue$2(object, key, value) {
2014
- var objValue = object[key];
2015
- if (!(hasOwnProperty$5.call(object, key) && eq(objValue, value)) ||
2016
- (value === undefined && !(key in object))) {
2017
- baseAssignValue$1(object, key, value);
2018
- }
2019
- }
2020
-
2021
- var _assignValue = assignValue$2;
2022
-
2023
- var assignValue$1 = _assignValue,
2024
- baseAssignValue = _baseAssignValue;
2025
-
2026
- /**
2027
- * Copies properties of `source` to `object`.
2028
- *
2029
- * @private
2030
- * @param {Object} source The object to copy properties from.
2031
- * @param {Array} props The property identifiers to copy.
2032
- * @param {Object} [object={}] The object to copy properties to.
2033
- * @param {Function} [customizer] The function to customize copied values.
2034
- * @returns {Object} Returns `object`.
2035
- */
2036
- function copyObject$4(source, props, object, customizer) {
2037
- var isNew = !object;
2038
- object || (object = {});
2039
-
2040
- var index = -1,
2041
- length = props.length;
2042
-
2043
- while (++index < length) {
2044
- var key = props[index];
2045
-
2046
- var newValue = customizer
2047
- ? customizer(object[key], source[key], key, object, source)
2048
- : undefined;
2049
-
2050
- if (newValue === undefined) {
2051
- newValue = source[key];
2052
- }
2053
- if (isNew) {
2054
- baseAssignValue(object, key, newValue);
2055
- } else {
2056
- assignValue$1(object, key, newValue);
2057
- }
2058
- }
2059
- return object;
2060
- }
2061
-
2062
- var _copyObject = copyObject$4;
2063
-
2064
- /**
2065
- * The base implementation of `_.times` without support for iteratee shorthands
2066
- * or max array length checks.
2067
- *
2068
- * @private
2069
- * @param {number} n The number of times to invoke `iteratee`.
2070
- * @param {Function} iteratee The function invoked per iteration.
2071
- * @returns {Array} Returns the array of results.
2072
- */
2073
-
2074
- function baseTimes$1(n, iteratee) {
2075
- var index = -1,
2076
- result = Array(n);
2077
-
2078
- while (++index < n) {
2079
- result[index] = iteratee(index);
2080
- }
2081
- return result;
2082
- }
2083
-
2084
- var _baseTimes = baseTimes$1;
2085
-
2086
- /**
2087
- * Checks if `value` is object-like. A value is object-like if it's not `null`
2088
- * and has a `typeof` result of "object".
2089
- *
2090
- * @static
2091
- * @memberOf _
2092
- * @since 4.0.0
2093
- * @category Lang
2094
- * @param {*} value The value to check.
2095
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
2096
- * @example
2097
- *
2098
- * _.isObjectLike({});
2099
- * // => true
2100
- *
2101
- * _.isObjectLike([1, 2, 3]);
2102
- * // => true
2103
- *
2104
- * _.isObjectLike(_.noop);
2105
- * // => false
2106
- *
2107
- * _.isObjectLike(null);
2108
- * // => false
2109
- */
2110
-
2111
- function isObjectLike$5(value) {
2112
- return value != null && typeof value == 'object';
2113
- }
2114
-
2115
- var isObjectLike_1 = isObjectLike$5;
2116
-
2117
- var baseGetTag$2 = _baseGetTag,
2118
- isObjectLike$4 = isObjectLike_1;
2119
-
2120
- /** `Object#toString` result references. */
2121
- var argsTag$2 = '[object Arguments]';
2122
-
2123
- /**
2124
- * The base implementation of `_.isArguments`.
2125
- *
2126
- * @private
2127
- * @param {*} value The value to check.
2128
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
2129
- */
2130
- function baseIsArguments$1(value) {
2131
- return isObjectLike$4(value) && baseGetTag$2(value) == argsTag$2;
2132
- }
2133
-
2134
- var _baseIsArguments = baseIsArguments$1;
2135
-
2136
- var baseIsArguments = _baseIsArguments,
2137
- isObjectLike$3 = isObjectLike_1;
2138
-
2139
- /** Used for built-in method references. */
2140
- var objectProto$6 = Object.prototype;
2141
-
2142
- /** Used to check objects for own properties. */
2143
- var hasOwnProperty$4 = objectProto$6.hasOwnProperty;
2144
-
2145
- /** Built-in value references. */
2146
- var propertyIsEnumerable$1 = objectProto$6.propertyIsEnumerable;
2147
-
2148
- /**
2149
- * Checks if `value` is likely an `arguments` object.
2150
- *
2151
- * @static
2152
- * @memberOf _
2153
- * @since 0.1.0
2154
- * @category Lang
2155
- * @param {*} value The value to check.
2156
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
2157
- * else `false`.
2158
- * @example
2159
- *
2160
- * _.isArguments(function() { return arguments; }());
2161
- * // => true
2162
- *
2163
- * _.isArguments([1, 2, 3]);
2164
- * // => false
2165
- */
2166
- var isArguments$1 = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
2167
- return isObjectLike$3(value) && hasOwnProperty$4.call(value, 'callee') &&
2168
- !propertyIsEnumerable$1.call(value, 'callee');
2169
- };
2170
-
2171
- var isArguments_1 = isArguments$1;
2172
-
2173
- /**
2174
- * Checks if `value` is classified as an `Array` object.
2175
- *
2176
- * @static
2177
- * @memberOf _
2178
- * @since 0.1.0
2179
- * @category Lang
2180
- * @param {*} value The value to check.
2181
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
2182
- * @example
2183
- *
2184
- * _.isArray([1, 2, 3]);
2185
- * // => true
2186
- *
2187
- * _.isArray(document.body.children);
2188
- * // => false
2189
- *
2190
- * _.isArray('abc');
2191
- * // => false
2192
- *
2193
- * _.isArray(_.noop);
2194
- * // => false
2195
- */
2196
-
2197
- var isArray$3 = Array.isArray;
2198
-
2199
- var isArray_1 = isArray$3;
2200
-
2201
- var isBuffer$2 = {exports: {}};
2202
-
2203
- /**
2204
- * This method returns `false`.
2205
- *
2206
- * @static
2207
- * @memberOf _
2208
- * @since 4.13.0
2209
- * @category Util
2210
- * @returns {boolean} Returns `false`.
2211
- * @example
2212
- *
2213
- * _.times(2, _.stubFalse);
2214
- * // => [false, false]
2215
- */
2216
-
2217
- function stubFalse() {
2218
- return false;
2219
- }
2220
-
2221
- var stubFalse_1 = stubFalse;
2222
-
2223
- (function (module, exports) {
2224
- var root = _root,
2225
- stubFalse = stubFalse_1;
2226
-
2227
- /** Detect free variable `exports`. */
2228
- var freeExports = exports && !exports.nodeType && exports;
2229
-
2230
- /** Detect free variable `module`. */
2231
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
2232
-
2233
- /** Detect the popular CommonJS extension `module.exports`. */
2234
- var moduleExports = freeModule && freeModule.exports === freeExports;
2235
-
2236
- /** Built-in value references. */
2237
- var Buffer = moduleExports ? root.Buffer : undefined;
2238
-
2239
- /* Built-in method references for those with the same name as other `lodash` methods. */
2240
- var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
2241
-
2242
- /**
2243
- * Checks if `value` is a buffer.
2244
- *
2245
- * @static
2246
- * @memberOf _
2247
- * @since 4.3.0
2248
- * @category Lang
2249
- * @param {*} value The value to check.
2250
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
2251
- * @example
2252
- *
2253
- * _.isBuffer(new Buffer(2));
2254
- * // => true
2255
- *
2256
- * _.isBuffer(new Uint8Array(2));
2257
- * // => false
2258
- */
2259
- var isBuffer = nativeIsBuffer || stubFalse;
2260
-
2261
- module.exports = isBuffer;
2262
- }(isBuffer$2, isBuffer$2.exports));
2263
-
2264
- /** Used as references for various `Number` constants. */
2265
-
2266
- var MAX_SAFE_INTEGER$1 = 9007199254740991;
2267
-
2268
- /** Used to detect unsigned integer values. */
2269
- var reIsUint = /^(?:0|[1-9]\d*)$/;
2270
-
2271
- /**
2272
- * Checks if `value` is a valid array-like index.
2273
- *
2274
- * @private
2275
- * @param {*} value The value to check.
2276
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
2277
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
2278
- */
2279
- function isIndex$1(value, length) {
2280
- var type = typeof value;
2281
- length = length == null ? MAX_SAFE_INTEGER$1 : length;
2282
-
2283
- return !!length &&
2284
- (type == 'number' ||
2285
- (type != 'symbol' && reIsUint.test(value))) &&
2286
- (value > -1 && value % 1 == 0 && value < length);
2287
- }
2288
-
2289
- var _isIndex = isIndex$1;
2290
-
2291
- /** Used as references for various `Number` constants. */
2292
-
2293
- var MAX_SAFE_INTEGER = 9007199254740991;
2294
-
2295
- /**
2296
- * Checks if `value` is a valid array-like length.
2297
- *
2298
- * **Note:** This method is loosely based on
2299
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
2300
- *
2301
- * @static
2302
- * @memberOf _
2303
- * @since 4.0.0
2304
- * @category Lang
2305
- * @param {*} value The value to check.
2306
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
2307
- * @example
2308
- *
2309
- * _.isLength(3);
2310
- * // => true
2311
- *
2312
- * _.isLength(Number.MIN_VALUE);
2313
- * // => false
2314
- *
2315
- * _.isLength(Infinity);
2316
- * // => false
2317
- *
2318
- * _.isLength('3');
2319
- * // => false
2320
- */
2321
- function isLength$2(value) {
2322
- return typeof value == 'number' &&
2323
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
2324
- }
2325
-
2326
- var isLength_1 = isLength$2;
2327
-
2328
- var baseGetTag$1 = _baseGetTag,
2329
- isLength$1 = isLength_1,
2330
- isObjectLike$2 = isObjectLike_1;
2331
-
2332
- /** `Object#toString` result references. */
2333
- var argsTag$1 = '[object Arguments]',
2334
- arrayTag$1 = '[object Array]',
2335
- boolTag$2 = '[object Boolean]',
2336
- dateTag$2 = '[object Date]',
2337
- errorTag$1 = '[object Error]',
2338
- funcTag$1 = '[object Function]',
2339
- mapTag$4 = '[object Map]',
2340
- numberTag$2 = '[object Number]',
2341
- objectTag$2 = '[object Object]',
2342
- regexpTag$2 = '[object RegExp]',
2343
- setTag$4 = '[object Set]',
2344
- stringTag$2 = '[object String]',
2345
- weakMapTag$2 = '[object WeakMap]';
2346
-
2347
- var arrayBufferTag$2 = '[object ArrayBuffer]',
2348
- dataViewTag$3 = '[object DataView]',
2349
- float32Tag$2 = '[object Float32Array]',
2350
- float64Tag$2 = '[object Float64Array]',
2351
- int8Tag$2 = '[object Int8Array]',
2352
- int16Tag$2 = '[object Int16Array]',
2353
- int32Tag$2 = '[object Int32Array]',
2354
- uint8Tag$2 = '[object Uint8Array]',
2355
- uint8ClampedTag$2 = '[object Uint8ClampedArray]',
2356
- uint16Tag$2 = '[object Uint16Array]',
2357
- uint32Tag$2 = '[object Uint32Array]';
2358
-
2359
- /** Used to identify `toStringTag` values of typed arrays. */
2360
- var typedArrayTags = {};
2361
- typedArrayTags[float32Tag$2] = typedArrayTags[float64Tag$2] =
2362
- typedArrayTags[int8Tag$2] = typedArrayTags[int16Tag$2] =
2363
- typedArrayTags[int32Tag$2] = typedArrayTags[uint8Tag$2] =
2364
- typedArrayTags[uint8ClampedTag$2] = typedArrayTags[uint16Tag$2] =
2365
- typedArrayTags[uint32Tag$2] = true;
2366
- typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] =
2367
- typedArrayTags[arrayBufferTag$2] = typedArrayTags[boolTag$2] =
2368
- typedArrayTags[dataViewTag$3] = typedArrayTags[dateTag$2] =
2369
- typedArrayTags[errorTag$1] = typedArrayTags[funcTag$1] =
2370
- typedArrayTags[mapTag$4] = typedArrayTags[numberTag$2] =
2371
- typedArrayTags[objectTag$2] = typedArrayTags[regexpTag$2] =
2372
- typedArrayTags[setTag$4] = typedArrayTags[stringTag$2] =
2373
- typedArrayTags[weakMapTag$2] = false;
2374
-
2375
- /**
2376
- * The base implementation of `_.isTypedArray` without Node.js optimizations.
2377
- *
2378
- * @private
2379
- * @param {*} value The value to check.
2380
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
2381
- */
2382
- function baseIsTypedArray$1(value) {
2383
- return isObjectLike$2(value) &&
2384
- isLength$1(value.length) && !!typedArrayTags[baseGetTag$1(value)];
2385
- }
2386
-
2387
- var _baseIsTypedArray = baseIsTypedArray$1;
2388
-
2389
- /**
2390
- * The base implementation of `_.unary` without support for storing metadata.
2391
- *
2392
- * @private
2393
- * @param {Function} func The function to cap arguments for.
2394
- * @returns {Function} Returns the new capped function.
2395
- */
2396
-
2397
- function baseUnary$3(func) {
2398
- return function(value) {
2399
- return func(value);
2400
- };
2401
- }
2402
-
2403
- var _baseUnary = baseUnary$3;
2404
-
2405
- var _nodeUtil = {exports: {}};
2406
-
2407
- (function (module, exports) {
2408
- var freeGlobal = _freeGlobal;
2409
-
2410
- /** Detect free variable `exports`. */
2411
- var freeExports = exports && !exports.nodeType && exports;
2412
-
2413
- /** Detect free variable `module`. */
2414
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
2415
-
2416
- /** Detect the popular CommonJS extension `module.exports`. */
2417
- var moduleExports = freeModule && freeModule.exports === freeExports;
2418
-
2419
- /** Detect free variable `process` from Node.js. */
2420
- var freeProcess = moduleExports && freeGlobal.process;
2421
-
2422
- /** Used to access faster Node.js helpers. */
2423
- var nodeUtil = (function() {
2424
- try {
2425
- // Use `util.types` for Node.js 10+.
2426
- var types = freeModule && freeModule.require && freeModule.require('util').types;
2427
-
2428
- if (types) {
2429
- return types;
2430
- }
2431
-
2432
- // Legacy `process.binding('util')` for Node.js < 10.
2433
- return freeProcess && freeProcess.binding && freeProcess.binding('util');
2434
- } catch (e) {}
2435
- }());
2436
-
2437
- module.exports = nodeUtil;
2438
- }(_nodeUtil, _nodeUtil.exports));
2439
-
2440
- var baseIsTypedArray = _baseIsTypedArray,
2441
- baseUnary$2 = _baseUnary,
2442
- nodeUtil$2 = _nodeUtil.exports;
2443
-
2444
- /* Node.js helper references. */
2445
- var nodeIsTypedArray = nodeUtil$2 && nodeUtil$2.isTypedArray;
2446
-
2447
- /**
2448
- * Checks if `value` is classified as a typed array.
2449
- *
2450
- * @static
2451
- * @memberOf _
2452
- * @since 3.0.0
2453
- * @category Lang
2454
- * @param {*} value The value to check.
2455
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
2456
- * @example
2457
- *
2458
- * _.isTypedArray(new Uint8Array);
2459
- * // => true
2460
- *
2461
- * _.isTypedArray([]);
2462
- * // => false
2463
- */
2464
- var isTypedArray$1 = nodeIsTypedArray ? baseUnary$2(nodeIsTypedArray) : baseIsTypedArray;
2465
-
2466
- var isTypedArray_1 = isTypedArray$1;
2467
-
2468
- var baseTimes = _baseTimes,
2469
- isArguments = isArguments_1,
2470
- isArray$2 = isArray_1,
2471
- isBuffer$1 = isBuffer$2.exports,
2472
- isIndex = _isIndex,
2473
- isTypedArray = isTypedArray_1;
2474
-
2475
- /** Used for built-in method references. */
2476
- var objectProto$5 = Object.prototype;
2477
-
2478
- /** Used to check objects for own properties. */
2479
- var hasOwnProperty$3 = objectProto$5.hasOwnProperty;
2480
-
2481
- /**
2482
- * Creates an array of the enumerable property names of the array-like `value`.
2483
- *
2484
- * @private
2485
- * @param {*} value The value to query.
2486
- * @param {boolean} inherited Specify returning inherited property names.
2487
- * @returns {Array} Returns the array of property names.
2488
- */
2489
- function arrayLikeKeys$2(value, inherited) {
2490
- var isArr = isArray$2(value),
2491
- isArg = !isArr && isArguments(value),
2492
- isBuff = !isArr && !isArg && isBuffer$1(value),
2493
- isType = !isArr && !isArg && !isBuff && isTypedArray(value),
2494
- skipIndexes = isArr || isArg || isBuff || isType,
2495
- result = skipIndexes ? baseTimes(value.length, String) : [],
2496
- length = result.length;
2497
-
2498
- for (var key in value) {
2499
- if ((inherited || hasOwnProperty$3.call(value, key)) &&
2500
- !(skipIndexes && (
2501
- // Safari 9 has enumerable `arguments.length` in strict mode.
2502
- key == 'length' ||
2503
- // Node.js 0.10 has enumerable non-index properties on buffers.
2504
- (isBuff && (key == 'offset' || key == 'parent')) ||
2505
- // PhantomJS 2 has enumerable non-index properties on typed arrays.
2506
- (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
2507
- // Skip index properties.
2508
- isIndex(key, length)
2509
- ))) {
2510
- result.push(key);
2511
- }
2512
- }
2513
- return result;
2514
- }
2515
-
2516
- var _arrayLikeKeys = arrayLikeKeys$2;
2517
-
2518
- /** Used for built-in method references. */
2519
-
2520
- var objectProto$4 = Object.prototype;
2521
-
2522
- /**
2523
- * Checks if `value` is likely a prototype object.
2524
- *
2525
- * @private
2526
- * @param {*} value The value to check.
2527
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
2528
- */
2529
- function isPrototype$3(value) {
2530
- var Ctor = value && value.constructor,
2531
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$4;
2532
-
2533
- return value === proto;
2534
- }
2535
-
2536
- var _isPrototype = isPrototype$3;
2537
-
2538
- /**
2539
- * Creates a unary function that invokes `func` with its argument transformed.
2540
- *
2541
- * @private
2542
- * @param {Function} func The function to wrap.
2543
- * @param {Function} transform The argument transform.
2544
- * @returns {Function} Returns the new function.
2545
- */
2546
-
2547
- function overArg$2(func, transform) {
2548
- return function(arg) {
2549
- return func(transform(arg));
2550
- };
2551
- }
2552
-
2553
- var _overArg = overArg$2;
2554
-
2555
- var overArg$1 = _overArg;
2556
-
2557
- /* Built-in method references for those with the same name as other `lodash` methods. */
2558
- var nativeKeys$1 = overArg$1(Object.keys, Object);
2559
-
2560
- var _nativeKeys = nativeKeys$1;
2561
-
2562
- var isPrototype$2 = _isPrototype,
2563
- nativeKeys = _nativeKeys;
2564
-
2565
- /** Used for built-in method references. */
2566
- var objectProto$3 = Object.prototype;
2567
-
2568
- /** Used to check objects for own properties. */
2569
- var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
2570
-
2571
- /**
2572
- * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
2573
- *
2574
- * @private
2575
- * @param {Object} object The object to query.
2576
- * @returns {Array} Returns the array of property names.
2577
- */
2578
- function baseKeys$1(object) {
2579
- if (!isPrototype$2(object)) {
2580
- return nativeKeys(object);
2581
- }
2582
- var result = [];
2583
- for (var key in Object(object)) {
2584
- if (hasOwnProperty$2.call(object, key) && key != 'constructor') {
2585
- result.push(key);
2586
- }
2587
- }
2588
- return result;
2589
- }
2590
-
2591
- var _baseKeys = baseKeys$1;
2592
-
2593
- var isFunction = isFunction_1,
2594
- isLength = isLength_1;
2595
-
2596
- /**
2597
- * Checks if `value` is array-like. A value is considered array-like if it's
2598
- * not a function and has a `value.length` that's an integer greater than or
2599
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
2600
- *
2601
- * @static
2602
- * @memberOf _
2603
- * @since 4.0.0
2604
- * @category Lang
2605
- * @param {*} value The value to check.
2606
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
2607
- * @example
2608
- *
2609
- * _.isArrayLike([1, 2, 3]);
2610
- * // => true
2611
- *
2612
- * _.isArrayLike(document.body.children);
2613
- * // => true
2614
- *
2615
- * _.isArrayLike('abc');
2616
- * // => true
2617
- *
2618
- * _.isArrayLike(_.noop);
2619
- * // => false
2620
- */
2621
- function isArrayLike$2(value) {
2622
- return value != null && isLength(value.length) && !isFunction(value);
2623
- }
2624
-
2625
- var isArrayLike_1 = isArrayLike$2;
2626
-
2627
- var arrayLikeKeys$1 = _arrayLikeKeys,
2628
- baseKeys = _baseKeys,
2629
- isArrayLike$1 = isArrayLike_1;
2630
-
2631
- /**
2632
- * Creates an array of the own enumerable property names of `object`.
2633
- *
2634
- * **Note:** Non-object values are coerced to objects. See the
2635
- * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
2636
- * for more details.
2637
- *
2638
- * @static
2639
- * @since 0.1.0
2640
- * @memberOf _
2641
- * @category Object
2642
- * @param {Object} object The object to query.
2643
- * @returns {Array} Returns the array of property names.
2644
- * @example
2645
- *
2646
- * function Foo() {
2647
- * this.a = 1;
2648
- * this.b = 2;
2649
- * }
2650
- *
2651
- * Foo.prototype.c = 3;
2652
- *
2653
- * _.keys(new Foo);
2654
- * // => ['a', 'b'] (iteration order is not guaranteed)
2655
- *
2656
- * _.keys('hi');
2657
- * // => ['0', '1']
2658
- */
2659
- function keys$3(object) {
2660
- return isArrayLike$1(object) ? arrayLikeKeys$1(object) : baseKeys(object);
2661
- }
2662
-
2663
- var keys_1 = keys$3;
2664
-
2665
- var copyObject$3 = _copyObject,
2666
- keys$2 = keys_1;
2667
-
2668
- /**
2669
- * The base implementation of `_.assign` without support for multiple sources
2670
- * or `customizer` functions.
2671
- *
2672
- * @private
2673
- * @param {Object} object The destination object.
2674
- * @param {Object} source The source object.
2675
- * @returns {Object} Returns `object`.
2676
- */
2677
- function baseAssign$1(object, source) {
2678
- return object && copyObject$3(source, keys$2(source), object);
2679
- }
2680
-
2681
- var _baseAssign = baseAssign$1;
2682
-
2683
- /**
2684
- * This function is like
2685
- * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
2686
- * except that it includes inherited enumerable properties.
2687
- *
2688
- * @private
2689
- * @param {Object} object The object to query.
2690
- * @returns {Array} Returns the array of property names.
2691
- */
2692
-
2693
- function nativeKeysIn$1(object) {
2694
- var result = [];
2695
- if (object != null) {
2696
- for (var key in Object(object)) {
2697
- result.push(key);
2698
- }
2699
- }
2700
- return result;
2701
- }
2702
-
2703
- var _nativeKeysIn = nativeKeysIn$1;
2704
-
2705
- var isObject$2 = isObject_1,
2706
- isPrototype$1 = _isPrototype,
2707
- nativeKeysIn = _nativeKeysIn;
2708
-
2709
- /** Used for built-in method references. */
2710
- var objectProto$2 = Object.prototype;
2711
-
2712
- /** Used to check objects for own properties. */
2713
- var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
2714
-
2715
- /**
2716
- * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
2717
- *
2718
- * @private
2719
- * @param {Object} object The object to query.
2720
- * @returns {Array} Returns the array of property names.
2721
- */
2722
- function baseKeysIn$1(object) {
2723
- if (!isObject$2(object)) {
2724
- return nativeKeysIn(object);
2725
- }
2726
- var isProto = isPrototype$1(object),
2727
- result = [];
2728
-
2729
- for (var key in object) {
2730
- if (!(key == 'constructor' && (isProto || !hasOwnProperty$1.call(object, key)))) {
2731
- result.push(key);
2732
- }
2733
- }
2734
- return result;
2735
- }
2736
-
2737
- var _baseKeysIn = baseKeysIn$1;
2738
-
2739
- var arrayLikeKeys = _arrayLikeKeys,
2740
- baseKeysIn = _baseKeysIn,
2741
- isArrayLike = isArrayLike_1;
2742
-
2743
- /**
2744
- * Creates an array of the own and inherited enumerable property names of `object`.
2745
- *
2746
- * **Note:** Non-object values are coerced to objects.
2747
- *
2748
- * @static
2749
- * @memberOf _
2750
- * @since 3.0.0
2751
- * @category Object
2752
- * @param {Object} object The object to query.
2753
- * @returns {Array} Returns the array of property names.
2754
- * @example
2755
- *
2756
- * function Foo() {
2757
- * this.a = 1;
2758
- * this.b = 2;
2759
- * }
2760
- *
2761
- * Foo.prototype.c = 3;
2762
- *
2763
- * _.keysIn(new Foo);
2764
- * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
2765
- */
2766
- function keysIn$3(object) {
2767
- return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
2768
- }
2769
-
2770
- var keysIn_1 = keysIn$3;
2771
-
2772
- var copyObject$2 = _copyObject,
2773
- keysIn$2 = keysIn_1;
2774
-
2775
- /**
2776
- * The base implementation of `_.assignIn` without support for multiple sources
2777
- * or `customizer` functions.
2778
- *
2779
- * @private
2780
- * @param {Object} object The destination object.
2781
- * @param {Object} source The source object.
2782
- * @returns {Object} Returns `object`.
2783
- */
2784
- function baseAssignIn$1(object, source) {
2785
- return object && copyObject$2(source, keysIn$2(source), object);
2786
- }
2787
-
2788
- var _baseAssignIn = baseAssignIn$1;
2789
-
2790
- var _cloneBuffer = {exports: {}};
2791
-
2792
- (function (module, exports) {
2793
- var root = _root;
2794
-
2795
- /** Detect free variable `exports`. */
2796
- var freeExports = exports && !exports.nodeType && exports;
2797
-
2798
- /** Detect free variable `module`. */
2799
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
2800
-
2801
- /** Detect the popular CommonJS extension `module.exports`. */
2802
- var moduleExports = freeModule && freeModule.exports === freeExports;
2803
-
2804
- /** Built-in value references. */
2805
- var Buffer = moduleExports ? root.Buffer : undefined,
2806
- allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
2807
-
2808
- /**
2809
- * Creates a clone of `buffer`.
2810
- *
2811
- * @private
2812
- * @param {Buffer} buffer The buffer to clone.
2813
- * @param {boolean} [isDeep] Specify a deep clone.
2814
- * @returns {Buffer} Returns the cloned buffer.
2815
- */
2816
- function cloneBuffer(buffer, isDeep) {
2817
- if (isDeep) {
2818
- return buffer.slice();
2819
- }
2820
- var length = buffer.length,
2821
- result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
2822
-
2823
- buffer.copy(result);
2824
- return result;
2825
- }
2826
-
2827
- module.exports = cloneBuffer;
2828
- }(_cloneBuffer, _cloneBuffer.exports));
2829
-
2830
- /**
2831
- * Copies the values of `source` to `array`.
2832
- *
2833
- * @private
2834
- * @param {Array} source The array to copy values from.
2835
- * @param {Array} [array=[]] The array to copy values to.
2836
- * @returns {Array} Returns `array`.
2837
- */
2838
-
2839
- function copyArray$1(source, array) {
2840
- var index = -1,
2841
- length = source.length;
2842
-
2843
- array || (array = Array(length));
2844
- while (++index < length) {
2845
- array[index] = source[index];
2846
- }
2847
- return array;
2848
- }
2849
-
2850
- var _copyArray = copyArray$1;
2851
-
2852
- /**
2853
- * A specialized version of `_.filter` for arrays without support for
2854
- * iteratee shorthands.
2855
- *
2856
- * @private
2857
- * @param {Array} [array] The array to iterate over.
2858
- * @param {Function} predicate The function invoked per iteration.
2859
- * @returns {Array} Returns the new filtered array.
2860
- */
2861
-
2862
- function arrayFilter$1(array, predicate) {
2863
- var index = -1,
2864
- length = array == null ? 0 : array.length,
2865
- resIndex = 0,
2866
- result = [];
2867
-
2868
- while (++index < length) {
2869
- var value = array[index];
2870
- if (predicate(value, index, array)) {
2871
- result[resIndex++] = value;
2872
- }
2873
- }
2874
- return result;
2875
- }
2876
-
2877
- var _arrayFilter = arrayFilter$1;
2878
-
2879
- /**
2880
- * This method returns a new empty array.
2881
- *
2882
- * @static
2883
- * @memberOf _
2884
- * @since 4.13.0
2885
- * @category Util
2886
- * @returns {Array} Returns the new empty array.
2887
- * @example
2888
- *
2889
- * var arrays = _.times(2, _.stubArray);
2890
- *
2891
- * console.log(arrays);
2892
- * // => [[], []]
2893
- *
2894
- * console.log(arrays[0] === arrays[1]);
2895
- * // => false
2896
- */
2897
-
2898
- function stubArray$2() {
2899
- return [];
2900
- }
2901
-
2902
- var stubArray_1 = stubArray$2;
2903
-
2904
- var arrayFilter = _arrayFilter,
2905
- stubArray$1 = stubArray_1;
2906
-
2907
- /** Used for built-in method references. */
2908
- var objectProto$1 = Object.prototype;
2909
-
2910
- /** Built-in value references. */
2911
- var propertyIsEnumerable = objectProto$1.propertyIsEnumerable;
2912
-
2913
- /* Built-in method references for those with the same name as other `lodash` methods. */
2914
- var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
2915
-
2916
- /**
2917
- * Creates an array of the own enumerable symbols of `object`.
2918
- *
2919
- * @private
2920
- * @param {Object} object The object to query.
2921
- * @returns {Array} Returns the array of symbols.
2922
- */
2923
- var getSymbols$3 = !nativeGetSymbols$1 ? stubArray$1 : function(object) {
2924
- if (object == null) {
2925
- return [];
2926
- }
2927
- object = Object(object);
2928
- return arrayFilter(nativeGetSymbols$1(object), function(symbol) {
2929
- return propertyIsEnumerable.call(object, symbol);
2930
- });
2931
- };
2932
-
2933
- var _getSymbols = getSymbols$3;
2934
-
2935
- var copyObject$1 = _copyObject,
2936
- getSymbols$2 = _getSymbols;
2937
-
2938
- /**
2939
- * Copies own symbols of `source` to `object`.
2940
- *
2941
- * @private
2942
- * @param {Object} source The object to copy symbols from.
2943
- * @param {Object} [object={}] The object to copy symbols to.
2944
- * @returns {Object} Returns `object`.
2945
- */
2946
- function copySymbols$1(source, object) {
2947
- return copyObject$1(source, getSymbols$2(source), object);
2948
- }
2949
-
2950
- var _copySymbols = copySymbols$1;
2951
-
2952
- /**
2953
- * Appends the elements of `values` to `array`.
2954
- *
2955
- * @private
2956
- * @param {Array} array The array to modify.
2957
- * @param {Array} values The values to append.
2958
- * @returns {Array} Returns `array`.
2959
- */
2960
-
2961
- function arrayPush$2(array, values) {
2962
- var index = -1,
2963
- length = values.length,
2964
- offset = array.length;
2965
-
2966
- while (++index < length) {
2967
- array[offset + index] = values[index];
2968
- }
2969
- return array;
2970
- }
2971
-
2972
- var _arrayPush = arrayPush$2;
2973
-
2974
- var overArg = _overArg;
2975
-
2976
- /** Built-in value references. */
2977
- var getPrototype$2 = overArg(Object.getPrototypeOf, Object);
2978
-
2979
- var _getPrototype = getPrototype$2;
2980
-
2981
- var arrayPush$1 = _arrayPush,
2982
- getPrototype$1 = _getPrototype,
2983
- getSymbols$1 = _getSymbols,
2984
- stubArray = stubArray_1;
2985
-
2986
- /* Built-in method references for those with the same name as other `lodash` methods. */
2987
- var nativeGetSymbols = Object.getOwnPropertySymbols;
2988
-
2989
- /**
2990
- * Creates an array of the own and inherited enumerable symbols of `object`.
2991
- *
2992
- * @private
2993
- * @param {Object} object The object to query.
2994
- * @returns {Array} Returns the array of symbols.
2995
- */
2996
- var getSymbolsIn$2 = !nativeGetSymbols ? stubArray : function(object) {
2997
- var result = [];
2998
- while (object) {
2999
- arrayPush$1(result, getSymbols$1(object));
3000
- object = getPrototype$1(object);
3001
- }
3002
- return result;
3003
- };
3004
-
3005
- var _getSymbolsIn = getSymbolsIn$2;
3006
-
3007
- var copyObject = _copyObject,
3008
- getSymbolsIn$1 = _getSymbolsIn;
3009
-
3010
- /**
3011
- * Copies own and inherited symbols of `source` to `object`.
3012
- *
3013
- * @private
3014
- * @param {Object} source The object to copy symbols from.
3015
- * @param {Object} [object={}] The object to copy symbols to.
3016
- * @returns {Object} Returns `object`.
3017
- */
3018
- function copySymbolsIn$1(source, object) {
3019
- return copyObject(source, getSymbolsIn$1(source), object);
3020
- }
3021
-
3022
- var _copySymbolsIn = copySymbolsIn$1;
3023
-
3024
- var arrayPush = _arrayPush,
3025
- isArray$1 = isArray_1;
3026
-
3027
- /**
3028
- * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
3029
- * `keysFunc` and `symbolsFunc` to get the enumerable property names and
3030
- * symbols of `object`.
3031
- *
3032
- * @private
3033
- * @param {Object} object The object to query.
3034
- * @param {Function} keysFunc The function to get the keys of `object`.
3035
- * @param {Function} symbolsFunc The function to get the symbols of `object`.
3036
- * @returns {Array} Returns the array of property names and symbols.
3037
- */
3038
- function baseGetAllKeys$2(object, keysFunc, symbolsFunc) {
3039
- var result = keysFunc(object);
3040
- return isArray$1(object) ? result : arrayPush(result, symbolsFunc(object));
3041
- }
3042
-
3043
- var _baseGetAllKeys = baseGetAllKeys$2;
3044
-
3045
- var baseGetAllKeys$1 = _baseGetAllKeys,
3046
- getSymbols = _getSymbols,
3047
- keys$1 = keys_1;
3048
-
3049
- /**
3050
- * Creates an array of own enumerable property names and symbols of `object`.
3051
- *
3052
- * @private
3053
- * @param {Object} object The object to query.
3054
- * @returns {Array} Returns the array of property names and symbols.
3055
- */
3056
- function getAllKeys$1(object) {
3057
- return baseGetAllKeys$1(object, keys$1, getSymbols);
3058
- }
3059
-
3060
- var _getAllKeys = getAllKeys$1;
3061
-
3062
- var baseGetAllKeys = _baseGetAllKeys,
3063
- getSymbolsIn = _getSymbolsIn,
3064
- keysIn$1 = keysIn_1;
3065
-
3066
- /**
3067
- * Creates an array of own and inherited enumerable property names and
3068
- * symbols of `object`.
3069
- *
3070
- * @private
3071
- * @param {Object} object The object to query.
3072
- * @returns {Array} Returns the array of property names and symbols.
3073
- */
3074
- function getAllKeysIn$1(object) {
3075
- return baseGetAllKeys(object, keysIn$1, getSymbolsIn);
3076
- }
3077
-
3078
- var _getAllKeysIn = getAllKeysIn$1;
3079
-
3080
- var getNative$3 = _getNative,
3081
- root$4 = _root;
3082
-
3083
- /* Built-in method references that are verified to be native. */
3084
- var DataView$1 = getNative$3(root$4, 'DataView');
3085
-
3086
- var _DataView = DataView$1;
3087
-
3088
- var getNative$2 = _getNative,
3089
- root$3 = _root;
3090
-
3091
- /* Built-in method references that are verified to be native. */
3092
- var Promise$2 = getNative$2(root$3, 'Promise');
3093
-
3094
- var _Promise = Promise$2;
3095
-
3096
- var getNative$1 = _getNative,
3097
- root$2 = _root;
3098
-
3099
- /* Built-in method references that are verified to be native. */
3100
- var Set$1 = getNative$1(root$2, 'Set');
3101
-
3102
- var _Set = Set$1;
3103
-
3104
- var getNative = _getNative,
3105
- root$1 = _root;
3106
-
3107
- /* Built-in method references that are verified to be native. */
3108
- var WeakMap$1 = getNative(root$1, 'WeakMap');
3109
-
3110
- var _WeakMap = WeakMap$1;
3111
-
3112
- var DataView = _DataView,
3113
- Map = _Map,
3114
- Promise$1 = _Promise,
3115
- Set = _Set,
3116
- WeakMap = _WeakMap,
3117
- baseGetTag = _baseGetTag,
3118
- toSource = _toSource;
3119
-
3120
- /** `Object#toString` result references. */
3121
- var mapTag$3 = '[object Map]',
3122
- objectTag$1 = '[object Object]',
3123
- promiseTag = '[object Promise]',
3124
- setTag$3 = '[object Set]',
3125
- weakMapTag$1 = '[object WeakMap]';
3126
-
3127
- var dataViewTag$2 = '[object DataView]';
3128
-
3129
- /** Used to detect maps, sets, and weakmaps. */
3130
- var dataViewCtorString = toSource(DataView),
3131
- mapCtorString = toSource(Map),
3132
- promiseCtorString = toSource(Promise$1),
3133
- setCtorString = toSource(Set),
3134
- weakMapCtorString = toSource(WeakMap);
3135
-
3136
- /**
3137
- * Gets the `toStringTag` of `value`.
3138
- *
3139
- * @private
3140
- * @param {*} value The value to query.
3141
- * @returns {string} Returns the `toStringTag`.
3142
- */
3143
- var getTag$3 = baseGetTag;
3144
-
3145
- // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
3146
- if ((DataView && getTag$3(new DataView(new ArrayBuffer(1))) != dataViewTag$2) ||
3147
- (Map && getTag$3(new Map) != mapTag$3) ||
3148
- (Promise$1 && getTag$3(Promise$1.resolve()) != promiseTag) ||
3149
- (Set && getTag$3(new Set) != setTag$3) ||
3150
- (WeakMap && getTag$3(new WeakMap) != weakMapTag$1)) {
3151
- getTag$3 = function(value) {
3152
- var result = baseGetTag(value),
3153
- Ctor = result == objectTag$1 ? value.constructor : undefined,
3154
- ctorString = Ctor ? toSource(Ctor) : '';
3155
-
3156
- if (ctorString) {
3157
- switch (ctorString) {
3158
- case dataViewCtorString: return dataViewTag$2;
3159
- case mapCtorString: return mapTag$3;
3160
- case promiseCtorString: return promiseTag;
3161
- case setCtorString: return setTag$3;
3162
- case weakMapCtorString: return weakMapTag$1;
3163
- }
3164
- }
3165
- return result;
3166
- };
3167
- }
3168
-
3169
- var _getTag = getTag$3;
3170
-
3171
- /** Used for built-in method references. */
3172
-
3173
- var objectProto = Object.prototype;
3174
-
3175
- /** Used to check objects for own properties. */
3176
- var hasOwnProperty = objectProto.hasOwnProperty;
3177
-
3178
- /**
3179
- * Initializes an array clone.
3180
- *
3181
- * @private
3182
- * @param {Array} array The array to clone.
3183
- * @returns {Array} Returns the initialized clone.
3184
- */
3185
- function initCloneArray$1(array) {
3186
- var length = array.length,
3187
- result = new array.constructor(length);
3188
-
3189
- // Add properties assigned by `RegExp#exec`.
3190
- if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
3191
- result.index = array.index;
3192
- result.input = array.input;
3193
- }
3194
- return result;
3195
- }
3196
-
3197
- var _initCloneArray = initCloneArray$1;
3198
-
3199
- var root = _root;
3200
-
3201
- /** Built-in value references. */
3202
- var Uint8Array$1 = root.Uint8Array;
3203
-
3204
- var _Uint8Array = Uint8Array$1;
3205
-
3206
- var Uint8Array = _Uint8Array;
3207
-
3208
- /**
3209
- * Creates a clone of `arrayBuffer`.
3210
- *
3211
- * @private
3212
- * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
3213
- * @returns {ArrayBuffer} Returns the cloned array buffer.
3214
- */
3215
- function cloneArrayBuffer$3(arrayBuffer) {
3216
- var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
3217
- new Uint8Array(result).set(new Uint8Array(arrayBuffer));
3218
- return result;
3219
- }
3220
-
3221
- var _cloneArrayBuffer = cloneArrayBuffer$3;
3222
-
3223
- var cloneArrayBuffer$2 = _cloneArrayBuffer;
3224
-
3225
- /**
3226
- * Creates a clone of `dataView`.
3227
- *
3228
- * @private
3229
- * @param {Object} dataView The data view to clone.
3230
- * @param {boolean} [isDeep] Specify a deep clone.
3231
- * @returns {Object} Returns the cloned data view.
3232
- */
3233
- function cloneDataView$1(dataView, isDeep) {
3234
- var buffer = isDeep ? cloneArrayBuffer$2(dataView.buffer) : dataView.buffer;
3235
- return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
3236
- }
3237
-
3238
- var _cloneDataView = cloneDataView$1;
3239
-
3240
- /** Used to match `RegExp` flags from their coerced string values. */
3241
-
3242
- var reFlags = /\w*$/;
3243
-
3244
- /**
3245
- * Creates a clone of `regexp`.
3246
- *
3247
- * @private
3248
- * @param {Object} regexp The regexp to clone.
3249
- * @returns {Object} Returns the cloned regexp.
3250
- */
3251
- function cloneRegExp$1(regexp) {
3252
- var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
3253
- result.lastIndex = regexp.lastIndex;
3254
- return result;
3255
- }
3256
-
3257
- var _cloneRegExp = cloneRegExp$1;
3258
-
3259
- var Symbol = _Symbol;
3260
-
3261
- /** Used to convert symbols to primitives and strings. */
3262
- var symbolProto = Symbol ? Symbol.prototype : undefined,
3263
- symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
3264
-
3265
- /**
3266
- * Creates a clone of the `symbol` object.
3267
- *
3268
- * @private
3269
- * @param {Object} symbol The symbol object to clone.
3270
- * @returns {Object} Returns the cloned symbol object.
3271
- */
3272
- function cloneSymbol$1(symbol) {
3273
- return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
3274
- }
3275
-
3276
- var _cloneSymbol = cloneSymbol$1;
3277
-
3278
- var cloneArrayBuffer$1 = _cloneArrayBuffer;
3279
-
3280
- /**
3281
- * Creates a clone of `typedArray`.
3282
- *
3283
- * @private
3284
- * @param {Object} typedArray The typed array to clone.
3285
- * @param {boolean} [isDeep] Specify a deep clone.
3286
- * @returns {Object} Returns the cloned typed array.
3287
- */
3288
- function cloneTypedArray$1(typedArray, isDeep) {
3289
- var buffer = isDeep ? cloneArrayBuffer$1(typedArray.buffer) : typedArray.buffer;
3290
- return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
3291
- }
3292
-
3293
- var _cloneTypedArray = cloneTypedArray$1;
3294
-
3295
- var cloneArrayBuffer = _cloneArrayBuffer,
3296
- cloneDataView = _cloneDataView,
3297
- cloneRegExp = _cloneRegExp,
3298
- cloneSymbol = _cloneSymbol,
3299
- cloneTypedArray = _cloneTypedArray;
3300
-
3301
- /** `Object#toString` result references. */
3302
- var boolTag$1 = '[object Boolean]',
3303
- dateTag$1 = '[object Date]',
3304
- mapTag$2 = '[object Map]',
3305
- numberTag$1 = '[object Number]',
3306
- regexpTag$1 = '[object RegExp]',
3307
- setTag$2 = '[object Set]',
3308
- stringTag$1 = '[object String]',
3309
- symbolTag$1 = '[object Symbol]';
3310
-
3311
- var arrayBufferTag$1 = '[object ArrayBuffer]',
3312
- dataViewTag$1 = '[object DataView]',
3313
- float32Tag$1 = '[object Float32Array]',
3314
- float64Tag$1 = '[object Float64Array]',
3315
- int8Tag$1 = '[object Int8Array]',
3316
- int16Tag$1 = '[object Int16Array]',
3317
- int32Tag$1 = '[object Int32Array]',
3318
- uint8Tag$1 = '[object Uint8Array]',
3319
- uint8ClampedTag$1 = '[object Uint8ClampedArray]',
3320
- uint16Tag$1 = '[object Uint16Array]',
3321
- uint32Tag$1 = '[object Uint32Array]';
3322
-
3323
- /**
3324
- * Initializes an object clone based on its `toStringTag`.
3325
- *
3326
- * **Note:** This function only supports cloning values with tags of
3327
- * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
3328
- *
3329
- * @private
3330
- * @param {Object} object The object to clone.
3331
- * @param {string} tag The `toStringTag` of the object to clone.
3332
- * @param {boolean} [isDeep] Specify a deep clone.
3333
- * @returns {Object} Returns the initialized clone.
3334
- */
3335
- function initCloneByTag$1(object, tag, isDeep) {
3336
- var Ctor = object.constructor;
3337
- switch (tag) {
3338
- case arrayBufferTag$1:
3339
- return cloneArrayBuffer(object);
3340
-
3341
- case boolTag$1:
3342
- case dateTag$1:
3343
- return new Ctor(+object);
3344
-
3345
- case dataViewTag$1:
3346
- return cloneDataView(object, isDeep);
3347
-
3348
- case float32Tag$1: case float64Tag$1:
3349
- case int8Tag$1: case int16Tag$1: case int32Tag$1:
3350
- case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1:
3351
- return cloneTypedArray(object, isDeep);
3352
-
3353
- case mapTag$2:
3354
- return new Ctor;
3355
-
3356
- case numberTag$1:
3357
- case stringTag$1:
3358
- return new Ctor(object);
3359
-
3360
- case regexpTag$1:
3361
- return cloneRegExp(object);
3362
-
3363
- case setTag$2:
3364
- return new Ctor;
3365
-
3366
- case symbolTag$1:
3367
- return cloneSymbol(object);
3368
- }
3369
- }
3370
-
3371
- var _initCloneByTag = initCloneByTag$1;
3372
-
3373
- var isObject$1 = isObject_1;
3374
-
3375
- /** Built-in value references. */
3376
- var objectCreate = Object.create;
3377
-
3378
- /**
3379
- * The base implementation of `_.create` without support for assigning
3380
- * properties to the created object.
3381
- *
3382
- * @private
3383
- * @param {Object} proto The object to inherit from.
3384
- * @returns {Object} Returns the new object.
3385
- */
3386
- var baseCreate$1 = (function() {
3387
- function object() {}
3388
- return function(proto) {
3389
- if (!isObject$1(proto)) {
3390
- return {};
3391
- }
3392
- if (objectCreate) {
3393
- return objectCreate(proto);
3394
- }
3395
- object.prototype = proto;
3396
- var result = new object;
3397
- object.prototype = undefined;
3398
- return result;
3399
- };
3400
- }());
3401
-
3402
- var _baseCreate = baseCreate$1;
3403
-
3404
- var baseCreate = _baseCreate,
3405
- getPrototype = _getPrototype,
3406
- isPrototype = _isPrototype;
3407
-
3408
- /**
3409
- * Initializes an object clone.
3410
- *
3411
- * @private
3412
- * @param {Object} object The object to clone.
3413
- * @returns {Object} Returns the initialized clone.
3414
- */
3415
- function initCloneObject$1(object) {
3416
- return (typeof object.constructor == 'function' && !isPrototype(object))
3417
- ? baseCreate(getPrototype(object))
3418
- : {};
3419
- }
3420
-
3421
- var _initCloneObject = initCloneObject$1;
3422
-
3423
- var getTag$2 = _getTag,
3424
- isObjectLike$1 = isObjectLike_1;
3425
-
3426
- /** `Object#toString` result references. */
3427
- var mapTag$1 = '[object Map]';
3428
-
3429
- /**
3430
- * The base implementation of `_.isMap` without Node.js optimizations.
3431
- *
3432
- * @private
3433
- * @param {*} value The value to check.
3434
- * @returns {boolean} Returns `true` if `value` is a map, else `false`.
3435
- */
3436
- function baseIsMap$1(value) {
3437
- return isObjectLike$1(value) && getTag$2(value) == mapTag$1;
3438
- }
3439
-
3440
- var _baseIsMap = baseIsMap$1;
3441
-
3442
- var baseIsMap = _baseIsMap,
3443
- baseUnary$1 = _baseUnary,
3444
- nodeUtil$1 = _nodeUtil.exports;
3445
-
3446
- /* Node.js helper references. */
3447
- var nodeIsMap = nodeUtil$1 && nodeUtil$1.isMap;
3448
-
3449
- /**
3450
- * Checks if `value` is classified as a `Map` object.
3451
- *
3452
- * @static
3453
- * @memberOf _
3454
- * @since 4.3.0
3455
- * @category Lang
3456
- * @param {*} value The value to check.
3457
- * @returns {boolean} Returns `true` if `value` is a map, else `false`.
3458
- * @example
3459
- *
3460
- * _.isMap(new Map);
3461
- * // => true
3462
- *
3463
- * _.isMap(new WeakMap);
3464
- * // => false
3465
- */
3466
- var isMap$1 = nodeIsMap ? baseUnary$1(nodeIsMap) : baseIsMap;
3467
-
3468
- var isMap_1 = isMap$1;
3469
-
3470
- var getTag$1 = _getTag,
3471
- isObjectLike = isObjectLike_1;
3472
-
3473
- /** `Object#toString` result references. */
3474
- var setTag$1 = '[object Set]';
3475
-
3476
- /**
3477
- * The base implementation of `_.isSet` without Node.js optimizations.
3478
- *
3479
- * @private
3480
- * @param {*} value The value to check.
3481
- * @returns {boolean} Returns `true` if `value` is a set, else `false`.
3482
- */
3483
- function baseIsSet$1(value) {
3484
- return isObjectLike(value) && getTag$1(value) == setTag$1;
3485
- }
3486
-
3487
- var _baseIsSet = baseIsSet$1;
3488
-
3489
- var baseIsSet = _baseIsSet,
3490
- baseUnary = _baseUnary,
3491
- nodeUtil = _nodeUtil.exports;
3492
-
3493
- /* Node.js helper references. */
3494
- var nodeIsSet = nodeUtil && nodeUtil.isSet;
3495
-
3496
- /**
3497
- * Checks if `value` is classified as a `Set` object.
3498
- *
3499
- * @static
3500
- * @memberOf _
3501
- * @since 4.3.0
3502
- * @category Lang
3503
- * @param {*} value The value to check.
3504
- * @returns {boolean} Returns `true` if `value` is a set, else `false`.
3505
- * @example
3506
- *
3507
- * _.isSet(new Set);
3508
- * // => true
3509
- *
3510
- * _.isSet(new WeakSet);
3511
- * // => false
3512
- */
3513
- var isSet$1 = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
3514
-
3515
- var isSet_1 = isSet$1;
3516
-
3517
- var Stack = _Stack,
3518
- arrayEach = _arrayEach,
3519
- assignValue = _assignValue,
3520
- baseAssign = _baseAssign,
3521
- baseAssignIn = _baseAssignIn,
3522
- cloneBuffer = _cloneBuffer.exports,
3523
- copyArray = _copyArray,
3524
- copySymbols = _copySymbols,
3525
- copySymbolsIn = _copySymbolsIn,
3526
- getAllKeys = _getAllKeys,
3527
- getAllKeysIn = _getAllKeysIn,
3528
- getTag = _getTag,
3529
- initCloneArray = _initCloneArray,
3530
- initCloneByTag = _initCloneByTag,
3531
- initCloneObject = _initCloneObject,
3532
- isArray = isArray_1,
3533
- isBuffer = isBuffer$2.exports,
3534
- isMap = isMap_1,
3535
- isObject = isObject_1,
3536
- isSet = isSet_1,
3537
- keys = keys_1,
3538
- keysIn = keysIn_1;
3539
-
3540
- /** Used to compose bitmasks for cloning. */
3541
- var CLONE_DEEP_FLAG$1 = 1,
3542
- CLONE_FLAT_FLAG = 2,
3543
- CLONE_SYMBOLS_FLAG$1 = 4;
3544
-
3545
- /** `Object#toString` result references. */
3546
- var argsTag = '[object Arguments]',
3547
- arrayTag = '[object Array]',
3548
- boolTag = '[object Boolean]',
3549
- dateTag = '[object Date]',
3550
- errorTag = '[object Error]',
3551
- funcTag = '[object Function]',
3552
- genTag = '[object GeneratorFunction]',
3553
- mapTag = '[object Map]',
3554
- numberTag = '[object Number]',
3555
- objectTag = '[object Object]',
3556
- regexpTag = '[object RegExp]',
3557
- setTag = '[object Set]',
3558
- stringTag = '[object String]',
3559
- symbolTag = '[object Symbol]',
3560
- weakMapTag = '[object WeakMap]';
3561
-
3562
- var arrayBufferTag = '[object ArrayBuffer]',
3563
- dataViewTag = '[object DataView]',
3564
- float32Tag = '[object Float32Array]',
3565
- float64Tag = '[object Float64Array]',
3566
- int8Tag = '[object Int8Array]',
3567
- int16Tag = '[object Int16Array]',
3568
- int32Tag = '[object Int32Array]',
3569
- uint8Tag = '[object Uint8Array]',
3570
- uint8ClampedTag = '[object Uint8ClampedArray]',
3571
- uint16Tag = '[object Uint16Array]',
3572
- uint32Tag = '[object Uint32Array]';
3573
-
3574
- /** Used to identify `toStringTag` values supported by `_.clone`. */
3575
- var cloneableTags = {};
3576
- cloneableTags[argsTag] = cloneableTags[arrayTag] =
3577
- cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
3578
- cloneableTags[boolTag] = cloneableTags[dateTag] =
3579
- cloneableTags[float32Tag] = cloneableTags[float64Tag] =
3580
- cloneableTags[int8Tag] = cloneableTags[int16Tag] =
3581
- cloneableTags[int32Tag] = cloneableTags[mapTag] =
3582
- cloneableTags[numberTag] = cloneableTags[objectTag] =
3583
- cloneableTags[regexpTag] = cloneableTags[setTag] =
3584
- cloneableTags[stringTag] = cloneableTags[symbolTag] =
3585
- cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
3586
- cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
3587
- cloneableTags[errorTag] = cloneableTags[funcTag] =
3588
- cloneableTags[weakMapTag] = false;
3589
-
3590
- /**
3591
- * The base implementation of `_.clone` and `_.cloneDeep` which tracks
3592
- * traversed objects.
3593
- *
3594
- * @private
3595
- * @param {*} value The value to clone.
3596
- * @param {boolean} bitmask The bitmask flags.
3597
- * 1 - Deep clone
3598
- * 2 - Flatten inherited properties
3599
- * 4 - Clone symbols
3600
- * @param {Function} [customizer] The function to customize cloning.
3601
- * @param {string} [key] The key of `value`.
3602
- * @param {Object} [object] The parent object of `value`.
3603
- * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
3604
- * @returns {*} Returns the cloned value.
3605
- */
3606
- function baseClone$1(value, bitmask, customizer, key, object, stack) {
3607
- var result,
3608
- isDeep = bitmask & CLONE_DEEP_FLAG$1,
3609
- isFlat = bitmask & CLONE_FLAT_FLAG,
3610
- isFull = bitmask & CLONE_SYMBOLS_FLAG$1;
3611
-
3612
- if (customizer) {
3613
- result = object ? customizer(value, key, object, stack) : customizer(value);
3614
- }
3615
- if (result !== undefined) {
3616
- return result;
3617
- }
3618
- if (!isObject(value)) {
3619
- return value;
3620
- }
3621
- var isArr = isArray(value);
3622
- if (isArr) {
3623
- result = initCloneArray(value);
3624
- if (!isDeep) {
3625
- return copyArray(value, result);
3626
- }
3627
- } else {
3628
- var tag = getTag(value),
3629
- isFunc = tag == funcTag || tag == genTag;
3630
-
3631
- if (isBuffer(value)) {
3632
- return cloneBuffer(value, isDeep);
3633
- }
3634
- if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
3635
- result = (isFlat || isFunc) ? {} : initCloneObject(value);
3636
- if (!isDeep) {
3637
- return isFlat
3638
- ? copySymbolsIn(value, baseAssignIn(result, value))
3639
- : copySymbols(value, baseAssign(result, value));
3640
- }
3641
- } else {
3642
- if (!cloneableTags[tag]) {
3643
- return object ? value : {};
3644
- }
3645
- result = initCloneByTag(value, tag, isDeep);
3646
- }
3647
- }
3648
- // Check for circular references and return its corresponding clone.
3649
- stack || (stack = new Stack);
3650
- var stacked = stack.get(value);
3651
- if (stacked) {
3652
- return stacked;
3653
- }
3654
- stack.set(value, result);
3655
-
3656
- if (isSet(value)) {
3657
- value.forEach(function(subValue) {
3658
- result.add(baseClone$1(subValue, bitmask, customizer, subValue, value, stack));
3659
- });
3660
- } else if (isMap(value)) {
3661
- value.forEach(function(subValue, key) {
3662
- result.set(key, baseClone$1(subValue, bitmask, customizer, key, value, stack));
3663
- });
3664
- }
3665
-
3666
- var keysFunc = isFull
3667
- ? (isFlat ? getAllKeysIn : getAllKeys)
3668
- : (isFlat ? keysIn : keys);
3669
-
3670
- var props = isArr ? undefined : keysFunc(value);
3671
- arrayEach(props || value, function(subValue, key) {
3672
- if (props) {
3673
- key = subValue;
3674
- subValue = value[key];
3675
- }
3676
- // Recursively populate clone (susceptible to call stack limits).
3677
- assignValue(result, key, baseClone$1(subValue, bitmask, customizer, key, value, stack));
3678
- });
3679
- return result;
3680
- }
3681
-
3682
- var _baseClone = baseClone$1;
3683
-
3684
- var baseClone = _baseClone;
3685
-
3686
- /** Used to compose bitmasks for cloning. */
3687
- var CLONE_DEEP_FLAG = 1,
3688
- CLONE_SYMBOLS_FLAG = 4;
3689
-
3690
- /**
3691
- * This method is like `_.clone` except that it recursively clones `value`.
3692
- *
3693
- * @static
3694
- * @memberOf _
3695
- * @since 1.0.0
3696
- * @category Lang
3697
- * @param {*} value The value to recursively clone.
3698
- * @returns {*} Returns the deep cloned value.
3699
- * @see _.clone
3700
- * @example
3701
- *
3702
- * var objects = [{ 'a': 1 }, { 'b': 2 }];
3703
- *
3704
- * var deep = _.cloneDeep(objects);
3705
- * console.log(deep[0] === objects[0]);
3706
- * // => false
3707
- */
3708
- function cloneDeep(value) {
3709
- return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
3710
- }
3711
-
3712
- var cloneDeep_1 = cloneDeep;
3713
-
3714
- var stringifyAttributes = ((attributes = {}) => Object.entries(attributes).map(([key, value], idx) => `${idx !== 0 ? ' ' : ''}${key}${value ? `="${value}"` : ''}`).join(' '));
3715
-
3716
- /* eslint-disable no-console */
3717
-
3718
- /**
3719
- * Web Application Response handler, sends a prepared express js response
3720
- * with the supplied content sending in the specified manner
3721
- * @param {response} request express js request object
3722
- * @param {response} response express js response object
3723
- * @param {string | object} content the content to send in the response body
3724
- * @param {"send" | "json" | "end"} send the response function to call e.g res.send() res.json() res.end()
3725
- */
3726
- const handleResponse = (request, response, content, send = 'send') => {
3727
- // console.log('---', response.statusCode, '---');
3728
- response[send](content);
3729
- };
3730
-
3731
- const readFileSync = path => fs__default["default"].readFileSync(path, 'utf8');
3732
-
3733
- const loadableBundleData = ({
3734
- stats,
3735
- templates
3736
- }, staticRoutePath, build) => {
3737
- const bundle = {};
3738
-
3739
- try {
3740
- bundle.stats = stats ? JSON.parse(readFileSync(stats.replace('/target', build ? `/${build}` : ''))) : null;
3741
- } catch (ex) {
3742
- // console.info(ex);
3743
- bundle.stats = null;
3744
- }
3745
-
3746
- try {
3747
- bundle.templates = {
3748
- templateHTML: replaceStaticPath(readFileSync(templates.html.replace('/target', build ? `/${build}` : '')), staticRoutePath),
3749
- templateHTMLStatic: replaceStaticPath(readFileSync(templates.static.replace('/target', build ? `/${build}` : '')), staticRoutePath),
3750
- templateHTMLFragment: replaceStaticPath(readFileSync(templates.fragment.replace('/target', build ? `/${build}` : '')), staticRoutePath)
3751
- };
3752
- } catch (ex) {
3753
- // console.info(ex);
3754
- bundle.templates = null;
3755
- }
3756
-
3757
- return bundle;
3758
- };
3759
- const loadableChunkExtractors = () => {
3760
- const commonLoadableExtractor = new server$2.ChunkExtractor({
3761
- stats: {}
3762
- });
3763
-
3764
- try {
3765
- let modern;
3766
- let legacy;
3767
-
3768
- try {
3769
- modern = new server$2.ChunkExtractor({
3770
- entrypoints: ['app'],
3771
- namespace: 'modern',
3772
- statsFile: path__default["default"].resolve('dist/modern/loadable-stats.json')
3773
- });
3774
- } catch (e) {
3775
- console.info('@loadable/server modern ChunkExtractor not available');
3776
- }
3777
-
3778
- try {
3779
- legacy = new server$2.ChunkExtractor({
3780
- entrypoints: ['app'],
3781
- namespace: 'legacy',
3782
- statsFile: path__default["default"].resolve('dist/legacy/loadable-stats.json')
3783
- });
3784
- } catch (e) {
3785
- console.info('@loadable/server legacy ChunkExtractor not available');
3786
- }
3787
-
3788
- commonLoadableExtractor.addChunk = chunk => {
3789
- var _modern, _legacy, _legacy2;
3790
-
3791
- (_modern = modern) === null || _modern === void 0 ? void 0 : _modern.addChunk(chunk);
3792
- if (typeof ((_legacy = legacy) === null || _legacy === void 0 ? void 0 : _legacy.stats.assetsByChunkName[chunk]) !== 'undefined') (_legacy2 = legacy) === null || _legacy2 === void 0 ? void 0 : _legacy2.addChunk(chunk);
3793
- };
3794
-
3795
- return {
3796
- commonLoadableExtractor,
3797
- modern,
3798
- legacy
3799
- };
3800
- } catch (e) {
3801
- console.info('@loadable/server no ChunkExtractor available');
3802
- return {
3803
- commonLoadableExtractor
3804
- };
3805
- }
3806
- };
3807
- const getBundleData = (config, staticRoutePath) => {
3808
- const bundleData = {
3809
- default: loadableBundleData(config, staticRoutePath),
3810
- legacy: loadableBundleData(config, staticRoutePath, 'legacy'),
3811
- modern: loadableBundleData(config, staticRoutePath, 'modern')
3812
- };
3813
- if (!bundleData.default || Object.keys(bundleData.default || {}).length === 0) bundleData.default = bundleData.legacy || bundleData.modern;
3814
- return bundleData;
3815
- }; // export const buildBundleTags = (
3816
- // bundles,
3817
- // differentialBundles = false,
3818
- // staticRoutePath = 'static',
3819
- // attributes = ''
3820
- // ) => {
3821
- // // Take the bundles returned from Loadable.Capture
3822
- // const bundleTags = bundles
3823
- // .filter(b => b)
3824
- // .map(bundle => {
3825
- // if (bundle.publicPath.includes('/modern/'))
3826
- // return differentialBundles
3827
- // ? `<script ${attributes} type="module" src="${replaceStaticPath(
3828
- // bundle.publicPath,
3829
- // staticRoutePath
3830
- // )}"></script>`
3831
- // : null;
3832
- // return `<script ${attributes}${
3833
- // differentialBundles ? ' nomodule' : ''
3834
- // } src="${replaceStaticPath(
3835
- // bundle.publicPath,
3836
- // staticRoutePath
3837
- // )}"></script>`;
3838
- // })
3839
- // .filter(f => f);
3840
- // return bundleTags;
3841
- // };
3842
-
3843
- const getBundleTags = (loadableExtractor, scripts, staticRoutePath = 'static') => {
3844
- let startupTag = ''; // Add the static startup script to the bundleTags
3845
-
3846
- if (scripts !== null && scripts !== void 0 && scripts.startup) startupTag = `<script ${stringifyAttributes(scripts.attributes)} src="/${staticRoutePath}/${scripts.startup}"></script>`; // Get the script tags from their respective extractor instances
1007
+ const getBundleTags = (loadableExtractor, scripts, staticRoutePath = 'static') => {
1008
+ let startupTag = '';
1009
+ // Add the static startup script to the bundleTags
1010
+ if (scripts !== null && scripts !== void 0 && scripts.startup) startupTag = `<script ${stringifyAttributes(scripts.attributes)} src="/${staticRoutePath}/${scripts.startup}"></script>`;
3847
1011
 
1012
+ // Get the script tags from their respective extractor instances
3848
1013
  if (loadableExtractor) {
3849
1014
  var _loadableExtractor$le, _loadableExtractor$mo;
3850
-
3851
1015
  const legacyScriptTags = (_loadableExtractor$le = loadableExtractor.legacy) === null || _loadableExtractor$le === void 0 ? void 0 : _loadableExtractor$le.getScriptTags({
3852
1016
  nomodule: 'nomodule'
3853
1017
  });
@@ -3857,28 +1021,60 @@ const getBundleTags = (loadableExtractor, scripts, staticRoutePath = 'static') =
3857
1021
  const scriptTags = `${startupTag}${legacyScriptTags || ''}${modernScriptTags || ''}`.replace(/"\/static\//g, `"/${staticRoutePath}/`);
3858
1022
  return scriptTags;
3859
1023
  }
3860
-
3861
1024
  return startupTag;
3862
1025
  };
3863
1026
 
3864
- const alias = ALIAS;
3865
- /* global ALIAS */
1027
+ const getVersionInfo = staticFolderPath => {
1028
+ try {
1029
+ const versionData = fs__default.default.readFileSync(`dist/${staticFolderPath}/version.json`, 'utf8');
1030
+ const versionInfo = JSON.parse(versionData);
1031
+ return versionInfo;
1032
+ } catch (ex) {
1033
+ console.error(`Unable to read from "version.json"`, ex);
1034
+ return {};
1035
+ }
1036
+ };
1037
+
1038
+ /* eslint-disable no-console */
1039
+
1040
+ // Default exception types to add event listeners for
1041
+ const handleDefaultEvents = ['uncaughtException', 'unhandledRejection'];
1042
+ const unhandledExceptionHandler = (handleExceptions = handleDefaultEvents) => {
1043
+ const exceptionTypes = Array.isArray(handleExceptions) ? handleExceptions : handleExceptions === false ? [] : handleDefaultEvents;
1044
+ for (const type of exceptionTypes) {
1045
+ process.on(type, err => {
1046
+ if (err && err instanceof Error) {
1047
+ // Print a message to inform admins and developers the error should not be ignored
1048
+ console.log(`${`[contensis-react-base] ❌ ${chalk__default.default.red.bold(`${type} - ${err.message}`)}`}`);
1049
+ console.log(chalk__default.default.gray` - you are seeing this because we have tried to prevent the app from completely crashing - you should not ignore this problem`);
1050
+ // Log the error to server console
1051
+ console.error(err);
1052
+ }
1053
+ });
1054
+ }
1055
+ };
3866
1056
 
3867
1057
  const addStandardHeaders = (state, response, packagejson, groups) => {
3868
1058
  if (state) {
3869
1059
  try {
3870
- console.info('About to add headers');
3871
- const routingSurrogateKeys = selectors.selectSurrogateKeys(state); // Check length of surrogate keys and prevent potential header overflow
3872
- // errors in prod by replacing with `any-update` header that will indiscriminately
3873
- // invalidate the SSR page cache when any content is updated
3874
-
3875
- const surrogateKeys = routingSurrogateKeys.length >= 2000 ? `${alias}_any-update` : routingSurrogateKeys.join(' ');
1060
+ const routingSurrogateKeys = selectors.selectSurrogateKeys(state);
1061
+ const apiCalls = selectors.selectSsrApiCalls(state);
1062
+ const anyApiError = !!apiCalls.find(([status]) => status >= 400);
1063
+
1064
+ // Check length of surrogate keys and prevent potential header overflow errors in prod
1065
+ // Check for any error set in the page response
1066
+ // And check if we have seen any error in any of the Delivery API calls
1067
+ // - add `any-update` header that will indiscriminately
1068
+ // invalidate the SSR page cache when any content is updated
1069
+ const addAnyUpdateHeader = routingSurrogateKeys.length >= 2000 || response.statusCode >= 400 || anyApiError;
1070
+ console.info(`[addStandardHeaders] ${addAnyUpdateHeader ? anyUpdateHeader : routingSurrogateKeys.length} surrogate keys for ${response.req.url}`);
1071
+ const surrogateKeys = addAnyUpdateHeader ? anyUpdateHeader : routingSurrogateKeys.join(' ');
3876
1072
  const surrogateKeyHeader = `${packagejson.name}-app ${surrogateKeys}`;
3877
1073
  response.setHeader('surrogate-key', surrogateKeyHeader);
3878
1074
  addVarnishAuthenticationHeaders(state, response, groups);
3879
1075
  response.setHeader('surrogate-control', `max-age=${getCacheDuration(response.statusCode)}`);
3880
1076
  } catch (e) {
3881
- console.info('Error Adding headers', e.message);
1077
+ console.info('[addStandardHeaders] Error adding headers', e.message);
3882
1078
  }
3883
1079
  }
3884
1080
  };
@@ -3890,14 +1086,12 @@ const addVarnishAuthenticationHeaders = (state, response, groups = {}) => {
3890
1086
  const {
3891
1087
  globalGroups,
3892
1088
  allowedGroups
3893
- } = groups; // console.info(globalGroups, allowedGroups);
3894
-
1089
+ } = groups;
1090
+ // console.info(globalGroups, allowedGroups);
3895
1091
  let allGroups = Array.from(globalGroups && globalGroups[project] || {});
3896
-
3897
1092
  if (stateEntry && selectors.getImmutableOrJS(stateEntry, ['authentication', 'isLoginRequired']) && allowedGroups && allowedGroups[project]) {
3898
1093
  allGroups = [...allGroups, ...allowedGroups[project]];
3899
1094
  }
3900
-
3901
1095
  response.header('x-contensis-viewer-groups', allGroups.join('|'));
3902
1096
  } catch (e) {
3903
1097
  console.info('Error adding authentication header', e);
@@ -3905,39 +1099,115 @@ const addVarnishAuthenticationHeaders = (state, response, groups = {}) => {
3905
1099
  }
3906
1100
  };
3907
1101
 
3908
- const getVersionInfo = staticFolderPath => {
3909
- try {
3910
- const versionData = fs__default["default"].readFileSync(`dist/${staticFolderPath}/version.json`, 'utf8');
3911
- const versionInfo = JSON.parse(versionData);
3912
- return versionInfo;
3913
- } catch (ex) {
3914
- console.error(`Unable to read from "version.json"`, ex);
3915
- return {};
1102
+ /**
1103
+ * Add assets to templateHTML in the positions represented
1104
+ * by replacing specific keys wrapped in handlebars depending
1105
+ * on the accessMethod(s) that have been set (or updated)
1106
+ * while processing the request
1107
+ */
1108
+ const replaceHtml = ({
1109
+ bundleTags = '',
1110
+ html = '',
1111
+ htmlAttributes = '',
1112
+ metadata = '',
1113
+ state = '',
1114
+ styleTags = '',
1115
+ title = '',
1116
+ templateHTML = '',
1117
+ templateHTMLFragment = '',
1118
+ templateHTMLStatic = ''
1119
+ }, accessMethod) => {
1120
+ let responseHTML = '';
1121
+ // Serve a blank HTML page with client scripts to load the app in the browser
1122
+ if (accessMethod.DYNAMIC) {
1123
+ responseHTML = templateHTML.replace('{{TITLE}}', '').replace('{{SEO_CRITICAL_METADATA}}', '').replace('{{CRITICAL_CSS}}', '').replace('{{APP}}', '')
1124
+ // .replace('{{LOADABLE_CHUNKS}}', bundleTags)
1125
+ .replace('{{REDUX_DATA}}', state);
3916
1126
  }
3917
- };
3918
1127
 
3919
- /* eslint-disable no-console */
1128
+ // Page fragment served with client scripts and redux data that hydrate the app client side
1129
+ else if (accessMethod.FRAGMENT && !accessMethod.STATIC) {
1130
+ responseHTML = templateHTMLFragment.replace('{{TITLE}}', title).replace('{{SEO_CRITICAL_METADATA}}', metadata).replace('{{CRITICAL_CSS}}', minifyCssString__default.default(styleTags))
1131
+ //.replace('{{APP}}', html)
1132
+ // .replace('{{LOADABLE_CHUNKS}}', bundleTags)
1133
+ .replace('{{REDUX_DATA}}', state);
1134
+ }
3920
1135
 
3921
- const handleDefaultEvents = ['uncaughtException', 'unhandledRejection'];
3922
- const unhandledExceptionHandler = (handleExceptions = handleDefaultEvents) => {
3923
- const exceptionTypes = Array.isArray(handleExceptions) ? handleExceptions : handleExceptions === false ? [] : handleDefaultEvents;
1136
+ // Full HTML page served statically
1137
+ else if (!accessMethod.FRAGMENT && accessMethod.STATIC) {
1138
+ responseHTML = templateHTMLStatic.replace('{{TITLE}}', title).replace('{{SEO_CRITICAL_METADATA}}', metadata).replace('{{CRITICAL_CSS}}', minifyCssString__default.default(styleTags))
1139
+ //.replace('{{APP}}', html)
1140
+ .replace('{{LOADABLE_CHUNKS}}', '');
1141
+ }
3924
1142
 
3925
- for (const type of exceptionTypes) {
3926
- process.on(type, err => {
3927
- if (err && err instanceof Error) {
3928
- // Print a message to inform admins and developers the error should not be ignored
3929
- console.log(`${`[contensis-react-base] ❌ ${chalk__default["default"].red.bold(`${type} - ${err.message}`)}`}`);
3930
- console.log(chalk__default["default"].gray` - you are seeing this because we have tried to prevent the app from completely crashing - you should not ignore this problem`); // Log the error to server console
1143
+ // Full HTML page served with client scripts and redux data that hydrate the app client side
1144
+ else if (!accessMethod.FRAGMENT && !accessMethod.STATIC) {
1145
+ responseHTML = templateHTML.replace('{{TITLE}}', title).replace('{{SEO_CRITICAL_METADATA}}', metadata).replace('{{CRITICAL_CSS}}', styleTags)
1146
+ //.replace('{{APP}}', html)
1147
+ // .replace('{{LOADABLE_CHUNKS}}', bundleTags)
1148
+ .replace('{{REDUX_DATA}}', state);
1149
+ }
3931
1150
 
3932
- console.error(err);
3933
- }
3934
- });
1151
+ // If react-helmet htmlAttributes are being used,
1152
+ // replace the html tag with those attributes sepcified
1153
+ // e.g. (lang, dir etc.)
1154
+ if (htmlAttributes) {
1155
+ responseHTML = responseHTML.replace(/<html?.+?>/, `<html ${htmlAttributes}>`);
3935
1156
  }
1157
+ responseHTML = html ? responseHTML.replace('{{APP}}', html) : responseHTML;
1158
+
1159
+ // Only replace bundle tags at the very end when we have rendered and are
1160
+ // streaming out the HTML "footer"
1161
+ if (bundleTags) responseHTML = responseHTML.replace('{{LOADABLE_CHUNKS}}', bundleTags);
1162
+ return responseHTML;
1163
+ };
1164
+
1165
+ /**
1166
+ * Produce the JSX wrapped in the necessary Providers
1167
+ * to render the app in SSR
1168
+ * @param ReactApp the JSX to render
1169
+ * @param { providers, props, ssrAssets }
1170
+ * @returns the final JSX to render decorated with all Provider and App props
1171
+ */
1172
+ const ssrJsxProducer = (ReactApp, {
1173
+ providers,
1174
+ props
1175
+ // ssrAssets,
1176
+ }) => {
1177
+ var _providers$styledComp;
1178
+ // Recast ChunkExtractorManager to avoid TS error `Property 'children' does not exist on type...`
1179
+ const ChunkExtractor = server$2.ChunkExtractorManager;
1180
+ const jsx = /*#__PURE__*/React__default.default.createElement(ChunkExtractor, {
1181
+ extractor: providers.loadable.extractor
1182
+ }, /*#__PURE__*/React__default.default.createElement(reactCookie.CookiesProvider, {
1183
+ cookies: providers.cookies
1184
+ }, /*#__PURE__*/React__default.default.createElement(reactRedux.Provider, {
1185
+ store: providers.redux
1186
+ }, /*#__PURE__*/React__default.default.createElement(RouteLoader.HttpContext.Provider, {
1187
+ value: providers.httpContext
1188
+ }, /*#__PURE__*/React__default.default.createElement(server$3.StaticRouter, {
1189
+ location: providers.router.url,
1190
+ future: {
1191
+ v7_startTransition: true,
1192
+ v7_relativeSplatPath: true
1193
+ }
1194
+ }, /*#__PURE__*/React__default.default.createElement(SSRContext.SSRContextProvider, {
1195
+ accessMethod: providers.ssrContext.accessMethod,
1196
+ request: providers.ssrContext.request,
1197
+ response: providers.ssrContext.response
1198
+ // ssrAssets={ssrAssets}
1199
+ }, /*#__PURE__*/React__default.default.createElement(ReactApp, {
1200
+ routes: props.routes,
1201
+ withEvents: props.withEvents
1202
+ })))))));
1203
+
1204
+ // Wrap the JSX in a StyleSheetManager if a ServerStyleSheet is provided
1205
+ return !((_providers$styledComp = providers.styledComponents) !== null && _providers$styledComp !== void 0 && _providers$styledComp.sheet) ? jsx : providers.styledComponents.sheet.collectStyles(jsx);
3936
1206
  };
3937
1207
 
3938
1208
  const webApp = (app, ReactApp, config) => {
3939
1209
  const {
3940
- stateType = 'immutable',
1210
+ stateType = 'js',
3941
1211
  routes,
3942
1212
  withReducers,
3943
1213
  withSagas,
@@ -3949,37 +1219,39 @@ const webApp = (app, ReactApp, config) => {
3949
1219
  allowedGroups,
3950
1220
  globalGroups,
3951
1221
  disableSsrRedux,
1222
+ enableSsrCookies,
3952
1223
  handleResponses,
3953
1224
  handleExceptions = true
3954
1225
  } = config;
3955
1226
  const staticRoutePath = config.staticRoutePath || staticFolderPath;
1227
+ let isRenderingJsxToString = config.renderToString || false;
3956
1228
  const bundleData = getBundleData(config, staticRoutePath);
3957
1229
  const attributes = stringifyAttributes(scripts.attributes);
3958
1230
  scripts.startup = scripts.startup || startupScriptFilename;
3959
- const responseHandler = typeof handleResponses === 'function' ? handleResponses : handleResponse;
1231
+ let responseHandler = handleResponse;
1232
+ if (typeof handleResponses === 'function') {
1233
+ responseHandler = handleResponses;
1234
+ isRenderingJsxToString = true;
1235
+ }
3960
1236
  if (handleExceptions !== false) unhandledExceptionHandler(handleExceptions); // Create `process.on` event handlers for unhandled exceptions (Node v15+)
3961
1237
 
3962
1238
  const versionInfo = getVersionInfo(staticFolderPath);
3963
- app.get('/*', cookiesMiddleware__default["default"](), async (request, response) => {
3964
- const {
3965
- url
3966
- } = request;
3967
- const matchedStaticRoute = require$$2.matchRoutes(routes.StaticRoutes, request.path);
1239
+ app.get('/{*splat}', cookiesMiddleware__default.default(), async (request, response) => {
1240
+ const url = encodeURI(request.url);
1241
+ const matchedStaticRoute = reactRouterDom.matchRoutes(routes.StaticRoutes, request.path);
3968
1242
  const isStaticRoute = matchedStaticRoute && matchedStaticRoute.length > 0;
3969
-
3970
1243
  if (isStaticRoute) {
3971
1244
  RouteLoader.mergeStaticRoutes(matchedStaticRoute);
3972
1245
  }
1246
+ const staticRoute = isStaticRoute ? matchedStaticRoute.pop() || null : null;
3973
1247
 
3974
- const staticRoute = isStaticRoute ? matchedStaticRoute.pop() || null : null; // Allow certain routes to avoid SSR
3975
-
1248
+ // Allow certain routes to avoid SSR
3976
1249
  const onlyDynamic = staticRoute && staticRoute.route.ssr === false;
3977
1250
  const onlySSR = staticRoute && staticRoute.route.ssrOnly === true;
1251
+ const normaliseQs = q => q && q.toLowerCase() === 'true' ? true : false;
3978
1252
 
3979
- const normaliseQs = q => q && q.toLowerCase() === 'true' ? true : false; // Determine functional params from QueryString and set access methods
3980
-
3981
-
3982
- const accessMethod = mapJson__default["default"](request.query, {
1253
+ // Determine functional params from QueryString and set access methods
1254
+ const accessMethod = mapJson__default.default(request.query, {
3983
1255
  DYNAMIC: ({
3984
1256
  dynamic
3985
1257
  }) => normaliseQs(dynamic) || onlyDynamic,
@@ -3993,84 +1265,103 @@ const webApp = (app, ReactApp, config) => {
3993
1265
  static: value
3994
1266
  }) => normaliseQs(value) || onlySSR
3995
1267
  });
3996
- const context = {
3997
- location: ''
3998
- }; // Track the current statusCode via the response object
3999
1268
 
4000
- response.status(200); // Create a store (with a memory history) from our current url
4001
-
4002
- const store = await version.createStore(withReducers, {}, App.history({
1269
+ // Create a store (with a memory history) from our current url
1270
+ const store$1 = await store.createStore(withReducers, {}, App.history({
4003
1271
  initialEntries: [url]
4004
- }), stateType); // dispatch any global and non-saga related actions before calling our JSX
1272
+ }), stateType);
4005
1273
 
4006
- const versionStatus = ContensisDeliveryApi.deliveryApi.getServerSideVersionStatus(request); // In server-side blocks world, the hostname requested by the client resides in the x-orig-host header
4007
- // Because of this, we prioritize x-orig-host when setting our hostname
1274
+ // dispatch any global and non-saga related actions before calling our JSX
1275
+ const versionStatus = ContensisDeliveryApi.deliveryApi.getServerSideVersionStatus(request);
4008
1276
 
1277
+ // In server-side blocks world, the hostname requested by the client resides in the x-orig-host header
1278
+ // Because of this, we prioritize x-orig-host when setting our hostname
4009
1279
  const hostname = request.headers['x-orig-host'] || request.hostname;
4010
1280
  console.info(`Request for ${request.path} hostname: ${hostname} versionStatus: ${versionStatus}`);
4011
- store.dispatch(version$1.setVersionStatus(versionStatus));
4012
- store.dispatch(version$1.setVersion(versionInfo.commitRef, versionInfo.buildNo));
1281
+ store$1.dispatch(version.setVersionStatus(versionStatus));
1282
+ store$1.dispatch(version.setVersion(versionInfo.commitRef, versionInfo.buildNo));
4013
1283
  const project = App.pickProject(hostname, request.query);
4014
1284
  const groups = allowedGroups && allowedGroups[project];
4015
- store.dispatch(selectors.setCurrentProject(project, groups, hostname));
1285
+ store$1.dispatch(selectors.setCurrentProject(project, groups, hostname));
4016
1286
  const loadableExtractor = loadableChunkExtractors();
4017
- // Recast ChunkExtractorManager to avoid TS error `Property 'children' does not exist on type...`
4018
- const ChunkExtractor = server$2.ChunkExtractorManager;
4019
- const jsx = /*#__PURE__*/React__default["default"].createElement(ChunkExtractor, {
4020
- extractor: loadableExtractor.commonLoadableExtractor
4021
- }, /*#__PURE__*/React__default["default"].createElement(reactCookie.CookiesProvider, {
4022
- cookies: request.universalCookies
4023
- }, /*#__PURE__*/React__default["default"].createElement(reactRedux.Provider, {
4024
- store: store
4025
- }, /*#__PURE__*/React__default["default"].createElement(RouteLoader.HttpContext.Provider, {
4026
- value: context
4027
- }, /*#__PURE__*/React__default["default"].createElement(StaticRouter_1, {
4028
- location: url
4029
- }, /*#__PURE__*/React__default["default"].createElement(ReactApp, {
4030
- routes: routes,
4031
- withEvents: withEvents
4032
- }))))));
1287
+ const ssrCookies = enableSsrCookies ?
1288
+ // these cookies are managed by the cookiesMiddleware and contain listeners
1289
+ // when cookies are read or written in ssr can be added to the `set-cookie` response header
1290
+ request.universalCookies :
1291
+ // this is a stub cookie collection so cookie methods can be used in code
1292
+ new CookieHelper_class.Cookies();
1293
+
1294
+ // Track the current statusCode via the response object
1295
+ response.status(200);
1296
+
1297
+ // Create the context we will pass to JSX HttpContext.Provider
1298
+ // and read back any context props set by the ReactApp
1299
+ const context = {};
1300
+
1301
+ // Amalgamate all props for the various Providers we wrap the ReactApp with
1302
+ const jsxProviderProps = {
1303
+ loadable: {
1304
+ extractor: loadableExtractor.commonLoadableExtractor
1305
+ },
1306
+ cookies: ssrCookies,
1307
+ redux: store$1,
1308
+ httpContext: context,
1309
+ router: {
1310
+ url
1311
+ },
1312
+ ssrContext: {
1313
+ accessMethod,
1314
+ request,
1315
+ response
1316
+ }
1317
+ };
1318
+ // These are the props we will pass to the ReactApp itself
1319
+ const jsxReactAppProps = {
1320
+ routes,
1321
+ withEvents
1322
+ };
1323
+
1324
+ // Get the configured HTML templates provided by the consumer
4033
1325
  const {
4034
1326
  templateHTML = '',
4035
1327
  templateHTMLFragment = '',
4036
1328
  templateHTMLStatic = ''
4037
- } = bundleData.default.templates || bundleData.legacy.templates || {}; // Serve a blank HTML page with client scripts to load the app in the browser
1329
+ } = bundleData.default.templates || bundleData.legacy.templates || {};
4038
1330
 
1331
+ // Serve a blank HTML page with client scripts to load the app in the browser
4039
1332
  if (accessMethod.DYNAMIC) {
4040
1333
  // Dynamic doesn't need sagas
4041
- server$3.renderToString(jsx); // Dynamic page render has only the necessary bundles to start up the app
4042
- // and does not include any react-loadable code-split bundles
1334
+ // or styles, or any split component bundles
1335
+ // nor are we streaming responses
1336
+ const isDynamicHints = `<script ${attributes}>window.versionStatus = "${versionStatus}"; window.isDynamic = true;</script>`;
1337
+ const jsx = ssrJsxProducer(ReactApp, {
1338
+ providers: jsxProviderProps,
1339
+ props: jsxReactAppProps
1340
+ });
1341
+ server$1.renderToString(jsx);
4043
1342
 
1343
+ // Dynamic page render has only the necessary bundles to start up the app
1344
+ // and does not include any react-loadable code-split bundles
4044
1345
  const bundleTags = getBundleTags(loadableExtractor, scripts, staticRoutePath);
4045
- const isDynamicHints = `<script ${attributes}>window.versionStatus = "${versionStatus}"; window.isDynamic = true;</script>`;
4046
- const responseHtmlDynamic = templateHTML.replace('{{TITLE}}', '').replace('{{SEO_CRITICAL_METADATA}}', '').replace('{{CRITICAL_CSS}}', '').replace('{{APP}}', '').replace('{{LOADABLE_CHUNKS}}', bundleTags).replace('{{REDUX_DATA}}', isDynamicHints); // Dynamic pages always return a 200 so we can run
1346
+ const responseHtmlDynamic = replaceHtml({
1347
+ bundleTags,
1348
+ state: isDynamicHints,
1349
+ templateHTML,
1350
+ templateHTMLFragment
1351
+ }, accessMethod);
1352
+
1353
+ // Dynamic pages always return a 200 so we can run
4047
1354
  // the app and serve up all errors inside the client
4048
-
4049
1355
  response.setHeader('Surrogate-Control', `max-age=${getCacheDuration(200)}`);
4050
1356
  responseHandler(request, response, responseHtmlDynamic);
4051
- } // Render the JSX server side and send response as per access method options
4052
-
1357
+ }
4053
1358
 
1359
+ // Render the JSX server side and send response as per access method options
4054
1360
  if (!accessMethod.DYNAMIC) {
4055
- store.runSaga(App.rootSaga(withSagas)).toPromise().then(() => {
4056
- const sheet = new styled.ServerStyleSheet();
4057
- const html = server$3.renderToString(sheet.collectStyles(jsx));
4058
- const helmet = reactHelmet.Helmet.renderStatic();
4059
- reactHelmet.Helmet.rewind();
4060
- const htmlAttributes = helmet.htmlAttributes.toString();
4061
- let title = helmet.title.toString();
4062
- const metadata = helmet.meta.toString().concat(helmet.base.toString()).concat(helmet.link.toString()).concat(helmet.script.toString()).concat(helmet.noscript.toString());
4063
-
4064
- if (context.url) {
4065
- return response.redirect(context.statusCode || 302, context.url);
4066
- }
4067
-
4068
- const reduxState = store.getState();
4069
- const styleTags = sheet.getStyleTags(); // After running rootSaga there should be an additional react-loadable
4070
- // code-split bundles for any page components as well as core app bundles
4071
-
4072
- const bundleTags = getBundleTags(loadableExtractor, scripts, staticRoutePath);
4073
- let serialisedReduxData = serialize__default["default"](lodashClean.buildCleaner({
1361
+ store$1.runSaga(App.rootSaga(withSagas)).toPromise().then(() => {
1362
+ var _selectCurrentSearch;
1363
+ const reduxState = store$1.getState();
1364
+ let clonedState = lodashClean.buildCleaner({
4074
1365
  isArray: lodash.identity,
4075
1366
  isBoolean: lodash.identity,
4076
1367
  isDate: lodash.identity,
@@ -4079,8 +1370,20 @@ const webApp = (app, ReactApp, config) => {
4079
1370
  isPlainObject: lodash.identity,
4080
1371
  isString: lodash.identity,
4081
1372
  isUndefined: lodash.noop
4082
- })(cloneDeep_1(reduxState)));
4083
-
1373
+ })(sagas.cloneDeep(reduxState));
1374
+ // These keys are used for preparing server-side response headers only
1375
+ // and are not required in the client at all except for debugging ssr
1376
+ if (!((_selectCurrentSearch = selectors.selectCurrentSearch(reduxState)) !== null && _selectCurrentSearch !== void 0 && _selectCurrentSearch.includes('includeApiCalls'))) {
1377
+ if (stateType === 'immutable') clonedState = clonedState.deleteIn(['routing', 'apiCalls']).deleteIn(['routing', 'surrogateKeys']);else {
1378
+ delete clonedState.routing.apiCalls;
1379
+ delete clonedState.routing.surrogateKeys;
1380
+ }
1381
+ }
1382
+ // Reset user state to prevent user details from being cached in SSR
1383
+ if (stateType === 'immutable') {
1384
+ clonedState = clonedState.delete('user');
1385
+ } else delete clonedState.user;
1386
+ let serialisedReduxData = serialize__default.default(clonedState);
4084
1387
  if (context.statusCode !== 404) {
4085
1388
  // For a request that returns a redux state object as a response
4086
1389
  if (accessMethod.REDUX) {
@@ -4091,58 +1394,93 @@ const webApp = (app, ReactApp, config) => {
4091
1394
  responseHandler(request, response, serialisedReduxData, 'json');
4092
1395
  return true;
4093
1396
  }
4094
-
4095
1397
  if (!disableSsrRedux) {
4096
1398
  // window.versionStatus is not strictly required here and is added to support cases
4097
1399
  // where a consumer may not be using the contensisVersionStatus in redux and calling
4098
1400
  // the `getClientSideVersionStatus()` method directly
4099
- serialisedReduxData = `<script ${attributes}>window.versionStatus = "${versionStatus}"; window.REDUX_DATA = ${serialisedReduxData}</script>`;
1401
+ serialisedReduxData = `<script ${attributes}>window.__USE_HYDRATE__ = true; window.versionStatus = "${versionStatus}"; window.REDUX_DATA = ${serialisedReduxData}</script>`;
4100
1402
  }
4101
1403
  }
4102
1404
 
4103
- if ((context.statusCode || 200) >= 404) {
4104
- accessMethod.STATIC = true;
4105
- } // Responses
4106
-
4107
-
4108
- let responseHTML = '';
4109
- if (context.statusCode === 404) title = '<title>404 page not found</title>'; // Static page served as a fragment
4110
-
4111
- if (accessMethod.FRAGMENT && accessMethod.STATIC) {
4112
- responseHTML = minifyCssString__default["default"](styleTags) + html;
4113
- } // Page fragment served with client scripts and redux data that hydrate the app client side
4114
-
4115
-
4116
- if (accessMethod.FRAGMENT && !accessMethod.STATIC) {
4117
- responseHTML = templateHTMLFragment.replace('{{TITLE}}', title).replace('{{SEO_CRITICAL_METADATA}}', metadata).replace('{{CRITICAL_CSS}}', minifyCssString__default["default"](styleTags)).replace('{{APP}}', html).replace('{{LOADABLE_CHUNKS}}', bundleTags).replace('{{REDUX_DATA}}', serialisedReduxData);
4118
- } // Full HTML page served statically
4119
-
4120
-
4121
- if (!accessMethod.FRAGMENT && accessMethod.STATIC) {
4122
- responseHTML = templateHTMLStatic.replace('{{TITLE}}', title).replace('{{SEO_CRITICAL_METADATA}}', metadata).replace('{{CRITICAL_CSS}}', minifyCssString__default["default"](styleTags)).replace('{{APP}}', html).replace('{{LOADABLE_CHUNKS}}', '');
4123
- } // Full HTML page served with client scripts and redux data that hydrate the app client side
4124
-
4125
-
4126
- if (!accessMethod.FRAGMENT && !accessMethod.STATIC) {
4127
- responseHTML = templateHTML.replace('{{TITLE}}', title).replace('{{SEO_CRITICAL_METADATA}}', metadata).replace('{{CRITICAL_CSS}}', styleTags).replace('{{APP}}', html).replace('{{LOADABLE_CHUNKS}}', bundleTags).replace('{{REDUX_DATA}}', serialisedReduxData);
4128
- } // Set response.status from React StaticRouter
4129
-
4130
-
4131
- if (typeof context.statusCode === 'number') response.status(context.statusCode);
1405
+ // Responses
4132
1406
  addStandardHeaders(reduxState, response, packagejson, {
4133
1407
  allowedGroups,
4134
1408
  globalGroups
4135
1409
  });
1410
+ const sheet = new styled.ServerStyleSheet();
1411
+ const styledJsx = ssrJsxProducer(ReactApp, {
1412
+ providers: {
1413
+ ...jsxProviderProps,
1414
+ styledComponents: {
1415
+ sheet
1416
+ }
1417
+ },
1418
+ props: jsxReactAppProps
1419
+ });
1420
+
1421
+ // We have to call renderToString() in order for all components to have
1422
+ // had chance to set the helmet metadata
1423
+ const html = server$1.renderToString(styledJsx);
1424
+ // Helmet.renderStatic() has to be called synchronously immediately after calling renderToString()
1425
+ // as it is not thread-safe (or specifically scoped to only this request)
1426
+ const helmet = reactHelmet.Helmet.renderStatic();
1427
+
1428
+ // Because we have had to call renderToString() here to reliably gather all helmet metadata
1429
+ // We could potentially call sheet.getStyleTags() here too and avoid piping a react-rendered
1430
+ // stream to a second stream to inject styled-components CSS
4136
1431
 
1432
+ const htmlAttributes = helmet.htmlAttributes.toString();
1433
+ let title = helmet.title.toString();
1434
+ const metadata = helmet.meta.toString().concat(helmet.base.toString()).concat(helmet.link.toString()).concat(helmet.script.toString()).concat(helmet.noscript.toString());
4137
1435
  try {
4138
- // If react-helmet htmlAttributes are being used,
4139
- // replace the html tag with those attributes sepcified
4140
- // e.g. (lang, dir etc.)
4141
- if (htmlAttributes) {
4142
- responseHTML = responseHTML.replace(/<html?.+?>/, `<html ${htmlAttributes}>`);
1436
+ /**
1437
+ * Loads all page assets into the provided templateHTML
1438
+ *
1439
+ * Is callable after the JSX has been rendered, as
1440
+ * JSX components may update the context via the
1441
+ * HttpContext.Provider which can influence whether
1442
+ * we render the page as STATIC or render nothing
1443
+ * if the context has requested a redirect
1444
+ * */
1445
+ const getContextHtml = (isFinal = false, styleTags, renderedJsxMarkup) => {
1446
+ if (context.url) {
1447
+ response.redirect(context.statusCode || 302, context.url);
1448
+ return '';
1449
+ }
1450
+
1451
+ // Make the page render statically if there is an error status code
1452
+ if ((context.statusCode || 200) >= 404) {
1453
+ accessMethod.STATIC = true;
1454
+ }
1455
+ if (context.statusCode === 404) title = '<title>404 page not found</title>';
1456
+
1457
+ // Set response.status from React StaticRouter
1458
+ if (typeof context.statusCode === 'number') response.status(context.statusCode);
1459
+ const bundleTags = isFinal ? getBundleTags(loadableExtractor, scripts, staticRoutePath) : '';
1460
+ const html = replaceHtml({
1461
+ bundleTags,
1462
+ html: renderedJsxMarkup,
1463
+ htmlAttributes,
1464
+ metadata,
1465
+ state: serialisedReduxData,
1466
+ styleTags,
1467
+ title,
1468
+ templateHTML,
1469
+ templateHTMLFragment,
1470
+ templateHTMLStatic
1471
+ }, accessMethod);
1472
+ return html;
1473
+ };
1474
+ if (isRenderingJsxToString) {
1475
+ // We have already (begrudgingly) rendered the JSX to a string above
1476
+ // so we can get all of the Helmet metadata out from any rendered component
1477
+ // const html = renderToString(styledJsx);
1478
+ const styleTags = sheet.getStyleTags();
1479
+ const responseHTML = getContextHtml(true, styleTags, html);
1480
+ responseHandler(request, response, responseHTML);
1481
+ } else {
1482
+ renderStream(getContextHtml, styledJsx, response, styledComponentsStream(sheet));
4143
1483
  }
4144
-
4145
- responseHandler(request, response, responseHTML);
4146
1484
  } catch (err) {
4147
1485
  console.info(err.message);
4148
1486
  }
@@ -4153,26 +1491,31 @@ const webApp = (app, ReactApp, config) => {
4153
1491
  response.status(500);
4154
1492
  responseHandler(request, response, `Error occurred: <br />${err.stack} <br />${JSON.stringify(err)}`);
4155
1493
  });
4156
- server$3.renderToString(jsx);
4157
- store.close();
1494
+
1495
+ // If this is removed we don't get the redux state populated
1496
+ // with the result of the actions RouteLoader component has dispatched
1497
+ server$1.renderToString(ssrJsxProducer(ReactApp, {
1498
+ providers: jsxProviderProps,
1499
+ props: jsxReactAppProps
1500
+ }));
1501
+ store$1.close();
4158
1502
  }
4159
1503
  });
4160
1504
  };
4161
1505
 
4162
- const app = express__default["default"]();
4163
- const server = http__default["default"].createServer(app);
4164
-
1506
+ const app = express__default.default();
1507
+ const server = http__default.default.createServer(app);
4165
1508
  const start = (ReactApp, config, ServerFeatures) => {
4166
1509
  global.PACKAGE_JSON = config.packagejson;
4167
1510
  global.DISABLE_SSR_REDUX = config.disableSsrRedux;
4168
1511
  global.PROXY_DELIVERY_API = config.proxyDeliveryApi;
4169
1512
  global.REVERSE_PROXY_PATHS = Object(config.reverseProxyPaths);
4170
- app.disable('x-powered-by'); // Output some information about the used build/startup configuration
4171
-
1513
+ app.disable('x-powered-by');
1514
+ // Output some information about the used build/startup configuration
4172
1515
  DisplayStartupConfiguration(config);
4173
- ServerFeatures(app); // Set-up local proxy for images from cms, and delivery api requests
1516
+ ServerFeatures(app);
1517
+ // Set-up local proxy for images from cms, and delivery api requests
4174
1518
  // to save doing rewrites and extra code
4175
-
4176
1519
  reverseProxies(app, config.reverseProxyPaths);
4177
1520
  staticAssets(app, config);
4178
1521
  webApp(app, ReactApp, config);
@@ -4191,7 +1534,6 @@ const start = (ReactApp, config, ServerFeatures) => {
4191
1534
  });
4192
1535
  });
4193
1536
  };
4194
-
4195
1537
  var internalServer = {
4196
1538
  app,
4197
1539
  apiProxy: deliveryProxy,
@@ -4200,6 +1542,6 @@ var internalServer = {
4200
1542
  };
4201
1543
 
4202
1544
  exports.ReactApp = App.AppRoot;
4203
- exports["default"] = internalServer;
1545
+ exports.default = internalServer;
4204
1546
  exports.linkDepthApi = makeLinkDepthApi;
4205
1547
  //# sourceMappingURL=contensis-react-base.js.map