@dr.pogodin/react-utils 1.17.1 → 1.17.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.
- package/build/development/client/index.js.map +1 -1
- package/build/development/client/init.js.map +1 -1
- package/build/development/index.js.map +1 -1
- package/build/development/server/Cache.js.map +1 -1
- package/build/development/server/index.js +5 -10
- package/build/development/server/index.js.map +1 -1
- package/build/development/server/renderer.js +35 -15
- package/build/development/server/renderer.js.map +1 -1
- package/build/development/server/server.js.map +1 -1
- package/build/development/server/utils/errors.js.map +1 -1
- package/build/development/server/utils/index.js.map +1 -1
- package/build/development/shared/components/Button/index.js.map +1 -1
- package/build/development/shared/components/Checkbox/index.js.map +1 -1
- package/build/development/shared/components/CodeSplit/index.js.map +1 -1
- package/build/development/shared/components/Dropdown/index.js.map +1 -1
- package/build/development/shared/components/GenericLink/index.js.map +1 -1
- package/build/development/shared/components/Input/index.js.map +1 -1
- package/build/development/shared/components/Link.js.map +1 -1
- package/build/development/shared/components/MetaTags.js.map +1 -1
- package/build/development/shared/components/Modal/index.js.map +1 -1
- package/build/development/shared/components/NavLink.js.map +1 -1
- package/build/development/shared/components/PageLayout/index.js.map +1 -1
- package/build/development/shared/components/ScalableRect/index.js.map +1 -1
- package/build/development/shared/components/Throbber/index.js.map +1 -1
- package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/development/shared/components/WithTooltip/index.js.map +1 -1
- package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/development/shared/components/index.js.map +1 -1
- package/build/development/shared/utils/Barrier.js.map +1 -1
- package/build/development/shared/utils/Emitter.js.map +1 -1
- package/build/development/shared/utils/Semaphore.js.map +1 -1
- package/build/development/shared/utils/config.js.map +1 -1
- package/build/development/shared/utils/index.js.map +1 -1
- package/build/development/shared/utils/isomorphy.js +1 -1
- package/build/development/shared/utils/isomorphy.js.map +1 -1
- package/build/development/shared/utils/jest/E2eSsrEnv.js +179 -0
- package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -0
- package/build/development/shared/utils/{jest.js → jest/index.js} +1 -1
- package/build/development/shared/utils/jest/index.js.map +1 -0
- package/build/development/shared/utils/splitComponent.js.map +1 -1
- package/build/development/shared/utils/time.js.map +1 -1
- package/build/development/shared/utils/webpack.js.map +1 -1
- package/build/development/web.bundle.js +1 -1
- package/build/production/client/index.js.map +1 -1
- package/build/production/client/init.js.map +1 -1
- package/build/production/index.js.map +1 -1
- package/build/production/server/Cache.js.map +1 -1
- package/build/production/server/index.js +5 -5
- package/build/production/server/index.js.map +1 -1
- package/build/production/server/renderer.js +27 -10
- package/build/production/server/renderer.js.map +1 -1
- package/build/production/server/server.js.map +1 -1
- package/build/production/server/utils/errors.js.map +1 -1
- package/build/production/server/utils/index.js.map +1 -1
- package/build/production/shared/components/Button/index.js.map +1 -1
- package/build/production/shared/components/Checkbox/index.js.map +1 -1
- package/build/production/shared/components/CodeSplit/index.js.map +1 -1
- package/build/production/shared/components/Dropdown/index.js.map +1 -1
- package/build/production/shared/components/GenericLink/index.js.map +1 -1
- package/build/production/shared/components/Input/index.js.map +1 -1
- package/build/production/shared/components/Link.js.map +1 -1
- package/build/production/shared/components/MetaTags.js.map +1 -1
- package/build/production/shared/components/Modal/index.js.map +1 -1
- package/build/production/shared/components/NavLink.js.map +1 -1
- package/build/production/shared/components/PageLayout/index.js.map +1 -1
- package/build/production/shared/components/ScalableRect/index.js.map +1 -1
- package/build/production/shared/components/Throbber/index.js.map +1 -1
- package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/production/shared/components/WithTooltip/index.js.map +1 -1
- package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/production/shared/components/index.js.map +1 -1
- package/build/production/shared/utils/Barrier.js.map +1 -1
- package/build/production/shared/utils/Emitter.js.map +1 -1
- package/build/production/shared/utils/Semaphore.js.map +1 -1
- package/build/production/shared/utils/config.js.map +1 -1
- package/build/production/shared/utils/index.js.map +1 -1
- package/build/production/shared/utils/isomorphy.js +1 -1
- package/build/production/shared/utils/isomorphy.js.map +1 -1
- package/build/production/shared/utils/jest/E2eSsrEnv.js +43 -0
- package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -0
- package/build/production/shared/utils/{jest.js → jest/index.js} +1 -1
- package/build/production/shared/utils/jest/index.js.map +1 -0
- package/build/production/shared/utils/splitComponent.js.map +1 -1
- package/build/production/shared/utils/time.js.map +1 -1
- package/build/production/shared/utils/webpack.js.map +1 -1
- package/build/production/web.bundle.js +1 -1
- package/build/production/web.bundle.js.map +1 -1
- package/config/webpack/app-base.js +48 -27
- package/config/webpack/app-development.js +40 -22
- package/config/webpack/app-production.js +8 -0
- package/config/webpack/lib-base.js +13 -6
- package/package.json +19 -16
- package/build/development/shared/utils/jest.js.map +0 -1
- package/build/production/shared/utils/jest.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/shared/components/WithTooltip/Tooltip.jsx"],"names":["PLACEMENTS","ABOVE_CURSOR","ABOVE_ELEMENT","BELOW_CURSOR","BELOW_ELEMENT","ARROW_STYLE_DOWN","join","ARROW_STYLE_UP","createTooltipComponents","theme","arrow","document","createElement","setAttribute","content","container","appendChild","body","calcTooltipRects","tooltip","getBoundingClientRect","calcViewportRect","pageXOffset","pageYOffset","window","documentElement","clientHeight","clientWidth","left","right","top","bottom","calcPositionAboveXY","x","y","tooltipRects","arrowX","width","arrowY","height","containerX","containerY","baseArrowStyle","setComponentPositions","pageX","pageY","placement","element","viewportRect","pos","Math","max","maxX","min","containerStyle","arrowStyle","Tooltip","children","ref","components","setComponents","pointTo","removeChild","propTypes","PT","node","shape","isRequired","defaultProps"],"mappings":"mMAOA,4BAMA,mCAEA,6DAfA;AACA;AACA;AACA;AACA,G,CACA,6B,CAYA;AACA,uDACO,KAAMA,CAAAA,UAAU,CAAG,CACxBC,YAAY,CAAE,cADU,CAExBC,aAAa,CAAE,eAFS,CAGxBC,YAAY,CAAE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aAAa,CAAC,IAAD,CACd,CACF,CAPD,CAOG,CAACnD,KAAD,CAPH,EASA,MAAOkD,CAAAA,UAAU,cAAG,2BAAaF,QAAb,CAAuBE,UAAU,CAAC7C,OAAlC,CAAH,CAAgD,IAClE,CAlBe,CAAhB,CAoBA0C,OAAO,CAACO,SAAR,CAAoB,CAClBN,QAAQ,CAAEO,mBAAGC,IADK,CAElBxD,KAAK,CAAEuD,mBAAGE,KAAH,GAAWC,UAFA,CAApB,CAKAX,OAAO,CAACY,YAAR,CAAuB,CACrBX,QAAQ,CAAE,IADW,CAAvB,C,aAIeD,O","sourcesContent":["/**\n * The actual tooltip component. It is rendered outside the regular document\n * hierarchy, and with sub-components managed without React to achieve the best\n * performance during animation.\n */\n/* global document, window */\n\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport PT from 'prop-types';\n\n/* Valid placements of the rendered tooltip. They will be overriden when\n * necessary to fit the tooltip within the viewport. */\nexport const PLACEMENTS = {\n ABOVE_CURSOR: 'ABOVE_CURSOR',\n ABOVE_ELEMENT: 'ABOVE_ELEMENT',\n BELOW_CURSOR: 'BELOW_CURSOR',\n BELOW_ELEMENT: 'BELOW_ELEMENT',\n};\n\nconst ARROW_STYLE_DOWN = [\n 'border-bottom-color:transparent',\n 'border-left-color:transparent',\n 'border-right-color:transparent',\n].join(';');\n\nconst ARROW_STYLE_UP = [\n 'border-top-color:transparent',\n 'border-left-color:transparent',\n 'border-right-color:transparent',\n].join(';');\n\n/**\n * Creates tooltip components.\n * @ignore\n * @param {object} theme Themes to use for tooltip container, arrow,\n * and content.\n * @return {object} Object with DOM references to the container components:\n * container, arrow, content.\n */\nfunction createTooltipComponents(theme) {\n const arrow = document.createElement('div');\n if (theme.arrow) arrow.setAttribute('class', theme.arrow);\n\n const content = document.createElement('div');\n if (theme.content) content.setAttribute('class', theme.content);\n\n const container = document.createElement('div');\n if (theme.container) container.setAttribute('class', theme.container);\n\n container.appendChild(arrow);\n container.appendChild(content);\n document.body.appendChild(container);\n\n return { container, arrow, content };\n}\n\n/**\n * Generates bounding client rectangles for tooltip components.\n * @ignore\n * @param {object} tooltip DOM references to the tooltip components.\n * @param {object} tooltip.arrow\n * @param {object} tooltip.container\n * @return {{ arrow: object, container}} Object holding tooltip rectangles in\n * two fields.\n */\nfunction calcTooltipRects(tooltip) {\n return {\n arrow: tooltip.arrow.getBoundingClientRect(),\n container: tooltip.container.getBoundingClientRect(),\n };\n}\n\n/**\n * Calculates the document viewport size.\n * @ignore\n * @return {{x, y, width, height}}\n */\nfunction calcViewportRect() {\n const { pageXOffset, pageYOffset } = window;\n const { documentElement: { clientHeight, clientWidth } } = document;\n return {\n left: pageXOffset,\n right: pageXOffset + clientWidth,\n top: pageYOffset,\n bottom: pageYOffset + clientHeight,\n };\n}\n\n/**\n * Calculates tooltip and arrow positions for the placement just above\n * the cursor.\n * @ignore\n * @param {number} x Cursor page-x position.\n * @param {number} y Cursor page-y position.\n * @param {object} tooltipRects Bounding client rectangles of tooltip parts.\n * @param {object} tooltipRects.arrow\n * @param {object} tooltipRects.container\n * @return {object} Contains the following fields:\n * - {number} arrowX\n * - {number} arrowY\n * - {number} containerX\n * - {number} containerY\n * - {string} baseArrowStyle\n */\nfunction calcPositionAboveXY(x, y, tooltipRects) {\n const { arrow, container } = tooltipRects;\n return {\n arrowX: 0.5 * (container.width - arrow.width),\n arrowY: container.height,\n containerX: x - container.width / 2,\n containerY: y - container.height - arrow.height / 1.5,\n\n // TODO: Instead of already setting the base style here, we should\n // introduce a set of constants for arrow directions, which will help\n // to do checks dependant on the arrow direction.\n baseArrowStyle: ARROW_STYLE_DOWN,\n };\n}\n\n/*\nconst HIT = {\n NONE: false,\n LEFT: 'LEFT',\n RIGHT: 'RIGHT',\n TOP: 'TOP',\n BOTTOM: 'BOTTOM',\n};\n*/\n\n/**\n * Checks whether\n * @param {object} pos\n * @param {object} tooltipRects\n * @param {object} viewportRect\n * @return {HIT}\n */\n/*\nfunction checkViewportFit(pos, tooltipRects, viewportRect) {\n const { containerX, containerY } = pos;\n if (containerX < viewportRect.left + 6) return HIT.LEFT;\n if (containerX > viewportRect.right - 6) return HIT.RIGHT;\n return HIT.NONE;\n}\n*/\n\n/**\n * Shifts tooltip horizontally to fit into the viewport, while keeping\n * the arrow pointed to the XY point.\n * @param {number} x\n * @param {number} y\n * @param {object} pos\n * @param {number} pageXOffset\n * @param {number} pageXWidth\n */\n/*\nfunction xPageFitCorrection(x, y, pos, pageXOffset, pageXWidth) {\n if (pos.containerX < pageXOffset + 6) {\n pos.containerX = pageXOffset + 6;\n pos.arrowX = Math.max(6, pageX - containerX - arrowRect.width / 2);\n } else {\n const maxX = pageXOffset + docRect.width - containerRect.width - 6;\n if (containerX > maxX) {\n containerX = maxX;\n arrowX = Math.min(\n containerRect.width - 6,\n pageX - containerX - arrowRect.width / 2,\n );\n }\n }\n}\n*/\n\n/**\n * Sets positions of tooltip components to point the tooltip to the specified\n * page point.\n * @ignore\n * @param {number} pageX\n * @param {number} pageY\n * @param {PLACEMENTS} placement\n * @param {object} element DOM reference to the element wrapped by the tooltip.\n * @param {object} tooltip\n * @param {object} tooltip.arrow DOM reference to the tooltip arrow.\n * @param {object} tooltip.container DOM reference to the tooltip container.\n */\nfunction setComponentPositions(\n pageX,\n pageY,\n placement,\n element,\n tooltip,\n) {\n const tooltipRects = calcTooltipRects(tooltip);\n const viewportRect = calcViewportRect();\n\n /* Default container coords: tooltip at the top. */\n const pos = calcPositionAboveXY(pageX, pageY, tooltipRects);\n\n if (pos.containerX < viewportRect.left + 6) {\n pos.containerX = viewportRect.left + 6;\n pos.arrowX = Math.max(\n 6,\n pageX - pos.containerX - tooltipRects.arrow.width / 2,\n );\n } else {\n const maxX = viewportRect.right - 6 - tooltipRects.container.width;\n if (pos.containerX > maxX) {\n pos.containerX = maxX;\n pos.arrowX = Math.min(\n tooltipRects.container.width - 6,\n pageX - pos.containerX - tooltipRects.arrow.width / 2,\n );\n }\n }\n\n /* If tooltip has not enough space on top - make it bottom tooltip. */\n if (pos.containerY < viewportRect.top + 6) {\n pos.containerY += tooltipRects.container.height\n + 2 * tooltipRects.arrow.height;\n pos.arrowY -= tooltipRects.container.height\n + tooltipRects.arrow.height;\n pos.baseArrowStyle = ARROW_STYLE_UP;\n }\n\n const containerStyle = `left:${pos.containerX}px;top:${pos.containerY}px`;\n tooltip.container.setAttribute('style', containerStyle);\n\n const arrowStyle = `${pos.baseArrowStyle};left:${pos.arrowX}px;top:${pos.arrowY}px`;\n tooltip.arrow.setAttribute('style', arrowStyle);\n}\n\n/* The Tooltip component itself. */\nconst Tooltip = forwardRef(({ children, theme }, ref) => {\n const [components, setComponents] = useState(null);\n\n const pointTo = (pageX, pageY, placement, element) => components\n && setComponentPositions(pageX, pageY, placement, element, components);\n useImperativeHandle(ref, () => ({ pointTo }));\n\n /* Inits and destroys tooltip components. */\n useEffect(() => {\n const x = createTooltipComponents(theme);\n setComponents(x);\n return () => {\n document.body.removeChild(x.container);\n setComponents(null);\n };\n }, [theme]);\n\n return components ? createPortal(children, components.content) : null;\n});\n\nTooltip.propTypes = {\n children: PT.node,\n theme: PT.shape().isRequired,\n};\n\nTooltip.defaultProps = {\n children: null,\n};\n\nexport default Tooltip;\n"],"file":"Tooltip.js"}
|
|
1
|
+
{"version":3,"file":"Tooltip.js","names":["PLACEMENTS","ABOVE_CURSOR","ABOVE_ELEMENT","BELOW_CURSOR","BELOW_ELEMENT","ARROW_STYLE_DOWN","join","ARROW_STYLE_UP","createTooltipComponents","theme","arrow","document","createElement","setAttribute","content","container","appendChild","body","calcTooltipRects","tooltip","getBoundingClientRect","calcViewportRect","pageXOffset","pageYOffset","window","documentElement","clientHeight","clientWidth","left","right","top","bottom","calcPositionAboveXY","x","y","tooltipRects","arrowX","width","arrowY","height","containerX","containerY","baseArrowStyle","setComponentPositions","pageX","pageY","placement","element","viewportRect","pos","Math","max","maxX","min","containerStyle","arrowStyle","Tooltip","children","ref","components","setComponents","pointTo","removeChild","propTypes","PT","node","shape","isRequired","defaultProps"],"sources":["../../../../../src/shared/components/WithTooltip/Tooltip.jsx"],"sourcesContent":["/**\n * The actual tooltip component. It is rendered outside the regular document\n * hierarchy, and with sub-components managed without React to achieve the best\n * performance during animation.\n */\n/* global document, window */\n\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport PT from 'prop-types';\n\n/* Valid placements of the rendered tooltip. They will be overriden when\n * necessary to fit the tooltip within the viewport. */\nexport const PLACEMENTS = {\n ABOVE_CURSOR: 'ABOVE_CURSOR',\n ABOVE_ELEMENT: 'ABOVE_ELEMENT',\n BELOW_CURSOR: 'BELOW_CURSOR',\n BELOW_ELEMENT: 'BELOW_ELEMENT',\n};\n\nconst ARROW_STYLE_DOWN = [\n 'border-bottom-color:transparent',\n 'border-left-color:transparent',\n 'border-right-color:transparent',\n].join(';');\n\nconst ARROW_STYLE_UP = [\n 'border-top-color:transparent',\n 'border-left-color:transparent',\n 'border-right-color:transparent',\n].join(';');\n\n/**\n * Creates tooltip components.\n * @ignore\n * @param {object} theme Themes to use for tooltip container, arrow,\n * and content.\n * @return {object} Object with DOM references to the container components:\n * container, arrow, content.\n */\nfunction createTooltipComponents(theme) {\n const arrow = document.createElement('div');\n if (theme.arrow) arrow.setAttribute('class', theme.arrow);\n\n const content = document.createElement('div');\n if (theme.content) content.setAttribute('class', theme.content);\n\n const container = document.createElement('div');\n if (theme.container) container.setAttribute('class', theme.container);\n\n container.appendChild(arrow);\n container.appendChild(content);\n document.body.appendChild(container);\n\n return { container, arrow, content };\n}\n\n/**\n * Generates bounding client rectangles for tooltip components.\n * @ignore\n * @param {object} tooltip DOM references to the tooltip components.\n * @param {object} tooltip.arrow\n * @param {object} tooltip.container\n * @return {{ arrow: object, container}} Object holding tooltip rectangles in\n * two fields.\n */\nfunction calcTooltipRects(tooltip) {\n return {\n arrow: tooltip.arrow.getBoundingClientRect(),\n container: tooltip.container.getBoundingClientRect(),\n };\n}\n\n/**\n * Calculates the document viewport size.\n * @ignore\n * @return {{x, y, width, height}}\n */\nfunction calcViewportRect() {\n const { pageXOffset, pageYOffset } = window;\n const { documentElement: { clientHeight, clientWidth } } = document;\n return {\n left: pageXOffset,\n right: pageXOffset + clientWidth,\n top: pageYOffset,\n bottom: pageYOffset + clientHeight,\n };\n}\n\n/**\n * Calculates tooltip and arrow positions for the placement just above\n * the cursor.\n * @ignore\n * @param {number} x Cursor page-x position.\n * @param {number} y Cursor page-y position.\n * @param {object} tooltipRects Bounding client rectangles of tooltip parts.\n * @param {object} tooltipRects.arrow\n * @param {object} tooltipRects.container\n * @return {object} Contains the following fields:\n * - {number} arrowX\n * - {number} arrowY\n * - {number} containerX\n * - {number} containerY\n * - {string} baseArrowStyle\n */\nfunction calcPositionAboveXY(x, y, tooltipRects) {\n const { arrow, container } = tooltipRects;\n return {\n arrowX: 0.5 * (container.width - arrow.width),\n arrowY: container.height,\n containerX: x - container.width / 2,\n containerY: y - container.height - arrow.height / 1.5,\n\n // TODO: Instead of already setting the base style here, we should\n // introduce a set of constants for arrow directions, which will help\n // to do checks dependant on the arrow direction.\n baseArrowStyle: ARROW_STYLE_DOWN,\n };\n}\n\n/*\nconst HIT = {\n NONE: false,\n LEFT: 'LEFT',\n RIGHT: 'RIGHT',\n TOP: 'TOP',\n BOTTOM: 'BOTTOM',\n};\n*/\n\n/**\n * Checks whether\n * @param {object} pos\n * @param {object} tooltipRects\n * @param {object} viewportRect\n * @return {HIT}\n */\n/*\nfunction checkViewportFit(pos, tooltipRects, viewportRect) {\n const { containerX, containerY } = pos;\n if (containerX < viewportRect.left + 6) return HIT.LEFT;\n if (containerX > viewportRect.right - 6) return HIT.RIGHT;\n return HIT.NONE;\n}\n*/\n\n/**\n * Shifts tooltip horizontally to fit into the viewport, while keeping\n * the arrow pointed to the XY point.\n * @param {number} x\n * @param {number} y\n * @param {object} pos\n * @param {number} pageXOffset\n * @param {number} pageXWidth\n */\n/*\nfunction xPageFitCorrection(x, y, pos, pageXOffset, pageXWidth) {\n if (pos.containerX < pageXOffset + 6) {\n pos.containerX = pageXOffset + 6;\n pos.arrowX = Math.max(6, pageX - containerX - arrowRect.width / 2);\n } else {\n const maxX = pageXOffset + docRect.width - containerRect.width - 6;\n if (containerX > maxX) {\n containerX = maxX;\n arrowX = Math.min(\n containerRect.width - 6,\n pageX - containerX - arrowRect.width / 2,\n );\n }\n }\n}\n*/\n\n/**\n * Sets positions of tooltip components to point the tooltip to the specified\n * page point.\n * @ignore\n * @param {number} pageX\n * @param {number} pageY\n * @param {PLACEMENTS} placement\n * @param {object} element DOM reference to the element wrapped by the tooltip.\n * @param {object} tooltip\n * @param {object} tooltip.arrow DOM reference to the tooltip arrow.\n * @param {object} tooltip.container DOM reference to the tooltip container.\n */\nfunction setComponentPositions(\n pageX,\n pageY,\n placement,\n element,\n tooltip,\n) {\n const tooltipRects = calcTooltipRects(tooltip);\n const viewportRect = calcViewportRect();\n\n /* Default container coords: tooltip at the top. */\n const pos = calcPositionAboveXY(pageX, pageY, tooltipRects);\n\n if (pos.containerX < viewportRect.left + 6) {\n pos.containerX = viewportRect.left + 6;\n pos.arrowX = Math.max(\n 6,\n pageX - pos.containerX - tooltipRects.arrow.width / 2,\n );\n } else {\n const maxX = viewportRect.right - 6 - tooltipRects.container.width;\n if (pos.containerX > maxX) {\n pos.containerX = maxX;\n pos.arrowX = Math.min(\n tooltipRects.container.width - 6,\n pageX - pos.containerX - tooltipRects.arrow.width / 2,\n );\n }\n }\n\n /* If tooltip has not enough space on top - make it bottom tooltip. */\n if (pos.containerY < viewportRect.top + 6) {\n pos.containerY += tooltipRects.container.height\n + 2 * tooltipRects.arrow.height;\n pos.arrowY -= tooltipRects.container.height\n + tooltipRects.arrow.height;\n pos.baseArrowStyle = ARROW_STYLE_UP;\n }\n\n const containerStyle = `left:${pos.containerX}px;top:${pos.containerY}px`;\n tooltip.container.setAttribute('style', containerStyle);\n\n const arrowStyle = `${pos.baseArrowStyle};left:${pos.arrowX}px;top:${pos.arrowY}px`;\n tooltip.arrow.setAttribute('style', arrowStyle);\n}\n\n/* The Tooltip component itself. */\nconst Tooltip = forwardRef(({ children, theme }, ref) => {\n const [components, setComponents] = useState(null);\n\n const pointTo = (pageX, pageY, placement, element) => components\n && setComponentPositions(pageX, pageY, placement, element, components);\n useImperativeHandle(ref, () => ({ pointTo }));\n\n /* Inits and destroys tooltip components. */\n useEffect(() => {\n const x = createTooltipComponents(theme);\n setComponents(x);\n return () => {\n document.body.removeChild(x.container);\n setComponents(null);\n };\n }, [theme]);\n\n return components ? createPortal(children, components.content) : null;\n});\n\nTooltip.propTypes = {\n children: PT.node,\n theme: PT.shape().isRequired,\n};\n\nTooltip.defaultProps = {\n children: null,\n};\n\nexport default Tooltip;\n"],"mappings":"mMAOA,4BAMA,mCAEA,6DAfA;AACA;AACA;AACA;AACA,G,CACA,6B,CAYA;AACA,uDACO,KAAMA,CAAAA,UAAU,CAAG,CACxBC,YAAY,CAAE,cADU,CAExBC,aAAa,CAAE,eAFS,CAGxBC,YAAY,CAAE,cAHU,CAIxBC,aAAa,CAAE,eAJS,CAAnB,C,8BAOP,KAAMC,CAAAA,gBAAgB,CAAG,CACvB,iCADuB,CAEvB,+BAFuB,CAGvB,gCAHuB,EAIvBC,IAJuB,CAIlB,GAJkB,CAAzB,CAMA,KAAMC,CAAAA,cAAc,CAAG,CACrB,8BADqB,CAErB,+BAFqB,CAGrB,gCAHqB,EAIrBD,IAJqB,CAIhB,GAJgB,CAAvB,CAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAASE,CAAAA,uBAAT,CAAiCC,KAAjC,CAAwC,CACtC,KAAMC,CAAAA,KAAK,CAAGC,QAAQ,CAACC,aAAT,CAAuB,KAAvB,CAAd,CACA,GAAIH,KAAK,CAACC,KAAV,CAAiBA,KAAK,CAACG,YAAN,CAAmB,OAAnB,CAA4BJ,KAAK,CAACC,KAAlC,EAEjB,KAAMI,CAA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B,OAA3B,CAAoC0C,UAApC,CACD,CAED,mCACA,KAAMC,CAAAA,OAAO,cAAG,sBAAW,CAAC,CAAEC,QAAF,CAAYhD,KAAZ,CAAD,CAAsBiD,GAAtB,GAA8B,CACvD,KAAM,CAACC,UAAD,CAAaC,aAAb,EAA8B,oBAAS,IAAT,CAApC,CAEA,KAAMC,CAAAA,OAAO,CAAG,CAACjB,KAAD,CAAQC,KAAR,CAAeC,SAAf,CAA0BC,OAA1B,GAAsCY,UAAU,EAC3DhB,qBAAqB,CAACC,KAAD,CAAQC,KAAR,CAAeC,SAAf,CAA0BC,OAA1B,CAAmCY,UAAnC,CAD1B,CAEA,+BAAoBD,GAApB,CAAyB,KAAO,CAAEG,OAAF,CAAP,CAAzB,EAEA,4CACA,qBAAU,IAAM,CACd,KAAM5B,CAAAA,CAAC,CAAGzB,uBAAuB,CAACC,KAAD,CAAjC,CACAmD,aAAa,CAAC3B,CAAD,CAAb,CACA,MAAO,IAAM,CACXtB,QAAQ,CAACM,IAAT,CAAc6C,WAAd,CAA0B7B,CAAC,CAAClB,SAA5B,EACA6C,aAAa,CAAC,IAAD,CACd,CACF,CAPD,CAOG,CAACnD,KAAD,CAPH,EASA,MAAOkD,CAAAA,UAAU,cAAG,2BAAaF,QAAb,CAAuBE,UAAU,CAAC7C,OAAlC,CAAH,CAAgD,IAClE,CAlBe,CAAhB,CAoBA0C,OAAO,CAACO,SAAR,CAAoB,CAClBN,QAAQ,CAAEO,mBAAGC,IADK,CAElBxD,KAAK,CAAEuD,mBAAGE,KAAH,GAAWC,UAFA,CAApB,CAKAX,OAAO,CAACY,YAAR,CAAuB,CACrBX,QAAQ,CAAE,IADW,CAAvB,C,aAIeD,O"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":["Wrapper","children","placement","tip","theme","tooltipRef","wrapperRef","showTooltip","setShowTooltip","updatePortalPosition","cursorX","cursorY","wrapperRect","current","getBoundingClientRect","left","right","top","bottom","pointTo","window","pageXOffset","pageYOffset","listener","addEventListener","removeEventListener","undefined","wrapper","e","clientX","clientY","ThemedWrapper","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 – 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,2D,igCAPA,mB,sJAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAASA,CAAAA,OAAT,CAAiB,CACfC,QADe,CAEfC,SAFe,CAGfC,GAHe,CAIfC,KAJe,CAAjB,CAKG,CACD,KAAMC,CAAAA,UAAU,CAAG,mBAAnB,CACA,KAAMC,CAAAA,UAAU,CAAG,mBAAnB,CACA,KAAM,CAACC,WAAD,CAAcC,cAAd,EAAgC,oBAAS,KAAT,CAAtC,CAEA,KAAMC,CAAAA,oBAAoB,CAAG,CAACC,OAAD,CAAUC,OAAV,GAAsB,CACjD,GAAI,CAACJ,WAAL,CAAkBC,cAAc,CAAC,IAAD,CAAd,CAAlB,IACK,CACH,KAAMI,CAAAA,WAAW,CAAGN,UAAU,CAACO,OAAX,CAAmBC,qBAAnB,EAApB,CACA,GACEJ,OAAO,CAAGE,WAAW,CAACG,IAAtB,EACGL,OAAO,CAAGE,WAAW,CAACI,KADzB,EAEGL,OAAO,CAAGC,WAAW,CA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A3B,CAEAjC,OAAO,CAACkC,SAAR,CAAoB,CAClBjC,QAAQ,CAAEkC,mBAAGC,IADK,CAElBlC,SAAS,CAAEiC,mBAAGE,KAAH,CAASC,MAAM,CAACC,MAAP,CAAcN,mBAAd,CAAT,CAFO,CAGlB7B,KAAK,CAAE2B,aAAa,CAACS,SAAd,CAAwBC,UAHb,CAIlBtC,GAAG,CAAEgC,mBAAGC,IAJU,CAApB,CAOApC,OAAO,CAAC0C,YAAR,CAAuB,CACrBzC,QAAQ,CAAE,IADW,CAErBC,SAAS,CAAE+B,oBAAWU,YAFD,CAGrBxC,GAAG,CAAE,IAHgB,CAAvB,C,aAMe4B,a"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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","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,6D,kPAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAASA,CAAAA,YAAT,CAAsB,CACpBC,QADoB,CAEpBC,GAFoB,CAGpBC,KAHoB,CAIpBC,KAJoB,CAAtB,CAKG,CACD,GAAI,CAACC,GAAD,CAAMC,KAAN,EAAeJ,GAAG,CAACK,KAAJ,CAAU,GAAV,CAAnB,CACAD,KAAK,CAAGA,KAAK,CAAGE,YAAGC,KAAH,CAASH,KAAT,CAAH,CAAqB,EAAlC,CAEA,KAAMI,CAAAA,OAAO,CAAGJ,KAAK,CAACK,CAAN,EAAWN,GAAG,CAACO,KAAJ,CAAU,qBAAV,EAAiC,CAAjC,CAA3B,CACAP,GAAG,CAAI,iCAAgCK,OAAQ,EAA/C,CAEA,MAAOJ,CAAAA,KAAK,CAACK,CAAb,CACAL,KAAK,CAACL,QAAN,CAAiBA,QAAQ,CAAG,CAAH,CAAO,CAAhC,CACAI,GAAG,EAAK,IAAGG,YAAGK,SAAH,CAAaP,KAAb,CAAoB,EAA/B,CAEA;AACA;AAEA,mBACE,qBAAC,qBAAD,EAAc,SAAS,CAAEH,KAAK,CAACW,SAA/B,CAA0C,KAAK,CAAC,MAAhD,wBACE,oBAAC,iBAAD,EAAU,KAAK,CAAEC,aAAjB,EADF,cAEE,8BACE,KAAK,CAAC,UADR,CAEE,eAAe,KAFjB,CAGE,SAAS,CAAEZ,KAAK,CAACa,KAHnB,CAIE,GAAG,CAAEX,GAJP,CAKE,KAAK,CAAED,KALT,EAFF,GAWH,CAED,KAAMa,CAAAA,kBAAkB,CAAG,yBACzB,cADyB,CAEzB,CACE,WADF,CAEE,OAFF,CAFyB,CAMzBC,SANyB,EAOzBlB,YAPyB,CAA3B,CASAA,YAAY,CAACmB,SAAb,CAAyB,CACvBlB,QAAQ,CAAEmB,mBAAGC,IADU,CAEvBnB,GAAG,CAAEkB,mBAAGE,MAAH,CAAUC,UAFQ,CAGvBpB,KAAK,CAAEc,kBAAkB,CAACO,SAAnB,CAA6BD,UAHb,CAIvBnB,KAAK,CAAEgB,mBAAGE,MAJa,CAAzB,CAOAtB,YAAY,CAACyB,YAAb,CAA4B,CAC1BxB,QAAQ,CAAE,KADgB,CAE1BG,KAAK,CAAE,EAFmB,CAA5B,C,aAKea,kB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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,oE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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,CAAAA,OAAN,QAAsBC,CAAAA,OAAQ,CACnC,CAACC,OAAD,CAEA,CAACC,QAAD,CAAY,KAAZ,CAEA,CAACC,MAAD,CAEA,CAACC,QAAD,CAAY,K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","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,CAAAA,OAAQ,CAC3B;AACF;AACA,KACEC,WAAW,EAAG,CACZ,KAAKC,SAAL,CAAiB,EAClB,CAED;AACF;AACA;AACA,KACkB,GAAZC,CAAAA,YAAY,EAAG,CACjB,MAAO,CAAC,CAAC,KAAKD,SAAL,CAAeE,MACzB,CAED;AACF;AACA;AACA;AACA,KACEC,WAAW,CAACC,QAAD,CAAW,CACpB,GAAI,CAAC,KAAKJ,SAAL,CAAeK,QAAf,CAAwBD,QAAxB,CAAL,CAAwC,CACtC,KAAKJ,SAAL,CAAeM,IAAf,CAAoBF,QAApB,CACD,CACD,MAAO,IAAM,KAAKG,cAAL,CAAoBH,QAApB,CACd,CAED;AACF;AACA;AACA,KACEI,IAAI,CAAC,GAAGC,IAAJ,CAAU,CACZ,KAAM,CAAET,SAAF,EAAgB,IAAtB,CACA,IAAK,GAAIU,CAAAA,CAAC,CAAG,CAAb,CAAgBA,CAAC,CAAGV,SAAS,CAACE,MAA9B,CAAsC,EAAEQ,CAAxC,CAA2C,CACzCV,SAAS,CAACU,CAAD,CAAT,CAAa,GAAGD,IAAhB,CACD,CACF,CAED;AACF;AACA;AACA,KACEF,cAAc,CAACH,QAAD,CAAW,CACvB,KAAMO,CAAAA,GAAG,CAAG,KAAKX,SAAL,CAAeY,OAAf,CAAuBR,QAAvB,CAAZ,CACA,GAAIO,GAAG,EAAI,CAAX,CAAc,KAAKX,SAAL,CAAea,MAAf,CAAsBF,GAAtB,CAA2B,CAA3B,CACf,CA9C0B,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Semaphore.js","names":["Semaphore","constructor","ready","setReady","bool","draining","drainQueue","seize","waitReady","queue","length","barrier","push","next","shift","resolve","setTimeout","bind"],"sources":["../../../../src/shared/utils/Semaphore.js"],"sourcesContent":["import { newBarrier } 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.#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 await this.waitReady();\n this.setReady(false);\n }\n\n async waitReady() {\n if (!this.#ready || this.#queue.length) {\n const barrier = newBarrier();\n this.#queue.push(barrier);\n await barrier;\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 #drainQueue() {\n if (this.#ready && this.#queue.length) {\n const next = this.#queue.shift();\n next.resolve();\n\n // Re-schedules itself for the next event loop iteration.\n if (this.#queue.length) {\n setTimeout(this.#drainQueue.bind(this));\n this.#draining = true;\n return; // Exit here to avoid the drain loop termination below.\n }\n }\n\n // Cleans up for the drain loop termination.\n this.#draining = false;\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 // 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,kCAEA;AACA;AACA,GACe,KAAMA,CAAAA,SAAU,CAC7BC,WAAW,CAACC,KAAD,CAAQ,CACjB,KAAK,CAACA,KAAN,CAAc,CAAC,CAACA,KACjB,CAEQ,GAALA,CAAAA,KAAK,EAAG,CAAE,MAAO,MAAK,CAACA,KAAQ,CAEnCC,QAAQ,CAACD,KAAD,CAAQ,CACd,KAAME,CAAAA,IAAI,CAAG,CAAC,CAACF,KAAf,CACA,GAAI,KAAK,CAACA,KAAN,GAAgBE,IAApB,CAA0B,CACxB,KAAK,CAACF,KAAN,CAAcE,IAAd,CACA,GAAIA,IAAI,EAAI,CAAC,KAAK,CAACC,QAAnB,CAA6B,KAAK,CAACC,UAAN,EAC9B,CACF,CAED;AACF;AACA;AACA,KACa,KAALC,CAAAA,KAAK,EAAG,CACZ,KAAM,MAAKC,SAAL,EAAN,CACA,KAAKL,QAAL,CAAc,KAAd,CACD,CAEc,KAATK,CAAAA,SAAS,EAAG,CAChB,GAAI,CAAC,KAAK,CAACN,KAAP,EAAgB,KAAK,CAACO,KAAN,CAAYC,MAAhC,CAAwC,CACtC,KAAMC,CAAAA,OAAO,CAAG,yBAAhB,CACA,KAAK,CAACF,KAAN,CAAYG,IAAZ,CAAiBD,OAAjB,EACA,KAAMA,CAAAA,OACP,CACF,CAED;AAEA;AACF;AACA;AACA;AACA;AACA,KACE,CAACL,UAAU,EAAG,CACZ,GAAI,KAAK,CAACJ,KAAN,EAAe,KAAK,CAACO,KAAN,CAAYC,MAA/B,CAAuC,CACrC,KAAMG,CAAAA,IAAI,CAAG,KAAK,CAACJ,KAAN,CAAYK,KAAZ,EAAb,CACAD,IAAI,CAACE,OAAL,GAEA;AACA,GAAI,KAAK,CAACN,KAAN,CAAYC,MAAhB,CAAwB,CACtBM,UAAU,CAAC,KAAK,CAACV,UAAN,CAAiBW,IAAjB,CAAsB,IAAtB,CAAD,CAAV,CACA,KAAK,CAACZ,QAAN,CAAiB,IAAjB,CACA,OAAQ;AACT,CACF,CAED;AACA,KAAK,CAACA,QAAN,CAAiB,KAClB,CAED;AACA;AACA,CAACA,QAAD,CAAY,KAAZ,CAEA;AACA;AACA,CAACI,KAAD,CAAS,EAAT,CAEA,CAACP,KAjE4B,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"config.js","names":["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,mB,CAIA,mC,aACe,yBAAY,QAAZ,GAAyBA,MAAM,CAACC,MAAhC,EAA0C,E,CACzD,kC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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","time","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 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 time.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,8D,4BACA,oDACA,0D,wBAEA,gVACA,0DACA,8DACA,wE,o9BAEAA,qBAAOC,OAAP,CAAiBA,oBAAjB,CACAD,qBAAOE,QAAP,CAAkBA,qBAAlB,CAEA;AACA;AACA;AACA,GAAIC,CAAAA,eAAJ,CACA,GAAI,CACFA,eAAe,CAAGC,OAAO,CAACC,GAAR,CAAYF,eAC/B,CAAC,KAAM,CAAE,UAAY,CAEtB,KAAME,CAAAA,GAAG,CAAGF,eAAe,EAAIC,OAAO,CAACC,GAAR,CAAYC,QAA3C,CACA,KAAMC,CAAAA,EAAE,CAAGF,GAAG,GAAK,YAAR,EAAwBG,OAAO,CAACC,WAAR,UAA8BC,SAA9B,CAAnC,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,G,cACO,cAAeC,CAAAA,WAAf,CAA2BC,MAA3B,CAAmCC,UAAU,CAAG,CAAhD,CAAmDC,QAAQ,CAAG,IAA9D,CAAoE,CACzE,qCACA,IAAK,GAAIC,CAAAA,CAAC,CAAG,CAAb,EAAkB,EAAEA,CAApB,CAAuB,CACrB,GAAI,CACF,MAAO,MAAMH,CAAAA,MAAM,EACpB,CAAC,MAAOI,KAAP,CAAc,CACd,GAAID,CAAC,CAAGF,UAAR,CAAoB,KAAMI,eAAKC,KAAL,CAAWJ,QAAX,CAAN,CAApB,IACK,MAAME,CAAAA,KACZ,CACF,CACD,oCACD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.IS_SERVER_SIDE=exports.IS_CLIENT_SIDE=void 0;exports.buildTimestamp=buildTimestamp;exports.getBuildInfo=getBuildInfo;exports.isDevBuild=isDevBuild;exports.isProdBuild=isProdBuild;/* global window */ /**
|
|
2
2
|
* `true` within client-side environment (browser), `false` at server-side.
|
|
3
|
-
*/const IS_CLIENT_SIDE=typeof process!=="object"||!process.versions||!process.versions.node;/**
|
|
3
|
+
*/const IS_CLIENT_SIDE=typeof process!=="object"||!process.versions||!process.versions.node||!!global.REACT_UTILS_FORCE_CLIENT_SIDE;/**
|
|
4
4
|
* `true` within the server-side environment (node), `false` at client-side.
|
|
5
5
|
*/exports.IS_CLIENT_SIDE=IS_CLIENT_SIDE;const IS_SERVER_SIDE=!IS_CLIENT_SIDE;/**
|
|
6
6
|
* @ignore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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,mB,CAEA;AACA;AACA,GACO,KAAMA,CAAAA,cAAc,CAAG,MAAOC,CAAAA,OAAP,GAAmB,QAAnB,EACzB,CAACA,OAAO,CAACC,QADgB,EACJ,CAACD,OAAO,CAACC,QAAR,CAAiBC,IADd,EAEzB,CAAC,CAACC,MAAM,CAACC,6BAFP,CAIP;AACA;AACA,G,sCACO,KAAMC,CAAAA,cAAc,CAAG,CAACN,cAAxB,CAEP;AACA;AACA;AACA,G,sCACA,QAASO,CAAAA,OAAT,EAAmB,CACjB,MAAON,CAAAA,OAAO,CAACO,GAAR,CAAYC,QACpB,CAED;AACA;AACA;AACA;AACA,GACO,QAASC,CAAAA,UAAT,EAAsB,CAC3B,MAAOH,CAAAA,OAAO,KAAO,aACtB,CAED;AACA;AACA;AACA;AACA,GACO,QAASI,CAAAA,WAAT,EAAuB,CAC5B,MAAOJ,CAAAA,OAAO,KAAO,YACtB,CAED;AACA;AACA;AACA,GACO,QAASK,CAAAA,YAAT,EAAwB,CAC7B,MAAO,CAACZ,cAAc,CAAGa,MAAH,CAAYT,MAA3B,EAAmCU,cAC3C,CAED;AACA;AACA;AACA,GACO,QAASC,CAAAA,cAAT,EAA0B,CAC/B,MAAOH,CAAAA,YAAY,GAAGI,SACvB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _path=_interopRequireDefault(require("path"));var _renderer=_interopRequireDefault(require("../../../server/renderer"));var _lodash=require("lodash");var _register=_interopRequireDefault(require("@babel/register"));var _jestEnvironmentJsdom=_interopRequireDefault(require("jest-environment-jsdom"));var _memfs=require("memfs");var _webpack=_interopRequireDefault(require("webpack"));/**
|
|
2
|
+
* Jest environment for end-to-end SSR and client-side testing. It relies on
|
|
3
|
+
* the standard react-utils mechanics to execute SSR of given scene, and also
|
|
4
|
+
* Webpack build of the code for client-side execution, it further exposes
|
|
5
|
+
* Jsdom environment for the client-side testing of the outcomes.
|
|
6
|
+
*/ /* eslint-disable global-require, import/no-dynamic-require */ // BEWARE: The module is not imported into the JU module / the main assembly of
|
|
7
|
+
// the library, because doing so easily breaks stuff:
|
|
8
|
+
// 1) This module depends on Node-specific modules, which would make JU
|
|
9
|
+
// incompatible with JsDom if included into JU.
|
|
10
|
+
// 2) If this module is weakly imported from somewhere else in the lib,
|
|
11
|
+
// it seems to randomly break tests using it for a different reason,
|
|
12
|
+
// probably some sort of a require-loop, or some issues with weak
|
|
13
|
+
// require in that scenario.
|
|
14
|
+
// As this environment is a part of the Jest testing utils,
|
|
15
|
+
// we assume development dependencies are available when it is used.
|
|
16
|
+
/* eslint-disable import/no-extraneous-dependencies */ /* eslint-enable import/no-extraneous-dependencies */class E2eSsrEnv extends _jestEnvironmentJsdom.default{/**
|
|
17
|
+
* Loads Webpack config, and exposes it to the environment via global
|
|
18
|
+
* webpackConfig object.
|
|
19
|
+
*/loadWebpackConfig(){let options=this.pragmas["webpack-config-options"];options=options?JSON.parse(options):{};(0,_lodash.defaults)(options,{context:this.testFolder,dontEmitBuildInfo:true});let factory=this.pragmas["webpack-config-factory"]||"";factory=require(_path.default.resolve(this.rootDir,factory));this.global.webpackConfig=factory(options);this.global.buildInfo=factory.buildInfo}/**
|
|
20
|
+
* Executes Webpack build.
|
|
21
|
+
* @return {Promise}
|
|
22
|
+
*/async runWebpack(){this.loadWebpackConfig();const compiler=(0,_webpack.default)(this.global.webpackConfig);const fs=(0,_memfs.createFsFromVolume)(new _memfs.Volume);compiler.outputFileSystem=fs;return new Promise((done,fail)=>{compiler.run((err,stats)=>{if(err)fail(err);this.global.webpackOutputFs=fs;this.global.webpackStats=stats.toJson();// Keeps reference to the raw Webpack stats object, which should be
|
|
23
|
+
// explicitly passed to the server-side renderer alongside the request,
|
|
24
|
+
// so that it can to pick up asset paths for different named chunks.
|
|
25
|
+
this.webpackStats=stats;done()})})}async runSsr(){let options=this.pragmas["ssr-options"];options=options?JSON.parse(options):{};// Note: This enables Babel transformation for the code dynamically loaded
|
|
26
|
+
// below, as the usual Jest Babel setup does not seem to apply to
|
|
27
|
+
// the environment code, and imports from it.
|
|
28
|
+
(0,_register.default)({envName:options.babelEnv,extensions:[".js",".jsx",".svg"]});if(!options.buildInfo)options.buildInfo=this.global.buildInfo;if(options.entry){const p=_path.default.resolve(this.testFolder,options.entry);options.Application=require(p)[options.entryExportName||"default"]}const renderer=(0,_renderer.default)(this.global.webpackConfig,options);const markup=await new Promise((done,fail)=>{renderer(this.ssrRequest,// TODO: This will do for now, with the current implementation of
|
|
29
|
+
// the renderer, but it will require a rework once the renderer is
|
|
30
|
+
// updated to do streaming.
|
|
31
|
+
{send:done,set:_lodash.noop,// This is how up-to-date Webpack stats are passed to the server in
|
|
32
|
+
// development mode, and we use this here always, instead of having
|
|
33
|
+
// to pass some information via filesystem.
|
|
34
|
+
locals:{webpack:{devMiddleware:{stats:this.webpackStats}}}},error=>{if(error)fail(error);else done("")})});this.global.ssrMarkup=markup;this.global.ssrOptions=options}constructor(config,context){const pragmas=context.docblockPragmas;let request=pragmas["ssr-request"];request=request?JSON.parse(request):{};if(!request.url)request.url="/";// This ensures the initial JsDom URL matches the value we use for SSR.
|
|
35
|
+
(0,_lodash.set)(config.projectConfig,"testEnvironmentOptions.url",`http://localhost${request.url}`);super(config,context);this.global.dom=this.dom;// Extracts necessary settings from config and context.
|
|
36
|
+
const{projectConfig}=config;this.rootDir=projectConfig.rootDir;this.testFolder=_path.default.dirname(context.testPath);this.withSsr=!pragmas["no-ssr"];this.ssrRequest=request;this.pragmas=pragmas}async setup(){await super.setup();await this.runWebpack();if(this.withSsr)await this.runSsr();this.global.REACT_UTILS_FORCE_CLIENT_SIDE=true}async teardown(){delete this.global.REACT_UTILS_FORCE_CLIENT_SIDE;// Resets module cache and @babel/register. Effectively this ensures that
|
|
37
|
+
// the next time an instance of this environment is set up, all modules are
|
|
38
|
+
// transformed by Babel from scratch, thus taking into account the latest
|
|
39
|
+
// Babel config (which may change between different environment instances,
|
|
40
|
+
// which does not seem to be taken into account by Babel / Node caches
|
|
41
|
+
// automatically).
|
|
42
|
+
Object.keys(require.cache).forEach(key=>{delete require.cache[key]});_register.default.revert();super.teardown()}}exports.default=E2eSsrEnv;
|
|
43
|
+
//# sourceMappingURL=E2eSsrEnv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"E2eSsrEnv.js","names":["E2eSsrEnv","JsdomEnv","loadWebpackConfig","options","pragmas","JSON","parse","context","testFolder","dontEmitBuildInfo","factory","require","path","resolve","rootDir","global","webpackConfig","buildInfo","runWebpack","compiler","fs","Volume","outputFileSystem","Promise","done","fail","run","err","stats","webpackOutputFs","webpackStats","toJson","runSsr","envName","babelEnv","extensions","entry","p","Application","entryExportName","renderer","markup","ssrRequest","send","set","noop","locals","webpack","devMiddleware","error","ssrMarkup","ssrOptions","constructor","config","docblockPragmas","request","url","projectConfig","dom","dirname","testPath","withSsr","setup","REACT_UTILS_FORCE_CLIENT_SIDE","teardown","Object","keys","cache","forEach","key","register","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 dontEmitBuildInfo: true,\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 this.global.buildInfo = factory.buildInfo;\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 const fs = createFsFromVolume(new Volume());\n compiler.outputFileSystem = fs;\n return new Promise((done, fail) => {\n compiler.run((err, stats) => {\n if (err) fail(err);\n this.global.webpackOutputFs = fs;\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 // 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 });\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 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 send: done,\n set: noop,\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 }\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\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\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,G,CACA,8D,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA,sD,CAKA,qDAEe,KAAMA,CAAAA,SAAN,QAAwBC,8BAAS,CAC9C;AACF;AACA;AACA,KACEC,iBAAiB,EAAG,CAClB,GAAIC,CAAAA,OAAO,CAAG,KAAKC,OAAL,CAAa,wBAAb,CAAd,CACAD,OAAO,CAAGA,OAAO,CAAGE,IAAI,CAACC,KAAL,CAAWH,OAAX,CAAH,CAAyB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lJ6C,C"}
|
|
@@ -52,4 +52,4 @@
|
|
|
52
52
|
* @param {object} component ReactJS component to render.
|
|
53
53
|
* @return {object} JSON render of the component.
|
|
54
54
|
*/function snapshot(component){const res=render(component);expect(res).toMatchSnapshot();return res}const simulate=_testUtils.default.Simulate;exports.simulate=simulate;
|
|
55
|
-
//# sourceMappingURL=
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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","unmount","remove","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,4E,o9BATA,mC,CACA,sD,CAMA,sD,CAGA,qD,CAEA;AACA;AACA;AACA;AACA,GAGAA,MAAM,CAACC,wBAAP,CAAkC,IAAlC,CAEA,KAAMC,CAAAA,uBAAuB,CAAGC,OAAO,CAACC,QAAxC,CAEA;AACA;AACA;AACA,GACO,QAASC,CAAAA,cAAT,EAA0B,CAC/BC,MAAM,CAACC,cAAP,CAAsBJ,OAAtB,CAA+B,UAA/B,CAA2C,CAAEK,KAAK,CAAE,IAAT,CAA3C,CACD,CAED;AACA;AACA,GACO,QAASC,CAAAA,gBAAT,EAA4B,CACjCH,MAAM,CAACC,cAAP,CAAsBJ,OAAtB,CAA+B,UAA/B,CAA2C,CACzCK,KAAK,CAAEN,uBADkC,CAEzCQ,QAAQ,CAAE,KAF+B,CAA3C,CAID,CAED;AACA;AACA;AACA;AACA;AACA,GACO,QAASC,CAAAA,WAAT,CAAqBC,IAAI,CAAG,CAA5B,CAA+B,CACpC,KAAMC,CAAAA,CAAC,CAAGD,IAAI,CAACE,QAAL,CAAc,EAAd,EAAkBC,QAAlB,CAA2B,EAA3B,CAA+B,GAA/B,CAAV,CACA,MAAQ,GAAEF,CAAC,CAACG,KAAF,CA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ACN,MAAT,CAAgBC,SAAhB,EACA,MAAOK,CAAAA,QAAQ,CAACE,eAAT,EACR,CAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACO,QAASC,CAAAA,eAAT,CAAyBR,SAAzB,CAAoC,CACzC,KAAMT,CAAAA,GAAG,CAAGa,aAAa,CAACJ,SAAD,CAAzB,CACAS,MAAM,CAAClB,GAAD,CAAN,CAAYmB,eAAZ,GACA,MAAOnB,CAAAA,GACR,CAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACO,QAASoB,CAAAA,QAAT,CAAkBX,SAAlB,CAA6B,CAClC,KAAMT,CAAAA,GAAG,CAAGQ,MAAM,CAACC,SAAD,CAAlB,CACAS,MAAM,CAAClB,GAAD,CAAN,CAAYmB,eAAZ,GACA,MAAOnB,CAAAA,GACR,CAEM,KAAMqB,CAAAA,QAAQ,CAAGC,mBAAGC,QAApB,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"splitComponent.js","names":["splitComponent","chunkName","getComponent","placeholder","children","props","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,iD,CAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACe,QAASA,CAAAA,cAAT,CAAwB,CACrCC,SADqC,CAErCC,YAFqC,CAGrCC,WAHqC,CAAxB,CAIZ,CACD;AACA,MAAO,CAAC,CAAEC,QAAF,CAAY,GAAGC,KAAf,EAAyB,EAA1B,gBAAiC,yBACtCC,kBADsC,CAEtC,CACE,GAAGD,KADL,CAEEJ,SAFF,CAGEC,YAHF,CAIEC,WAJF,CAFsC,CAQtCC,QARsC,CAUzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"],"sources":["../../../../src/shared/utils/time.js"],"sourcesContent":["import dayjs from 'dayjs';\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 × `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 × `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 × `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 × `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 */\ndayjs.timer = async function timer(timeout) {\n const res = new Barrier();\n const id = setTimeout(res.resolve.bind(res), timeout);\n res.abort = () => clearTimeout(id);\n return res;\n};\n\nexport default dayjs;\n"],"mappings":"gLAAA,oDACA,kCAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAA,eAAMC,MAAN,CAAe,IAAf,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAD,eAAME,MAAN,CAAe,GAAKF,eAAMC,MAA1B,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAD,eAAMG,OAAN,CAAgB,GAAKH,eAAME,MAA3B,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAF,eAAMI,MAAN,CAAe,GAAKJ,eAAMG,OAA1B,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAH,eAAMK,OAAN,CAAgB,IAAML,eAAMI,MAA5B,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACAJ,eAAMM,GAAN,CAAYC,IAAI,CAACD,GAAjB,CAEA;AACA;AACA;AACA;AACA;AACA;AACA,GACAN,eAAMQ,KAAN,CAAc,cAAeA,CAAAA,KAAf,CAAqBC,OAArB,CAA8B,CAC1C,KAAMC,CAAAA,GAAG,CAAG,GAAIC,iBAAhB,CACA,KAAMC,CAAAA,EAAE,CAAGC,UAAU,CAACH,GAAG,CAACI,OAAJ,CAAYC,IAAZ,CAAiBL,GAAjB,CAAD,CAAwBD,OAAxB,CAArB,CACAC,GAAG,CAACM,KAAJ,CAAY,IAAMC,YAAY,CAACL,EAAD,CAA9B,CACA,MAAOF,CAAAA,GACR,CALD,C,aAOeV,c"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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,CAAAA,WAAT,CAAqBC,UAArB,CAAiCC,QAAjC,CAA2C,CAChD,GAAIC,yBAAJ,CAAoB,MAAO,KAAP,CAEpB,GAAI,CACF,4BACA,KAAM,CAAEC,OAAF,EAAcC,IAAI,CAAC,SAAD,CAAJ,CAAgB,MAAhB,CAApB,CACA,KAAMC,CAAAA,IAAI,CAAGJ,QAAQ,CAAGE,OAAO,CAACF,QAAD,CAAWD,UAAX,CAAV,CAAmCA,UAAxD,CACA,KAAM,CAAEM,OAAO,CAAEC,GAAX,CAAgB,GAAGC,KAAnB,EAA6BJ,IAAI,CAAC,SAAD,CAAJ,CAAgBC,IAAhB,CAAnC,CACA,2BAEA,GAAI,CAACE,GAAL,CAAU,MAAOC,CAAAA,KAAP,CAEVC,MAAM,CAACC,OAAP,CAAeF,KAAf,EAAsBG,OAAtB,CAA8B,CAAC,CAACC,GAAD,CAAMC,KAAN,CAAD,GAAkB,CAC9C,GAAIN,GAAG,CAACK,GAAD,CAAP,CAAc,KAAME,CAAAA,KAAK,CAAC,4CAAD,CAAX,CACdP,GAAG,CAACK,GAAD,CAAH,CAAWC,KACZ,CAHD,EAIA,MAAON,CAAAA,GACR,CAAC,KAAM,CACN,MAAO,KACR,CACF,CAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACO,QAASQ,CAAAA,WAAT,CAAqBf,UAArB,CAAiC,CACtC,MAAOA,CAAAA,UACR"}
|