@dr.pogodin/react-utils 1.10.2 → 1.12.0
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.
- package/bin/build.js +1 -3
- package/bin/setup.js +2 -2
- package/build/development/client/index.js.map +1 -1
- package/build/development/index.js +0 -9
- package/build/development/index.js.map +1 -1
- package/build/development/server/index.js +9 -12
- package/build/development/server/index.js.map +1 -1
- package/build/development/server/renderer.js +13 -16
- package/build/development/server/renderer.js.map +1 -1
- package/build/development/shared/components/Button/index.js +6 -6
- package/build/development/shared/components/Checkbox/index.js +6 -6
- package/build/development/shared/components/CodeSplit/ServerSide.js +2 -3
- package/build/development/shared/components/CodeSplit/ServerSide.js.map +1 -1
- package/build/development/shared/components/Dropdown/index.js +9 -9
- package/build/development/shared/components/GenericLink/index.js +1 -1
- package/build/development/shared/components/Input/index.js +6 -6
- package/build/development/shared/components/MetaTags.js +10 -9
- package/build/development/shared/components/MetaTags.js.map +1 -1
- package/build/development/shared/components/Modal/index.js +5 -5
- package/build/development/shared/components/PageLayout/index.js +6 -6
- package/build/development/shared/components/ScalableRect/index.js +2 -2
- package/build/development/shared/components/Throbber/index.js +10 -10
- package/build/development/shared/components/WithTooltip/index.js +7 -7
- package/build/development/shared/components/YouTubeVideo/index.js +9 -9
- package/build/development/shared/utils/index.js +1 -5
- package/build/development/shared/utils/index.js.map +1 -1
- package/build/development/shared/utils/time.js +3 -1
- package/build/development/shared/utils/time.js.map +1 -1
- package/build/development/style.css +149 -149
- package/build/development/web.bundle.js +19 -29
- package/build/production/client/index.js.map +1 -1
- package/build/production/index.js +1 -1
- package/build/production/index.js.map +1 -1
- package/build/production/server/index.js +3 -3
- package/build/production/server/index.js.map +1 -1
- package/build/production/server/renderer.js +8 -7
- package/build/production/server/renderer.js.map +1 -1
- package/build/production/shared/components/Button/index.js +1 -1
- package/build/production/shared/components/Button/index.js.map +1 -1
- package/build/production/shared/components/Checkbox/index.js +1 -1
- package/build/production/shared/components/Checkbox/index.js.map +1 -1
- package/build/production/shared/components/CodeSplit/ServerSide.js +2 -2
- package/build/production/shared/components/CodeSplit/ServerSide.js.map +1 -1
- package/build/production/shared/components/Dropdown/index.js +1 -1
- package/build/production/shared/components/Dropdown/index.js.map +1 -1
- package/build/production/shared/components/GenericLink/index.js +1 -1
- package/build/production/shared/components/GenericLink/index.js.map +1 -1
- package/build/production/shared/components/Input/index.js +1 -1
- package/build/production/shared/components/Input/index.js.map +1 -1
- package/build/production/shared/components/MetaTags.js +1 -1
- package/build/production/shared/components/MetaTags.js.map +1 -1
- package/build/production/shared/components/Modal/index.js +1 -1
- package/build/production/shared/components/Modal/index.js.map +1 -1
- package/build/production/shared/components/PageLayout/index.js +1 -1
- package/build/production/shared/components/PageLayout/index.js.map +1 -1
- package/build/production/shared/components/ScalableRect/index.js +1 -1
- package/build/production/shared/components/ScalableRect/index.js.map +1 -1
- package/build/production/shared/components/Throbber/index.js +2 -2
- package/build/production/shared/components/Throbber/index.js.map +1 -1
- package/build/production/shared/components/WithTooltip/index.js +1 -1
- package/build/production/shared/components/WithTooltip/index.js.map +1 -1
- package/build/production/shared/components/YouTubeVideo/index.js +1 -1
- package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/production/shared/utils/index.js +1 -1
- package/build/production/shared/utils/index.js.map +1 -1
- package/build/production/shared/utils/time.js +1 -1
- package/build/production/shared/utils/time.js.map +1 -1
- package/build/production/style.css +1 -1
- package/build/production/style.css.map +1 -1
- package/build/production/web.bundle.js +1 -1
- package/build/production/web.bundle.js.map +1 -1
- package/config/babel/node-ssr.js +3 -3
- package/config/babel/webpack.js +2 -2
- package/config/eslint/default.json +6 -1
- package/config/stylelint/default.js +1 -0
- package/config/webpack/app-base.js +10 -4
- package/config/webpack/app-development.js +2 -2
- package/package.json +30 -29
- package/build/development/shared/utils/url.js +0 -41
- package/build/development/shared/utils/url.js.map +0 -1
- package/build/production/shared/utils/url.js +0 -23
- package/build/production/shared/utils/url.js.map +0 -1
|
@@ -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":"4VAAA,uCAEA,sDACA,kDACA,oDAGA,wBAEA,wDAEA,yDACA,oCAGA,sU,o9BATA,mC,CAWA;AACA,KAAMA,CAAAA,sBAAsB,CAAG,EAA/B,CACA,KAAMC,CAAAA,mBAAmB,CAAG,IAA5B,CAEA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAASC,CAAAA,aAAT,CAAuBC,KAAvB,CAA8B,CAC5B,KAAMC,CAAAA,IAAI,CAAGC,gBAAEC,QAAF,CAAWH,KAAX,CAAb,CACA,GAAIE,gBAAEE,QAAF,CAAWH,IAAX,CAAJ,CAAsB,MAAOA,CAAAA,IAAP,CAAa,iBACnC,GAAI,CAACC,gBAAEG,QAAF,CAAWJ,IAAX,CAAL,CAAuB,MAAOD,CAAAA,KAAP,CAAc,gBACrC,MAAO,MACR,CAED;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;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,CAAkB,GAAEE,IAAK,+BAAzB,EACAzC,OAAO,CAAC4C,IAAR,CAAa,CAAb,EACA,MACF,IAAK,YAAL,CACE9C,GAAG,CAACW,MAAJ,CAAW8B,KAAX,CAAkB,GAAEE,IAAK,oBAAzB,EACAzC,OAAO,CAAC4C,IAAR,CAAa,CAAb,EACA,MACF,QACE,KAAML,CAAAA,KAAN,CAVJ,CAYD,CAjBD,EAmBA,iDACAP,UAAU,CAACM,EAAX,CAAc,WAAd,CAA2B,IAAM,CAC/B,KAAMO,CAAAA,IAAI,CAAGb,UAAU,CAACc,OAAX,EAAb,CACA,KAAML,CAAAA,IAAI,CAAGlD,gBAAEmD,QAAF,CAAWG,IAAX,EAAoB,QAAOA,IAAK,EAAhC,CAAqC,QAAOA,IAAI,CAACvD,IAAK,EAAnE,CACAQ,GAAG,CAACW,MAAJ,CAAWsC,IAAX,CAAiB,uBAAsBN,IAAK,OAC1CzC,OAAO,CAACC,GAAR,CAAY+C,QAAS,OADvB,CAED,CALD,EAOAhB,UAAU,CAACiB,MAAX,CAAkBnD,GAAG,CAACR,IAAtB,EAEA,MAAO,CACLyC,aADK,CAELC,UAFK,CAIR,CAEDrC,MAAM,CAACuD,gBAAP,CAA0BA,0BAA1B,C,aAEevD,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)` ⇒ `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` – the cache key for the response;\n * - `maxage?: number` – 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":"4VAAA,uCAEA,8BAUA,kDACA,oDAGA,wBAEA,wDAEA,yDACA,oCAGA,sU,o9BATA,mC,CAWA;AACA,KAAMA,CAAAA,sBAAsB,CAAG,EAA/B,CACA,KAAMC,CAAAA,mBAAmB,CAAG,IAA5B,CAEA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAASC,CAAAA,aAAT,CAAuBC,KAAvB,CAA8B,CAC5B,KAAMC,CAAAA,IAAI,CAAG,qBAASD,KAAT,CAAb,CACA,GAAI,qBAASC,IAAT,CAAJ,CAAoB,MAAOA,CAAAA,IAAP,CAAa,iBACjC,GAAI,CAAC,qBAASA,IAAT,CAAL,CAAqB,MAAOD,CAAAA,KAAP,CAAc,gBACnC,MAAO,MACR,CAED;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,cAAeE,CAAAA,MAAf,CAAsBC,aAAtB,CAAqCC,OAArC,CAA8C,CAC5C,4BACA,KAAMC,CAAAA,GAAG,CAAGD,OAAO,CAAG,sBAAUA,OAAV,CAAH,CAAwB,EAA3C,CACAC,GAAG,CAACJ,IAAJ,CAAWF,aAAa,CAACM,GAAG,CAACJ,IAAJ,EAAYK,OAAO,CAACC,GAAR,CAAYC,IAAxB,EAAgC,IAAjC,CAAxB,CACA,qBAASH,GAAT,CAAc,CACZ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AAkB/C,GAAG,CAACJ,IAAtB,EAEA,MAAO,CACLkC,aADK,CAELC,UAFK,CAIR,CAEDlC,MAAM,CAACmD,gBAAP,CAA0BA,0BAA1B,C,aAEenD,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)` ⇒ `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` – the cache key for the response;\n * - `maxage?: number` – 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,6 +1,6 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.SCRIPT_LOCATIONS=void 0;exports.default=factory;exports.isBrotliAcceptable=isBrotliAcceptable;var _reactGlobalState=require("@dr.pogodin/react-global-state");var _lodash=
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.SCRIPT_LOCATIONS=void 0;exports.default=factory;exports.isBrotliAcceptable=isBrotliAcceptable;var _reactGlobalState=require("@dr.pogodin/react-global-state");var _lodash=require("lodash");var _config=_interopRequireDefault(require("config"));var _nodeForge=_interopRequireDefault(require("node-forge"));var _fs=_interopRequireDefault(require("fs"));var _path=_interopRequireDefault(require("path"));var _zlib=require("zlib");var _server=_interopRequireDefault(require("react-dom/server"));var _reactHelmet=require("react-helmet");var _server2=require("react-router-dom/server");var _serializeJavascript=_interopRequireDefault(require("serialize-javascript"));var _time=_interopRequireDefault(require("../shared/utils/time"));var _Cache=_interopRequireDefault(require("./Cache"));var _jsxRuntime=require("react/jsx-runtime");/**
|
|
2
2
|
* ExpressJS middleware for server-side rendering of a ReactJS app.
|
|
3
|
-
*/const sanitizedConfig=_lodash.
|
|
3
|
+
*/const sanitizedConfig=(0,_lodash.omit)(_config.default,"SECRET");const SCRIPT_LOCATIONS={BODY_OPEN:"BODY_OPEN",DEFAULT:"DEFAULT",HEAD_OPEN:"HEAD_OPEN"};/**
|
|
4
4
|
* Reads build-time information about the app. This information is generated
|
|
5
5
|
* by our standard Webpack config for apps, and it is written into
|
|
6
6
|
* ".build-info" file in the context folder specified in Webpack config.
|
|
@@ -46,12 +46,13 @@
|
|
|
46
46
|
*/function factory(webpackConfig,options){const buildInfo=getBuildInfo(webpackConfig.context);global.TRU_BUILD_INFO=buildInfo;// publicPath from webpack.output has a trailing slash at the end.
|
|
47
47
|
const{publicPath,path:outputPath}=webpackConfig.output;let manifestLink=_fs.default.existsSync(`${outputPath}/manifest.json`);manifestLink=manifestLink?`<link rel="manifest" href="${publicPath}manifest.json"></link>`:"";// TODO: Update the caching mechanics to stored cached data gzipped,
|
|
48
48
|
// and serve them without a need to unpacking server-side.
|
|
49
|
-
const cache=options.staticCacheController?new _Cache.default(options.staticCacheSize):null;const CHUNK_GROUPS=readChunkGroupsJson(outputPath);const ops=_lodash.
|
|
49
|
+
const cache=options.staticCacheController?new _Cache.default(options.staticCacheSize):null;const CHUNK_GROUPS=readChunkGroupsJson(outputPath);const ops=(0,_lodash.defaults)((0,_lodash.clone)(options),{beforeRender:()=>Promise.resolve({})});return async(req,res,next)=>{try{// Ensures any caches always revalidate HTML markup before reuse.
|
|
50
|
+
res.set("Cache-Control","no-cache");let cacheRef;if(cache){cacheRef=options.staticCacheController(req);if(cacheRef){const data=cache.get(cacheRef);if(data!==null){if(options.noCsp&&isBrotliAcceptable(req)){res.set("Content-Type","text/html");res.set("Content-Encoding","br");res.send(data)}else{(0,_zlib.brotliDecompress)(data,(error,html)=>{if(error)next(error);else{let h=html.toString();if(!options.noCsp){// TODO: Starting from Node v15 we'll be able to use string's
|
|
50
51
|
// .replaceAll() method instead relying on reg. expression for
|
|
51
52
|
// global matching.
|
|
52
|
-
const regex=new RegExp(data.nonce,"g");h=h.replace(regex,req.nonce)}res.send(h)}})}return}}}const[{configToInject,extraScripts,initialState},{cipher,iv}]=await Promise.all([ops.beforeRender(req,sanitizedConfig),prepareCipher(buildInfo.key)]);let helmet;/* Optional server-side rendering. */let App=options.Application;const ssrContext={req,state:_lodash.
|
|
53
|
-
chunks:[]};if(App){let markup;const ssrStart=Date.now();for(let round=0;round<options.maxSsrRounds;++round){ssrContext.chunks=[];markup=_server.default.renderToString(/*#__PURE__*/(0,_jsxRuntime.jsx)(_reactGlobalState.GlobalStateProvider,{initialState:ssrContext.state,ssrContext:ssrContext,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(
|
|
54
|
-
* (still demands injection into HTML template, which happens below). */helmet=_reactHelmet.Helmet.renderStatic()}let chunkGroups;const webpackStats=_lodash.
|
|
53
|
+
const regex=new RegExp(data.nonce,"g");h=h.replace(regex,req.nonce)}res.send(h)}})}return}}}const[{configToInject,extraScripts,initialState},{cipher,iv}]=await Promise.all([ops.beforeRender(req,sanitizedConfig),prepareCipher(buildInfo.key)]);let helmet;/* Optional server-side rendering. */let App=options.Application;const ssrContext={req,state:(0,_lodash.cloneDeep)(initialState||{}),// Array of chunk names encountered during the rendering.
|
|
54
|
+
chunks:[]};if(App){let markup;const ssrStart=Date.now();for(let round=0;round<options.maxSsrRounds;++round){ssrContext.chunks=[];markup=_server.default.renderToString(/*#__PURE__*/(0,_jsxRuntime.jsx)(_reactGlobalState.GlobalStateProvider,{initialState:ssrContext.state,ssrContext:ssrContext,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_server2.StaticRouter,{location:req.url,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(App,{})})}));if(!ssrContext.dirty)break;/* eslint-disable no-await-in-loop */const timeout=options.ssrTimeout+ssrStart-Date.now();const ok=timeout>0&&(await Promise.race([Promise.allSettled(ssrContext.pending),_time.default.timer(timeout).then(()=>false)]));if(!ok)break;/* eslint-enable no-await-in-loop */}App=markup;/* This takes care about server-side rendering of page title and meta tags
|
|
55
|
+
* (still demands injection into HTML template, which happens below). */helmet=_reactHelmet.Helmet.renderStatic()}let chunkGroups;const webpackStats=(0,_lodash.get)(res.locals,"webpack.devMiddleware.stats");if(webpackStats){chunkGroups=(0,_lodash.mapValues)(webpackStats.toJson({all:false,chunkGroups:true}).namedChunkGroups,item=>item.assets.map(({name})=>name))}else if(CHUNK_GROUPS)chunkGroups=CHUNK_GROUPS;else chunkGroups={};/* Encrypts data to be injected into HTML.
|
|
55
56
|
* Keep in mind, that this encryption is no way secure: as the JS bundle
|
|
56
57
|
* contains decryption key and is able to decode it at the client side.
|
|
57
58
|
* Hovewer, for a number of reasons, encryption of injected data is still
|
|
@@ -65,7 +66,7 @@ chunks:[]};if(App){let markup;const ssrStart=Date.now();for(let round=0;round<op
|
|
|
65
66
|
// thus for now this handles the default config.
|
|
66
67
|
["main",...ssrContext.chunks].forEach(chunk=>{const assets=chunkGroups[chunk];if(assets)assets.forEach(asset=>chunkSet.add(asset))});let styleChunkString="";let scriptChunkString="";chunkSet.forEach(chunk=>{if(chunk.endsWith(".css")){styleChunkString+=`<link href="${publicPath}${chunk}" rel="stylesheet" />`}else if(chunk.endsWith(".js")// In dev mode HMR adds JS updates into asset arrays,
|
|
67
68
|
// and they (updates) should be ignored.
|
|
68
|
-
&&!chunk.endsWith(".hot-update.js")){scriptChunkString+=`<script src="${publicPath}${chunk}" type="application/javascript"></script>`}});let bodyOpenExtraScripts;let defaultExtraScripts;let headOpenExtraScripts;if(extraScripts){bodyOpenExtraScripts=extraScripts.filter(script=>_lodash.
|
|
69
|
+
&&!chunk.endsWith(".hot-update.js")){scriptChunkString+=`<script src="${publicPath}${chunk}" type="application/javascript"></script>`}});let bodyOpenExtraScripts;let defaultExtraScripts;let headOpenExtraScripts;if(extraScripts){bodyOpenExtraScripts=extraScripts.filter(script=>(0,_lodash.isObject)(script)&&script.location===SCRIPT_LOCATIONS.BODY_OPEN).map(script=>script.code).join("");defaultExtraScripts=extraScripts.filter(script=>(0,_lodash.isString)(script)||script.location===SCRIPT_LOCATIONS.DEFAULT).map(script=>(0,_lodash.isString)(script)?script:script.code).join("");headOpenExtraScripts=extraScripts.filter(script=>(0,_lodash.isObject)(script)&&script.location===SCRIPT_LOCATIONS.HEAD_OPEN).map(script=>script.code).join("")}const faviconLink=ops.favicon?"<link rel=\"shortcut icon\" href=\"/favicon.ico\" />":"";const html=`<!DOCTYPE html>
|
|
69
70
|
<html lang="en">
|
|
70
71
|
<head>
|
|
71
72
|
${headOpenExtraScripts||""}
|
|
@@ -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":"+PAIA,gEAEA,sDACA,sDACA,6DACA,8CACA,kDACA,0BAEA,gEACA,yCACA,gDACA,iFAEA,kEAEA,sD,6CApBA;AACA;AACA,GAoBA,KAAMA,CAAAA,eAAe,CAAGC,gBAAEC,IAAF,CAAOC,eAAP,CAAe,QAAf,CAAxB,CAEO,KAAMC,CAAAA,gBAAgB,CAAG,CAC9BC,SAAS,CAAE,WADm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AAcoF,gBAAiB;AAC/B,cAAca,WAAY;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAcV,oBAAoB,EAAI,EAAG;AACzC,mCAAmC1D,GAAG,EAAI,EAAG;AAC7C;AACA;AACA;AACA,gBAAgBpC,OAAO,CAACoB,KAAR,CAAgB,EAAhB,CAAsB,UAASjC,GAAG,CAAC0C,KAAM,GAAG;AAC5D;AACA,4BAA4BqD,GAAI;AAChC;AACA,cAAcU,iBAAkB;AAChC,cAAcG,mBAAmB,EAAI,EAAG;AACxC;AACA,gBA7BM,CA+BA1H,GAAG,CAACiD,IAAJ,CAASE,IAAT,EAEA,GAAIN,QAAJ,CAAc,CACZ,yBAAeM,IAAf,CAAqB,CAACD,KAAD,CAAQqF,MAAR,GAAmB,CACtC,GAAIrF,KAAJ,CAAW,KAAMA,CAAAA,KAAN,CACXqF,MAAM,CAAC/E,KAAP,CAAe1C,GAAG,CAAC0C,KAAnB,CAA0B;AAC1BpB,KAAK,CAACiF,GAAN,CAAUkB,MAAV,CAAkB1F,QAAQ,CAAC1C,GAA3B,CACD,CAJD,CAKD,CACF,CAAC,MAAO+C,KAAP,CAAc,CACdN,IAAI,CAACM,KAAD,CACL,CACF,CACF","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';\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\n context={ssrContext}\n location={req.url}\n >\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":"+PAIA,gEAEA,8BAWA,sDACA,6DACA,8CACA,kDACA,0BAEA,gEACA,yCACA,gDACA,iFAEA,kEAEA,sD,6CA9BA;AACA;AACA,GA8BA,KAAMA,CAAAA,eAAe,CAAG,iBAAKC,eAAL,CAAa,QAAb,CAAxB,CAEO,KAAMC,CAAAA,gBAAgB,CAAG,CAC9BC,SAAS,CAAE,WADmB,CAE9BC,OAAO,CAAE,SAFqB,CAG9BC,SAAS,CAAE,WAHmB,CAAzB,CAMP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,G,0CACA,QAASC,CAAAA,YAAT,CAAsBC,OAAtB,CAA+B,CAC7B,KAAMC,CAAAA,GAAG,CAAGC,cAAKC,OAAL,CAAaH,OAAb,CAAsB,aAAtB,CAAZ,CACA,MAAOI,CAAAA,IAAI,CAACC,KAAL,CAAWC,YAAGC,YAAH,CAAgBN,GAAhB,CAAX,CACR,CAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAASO,CAAAA,mBAAT,CAA6BC,QAA7B,CAAuC,CACrC,KAAMR,CAAAA,GAAG,CAAGC,cAAKC,OAAL,CAAaM,QAAb,CAAuB,uBAAvB,CAAZ,CACA,GAAIC,CAAAA,GAAJ,CACA,GAAI,CACFA,GAAG,CAAGN,IAAI,CAACC,KAAL,CAAWC,YAAGC,YAAH,CAAgBN,GAAhB,CAAX,CACP,CAAC,MAAOU,GAAP,CAAY,CACZD,GAAG,CAAG,IACP,CACD,MAAOA,CAAAA,GACR,CAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAASE,CAAAA,aAAT,CAAuBC,GAAvB,CAA4B,CAC1B,MAAO,IAAIC,CAAAA,OAAJ,CAAY,CAACX,OAAD,CAAUY,MAAV,GAAqB,CACtCC,mBAAMC,MAAN,CAAaC,QAAb,CAAsB,E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EAAI,EAAG;AACzC,cAAc3D,MAAM,CAAGA,MAAM,CAACmE,KAAP,CAAa5E,QAAb,EAAH,CAA6B,EAAG;AACpD,cAAcS,MAAM,CAAGA,MAAM,CAACoE,IAAP,CAAY7E,QAAZ,EAAH,CAA4B,EAAG;AACnD;AACA,cAAcjB,YAAa;AAC3B,cAAcgF,gBAAiB;AAC/B,cAAcW,WAAY;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAcR,oBAAoB,EAAI,EAAG;AACzC,mCAAmCxD,GAAG,EAAI,EAAG;AAC7C;AACA;AACA;AACA,gBAAgBlC,OAAO,CAACmB,KAAR,CAAgB,EAAhB,CAAsB,UAAShC,GAAG,CAACwC,KAAM,GAAG;AAC5D;AACA,4BAA4BmD,GAAI;AAChC;AACA,cAAcU,iBAAkB;AAChC,cAAcG,mBAAmB,EAAI,EAAG;AACxC;AACA,gBA7BM,CA+BAtH,GAAG,CAAC+C,IAAJ,CAASE,IAAT,EAEA,GAAIL,QAAJ,CAAc,CACZ,yBAAeK,IAAf,CAAqB,CAACD,KAAD,CAAQiF,MAAR,GAAmB,CACtC,GAAIjF,KAAJ,CAAW,KAAMA,CAAAA,KAAN,CACXiF,MAAM,CAAC3E,KAAP,CAAexC,GAAG,CAACwC,KAAnB,CAA0B;AAC1BlB,KAAK,CAAC6E,GAAN,CAAUgB,MAAV,CAAkBrF,QAAQ,CAACzC,GAA3B,CACD,CAJD,CAKD,CACF,CAAC,MAAO6C,KAAP,CAAc,CACdN,IAAI,CAACM,KAAD,CACL,CACF,CACF","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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _propTypes=_interopRequireDefault(require("prop-types"));var _Link=_interopRequireDefault(require("../Link"));var _utils=require("../../utils");var _jsxRuntime=require("react/jsx-runtime");// The <Button> component implements a standard button / button-like link.
|
|
2
|
-
var defaultTheme={"context":"
|
|
2
|
+
var defaultTheme={"context":"KM0v4f","ad":"_3jm1-Q","hoc":"_0plpDL","button":"E1FNQT","active":"MAe9O6","disabled":"Br9IWV"};function BaseButton({active,children,disabled,enforceA,onClick,onMouseDown,openNewTab,replace,theme,to}){let className=theme.button;if(active&&theme.active)className+=` ${theme.active}`;if(disabled){if(theme.disabled)className+=` ${theme.disabled}`;return/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:className,children:children})}if(to){return/*#__PURE__*/(0,_jsxRuntime.jsx)(_Link.default,{className:className,enforceA:enforceA,onClick:onClick,onMouseDown:onMouseDown,openNewTab:openNewTab,replace:replace,to:to,children:children})}return/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:className,onClick:onClick,onKeyPress:onClick,onMouseDown:onMouseDown,role:"button",tabIndex:0,children:children})}/**
|
|
3
3
|
* Button component theme: a map of CSS
|
|
4
4
|
* class names to append to button elements:
|
|
5
5
|
* @prop {string} [active] to the root element of active button.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/shared/components/Button/index.jsx"],"names":["BaseButton","active","children","disabled","enforceA","onClick","onMouseDown","openNewTab","replace","theme","to","className","button","ThemedButton","defaultTheme","defaultProps","undefined","propTypes","PT","bool","node","func","themeType","isRequired","oneOfType","object","string"],"mappings":"gLAEA,6DAEA,qDAEA,kC,6CANA;
|
|
1
|
+
{"version":3,"sources":["../../../../../src/shared/components/Button/index.jsx"],"names":["BaseButton","active","children","disabled","enforceA","onClick","onMouseDown","openNewTab","replace","theme","to","className","button","ThemedButton","defaultTheme","defaultProps","undefined","propTypes","PT","bool","node","func","themeType","isRequired","oneOfType","object","string"],"mappings":"gLAEA,6DAEA,qDAEA,kC,6CANA;6HAUA,QAASA,CAAAA,UAAT,CAAoB,CAClBC,MADkB,CAElBC,QAFkB,CAGlBC,QAHkB,CAIlBC,QAJkB,CAKlBC,OALkB,CAMlBC,WANkB,CAOlBC,UAPkB,CAQlBC,OARkB,CASlBC,KATkB,CAUlBC,EAVkB,CAApB,CAWG,CACD,GAAIC,CAAAA,SAAS,CAAGF,KAAK,CAACG,MAAtB,CACA,GAAIX,MAAM,EAAIQ,KAAK,CAACR,MAApB,CAA4BU,SAAS,EAAK,IAAGF,KAAK,CAACR,MAAO,EAA9B,CAC5B,GAAIE,QAAJ,CA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mBAAGE,IAFQ,CAGrBjB,QAAQ,CAAEe,mBAAGC,IAHQ,CAIrBf,QAAQ,CAAEc,mBAAGC,IAJQ,CAKrBd,OAAO,CAAEa,mBAAGG,IALS,CAMrBf,WAAW,CAAEY,mBAAGG,IANK,CAOrBd,UAAU,CAAEW,mBAAGC,IAPM,CAQrBX,OAAO,CAAEU,mBAAGC,IARS,CASrBV,KAAK,CAAEI,YAAY,CAACS,SAAb,CAAuBC,UATT,CAUrBb,EAAE,CAAEQ,mBAAGM,SAAH,CAAa,CAACN,mBAAGO,MAAJ,CAAYP,mBAAGQ,MAAf,CAAb,CAViB,CAAvB,C,aAaeb,Y","sourcesContent":["// The <Button> component implements a standard button / button-like link.\n\nimport PT from 'prop-types';\n\nimport Link from 'components/Link';\n\nimport { themed } from 'utils';\n\nimport defaultTheme from './style.scss';\n\nfunction BaseButton({\n active,\n children,\n disabled,\n enforceA,\n onClick,\n onMouseDown,\n openNewTab,\n replace,\n theme,\n to,\n}) {\n let className = theme.button;\n if (active && theme.active) className += ` ${theme.active}`;\n if (disabled) {\n if (theme.disabled) className += ` ${theme.disabled}`;\n return (\n <div className={className}>\n {children}\n </div>\n );\n }\n if (to) {\n return (\n <Link\n className={className}\n enforceA={enforceA}\n onClick={onClick}\n onMouseDown={onMouseDown}\n openNewTab={openNewTab}\n replace={replace}\n to={to}\n >\n {children}\n </Link>\n );\n }\n return (\n <div\n className={className}\n onClick={onClick}\n onKeyPress={onClick}\n onMouseDown={onMouseDown}\n role=\"button\"\n tabIndex={0}\n >\n {children}\n </div>\n );\n}\n\n/**\n * Button component theme: a map of CSS\n * class names to append to button elements:\n * @prop {string} [active] to the root element of active button.\n * @prop {string} [button] to the root element of any button.\n * @prop {string} [disabled] to the root element of disabled button.\n */\nconst ThemedButton = themed('Button', [\n 'active',\n 'button',\n 'disabled',\n], defaultTheme)(BaseButton);\n\n/**\n * Implements themeable buttons, and button-line links (elements which look\n * like buttons, but behave as links) in the same uniform manner.\n * @param {object} [props] Component props.\n * @param {boolean} [props.active] Set `true` to render the button as\n * active, even if it is not active otherwise.\n * @param {boolean} [props.disabled] Set `true` to disable the button.\n * @param {boolean} [props.enforceA] When the button is rendered as `<Link>`\n * component, this prop enforces it to be rendered as a simple `<a>` element\n * (external link), rather than the React router's internal link.\n * See `<Link>` documentation to learn when links are rendered as `<a>`\n * by default.\n * @param {function} [props.onClick] Click event handler.\n * @param {function} [props.onMouseDown] Mouse down event handler.\n * @param {boolean} [props.openNewTab] Set `true` to open link in the new tab.\n * @param {boolean} [props.replace] When the button is rendered as\n * `<Link>`, and the target URL is internal, this property tells that\n * the new route should replace the last record in the browser's history,\n * rather than to be pushed as a new entry into the history stack.\n * @param {ButtonTheme} [props.theme] _Ad hoc_ button theme.\n * @param {object|string} [props.to] If specified, the button will be rendered\n * as `<Link>` (if not disabled), and it will point to the specified location\n * or URL.\n * @param {...any} [props....]\n * [Other properties of themeable components](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nBaseButton.defaultProps = {\n active: false,\n children: undefined,\n disabled: false,\n enforceA: false,\n onClick: undefined,\n onMouseDown: undefined,\n openNewTab: false,\n replace: false,\n to: undefined,\n};\n\nBaseButton.propTypes = {\n active: PT.bool,\n children: PT.node,\n disabled: PT.bool,\n enforceA: PT.bool,\n onClick: PT.func,\n onMouseDown: PT.func,\n openNewTab: PT.bool,\n replace: PT.bool,\n theme: ThemedButton.themeType.isRequired,\n to: PT.oneOfType([PT.object, PT.string]),\n};\n\nexport default ThemedButton;\n"],"file":"index.js"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _propTypes=_interopRequireDefault(require("prop-types"));var _utils=require("../../utils");var _jsxRuntime=require("react/jsx-runtime");var defaultTheme={"context":"
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _propTypes=_interopRequireDefault(require("prop-types"));var _utils=require("../../utils");var _jsxRuntime=require("react/jsx-runtime");var defaultTheme={"context":"dNQcC6","ad":"earXxa","hoc":"qAPfQ6","checkbox":"A-f8qJ","container":"Kr0g3M","label":"_3dML-O"};function Checkbox({checked,label,onChange,theme}){return/*#__PURE__*/(0,_jsxRuntime.jsxs)("div",{className:theme.container,children:[label===undefined?null:/*#__PURE__*/(0,_jsxRuntime.jsx)("p",{className:theme.label,children:label}),/*#__PURE__*/(0,_jsxRuntime.jsx)("input",{checked:checked,className:theme.checkbox,onChange:onChange,type:"checkbox"})]})}/**
|
|
2
2
|
* Checkbox component theme: a map of
|
|
3
3
|
* CSS classes to append to its elements:
|
|
4
4
|
* @prop {string} [checkbox] to the underlying checkbox `<input>` element.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/shared/components/Checkbox/index.jsx"],"names":["Checkbox","checked","label","onChange","theme","container","undefined","checkbox","ThemedCheckbox","defaultTheme","propTypes","PT","bool","string","func","themeType","isRequired","defaultProps"],"mappings":"gLAAA,6DAEA,kC,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/shared/components/Checkbox/index.jsx"],"names":["Checkbox","checked","label","onChange","theme","container","undefined","checkbox","ThemedCheckbox","defaultTheme","propTypes","PT","bool","string","func","themeType","isRequired","defaultProps"],"mappings":"gLAAA,6DAEA,kC,2KAIA,QAASA,CAAAA,QAAT,CAAkB,CAChBC,OADgB,CAEhBC,KAFgB,CAGhBC,QAHgB,CAIhBC,KAJgB,CAAlB,CAKG,CACD,mBACE,4BAAK,SAAS,CAAEA,KAAK,CAACC,SAAtB,WACIH,KAAK,GAAKI,SAAV,CAAsB,IAAtB,cAA6B,yBAAG,SAAS,CAAEF,KAAK,CAACF,KAApB,UAA4BA,KAA5B,EADjC,cAEE,6BACE,OAAO,CAAED,OADX,CAEE,SAAS,CAAEG,KAAK,CAACG,QAFnB,CAGE,QAAQ,CAAEJ,QAHZ,CAIE,IAAI,CAAC,UAJP,EAFF,GAUH,CAED;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAMK,CAAAA,cAAc,CAAG,kBAAO,UAAP,CAAmB,CACxC,UADwC,CAExC,WAFwC,CAGxC,OAHwC,CAAnB,CAIpBC,YAJoB,EAINT,QAJM,CAAvB,CAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAA,QAAQ,CAACU,SAAT,CAAqB,CACnBT,OAAO,CAAEU,mBAAGC,IADO,CAEnBV,KAAK,CAAES,mBAAGE,MAFS,CAGnBV,QAAQ,CAAEQ,mBAAGG,IAHM,CAInBV,KAAK,CAAEI,cAAc,CAACO,SAAf,CAAyBC,UAJb,CAArB,CAOAhB,QAAQ,CAACiB,YAAT,CAAwB,CACtBhB,OAAO,CAAEK,SADa,CAEtBJ,KAAK,CAAEI,SAFe,CAGtBH,QAAQ,CAAEG,SAHY,CAAxB,C,aAMeE,c","sourcesContent":["import PT from 'prop-types';\n\nimport { themed } from 'utils';\n\nimport defaultTheme from './theme.scss';\n\nfunction Checkbox({\n checked,\n label,\n onChange,\n theme,\n}) {\n return (\n <div className={theme.container}>\n { label === undefined ? null : <p className={theme.label}>{label}</p> }\n <input\n checked={checked}\n className={theme.checkbox}\n onChange={onChange}\n type=\"checkbox\"\n />\n </div>\n );\n}\n\n/**\n * Checkbox component theme: a map of\n * CSS classes to append to its elements:\n * @prop {string} [checkbox] to the underlying checkbox `<input>` element.\n * @prop {string} [container] to the root checkbox element.\n * @prop {string} [label] to the checkbox label element.\n */\nconst ThemedCheckbox = themed('Checkbox', [\n 'checkbox',\n 'container',\n 'label',\n], defaultTheme)(Checkbox);\n\n/**\n * The `<Checkbox>` component implements themeable checkboxes.\n * @param {object} [props] Component properties.\n * @param {boolean} [props.checked] Checkbox value.\n * @param {string} [props.label] Checkbox label.\n * @param {function} [props.onChange] State change handler.\n * @param {CheckboxTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other properties of themeable components](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties).\n */\nCheckbox.propTypes = {\n checked: PT.bool,\n label: PT.string,\n onChange: PT.func,\n theme: ThemedCheckbox.themeType.isRequired,\n};\n\nCheckbox.defaultProps = {\n checked: undefined,\n label: undefined,\n onChange: undefined,\n};\n\nexport default ThemedCheckbox;\n"],"file":"index.js"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=ServerSide;var _server=_interopRequireDefault(require("react-dom/server"));var _propTypes=_interopRequireDefault(require("prop-types"));var _reactGlobalState=require("@dr.pogodin/react-global-state");var
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=ServerSide;var _server=_interopRequireDefault(require("react-dom/server"));var _propTypes=_interopRequireDefault(require("prop-types"));var _reactGlobalState=require("@dr.pogodin/react-global-state");var _server2=require("react-router-dom/server");var _jsxRuntime=require("react/jsx-runtime");/**
|
|
2
2
|
* Server-side implementation.
|
|
3
3
|
*/ /* eslint-disable react/jsx-props-no-spreading */ /**
|
|
4
4
|
* A specially wrapped `require()`, which is passed as an argument into
|
|
@@ -18,7 +18,7 @@ const p=require.resolve(path,{paths:[base]});/* eslint-disable global-require, i
|
|
|
18
18
|
* to load the component is provider, `useAsyncData(..)` is used to
|
|
19
19
|
* attempt to load and use the component via SSR mechanics. */let Scene;if(getComponentServer)Scene=getComponentServer(resolveRequire);else{// In this case we are sure the condition won't change during the rendering
|
|
20
20
|
// loop, thus we can ignore the rule.
|
|
21
|
-
/* eslint-disable react-hooks/rules-of-hooks */const{data}=(0,_reactGlobalState.useAsyncData)(`dr_pogodin_react_utils___split_components.${chunkName}`,getComponentAsync);Scene=data?data.default||data:placeholder||(()=>null);/* eslint-enable react-hooks/rules-of-hooks */}const globalState=(0,_reactGlobalState.getGlobalState)();const html=_server.default.renderToString(/*#__PURE__*/(0,_jsxRuntime.jsx)(_reactGlobalState.GlobalStateProvider,{stateProxy:globalState,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(
|
|
21
|
+
/* eslint-disable react-hooks/rules-of-hooks */const{data}=(0,_reactGlobalState.useAsyncData)(`dr_pogodin_react_utils___split_components.${chunkName}`,getComponentAsync);Scene=data?data.default||data:placeholder||(()=>null);/* eslint-enable react-hooks/rules-of-hooks */}const globalState=(0,_reactGlobalState.getGlobalState)();const html=_server.default.renderToString(/*#__PURE__*/(0,_jsxRuntime.jsx)(_reactGlobalState.GlobalStateProvider,{stateProxy:globalState,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_server2.StaticRouter,{location:globalState.ssrContext.req.url,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(Scene,{...rest})})}));/* 2. `chunks` array is used to record CSS chunks to inject. */const{chunks}=globalState.ssrContext;if(chunks.includes(chunkName)){throw new Error(`CodeSplit: chunk name clash for (${chunkName})`)}else chunks.push(chunkName);/* The result is rendered using the container with `dangerouslySetInnerHTML`
|
|
22
22
|
* to allow reproduce the same rendering result at the client side, even prior
|
|
23
23
|
* to the async loading of the split code. */ /* eslint-disable react/no-danger */return/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{dangerouslySetInnerHTML:{__html:html},"data-chunk-name":chunkName});/* eslint-enable react/no-danger */}ServerSide.propTypes={chunkName:_propTypes.default.string.isRequired,getComponentAsync:_propTypes.default.func,getComponentServer:_propTypes.default.func,placeholder:_propTypes.default.elementType};ServerSide.defaultProps={getComponentAsync:null,getComponentServer:null,placeholder:null};
|
|
24
24
|
//# sourceMappingURL=ServerSide.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/shared/components/CodeSplit/ServerSide.jsx"],"names":["resolveRequire","base","path","p","require","resolve","paths","default","def","named","Object","entries","forEach","key","value","Error","ServerSide","chunkName","getComponentAsync","getComponentServer","placeholder","rest","Scene","data","globalState","html","ReactDom","renderToString","ssrContext","req","url","chunks","includes","push","__html","propTypes","PT","string","isRequired","func","elementType","defaultProps"],"mappings":"oLAKA,gEACA,6DAEA,gEAKA,gD,6CAbA;AACA;AACA,G,CACA,iD,CAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAASA,CAAAA,cAAT,CAAwBC,IAAxB,CAA8BC,IAA9B,CAAoC,CAClC;AACA;AACA;AACA;AACA,KAAMC,CAAAA,CAAC,CAAGC,OAAO,CAACC,OAAR,CAAgBH,IAAhB,CAAsB,CAAEI,KAAK,CAAE,CAACL,IAAD,CAAT,CAAtB,CAAV,CACA,8DACA,KAAM,CAAEM,OAAO,CAAEC,GAAX,CAAgB,GAAGC,KAAnB,EAA6BL,OAAO,CAACD,CAAD,CAA1C,CACA,6DACA,GAAI,CAACK,GAAL,CAAU,MAAOC,CAAAA,KAAP,CAEVC,MAAM,CAACC,OAAP,CAAeF,KAAf,EAAsBG,OAAtB,CAA8B,CAAC,CAACC,GAAD,CAAMC,KAAN,CAAD,GAAkB,CAC9C,GAAIN,GAAG,CAACK,GAAD,CAAP,CAAc,KAAME,CAAAA,KAAK,CAAC,4CAAD,CAAX,CACdP,GAAG,CAACK,GAAD,CAAH,CAAWC,KACZ,CAHD,EAIA,MAAON,CAAAA,GACR,CAEc,QAASQ,CAAAA,UAAT,CAAoB,CACjCC,SADiC,CAEjCC,iBAFiC,CAGjCC,kBAHiC,CAIjCC,WAJiC,CAKjC,GAAGC,IAL8B,CAApB,CAMZ,CACD;AACF;AACA;AACA;AACA;AACA,mEACE,GAAIC,CAAAA,KAAJ,CACA,GAAIH,kBAAJ,CAAwBG,KAAK,CAAGH,kBAAkB,CAACnB,cAAD,CAA1B,CAAxB,IACK,CACH;AACA;AACA,+CACA,KAAM,CAAEuB,IAAF,EAAW,mCACd,6CAA4CN,SAAU,EADxC,CAEfC,iBAFe,CAAjB,CAIAI,KAAK,CAAGC,IAAI,CAAIA,IAAI,CAAChB,OAAL,EAAgBgB,IAApB,CAA6BH,WAAW,GAAK,IAAM,IAAX,CAApD,CACA,8CACD,CAED,KAAMI,CAAAA,WAAW,CAAG,sCAApB,CACA,KAAMC,CAAAA,IAAI,CAAGC,gBAASC,cAAT,cACX,oBAAC,qCAAD,EAAqB,UAAU,CAAEH,WAAjC,uBACE,oBAAC,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/shared/components/CodeSplit/ServerSide.jsx"],"names":["resolveRequire","base","path","p","require","resolve","paths","default","def","named","Object","entries","forEach","key","value","Error","ServerSide","chunkName","getComponentAsync","getComponentServer","placeholder","rest","Scene","data","globalState","html","ReactDom","renderToString","ssrContext","req","url","chunks","includes","push","__html","propTypes","PT","string","isRequired","func","elementType","defaultProps"],"mappings":"oLAKA,gEACA,6DAEA,gEAKA,gD,6CAbA;AACA;AACA,G,CACA,iD,CAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAASA,CAAAA,cAAT,CAAwBC,IAAxB,CAA8BC,IAA9B,CAAoC,CAClC;AACA;AACA;AACA;AACA,KAAMC,CAAAA,CAAC,CAAGC,OAAO,CAACC,OAAR,CAAgBH,IAAhB,CAAsB,CAAEI,KAAK,CAAE,CAACL,IAAD,CAAT,CAAtB,CAAV,CACA,8DACA,KAAM,CAAEM,OAAO,CAAEC,GAAX,CAAgB,GAAGC,KAAnB,EAA6BL,OAAO,CAACD,CAAD,CAA1C,CACA,6DACA,GAAI,CAACK,GAAL,CAAU,MAAOC,CAAAA,KAAP,CAEVC,MAAM,CAACC,OAAP,CAAeF,KAAf,EAAsBG,OAAtB,CAA8B,CAAC,CAACC,GAAD,CAAMC,KAAN,CAAD,GAAkB,CAC9C,GAAIN,GAAG,CAACK,GAAD,CAAP,CAAc,KAAME,CAAAA,KAAK,CAAC,4CAAD,CAAX,CACdP,GAAG,CAACK,GAAD,CAAH,CAAWC,KACZ,CAHD,EAIA,MAAON,CAAAA,GACR,CAEc,Q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AAEkB,mBAAGG,IAFD,CAGrBpB,kBAAkB,CAAEiB,mBAAGG,IAHF,CAIrBnB,WAAW,CAAEgB,mBAAGI,WAJK,CAAvB,CAOAxB,UAAU,CAACyB,YAAX,CAA0B,CACxBvB,iBAAiB,CAAE,IADK,CAExBC,kBAAkB,CAAE,IAFI,CAGxBC,WAAW,CAAE,IAHW,CAA1B","sourcesContent":["/**\n * Server-side implementation.\n */\n/* eslint-disable react/jsx-props-no-spreading */\n\nimport ReactDom from 'react-dom/server';\nimport PT from 'prop-types';\n\nimport {\n getGlobalState,\n GlobalStateProvider,\n useAsyncData,\n} from '@dr.pogodin/react-global-state';\nimport { StaticRouter } from 'react-router-dom/server';\n\n/**\n * A specially wrapped `require()`, which is passed as an argument into\n * the optional `getComponentServer` prop of <{@link CodeSplit}> component.\n * @param {string} base Path resolution base, you want to pass in `__dirname`\n * value from the host module using `<CodeSplit>`.\n * @param {string} path The path of module to require.\n * @return {object} Required module.\n */\nfunction resolveRequire(base, path) {\n // NOTE: A part of code here attempts to correctly load ES6 modules\n // transformed by Babel; namely if required module has \"default\" field,\n // all other fields (presumed to be named exports) are attached to\n // the \"default\".\n const p = require.resolve(path, { paths: [base] });\n /* eslint-disable global-require, import/no-dynamic-require */\n const { default: def, ...named } = require(p);\n /* eslint-enable global-require, import/no-dynamic-require */\n if (!def) return named;\n\n Object.entries(named).forEach(([key, value]) => {\n if (def[key]) throw Error('Conflict between default and named exports');\n def[key] = value;\n });\n return def;\n}\n\nexport default function ServerSide({\n chunkName,\n getComponentAsync,\n getComponentServer,\n placeholder,\n ...rest\n}) {\n /* 1. The component, or its placeholder is rendered into HTML string.\n * The component is wrapped into <GlobalStateProvider>, and <StaticRouter>\n * to ensure that global state, and react router will work inside\n * the component, if present there. Also, if no server-side (sync) way\n * to load the component is provider, `useAsyncData(..)` is used to\n * attempt to load and use the component via SSR mechanics. */\n let Scene;\n if (getComponentServer) Scene = getComponentServer(resolveRequire);\n else {\n // In this case we are sure the condition won't change during the rendering\n // loop, thus we can ignore the rule.\n /* eslint-disable react-hooks/rules-of-hooks */\n const { data } = useAsyncData(\n `dr_pogodin_react_utils___split_components.${chunkName}`,\n getComponentAsync,\n );\n Scene = data ? (data.default || data) : (placeholder || (() => null));\n /* eslint-enable react-hooks/rules-of-hooks */\n }\n\n const globalState = getGlobalState();\n const html = ReactDom.renderToString((\n <GlobalStateProvider stateProxy={globalState}>\n <StaticRouter location={globalState.ssrContext.req.url}>\n <Scene {...rest} />\n </StaticRouter>\n </GlobalStateProvider>\n ));\n\n /* 2. `chunks` array is used to record CSS chunks to inject. */\n const { chunks } = globalState.ssrContext;\n if (chunks.includes(chunkName)) {\n throw new Error(`CodeSplit: chunk name clash for (${chunkName})`);\n } else chunks.push(chunkName);\n\n /* The result is rendered using the container with `dangerouslySetInnerHTML`\n * to allow reproduce the same rendering result at the client side, even prior\n * to the async loading of the split code. */\n /* eslint-disable react/no-danger */\n return (\n <div\n dangerouslySetInnerHTML={{ __html: html }}\n data-chunk-name={chunkName}\n />\n );\n /* eslint-enable react/no-danger */\n}\n\nServerSide.propTypes = {\n chunkName: PT.string.isRequired,\n getComponentAsync: PT.func,\n getComponentServer: PT.func,\n placeholder: PT.elementType,\n};\n\nServerSide.defaultProps = {\n getComponentAsync: null,\n getComponentServer: null,\n placeholder: null,\n};\n"],"file":"ServerSide.js"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _lodash=require("lodash");var _propTypes=_interopRequireDefault(require("prop-types"));var _utils=require("../../utils");var _jsxRuntime=require("react/jsx-runtime");var defaultTheme={"context":"
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _lodash=require("lodash");var _propTypes=_interopRequireDefault(require("prop-types"));var _utils=require("../../utils");var _jsxRuntime=require("react/jsx-runtime");var defaultTheme={"context":"haRIry","ad":"D4XHG2","hoc":"N3nd34","arrow":"-zPK7Y","container":"_9CQpeA","label":"Gv0kyu","option":"xmsujA","hiddenOption":"RdW3yR","select":"JXK1uw"};/**
|
|
2
2
|
* Implements a themeable dropdown list. Internally it is rendered with help of
|
|
3
3
|
* the standard HTML `<select>` element, thus the styling support is somewhat
|
|
4
4
|
* limited.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/shared/components/Dropdown/index.jsx"],"names":["Dropdown","filter","label","onChange","options","theme","value","optionArray","hiddenOption","i","length","op","push","option","name","undefined","container","select","arrow","ThemedDropdown","defaultTheme","propTypes","PT","func","string","arrayOf","oneOfType","shape","node","isRequired","themeType","defaultProps"],"mappings":"gLAAA,8BACA,6DAEA,kC,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/shared/components/Dropdown/index.jsx"],"names":["Dropdown","filter","label","onChange","options","theme","value","optionArray","hiddenOption","i","length","op","push","option","name","undefined","container","select","arrow","ThemedDropdown","defaultTheme","propTypes","PT","func","string","arrayOf","oneOfType","shape","node","isRequired","themeType","defaultProps"],"mappings":"gLAAA,8BACA,6DAEA,kC,oOAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAASA,CAAAA,QAAT,CAAkB,CAChBC,MADgB,CAEhBC,KAFgB,CAGhBC,QAHgB,CAIhBC,OAJgB,CAKhBC,KALgB,CAMhBC,KANgB,CAAlB,CAOG,CACD,KAAMC,CAAAA,WAAW,CAAG,cAClB,8BACE,SAAS,CAAEF,KAAK,CAACG,YADnB,oBAEM,0BAFN,CADkB,CAApB,CAQA,IAAK,GAAIC,CAAAA,CAAC,CAAG,CAAb,CAAgBA,CAAC,CAAGL,OAAO,CAACM,MAA5B,CAAoC,EAAED,CAAtC,CAAyC,CACvC,GAAIE,CAAAA,EAAE,CAAGP,OAAO,CAACK,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UAFV,CAAT,CADW,CAKXP,mBAAGE,MALQ,CAAb,EAMGK,UAPI,CAJU,CAanBxB,KAAK,CAAEc,cAAc,CAACW,SAAf,CAAyBD,UAbb,CAcnBvB,KAAK,CAAEgB,mBAAGE,MAdS,CAArB,CAiBAxB,QAAQ,CAAC+B,YAAT,CAAwB,CACtB9B,MAAM,CAAEc,SADc,CAEtBb,KAAK,CAAEa,SAFe,CAGtBZ,QAAQ,CAAEY,SAHY,CAItBX,OAAO,CAAE,EAJa,CAKtBE,KAAK,CAAES,SALe,CAAxB,C,aAQeI,c","sourcesContent":["import { isString } from 'lodash';\nimport PT from 'prop-types';\n\nimport { themed } from 'utils';\n\nimport defaultTheme from './theme.scss';\n\n/**\n * Implements a themeable dropdown list. Internally it is rendered with help of\n * the standard HTML `<select>` element, thus the styling support is somewhat\n * limited.\n * @param {object} [props] Component properties.\n * @param {function} [props.filter] Options filter function. If provided, only\n * those elements of `options` list will be used by the dropdown, for which this\n * filter returns `true`.\n * @param {string} [props.label] Dropdown label.\n * @param {string} [props.onChange] Selection event handler.\n * @param {DropdownOption[]|string[]} [props.options=[]] Array of dropdown\n * options. For string elements the option value and name will be the same.\n * It is allowed to mix DropdownOption and string elements in the same option\n * list.\n * @param {DropdownTheme} [props.theme] _Ad hoc_ theme.\n * @param {string} [props.value] Currently selected value.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nfunction Dropdown({\n filter,\n label,\n onChange,\n options,\n theme,\n value,\n}) {\n const optionArray = [(\n <option\n className={theme.hiddenOption}\n key=\"__reactUtilsHiddenOption\"\n >\n ‌\n </option>\n )];\n for (let i = 0; i < options.length; ++i) {\n let op = options[i];\n if (!filter || filter(op)) {\n if (isString(op)) op = { value: op };\n optionArray.push((\n <option className={theme.option} key={op.value} value={op.value}>\n {op.name === undefined ? op.value : op.name }\n </option>\n ));\n }\n }\n return (\n <div className={theme.container}>\n { label === undefined ? null : <p className={theme.label}>{label}</p> }\n <select\n className={theme.select}\n onChange={onChange}\n value={value}\n >\n {optionArray}\n </select>\n <div className={theme.arrow}>▼</div>\n </div>\n );\n}\n\nconst ThemedDropdown = themed('Dropdown', [\n 'arrow',\n 'container',\n 'hiddenOption',\n 'label',\n 'option',\n 'select',\n], defaultTheme)(Dropdown);\n\nDropdown.propTypes = {\n filter: PT.func,\n label: PT.string,\n onChange: PT.func,\n options: PT.arrayOf(\n PT.oneOfType([\n PT.shape({\n name: PT.node,\n value: PT.string.isRequired,\n }),\n PT.string,\n ]).isRequired,\n ),\n theme: ThemedDropdown.themeType.isRequired,\n value: PT.string,\n};\n\nDropdown.defaultProps = {\n filter: undefined,\n label: undefined,\n onChange: undefined,\n options: [],\n value: undefined,\n};\n\nexport default ThemedDropdown;\n"],"file":"index.js"}
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
* - It is opted explicitely by `enforceA` prop;
|
|
42
42
|
* - It should be opened in a new tab;
|
|
43
43
|
* - It is an absolte URL (starts with http:// or https://);
|
|
44
|
-
* - It is anchor link (starts with #). */if(disabled||enforceA||openNewTab||to.match(/^(#|(https?|mailto):)/)){return/*#__PURE__*/(0,_jsxRuntime.jsx)("a",{className:(className?className+" ":"")+"
|
|
44
|
+
* - It is anchor link (starts with #). */if(disabled||enforceA||openNewTab||to.match(/^(#|(https?|mailto):)/)){return/*#__PURE__*/(0,_jsxRuntime.jsx)("a",{className:(className?className+" ":"")+"zH52sA",disabled:disabled,href:to,onClick:disabled?e=>e.preventDefault():onClick,onMouseDown:disabled?e=>e.preventDefault():onMouseDown,rel:"noopener noreferrer",target:openNewTab?"_blank":"",children:children})}/* Otherwise we render the link as React Router's Link or NavLink element. */return/*#__PURE__*/(0,_react.createElement)(routerLinkType,{className,disabled,onMouseDown,replace,to,onClick:e=>{// Executes the user-provided event handler, if any.
|
|
45
45
|
if(onClick)onClick(e);// By default, clicking the link scrolls the page to beginning.
|
|
46
46
|
if(!keepScrollPosition)window.scroll(0,0)},...rest},children)}GenericLink.defaultProps={children:null,className:null,disabled:false,enforceA:false,keepScrollPosition:false,onClick:null,onMouseDown:null,openNewTab:false,replace:false,to:""};GenericLink.propTypes={children:_propTypes.default.node,className:_propTypes.default.string,disabled:_propTypes.default.bool,enforceA:_propTypes.default.bool,keepScrollPosition:_propTypes.default.bool,onClick:_propTypes.default.func,onMouseDown:_propTypes.default.func,openNewTab:_propTypes.default.bool,replace:_propTypes.default.bool,routerLinkType:_propTypes.default.elementType.isRequired,to:_propTypes.default.oneOfType([_propTypes.default.object,_propTypes.default.string])};
|
|
47
47
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/shared/components/GenericLink/index.jsx"],"names":["GenericLink","children","className","disabled","enforceA","keepScrollPosition","onClick","onMouseDown","openNewTab","replace","routerLinkType","to","rest","match","e","preventDefault","window","scroll","defaultProps","propTypes","PT","node","string","bool","func","elementType","isRequired","oneOfType","object"],"mappings":"qLAEA,6DACA,4B,6CAHA,mB,CAOA;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,GACe,QAASA,CAAAA,WAAT,CAAqB,CAClCC,QADkC,CAElCC,SAFkC,CAGlCC,QAHkC,CAIlCC,QAJkC,CAKlCC,kBALkC,CAMlCC,OANkC,CAOlCC,WAPkC,CAQlCC,UARkC,CASlCC,OATkC,CAUlCC,cAVkC,CAWlCC,EAXkC,CAYlC,GAAGC,IAZ+B,CAArB,CAaZ,CACD;AACF;AACA;AACA;AACA,4CACE,GAAIT,QAAQ,EAAIC,QAAZ,EAAwBI,UAAxB,EAAsCG,EAAE,CAACE,KAAH,CAAS,uBAAT,CAA1C,CAA6E,CAC3E,mBACE,yBACE,SAAS,EAAEX,SAAF,CAAEA,SAAF,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/shared/components/GenericLink/index.jsx"],"names":["GenericLink","children","className","disabled","enforceA","keepScrollPosition","onClick","onMouseDown","openNewTab","replace","routerLinkType","to","rest","match","e","preventDefault","window","scroll","defaultProps","propTypes","PT","node","string","bool","func","elementType","isRequired","oneOfType","object"],"mappings":"qLAEA,6DACA,4B,6CAHA,mB,CAOA;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,GACe,QAASA,CAAAA,WAAT,CAAqB,CAClCC,QADkC,CAElCC,SAFkC,CAGlCC,QAHkC,CAIlCC,QAJkC,CAKlCC,kBALkC,CAMlCC,OANkC,CAOlCC,WAPkC,CAQlCC,UARkC,CASlCC,OATkC,CAUlCC,cAVkC,CAWlCC,EAXkC,CAYlC,GAAGC,IAZ+B,CAArB,CAaZ,CACD;AACF;AACA;AACA;AACA,4CACE,GAAIT,QAAQ,EAAIC,QAAZ,EAAwBI,UAAxB,EAAsCG,EAAE,CAACE,KAAH,CAAS,uBAAT,CAA1C,CAA6E,CAC3E,mBACE,yBACE,SAAS,EAAEX,SAAF,CAAEA,SAAF,iBADX,CAEE,QAAQ,CAAEC,QAFZ,CAGE,IAAI,CAAEQ,EAHR,CAIE,OAAO,CAAER,QAAQ,CAAIW,CAAD,EAAOA,CAAC,CAACC,cAAF,EAAV,CAA+BT,OAJlD,CAKE,WAAW,CAAEH,QAAQ,CAAIW,CAAD,EAAOA,CAAC,CAACC,cAAF,EAAV,CAA+BR,WALtD,CAME,GAAG,CAAC,qBANN,CAQE,MAAM,CAAEC,UAAU,CAAG,QAAH,CAAc,EARlC,UAUGP,QAVH,EAaH,CAED,6EACA,mBAAO,yBAAcS,cAAd,CAA8B,CACnCR,SADmC,CAEnCC,QAFmC,CAGnCI,WAHmC,CAInCE,OAJmC,CAKnCE,EALmC,CAMnCL,OAAO,CAAGQ,CAAD,EAAO,CACd;AACA,GAAIR,OAAJ,CAAaA,OAAO,CAACQ,CAAD,CAAP,CAEb;AACA,GAAI,CAACT,kBAAL,CAAyBW,MAAM,CAACC,MAAP,CAAc,CAAd,CAAiB,CAAjB,CAC1B,CAZkC,CAanC,GAAGL,IAbgC,CAA9B,CAcJX,QAdI,CAeR,CAEDD,WAAW,CAACkB,YAAZ,CAA2B,CACzBjB,QAAQ,CAAE,IADe,CAEzBC,SAAS,CAAE,IAFc,CAGzBC,QAAQ,CAAE,KAHe,CAIzBC,QAAQ,CAAE,KAJe,CAKzBC,kBAAkB,CAAE,KALK,CAMzBC,OAAO,CAAE,IANgB,CAOzBC,WAAW,CAAE,IAPY,CAQzBC,UAAU,CAAE,KARa,CASzBC,OAAO,CAAE,KATgB,CAUzBE,EAAE,CAAE,EAVqB,CAA3B,CAaAX,WAAW,CAACmB,SAAZ,CAAwB,CACtBlB,QAAQ,CAAEmB,mBAAGC,IADS,CAEtBnB,SAAS,CAAEkB,mBAAGE,MAFQ,CAGtBnB,QAAQ,CAAEiB,mBAAGG,IAHS,CAItBnB,QAAQ,CAAEgB,mBAAGG,IAJS,CAKtBlB,kBAAkB,CAAEe,mBAAGG,IALD,CAMtBjB,OAAO,CAAEc,mBAAGI,IANU,CAOtBjB,WAAW,CAAEa,mBAAGI,IAPM,CAQtBhB,UAAU,CAAEY,mBAAGG,IARO,CAStBd,OAAO,CAAEW,mBAAGG,IATU,CAUtBb,cAAc,CAAEU,mBAAGK,WAAH,CAAeC,UAVT,CAWtBf,EAAE,CAAES,mBAAGO,SAAH,CAAa,CAACP,mBAAGQ,MAAJ,CAAYR,mBAAGE,MAAf,CAAb,CAXkB,CAAxB","sourcesContent":["/* global window */\n\nimport PT from 'prop-types';\nimport { createElement } from 'react';\n\nimport './style.scss';\n\n/**\n * The `<Link>` component, and almost identical `<NavLink>` component, are\n * auxiliary wrappers around\n * [React Router](https://github.com/ReactTraining/react-router)'s\n * `<Link>` and `<NavLink>` components; they help to handle external and\n * internal links in uniform manner.\n *\n * @param {object} [props] Component properties.\n * @param {string} [props.className] CSS classes to apply to the link.\n * @param {boolean} [props.disabled] Disables the link.\n * @param {boolean} [props.enforceA] `true` enforces rendering of the link as\n * a simple `<a>` element.\n * @param {boolean} [props.keepScrollPosition] If `true`, and the link is\n * rendered as a React Router's component, it won't reset the viewport scrolling\n * position to the origin when clicked.\n * @param {function} [props.onClick] Event handler to trigger upon click.\n * @param {function} [props.onMouseDown] Event handler to trigger on MouseDown\n * event.\n * @param {boolean} [props.openNewTab] If `true` the link opens in a new tab.\n * @param {boolean} [props.replace] When `true`, the link will replace current\n * entry in the history stack instead of adding a new one.\n * @param {string} [props.to] Link URL.\n * @param {string} [props.activeClassName] **`<NavLink>`** only: CSS class(es)\n * to apply to rendered link when it is active.\n * @param {string} [props.activeStyle] **`<NavLink>`** only: CSS styles\n * to apply to the rendered link when it is active.\n * @param {boolean} [props.exact] **`<NavLink>`** only: if `true`, the active\n * class/style will only be applied if the location is matched exactly.\n * @param {function} [props.isActive] **`<NavLink>`** only: Add extra\n * logic for determining whether the link is active. This should be used if you\n * want to do more than verify that the link’s pathname matches the current URL\n * pathname.\n * @param {object} [props.location] **`<NavLink>`** only: `isActive` compares\n * current history location (usually the current browser URL). To compare to\n * a different location, a custom `location` can be passed.\n * @param {boolean} [props.strict] **`<NavLink>`** only: . When `true`, trailing\n * slash on a location’s pathname will be taken into consideration when\n * determining if the location matches the current URL. See the `<Route strict>`\n * documentation for more information.\n */\nexport default function GenericLink({\n children,\n className,\n disabled,\n enforceA,\n keepScrollPosition,\n onClick,\n onMouseDown,\n openNewTab,\n replace,\n routerLinkType,\n to,\n ...rest\n}) {\n /* Renders Link as <a> element if:\n * - It is opted explicitely by `enforceA` prop;\n * - It should be opened in a new tab;\n * - It is an absolte URL (starts with http:// or https://);\n * - It is anchor link (starts with #). */\n if (disabled || enforceA || openNewTab || to.match(/^(#|(https?|mailto):)/)) {\n return (\n <a\n className={className}\n disabled={disabled}\n href={to}\n onClick={disabled ? (e) => e.preventDefault() : onClick}\n onMouseDown={disabled ? (e) => e.preventDefault() : onMouseDown}\n rel=\"noopener noreferrer\"\n styleName=\"link\"\n target={openNewTab ? '_blank' : ''}\n >\n {children}\n </a>\n );\n }\n\n /* Otherwise we render the link as React Router's Link or NavLink element. */\n return createElement(routerLinkType, {\n className,\n disabled,\n onMouseDown,\n replace,\n to,\n onClick: (e) => {\n // Executes the user-provided event handler, if any.\n if (onClick) onClick(e);\n\n // By default, clicking the link scrolls the page to beginning.\n if (!keepScrollPosition) window.scroll(0, 0);\n },\n ...rest,\n }, children);\n}\n\nGenericLink.defaultProps = {\n children: null,\n className: null,\n disabled: false,\n enforceA: false,\n keepScrollPosition: false,\n onClick: null,\n onMouseDown: null,\n openNewTab: false,\n replace: false,\n to: '',\n};\n\nGenericLink.propTypes = {\n children: PT.node,\n className: PT.string,\n disabled: PT.bool,\n enforceA: PT.bool,\n keepScrollPosition: PT.bool,\n onClick: PT.func,\n onMouseDown: PT.func,\n openNewTab: PT.bool,\n replace: PT.bool,\n routerLinkType: PT.elementType.isRequired,\n to: PT.oneOfType([PT.object, PT.string]),\n};\n"],"file":"index.js"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _propTypes=_interopRequireDefault(require("prop-types"));var _utils=require("../../utils");var _jsxRuntime=require("react/jsx-runtime");var defaultTheme={"context":"
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _propTypes=_interopRequireDefault(require("prop-types"));var _utils=require("../../utils");var _jsxRuntime=require("react/jsx-runtime");var defaultTheme={"context":"X5WszA","ad":"_8s7GCr","hoc":"TVlBYc","container":"Cxx397","input":"M07d4s","label":"gfbdq-"};/**
|
|
2
2
|
* Themeable input field, based on the standard HTML `<input>` element.
|
|
3
3
|
* @param {object} [props]
|
|
4
4
|
* @param {string} [props.label] Input label.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/shared/components/Input/index.jsx"],"names":["Input","label","theme","rest","container","undefined","input","ThemedInput","defaultTheme","propTypes","PT","string","themeType","isRequired","defaultProps"],"mappings":"gLAAA,6DAEA,kC,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/shared/components/Input/index.jsx"],"names":["Input","label","theme","rest","container","undefined","input","ThemedInput","defaultTheme","propTypes","PT","string","themeType","isRequired","defaultProps"],"mappings":"gLAAA,6DAEA,kC,wKAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAASA,CAAAA,KAAT,CAAe,CACbC,KADa,CAEbC,KAFa,CAGb,GAAGC,IAHU,CAAf,CAIG,CACD,mBACE,4BAAK,SAAS,CAAED,KAAK,CAACE,SAAtB,WACIH,KAAK,GAAKI,SAAV,CAAsB,IAAtB,cAA6B,yBAAG,SAAS,CAAEH,KAAK,CAACD,KAApB,UAA4BA,KAA5B,EADjC,cAEE,6BACE,SAAS,CAAEC,KAAK,CAACI,KADnB,IAEMH,IAFN,EAFF,GAQH,CAED,KAAMI,CAAAA,WAAW,CAAG,kBAAO,OAAP,CAAgB,CAClC,WADkC,CAElC,OAFkC,CAGlC,OAHkC,CAAhB,CAIjBC,YAJiB,EAIHR,KAJG,CAApB,CAMAA,KAAK,CAACS,SAAN,CAAkB,CAChBR,KAAK,CAAES,mBAAGC,MADM,CAEhBT,KAAK,CAAEK,WAAW,CAACK,SAAZ,CAAsBC,UAFb,CAAlB,CAKAb,KAAK,CAACc,YAAN,CAAqB,CACnBb,KAAK,CAAEI,SADY,CAArB,C,aAIeE,W","sourcesContent":["import PT from 'prop-types';\n\nimport { themed } from 'utils';\n\nimport defaultTheme from './theme.scss';\n\n/**\n * Themeable input field, based on the standard HTML `<input>` element.\n * @param {object} [props]\n * @param {string} [props.label] Input label.\n * @param {InputTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....] [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n * @param {...any} [props....] Any other properties are passed to the underlying\n * `<input>` element.\n */\nfunction Input({\n label,\n theme,\n ...rest\n}) {\n return (\n <div className={theme.container}>\n { label === undefined ? null : <p className={theme.label}>{label}</p> }\n <input\n className={theme.input}\n {...rest} // eslint-disable-line react/jsx-props-no-spreading\n />\n </div>\n );\n}\n\nconst ThemedInput = themed('Input', [\n 'container',\n 'input',\n 'label',\n], defaultTheme)(Input);\n\nInput.propTypes = {\n label: PT.string,\n theme: ThemedInput.themeType.isRequired,\n};\n\nInput.defaultProps = {\n label: undefined,\n};\n\nexport default ThemedInput;\n"],"file":"index.js"}
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
*
|
|
51
51
|
* @param {string} [props.url] The page URL to use in `og:url` tag.
|
|
52
52
|
* By default the tag is not injected.
|
|
53
|
-
*/function MetaTags({children,description,image,siteName,socialDescription,socialTitle,title,url}){const socTitle=socialTitle||title;const socDesc=socialDescription||description;return/*#__PURE__*/(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[/*#__PURE__*/(0,_jsxRuntime.jsxs)(_reactHelmet.Helmet,{children:[/*#__PURE__*/(0,_jsxRuntime.jsx)("title",{children:title}),/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"description",content:description}),/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"twitter:card",content:"summary_large_image"}),/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"twitter:title",content:socTitle}),/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"twitter:description",content:socDesc}),image?/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"twitter:image",content:image}):null,siteName?/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"twitter:site",content:`@${siteName}`}):null,/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"og:title",content:socTitle}),image?/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"og:image",content:image}):null,image?/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"og:image:alt",content:socTitle}):null,/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"og:description",content:socDesc}),siteName?/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"og:sitename",content:siteName}):null,url?/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"og:url",content:url}):null]}),children?/*#__PURE__*/(0,_jsxRuntime.jsx)(Context.Provider,{value:
|
|
53
|
+
*/function MetaTags({children,description,image,siteName,socialDescription,socialTitle,title,url}){const socTitle=socialTitle||title;const socDesc=socialDescription||description;const context=(0,_react.useMemo)(()=>({description,image,siteName,socialDescription,socialTitle,title,url}),[description,image,siteName,socialDescription,socialTitle,title,url]);return/*#__PURE__*/(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[/*#__PURE__*/(0,_jsxRuntime.jsxs)(_reactHelmet.Helmet,{children:[/*#__PURE__*/(0,_jsxRuntime.jsx)("title",{children:title}),/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"description",content:description}),/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"twitter:card",content:"summary_large_image"}),/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"twitter:title",content:socTitle}),/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"twitter:description",content:socDesc}),image?/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"twitter:image",content:image}):null,siteName?/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"twitter:site",content:`@${siteName}`}):null,/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"og:title",content:socTitle}),image?/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"og:image",content:image}):null,image?/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"og:image:alt",content:socTitle}):null,/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"og:description",content:socDesc}),siteName?/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"og:sitename",content:siteName}):null,url?/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"og:url",content:url}):null]}),children?/*#__PURE__*/(0,_jsxRuntime.jsx)(Context.Provider,{value:context,children:children}):null]})}MetaTags.Context=Context;MetaTags.defaultProps={children:null,image:null,siteName:null,socialDescription:null,socialTitle:null,url:null};MetaTags.propTypes={children:_propTypes.default.node,description:_propTypes.default.string.isRequired,image:_propTypes.default.string,siteName:_propTypes.default.string,socialDescription:_propTypes.default.string,socialTitle:_propTypes.default.string,title:_propTypes.default.string.isRequired,url:_propTypes.default.string};
|
|
54
54
|
//# sourceMappingURL=MetaTags.js.map
|
|
@@ -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":"kLAAA,6DACA,4BACA,yC,6CAEA,KAAMA,CAAAA,OAAO,cAAG,0BAAhB,CAEA;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,GACe,QAASC,CAAAA,QAAT,CAAkB,CAC/BC,QAD+B,CAE/BC,WAF+B,CAG/BC,KAH+B,CAI/BC,QAJ+B,CAK/BC,iBAL+B,CAM/BC,WAN+B,CAO/BC,KAP+B,CAQ/BC,GAR+B,CAAlB,CASZ,CACD,KAAMC,CAAAA,QAAQ,CAAGH,WAAW,EAAIC,KAAhC,CACA,KAAMG,CAAAA,OAAO,CAAGL,iBAAiB,EAAIH,WAArC,
|
|
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":"kLAAA,6DACA,4BACA,yC,6CAEA,KAAMA,CAAAA,OAAO,cAAG,0BAAhB,CAEA;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,GACe,QAASC,CAAAA,QAAT,CAAkB,CAC/BC,QAD+B,CAE/BC,WAF+B,CAG/BC,KAH+B,CAI/BC,QAJ+B,CAK/BC,iBAL+B,CAM/BC,WAN+B,CAO/BC,KAP+B,CAQ/BC,GAR+B,CAAlB,CASZ,CACD,KAAMC,CAAAA,QAAQ,CAAGH,WAAW,EAAIC,KAAhC,CACA,KAAMG,CAAAA,OAAO,CAAGL,iBAAiB,EAAIH,WAArC,CAEA,KAAMS,CAAAA,OAAO,CAAG,mBAAQ,KAAO,CAC7BT,WAD6B,CAE7BC,KAF6B,CAG7BC,QAH6B,CAI7BC,iBAJ6B,CAK7BC,WAL6B,CAM7BC,KAN6B,CAO7BC,GAP6B,CAAP,CAAR,CAQZ,CACFN,WADE,CAEFC,KAFE,CAGFC,QAHE,CAIFC,iBAJE,CAKFC,WALE,CAMFC,KANE,CAOFC,GAPE,CARY,CAAhB,CAkBA,mBACE,kEACE,qBAAC,mBAAD,yBAEE,sCACGD,KADH,EAFF,cAKE,4BAAM,IAAI,CAAC,aAAX,CAAy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C,WAAW,CAAE,IALS,CAMtBE,GAAG,CAAE,IANiB,CAAxB,CASAR,QAAQ,CAACa,SAAT,CAAqB,CACnBZ,QAAQ,CAAEa,mBAAGC,IADM,CAEnBb,WAAW,CAAEY,mBAAGE,MAAH,CAAUC,UAFJ,CAGnBd,KAAK,CAAEW,mBAAGE,MAHS,CAInBZ,QAAQ,CAAEU,mBAAGE,MAJM,CAKnBX,iBAAiB,CAAES,mBAAGE,MALH,CAMnBV,WAAW,CAAEQ,mBAAGE,MANG,CAOnBT,KAAK,CAAEO,mBAAGE,MAAH,CAAUC,UAPE,CAQnBT,GAAG,CAAEM,mBAAGE,MARW,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"}
|