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