@dr.pogodin/react-utils 1.57.0 → 1.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/development/server/Cache.js +7 -7
- package/build/development/server/Cache.js.map +1 -1
- package/build/development/server/index.js +6 -3
- package/build/development/server/index.js.map +1 -1
- package/build/development/server/renderer.js +18 -7
- package/build/development/server/renderer.js.map +1 -1
- package/build/development/server/server.js +12 -6
- package/build/development/server/server.js.map +1 -1
- package/build/development/server/utils/errors.js +10 -10
- package/build/development/server/utils/errors.js.map +1 -1
- package/build/development/shared/components/Button/index.js +1 -1
- package/build/development/shared/components/Button/index.js.map +1 -1
- package/build/development/shared/components/Checkbox/index.js +5 -5
- package/build/development/shared/components/Checkbox/index.js.map +1 -1
- package/build/development/shared/components/Input/index.js +3 -3
- package/build/development/shared/components/Input/index.js.map +1 -1
- package/build/development/shared/components/Modal/index.js +3 -0
- package/build/development/shared/components/Modal/index.js.map +1 -1
- package/build/development/shared/components/TextArea/index.js +3 -3
- package/build/development/shared/components/TextArea/index.js.map +1 -1
- package/build/development/shared/components/WithTooltip/Tooltip.js +2 -2
- package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/development/shared/components/WithTooltip/index.js +3 -1
- package/build/development/shared/components/WithTooltip/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +4 -1
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/index.js +7 -4
- package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/NativeDropdown/index.js +3 -3
- package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/Switch/index.js +2 -2
- package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/development/shared/utils/config.js.map +1 -1
- package/build/development/shared/utils/jest/E2eSsrEnv/index.js +7 -6
- package/build/development/shared/utils/jest/E2eSsrEnv/index.js.map +1 -1
- package/build/development/shared/utils/jest/index.js +2 -1
- package/build/development/shared/utils/jest/index.js.map +1 -1
- package/build/development/shared/utils/splitComponent.js +10 -8
- package/build/development/shared/utils/splitComponent.js.map +1 -1
- package/build/development/shared/utils/webpack.js +2 -1
- package/build/development/shared/utils/webpack.js.map +1 -1
- package/build/production/server/Cache.js +3 -3
- package/build/production/server/Cache.js.map +1 -1
- package/build/production/server/index.js +1 -1
- package/build/production/server/index.js.map +1 -1
- package/build/production/server/renderer.js +9 -9
- package/build/production/server/renderer.js.map +1 -1
- package/build/production/server/server.js +6 -6
- package/build/production/server/server.js.map +1 -1
- package/build/production/server/utils/errors.js +1 -1
- package/build/production/server/utils/errors.js.map +1 -1
- package/build/production/shared/components/Button/index.js +1 -1
- package/build/production/shared/components/Button/index.js.map +1 -1
- package/build/production/shared/components/Checkbox/index.js +1 -1
- package/build/production/shared/components/Checkbox/index.js.map +1 -1
- package/build/production/shared/components/Input/index.js +1 -1
- package/build/production/shared/components/Input/index.js.map +1 -1
- package/build/production/shared/components/Modal/index.js +1 -1
- package/build/production/shared/components/Modal/index.js.map +1 -1
- package/build/production/shared/components/TextArea/index.js +1 -1
- package/build/production/shared/components/TextArea/index.js.map +1 -1
- package/build/production/shared/components/WithTooltip/Tooltip.js +1 -1
- package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/production/shared/components/WithTooltip/index.js +2 -2
- package/build/production/shared/components/WithTooltip/index.js.map +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/index.js +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/production/shared/components/selectors/NativeDropdown/index.js +2 -2
- package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/production/shared/components/selectors/Switch/index.js +1 -1
- package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/production/shared/utils/config.js.map +1 -1
- package/build/production/shared/utils/jest/E2eSsrEnv/index.js +2 -2
- package/build/production/shared/utils/jest/E2eSsrEnv/index.js.map +1 -1
- package/build/production/shared/utils/jest/index.js +2 -2
- package/build/production/shared/utils/jest/index.js.map +1 -1
- package/build/production/shared/utils/splitComponent.js +3 -3
- package/build/production/shared/utils/splitComponent.js.map +1 -1
- package/build/production/shared/utils/webpack.js +3 -2
- package/build/production/shared/utils/webpack.js.map +1 -1
- package/build/types-code/shared/utils/config.d.ts +1 -1
- package/build/web/server/Cache.js +3 -3
- package/build/web/server/Cache.js.map +1 -1
- package/build/web/server/index.js +1 -1
- package/build/web/server/index.js.map +1 -1
- package/build/web/server/renderer.js +9 -9
- package/build/web/server/renderer.js.map +1 -1
- package/build/web/server/server.js +6 -6
- package/build/web/server/server.js.map +1 -1
- package/build/web/server/utils/errors.js +1 -1
- package/build/web/server/utils/errors.js.map +1 -1
- package/build/web/shared/components/Button/index.js +1 -1
- package/build/web/shared/components/Button/index.js.map +1 -1
- package/build/web/shared/components/Checkbox/index.js +1 -1
- package/build/web/shared/components/Checkbox/index.js.map +1 -1
- package/build/web/shared/components/Input/index.js +1 -1
- package/build/web/shared/components/Input/index.js.map +1 -1
- package/build/web/shared/components/Modal/index.js +1 -1
- package/build/web/shared/components/Modal/index.js.map +1 -1
- package/build/web/shared/components/TextArea/index.js +1 -1
- package/build/web/shared/components/TextArea/index.js.map +1 -1
- package/build/web/shared/components/WithTooltip/Tooltip.js +1 -1
- package/build/web/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/web/shared/components/WithTooltip/index.js +2 -2
- package/build/web/shared/components/WithTooltip/index.js.map +1 -1
- package/build/web/shared/components/selectors/CustomDropdown/Options/index.js +1 -1
- package/build/web/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/web/shared/components/selectors/CustomDropdown/index.js +1 -1
- package/build/web/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/web/shared/components/selectors/NativeDropdown/index.js +2 -2
- package/build/web/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/web/shared/components/selectors/Switch/index.js +1 -1
- package/build/web/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/web/shared/utils/config.js.map +1 -1
- package/build/web/shared/utils/jest/E2eSsrEnv/index.js +2 -2
- package/build/web/shared/utils/jest/E2eSsrEnv/index.js.map +1 -1
- package/build/web/shared/utils/jest/index.js +2 -2
- package/build/web/shared/utils/jest/index.js.map +1 -1
- package/build/web/shared/utils/splitComponent.js +3 -3
- package/build/web/shared/utils/splitComponent.js.map +1 -1
- package/build/web/shared/utils/webpack.js +3 -2
- package/build/web/shared/utils/webpack.js.map +1 -1
- package/config/babel/webpack.js +6 -1
- package/config/webpack/app-base.js +16 -6
- package/config/webpack/app-development.js +2 -0
- package/package.json +21 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../../src/shared/utils/jest/index.ts"],"sourcesContent":["/* global document */\n/* eslint-disable import/no-extraneous-dependencies */\n\nimport type {\n AxiosRequestConfig,\n AxiosResponse,\n AxiosStatic,\n InternalAxiosRequestConfig,\n} from 'axios';\n\nimport mockdate from 'mockdate';\nimport { type ReactElement, type ReactNode, act } from 'react';\nimport { type Root, createRoot } from 'react-dom/client';\n\nimport { expect, jest } from '@jest/globals';\nimport { type RenderResult, render } from '@testing-library/react';\n\n/**\n * An alias for [act(..)](https://reactjs.org/docs/test-utils.html#act)\n * from `react`.\n */\nexport { act };\n\nexport { default as getGlobal } from './global';\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(): void {\n Object.defineProperty(process, 'versions', { value: undefined });\n}\n\n/**\n * Reverts the effect of {@link module:JU.mockClientSide mockClientSide(..)}.\n */\nexport function unmockClientSide(): void {\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): `${string}-${string}-${string}-${string}-${string}` {\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\nexport type AxiosRequestHandlerT = (\n config: AxiosRequestConfig,\n) => Partial<AxiosResponse> | null | undefined;\n\nexport function mockAxios(handlers: AxiosRequestHandlerT[]): AxiosStatic {\n const axios: AxiosStatic = jest.requireActual('axios');\n\n axios.defaults.adapter = async (\n config: AxiosRequestConfig,\n ): Promise<AxiosResponse> => {\n for (const handler of handlers) {\n const res = handler(config);\n if (res) {\n return {\n config: config as InternalAxiosRequestConfig,\n data: null,\n headers: {},\n status: 200,\n statusText: 'OK',\n ...res,\n };\n }\n }\n\n // Fallback to the regular network request.\n let res: AxiosResponse;\n try {\n res = await axios({ ...config, adapter: ['xhr', 'http', 'fetch'] });\n // eslint-disable-next-line no-console\n console.warn(\n 'Network request has not been mocked for a test.\\n\\nConfig:\\n',\n config,\n '\\n\\nResult:\\n',\n JSON.stringify(res, null, 2),\n );\n } catch (e) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Network request has not been mocked for a test, and failed.\\n\\nConfig:\\n',\n config,\n '\\n\\nError\\n',\n JSON.stringify(e, null, 2),\n );\n throw e;\n }\n\n return res;\n };\n\n return axios;\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: number): Promise<void> {\n mockdate.set(time + Date.now());\n await jest.advanceTimersByTimeAsync(time);\n}\n\nexport type MountedSceneT = HTMLElement & {\n destroy: () => void;\n snapshot: () => void;\n};\n\n/**\n * Mounts `scene` to the DOM, and returns the root scene element.\n * @param scene\n * @return Created container DOM element with destroy() function\n * attached.\n */\nexport function mount(scene: ReactNode): MountedSceneT {\n let root: Root;\n const element = document.createElement('div');\n document.body.appendChild(element);\n\n const res: MountedSceneT = (element as unknown) as MountedSceneT;\n res.destroy = () => {\n // NOTE: As it seems @testing-library may reset this flag to false\n // when it is simulating user events.\n global.IS_REACT_ACT_ENVIRONMENT = true;\n\n act(() => {\n root.unmount();\n });\n res.remove();\n };\n\n res.snapshot = () => {\n expect(res).toMatchSnapshot();\n };\n\n // NOTE: As it seems @testing-library may reset this flag to false\n // when it is simulating user events.\n global.IS_REACT_ACT_ENVIRONMENT = true;\n\n act(() => {\n root = createRoot(res);\n root.render(scene);\n });\n return res;\n}\n\n// NOTE: If in future we have additional options here, they should be distributed\n// across two objects, depending whether they are applicable to the sync, or async\n// versions of snapshot(), or both.\ntype AsyncSnapshotOptionsT = {\n await?: Promise<void>;\n};\n\nexport function snapshot(element: ReactElement): RenderResult;\n\nexport async function snapshot(\n element: ReactElement,\n options: AsyncSnapshotOptionsT,\n): Promise<RenderResult>;\n\nexport function snapshot(\n element: ReactElement,\n options?: AsyncSnapshotOptionsT,\n): Promise<RenderResult> | RenderResult {\n let res: RenderResult | undefined;\n\n // TODO: Just adding async to the actor function breaks stuff, as it makes\n // act() asynchronous no matter the `options.await` value, thus breaking all\n // calls that do not await for snapshot() result... thus... perhaps we need\n // to have a more complex typing to ensure it all works as intended in all\n // cases, and while being correctly enforced by TypeScript.\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n const promise = act(() => {\n res = render(element);\n return options?.await;\n });\n\n if (res === undefined) throw Error('Render failed');\n if (options?.await) {\n // BEWARE: Although `promise` is thenable (i.e. it has .then() method),\n // it is not an instance of proper Promise class, and returning it directly\n // breaks some async logic in Jest test or React test functions... thus, we\n // wrap it into Promise instance here.\n return new Promise((resolve, reject) => {\n let rejected = false;\n\n // BEWARE: The \"promise\" returned by act() does not behave as a regular\n // Promise instance:\n // 1. In case of errors its .then() method both calls its \"reject\"\n // callback (first), and then its \"resolve\" callback second.\n // 2. It errors out if a rendering error happens, and there is no\n // \"reject\" argument provided.\n void promise.then(() => {\n if (!rejected) {\n // TODO: These lines are the same as the lines below for sync variant of\n // the function. We should split and reuse them in both places.\n const nodes = res!.asFragment().childNodes;\n expect(nodes.length > 1 ? [...nodes] : nodes[0]).toMatchSnapshot();\n resolve(res!);\n }\n }, (error: unknown) => {\n rejected = true;\n\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(error);\n });\n });\n }\n\n const nodes = res.asFragment().childNodes;\n expect(nodes.length > 1 ? [...nodes] : nodes[0]).toMatchSnapshot();\n return res;\n}\n"],"mappings":"mEAAA,qBACA,sDASA,MAAO,SAAQ,KAAM,UAAU,CAC/B,OAA4C,GAAG,KAAQ,OAAO,CAC9D,OAAoB,UAAU,KAAQ,kBAAkB,CAExD,OAAS,MAAM,CAAE,IAAI,KAAQ,eAAe,CAC5C,OAA4B,MAAM,KAAQ,wBAAwB,CAElE;AACA;AACA;AACA,GACA,OAAS,GAAG,EAAG,OAEN,OAAO,GAAI,UAAS,mBAE7B,MAAM,CAAC,wBAAwB,CAAG,IAAI,CAEtC,KAAM,wBAAuB,CAAG,OAAO,CAAC,QAAQ,CAEhD;AACA;AACA;AACA,GACA,MAAO,SAAS,eAAc,EAAS,CACrC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAE,UAAU,CAAE,CAAE,KAAK,CAAE,SAAU,CAAC,CAAC,CAClE,CAEA;AACA;AACA,GACA,MAAO,SAAS,iBAAgB,EAAS,CACvC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAE,UAAU,CAAE,CACzC,KAAK,CAAE,uBAAuB,CAC9B,QAAQ,CAAE,KACZ,CAAC,CAAC,CACJ,CAEA;AACA;AACA;AACA;AACA;AACA,GACA,MAAO,SAAS,YAAW,CAAC,IAAI,CAAG,CAAC,CAAuD,CACzF,KAAM,E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GAAG,CAAG,MAAM,CAAC,OAAO,CAAC,CACrB,MAAO,QAAO,EAAE,KAAK,CACvB,CAAC,CAAC,CAEF,GAAI,GAAG,GAAK,SAAS,CAAE,KAAM,MAAK,CAAC,eAAe,CAAC,CACnD,GAAI,OAAO,EAAE,KAAK,CAAE,CAClB;AACA;AACA;AACA;AACA,MAAO,IAAI,QAAO,CAAC,CAAC,OAAO,CAAE,MAAM,GAAK,CACtC,GAAI,SAAQ,CAAG,KAAK,CAEpB;AACA;AACA;AACA;AACA;AACA;AACA,IAAK,QAAO,CAAC,IAAI,CAAC,IAAM,CACtB,GAAI,CAAC,QAAQ,CAAE,CACb;AACA;AACA,KAAM,MAAK,CAAG,GAAG,CAAE,UAAU,CAAC,CAAC,CAAC,UAAU,CAC1C,MAAM,CAAC,KAAK,CAAC,MAAM,CAAG,CAAC,CAAG,CAAC,GAAG,KAAK,CAAC,CAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAClE,OAAO,CAAC,GAAI,CAAC,CACf,CACF,CAAC,CAAG,KAAc,EAAK,CACrB,QAAQ,CAAG,IAAI,CAEf;AACA,MAAM,CAAC,KAAK,CAAC,CACf,CAAC,CAAC,CACJ,CAAC,CAAC,CACJ,CAEA,KAAM,MAAK,CAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CACzC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAG,CAAC,CAAG,CAAC,GAAG,KAAK,CAAC,CAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAClE,MAAO,IAAG,CACZ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../src/shared/utils/jest/index.ts"],"sourcesContent":["/* global document */\n/* eslint-disable import/no-extraneous-dependencies */\n\nimport type {\n AxiosRequestConfig,\n AxiosResponse,\n AxiosStatic,\n InternalAxiosRequestConfig,\n} from 'axios';\n\nimport mockdate from 'mockdate';\nimport { type ReactElement, type ReactNode, act } from 'react';\nimport { type Root, createRoot } from 'react-dom/client';\n\nimport { expect, jest } from '@jest/globals';\nimport { type RenderResult, render } from '@testing-library/react';\n\n/**\n * An alias for [act(..)](https://reactjs.org/docs/test-utils.html#act)\n * from `react`.\n */\nexport { act };\n\nexport { default as getGlobal } from './global';\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(): void {\n Object.defineProperty(process, 'versions', { value: undefined });\n}\n\n/**\n * Reverts the effect of {@link module:JU.mockClientSide mockClientSide(..)}.\n */\nexport function unmockClientSide(): void {\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): `${string}-${string}-${string}-${string}-${string}` {\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\nexport type AxiosRequestHandlerT = (\n config: AxiosRequestConfig,\n) => Partial<AxiosResponse> | null | undefined;\n\nexport function mockAxios(handlers: AxiosRequestHandlerT[]): AxiosStatic {\n const axios: AxiosStatic = jest.requireActual('axios');\n\n axios.defaults.adapter = async (\n config: AxiosRequestConfig,\n ): Promise<AxiosResponse> => {\n for (const handler of handlers) {\n const res = handler(config);\n if (res) {\n return {\n config: config as InternalAxiosRequestConfig,\n data: null,\n headers: {},\n status: 200,\n statusText: 'OK',\n ...res,\n };\n }\n }\n\n // Fallback to the regular network request.\n let res: AxiosResponse;\n try {\n res = await axios({ ...config, adapter: ['xhr', 'http', 'fetch'] });\n // eslint-disable-next-line no-console\n console.warn(\n 'Network request has not been mocked for a test.\\n\\nConfig:\\n',\n config,\n '\\n\\nResult:\\n',\n JSON.stringify(res, null, 2),\n );\n } catch (e) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Network request has not been mocked for a test, and failed.\\n\\nConfig:\\n',\n config,\n '\\n\\nError\\n',\n JSON.stringify(e, null, 2),\n );\n throw e;\n }\n\n return res;\n };\n\n return axios;\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: number): Promise<void> {\n mockdate.set(time + Date.now());\n await jest.advanceTimersByTimeAsync(time);\n}\n\nexport type MountedSceneT = HTMLElement & {\n destroy: () => void;\n snapshot: () => void;\n};\n\n/**\n * Mounts `scene` to the DOM, and returns the root scene element.\n * @param scene\n * @return Created container DOM element with destroy() function\n * attached.\n */\nexport function mount(scene: ReactNode): MountedSceneT {\n let root: Root;\n const element = document.createElement('div');\n document.body.appendChild(element);\n\n const res: MountedSceneT = (element as unknown) as MountedSceneT;\n res.destroy = () => {\n // NOTE: As it seems @testing-library may reset this flag to false\n // when it is simulating user events.\n global.IS_REACT_ACT_ENVIRONMENT = true;\n\n act(() => {\n root.unmount();\n });\n res.remove();\n };\n\n res.snapshot = () => {\n expect(res).toMatchSnapshot();\n };\n\n // NOTE: As it seems @testing-library may reset this flag to false\n // when it is simulating user events.\n global.IS_REACT_ACT_ENVIRONMENT = true;\n\n act(() => {\n root = createRoot(res);\n root.render(scene);\n });\n return res;\n}\n\n// NOTE: If in future we have additional options here, they should be distributed\n// across two objects, depending whether they are applicable to the sync, or async\n// versions of snapshot(), or both.\ntype AsyncSnapshotOptionsT = {\n await?: Promise<void>;\n};\n\nexport function snapshot(element: ReactElement): RenderResult;\n\nexport async function snapshot(\n element: ReactElement,\n options: AsyncSnapshotOptionsT,\n): Promise<RenderResult>;\n\nexport function snapshot(\n element: ReactElement,\n options?: AsyncSnapshotOptionsT,\n): Promise<RenderResult> | RenderResult {\n let res: RenderResult | undefined;\n\n // TODO: Just adding async to the actor function breaks stuff, as it makes\n // act() asynchronous no matter the `options.await` value, thus breaking all\n // calls that do not await for snapshot() result... thus... perhaps we need\n // to have a more complex typing to ensure it all works as intended in all\n // cases, and while being correctly enforced by TypeScript.\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n const promise = act(() => {\n res = render(element);\n return options?.await;\n });\n\n if (res === undefined) throw Error('Render failed');\n if (options?.await) {\n // BEWARE: Although `promise` is thenable (i.e. it has .then() method),\n // it is not an instance of proper Promise class, and returning it directly\n // breaks some async logic in Jest test or React test functions... thus, we\n // wrap it into Promise instance here.\n return new Promise((resolve, reject) => {\n let rejected = false;\n\n // BEWARE: The \"promise\" returned by act() does not behave as a regular\n // Promise instance:\n // 1. In case of errors its .then() method both calls its \"reject\"\n // callback (first), and then its \"resolve\" callback second.\n // 2. It errors out if a rendering error happens, and there is no\n // \"reject\" argument provided.\n void promise.then(() => {\n if (!rejected) {\n // TODO: These lines are the same as the lines below for sync variant of\n // the function. We should split and reuse them in both places.\n if (!res) throw Error('Missing render result');\n const nodes = res.asFragment().childNodes;\n expect(nodes.length > 1 ? [...nodes] : nodes[0]).toMatchSnapshot();\n resolve(res);\n }\n }, (error: unknown) => {\n rejected = true;\n\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(error);\n });\n });\n }\n\n const nodes = res.asFragment().childNodes;\n expect(nodes.length > 1 ? [...nodes] : nodes[0]).toMatchSnapshot();\n return res;\n}\n"],"mappings":"qEAAA,qBACA,sDASA,MAAO,SAAQ,KAAM,UAAU,CAC/B,OAA4C,GAAG,KAAQ,OAAO,CAC9D,OAAoB,UAAU,KAAQ,kBAAkB,CAExD,OAAS,MAAM,CAAE,IAAI,KAAQ,eAAe,CAC5C,OAA4B,MAAM,KAAQ,wBAAwB,CAElE;AACA;AACA;AACA,GACA,OAAS,GAAG,EAAG,OAEN,OAAO,GAAI,UAAS,mBAE7B,MAAM,CAAC,wBAAwB,CAAG,IAAI,CA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;AACA,MAAM,CAAC,KAAK,CAAC,CACf,CAAC,CAAC,CACJ,CAAC,CAAC,CACJ,CAEA,KAAM,MAAK,CAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CACzC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAG,CAAC,CAAG,CAAC,GAAG,KAAK,CAAC,CAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAClE,MAAO,IAAG,CACZ","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _pushInstanceProperty from"core-js-pure/
|
|
1
|
+
import _pushInstanceProperty from"core-js-pure/features/instance/push.js";import{c as _c}from"react/compiler-runtime";/* global document */import{Suspense,lazy,useInsertionEffect}from"react";import{Barrier}from"@dr.pogodin/js-utils";import{useSsrContext}from"./globalState.js";import{IS_CLIENT_SIDE,IS_SERVER_SIDE,assertClientSide,getBuildInfo}from"./isomorphy/index.js";import{jsx as _jsx}from"react/jsx-runtime";let clientChunkGroups;export function setClientChunkGroups(groups){assertClientSide();clientChunkGroups=groups;}const refCounts=new Map;function getPublicPath(){return getBuildInfo().publicPath;}/**
|
|
2
2
|
* Client-side only! Ensures the specified CSS stylesheet is loaded into
|
|
3
3
|
* the document; loads if it is missing; and does simple reference counting
|
|
4
4
|
* to facilitate future clean-up.
|
|
@@ -6,7 +6,7 @@ import _pushInstanceProperty from"core-js-pure/stable/instance/push.js";import{c
|
|
|
6
6
|
* @param loadedSheets
|
|
7
7
|
* @param refCount
|
|
8
8
|
* @return
|
|
9
|
-
*/function bookStyleSheet(name,loadedSheets,refCount){let res;const path=`${getPublicPath()}/${name}`;const fullPath=`${document.location.origin}${path}`;if(!loadedSheets.has(fullPath)){let link=document.querySelector(`link[href="${path}"]`);if(!link){link=document.createElement("link");link.setAttribute("rel","stylesheet");link.setAttribute("href",path);document.head.appendChild(link);}res=new Barrier;link.addEventListener("load",()=>{if(!res)throw Error("Internal error");void res.resolve();});link.addEventListener("error",()=>{if(!res)throw Error("Internal error");void res.resolve();});}if(refCount){const current=refCounts
|
|
9
|
+
*/function bookStyleSheet(name,loadedSheets,refCount){let res;const path=`${getPublicPath()}/${name}`;const fullPath=`${document.location.origin}${path}`;if(!loadedSheets.has(fullPath)){let link=document.querySelector(`link[href="${path}"]`);if(!link){link=document.createElement("link");link.setAttribute("rel","stylesheet");link.setAttribute("href",path);document.head.appendChild(link);}res=new Barrier;link.addEventListener("load",()=>{if(!res)throw Error("Internal error");void res.resolve();});link.addEventListener("error",()=>{if(!res)throw Error("Internal error");void res.resolve();});}if(refCount){const current=refCounts.get(path)??0;refCounts.set(path,1+current);}return res;}/**
|
|
10
10
|
* Generates the set of URLs for currently loaded, linked stylesheets.
|
|
11
11
|
* @return
|
|
12
12
|
*/function getLoadedStyleSheets(){const res=new Set;const{styleSheets}=document;for(const{href}of styleSheets){if(href)res.add(href);}return res;}function assertChunkName(chunkName,chunkGroups){if(chunkGroups[chunkName])return;throw Error(`Unknown chunk name "${chunkName}"`);}/**
|
|
@@ -23,7 +23,7 @@ import _pushInstanceProperty from"core-js-pure/stable/instance/push.js";import{c
|
|
|
23
23
|
* (for chunks with larger reference counter values, it just decrements
|
|
24
24
|
* the reference counter).
|
|
25
25
|
* @param {string} chunkName
|
|
26
|
-
*/export function freeStyleSheets(chunkName,chunkGroups){const assets=chunkGroups[chunkName];if(!assets)return;for(const asset of assets){if(asset.endsWith(".css")){const path=`${getPublicPath()}/${asset}`;const pathRefCount=refCounts
|
|
26
|
+
*/export function freeStyleSheets(chunkName,chunkGroups){const assets=chunkGroups[chunkName];if(!assets)return;for(const asset of assets){if(asset.endsWith(".css")){const path=`${getPublicPath()}/${asset}`;const pathRefCount=refCounts.get(path);if(pathRefCount){if(pathRefCount<=1){const node=document.head.querySelector(`link[href="${path}"]`);if(!node)throw Error("Missing node");node.remove();refCounts.delete(path);}else refCounts.set(path,pathRefCount-1);}}}}// Holds the set of chunk names already used for splitComponent() calls.
|
|
27
27
|
const usedChunkNames=new Set;/**
|
|
28
28
|
* Given an async component retrieval function `getComponent()` it creates
|
|
29
29
|
* a special "code split" component, which uses <Suspense> to asynchronously
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"splitComponent.js","names":["chunkGroups","placeholder"],"sources":["../../../../src/shared/utils/splitComponent.tsx"],"sourcesContent":["/* global document */\n\nimport {\n type ComponentType,\n type FunctionComponent,\n type ReactNode,\n type RefObject,\n Suspense,\n lazy,\n useInsertionEffect,\n} from 'react';\n\nimport { Barrier } from '@dr.pogodin/js-utils';\n\nimport { type ChunkGroupsT, useSsrContext } from './globalState';\n\nimport {\n IS_CLIENT_SIDE,\n IS_SERVER_SIDE,\n assertClientSide,\n getBuildInfo,\n} from './isomorphy';\n\nlet clientChunkGroups: ChunkGroupsT | undefined;\n\nexport function setClientChunkGroups(groups: ChunkGroupsT): void {\n assertClientSide();\n clientChunkGroups = groups;\n}\n\nconst refCounts: Record<string, number> = {};\n\nfunction getPublicPath() {\n return getBuildInfo().publicPath;\n}\n\n/**\n * Client-side only! Ensures the specified CSS stylesheet is loaded into\n * the document; loads if it is missing; and does simple reference counting\n * to facilitate future clean-up.\n * @param name\n * @param loadedSheets\n * @param refCount\n * @return\n */\nfunction bookStyleSheet(\n name: string,\n loadedSheets: Set<string>,\n refCount: boolean,\n): Promise<void> | undefined {\n let res: Barrier<void> | undefined;\n const path = `${getPublicPath()}/${name}`;\n const fullPath = `${document.location.origin}${path}`;\n\n if (!loadedSheets.has(fullPath)) {\n let link = document.querySelector(`link[href=\"${path}\"]`);\n\n if (!link) {\n link = document.createElement('link');\n link.setAttribute('rel', 'stylesheet');\n link.setAttribute('href', path);\n document.head.appendChild(link);\n }\n\n res = new Barrier<void>();\n link.addEventListener('load', () => {\n if (!res) throw Error('Internal error');\n void res.resolve();\n });\n link.addEventListener('error', () => {\n if (!res) throw Error('Internal error');\n void res.resolve();\n });\n }\n\n if (refCount) {\n const current = refCounts[path] ?? 0;\n refCounts[path] = 1 + current;\n }\n\n return res;\n}\n\n/**\n * Generates the set of URLs for currently loaded, linked stylesheets.\n * @return\n */\nfunction getLoadedStyleSheets(): Set<string> {\n const res = new Set<string>();\n const { styleSheets } = document;\n for (const { href } of styleSheets) {\n if (href) res.add(href);\n }\n return res;\n}\n\nfunction assertChunkName(\n chunkName: string,\n chunkGroups: ChunkGroupsT,\n) {\n if (chunkGroups[chunkName]) return;\n throw Error(`Unknown chunk name \"${chunkName}\"`);\n}\n\n/**\n * Client-side only! Ensures all CSS stylesheets required for the specified\n * code chunk are loaded into the document; loads the missing ones; and does\n * simple reference counting to facilitate future clean-up.\n * @param chunkName Chunk name.\n * @param refCount\n * @return Resolves once all pending stylesheets, necessary for\n * the chunk, are either loaded, or failed to load.\n */\nexport async function bookStyleSheets(\n chunkName: string,\n chunkGroups: ChunkGroupsT,\n refCount: boolean,\n): Promise<void> {\n const promises = [];\n const assets = chunkGroups[chunkName];\n if (!assets) return Promise.resolve();\n\n const loadedSheets = getLoadedStyleSheets();\n\n for (const asset of assets) {\n if (asset.endsWith('.css')) {\n const promise = bookStyleSheet(asset, loadedSheets, refCount);\n if (promise) promises.push(promise);\n }\n }\n\n return promises.length\n ? Promise.allSettled(promises).then()\n : Promise.resolve();\n}\n\n/**\n * Client-side only! Frees from the document all CSS stylesheets that are\n * required by the specified chunk, and have reference counter equal to one\n * (for chunks with larger reference counter values, it just decrements\n * the reference counter).\n * @param {string} chunkName\n */\nexport function freeStyleSheets(\n chunkName: string,\n chunkGroups: ChunkGroupsT,\n): void {\n const assets = chunkGroups[chunkName];\n if (!assets) return;\n\n for (const asset of assets) {\n if (asset.endsWith('.css')) {\n const path = `${getPublicPath()}/${asset}`;\n\n const pathRefCount = refCounts[path];\n if (pathRefCount) {\n if (pathRefCount <= 1) {\n document.head.querySelector(`link[href=\"${path}\"]`)!.remove();\n delete refCounts[path];\n } else refCounts[path] = pathRefCount - 1;\n }\n }\n }\n}\n\n// Holds the set of chunk names already used for splitComponent() calls.\nconst usedChunkNames = new Set();\n\ntype ComponentOrModule<PropsT> = ComponentType<PropsT> | {\n default: ComponentType<PropsT>;\n};\n\ntype GenericComponentPropsT = {\n children?: ReactNode;\n ref?: RefObject<unknown>;\n\n // NOTE: This is necessary, as without it this type (with only optional\n // fields) will be conisdered as \"weak\" by TypeScript, and it will be\n // a error to assign to it any type that does not use \"children\", or \"ref\".\n [propName: string]: unknown;\n};\n\n/**\n * Given an async component retrieval function `getComponent()` it creates\n * a special \"code split\" component, which uses <Suspense> to asynchronously\n * load on demand the code required by `getComponent()`.\n * @param options\n * @param options.chunkName\n * @param {function} options.getComponent\n * @param {React.Element} [options.placeholder]\n * @return {React.ElementType}\n */\nexport default function splitComponent<\n ComponentPropsT extends GenericComponentPropsT,\n>({\n chunkName,\n getComponent,\n placeholder,\n}: {\n chunkName: string;\n getComponent: () => Promise<ComponentOrModule<ComponentPropsT>>;\n placeholder?: ReactNode;\n}): FunctionComponent<ComponentPropsT> {\n // The correct usage of splitComponent() assumes a single call per chunk.\n if (usedChunkNames.has(chunkName)\n\n // When HMR happens splitComponent() ends up getting called again for some\n // chunks, thus we should not throw this error. Not sure, if we need to do\n // some additional handling in that case, or just not throwing is all we\n // need.\n && !import.meta.webpackHot\n ) {\n throw Error(`Repeated splitComponent() call for the chunk \"${chunkName}\"`);\n } else usedChunkNames.add(chunkName);\n\n const LazyComponent = lazy(async () => {\n const resolved = await getComponent();\n const Component = 'default' in resolved ? resolved.default : resolved;\n\n // This pre-loads necessary stylesheets prior to the first mount of\n // the component (the lazy load function is executed by React one at\n // the frist mount).\n if (IS_CLIENT_SIDE) {\n if (!clientChunkGroups) throw Error('Internal error');\n await bookStyleSheets(chunkName, clientChunkGroups, false);\n }\n\n const Wrapper: FunctionComponent<ComponentPropsT & {\n chunkGroups: ChunkGroupsT;\n }> = ({\n children,\n chunkGroups,\n ref,\n ...rest\n }) => {\n // This takes care about stylesheets management every time an instance of\n // this component is mounted / unmounted.\n useInsertionEffect(() => {\n if (!clientChunkGroups) throw Error('Internal error');\n void bookStyleSheets(chunkName, chunkGroups, true);\n return () => {\n freeStyleSheets(chunkName, chunkGroups);\n };\n }, [chunkGroups]);\n\n return (\n <Component\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...(rest as unknown as ComponentPropsT)}\n ref={ref}\n >\n {children}\n </Component>\n );\n };\n\n return { default: Wrapper };\n });\n\n const CodeSplit: FunctionComponent<ComponentPropsT> = ({\n children,\n ...rest\n }: ComponentPropsT) => {\n let chunkGroups: ChunkGroupsT;\n\n const ssrContext = useSsrContext(false);\n\n // On the server side we'll assert the chunk name here,\n // and also push it to the SSR chunks array.\n if (IS_SERVER_SIDE) {\n if (!ssrContext) throw Error('Internal error');\n ({ chunkGroups } = ssrContext);\n const { chunks } = ssrContext;\n\n if (!chunks.includes(chunkName)) chunks.push(chunkName);\n } else {\n if (!clientChunkGroups) {\n throw Error('Missing client-side chunk groups data');\n }\n chunkGroups = clientChunkGroups;\n }\n\n assertChunkName(chunkName, chunkGroups);\n\n return (\n <Suspense fallback={placeholder}>\n <LazyComponent\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...rest as Parameters<typeof LazyComponent>[0]}\n\n chunkGroups={chunkGroups}\n >\n {children}\n </LazyComponent>\n </Suspense>\n );\n };\n\n return CodeSplit;\n}\n"],"mappings":"oHAAA,qBAEA,OAKE,QAAQ,CACR,IAAI,CACJ,kBAAkB,KACb,OAAO,CAEd,OAAS,OAAO,KAAQ,sBAAsB,CAAC,OAEnB,aAAa,+BAGvC,cAAc,CACd,cAAc,CACd,gBAAgB,CAChB,YAAY,uEAGd,GAAI,kBAA2C,CAE/C,MAAO,SAAS,qBAAoB,CAAC,MAAoB,CAAQ,CAC/D,gBAAgB,CAAC,CAAC,CAClB,iBAAiB,CAAG,MAAM,CAC5B,CAEA,KAAM,UAAiC,CAAG,CAAC,CAAC,CAE5C,QAAS,cAAa,EAAG,CACvB,MAAO,aAAY,CAAC,CAAC,CAAC,UAAU,CAClC,CAEA;AACA;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.js","names":["chunkGroups","placeholder"],"sources":["../../../../src/shared/utils/splitComponent.tsx"],"sourcesContent":["/* global document */\n\nimport {\n type ComponentType,\n type FunctionComponent,\n type ReactNode,\n type RefObject,\n Suspense,\n lazy,\n useInsertionEffect,\n} from 'react';\n\nimport { Barrier } from '@dr.pogodin/js-utils';\n\nimport { type ChunkGroupsT, useSsrContext } from './globalState';\n\nimport {\n IS_CLIENT_SIDE,\n IS_SERVER_SIDE,\n assertClientSide,\n getBuildInfo,\n} from './isomorphy';\n\nlet clientChunkGroups: ChunkGroupsT | undefined;\n\nexport function setClientChunkGroups(groups: ChunkGroupsT): void {\n assertClientSide();\n clientChunkGroups = groups;\n}\n\nconst refCounts = new Map<string, number>();\n\nfunction getPublicPath() {\n return getBuildInfo().publicPath;\n}\n\n/**\n * Client-side only! Ensures the specified CSS stylesheet is loaded into\n * the document; loads if it is missing; and does simple reference counting\n * to facilitate future clean-up.\n * @param name\n * @param loadedSheets\n * @param refCount\n * @return\n */\nfunction bookStyleSheet(\n name: string,\n loadedSheets: Set<string>,\n refCount: boolean,\n): Promise<void> | undefined {\n let res: Barrier<void> | undefined;\n const path = `${getPublicPath()}/${name}`;\n const fullPath = `${document.location.origin}${path}`;\n\n if (!loadedSheets.has(fullPath)) {\n let link = document.querySelector(`link[href=\"${path}\"]`);\n\n if (!link) {\n link = document.createElement('link');\n link.setAttribute('rel', 'stylesheet');\n link.setAttribute('href', path);\n document.head.appendChild(link);\n }\n\n res = new Barrier<void>();\n link.addEventListener('load', () => {\n if (!res) throw Error('Internal error');\n void res.resolve();\n });\n link.addEventListener('error', () => {\n if (!res) throw Error('Internal error');\n void res.resolve();\n });\n }\n\n if (refCount) {\n const current = refCounts.get(path) ?? 0;\n refCounts.set(path, 1 + current);\n }\n\n return res;\n}\n\n/**\n * Generates the set of URLs for currently loaded, linked stylesheets.\n * @return\n */\nfunction getLoadedStyleSheets(): Set<string> {\n const res = new Set<string>();\n const { styleSheets } = document;\n for (const { href } of styleSheets) {\n if (href) res.add(href);\n }\n return res;\n}\n\nfunction assertChunkName(\n chunkName: string,\n chunkGroups: ChunkGroupsT,\n) {\n if (chunkGroups[chunkName]) return;\n throw Error(`Unknown chunk name \"${chunkName}\"`);\n}\n\n/**\n * Client-side only! Ensures all CSS stylesheets required for the specified\n * code chunk are loaded into the document; loads the missing ones; and does\n * simple reference counting to facilitate future clean-up.\n * @param chunkName Chunk name.\n * @param refCount\n * @return Resolves once all pending stylesheets, necessary for\n * the chunk, are either loaded, or failed to load.\n */\nexport async function bookStyleSheets(\n chunkName: string,\n chunkGroups: ChunkGroupsT,\n refCount: boolean,\n): Promise<void> {\n const promises = [];\n const assets = chunkGroups[chunkName];\n if (!assets) return Promise.resolve();\n\n const loadedSheets = getLoadedStyleSheets();\n\n for (const asset of assets) {\n if (asset.endsWith('.css')) {\n const promise = bookStyleSheet(asset, loadedSheets, refCount);\n if (promise) promises.push(promise);\n }\n }\n\n return promises.length\n ? Promise.allSettled(promises).then()\n : Promise.resolve();\n}\n\n/**\n * Client-side only! Frees from the document all CSS stylesheets that are\n * required by the specified chunk, and have reference counter equal to one\n * (for chunks with larger reference counter values, it just decrements\n * the reference counter).\n * @param {string} chunkName\n */\nexport function freeStyleSheets(\n chunkName: string,\n chunkGroups: ChunkGroupsT,\n): void {\n const assets = chunkGroups[chunkName];\n if (!assets) return;\n\n for (const asset of assets) {\n if (asset.endsWith('.css')) {\n const path = `${getPublicPath()}/${asset}`;\n\n const pathRefCount = refCounts.get(path);\n if (pathRefCount) {\n if (pathRefCount <= 1) {\n const node = document.head.querySelector(`link[href=\"${path}\"]`);\n if (!node) throw Error('Missing node');\n node.remove();\n refCounts.delete(path);\n } else refCounts.set(path, pathRefCount - 1);\n }\n }\n }\n}\n\n// Holds the set of chunk names already used for splitComponent() calls.\nconst usedChunkNames = new Set();\n\ntype ComponentOrModule<PropsT> = ComponentType<PropsT> | {\n default: ComponentType<PropsT>;\n};\n\ntype GenericComponentPropsT = {\n children?: ReactNode;\n ref?: RefObject<unknown>;\n\n // NOTE: This is necessary, as without it this type (with only optional\n // fields) will be conisdered as \"weak\" by TypeScript, and it will be\n // a error to assign to it any type that does not use \"children\", or \"ref\".\n [propName: string]: unknown;\n};\n\n/**\n * Given an async component retrieval function `getComponent()` it creates\n * a special \"code split\" component, which uses <Suspense> to asynchronously\n * load on demand the code required by `getComponent()`.\n * @param options\n * @param options.chunkName\n * @param {function} options.getComponent\n * @param {React.Element} [options.placeholder]\n * @return {React.ElementType}\n */\nexport default function splitComponent<\n ComponentPropsT extends GenericComponentPropsT,\n>({\n chunkName,\n getComponent,\n placeholder,\n}: {\n chunkName: string;\n getComponent: () => Promise<ComponentOrModule<ComponentPropsT>>;\n placeholder?: ReactNode;\n}): FunctionComponent<ComponentPropsT> {\n // The correct usage of splitComponent() assumes a single call per chunk.\n if (usedChunkNames.has(chunkName)\n\n // When HMR happens splitComponent() ends up getting called again for some\n // chunks, thus we should not throw this error. Not sure, if we need to do\n // some additional handling in that case, or just not throwing is all we\n // need.\n && !import.meta.webpackHot\n ) {\n throw Error(`Repeated splitComponent() call for the chunk \"${chunkName}\"`);\n } else usedChunkNames.add(chunkName);\n\n const LazyComponent = lazy(async () => {\n const resolved = await getComponent();\n const Component = 'default' in resolved ? resolved.default : resolved;\n\n // This pre-loads necessary stylesheets prior to the first mount of\n // the component (the lazy load function is executed by React one at\n // the frist mount).\n if (IS_CLIENT_SIDE) {\n if (!clientChunkGroups) throw Error('Internal error');\n await bookStyleSheets(chunkName, clientChunkGroups, false);\n }\n\n const Wrapper: FunctionComponent<ComponentPropsT & {\n chunkGroups: ChunkGroupsT;\n }> = ({\n children,\n chunkGroups,\n ref,\n ...rest\n }) => {\n // This takes care about stylesheets management every time an instance of\n // this component is mounted / unmounted.\n useInsertionEffect(() => {\n if (!clientChunkGroups) throw Error('Internal error');\n void bookStyleSheets(chunkName, chunkGroups, true);\n return () => {\n freeStyleSheets(chunkName, chunkGroups);\n };\n }, [chunkGroups]);\n\n return (\n <Component\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...(rest as unknown as ComponentPropsT)}\n ref={ref}\n >\n {children}\n </Component>\n );\n };\n\n return { default: Wrapper };\n });\n\n const CodeSplit: FunctionComponent<ComponentPropsT> = ({\n children,\n ...rest\n }: ComponentPropsT) => {\n let chunkGroups: ChunkGroupsT;\n\n const ssrContext = useSsrContext(false);\n\n // On the server side we'll assert the chunk name here,\n // and also push it to the SSR chunks array.\n if (IS_SERVER_SIDE) {\n if (!ssrContext) throw Error('Internal error');\n ({ chunkGroups } = ssrContext);\n const { chunks } = ssrContext;\n\n if (!chunks.includes(chunkName)) chunks.push(chunkName);\n } else {\n if (!clientChunkGroups) {\n throw Error('Missing client-side chunk groups data');\n }\n chunkGroups = clientChunkGroups;\n }\n\n assertChunkName(chunkName, chunkGroups);\n\n return (\n <Suspense fallback={placeholder}>\n <LazyComponent\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...rest as Parameters<typeof LazyComponent>[0]}\n\n chunkGroups={chunkGroups}\n >\n {children}\n </LazyComponent>\n </Suspense>\n );\n };\n\n return CodeSplit;\n}\n"],"mappings":"sHAAA,qBAEA,OAKE,QAAQ,CACR,IAAI,CACJ,kBAAkB,KACb,OAAO,CAEd,OAAS,OAAO,KAAQ,sBAAsB,CAAC,OAEnB,aAAa,+BAGvC,cAAc,CACd,cAAc,CACd,gBAAgB,CAChB,YAAY,uEAGd,GAAI,kBAA2C,CAE/C,MAAO,SAAS,qBAAoB,CAAC,MAAoB,CAAQ,CAC/D,gBAAgB,CAAC,CAAC,CAClB,iBAAiB,CAAG,MAAM,CAC5B,CAEA,KAAM,UAAS,CAAG,GAAI,IAAqB,CAE3C,QAAS,cAAa,EAAG,CACvB,MAAO,aAAY,CAAC,CAAC,CAAC,UAAU,CAClC,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,eAAc,CACrB,IAAY,CACZ,YAAyB,CACzB,QAAiB,CACU,CAC3B,GAAI,IAA8B,CACl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 -8,8 +8,9 @@ import{createRequire}from"module";import{IS_CLIENT_SIDE,IS_SERVER_SIDE}from"./is
|
|
|
8
8
|
*/export function requireWeak(modulePath,// TODO: For now `basePath` can be provided directly as a string here,
|
|
9
9
|
// for backward compatibility. Deprecate it in future, if any other
|
|
10
10
|
// breaking changes are done for requireWeak().
|
|
11
|
-
basePathOrOptions){if(IS_CLIENT_SIDE)return null;let basePath;let ops;if(typeof basePathOrOptions==="string"){basePath=basePathOrOptions;}else{ops=basePathOrOptions??{};({basePath}=ops);}// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
12
|
-
const{resolve}=require("node:path");const path=basePath?resolve(basePath,modulePath):modulePath
|
|
11
|
+
basePathOrOptions){if(IS_CLIENT_SIDE)return null;if(!require)throw Error("Internal error (missing require)");let basePath;let ops;if(typeof basePathOrOptions==="string"){basePath=basePathOrOptions;}else{ops=basePathOrOptions??{};({basePath}=ops);}// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
12
|
+
const{resolve}=require("node:path");const path=basePath?resolve(basePath,modulePath):modulePath;// eslint-disable-next-line import/no-dynamic-require
|
|
13
|
+
const module=require(path);if(!("default"in module)||!module.default)return module;const{default:def,...named}=module;const res=def;Object.entries(named).forEach(([name,value])=>{const assigned=res[name];if(assigned===undefined){res[name]=value;}else if(assigned!==value){throw Error("Conflict between default and named exports");}});return res;}/**
|
|
13
14
|
* Resolves specified module path with help of Babel's module resolver.
|
|
14
15
|
* Yes, the function itself just returns its argument to the caller, but Babel
|
|
15
16
|
* is configured to resolve the first argument of resolveWeak(..) function, thus
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.js","names":[],"sources":["../../../../src/shared/utils/webpack.ts"],"sourcesContent":["import type PathNS from 'node:path';\n\n// eslint-disable-next-line import/enforce-node-protocol-usage, perfectionist/sort-imports\nimport { createRequire } from 'module';\n\nimport { IS_CLIENT_SIDE, IS_SERVER_SIDE } from './isomorphy';\n\ntype RequireWeakOptionsT = {\n basePath?: string;\n};\n\ntype RequireWeakResT<T> = T extends { default: infer D }\n ? (D extends null | undefined ? T : D & Omit<T, 'default'>)\n : T;\n\nlet require: ((url: string) => unknown) | undefined;\n\nif (IS_SERVER_SIDE) require = createRequire(import.meta.url);\n\n/**\n * Requires the specified module without including it into the bundle during\n * Webpack build.\n * @param modulePath\n * @param [basePath]\n * @return Required module.\n */\nexport function requireWeak<T extends object>(\n modulePath: string,\n\n // TODO: For now `basePath` can be provided directly as a string here,\n // for backward compatibility. Deprecate it in future, if any other\n // breaking changes are done for requireWeak().\n basePathOrOptions?: RequireWeakOptionsT | string,\n): RequireWeakResT<T> | null {\n if (IS_CLIENT_SIDE) return null;\n\n let basePath: string | undefined;\n let ops: RequireWeakOptionsT;\n if (typeof basePathOrOptions === 'string') {\n basePath = basePathOrOptions;\n } else {\n ops = basePathOrOptions ?? {};\n ({ basePath } = ops);\n }\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const { resolve } = require
|
|
1
|
+
{"version":3,"file":"webpack.js","names":[],"sources":["../../../../src/shared/utils/webpack.ts"],"sourcesContent":["import type PathNS from 'node:path';\n\n// eslint-disable-next-line import/enforce-node-protocol-usage, perfectionist/sort-imports\nimport { createRequire } from 'module';\n\nimport { IS_CLIENT_SIDE, IS_SERVER_SIDE } from './isomorphy';\n\ntype RequireWeakOptionsT = {\n basePath?: string;\n};\n\ntype RequireWeakResT<T> = T extends { default: infer D }\n ? (D extends null | undefined ? T : D & Omit<T, 'default'>)\n : T;\n\nlet require: ((url: string) => unknown) | undefined;\n\nif (IS_SERVER_SIDE) require = createRequire(import.meta.url);\n\n/**\n * Requires the specified module without including it into the bundle during\n * Webpack build.\n * @param modulePath\n * @param [basePath]\n * @return Required module.\n */\nexport function requireWeak<T extends object>(\n modulePath: string,\n\n // TODO: For now `basePath` can be provided directly as a string here,\n // for backward compatibility. Deprecate it in future, if any other\n // breaking changes are done for requireWeak().\n basePathOrOptions?: RequireWeakOptionsT | string,\n): RequireWeakResT<T> | null {\n if (IS_CLIENT_SIDE) return null;\n\n if (!require) throw Error('Internal error (missing require)');\n\n let basePath: string | undefined;\n let ops: RequireWeakOptionsT;\n if (typeof basePathOrOptions === 'string') {\n basePath = basePathOrOptions;\n } else {\n ops = basePathOrOptions ?? {};\n ({ basePath } = ops);\n }\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const { resolve } = require('node:path') as typeof PathNS;\n\n const path = basePath ? resolve(basePath, modulePath) : modulePath;\n\n // eslint-disable-next-line import/no-dynamic-require\n const module = require(path) as T;\n\n if (!('default' in module) || !module.default) return module as RequireWeakResT<T>;\n\n const { default: def, ...named } = module;\n\n const res = def as RequireWeakResT<T>;\n\n Object.entries(named).forEach(([name, value]) => {\n const assigned = res[name as keyof RequireWeakResT<T>];\n if (assigned === undefined) {\n (res[name as keyof RequireWeakResT<T>] as unknown) = value;\n } else if (assigned !== value) {\n throw Error('Conflict between default and named exports');\n }\n });\n return res;\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 modulePath\n * @return Absolute or relative path to the module.\n */\nexport function resolveWeak(modulePath: string): string {\n return modulePath;\n}\n"],"mappings":"AAEA;AACA,OAAS,aAAa,KAAQ,QAAQ,CAAC,OAE9B,cAAc,CAAE,cAAc,4BAUvC,GAAI,QAA+C,CAEnD,GAAI,cAAc,CAAE,OAAO,CAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAE5D;AACA;AACA;AACA;AACA;AACA;AACA,GACA,MAAO,SAAS,YAAW,CACzB,UAAkB,CAElB;AACA;AACA;AACA,iBAAgD,CACrB,CAC3B,GAAI,cAAc,CAAE,MAAO,KAAI,CAE/B,GAAI,CAAC,OAAO,CAAE,KAAM,MAAK,CAAC,kCAAkC,CAAC,CAE7D,GAAI,SAA4B,CAChC,GAAI,IAAwB,CAC5B,GAAI,MAAO,kBAAiB,GAAK,QAAQ,CAAE,CACzC,QAAQ,CAAG,iBAAiB,CAC9B,CAAC,IAAM,CACL,GAAG,CAAG,iBAAiB,EAAI,CAAC,CAAC,CAC7B,CAAC,CAAE,QAAS,CAAC,CAAG,GAAG,EACrB,CAEA;AACA,KAAM,CAAE,OAAQ,CAAC,CAAG,OAAO,CAAC,WAAW,CAAkB,CAEzD,KAAM,KAAI,CAAG,QAAQ,CAAG,OAAO,CAAC,QAAQ,CAAE,UAAU,CAAC,CAAG,UAAU,CAElE;AACA,KAAM,OAAM,CAAG,OAAO,CAAC,IAAI,CAAM,CAEjC,GAAI,EAAE,SAAS,EAAI,OAAM,CAAC,EAAI,CAAC,MAAM,CAAC,OAAO,CAAE,MAAO,OAAM,CAE5D,KAAM,CAAE,OAAO,CAAE,GAAG,CAAE,GAAG,KAAM,CAAC,CAAG,MAAM,CAEzC,KAAM,IAAG,CAAG,GAAyB,CAErC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAE,KAAK,CAAC,GAAK,CAC/C,KAAM,SAAQ,CAAG,GAAG,CAAC,IAAI,CAA6B,CACtD,GAAI,QAAQ,GAAK,SAAS,CAAE,CACzB,GAAG,CAAC,IAAI,CAA6B,CAAe,KAAK,CAC5D,CAAC,IAAM,IAAI,QAAQ,GAAK,KAAK,CAAE,CAC7B,KAAM,MAAK,CAAC,4CAA4C,CAAC,CAC3D,CACF,CAAC,CAAC,CACF,MAAO,IAAG,CACZ,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,MAAO,SAAS,YAAW,CAAC,UAAkB,CAAU,CACtD,MAAO,WAAU,CACnB","ignoreList":[]}
|
package/config/babel/webpack.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import coreJsPackage from 'core-js-pure/package.json' with { type: 'json' };
|
|
1
2
|
import { localIdentNameFactory, } from '@dr.pogodin/babel-plugin-react-css-modules/utils';
|
|
2
3
|
const localIdentNameDev = localIdentNameFactory('[package]___[path][name]___[local]___[hash:base64:6]');
|
|
3
4
|
const localIdentNameProd = localIdentNameFactory('[hash:base64:6]');
|
|
@@ -23,7 +24,11 @@ function newBaseConfig(options) {
|
|
|
23
24
|
plugins.push(['module-resolver', {
|
|
24
25
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
25
26
|
root: ['./src/shared', './src'],
|
|
26
|
-
}], '@babel/transform-runtime', ['polyfill-corejs3', {
|
|
27
|
+
}], '@babel/transform-runtime', ['polyfill-corejs3', {
|
|
28
|
+
method: 'usage-pure',
|
|
29
|
+
proposals: true,
|
|
30
|
+
version: coreJsPackage.version,
|
|
31
|
+
}]);
|
|
27
32
|
if (options.addImportExtensions) {
|
|
28
33
|
plugins.push(['@dr.pogodin/add-import-extension',
|
|
29
34
|
typeof options.addImportExtensions === 'object'
|
|
@@ -3,6 +3,7 @@ import { randomBytes } from 'node:crypto';
|
|
|
3
3
|
import nodeFs from 'node:fs';
|
|
4
4
|
import { createRequire } from 'node:module';
|
|
5
5
|
import { resolve } from 'node:path';
|
|
6
|
+
import autoprefixer from 'autoprefixer';
|
|
6
7
|
import { isFunction } from 'lodash-es';
|
|
7
8
|
import { SitemapStream, streamToPromise } from 'sitemap';
|
|
8
9
|
// NOTE: As "webpack" is still distributed as CJS module, now that we have
|
|
@@ -260,12 +261,19 @@ export default function configFactory({ babelEnv, babelLoaderExclude, babelLoade
|
|
|
260
261
|
/* Loads SCSS stylesheets. */
|
|
261
262
|
test: /\.scss$/,
|
|
262
263
|
type: 'css/module',
|
|
263
|
-
use: {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
264
|
+
use: [{
|
|
265
|
+
loader: 'postcss-loader',
|
|
266
|
+
options: {
|
|
267
|
+
postcssOptions: {
|
|
268
|
+
plugins: [autoprefixer],
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
}, {
|
|
272
|
+
loader: 'sass-loader',
|
|
273
|
+
options: {
|
|
274
|
+
sourceMap: true,
|
|
275
|
+
},
|
|
276
|
+
}],
|
|
269
277
|
}],
|
|
270
278
|
},
|
|
271
279
|
node: {
|
|
@@ -273,6 +281,8 @@ export default function configFactory({ babelEnv, babelLoaderExclude, babelLoade
|
|
|
273
281
|
},
|
|
274
282
|
output: {
|
|
275
283
|
chunkFilename: '[contenthash].js',
|
|
284
|
+
cssChunkFilename: '[contenthash].css',
|
|
285
|
+
cssFilename: '[contenthash].css',
|
|
276
286
|
filename: '[contenthash].js',
|
|
277
287
|
path: resolve(import.meta.dirname, context, outputPath),
|
|
278
288
|
publicPath: `${publicPath}/`,
|
|
@@ -40,6 +40,8 @@ export default function configFactory(ops) {
|
|
|
40
40
|
const res = merge(baseFactory(Object.assign(Object.assign({}, o), { babelEnv: 'development', entry, mode: 'development' })), {
|
|
41
41
|
output: {
|
|
42
42
|
chunkFilename: '[id].js',
|
|
43
|
+
cssChunkFilename: '[id].css',
|
|
44
|
+
cssFilename: '[id].css',
|
|
43
45
|
filename: '[id].js',
|
|
44
46
|
},
|
|
45
47
|
plugins,
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.58.0",
|
|
3
3
|
"bin": {
|
|
4
4
|
"react-utils-build": "bin/build.js",
|
|
5
5
|
"react-utils-run-with-babel": "bin/run-with-babel.js",
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"url": "https://github.com/birdofpreyru/react-utils/issues"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@babel/runtime-corejs3": "^8.0.
|
|
12
|
+
"@babel/runtime-corejs3": "^8.0.7",
|
|
13
13
|
"@commander-js/extra-typings": "^15.0.0",
|
|
14
14
|
"@dr.pogodin/babel-plugin-react-css-modules": "^8.0.0",
|
|
15
|
-
"@dr.pogodin/csurf": "^1.18.
|
|
15
|
+
"@dr.pogodin/csurf": "^1.18.2",
|
|
16
16
|
"@dr.pogodin/js-utils": "^0.2.0",
|
|
17
17
|
"@dr.pogodin/react-global-state": "^0.25.0",
|
|
18
18
|
"@dr.pogodin/react-helmet": "^3.3.2",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"core-js-pure": "^3.50.0",
|
|
28
28
|
"cross-env": "^10.1.0",
|
|
29
29
|
"dayjs": "^1.11.23",
|
|
30
|
-
"express": "^5.
|
|
30
|
+
"express": "^5.3.0",
|
|
31
31
|
"helmet": "^8.3.0",
|
|
32
32
|
"http-status-codes": "^2.3.0",
|
|
33
33
|
"lodash-es": "^4.18.1",
|
|
34
34
|
"morgan": "^1.12.1",
|
|
35
|
-
"qs": "^6.16.
|
|
35
|
+
"qs": "^6.16.1",
|
|
36
36
|
"raf": "^3.4.1",
|
|
37
|
-
"react": "^19.3.
|
|
38
|
-
"react-dom": "^19.3.
|
|
37
|
+
"react": "^19.3.1",
|
|
38
|
+
"react-dom": "^19.3.1",
|
|
39
39
|
"react-router": "^8.4.0",
|
|
40
40
|
"request-ip": "^3.3.0",
|
|
41
41
|
"rimraf": "^6.1.3",
|
|
@@ -47,22 +47,22 @@
|
|
|
47
47
|
"description": "Collection of generic ReactJS components and utils",
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@babel/cli": "^8.0.6",
|
|
50
|
-
"@babel/core": "^8.0.
|
|
50
|
+
"@babel/core": "^8.0.7",
|
|
51
51
|
"@babel/plugin-transform-runtime": "^8.0.6",
|
|
52
|
-
"@babel/preset-env": "^8.0.
|
|
52
|
+
"@babel/preset-env": "^8.0.7",
|
|
53
53
|
"@babel/preset-react": "^8.0.1",
|
|
54
|
-
"@babel/preset-typescript": "^8.0.
|
|
54
|
+
"@babel/preset-typescript": "^8.0.7",
|
|
55
55
|
"@babel/register": "^8.0.6",
|
|
56
56
|
"@dr.pogodin/babel-plugin-add-import-extension": "^3.0.2",
|
|
57
57
|
"@dr.pogodin/babel-plugin-transform-assets": "^2.0.0",
|
|
58
58
|
"@dr.pogodin/babel-preset-svgr": "^2.0.0",
|
|
59
|
-
"@dr.pogodin/eslint-configs": "^0.3.
|
|
59
|
+
"@dr.pogodin/eslint-configs": "^0.3.9",
|
|
60
60
|
"@jest/globals": "^30.5.2",
|
|
61
61
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.6.3",
|
|
62
62
|
"@standard-schema/spec": "^1.1.0",
|
|
63
63
|
"@testing-library/dom": "^10.4.2",
|
|
64
64
|
"@testing-library/react": "^16.3.3",
|
|
65
|
-
"@testing-library/user-event": "^14.6.
|
|
65
|
+
"@testing-library/user-event": "^14.6.8",
|
|
66
66
|
"@tsconfig/recommended": "^1.0.13",
|
|
67
67
|
"@types/compression": "^1.8.1",
|
|
68
68
|
"@types/config": "^3.3.5",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@types/cookie-parser": "^1.4.10",
|
|
71
71
|
"@types/express": "^5.0.6",
|
|
72
72
|
"@types/jest": "^30.0.0",
|
|
73
|
-
"@types/lodash": "^4.17.
|
|
73
|
+
"@types/lodash": "^4.17.26",
|
|
74
74
|
"@types/lodash-es": "^4.17.12",
|
|
75
75
|
"@types/morgan": "^1.9.10",
|
|
76
76
|
"@types/pretty": "^2.0.3",
|
|
@@ -81,12 +81,13 @@
|
|
|
81
81
|
"@types/serve-favicon": "^2.5.7",
|
|
82
82
|
"@types/supertest": "^7.2.1",
|
|
83
83
|
"@types/webpack": "^5.28.5",
|
|
84
|
+
"autoprefixer": "^10.6.1",
|
|
84
85
|
"babel-jest": "^30.5.2",
|
|
85
86
|
"babel-loader": "^10.1.1",
|
|
86
87
|
"babel-plugin-module-resolver": "^5.0.3",
|
|
87
88
|
"babel-plugin-polyfill-corejs3": "^1.0.0",
|
|
88
89
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
89
|
-
"cssnano": "^9.
|
|
90
|
+
"cssnano": "^9.9.0",
|
|
90
91
|
"identity-obj-proxy": "^3.0.0",
|
|
91
92
|
"jest": "^30.5.2",
|
|
92
93
|
"jest-environment-jsdom": "^30.5.2",
|
|
@@ -94,23 +95,24 @@
|
|
|
94
95
|
"minimizer-webpack-plugin": "^5.13.0",
|
|
95
96
|
"mockdate": "^3.0.5",
|
|
96
97
|
"nodelist-foreach-polyfill": "^1.2.0",
|
|
97
|
-
"postcss": "^8.5.
|
|
98
|
+
"postcss": "^8.5.30",
|
|
99
|
+
"postcss-loader": "^8.2.1",
|
|
98
100
|
"postcss-scss": "^4.0.9",
|
|
99
101
|
"pretty": "^2.0.0",
|
|
100
102
|
"react-refresh": "^0.19.0",
|
|
101
|
-
"sass": "^1.
|
|
103
|
+
"sass": "^1.105.2",
|
|
102
104
|
"sass-loader": "^17.0.1",
|
|
103
105
|
"sitemap": "^9.0.1",
|
|
104
106
|
"source-map-loader": "^5.0.0",
|
|
105
107
|
"stylelint": "^17.16.0",
|
|
106
108
|
"stylelint-config-standard-scss": "^17.0.0",
|
|
107
109
|
"supertest": "^7.3.1",
|
|
108
|
-
"tsc-alias": "^1.9.
|
|
110
|
+
"tsc-alias": "^1.9.8",
|
|
109
111
|
"tstyche": "^7.2.5",
|
|
110
112
|
"typed-scss-modules": "^8.1.1",
|
|
111
113
|
"typescript": "^6.0.3",
|
|
112
|
-
"webpack": "^5.
|
|
113
|
-
"webpack-dev-middleware": "^8.
|
|
114
|
+
"webpack": "^5.112.0",
|
|
115
|
+
"webpack-dev-middleware": "^8.4.0",
|
|
114
116
|
"webpack-merge": "^6.0.1",
|
|
115
117
|
"workbox-core": "^7.4.1",
|
|
116
118
|
"workbox-precaching": "^7.4.1",
|