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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +18 -478
  3. package/cjs/{App-b56aca04.js → App-DXro6av4.js} +215 -234
  4. package/cjs/App-DXro6av4.js.map +1 -0
  5. package/cjs/{ChangePassword.container-ae35785e.js → ChangePassword.container-ECjEXixF.js} +209 -286
  6. package/cjs/ChangePassword.container-ECjEXixF.js.map +1 -0
  7. package/cjs/CookieHelper.class-C3Eqoze9.js +471 -0
  8. package/cjs/CookieHelper.class-C3Eqoze9.js.map +1 -0
  9. package/cjs/{RouteLoader-c06dccd5.js → RouteLoader-BFc-Wl6M.js} +55 -68
  10. package/cjs/RouteLoader-BFc-Wl6M.js.map +1 -0
  11. package/cjs/{ContensisDeliveryApi-4fcf049d.js → SSRContext-CFeZxG9H.js} +165 -119
  12. package/cjs/SSRContext-CFeZxG9H.js.map +1 -0
  13. package/cjs/{ToJs-a8d8f3f0.js → ToJs-C9jwV7YB.js} +26 -80
  14. package/cjs/ToJs-C9jwV7YB.js.map +1 -0
  15. package/cjs/{_commonjsHelpers-b3309d7b.js → _commonjsHelpers-BJu3ubxk.js} +1 -1
  16. package/cjs/_commonjsHelpers-BJu3ubxk.js.map +1 -0
  17. package/cjs/client.js +67 -65
  18. package/cjs/client.js.map +1 -1
  19. package/cjs/contensis-react-base.js +387 -3294
  20. package/cjs/contensis-react-base.js.map +1 -1
  21. package/cjs/{fromJSLeaveImmer-e74c673c.js → fromJSLeaveImmer-Blvlk4t2.js} +3 -7
  22. package/{esm/fromJSLeaveImmer-0114ffcf.js.map → cjs/fromJSLeaveImmer-Blvlk4t2.js.map} +1 -1
  23. package/cjs/redux.js +19 -20
  24. package/cjs/redux.js.map +1 -1
  25. package/cjs/routing.js +13 -6
  26. package/cjs/routing.js.map +1 -1
  27. package/cjs/sagas-CbZhaRNd.js +6010 -0
  28. package/cjs/sagas-CbZhaRNd.js.map +1 -0
  29. package/cjs/search.js +105 -305
  30. package/cjs/search.js.map +1 -1
  31. package/cjs/selectors-wCs5fHD4.js +460 -0
  32. package/cjs/selectors-wCs5fHD4.js.map +1 -0
  33. package/cjs/{version-34d91f68.js → store-D07FOXvM.js} +44 -114
  34. package/cjs/store-D07FOXvM.js.map +1 -0
  35. package/cjs/{urls-6fcaf4c6.js → urls-DVIwGZmd.js} +1 -1
  36. package/{esm/urls-eac9a747.js.map → cjs/urls-DVIwGZmd.js.map} +1 -1
  37. package/cjs/user.js +12 -20
  38. package/cjs/user.js.map +1 -1
  39. package/cjs/util.js +109 -116
  40. package/cjs/util.js.map +1 -1
  41. package/cjs/{version-a410c88e.js → version-B7XFkBhY.js} +19 -22
  42. package/{esm/version-9f29becb.js.map → cjs/version-B7XFkBhY.js.map} +1 -1
  43. package/cjs/version-CM-bJ62L.js +20 -0
  44. package/cjs/version-CM-bJ62L.js.map +1 -0
  45. package/esm/{App-83107d7e.js → App-CIlf4cl4.js} +176 -195
  46. package/esm/App-CIlf4cl4.js.map +1 -0
  47. package/esm/{ChangePassword.container-76fd5e9b.js → ChangePassword.container-C0tFq0Tf.js} +191 -250
  48. package/esm/ChangePassword.container-C0tFq0Tf.js.map +1 -0
  49. package/esm/CookieHelper.class-FTURFpz3.js +464 -0
  50. package/esm/CookieHelper.class-FTURFpz3.js.map +1 -0
  51. package/esm/{RouteLoader-29fd689a.js → RouteLoader-D7HmVx5l.js} +40 -53
  52. package/esm/RouteLoader-D7HmVx5l.js.map +1 -0
  53. package/esm/{ContensisDeliveryApi-fe57a037.js → SSRContext-CkiWIvde.js} +159 -120
  54. package/esm/SSRContext-CkiWIvde.js.map +1 -0
  55. package/esm/{ToJs-df57f31d.js → ToJs-CpPNdcXS.js} +24 -77
  56. package/esm/ToJs-CpPNdcXS.js.map +1 -0
  57. package/esm/{_commonjsHelpers-1789f0cf.js → _commonjsHelpers-BFTU3MAI.js} +1 -1
  58. package/esm/_commonjsHelpers-BFTU3MAI.js.map +1 -0
  59. package/esm/client.js +55 -53
  60. package/esm/client.js.map +1 -1
  61. package/esm/contensis-react-base.js +318 -3223
  62. package/esm/contensis-react-base.js.map +1 -1
  63. package/esm/{fromJSLeaveImmer-0114ffcf.js → fromJSLeaveImmer-C_YACmOf.js} +2 -6
  64. package/{cjs/fromJSLeaveImmer-e74c673c.js.map → esm/fromJSLeaveImmer-C_YACmOf.js.map} +1 -1
  65. package/esm/redux.js +10 -9
  66. package/esm/redux.js.map +1 -1
  67. package/esm/routing.js +13 -4
  68. package/esm/routing.js.map +1 -1
  69. package/esm/sagas-xJU-zOpn.js +5916 -0
  70. package/esm/sagas-xJU-zOpn.js.map +1 -0
  71. package/esm/search.js +113 -311
  72. package/esm/search.js.map +1 -1
  73. package/esm/selectors-CBdCY0u3.js +396 -0
  74. package/esm/selectors-CBdCY0u3.js.map +1 -0
  75. package/esm/{version-3d9911e2.js → store-v2gyr6u2.js} +38 -85
  76. package/esm/store-v2gyr6u2.js.map +1 -0
  77. package/esm/{urls-eac9a747.js → urls-DfCisos-.js} +1 -1
  78. package/{cjs/urls-6fcaf4c6.js.map → esm/urls-DfCisos-.js.map} +1 -1
  79. package/esm/user.js +7 -13
  80. package/esm/user.js.map +1 -1
  81. package/esm/util.js +67 -75
  82. package/esm/util.js.map +1 -1
  83. package/esm/version-D773TD9j.js +15 -0
  84. package/esm/version-D773TD9j.js.map +1 -0
  85. package/esm/{version-9f29becb.js → version-DvjTUbcA.js} +6 -9
  86. package/{cjs/version-a410c88e.js.map → esm/version-DvjTUbcA.js.map} +1 -1
  87. package/models/app/App.d.ts +1 -1
  88. package/models/app/pages/VersionInfo/components/VersionInfo.d.ts +4 -1
  89. package/models/app/pages/VersionInfo/components/VersionInfo.styled.d.ts +2 -1
  90. package/models/client/client.d.ts +1 -1
  91. package/models/index.d.ts +1 -2
  92. package/models/models/AppRouteProps.d.ts +11 -0
  93. package/models/{redux/appstate.d.ts → models/AppState.d.ts} +3 -3
  94. package/models/models/ContentTypeMapping.d.ts +89 -0
  95. package/models/models/EntryMapper.d.ts +3 -0
  96. package/models/models/GetRouteActionArgs.d.ts +15 -0
  97. package/models/models/MatchedRoute.d.ts +4 -0
  98. package/models/models/ReduxInjector.d.ts +5 -0
  99. package/models/models/RequireLogin.d.ts +6 -0
  100. package/models/models/RouteComponent.d.ts +4 -0
  101. package/models/models/RouteComponentProps.d.ts +9 -0
  102. package/models/models/RouteLoaderProps.d.ts +9 -0
  103. package/models/models/RouteNode.d.ts +5 -0
  104. package/models/models/SSRContext.d.ts +11 -0
  105. package/models/models/StaticRoute.d.ts +61 -0
  106. package/models/models/WithEvents.d.ts +58 -0
  107. package/models/models/config/AppConfig.d.ts +12 -0
  108. package/models/{config.d.ts → models/config/ServerConfig.d.ts} +3 -12
  109. package/models/models/config/StateType.d.ts +1 -0
  110. package/models/models/config/index.d.ts +3 -0
  111. package/models/models/index.d.ts +16 -0
  112. package/models/redux/actions/index.d.ts +2 -2
  113. package/models/redux/sagas/navigation.d.ts +1 -3
  114. package/models/redux/selectors/index.d.ts +2 -2
  115. package/models/redux/store/injectors.d.ts +16 -4
  116. package/models/redux/store/store.d.ts +10 -4
  117. package/models/redux/types/index.d.ts +2 -2
  118. package/models/redux/types/navigation.d.ts +3 -3
  119. package/models/redux/types/version.d.ts +2 -2
  120. package/models/routing/components/Redirect.d.ts +1 -1
  121. package/models/routing/components/RouteLoader.d.ts +1 -1
  122. package/models/routing/components/StaticRouteLoader.d.ts +1 -1
  123. package/models/routing/components/Status.d.ts +1 -1
  124. package/models/routing/redux/actions.d.ts +3 -4
  125. package/models/routing/redux/selectors.d.ts +2 -2
  126. package/models/routing/redux/types.d.ts +11 -11
  127. package/models/routing/util/find-contenttype-mapping.d.ts +1 -1
  128. package/models/routing/util/queries.d.ts +2 -2
  129. package/models/search/containers/withListing.d.ts +4 -1
  130. package/models/search/containers/withSearch.d.ts +4 -1
  131. package/models/search/models/Queries.d.ts +4 -2
  132. package/models/search/models/Search.d.ts +8 -1
  133. package/models/search/models/SearchActions.d.ts +3 -2
  134. package/models/search/models/SearchState.d.ts +5 -1
  135. package/models/search/redux/reducers.d.ts +2 -257
  136. package/models/search/redux/schema.d.ts +1 -1
  137. package/models/search/redux/selectors.d.ts +5 -5
  138. package/models/search/search/ContensisDeliveryApi.d.ts +2 -2
  139. package/models/search/search/ToJs.d.ts +1 -1
  140. package/models/search/search/expressions.d.ts +3 -3
  141. package/models/search/search/util.d.ts +17 -2
  142. package/models/search/transformations/searchresult-to-state.mapper.d.ts +1 -2
  143. package/models/server/features/caching/cacheDuration.schema.d.ts +1 -0
  144. package/models/server/features/linkdepth-api/search.d.ts +1 -1
  145. package/models/server/features/static-assets/index.d.ts +1 -1
  146. package/models/server/internalServer.d.ts +1 -1
  147. package/models/server/util/bundles.d.ts +1 -1
  148. package/models/server/util/headers.d.ts +1 -1
  149. package/models/server/webApp.d.ts +1 -1
  150. package/models/user/components/Login.d.ts +1 -1
  151. package/models/user/components/LoginForm.d.ts +6 -6
  152. package/models/user/components/LogoutForm.d.ts +4 -4
  153. package/models/user/components.styled/Login.styled.d.ts +1 -1
  154. package/models/user/components.styled/LoginForm.styled.d.ts +1 -1
  155. package/models/user/hocs/withLogin.d.ts +4 -4
  156. package/models/user/hocs/withRegistration.d.ts +6 -3
  157. package/models/user/hooks/useLogin.d.ts +4 -4
  158. package/models/user/redux/actions.d.ts +7 -6
  159. package/models/user/redux/sagas/index.d.ts +1 -1
  160. package/models/user/redux/sagas/login.d.ts +5 -17
  161. package/models/user/redux/selectors.d.ts +1 -2
  162. package/models/user/redux/types.d.ts +21 -21
  163. package/models/user/state.d.ts +12 -0
  164. package/models/user/transformations/mapClientCredentials.d.ts +3 -1
  165. package/models/user/util/ContensisManagementApi.d.ts +10 -9
  166. package/models/user/util/CookieConstants.d.ts +1 -0
  167. package/models/user/util/CookieHelper.class.d.ts +8 -4
  168. package/models/user/util/LoginHelper.class.d.ts +25 -37
  169. package/models/user/util/OidcUserManager.d.ts +1 -1
  170. package/models/user/util/matchGroups.d.ts +1 -1
  171. package/models/util/CachedDeliveryApi.d.ts +11 -10
  172. package/models/util/ContensisDeliveryApi.d.ts +11 -7
  173. package/models/util/SSRContext.d.ts +29 -0
  174. package/models/util/index.d.ts +1 -0
  175. package/models/util/json-mapper.d.ts +4 -5
  176. package/package.json +71 -92
  177. package/cjs/App-b56aca04.js.map +0 -1
  178. package/cjs/ChangePassword.container-ae35785e.js.map +0 -1
  179. package/cjs/ContensisDeliveryApi-4fcf049d.js.map +0 -1
  180. package/cjs/CookieConstants-000427db.js +0 -10
  181. package/cjs/CookieConstants-000427db.js.map +0 -1
  182. package/cjs/RouteLoader-c06dccd5.js.map +0 -1
  183. package/cjs/ToJs-a8d8f3f0.js.map +0 -1
  184. package/cjs/_commonjsHelpers-b3309d7b.js.map +0 -1
  185. package/cjs/forms.js +0 -5998
  186. package/cjs/forms.js.map +0 -1
  187. package/cjs/reducers-73a03ef4.js +0 -257
  188. package/cjs/reducers-73a03ef4.js.map +0 -1
  189. package/cjs/sagas-570f23ba.js +0 -2175
  190. package/cjs/sagas-570f23ba.js.map +0 -1
  191. package/cjs/selectors-14caa813.js +0 -228
  192. package/cjs/selectors-14caa813.js.map +0 -1
  193. package/cjs/version-34d91f68.js.map +0 -1
  194. package/esm/App-83107d7e.js.map +0 -1
  195. package/esm/ChangePassword.container-76fd5e9b.js.map +0 -1
  196. package/esm/ContensisDeliveryApi-fe57a037.js.map +0 -1
  197. package/esm/CookieConstants-3d3b6531.js +0 -6
  198. package/esm/CookieConstants-3d3b6531.js.map +0 -1
  199. package/esm/RouteLoader-29fd689a.js.map +0 -1
  200. package/esm/ToJs-df57f31d.js.map +0 -1
  201. package/esm/_commonjsHelpers-1789f0cf.js.map +0 -1
  202. package/esm/forms.js +0 -5984
  203. package/esm/forms.js.map +0 -1
  204. package/esm/reducers-aa8cef1e.js +0 -234
  205. package/esm/reducers-aa8cef1e.js.map +0 -1
  206. package/esm/sagas-07e82e18.js +0 -2083
  207. package/esm/sagas-07e82e18.js.map +0 -1
  208. package/esm/selectors-691caf02.js +0 -186
  209. package/esm/selectors-691caf02.js.map +0 -1
  210. package/esm/version-3d9911e2.js.map +0 -1
  211. package/models/forms/index.d.ts +0 -1
  212. package/models/routing/routes.d.ts +0 -133
@@ -1,16 +1,16 @@
1
- import { c as cachedSearch, d as deliveryApi } from './ContensisDeliveryApi-fe57a037.js';
1
+ import { c as cachedSearch, d as deliveryApi, S as SSRContextProvider } from './SSRContext-CkiWIvde.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 { a8 as defaultExpressions, a9 as termExpressions, aa as contentTypeIdExpression, ab as filterExpressions, ac as orderByExpression, ad as customWhereExpressions, ae as cloneDeep } from './sagas-xJU-zOpn.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 './urls-DfCisos-.js';
14
14
  import 'isomorphic-fetch';
15
15
  import express from 'express';
16
16
  import http from 'http';
@@ -19,36 +19,37 @@ import fs from 'fs';
19
19
  import path from 'path';
20
20
  import { path as path$1 } from 'app-root-path';
21
21
  import { renderToString } from 'react-dom/server';
22
- import require$$1 from 'history';
23
- import require$$2, { matchRoutes } from 'react-router-dom';
22
+ import { StaticRouter } from 'react-router-dom/server';
23
+ import { matchRoutes } from 'react-router-dom';
24
24
  import { Helmet } from 'react-helmet';
25
25
  import { ServerStyleSheet } from 'styled-components';
26
26
  import serialize from 'serialize-javascript';
27
27
  import minifyCssString from 'minify-css-string';
28
28
  import { ChunkExtractor, ChunkExtractorManager } from '@loadable/server';
29
- import { identity, noop } from 'lodash';
30
- import { c as commonjsGlobal } from './_commonjsHelpers-1789f0cf.js';
29
+ import { noop, identity } from 'lodash';
31
30
  import { buildCleaner } from 'lodash-clean';
32
31
  import { CookiesProvider } from 'react-cookie';
32
+ import { a as Cookies } from './CookieHelper.class-FTURFpz3.js';
33
33
  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';
34
+ import { c as createStore } from './store-v2gyr6u2.js';
35
+ import { h as history, p as pickProject, r as rootSaga } from './App-CIlf4cl4.js';
36
+ export { A as ReactApp } from './App-CIlf4cl4.js';
37
+ import { s as setVersionStatus, d as setVersion } from './version-DvjTUbcA.js';
38
+ import { m as mergeStaticRoutes, H as HttpContext } from './RouteLoader-D7HmVx5l.js';
39
+ import { a3 as selectSurrogateKeys, a4 as selectSsrApiCalls, j as selectRouteEntry, f as selectCurrentProject, g as getImmutableOrJS, d as setCurrentProject, K as selectCurrentSearch } from './selectors-CBdCY0u3.js';
40
40
  import chalk from 'chalk';
41
- import './CookieConstants-3d3b6531.js';
42
41
  import 'loglevel';
43
42
  import '@redux-saga/core/effects';
43
+ import './_commonjsHelpers-BFTU3MAI.js';
44
44
  import 'redux';
45
45
  import 'redux-thunk';
46
46
  import 'redux-saga';
47
- import 'redux-injectors';
48
- import './reducers-aa8cef1e.js';
47
+ import 'redux-injectors-19';
48
+ import 'history';
49
49
  import 'await-to-js';
50
- import './ChangePassword.container-76fd5e9b.js';
51
- import './ToJs-df57f31d.js';
50
+ import './version-D773TD9j.js';
51
+ import './ChangePassword.container-C0tFq0Tf.js';
52
+ import './ToJs-CpPNdcXS.js';
52
53
 
53
54
  /**
54
55
  * Util class holds our search results helper boilerplate methods
@@ -57,27 +58,21 @@ class Util {
57
58
  static GetIds(entries, fieldId) {
58
59
  if (fieldId) {
59
60
  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 => {
61
+ var _e$fieldId, _e$fieldId2;
62
+ 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
63
  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) || '';
64
+ return f === null || f === void 0 || (_f$sys = f.sys) === null || _f$sys === void 0 ? void 0 : _f$sys.id;
65
+ }) : (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
66
  }).flat();
68
67
  }
69
-
70
68
  return entries === null || entries === void 0 ? void 0 : entries.map(e => {
71
69
  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) || '';
70
+ return (e === null || e === void 0 || (_e$sys = e.sys) === null || _e$sys === void 0 ? void 0 : _e$sys.id) || '';
74
71
  });
75
72
  }
76
-
77
73
  static GetItems(result) {
78
74
  return this.GetResults(result) ? result.items : [];
79
75
  }
80
-
81
76
  static GetResults(result) {
82
77
  if (result !== null && result !== void 0 && result.items) {
83
78
  return result;
@@ -85,20 +80,18 @@ class Util {
85
80
  return null;
86
81
  }
87
82
  }
88
-
89
83
  }
90
84
  const mergeResults = (results, parentResults, replaceContentTypeIds, linkFieldId) => results.map(r => {
91
85
  if (replaceContentTypeIds.some(c => c === r.sys.contentTypeId)) {
92
86
  const resolvedParent = parentResults === null || parentResults === void 0 ? void 0 : parentResults.find(e => {
93
87
  var _e$linkFieldId;
94
-
95
88
  return (_e$linkFieldId = e[linkFieldId]) === null || _e$linkFieldId === void 0 ? void 0 : _e$linkFieldId.some(l => {
96
89
  var _l$sys;
97
-
98
90
  return ((_l$sys = l.sys) === null || _l$sys === void 0 ? void 0 : _l$sys.id) === r.sys.id;
99
91
  });
100
92
  });
101
- if (resolvedParent) return { ...resolvedParent,
93
+ if (resolvedParent) return {
94
+ ...resolvedParent,
102
95
  ...r,
103
96
  entryTitle: resolvedParent.entryTitle,
104
97
  entryDescription: resolvedParent.entryDescription,
@@ -106,12 +99,9 @@ const mergeResults = (results, parentResults, replaceContentTypeIds, linkFieldId
106
99
  originalSys: r.sys
107
100
  };else return r;
108
101
  }
109
-
110
102
  return r;
111
103
  }).filter(r => r);
112
104
 
113
- /* eslint-disable no-console */
114
-
115
105
  /**
116
106
  * Builds our complete Delivery API Query object from a set of provided arguments
117
107
  * @param queryParams
@@ -136,13 +126,12 @@ const searchQuery = ({
136
126
  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
127
  const query = new Query(...expressions$1);
138
128
  query.orderBy = orderByExpression(orderBy || []);
139
-
140
129
  if (fields && fields.length > 0) {
141
130
  query.fields = fields;
142
- } // (query as any).includeArchived = true;
143
- // (query as any).includeDeleted = true;
144
-
131
+ }
145
132
 
133
+ // (query as any).includeArchived = true;
134
+ // (query as any).includeDeleted = true;
146
135
  query.pageIndex = pageIndex;
147
136
  query.pageSize = pageSize;
148
137
  return query;
@@ -165,7 +154,8 @@ const finalQuery = ({
165
154
  webpageTemplates,
166
155
  weightedSearchFields
167
156
  }, 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(
157
+ 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 || [])
158
+ // Op.and(
169
159
  // ...sharedFilters.map(sf =>
170
160
  // Op.not(exp.fieldExpression(sf.key, true, 'exists')[0])
171
161
  // ),
@@ -174,17 +164,17 @@ const finalQuery = ({
174
164
  )] : [])), ...children.map(child => Op.and(...contentTypeIdExpression(child.contentTypeIds, child.webpageTemplates, child.assetTypes), ...filterExpressions(child.sharedFilters || []), ...filterExpressions(child.idFilters || [])))), ...termExpressions(searchTerm || '', weightedSearchFields || [])];
175
165
  const query = new Query(...expressions$1);
176
166
  query.orderBy = orderByExpression(orderBy || []);
177
-
178
167
  if (fields && fields.length > 0) {
179
168
  query.fields = fields;
180
- } // (query as any).includeArchived = true;
181
- // (query as any).includeDeleted = true;
182
-
169
+ }
183
170
 
171
+ // (query as any).includeArchived = true;
172
+ // (query as any).includeDeleted = true;
184
173
  query.pageIndex = pageIndex || 0;
185
174
  query.pageSize = pageSize;
186
175
  return query;
187
176
  };
177
+
188
178
  /**
189
179
  * Create a filter expression from a provided filters configuration object
190
180
  * and populate them based on the presence of that key in params, filter
@@ -193,13 +183,10 @@ const finalQuery = ({
193
183
  * @param params request.query object from Express middleware
194
184
  * @returns FilterExpression[] we can use to use with searchQuery function
195
185
  */
196
-
197
186
  const makeFilterExpressions = (f, params) => {
198
187
  const expressions = [];
199
-
200
188
  for (const [paramKey, filterConfig] of Object.entries(f)) {
201
189
  var _params$paramKey;
202
-
203
190
  const filterValues = (_params$paramKey = params[paramKey]) === null || _params$paramKey === void 0 ? void 0 : _params$paramKey.split(',');
204
191
  if (typeof filterValues !== 'undefined') expressions.push({
205
192
  key: typeof filterConfig === 'object' ? filterConfig.fieldId : filterConfig,
@@ -208,7 +195,6 @@ const makeFilterExpressions = (f, params) => {
208
195
  logicOperator: typeof filterConfig === 'object' && filterConfig.logicOperator ? filterConfig.logicOperator : 'or'
209
196
  });
210
197
  }
211
-
212
198
  return expressions;
213
199
  };
214
200
  const makeDerivedIdsFilterExpression = (prevFieldId, entries, ownIds = false, alwaysApplyFilter = false) => {
@@ -255,32 +241,18 @@ class QueryLevelResults {
255
241
  parent: _parent,
256
242
  debug = false
257
243
  }) {
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
244
  this.validatedLinks = [];
267
- this.parent = void 0;
268
245
  this.children = [];
269
- this.runFirstQuery = void 0;
270
- this.runFinalQuery = void 0;
271
246
  this.params = {};
272
- this.debug = void 0;
273
247
  this.firstQuery = new Query$1();
274
248
  this.firstResults = {};
275
249
  this.finalQuery = new Query$1();
276
250
  this.finalResults = {};
277
-
278
251
  this.AddChild = ({
279
252
  child
280
253
  }) => {
281
254
  this.children.push(child);
282
255
  };
283
-
284
256
  this.RunFirstQuery = async () => {
285
257
  const {
286
258
  firstQuery: query,
@@ -288,18 +260,17 @@ class QueryLevelResults {
288
260
  parent,
289
261
  runFirstQuery
290
262
  } = this;
291
-
292
263
  if (parent !== null && parent !== void 0 && parent.validatedLinks.length) {
293
264
  // add any idFilters derived from parent query results
294
265
  appendSearchQueryFilters(query, makeFilterExpressions(Object.fromEntries(parent.validatedLinks.map(vl => [vl.linkFieldId, {
295
266
  fieldId: `sys.id`
296
267
  }])), Object.fromEntries(parent.validatedLinks.map(vl => [vl.linkFieldId, vl.entryIds.join(',') || `no ids from parent ${parent.level}`]))));
297
268
  }
298
-
299
269
  if (runFirstQuery) {
300
270
  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
271
+ this.firstResults = await cachedSearch.searchUsingPost(query, 0, params.projectId);
302
272
 
273
+ // mapResultsToValidatedLinks
303
274
  for (const linkFieldId of this.linkFieldIds) {
304
275
  this.validatedLinks.push({
305
276
  contentTypeId: this.linkFields[linkFieldId].contentTypeId || '',
@@ -309,7 +280,6 @@ class QueryLevelResults {
309
280
  }
310
281
  }
311
282
  };
312
-
313
283
  this.RunFinalQuery = async () => {
314
284
  const {
315
285
  level,
@@ -318,31 +288,29 @@ class QueryLevelResults {
318
288
  params,
319
289
  runFinalQuery
320
290
  } = this;
321
-
322
291
  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
-
292
+ const firstChild = children === null || children === void 0 ? void 0 : children[0];
293
+ // add any idFilters derived from child query results
325
294
  if (firstChild) appendSearchQueryFilters(query, makeFilterExpressions(Object.fromEntries(firstChild.validatedLinks.map(vl => [vl.linkFieldId, {
326
295
  fieldId: `${vl.linkFieldId}.sys.id`
327
296
  }])), Object.fromEntries(firstChild.validatedLinks.map(vl => [vl.linkFieldId, vl.entryIds.join(',') || `no ids from child ${firstChild.level}`]))));
328
297
  }
329
-
330
298
  if (level === 0 && this.returnEntries) {
331
299
  // This is the final query to be run and response returned to the caller
332
300
  // Only this bit cares about linkDepth, fields and pagination parameters
333
301
  query.fields = JSON.parse(params.fields || '[]');
334
302
  query.pageSize = params.pageSize;
335
- query.pageIndex = params.pageIndex; // query.orderBy = params.orderBy;
303
+ query.pageIndex = params.pageIndex;
304
+ // query.orderBy = params.orderBy;
336
305
  }
337
-
338
306
  if (runFinalQuery) {
339
307
  if (this.debug) console.log(`\nLevel ${this.level} - Final query: \n${JSON.stringify(query.toJSON()).substring(0, 1000)}`);
340
308
  this.finalResults = await cachedSearch.searchUsingPost(query, Number(params.linkDepth) || 0, params.projectId);
341
- if (this.parent) this.parent.runFinalQuery = true; // mapResultsToValidatedLinks
309
+ if (this.parent) this.parent.runFinalQuery = true;
342
310
 
311
+ // mapResultsToValidatedLinks
343
312
  for (const linkFieldId of ((_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.linkFieldIds) || []) {
344
313
  var _this$parent, _this$parent2;
345
-
346
314
  this.validatedLinks.push({
347
315
  contentTypeId: ((_this$parent2 = this.parent) === null || _this$parent2 === void 0 ? void 0 : _this$parent2.linkFields[linkFieldId].contentTypeId) || '',
348
316
  linkFieldId,
@@ -351,17 +319,14 @@ class QueryLevelResults {
351
319
  }
352
320
  }
353
321
  };
354
-
355
322
  this.GetResultsEntries = () => {
356
323
  var _finalResults$items;
357
-
358
324
  const {
359
325
  finalResults,
360
326
  firstResults
361
327
  } = this;
362
328
  return finalResults !== null && finalResults !== void 0 && (_finalResults$items = finalResults.items) !== null && _finalResults$items !== void 0 && _finalResults$items.length ? finalResults.items : firstResults.items;
363
329
  };
364
-
365
330
  this.GetResults = () => {
366
331
  const {
367
332
  finalResults,
@@ -369,7 +334,6 @@ class QueryLevelResults {
369
334
  } = this;
370
335
  return typeof (finalResults === null || finalResults === void 0 ? void 0 : finalResults.totalCount) !== 'undefined' ? finalResults : firstResults;
371
336
  };
372
-
373
337
  this.level = _level;
374
338
  this.contentTypeIds = contentTypeIds;
375
339
  this.linkFields = linkFields;
@@ -406,11 +370,9 @@ class QueryLevelResults {
406
370
  versionStatus: _params.versionStatus
407
371
  });
408
372
  }
409
-
410
373
  }
411
374
 
412
375
  /* eslint-disable no-console */
413
-
414
376
  class LinkDepthSearchService {
415
377
  constructor({
416
378
  contentTypeId: _contentTypeId = '',
@@ -420,36 +382,27 @@ class LinkDepthSearchService {
420
382
  params: _params,
421
383
  debug = false
422
384
  }) {
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
385
  this.DoSearch = async () => {
432
386
  // Run queries "top-down" through each level of `linkField`
433
387
  for (const queryLevel of this.queryLevels) {
434
388
  await queryLevel.RunFirstQuery();
435
- } // Run queries "bottom-up" through each level of `linkField`
436
-
389
+ }
437
390
 
391
+ // Run queries "bottom-up" through each level of `linkField`
438
392
  for (const queryLevel of [...this.queryLevels].reverse()) {
439
393
  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
-
394
+ }
443
395
 
396
+ // Run a final query that will aggregate the results from all levels
397
+ // adding all levels to the query that have `returnEntries` set true
444
398
  return await this.RunFinalQueries();
445
399
  };
446
-
447
400
  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
401
+ const finalQueryLevels = this.queryLevels.filter(ql => ql.level > 0 && ql.returnEntries || ql.level === 0 && ql.returnEntries !== false);
449
402
 
403
+ // Decide if we need a further final query if any child level(s) have had `returnEntries` set to true
450
404
  if (finalQueryLevels.length > 1 || finalQueryLevels.length === 1 && finalQueryLevels[0].level !== 0) {
451
405
  var _params$orderBy;
452
-
453
406
  // Build final query
454
407
  const {
455
408
  contentTypeIds,
@@ -464,9 +417,9 @@ class LinkDepthSearchService {
464
417
  }
465
418
  }, {
466
419
  [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
420
+ })).flat() || [];
421
+ // This is the final query to be run and response returned to the caller
468
422
  // Only this bit cares about linkDepth, fields and pagination parameters
469
-
470
423
  const query = finalQuery({
471
424
  contentTypeIds,
472
425
  filters: makeFilterExpressions(filters, params),
@@ -474,7 +427,6 @@ class LinkDepthSearchService {
474
427
  idFilters: derivedIdFilters,
475
428
  fields: params.fields ? [...JSON.parse(params.fields), ...finalQueryLevels.map(l => {
476
429
  var _l$parent;
477
-
478
430
  return ((_l$parent = l.parent) === null || _l$parent === void 0 ? void 0 : _l$parent.linkFieldIds) || [];
479
431
  }).flat()] : [],
480
432
  orderBy: (_params$orderBy = params.orderBy) === null || _params$orderBy === void 0 ? void 0 : _params$orderBy.split(','),
@@ -484,7 +436,6 @@ class LinkDepthSearchService {
484
436
  versionStatus: params.versionStatus
485
437
  }, (finalQueryLevels === null || finalQueryLevels === void 0 ? void 0 : finalQueryLevels[0].children.filter(ql => ql.returnEntries).map(ql => {
486
438
  var _ql$parent, _ql$parent2;
487
-
488
439
  const entriesAtLevel = ql.GetResultsEntries() || ((_ql$parent = ql.parent) === null || _ql$parent === void 0 ? void 0 : _ql$parent.GetResultsEntries());
489
440
  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
441
  return {
@@ -495,29 +446,28 @@ class LinkDepthSearchService {
495
446
  };
496
447
  })) || []);
497
448
  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
449
+ const finalQueryResult = await cachedSearch.searchUsingPost(query, Number(params.linkDepth) || 0, params.projectId);
450
+
451
+ // Resolve any parent entries
499
452
 
500
453
  const resolveParentLevels = finalQueryLevels.filter(ql => ql.resolveFirstParent);
501
454
  let entries = finalQueryResult.items;
502
-
503
455
  for (const resolveParents of resolveParentLevels) {
504
456
  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?
457
+ 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,
458
+ // or entries?
507
459
  this.params, this.debug);
508
460
  }
509
-
510
- return { ...finalQueryResult,
461
+ return {
462
+ ...finalQueryResult,
511
463
  items: entries
512
464
  };
513
465
  } else {
514
466
  var _this$queryLevels$fin;
515
-
516
467
  if (this.debug) console.log(`\nNo further queries required\n`);
517
468
  return (_this$queryLevels$fin = this.queryLevels.find(ql => ql.level === 0)) === null || _this$queryLevels$fin === void 0 ? void 0 : _this$queryLevels$fin.GetResults();
518
469
  }
519
470
  };
520
-
521
471
  this.InitQueryLevels = () => {
522
472
  const createChildQueryLevels = (linkFields, parentQueryLevel, level = 1) => {
523
473
  return Object.entries(linkFields).map(([, {
@@ -550,7 +500,6 @@ class LinkDepthSearchService {
550
500
  return [thisLevel, ...createChildQueryLevels(linkFields, thisLevel, level + 1)];
551
501
  }).flat();
552
502
  };
553
-
554
503
  const {
555
504
  contentTypeIds,
556
505
  filters,
@@ -571,17 +520,17 @@ class LinkDepthSearchService {
571
520
  params,
572
521
  debug: this.debug
573
522
  });
574
- const queryLevels = [firstLevel, ...createChildQueryLevels(linkFields, firstLevel)]; // return queryLevels;
523
+ const queryLevels = [firstLevel, ...createChildQueryLevels(linkFields, firstLevel)];
524
+ // return queryLevels;
525
+
575
526
  // If we are only returning entries from level 0
576
527
  // we can skip running the first query and finalQuery will suffice
577
-
578
528
  if (queryLevels.find(ql => ql.returnEntries && ql.level !== 0)) return queryLevels;else return queryLevels.map(ql => {
579
- ql.runFirstQuery = false; // ql.runFinalQuery = false;
580
-
529
+ ql.runFirstQuery = false;
530
+ // ql.runFinalQuery = false;
581
531
  return ql;
582
532
  });
583
533
  };
584
-
585
534
  this.contentTypeIds = Array.isArray(_contentTypeId) ? _contentTypeId : [_contentTypeId];
586
535
  this.filters = _filters;
587
536
  this.sharedFilters = _sharedFilters;
@@ -590,7 +539,6 @@ class LinkDepthSearchService {
590
539
  this.debug = debug;
591
540
  this.queryLevels = this.InitQueryLevels();
592
541
  }
593
-
594
542
  }
595
543
 
596
544
  /**
@@ -610,10 +558,9 @@ const makeLinkDepthApi = (app, middlewareConfig) => {
610
558
  if (!contentTypeId || !linkFields || !uri) return;
611
559
  app.get(uri, makeLinkDepthMiddleware(middlewareConfig));
612
560
  };
561
+
613
562
  /** Create a content type hierarchy from supplied config and produces
614
563
  * a RequestHandler function to serve our Express middleware */
615
-
616
-
617
564
  const makeLinkDepthMiddleware = ({
618
565
  contentTypeId,
619
566
  filters = {},
@@ -629,8 +576,9 @@ const makeLinkDepthMiddleware = ({
629
576
  setCachingHeaders(res, {
630
577
  cacheControl: 'private',
631
578
  surrogateControl: '10'
632
- }); // Gather all params from the request, we will use them at the right query levels later
579
+ });
633
580
 
581
+ // Gather all params from the request, we will use them at the right query levels later
634
582
  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
583
  const result = await new LinkDepthSearchService({
636
584
  contentTypeId,
@@ -648,35 +596,25 @@ const makeLinkDepthMiddleware = ({
648
596
  res.json(error);
649
597
  }
650
598
  };
651
-
652
599
  return linkDepthMiddleware;
653
600
  } catch (error) {
654
601
  // This will be an error building the middleware
655
602
  // we can only serve what the error was as the request handler instead
656
603
  console.error(error);
657
-
658
604
  const errorMiddleware = async (req, res) => {
659
605
  res.statusCode = 500;
660
606
  res.json(JSON.stringify(error));
661
607
  };
662
-
663
608
  return errorMiddleware;
664
609
  }
665
610
  };
666
611
 
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
-
612
+ const servers$1 = SERVERS; /* global SERVERS */
613
+ const project = PROJECT; /* global PROJECT */
614
+ const alias$1 = ALIAS; /* global ALIAS */
676
615
  const deliveryApiHostname = url(alias$1, project).api;
677
616
  const assetProxy = httpProxy.createProxyServer();
678
617
  const deliveryProxy = httpProxy.createProxyServer();
679
-
680
618
  const reverseProxies = (app, reverseProxyPaths = []) => {
681
619
  deliveryApiProxy(deliveryProxy, app);
682
620
  app.all(reverseProxyPaths, (req, res) => {
@@ -692,10 +630,9 @@ const reverseProxies = (app, reverseProxyPaths = []) => {
692
630
  });
693
631
  });
694
632
  };
695
-
696
633
  const deliveryApiProxy = (apiProxy, app) => {
697
634
  // 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) => {
635
+ app.all(['/api/delivery/*', '/api/forms/*', '/api/image/*', '/authenticate/*'], (req, res) => {
699
636
  /* eslint-disable no-console */
700
637
  console.log(`Proxying api request to ${servers$1.alias}`);
701
638
  apiProxy.web(req, res, {
@@ -716,12 +653,14 @@ const CacheDuration = {
716
653
  static: '31536000',
717
654
  // Believe it or not these two max ages are the same in runtime
718
655
  expressStatic: '31557600h' // Believe it or not these two max ages are the same in runtime
719
-
720
656
  };
721
657
  const getCacheDuration = (status = 200) => {
722
- if (status > 400) return CacheDuration[404];
658
+ if (status >= 400) return CacheDuration[404];
723
659
  return CacheDuration[200];
724
660
  };
661
+ const alias = ALIAS; /* global ALIAS */
662
+
663
+ const anyUpdateHeader = `${alias}_any-update`;
725
664
 
726
665
  const replaceStaticPath = (str, staticFolderPath = 'static') => str.replace(/static\//g, `${staticFolderPath}/`);
727
666
 
@@ -731,13 +670,11 @@ const bundleManipulationMiddleware = ({
731
670
  staticFolderPath,
732
671
  staticRoutePath
733
672
  }) => (req, res, next) => {
734
- const filename = path.basename(req.path);
673
+ const filename = path.basename(encodeURI(req.path));
735
674
  const modernBundle = filename.endsWith('.mjs');
736
675
  const legacyBundle = filename.endsWith('.js');
737
-
738
676
  if ((legacyBundle || modernBundle) && filename.startsWith('runtime.')) {
739
677
  const jsRuntimeLocation = path.resolve(appRootPath, `dist/${staticFolderPath}/${modernBundle ? 'modern/js' : 'legacy/js'}/${filename}`);
740
-
741
678
  try {
742
679
  const jsRuntimeBundle = fs.readFileSync(jsRuntimeLocation, 'utf8');
743
680
  const modifiedBundle = replaceStaticPath(jsRuntimeBundle, staticRoutePath);
@@ -745,7 +682,6 @@ const bundleManipulationMiddleware = ({
745
682
  res.type('.js').send(modifiedBundle);
746
683
  return;
747
684
  } catch (readError) {
748
- // eslint-disable-next-line no-console
749
685
  console.log(`Unable to find js runtime bundle at '${jsRuntimeLocation}'`, readError);
750
686
  next();
751
687
  }
@@ -760,7 +696,6 @@ const bundleManipulationMiddleware = ({
760
696
  * @returns Response | next()
761
697
  * A middleware function to resolve /dist/static/startup.js under a supplied startupScriptFilename variable
762
698
  */
763
-
764
699
  const resolveStartupMiddleware = ({
765
700
  appRootPath,
766
701
  maxage,
@@ -769,7 +704,6 @@ const resolveStartupMiddleware = ({
769
704
  }) => async (req, res, next) => {
770
705
  if (startupScriptFilename !== 'startup.js' && req.path === `/${startupScriptFilename}`) {
771
706
  let startupFileLocation = '';
772
-
773
707
  try {
774
708
  const startupFilePaths = [`dist/static/startup.js`, `dist/${staticFolderPath}/startup.js`];
775
709
  let startupFilePath = '';
@@ -777,7 +711,8 @@ const resolveStartupMiddleware = ({
777
711
  try {
778
712
  fs.accessSync(testPath);
779
713
  startupFilePath = testPath;
780
- } catch (ex) {// Do nothing
714
+ } catch (ex) {
715
+ // Do nothing
781
716
  }
782
717
  });
783
718
  startupFileLocation = path.resolve(appRootPath, startupFilePath);
@@ -814,7 +749,8 @@ const staticAssets = (app, {
814
749
  maxage: CacheDuration.static,
815
750
  startupScriptFilename: scripts.startup || startupScriptFilename,
816
751
  staticFolderPath
817
- }), // eslint-disable-next-line import/no-named-as-default-member
752
+ }),
753
+ // eslint-disable-next-line import/no-named-as-default-member
818
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
@@ -822,11 +758,8 @@ const staticAssets = (app, {
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,3023 +776,169 @@ 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
- },
883
-
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.`);
886
- },
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.`);
890
- },
891
-
892
- back() {
893
- throw new Error(`You cannot use navigator.back() on the server because it is a stateless ` + `environment.`);
894
- },
791
+ const handleResponse = (request, response, content, send = 'send') => {
792
+ // console.log('---', response.statusCode, '---');
793
+ response[send](content);
794
+ };
895
795
 
896
- forward() {
897
- throw new Error(`You cannot use navigator.forward() on the server because it is a stateless ` + `environment.`);
796
+ const readFileSync = path => fs.readFileSync(path, 'utf8');
797
+ const loadableBundleData = ({
798
+ stats,
799
+ templates
800
+ }, staticRoutePath, build) => {
801
+ const bundle = {};
802
+ try {
803
+ bundle.stats = stats ? JSON.parse(readFileSync(stats.replace('/target', build ? `/${build}` : ''))) : null;
804
+ } catch (ex) {
805
+ // console.info(ex);
806
+ bundle.stats = null;
807
+ }
808
+ try {
809
+ bundle.templates = {
810
+ templateHTML: replaceStaticPath(readFileSync(templates.html.replace('/target', build ? `/${build}` : '')), staticRoutePath),
811
+ templateHTMLStatic: replaceStaticPath(readFileSync(templates.static.replace('/target', build ? `/${build}` : '')), staticRoutePath),
812
+ templateHTMLFragment: replaceStaticPath(readFileSync(templates.fragment.replace('/target', build ? `/${build}` : '')), staticRoutePath)
813
+ };
814
+ } catch (ex) {
815
+ // console.info(ex);
816
+ bundle.templates = null;
817
+ }
818
+ return bundle;
819
+ };
820
+ const loadableChunkExtractors = () => {
821
+ const commonLoadableExtractor = new ChunkExtractor({
822
+ stats: {}
823
+ });
824
+ try {
825
+ let modern;
826
+ let legacy;
827
+ try {
828
+ modern = new ChunkExtractor({
829
+ entrypoints: ['app'],
830
+ namespace: 'modern',
831
+ statsFile: path.resolve('dist/modern/loadable-stats.json')
832
+ });
833
+ } catch (e) {
834
+ console.info('@loadable/server modern ChunkExtractor not available');
898
835
  }
899
-
836
+ try {
837
+ legacy = new ChunkExtractor({
838
+ entrypoints: ['app'],
839
+ namespace: 'legacy',
840
+ statsFile: path.resolve('dist/legacy/loadable-stats.json')
841
+ });
842
+ } catch (e) {
843
+ console.info('@loadable/server legacy ChunkExtractor not available');
844
+ }
845
+ commonLoadableExtractor.addChunk = chunk => {
846
+ var _modern, _legacy, _legacy2;
847
+ (_modern = modern) === null || _modern === void 0 || _modern.addChunk(chunk);
848
+ if (typeof ((_legacy = legacy) === null || _legacy === void 0 ? void 0 : _legacy.stats.assetsByChunkName[chunk]) !== 'undefined') (_legacy2 = legacy) === null || _legacy2 === void 0 || _legacy2.addChunk(chunk);
849
+ };
850
+ return {
851
+ commonLoadableExtractor,
852
+ modern,
853
+ legacy
854
+ };
855
+ } catch (e) {
856
+ console.info('@loadable/server no ChunkExtractor available');
857
+ return {
858
+ commonLoadableExtractor
859
+ };
860
+ }
861
+ };
862
+ const getBundleData = (config, staticRoutePath) => {
863
+ const bundleData = {
864
+ default: loadableBundleData(config, staticRoutePath),
865
+ legacy: loadableBundleData(config, staticRoutePath, 'legacy'),
866
+ modern: loadableBundleData(config, staticRoutePath, 'modern')
900
867
  };
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
- });
909
- }
910
-
911
- var StaticRouter_1 = server$1.StaticRouter = StaticRouter;
912
-
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;
868
+ if (!bundleData.default || Object.keys(bundleData.default || {}).length === 0) bundleData.default = bundleData.legacy || bundleData.modern;
869
+ return bundleData;
870
+ };
927
871
 
928
- /**
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
- */
872
+ // export const buildBundleTags = (
873
+ // bundles,
874
+ // differentialBundles = false,
875
+ // staticRoutePath = 'static',
876
+ // attributes = ''
877
+ // ) => {
878
+ // // Take the bundles returned from Loadable.Capture
879
+ // const bundleTags = bundles
880
+ // .filter(b => b)
881
+ // .map(bundle => {
882
+ // if (bundle.publicPath.includes('/modern/'))
883
+ // return differentialBundles
884
+ // ? `<script ${attributes} type="module" src="${replaceStaticPath(
885
+ // bundle.publicPath,
886
+ // staticRoutePath
887
+ // )}"></script>`
888
+ // : null;
889
+ // return `<script ${attributes}${
890
+ // differentialBundles ? ' nomodule' : ''
891
+ // } src="${replaceStaticPath(
892
+ // bundle.publicPath,
893
+ // staticRoutePath
894
+ // )}"></script>`;
895
+ // })
896
+ // .filter(f => f);
960
897
 
961
- function eq$2(value, other) {
962
- return value === other || (value !== value && other !== other);
963
- }
898
+ // return bundleTags;
899
+ // };
964
900
 
965
- var eq_1 = eq$2;
901
+ const getBundleTags = (loadableExtractor, scripts, staticRoutePath = 'static') => {
902
+ let startupTag = '';
903
+ // Add the static startup script to the bundleTags
904
+ if (scripts !== null && scripts !== void 0 && scripts.startup) startupTag = `<script ${stringifyAttributes(scripts.attributes)} src="/${staticRoutePath}/${scripts.startup}"></script>`;
966
905
 
967
- var eq$1 = eq_1;
906
+ // Get the script tags from their respective extractor instances
907
+ if (loadableExtractor) {
908
+ var _loadableExtractor$le, _loadableExtractor$mo;
909
+ const legacyScriptTags = (_loadableExtractor$le = loadableExtractor.legacy) === null || _loadableExtractor$le === void 0 ? void 0 : _loadableExtractor$le.getScriptTags({
910
+ nomodule: 'nomodule'
911
+ });
912
+ const modernScriptTags = (_loadableExtractor$mo = loadableExtractor.modern) === null || _loadableExtractor$mo === void 0 ? void 0 : _loadableExtractor$mo.getScriptTags({
913
+ type: 'module'
914
+ });
915
+ const scriptTags = `${startupTag}${legacyScriptTags || ''}${modernScriptTags || ''}`.replace(/"\/static\//g, `"/${staticRoutePath}/`);
916
+ return scriptTags;
917
+ }
918
+ return startupTag;
919
+ };
968
920
 
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;
982
- }
983
- }
984
- return -1;
985
- }
986
-
987
- var _assocIndexOf = assocIndexOf$4;
988
-
989
- var assocIndexOf$3 = _assocIndexOf;
990
-
991
- /** Used for built-in method references. */
992
- var arrayProto = Array.prototype;
993
-
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
3828
-
3829
- if (loadableExtractor) {
3830
- var _loadableExtractor$le, _loadableExtractor$mo;
3831
-
3832
- const legacyScriptTags = (_loadableExtractor$le = loadableExtractor.legacy) === null || _loadableExtractor$le === void 0 ? void 0 : _loadableExtractor$le.getScriptTags({
3833
- nomodule: 'nomodule'
3834
- });
3835
- const modernScriptTags = (_loadableExtractor$mo = loadableExtractor.modern) === null || _loadableExtractor$mo === void 0 ? void 0 : _loadableExtractor$mo.getScriptTags({
3836
- type: 'module'
3837
- });
3838
- const scriptTags = `${startupTag}${legacyScriptTags || ''}${modernScriptTags || ''}`.replace(/"\/static\//g, `"/${staticRoutePath}/`);
3839
- return scriptTags;
3840
- }
3841
-
3842
- return startupTag;
3843
- };
3844
-
3845
- const alias = ALIAS;
3846
- /* global ALIAS */
3847
-
3848
- const addStandardHeaders = (state, response, packagejson, groups) => {
3849
- if (state) {
3850
- 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(' ');
3857
- const surrogateKeyHeader = `${packagejson.name}-app ${surrogateKeys}`;
3858
- response.setHeader('surrogate-key', surrogateKeyHeader);
3859
- addVarnishAuthenticationHeaders(state, response, groups);
3860
- response.setHeader('surrogate-control', `max-age=${getCacheDuration(response.statusCode)}`);
3861
- } catch (e) {
3862
- console.info('Error Adding headers', e.message);
921
+ const addStandardHeaders = (state, response, packagejson, groups) => {
922
+ if (state) {
923
+ try {
924
+ const routingSurrogateKeys = selectSurrogateKeys(state);
925
+ const apiCalls = selectSsrApiCalls(state);
926
+ const anyApiError = !!apiCalls.find(([status]) => status >= 400);
927
+
928
+ // Check length of surrogate keys and prevent potential header overflow errors in prod
929
+ // Check for any error set in the page response
930
+ // And check if we have seen any error in any of the Delivery API calls
931
+ // - add `any-update` header that will indiscriminately
932
+ // invalidate the SSR page cache when any content is updated
933
+ const addAnyUpdateHeader = routingSurrogateKeys.length >= 2000 || response.statusCode >= 400 || anyApiError;
934
+ console.info(`[addStandardHeaders] ${addAnyUpdateHeader ? anyUpdateHeader : routingSurrogateKeys.length} surrogate keys for ${response.req.url}`);
935
+ const surrogateKeys = addAnyUpdateHeader ? anyUpdateHeader : routingSurrogateKeys.join(' ');
936
+ const surrogateKeyHeader = `${packagejson.name}-app ${surrogateKeys}`;
937
+ response.setHeader('surrogate-key', surrogateKeyHeader);
938
+ addVarnishAuthenticationHeaders(state, response, groups);
939
+ response.setHeader('surrogate-control', `max-age=${getCacheDuration(response.statusCode)}`);
940
+ } catch (e) {
941
+ console.info('[addStandardHeaders] Error adding headers', e.message);
3863
942
  }
3864
943
  }
3865
944
  };
@@ -3871,14 +950,12 @@ const addVarnishAuthenticationHeaders = (state, response, groups = {}) => {
3871
950
  const {
3872
951
  globalGroups,
3873
952
  allowedGroups
3874
- } = groups; // console.info(globalGroups, allowedGroups);
3875
-
953
+ } = groups;
954
+ // console.info(globalGroups, allowedGroups);
3876
955
  let allGroups = Array.from(globalGroups && globalGroups[project] || {});
3877
-
3878
956
  if (stateEntry && getImmutableOrJS(stateEntry, ['authentication', 'isLoginRequired']) && allowedGroups && allowedGroups[project]) {
3879
957
  allGroups = [...allGroups, ...allowedGroups[project]];
3880
958
  }
3881
-
3882
959
  response.header('x-contensis-viewer-groups', allGroups.join('|'));
3883
960
  } catch (e) {
3884
961
  console.info('Error adding authentication header', e);
@@ -3899,17 +976,17 @@ const getVersionInfo = staticFolderPath => {
3899
976
 
3900
977
  /* eslint-disable no-console */
3901
978
 
979
+ // Default exception types to add event listeners for
3902
980
  const handleDefaultEvents = ['uncaughtException', 'unhandledRejection'];
3903
981
  const unhandledExceptionHandler = (handleExceptions = handleDefaultEvents) => {
3904
982
  const exceptionTypes = Array.isArray(handleExceptions) ? handleExceptions : handleExceptions === false ? [] : handleDefaultEvents;
3905
-
3906
983
  for (const type of exceptionTypes) {
3907
984
  process.on(type, err => {
3908
985
  if (err && err instanceof Error) {
3909
986
  // Print a message to inform admins and developers the error should not be ignored
3910
987
  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
3912
-
988
+ 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`);
989
+ // Log the error to server console
3913
990
  console.error(err);
3914
991
  }
3915
992
  });
@@ -3930,6 +1007,7 @@ const webApp = (app, ReactApp, config) => {
3930
1007
  allowedGroups,
3931
1008
  globalGroups,
3932
1009
  disableSsrRedux,
1010
+ enableSsrCookies,
3933
1011
  handleResponses,
3934
1012
  handleExceptions = true
3935
1013
  } = config;
@@ -3942,24 +1020,20 @@ const webApp = (app, ReactApp, config) => {
3942
1020
 
3943
1021
  const versionInfo = getVersionInfo(staticFolderPath);
3944
1022
  app.get('/*', cookiesMiddleware(), async (request, response) => {
3945
- const {
3946
- url
3947
- } = request;
1023
+ const url = encodeURI(request.url);
3948
1024
  const matchedStaticRoute = matchRoutes(routes.StaticRoutes, request.path);
3949
1025
  const isStaticRoute = matchedStaticRoute && matchedStaticRoute.length > 0;
3950
-
3951
1026
  if (isStaticRoute) {
3952
1027
  mergeStaticRoutes(matchedStaticRoute);
3953
1028
  }
1029
+ const staticRoute = isStaticRoute ? matchedStaticRoute.pop() || null : null;
3954
1030
 
3955
- const staticRoute = isStaticRoute ? matchedStaticRoute.pop() || null : null; // Allow certain routes to avoid SSR
3956
-
1031
+ // Allow certain routes to avoid SSR
3957
1032
  const onlyDynamic = staticRoute && staticRoute.route.ssr === false;
3958
1033
  const onlySSR = staticRoute && staticRoute.route.ssrOnly === true;
1034
+ const normaliseQs = q => q && q.toLowerCase() === 'true' ? true : false;
3959
1035
 
3960
- const normaliseQs = q => q && q.toLowerCase() === 'true' ? true : false; // Determine functional params from QueryString and set access methods
3961
-
3962
-
1036
+ // Determine functional params from QueryString and set access methods
3963
1037
  const accessMethod = mapJson(request.query, {
3964
1038
  DYNAMIC: ({
3965
1039
  dynamic
@@ -3976,17 +1050,20 @@ const webApp = (app, ReactApp, config) => {
3976
1050
  });
3977
1051
  const context = {
3978
1052
  location: ''
3979
- }; // Track the current statusCode via the response object
3980
-
3981
- response.status(200); // Create a store (with a memory history) from our current url
1053
+ };
1054
+ // Track the current statusCode via the response object
1055
+ response.status(200);
3982
1056
 
3983
- const store = await createStore(withReducers, {}, history$1({
1057
+ // Create a store (with a memory history) from our current url
1058
+ const store = await createStore(withReducers, {}, history({
3984
1059
  initialEntries: [url]
3985
- }), stateType); // dispatch any global and non-saga related actions before calling our JSX
1060
+ }), stateType);
3986
1061
 
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
1062
+ // dispatch any global and non-saga related actions before calling our JSX
1063
+ const versionStatus = deliveryApi.getServerSideVersionStatus(request);
3989
1064
 
1065
+ // In server-side blocks world, the hostname requested by the client resides in the x-orig-host header
1066
+ // Because of this, we prioritize x-orig-host when setting our hostname
3990
1067
  const hostname = request.headers['x-orig-host'] || request.hostname;
3991
1068
  console.info(`Request for ${request.path} hostname: ${hostname} versionStatus: ${versionStatus}`);
3992
1069
  store.dispatch(setVersionStatus(versionStatus));
@@ -3997,43 +1074,55 @@ const webApp = (app, ReactApp, config) => {
3997
1074
  const loadableExtractor = loadableChunkExtractors();
3998
1075
  // Recast ChunkExtractorManager to avoid TS error `Property 'children' does not exist on type...`
3999
1076
  const ChunkExtractor = ChunkExtractorManager;
4000
- const jsx = /*#__PURE__*/React$1.createElement(ChunkExtractor, {
1077
+ const ssrCookies = enableSsrCookies ?
1078
+ // these cookies are managed by the cookiesMiddleware and contain listeners
1079
+ // when cookies are read or written in ssr can be added to the `set-cookie` response header
1080
+ request.universalCookies :
1081
+ // this is a stub cookie collection so cookie methods can be used in code
1082
+ new Cookies();
1083
+ const jsx = /*#__PURE__*/React.createElement(ChunkExtractor, {
4001
1084
  extractor: loadableExtractor.commonLoadableExtractor
4002
- }, /*#__PURE__*/React$1.createElement(CookiesProvider, {
4003
- cookies: request.universalCookies
4004
- }, /*#__PURE__*/React$1.createElement(Provider, {
1085
+ }, /*#__PURE__*/React.createElement(CookiesProvider, {
1086
+ cookies: ssrCookies
1087
+ }, /*#__PURE__*/React.createElement(Provider, {
4005
1088
  store: store
4006
- }, /*#__PURE__*/React$1.createElement(HttpContext.Provider, {
1089
+ }, /*#__PURE__*/React.createElement(HttpContext.Provider, {
4007
1090
  value: context
4008
- }, /*#__PURE__*/React$1.createElement(StaticRouter_1, {
1091
+ }, /*#__PURE__*/React.createElement(StaticRouter, {
4009
1092
  location: url
4010
- }, /*#__PURE__*/React$1.createElement(ReactApp, {
1093
+ }, /*#__PURE__*/React.createElement(SSRContextProvider, {
1094
+ request: request,
1095
+ response: response
1096
+ }, /*#__PURE__*/React.createElement(ReactApp, {
4011
1097
  routes: routes,
4012
1098
  withEvents: withEvents
4013
- }))))));
1099
+ })))))));
4014
1100
  const {
4015
1101
  templateHTML = '',
4016
1102
  templateHTMLFragment = '',
4017
1103
  templateHTMLStatic = ''
4018
- } = bundleData.default.templates || bundleData.legacy.templates || {}; // Serve a blank HTML page with client scripts to load the app in the browser
1104
+ } = bundleData.default.templates || bundleData.legacy.templates || {};
4019
1105
 
1106
+ // Serve a blank HTML page with client scripts to load the app in the browser
4020
1107
  if (accessMethod.DYNAMIC) {
4021
1108
  // 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
1109
+ renderToString(jsx);
4024
1110
 
1111
+ // Dynamic page render has only the necessary bundles to start up the app
1112
+ // and does not include any react-loadable code-split bundles
4025
1113
  const bundleTags = getBundleTags(loadableExtractor, scripts, staticRoutePath);
4026
1114
  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
1115
+ const responseHtmlDynamic = templateHTML.replace('{{TITLE}}', '').replace('{{SEO_CRITICAL_METADATA}}', '').replace('{{CRITICAL_CSS}}', '').replace('{{APP}}', '').replace('{{LOADABLE_CHUNKS}}', bundleTags).replace('{{REDUX_DATA}}', isDynamicHints);
1116
+ // Dynamic pages always return a 200 so we can run
4028
1117
  // the app and serve up all errors inside the client
4029
-
4030
1118
  response.setHeader('Surrogate-Control', `max-age=${getCacheDuration(200)}`);
4031
1119
  responseHandler(request, response, responseHtmlDynamic);
4032
- } // Render the JSX server side and send response as per access method options
4033
-
1120
+ }
4034
1121
 
1122
+ // Render the JSX server side and send response as per access method options
4035
1123
  if (!accessMethod.DYNAMIC) {
4036
1124
  store.runSaga(rootSaga(withSagas)).toPromise().then(() => {
1125
+ var _selectCurrentSearch;
4037
1126
  const sheet = new ServerStyleSheet();
4038
1127
  const html = renderToString(sheet.collectStyles(jsx));
4039
1128
  const helmet = Helmet.renderStatic();
@@ -4041,17 +1130,16 @@ const webApp = (app, ReactApp, config) => {
4041
1130
  const htmlAttributes = helmet.htmlAttributes.toString();
4042
1131
  let title = helmet.title.toString();
4043
1132
  const metadata = helmet.meta.toString().concat(helmet.base.toString()).concat(helmet.link.toString()).concat(helmet.script.toString()).concat(helmet.noscript.toString());
4044
-
4045
1133
  if (context.url) {
4046
1134
  return response.redirect(context.statusCode || 302, context.url);
4047
1135
  }
4048
-
4049
1136
  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
1137
+ const styleTags = sheet.getStyleTags();
4052
1138
 
1139
+ // After running rootSaga there should be an additional react-loadable
1140
+ // code-split bundles for any page components as well as core app bundles
4053
1141
  const bundleTags = getBundleTags(loadableExtractor, scripts, staticRoutePath);
4054
- let serialisedReduxData = serialize(buildCleaner({
1142
+ let clonedState = buildCleaner({
4055
1143
  isArray: identity,
4056
1144
  isBoolean: identity,
4057
1145
  isDate: identity,
@@ -4060,8 +1148,20 @@ const webApp = (app, ReactApp, config) => {
4060
1148
  isPlainObject: identity,
4061
1149
  isString: identity,
4062
1150
  isUndefined: noop
4063
- })(cloneDeep_1(reduxState)));
4064
-
1151
+ })(cloneDeep(reduxState));
1152
+ // These keys are used for preparing server-side response headers only
1153
+ // and are not required in the client at all except for debugging ssr
1154
+ if (!((_selectCurrentSearch = selectCurrentSearch(reduxState)) !== null && _selectCurrentSearch !== void 0 && _selectCurrentSearch.includes('includeApiCalls'))) {
1155
+ if (stateType === 'immutable') clonedState = clonedState.deleteIn(['routing', 'apiCalls']).deleteIn(['routing', 'surrogateKeys']);else {
1156
+ delete clonedState.routing.apiCalls;
1157
+ delete clonedState.routing.surrogateKeys;
1158
+ }
1159
+ }
1160
+ // Reset user state to prevent user details from being cached in SSR
1161
+ if (stateType === 'immutable') {
1162
+ clonedState = clonedState.delete('user');
1163
+ } else delete clonedState.user;
1164
+ let serialisedReduxData = serialize(clonedState);
4065
1165
  if (context.statusCode !== 404) {
4066
1166
  // For a request that returns a redux state object as a response
4067
1167
  if (accessMethod.REDUX) {
@@ -4072,7 +1172,6 @@ const webApp = (app, ReactApp, config) => {
4072
1172
  responseHandler(request, response, serialisedReduxData, 'json');
4073
1173
  return true;
4074
1174
  }
4075
-
4076
1175
  if (!disableSsrRedux) {
4077
1176
  // window.versionStatus is not strictly required here and is added to support cases
4078
1177
  // where a consumer may not be using the contensisVersionStatus in redux and calling
@@ -4080,41 +1179,40 @@ const webApp = (app, ReactApp, config) => {
4080
1179
  serialisedReduxData = `<script ${attributes}>window.versionStatus = "${versionStatus}"; window.REDUX_DATA = ${serialisedReduxData}</script>`;
4081
1180
  }
4082
1181
  }
4083
-
4084
1182
  if ((context.statusCode || 200) >= 404) {
4085
1183
  accessMethod.STATIC = true;
4086
- } // Responses
4087
-
1184
+ }
4088
1185
 
1186
+ // Responses
4089
1187
  let responseHTML = '';
4090
- if (context.statusCode === 404) title = '<title>404 page not found</title>'; // Static page served as a fragment
1188
+ if (context.statusCode === 404) title = '<title>404 page not found</title>';
4091
1189
 
1190
+ // Static page served as a fragment
4092
1191
  if (accessMethod.FRAGMENT && accessMethod.STATIC) {
4093
1192
  responseHTML = minifyCssString(styleTags) + html;
4094
- } // Page fragment served with client scripts and redux data that hydrate the app client side
4095
-
1193
+ }
4096
1194
 
1195
+ // Page fragment served with client scripts and redux data that hydrate the app client side
4097
1196
  if (accessMethod.FRAGMENT && !accessMethod.STATIC) {
4098
1197
  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
-
1198
+ }
4101
1199
 
1200
+ // Full HTML page served statically
4102
1201
  if (!accessMethod.FRAGMENT && accessMethod.STATIC) {
4103
1202
  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
-
1203
+ }
4106
1204
 
1205
+ // Full HTML page served with client scripts and redux data that hydrate the app client side
4107
1206
  if (!accessMethod.FRAGMENT && !accessMethod.STATIC) {
4108
1207
  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
-
1208
+ }
4111
1209
 
1210
+ // Set response.status from React StaticRouter
4112
1211
  if (typeof context.statusCode === 'number') response.status(context.statusCode);
4113
1212
  addStandardHeaders(reduxState, response, packagejson, {
4114
1213
  allowedGroups,
4115
1214
  globalGroups
4116
1215
  });
4117
-
4118
1216
  try {
4119
1217
  // If react-helmet htmlAttributes are being used,
4120
1218
  // replace the html tag with those attributes sepcified
@@ -4122,7 +1220,6 @@ const webApp = (app, ReactApp, config) => {
4122
1220
  if (htmlAttributes) {
4123
1221
  responseHTML = responseHTML.replace(/<html?.+?>/, `<html ${htmlAttributes}>`);
4124
1222
  }
4125
-
4126
1223
  responseHandler(request, response, responseHTML);
4127
1224
  } catch (err) {
4128
1225
  console.info(err.message);
@@ -4142,18 +1239,17 @@ const webApp = (app, ReactApp, config) => {
4142
1239
 
4143
1240
  const app = express();
4144
1241
  const server = http.createServer(app);
4145
-
4146
1242
  const start = (ReactApp, config, ServerFeatures) => {
4147
1243
  global.PACKAGE_JSON = config.packagejson;
4148
1244
  global.DISABLE_SSR_REDUX = config.disableSsrRedux;
4149
1245
  global.PROXY_DELIVERY_API = config.proxyDeliveryApi;
4150
1246
  global.REVERSE_PROXY_PATHS = Object(config.reverseProxyPaths);
4151
- app.disable('x-powered-by'); // Output some information about the used build/startup configuration
4152
-
1247
+ app.disable('x-powered-by');
1248
+ // Output some information about the used build/startup configuration
4153
1249
  DisplayStartupConfiguration(config);
4154
- ServerFeatures(app); // Set-up local proxy for images from cms, and delivery api requests
1250
+ ServerFeatures(app);
1251
+ // Set-up local proxy for images from cms, and delivery api requests
4155
1252
  // to save doing rewrites and extra code
4156
-
4157
1253
  reverseProxies(app, config.reverseProxyPaths);
4158
1254
  staticAssets(app, config);
4159
1255
  webApp(app, ReactApp, config);
@@ -4172,7 +1268,6 @@ const start = (ReactApp, config, ServerFeatures) => {
4172
1268
  });
4173
1269
  });
4174
1270
  };
4175
-
4176
1271
  var internalServer = {
4177
1272
  app,
4178
1273
  apiProxy: deliveryProxy,