@dr.pogodin/react-utils 1.11.0 → 1.12.1

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 (36) hide show
  1. package/bin/build.js +1 -3
  2. package/bin/setup.js +2 -2
  3. package/build/development/client/index.js.map +1 -1
  4. package/build/development/index.js +0 -9
  5. package/build/development/index.js.map +1 -1
  6. package/build/development/server/index.js +9 -12
  7. package/build/development/server/index.js.map +1 -1
  8. package/build/development/server/renderer.js +11 -13
  9. package/build/development/server/renderer.js.map +1 -1
  10. package/build/development/shared/components/MetaTags.js +10 -9
  11. package/build/development/shared/components/MetaTags.js.map +1 -1
  12. package/build/development/shared/utils/time.js +3 -1
  13. package/build/development/shared/utils/time.js.map +1 -1
  14. package/build/development/style.css +6 -6
  15. package/build/development/web.bundle.js +3 -3
  16. package/build/production/client/index.js.map +1 -1
  17. package/build/production/index.js +1 -1
  18. package/build/production/index.js.map +1 -1
  19. package/build/production/server/index.js +3 -3
  20. package/build/production/server/index.js.map +1 -1
  21. package/build/production/server/renderer.js +7 -6
  22. package/build/production/server/renderer.js.map +1 -1
  23. package/build/production/shared/components/MetaTags.js +1 -1
  24. package/build/production/shared/components/MetaTags.js.map +1 -1
  25. package/build/production/shared/utils/time.js +1 -1
  26. package/build/production/shared/utils/time.js.map +1 -1
  27. package/build/production/style.css +1 -1
  28. package/build/production/style.css.map +1 -1
  29. package/build/production/web.bundle.js +1 -1
  30. package/build/production/web.bundle.js.map +1 -1
  31. package/config/babel/node-ssr.js +3 -3
  32. package/config/babel/webpack.js +2 -2
  33. package/config/eslint/default.json +6 -1
  34. package/config/webpack/app-base.js +10 -4
  35. package/config/webpack/app-development.js +2 -2
  36. package/package.json +35 -34
package/bin/build.js CHANGED
@@ -59,9 +59,7 @@ program
59
59
  'path to the webpack config',
60
60
  'webpack.config.js',
61
61
  )
62
- .option(
63
- '-c, --copy-files <regex>', 'copy files matching the pattern into the build folder',
64
- );
62
+ .option('-c, --copy-files <regex>', 'copy files matching the pattern into the build folder');
65
63
 
66
64
  program.parse(process.argv);
67
65
  const cmdLineArgs = program.opts();
package/bin/setup.js CHANGED
@@ -6,7 +6,7 @@ const { spawnSync } = require('child_process');
6
6
  const fs = require('fs');
7
7
  const path = require('path');
8
8
 
9
- const _ = require('lodash');
9
+ const { clone } = require('lodash');
10
10
  const { program } = require('commander');
11
11
 
12
12
  const NPM_COMMAND = process.platform === 'win32' ? 'npm.cmd' : 'npm';
@@ -78,7 +78,7 @@ function generateTargetPackage(entry) {
78
78
  */
79
79
  function adoptDevDependencies(donorData, hostData) {
80
80
  /* Inits deps as a map of all donor's dev dependencies. */
81
- let deps = _.clone(donorData.devDependencies) || {};
81
+ let deps = clone(donorData.devDependencies) || {};
82
82
 
83
83
  /* Removes from the map any prod dependencies of host. */
84
84
  Object.entries(hostData.dependencies || {})
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/index.jsx"],"names":["Launch","Application","ReactDom","hydrate","window","ISTATE","document","getElementById"],"mappings":";;;;;;;;;AAGA;;AAEA;;AACA;;;;AANA;;AACA;;AAOA;AACA;AACA;AACA;AACe,SAASA,MAAT,CAAgBC,WAAhB,EAA6B;AAC1CC,oBAASC,OAAT,eACE,qBAAC,qCAAD;AAAqB,IAAA,YAAY,EAAEC,MAAM,CAACC,MAA1C;AAAA,2BACE,qBAAC,6BAAD;AAAA,6BACE,qBAAC,WAAD;AADF;AADF,IADF,EAMGC,QAAQ,CAACC,cAAT,CAAwB,YAAxB,CANH;AAOD","sourcesContent":["// Initialization of client-side code.\n/* global document, window */\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\n\nimport ReactDom from 'react-dom';\nimport { BrowserRouter } from 'react-router-dom';\n\n/**\n * Prepares and launches the app at client side.\n * @param {object} Application Root application component\n */\nexport default function Launch(Application) {\n ReactDom.hydrate((\n <GlobalStateProvider initialState={window.ISTATE}>\n <BrowserRouter>\n <Application />\n </BrowserRouter>\n </GlobalStateProvider>\n ), document.getElementById('react-view'));\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../src/client/index.jsx"],"names":["Launch","Application","ReactDom","hydrate","window","ISTATE","document","getElementById"],"mappings":";;;;;;;;;AAGA;;AAEA;;AACA;;;;AANA;;AACA;;AAOA;AACA;AACA;AACA;AACe,SAASA,MAAT,CAAgBC,WAAhB,EAA6B;AAC1CC,oBAASC,OAAT,eAEI,qBAAC,qCAAD;AAAqB,IAAA,YAAY,EAAEC,MAAM,CAACC,MAA1C;AAAA,2BACE,qBAAC,6BAAD;AAAA,6BACE,qBAAC,WAAD;AADF;AADF,IAFJ,EAOKC,QAAQ,CAACC,cAAT,CAAwB,YAAxB,CAPL;AASD","sourcesContent":["// Initialization of client-side code.\n/* global document, window */\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\n\nimport ReactDom from 'react-dom';\nimport { BrowserRouter } from 'react-router-dom';\n\n/**\n * Prepares and launches the app at client side.\n * @param {object} Application Root application component\n */\nexport default function Launch(Application) {\n ReactDom.hydrate(\n (\n <GlobalStateProvider initialState={window.ISTATE}>\n <BrowserRouter>\n <Application />\n </BrowserRouter>\n </GlobalStateProvider>\n ), document.getElementById('react-view'),\n );\n}\n"],"file":"index.js"}
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  var _exportNames = {
9
9
  server: true,
10
- _: true,
11
10
  api: true,
12
11
  PT: true,
13
12
  getGlobalState: true,
@@ -23,12 +22,6 @@ Object.defineProperty(exports, "GlobalStateProvider", {
23
22
  }
24
23
  });
25
24
  exports.PT = void 0;
26
- Object.defineProperty(exports, "_", {
27
- enumerable: true,
28
- get: function () {
29
- return _lodash.default;
30
- }
31
- });
32
25
  Object.defineProperty(exports, "api", {
33
26
  enumerable: true,
34
27
  get: function () {
@@ -75,8 +68,6 @@ Object.keys(_utils).forEach(function (key) {
75
68
  });
76
69
  });
77
70
 
78
- var _lodash = _interopRequireDefault(require("lodash"));
79
-
80
71
  var _axios = _interopRequireDefault(require("axios"));
81
72
 
82
73
  var _PT = _interopRequireWildcard(require("prop-types"));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.js"],"names":["server","isomorphy","IS_SERVER_SIDE","path","webpack","requireWeak","resolve","__dirname","error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;AAyBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAbA;;AACA;;;;;;AAGA;;AAQA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;AAtBA,IAAIA,MAAM,GAAG,IAAb,C,CAAmB;;;;AACnB,IAAIC,iBAAUC,cAAd,EAA8B;AAC5B,MAAI;AACF,UAAMC,IAAI,GAAGC,eAAQC,WAAR,CAAoB,MAApB,CAAb;;AACA,qBAAAL,MAAM,GAAGI,eAAQC,WAAR,CAAoBF,IAAI,CAACG,OAAL,CAAaC,SAAb,EAAwB,UAAxB,CAApB,CAAT;AACD,GAHD,CAGE,OAAOC,KAAP,EAAc;AACd,qBAAAR,MAAM,GAAG,IAAT;AACD;AACF","sourcesContent":["import 'styles/global.scss';\n\nimport { isomorphy, webpack } from 'utils';\n\nlet server = null; // eslint-disable-line import/no-mutable-exports\nif (isomorphy.IS_SERVER_SIDE) {\n try {\n const path = webpack.requireWeak('path');\n server = webpack.requireWeak(path.resolve(__dirname, './server'));\n } catch (error) {\n server = null;\n }\n}\n\nexport { default as _ } from 'lodash';\nexport { default as api } from 'axios';\nexport * as PT from 'prop-types';\n\nexport {\n getGlobalState,\n GlobalStateProvider,\n useAsyncCollection,\n useAsyncData,\n useGlobalState,\n} from '@dr.pogodin/react-global-state';\n\nexport * from 'components';\nexport * from 'utils';\n\nexport { server };\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/index.js"],"names":["server","isomorphy","IS_SERVER_SIDE","path","webpack","requireWeak","resolve","__dirname","error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;AAwBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAZA;;;;;;AAGA;;AAQA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;AArBA,IAAIA,MAAM,GAAG,IAAb,C,CAAmB;;;;AACnB,IAAIC,iBAAUC,cAAd,EAA8B;AAC5B,MAAI;AACF,UAAMC,IAAI,GAAGC,eAAQC,WAAR,CAAoB,MAApB,CAAb;;AACA,qBAAAL,MAAM,GAAGI,eAAQC,WAAR,CAAoBF,IAAI,CAACG,OAAL,CAAaC,SAAb,EAAwB,UAAxB,CAApB,CAAT;AACD,GAHD,CAGE,OAAOC,KAAP,EAAc;AACd,qBAAAR,MAAM,GAAG,IAAT;AACD;AACF","sourcesContent":["import 'styles/global.scss';\n\nimport { isomorphy, webpack } from 'utils';\n\nlet server = null; // eslint-disable-line import/no-mutable-exports\nif (isomorphy.IS_SERVER_SIDE) {\n try {\n const path = webpack.requireWeak('path');\n server = webpack.requireWeak(path.resolve(__dirname, './server'));\n } catch (error) {\n server = null;\n }\n}\n\nexport { default as api } from 'axios';\nexport * as PT from 'prop-types';\n\nexport {\n getGlobalState,\n GlobalStateProvider,\n useAsyncCollection,\n useAsyncData,\n useGlobalState,\n} from '@dr.pogodin/react-global-state';\n\nexport * from 'components';\nexport * from 'utils';\n\nexport { server };\n"],"file":"index.js"}
@@ -18,7 +18,7 @@ Object.defineProperty(exports, "getDefaultCspSettings", {
18
18
 
19
19
  require("source-map-support/register");
20
20
 
21
- var _lodash = _interopRequireDefault(require("lodash"));
21
+ var _lodash = require("lodash");
22
22
 
23
23
  var _http = _interopRequireDefault(require("http"));
24
24
 
@@ -63,12 +63,11 @@ const DEFAULT_SSR_TIMEOUT = 1000;
63
63
  */
64
64
 
65
65
  function normalizePort(value) {
66
- const port = _lodash.default.toNumber(value);
67
-
68
- if (_lodash.default.isFinite(port)) return port;
66
+ const port = (0, _lodash.toNumber)(value);
67
+ if ((0, _lodash.isFinite)(port)) return port;
69
68
  /* port number */
70
69
 
71
- if (!_lodash.default.isNumber(port)) return value;
70
+ if (!(0, _lodash.isNumber)(port)) return value;
72
71
  /* named pipe */
73
72
 
74
73
  return false;
@@ -195,18 +194,16 @@ function normalizePort(value) {
195
194
 
196
195
  async function launch(webpackConfig, options) {
197
196
  /* Options normalization. */
198
- const ops = options ? _lodash.default.cloneDeep(options) : {};
197
+ const ops = options ? (0, _lodash.cloneDeep)(options) : {};
199
198
  ops.port = normalizePort(ops.port || process.env.PORT || 3000);
200
-
201
- _lodash.default.defaults(ops, {
199
+ (0, _lodash.defaults)(ops, {
202
200
  httpsRedirect: true,
203
201
  maxSsrRounds: DEFAULT_MAX_SSR_ROUNDS,
204
202
  ssrTimeout: DEFAULT_SSR_TIMEOUT
205
203
  });
206
-
207
204
  if (!ops.staticCacheSize) ops.staticCacheSize = 1.e7;
208
205
 
209
- if (_lodash.default.isUndefined(ops.logger)) {
206
+ if ((0, _lodash.isUndefined)(ops.logger)) {
210
207
  const {
211
208
  format,
212
209
  transports
@@ -249,7 +246,7 @@ async function launch(webpackConfig, options) {
249
246
 
250
247
  httpServer.on('error', error => {
251
248
  if (error.syscall !== 'listen') throw error;
252
- const bind = _lodash.default.isString(ops.port) ? `Pipe ${ops.port}` : `Port ${ops.port}`;
249
+ const bind = (0, _lodash.isString)(ops.port) ? `Pipe ${ops.port}` : `Port ${ops.port}`;
253
250
  /* Human-readable message for some specific listen errors. */
254
251
 
255
252
  switch (error.code) {
@@ -271,7 +268,7 @@ async function launch(webpackConfig, options) {
271
268
 
272
269
  httpServer.on('listening', () => {
273
270
  const addr = httpServer.address();
274
- const bind = _lodash.default.isString(addr) ? `pipe ${addr}` : `port ${addr.port}`;
271
+ const bind = (0, _lodash.isString)(addr) ? `pipe ${addr}` : `port ${addr.port}`;
275
272
  ops.logger.info(`Server listening on ${bind} in ${process.env.NODE_ENV} mode`);
276
273
  });
277
274
  httpServer.listen(ops.port);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/index.js"],"names":["DEFAULT_MAX_SSR_ROUNDS","DEFAULT_SSR_TIMEOUT","normalizePort","value","port","_","toNumber","isFinite","isNumber","launch","webpackConfig","options","ops","cloneDeep","process","env","PORT","defaults","httpsRedirect","maxSsrRounds","ssrTimeout","staticCacheSize","isUndefined","logger","format","transports","winston","createLogger","level","defaultLoggerLogLevel","combine","splat","timestamp","colorize","printf","message","stack","rest","res","Object","keys","length","JSON","stringify","Console","expressServer","httpServer","https","createServer","cert","key","http","on","error","syscall","bind","isString","code","exit","addr","address","info","NODE_ENV","listen","SCRIPT_LOCATIONS"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AAGA;;AAEA;;AAEA;;AACA;;AAGA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;AATA;AAWA;AACA,MAAMA,sBAAsB,GAAG,EAA/B;AACA,MAAMC,mBAAmB,GAAG,IAA5B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,aAAT,CAAuBC,KAAvB,EAA8B;AAC5B,QAAMC,IAAI,GAAGC,gBAAEC,QAAF,CAAWH,KAAX,CAAb;;AACA,MAAIE,gBAAEE,QAAF,CAAWH,IAAX,CAAJ,EAAsB,OAAOA,IAAP;AAAa;;AACnC,MAAI,CAACC,gBAAEG,QAAF,CAAWJ,IAAX,CAAL,EAAuB,OAAOD,KAAP;AAAc;;AACrC,SAAO,KAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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D,KAAN;AAChC,UAAME,IAAI,GAAGlD,gBAAEmD,QAAF,CAAW5C,GAAG,CAACR,IAAf,IAAwB,QAAOQ,GAAG,CAACR,IAAK,EAAxC,GAA6C,QAAOQ,GAAG,CAACR,IAAK,EAA1E;AAEA;;AACA,YAAQiD,KAAK,CAACI,IAAd;AACE,WAAK,QAAL;AACE7C,QAAAA,GAAG,CAACW,MAAJ,CAAW8B,KAAX,CAAkB,GAAEE,IAAK,+BAAzB;AACAzC,QAAAA,OAAO,CAAC4C,IAAR,CAAa,CAAb;AACA;;AACF,WAAK,YAAL;AACE9C,QAAAA,GAAG,CAACW,MAAJ,CAAW8B,KAAX,CAAkB,GAAEE,IAAK,oBAAzB;AACAzC,QAAAA,OAAO,CAAC4C,IAAR,CAAa,CAAb;AACA;;AACF;AACE,cAAML,KAAN;AAVJ;AAYD,GAjBD;AAmBA;;AACAP,EAAAA,UAAU,CAACM,EAAX,CAAc,WAAd,EAA2B,MAAM;AAC/B,UAAMO,IAAI,GAAGb,UAAU,CAACc,OAAX,EAAb;AACA,UAAML,IAAI,GAAGlD,gBAAEmD,QAAF,CAAWG,IAAX,IAAoB,QAAOA,IAAK,EAAhC,GAAqC,QAAOA,IAAI,CAACvD,IAAK,EAAnE;AACAQ,IAAAA,GAAG,CAACW,MAAJ,CAAWsC,IAAX,CAAiB,uBAAsBN,IAAK,OAC1CzC,OAAO,CAACC,GAAR,CAAY+C,QAAS,OADvB;AAED,GALD;AAOAhB,EAAAA,UAAU,CAACiB,MAAX,CAAkBnD,GAAG,CAACR,IAAtB;AAEA,SAAO;AACLyC,IAAAA,aADK;AAELC,IAAAA;AAFK,GAAP;AAID;;AAEDrC,MAAM,CAACuD,gBAAP,GAA0BA,0BAA1B;eAEevD,M","sourcesContent":["import 'source-map-support/register';\n\nimport _ from 'lodash';\nimport http from 'http';\nimport https from 'https';\n\n/* Polyfill required by ReactJS. */\nimport 'raf/polyfill';\n\nimport winston from 'winston';\n\nimport serverFactory from './server';\nimport { SCRIPT_LOCATIONS } from './renderer';\n\nexport { getDefaultCspSettings } from './server';\nexport * from './utils';\n\n// Various default settings of server factory (launch() function).\nconst DEFAULT_MAX_SSR_ROUNDS = 10;\nconst DEFAULT_SSR_TIMEOUT = 1000;\n\n/**\n * Normalizes a port into a number, string, or false.\n * TODO: Drop this function?\n * @ignore\n * @param {String} value Port name or number.\n * @return Port number (Number), name (String), or false.\n */\nfunction normalizePort(value) {\n const port = _.toNumber(value);\n if (_.isFinite(port)) return port; /* port number */\n if (!_.isNumber(port)) return value; /* named pipe */\n return false;\n}\n\n/**\n * Creates and launches web-server for ReactJS application. Allows zero\n * or detailed configuration, supports server-side rendering,\n * and development tools, including Hot Module Reloading (HMR).\n *\n * See {@link module:ReactGlobalState ReactGlobalState} for some additional\n * notes related to SSR, access to incoming requests during SSR, _etc._\n *\n * @param {object} webpackConfig Webpack configuration used to build\n * the frontend bundle. In production mode the server will read out of it\n * `context`, `publicPath`, and a few other parameters, necessary to locate\n * and serve the app bundle. In development mode the server will use entire\n * provided config to build the app bundle in memory, and further watch and\n * update it via HMR.\n * @param {object} [options] Additional parameters.\n * @param {Component} [options.Application] The root ReactJS component of\n * the app to use for the server-side rendering. When not provided\n * the server-side rendering is disabled.\n * @param {function} [options.beforeExpressJsError] Asynchronous callback\n * (`(server) => Promise<boolean>`) to be executed just before the default error\n * handler is added to ExpressJS server. If the callback is provided and its\n * result resolves to a truthy value, `react-utils` won't attach the default\n * error handler.\n * @param {function} [options.beforeExpressJsSetup] Asynchronous callback\n * (`(server) => Promise) to be executed right after ExpressJS server creation,\n * before any configuration is performed.\n * @param {BeforeRenderHook} [options.beforeRender] The hook to run just before\n * the server-side rendering. For each incoming request, it will be executed\n * just before the HTML markup is generated at the server. It allows to load\n * and provide the data necessary for server-side rendering, and also to inject\n * additional configuration and scripts into the generated HTML code.\n * @param {boolean} [options.noCsp] Set `true` to disable\n * Content-Security-Policy (CSP) headers altogether.\n * @param {function} [options.cspSettingsHook] A hook allowing\n * to customize [CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP)\n * settings for [helmet](https://github.com/helmetjs/helmet)'s\n * `contentSecurityPolicy` middleware on per-request basis.\n *\n * If provided it should be a with signature: \\\n * `(defaultSettings: object, req: object)` &rArr; `object` \\\n * which gets the default settings (also used without the hook),\n * and the incoming request object. The hook response will be passed\n * as options to the helmet `contentSecurityPolicy` middleware.\n *\n * Currently, the default settings is the following object in production\n * environment:\n * ```js\n * {\n * directives: {\n * defaultSrc: [\"'self'\"],\n * baseUri: [\"'self'\"],\n * blockAllMixedContent: [],\n * fontSrc: [\"'self'\", 'https:', 'data:'],\n * frameAncestors: [\"'self'\"],\n * frameSrc: [\"'self'\", 'https://*.youtube.com'],\n * imgSrc: [\"'self'\", 'data:'],\n * objectSrc: [\"'none'\"],\n * scriptSrc: [\"'self'\", \"'unsafe-eval'\", `'nonce-UNIQUE_NONCE_VALUE'`],\n * scriptSrcAttr: [\"'none'\"],\n * styleSrc: [\"'self'\", 'https:', \"'unsafe-inline'\"],\n * upgradeInsecureRequests: [] // Removed in dev mode.\n * }\n * }\n * ```\n * It matches the default value used by Helmet with a few updates:\n * - YouTube host is whitelisted in the `frameSrc` directive to ensure\n * the {@link YouTubeVideo} component works.\n * - An unique per-request nonce is added to `scriptSrc` directive to\n * whitelist auxiliary scripts injected by react-utils. The actual nonce\n * value can be fetched by host code via `.nonce` field of `req` argument\n * of `.beforeRender` hook.\n * - `upgradeInsecureRequests` directive is removed in development mode,\n * to simplify local testing with http requests.\n * @param {string} [options.defaultLoggerLogLevel=info] Log level for\n * the default logger, which is created if no `logger` option provided.\n * @param {boolean} [options.devMode] Pass in `true` to start the server in\n * development mode.\n * @param {string} [options.favicon] Path to the favicon to use by the server.\n * By default no favicon is used.\n * @param {object} [options.https] If provided, HTTPS server will be started,\n * instead of HTTP otherwise. The object should provide SSL certificate and key\n * via two string fields: `cert`, and `key`.\n * @param {string} [options.https.cert] SSL Certificate.\n * @param {string} [options.https.key] SSL key.\n * @param {boolean} [options.httpsRedirect=true] Pass in `true` to enable\n * automatic redirection of all incoming HTTP requests to HTTPS.\n *\n * To smoothly use it at `localhost` you need to run the server in HTTPS mode,\n * and also properly create and install a self-signed SSL sertificate on your\n * system. This article is helpful:\n * [How to get HTTPS working on your local development environment in 5 minutes](https://medium.freecodecamp.org/how-to-get-https-working-on-your-local-development-environment-in-5-minutes-7af615770eec)\n * @param {Logger} [options.logger] The logger to use at server side.\n * By default [`winston`](https://www.npmjs.com/package/winston) logger\n * with console transport is used. The logger you provide, or the default\n * `winston` logger otherwise, will be attached to the created ExpressJS server\n * object.\n * @param {function} [options.onExpressJsSetup] An async callback\n * (`(server) => Promise`) to be triggered when most of the server\n * configuration is completed, just before the server-side renderer,\n * and the default error handler are attached. You can use it to mount\n * custom API routes. The server-side logger can be accessed as `server.logger`.\n * @param {number|string} [options.port=3000] The port to start the server on.\n * @param {number} [options.staticCacheSize=1.e7] The maximum\n * static cache size in bytes. Defaults to ~10 MB.\n * @param {function} [options.staticCacheController] When given, it activates,\n * and controls the static caching of generated HTML markup. When this function\n * is provided, on each incoming request it is triggered with the request\n * passed in as the argument. To attempt to serve the response from the cache\n * it should return the object with the following fields:\n * - `key: string` &ndash; the cache key for the response;\n * - `maxage?: number` &ndash; the maximum age of cached result in ms.\n * If undefined - infinite age is assumed.\n * @param {number} [options.maxSsrRounds=10] Maximum number of SSR rounds.\n * @param {number} [options.ssrTimeout=1000] SSR timeout in milliseconds,\n * defaults to 1 second.\n * @return {Promise<{ expressServer: object, httpServer: object }>} Resolves to\n * an object with created Express and HTTP servers.\n */\nasync function launch(webpackConfig, options) {\n /* Options normalization. */\n const ops = options ? _.cloneDeep(options) : {};\n ops.port = normalizePort(ops.port || process.env.PORT || 3000);\n _.defaults(ops, {\n httpsRedirect: true,\n maxSsrRounds: DEFAULT_MAX_SSR_ROUNDS,\n ssrTimeout: DEFAULT_SSR_TIMEOUT,\n });\n if (!ops.staticCacheSize) ops.staticCacheSize = 1.e7;\n\n if (_.isUndefined(ops.logger)) {\n const { format, transports } = winston;\n ops.logger = winston.createLogger({\n level: ops.defaultLoggerLogLevel || 'info',\n format: format.combine(\n format.splat(),\n format.timestamp(),\n format.colorize(),\n format.printf(\n ({\n level,\n message,\n timestamp,\n stack,\n ...rest\n }) => {\n let res = `${level}\\t(at ${timestamp}):\\t${message}`;\n if (Object.keys(rest).length) {\n res += `\\n${JSON.stringify(rest, null, 2)}`;\n }\n if (stack) res += `\\n${stack}`;\n return res;\n },\n ),\n ),\n transports: [new transports.Console()],\n });\n }\n\n /* Creates servers, resolves and sets the port. */\n const expressServer = await serverFactory(webpackConfig, ops);\n\n let httpServer;\n if (ops.https) {\n httpServer = https.createServer({\n cert: ops.https.cert,\n key: ops.https.key,\n }, expressServer);\n } else httpServer = http.createServer(expressServer);\n\n /* Sets error handler for HTTP(S) server. */\n httpServer.on('error', (error) => {\n if (error.syscall !== 'listen') throw error;\n const bind = _.isString(ops.port) ? `Pipe ${ops.port}` : `Port ${ops.port}`;\n\n /* Human-readable message for some specific listen errors. */\n switch (error.code) {\n case 'EACCES':\n ops.logger.error(`${bind} requires elevated privileges`);\n process.exit(1);\n break;\n case 'EADDRINUSE':\n ops.logger.error(`${bind} is already in use`);\n process.exit(1);\n break;\n default:\n throw error;\n }\n });\n\n /* Listening event handler for HTTP(S) server. */\n httpServer.on('listening', () => {\n const addr = httpServer.address();\n const bind = _.isString(addr) ? `pipe ${addr}` : `port ${addr.port}`;\n ops.logger.info(`Server listening on ${bind} in ${\n process.env.NODE_ENV} mode`);\n });\n\n httpServer.listen(ops.port);\n\n return {\n expressServer,\n httpServer,\n };\n}\n\nlaunch.SCRIPT_LOCATIONS = SCRIPT_LOCATIONS;\n\nexport default launch;\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../src/server/index.js"],"names":["DEFAULT_MAX_SSR_ROUNDS","DEFAULT_SSR_TIMEOUT","normalizePort","value","port","launch","webpackConfig","options","ops","process","env","PORT","httpsRedirect","maxSsrRounds","ssrTimeout","staticCacheSize","logger","format","transports","winston","createLogger","level","defaultLoggerLogLevel","combine","splat","timestamp","colorize","printf","message","stack","rest","res","Object","keys","length","JSON","stringify","Console","expressServer","httpServer","https","createServer","cert","key","http","on","error","syscall","bind","code","exit","addr","address","info","NODE_ENV","listen","SCRIPT_LOCATIONS"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AAUA;;AACA;;AAGA;;AAEA;;AAEA;;AACA;;AAGA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;AATA;AAWA;AACA,MAAMA,sBAAsB,GAAG,EAA/B;AACA,MAAMC,mBAAmB,GAAG,IAA5B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,aAAT,CAAuBC,KAAvB,EAA8B;AAC5B,QAAMC,IAAI,GAAG,sBAASD,KAAT,CAAb;AACA,MAAI,sBAASC,IAAT,CAAJ,EAAoB,OAAOA,IAAP;AAAa;;AACjC,MAAI,CAAC,sBAASA,IAAT,CAAL,EAAqB,OAAOD,KAAP;AAAc;;AACnC,SAAO,KAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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AvC,QAAAA,OAAO,CAACyC,IAAR,CAAa,CAAb;AACA;;AACF;AACE,cAAMJ,KAAN;AAVJ;AAYD,GAjBD;AAmBA;;AACAP,EAAAA,UAAU,CAACM,EAAX,CAAc,WAAd,EAA2B,MAAM;AAC/B,UAAMM,IAAI,GAAGZ,UAAU,CAACa,OAAX,EAAb;AACA,UAAMJ,IAAI,GAAG,sBAASG,IAAT,IAAkB,QAAOA,IAAK,EAA9B,GAAmC,QAAOA,IAAI,CAAC/C,IAAK,EAAjE;AACAI,IAAAA,GAAG,CAACQ,MAAJ,CAAWqC,IAAX,CAAiB,uBAAsBL,IAAK,OAC1CvC,OAAO,CAACC,GAAR,CAAY4C,QAAS,OADvB;AAED,GALD;AAOAf,EAAAA,UAAU,CAACgB,MAAX,CAAkB/C,GAAG,CAACJ,IAAtB;AAEA,SAAO;AACLkC,IAAAA,aADK;AAELC,IAAAA;AAFK,GAAP;AAID;;AAEDlC,MAAM,CAACmD,gBAAP,GAA0BA,0BAA1B;eAEenD,M","sourcesContent":["import 'source-map-support/register';\n\nimport {\n cloneDeep,\n defaults,\n isFinite,\n isNumber,\n isUndefined,\n isString,\n toNumber,\n} from 'lodash';\n\nimport http from 'http';\nimport https from 'https';\n\n/* Polyfill required by ReactJS. */\nimport 'raf/polyfill';\n\nimport winston from 'winston';\n\nimport serverFactory from './server';\nimport { SCRIPT_LOCATIONS } from './renderer';\n\nexport { getDefaultCspSettings } from './server';\nexport * from './utils';\n\n// Various default settings of server factory (launch() function).\nconst DEFAULT_MAX_SSR_ROUNDS = 10;\nconst DEFAULT_SSR_TIMEOUT = 1000;\n\n/**\n * Normalizes a port into a number, string, or false.\n * TODO: Drop this function?\n * @ignore\n * @param {String} value Port name or number.\n * @return Port number (Number), name (String), or false.\n */\nfunction normalizePort(value) {\n const port = toNumber(value);\n if (isFinite(port)) return port; /* port number */\n if (!isNumber(port)) return value; /* named pipe */\n return false;\n}\n\n/**\n * Creates and launches web-server for ReactJS application. Allows zero\n * or detailed configuration, supports server-side rendering,\n * and development tools, including Hot Module Reloading (HMR).\n *\n * See {@link module:ReactGlobalState ReactGlobalState} for some additional\n * notes related to SSR, access to incoming requests during SSR, _etc._\n *\n * @param {object} webpackConfig Webpack configuration used to build\n * the frontend bundle. In production mode the server will read out of it\n * `context`, `publicPath`, and a few other parameters, necessary to locate\n * and serve the app bundle. In development mode the server will use entire\n * provided config to build the app bundle in memory, and further watch and\n * update it via HMR.\n * @param {object} [options] Additional parameters.\n * @param {Component} [options.Application] The root ReactJS component of\n * the app to use for the server-side rendering. When not provided\n * the server-side rendering is disabled.\n * @param {function} [options.beforeExpressJsError] Asynchronous callback\n * (`(server) => Promise<boolean>`) to be executed just before the default error\n * handler is added to ExpressJS server. If the callback is provided and its\n * result resolves to a truthy value, `react-utils` won't attach the default\n * error handler.\n * @param {function} [options.beforeExpressJsSetup] Asynchronous callback\n * (`(server) => Promise) to be executed right after ExpressJS server creation,\n * before any configuration is performed.\n * @param {BeforeRenderHook} [options.beforeRender] The hook to run just before\n * the server-side rendering. For each incoming request, it will be executed\n * just before the HTML markup is generated at the server. It allows to load\n * and provide the data necessary for server-side rendering, and also to inject\n * additional configuration and scripts into the generated HTML code.\n * @param {boolean} [options.noCsp] Set `true` to disable\n * Content-Security-Policy (CSP) headers altogether.\n * @param {function} [options.cspSettingsHook] A hook allowing\n * to customize [CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP)\n * settings for [helmet](https://github.com/helmetjs/helmet)'s\n * `contentSecurityPolicy` middleware on per-request basis.\n *\n * If provided it should be a with signature: \\\n * `(defaultSettings: object, req: object)` &rArr; `object` \\\n * which gets the default settings (also used without the hook),\n * and the incoming request object. The hook response will be passed\n * as options to the helmet `contentSecurityPolicy` middleware.\n *\n * Currently, the default settings is the following object in production\n * environment:\n * ```js\n * {\n * directives: {\n * defaultSrc: [\"'self'\"],\n * baseUri: [\"'self'\"],\n * blockAllMixedContent: [],\n * fontSrc: [\"'self'\", 'https:', 'data:'],\n * frameAncestors: [\"'self'\"],\n * frameSrc: [\"'self'\", 'https://*.youtube.com'],\n * imgSrc: [\"'self'\", 'data:'],\n * objectSrc: [\"'none'\"],\n * scriptSrc: [\"'self'\", \"'unsafe-eval'\", `'nonce-UNIQUE_NONCE_VALUE'`],\n * scriptSrcAttr: [\"'none'\"],\n * styleSrc: [\"'self'\", 'https:', \"'unsafe-inline'\"],\n * upgradeInsecureRequests: [] // Removed in dev mode.\n * }\n * }\n * ```\n * It matches the default value used by Helmet with a few updates:\n * - YouTube host is whitelisted in the `frameSrc` directive to ensure\n * the {@link YouTubeVideo} component works.\n * - An unique per-request nonce is added to `scriptSrc` directive to\n * whitelist auxiliary scripts injected by react-utils. The actual nonce\n * value can be fetched by host code via `.nonce` field of `req` argument\n * of `.beforeRender` hook.\n * - `upgradeInsecureRequests` directive is removed in development mode,\n * to simplify local testing with http requests.\n * @param {string} [options.defaultLoggerLogLevel=info] Log level for\n * the default logger, which is created if no `logger` option provided.\n * @param {boolean} [options.devMode] Pass in `true` to start the server in\n * development mode.\n * @param {string} [options.favicon] Path to the favicon to use by the server.\n * By default no favicon is used.\n * @param {object} [options.https] If provided, HTTPS server will be started,\n * instead of HTTP otherwise. The object should provide SSL certificate and key\n * via two string fields: `cert`, and `key`.\n * @param {string} [options.https.cert] SSL Certificate.\n * @param {string} [options.https.key] SSL key.\n * @param {boolean} [options.httpsRedirect=true] Pass in `true` to enable\n * automatic redirection of all incoming HTTP requests to HTTPS.\n *\n * To smoothly use it at `localhost` you need to run the server in HTTPS mode,\n * and also properly create and install a self-signed SSL sertificate on your\n * system. This article is helpful:\n * [How to get HTTPS working on your local development environment in 5 minutes](https://medium.freecodecamp.org/how-to-get-https-working-on-your-local-development-environment-in-5-minutes-7af615770eec)\n * @param {Logger} [options.logger] The logger to use at server side.\n * By default [`winston`](https://www.npmjs.com/package/winston) logger\n * with console transport is used. The logger you provide, or the default\n * `winston` logger otherwise, will be attached to the created ExpressJS server\n * object.\n * @param {function} [options.onExpressJsSetup] An async callback\n * (`(server) => Promise`) to be triggered when most of the server\n * configuration is completed, just before the server-side renderer,\n * and the default error handler are attached. You can use it to mount\n * custom API routes. The server-side logger can be accessed as `server.logger`.\n * @param {number|string} [options.port=3000] The port to start the server on.\n * @param {number} [options.staticCacheSize=1.e7] The maximum\n * static cache size in bytes. Defaults to ~10 MB.\n * @param {function} [options.staticCacheController] When given, it activates,\n * and controls the static caching of generated HTML markup. When this function\n * is provided, on each incoming request it is triggered with the request\n * passed in as the argument. To attempt to serve the response from the cache\n * it should return the object with the following fields:\n * - `key: string` &ndash; the cache key for the response;\n * - `maxage?: number` &ndash; the maximum age of cached result in ms.\n * If undefined - infinite age is assumed.\n * @param {number} [options.maxSsrRounds=10] Maximum number of SSR rounds.\n * @param {number} [options.ssrTimeout=1000] SSR timeout in milliseconds,\n * defaults to 1 second.\n * @return {Promise<{ expressServer: object, httpServer: object }>} Resolves to\n * an object with created Express and HTTP servers.\n */\nasync function launch(webpackConfig, options) {\n /* Options normalization. */\n const ops = options ? cloneDeep(options) : {};\n ops.port = normalizePort(ops.port || process.env.PORT || 3000);\n defaults(ops, {\n httpsRedirect: true,\n maxSsrRounds: DEFAULT_MAX_SSR_ROUNDS,\n ssrTimeout: DEFAULT_SSR_TIMEOUT,\n });\n if (!ops.staticCacheSize) ops.staticCacheSize = 1.e7;\n\n if (isUndefined(ops.logger)) {\n const { format, transports } = winston;\n ops.logger = winston.createLogger({\n level: ops.defaultLoggerLogLevel || 'info',\n format: format.combine(\n format.splat(),\n format.timestamp(),\n format.colorize(),\n format.printf(\n ({\n level,\n message,\n timestamp,\n stack,\n ...rest\n }) => {\n let res = `${level}\\t(at ${timestamp}):\\t${message}`;\n if (Object.keys(rest).length) {\n res += `\\n${JSON.stringify(rest, null, 2)}`;\n }\n if (stack) res += `\\n${stack}`;\n return res;\n },\n ),\n ),\n transports: [new transports.Console()],\n });\n }\n\n /* Creates servers, resolves and sets the port. */\n const expressServer = await serverFactory(webpackConfig, ops);\n\n let httpServer;\n if (ops.https) {\n httpServer = https.createServer({\n cert: ops.https.cert,\n key: ops.https.key,\n }, expressServer);\n } else httpServer = http.createServer(expressServer);\n\n /* Sets error handler for HTTP(S) server. */\n httpServer.on('error', (error) => {\n if (error.syscall !== 'listen') throw error;\n const bind = isString(ops.port) ? `Pipe ${ops.port}` : `Port ${ops.port}`;\n\n /* Human-readable message for some specific listen errors. */\n switch (error.code) {\n case 'EACCES':\n ops.logger.error(`${bind} requires elevated privileges`);\n process.exit(1);\n break;\n case 'EADDRINUSE':\n ops.logger.error(`${bind} is already in use`);\n process.exit(1);\n break;\n default:\n throw error;\n }\n });\n\n /* Listening event handler for HTTP(S) server. */\n httpServer.on('listening', () => {\n const addr = httpServer.address();\n const bind = isString(addr) ? `pipe ${addr}` : `port ${addr.port}`;\n ops.logger.info(`Server listening on ${bind} in ${\n process.env.NODE_ENV} mode`);\n });\n\n httpServer.listen(ops.port);\n\n return {\n expressServer,\n httpServer,\n };\n}\n\nlaunch.SCRIPT_LOCATIONS = SCRIPT_LOCATIONS;\n\nexport default launch;\n"],"file":"index.js"}
@@ -11,7 +11,7 @@ exports.isBrotliAcceptable = isBrotliAcceptable;
11
11
 
12
12
  var _reactGlobalState = require("@dr.pogodin/react-global-state");
13
13
 
14
- var _lodash = _interopRequireDefault(require("lodash"));
14
+ var _lodash = require("lodash");
15
15
 
16
16
  var _config = _interopRequireDefault(require("config"));
17
17
 
@@ -40,8 +40,7 @@ var _jsxRuntime = require("react/jsx-runtime");
40
40
  /**
41
41
  * ExpressJS middleware for server-side rendering of a ReactJS app.
42
42
  */
43
- const sanitizedConfig = _lodash.default.omit(_config.default, 'SECRET');
44
-
43
+ const sanitizedConfig = (0, _lodash.omit)(_config.default, 'SECRET');
45
44
  const SCRIPT_LOCATIONS = {
46
45
  BODY_OPEN: 'BODY_OPEN',
47
46
  DEFAULT: 'DEFAULT',
@@ -174,13 +173,13 @@ function factory(webpackConfig, options) {
174
173
 
175
174
  const cache = options.staticCacheController ? new _Cache.default(options.staticCacheSize) : null;
176
175
  const CHUNK_GROUPS = readChunkGroupsJson(outputPath);
177
-
178
- const ops = _lodash.default.defaults(_lodash.default.clone(options), {
176
+ const ops = (0, _lodash.defaults)((0, _lodash.clone)(options), {
179
177
  beforeRender: () => Promise.resolve({})
180
178
  });
181
-
182
179
  return async (req, res, next) => {
183
180
  try {
181
+ // Ensures any caches always revalidate HTML markup before reuse.
182
+ res.set('Cache-Control', 'no-cache');
184
183
  let cacheRef;
185
184
 
186
185
  if (cache) {
@@ -231,7 +230,7 @@ function factory(webpackConfig, options) {
231
230
  let App = options.Application;
232
231
  const ssrContext = {
233
232
  req,
234
- state: _lodash.default.cloneDeep(initialState || {}),
233
+ state: (0, _lodash.cloneDeep)(initialState || {}),
235
234
  // Array of chunk names encountered during the rendering.
236
235
  chunks: []
237
236
  };
@@ -267,11 +266,10 @@ function factory(webpackConfig, options) {
267
266
  }
268
267
 
269
268
  let chunkGroups;
270
-
271
- const webpackStats = _lodash.default.get(res.locals, 'webpack.devMiddleware.stats');
269
+ const webpackStats = (0, _lodash.get)(res.locals, 'webpack.devMiddleware.stats');
272
270
 
273
271
  if (webpackStats) {
274
- chunkGroups = _lodash.default.mapValues(webpackStats.toJson({
272
+ chunkGroups = (0, _lodash.mapValues)(webpackStats.toJson({
275
273
  all: false,
276
274
  chunkGroups: true
277
275
  }).namedChunkGroups, item => item.assets.map(({
@@ -329,9 +327,9 @@ function factory(webpackConfig, options) {
329
327
  let headOpenExtraScripts;
330
328
 
331
329
  if (extraScripts) {
332
- bodyOpenExtraScripts = extraScripts.filter(script => _lodash.default.isObject(script) && script.location === SCRIPT_LOCATIONS.BODY_OPEN).map(script => script.code).join('');
333
- defaultExtraScripts = extraScripts.filter(script => _lodash.default.isString(script) || script.location === SCRIPT_LOCATIONS.DEFAULT).map(script => _lodash.default.isString(script) ? script : script.code).join('');
334
- headOpenExtraScripts = extraScripts.filter(script => _lodash.default.isObject(script) && script.location === SCRIPT_LOCATIONS.HEAD_OPEN).map(script => script.code).join('');
330
+ bodyOpenExtraScripts = extraScripts.filter(script => (0, _lodash.isObject)(script) && script.location === SCRIPT_LOCATIONS.BODY_OPEN).map(script => script.code).join('');
331
+ defaultExtraScripts = extraScripts.filter(script => (0, _lodash.isString)(script) || script.location === SCRIPT_LOCATIONS.DEFAULT).map(script => (0, _lodash.isString)(script) ? script : script.code).join('');
332
+ headOpenExtraScripts = extraScripts.filter(script => (0, _lodash.isObject)(script) && script.location === SCRIPT_LOCATIONS.HEAD_OPEN).map(script => script.code).join('');
335
333
  }
336
334
 
337
335
  const faviconLink = ops.favicon ? '<link rel="shortcut icon" href="/favicon.ico" />' : '';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/renderer.jsx"],"names":["sanitizedConfig","_","omit","config","SCRIPT_LOCATIONS","BODY_OPEN","DEFAULT","HEAD_OPEN","getBuildInfo","context","url","path","resolve","JSON","parse","fs","readFileSync","readChunkGroupsJson","buildDir","res","err","prepareCipher","key","Promise","reject","forge","random","getBytes","iv","cipher","createCipher","start","isBrotliAcceptable","req","acceptable","get","ops","split","i","length","type","priority","trim","parseFloat","factory","webpackConfig","options","buildInfo","global","TRU_BUILD_INFO","publicPath","outputPath","output","manifestLink","existsSync","cache","staticCacheController","Cache","staticCacheSize","CHUNK_GROUPS","defaults","clone","beforeRender","next","cacheRef","data","noCsp","set","send","error","html","h","toString","regex","RegExp","nonce","replace","configToInject","extraScripts","initialState","all","helmet","App","Application","ssrContext","state","cloneDeep","chunks","markup","ssrStart","Date","now","round","maxSsrRounds","ReactDOM","renderToString","dirty","timeout","ssrTimeout","ok","race","allSettled","pending","time","timer","then","Helmet","renderStatic","chunkGroups","webpackStats","locals","mapValues","toJson","namedChunkGroups","item","assets","map","name","dr_pogodin_react_utils___split_components","payload","CONFIG","ISTATE","ignoreFunction","unsafe","update","util","createBuffer","finish","INJ","encode64","status","chunkSet","Set","forEach","chunk","asset","add","styleChunkString","scriptChunkString","endsWith","bodyOpenExtraScripts","defaultExtraScripts","headOpenExtraScripts","filter","script","isObject","location","code","join","isString","faviconLink","favicon","title","meta","buffer"],"mappings":";;;;;;;;;;;AAIA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;;;AApBA;AACA;AACA;AAoBA,MAAMA,eAAe,GAAGC,gBAAEC,IAAF,CAAOC,eAAP,EAAe,QAAf,CAAxB;;AAEO,MAAMC,gBAAgB,GAAG;AAC9BC,EAAAA,SAAS,EAAE,WADmB;AAE9BC,EAAAA,OAAO,EAAE,SAFqB;AAG9BC,EAAAA,SAAS,EAAE;AAHmB,CAAzB;AAMP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACA,SAASC,YAAT,CAAsBC,OAAtB,EAA+B;AAC7B,QAAMC,GAAG,GAAGC,cAAKC,OAAL,CAAaH,OAAb,EAAsB,aAAtB,CAAZ;;AACA,SAAOI,IAAI,CAACC,KAAL,CAAWC,YAAGC,YAAH,CAAgBN,GAAhB,CAAX,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASO,mBAAT,CAA6BC,QAA7B,EAAuC;AACrC,QAAMR,GAAG,GAAGC,cAAKC,OAAL,CAAaM,QAAb,EAAuB,uBAAvB,CAAZ;;AACA,MAAIC,GAAJ;;AACA,MAAI;AACFA,IAAAA,GAAG,GAAGN,IAAI,CAACC,KAAL,CAAWC,YAAGC,YAAH,CAAgBN,GAAhB,CAAX,CAAN;AACD,GAFD,CAEE,OAAOU,GAAP,EAAY;AACZD,IAAAA,GAAG,GAAG,IAAN;AACD;;AACD,SAAOA,GAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASE,aAAT,CAAuBC,GAAvB,EAA4B;AAC1B,SAAO,IAAIC,OAAJ,CAAY,CAACX,OAAD,EAAUY,MAAV,KAAqB;AACtCC,uBAAMC,MAAN,CAAaC,QAAb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A6NE,OAAO+C,KAAP,EAAc;AACdN,MAAAA,IAAI,CAACM,KAAD,CAAJ;AACD;AACF,GAjOD;AAkOD","sourcesContent":["/**\n * ExpressJS middleware for server-side rendering of a ReactJS app.\n */\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\n\nimport _ from 'lodash';\nimport config from 'config';\nimport forge from 'node-forge';\nimport fs from 'fs';\nimport path from 'path';\nimport { brotliCompress, brotliDecompress } from 'zlib';\n\nimport ReactDOM from 'react-dom/server';\nimport { Helmet } from 'react-helmet';\nimport { StaticRouter } from 'react-router-dom/server';\nimport serializeJs from 'serialize-javascript';\n\nimport time from 'utils/time';\n\nimport Cache from './Cache';\n\nconst sanitizedConfig = _.omit(config, 'SECRET');\n\nexport const SCRIPT_LOCATIONS = {\n BODY_OPEN: 'BODY_OPEN',\n DEFAULT: 'DEFAULT',\n HEAD_OPEN: 'HEAD_OPEN',\n};\n\n/**\n * Reads build-time information about the app. This information is generated\n * by our standard Webpack config for apps, and it is written into\n * \".build-info\" file in the context folder specified in Webpack config.\n * At the moment, that file contains build timestamp and a random 32-bit key,\n * suitable for cryptographical use.\n * @ignore\n * @param {String} context Webpack context path used during the build.\n * @return {Object} Resolves to the build-time information.\n */\nfunction getBuildInfo(context) {\n const url = path.resolve(context, '.build-info');\n return JSON.parse(fs.readFileSync(url));\n}\n\n/**\n * Attempts to read from disk the named chunk groups mapping generated\n * by Webpack during the compilation.\n * It will not work for development builds, where these stats should be captured\n * via compilator callback.\n * @ignore\n * @param {string} buildDir\n * @return {object}\n */\nfunction readChunkGroupsJson(buildDir) {\n const url = path.resolve(buildDir, '__chunk_groups__.json');\n let res;\n try {\n res = JSON.parse(fs.readFileSync(url));\n } catch (err) {\n res = null;\n }\n return res;\n}\n\n/**\n * Prepares a new Cipher for data encryption.\n * @ignore\n * @param {String} key Encryption key (32-bit random key is expected, see\n * node-forge documentation, in case of doubts).\n * @return {Promise} Resolves to the object with two fields:\n * 1. cipher - a new Cipher, ready for encryption;\n * 2. iv - initial vector used by the cipher.\n */\nfunction prepareCipher(key) {\n return new Promise((resolve, reject) => {\n forge.random.getBytes(32, (err, iv) => {\n if (err) reject(err);\n else {\n const cipher = forge.cipher.createCipher('AES-CBC', key);\n cipher.start({ iv });\n resolve({ cipher, iv });\n }\n });\n });\n}\n\n/**\n * Given an incoming HTTP requests, it deduces whether Brotli-encoded responses\n * are acceptable to the caller.\n * @param {object} req\n * @return {boolean}\n * @ignore\n */\nexport function isBrotliAcceptable(req) {\n const acceptable = req.get('accept-encoding');\n if (acceptable) {\n const ops = acceptable.split(',');\n for (let i = 0; i < ops.length; ++i) {\n const [type, priority] = ops[i].trim().split(';q=');\n if ((type === '*' || type === 'br')\n && (!priority || parseFloat(priority) > 0)) {\n return true;\n }\n }\n }\n return false;\n}\n\n/**\n * Creates the middleware.\n * @param {object} webpackConfig\n * @param {object} options Additional options:\n * @param {boolean} [options.favicon] `true` will include favicon\n * link into the rendered HTML templates.\n * @param {boolean} [options.noCsp] `true` means that no\n * Content-Security-Policy (CSP) is used by server, thus the renderer\n * may cut a few corners.\n * @param {number} options.maxSsrRounds\n * @param {number} options.ssrTimeout\n * @return {function} Created middleware.\n */\nexport default function factory(webpackConfig, options) {\n const buildInfo = getBuildInfo(webpackConfig.context);\n\n global.TRU_BUILD_INFO = buildInfo;\n\n // publicPath from webpack.output has a trailing slash at the end.\n const { publicPath, path: outputPath } = webpackConfig.output;\n\n let manifestLink = fs.existsSync(`${outputPath}/manifest.json`);\n manifestLink = manifestLink ? (\n `<link rel=\"manifest\" href=\"${publicPath}manifest.json\"></link>`\n ) : '';\n\n // TODO: Update the caching mechanics to stored cached data gzipped,\n // and serve them without a need to unpacking server-side.\n const cache = options.staticCacheController\n ? new Cache(options.staticCacheSize) : null;\n\n const CHUNK_GROUPS = readChunkGroupsJson(outputPath);\n\n const ops = _.defaults(_.clone(options), {\n beforeRender: () => Promise.resolve({}),\n });\n\n return async (req, res, next) => {\n try {\n let cacheRef;\n if (cache) {\n cacheRef = options.staticCacheController(req);\n if (cacheRef) {\n const data = cache.get(cacheRef);\n if (data !== null) {\n if (options.noCsp && isBrotliAcceptable(req)) {\n res.set('Content-Type', 'text/html');\n res.set('Content-Encoding', 'br');\n res.send(data);\n } else {\n brotliDecompress(data, (error, html) => {\n if (error) next(error);\n else {\n let h = html.toString();\n if (!options.noCsp) {\n // TODO: Starting from Node v15 we'll be able to use string's\n // .replaceAll() method instead relying on reg. expression for\n // global matching.\n const regex = new RegExp(data.nonce, 'g');\n h = h.replace(regex, req.nonce);\n }\n res.send(h);\n }\n });\n }\n return;\n }\n }\n }\n\n const [{\n configToInject,\n extraScripts,\n initialState,\n }, {\n cipher,\n iv,\n }] = await Promise.all([\n ops.beforeRender(req, sanitizedConfig),\n prepareCipher(buildInfo.key),\n ]);\n\n let helmet;\n\n /* Optional server-side rendering. */\n let App = options.Application;\n const ssrContext = {\n req,\n state: _.cloneDeep(initialState || {}),\n\n // Array of chunk names encountered during the rendering.\n chunks: [],\n };\n if (App) {\n let markup;\n const ssrStart = Date.now();\n for (let round = 0; round < options.maxSsrRounds; ++round) {\n ssrContext.chunks = [];\n markup = ReactDOM.renderToString((\n <GlobalStateProvider\n initialState={ssrContext.state}\n ssrContext={ssrContext}\n >\n <StaticRouter location={req.url}>\n <App />\n </StaticRouter>\n </GlobalStateProvider>\n ));\n\n if (!ssrContext.dirty) break;\n\n /* eslint-disable no-await-in-loop */\n const timeout = options.ssrTimeout + ssrStart - Date.now();\n const ok = timeout > 0 && await Promise.race([\n Promise.allSettled(ssrContext.pending),\n time.timer(timeout).then(() => false),\n ]);\n if (!ok) break;\n /* eslint-enable no-await-in-loop */\n }\n App = markup;\n\n /* This takes care about server-side rendering of page title and meta tags\n * (still demands injection into HTML template, which happens below). */\n helmet = Helmet.renderStatic();\n }\n\n let chunkGroups;\n const webpackStats = _.get(res.locals, 'webpack.devMiddleware.stats');\n if (webpackStats) {\n chunkGroups = _.mapValues(\n webpackStats.toJson({\n all: false,\n chunkGroups: true,\n }).namedChunkGroups,\n (item) => item.assets.map(({ name }) => name),\n );\n } else if (CHUNK_GROUPS) chunkGroups = CHUNK_GROUPS;\n else chunkGroups = {};\n\n /* Encrypts data to be injected into HTML.\n * Keep in mind, that this encryption is no way secure: as the JS bundle\n * contains decryption key and is able to decode it at the client side.\n * Hovewer, for a number of reasons, encryption of injected data is still\n * better than injection of a plain text. */\n delete ssrContext.state.dr_pogodin_react_utils___split_components;\n\n const payload = serializeJs({\n CHUNK_GROUPS: chunkGroups,\n CONFIG: configToInject || sanitizedConfig,\n ISTATE: ssrContext.state,\n }, {\n ignoreFunction: true,\n unsafe: true,\n });\n cipher.update(forge.util.createBuffer(payload, 'utf8'));\n cipher.finish();\n const INJ = forge.util.encode64(`${iv}${cipher.output.data}`);\n\n if (ssrContext.status) res.status(ssrContext.status);\n\n const chunkSet = new Set();\n\n // TODO: \"main\" chunk has to be added explicitly,\n // because unlike all other chunks they are not managed by <CodeSplit>\n // component, thus they are not added to the ssrContext.chunks\n // automatically. Actually, names of these entry chunks should be\n // read from Wepback config, as the end user may customize them,\n // remove or add other entry points, but it requires additional\n // efforts to figure out how to automatically order them right,\n // thus for now this handles the default config.\n [\n 'main',\n ...ssrContext.chunks,\n ].forEach((chunk) => {\n const assets = chunkGroups[chunk];\n if (assets) assets.forEach((asset) => chunkSet.add(asset));\n });\n\n let styleChunkString = '';\n let scriptChunkString = '';\n chunkSet.forEach((chunk) => {\n if (chunk.endsWith('.css')) {\n styleChunkString += `<link href=\"${publicPath}${chunk}\" rel=\"stylesheet\" />`;\n } else if (\n chunk.endsWith('.js')\n // In dev mode HMR adds JS updates into asset arrays,\n // and they (updates) should be ignored.\n && !chunk.endsWith('.hot-update.js')\n ) {\n scriptChunkString += `<script src=\"${publicPath}${chunk}\" type=\"application/javascript\"></script>`;\n }\n });\n\n let bodyOpenExtraScripts;\n let defaultExtraScripts;\n let headOpenExtraScripts;\n if (extraScripts) {\n bodyOpenExtraScripts = extraScripts\n .filter((script) => _.isObject(script)\n && script.location === SCRIPT_LOCATIONS.BODY_OPEN)\n .map((script) => script.code)\n .join('');\n defaultExtraScripts = extraScripts\n .filter((script) => _.isString(script)\n || script.location === SCRIPT_LOCATIONS.DEFAULT)\n .map((script) => (_.isString(script) ? script : script.code))\n .join('');\n headOpenExtraScripts = extraScripts\n .filter((script) => _.isObject(script)\n && script.location === SCRIPT_LOCATIONS.HEAD_OPEN)\n .map((script) => script.code)\n .join('');\n }\n\n const faviconLink = ops.favicon ? (\n '<link rel=\"shortcut icon\" href=\"/favicon.ico\" />'\n ) : '';\n\n const html = `<!DOCTYPE html>\n <html lang=\"en\">\n <head>\n ${headOpenExtraScripts || ''}\n ${helmet ? helmet.title.toString() : ''}\n ${helmet ? helmet.meta.toString() : ''}\n <meta name=\"theme-color\" content=\"#FFFFFF\"/>\n ${manifestLink}\n ${styleChunkString}\n ${faviconLink}\n <meta charset=\"utf-8\" />\n <meta\n content=\"width=device-width,initial-scale=1.0\"\n name=\"viewport\"\n />\n </head>\n <body>\n ${bodyOpenExtraScripts || ''}\n <div id=\"react-view\">${App || ''}</div>\n <script\n id=\"inj\"\n type=\"application/javascript\"\n ${options.noCsp ? '' : `nonce=\"${req.nonce}\"`}\n >\n window.INJ=\"${INJ}\"\n </script>\n ${scriptChunkString}\n ${defaultExtraScripts || ''}\n </body>\n </html>`;\n\n res.send(html);\n\n if (cacheRef) {\n brotliCompress(html, (error, buffer) => {\n if (error) throw error;\n buffer.nonce = req.nonce; // eslint-disable-line no-param-reassign\n cache.add(buffer, cacheRef.key);\n });\n }\n } catch (error) {\n next(error);\n }\n };\n}\n"],"file":"renderer.js"}
1
+ {"version":3,"sources":["../../../src/server/renderer.jsx"],"names":["sanitizedConfig","config","SCRIPT_LOCATIONS","BODY_OPEN","DEFAULT","HEAD_OPEN","getBuildInfo","context","url","path","resolve","JSON","parse","fs","readFileSync","readChunkGroupsJson","buildDir","res","err","prepareCipher","key","Promise","reject","forge","random","getBytes","iv","cipher","createCipher","start","isBrotliAcceptable","req","acceptable","get","ops","split","i","length","type","priority","trim","parseFloat","factory","webpackConfig","options","buildInfo","global","TRU_BUILD_INFO","publicPath","outputPath","output","manifestLink","existsSync","cache","staticCacheController","Cache","staticCacheSize","CHUNK_GROUPS","beforeRender","next","set","cacheRef","data","noCsp","send","error","html","h","toString","regex","RegExp","nonce","replace","configToInject","extraScripts","initialState","all","helmet","App","Application","ssrContext","state","chunks","markup","ssrStart","Date","now","round","maxSsrRounds","ReactDOM","renderToString","dirty","timeout","ssrTimeout","ok","race","allSettled","pending","time","timer","then","Helmet","renderStatic","chunkGroups","webpackStats","locals","toJson","namedChunkGroups","item","assets","map","name","dr_pogodin_react_utils___split_components","payload","CONFIG","ISTATE","ignoreFunction","unsafe","update","util","createBuffer","finish","INJ","encode64","status","chunkSet","Set","forEach","chunk","asset","add","styleChunkString","scriptChunkString","endsWith","bodyOpenExtraScripts","defaultExtraScripts","headOpenExtraScripts","filter","script","location","code","join","faviconLink","favicon","title","meta","buffer"],"mappings":";;;;;;;;;;;AAIA;;AAEA;;AAWA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;;;AA9BA;AACA;AACA;AA8BA,MAAMA,eAAe,GAAG,kBAAKC,eAAL,EAAa,QAAb,CAAxB;AAEO,MAAMC,gBAAgB,GAAG;AAC9BC,EAAAA,SAAS,EAAE,WADmB;AAE9BC,EAAAA,OAAO,EAAE,SAFqB;AAG9BC,EAAAA,SAAS,EAAE;AAHmB,CAAzB;AAMP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACA,SAASC,YAAT,CAAsBC,OAAtB,EAA+B;AAC7B,QAAMC,GAAG,GAAGC,cAAKC,OAAL,CAAaH,OAAb,EAAsB,aAAtB,CAAZ;;AACA,SAAOI,IAAI,CAACC,KAAL,CAAWC,YAAGC,YAAH,CAAgBN,GAAhB,CAAX,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA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;AACA,cAAcU,iBAAkB;AAChC,cAAcG,mBAAmB,IAAI,EAAG;AACxC;AACA,gBA7BM;AA+BAtH,MAAAA,GAAG,CAAC+C,IAAJ,CAASE,IAAT;;AAEA,UAAIL,QAAJ,EAAc;AACZ,kCAAeK,IAAf,EAAqB,CAACD,KAAD,EAAQiF,MAAR,KAAmB;AACtC,cAAIjF,KAAJ,EAAW,MAAMA,KAAN;AACXiF,UAAAA,MAAM,CAAC3E,KAAP,GAAexC,GAAG,CAACwC,KAAnB,CAFsC,CAEZ;;AAC1BlB,UAAAA,KAAK,CAAC6E,GAAN,CAAUgB,MAAV,EAAkBrF,QAAQ,CAACzC,GAA3B;AACD,SAJD;AAKD;AACF,KAhOD,CAgOE,OAAO6C,KAAP,EAAc;AACdN,MAAAA,IAAI,CAACM,KAAD,CAAJ;AACD;AACF,GApOD;AAqOD","sourcesContent":["/**\n * ExpressJS middleware for server-side rendering of a ReactJS app.\n */\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\n\nimport {\n clone,\n cloneDeep,\n defaults,\n isObject,\n isString,\n get,\n mapValues,\n omit,\n} from 'lodash';\n\nimport config from 'config';\nimport forge from 'node-forge';\nimport fs from 'fs';\nimport path from 'path';\nimport { brotliCompress, brotliDecompress } from 'zlib';\n\nimport ReactDOM from 'react-dom/server';\nimport { Helmet } from 'react-helmet';\nimport { StaticRouter } from 'react-router-dom/server';\nimport serializeJs from 'serialize-javascript';\n\nimport time from 'utils/time';\n\nimport Cache from './Cache';\n\nconst sanitizedConfig = omit(config, 'SECRET');\n\nexport const SCRIPT_LOCATIONS = {\n BODY_OPEN: 'BODY_OPEN',\n DEFAULT: 'DEFAULT',\n HEAD_OPEN: 'HEAD_OPEN',\n};\n\n/**\n * Reads build-time information about the app. This information is generated\n * by our standard Webpack config for apps, and it is written into\n * \".build-info\" file in the context folder specified in Webpack config.\n * At the moment, that file contains build timestamp and a random 32-bit key,\n * suitable for cryptographical use.\n * @ignore\n * @param {String} context Webpack context path used during the build.\n * @return {Object} Resolves to the build-time information.\n */\nfunction getBuildInfo(context) {\n const url = path.resolve(context, '.build-info');\n return JSON.parse(fs.readFileSync(url));\n}\n\n/**\n * Attempts to read from disk the named chunk groups mapping generated\n * by Webpack during the compilation.\n * It will not work for development builds, where these stats should be captured\n * via compilator callback.\n * @ignore\n * @param {string} buildDir\n * @return {object}\n */\nfunction readChunkGroupsJson(buildDir) {\n const url = path.resolve(buildDir, '__chunk_groups__.json');\n let res;\n try {\n res = JSON.parse(fs.readFileSync(url));\n } catch (err) {\n res = null;\n }\n return res;\n}\n\n/**\n * Prepares a new Cipher for data encryption.\n * @ignore\n * @param {String} key Encryption key (32-bit random key is expected, see\n * node-forge documentation, in case of doubts).\n * @return {Promise} Resolves to the object with two fields:\n * 1. cipher - a new Cipher, ready for encryption;\n * 2. iv - initial vector used by the cipher.\n */\nfunction prepareCipher(key) {\n return new Promise((resolve, reject) => {\n forge.random.getBytes(32, (err, iv) => {\n if (err) reject(err);\n else {\n const cipher = forge.cipher.createCipher('AES-CBC', key);\n cipher.start({ iv });\n resolve({ cipher, iv });\n }\n });\n });\n}\n\n/**\n * Given an incoming HTTP requests, it deduces whether Brotli-encoded responses\n * are acceptable to the caller.\n * @param {object} req\n * @return {boolean}\n * @ignore\n */\nexport function isBrotliAcceptable(req) {\n const acceptable = req.get('accept-encoding');\n if (acceptable) {\n const ops = acceptable.split(',');\n for (let i = 0; i < ops.length; ++i) {\n const [type, priority] = ops[i].trim().split(';q=');\n if ((type === '*' || type === 'br')\n && (!priority || parseFloat(priority) > 0)) {\n return true;\n }\n }\n }\n return false;\n}\n\n/**\n * Creates the middleware.\n * @param {object} webpackConfig\n * @param {object} options Additional options:\n * @param {boolean} [options.favicon] `true` will include favicon\n * link into the rendered HTML templates.\n * @param {boolean} [options.noCsp] `true` means that no\n * Content-Security-Policy (CSP) is used by server, thus the renderer\n * may cut a few corners.\n * @param {number} options.maxSsrRounds\n * @param {number} options.ssrTimeout\n * @return {function} Created middleware.\n */\nexport default function factory(webpackConfig, options) {\n const buildInfo = getBuildInfo(webpackConfig.context);\n\n global.TRU_BUILD_INFO = buildInfo;\n\n // publicPath from webpack.output has a trailing slash at the end.\n const { publicPath, path: outputPath } = webpackConfig.output;\n\n let manifestLink = fs.existsSync(`${outputPath}/manifest.json`);\n manifestLink = manifestLink ? (\n `<link rel=\"manifest\" href=\"${publicPath}manifest.json\"></link>`\n ) : '';\n\n // TODO: Update the caching mechanics to stored cached data gzipped,\n // and serve them without a need to unpacking server-side.\n const cache = options.staticCacheController\n ? new Cache(options.staticCacheSize) : null;\n\n const CHUNK_GROUPS = readChunkGroupsJson(outputPath);\n\n const ops = defaults(clone(options), {\n beforeRender: () => Promise.resolve({}),\n });\n\n return async (req, res, next) => {\n try {\n // Ensures any caches always revalidate HTML markup before reuse.\n res.set('Cache-Control', 'no-cache');\n\n let cacheRef;\n if (cache) {\n cacheRef = options.staticCacheController(req);\n if (cacheRef) {\n const data = cache.get(cacheRef);\n if (data !== null) {\n if (options.noCsp && isBrotliAcceptable(req)) {\n res.set('Content-Type', 'text/html');\n res.set('Content-Encoding', 'br');\n res.send(data);\n } else {\n brotliDecompress(data, (error, html) => {\n if (error) next(error);\n else {\n let h = html.toString();\n if (!options.noCsp) {\n // TODO: Starting from Node v15 we'll be able to use string's\n // .replaceAll() method instead relying on reg. expression for\n // global matching.\n const regex = new RegExp(data.nonce, 'g');\n h = h.replace(regex, req.nonce);\n }\n res.send(h);\n }\n });\n }\n return;\n }\n }\n }\n\n const [{\n configToInject,\n extraScripts,\n initialState,\n }, {\n cipher,\n iv,\n }] = await Promise.all([\n ops.beforeRender(req, sanitizedConfig),\n prepareCipher(buildInfo.key),\n ]);\n\n let helmet;\n\n /* Optional server-side rendering. */\n let App = options.Application;\n const ssrContext = {\n req,\n state: cloneDeep(initialState || {}),\n\n // Array of chunk names encountered during the rendering.\n chunks: [],\n };\n if (App) {\n let markup;\n const ssrStart = Date.now();\n for (let round = 0; round < options.maxSsrRounds; ++round) {\n ssrContext.chunks = [];\n markup = ReactDOM.renderToString((\n <GlobalStateProvider\n initialState={ssrContext.state}\n ssrContext={ssrContext}\n >\n <StaticRouter location={req.url}>\n <App />\n </StaticRouter>\n </GlobalStateProvider>\n ));\n\n if (!ssrContext.dirty) break;\n\n /* eslint-disable no-await-in-loop */\n const timeout = options.ssrTimeout + ssrStart - Date.now();\n const ok = timeout > 0 && await Promise.race([\n Promise.allSettled(ssrContext.pending),\n time.timer(timeout).then(() => false),\n ]);\n if (!ok) break;\n /* eslint-enable no-await-in-loop */\n }\n App = markup;\n\n /* This takes care about server-side rendering of page title and meta tags\n * (still demands injection into HTML template, which happens below). */\n helmet = Helmet.renderStatic();\n }\n\n let chunkGroups;\n const webpackStats = get(res.locals, 'webpack.devMiddleware.stats');\n if (webpackStats) {\n chunkGroups = mapValues(\n webpackStats.toJson({\n all: false,\n chunkGroups: true,\n }).namedChunkGroups,\n (item) => item.assets.map(({ name }) => name),\n );\n } else if (CHUNK_GROUPS) chunkGroups = CHUNK_GROUPS;\n else chunkGroups = {};\n\n /* Encrypts data to be injected into HTML.\n * Keep in mind, that this encryption is no way secure: as the JS bundle\n * contains decryption key and is able to decode it at the client side.\n * Hovewer, for a number of reasons, encryption of injected data is still\n * better than injection of a plain text. */\n delete ssrContext.state.dr_pogodin_react_utils___split_components;\n\n const payload = serializeJs({\n CHUNK_GROUPS: chunkGroups,\n CONFIG: configToInject || sanitizedConfig,\n ISTATE: ssrContext.state,\n }, {\n ignoreFunction: true,\n unsafe: true,\n });\n cipher.update(forge.util.createBuffer(payload, 'utf8'));\n cipher.finish();\n const INJ = forge.util.encode64(`${iv}${cipher.output.data}`);\n\n if (ssrContext.status) res.status(ssrContext.status);\n\n const chunkSet = new Set();\n\n // TODO: \"main\" chunk has to be added explicitly,\n // because unlike all other chunks they are not managed by <CodeSplit>\n // component, thus they are not added to the ssrContext.chunks\n // automatically. Actually, names of these entry chunks should be\n // read from Wepback config, as the end user may customize them,\n // remove or add other entry points, but it requires additional\n // efforts to figure out how to automatically order them right,\n // thus for now this handles the default config.\n [\n 'main',\n ...ssrContext.chunks,\n ].forEach((chunk) => {\n const assets = chunkGroups[chunk];\n if (assets) assets.forEach((asset) => chunkSet.add(asset));\n });\n\n let styleChunkString = '';\n let scriptChunkString = '';\n chunkSet.forEach((chunk) => {\n if (chunk.endsWith('.css')) {\n styleChunkString += `<link href=\"${publicPath}${chunk}\" rel=\"stylesheet\" />`;\n } else if (\n chunk.endsWith('.js')\n // In dev mode HMR adds JS updates into asset arrays,\n // and they (updates) should be ignored.\n && !chunk.endsWith('.hot-update.js')\n ) {\n scriptChunkString += `<script src=\"${publicPath}${chunk}\" type=\"application/javascript\"></script>`;\n }\n });\n\n let bodyOpenExtraScripts;\n let defaultExtraScripts;\n let headOpenExtraScripts;\n if (extraScripts) {\n bodyOpenExtraScripts = extraScripts\n .filter((script) => isObject(script)\n && script.location === SCRIPT_LOCATIONS.BODY_OPEN)\n .map((script) => script.code)\n .join('');\n defaultExtraScripts = extraScripts\n .filter((script) => isString(script)\n || script.location === SCRIPT_LOCATIONS.DEFAULT)\n .map((script) => (isString(script) ? script : script.code))\n .join('');\n headOpenExtraScripts = extraScripts\n .filter((script) => isObject(script)\n && script.location === SCRIPT_LOCATIONS.HEAD_OPEN)\n .map((script) => script.code)\n .join('');\n }\n\n const faviconLink = ops.favicon ? (\n '<link rel=\"shortcut icon\" href=\"/favicon.ico\" />'\n ) : '';\n\n const html = `<!DOCTYPE html>\n <html lang=\"en\">\n <head>\n ${headOpenExtraScripts || ''}\n ${helmet ? helmet.title.toString() : ''}\n ${helmet ? helmet.meta.toString() : ''}\n <meta name=\"theme-color\" content=\"#FFFFFF\"/>\n ${manifestLink}\n ${styleChunkString}\n ${faviconLink}\n <meta charset=\"utf-8\" />\n <meta\n content=\"width=device-width,initial-scale=1.0\"\n name=\"viewport\"\n />\n </head>\n <body>\n ${bodyOpenExtraScripts || ''}\n <div id=\"react-view\">${App || ''}</div>\n <script\n id=\"inj\"\n type=\"application/javascript\"\n ${options.noCsp ? '' : `nonce=\"${req.nonce}\"`}\n >\n window.INJ=\"${INJ}\"\n </script>\n ${scriptChunkString}\n ${defaultExtraScripts || ''}\n </body>\n </html>`;\n\n res.send(html);\n\n if (cacheRef) {\n brotliCompress(html, (error, buffer) => {\n if (error) throw error;\n buffer.nonce = req.nonce; // eslint-disable-line no-param-reassign\n cache.add(buffer, cacheRef.key);\n });\n }\n } catch (error) {\n next(error);\n }\n };\n}\n"],"file":"renderer.js"}
@@ -82,6 +82,15 @@ function MetaTags({
82
82
  }) {
83
83
  const socTitle = socialTitle || title;
84
84
  const socDesc = socialDescription || description;
85
+ const context = (0, _react.useMemo)(() => ({
86
+ description,
87
+ image,
88
+ siteName,
89
+ socialDescription,
90
+ socialTitle,
91
+ title,
92
+ url
93
+ }), [description, image, siteName, socialDescription, socialTitle, title, url]);
85
94
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
86
95
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactHelmet.Helmet, {
87
96
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("title", {
@@ -124,15 +133,7 @@ function MetaTags({
124
133
  content: url
125
134
  }) : null]
126
135
  }), children ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Context.Provider, {
127
- value: {
128
- description,
129
- image,
130
- siteName,
131
- socialDescription,
132
- socialTitle,
133
- title,
134
- url
135
- },
136
+ value: context,
136
137
  children: children
137
138
  }) : null]
138
139
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/shared/components/MetaTags.jsx"],"names":["Context","MetaTags","children","description","image","siteName","socialDescription","socialTitle","title","url","socTitle","socDesc","defaultProps","propTypes","PT","node","string","isRequired"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;;;AAEA,MAAMA,OAAO,gBAAG,2BAAhB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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JM;AAKnBV,EAAAA,iBAAiB,EAAEQ,mBAAGE,MALH;AAMnBT,EAAAA,WAAW,EAAEO,mBAAGE,MANG;AAOnBR,EAAAA,KAAK,EAAEM,mBAAGE,MAAH,CAAUC,UAPE;AAQnBR,EAAAA,GAAG,EAAEK,mBAAGE;AARW,CAArB","sourcesContent":["import PT from 'prop-types';\nimport { createContext } from 'react';\nimport { Helmet } from 'react-helmet';\n\nconst Context = createContext();\n\n/**\n * The `<MetaTags>` component is an auxiliary wrapper around `react-helmet`,\n * which helps to inject meta tags (page title, a brief content description,\n * and social media thumbnails) into generated pages.\n *\n * When `<MetaTags>` are nested within the app's component tree, meta tags\n * content injected by components encountered down the tree overrides tags\n * injected by previously encountered `<MetaTags>` components.\n *\n * **Children:** `<MetaTags>` children, if any, are rendered at the component's\n * location. The context passes down all meta tag properties of parent\n * `<MetaTag>` instances. These properties can fetched within children\n * hierarchy in the following way, thus facilitating tags modification by\n * children:\n * ```jsx\n * import { useContext } from 'react';\n * import { MetaTags } from '@dr.pogodin/react-utils';\n * export default function SampleComponent() {\n * const { title, description, ...rest } = useContext(MetaTags.Context);\n * // Do something with these props here, e.g. prefix the page title with\n * // the component name:\n * return (\n * <MetaTags title={`Sample component - ${title}`} />\n * );\n * }\n * ```\n * @param {object} [props]\n * @param {string} [props.description] Page description to use in\n * the `description` meta tag, and as a default description of Open Graph Tags.\n * @param {string} [props.image] The absolute URL of thumbnail image to use\n * in Open Graph Tags (`twitter:image`, and `og:image`). By default these tags\n * are not injected.\n *\n * **BEWARE:** It must be a complete, absolute URL, including the correct\n * website domain and HTTP schema.\n *\n * @param {string} [props.siteName]: The site name to use in `twitter:site`,\n * and `og:sitename` tags. By default these tags are not injected.\n *\n * @param {string} [props.socialDescription] The site description to use in\n * `twitter:description` and `og:description` meta tags. By default the value of\n * `description` prop is used.\n * @param {string} [props.socialTitle] The page title to use in\n * `twitter:title`, `og:title`, and `og:image:alt` tags. By default the value of\n * `title` prop is used. Also the `og:image:alt` tag is only injected if `image`\n * prop is present.\n *\n * @param {string} props.title: The page name to use in the `<title>` tag.\n * It is also used as the default value of `socialTitle` prop.\n *\n * @param {string} [props.url] The page URL to use in `og:url` tag.\n * By default the tag is not injected.\n */\nexport default function MetaTags({\n children,\n description,\n image,\n siteName,\n socialDescription,\n socialTitle,\n title,\n url,\n}) {\n const socTitle = socialTitle || title;\n const socDesc = socialDescription || description;\n return (\n <>\n <Helmet>\n {/* General tags. */}\n <title>\n {title}\n </title>\n <meta name=\"description\" content={description} />\n\n {/* Twitter cards. */}\n <meta name=\"twitter:card\" content=\"summary_large_image\" />\n <meta name=\"twitter:title\" content={socTitle} />\n <meta name=\"twitter:description\" content={socDesc} />\n { image ? <meta name=\"twitter:image\" content={image} /> : null }\n {\n siteName ? (\n <meta name=\"twitter:site\" content={`@${siteName}`} />\n ) : null\n }\n\n {/* Open Graph data. */}\n <meta name=\"og:title\" content={socTitle} />\n { image ? <meta name=\"og:image\" content={image} /> : null }\n { image ? <meta name=\"og:image:alt\" content={socTitle} /> : null }\n <meta name=\"og:description\" content={socDesc} />\n {\n siteName ? (<meta name=\"og:sitename\" content={siteName} />) : null\n }\n { url ? (<meta name=\"og:url\" content={url} />) : null }\n </Helmet>\n {\n children ? (\n <Context.Provider\n value={{\n description,\n image,\n siteName,\n socialDescription,\n socialTitle,\n title,\n url,\n }}\n >\n {children}\n </Context.Provider>\n ) : null\n }\n </>\n );\n}\n\nMetaTags.Context = Context;\n\nMetaTags.defaultProps = {\n children: null,\n image: null,\n siteName: null,\n socialDescription: null,\n socialTitle: null,\n url: null,\n};\n\nMetaTags.propTypes = {\n children: PT.node,\n description: PT.string.isRequired,\n image: PT.string,\n siteName: PT.string,\n socialDescription: PT.string,\n socialTitle: PT.string,\n title: PT.string.isRequired,\n url: PT.string,\n};\n"],"file":"MetaTags.js"}
1
+ {"version":3,"sources":["../../../../src/shared/components/MetaTags.jsx"],"names":["Context","MetaTags","children","description","image","siteName","socialDescription","socialTitle","title","url","socTitle","socDesc","context","defaultProps","propTypes","PT","node","string","isRequired"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;;;AAEA,MAAMA,OAAO,gBAAG,2BAAhB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACe,SAASC,QAAT,CAAkB;AAC/BC,EAAAA,QAD+B;AAE/BC,EAAAA,WAF+B;AAG/BC,EAAAA,KAH+B;AAI/BC,EAAAA,QAJ+B;AAK/BC,EAAAA,iBAL+B;AAM/BC,EAAAA,WAN+B;AAO/BC,EAAAA,KAP+B;AAQ/BC,EAAAA;AAR+B,CAAlB,EASZ;AACD,QAAMC,QAAQ,GAAGH,WAAW,IAAIC,KAAhC;AACA,QAAMG,OAAO,GAAGL,iBAAiB,IAAIH,WAArC;AAEA,QAAMS,OAAO,GAAG,oBAAQ,OAAO;AAC7BT,IAAAA,WAD6B;AAE7BC,IAAAA,KAF6B;AAG7BC,IAAAA,QAH6B;AAI7BC,IAAAA,iBAJ6B;AAK7BC,IAAAA,WAL6B;AAM7BC,IAAAA,KAN6B;AAO7BC,IAAAA;AAP6B,GAAP,CAAR,EAQZ,CACFN,WADE,EAEFC,KAFE,EAGFC,QAHE,EAIFC,iBAJE,EAKFC,WALE,EAMFC,KANE,EAOFC,GAPE,CARY,CAAhB;AAkBA,sBACE;AAAA,4BACE,sBAAC,mBAAD;AAAA,8BAEE;AAAA,kBACGD;AADH,QAFF,eAKE;AAAM,QAAA,IAAI,EAAC,aAAX;AAAyB,QAAA,OAAO,EAAEL;AAAlC,QALF,eAQE;AAAM,QAAA,IAAI,EAAC,cAAX;AAA0B,QAAA,OAAO,EAAC;AAAlC,QARF,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AE,IAFe;AAGtBC,EAAAA,QAAQ,EAAE,IAHY;AAItBC,EAAAA,iBAAiB,EAAE,IAJG;AAKtBC,EAAAA,WAAW,EAAE,IALS;AAMtBE,EAAAA,GAAG,EAAE;AANiB,CAAxB;AASAR,QAAQ,CAACa,SAAT,GAAqB;AACnBZ,EAAAA,QAAQ,EAAEa,mBAAGC,IADM;AAEnBb,EAAAA,WAAW,EAAEY,mBAAGE,MAAH,CAAUC,UAFJ;AAGnBd,EAAAA,KAAK,EAAEW,mBAAGE,MAHS;AAInBZ,EAAAA,QAAQ,EAAEU,mBAAGE,MAJM;AAKnBX,EAAAA,iBAAiB,EAAES,mBAAGE,MALH;AAMnBV,EAAAA,WAAW,EAAEQ,mBAAGE,MANG;AAOnBT,EAAAA,KAAK,EAAEO,mBAAGE,MAAH,CAAUC,UAPE;AAQnBT,EAAAA,GAAG,EAAEM,mBAAGE;AARW,CAArB","sourcesContent":["import PT from 'prop-types';\nimport { createContext, useMemo } from 'react';\nimport { Helmet } from 'react-helmet';\n\nconst Context = createContext();\n\n/**\n * The `<MetaTags>` component is an auxiliary wrapper around `react-helmet`,\n * which helps to inject meta tags (page title, a brief content description,\n * and social media thumbnails) into generated pages.\n *\n * When `<MetaTags>` are nested within the app's component tree, meta tags\n * content injected by components encountered down the tree overrides tags\n * injected by previously encountered `<MetaTags>` components.\n *\n * **Children:** `<MetaTags>` children, if any, are rendered at the component's\n * location. The context passes down all meta tag properties of parent\n * `<MetaTag>` instances. These properties can fetched within children\n * hierarchy in the following way, thus facilitating tags modification by\n * children:\n * ```jsx\n * import { useContext } from 'react';\n * import { MetaTags } from '@dr.pogodin/react-utils';\n * export default function SampleComponent() {\n * const { title, description, ...rest } = useContext(MetaTags.Context);\n * // Do something with these props here, e.g. prefix the page title with\n * // the component name:\n * return (\n * <MetaTags title={`Sample component - ${title}`} />\n * );\n * }\n * ```\n * @param {object} [props]\n * @param {string} [props.description] Page description to use in\n * the `description` meta tag, and as a default description of Open Graph Tags.\n * @param {string} [props.image] The absolute URL of thumbnail image to use\n * in Open Graph Tags (`twitter:image`, and `og:image`). By default these tags\n * are not injected.\n *\n * **BEWARE:** It must be a complete, absolute URL, including the correct\n * website domain and HTTP schema.\n *\n * @param {string} [props.siteName]: The site name to use in `twitter:site`,\n * and `og:sitename` tags. By default these tags are not injected.\n *\n * @param {string} [props.socialDescription] The site description to use in\n * `twitter:description` and `og:description` meta tags. By default the value of\n * `description` prop is used.\n * @param {string} [props.socialTitle] The page title to use in\n * `twitter:title`, `og:title`, and `og:image:alt` tags. By default the value of\n * `title` prop is used. Also the `og:image:alt` tag is only injected if `image`\n * prop is present.\n *\n * @param {string} props.title: The page name to use in the `<title>` tag.\n * It is also used as the default value of `socialTitle` prop.\n *\n * @param {string} [props.url] The page URL to use in `og:url` tag.\n * By default the tag is not injected.\n */\nexport default function MetaTags({\n children,\n description,\n image,\n siteName,\n socialDescription,\n socialTitle,\n title,\n url,\n}) {\n const socTitle = socialTitle || title;\n const socDesc = socialDescription || description;\n\n const context = useMemo(() => ({\n description,\n image,\n siteName,\n socialDescription,\n socialTitle,\n title,\n url,\n }), [\n description,\n image,\n siteName,\n socialDescription,\n socialTitle,\n title,\n url,\n ]);\n\n return (\n <>\n <Helmet>\n {/* General tags. */}\n <title>\n {title}\n </title>\n <meta name=\"description\" content={description} />\n\n {/* Twitter cards. */}\n <meta name=\"twitter:card\" content=\"summary_large_image\" />\n <meta name=\"twitter:title\" content={socTitle} />\n <meta name=\"twitter:description\" content={socDesc} />\n { image ? <meta name=\"twitter:image\" content={image} /> : null }\n {\n siteName ? (\n <meta name=\"twitter:site\" content={`@${siteName}`} />\n ) : null\n }\n\n {/* Open Graph data. */}\n <meta name=\"og:title\" content={socTitle} />\n { image ? <meta name=\"og:image\" content={image} /> : null }\n { image ? <meta name=\"og:image:alt\" content={socTitle} /> : null }\n <meta name=\"og:description\" content={socDesc} />\n {\n siteName ? (<meta name=\"og:sitename\" content={siteName} />) : null\n }\n { url ? (<meta name=\"og:url\" content={url} />) : null }\n </Helmet>\n {\n children ? (\n <Context.Provider value={context}>\n {children}\n </Context.Provider>\n ) : null\n }\n </>\n );\n}\n\nMetaTags.Context = Context;\n\nMetaTags.defaultProps = {\n children: null,\n image: null,\n siteName: null,\n socialDescription: null,\n socialTitle: null,\n url: null,\n};\n\nMetaTags.propTypes = {\n children: PT.node,\n description: PT.string.isRequired,\n image: PT.string,\n siteName: PT.string,\n socialDescription: PT.string,\n socialTitle: PT.string,\n title: PT.string.isRequired,\n url: PT.string,\n};\n"],"file":"MetaTags.js"}
@@ -95,7 +95,9 @@ _dayjs.default.now = Date.now;
95
95
  */
96
96
 
97
97
  _dayjs.default.timer = async function timer(timeout) {
98
- return new Promise(resolve => setTimeout(resolve, timeout));
98
+ return new Promise(resolve => {
99
+ setTimeout(resolve, timeout);
100
+ });
99
101
  };
100
102
 
101
103
  var _default = _dayjs.default;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/shared/utils/time.js"],"names":["dayjs","SEC_MS","MIN_MS","HOUR_MS","DAY_MS","YEAR_MS","now","Date","timer","timeout","Promise","resolve","setTimeout"],"mappings":";;;;;;;;;AAaA;;AAbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAA,eAAMC,MAAN,GAAe,IAAf;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACAD,eAAME,MAAN,GAAe,KAAKF,eAAMC,MAA1B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACAD,eAAMG,OAAN,GAAgB,KAAKH,eAAME,MAA3B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACAF,eAAMI,MAAN,GAAe,KAAKJ,eAAMG,OAA1B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACAH,eAAMK,OAAN,GAAgB,MAAML,eAAMI,MAA5B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACAJ,eAAMM,GAAN,GAAYC,IAAI,CAACD,GAAjB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACAN,eAAMQ,KAAN,GAAc,eAAeA,KAAf,CAAqBC,OAArB,EAA8B;AAC1C,SAAO,IAAIC,OAAJ,CAAaC,OAAD,IAAaC,UAAU,CAACD,OAAD,EAAUF,OAAV,CAAnC,CAAP;AACD,CAFD;;eAIeT,c","sourcesContent":["/**\n * @category Utilities\n * @module time\n * @desc\n * ```js\n * import { time } from '@dr.pogodin/react-utils';\n * ```\n * Date & time utilities. The `time` export is a convenient alias for\n * [dayjs](https://day.js.org/en/) library, _i.e._ you can use `time`\n * in all ways you would use `dayjs`. It is further extended with\n * the following additional members.\n */\n\nimport dayjs from 'dayjs';\n\n/**\n * @static\n * @const SEC_MS\n * @desc One second, expressed in milliseconds (equals 1000 ms).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.SEC_MS); // Prints: 1000\n */\ndayjs.SEC_MS = 1000;\n\n/**\n * @static\n * @const MIN_MS\n * @desc One minute, expressed in milliseconds (equals 60 &times; `SEC_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.MIN_MS); // Prints: 60000\n */\ndayjs.MIN_MS = 60 * dayjs.SEC_MS;\n\n/**\n * @static\n * @const HOUR_MS\n * @desc One hour, expressed in milliseconds (equals 60 &times; `MIN_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.HOUR_MS); // Prints: 3600000\n */\ndayjs.HOUR_MS = 60 * dayjs.MIN_MS;\n\n/**\n * @static\n * @const DAY_MS\n * @desc One day, expressed in milliseconds (equals 24 &times; `HOUR_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.DAY_MS); // Prints: 86400000\n */\ndayjs.DAY_MS = 24 * dayjs.HOUR_MS;\n\n/**\n * @static\n * @const YEAR_MS\n * @desc One year, expressed in milliseconds (equals 365 &times; `DAY_MS`,\n * thus a normal, non-leap year).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.YEAR_MS); // Prints: 31536000000\n */\ndayjs.YEAR_MS = 365 * dayjs.DAY_MS;\n\n/**\n * @static\n * @func now\n * @desc Returns Unix timestamp [ms] (thus, it is just an alias for `Date.now`).\n * @return {number}\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.now()); // Prints the current timestamp, e.g. 1618608761000.\n */\ndayjs.now = Date.now;\n\n/**\n * @static\n * @func timer\n * @desc Creates a Promise, which resolves after the given timeout.\n * @param {number} timeout Timeout [ms].\n * @return {Promise} Resolves after the timeout.\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * time.timer(5000).then(() => console.log('5 seconds have passed'))\n */\ndayjs.timer = async function timer(timeout) {\n return new Promise((resolve) => setTimeout(resolve, timeout));\n};\n\nexport default dayjs;\n"],"file":"time.js"}
1
+ {"version":3,"sources":["../../../../src/shared/utils/time.js"],"names":["dayjs","SEC_MS","MIN_MS","HOUR_MS","DAY_MS","YEAR_MS","now","Date","timer","timeout","Promise","resolve","setTimeout"],"mappings":";;;;;;;;;AAaA;;AAbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAA,eAAMC,MAAN,GAAe,IAAf;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACAD,eAAME,MAAN,GAAe,KAAKF,eAAMC,MAA1B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACAD,eAAMG,OAAN,GAAgB,KAAKH,eAAME,MAA3B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACAF,eAAMI,MAAN,GAAe,KAAKJ,eAAMG,OAA1B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACAH,eAAMK,OAAN,GAAgB,MAAML,eAAMI,MAA5B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACAJ,eAAMM,GAAN,GAAYC,IAAI,CAACD,GAAjB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACAN,eAAMQ,KAAN,GAAc,eAAeA,KAAf,CAAqBC,OAArB,EAA8B;AAC1C,SAAO,IAAIC,OAAJ,CAAaC,OAAD,IAAa;AAC9BC,IAAAA,UAAU,CAACD,OAAD,EAAUF,OAAV,CAAV;AACD,GAFM,CAAP;AAGD,CAJD;;eAMeT,c","sourcesContent":["/**\n * @category Utilities\n * @module time\n * @desc\n * ```js\n * import { time } from '@dr.pogodin/react-utils';\n * ```\n * Date & time utilities. The `time` export is a convenient alias for\n * [dayjs](https://day.js.org/en/) library, _i.e._ you can use `time`\n * in all ways you would use `dayjs`. It is further extended with\n * the following additional members.\n */\n\nimport dayjs from 'dayjs';\n\n/**\n * @static\n * @const SEC_MS\n * @desc One second, expressed in milliseconds (equals 1000 ms).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.SEC_MS); // Prints: 1000\n */\ndayjs.SEC_MS = 1000;\n\n/**\n * @static\n * @const MIN_MS\n * @desc One minute, expressed in milliseconds (equals 60 &times; `SEC_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.MIN_MS); // Prints: 60000\n */\ndayjs.MIN_MS = 60 * dayjs.SEC_MS;\n\n/**\n * @static\n * @const HOUR_MS\n * @desc One hour, expressed in milliseconds (equals 60 &times; `MIN_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.HOUR_MS); // Prints: 3600000\n */\ndayjs.HOUR_MS = 60 * dayjs.MIN_MS;\n\n/**\n * @static\n * @const DAY_MS\n * @desc One day, expressed in milliseconds (equals 24 &times; `HOUR_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.DAY_MS); // Prints: 86400000\n */\ndayjs.DAY_MS = 24 * dayjs.HOUR_MS;\n\n/**\n * @static\n * @const YEAR_MS\n * @desc One year, expressed in milliseconds (equals 365 &times; `DAY_MS`,\n * thus a normal, non-leap year).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.YEAR_MS); // Prints: 31536000000\n */\ndayjs.YEAR_MS = 365 * dayjs.DAY_MS;\n\n/**\n * @static\n * @func now\n * @desc Returns Unix timestamp [ms] (thus, it is just an alias for `Date.now`).\n * @return {number}\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.now()); // Prints the current timestamp, e.g. 1618608761000.\n */\ndayjs.now = Date.now;\n\n/**\n * @static\n * @func timer\n * @desc Creates a Promise, which resolves after the given timeout.\n * @param {number} timeout Timeout [ms].\n * @return {Promise} Resolves after the timeout.\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * time.timer(5000).then(() => console.log('5 seconds have passed'))\n */\ndayjs.timer = async function timer(timeout) {\n return new Promise((resolve) => {\n setTimeout(resolve, timeout);\n });\n};\n\nexport default dayjs;\n"],"file":"time.js"}
@@ -123,7 +123,7 @@ body {
123
123
  .-dr-pogodin-react-utils___src-shared-components-Button-style___context___KM0v4f.-dr-pogodin-react-utils___src-shared-components-Button-style___disabled___Br9IWV,
124
124
  .-dr-pogodin-react-utils___src-shared-components-Button-style___ad___3jm1-Q.-dr-pogodin-react-utils___src-shared-components-Button-style___hoc___0plpDL.-dr-pogodin-react-utils___src-shared-components-Button-style___disabled___Br9IWV {
125
125
  cursor: not-allowed;
126
- opacity: 33%;
126
+ opacity: 0.33;
127
127
  }
128
128
  /*!*************************************************************************************************************************************************************************************************************************************************************************************************************!*\
129
129
  !*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[2].use[2]!./node_modules/resolve-url-loader/index.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[4]!./src/shared/components/Checkbox/theme.scss ***!
@@ -439,7 +439,7 @@ body {
439
439
  background: #eee;
440
440
  height: 100%;
441
441
  left: 0;
442
- opacity: 80%;
442
+ opacity: 0.8;
443
443
  position: fixed;
444
444
  top: 0;
445
445
  width: 100%;
@@ -547,18 +547,18 @@ body.scrolling-disabled-by-modal {
547
547
  \************************************************************************************************************************************************************************************************************************************************************************************************************************/
548
548
  @-webkit-keyframes -dr-pogodin-react-utils___src-shared-components-WithTooltip-default-theme___appearance___L4ubm- {
549
549
  from {
550
- opacity: 0%;
550
+ opacity: 0;
551
551
  }
552
552
  to {
553
- opacity: 100%;
553
+ opacity: 1;
554
554
  }
555
555
  }
556
556
  @keyframes -dr-pogodin-react-utils___src-shared-components-WithTooltip-default-theme___appearance___L4ubm- {
557
557
  from {
558
- opacity: 0%;
558
+ opacity: 0;
559
559
  }
560
560
  to {
561
- opacity: 100%;
561
+ opacity: 1;
562
562
  }
563
563
  }
564
564
  *,