@dr.pogodin/react-utils 1.25.0 → 1.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/build/development/server/index.js +1 -1
  2. package/build/development/server/index.js.map +1 -1
  3. package/build/development/server/renderer.js +4 -4
  4. package/build/development/server/renderer.js.map +1 -1
  5. package/build/development/shared/components/Dropdown/index.js +25 -17
  6. package/build/development/shared/components/Dropdown/index.js.map +1 -1
  7. package/build/development/shared/components/WithTooltip/Tooltip.js +41 -7
  8. package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
  9. package/build/development/shared/components/WithTooltip/index.js +49 -3
  10. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  11. package/build/development/shared/components/YouTubeVideo/index.js +1 -1
  12. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  13. package/build/development/shared/utils/jest/E2eSsrEnv.js +1 -1
  14. package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  15. package/build/development/style.css +8 -4
  16. package/build/development/web.bundle.js +4 -4
  17. package/build/production/server/index.js +1 -1
  18. package/build/production/server/index.js.map +1 -1
  19. package/build/production/server/renderer.js +1 -1
  20. package/build/production/server/renderer.js.map +1 -1
  21. package/build/production/shared/components/Dropdown/index.js +6 -2
  22. package/build/production/shared/components/Dropdown/index.js.map +1 -1
  23. package/build/production/shared/components/WithTooltip/Tooltip.js +13 -2
  24. package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
  25. package/build/production/shared/components/WithTooltip/index.js +11 -1
  26. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  27. package/build/production/shared/components/YouTubeVideo/index.js +1 -1
  28. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  29. package/build/production/shared/utils/jest/E2eSsrEnv.js +1 -1
  30. package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  31. package/build/production/web.bundle.js +1 -1
  32. package/build/production/web.bundle.js.map +1 -1
  33. package/config/webpack/app-base.js +3 -2
  34. package/config/webpack/lib-base.js +4 -7
  35. package/config/webpack/lib-production.js +3 -7
  36. package/package.json +32 -28
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.js","names":["_stream","require","_reactGlobalState","_jsUtils","_lodash","_config","_interopRequireDefault","_nodeForge","_fs","_path","_zlib","_server","_reactHelmet","_server2","_serializeJavascript","_buildInfo","_winston","_Cache","_jsxRuntime","sanitizedConfig","omit","config","SCRIPT_LOCATIONS","BODY_OPEN","DEFAULT","HEAD_OPEN","exports","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","groupExtraScripts","scripts","script","isString","code","location","undefined","Error","newDefaultLogger","defaultLogLevel","format","transports","winston","createLogger","level","combine","splat","timestamp","colorize","printf","message","stack","rest","Object","keys","stringify","Console","factory","webpackConfig","options","defaults","clone","beforeRender","maxSsrRounds","ssrTimeout","staticCacheSize","logger","defaultLoggerLogLevel","buildInfo","setBuildInfo","publicPath","outputPath","output","manifestLink","existsSync","cache","staticCacheController","Cache","CHUNK_GROUPS","next","set","cookie","csrfToken","cacheRef","data","buffer","status","noCsp","send","done","failed","brotliDecompress","error","html","h","toString","regex","RegExp","nonce","replace","configToInject","extraScripts","initialState","all","helmet","chunkGroups","webpackStats","locals","mapValues","toJson","namedChunkGroups","item","assets","map","name","App","Application","ssrContext","state","cloneDeep","chunks","stream","ssrStart","Date","now","renderPass","pipeableStream","renderToPipeableStream","jsx","GlobalStateProvider","children","StaticRouter","onAllReady","onError","ssrRound","bailed","dirty","timeout","race","allSettled","pending","timer","then","logMsg","log","pipe","Writable","write","chunk","_","Helmet","renderStatic","payload","serializeJs","CONFIG","ISTATE","ignoreFunction","unsafe","update","util","createBuffer","finish","INJ","encode64","chunkSet","Set","forEach","asset","add","styleChunkString","scriptChunkString","endsWith","grouppedExtraScripts","faviconLink","favicon","title","meta","brotliCompress"],"sources":["../../../src/server/renderer.jsx"],"sourcesContent":["/**\n * ExpressJS middleware for server-side rendering of a ReactJS app.\n */\n\nimport { Writable } from 'stream';\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\nimport { timer } from '@dr.pogodin/js-utils';\n\nimport {\n clone,\n cloneDeep,\n defaults,\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 { renderToPipeableStream } from 'react-dom/server';\nimport { Helmet } from 'react-helmet';\nimport { StaticRouter } from 'react-router-dom/server';\nimport serializeJs from 'serialize-javascript';\nimport { setBuildInfo } from 'utils/isomorphy/buildInfo';\nimport winston from 'winston';\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 * Given an array of extra script strings / objects, it returns an object with\n * arrays of scripts to inject in different HTML template locations. During\n * the script groupping it also filters out any empty scripts.\n * @param {({\n * code: string;\n * location: string;\n * }|string)[]} [scripts=[]]\n * @return {{\n * BODY_OPEN: string[];\n * DEFAULT: string[];\n * HEAD_OPEN: string[];\n * }}\n */\nfunction groupExtraScripts(scripts = []) {\n const res = {\n [SCRIPT_LOCATIONS.BODY_OPEN]: '',\n [SCRIPT_LOCATIONS.DEFAULT]: '',\n [SCRIPT_LOCATIONS.HEAD_OPEN]: '',\n };\n for (let i = 0; i < scripts.length; ++i) {\n const script = scripts[i];\n if (isString(script)) {\n if (script) res[SCRIPT_LOCATIONS.DEFAULT] += script;\n } else if (script.code) {\n if (res[script.location] !== undefined) {\n res[script.location] += script.code;\n } else throw Error(`Invalid location \"${script.location}\"`);\n }\n }\n return res;\n}\n\n/**\n * Creates a new default (Winston) logger.\n * @param {object} [options={}]\n * @param {string} [options.defaultLogLevel='info']\n * @return {object}\n */\nexport function newDefaultLogger({\n defaultLogLevel = 'info',\n} = {}) {\n const { format, transports } = winston;\n return winston.createLogger({\n level: defaultLogLevel,\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/**\n * Creates the middleware.\n * @param {object} webpackConfig\n * @param {object} options Additional options:\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 {object} [options.buildInfo] \"Build info\" object to use. If provided,\n * it will be used, instead of trying to load from the filesystem the one\n * generated by the Webpack build. It is intended for test environments,\n * where passing this stuff via file system is no bueno.\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=10] Maximum number of SSR rounds.\n * @param {number} [options.ssrTimeout=1000] SSR timeout in milliseconds,\n * defaults to 1 second.\n * @param {number} [options.staticCacheSize=1.e7] The maximum\n * static cache size in bytes. Defaults to ~10 MB.\n * @param {function} [options.staticCacheController] When given, it activates,\n * and controls the static caching of generated HTML markup. When this function\n * is provided, on each incoming request it is triggered with the request\n * passed in as the argument. To attempt to serve the response from the cache\n * it should return the object with the following fields:\n * - `key: string` &ndash; the cache key for the response;\n * - `maxage?: number` &ndash; the maximum age of cached result in ms.\n * If undefined - infinite age is assumed.\n * @return {function} Created middleware.\n */\nexport default function factory(webpackConfig, options) {\n const ops = defaults(clone(options), {\n beforeRender: () => Promise.resolve({}),\n maxSsrRounds: 10,\n ssrTimeout: 1000,\n staticCacheSize: 1.e7,\n });\n\n // Note: in normal use the default logger is created and set in the root\n // server function, and this initialization is for testing uses, where\n // renderer is imported directly.\n if (ops.logger === undefined) {\n ops.logger = newDefaultLogger({\n defaultLogLevel: ops.defaultLoggerLogLevel,\n });\n }\n\n const buildInfo = ops.buildInfo || getBuildInfo(webpackConfig.context);\n setBuildInfo(buildInfo);\n\n // publicPath from webpack.output has a trailing slash at the end.\n const { publicPath, path: outputPath } = webpackConfig.output;\n\n const manifestLink = fs.existsSync(`${outputPath}/manifest.json`)\n ? `<link rel=\"manifest\" href=\"${publicPath}manifest.json\">` : '';\n\n const cache = ops.staticCacheController\n ? new Cache(ops.staticCacheSize) : null;\n\n const CHUNK_GROUPS = readChunkGroupsJson(outputPath);\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 res.cookie('csrfToken', req.csrfToken());\n\n let cacheRef;\n if (cache) {\n cacheRef = ops.staticCacheController(req);\n if (cacheRef) {\n const data = cache.get(cacheRef);\n if (data !== null) {\n const { buffer, status } = data;\n if (ops.noCsp && isBrotliAcceptable(req)) {\n res.set('Content-Type', 'text/html');\n res.set('Content-Encoding', 'br');\n if (status !== 200) res.status(status);\n res.send(buffer);\n } else {\n await new Promise((done, failed) => {\n brotliDecompress(buffer, (error, html) => {\n if (error) failed(error);\n else {\n let h = html.toString();\n if (!ops.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(buffer.nonce, 'g');\n h = h.replace(regex, req.nonce);\n }\n if (status !== 200) res.status(status);\n res.send(h);\n done();\n }\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 // Gets the mapping between code chunk names and their asset files.\n // These data come from the Webpack compilation, either from the stats\n // attached to the request (in dev mode), or from a file output during\n // the build (in prod mode).\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 /* Optional server-side rendering. */\n let App = ops.Application;\n const ssrContext = {\n req,\n state: cloneDeep(initialState || {}),\n\n // Array of chunk names encountered during the rendering.\n chunks: [],\n\n chunkGroups,\n };\n let stream;\n if (App) {\n const ssrStart = Date.now();\n\n const renderPass = async () => {\n ssrContext.chunks = [];\n return new Promise((resolve, reject) => {\n const pipeableStream = renderToPipeableStream(\n <GlobalStateProvider\n initialState={ssrContext.state}\n ssrContext={ssrContext}\n >\n <StaticRouter location={req.url}>\n <App />\n </StaticRouter>\n </GlobalStateProvider>,\n {\n onAllReady: () => resolve(pipeableStream),\n onError: reject,\n },\n );\n });\n };\n\n let ssrRound = 0;\n let bailed = false;\n for (; ssrRound < ops.maxSsrRounds; ++ssrRound) {\n stream = await renderPass(); // eslint-disable-line no-await-in-loop\n\n if (!ssrContext.dirty) break;\n\n /* eslint-disable no-await-in-loop */\n const timeout = ops.ssrTimeout + ssrStart - Date.now();\n bailed = timeout <= 0 || !await Promise.race([\n Promise.allSettled(ssrContext.pending),\n timer(timeout).then(() => false),\n ]);\n if (bailed) break;\n /* eslint-enable no-await-in-loop */\n }\n\n let logMsg;\n if (ssrContext.dirty) {\n // NOTE: In the case of incomplete SSR one more round is necessary\n // to ensure the correct hydration when some pending promises have\n // resolved and placed their data into the initial global state.\n stream = await renderPass();\n\n logMsg = bailed ? `SSR timed out after ${ops.ssrTimeout} second(s)`\n : `SSR bailed out after ${ops.maxSsrRounds} round(s)`;\n } else logMsg = `SSR completed in ${ssrRound + 1} round(s)`;\n\n ops.logger.log(ssrContext.dirty ? 'warn' : 'info', logMsg);\n\n App = '';\n stream.pipe(new Writable({\n write: (chunk, _, done) => {\n App += chunk.toString();\n done();\n },\n }));\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 /* 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 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 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 const grouppedExtraScripts = groupExtraScripts(extraScripts);\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 ${grouppedExtraScripts[SCRIPT_LOCATIONS.HEAD_OPEN]}\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 <meta itemprop=\"drpruinj\" content=\"${INJ}\">\n </head>\n <body>\n ${grouppedExtraScripts[SCRIPT_LOCATIONS.BODY_OPEN]}\n <div id=\"react-view\">${App || ''}</div>\n ${scriptChunkString}\n ${grouppedExtraScripts[SCRIPT_LOCATIONS.DEFAULT]}\n </body>\n </html>`;\n\n const status = ssrContext.status || 200;\n if (status !== 200) res.status(status);\n\n if (cacheRef && status < 500) {\n // Note: waiting for the caching to complete is not strictly necessary,\n // but it greately simplifies testing, and error reporting.\n await new Promise((done, failed) => {\n brotliCompress(html, (error, buffer) => {\n if (error) failed(error);\n else {\n buffer.nonce = req.nonce; // eslint-disable-line no-param-reassign\n cache.add({ buffer, status }, cacheRef.key);\n done();\n }\n });\n });\n }\n\n // Note: as caching code above may throw in some cases, sending response\n // before it completes will likely hide the error, making it difficult\n // to debug. Thus, at least for now, lets send response after it.\n res.send(html);\n } catch (error) {\n next(error);\n }\n };\n}\n"],"mappings":"ySAIA,IAAAA,OAAA,CAAAC,OAAA,WAEA,IAAAC,iBAAA,CAAAD,OAAA,mCACA,IAAAE,QAAA,CAAAF,OAAA,yBAEA,IAAAG,OAAA,CAAAH,OAAA,WAUA,IAAAI,OAAA,CAAAC,sBAAA,CAAAL,OAAA,YACA,IAAAM,UAAA,CAAAD,sBAAA,CAAAL,OAAA,gBACA,IAAAO,GAAA,CAAAF,sBAAA,CAAAL,OAAA,QACA,IAAAQ,KAAA,CAAAH,sBAAA,CAAAL,OAAA,UACA,IAAAS,KAAA,CAAAT,OAAA,SA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,CAAA+F,MAAM,CAAG+B,UAAU,CAAC/B,MAAM,EAAI,GAAG,CACvC,GAAIA,MAAM,GAAK,GAAG,CAAEjF,GAAG,CAACiF,MAAM,CAACA,MAAM,CAAC,CAEtC,GAAIH,QAAQ,EAAIG,MAAM,CAAG,GAAG,CAAE,CAC5B;AACA;AACA,KAAM,IAAI,CAAA7E,OAAO,CAAC,CAACgF,IAAI,CAAEC,MAAM,GAAK,CAClC,GAAAuF,oBAAc,EAACpF,IAAI,CAAE,CAACD,KAAK,CAAEP,MAAM,GAAK,CACtC,GAAIO,KAAK,CAAEF,MAAM,CAACE,KAAK,CAAC,CAAC,IACpB,CACHP,MAAM,CAACa,KAAK,CAAG/E,GAAG,CAAC+E,KAAK,CAAE;AAC1BvB,KAAK,CAAC6F,GAAG,CAAC,CAAEnF,MAAM,CAAEC,MAAO,CAAC,CAAEH,QAAQ,CAAC3E,GAAG,CAAC,CAC3CiF,IAAI,CAAC,CACP,CACF,CAAC,CACH,CAAC,CACH,CAEA;AACA;AACA;AACApF,GAAG,CAACmF,IAAI,CAACK,IAAI,CACf,CAAE,MAAOD,KAAK,CAAE,CACdb,IAAI,CAACa,KAAK,CACZ,CACF,CACF"}
1
+ {"version":3,"file":"renderer.js","names":["_fs","_interopRequireDefault","require","_path","_stream","_zlib","_winston","_reactGlobalState","_jsUtils","_lodash","_config","_nodeForge","_server","_reactHelmet","_server2","_serializeJavascript","_buildInfo","_Cache","_jsxRuntime","sanitizedConfig","omit","config","SCRIPT_LOCATIONS","BODY_OPEN","DEFAULT","HEAD_OPEN","exports","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","groupExtraScripts","scripts","script","isString","code","location","undefined","Error","newDefaultLogger","defaultLogLevel","format","transports","winston","createLogger","level","combine","splat","timestamp","colorize","printf","message","stack","rest","Object","keys","stringify","Console","factory","webpackConfig","options","defaults","clone","beforeRender","maxSsrRounds","ssrTimeout","staticCacheSize","logger","defaultLoggerLogLevel","buildInfo","setBuildInfo","publicPath","outputPath","output","manifestLink","existsSync","cache","staticCacheController","Cache","CHUNK_GROUPS","next","set","cookie","csrfToken","cacheRef","data","buffer","status","noCsp","send","done","failed","brotliDecompress","error","html","h","toString","regex","RegExp","nonce","replace","configToInject","extraScripts","initialState","all","helmet","chunkGroups","webpackStats","locals","mapValues","toJson","namedChunkGroups","item","assets","map","name","App","Application","ssrContext","state","cloneDeep","chunks","stream","ssrStart","Date","now","renderPass","pipeableStream","renderToPipeableStream","jsx","GlobalStateProvider","children","StaticRouter","onAllReady","onError","ssrRound","bailed","dirty","timeout","race","allSettled","pending","timer","then","logMsg","log","pipe","Writable","write","chunk","_","Helmet","renderStatic","payload","serializeJs","CONFIG","ISTATE","ignoreFunction","unsafe","update","util","createBuffer","finish","INJ","encode64","chunkSet","Set","forEach","asset","add","styleChunkString","scriptChunkString","endsWith","grouppedExtraScripts","faviconLink","favicon","title","meta","brotliCompress"],"sources":["../../../src/server/renderer.jsx"],"sourcesContent":["/**\n * ExpressJS middleware for server-side rendering of a ReactJS app.\n */\n\nimport fs from 'fs';\nimport path from 'path';\n\nimport { Writable } from 'stream';\nimport { brotliCompress, brotliDecompress } from 'zlib';\nimport winston from 'winston';\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\nimport { timer } from '@dr.pogodin/js-utils';\n\nimport {\n clone,\n cloneDeep,\n defaults,\n isString,\n get,\n mapValues,\n omit,\n} from 'lodash';\n\nimport config from 'config';\nimport forge from 'node-forge';\n\nimport { renderToPipeableStream } from 'react-dom/server';\nimport { Helmet } from 'react-helmet';\nimport { StaticRouter } from 'react-router-dom/server';\nimport serializeJs from 'serialize-javascript';\nimport { setBuildInfo } from 'utils/isomorphy/buildInfo';\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 * Given an array of extra script strings / objects, it returns an object with\n * arrays of scripts to inject in different HTML template locations. During\n * the script groupping it also filters out any empty scripts.\n * @param {({\n * code: string;\n * location: string;\n * }|string)[]} [scripts=[]]\n * @return {{\n * BODY_OPEN: string[];\n * DEFAULT: string[];\n * HEAD_OPEN: string[];\n * }}\n */\nfunction groupExtraScripts(scripts = []) {\n const res = {\n [SCRIPT_LOCATIONS.BODY_OPEN]: '',\n [SCRIPT_LOCATIONS.DEFAULT]: '',\n [SCRIPT_LOCATIONS.HEAD_OPEN]: '',\n };\n for (let i = 0; i < scripts.length; ++i) {\n const script = scripts[i];\n if (isString(script)) {\n if (script) res[SCRIPT_LOCATIONS.DEFAULT] += script;\n } else if (script.code) {\n if (res[script.location] !== undefined) {\n res[script.location] += script.code;\n } else throw Error(`Invalid location \"${script.location}\"`);\n }\n }\n return res;\n}\n\n/**\n * Creates a new default (Winston) logger.\n * @param {object} [options={}]\n * @param {string} [options.defaultLogLevel='info']\n * @return {object}\n */\nexport function newDefaultLogger({\n defaultLogLevel = 'info',\n} = {}) {\n const { format, transports } = winston;\n return winston.createLogger({\n level: defaultLogLevel,\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/**\n * Creates the middleware.\n * @param {object} webpackConfig\n * @param {object} options Additional options:\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 {object} [options.buildInfo] \"Build info\" object to use. If provided,\n * it will be used, instead of trying to load from the filesystem the one\n * generated by the Webpack build. It is intended for test environments,\n * where passing this stuff via file system is no bueno.\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=10] Maximum number of SSR rounds.\n * @param {number} [options.ssrTimeout=1000] SSR timeout in milliseconds,\n * defaults to 1 second.\n * @param {number} [options.staticCacheSize=1.e7] The maximum\n * static cache size in bytes. Defaults to ~10 MB.\n * @param {function} [options.staticCacheController] When given, it activates,\n * and controls the static caching of generated HTML markup. When this function\n * is provided, on each incoming request it is triggered with the request\n * passed in as the argument. To attempt to serve the response from the cache\n * it should return the object with the following fields:\n * - `key: string` &ndash; the cache key for the response;\n * - `maxage?: number` &ndash; the maximum age of cached result in ms.\n * If undefined - infinite age is assumed.\n * @return {function} Created middleware.\n */\nexport default function factory(webpackConfig, options) {\n const ops = defaults(clone(options), {\n beforeRender: () => Promise.resolve({}),\n maxSsrRounds: 10,\n ssrTimeout: 1000,\n staticCacheSize: 1.e7,\n });\n\n // Note: in normal use the default logger is created and set in the root\n // server function, and this initialization is for testing uses, where\n // renderer is imported directly.\n if (ops.logger === undefined) {\n ops.logger = newDefaultLogger({\n defaultLogLevel: ops.defaultLoggerLogLevel,\n });\n }\n\n const buildInfo = ops.buildInfo || getBuildInfo(webpackConfig.context);\n setBuildInfo(buildInfo);\n\n // publicPath from webpack.output has a trailing slash at the end.\n const { publicPath, path: outputPath } = webpackConfig.output;\n\n const manifestLink = fs.existsSync(`${outputPath}/manifest.json`)\n ? `<link rel=\"manifest\" href=\"${publicPath}manifest.json\">` : '';\n\n const cache = ops.staticCacheController\n ? new Cache(ops.staticCacheSize) : null;\n\n const CHUNK_GROUPS = readChunkGroupsJson(outputPath);\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 res.cookie('csrfToken', req.csrfToken());\n\n let cacheRef;\n if (cache) {\n cacheRef = ops.staticCacheController(req);\n if (cacheRef) {\n const data = cache.get(cacheRef);\n if (data !== null) {\n const { buffer, status } = data;\n if (ops.noCsp && isBrotliAcceptable(req)) {\n res.set('Content-Type', 'text/html');\n res.set('Content-Encoding', 'br');\n if (status !== 200) res.status(status);\n res.send(buffer);\n } else {\n await new Promise((done, failed) => {\n brotliDecompress(buffer, (error, html) => {\n if (error) failed(error);\n else {\n let h = html.toString();\n if (!ops.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(buffer.nonce, 'g');\n h = h.replace(regex, req.nonce);\n }\n if (status !== 200) res.status(status);\n res.send(h);\n done();\n }\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 // Gets the mapping between code chunk names and their asset files.\n // These data come from the Webpack compilation, either from the stats\n // attached to the request (in dev mode), or from a file output during\n // the build (in prod mode).\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 /* Optional server-side rendering. */\n let App = ops.Application;\n const ssrContext = {\n req,\n state: cloneDeep(initialState || {}),\n\n // Array of chunk names encountered during the rendering.\n chunks: [],\n\n chunkGroups,\n };\n let stream;\n if (App) {\n const ssrStart = Date.now();\n\n const renderPass = async () => {\n ssrContext.chunks = [];\n return new Promise((resolve, reject) => {\n const pipeableStream = renderToPipeableStream(\n <GlobalStateProvider\n initialState={ssrContext.state}\n ssrContext={ssrContext}\n >\n <StaticRouter location={req.url}>\n <App />\n </StaticRouter>\n </GlobalStateProvider>,\n {\n onAllReady: () => resolve(pipeableStream),\n onError: reject,\n },\n );\n });\n };\n\n let ssrRound = 0;\n let bailed = false;\n for (; ssrRound < ops.maxSsrRounds; ++ssrRound) {\n stream = await renderPass(); // eslint-disable-line no-await-in-loop\n\n if (!ssrContext.dirty) break;\n\n /* eslint-disable no-await-in-loop */\n const timeout = ops.ssrTimeout + ssrStart - Date.now();\n bailed = timeout <= 0 || !await Promise.race([\n Promise.allSettled(ssrContext.pending),\n timer(timeout).then(() => false),\n ]);\n if (bailed) break;\n /* eslint-enable no-await-in-loop */\n }\n\n let logMsg;\n if (ssrContext.dirty) {\n // NOTE: In the case of incomplete SSR one more round is necessary\n // to ensure the correct hydration when some pending promises have\n // resolved and placed their data into the initial global state.\n stream = await renderPass();\n\n logMsg = bailed ? `SSR timed out after ${ops.ssrTimeout} second(s)`\n : `SSR bailed out after ${ops.maxSsrRounds} round(s)`;\n } else logMsg = `SSR completed in ${ssrRound + 1} round(s)`;\n\n ops.logger.log(ssrContext.dirty ? 'warn' : 'info', logMsg);\n\n App = '';\n stream.pipe(new Writable({\n write: (chunk, _, done) => {\n App += chunk.toString();\n done();\n },\n }));\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 /* 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 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 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 const grouppedExtraScripts = groupExtraScripts(extraScripts);\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 ${grouppedExtraScripts[SCRIPT_LOCATIONS.HEAD_OPEN]}\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 <meta itemprop=\"drpruinj\" content=\"${INJ}\">\n </head>\n <body>\n ${grouppedExtraScripts[SCRIPT_LOCATIONS.BODY_OPEN]}\n <div id=\"react-view\">${App || ''}</div>\n ${scriptChunkString}\n ${grouppedExtraScripts[SCRIPT_LOCATIONS.DEFAULT]}\n </body>\n </html>`;\n\n const status = ssrContext.status || 200;\n if (status !== 200) res.status(status);\n\n if (cacheRef && status < 500) {\n // Note: waiting for the caching to complete is not strictly necessary,\n // but it greately simplifies testing, and error reporting.\n await new Promise((done, failed) => {\n brotliCompress(html, (error, buffer) => {\n if (error) failed(error);\n else {\n buffer.nonce = req.nonce; // eslint-disable-line no-param-reassign\n cache.add({ buffer, status }, cacheRef.key);\n done();\n }\n });\n });\n }\n\n // Note: as caching code above may throw in some cases, sending response\n // before it completes will likely hide the error, making it difficult\n // to debug. Thus, at least for now, lets send response after it.\n res.send(html);\n } catch (error) {\n next(error);\n }\n };\n}\n"],"mappings":"ySAIA,IAAAA,GAAA,CAAAC,sBAAA,CAAAC,OAAA,QACA,IAAAC,KAAA,CAAAF,sBAAA,CAAAC,OAAA,UAEA,IAAAE,OAAA,CAAAF,OAAA,WACA,IAAAG,KAAA,CAAAH,OAAA,SACA,IAAAI,QAAA,CAAAL,sBAAA,CAAAC,OAAA,aAEA,IAAAK,iBAAA,CAAAL,OAAA,mCACA,IAAAM,QAAA,CAAAN,OAAA,yBAEA,IAAAO,OAAA,CAAAP,OAAA,WAUA,IAAAQ,OAAA,CAAAT,sBAAA,CAAAC,OAAA,YACA,IAAAS,UAAA,CAAAV,sBAAA,CAAAC,OAAA,gBAEA,IAAAU,OAAA,CAAAV,OAAA,qBACA,IAAAW,YAAA,CAAAX,OAAA,iBACA,IAAAY,QAAA,CAAAZ,OAAA,4BACA,IAAAa,oBAAA,CAAAd,sBAAA,CAAAC,OAAA,0BACA,IAAAc,UAAA,CAAAd,OAAA,wCAEA,IAAAe,MAAA,CAAAhB,sBAAA,CAAAC,OAAA,aAA4B,IAAAgB,WAAA,CAAAhB,OAAA,sBAjC5B;AACA;AACA,GAiCA,KAAM,CAAAiB,eAAe,CAAG,GAAAC,YAAI,EAACC,eAAM,CAAE,QAAQ,CAAC,CAEvC,KAAM,CAAAC,gBAAgB,CAAG,CAC9BC,SAAS,CAAE,WAAW,CACtBC,OAAO,CAAE,SAAS,CAClBC,SAAS,CAAE,WACb,CAAC,CAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GATAC,OAAA,CAAAJ,gBAAA,CAAA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,CACH,CAAC,CACH,CAEA;AACA;AACA;AACApF,GAAG,CAACmF,IAAI,CAACK,IAAI,CACf,CAAE,MAAOD,KAAK,CAAE,CACdb,IAAI,CAACa,KAAK,CACZ,CACF,CACF"}
@@ -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");const defaultTheme={"context":"haRIry","ad":"D4XHG2","hoc":"N3nd34","arrow":"-zPK7Y","container":"_9CQpeA","label":"Gv0kyu","option":"xmsujA","hiddenOption":"RdW3yR","select":"JXK1uw"};/**
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");const 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.
@@ -16,5 +16,9 @@
16
16
  * @param {string} [props.value] Currently selected value.
17
17
  * @param {...any} [props....]
18
18
  * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
19
- */function Dropdown({filter,label,onChange,options,theme,value}){const optionArray=[/*#__PURE__*/(0,_jsxRuntime.jsx)("option",{className:theme.hiddenOption,children:"\u200C"},"__reactUtilsHiddenOption")];for(let i=0;i<options.length;++i){let op=options[i];if(!filter||filter(op)){if((0,_lodash.isString)(op))op={value:op};optionArray.push(/*#__PURE__*/(0,_jsxRuntime.jsx)("option",{className:theme.option,value:op.value,children:op.name===undefined?op.value:op.name},op.value))}}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)("select",{className:theme.select,onChange:onChange,value:value,children:optionArray}),/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:theme.arrow,children:"\u25BC"})]})}const ThemedDropdown=(0,_utils.themed)("Dropdown",["arrow","container","hiddenOption","label","option","select"],defaultTheme)(Dropdown);Dropdown.propTypes={filter:_propTypes.default.func,label:_propTypes.default.string,onChange:_propTypes.default.func,options:_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.shape({name:_propTypes.default.node,value:_propTypes.default.string.isRequired}),_propTypes.default.string]).isRequired),theme:ThemedDropdown.themeType.isRequired,value:_propTypes.default.string};Dropdown.defaultProps={filter:undefined,label:undefined,onChange:undefined,options:[],value:undefined};var _default=ThemedDropdown;exports.default=_default;
19
+ */function Dropdown({filter,label,onChange,options,theme,value}){let isValidValue=false;const optionElements=[];for(let i=0;i<options.length;++i){const option=options[i];if(!filter||filter(option)){const optionValue=typeof option==="string"?option:option.value;const optionName=option.name===undefined?optionValue:option.name;isValidValue||=optionValue===value;optionElements.push(/*#__PURE__*/(0,_jsxRuntime.jsx)("option",{className:theme.option,value:optionValue,children:optionName},optionValue))}}// NOTE: This element represents the current `value` when it does not match
20
+ // any valid option. In Chrome, and some other browsers, we are able to hide
21
+ // it from the opened dropdown; in others, e.g. Safari, the best we can do is
22
+ // to show it as disabled.
23
+ const hiddenOption=isValidValue?null:/*#__PURE__*/(0,_jsxRuntime.jsx)("option",{disabled:true,className:theme.hiddenOption,value:value,children:value},"__reactUtilsHiddenOption");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.jsxs)("select",{className:theme.select,onChange:onChange,value:value,children:[hiddenOption,optionElements]}),/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:theme.arrow,children:"\u25BC"})]})}const ThemedDropdown=(0,_utils.themed)("Dropdown",["arrow","container","hiddenOption","label","option","select"],defaultTheme)(Dropdown);Dropdown.propTypes={filter:_propTypes.default.func,label:_propTypes.default.string,onChange:_propTypes.default.func,options:_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.shape({name:_propTypes.default.node,value:_propTypes.default.string.isRequired}),_propTypes.default.string]).isRequired),theme:ThemedDropdown.themeType.isRequired,value:_propTypes.default.string};Dropdown.defaultProps={filter:undefined,label:undefined,onChange:undefined,options:[],value:""};var _default=ThemedDropdown;exports.default=_default;
20
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_lodash","require","_propTypes","_interopRequireDefault","_utils","_jsxRuntime","defaultTheme","Dropdown","filter","label","onChange","options","theme","value","optionArray","jsx","className","hiddenOption","children","i","length","op","isString","push","option","name","undefined","jsxs","container","select","arrow","ThemedDropdown","themed","propTypes","PT","func","string","arrayOf","oneOfType","shape","node","isRequired","themeType","defaultProps","_default","exports","default"],"sources":["../../../../../src/shared/components/Dropdown/index.jsx"],"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 &zwnj;\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"],"mappings":"gLAAA,IAAAA,OAAA,CAAAC,OAAA,WACA,IAAAC,UAAA,CAAAC,sBAAA,CAAAF,OAAA,gBAEA,IAAAG,MAAA,CAAAH,OAAA,gBAA+B,IAAAI,WAAA,CAAAJ,OAAA,4BAAAK,YAAA,uKAI/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAC,QAAQA,CAAC,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,WAAW,CACN,CAAC,cACT,GAAAT,WAAA,CAAAU,GAAA,SAAKC,SAAS,CAAEJ,KAAK,CAACkB,KAAM,CAAAZ,QAAA,CAAC,QAAC,CAAK,CAAC,EACjC,CAET,CAEA,KAAM,CAAAa,cAAc,CAAG,GAAAC,aAAM,EAAC,UAAU,CAAE,CACxC,OAAO,CACP,WAAW,CACX,cAAc,CACd,OAAO,CACP,QAAQ,CACR,QAAQ,CACT,CAAE1B,YAAY,CAAC,CAACC,QAAQ,CAAC,CAE1BA,QAAQ,CAAC0B,SAAS,CAAG,CACnBzB,MAAM,CAAE0B,kBAAE,CAACC,IAAI,CACf1B,KAAK,CAAEyB,kBAAE,CAACE,MAAM,CAChB1B,QAAQ,CAAEwB,kBAAE,CAACC,IAAI,CACjBxB,OAAO,CAAEuB,kBAAE,CAACG,OAAO,CACjBH,kBAAE,CAACI,SAAS,CAAC,CACXJ,kBAAE,CAACK,KAAK,CAAC,CACPd,IAAI,CAAES,kBAAE,CAACM,IAAI,CACb3B,KAAK,CAAEqB,kBAAE,CAACE,MAAM,CAACK,UACnB,CAAC,CAAC,CACFP,kBAAE,CAACE,MAAM,CACV,CAAC,CAACK,UACL,CAAC,CACD7B,KAAK,CAAEmB,cAAc,CAACW,SAAS,CAACD,UAAU,CAC1C5B,KAAK,CAAEqB,kBAAE,CAACE,MACZ,CAAC,CAED7B,QAAQ,CAACoC,YAAY,CAAG,CACtBnC,MAAM,CAAEkB,SAAS,CACjBjB,KAAK,CAAEiB,SAAS,CAChBhB,QAAQ,CAAEgB,SAAS,CACnBf,OAAO,CAAE,EAAE,CACXE,KAAK,CAAEa,SACT,CAAC,CAAC,IAAAkB,QAAA,CAEab,cAAc,CAAAc,OAAA,CAAAC,OAAA,CAAAF,QAAA"}
1
+ {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_utils","_jsxRuntime","defaultTheme","Dropdown","filter","label","onChange","options","theme","value","isValidValue","optionElements","i","length","option","optionValue","optionName","name","undefined","push","jsx","className","children","hiddenOption","disabled","jsxs","container","select","arrow","ThemedDropdown","themed","propTypes","PT","func","string","arrayOf","oneOfType","shape","node","isRequired","themeType","defaultProps","_default","exports","default"],"sources":["../../../../../src/shared/components/Dropdown/index.jsx"],"sourcesContent":["import 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 let isValidValue = false;\n const optionElements = [];\n\n for (let i = 0; i < options.length; ++i) {\n const option = options[i];\n if (!filter || filter(option)) {\n const optionValue = typeof option === 'string' ? option : option.value;\n const optionName = option.name === undefined ? optionValue : option.name;\n isValidValue ||= optionValue === value;\n optionElements.push(\n <option className={theme.option} key={optionValue} value={optionValue}>\n {optionName}\n </option>,\n );\n }\n }\n\n // NOTE: This element represents the current `value` when it does not match\n // any valid option. In Chrome, and some other browsers, we are able to hide\n // it from the opened dropdown; in others, e.g. Safari, the best we can do is\n // to show it as disabled.\n const hiddenOption = isValidValue ? null : (\n <option\n disabled\n className={theme.hiddenOption}\n key=\"__reactUtilsHiddenOption\"\n value={value}\n >\n {value}\n </option>\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 {hiddenOption}\n {optionElements}\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: '',\n};\n\nexport default ThemedDropdown;\n"],"mappings":"gLAAA,IAAAA,UAAA,CAAAC,sBAAA,CAAAC,OAAA,gBAEA,IAAAC,MAAA,CAAAD,OAAA,gBAA+B,IAAAE,WAAA,CAAAF,OAAA,4BAAAG,YAAA,uKAI/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAC,QAAQA,CAAC,CAChBC,MAAM,CACNC,KAAK,CACLC,QAAQ,CACRC,OAAO,CACPC,KAAK,CACLC,KACF,CAAC,CAAE,CACD,GAAI,CAAAC,YAAY,CAAG,KAAK,CACxB,KAAM,CAAAC,cAAc,CAAG,EAAE,CAEzB,IAAK,GAAI,CAAAC,CAAC,CAAG,CAAC,CAAEA,CAAC,CAAGL,OAAO,CAACM,MAAM,CAAE,EAAED,CAAC,CAAE,CACvC,KAAM,CAAAE,MAAM,CAAGP,OAAO,CAACK,CAAC,CAAC,CACzB,GAAI,CAACR,MAAM,EAAIA,MAAM,CAACU,MAAM,CAAC,CAAE,CAC7B,KAAM,CAAAC,WAAW,CAAG,MAAO,CAAAD,MAAM,GAAK,QAAQ,CAAGA,MAAM,CAAGA,MAAM,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,CACR,QAAQ,CACT,CAAE5B,YAAY,CAAC,CAACC,QAAQ,CAAC,CAE1BA,QAAQ,CAAC4B,SAAS,CAAG,CACnB3B,MAAM,CAAE4B,kBAAE,CAACC,IAAI,CACf5B,KAAK,CAAE2B,kBAAE,CAACE,MAAM,CAChB5B,QAAQ,CAAE0B,kBAAE,CAACC,IAAI,CACjB1B,OAAO,CAAEyB,kBAAE,CAACG,OAAO,CACjBH,kBAAE,CAACI,SAAS,CAAC,CACXJ,kBAAE,CAACK,KAAK,CAAC,CACPpB,IAAI,CAAEe,kBAAE,CAACM,IAAI,CACb7B,KAAK,CAAEuB,kBAAE,CAACE,MAAM,CAACK,UACnB,CAAC,CAAC,CACFP,kBAAE,CAACE,MAAM,CACV,CAAC,CAACK,UACL,CAAC,CACD/B,KAAK,CAAEqB,cAAc,CAACW,SAAS,CAACD,UAAU,CAC1C9B,KAAK,CAAEuB,kBAAE,CAACE,MACZ,CAAC,CAED/B,QAAQ,CAACsC,YAAY,CAAG,CACtBrC,MAAM,CAAEc,SAAS,CACjBb,KAAK,CAAEa,SAAS,CAChBZ,QAAQ,CAAEY,SAAS,CACnBX,OAAO,CAAE,EAAE,CACXE,KAAK,CAAE,EACT,CAAC,CAAC,IAAAiC,QAAA,CAEab,cAAc,CAAAc,OAAA,CAAAC,OAAA,CAAAF,QAAA"}
@@ -22,7 +22,7 @@
22
22
  * Calculates the document viewport size.
23
23
  * @ignore
24
24
  * @return {{x, y, width, height}}
25
- */function calcViewportRect(){const{pageXOffset,pageYOffset}=window;const{documentElement:{clientHeight,clientWidth}}=document;return{left:pageXOffset,right:pageXOffset+clientWidth,top:pageYOffset,bottom:pageYOffset+clientHeight}}/**
25
+ */function calcViewportRect(){const{scrollX,scrollY}=window;const{documentElement:{clientHeight,clientWidth}}=document;return{left:scrollX,right:scrollX+clientWidth,top:scrollY,bottom:scrollY+clientHeight}}/**
26
26
  * Calculates tooltip and arrow positions for the placement just above
27
27
  * the cursor.
28
28
  * @ignore
@@ -96,5 +96,16 @@ function xPageFitCorrection(x, y, pos, pageXOffset, pageXWidth) {
96
96
  * @param {object} tooltip
97
97
  * @param {object} tooltip.arrow DOM reference to the tooltip arrow.
98
98
  * @param {object} tooltip.container DOM reference to the tooltip container.
99
- */function setComponentPositions(pageX,pageY,placement,element,tooltip){const tooltipRects=calcTooltipRects(tooltip);const viewportRect=calcViewportRect();/* Default container coords: tooltip at the top. */const pos=calcPositionAboveXY(pageX,pageY,tooltipRects);if(pos.containerX<viewportRect.left+6){pos.containerX=viewportRect.left+6;pos.arrowX=Math.max(6,pageX-pos.containerX-tooltipRects.arrow.width/2)}else{const maxX=viewportRect.right-6-tooltipRects.container.width;if(pos.containerX>maxX){pos.containerX=maxX;pos.arrowX=Math.min(tooltipRects.container.width-6,pageX-pos.containerX-tooltipRects.arrow.width/2)}}/* If tooltip has not enough space on top - make it bottom tooltip. */if(pos.containerY<viewportRect.top+6){pos.containerY+=tooltipRects.container.height+2*tooltipRects.arrow.height;pos.arrowY-=tooltipRects.container.height+tooltipRects.arrow.height;pos.baseArrowStyle=ARROW_STYLE_UP}const containerStyle=`left:${pos.containerX}px;top:${pos.containerY}px`;tooltip.container.setAttribute("style",containerStyle);const arrowStyle=`${pos.baseArrowStyle};left:${pos.arrowX}px;top:${pos.arrowY}px`;tooltip.arrow.setAttribute("style",arrowStyle)}/* The Tooltip component itself. */const Tooltip=/*#__PURE__*/(0,_react.forwardRef)(({children,theme},ref)=>{const[components,setComponents]=(0,_react.useState)(null);const pointTo=(pageX,pageY,placement,element)=>components&&setComponentPositions(pageX,pageY,placement,element,components);(0,_react.useImperativeHandle)(ref,()=>({pointTo}));/* Inits and destroys tooltip components. */(0,_react.useEffect)(()=>{const x=createTooltipComponents(theme);setComponents(x);return()=>{document.body.removeChild(x.container);setComponents(null)}},[theme]);return components?/*#__PURE__*/(0,_reactDom.createPortal)(children,components.content):null});Tooltip.propTypes={children:_propTypes.default.node,theme:_propTypes.default.shape().isRequired};Tooltip.defaultProps={children:null};var _default=Tooltip;exports.default=_default;
99
+ */function setComponentPositions(pageX,pageY,placement,element,tooltip){const tooltipRects=calcTooltipRects(tooltip);const viewportRect=calcViewportRect();/* Default container coords: tooltip at the top. */const pos=calcPositionAboveXY(pageX,pageY,tooltipRects);if(pos.containerX<viewportRect.left+6){pos.containerX=viewportRect.left+6;pos.arrowX=Math.max(6,pageX-pos.containerX-tooltipRects.arrow.width/2)}else{const maxX=viewportRect.right-6-tooltipRects.container.width;if(pos.containerX>maxX){pos.containerX=maxX;pos.arrowX=Math.min(tooltipRects.container.width-6,pageX-pos.containerX-tooltipRects.arrow.width/2)}}/* If tooltip has not enough space on top - make it bottom tooltip. */if(pos.containerY<viewportRect.top+6){pos.containerY+=tooltipRects.container.height+2*tooltipRects.arrow.height;pos.arrowY-=tooltipRects.container.height+tooltipRects.arrow.height;pos.baseArrowStyle=ARROW_STYLE_UP}const containerStyle=`left:${pos.containerX}px;top:${pos.containerY}px`;tooltip.container.setAttribute("style",containerStyle);const arrowStyle=`${pos.baseArrowStyle};left:${pos.arrowX}px;top:${pos.arrowY}px`;tooltip.arrow.setAttribute("style",arrowStyle)}/* The Tooltip component itself. */const Tooltip=/*#__PURE__*/(0,_react.forwardRef)(({children,theme},ref)=>{// NOTE: The way it has to be implemented, for clean mounting and unmounting
100
+ // at the client side, the <Tooltip> is fully mounted into DOM in the next
101
+ // rendering cycles, and only then it can be correctly measured and positioned.
102
+ // Thus, when we create the <Tooltip> we have to record its target positioning
103
+ // details, and then apply them when it is created.
104
+ const{current:heap}=(0,_react.useRef)({lastElement:undefined,lastPageX:0,lastPageY:0,lastPlacement:undefined});const[components,setComponents]=(0,_react.useState)(null);const pointTo=(pageX,pageY,placement,element)=>{heap.lastElement=element;heap.lastPageX=pageX;heap.lastPageY=pageY;heap.lastPlacement=placement;if(components){setComponentPositions(pageX,pageY,placement,element,components)}};(0,_react.useImperativeHandle)(ref,()=>({pointTo}));/* Inits and destroys tooltip components. */(0,_react.useEffect)(()=>{const x=createTooltipComponents(theme);setComponents(x);return()=>{document.body.removeChild(x.container);setComponents(null)}},[theme]);(0,_react.useEffect)(()=>{if(components){setComponentPositions(heap.lastPageX,heap.lastPageY,heap.lastPlacement,heap.lastElement,components)}},[components,// BEWARE: Careful about these dependencies - they are updated when mouse
105
+ // is moved over the tool-tipped element, thus potentially may cause
106
+ // unnecessary firing of this effect on each mouse event. It does not
107
+ // happen now just because the mouse movements themselves are not causing
108
+ // the component re-rendering, thus dependencies of this effect are not
109
+ // really re-evaluated.
110
+ heap.lastPageX,heap.lastPageY,heap.lastPlacement,heap.lastElement]);return components?/*#__PURE__*/(0,_reactDom.createPortal)(children,components.content):null});Tooltip.propTypes={children:_propTypes.default.node,theme:_propTypes.default.shape().isRequired};Tooltip.defaultProps={children:null};var _default=Tooltip;exports.default=_default;
100
111
  //# sourceMappingURL=Tooltip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","names":["_react","require","_reactDom","_propTypes","_interopRequireDefault","PLACEMENTS","ABOVE_CURSOR","ABOVE_ELEMENT","BELOW_CURSOR","BELOW_ELEMENT","exports","ARROW_STYLE_DOWN","join","ARROW_STYLE_UP","createTooltipComponents","theme","arrow","document","createElement","setAttribute","content","container","appendChild","body","calcTooltipRects","tooltip","getBoundingClientRect","calcViewportRect","pageXOffset","pageYOffset","window","documentElement","clientHeight","clientWidth","left","right","top","bottom","calcPositionAboveXY","x","y","tooltipRects","arrowX","width","arrowY","height","containerX","containerY","baseArrowStyle","setComponentPositions","pageX","pageY","placement","element","viewportRect","pos","Math","max","maxX","min","containerStyle","arrowStyle","Tooltip","forwardRef","children","ref","components","setComponents","useState","pointTo","useImperativeHandle","useEffect","removeChild","createPortal","propTypes","PT","node","shape","isRequired","defaultProps","_default","default"],"sources":["../../../../../src/shared/components/WithTooltip/Tooltip.jsx"],"sourcesContent":["/**\n * The actual tooltip component. It is rendered outside the regular document\n * hierarchy, and with sub-components managed without React to achieve the best\n * performance during animation.\n */\n/* global document, window */\n\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport PT from 'prop-types';\n\n/* Valid placements of the rendered tooltip. They will be overriden when\n * necessary to fit the tooltip within the viewport. */\nexport const PLACEMENTS = {\n ABOVE_CURSOR: 'ABOVE_CURSOR',\n ABOVE_ELEMENT: 'ABOVE_ELEMENT',\n BELOW_CURSOR: 'BELOW_CURSOR',\n BELOW_ELEMENT: 'BELOW_ELEMENT',\n};\n\nconst ARROW_STYLE_DOWN = [\n 'border-bottom-color:transparent',\n 'border-left-color:transparent',\n 'border-right-color:transparent',\n].join(';');\n\nconst ARROW_STYLE_UP = [\n 'border-top-color:transparent',\n 'border-left-color:transparent',\n 'border-right-color:transparent',\n].join(';');\n\n/**\n * Creates tooltip components.\n * @ignore\n * @param {object} theme Themes to use for tooltip container, arrow,\n * and content.\n * @return {object} Object with DOM references to the container components:\n * container, arrow, content.\n */\nfunction createTooltipComponents(theme) {\n const arrow = document.createElement('div');\n if (theme.arrow) arrow.setAttribute('class', theme.arrow);\n\n const content = document.createElement('div');\n if (theme.content) content.setAttribute('class', theme.content);\n\n const container = document.createElement('div');\n if (theme.container) container.setAttribute('class', theme.container);\n\n container.appendChild(arrow);\n container.appendChild(content);\n document.body.appendChild(container);\n\n return { container, arrow, content };\n}\n\n/**\n * Generates bounding client rectangles for tooltip components.\n * @ignore\n * @param {object} tooltip DOM references to the tooltip components.\n * @param {object} tooltip.arrow\n * @param {object} tooltip.container\n * @return {{ arrow: object, container}} Object holding tooltip rectangles in\n * two fields.\n */\nfunction calcTooltipRects(tooltip) {\n return {\n arrow: tooltip.arrow.getBoundingClientRect(),\n container: tooltip.container.getBoundingClientRect(),\n };\n}\n\n/**\n * Calculates the document viewport size.\n * @ignore\n * @return {{x, y, width, height}}\n */\nfunction calcViewportRect() {\n const { pageXOffset, pageYOffset } = window;\n const { documentElement: { clientHeight, clientWidth } } = document;\n return {\n left: pageXOffset,\n right: pageXOffset + clientWidth,\n top: pageYOffset,\n bottom: pageYOffset + clientHeight,\n };\n}\n\n/**\n * Calculates tooltip and arrow positions for the placement just above\n * the cursor.\n * @ignore\n * @param {number} x Cursor page-x position.\n * @param {number} y Cursor page-y position.\n * @param {object} tooltipRects Bounding client rectangles of tooltip parts.\n * @param {object} tooltipRects.arrow\n * @param {object} tooltipRects.container\n * @return {object} Contains the following fields:\n * - {number} arrowX\n * - {number} arrowY\n * - {number} containerX\n * - {number} containerY\n * - {string} baseArrowStyle\n */\nfunction calcPositionAboveXY(x, y, tooltipRects) {\n const { arrow, container } = tooltipRects;\n return {\n arrowX: 0.5 * (container.width - arrow.width),\n arrowY: container.height,\n containerX: x - container.width / 2,\n containerY: y - container.height - arrow.height / 1.5,\n\n // TODO: Instead of already setting the base style here, we should\n // introduce a set of constants for arrow directions, which will help\n // to do checks dependant on the arrow direction.\n baseArrowStyle: ARROW_STYLE_DOWN,\n };\n}\n\n/*\nconst HIT = {\n NONE: false,\n LEFT: 'LEFT',\n RIGHT: 'RIGHT',\n TOP: 'TOP',\n BOTTOM: 'BOTTOM',\n};\n*/\n\n/**\n * Checks whether\n * @param {object} pos\n * @param {object} tooltipRects\n * @param {object} viewportRect\n * @return {HIT}\n */\n/*\nfunction checkViewportFit(pos, tooltipRects, viewportRect) {\n const { containerX, containerY } = pos;\n if (containerX < viewportRect.left + 6) return HIT.LEFT;\n if (containerX > viewportRect.right - 6) return HIT.RIGHT;\n return HIT.NONE;\n}\n*/\n\n/**\n * Shifts tooltip horizontally to fit into the viewport, while keeping\n * the arrow pointed to the XY point.\n * @param {number} x\n * @param {number} y\n * @param {object} pos\n * @param {number} pageXOffset\n * @param {number} pageXWidth\n */\n/*\nfunction xPageFitCorrection(x, y, pos, pageXOffset, pageXWidth) {\n if (pos.containerX < pageXOffset + 6) {\n pos.containerX = pageXOffset + 6;\n pos.arrowX = Math.max(6, pageX - containerX - arrowRect.width / 2);\n } else {\n const maxX = pageXOffset + docRect.width - containerRect.width - 6;\n if (containerX > maxX) {\n containerX = maxX;\n arrowX = Math.min(\n containerRect.width - 6,\n pageX - containerX - arrowRect.width / 2,\n );\n }\n }\n}\n*/\n\n/**\n * Sets positions of tooltip components to point the tooltip to the specified\n * page point.\n * @ignore\n * @param {number} pageX\n * @param {number} pageY\n * @param {PLACEMENTS} placement\n * @param {object} element DOM reference to the element wrapped by the tooltip.\n * @param {object} tooltip\n * @param {object} tooltip.arrow DOM reference to the tooltip arrow.\n * @param {object} tooltip.container DOM reference to the tooltip container.\n */\nfunction setComponentPositions(\n pageX,\n pageY,\n placement,\n element,\n tooltip,\n) {\n const tooltipRects = calcTooltipRects(tooltip);\n const viewportRect = calcViewportRect();\n\n /* Default container coords: tooltip at the top. */\n const pos = calcPositionAboveXY(pageX, pageY, tooltipRects);\n\n if (pos.containerX < viewportRect.left + 6) {\n pos.containerX = viewportRect.left + 6;\n pos.arrowX = Math.max(\n 6,\n pageX - pos.containerX - tooltipRects.arrow.width / 2,\n );\n } else {\n const maxX = viewportRect.right - 6 - tooltipRects.container.width;\n if (pos.containerX > maxX) {\n pos.containerX = maxX;\n pos.arrowX = Math.min(\n tooltipRects.container.width - 6,\n pageX - pos.containerX - tooltipRects.arrow.width / 2,\n );\n }\n }\n\n /* If tooltip has not enough space on top - make it bottom tooltip. */\n if (pos.containerY < viewportRect.top + 6) {\n pos.containerY += tooltipRects.container.height\n + 2 * tooltipRects.arrow.height;\n pos.arrowY -= tooltipRects.container.height\n + tooltipRects.arrow.height;\n pos.baseArrowStyle = ARROW_STYLE_UP;\n }\n\n const containerStyle = `left:${pos.containerX}px;top:${pos.containerY}px`;\n tooltip.container.setAttribute('style', containerStyle);\n\n const arrowStyle = `${pos.baseArrowStyle};left:${pos.arrowX}px;top:${pos.arrowY}px`;\n tooltip.arrow.setAttribute('style', arrowStyle);\n}\n\n/* The Tooltip component itself. */\nconst Tooltip = forwardRef(({ children, theme }, ref) => {\n const [components, setComponents] = useState(null);\n\n const pointTo = (pageX, pageY, placement, element) => components\n && setComponentPositions(pageX, pageY, placement, element, components);\n useImperativeHandle(ref, () => ({ pointTo }));\n\n /* Inits and destroys tooltip components. */\n useEffect(() => {\n const x = createTooltipComponents(theme);\n setComponents(x);\n return () => {\n document.body.removeChild(x.container);\n setComponents(null);\n };\n }, [theme]);\n\n return components ? createPortal(children, components.content) : null;\n});\n\nTooltip.propTypes = {\n children: PT.node,\n theme: PT.shape().isRequired,\n};\n\nTooltip.defaultProps = {\n children: null,\n};\n\nexport default Tooltip;\n"],"mappings":"mMAOA,IAAAA,MAAA,CAAAC,OAAA,UAMA,IAAAC,SAAA,CAAAD,OAAA,cAEA,IAAAE,UAAA,CAAAC,sBAAA,CAAAH,OAAA,gBAfA;AACA;AACA;AACA;AACA,GAJA,CAKA,8BAYA;AACA,uDACO,KAAM,CAAAI,UAAU,CAAG,CACxBC,YAAY,CAAE,cAAc,CAC5BC,aAAa,CAAE,eAAe,CAC9BC,YAAY,CAAE,cAAc,CAC5BC,aAAa,CAAE,eACjB,CAAC,CAACC,OAAA,CAAAL,UAAA,CAAAA,UAAA,CAEF,KAAM,CAAAM,gBAAgB,CAAG,CACvB,iCAAiC,CACjC,+BAA+B,CAC/B,gCAAgC,CACjC,CAACC,IAAI,CAAC,GAAG,CAAC,CAEX,KAAM,CAAAC,cAAc,CAAG,CACrB,8BAA8B,CAC9B,+BAA+B,CAC/B,gCAAgC,CACjC,CAACD,IAAI,CAAC,GAAG,CAAC,CAEX;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAE,uBAAuBA,CAACC,KAAK,CAAE,CACtC,KAAM,CAAAC,KAAK,CAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC,CAC3C,GAAIH,KAAK,CAACC,KAAK,CAAEA,KAAK,CAACG,YAAY,CAAC,OAAO,CAAEJ,KAAK,CAACC,KAAK,CAAC,CAEzD,KAAM,CAAAI,OAAO,CAAGH,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC,CAC7C,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","ABOVE_CURSOR","ABOVE_ELEMENT","BELOW_CURSOR","BELOW_ELEMENT","exports","ARROW_STYLE_DOWN","join","ARROW_STYLE_UP","createTooltipComponents","theme","arrow","document","createElement","setAttribute","content","container","appendChild","body","calcTooltipRects","tooltip","getBoundingClientRect","calcViewportRect","scrollX","scrollY","window","documentElement","clientHeight","clientWidth","left","right","top","bottom","calcPositionAboveXY","x","y","tooltipRects","arrowX","width","arrowY","height","containerX","containerY","baseArrowStyle","setComponentPositions","pageX","pageY","placement","element","viewportRect","pos","Math","max","maxX","min","containerStyle","arrowStyle","Tooltip","forwardRef","children","ref","current","heap","useRef","lastElement","undefined","lastPageX","lastPageY","lastPlacement","components","setComponents","useState","pointTo","useImperativeHandle","useEffect","removeChild","createPortal","propTypes","PT","node","shape","isRequired","defaultProps","_default","default"],"sources":["../../../../../src/shared/components/WithTooltip/Tooltip.jsx"],"sourcesContent":["/**\n * The actual tooltip component. It is rendered outside the regular document\n * hierarchy, and with sub-components managed without React to achieve the best\n * performance during animation.\n */\n/* global document, window */\n\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport PT from 'prop-types';\n\n/* Valid placements of the rendered tooltip. They will be overriden when\n * necessary to fit the tooltip within the viewport. */\nexport const PLACEMENTS = {\n ABOVE_CURSOR: 'ABOVE_CURSOR',\n ABOVE_ELEMENT: 'ABOVE_ELEMENT',\n BELOW_CURSOR: 'BELOW_CURSOR',\n BELOW_ELEMENT: 'BELOW_ELEMENT',\n};\n\nconst ARROW_STYLE_DOWN = [\n 'border-bottom-color:transparent',\n 'border-left-color:transparent',\n 'border-right-color:transparent',\n].join(';');\n\nconst ARROW_STYLE_UP = [\n 'border-top-color:transparent',\n 'border-left-color:transparent',\n 'border-right-color:transparent',\n].join(';');\n\n/**\n * Creates tooltip components.\n * @ignore\n * @param {object} theme Themes to use for tooltip container, arrow,\n * and content.\n * @return {object} Object with DOM references to the container components:\n * container, arrow, content.\n */\nfunction createTooltipComponents(theme) {\n const arrow = document.createElement('div');\n if (theme.arrow) arrow.setAttribute('class', theme.arrow);\n\n const content = document.createElement('div');\n if (theme.content) content.setAttribute('class', theme.content);\n\n const container = document.createElement('div');\n if (theme.container) container.setAttribute('class', theme.container);\n\n container.appendChild(arrow);\n container.appendChild(content);\n document.body.appendChild(container);\n\n return { container, arrow, content };\n}\n\n/**\n * Generates bounding client rectangles for tooltip components.\n * @ignore\n * @param {object} tooltip DOM references to the tooltip components.\n * @param {object} tooltip.arrow\n * @param {object} tooltip.container\n * @return {{ arrow: object, container}} Object holding tooltip rectangles in\n * two fields.\n */\nfunction calcTooltipRects(tooltip) {\n return {\n arrow: tooltip.arrow.getBoundingClientRect(),\n container: tooltip.container.getBoundingClientRect(),\n };\n}\n\n/**\n * Calculates the document viewport size.\n * @ignore\n * @return {{x, y, width, height}}\n */\nfunction calcViewportRect() {\n const { scrollX, scrollY } = window;\n const { documentElement: { clientHeight, clientWidth } } = document;\n return {\n left: scrollX,\n right: scrollX + clientWidth,\n top: scrollY,\n bottom: scrollY + clientHeight,\n };\n}\n\n/**\n * Calculates tooltip and arrow positions for the placement just above\n * the cursor.\n * @ignore\n * @param {number} x Cursor page-x position.\n * @param {number} y Cursor page-y position.\n * @param {object} tooltipRects Bounding client rectangles of tooltip parts.\n * @param {object} tooltipRects.arrow\n * @param {object} tooltipRects.container\n * @return {object} Contains the following fields:\n * - {number} arrowX\n * - {number} arrowY\n * - {number} containerX\n * - {number} containerY\n * - {string} baseArrowStyle\n */\nfunction calcPositionAboveXY(x, y, tooltipRects) {\n const { arrow, container } = tooltipRects;\n return {\n arrowX: 0.5 * (container.width - arrow.width),\n arrowY: container.height,\n containerX: x - container.width / 2,\n containerY: y - container.height - arrow.height / 1.5,\n\n // TODO: Instead of already setting the base style here, we should\n // introduce a set of constants for arrow directions, which will help\n // to do checks dependant on the arrow direction.\n baseArrowStyle: ARROW_STYLE_DOWN,\n };\n}\n\n/*\nconst HIT = {\n NONE: false,\n LEFT: 'LEFT',\n RIGHT: 'RIGHT',\n TOP: 'TOP',\n BOTTOM: 'BOTTOM',\n};\n*/\n\n/**\n * Checks whether\n * @param {object} pos\n * @param {object} tooltipRects\n * @param {object} viewportRect\n * @return {HIT}\n */\n/*\nfunction checkViewportFit(pos, tooltipRects, viewportRect) {\n const { containerX, containerY } = pos;\n if (containerX < viewportRect.left + 6) return HIT.LEFT;\n if (containerX > viewportRect.right - 6) return HIT.RIGHT;\n return HIT.NONE;\n}\n*/\n\n/**\n * Shifts tooltip horizontally to fit into the viewport, while keeping\n * the arrow pointed to the XY point.\n * @param {number} x\n * @param {number} y\n * @param {object} pos\n * @param {number} pageXOffset\n * @param {number} pageXWidth\n */\n/*\nfunction xPageFitCorrection(x, y, pos, pageXOffset, pageXWidth) {\n if (pos.containerX < pageXOffset + 6) {\n pos.containerX = pageXOffset + 6;\n pos.arrowX = Math.max(6, pageX - containerX - arrowRect.width / 2);\n } else {\n const maxX = pageXOffset + docRect.width - containerRect.width - 6;\n if (containerX > maxX) {\n containerX = maxX;\n arrowX = Math.min(\n containerRect.width - 6,\n pageX - containerX - arrowRect.width / 2,\n );\n }\n }\n}\n*/\n\n/**\n * Sets positions of tooltip components to point the tooltip to the specified\n * page point.\n * @ignore\n * @param {number} pageX\n * @param {number} pageY\n * @param {PLACEMENTS} placement\n * @param {object} element DOM reference to the element wrapped by the tooltip.\n * @param {object} tooltip\n * @param {object} tooltip.arrow DOM reference to the tooltip arrow.\n * @param {object} tooltip.container DOM reference to the tooltip container.\n */\nfunction setComponentPositions(\n pageX,\n pageY,\n placement,\n element,\n tooltip,\n) {\n const tooltipRects = calcTooltipRects(tooltip);\n const viewportRect = calcViewportRect();\n\n /* Default container coords: tooltip at the top. */\n const pos = calcPositionAboveXY(pageX, pageY, tooltipRects);\n\n if (pos.containerX < viewportRect.left + 6) {\n pos.containerX = viewportRect.left + 6;\n pos.arrowX = Math.max(\n 6,\n pageX - pos.containerX - tooltipRects.arrow.width / 2,\n );\n } else {\n const maxX = viewportRect.right - 6 - tooltipRects.container.width;\n if (pos.containerX > maxX) {\n pos.containerX = maxX;\n pos.arrowX = Math.min(\n tooltipRects.container.width - 6,\n pageX - pos.containerX - tooltipRects.arrow.width / 2,\n );\n }\n }\n\n /* If tooltip has not enough space on top - make it bottom tooltip. */\n if (pos.containerY < viewportRect.top + 6) {\n pos.containerY += tooltipRects.container.height\n + 2 * tooltipRects.arrow.height;\n pos.arrowY -= tooltipRects.container.height\n + tooltipRects.arrow.height;\n pos.baseArrowStyle = ARROW_STYLE_UP;\n }\n\n const containerStyle = `left:${pos.containerX}px;top:${pos.containerY}px`;\n tooltip.container.setAttribute('style', containerStyle);\n\n const arrowStyle = `${pos.baseArrowStyle};left:${pos.arrowX}px;top:${pos.arrowY}px`;\n tooltip.arrow.setAttribute('style', arrowStyle);\n}\n\n/* The Tooltip component itself. */\nconst Tooltip = forwardRef(({ children, theme }, ref) => {\n // NOTE: The way it has to be implemented, for clean mounting and unmounting\n // at the client side, the <Tooltip> is fully mounted into DOM in the next\n // rendering cycles, and only then it can be correctly measured and positioned.\n // Thus, when we create the <Tooltip> we have to record its target positioning\n // details, and then apply them when it is created.\n\n const { current: heap } = useRef({\n lastElement: undefined,\n lastPageX: 0,\n lastPageY: 0,\n lastPlacement: undefined,\n });\n\n const [components, setComponents] = useState(null);\n\n const pointTo = (pageX, pageY, placement, element) => {\n heap.lastElement = element;\n heap.lastPageX = pageX;\n heap.lastPageY = pageY;\n heap.lastPlacement = placement;\n\n if (components) {\n setComponentPositions(pageX, pageY, placement, element, components);\n }\n };\n useImperativeHandle(ref, () => ({ pointTo }));\n\n /* Inits and destroys tooltip components. */\n useEffect(() => {\n const x = createTooltipComponents(theme);\n setComponents(x);\n return () => {\n document.body.removeChild(x.container);\n setComponents(null);\n };\n }, [theme]);\n\n useEffect(() => {\n if (components) {\n setComponentPositions(\n heap.lastPageX,\n heap.lastPageY,\n heap.lastPlacement,\n heap.lastElement,\n components,\n );\n }\n }, [\n components,\n // BEWARE: Careful about these dependencies - they are updated when mouse\n // is moved over the tool-tipped element, thus potentially may cause\n // unnecessary firing of this effect on each mouse event. It does not\n // happen now just because the mouse movements themselves are not causing\n // the component re-rendering, thus dependencies of this effect are not\n // really re-evaluated.\n heap.lastPageX,\n heap.lastPageY,\n heap.lastPlacement,\n heap.lastElement,\n ]);\n\n return components ? createPortal(children, components.content) : null;\n});\n\nTooltip.propTypes = {\n children: PT.node,\n theme: PT.shape().isRequired,\n};\n\nTooltip.defaultProps = {\n children: null,\n};\n\nexport default Tooltip;\n"],"mappings":"mMAOA,IAAAA,MAAA,CAAAC,OAAA,UAQA,IAAAC,SAAA,CAAAD,OAAA,cAEA,IAAAE,UAAA,CAAAC,sBAAA,CAAAH,OAAA,gBAjBA;AACA;AACA;AACA;AACA,GAJA,CAKA,8BAcA;AACA,uDACO,KAAM,CAAAI,UAAU,CAAG,CACxBC,YAAY,CAAE,cAAc,CAC5BC,aAAa,CAAE,eAAe,CAC9BC,YAAY,CAAE,cAAc,CAC5BC,aAAa,CAAE,eACjB,CAAC,CAACC,OAAA,CAAAL,UAAA,CAAAA,UAAA,CAEF,KAAM,CAAAM,gBAAgB,CAAG,CACvB,iCAAiC,CACjC,+BAA+B,CAC/B,gCAAgC,CACjC,CAACC,IAAI,CAAC,GAAG,CAAC,CAEX,KAAM,CAAAC,cAAc,CAAG,CACrB,8BAA8B,CAC9B,+BAA+B,CAC/B,gCAAgC,CACjC,CAACD,IAAI,CAAC,GAAG,CAAC,CAEX;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAE,uBAAuBA,CAACC,KAAK,CAAE,CACtC,KAAM,CAAAC,KAAK,CAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC,CAC3C,GAAIH,KAAK,CAACC,KAAK,CAAEA,KAAK,CAACG,YAAY,CAAC,OAAO,CAAEJ,KAAK,CAACC,KAAK,CAAC,CAEzD,KAAM,CAAAI,OA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EAAC,IAAM,CACd,GAAIL,UAAU,CAAE,CACdzB,qBAAqB,CACnBkB,IAAI,CAACI,SAAS,CACdJ,IAAI,CAACK,SAAS,CACdL,IAAI,CAACM,aAAa,CAClBN,IAAI,CAACE,WAAW,CAChBK,UACF,CACF,CACF,CAAC,CAAE,CACDA,UAAU,CACV;AACA;AACA;AACA;AACA;AACA;AACAP,IAAI,CAACI,SAAS,CACdJ,IAAI,CAACK,SAAS,CACdL,IAAI,CAACM,aAAa,CAClBN,IAAI,CAACE,WAAW,CACjB,CAAC,CAEF,MAAO,CAAAK,UAAU,cAAG,GAAAO,sBAAY,EAACjB,QAAQ,CAAEU,UAAU,CAACtD,OAAO,CAAC,CAAG,IACnE,CAAC,CAAC,CAEF0C,OAAO,CAACoB,SAAS,CAAG,CAClBlB,QAAQ,CAAEmB,kBAAE,CAACC,IAAI,CACjBrE,KAAK,CAAEoE,kBAAE,CAACE,KAAK,CAAC,CAAC,CAACC,UACpB,CAAC,CAEDxB,OAAO,CAACyB,YAAY,CAAG,CACrBvB,QAAQ,CAAE,IACZ,CAAC,CAAC,IAAAwB,QAAA,CAEa1B,OAAO,CAAApD,OAAA,CAAA+E,OAAA,CAAAD,QAAA"}
@@ -12,5 +12,15 @@
12
12
  * @param {React.node} props.tip &ndash; Anything React is able to render,
13
13
  * _e.g._ a tooltip text. This will be the tooltip content.
14
14
  * @param {WithTooltipTheme} props.theme _Ad hoc_ theme.
15
- */function Wrapper({children,placement,tip,theme}){const tooltipRef=(0,_react.useRef)();const wrapperRef=(0,_react.useRef)();const[showTooltip,setShowTooltip]=(0,_react.useState)(false);const updatePortalPosition=(cursorX,cursorY)=>{if(!showTooltip)setShowTooltip(true);else{const wrapperRect=wrapperRef.current.getBoundingClientRect();if(cursorX<wrapperRect.left||cursorX>wrapperRect.right||cursorY<wrapperRect.top||cursorY>wrapperRect.bottom){setShowTooltip(false)}else if(tooltipRef.current){tooltipRef.current.pointTo(cursorX+window.pageXOffset,cursorY+window.pageYOffset,placement,wrapperRef.current)}}};(0,_react.useEffect)(()=>{if(showTooltip&&tip!==null){const listener=()=>setShowTooltip(false);window.addEventListener("scroll",listener);return()=>window.removeEventListener("scroll",listener)}return undefined},[showTooltip,tip]);return/*#__PURE__*/(0,_jsxRuntime.jsxs)("div",{className:theme.wrapper,onMouseLeave:()=>setShowTooltip(false),onMouseMove:e=>updatePortalPosition(e.clientX,e.clientY),ref:wrapperRef,children:[showTooltip&&tip!==null?/*#__PURE__*/(0,_jsxRuntime.jsx)(_Tooltip.default,{ref:tooltipRef,theme:theme,children:tip}):null,children]})}const ThemedWrapper=(0,_utils.themed)("WithTooltip",["appearance","arrow","container","content","wrapper"],defaultTheme)(Wrapper);ThemedWrapper.PLACEMENTS=_Tooltip.PLACEMENTS;Wrapper.propTypes={children:_propTypes.default.node,placement:_propTypes.default.oneOf(Object.values(_Tooltip.PLACEMENTS)),theme:ThemedWrapper.themeType.isRequired,tip:_propTypes.default.node};Wrapper.defaultProps={children:null,placement:_Tooltip.PLACEMENTS.ABOVE_CURSOR,tip:null};var _default=ThemedWrapper;exports.default=_default;
15
+ */function Wrapper({children,placement,tip,theme}){const{current:heap}=(0,_react.useRef)({lastCursorX:0,lastCursorY:0,triggeredByTouch:false,timerId:undefined});const tooltipRef=(0,_react.useRef)();const wrapperRef=(0,_react.useRef)();const[showTooltip,setShowTooltip]=(0,_react.useState)(false);const updatePortalPosition=(cursorX,cursorY)=>{if(!showTooltip){heap.lastCursorX=cursorX;heap.lastCursorY=cursorY;// If tooltip was triggered by a touch, we delay its opening by a bit,
16
+ // to ensure it was not a touch-click - in the case of touch click we
17
+ // want to do the click, rather than show the tooltip, and the delay
18
+ // gives click handler a chance to abort the tooltip openning.
19
+ if(heap.triggeredByTouch){if(!heap.timerId){heap.timerId=setTimeout(()=>{heap.triggeredByTouch=false;heap.timerId=undefined;setShowTooltip(true)},300)}// Otherwise we can just open the tooltip right away.
20
+ }else setShowTooltip(true)}else{const wrapperRect=wrapperRef.current.getBoundingClientRect();if(cursorX<wrapperRect.left||cursorX>wrapperRect.right||cursorY<wrapperRect.top||cursorY>wrapperRect.bottom){setShowTooltip(false)}else if(tooltipRef.current){tooltipRef.current.pointTo(cursorX+window.scrollX,cursorY+window.scrollY,placement,wrapperRef.current)}}};(0,_react.useEffect)(()=>{if(showTooltip&&tip!==null){// This is necessary to ensure that even when a single mouse event
21
+ // arrives to a tool-tipped component, the tooltip is correctly positioned
22
+ // once opened (because similar call above does not have effect until
23
+ // the tooltip is fully mounted, and that is delayed to future rendering
24
+ // cycle due to the implementation).
25
+ if(tooltipRef.current){tooltipRef.current.pointTo(heap.lastCursorX+window.scrollX,heap.lastCursorY+window.scrollY,placement,wrapperRef.current)}const listener=()=>setShowTooltip(false);window.addEventListener("scroll",listener);return()=>window.removeEventListener("scroll",listener)}return undefined},[heap.lastCursorX,heap.lastCursorY,placement,showTooltip,tip]);return/*#__PURE__*/(0,_jsxRuntime.jsxs)("div",{className:theme.wrapper,onMouseLeave:()=>setShowTooltip(false),onMouseMove:e=>updatePortalPosition(e.clientX,e.clientY),onClick:()=>{if(heap.timerId){clearTimeout(heap.timerId);heap.timerId=undefined;heap.triggeredByTouch=false}},onTouchStart:()=>{heap.triggeredByTouch=true},ref:wrapperRef,role:"presentation",children:[showTooltip&&tip!==null?/*#__PURE__*/(0,_jsxRuntime.jsx)(_Tooltip.default,{ref:tooltipRef,theme:theme,children:tip}):null,children]})}const ThemedWrapper=(0,_utils.themed)("WithTooltip",["appearance","arrow","container","content","wrapper"],defaultTheme)(Wrapper);ThemedWrapper.PLACEMENTS=_Tooltip.PLACEMENTS;Wrapper.propTypes={children:_propTypes.default.node,placement:_propTypes.default.oneOf(Object.values(_Tooltip.PLACEMENTS)),theme:ThemedWrapper.themeType.isRequired,tip:_propTypes.default.node};Wrapper.defaultProps={children:null,placement:_Tooltip.PLACEMENTS.ABOVE_CURSOR,tip:null};var _default=ThemedWrapper;exports.default=_default;
16
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_react","_utils","_Tooltip","_interopRequireWildcard","_jsxRuntime","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","defaultTheme","Wrapper","children","placement","tip","theme","tooltipRef","useRef","wrapperRef","showTooltip","setShowTooltip","useState","updatePortalPosition","cursorX","cursorY","wrapperRect","current","getBoundingClientRect","left","right","top","bottom","pointTo","window","pageXOffset","pageYOffset","useEffect","listener","addEventListener","removeEventListener","undefined","jsxs","className","wrapper","onMouseLeave","onMouseMove","e","clientX","clientY","ref","jsx","ThemedWrapper","themed","PLACEMENTS","propTypes","PT","node","oneOf","values","themeType","isRequired","defaultProps","ABOVE_CURSOR","_default","exports"],"sources":["../../../../../src/shared/components/WithTooltip/index.jsx"],"sourcesContent":["/* global window */\n\nimport PT from 'prop-types';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { themed } from 'utils';\n\nimport Tooltip, { PLACEMENTS } from './Tooltip';\n\nimport defaultTheme from './default-theme.scss';\n\n/**\n * Implements a simple to use and themeable tooltip component, _e.g._\n * ```js\n * <WithTooltip tip=\"This is example tooltip.\">\n * <p>Hover to see the tooltip.</p>\n * </WithTooltip>\n * ```\n * **Children:** Children are rendered in the place of `<WithTooltip>`,\n * and when hovered the tooltip is shown. By default the wrapper itself is\n * `<div>` block with `display: inline-block`.\n * @param {object} props Component properties.\n * @param {React.node} props.tip &ndash; Anything React is able to render,\n * _e.g._ a tooltip text. This will be the tooltip content.\n * @param {WithTooltipTheme} props.theme _Ad hoc_ theme.\n */\nfunction Wrapper({\n children,\n placement,\n tip,\n theme,\n}) {\n const tooltipRef = useRef();\n const wrapperRef = useRef();\n const [showTooltip, setShowTooltip] = useState(false);\n\n const updatePortalPosition = (cursorX, cursorY) => {\n if (!showTooltip) setShowTooltip(true);\n else {\n const wrapperRect = wrapperRef.current.getBoundingClientRect();\n if (\n cursorX < wrapperRect.left\n || cursorX > wrapperRect.right\n || cursorY < wrapperRect.top\n || cursorY > wrapperRect.bottom\n ) {\n setShowTooltip(false);\n } else if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n cursorX + window.pageXOffset,\n cursorY + window.pageYOffset,\n placement,\n wrapperRef.current,\n );\n }\n }\n };\n\n useEffect(() => {\n if (showTooltip && tip !== null) {\n const listener = () => setShowTooltip(false);\n window.addEventListener('scroll', listener);\n return () => window.removeEventListener('scroll', listener);\n }\n return undefined;\n }, [showTooltip, tip]);\n\n return (\n <div\n className={theme.wrapper}\n onMouseLeave={() => setShowTooltip(false)}\n onMouseMove={(e) => updatePortalPosition(e.clientX, e.clientY)}\n ref={wrapperRef}\n >\n {\n showTooltip && tip !== null ? (\n <Tooltip ref={tooltipRef} theme={theme}>{tip}</Tooltip>\n ) : null\n }\n {children}\n </div>\n );\n}\n\nconst ThemedWrapper = themed(\n 'WithTooltip',\n [\n 'appearance',\n 'arrow',\n 'container',\n 'content',\n 'wrapper',\n ],\n defaultTheme,\n)(Wrapper);\n\nThemedWrapper.PLACEMENTS = PLACEMENTS;\n\nWrapper.propTypes = {\n children: PT.node,\n placement: PT.oneOf(Object.values(PLACEMENTS)),\n theme: ThemedWrapper.themeType.isRequired,\n tip: PT.node,\n};\n\nWrapper.defaultProps = {\n children: null,\n placement: PLACEMENTS.ABOVE_CURSOR,\n tip: null,\n};\n\nexport default ThemedWrapper;\n"],"mappings":"gLAEA,IAAAA,UAAA,CAAAC,sBAAA,CAAAC,OAAA,gBACA,IAAAC,MAAA,CAAAD,OAAA,UAEA,IAAAE,MAAA,CAAAF,OAAA,gBAEA,IAAAG,QAAA,CAAAC,uBAAA,CAAAJ,OAAA,eAAgD,IAAAK,WAAA,CAAAL,OAAA,+BAAAM,yBAAAC,WAAA,YAAAC,OAAA,8BAAAC,iBAAA,KAAAD,OAAA,KAAAE,gBAA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OAAQ,CACzBC,YAAY,CAAEA,CAAA,GAAMxB,cAAc,CAAC,KAAK,CAAE,CAC1CyB,WAAW,CAAGC,CAAC,EAAKxB,oBAAoB,CAACwB,CAAC,CAACC,OAAO,CAAED,CAAC,CAACE,OAAO,CAAE,CAC/DC,GAAG,CAAE/B,UAAW,CAAAN,QAAA,EAGdO,WAAW,EAAIL,GAAG,GAAK,IAAI,cACzB,GAAA3B,WAAA,CAAA+D,GAAA,EAACjE,QAAA,CAAAU,OAAO,EAACsD,GAAG,CAAEjC,UAAW,CAACD,KAAK,CAAEA,KAAM,CAAAH,QAAA,CAAEE,GAAG,CAAU,CAAC,CACrD,IAAI,CAETF,QAAQ,EACN,CAET,CAEA,KAAM,CAAAuC,aAAa,CAAG,GAAAC,aAAM,EAC1B,aAAa,CACb,CACE,YAAY,CACZ,OAAO,CACP,WAAW,CACX,SAAS,CACT,SAAS,CACV,CACD1C,YACF,CAAC,CAACC,OAAO,CAAC,CAEVwC,aAAa,CAACE,UAAU,CAAGA,mBAAU,CAErC1C,OAAO,CAAC2C,SAAS,CAAG,CAClB1C,QAAQ,CAAE2C,kBAAE,CAACC,IAAI,CACjB3C,SAAS,CAAE0C,kBAAE,CAACE,KAAK,CAACxD,MAAM,CAACyD,MAAM,CAACL,mBAAU,CAAC,CAAC,CAC9CtC,KAAK,CAAEoC,aAAa,CAACQ,SAAS,CAACC,UAAU,CACzC9C,GAAG,CAAEyC,kBAAE,CAACC,IACV,CAAC,CAED7C,OAAO,CAACkD,YAAY,CAAG,CACrBjD,QAAQ,CAAE,IAAI,CACdC,SAAS,CAAEwC,mBAAU,CAACS,YAAY,CAClChD,GAAG,CAAE,IACP,CAAC,CAAC,IAAAiD,QAAA,CAEaZ,aAAa,CAAAa,OAAA,CAAArE,OAAA,CAAAoE,QAAA"}
1
+ {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_react","_utils","_Tooltip","_interopRequireWildcard","_jsxRuntime","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","defaultTheme","Wrapper","children","placement","tip","theme","current","heap","useRef","lastCursorX","lastCursorY","triggeredByTouch","timerId","undefined","tooltipRef","wrapperRef","showTooltip","setShowTooltip","useState","updatePortalPosition","cursorX","cursorY","setTimeout","wrapperRect","getBoundingClientRect","left","right","top","bottom","pointTo","window","scrollX","scrollY","useEffect","listener","addEventListener","removeEventListener","jsxs","className","wrapper","onMouseLeave","onMouseMove","e","clientX","clientY","onClick","clearTimeout","onTouchStart","ref","role","jsx","ThemedWrapper","themed","PLACEMENTS","propTypes","PT","node","oneOf","values","themeType","isRequired","defaultProps","ABOVE_CURSOR","_default","exports"],"sources":["../../../../../src/shared/components/WithTooltip/index.jsx"],"sourcesContent":["/* global window */\n\nimport PT from 'prop-types';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { themed } from 'utils';\n\nimport Tooltip, { PLACEMENTS } from './Tooltip';\n\nimport defaultTheme from './default-theme.scss';\n\n/**\n * Implements a simple to use and themeable tooltip component, _e.g._\n * ```js\n * <WithTooltip tip=\"This is example tooltip.\">\n * <p>Hover to see the tooltip.</p>\n * </WithTooltip>\n * ```\n * **Children:** Children are rendered in the place of `<WithTooltip>`,\n * and when hovered the tooltip is shown. By default the wrapper itself is\n * `<div>` block with `display: inline-block`.\n * @param {object} props Component properties.\n * @param {React.node} props.tip &ndash; Anything React is able to render,\n * _e.g._ a tooltip text. This will be the tooltip content.\n * @param {WithTooltipTheme} props.theme _Ad hoc_ theme.\n */\nfunction Wrapper({\n children,\n placement,\n tip,\n theme,\n}) {\n const { current: heap } = useRef({\n lastCursorX: 0,\n lastCursorY: 0,\n triggeredByTouch: false,\n timerId: undefined,\n });\n const tooltipRef = useRef();\n const wrapperRef = useRef();\n const [showTooltip, setShowTooltip] = useState(false);\n\n const updatePortalPosition = (cursorX, cursorY) => {\n if (!showTooltip) {\n heap.lastCursorX = cursorX;\n heap.lastCursorY = cursorY;\n\n // If tooltip was triggered by a touch, we delay its opening by a bit,\n // to ensure it was not a touch-click - in the case of touch click we\n // want to do the click, rather than show the tooltip, and the delay\n // gives click handler a chance to abort the tooltip openning.\n if (heap.triggeredByTouch) {\n if (!heap.timerId) {\n heap.timerId = setTimeout(() => {\n heap.triggeredByTouch = false;\n heap.timerId = undefined;\n setShowTooltip(true);\n }, 300);\n }\n\n // Otherwise we can just open the tooltip right away.\n } else setShowTooltip(true);\n } else {\n const wrapperRect = wrapperRef.current.getBoundingClientRect();\n if (\n cursorX < wrapperRect.left\n || cursorX > wrapperRect.right\n || cursorY < wrapperRect.top\n || cursorY > wrapperRect.bottom\n ) {\n setShowTooltip(false);\n } else if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n cursorX + window.scrollX,\n cursorY + window.scrollY,\n placement,\n wrapperRef.current,\n );\n }\n }\n };\n\n useEffect(() => {\n if (showTooltip && tip !== null) {\n // This is necessary to ensure that even when a single mouse event\n // arrives to a tool-tipped component, the tooltip is correctly positioned\n // once opened (because similar call above does not have effect until\n // the tooltip is fully mounted, and that is delayed to future rendering\n // cycle due to the implementation).\n if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n heap.lastCursorX + window.scrollX,\n heap.lastCursorY + window.scrollY,\n placement,\n wrapperRef.current,\n );\n }\n\n const listener = () => setShowTooltip(false);\n window.addEventListener('scroll', listener);\n return () => window.removeEventListener('scroll', listener);\n }\n return undefined;\n }, [\n heap.lastCursorX,\n heap.lastCursorY,\n placement,\n showTooltip,\n tip,\n ]);\n\n return (\n <div\n className={theme.wrapper}\n onMouseLeave={() => setShowTooltip(false)}\n onMouseMove={(e) => updatePortalPosition(e.clientX, e.clientY)}\n onClick={() => {\n if (heap.timerId) {\n clearTimeout(heap.timerId);\n heap.timerId = undefined;\n heap.triggeredByTouch = false;\n }\n }}\n onTouchStart={() => {\n heap.triggeredByTouch = true;\n }}\n ref={wrapperRef}\n role=\"presentation\"\n >\n {\n showTooltip && tip !== null ? (\n <Tooltip ref={tooltipRef} theme={theme}>{tip}</Tooltip>\n ) : null\n }\n {children}\n </div>\n );\n}\n\nconst ThemedWrapper = themed(\n 'WithTooltip',\n [\n 'appearance',\n 'arrow',\n 'container',\n 'content',\n 'wrapper',\n ],\n defaultTheme,\n)(Wrapper);\n\nThemedWrapper.PLACEMENTS = PLACEMENTS;\n\nWrapper.propTypes = {\n children: PT.node,\n placement: PT.oneOf(Object.values(PLACEMENTS)),\n theme: ThemedWrapper.themeType.isRequired,\n tip: PT.node,\n};\n\nWrapper.defaultProps = {\n children: null,\n placement: PLACEMENTS.ABOVE_CURSOR,\n tip: null,\n};\n\nexport default ThemedWrapper;\n"],"mappings":"gLAEA,IAAAA,UAAA,CAAAC,sBAAA,CAAAC,OAAA,gBACA,IAAAC,MAAA,CAAAD,OAAA,UAEA,IAAAE,MAAA,CAAAF,OAAA,gBAEA,IAAAG,QAAA,CAAAC,uBAAA,CAAAJ,OAAA,eAAgD,IAAAK,WAAA,CAAAL,OAAA,+BAAAM,yBAAAC,WAAA,YAAAC,OAAA,8BAAAC,iBAAA,KAAAD,OAAA,KAAAE,gBAAA,KAAAF,OAAA,QAAAF,wBAAA,SAAAA,CAAAC,WAAA,SAAAA,WAAA,CAAAG,gBAAA,CAAAD,iBAAA,GAAAF,WAAA,WAAAH,wBAAAO,GAAA,CAAAJ,WAAA,MAAAA,WAAA,EAAAI,GAAA,EAAAA,GAAA,CAAAC,UAAA,SAAAD,GAAA,IAAAA,GAAA,gBAAAA,GAAA,oBAAAA,GAAA,sBAAAE,OAAA,CAAAF,GAAA,MAAAG,KAAA,CAAAR,wBAAA,CAAAC,WAAA,KAAAO,KAAA,EAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,UAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,MAAAM,MAAA,QAAAC,qBAAA,CAAAC,MAAA,CAAAC,cAAA,EAAAD,MAAA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E,YAAY,CACZ,OAAO,CACP,WAAW,CACX,SAAS,CACT,SAAS,CACV,CACDpD,YACF,CAAC,CAACC,OAAO,CAAC,CAEVkD,aAAa,CAACE,UAAU,CAAGA,mBAAU,CAErCpD,OAAO,CAACqD,SAAS,CAAG,CAClBpD,QAAQ,CAAEqD,kBAAE,CAACC,IAAI,CACjBrD,SAAS,CAAEoD,kBAAE,CAACE,KAAK,CAAClE,MAAM,CAACmE,MAAM,CAACL,mBAAU,CAAC,CAAC,CAC9ChD,KAAK,CAAE8C,aAAa,CAACQ,SAAS,CAACC,UAAU,CACzCxD,GAAG,CAAEmD,kBAAE,CAACC,IACV,CAAC,CAEDvD,OAAO,CAAC4D,YAAY,CAAG,CACrB3D,QAAQ,CAAE,IAAI,CACdC,SAAS,CAAEkD,mBAAU,CAACS,YAAY,CAClC1D,GAAG,CAAE,IACP,CAAC,CAAC,IAAA2D,QAAA,CAEaZ,aAAa,CAAAa,OAAA,CAAA/E,OAAA,CAAA8E,QAAA"}
@@ -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 _qs=_interopRequireDefault(require("qs"));var _ScalableRect=_interopRequireDefault(require("../ScalableRect"));var _reactThemes=_interopRequireDefault(require("@dr.pogodin/react-themes"));var _Throbber=_interopRequireDefault(require("../Throbber"));var _jsxRuntime=require("react/jsx-runtime");const baseTheme={"context":"veKyYi","ad":"r3ABzd","hoc":"YKcPnR","container":"sXHM81","video":"SlV2zw"};const throbberTheme={"context":"dzIcLh","ad":"_5a9XX1","hoc":"_7sH52O","container":"jTxmOX"};/**
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 _qs=_interopRequireDefault(require("qs"));var _reactThemes=_interopRequireDefault(require("@dr.pogodin/react-themes"));var _ScalableRect=_interopRequireDefault(require("../ScalableRect"));var _Throbber=_interopRequireDefault(require("../Throbber"));var _jsxRuntime=require("react/jsx-runtime");const baseTheme={"context":"veKyYi","ad":"r3ABzd","hoc":"YKcPnR","container":"sXHM81","video":"SlV2zw"};const throbberTheme={"context":"dzIcLh","ad":"_5a9XX1","hoc":"_7sH52O","container":"jTxmOX"};/**
2
2
  * A component for embeding a YouTube video.
3
3
  * @param {object} [props] Component properties.
4
4
  * @param {boolean} [props.autoplay] If `true` the video will start to play
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_qs","_ScalableRect","_reactThemes","_Throbber","_jsxRuntime","baseTheme","throbberTheme","YouTubeVideo","autoplay","src","theme","title","url","query","split","qs","parse","videoId","v","match","stringify","jsxs","default","className","container","ratio","children","jsx","allow","allowFullScreen","video","ThemedYouTubeVideo","themed","propTypes","PT","bool","string","isRequired","themeType","defaultProps","_default","exports"],"sources":["../../../../../src/shared/components/YouTubeVideo/index.jsx"],"sourcesContent":["import PT from 'prop-types';\nimport qs from 'qs';\nimport ScalableRect from 'components/ScalableRect';\nimport themed from '@dr.pogodin/react-themes';\nimport Throbber from 'components/Throbber';\n\nimport baseTheme from './base.scss';\nimport throbberTheme from './throbber.scss';\n\n/**\n * A component for embeding a YouTube video.\n * @param {object} [props] Component properties.\n * @param {boolean} [props.autoplay] If `true` the video will start to play\n * automatically once loaded.\n * @param {string} [props.src] URL of the video to play. Can be in any of\n * the following formats, and keeps any additional query parameters understood\n * by the YouTube IFrame player:\n * - `https://www.youtube.com/watch?v=NdF6Rmt6Ado`\n * - `https://youtu.be/NdF6Rmt6Ado`\n * - `https://www.youtube.com/embed/NdF6Rmt6Ado`\n * @param {YouTubeVideoTheme} [props.theme] _Ad hoc_ theme.\n * @param {string} [props.title] The `title` attribute to add to the player\n * IFrame.\n */\nfunction YouTubeVideo({\n autoplay,\n src,\n theme,\n title,\n}) {\n let [url, query] = src.split('?');\n query = query ? qs.parse(query) : {};\n\n const videoId = query.v || url.match(/\\/([a-zA-Z0-9-_]*)$/)[1];\n url = `https://www.youtube.com/embed/${videoId}`;\n\n delete query.v;\n query.autoplay = autoplay ? 1 : 0;\n url += `?${qs.stringify(query)}`;\n\n // TODO: https://developers.google.com/youtube/player_parameters\n // More query parameters can be exposed via the component props.\n\n return (\n <ScalableRect className={theme.container} ratio=\"16:9\">\n <Throbber theme={throbberTheme} />\n <iframe\n allow=\"autoplay\"\n allowFullScreen\n className={theme.video}\n src={url}\n title={title}\n />\n </ScalableRect>\n );\n}\n\nconst ThemedYouTubeVideo = themed(\n 'YouTubeVideo',\n [\n 'container',\n 'video',\n ],\n baseTheme,\n)(YouTubeVideo);\n\nYouTubeVideo.propTypes = {\n autoplay: PT.bool,\n src: PT.string.isRequired,\n theme: ThemedYouTubeVideo.themeType.isRequired,\n title: PT.string,\n};\n\nYouTubeVideo.defaultProps = {\n autoplay: false,\n title: '',\n};\n\nexport default ThemedYouTubeVideo;\n"],"mappings":"gLAAA,IAAAA,UAAA,CAAAC,sBAAA,CAAAC,OAAA,gBACA,IAAAC,GAAA,CAAAF,sBAAA,CAAAC,OAAA,QACA,IAAAE,aAAA,CAAAH,sBAAA,CAAAC,OAAA,qBACA,IAAAG,YAAA,CAAAJ,sBAAA,CAAAC,OAAA,8BACA,IAAAI,SAAA,CAAAL,sBAAA,CAAAC,OAAA,iBAA2C,IAAAK,WAAA,CAAAL,OAAA,4BAAAM,SAAA,+FAAAC,aAAA,0EAK3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAC,YAAYA,CAAC,CACpBC,QAAQ,CACRC,GAAG,CACHC,KAAK,CACLC,KACF,CAAC,CAAE,CACD,GAAI,CAACC,GAAG,CAAEC,KAAK,CAAC,CAAGJ,GAAG,CAACK,KAAK,CAAC,GAAG,CAAC,CACjCD,KAAK,CAAGA,KAAK,CAAGE,WA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,QAAQ,CAAE,KAAK,CACfG,KAAK,CAAE,EACT,CAAC,CAAC,IAAA6B,QAAA,CAEaT,kBAAkB,CAAAU,OAAA,CAAAnB,OAAA,CAAAkB,QAAA"}
1
+ {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_qs","_reactThemes","_ScalableRect","_Throbber","_jsxRuntime","baseTheme","throbberTheme","YouTubeVideo","autoplay","src","theme","title","url","query","split","qs","parse","videoId","v","match","stringify","jsxs","default","className","container","ratio","children","jsx","allow","allowFullScreen","video","ThemedYouTubeVideo","themed","propTypes","PT","bool","string","isRequired","themeType","defaultProps","_default","exports"],"sources":["../../../../../src/shared/components/YouTubeVideo/index.jsx"],"sourcesContent":["import PT from 'prop-types';\nimport qs from 'qs';\nimport themed from '@dr.pogodin/react-themes';\n\nimport ScalableRect from 'components/ScalableRect';\nimport Throbber from 'components/Throbber';\n\nimport baseTheme from './base.scss';\nimport throbberTheme from './throbber.scss';\n\n/**\n * A component for embeding a YouTube video.\n * @param {object} [props] Component properties.\n * @param {boolean} [props.autoplay] If `true` the video will start to play\n * automatically once loaded.\n * @param {string} [props.src] URL of the video to play. Can be in any of\n * the following formats, and keeps any additional query parameters understood\n * by the YouTube IFrame player:\n * - `https://www.youtube.com/watch?v=NdF6Rmt6Ado`\n * - `https://youtu.be/NdF6Rmt6Ado`\n * - `https://www.youtube.com/embed/NdF6Rmt6Ado`\n * @param {YouTubeVideoTheme} [props.theme] _Ad hoc_ theme.\n * @param {string} [props.title] The `title` attribute to add to the player\n * IFrame.\n */\nfunction YouTubeVideo({\n autoplay,\n src,\n theme,\n title,\n}) {\n let [url, query] = src.split('?');\n query = query ? qs.parse(query) : {};\n\n const videoId = query.v || url.match(/\\/([a-zA-Z0-9-_]*)$/)[1];\n url = `https://www.youtube.com/embed/${videoId}`;\n\n delete query.v;\n query.autoplay = autoplay ? 1 : 0;\n url += `?${qs.stringify(query)}`;\n\n // TODO: https://developers.google.com/youtube/player_parameters\n // More query parameters can be exposed via the component props.\n\n return (\n <ScalableRect className={theme.container} ratio=\"16:9\">\n <Throbber theme={throbberTheme} />\n <iframe\n allow=\"autoplay\"\n allowFullScreen\n className={theme.video}\n src={url}\n title={title}\n />\n </ScalableRect>\n );\n}\n\nconst ThemedYouTubeVideo = themed(\n 'YouTubeVideo',\n [\n 'container',\n 'video',\n ],\n baseTheme,\n)(YouTubeVideo);\n\nYouTubeVideo.propTypes = {\n autoplay: PT.bool,\n src: PT.string.isRequired,\n theme: ThemedYouTubeVideo.themeType.isRequired,\n title: PT.string,\n};\n\nYouTubeVideo.defaultProps = {\n autoplay: false,\n title: '',\n};\n\nexport default ThemedYouTubeVideo;\n"],"mappings":"gLAAA,IAAAA,UAAA,CAAAC,sBAAA,CAAAC,OAAA,gBACA,IAAAC,GAAA,CAAAF,sBAAA,CAAAC,OAAA,QACA,IAAAE,YAAA,CAAAH,sBAAA,CAAAC,OAAA,8BAEA,IAAAG,aAAA,CAAAJ,sBAAA,CAAAC,OAAA,qBACA,IAAAI,SAAA,CAAAL,sBAAA,CAAAC,OAAA,iBAA2C,IAAAK,WAAA,CAAAL,OAAA,4BAAAM,SAAA,+FAAAC,aAAA,0EAK3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAC,YAAYA,CAAC,CACpBC,QAAQ,CACRC,GAAG,CACHC,KAAK,CACLC,KACF,CAAC,CAAE,CACD,GAAI,CAACC,GAAG,CAAEC,KAAK,CAAC,CAAGJ,GAAG,CAACK,KAAK,CAAC,GAAG,CAAC,CACjCD,KAAK,CAAGA,KAAK,CAAGE,WAAE,CAACC,KAAK,CAACH,KAAK,CAAC,CAAG,CAAC,CAAC,CAEpC,KAAM,CAAAI,OAAO,CAAGJ,KAAK,CAACK,CAAC,EAAIN,GAAG,CAACO,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAC9DP,GAAG,CAAI,iCAAgCK,OAAQ,EAAC,CAEhD,MAAO,CAAAJ,KAAK,CAACK,CAAC,CACdL,KAAK,CAACL,QAAQ,CAAGA,QAAQ,CAAG,CAAC,CAAG,CAAC,CACjCI,GAAG,EAAK,IAAGG,WAAE,CAACK,SAAS,CAACP,KAAK,CAAE,EAAC,CAEhC;AACA;AAEA,mBACE,GAAAT,WAAA,CAAAiB,IAAA,EAACnB,aAAA,CAAAoB,OAAY,EAACC,SAAS,CAAEb,KAAK,CAACc,SAAU,CAACC,KAAK,CAAC,MAAM,CAAAC,QAAA,eACpD,GAAAtB,WAAA,CAAAuB,GAAA,EAACxB,SAAA,CAAAmB,OAAQ,EAACZ,KAAK,CAAEJ,aAAc,CAAE,CAAC,cAClC,GAAAF,WAAA,CAAAuB,GAAA,YACEC,KAAK,CAAC,UAAU,CAChBC,eAAe,MACfN,SAAS,CAAEb,KAAK,CAACoB,KAAM,CACvBrB,GAAG,CAAEG,GAAI,CACTD,KAAK,CAAEA,KAAM,CACd,CAAC,EACU,CAElB,CAEA,KAAM,CAAAoB,kBAAkB,CAAG,GAAAC,oBAAM,EAC/B,cAAc,CACd,CACE,WAAW,CACX,OAAO,CACR,CACD3B,SACF,CAAC,CAACE,YAAY,CAAC,CAEfA,YAAY,CAAC0B,SAAS,CAAG,CACvBzB,QAAQ,CAAE0B,kBAAE,CAACC,IAAI,CACjB1B,GAAG,CAAEyB,kBAAE,CAACE,MAAM,CAACC,UAAU,CACzB3B,KAAK,CAAEqB,kBAAkB,CAACO,SAAS,CAACD,UAAU,CAC9C1B,KAAK,CAAEuB,kBAAE,CAACE,MACZ,CAAC,CAED7B,YAAY,CAACgC,YAAY,CAAG,CAC1B/B,QAAQ,CAAE,KAAK,CACfG,KAAK,CAAE,EACT,CAAC,CAAC,IAAA6B,QAAA,CAEaT,kBAAkB,CAAAU,OAAA,CAAAnB,OAAA,CAAAkB,QAAA"}
@@ -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 _path=_interopRequireDefault(require("path"));var _renderer=_interopRequireDefault(require("../../../server/renderer"));var _lodash=require("lodash");var _register=_interopRequireDefault(require("@babel/register"));var _jestEnvironmentJsdom=_interopRequireDefault(require("jest-environment-jsdom"));var _memfs=require("memfs");var _webpack=_interopRequireDefault(require("webpack"));/**
1
+ "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _path=_interopRequireDefault(require("path"));var _lodash=require("lodash");var _register=_interopRequireDefault(require("@babel/register"));var _jestEnvironmentJsdom=_interopRequireDefault(require("jest-environment-jsdom"));var _memfs=require("memfs");var _webpack=_interopRequireDefault(require("webpack"));var _renderer=_interopRequireDefault(require("../../../server/renderer"));/**
2
2
  * Jest environment for end-to-end SSR and client-side testing. It relies on
3
3
  * the standard react-utils mechanics to execute SSR of given scene, and also
4
4
  * Webpack build of the code for client-side execution, it further exposes
@@ -1 +1 @@
1
- {"version":3,"file":"E2eSsrEnv.js","names":["_path","_interopRequireDefault","require","_renderer","_lodash","_register","_jestEnvironmentJsdom","_memfs","_webpack","E2eSsrEnv","JsdomEnv","loadWebpackConfig","options","pragmas","JSON","parse","defaults","context","testFolder","fs","global","webpackOutputFs","factory","path","resolve","rootDir","webpackConfig","buildInfo","existsSync","readFileSync","runWebpack","compiler","webpack","outputFileSystem","Promise","done","fail","run","err","stats","hasErrors","console","error","toJson","errors","Error","webpackStats","runSsr","logger","undefined","debug","noop","info","log","warn","root","process","cwd","register","envName","babelEnv","extensions","entry","p","Application","entryExportName","renderer","ssrFactory","status","markup","ssrRequest","cookie","send","set","value","locals","devMiddleware","ssrMarkup","ssrOptions","ssrStatus","constructor","config","docblockPragmas","request","url","csrfToken","projectConfig","dom","createFsFromVolume","Volume","dirname","testPath","withSsr","setup","REACT_UTILS_FORCE_CLIENT_SIDE","teardown","Object","keys","cache","forEach","key","revert","exports","default"],"sources":["../../../../../src/shared/utils/jest/E2eSsrEnv.js"],"sourcesContent":["/**\n * Jest environment for end-to-end SSR and client-side testing. It relies on\n * the standard react-utils mechanics to execute SSR of given scene, and also\n * Webpack build of the code for client-side execution, it further exposes\n * Jsdom environment for the client-side testing of the outcomes.\n */\n/* eslint-disable global-require, import/no-dynamic-require */\n\n// BEWARE: The module is not imported into the JU module / the main assembly of\n// the library, because doing so easily breaks stuff:\n// 1) This module depends on Node-specific modules, which would make JU\n// incompatible with JsDom if included into JU.\n// 2) If this module is weakly imported from somewhere else in the lib,\n// it seems to randomly break tests using it for a different reason,\n// probably some sort of a require-loop, or some issues with weak\n// require in that scenario.\n\nimport path from 'path';\nimport ssrFactory from 'server/renderer';\n\nimport { defaults, noop, set } from 'lodash';\n\n// As this environment is a part of the Jest testing utils,\n// we assume development dependencies are available when it is used.\n/* eslint-disable import/no-extraneous-dependencies */\nimport register from '@babel/register';\nimport JsdomEnv from 'jest-environment-jsdom';\nimport { createFsFromVolume, Volume } from 'memfs';\nimport webpack from 'webpack';\n/* eslint-enable import/no-extraneous-dependencies */\n\nexport default class E2eSsrEnv extends JsdomEnv {\n /**\n * Loads Webpack config, and exposes it to the environment via global\n * webpackConfig object.\n */\n loadWebpackConfig() {\n let options = this.pragmas['webpack-config-options'];\n options = options ? JSON.parse(options) : {};\n defaults(options, {\n context: this.testFolder,\n fs: this.global.webpackOutputFs,\n });\n\n let factory = this.pragmas['webpack-config-factory'] || '';\n factory = require(path.resolve(this.rootDir, factory));\n this.global.webpackConfig = factory(options);\n\n const fs = this.global.webpackOutputFs;\n let buildInfo = `${options.context}/.build-info`;\n if (fs.existsSync(buildInfo)) {\n buildInfo = fs.readFileSync(buildInfo, 'utf8');\n this.global.buildInfo = JSON.parse(buildInfo);\n }\n }\n\n /**\n * Executes Webpack build.\n * @return {Promise}\n */\n async runWebpack() {\n this.loadWebpackConfig();\n\n const compiler = webpack(this.global.webpackConfig);\n compiler.outputFileSystem = this.global.webpackOutputFs;\n return new Promise((done, fail) => {\n compiler.run((err, stats) => {\n if (err) fail(err);\n if (stats.hasErrors()) {\n console.error(stats.toJson().errors);\n fail(Error('Webpack compilation failed'));\n }\n\n this.global.webpackStats = stats.toJson();\n\n // Keeps reference to the raw Webpack stats object, which should be\n // explicitly passed to the server-side renderer alongside the request,\n // so that it can to pick up asset paths for different named chunks.\n this.webpackStats = stats;\n\n done();\n });\n });\n }\n\n async runSsr() {\n let options = this.pragmas['ssr-options'];\n options = options ? JSON.parse(options) : {};\n\n // TODO: This is temporary to shortcut the logging added to SSR.\n if (options.logger === undefined) {\n options.logger = {\n debug: noop,\n info: noop,\n log: noop,\n warn: noop,\n };\n }\n\n let root;\n switch (options.root) {\n case 'TEST': root = this.testFolder; break;\n default: root = process.cwd();\n }\n\n // Note: This enables Babel transformation for the code dynamically loaded\n // below, as the usual Jest Babel setup does not seem to apply to\n // the environment code, and imports from it.\n register({\n envName: options.babelEnv,\n extensions: ['.js', '.jsx', '.svg'],\n root,\n });\n\n if (!options.buildInfo) options.buildInfo = this.global.buildInfo;\n\n if (options.entry) {\n const p = path.resolve(this.testFolder, options.entry);\n options.Application = require(p)[options.entryExportName || 'default'];\n }\n\n const renderer = ssrFactory(this.global.webpackConfig, options);\n let status = 200; // OK\n const markup = await new Promise((done, fail) => {\n renderer(\n this.ssrRequest,\n\n // TODO: This will do for now, with the current implementation of\n // the renderer, but it will require a rework once the renderer is\n // updated to do streaming.\n {\n cookie: noop,\n send: done,\n set: noop,\n status: (value) => {\n status = value;\n },\n\n // This is how up-to-date Webpack stats are passed to the server in\n // development mode, and we use this here always, instead of having\n // to pass some information via filesystem.\n locals: {\n webpack: {\n devMiddleware: {\n stats: this.webpackStats,\n },\n },\n },\n },\n\n (error) => {\n if (error) fail(error);\n else done('');\n },\n );\n });\n\n this.global.ssrMarkup = markup;\n this.global.ssrOptions = options;\n this.global.ssrStatus = status;\n }\n\n constructor(config, context) {\n const pragmas = context.docblockPragmas;\n let request = pragmas['ssr-request'];\n request = request ? JSON.parse(request) : {};\n if (!request.url) request.url = '/';\n request.csrfToken = noop;\n\n // This ensures the initial JsDom URL matches the value we use for SSR.\n set(\n config.projectConfig,\n 'testEnvironmentOptions.url',\n `http://localhost${request.url}`,\n );\n\n super(config, context);\n\n this.global.dom = this.dom;\n this.global.webpackOutputFs = createFsFromVolume(new Volume());\n\n // Extracts necessary settings from config and context.\n const { projectConfig } = config;\n this.rootDir = projectConfig.rootDir;\n this.testFolder = path.dirname(context.testPath);\n this.withSsr = !pragmas['no-ssr'];\n this.ssrRequest = request;\n this.pragmas = pragmas;\n }\n\n async setup() {\n await super.setup();\n await this.runWebpack();\n if (this.withSsr) await this.runSsr();\n this.global.REACT_UTILS_FORCE_CLIENT_SIDE = true;\n }\n\n async teardown() {\n delete this.global.REACT_UTILS_FORCE_CLIENT_SIDE;\n\n // Resets module cache and @babel/register. Effectively this ensures that\n // the next time an instance of this environment is set up, all modules are\n // transformed by Babel from scratch, thus taking into account the latest\n // Babel config (which may change between different environment instances,\n // which does not seem to be taken into account by Babel / Node caches\n // automatically).\n Object.keys(require.cache).forEach((key) => {\n delete require.cache[key];\n });\n register.revert();\n super.teardown();\n }\n}\n"],"mappings":"gLAiBA,IAAAA,KAAA,CAAAC,sBAAA,CAAAC,OAAA,UACA,IAAAC,SAAA,CAAAF,sBAAA,CAAAC,OAAA,8BAEA,IAAAE,OAAA,CAAAF,OAAA,WAKA,IAAAG,SAAA,CAAAJ,sBAAA,CAAAC,OAAA,qBACA,IAAAI,qBAAA,CAAAL,sBAAA,CAAAC,OAAA,4BACA,IAAAK,MAAA,CAAAL,OAAA,UACA,IAAAM,QAAA,CAAAP,sBAAA,CAAAC,OAAA,aA5BA;AACA;AACA;AACA;AACA;AACA,GALA,CAMA,+DAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA,uDAKA,qDAEe,KAAM,CAAAO,SAAS,QAAS,CAAAC,6BAAS,CAC9C;AACF;AACA;AACA,KACEC,iBAAiBA,CAAA,CAAG,CAClB,GAA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AQA,CAAA,CAAG,CACf,MAAO,KAAI,CAAC3E,MAAM,CAAC0E,6BAA6B,CAEhD;AACA;AACA;AACA;AACA;AACA;AACAE,MAAM,CAACC,IAAI,CAAC/F,OAAO,CAACgG,KAAK,CAAC,CAACC,OAAO,CAAEC,GAAG,EAAK,CAC1C,MAAO,CAAAlG,OAAO,CAACgG,KAAK,CAACE,GAAG,CAC1B,CAAC,CAAC,CACF1C,iBAAQ,CAAC2C,MAAM,CAAC,CAAC,CACjB,KAAK,CAACN,QAAQ,CAAC,CACjB,CACF,CAACO,OAAA,CAAAC,OAAA,CAAA9F,SAAA"}
1
+ {"version":3,"file":"E2eSsrEnv.js","names":["_path","_interopRequireDefault","require","_lodash","_register","_jestEnvironmentJsdom","_memfs","_webpack","_renderer","E2eSsrEnv","JsdomEnv","loadWebpackConfig","options","pragmas","JSON","parse","defaults","context","testFolder","fs","global","webpackOutputFs","factory","path","resolve","rootDir","webpackConfig","buildInfo","existsSync","readFileSync","runWebpack","compiler","webpack","outputFileSystem","Promise","done","fail","run","err","stats","hasErrors","console","error","toJson","errors","Error","webpackStats","runSsr","logger","undefined","debug","noop","info","log","warn","root","process","cwd","register","envName","babelEnv","extensions","entry","p","Application","entryExportName","renderer","ssrFactory","status","markup","ssrRequest","cookie","send","set","value","locals","devMiddleware","ssrMarkup","ssrOptions","ssrStatus","constructor","config","docblockPragmas","request","url","csrfToken","projectConfig","dom","createFsFromVolume","Volume","dirname","testPath","withSsr","setup","REACT_UTILS_FORCE_CLIENT_SIDE","teardown","Object","keys","cache","forEach","key","revert","exports","default"],"sources":["../../../../../src/shared/utils/jest/E2eSsrEnv.js"],"sourcesContent":["/**\n * Jest environment for end-to-end SSR and client-side testing. It relies on\n * the standard react-utils mechanics to execute SSR of given scene, and also\n * Webpack build of the code for client-side execution, it further exposes\n * Jsdom environment for the client-side testing of the outcomes.\n */\n/* eslint-disable global-require, import/no-dynamic-require */\n\n// BEWARE: The module is not imported into the JU module / the main assembly of\n// the library, because doing so easily breaks stuff:\n// 1) This module depends on Node-specific modules, which would make JU\n// incompatible with JsDom if included into JU.\n// 2) If this module is weakly imported from somewhere else in the lib,\n// it seems to randomly break tests using it for a different reason,\n// probably some sort of a require-loop, or some issues with weak\n// require in that scenario.\n\nimport path from 'path';\n\nimport { defaults, noop, set } from 'lodash';\n\n// As this environment is a part of the Jest testing utils,\n// we assume development dependencies are available when it is used.\n/* eslint-disable import/no-extraneous-dependencies */\nimport register from '@babel/register';\nimport JsdomEnv from 'jest-environment-jsdom';\nimport { createFsFromVolume, Volume } from 'memfs';\nimport webpack from 'webpack';\n/* eslint-enable import/no-extraneous-dependencies */\n\nimport ssrFactory from 'server/renderer';\n\nexport default class E2eSsrEnv extends JsdomEnv {\n /**\n * Loads Webpack config, and exposes it to the environment via global\n * webpackConfig object.\n */\n loadWebpackConfig() {\n let options = this.pragmas['webpack-config-options'];\n options = options ? JSON.parse(options) : {};\n defaults(options, {\n context: this.testFolder,\n fs: this.global.webpackOutputFs,\n });\n\n let factory = this.pragmas['webpack-config-factory'] || '';\n factory = require(path.resolve(this.rootDir, factory));\n this.global.webpackConfig = factory(options);\n\n const fs = this.global.webpackOutputFs;\n let buildInfo = `${options.context}/.build-info`;\n if (fs.existsSync(buildInfo)) {\n buildInfo = fs.readFileSync(buildInfo, 'utf8');\n this.global.buildInfo = JSON.parse(buildInfo);\n }\n }\n\n /**\n * Executes Webpack build.\n * @return {Promise}\n */\n async runWebpack() {\n this.loadWebpackConfig();\n\n const compiler = webpack(this.global.webpackConfig);\n compiler.outputFileSystem = this.global.webpackOutputFs;\n return new Promise((done, fail) => {\n compiler.run((err, stats) => {\n if (err) fail(err);\n if (stats.hasErrors()) {\n console.error(stats.toJson().errors);\n fail(Error('Webpack compilation failed'));\n }\n\n this.global.webpackStats = stats.toJson();\n\n // Keeps reference to the raw Webpack stats object, which should be\n // explicitly passed to the server-side renderer alongside the request,\n // so that it can to pick up asset paths for different named chunks.\n this.webpackStats = stats;\n\n done();\n });\n });\n }\n\n async runSsr() {\n let options = this.pragmas['ssr-options'];\n options = options ? JSON.parse(options) : {};\n\n // TODO: This is temporary to shortcut the logging added to SSR.\n if (options.logger === undefined) {\n options.logger = {\n debug: noop,\n info: noop,\n log: noop,\n warn: noop,\n };\n }\n\n let root;\n switch (options.root) {\n case 'TEST': root = this.testFolder; break;\n default: root = process.cwd();\n }\n\n // Note: This enables Babel transformation for the code dynamically loaded\n // below, as the usual Jest Babel setup does not seem to apply to\n // the environment code, and imports from it.\n register({\n envName: options.babelEnv,\n extensions: ['.js', '.jsx', '.svg'],\n root,\n });\n\n if (!options.buildInfo) options.buildInfo = this.global.buildInfo;\n\n if (options.entry) {\n const p = path.resolve(this.testFolder, options.entry);\n options.Application = require(p)[options.entryExportName || 'default'];\n }\n\n const renderer = ssrFactory(this.global.webpackConfig, options);\n let status = 200; // OK\n const markup = await new Promise((done, fail) => {\n renderer(\n this.ssrRequest,\n\n // TODO: This will do for now, with the current implementation of\n // the renderer, but it will require a rework once the renderer is\n // updated to do streaming.\n {\n cookie: noop,\n send: done,\n set: noop,\n status: (value) => {\n status = value;\n },\n\n // This is how up-to-date Webpack stats are passed to the server in\n // development mode, and we use this here always, instead of having\n // to pass some information via filesystem.\n locals: {\n webpack: {\n devMiddleware: {\n stats: this.webpackStats,\n },\n },\n },\n },\n\n (error) => {\n if (error) fail(error);\n else done('');\n },\n );\n });\n\n this.global.ssrMarkup = markup;\n this.global.ssrOptions = options;\n this.global.ssrStatus = status;\n }\n\n constructor(config, context) {\n const pragmas = context.docblockPragmas;\n let request = pragmas['ssr-request'];\n request = request ? JSON.parse(request) : {};\n if (!request.url) request.url = '/';\n request.csrfToken = noop;\n\n // This ensures the initial JsDom URL matches the value we use for SSR.\n set(\n config.projectConfig,\n 'testEnvironmentOptions.url',\n `http://localhost${request.url}`,\n );\n\n super(config, context);\n\n this.global.dom = this.dom;\n this.global.webpackOutputFs = createFsFromVolume(new Volume());\n\n // Extracts necessary settings from config and context.\n const { projectConfig } = config;\n this.rootDir = projectConfig.rootDir;\n this.testFolder = path.dirname(context.testPath);\n this.withSsr = !pragmas['no-ssr'];\n this.ssrRequest = request;\n this.pragmas = pragmas;\n }\n\n async setup() {\n await super.setup();\n await this.runWebpack();\n if (this.withSsr) await this.runSsr();\n this.global.REACT_UTILS_FORCE_CLIENT_SIDE = true;\n }\n\n async teardown() {\n delete this.global.REACT_UTILS_FORCE_CLIENT_SIDE;\n\n // Resets module cache and @babel/register. Effectively this ensures that\n // the next time an instance of this environment is set up, all modules are\n // transformed by Babel from scratch, thus taking into account the latest\n // Babel config (which may change between different environment instances,\n // which does not seem to be taken into account by Babel / Node caches\n // automatically).\n Object.keys(require.cache).forEach((key) => {\n delete require.cache[key];\n });\n register.revert();\n super.teardown();\n }\n}\n"],"mappings":"gLAiBA,IAAAA,KAAA,CAAAC,sBAAA,CAAAC,OAAA,UAEA,IAAAC,OAAA,CAAAD,OAAA,WAKA,IAAAE,SAAA,CAAAH,sBAAA,CAAAC,OAAA,qBACA,IAAAG,qBAAA,CAAAJ,sBAAA,CAAAC,OAAA,4BACA,IAAAI,MAAA,CAAAJ,OAAA,UACA,IAAAK,QAAA,CAAAN,sBAAA,CAAAC,OAAA,aAGA,IAAAM,SAAA,CAAAP,sBAAA,CAAAC,OAAA,8BA9BA;AACA;AACA;AACA;AACA;AACA,GALA,CAMA,+DAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA,uDAKA,qDAIe,KAAM,CAAAO,SAAS,QAAS,CAAAC,6BAAS,CAC9C;AACF;AACA;AACA,KACEC,iBAAiBA,CAAA,CAAG,CAClB,GAAI,CAAAC,OAAO,CAAG,IAAI,CAACC,OAAO,CAAC,wBAAwB,CAAC,CACpDD,OAAO,CAAGA,OAAO,CAAGE,IAAI,CAACC,KAAK,CAACH,OAAO,CAAC,CAAG,CAAC,CAAC,CAC5C,GAAAI,gBAAQ,EAACJ,OAAO,CAAE,CAChBK,OAAO,CAAE,IAAI,CAACC,UAAU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