@dr.pogodin/react-utils 1.12.1 → 1.12.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/shared/components/CodeSplit/ServerSide.js +6 -0
- package/build/development/shared/components/CodeSplit/ServerSide.js.map +1 -1
- package/build/production/shared/components/CodeSplit/ServerSide.js +2 -2
- package/build/production/shared/components/CodeSplit/ServerSide.js.map +1 -1
- package/package.json +4 -4
|
@@ -13,6 +13,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
13
13
|
|
|
14
14
|
var _reactGlobalState = require("@dr.pogodin/react-global-state");
|
|
15
15
|
|
|
16
|
+
var _reactRouterDom = require("react-router-dom");
|
|
17
|
+
|
|
16
18
|
var _server2 = require("react-router-dom/server");
|
|
17
19
|
|
|
18
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -83,10 +85,14 @@ function ServerSide({
|
|
|
83
85
|
/* eslint-enable react-hooks/rules-of-hooks */
|
|
84
86
|
}
|
|
85
87
|
const globalState = (0, _reactGlobalState.getGlobalState)();
|
|
88
|
+
const {
|
|
89
|
+
pathname
|
|
90
|
+
} = (0, _reactRouterDom.useResolvedPath)('');
|
|
86
91
|
|
|
87
92
|
const html = _server.default.renderToString( /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactGlobalState.GlobalStateProvider, {
|
|
88
93
|
stateProxy: globalState,
|
|
89
94
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_server2.StaticRouter, {
|
|
95
|
+
basename: pathname,
|
|
90
96
|
location: globalState.ssrContext.req.url,
|
|
91
97
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Scene, { ...rest
|
|
92
98
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/shared/components/CodeSplit/ServerSide.jsx"],"names":["resolveRequire","base","path","p","require","resolve","paths","default","def","named","Object","entries","forEach","key","value","Error","ServerSide","chunkName","getComponentAsync","getComponentServer","placeholder","rest","Scene","data","globalState","html","ReactDom","renderToString","ssrContext","req","url","chunks","includes","push","__html","propTypes","PT","string","isRequired","func","elementType","defaultProps"],"mappings":";;;;;;;;;AAKA;;AACA;;AAEA;;
|
|
1
|
+
{"version":3,"sources":["../../../../../src/shared/components/CodeSplit/ServerSide.jsx"],"names":["resolveRequire","base","path","p","require","resolve","paths","default","def","named","Object","entries","forEach","key","value","Error","ServerSide","chunkName","getComponentAsync","getComponentServer","placeholder","rest","Scene","data","globalState","pathname","html","ReactDom","renderToString","ssrContext","req","url","chunks","includes","push","__html","propTypes","PT","string","isRequired","func","elementType","defaultProps"],"mappings":";;;;;;;;;AAKA;;AACA;;AAEA;;AAMA;;AACA;;;;AAfA;AACA;AACA;;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,cAAT,CAAwBC,IAAxB,EAA8BC,IAA9B,EAAoC;AAClC;AACA;AACA;AACA;AACA,QAAMC,CAAC,GAAGC,OAAO,CAACC,OAAR,CAAgBH,IAAhB,EAAsB;AAAEI,IAAAA,KAAK,EAAE,CAACL,IAAD;AAAT,GAAtB,CAAV;AACA;;;AACA,QAAM;AAAEM,IAAAA,OAAO,EAAEC,GAAX;AAAgB,OAAGC;AAAnB,MAA6BL,OAAO,CAACD,CAAD,CAA1C;AACA;;;AACA,MAAI,CAACK,GAAL,EAAU,OAAOC,KAAP;AAEVC,EAAAA,MAAM,CAACC,OAAP,CAAeF,KAAf,EAAsBG,OAAtB,CAA8B,CAAC,CAACC,GAAD,EAAMC,KAAN,CAAD,KAAkB;AAC9C,QAAIN,GAAG,CAACK,GAAD,CAAP,EAAc,MAAME,KAAK,CAAC,4CAAD,CAAX;AACdP,IAAAA,GAAG,CAACK,GAAD,CAAH,GAAWC,KAAX;AACD,GAHD;AAIA,SAAON,GAAP;AACD;;AAEc,SAASQ,UAAT,CAAoB;AACjCC,EAAAA,SADiC;AAEjCC,EAAAA,iBAFiC;AAGjCC,EAAA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EAAAA,SAAS,EAAEoB,mBAAGC,MAAH,CAAUC,UADA;AAErBrB,EAAAA,iBAAiB,EAAEmB,mBAAGG,IAFD;AAGrBrB,EAAAA,kBAAkB,EAAEkB,mBAAGG,IAHF;AAIrBpB,EAAAA,WAAW,EAAEiB,mBAAGI;AAJK,CAAvB;AAOAzB,UAAU,CAAC0B,YAAX,GAA0B;AACxBxB,EAAAA,iBAAiB,EAAE,IADK;AAExBC,EAAAA,kBAAkB,EAAE,IAFI;AAGxBC,EAAAA,WAAW,EAAE;AAHW,CAA1B","sourcesContent":["/**\n * Server-side implementation.\n */\n/* eslint-disable react/jsx-props-no-spreading */\n\nimport ReactDom from 'react-dom/server';\nimport PT from 'prop-types';\n\nimport {\n getGlobalState,\n GlobalStateProvider,\n useAsyncData,\n} from '@dr.pogodin/react-global-state';\n\nimport { useResolvedPath } from 'react-router-dom';\nimport { StaticRouter } from 'react-router-dom/server';\n\n/**\n * A specially wrapped `require()`, which is passed as an argument into\n * the optional `getComponentServer` prop of <{@link CodeSplit}> component.\n * @param {string} base Path resolution base, you want to pass in `__dirname`\n * value from the host module using `<CodeSplit>`.\n * @param {string} path The path of module to require.\n * @return {object} Required module.\n */\nfunction resolveRequire(base, path) {\n // NOTE: A part of code here attempts to correctly load ES6 modules\n // transformed by Babel; namely if required module has \"default\" field,\n // all other fields (presumed to be named exports) are attached to\n // the \"default\".\n const p = require.resolve(path, { paths: [base] });\n /* eslint-disable global-require, import/no-dynamic-require */\n const { default: def, ...named } = require(p);\n /* eslint-enable global-require, import/no-dynamic-require */\n if (!def) return named;\n\n Object.entries(named).forEach(([key, value]) => {\n if (def[key]) throw Error('Conflict between default and named exports');\n def[key] = value;\n });\n return def;\n}\n\nexport default function ServerSide({\n chunkName,\n getComponentAsync,\n getComponentServer,\n placeholder,\n ...rest\n}) {\n /* 1. The component, or its placeholder is rendered into HTML string.\n * The component is wrapped into <GlobalStateProvider>, and <StaticRouter>\n * to ensure that global state, and react router will work inside\n * the component, if present there. Also, if no server-side (sync) way\n * to load the component is provider, `useAsyncData(..)` is used to\n * attempt to load and use the component via SSR mechanics. */\n let Scene;\n if (getComponentServer) Scene = getComponentServer(resolveRequire);\n else {\n // In this case we are sure the condition won't change during the rendering\n // loop, thus we can ignore the rule.\n /* eslint-disable react-hooks/rules-of-hooks */\n const { data } = useAsyncData(\n `dr_pogodin_react_utils___split_components.${chunkName}`,\n getComponentAsync,\n );\n Scene = data ? (data.default || data) : (placeholder || (() => null));\n /* eslint-enable react-hooks/rules-of-hooks */\n }\n\n const globalState = getGlobalState();\n const { pathname } = useResolvedPath('');\n const html = ReactDom.renderToString((\n <GlobalStateProvider stateProxy={globalState}>\n <StaticRouter\n basename={pathname}\n location={globalState.ssrContext.req.url}\n >\n <Scene {...rest} />\n </StaticRouter>\n </GlobalStateProvider>\n ));\n\n /* 2. `chunks` array is used to record CSS chunks to inject. */\n const { chunks } = globalState.ssrContext;\n if (chunks.includes(chunkName)) {\n throw new Error(`CodeSplit: chunk name clash for (${chunkName})`);\n } else chunks.push(chunkName);\n\n /* The result is rendered using the container with `dangerouslySetInnerHTML`\n * to allow reproduce the same rendering result at the client side, even prior\n * to the async loading of the split code. */\n /* eslint-disable react/no-danger */\n return (\n <div\n dangerouslySetInnerHTML={{ __html: html }}\n data-chunk-name={chunkName}\n />\n );\n /* eslint-enable react/no-danger */\n}\n\nServerSide.propTypes = {\n chunkName: PT.string.isRequired,\n getComponentAsync: PT.func,\n getComponentServer: PT.func,\n placeholder: PT.elementType,\n};\n\nServerSide.defaultProps = {\n getComponentAsync: null,\n getComponentServer: null,\n placeholder: null,\n};\n"],"file":"ServerSide.js"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=ServerSide;var _server=_interopRequireDefault(require("react-dom/server"));var _propTypes=_interopRequireDefault(require("prop-types"));var _reactGlobalState=require("@dr.pogodin/react-global-state");var _server2=require("react-router-dom/server");var _jsxRuntime=require("react/jsx-runtime");/**
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=ServerSide;var _server=_interopRequireDefault(require("react-dom/server"));var _propTypes=_interopRequireDefault(require("prop-types"));var _reactGlobalState=require("@dr.pogodin/react-global-state");var _reactRouterDom=require("react-router-dom");var _server2=require("react-router-dom/server");var _jsxRuntime=require("react/jsx-runtime");/**
|
|
2
2
|
* Server-side implementation.
|
|
3
3
|
*/ /* eslint-disable react/jsx-props-no-spreading */ /**
|
|
4
4
|
* A specially wrapped `require()`, which is passed as an argument into
|
|
@@ -18,7 +18,7 @@ const p=require.resolve(path,{paths:[base]});/* eslint-disable global-require, i
|
|
|
18
18
|
* to load the component is provider, `useAsyncData(..)` is used to
|
|
19
19
|
* attempt to load and use the component via SSR mechanics. */let Scene;if(getComponentServer)Scene=getComponentServer(resolveRequire);else{// In this case we are sure the condition won't change during the rendering
|
|
20
20
|
// loop, thus we can ignore the rule.
|
|
21
|
-
/* eslint-disable react-hooks/rules-of-hooks */const{data}=(0,_reactGlobalState.useAsyncData)(`dr_pogodin_react_utils___split_components.${chunkName}`,getComponentAsync);Scene=data?data.default||data:placeholder||(()=>null);/* eslint-enable react-hooks/rules-of-hooks */}const globalState=(0,_reactGlobalState.getGlobalState)();const html=_server.default.renderToString(/*#__PURE__*/(0,_jsxRuntime.jsx)(_reactGlobalState.GlobalStateProvider,{stateProxy:globalState,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_server2.StaticRouter,{location:globalState.ssrContext.req.url,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(Scene,{...rest})})}));/* 2. `chunks` array is used to record CSS chunks to inject. */const{chunks}=globalState.ssrContext;if(chunks.includes(chunkName)){throw new Error(`CodeSplit: chunk name clash for (${chunkName})`)}else chunks.push(chunkName);/* The result is rendered using the container with `dangerouslySetInnerHTML`
|
|
21
|
+
/* eslint-disable react-hooks/rules-of-hooks */const{data}=(0,_reactGlobalState.useAsyncData)(`dr_pogodin_react_utils___split_components.${chunkName}`,getComponentAsync);Scene=data?data.default||data:placeholder||(()=>null);/* eslint-enable react-hooks/rules-of-hooks */}const globalState=(0,_reactGlobalState.getGlobalState)();const{pathname}=(0,_reactRouterDom.useResolvedPath)("");const html=_server.default.renderToString(/*#__PURE__*/(0,_jsxRuntime.jsx)(_reactGlobalState.GlobalStateProvider,{stateProxy:globalState,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_server2.StaticRouter,{basename:pathname,location:globalState.ssrContext.req.url,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(Scene,{...rest})})}));/* 2. `chunks` array is used to record CSS chunks to inject. */const{chunks}=globalState.ssrContext;if(chunks.includes(chunkName)){throw new Error(`CodeSplit: chunk name clash for (${chunkName})`)}else chunks.push(chunkName);/* The result is rendered using the container with `dangerouslySetInnerHTML`
|
|
22
22
|
* to allow reproduce the same rendering result at the client side, even prior
|
|
23
23
|
* to the async loading of the split code. */ /* eslint-disable react/no-danger */return/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{dangerouslySetInnerHTML:{__html:html},"data-chunk-name":chunkName});/* eslint-enable react/no-danger */}ServerSide.propTypes={chunkName:_propTypes.default.string.isRequired,getComponentAsync:_propTypes.default.func,getComponentServer:_propTypes.default.func,placeholder:_propTypes.default.elementType};ServerSide.defaultProps={getComponentAsync:null,getComponentServer:null,placeholder:null};
|
|
24
24
|
//# sourceMappingURL=ServerSide.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/shared/components/CodeSplit/ServerSide.jsx"],"names":["resolveRequire","base","path","p","require","resolve","paths","default","def","named","Object","entries","forEach","key","value","Error","ServerSide","chunkName","getComponentAsync","getComponentServer","placeholder","rest","Scene","data","globalState","html","ReactDom","renderToString","ssrContext","req","url","chunks","includes","push","__html","propTypes","PT","string","isRequired","func","elementType","defaultProps"],"mappings":"oLAKA,gEACA,6DAEA,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/shared/components/CodeSplit/ServerSide.jsx"],"names":["resolveRequire","base","path","p","require","resolve","paths","default","def","named","Object","entries","forEach","key","value","Error","ServerSide","chunkName","getComponentAsync","getComponentServer","placeholder","rest","Scene","data","globalState","pathname","html","ReactDom","renderToString","ssrContext","req","url","chunks","includes","push","__html","propTypes","PT","string","isRequired","func","elementType","defaultProps"],"mappings":"oLAKA,gEACA,6DAEA,gEAMA,gDACA,gD,6CAfA;AACA;AACA,G,CACA,iD,CAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAASA,CAAAA,cAAT,CAAwBC,IAAxB,CAA8BC,IAA9B,CAAoC,CAClC;AACA;AACA;AACA;AACA,KAAMC,CAAAA,CAAC,CAAGC,OAAO,CAACC,OAAR,CAAgBH,IAAhB,CAAsB,CAAEI,KAAK,CAAE,CAACL,IAAD,CAAT,CAAtB,CAAV,CACA,8DACA,KAAM,CAAEM,OAAO,CAAEC,GAAX,CAAgB,GAAGC,KAAnB,EAA6BL,OAAO,CAACD,CAAD,CAA1C,CACA,6DACA,GAAI,CAACK,GAAL,CAAU,MAAOC,CAAAA,KAAP,CAEVC,MAAM,CAACC,OAAP,CAAeF,KAAf,EAAsBG,OAAtB,CAA8B,CAAC,CAACC,GAAD,CAAMC,KAAN,CAAD,GAAkB,CAC9C,GAAIN,GAAG,CAACK,GAAD,CAAP,CAAc,KAAME,CAAAA,KAAK,CAAC,4CAAD,CAAX,CACdP,GAAG,CAACK,GAAD,CAAH,CAAWC,KACZ,CAHD,EAIA,MAAON,CAAAA,GACR,CAEc,QAASQ,CAAAA,UAAT,CAAoB,CACjCC,SADiC,CAEjCC,iBAFiC,CAGjCC,kBAHiC,CAIjCC,WAJiC,CAKjC,GAAGC,IAL8B,CAApB,CAMZ,CACD;AACF;AACA;AACA;AACA;AACA,mEACE,GAAIC,CAAAA,KAAJ,CACA,GAAIH,kBAAJ,CAAwBG,KAAK,C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,CAA0B,CACxBxB,iBAAiB,CAAE,IADK,CAExBC,kBAAkB,CAAE,IAFI,CAGxBC,WAAW,CAAE,IAHW,CAA1B","sourcesContent":["/**\n * Server-side implementation.\n */\n/* eslint-disable react/jsx-props-no-spreading */\n\nimport ReactDom from 'react-dom/server';\nimport PT from 'prop-types';\n\nimport {\n getGlobalState,\n GlobalStateProvider,\n useAsyncData,\n} from '@dr.pogodin/react-global-state';\n\nimport { useResolvedPath } from 'react-router-dom';\nimport { StaticRouter } from 'react-router-dom/server';\n\n/**\n * A specially wrapped `require()`, which is passed as an argument into\n * the optional `getComponentServer` prop of <{@link CodeSplit}> component.\n * @param {string} base Path resolution base, you want to pass in `__dirname`\n * value from the host module using `<CodeSplit>`.\n * @param {string} path The path of module to require.\n * @return {object} Required module.\n */\nfunction resolveRequire(base, path) {\n // NOTE: A part of code here attempts to correctly load ES6 modules\n // transformed by Babel; namely if required module has \"default\" field,\n // all other fields (presumed to be named exports) are attached to\n // the \"default\".\n const p = require.resolve(path, { paths: [base] });\n /* eslint-disable global-require, import/no-dynamic-require */\n const { default: def, ...named } = require(p);\n /* eslint-enable global-require, import/no-dynamic-require */\n if (!def) return named;\n\n Object.entries(named).forEach(([key, value]) => {\n if (def[key]) throw Error('Conflict between default and named exports');\n def[key] = value;\n });\n return def;\n}\n\nexport default function ServerSide({\n chunkName,\n getComponentAsync,\n getComponentServer,\n placeholder,\n ...rest\n}) {\n /* 1. The component, or its placeholder is rendered into HTML string.\n * The component is wrapped into <GlobalStateProvider>, and <StaticRouter>\n * to ensure that global state, and react router will work inside\n * the component, if present there. Also, if no server-side (sync) way\n * to load the component is provider, `useAsyncData(..)` is used to\n * attempt to load and use the component via SSR mechanics. */\n let Scene;\n if (getComponentServer) Scene = getComponentServer(resolveRequire);\n else {\n // In this case we are sure the condition won't change during the rendering\n // loop, thus we can ignore the rule.\n /* eslint-disable react-hooks/rules-of-hooks */\n const { data } = useAsyncData(\n `dr_pogodin_react_utils___split_components.${chunkName}`,\n getComponentAsync,\n );\n Scene = data ? (data.default || data) : (placeholder || (() => null));\n /* eslint-enable react-hooks/rules-of-hooks */\n }\n\n const globalState = getGlobalState();\n const { pathname } = useResolvedPath('');\n const html = ReactDom.renderToString((\n <GlobalStateProvider stateProxy={globalState}>\n <StaticRouter\n basename={pathname}\n location={globalState.ssrContext.req.url}\n >\n <Scene {...rest} />\n </StaticRouter>\n </GlobalStateProvider>\n ));\n\n /* 2. `chunks` array is used to record CSS chunks to inject. */\n const { chunks } = globalState.ssrContext;\n if (chunks.includes(chunkName)) {\n throw new Error(`CodeSplit: chunk name clash for (${chunkName})`);\n } else chunks.push(chunkName);\n\n /* The result is rendered using the container with `dangerouslySetInnerHTML`\n * to allow reproduce the same rendering result at the client side, even prior\n * to the async loading of the split code. */\n /* eslint-disable react/no-danger */\n return (\n <div\n dangerouslySetInnerHTML={{ __html: html }}\n data-chunk-name={chunkName}\n />\n );\n /* eslint-enable react/no-danger */\n}\n\nServerSide.propTypes = {\n chunkName: PT.string.isRequired,\n getComponentAsync: PT.func,\n getComponentServer: PT.func,\n placeholder: PT.elementType,\n};\n\nServerSide.defaultProps = {\n getComponentAsync: null,\n getComponentServer: null,\n placeholder: null,\n};\n"],"file":"ServerSide.js"}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@babel/runtime": "^7.16.3",
|
|
11
11
|
"@dr.pogodin/babel-plugin-react-css-modules": "^6.5.3",
|
|
12
|
-
"@dr.pogodin/react-global-state": "^0.6.
|
|
12
|
+
"@dr.pogodin/react-global-state": "^0.6.5",
|
|
13
13
|
"@dr.pogodin/react-themes": "^1.3.3",
|
|
14
14
|
"autoprefix": "^1.0.1",
|
|
15
15
|
"axios": "^0.24.0",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"core-js": "^3.19.3",
|
|
66
66
|
"css-loader": "^6.5.1",
|
|
67
67
|
"css-minimizer-webpack-plugin": "^3.2.0",
|
|
68
|
-
"eslint": "^8.4.
|
|
68
|
+
"eslint": "^8.4.1",
|
|
69
69
|
"eslint-config-airbnb": "^19.0.2",
|
|
70
70
|
"eslint-import-resolver-babel-module": "^5.3.1",
|
|
71
71
|
"eslint-plugin-import": "^2.25.3",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"regenerator-runtime": "^0.13.9",
|
|
88
88
|
"resolve-url-loader": "^4.0.0",
|
|
89
89
|
"sass": "^1.44.0",
|
|
90
|
-
"sass-loader": "^12.
|
|
90
|
+
"sass-loader": "^12.4.0",
|
|
91
91
|
"sitemap": "^7.0.0",
|
|
92
92
|
"stylelint": "^14.1.0",
|
|
93
93
|
"stylelint-config-standard-scss": "^3.0.0",
|
|
@@ -132,5 +132,5 @@
|
|
|
132
132
|
"lint:scss": "stylelint -- **/*.{css,scss}",
|
|
133
133
|
"test": "npm run lint && npm run jest"
|
|
134
134
|
},
|
|
135
|
-
"version": "1.12.
|
|
135
|
+
"version": "1.12.2"
|
|
136
136
|
}
|