@dr.pogodin/react-utils 1.23.0 → 1.23.2

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 (81) hide show
  1. package/LICENSE.md +4 -3
  2. package/README.md +4 -5
  3. package/bin/release.sh +2 -0
  4. package/build/development/client/index.js.map +1 -1
  5. package/build/development/client/init.js.map +1 -1
  6. package/build/development/index.js.map +1 -1
  7. package/build/development/server/Cache.js.map +1 -1
  8. package/build/development/server/index.js.map +1 -1
  9. package/build/development/server/renderer.js.map +1 -1
  10. package/build/development/server/server.js.map +1 -1
  11. package/build/development/server/utils/errors.js.map +1 -1
  12. package/build/development/shared/components/Button/index.js.map +1 -1
  13. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  14. package/build/development/shared/components/CodeSplit/index.js.map +1 -1
  15. package/build/development/shared/components/Dropdown/index.js.map +1 -1
  16. package/build/development/shared/components/GenericLink/index.js.map +1 -1
  17. package/build/development/shared/components/Input/index.js.map +1 -1
  18. package/build/development/shared/components/Link.js.map +1 -1
  19. package/build/development/shared/components/MetaTags.js.map +1 -1
  20. package/build/development/shared/components/Modal/index.js.map +1 -1
  21. package/build/development/shared/components/NavLink.js.map +1 -1
  22. package/build/development/shared/components/PageLayout/index.js.map +1 -1
  23. package/build/development/shared/components/ScalableRect/index.js.map +1 -1
  24. package/build/development/shared/components/Throbber/index.js.map +1 -1
  25. package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
  26. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  27. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  28. package/build/development/shared/components/index.js.map +1 -1
  29. package/build/development/shared/utils/Barrier.js.map +1 -1
  30. package/build/development/shared/utils/Emitter.js.map +1 -1
  31. package/build/development/shared/utils/Semaphore.js +1 -1
  32. package/build/development/shared/utils/Semaphore.js.map +1 -1
  33. package/build/development/shared/utils/config.js.map +1 -1
  34. package/build/development/shared/utils/index.js.map +1 -1
  35. package/build/development/shared/utils/isomorphy.js.map +1 -1
  36. package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  37. package/build/development/shared/utils/jest/index.js.map +1 -1
  38. package/build/development/shared/utils/splitComponent.js.map +1 -1
  39. package/build/development/shared/utils/time.js.map +1 -1
  40. package/build/development/shared/utils/webpack.js.map +1 -1
  41. package/build/development/web.bundle.js +1 -1
  42. package/build/production/client/index.js.map +1 -1
  43. package/build/production/client/init.js.map +1 -1
  44. package/build/production/index.js.map +1 -1
  45. package/build/production/server/Cache.js.map +1 -1
  46. package/build/production/server/index.js.map +1 -1
  47. package/build/production/server/renderer.js.map +1 -1
  48. package/build/production/server/server.js.map +1 -1
  49. package/build/production/server/utils/errors.js.map +1 -1
  50. package/build/production/shared/components/Button/index.js.map +1 -1
  51. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  52. package/build/production/shared/components/CodeSplit/index.js.map +1 -1
  53. package/build/production/shared/components/Dropdown/index.js.map +1 -1
  54. package/build/production/shared/components/GenericLink/index.js.map +1 -1
  55. package/build/production/shared/components/Input/index.js.map +1 -1
  56. package/build/production/shared/components/Link.js.map +1 -1
  57. package/build/production/shared/components/MetaTags.js.map +1 -1
  58. package/build/production/shared/components/Modal/index.js.map +1 -1
  59. package/build/production/shared/components/NavLink.js.map +1 -1
  60. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  61. package/build/production/shared/components/ScalableRect/index.js.map +1 -1
  62. package/build/production/shared/components/Throbber/index.js.map +1 -1
  63. package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
  64. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  65. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  66. package/build/production/shared/components/index.js.map +1 -1
  67. package/build/production/shared/utils/Barrier.js.map +1 -1
  68. package/build/production/shared/utils/Emitter.js.map +1 -1
  69. package/build/production/shared/utils/Semaphore.js +1 -1
  70. package/build/production/shared/utils/Semaphore.js.map +1 -1
  71. package/build/production/shared/utils/config.js.map +1 -1
  72. package/build/production/shared/utils/index.js.map +1 -1
  73. package/build/production/shared/utils/isomorphy.js.map +1 -1
  74. package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  75. package/build/production/shared/utils/jest/index.js.map +1 -1
  76. package/build/production/shared/utils/splitComponent.js.map +1 -1
  77. package/build/production/shared/utils/time.js.map +1 -1
  78. package/build/production/shared/utils/webpack.js.map +1 -1
  79. package/build/production/web.bundle.js +1 -1
  80. package/build/production/web.bundle.js.map +1 -1
  81. package/package.json +18 -18
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["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","wrapper","e","clientX","clientY","ThemedWrapper","themed","defaultTheme","PLACEMENTS","propTypes","PT","node","oneOf","Object","values","themeType","isRequired","defaultProps","ABOVE_CURSOR"],"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,6DACA,4BAEA,kCAEA,2DAAgD,igCAPhD,yKAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAASA,QAAO,CAAC,CACfC,QAAQ,CACRC,SAAS,CACTC,GAAG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E,IAAMrB,cAAc,CAAC,KAAK,CAAE,CAC1C,WAAW,CAAGsB,CAAC,EAAKpB,oBAAoB,CAACoB,CAAC,CAACC,OAAO,CAAED,CAAC,CAACE,OAAO,CAAE,CAC/D,GAAG,CAAE1B,UAAW,WAGdC,WAAW,EAAIL,GAAG,GAAK,IAAI,cACzB,oBAAC,gBAAO,EAAC,GAAG,CAAEE,UAAW,CAAC,KAAK,CAAED,KAAM,UAAED,GAAG,EAAW,CACrD,IAAI,CAETF,QAAQ,GAGf,CAEA,KAAMiC,cAAa,CAAG,GAAAC,aAAM,EAC1B,aAAa,CACb,CACE,YAAY,CACZ,OAAO,CACP,WAAW,CACX,SAAS,CACT,SAAS,CACV,CACDC,YAAY,CACb,CAACpC,OAAO,CAAC,CAEVkC,aAAa,CAACG,UAAU,CAAGA,mBAAU,CAErCrC,OAAO,CAACsC,SAAS,CAAG,CAClBrC,QAAQ,CAAEsC,kBAAE,CAACC,IAAI,CACjBtC,SAAS,CAAEqC,kBAAE,CAACE,KAAK,CAACC,MAAM,CAACC,MAAM,CAACN,mBAAU,CAAC,CAAC,CAC9CjC,KAAK,CAAE8B,aAAa,CAACU,SAAS,CAACC,UAAU,CACzC1C,GAAG,CAAEoC,kBAAE,CAACC,IACV,CAAC,CAEDxC,OAAO,CAAC8C,YAAY,CAAG,CACrB7C,QAAQ,CAAE,IAAI,CACdC,SAAS,CAAEmC,mBAAU,CAACU,YAAY,CAClC5C,GAAG,CAAE,IACP,CAAC,CAAC,aAEa+B,aAAa"}
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,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,CAA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EAACsD,GAAG,CAAEjC,UAAW,CAACD,KAAK,CAAEA,KAAM,CAAAH,QAAA,CAAEE,GAAG,EAAW,CACrD,IAAI,CAETF,QAAQ,GAGf,CAEA,KAAM,CAAAuC,aAAa,CAAG,GAAAC,aAAM,EAC1B,aAAa,CACb,CACE,YAAY,CACZ,OAAO,CACP,WAAW,CACX,SAAS,CACT,SAAS,CACV,CACD1C,YAAY,CACb,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 +1 @@
1
- {"version":3,"file":"index.js","names":["YouTubeVideo","autoplay","src","theme","title","url","query","split","qs","parse","videoId","v","match","stringify","container","throbberTheme","video","ThemedYouTubeVideo","themed","baseTheme","propTypes","PT","bool","string","isRequired","themeType","defaultProps"],"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,6DACA,8CACA,qEACA,6EACA,6DAA2C,kPAK3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAASA,aAAY,CAAC,CACpBC,QAAQ,CACRC,GAAG,CACHC,KAAK,CACLC,KACF,CAAC,CAAE,CACD,GAAI,CAACC,GAAG,CAAEC,KAAK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"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,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,EAACpB,aAAA,CAAAqB,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,EAAG,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,EACb,GAGR,CAEA,KAAM,CAAAoB,kBAAkB,CAAG,GAAAC,oBAAM,EAC/B,cAAc,CACd,CACE,WAAW,CACX,OAAO,CACR,CACD3B,SAAS,CACV,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 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../src/shared/components/index.js"],"sourcesContent":["/**\n * Just an aggregation of all exported components into a single module.\n */\n\nexport { default as Button } from 'components/Button';\nexport { default as Checkbox } from 'components/Checkbox';\nexport { default as client } from 'client';\nexport { default as Dropdown } from 'components/Dropdown';\nexport { default as Input } from 'components/Input';\nexport { default as Link } from 'components/Link';\nexport { default as PageLayout } from 'components/PageLayout';\nexport { default as MetaTags } from 'components/MetaTags';\nexport { default as Modal, BaseModal } from 'components/Modal';\nexport { default as NavLink } from 'components/NavLink';\nexport { default as ScalableRect } from 'components/ScalableRect';\nexport { default as Throbber } from 'components/Throbber';\nexport { default as WithTooltip } from 'components/WithTooltip';\nexport { default as YouTubeVideo } from 'components/YouTubeVideo';\n"],"mappings":"goDAIA,wDACA,4DACA,4DACA,4DACA,sDACA,oDACA,gEACA,4DACA,uDACA,0DACA,oEACA,4DACA,kEACA,oEAAkE"}
1
+ {"version":3,"file":"index.js","names":["_Button","_interopRequireDefault","require","_Checkbox","_client","_Dropdown","_Input","_Link","_PageLayout","_MetaTags","_Modal","_interopRequireWildcard","_NavLink","_ScalableRect","_Throbber","_WithTooltip","_YouTubeVideo","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set"],"sources":["../../../../src/shared/components/index.js"],"sourcesContent":["/**\n * Just an aggregation of all exported components into a single module.\n */\n\nexport { default as Button } from 'components/Button';\nexport { default as Checkbox } from 'components/Checkbox';\nexport { default as client } from 'client';\nexport { default as Dropdown } from 'components/Dropdown';\nexport { default as Input } from 'components/Input';\nexport { default as Link } from 'components/Link';\nexport { default as PageLayout } from 'components/PageLayout';\nexport { default as MetaTags } from 'components/MetaTags';\nexport { default as Modal, BaseModal } from 'components/Modal';\nexport { default as NavLink } from 'components/NavLink';\nexport { default as ScalableRect } from 'components/ScalableRect';\nexport { default as Throbber } from 'components/Throbber';\nexport { default as WithTooltip } from 'components/WithTooltip';\nexport { default as YouTubeVideo } from 'components/YouTubeVideo';\n"],"mappings":"goDAIA,IAAAA,OAAA,CAAAC,sBAAA,CAAAC,OAAA,cACA,IAAAC,SAAA,CAAAF,sBAAA,CAAAC,OAAA,gBACA,IAAAE,OAAA,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W,GAAA,OAAAI,IAAA,CAAAR,qBAAA,CAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,CAAAW,GAAA,UAAAI,IAAA,GAAAA,IAAA,CAAAV,GAAA,EAAAU,IAAA,CAAAC,GAAA,GAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,CAAAK,GAAA,CAAAI,IAAA,OAAAT,MAAA,CAAAK,GAAA,EAAAX,GAAA,CAAAW,GAAA,IAAAL,MAAA,CAAAJ,OAAA,CAAAF,GAAA,IAAAG,KAAA,EAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,CAAAM,MAAA,SAAAA,MAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"Barrier.js","names":["Barrier","Promise","resolve","resolved","reject","rejected","constructor","executor","resolveRef","rejectRef","value","error","then","onFulfilled","onRejected","res","newBarrier"],"sources":["../../../../src/shared/utils/Barrier.js"],"sourcesContent":["/**\n * Barrier is just a Promise which has resolve and reject exposed as instance\n * methods.\n */\nexport class Barrier extends Promise {\n #resolve;\n\n #resolved = false;\n\n #reject;\n\n #rejected = false;\n\n constructor(executor) {\n let resolveRef;\n let rejectRef;\n super((resolve, reject) => {\n resolveRef = (value) => {\n resolve(value);\n this.#resolved = true;\n };\n rejectRef = (error) => {\n reject(error);\n this.#rejected = true;\n };\n if (executor) executor(resolveRef, rejectRef);\n });\n this.#resolve = resolveRef;\n this.#reject = rejectRef;\n }\n\n get resolve() { return this.#resolve; }\n\n get resolved() { return this.#resolved; }\n\n get reject() { return this.#reject; }\n\n get rejected() { return this.#rejected; }\n\n then(onFulfilled, onRejected) {\n const res = super.then(onFulfilled, onRejected);\n res.#resolve = this.#resolve;\n res.#reject = this.#reject;\n return res;\n }\n}\n\n/**\n * Creates a new Barrier.\n * @returns {Barrier}\n */\nexport function newBarrier(executor) {\n return new Barrier(executor);\n}\n"],"mappings":"2HAAA;AACA;AACA;AACA,GACO,KAAMA,QAAO,QAASC,QAAQ,CACnC,CAACC,OAAO,CAER,CA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":"Barrier.js","names":["Barrier","Promise","resolve","resolved","reject","rejected","constructor","executor","resolveRef","rejectRef","value","error","then","onFulfilled","onRejected","res","exports","newBarrier"],"sources":["../../../../src/shared/utils/Barrier.js"],"sourcesContent":["/**\n * Barrier is just a Promise which has resolve and reject exposed as instance\n * methods.\n */\nexport class Barrier extends Promise {\n #resolve;\n\n #resolved = false;\n\n #reject;\n\n #rejected = false;\n\n constructor(executor) {\n let resolveRef;\n let rejectRef;\n super((resolve, reject) => {\n resolveRef = (value) => {\n resolve(value);\n this.#resolved = true;\n };\n rejectRef = (error) => {\n reject(error);\n this.#rejected = true;\n };\n if (executor) executor(resolveRef, rejectRef);\n });\n this.#resolve = resolveRef;\n this.#reject = rejectRef;\n }\n\n get resolve() { return this.#resolve; }\n\n get resolved() { return this.#resolved; }\n\n get reject() { return this.#reject; }\n\n get rejected() { return this.#rejected; }\n\n then(onFulfilled, onRejected) {\n const res = super.then(onFulfilled, onRejected);\n res.#resolve = this.#resolve;\n res.#reject = this.#reject;\n return res;\n }\n}\n\n/**\n * Creates a new Barrier.\n * @returns {Barrier}\n */\nexport function newBarrier(executor) {\n return new Barrier(executor);\n}\n"],"mappings":"2HAAA;AACA;AACA;AACA,GACO,KAAM,CAAAA,OAAO,QAAS,CAAAC,OAAQ,CACnC,CAACC,OAAO,CAER,CAACC,QAAQ,CAAG,KAAK,CAEjB,CAACC,MAAM,CAEP,CAACC,QAAQ,CAAG,KAAK,CAEjBC,WAAWA,CAACC,QAAQ,CAAE,CACpB,GAAI,CAAAC,UAAU,CACd,GAAI,CAAAC,SAAS,CACb,KAAK,CAAC,CAACP,OAAO,CAAEE,MAAM,GAAK,CACzBI,UAAU,CAAIE,KAAK,EAAK,CACtBR,OAAO,CAACQ,KAAK,CAAC,CACd,IAAI,CAAC,CAACP,QAAQ,CAAG,IACnB,CAAC,CACDM,SAAS,CAAIE,KAAK,EAAK,CACrBP,MAAM,CAACO,KAAK,CAAC,CACb,IAAI,CAAC,CAACN,QAAQ,CAAG,IACnB,CAAC,CACD,GAAIE,QAAQ,CAAEA,QAAQ,CAACC,UAAU,CAAEC,SAAS,CAC9C,CAAC,CAAC,CACF,IAAI,CAAC,CAACP,OAAO,CAAGM,UAAU,CAC1B,IAAI,CAAC,CAACJ,MAAM,CAAGK,SACjB,CAEA,GAAI,CAAAP,OAAOA,CAAA,CAAG,CAAE,MAAO,KAAI,CAAC,CAACA,OAAS,CAEtC,GAAI,CAAAC,QAAQA,CAAA,CAAG,CAAE,MAAO,KAAI,CAAC,CAACA,QAAU,CAExC,GAAI,CAAAC,MAAMA,CAAA,CAAG,CAAE,MAAO,KAAI,CAAC,CAACA,MAAQ,CAEpC,GAAI,CAAAC,QAAQA,CAAA,CAAG,CAAE,MAAO,KAAI,CAAC,CAACA,QAAU,CAExCO,IAAIA,CAACC,WAAW,CAAEC,UAAU,CAAE,CAC5B,KAAM,CAAAC,GAAG,CAAG,KAAK,CAACH,IAAI,CAACC,WAAW,CAAEC,UAAU,CAAC,CAC/CC,GAAG,CAAC,CAACb,OAAO,CAAG,IAAI,CAAC,CAACA,OAAO,CAC5Ba,GAAG,CAAC,CAACX,MAAM,CAAG,IAAI,CAAC,CAACA,MAAM,CAC1B,MAAO,CAAAW,GACT,CACF,CAEA;AACA;AACA;AACA,GAHAC,OAAA,CAAAhB,OAAA,CAAAA,OAAA,CAIO,QAAS,CAAAiB,UAAUA,CAACV,QAAQ,CAAE,CACnC,MAAO,IAAI,CAAAP,OAAO,CAACO,QAAQ,CAC7B"}
@@ -1 +1 @@
1
- {"version":3,"file":"Emitter.js","names":["Emitter","constructor","listeners","hasListeners","length","addListener","listener","includes","push","removeListener","emit","args","i","idx","indexOf","splice"],"sources":["../../../../src/shared/utils/Emitter.js"],"sourcesContent":["/**\n * Simple listeneable data Emitter.\n */\nexport default class Emitter {\n /**\n * Creates a new Emitter.\n */\n constructor() {\n this.listeners = [];\n }\n\n /**\n * Returns \"true\" if any listener is connected; \"false\" otherwise.\n * @return {boolean}\n */\n get hasListeners() {\n return !!this.listeners.length;\n }\n\n /**\n * Adds `listener` if it is not already connected.\n * @param {function} listener\n * @return {function} Unsubscribe function.\n */\n addListener(listener) {\n if (!this.listeners.includes(listener)) {\n this.listeners.push(listener);\n }\n return () => this.removeListener(listener);\n }\n\n /**\n * Calls every connected listener with the given arguments.\n * @param {...any} args\n */\n emit(...args) {\n const { listeners } = this;\n for (let i = 0; i < listeners.length; ++i) {\n listeners[i](...args);\n }\n }\n\n /**\n * Removes specified `listener`, if connected.\n * @param {function} listener\n */\n removeListener(listener) {\n const idx = this.listeners.indexOf(listener);\n if (idx >= 0) this.listeners.splice(idx, 1);\n }\n}\n"],"mappings":"6FAAA;AACA;AACA,GACe,KAAMA,QAAQ,CAC3B;AACF;AACA,KACEC,WAAW,EAAG,CACZ,IAAI,CAACC,SAAS,CAAG,EACnB,CAEA;AACF;AACA;AACA,KACE,GAAIC,aAAY,EAAG,CACjB,MAAO,CAAC,CAAC,IAAI,CAACD,SAAS,CAACE,MAC1B,CAEA;AACF;AACA;AACA;AACA,KACEC,WAAW,CAACC,QAAQ,CAAE,CACpB,GAAI,CAAC,IAAI,CAACJ,SAAS,CAACK,QAAQ,CAACD,QAAQ,CAAC,CAAE,CACtC,IAAI,CAACJ,SAAS,CAACM,IAAI,CAACF,QAAQ,CAC9B,CACA,MAAO,IAAM,IAAI,CAACG,cAAc,CAACH,QAAQ,CAC3C,CAEA;AACF;AACA;AACA,KACEI,IAAI,CAAC,GAAGC,IAAI,CAAE,CACZ,KAAM,CAAET,SAAU,CAAC,CAAG,IAAI,CAC1B,IAAK,GAAIU,EAAC,CAAG,CAAC,CAAEA,CAAC,CAAGV,SAAS,CAACE,MAAM,CAAE,EAAEQ,CAAC,CAAE,CACzCV,SAAS,CAACU,CAAC,CAAC,CAAC,GAAGD,IAAI,CACtB,CACF,CAEA;AACF;AACA;AACA,KACEF,cAAc,CAACH,QAAQ,CAAE,CACvB,KAAMO,IAAG,CAAG,IAAI,CAACX,SAAS,CAACY,OAAO,CAACR,QAAQ,CAAC,CAC5C,GAAIO,GAAG,EAAI,CAAC,CAAE,IAAI,CAACX,SAAS,CAACa,MAAM,CAACF,GAAG,CAAE,CAAC,CAC5C,CACF,CAAC"}
1
+ {"version":3,"file":"Emitter.js","names":["Emitter","constructor","listeners","hasListeners","length","addListener","listener","includes","push","removeListener","emit","args","i","idx","indexOf","splice","exports","default"],"sources":["../../../../src/shared/utils/Emitter.js"],"sourcesContent":["/**\n * Simple listeneable data Emitter.\n */\nexport default class Emitter {\n /**\n * Creates a new Emitter.\n */\n constructor() {\n this.listeners = [];\n }\n\n /**\n * Returns \"true\" if any listener is connected; \"false\" otherwise.\n * @return {boolean}\n */\n get hasListeners() {\n return !!this.listeners.length;\n }\n\n /**\n * Adds `listener` if it is not already connected.\n * @param {function} listener\n * @return {function} Unsubscribe function.\n */\n addListener(listener) {\n if (!this.listeners.includes(listener)) {\n this.listeners.push(listener);\n }\n return () => this.removeListener(listener);\n }\n\n /**\n * Calls every connected listener with the given arguments.\n * @param {...any} args\n */\n emit(...args) {\n const { listeners } = this;\n for (let i = 0; i < listeners.length; ++i) {\n listeners[i](...args);\n }\n }\n\n /**\n * Removes specified `listener`, if connected.\n * @param {function} listener\n */\n removeListener(listener) {\n const idx = this.listeners.indexOf(listener);\n if (idx >= 0) this.listeners.splice(idx, 1);\n }\n}\n"],"mappings":"6FAAA;AACA;AACA,GACe,KAAM,CAAAA,OAAQ,CAC3B;AACF;AACA,KACEC,WAAWA,CAAA,CAAG,CACZ,IAAI,CAACC,SAAS,CAAG,EACnB,CAEA;AACF;AACA;AACA,KACE,GAAI,CAAAC,YAAYA,CAAA,CAAG,CACjB,MAAO,CAAC,CAAC,IAAI,CAACD,SAAS,CAACE,MAC1B,CAEA;AACF;AACA;AACA;AACA,KACEC,WAAWA,CAACC,QAAQ,CAAE,CACpB,GAAI,CAAC,IAAI,CAACJ,SAAS,CAACK,QAAQ,CAACD,QAAQ,CAAC,CAAE,CACtC,IAAI,CAACJ,SAAS,CAACM,IAAI,CAACF,QAAQ,CAC9B,CACA,MAAO,IAAM,IAAI,CAACG,cAAc,CAACH,QAAQ,CAC3C,CAEA;AACF;AACA;AACA,KACEI,IAAIA,CAAC,GAAGC,IAAI,CAAE,CACZ,KAAM,CAAET,SAAU,CAAC,CAAG,IAAI,CAC1B,IAAK,GAAI,CAAAU,CAAC,CAAG,CAAC,CAAEA,CAAC,CAAGV,SAAS,CAACE,MAAM,CAAE,EAAEQ,CAAC,CAAE,CACzCV,SAAS,CAACU,CAAC,CAAC,CAAC,GAAGD,IAAI,CACtB,CACF,CAEA;AACF;AACA;AACA,KACEF,cAAcA,CAACH,QAAQ,CAAE,CACvB,KAAM,CAAAO,GAAG,CAAG,IAAI,CAACX,SAAS,CAACY,OAAO,CAACR,QAAQ,CAAC,CAC5C,GAAIO,GAAG,EAAI,CAAC,CAAE,IAAI,CAACX,SAAS,CAACa,MAAM,CAACF,GAAG,CAAE,CAAC,CAC5C,CACF,CAACG,OAAA,CAAAC,OAAA,CAAAjB,OAAA"}
@@ -3,7 +3,7 @@
3
3
  */class Semaphore{constructor(ready){this.#ready=!!ready}get ready(){return this.#ready}setReady(ready){const bool=!!ready;if(this.#ready!==bool){this.#ready=bool;if(bool&&!this.#draining&&this.#queue.length)this.#drainQueue()}}/**
4
4
  * Waits until the semaphore is ready, and marks it as non-ready (seizes it).
5
5
  * @return {Promise}
6
- */async seize(){return this.waitReady(true)}async waitReady(seize=false){if(!this.#ready||this.#queue.length){const barrier=new _Barrier.Barrier;this.#queue.push(barrier);await barrier;if(seize)this.#ready=false;this.#drainLock.resolve()}}// Private members below this point.
6
+ */async seize(){return this.waitReady(true)}async waitReady(seize=false){if(!this.#ready||this.#queue.length){const barrier=new _Barrier.Barrier;this.#queue.push(barrier);await barrier;if(seize)this.#ready=false;this.#drainLock.resolve()}else if(seize)this.#ready=false}// Private members below this point.
7
7
  /**
8
8
  * If semaphore is ready, it releases the next barrier in the queue, if any,
9
9
  * and reschedules itself for a call in the next event loop iteration.
@@ -1 +1 @@
1
- {"version":3,"file":"Semaphore.js","names":["Semaphore","constructor","ready","setReady","bool","draining","queue","length","drainQueue","seize","waitReady","barrier","Barrier","push","drainLock","resolve","shift"],"sources":["../../../../src/shared/utils/Semaphore.js"],"sourcesContent":["import { Barrier } from './Barrier';\n\n/**\n * Implements a simple semaphore for async code logic.\n */\nexport default class Semaphore {\n constructor(ready) {\n this.#ready = !!ready;\n }\n\n get ready() { return this.#ready; }\n\n setReady(ready) {\n const bool = !!ready;\n if (this.#ready !== bool) {\n this.#ready = bool;\n if (bool && !this.#draining && this.#queue.length) this.#drainQueue();\n }\n }\n\n /**\n * Waits until the semaphore is ready, and marks it as non-ready (seizes it).\n * @return {Promise}\n */\n async seize() {\n return this.waitReady(true);\n }\n\n async waitReady(seize = false) {\n if (!this.#ready || this.#queue.length) {\n const barrier = new Barrier();\n this.#queue.push(barrier);\n await barrier;\n if (seize) this.#ready = false;\n this.#drainLock.resolve();\n }\n }\n\n // Private members below this point.\n\n /**\n * If semaphore is ready, it releases the next barrier in the queue, if any,\n * and reschedules itself for a call in the next event loop iteration.\n * Otherwise, it breaks the queue draining loop, which will be restarted\n * the next time the semaphore is set ready.\n */\n async #drainQueue() {\n this.#draining = true;\n while (this.#ready && this.#queue.length) {\n this.#drainLock = new Barrier();\n this.#queue[0].resolve();\n await this.#drainLock; // eslint-disable-line no-await-in-loop\n this.#queue.shift();\n }\n this.#draining = false;\n this.#drainLock = null;\n }\n\n // \"true\" when the drain queue process is running (and thus no need to start\n // a new one).\n #draining = false;\n\n // Each time a Promise from drain queue is resolved this drainLock is set\n // to block further queue draining until the promise resolution handler\n // (.seize() or .waitReady()) unlocks it, thus confirming it is fine\n // to continue the draining. This is specifically important for .seize(),\n // which should have a chance to switch semaphore state to non-ready prior\n // to next Promise in the queue being unlocked.\n #drainLock = null;\n\n // The array of barriers set for each async code flow awaiting for\n // the Semaphore to become ready.\n #queue = [];\n\n #ready;\n}\n"],"mappings":"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,CAACN,KAAK,CAAC,CAAC,CAAC,CAACS,OAAO,EAAE,CACxB,KAAM,KAAI,CAAC,CAACD,SAAS,CAAE;AACvB,IAAI,CAAC,CAACR,KAAK,CAACU,KAAK,EACnB,CACA,IAAI,CAAC,CAACX,QAAQ,CAAG,KAAK,CACtB,IAAI,CAAC,CAACS,SAAS,CAAG,IACpB,CAEA;AACA;AACA,CAACT,QAAQ,CAAG,KAAK,CAEjB;AACA;AACA;AACA;AACA;AACA;AACA,CAACS,SAAS,CAAG,IAAI,CAEjB;AACA;AACA,CAACR,KAAK,CAAG,EAAE,CAEX,CAACJ,KACH,CAAC"}
1
+ {"version":3,"file":"Semaphore.js","names":["_Barrier","require","Semaphore","constructor","ready","setReady","bool","draining","queue","length","drainQueue","seize","waitReady","barrier","Barrier","push","drainLock","resolve","#drainQueue","shift","exports","default"],"sources":["../../../../src/shared/utils/Semaphore.js"],"sourcesContent":["import { Barrier } from './Barrier';\n\n/**\n * Implements a simple semaphore for async code logic.\n */\nexport default class Semaphore {\n constructor(ready) {\n this.#ready = !!ready;\n }\n\n get ready() { return this.#ready; }\n\n setReady(ready) {\n const bool = !!ready;\n if (this.#ready !== bool) {\n this.#ready = bool;\n if (bool && !this.#draining && this.#queue.length) this.#drainQueue();\n }\n }\n\n /**\n * Waits until the semaphore is ready, and marks it as non-ready (seizes it).\n * @return {Promise}\n */\n async seize() {\n return this.waitReady(true);\n }\n\n async waitReady(seize = false) {\n if (!this.#ready || this.#queue.length) {\n const barrier = new Barrier();\n this.#queue.push(barrier);\n await barrier;\n if (seize) this.#ready = false;\n this.#drainLock.resolve();\n } else if (seize) this.#ready = false;\n }\n\n // Private members below this point.\n\n /**\n * If semaphore is ready, it releases the next barrier in the queue, if any,\n * and reschedules itself for a call in the next event loop iteration.\n * Otherwise, it breaks the queue draining loop, which will be restarted\n * the next time the semaphore is set ready.\n */\n async #drainQueue() {\n this.#draining = true;\n while (this.#ready && this.#queue.length) {\n this.#drainLock = new Barrier();\n this.#queue[0].resolve();\n await this.#drainLock; // eslint-disable-line no-await-in-loop\n this.#queue.shift();\n }\n this.#draining = false;\n this.#drainLock = null;\n }\n\n // \"true\" when the drain queue process is running (and thus no need to start\n // a new one).\n #draining = false;\n\n // Each time a Promise from drain queue is resolved this drainLock is set\n // to block further queue draining until the promise resolution handler\n // (.seize() or .waitReady()) unlocks it, thus confirming it is fine\n // to continue the draining. This is specifically important for .seize(),\n // which should have a chance to switch semaphore state to non-ready prior\n // to next Promise in the queue being unlocked.\n #drainLock = null;\n\n // The array of barriers set for each async code flow awaiting for\n // the Semaphore to become ready.\n #queue = [];\n\n #ready;\n}\n"],"mappings":"6FAAA,IAAAA,QAAA,CAAAC,OAAA,cAEA;AACA;AACA,GACe,KAAM,CAAAC,SAAU,CAC7BC,WAAWA,CAACC,KAAK,CAAE,CACjB,IAAI,CAAC,CAACA,KAAK,CAAG,CAAC,CAACA,KAClB,CAEA,GAAI,CAAAA,KAAKA,CAAA,CAAG,CAAE,MAAO,KAAI,CAAC,CAACA,KAAO,CAElCC,QAAQA,CAACD,KAAK,CAAE,CACd,KAAM,CAAAE,IAAI,CAAG,CAAC,CAACF,KAAK,CACpB,GAAI,IAAI,CAAC,CAACA,KAAK,GAAKE,IAAI,CAAE,CACxB,IAAI,CAAC,CAACF,KAAK,CAAGE,IAAI,CAClB,GAAIA,IAAI,EAAI,CAAC,IAAI,CAAC,CAACC,QAAQ,EAAI,IAAI,CAAC,CAACC,KAAK,CAACC,MAAM,CAAE,IAAI,CAAC,CAACC,UAAU,EACrE,CACF,CAEA;AACF;AACA;AACA,KACE,KAAM,CAAAC,KAAKA,CAAA,CAAG,CACZ,MAAO,KAAI,CAACC,SAAS,CAAC,IAAI,CAC5B,CAEA,KAAM,CAAAA,SAASA,CAACD,KAAK,CAAG,KAAK,CAAE,CAC7B,GAAI,CAAC,IAAI,CAAC,CAACP,KAAK,EAAI,IAAI,CAAC,CAACI,KAAK,CAACC,MAAM,CAAE,CACtC,KAAM,CAAAI,OAAO,CAAG,GAAI,CAAAC,gBAAS,CAC7B,IAAI,CAAC,CAACN,KAAK,CAACO,IAAI,CAACF,OAAO,CAAC,CACzB,KAAM,CAAAA,OAAO,CACb,GAAIF,KAAK,CAAE,IAAI,CAAC,CAACP,KAAK,CAAG,KAAK,CAC9B,IAAI,CAAC,CAACY,SAAS,CAACC,OAAO,EACzB,CAAC,IAAM,IAAIN,KAAK,CAAE,IAAI,CAAC,CAACP,KAAK,CAAG,KAClC,CAEA;AAEA;AACF;AACA;AACA;AACA;AACA,KACE,KAAM,CAACM,UAAUQ,CAAA,CAAG,CAClB,IAAI,CAAC,CAACX,QAAQ,CAAG,IAAI,CACrB,MAAO,IAAI,CAAC,CAACH,KAAK,EAAI,IAAI,CAAC,CAACI,KAAK,CAACC,MAAM,CAAE,CACxC,IAAI,CAAC,CAACO,SAAS,CAAG,GAAI,CAAAF,gBAAS,CAC/B,IAAI,CAAC,CAACN,KAAK,CAAC,CAAC,CAAC,CAACS,OAAO,EAAE,CACxB,KAAM,KAAI,CAAC,CAACD,SAAS,CAAE;AACvB,IAAI,CAAC,CAACR,KAAK,CAACW,KAAK,EACnB,CACA,IAAI,CAAC,CAACZ,QAAQ,CAAG,KAAK,CACtB,IAAI,CAAC,CAACS,SAAS,CAAG,IACpB,CAEA;AACA;AACA,CAACT,QAAQ,CAAG,KAAK,CAEjB;AACA;AACA;AACA;AACA;AACA;AACA,CAACS,SAAS,CAAG,IAAI,CAEjB;AACA;AACA,CAACR,KAAK,CAAG,EAAE,CAEX,CAACJ,KACH,CAACgB,OAAA,CAAAC,OAAA,CAAAnB,SAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":["requireWeak","window","CONFIG"],"sources":["../../../../src/shared/utils/config.js"],"sourcesContent":["/* global window */\n\nimport { requireWeak } from './webpack';\n\n/* eslint-disable global-require */\nexport default requireWeak('config') || window.CONFIG || {};\n/* eslint-enable global-require */\n"],"mappings":"6FAEA,kCAFA,oBAIA,gDACe,GAAAA,oBAAW,EAAC,QAAQ,CAAC,EAAIC,MAAM,CAACC,MAAM,EAAI,CAAC,CAAC,CAC3D"}
1
+ {"version":3,"file":"config.js","names":["_webpack","require","_default","requireWeak","window","CONFIG","exports","default"],"sources":["../../../../src/shared/utils/config.js"],"sourcesContent":["/* global window */\n\nimport { requireWeak } from './webpack';\n\n/* eslint-disable global-require */\nexport default requireWeak('config') || window.CONFIG || {};\n/* eslint-enable global-require */\n"],"mappings":"6FAEA,IAAAA,QAAA,CAAAC,OAAA,cAFA,oBAIA,uCAAAC,QAAA,CACe,GAAAC,oBAAW,EAAC,QAAQ,CAAC,EAAIC,MAAM,CAACC,MAAM,EAAI,CAAC,CAAC,CAC3D,kCAAAC,OAAA,CAAAC,OAAA,CAAAL,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["themed","COMPOSE","PRIORITY","NODE_CONFIG_ENV","process","env","NODE_ENV","JU","webpack","requireWeak","__dirname","withRetries","action","maxRetries","interval","n","error","timer"],"sources":["../../../../src/shared/utils/index.js"],"sourcesContent":["import themed, {\n COMPOSE,\n PRIORITY,\n ThemeProvider,\n} from '@dr.pogodin/react-themes';\n\nimport config from './config';\nimport * as isomorphy from './isomorphy';\nimport time, { timer } from './time';\nimport * as webpack from './webpack';\n\nexport * from './Barrier';\nexport { default as Emitter } from './Emitter';\nexport { default as Semaphore } from './Semaphore';\nexport { default as splitComponent } from './splitComponent';\n\nthemed.COMPOSE = COMPOSE;\nthemed.PRIORITY = PRIORITY;\n\n// Note: it should be done this way, as in some environments\n// \"process\" might not exist, and process.env.NODE_CONFIG_ENV\n// not injected by Webpack.\nlet NODE_CONFIG_ENV;\ntry {\n NODE_CONFIG_ENV = process.env.NODE_CONFIG_ENV;\n} catch { /* noop */ }\n\nconst env = NODE_CONFIG_ENV || process.env.NODE_ENV;\nconst JU = env !== 'production' && webpack.requireWeak('./jest', __dirname);\n\n/**\n * @category Utilities\n * @global\n * @func withRetries\n * @desc\n * ```js\n * import { withRetries } from '@dr.pogodin/react-utils';\n * ```\n * Attempts to perform given asynchronous `action` up to `maxRetries` times,\n * with the given `interval` between attempts. If any attempt is successful,\n * the result is returned immediately, with no further attempts done;\n * otherwise, if all attempts fail, the result Promise rejects after the last\n * attempt.\n * @param {function} action\n * @param {number} [maxRetries=5] Optional. Maximum number of retries. Defaults\n * to 5 attempts.\n * @param {number} [interval=1000] Optional. Interval between retries [ms].\n * Defaults to 1 second.\n * @return {Promise} Resolves to the result of successful operation, or\n * rejects with the error from the latst failed attempt.\n * @example\n * import { withRetries } from '@dr.pogodin/react-utils';\n *\n * let firstCall = true;\n *\n * function sampleAction() {\n * if (!firstCall) return 'success';\n * firstCall = false;\n * throw Error('The first call to this method fails');\n * }\n *\n * withRetries(sampleAction).then(console.log);\n * // It will print 'success' after one second, once the second attempt\n * // is performed.\n */\nexport async function withRetries(action, maxRetries = 5, interval = 1000) {\n /* eslint-disable no-await-in-loop */\n for (let n = 1; ; ++n) {\n try {\n return await action();\n } catch (error) {\n if (n < maxRetries) await timer(interval);\n else throw error;\n }\n }\n /* eslint-enable no-await-in-loop */\n}\n\nexport {\n config,\n isomorphy,\n JU,\n themed,\n ThemeProvider,\n time,\n webpack,\n};\n"],"mappings":"0nCAAA,8EAMA,wDACA,8DAAyC,4BACzC,qDACA,0DAAqC,wBAErC,gVACA,0DACA,8DACA,wEAA6D,o9BAE7DA,oBAAM,CAACC,OAAO,CAAGA,oBAAO,CACxBD,oBAAM,CAACE,QAAQ,CAAGA,qBAAQ,CAE1B;AACA;AACA;AACA,GAAIC,gBAAe,CACnB,GAAI,CACFA,eAAe,CAAGC,OAAO,CAACC,GAAG,CAACF,eAChC,CAAE,KAAM,CAAE,WAEV,KAAME,IAAG,CAAGF,eAAe,EAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,CACnD,KAAMC,GAAE,CAAGF,GAAG,GAAK,YAAY,EAAIG,OAAO,CAACC,WAAW,UAAWC,SAAS,CAAC,CAE3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAlCA,cAmCO,cAAeC,YAAW,CAACC,MAAM,CAAEC,UAAU,CAAG,CAAC,CAAEC,QAAQ,CAAG,IAAI,CAAE,CACzE,qCACA,IAAK,GAAIC,EAAC,CAAG,CAAC,EAAI,EAAEA,CAAC,CAAE,CACrB,GAAI,CACF,MAAO,MAAMH,OAAM,EACrB,CAAE,MAAOI,KAAK,CAAE,CACd,GAAID,CAAC,CAAGF,UAAU,CAAE,KAAM,GAAAI,WAAK,EAACH,QAAQ,CAAC,CAAC,IACrC,MAAME,MACb,CACF,CACA,oCACF"}
1
+ {"version":3,"file":"index.js","names":["_reactThemes","_interopRequireWildcard","require","_config","_interopRequireDefault","isomorphy","exports","_time","webpack","_Barrier","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","defineProperty","enumerable","get","_Emitter","_Semaphore","_splitComponent","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","newObj","hasPropertyDescriptor","getOwnPropertyDescriptor","desc","set","themed","COMPOSE","PRIORITY","NODE_CONFIG_ENV","process","env","NODE_ENV","JU","requireWeak","__dirname","withRetries","action","maxRetries","interval","n","error","timer"],"sources":["../../../../src/shared/utils/index.js"],"sourcesContent":["import themed, {\n COMPOSE,\n PRIORITY,\n ThemeProvider,\n} from '@dr.pogodin/react-themes';\n\nimport config from './config';\nimport * as isomorphy from './isomorphy';\nimport time, { timer } from './time';\nimport * as webpack from './webpack';\n\nexport * from './Barrier';\nexport { default as Emitter } from './Emitter';\nexport { default as Semaphore } from './Semaphore';\nexport { default as splitComponent } from './splitComponent';\n\nthemed.COMPOSE = COMPOSE;\nthemed.PRIORITY = PRIORITY;\n\n// Note: it should be done this way, as in some environments\n// \"process\" might not exist, and process.env.NODE_CONFIG_ENV\n// not injected by Webpack.\nlet NODE_CONFIG_ENV;\ntry {\n NODE_CONFIG_ENV = process.env.NODE_CONFIG_ENV;\n} catch { /* noop */ }\n\nconst env = NODE_CONFIG_ENV || process.env.NODE_ENV;\nconst JU = env !== 'production' && webpack.requireWeak('./jest', __dirname);\n\n/**\n * @category Utilities\n * @global\n * @func withRetries\n * @desc\n * ```js\n * import { withRetries } from '@dr.pogodin/react-utils';\n * ```\n * Attempts to perform given asynchronous `action` up to `maxRetries` times,\n * with the given `interval` between attempts. If any attempt is successful,\n * the result is returned immediately, with no further attempts done;\n * otherwise, if all attempts fail, the result Promise rejects after the last\n * attempt.\n * @param {function} action\n * @param {number} [maxRetries=5] Optional. Maximum number of retries. Defaults\n * to 5 attempts.\n * @param {number} [interval=1000] Optional. Interval between retries [ms].\n * Defaults to 1 second.\n * @return {Promise} Resolves to the result of successful operation, or\n * rejects with the error from the latst failed attempt.\n * @example\n * import { withRetries } from '@dr.pogodin/react-utils';\n *\n * let firstCall = true;\n *\n * function sampleAction() {\n * if (!firstCall) return 'success';\n * firstCall = false;\n * throw Error('The first call to this method fails');\n * }\n *\n * withRetries(sampleAction).then(console.log);\n * // It will print 'success' after one second, once the second attempt\n * // is performed.\n */\nexport async function withRetries(action, maxRetries = 5, interval = 1000) {\n /* eslint-disable no-await-in-loop */\n for (let n = 1; ; ++n) {\n try {\n return await action();\n } catch (error) {\n if (n < maxRetries) await timer(interval);\n else throw error;\n }\n }\n /* eslint-enable no-await-in-loop */\n}\n\nexport {\n config,\n isomorphy,\n JU,\n themed,\n ThemeProvider,\n time,\n webpack,\n};\n"],"mappings":"0nCAAA,IAAAA,YAAA,CAAAC,uBAAA,CAAAC,OAAA,8BAMA,IAAAC,OAAA,CAAAC,sBAAA,CAAAF,OAAA,cACA,IAAAG,SAAA,CAAAJ,uBAAA,CAAAC,OAAA,iBAAyCI,OAAA,CAAAD,SAAA,CAAAA,SAAA,CACzC,IAAAE,KAAA,CAAAN,u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AE,CACzE,qCACA,IAAK,GAAI,CAAAC,CAAC,CAAG,CAAC,EAAI,EAAEA,CAAC,CAAE,CACrB,GAAI,CACF,MAAO,MAAM,CAAAH,MAAM,EACrB,CAAE,MAAOI,KAAK,CAAE,CACd,GAAID,CAAC,CAAGF,UAAU,CAAE,KAAM,GAAAI,WAAK,EAACH,QAAQ,CAAC,CAAC,IACrC,MAAM,CAAAE,KACb,CACF,CACA,oCACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"isomorphy.js","names":["IS_CLIENT_SIDE","process","versions","node","global","REACT_UTILS_FORCE_CLIENT_SIDE","IS_SERVER_SIDE","getMode","env","NODE_ENV","isDevBuild","isProdBuild","getBuildInfo","window","TRU_BUILD_INFO","buildTimestamp","timestamp"],"sources":["../../../../src/shared/utils/isomorphy.js"],"sourcesContent":["/* global window */\n\n/**\n * `true` within client-side environment (browser), `false` at server-side.\n */\nexport const IS_CLIENT_SIDE = typeof process !== 'object'\n || !process.versions || !process.versions.node\n || !!global.REACT_UTILS_FORCE_CLIENT_SIDE;\n\n/**\n * `true` within the server-side environment (node), `false` at client-side.\n */\nexport const IS_SERVER_SIDE = !IS_CLIENT_SIDE;\n\n/**\n * @ignore\n * @return {string} Code mode: \"development\" or \"production\".\n */\nfunction getMode() {\n return process.env.NODE_ENV;\n}\n\n/**\n * Returns `true` if development version of the code is running;\n * `false` otherwise.\n * @return {boolean}\n */\nexport function isDevBuild() {\n return getMode() === 'development';\n}\n\n/**\n * Returns `true` if production build of the code is running;\n * `false` otherwise.\n * @return {boolean}\n */\nexport function isProdBuild() {\n return getMode() === 'production';\n}\n\n/**\n * Returns build info object.\n * @returns {object}\n */\nexport function getBuildInfo() {\n return (IS_CLIENT_SIDE ? window : global).TRU_BUILD_INFO;\n}\n\n/**\n * Returns build timestamp of the front-end JS bundle.\n * @return {string} ISO date/time string.\n */\nexport function buildTimestamp() {\n return getBuildInfo().timestamp;\n}\n"],"mappings":"iQAAA,oBAEA;AACA;AACA,GACO,KAAMA,eAAc,CAAG,MAAOC,QAAO,GAAK,QAAQ,EACpD,CAACA,OAAO,CAACC,QAAQ,EAAI,CAACD,OAAO,CAACC,QAAQ,CAACC,IAAI,EAC3C,CAAC,CAACC,MAAM,CAACC,6BAA6B,CAE3C;AACA;AACA,GAFA,sCAGO,KAAMC,eAAc,CAAG,CAACN,cAAc,CAE7C;AACA;AACA;AACA,GAHA,sCAIA,QAASO,QAAO,EAAG,CACjB,MAAON,QAAO,CAACO,GAAG,CAACC,QACrB,CAEA;AACA;AACA;AACA;AACA,GACO,QAASC,WAAU,EAAG,CAC3B,MAAOH,QAAO,EAAE,GAAK,aACvB,CAEA;AACA;AACA;AACA;AACA,GACO,QAASI,YAAW,EAAG,CAC5B,MAAOJ,QAAO,EAAE,GAAK,YACvB,CAEA;AACA;AACA;AACA,GACO,QAASK,aAAY,EAAG,CAC7B,MAAO,CAACZ,cAAc,CAAGa,MAAM,CAAGT,MAAM,EAAEU,cAC5C,CAEA;AACA;AACA;AACA,GACO,QAASC,eAAc,EAAG,CAC/B,MAAOH,aAAY,EAAE,CAACI,SACxB"}
1
+ {"version":3,"file":"isomorphy.js","names":["IS_CLIENT_SIDE","process","versions","node","global","REACT_UTILS_FORCE_CLIENT_SIDE","exports","IS_SERVER_SIDE","getMode","env","NODE_ENV","isDevBuild","isProdBuild","getBuildInfo","window","TRU_BUILD_INFO","buildTimestamp","timestamp"],"sources":["../../../../src/shared/utils/isomorphy.js"],"sourcesContent":["/* global window */\n\n/**\n * `true` within client-side environment (browser), `false` at server-side.\n */\nexport const IS_CLIENT_SIDE = typeof process !== 'object'\n || !process.versions || !process.versions.node\n || !!global.REACT_UTILS_FORCE_CLIENT_SIDE;\n\n/**\n * `true` within the server-side environment (node), `false` at client-side.\n */\nexport const IS_SERVER_SIDE = !IS_CLIENT_SIDE;\n\n/**\n * @ignore\n * @return {string} Code mode: \"development\" or \"production\".\n */\nfunction getMode() {\n return process.env.NODE_ENV;\n}\n\n/**\n * Returns `true` if development version of the code is running;\n * `false` otherwise.\n * @return {boolean}\n */\nexport function isDevBuild() {\n return getMode() === 'development';\n}\n\n/**\n * Returns `true` if production build of the code is running;\n * `false` otherwise.\n * @return {boolean}\n */\nexport function isProdBuild() {\n return getMode() === 'production';\n}\n\n/**\n * Returns build info object.\n * @returns {object}\n */\nexport function getBuildInfo() {\n return (IS_CLIENT_SIDE ? window : global).TRU_BUILD_INFO;\n}\n\n/**\n * Returns build timestamp of the front-end JS bundle.\n * @return {string} ISO date/time string.\n */\nexport function buildTimestamp() {\n return getBuildInfo().timestamp;\n}\n"],"mappings":"iQAAA,oBAEA;AACA;AACA,GACO,KAAM,CAAAA,cAAc,CAAG,MAAO,CAAAC,OAAO,GAAK,QAAQ,EACpD,CAACA,OAAO,CAACC,QAAQ,EAAI,CAACD,OAAO,CAACC,QAAQ,CAACC,IAAI,EAC3C,CAAC,CAACC,MAAM,CAACC,6BAA6B,CAE3C;AACA;AACA,GAFAC,OAAA,CAAAN,cAAA,CAAAA,cAAA,CAGO,KAAM,CAAAO,cAAc,CAAG,CAACP,cAAc,CAE7C;AACA;AACA;AACA,GAHAM,OAAA,CAAAC,cAAA,CAAAA,cAAA,CAIA,QAAS,CAAAC,OAAOA,CAAA,CAAG,CACjB,MAAO,CAAAP,OAAO,CAACQ,GAAG,CAACC,QACrB,CAEA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAAC,UAAUA,CAAA,CAAG,CAC3B,MAAO,CAAAH,OAAO,EAAE,GAAK,aACvB,CAEA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAAI,WAAWA,CAAA,CAAG,CAC5B,MAAO,CAAAJ,OAAO,EAAE,GAAK,YACvB,CAEA;AACA;AACA;AACA,GACO,QAAS,CAAAK,YAAYA,CAAA,CAAG,CAC7B,MAAO,CAACb,cAAc,CAAGc,MAAM,CAAGV,MAAM,EAAEW,cAC5C,CAEA;AACA;AACA;AACA,GACO,QAAS,CAAAC,cAAcA,CAAA,CAAG,CAC/B,MAAO,CAAAH,YAAY,EAAE,CAACI,SACxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"E2eSsrEnv.js","names":["E2eSsrEnv","JsdomEnv","loadWebpackConfig","options","pragmas","JSON","parse","defaults","context","testFolder","fs","global","webpackOutputFs","factory","require","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"],"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,kDACA,0EAEA,8BAKA,iEACA,oFACA,4BACA,wDA5BA;AACA;AACA;AACA;AACA;AACA,GALA,CAMA,+DAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA,uDAKA,qDAEe,KAAMA,UAAS,QAASC,8BAAS,CAC9C;AACF;AACA;AACA,KACEC,iBAAiB,EAAG,CAClB,GAAIC,QAAO,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,CACxBC,EAAE,CAAE,IAAI,CAACC,MAAM,CAACC,eAClB,CAAC,CAAC,CAEF,GAAIC,QAAO,CAAG,IAAI,CAACT,OAAO,CAAC,wBAAwB,CAAC,EAAI,EAAE,CAC1DS,OAAO,CAAGC,OAAO,CAACC,aAAI,CAACC,OAAO,CAAC,IAAI,CAACC,OAAO,CAAEJ,OAAO,CAAC,CAAC,CACtD,IAAI,CAACF,MAAM,CAACO,aAAa,CAAGL,OAAO,CAACV,OAAO,CAAC,CAE5C,KAAMO,GAAE,CAAG,IAAI,CAACC,MAAM,CAACC,eAAe,CACtC,GAAIO,UAAS,CAAI,GAAEhB,OAAO,CAACK,OAAQ,cAAa,CAChD,GAAIE,EAAE,CAACU,UAAU,CAACD,SAAS,CAAC,CAAE,CAC5BA,SAAS,CAAGT,EAAE,CAACW,YAAY,CAACF,SAAS,CAAE,MAAM,CAAC,CAC9C,IAAI,CAACR,MAAM,CAACQ,SAAS,CAAGd,IAAI,CAACC,KAAK,CAACa,SAAS,CAC9C,CACF,CAEA;AACF;AACA;AACA,KACE,KAAMG,WAAU,EAAG,CACjB,IAAI,C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I,CAAC8D,OAAO,CAAE,KAAM,KAAI,CAAC7C,MAAM,EAAE,CACrC,IAAI,CAAC5B,MAAM,CAAC2E,6BAA6B,CAAG,IAC9C,CAEA,KAAMC,SAAQ,EAAG,CACf,MAAO,KAAI,CAAC5E,MAAM,CAAC2E,6BAA6B,CAEhD;AACA;AACA;AACA;AACA;AACA;AACAE,MAAM,CAACC,IAAI,CAAC3E,OAAO,CAAC4E,KAAK,CAAC,CAACC,OAAO,CAAEC,GAAG,EAAK,CAC1C,MAAO9E,QAAO,CAAC4E,KAAK,CAACE,GAAG,CAC1B,CAAC,CAAC,CACF1C,iBAAQ,CAAC2C,MAAM,EAAE,CACjB,KAAK,CAACN,QAAQ,EAChB,CACF,CAAC"}
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,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,GAA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G,OAAO,CAACgG,KAAK,CAACE,GAAG,CAC1B,CAAC,CAAC,CACF1C,iBAAQ,CAAC2C,MAAM,EAAE,CACjB,KAAK,CAACN,QAAQ,EAChB,CACF,CAACO,OAAA,CAAAC,OAAA,CAAA9F,SAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["global","IS_REACT_ACT_ENVIRONMENT","originalProcessVersions","process","versions","mockClientSide","Object","defineProperty","value","unmockClientSide","writable","getMockUuid","seed","x","toString","padStart","slice","mockTimer","time","mockdate","set","Date","now","jest","advanceTimersByTime","mount","scene","root","res","document","createElement","body","appendChild","destroy","act","unmount","remove","createRoot","render","component","Renderer","create","toJSON","shallowRender","renderer","ShallowRenderer","getRenderOutput","shallowSnapshot","expect","toMatchSnapshot","snapshot","simulate","TU","Simulate"],"sources":["../../../../../src/shared/utils/jest/index.jsx"],"sourcesContent":["/* global expect, jest, document */\n/* eslint-disable import/no-extraneous-dependencies */\n\nimport mockdate from 'mockdate';\nimport { createRoot } from 'react-dom/client';\nimport TU, { act } from 'react-dom/test-utils';\n\n/* eslint-disable import/no-extraneous-dependencies */\nimport Renderer from 'react-test-renderer';\nimport ShallowRenderer from 'react-test-renderer/shallow';\n/* eslint-enable import/no-extraneous-dependencies */\n\n/**\n * An alias for [act(..)](https://reactjs.org/docs/test-utils.html#act)\n * from `react-dom/test-utils`.\n * @param {function} action\n */\nexport { act };\n\nglobal.IS_REACT_ACT_ENVIRONMENT = true;\n\nconst originalProcessVersions = process.versions;\n\n/**\n * Tricks **react-utils** into thinking the test is running within client-side\n * (browser) environment.\n */\nexport function mockClientSide() {\n Object.defineProperty(process, 'versions', { value: null });\n}\n\n/**\n * Reverts the effect of {@link module:JU.mockClientSide mockClientSide(..)}.\n */\nexport function unmockClientSide() {\n Object.defineProperty(process, 'versions', {\n value: originalProcessVersions,\n writable: false,\n });\n}\n\n/**\n * Generates a mock UUID, or better said it determenistically transforms given\n * `seed` number into a UUID-formatted string.\n * @param {number} seed\n * @return {string}\n */\nexport function getMockUuid(seed = 0) {\n const x = seed.toString(16).padStart(32, '0');\n return `${x.slice(0, 8)}-${x.slice(8, 12)}-${x.slice(12, 16)}-${x.slice(16, 20)}-${x.slice(20)}`;\n}\n\n/**\n * Advances mock timers, and mock date by the specified time.\n * @param {number} time Time step [ms].\n * @returns {Promise} Wait for this to \"jump after\" any async code which should\n * be executed because of the mock time movement.\n */\nexport async function mockTimer(time) {\n mockdate.set(time + Date.now());\n jest.advanceTimersByTime(time);\n}\n\n/**\n * Mounts `scene` to the DOM, and returns the root scene element.\n * @param {React.ReactNode} scene\n * @return {HTMLElement} Created container DOM element with destroy() function\n * attached.\n */\nexport function mount(scene) {\n let root;\n const res = document.createElement('div');\n document.body.appendChild(res);\n res.destroy = () => {\n act(() => root.unmount());\n res.remove();\n };\n act(() => {\n root = createRoot(res);\n root.render(scene);\n });\n return res;\n}\n\n/* OLD STUFF BELOW THIS MARK */\n\n/**\n * Renders provided ReactJS component into JSON representation of the component\n * tree, using [`react-test-renderer`](https://www.npmjs.com/package/react-test-renderer).\n * @param {object} component ReactJS component to render.\n * @return {object} JSON representation of the rendered tree.\n * @example\n * import { JU } from '@dr.pogodin/react-utils';\n * console.log(JU.render(<div>Example</div>));\n */\nexport function render(component) {\n return Renderer.create(component).toJSON();\n}\n\n/**\n * Generates a shallow render of given ReactJS component, using\n * [react-test-renderer/shallow](https://reactjs.org/docs/shallow-renderer.html)\n * and returns the result.\n * @param {object} component ReactJS component to render.\n * @return {object} JSON representation of the shallow component's render tree.\n */\nexport function shallowRender(component) {\n const renderer = new ShallowRenderer();\n renderer.render(component);\n return renderer.getRenderOutput();\n}\n\n/**\n * Makes a shallow snapshot test of the given ReactJS component, and also\n * returns JSON representation of the rendered component tree. Under the hood\n * it uses {@link module:JU.shallowRender shallowRender(..)} to generate\n * the render, then executes `expect(RENDER_RESULT).toMatchSnapshot()`,\n * and finally returns the `RENDER_RESULT` to the caller.\n * @param {object} component ReactJS component to render.\n * @return {object} JSON representation of shallow render.\n */\nexport function shallowSnapshot(component) {\n const res = shallowRender(component);\n expect(res).toMatchSnapshot();\n return res;\n}\n\n/**\n * Makes snapshot test of the given ReactJS component, and also returns JSON\n * representation of the rendered component tree. Under the hood, it uses\n * {@link module:JU.render render(..)} to render it, then executes\n * `expect(RENDER_RESULT).toMatchSnapshot()`, and then returns `RENDER_RESULT`.\n * @param {object} component ReactJS component to render.\n * @return {object} JSON render of the component.\n */\nexport function snapshot(component) {\n const res = render(component);\n expect(res).toMatchSnapshot();\n return res;\n}\n\nexport const simulate = TU.Simulate;\n"],"mappings":"0iBAGA,0DACA,wCACA,wEAGA,8EACA,4EAA0D,o9BAT1D,oCACA,uDAMA,uDAGA,sDAEA;AACA;AACA;AACA;AACA,GAGAA,MAAM,CAACC,wBAAwB,CAAG,IAAI,CAEtC,KAAMC,wBAAuB,CAAGC,OAAO,CAACC,QAAQ,CAEhD;AACA;AACA;AACA,GACO,QAASC,eAAc,EAAG,CAC/BC,MAAM,CAACC,cAAc,CAACJ,OAAO,CAAE,UAAU,CAAE,CAAEK,KAAK,CAAE,IAAK,CAAC,CAC5D,CAEA;AACA;AACA,GACO,QAASC,iBAAgB,EAAG,CACjCH,MAAM,CAACC,cAAc,CAACJ,OAAO,CAAE,UAAU,CAAE,CACzCK,KAAK,CAAEN,uBAAuB,CAC9BQ,QAAQ,CAAE,KACZ,CAAC,CACH,CAEA;AACA;AACA;AACA;AACA;AACA,GACO,QAASC,YAAW,CAACC,IAAI,CAAG,CAAC,CAAE,CACpC,KAAMC,EAAC,CAAGD,IAAI,CAACE,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAE,GAAG,CAAC,CAC7C,MAAQ,GAAEF,CAAC,CAACG,KAAK,CAAC,CAAC,CAAE,CAAC,CAAE,IAAGH,CAAC,CAACG,KAAK,CAAC,CAAC,CAAE,EAAE,CAAE,IAAGH,CAAC,CAACG,KAAK,CAAC,EAAE,CAAE,EAAE,CAAE,IAAGH,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AAMX,IAAG,CAAGe,aAAa,CAACJ,SAAS,CAAC,CACpCS,MAAM,CAACpB,GAAG,CAAC,CAACqB,eAAe,EAAE,CAC7B,MAAOrB,IACT,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACO,QAASsB,SAAQ,CAACX,SAAS,CAAE,CAClC,KAAMX,IAAG,CAAGU,MAAM,CAACC,SAAS,CAAC,CAC7BS,MAAM,CAACpB,GAAG,CAAC,CAACqB,eAAe,EAAE,CAC7B,MAAOrB,IACT,CAEO,KAAMuB,SAAQ,CAAGC,kBAAE,CAACC,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.js","names":["_mockdate","_interopRequireDefault","require","_client","_testUtils","_interopRequireWildcard","_reactTestRenderer","_shallow","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","global","IS_REACT_ACT_ENVIRONMENT","originalProcessVersions","process","versions","mockClientSide","value","unmockClientSide","writable","getMockUuid","seed","x","toString","padStart","slice","mockTimer","time","mockdate","Date","now","jest","advanceTimersByTime","mount","scene","root","res","document","createElement","body","appendChild","destroy","act","unmount","remove","createRoot","render","component","Renderer","create","toJSON","shallowRender","renderer","ShallowRenderer","getRenderOutput","shallowSnapshot","expect","toMatchSnapshot","snapshot","simulate","TU","Simulate","exports"],"sources":["../../../../../src/shared/utils/jest/index.jsx"],"sourcesContent":["/* global expect, jest, document */\n/* eslint-disable import/no-extraneous-dependencies */\n\nimport mockdate from 'mockdate';\nimport { createRoot } from 'react-dom/client';\nimport TU, { act } from 'react-dom/test-utils';\n\n/* eslint-disable import/no-extraneous-dependencies */\nimport Renderer from 'react-test-renderer';\nimport ShallowRenderer from 'react-test-renderer/shallow';\n/* eslint-enable import/no-extraneous-dependencies */\n\n/**\n * An alias for [act(..)](https://reactjs.org/docs/test-utils.html#act)\n * from `react-dom/test-utils`.\n * @param {function} action\n */\nexport { act };\n\nglobal.IS_REACT_ACT_ENVIRONMENT = true;\n\nconst originalProcessVersions = process.versions;\n\n/**\n * Tricks **react-utils** into thinking the test is running within client-side\n * (browser) environment.\n */\nexport function mockClientSide() {\n Object.defineProperty(process, 'versions', { value: null });\n}\n\n/**\n * Reverts the effect of {@link module:JU.mockClientSide mockClientSide(..)}.\n */\nexport function unmockClientSide() {\n Object.defineProperty(process, 'versions', {\n value: originalProcessVersions,\n writable: false,\n });\n}\n\n/**\n * Generates a mock UUID, or better said it determenistically transforms given\n * `seed` number into a UUID-formatted string.\n * @param {number} seed\n * @return {string}\n */\nexport function getMockUuid(seed = 0) {\n const x = seed.toString(16).padStart(32, '0');\n return `${x.slice(0, 8)}-${x.slice(8, 12)}-${x.slice(12, 16)}-${x.slice(16, 20)}-${x.slice(20)}`;\n}\n\n/**\n * Advances mock timers, and mock date by the specified time.\n * @param {number} time Time step [ms].\n * @returns {Promise} Wait for this to \"jump after\" any async code which should\n * be executed because of the mock time movement.\n */\nexport async function mockTimer(time) {\n mockdate.set(time + Date.now());\n jest.advanceTimersByTime(time);\n}\n\n/**\n * Mounts `scene` to the DOM, and returns the root scene element.\n * @param {React.ReactNode} scene\n * @return {HTMLElement} Created container DOM element with destroy() function\n * attached.\n */\nexport function mount(scene) {\n let root;\n const res = document.createElement('div');\n document.body.appendChild(res);\n res.destroy = () => {\n act(() => root.unmount());\n res.remove();\n };\n act(() => {\n root = createRoot(res);\n root.render(scene);\n });\n return res;\n}\n\n/* OLD STUFF BELOW THIS MARK */\n\n/**\n * Renders provided ReactJS component into JSON representation of the component\n * tree, using [`react-test-renderer`](https://www.npmjs.com/package/react-test-renderer).\n * @param {object} component ReactJS component to render.\n * @return {object} JSON representation of the rendered tree.\n * @example\n * import { JU } from '@dr.pogodin/react-utils';\n * console.log(JU.render(<div>Example</div>));\n */\nexport function render(component) {\n return Renderer.create(component).toJSON();\n}\n\n/**\n * Generates a shallow render of given ReactJS component, using\n * [react-test-renderer/shallow](https://reactjs.org/docs/shallow-renderer.html)\n * and returns the result.\n * @param {object} component ReactJS component to render.\n * @return {object} JSON representation of the shallow component's render tree.\n */\nexport function shallowRender(component) {\n const renderer = new ShallowRenderer();\n renderer.render(component);\n return renderer.getRenderOutput();\n}\n\n/**\n * Makes a shallow snapshot test of the given ReactJS component, and also\n * returns JSON representation of the rendered component tree. Under the hood\n * it uses {@link module:JU.shallowRender shallowRender(..)} to generate\n * the render, then executes `expect(RENDER_RESULT).toMatchSnapshot()`,\n * and finally returns the `RENDER_RESULT` to the caller.\n * @param {object} component ReactJS component to render.\n * @return {object} JSON representation of shallow render.\n */\nexport function shallowSnapshot(component) {\n const res = shallowRender(component);\n expect(res).toMatchSnapshot();\n return res;\n}\n\n/**\n * Makes snapshot test of the given ReactJS component, and also returns JSON\n * representation of the rendered component tree. Under the hood, it uses\n * {@link module:JU.render render(..)} to render it, then executes\n * `expect(RENDER_RESULT).toMatchSnapshot()`, and then returns `RENDER_RESULT`.\n * @param {object} component ReactJS component to render.\n * @return {object} JSON render of the component.\n */\nexport function snapshot(component) {\n const res = render(component);\n expect(res).toMatchSnapshot();\n return res;\n}\n\nexport const simulate = TU.Simulate;\n"],"mappings":"0iBAGA,IAAAA,SAAA,CAAAC,sBAAA,CAAAC,OAAA,cACA,IAAAC,OAAA,CAAAD,OAAA,qBACA,IAAAE,UAAA,CAAAC,uBAAA,CAAAH,OAAA,0BAGA,IAAAI,kBAAA,CAAAL,sBAAA,CAAAC,OAAA,yBACA,IAAAK,QAAA,CAAAN,sBAAA,CAAAC,OAAA,iCAA0D,SAAAM,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,WAAAJ,wBAAAQ,GAAA,CAAAJ,WAAA,MAAAA,WAAA,EAA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,IAAI,CAACW,MAAM,CAACZ,KAAK,CACnB,CAAC,CAAC,CACF,MAAO,CAAAE,GACT,CAEA,gCAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAAU,MAAMA,CAACC,SAAS,CAAE,CAChC,MAAO,CAAAC,0BAAQ,CAACC,MAAM,CAACF,SAAS,CAAC,CAACG,MAAM,EAC1C,CAEA;AACA;AACA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAAC,aAAaA,CAACJ,SAAS,CAAE,CACvC,KAAM,CAAAK,QAAQ,CAAG,GAAI,CAAAC,gBAAiB,CACtCD,QAAQ,CAACN,MAAM,CAACC,SAAS,CAAC,CAC1B,MAAO,CAAAK,QAAQ,CAACE,eAAe,EACjC,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAAC,eAAeA,CAACR,SAAS,CAAE,CACzC,KAAM,CAAAX,GAAG,CAAGe,aAAa,CAACJ,SAAS,CAAC,CACpCS,MAAM,CAACpB,GAAG,CAAC,CAACqB,eAAe,EAAE,CAC7B,MAAO,CAAArB,GACT,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAAsB,QAAQA,CAACX,SAAS,CAAE,CAClC,KAAM,CAAAX,GAAG,CAAGU,MAAM,CAACC,SAAS,CAAC,CAC7BS,MAAM,CAACpB,GAAG,CAAC,CAACqB,eAAe,EAAE,CAC7B,MAAO,CAAArB,GACT,CAEO,KAAM,CAAAuB,QAAQ,CAAGC,kBAAE,CAACC,QAAQ,CAACC,OAAA,CAAAH,QAAA,CAAAA,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"splitComponent.js","names":["splitComponent","chunkName","getComponent","placeholder","children","props","createElement","CodeSplit"],"sources":["../../../../src/shared/utils/splitComponent.js"],"sourcesContent":["/* eslint-disable react/jsx-props-no-spreading */\n\nimport { createElement } from 'react';\n\nimport CodeSplit from 'components/CodeSplit';\n\n/**\n * Wraps a regular React component into a \"code splitting\" component,\n * i.e. all code used exclusively by that component and its sub-tree\n * will go into a separate, asynchronously loaded, code chunk for\n * the client-side.\n * @param {object} options\n * @param {string} options.chunkName\n * @param {function} options.getComponent\n * @param {React.Element} [options.placeholder]\n * @return {React.ElementType}\n */\nexport default function splitComponent({\n chunkName,\n getComponent,\n placeholder,\n}) {\n // eslint-disable-next-line react/prop-types\n return ({ children, ...props } = {}) => createElement(\n CodeSplit,\n {\n ...props,\n chunkName,\n getComponent,\n placeholder,\n },\n children,\n );\n}\n"],"mappings":"wLAEA,4BAEA,0EAJA,kDAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACe,QAASA,eAAc,CAAC,CACrCC,SAAS,CACTC,YAAY,CACZC,WACF,CAAC,CAAE,CACD;AACA,MAAO,CAAC,CAAEC,QAAQ,CAAE,GAAGC,KAAM,CAAC,CAAG,CAAC,CAAC,gBAAK,GAAAC,oBAAa,EACnDC,kBAAS,CACT,CACE,GAAGF,KAAK,CACRJ,SAAS,CACTC,YAAY,CACZC,WACF,CAAC,CACDC,QAAQ,CAEZ"}
1
+ {"version":3,"file":"splitComponent.js","names":["_react","require","_CodeSplit","_interopRequireDefault","splitComponent","chunkName","getComponent","placeholder","children","props","createElement","CodeSplit"],"sources":["../../../../src/shared/utils/splitComponent.js"],"sourcesContent":["/* eslint-disable react/jsx-props-no-spreading */\n\nimport { createElement } from 'react';\n\nimport CodeSplit from 'components/CodeSplit';\n\n/**\n * Wraps a regular React component into a \"code splitting\" component,\n * i.e. all code used exclusively by that component and its sub-tree\n * will go into a separate, asynchronously loaded, code chunk for\n * the client-side.\n * @param {object} options\n * @param {string} options.chunkName\n * @param {function} options.getComponent\n * @param {React.Element} [options.placeholder]\n * @return {React.ElementType}\n */\nexport default function splitComponent({\n chunkName,\n getComponent,\n placeholder,\n}) {\n // eslint-disable-next-line react/prop-types\n return ({ children, ...props } = {}) => createElement(\n CodeSplit,\n {\n ...props,\n chunkName,\n getComponent,\n placeholder,\n },\n children,\n );\n}\n"],"mappings":"wLAEA,IAAAA,MAAA,CAAAC,OAAA,UAEA,IAAAC,UAAA,CAAAC,sBAAA,CAAAF,OAAA,6BAJA,kDAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACe,QAAS,CAAAG,cAAcA,CAAC,CACrCC,SAAS,CACTC,YAAY,CACZC,WACF,CAAC,CAAE,CACD;AACA,MAAO,CAAC,CAAEC,QAAQ,CAAE,GAAGC,KAAM,CAAC,CAAG,CAAC,CAAC,gBAAK,GAAAC,oBAAa,EACnDC,kBAAS,CACT,CACE,GAAGF,KAAK,CACRJ,SAAS,CACTC,YAAY,CACZC,WACF,CAAC,CACDC,QAAQ,CAEZ"}
@@ -1 +1 @@
1
- {"version":3,"file":"time.js","names":["dayjs","SEC_MS","MIN_MS","HOUR_MS","DAY_MS","YEAR_MS","now","Date","timer","timeout","res","Barrier","id","setTimeout","resolve","bind","abort","clearTimeout","noop","useCurrent","autorefresh","globalStatePath","precision","setter","useGlobalState","useEffect","timerId","update","old","neu","Math","abs","useTimezoneOffset","cookieName","ssrContext","getSsrContext","offset","setOffset","value","req","cookies","parseInt","date","getTimezoneOffset","document","cookie","Cookie","serialize","path"],"sources":["../../../../src/shared/utils/time.js"],"sourcesContent":["/* global document */\n\nimport Cookie from 'cookie';\nimport dayjs from 'dayjs';\nimport { noop } from 'lodash';\nimport { useEffect } from 'react';\n\nimport { getSsrContext, useGlobalState } from '@dr.pogodin/react-global-state';\n\nimport { Barrier } from './Barrier';\n\n/**\n * @static\n * @const SEC_MS\n * @desc One second, expressed in milliseconds (equals 1000 ms).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.SEC_MS); // Prints: 1000\n */\ndayjs.SEC_MS = 1000;\n\n/**\n * @static\n * @const MIN_MS\n * @desc One minute, expressed in milliseconds (equals 60 &times; `SEC_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.MIN_MS); // Prints: 60000\n */\ndayjs.MIN_MS = 60 * dayjs.SEC_MS;\n\n/**\n * @static\n * @const HOUR_MS\n * @desc One hour, expressed in milliseconds (equals 60 &times; `MIN_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.HOUR_MS); // Prints: 3600000\n */\ndayjs.HOUR_MS = 60 * dayjs.MIN_MS;\n\n/**\n * @static\n * @const DAY_MS\n * @desc One day, expressed in milliseconds (equals 24 &times; `HOUR_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.DAY_MS); // Prints: 86400000\n */\ndayjs.DAY_MS = 24 * dayjs.HOUR_MS;\n\n/**\n * @static\n * @const YEAR_MS\n * @desc One year, expressed in milliseconds (equals 365 &times; `DAY_MS`,\n * thus a normal, non-leap year).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.YEAR_MS); // Prints: 31536000000\n */\ndayjs.YEAR_MS = 365 * dayjs.DAY_MS;\n\n/**\n * @static\n * @func now\n * @desc Returns Unix timestamp [ms] (thus, it is just an alias for `Date.now`).\n * @return {number}\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.now()); // Prints the current timestamp, e.g. 1618608761000.\n */\ndayjs.now = Date.now;\n\n/**\n * Creates a Promise, which resolves after the given timeout.\n * @param {number} timeout Timeout [ms].\n * @return {Barrier} Resolves after the timeout. It has additional\n * .abort() method attached, which cancels the pending timer resolution\n * (without resolving or rejecting the barrier).\n */\nexport async function timer(timeout) {\n const res = new Barrier();\n if (timeout > 0) {\n const id = setTimeout(res.resolve.bind(res), timeout);\n res.abort = () => clearTimeout(id);\n } else {\n res.abort = noop;\n res.resolve();\n }\n return res;\n}\n\n/**\n * This react hook wraps Date.now() function in a SSR friendly way,\n * ensuring that all calls to useCurrent() within the same render return\n * exactly the same time (which is retrieved from Date.now() first, and\n * then stored in the global state to be reused in all other calls), which\n * is also passed and used in the first client side render, and then updated\n * with a finite precision to avoid infinite re-rendering loops.\n * @param {object} [options] Optional settings.\n * @param {string} [options.globalStatePath=\"currentTime\"] Global state path\n * to keep the current time value.\n * @param {number} [options.precision= 5 * time.SEC_MS] Current time precision.\n * The hook won't update the current time stored in the global state unless it\n * is different from Date.now() result by this number (in milliseconds).\n * Default to 5 seconds.\n * @param {boolean} [options.autorefresh=false] Set `true` to automatically\n * refresh time stored in the global state with the given `precision` (and\n * thus automatically re-rendering components dependent on this hook, or\n * the global state with the period equal to the `precision`.\n * @return {number} Unix timestamp in milliseconds.\n */\nexport function useCurrent({\n autorefresh = false,\n globalStatePath = 'currentTime',\n precision = 5 * dayjs.SEC_MS,\n} = {}) {\n const [now, setter] = useGlobalState(globalStatePath, Date.now);\n useEffect(() => {\n let timerId;\n const update = () => {\n setter((old) => {\n const neu = Date.now();\n return Math.abs(neu - old) > precision ? neu : old;\n });\n if (autorefresh) timerId = setTimeout(update, precision);\n };\n update();\n return () => {\n if (timerId) clearTimeout(timerId);\n };\n }, [autorefresh, precision, setter]);\n return now;\n}\n\n/**\n * Wraps the standard Date.getTimezoneOffset() method in a SSR-friendly way.\n * This hook retrieves the offset value at the client side and uses a cookie\n * to pass it to the server in subsequent requests from that user. At the server\n * side the value from cookie is used in renders and passed back to the client\n * via the global state. Prior to the value being known (in the very first\n * request from the user, when the cookie is still missing), zero value is used\n * as the default value.\n *\n * @param {object} [options] Optional settings.\n * @param {string} [options.cookieName=\"timezoneOffset\"] Optional. The name of\n * cookie to use to store the timezone offset. Defaults \"timezoneOffset\". Set\n * to a falsy value to forbid using cookies altogether (in that case the hook\n * will always return zero value at the server-side, and in the first render\n * at the client-side).\n * @param {string} [options.timezoneOffset=\"timezoneOffset\"] Optional.\n * The global state path to store the offset. Defaults \"timezoneOffset\".\n * @return {number} Timezone offset.\n */\nexport function useTimezoneOffset({\n cookieName = 'timezoneOffset',\n globalStatePath = 'timezoneOffset',\n} = {}) {\n const ssrContext = getSsrContext(false);\n const [offset, setOffset] = useGlobalState(globalStatePath, () => {\n const value = cookieName && ssrContext?.req?.cookies?.[cookieName];\n return value ? parseInt(value, 10) : 0;\n });\n useEffect(() => {\n const date = new Date();\n const value = date.getTimezoneOffset();\n setOffset(value);\n if (cookieName) {\n document.cookie = Cookie.serialize(cookieName, value, { path: '/' });\n }\n }, [cookieName, setOffset]);\n return offset;\n}\n\ndayjs.timer = timer;\ndayjs.useCurrent = useCurrent;\ndayjs.useTimezoneOffset = useTimezoneOffset;\n\nexport default dayjs;\n"],"mappings":"8QAEA,sDACA,oDACA,8BACA,4BAEA,gEAEA,kCATA,sBAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAA,cAAK,CAACC,MAAM,CAAG,IAAI,CAEnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAD,cAAK,CAACE,MAAM,CAAG,EAAE,CAAGF,cAAK,CAACC,MAAM,CAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAD,cAAK,CAACG,OAAO,CAAG,EAAE,CAAGH,cAAK,CAACE,MAAM,CAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAF,cAAK,CAACI,MAAM,CAAG,EAAE,CAAGJ,cAAK,CAACG,OAAO,CAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAH,cAAK,CAACK,OAAO,CAAG,GAAG,CAAGL,cAAK,CAACI,MAAM,CAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAJ,cAAK,CAACM,GAAG,CAAGC,IAAI,CAACD,GAAG,CAEpB;AACA;AACA;AACA;AACA;AACA;AACA,GACO,cAAeE,MAAK,CAACC,OAAO,CAAE,CACnC,KAAMC,IAAG,CAAG,GAAIC,iBAAS,CACzB,GAAIF,OAAO,CAAG,CAAC,CAAE,CACf,KAAMG,GAAE,CAAGC,UAAU,CAACH,GAAG,CAACI,OAAO,CAACC,IAAI,CAACL,GAAG,CAAC,CAAED,OAAO,CAAC,CACrDC,GAAG,CAACM,KAAK,CAAG,IAAMC,YAAY,CAACL,EAAE,CACnC,CAAC,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AAC,KAAK,CAAC,CACvC,KAAM,CAACC,MAAM,CAAEC,SAAS,CAAC,CAAG,GAAAb,gCAAc,EAACH,eAAe,CAAE,IAAM,CAChE,KAAMiB,MAAK,CAAGL,UAAU,EAAIC,UAAU,EAAEK,GAAG,EAAEC,OAAO,GAAGP,UAAU,CAAC,CAClE,MAAOK,MAAK,CAAGG,QAAQ,CAACH,KAAK,CAAE,EAAE,CAAC,CAAG,CACvC,CAAC,CAAC,CACF,GAAAb,gBAAS,EAAC,IAAM,CACd,KAAMiB,KAAI,CAAG,GAAInC,KAAM,CACvB,KAAM+B,MAAK,CAAGI,IAAI,CAACC,iBAAiB,EAAE,CACtCN,SAAS,CAACC,KAAK,CAAC,CAChB,GAAIL,UAAU,CAAE,CACdW,QAAQ,CAACC,MAAM,CAAGC,eAAM,CAACC,SAAS,CAACd,UAAU,CAAEK,KAAK,CAAE,CAAEU,IAAI,CAAE,GAAI,CAAC,CACrE,CACF,CAAC,CAAE,CAACf,UAAU,CAAEI,SAAS,CAAC,CAAC,CAC3B,MAAOD,OACT,CAEApC,cAAK,CAACQ,KAAK,CAAGA,KAAK,CACnBR,cAAK,CAACmB,UAAU,CAAGA,UAAU,CAC7BnB,cAAK,CAACgC,iBAAiB,CAAGA,iBAAiB,CAAC,aAE7BhC,cAAK"}
1
+ {"version":3,"file":"time.js","names":["_cookie","_interopRequireDefault","require","_dayjs","_lodash","_react","_reactGlobalState","_Barrier","dayjs","SEC_MS","MIN_MS","HOUR_MS","DAY_MS","YEAR_MS","now","Date","timer","timeout","res","Barrier","id","setTimeout","resolve","bind","abort","clearTimeout","noop","useCurrent","autorefresh","globalStatePath","precision","setter","useGlobalState","useEffect","timerId","update","old","neu","Math","abs","useTimezoneOffset","cookieName","ssrContext","getSsrContext","offset","setOffset","value","req","cookies","parseInt","date","getTimezoneOffset","document","cookie","Cookie","serialize","path","_default","exports","default"],"sources":["../../../../src/shared/utils/time.js"],"sourcesContent":["/* global document */\n\nimport Cookie from 'cookie';\nimport dayjs from 'dayjs';\nimport { noop } from 'lodash';\nimport { useEffect } from 'react';\n\nimport { getSsrContext, useGlobalState } from '@dr.pogodin/react-global-state';\n\nimport { Barrier } from './Barrier';\n\n/**\n * @static\n * @const SEC_MS\n * @desc One second, expressed in milliseconds (equals 1000 ms).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.SEC_MS); // Prints: 1000\n */\ndayjs.SEC_MS = 1000;\n\n/**\n * @static\n * @const MIN_MS\n * @desc One minute, expressed in milliseconds (equals 60 &times; `SEC_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.MIN_MS); // Prints: 60000\n */\ndayjs.MIN_MS = 60 * dayjs.SEC_MS;\n\n/**\n * @static\n * @const HOUR_MS\n * @desc One hour, expressed in milliseconds (equals 60 &times; `MIN_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.HOUR_MS); // Prints: 3600000\n */\ndayjs.HOUR_MS = 60 * dayjs.MIN_MS;\n\n/**\n * @static\n * @const DAY_MS\n * @desc One day, expressed in milliseconds (equals 24 &times; `HOUR_MS`).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.DAY_MS); // Prints: 86400000\n */\ndayjs.DAY_MS = 24 * dayjs.HOUR_MS;\n\n/**\n * @static\n * @const YEAR_MS\n * @desc One year, expressed in milliseconds (equals 365 &times; `DAY_MS`,\n * thus a normal, non-leap year).\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.YEAR_MS); // Prints: 31536000000\n */\ndayjs.YEAR_MS = 365 * dayjs.DAY_MS;\n\n/**\n * @static\n * @func now\n * @desc Returns Unix timestamp [ms] (thus, it is just an alias for `Date.now`).\n * @return {number}\n * @example\n * import { time } from '@dr.pogodin/react-utils';\n * console.log(time.now()); // Prints the current timestamp, e.g. 1618608761000.\n */\ndayjs.now = Date.now;\n\n/**\n * Creates a Promise, which resolves after the given timeout.\n * @param {number} timeout Timeout [ms].\n * @return {Barrier} Resolves after the timeout. It has additional\n * .abort() method attached, which cancels the pending timer resolution\n * (without resolving or rejecting the barrier).\n */\nexport async function timer(timeout) {\n const res = new Barrier();\n if (timeout > 0) {\n const id = setTimeout(res.resolve.bind(res), timeout);\n res.abort = () => clearTimeout(id);\n } else {\n res.abort = noop;\n res.resolve();\n }\n return res;\n}\n\n/**\n * This react hook wraps Date.now() function in a SSR friendly way,\n * ensuring that all calls to useCurrent() within the same render return\n * exactly the same time (which is retrieved from Date.now() first, and\n * then stored in the global state to be reused in all other calls), which\n * is also passed and used in the first client side render, and then updated\n * with a finite precision to avoid infinite re-rendering loops.\n * @param {object} [options] Optional settings.\n * @param {string} [options.globalStatePath=\"currentTime\"] Global state path\n * to keep the current time value.\n * @param {number} [options.precision= 5 * time.SEC_MS] Current time precision.\n * The hook won't update the current time stored in the global state unless it\n * is different from Date.now() result by this number (in milliseconds).\n * Default to 5 seconds.\n * @param {boolean} [options.autorefresh=false] Set `true` to automatically\n * refresh time stored in the global state with the given `precision` (and\n * thus automatically re-rendering components dependent on this hook, or\n * the global state with the period equal to the `precision`.\n * @return {number} Unix timestamp in milliseconds.\n */\nexport function useCurrent({\n autorefresh = false,\n globalStatePath = 'currentTime',\n precision = 5 * dayjs.SEC_MS,\n} = {}) {\n const [now, setter] = useGlobalState(globalStatePath, Date.now);\n useEffect(() => {\n let timerId;\n const update = () => {\n setter((old) => {\n const neu = Date.now();\n return Math.abs(neu - old) > precision ? neu : old;\n });\n if (autorefresh) timerId = setTimeout(update, precision);\n };\n update();\n return () => {\n if (timerId) clearTimeout(timerId);\n };\n }, [autorefresh, precision, setter]);\n return now;\n}\n\n/**\n * Wraps the standard Date.getTimezoneOffset() method in a SSR-friendly way.\n * This hook retrieves the offset value at the client side and uses a cookie\n * to pass it to the server in subsequent requests from that user. At the server\n * side the value from cookie is used in renders and passed back to the client\n * via the global state. Prior to the value being known (in the very first\n * request from the user, when the cookie is still missing), zero value is used\n * as the default value.\n *\n * @param {object} [options] Optional settings.\n * @param {string} [options.cookieName=\"timezoneOffset\"] Optional. The name of\n * cookie to use to store the timezone offset. Defaults \"timezoneOffset\". Set\n * to a falsy value to forbid using cookies altogether (in that case the hook\n * will always return zero value at the server-side, and in the first render\n * at the client-side).\n * @param {string} [options.timezoneOffset=\"timezoneOffset\"] Optional.\n * The global state path to store the offset. Defaults \"timezoneOffset\".\n * @return {number} Timezone offset.\n */\nexport function useTimezoneOffset({\n cookieName = 'timezoneOffset',\n globalStatePath = 'timezoneOffset',\n} = {}) {\n const ssrContext = getSsrContext(false);\n const [offset, setOffset] = useGlobalState(globalStatePath, () => {\n const value = cookieName && ssrContext?.req?.cookies?.[cookieName];\n return value ? parseInt(value, 10) : 0;\n });\n useEffect(() => {\n const date = new Date();\n const value = date.getTimezoneOffset();\n setOffset(value);\n if (cookieName) {\n document.cookie = Cookie.serialize(cookieName, value, { path: '/' });\n }\n }, [cookieName, setOffset]);\n return offset;\n}\n\ndayjs.timer = timer;\ndayjs.useCurrent = useCurrent;\ndayjs.useTimezoneOffset = useTimezoneOffset;\n\nexport default dayjs;\n"],"mappings":"8QAEA,IAAAA,OAAA,CAAAC,sBAAA,CAAAC,OAAA,YACA,IAAAC,MAAA,CAAAF,sBAAA,CAAAC,OAAA,WACA,IAAAE,OAAA,CAAAF,OAAA,WACA,IAAAG,MAAA,CAAAH,OAAA,UAEA,IAAAI,iBAAA,CAAAJ,OAAA,mCAEA,IAAAK,QAAA,CAAAL,OAAA,cATA,sBAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAM,cAAK,CAACC,MAAM,CAAG,IAAI,CAEnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAD,cAAK,CAACE,MAAM,CAAG,EAAE,CAAGF,cAAK,CAACC,MAAM,CAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAD,cAAK,CAACG,OAAO,CAAG,EAAE,CAAGH,cAAK,CAACE,MAAM,CAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAC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,CAAEK,KAAK,CAAE,CAAEU,IAAI,CAAE,GAAI,CAAC,CACrE,CACF,CAAC,CAAE,CAACf,UAAU,CAAEI,SAAS,CAAC,CAAC,CAC3B,MAAO,CAAAD,MACT,CAEApC,cAAK,CAACQ,KAAK,CAAGA,KAAK,CACnBR,cAAK,CAACmB,UAAU,CAAGA,UAAU,CAC7BnB,cAAK,CAACgC,iBAAiB,CAAGA,iBAAiB,CAAC,IAAAiB,QAAA,CAE7BjD,cAAK,CAAAkD,OAAA,CAAAC,OAAA,CAAAF,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"webpack.js","names":["requireWeak","modulePath","basePath","IS_CLIENT_SIDE","resolve","eval","path","default","def","named","Object","entries","forEach","key","value","Error","resolveWeak"],"sources":["../../../../src/shared/utils/webpack.js"],"sourcesContent":["import { IS_CLIENT_SIDE } from './isomorphy';\n\n/**\n * Requires the specified module without including it into the bundle during\n * Webpack build.\n * @param {string} modulePath\n * @param {string} [basePath]\n * @return {object} Required module.\n */\nexport function requireWeak(modulePath, basePath) {\n if (IS_CLIENT_SIDE) return null;\n\n try {\n /* eslint-disable no-eval */\n const { resolve } = eval('require')('path');\n const path = basePath ? resolve(basePath, modulePath) : modulePath;\n const { default: def, ...named } = eval('require')(path);\n /* eslint-enable no-eval */\n\n if (!def) return named;\n\n Object.entries(named).forEach(([key, value]) => {\n if (def[key]) throw Error('Conflict between default and named exports');\n def[key] = value;\n });\n return def;\n } catch {\n return null;\n }\n}\n\n/**\n * Resolves specified module path with help of Babel's module resolver.\n * Yes, the function itself just returns its argument to the caller, but Babel\n * is configured to resolve the first argument of resolveWeak(..) function, thus\n * the result will be the resolved path.\n * @param {string} modulePath\n * @return {string} Absolute or relative path to the module.\n */\nexport function resolveWeak(modulePath) {\n return modulePath;\n}\n"],"mappings":"sIAAA,sCAEA;AACA;AACA;AACA;AACA;AACA;AACA,GACO,QAASA,YAAW,CAACC,UAAU,CAAEC,QAAQ,CAAE,CAChD,GAAIC,yBAAc,CAAE,MAAO,KAAI,CAE/B,GAAI,CACF,4BACA,KAAM,CAAEC,OAAQ,CAAC,CAAGC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAC3C,KAAMC,KAAI,CAAGJ,QAAQ,CAAGE,OAAO,CAACF,QAAQ,CAAED,UAAU,CAAC,CAAGA,UAAU,CAClE,KAAM,CAAEM,OAAO,CAAEC,GAAG,CAAE,GAAGC,KAAM,CAAC,CAAGJ,IAAI,CAAC,SAAS,CAAC,CAACC,IAAI,CAAC,CACxD,2BAEA,GAAI,CAACE,GAAG,CAAE,MAAOC,MAAK,CAEtBC,MAAM,CAACC,OAAO,CAACF,KAAK,CAAC,CAACG,OAAO,CAAC,CAAC,CAACC,GAAG,CAAEC,KAAK,CAAC,GAAK,CAC9C,GAAIN,GAAG,CAACK,GAAG,CAAC,CAAE,KAAME,MAAK,CAAC,4CAA4C,CAAC,CACvEP,GAAG,CAACK,GAAG,CAAC,CAAGC,KACb,CAAC,CAAC,CACF,MAAON,IACT,CAAE,KAAM,CACN,MAAO,KACT,CACF,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACO,QAASQ,YAAW,CAACf,UAAU,CAAE,CACtC,MAAOA,WACT"}
1
+ {"version":3,"file":"webpack.js","names":["_isomorphy","require","requireWeak","modulePath","basePath","IS_CLIENT_SIDE","resolve","eval","path","default","def","named","Object","entries","forEach","key","value","Error","resolveWeak"],"sources":["../../../../src/shared/utils/webpack.js"],"sourcesContent":["import { IS_CLIENT_SIDE } from './isomorphy';\n\n/**\n * Requires the specified module without including it into the bundle during\n * Webpack build.\n * @param {string} modulePath\n * @param {string} [basePath]\n * @return {object} Required module.\n */\nexport function requireWeak(modulePath, basePath) {\n if (IS_CLIENT_SIDE) return null;\n\n try {\n /* eslint-disable no-eval */\n const { resolve } = eval('require')('path');\n const path = basePath ? resolve(basePath, modulePath) : modulePath;\n const { default: def, ...named } = eval('require')(path);\n /* eslint-enable no-eval */\n\n if (!def) return named;\n\n Object.entries(named).forEach(([key, value]) => {\n if (def[key]) throw Error('Conflict between default and named exports');\n def[key] = value;\n });\n return def;\n } catch {\n return null;\n }\n}\n\n/**\n * Resolves specified module path with help of Babel's module resolver.\n * Yes, the function itself just returns its argument to the caller, but Babel\n * is configured to resolve the first argument of resolveWeak(..) function, thus\n * the result will be the resolved path.\n * @param {string} modulePath\n * @return {string} Absolute or relative path to the module.\n */\nexport function resolveWeak(modulePath) {\n return modulePath;\n}\n"],"mappings":"sIAAA,IAAAA,UAAA,CAAAC,OAAA,gBAEA;AACA;AACA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAAC,WAAWA,CAACC,UAAU,CAAEC,QAAQ,CAAE,CAChD,GAAIC,yBAAc,CAAE,MAAO,KAAI,CAE/B,GAAI,CACF,4BACA,KAAM,CAAEC,OAAQ,CAAC,CAAGC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAC3C,KAAM,CAAAC,IAAI,CAAGJ,QAAQ,CAAGE,OAAO,CAACF,QAAQ,CAAED,UAAU,CAAC,CAAGA,UAAU,CAClE,KAAM,CAAEM,OAAO,CAAEC,GAAG,CAAE,GAAGC,KAAM,CAAC,CAAGJ,IAAI,CAAC,SAAS,CAAC,CAACC,IAAI,CAAC,CACxD,2BAEA,GAAI,CAACE,GAAG,CAAE,MAAO,CAAAC,KAAK,CAEtBC,MAAM,CAACC,OAAO,CAACF,KAAK,CAAC,CAACG,OAAO,CAAC,CAAC,CAACC,GAAG,CAAEC,KAAK,CAAC,GAAK,CAC9C,GAAIN,GAAG,CAACK,GAAG,CAAC,CAAE,KAAM,CAAAE,KAAK,CAAC,4CAA4C,CAAC,CACvEP,GAAG,CAACK,GAAG,CAAC,CAAGC,KACb,CAAC,CAAC,CACF,MAAO,CAAAN,GACT,CAAE,KAAM,CACN,MAAO,KACT,CACF,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAAQ,WAAWA,CAACf,UAAU,CAAE,CACtC,MAAO,CAAAA,UACT"}