@zengenti/contensis-react-base 3.0.0-beta.56 → 3.0.0-beta.59

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.
@@ -11,15 +11,16 @@ import { Provider } from 'react-redux';
11
11
  import { matchRoutes } from 'react-router-config';
12
12
  import { Helmet } from 'react-helmet';
13
13
  import { ServerStyleSheet } from 'styled-components';
14
- import serialize from 'serialize-javascript';
14
+ import serialize$1 from 'serialize-javascript';
15
15
  import minifyCssString from 'minify-css-string';
16
16
  import mapJson from 'jsonpath-mapper';
17
17
  import { ChunkExtractor, ChunkExtractorManager } from '@loadable/server';
18
18
  import { identity, noop } from 'lodash';
19
19
  import { buildCleaner } from 'lodash-clean';
20
- import { c as createStore, s as setVersionStatus, a as setVersion } from './version-b2ca1dab.js';
21
- import { h as history, d as deliveryApi, p as pickProject, r as rootSaga } from './App-33079006.js';
22
- export { A as ReactApp } from './App-33079006.js';
20
+ import { CookiesProvider } from 'react-cookie';
21
+ import { c as createStore, s as setVersionStatus, a as setVersion } from './version-1d46bde8.js';
22
+ import { h as history, d as deliveryApi, p as pickProject, r as rootSaga } from './App-509c41f4.js';
23
+ export { A as ReactApp } from './App-509c41f4.js';
23
24
  import { s as setCurrentProject } from './actions-5437f43d.js';
24
25
  import { s as selectSurrogateKeys, a as selectRouteEntry, b as selectCurrentProject, g as getImmutableOrJS } from './selectors-65f0f31c.js';
25
26
  import '@redux-saga/core/effects';
@@ -2999,6 +3000,332 @@ function cloneDeep(value) {
2999
3000
 
3000
3001
  var cloneDeep_1 = cloneDeep;
3001
3002
 
3003
+ /*!
3004
+ * cookie
3005
+ * Copyright(c) 2012-2014 Roman Shtylman
3006
+ * Copyright(c) 2015 Douglas Christopher Wilson
3007
+ * MIT Licensed
3008
+ */
3009
+
3010
+ /**
3011
+ * Module exports.
3012
+ * @public
3013
+ */
3014
+
3015
+ var parse_1 = parse;
3016
+ var serialize_1 = serialize;
3017
+
3018
+ /**
3019
+ * Module variables.
3020
+ * @private
3021
+ */
3022
+
3023
+ var decode = decodeURIComponent;
3024
+ var encode = encodeURIComponent;
3025
+
3026
+ /**
3027
+ * RegExp to match field-content in RFC 7230 sec 3.2
3028
+ *
3029
+ * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
3030
+ * field-vchar = VCHAR / obs-text
3031
+ * obs-text = %x80-FF
3032
+ */
3033
+
3034
+ var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
3035
+
3036
+ /**
3037
+ * Parse a cookie header.
3038
+ *
3039
+ * Parse the given cookie header string into an object
3040
+ * The object has the various cookies as keys(names) => values
3041
+ *
3042
+ * @param {string} str
3043
+ * @param {object} [options]
3044
+ * @return {object}
3045
+ * @public
3046
+ */
3047
+
3048
+ function parse(str, options) {
3049
+ if (typeof str !== 'string') {
3050
+ throw new TypeError('argument str must be a string');
3051
+ }
3052
+
3053
+ var obj = {};
3054
+ var opt = options || {};
3055
+ var pairs = str.split(';');
3056
+ var dec = opt.decode || decode;
3057
+
3058
+ for (var i = 0; i < pairs.length; i++) {
3059
+ var pair = pairs[i];
3060
+ var index = pair.indexOf('=');
3061
+
3062
+ // skip things that don't look like key=value
3063
+ if (index < 0) {
3064
+ continue;
3065
+ }
3066
+
3067
+ var key = pair.substring(0, index).trim();
3068
+
3069
+ // only assign once
3070
+ if (undefined == obj[key]) {
3071
+ var val = pair.substring(index + 1, pair.length).trim();
3072
+
3073
+ // quoted values
3074
+ if (val[0] === '"') {
3075
+ val = val.slice(1, -1);
3076
+ }
3077
+
3078
+ obj[key] = tryDecode(val, dec);
3079
+ }
3080
+ }
3081
+
3082
+ return obj;
3083
+ }
3084
+
3085
+ /**
3086
+ * Serialize data into a cookie header.
3087
+ *
3088
+ * Serialize the a name value pair into a cookie string suitable for
3089
+ * http headers. An optional options object specified cookie parameters.
3090
+ *
3091
+ * serialize('foo', 'bar', { httpOnly: true })
3092
+ * => "foo=bar; httpOnly"
3093
+ *
3094
+ * @param {string} name
3095
+ * @param {string} val
3096
+ * @param {object} [options]
3097
+ * @return {string}
3098
+ * @public
3099
+ */
3100
+
3101
+ function serialize(name, val, options) {
3102
+ var opt = options || {};
3103
+ var enc = opt.encode || encode;
3104
+
3105
+ if (typeof enc !== 'function') {
3106
+ throw new TypeError('option encode is invalid');
3107
+ }
3108
+
3109
+ if (!fieldContentRegExp.test(name)) {
3110
+ throw new TypeError('argument name is invalid');
3111
+ }
3112
+
3113
+ var value = enc(val);
3114
+
3115
+ if (value && !fieldContentRegExp.test(value)) {
3116
+ throw new TypeError('argument val is invalid');
3117
+ }
3118
+
3119
+ var str = name + '=' + value;
3120
+
3121
+ if (null != opt.maxAge) {
3122
+ var maxAge = opt.maxAge - 0;
3123
+
3124
+ if (isNaN(maxAge) || !isFinite(maxAge)) {
3125
+ throw new TypeError('option maxAge is invalid')
3126
+ }
3127
+
3128
+ str += '; Max-Age=' + Math.floor(maxAge);
3129
+ }
3130
+
3131
+ if (opt.domain) {
3132
+ if (!fieldContentRegExp.test(opt.domain)) {
3133
+ throw new TypeError('option domain is invalid');
3134
+ }
3135
+
3136
+ str += '; Domain=' + opt.domain;
3137
+ }
3138
+
3139
+ if (opt.path) {
3140
+ if (!fieldContentRegExp.test(opt.path)) {
3141
+ throw new TypeError('option path is invalid');
3142
+ }
3143
+
3144
+ str += '; Path=' + opt.path;
3145
+ }
3146
+
3147
+ if (opt.expires) {
3148
+ if (typeof opt.expires.toUTCString !== 'function') {
3149
+ throw new TypeError('option expires is invalid');
3150
+ }
3151
+
3152
+ str += '; Expires=' + opt.expires.toUTCString();
3153
+ }
3154
+
3155
+ if (opt.httpOnly) {
3156
+ str += '; HttpOnly';
3157
+ }
3158
+
3159
+ if (opt.secure) {
3160
+ str += '; Secure';
3161
+ }
3162
+
3163
+ if (opt.sameSite) {
3164
+ var sameSite = typeof opt.sameSite === 'string'
3165
+ ? opt.sameSite.toLowerCase() : opt.sameSite;
3166
+
3167
+ switch (sameSite) {
3168
+ case true:
3169
+ str += '; SameSite=Strict';
3170
+ break;
3171
+ case 'lax':
3172
+ str += '; SameSite=Lax';
3173
+ break;
3174
+ case 'strict':
3175
+ str += '; SameSite=Strict';
3176
+ break;
3177
+ case 'none':
3178
+ str += '; SameSite=None';
3179
+ break;
3180
+ default:
3181
+ throw new TypeError('option sameSite is invalid');
3182
+ }
3183
+ }
3184
+
3185
+ return str;
3186
+ }
3187
+
3188
+ /**
3189
+ * Try decoding a string using a decoding function.
3190
+ *
3191
+ * @param {string} str
3192
+ * @param {function} decode
3193
+ * @private
3194
+ */
3195
+
3196
+ function tryDecode(str, decode) {
3197
+ try {
3198
+ return decode(str);
3199
+ } catch (e) {
3200
+ return str;
3201
+ }
3202
+ }
3203
+
3204
+ function hasDocumentCookie() {
3205
+ // Can we get/set cookies on document.cookie?
3206
+ return typeof document === 'object' && typeof document.cookie === 'string';
3207
+ }
3208
+ function parseCookies(cookies, options) {
3209
+ if (typeof cookies === 'string') {
3210
+ return parse_1(cookies, options);
3211
+ }
3212
+ else if (typeof cookies === 'object' && cookies !== null) {
3213
+ return cookies;
3214
+ }
3215
+ else {
3216
+ return {};
3217
+ }
3218
+ }
3219
+ function isParsingCookie(value, doNotParse) {
3220
+ if (typeof doNotParse === 'undefined') {
3221
+ // We guess if the cookie start with { or [, it has been serialized
3222
+ doNotParse =
3223
+ !value || (value[0] !== '{' && value[0] !== '[' && value[0] !== '"');
3224
+ }
3225
+ return !doNotParse;
3226
+ }
3227
+ function readCookie(value, options) {
3228
+ if (options === void 0) { options = {}; }
3229
+ var cleanValue = cleanupCookieValue(value);
3230
+ if (isParsingCookie(cleanValue, options.doNotParse)) {
3231
+ try {
3232
+ return JSON.parse(cleanValue);
3233
+ }
3234
+ catch (e) {
3235
+ // At least we tried
3236
+ }
3237
+ }
3238
+ // Ignore clean value if we failed the deserialization
3239
+ // It is not relevant anymore to trim those values
3240
+ return value;
3241
+ }
3242
+ function cleanupCookieValue(value) {
3243
+ // express prepend j: before serializing a cookie
3244
+ if (value && value[0] === 'j' && value[1] === ':') {
3245
+ return value.substr(2);
3246
+ }
3247
+ return value;
3248
+ }
3249
+
3250
+ var __assign = (undefined && undefined.__assign) || function () {
3251
+ __assign = Object.assign || function(t) {
3252
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
3253
+ s = arguments[i];
3254
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
3255
+ t[p] = s[p];
3256
+ }
3257
+ return t;
3258
+ };
3259
+ return __assign.apply(this, arguments);
3260
+ };
3261
+ var Cookies = /** @class */ (function () {
3262
+ function Cookies(cookies, options) {
3263
+ var _this = this;
3264
+ this.changeListeners = [];
3265
+ this.HAS_DOCUMENT_COOKIE = false;
3266
+ this.cookies = parseCookies(cookies, options);
3267
+ new Promise(function () {
3268
+ _this.HAS_DOCUMENT_COOKIE = hasDocumentCookie();
3269
+ }).catch(function () { });
3270
+ }
3271
+ Cookies.prototype._updateBrowserValues = function (parseOptions) {
3272
+ if (!this.HAS_DOCUMENT_COOKIE) {
3273
+ return;
3274
+ }
3275
+ this.cookies = parse_1(document.cookie, parseOptions);
3276
+ };
3277
+ Cookies.prototype._emitChange = function (params) {
3278
+ for (var i = 0; i < this.changeListeners.length; ++i) {
3279
+ this.changeListeners[i](params);
3280
+ }
3281
+ };
3282
+ Cookies.prototype.get = function (name, options, parseOptions) {
3283
+ if (options === void 0) { options = {}; }
3284
+ this._updateBrowserValues(parseOptions);
3285
+ return readCookie(this.cookies[name], options);
3286
+ };
3287
+ Cookies.prototype.getAll = function (options, parseOptions) {
3288
+ if (options === void 0) { options = {}; }
3289
+ this._updateBrowserValues(parseOptions);
3290
+ var result = {};
3291
+ for (var name_1 in this.cookies) {
3292
+ result[name_1] = readCookie(this.cookies[name_1], options);
3293
+ }
3294
+ return result;
3295
+ };
3296
+ Cookies.prototype.set = function (name, value, options) {
3297
+ var _a;
3298
+ if (typeof value === 'object') {
3299
+ value = JSON.stringify(value);
3300
+ }
3301
+ this.cookies = __assign(__assign({}, this.cookies), (_a = {}, _a[name] = value, _a));
3302
+ if (this.HAS_DOCUMENT_COOKIE) {
3303
+ document.cookie = serialize_1(name, value, options);
3304
+ }
3305
+ this._emitChange({ name: name, value: value, options: options });
3306
+ };
3307
+ Cookies.prototype.remove = function (name, options) {
3308
+ var finalOptions = (options = __assign(__assign({}, options), { expires: new Date(1970, 1, 1, 0, 0, 1), maxAge: 0 }));
3309
+ this.cookies = __assign({}, this.cookies);
3310
+ delete this.cookies[name];
3311
+ if (this.HAS_DOCUMENT_COOKIE) {
3312
+ document.cookie = serialize_1(name, '', finalOptions);
3313
+ }
3314
+ this._emitChange({ name: name, value: undefined, options: options });
3315
+ };
3316
+ Cookies.prototype.addChangeListener = function (callback) {
3317
+ this.changeListeners.push(callback);
3318
+ };
3319
+ Cookies.prototype.removeChangeListener = function (callback) {
3320
+ var idx = this.changeListeners.indexOf(callback);
3321
+ if (idx >= 0) {
3322
+ this.changeListeners.splice(idx, 1);
3323
+ }
3324
+ };
3325
+ return Cookies;
3326
+ }());
3327
+ var Cookies$1 = Cookies;
3328
+
3002
3329
  var stringifyAttributes = ((attributes = {}) => Object.entries(attributes).map(([key, value], idx) => `${idx !== 0 ? ' ' : ''}${key}${value ? `="${value}"` : ''}`).join(' '));
3003
3330
 
3004
3331
  /* eslint-disable no-console */
@@ -3163,6 +3490,7 @@ const webApp = (app, ReactApp, config) => {
3163
3490
  const {
3164
3491
  url
3165
3492
  } = request;
3493
+ const cookies = new Cookies$1(request.headers.cookie);
3166
3494
 
3167
3495
  const matchedStaticRoute = () => matchRoutes(routes.StaticRoutes, request.path);
3168
3496
 
@@ -3208,6 +3536,8 @@ const webApp = (app, ReactApp, config) => {
3208
3536
  const loadableExtractor = loadableChunkExtractors();
3209
3537
  const jsx = /*#__PURE__*/React.createElement(ChunkExtractorManager, {
3210
3538
  extractor: loadableExtractor === null || loadableExtractor === void 0 ? void 0 : loadableExtractor.commonLoadableExtractor
3539
+ }, /*#__PURE__*/React.createElement(CookiesProvider, {
3540
+ cookies: cookies
3211
3541
  }, /*#__PURE__*/React.createElement(Provider, {
3212
3542
  store: store
3213
3543
  }, /*#__PURE__*/React.createElement(StaticRouter, {
@@ -3216,7 +3546,7 @@ const webApp = (app, ReactApp, config) => {
3216
3546
  }, /*#__PURE__*/React.createElement(ReactApp, {
3217
3547
  routes: routes,
3218
3548
  withEvents: withEvents
3219
- }))));
3549
+ })))));
3220
3550
  const {
3221
3551
  templateHTML,
3222
3552
  templateHTMLFragment,
@@ -3257,7 +3587,7 @@ const webApp = (app, ReactApp, config) => {
3257
3587
  // code-split bundles for any page components as well as core app bundles
3258
3588
 
3259
3589
  const bundleTags = getBundleTags(loadableExtractor, scripts, staticRoutePath);
3260
- let serialisedReduxData = serialize(buildCleaner({
3590
+ let serialisedReduxData = serialize$1(buildCleaner({
3261
3591
  isArray: identity,
3262
3592
  isBoolean: identity,
3263
3593
  isDate: identity,
@@ -3360,8 +3690,6 @@ const start = (ReactApp, config, ServerFeatures) => {
3360
3690
  staticAssets(app, config);
3361
3691
  webApp(app, ReactApp, config);
3362
3692
  app.on('ready', async () => {
3363
- // Configure DNS to make life easier
3364
- // await ConfigureLocalDNS();
3365
3693
  const server = app.listen(3001, () => {
3366
3694
  console.info(`HTTP server is listening @ port 3001`);
3367
3695
  setTimeout(function () {