@dr.pogodin/react-utils 1.35.2 → 1.35.3
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/getInj.js +10 -0
- package/build/development/client/getInj.js.map +1 -1
- package/build/development/client/index.js +9 -2
- package/build/development/client/index.js.map +1 -1
- package/build/development/index.js +9 -1
- package/build/development/index.js.map +1 -1
- package/build/development/shared/utils/splitComponent.js +16 -10
- package/build/development/shared/utils/splitComponent.js.map +1 -1
- package/build/development/web.bundle.js +4 -4
- package/build/production/client/getInj.js +6 -2
- package/build/production/client/getInj.js.map +1 -1
- package/build/production/client/index.js +1 -1
- package/build/production/client/index.js.map +1 -1
- package/build/production/index.js +4 -1
- package/build/production/index.js.map +1 -1
- package/build/production/shared/utils/splitComponent.js +9 -7
- package/build/production/shared/utils/splitComponent.js.map +1 -1
- package/build/production/web.bundle.js +1 -1
- package/build/production/web.bundle.js.map +1 -1
- package/build/types-code/client/getInj.d.ts +6 -0
- package/build/types-code/client/index.d.ts +2 -1
- package/build/types-code/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/client/getInj.ts +9 -0
- package/src/client/index.tsx +3 -1
- package/src/index.ts +9 -1
- package/src/shared/utils/splitComponent.tsx +18 -10
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = getInj;
|
|
8
|
+
exports.setInj = setInj;
|
|
8
9
|
var _forge = _interopRequireDefault(require("node-forge/lib/forge"));
|
|
9
10
|
require("node-forge/lib/aes");
|
|
10
11
|
var _buildInfo = require("../shared/utils/isomorphy/buildInfo");
|
|
@@ -43,4 +44,13 @@ if (metaElement) {
|
|
|
43
44
|
function getInj() {
|
|
44
45
|
return inj;
|
|
45
46
|
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Allows to set a custom injection object instance,
|
|
50
|
+
* for server-less scenarios, for example, where it is not auto-injected
|
|
51
|
+
* into generated pages from the server side.
|
|
52
|
+
*/
|
|
53
|
+
function setInj(value) {
|
|
54
|
+
inj = value;
|
|
55
|
+
}
|
|
46
56
|
//# sourceMappingURL=getInj.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getInj.js","names":["_forge","_interopRequireDefault","require","_buildInfo","inj","metaElement","document","querySelector","remove","data","forge","util","decode64","content","key","getBuildInfo","d","cipher","createDecipher","start","iv","slice","length","update","createBuffer","finish","decodeUtf8","output","eval","getInj"],"sources":["../../../src/client/getInj.ts"],"sourcesContent":["// Encapsulates retrieval of server-side data injection into HTML template.\n\n/* global document */\n\n// Note: this way, only required part of \"node-forge\": AES, and some utils,\n// is bundled into client-side code.\nimport forge from 'node-forge/lib/forge';\nimport 'node-forge/lib/aes';\n\nimport type { InjT } from 'utils/globalState';\n\nimport { getBuildInfo } from 'utils/isomorphy/buildInfo';\n\n// Safeguard is needed here, because the server-side version of Docusaurus docs\n// is compiled (at least now) with settings suggesting it is a client-side\n// environment, but there is no document.\nlet inj: InjT = {};\n\nconst metaElement: HTMLMetaElement | null = typeof document !== 'undefined'\n ? document.querySelector('meta[itemprop=\"drpruinj\"]') : null;\n\nif (metaElement) {\n metaElement.remove();\n let data = forge.util.decode64(metaElement.content);\n\n const { key } = getBuildInfo();\n const d = forge.cipher.createDecipher('AES-CBC', key);\n d.start({ iv: data.slice(0, key.length) });\n d.update(forge.util.createBuffer(data.slice(key.length)));\n d.finish();\n\n data = forge.util.decodeUtf8(d.output.data);\n inj = eval(`(${data})`); // eslint-disable-line no-eval\n} else {\n // Otherwise, a bunch of dependent stuff will easily fail in non-standard\n // environments, where no client-side initialization is performed. Like tests,\n // Docusaurus examples, etc.\n inj = {};\n}\n\nexport default function getInj(): InjT {\n return inj;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getInj.js","names":["_forge","_interopRequireDefault","require","_buildInfo","inj","metaElement","document","querySelector","remove","data","forge","util","decode64","content","key","getBuildInfo","d","cipher","createDecipher","start","iv","slice","length","update","createBuffer","finish","decodeUtf8","output","eval","getInj","setInj","value"],"sources":["../../../src/client/getInj.ts"],"sourcesContent":["// Encapsulates retrieval of server-side data injection into HTML template.\n\n/* global document */\n\n// Note: this way, only required part of \"node-forge\": AES, and some utils,\n// is bundled into client-side code.\nimport forge from 'node-forge/lib/forge';\nimport 'node-forge/lib/aes';\n\nimport type { InjT } from 'utils/globalState';\n\nimport { getBuildInfo } from 'utils/isomorphy/buildInfo';\n\n// Safeguard is needed here, because the server-side version of Docusaurus docs\n// is compiled (at least now) with settings suggesting it is a client-side\n// environment, but there is no document.\nlet inj: InjT = {};\n\nconst metaElement: HTMLMetaElement | null = typeof document !== 'undefined'\n ? document.querySelector('meta[itemprop=\"drpruinj\"]') : null;\n\nif (metaElement) {\n metaElement.remove();\n let data = forge.util.decode64(metaElement.content);\n\n const { key } = getBuildInfo();\n const d = forge.cipher.createDecipher('AES-CBC', key);\n d.start({ iv: data.slice(0, key.length) });\n d.update(forge.util.createBuffer(data.slice(key.length)));\n d.finish();\n\n data = forge.util.decodeUtf8(d.output.data);\n inj = eval(`(${data})`); // eslint-disable-line no-eval\n} else {\n // Otherwise, a bunch of dependent stuff will easily fail in non-standard\n // environments, where no client-side initialization is performed. Like tests,\n // Docusaurus examples, etc.\n inj = {};\n}\n\nexport default function getInj(): InjT {\n return inj;\n}\n\n/**\n * Allows to set a custom injection object instance,\n * for server-less scenarios, for example, where it is not auto-injected\n * into generated pages from the server side.\n */\nexport function setInj(value: InjT) {\n inj = value;\n}\n"],"mappings":";;;;;;;;AAMA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACAA,OAAA;AAIA,IAAAC,UAAA,GAAAD,OAAA;AAXA;;AAEA;;AAEA;AACA;;AAQA;AACA;AACA;AACA,IAAIE,GAAS,GAAG,CAAC,CAAC;AAElB,MAAMC,WAAmC,GAAG,OAAOC,QAAQ,KAAK,WAAW,GACvEA,QAAQ,CAACC,aAAa,CAAC,2BAA2B,CAAC,GAAG,IAAI;AAE9D,IAAIF,WAAW,EAAE;EACfA,WAAW,CAACG,MAAM,CAAC,CAAC;EACpB,IAAIC,IAAI,GAAGC,cAAK,CAACC,IAAI,CAACC,QAAQ,CAACP,WAAW,CAACQ,OAAO,CAAC;EAEnD,MAAM;IAAEC;EAAI,CAAC,GAAG,IAAAC,uBAAY,EAAC,CAAC;EAC9B,MAAMC,CAAC,GAAGN,cAAK,CAACO,MAAM,CAACC,cAAc,CAAC,SAAS,EAAEJ,GAAG,CAAC;EACrDE,CAAC,CAACG,KAAK,CAAC;IAAEC,EAAE,EAAEX,IAAI,CAACY,KAAK,CAAC,CAAC,EAAEP,GAAG,CAACQ,MAAM;EAAE,CAAC,CAAC;EAC1CN,CAAC,CAACO,MAAM,CAACb,cAAK,CAACC,IAAI,CAACa,YAAY,CAACf,IAAI,CAACY,KAAK,CAACP,GAAG,CAACQ,MAAM,CAAC,CAAC,CAAC;EACzDN,CAAC,CAACS,MAAM,CAAC,CAAC;EAEVhB,IAAI,GAAGC,cAAK,CAACC,IAAI,CAACe,UAAU,CAACV,CAAC,CAACW,MAAM,CAAClB,IAAI,CAAC;EAC3CL,GAAG,GAAGwB,IAAI,CAAC,IAAInB,IAAI,GAAG,CAAC,CAAC,CAAC;AAC3B,CAAC,MAAM;EACL;EACA;EACA;EACAL,GAAG,GAAG,CAAC,CAAC;AACV;AAEe,SAASyB,MAAMA,CAAA,EAAS;EACrC,OAAOzB,GAAG;AACZ;;AAEA;AACA;AACA;AACA;AACA;AACO,SAAS0B,MAAMA,CAACC,KAAW,EAAE;EAClC3B,GAAG,GAAG2B,KAAK;AACb","ignoreList":[]}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = Launch;
|
|
7
|
+
Object.defineProperty(exports, "setInj", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _getInj.setInj;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
8
13
|
require("react");
|
|
9
14
|
var _reactGlobalState = require("@dr.pogodin/react-global-state");
|
|
10
15
|
var _client = require("react-dom/client");
|
|
11
16
|
var _reactRouterDom = require("react-router-dom");
|
|
12
|
-
var _getInj =
|
|
17
|
+
var _getInj = _interopRequireWildcard(require("./getInj"));
|
|
13
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
20
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
21
|
// Initialization of client-side code.
|
|
15
22
|
/* global document */
|
|
16
23
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["require","_reactGlobalState","_client","_reactRouterDom","_getInj","
|
|
1
|
+
{"version":3,"file":"index.js","names":["require","_reactGlobalState","_client","_reactRouterDom","_getInj","_interopRequireWildcard","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Launch","Application","options","arguments","length","undefined","container","document","getElementById","Error","scene","jsx","GlobalStateProvider","initialState","getInj","ISTATE","children","BrowserRouter","future","v7_relativeSplatPath","dontHydrate","root","createRoot","render","hydrateRoot"],"sources":["../../../src/client/index.tsx"],"sourcesContent":["// Initialization of client-side code.\n/* global document */\n\nimport { type ComponentType } from 'react';\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\n\nimport { createRoot, hydrateRoot } from 'react-dom/client';\nimport { BrowserRouter } from 'react-router-dom';\n\nimport getInj, { setInj } from './getInj';\n\ntype OptionsT = {\n dontHydrate?: boolean;\n initialState?: any;\n};\n\nexport { setInj };\n\n/**\n * Prepares and launches the app at client side.\n * @param Application Root application component\n * @param [options={}] Optional. Additional settings.\n */\nexport default function Launch(\n Application: ComponentType,\n options: OptionsT = {},\n) {\n const container = document.getElementById('react-view');\n if (!container) throw Error('Failed to find container for React app');\n const scene = (\n <GlobalStateProvider initialState={getInj().ISTATE || options.initialState}>\n <BrowserRouter future={{ v7_relativeSplatPath: true }}>\n <Application />\n </BrowserRouter>\n </GlobalStateProvider>\n );\n\n if (options.dontHydrate) {\n const root = createRoot(container);\n root.render(scene);\n } else hydrateRoot(container, scene);\n}\n"],"mappings":";;;;;;;;;;;;AAGAA,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAC,uBAAA,CAAAL,OAAA;AAA0C,IAAAM,WAAA,GAAAN,OAAA;AAAA,SAAAO,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,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eACzE,IAAArC,WAAA,CAAAgC,GAAA,EAACnC,eAAA,CAAAyC,aAAa;MAACC,MAAM,EAAE;QAAEC,oBAAoB,EAAE;MAAK,CAAE;MAAAH,QAAA,eACpD,IAAArC,WAAA,CAAAgC,GAAA,EAACV,WAAW,IAAE;IAAC,CACF;EAAC,CACG,CACtB;EAED,IAAIC,OAAO,CAACkB,WAAW,EAAE;IACvB,MAAMC,IAAI,GAAG,IAAAC,kBAAU,EAAChB,SAAS,CAAC;IAClCe,IAAI,CAACE,MAAM,CAACb,KAAK,CAAC;EACpB,CAAC,MAAM,IAAAc,mBAAW,EAAClB,SAAS,EAAEI,KAAK,CAAC;AACtC","ignoreList":[]}
|
|
@@ -172,5 +172,13 @@ Object.keys(_components).forEach(function (key) {
|
|
|
172
172
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
173
173
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
174
174
|
const server = exports.server = _utils.webpack.requireWeak("./server", __dirname);
|
|
175
|
-
|
|
175
|
+
|
|
176
|
+
// TODO: Should be done in a cleaner way, but technically it is fine
|
|
177
|
+
// for this scenario.
|
|
178
|
+
// eslint-disable-next-line import/no-mutable-exports
|
|
179
|
+
let client = exports.client = server ? undefined : require("./client");
|
|
180
|
+
if (client) {
|
|
181
|
+
client.default.setInj = client.setInj;
|
|
182
|
+
exports.client = client = client.default;
|
|
183
|
+
}
|
|
176
184
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_utils","require","_axios","_interopRequireDefault","_PT","_interopRequireWildcard","exports","PT","_reactGlobalState","_components","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","defineProperty","enumerable","get","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set","server","webpack","requireWeak","__dirname","client","undefined"],"sources":["../../src/index.ts"],"sourcesContent":["import 'styles/global.scss';\n\nimport { webpack } from 'utils';\n\nimport type ServerT from './server';\n\nconst server = webpack.requireWeak('./server', __dirname) as (typeof ServerT) | null;\n\
|
|
1
|
+
{"version":3,"file":"index.js","names":["_utils","require","_axios","_interopRequireDefault","_PT","_interopRequireWildcard","exports","PT","_reactGlobalState","_components","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","defineProperty","enumerable","get","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set","server","webpack","requireWeak","__dirname","client","undefined","setInj"],"sources":["../../src/index.ts"],"sourcesContent":["import 'styles/global.scss';\n\nimport { webpack } from 'utils';\n\nimport type ServerT from './server';\n\nconst server = webpack.requireWeak('./server', __dirname) as (typeof ServerT) | null;\n\n// TODO: Should be done in a cleaner way, but technically it is fine\n// for this scenario.\n// eslint-disable-next-line import/no-mutable-exports\nlet client = server ? undefined : require('./client');\n\nif (client) {\n client.default.setInj = client.setInj;\n client = client.default;\n}\n\nexport { default as api } from 'axios';\nexport * as PT from 'prop-types';\n\nexport {\n type AsyncCollectionLoaderT,\n type AsyncDataEnvelopeT,\n type AsyncDataLoaderT,\n type ForceT,\n type UseAsyncDataOptionsT,\n type UseAsyncDataResT,\n type UseGlobalStateResT,\n type ValueOrInitializerT,\n getGlobalState,\n GlobalStateProvider,\n newAsyncDataEnvelope,\n useAsyncCollection,\n useAsyncData,\n useGlobalState,\n withGlobalStateType,\n} from '@dr.pogodin/react-global-state';\n\nexport * from 'components';\n\nexport {\n type Listener,\n type Theme,\n config,\n Barrier,\n Emitter,\n isomorphy,\n getSsrContext,\n Semaphore,\n splitComponent,\n themed,\n ThemeProvider,\n time,\n webpack,\n withRetries,\n} from 'utils';\n\nexport { client, server };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAgBA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAuC,IAAAG,GAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAAAK,OAAA,CAAAC,EAAA,GAAAH,GAAA;AAGvC,IAAAI,iBAAA,GAAAP,OAAA;AAkBA,IAAAQ,WAAA,GAAAR,OAAA;AAAAS,MAAA,CAAAC,IAAA,CAAAF,WAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAP,OAAA,IAAAA,OAAA,CAAAO,GAAA,MAAAJ,WAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAQ,cAAA,CAAAZ,OAAA,EAAAO,GAAA;IAAAM,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAX,WAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAA2B,SAAAQ,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAA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AAA,GAAAA,MAAM,GAAGA,MAAM,CAACb,OAAO;AACzB","ignoreList":[]}
|
|
@@ -16,14 +16,20 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
16
16
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
17
17
|
/* global document */
|
|
18
18
|
|
|
19
|
-
//
|
|
20
|
-
//
|
|
19
|
+
// NOTE: At the client-side we get chunk groups the first time they are needed
|
|
20
|
+
// (we used to get them eagerly when this module loaded, but it did not work well
|
|
21
|
+
// alongside custom chunk info injection in server-less scenario);
|
|
22
|
+
// at the server-side we only can get them within React render flow.
|
|
21
23
|
// Thus, we set and use the following variable at the client-side, and then when
|
|
22
24
|
// needed on the server side, we'll fetch it differently.
|
|
23
|
-
let
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
let cachedClientChunkGroups;
|
|
26
|
+
function getClientChunkGroups() {
|
|
27
|
+
if (_isomorphy.IS_CLIENT_SIDE && !cachedClientChunkGroups) {
|
|
28
|
+
// eslint-disable-next-line global-require
|
|
29
|
+
cachedClientChunkGroups = require("../../client/getInj").default().CHUNK_GROUPS || {};
|
|
30
|
+
}
|
|
31
|
+
if (!cachedClientChunkGroups) throw Error('Internal error');
|
|
32
|
+
return cachedClientChunkGroups;
|
|
27
33
|
}
|
|
28
34
|
const refCounts = {};
|
|
29
35
|
function getPublicPath() {
|
|
@@ -145,7 +151,7 @@ function splitComponent({
|
|
|
145
151
|
placeholder
|
|
146
152
|
}) {
|
|
147
153
|
// On the client side we can check right away if the chunk name is known.
|
|
148
|
-
if (_isomorphy.IS_CLIENT_SIDE) assertChunkName(chunkName,
|
|
154
|
+
if (_isomorphy.IS_CLIENT_SIDE) assertChunkName(chunkName, getClientChunkGroups());
|
|
149
155
|
|
|
150
156
|
// The correct usage of splitComponent() assumes a single call per chunk.
|
|
151
157
|
if (usedChunkNames.has(chunkName)) {
|
|
@@ -159,7 +165,7 @@ function splitComponent({
|
|
|
159
165
|
// the component (the lazy load function is executed by React one at
|
|
160
166
|
// the frist mount).
|
|
161
167
|
if (_isomorphy.IS_CLIENT_SIDE) {
|
|
162
|
-
await bookStyleSheets(chunkName,
|
|
168
|
+
await bookStyleSheets(chunkName, getClientChunkGroups(), false);
|
|
163
169
|
}
|
|
164
170
|
const Wrapper = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
165
171
|
children,
|
|
@@ -179,8 +185,8 @@ function splitComponent({
|
|
|
179
185
|
// This takes care about stylesheets management every time an instance of
|
|
180
186
|
// this component is mounted / unmounted.
|
|
181
187
|
(0, _react.useInsertionEffect)(() => {
|
|
182
|
-
bookStyleSheets(chunkName,
|
|
183
|
-
return () => freeStyleSheets(chunkName,
|
|
188
|
+
bookStyleSheets(chunkName, getClientChunkGroups(), true);
|
|
189
|
+
return () => freeStyleSheets(chunkName, getClientChunkGroups());
|
|
184
190
|
}, []);
|
|
185
191
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
186
192
|
ref: ref,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"splitComponent.js","names":["_propTypes","_interopRequireDefault","require","_react","_jsUtils","_globalState","_isomorphy","_jsxRuntime","clientChunkGroups","IS_CLIENT_SIDE","default","CHUNK_GROUPS","refCounts","getPublicPath","getBuildInfo","publicPath","bookStyleSheet","name","loadedSheets","refCount","res","path","fullPath","document","location","origin","has","link","querySelector","createElement","setAttribute","head","appendChild","Barrier","addEventListener","resolve","current","getLoadedStyleSheets","Set","styleSheets","i","length","href","add","assertChunkName","chunkName","chunkGroups","Error","bookStyleSheets","promises","assets","asset","endsWith","promise","push","Promise","allSettled","then","freeStyleSheets","remove","usedChunkNames","splitComponent","getComponent","placeholder","LazyComponent","lazy","resolved","Component","Wrapper","forwardRef","children","rest","ref","IS_SERVER_SIDE","chunks","getSsrContext","includes","useInsertionEffect","jsx","CodeSplit","Suspense","fallback","propTypes","PT","node"],"sources":["../../../../src/shared/utils/splitComponent.tsx"],"sourcesContent":["/* eslint-disable react/jsx-props-no-spreading */\n/* global document */\n\nimport PT from 'prop-types';\n\nimport {\n type ComponentType,\n type ReactNode,\n forwardRef,\n lazy,\n Suspense,\n useInsertionEffect,\n} from 'react';\n\nimport { Barrier } from '@dr.pogodin/js-utils';\n\nimport { type ChunkGroupsT, getSsrContext } from './globalState';\n\nimport {\n IS_CLIENT_SIDE,\n IS_SERVER_SIDE,\n getBuildInfo,\n} from './isomorphy';\n\n// Note: At the client side we can get chunk groups immediately when loading\n// the module; at the server-side we only can get them within React render flow.\n// Thus, we set and use the following variable at the client-side, and then when\n// needed on the server side, we'll fetch it differently.\nlet clientChunkGroups: ChunkGroupsT;\n\nif (IS_CLIENT_SIDE) {\n // eslint-disable-next-line global-require\n clientChunkGroups = require('client/getInj').default().CHUNK_GROUPS || {};\n}\n\nconst refCounts: { [path: 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', () => res!.resolve());\n link.addEventListener('error', () => res!.resolve());\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 (let i = 0; i < styleSheets.length; ++i) {\n const { href } = styleSheets[i];\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 function bookStyleSheets(\n chunkName: string,\n chunkGroups: ChunkGroupsT,\n refCount: boolean,\n): Promise<void> {\n const promises = [];\n const assets = chunkGroups[chunkName];\n const loadedSheets = getLoadedStyleSheets();\n\n for (let i = 0; i < assets.length; ++i) {\n const asset = assets[i];\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) {\n const assets = chunkGroups[chunkName];\n for (let i = 0; i < assets.length; ++i) {\n const asset = assets[i];\n if (asset.endsWith('.css')) {\n const path = `${getPublicPath()}/${asset}`;\n if (--refCounts[path] <= 0) {\n document.head.querySelector(`link[href=\"${path}\"]`)!.remove();\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\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 { children?: ReactNode },\n>({\n chunkName,\n getComponent,\n placeholder,\n}: {\n chunkName: string;\n getComponent: () => Promise<ComponentOrModule<ComponentPropsT>>,\n placeholder?: ReactNode,\n}) {\n // On the client side we can check right away if the chunk name is known.\n if (IS_CLIENT_SIDE) assertChunkName(chunkName, clientChunkGroups);\n\n // The correct usage of splitComponent() assumes a single call per chunk.\n if (usedChunkNames.has(chunkName)) {\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 await bookStyleSheets(chunkName, clientChunkGroups, false);\n }\n\n const Wrapper = forwardRef((\n { children, ...rest }: ComponentPropsT,\n ref,\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 const { chunkGroups, chunks } = getSsrContext()!;\n assertChunkName(chunkName, chunkGroups);\n if (!chunks.includes(chunkName)) chunks.push(chunkName);\n }\n\n // This takes care about stylesheets management every time an instance of\n // this component is mounted / unmounted.\n useInsertionEffect(() => {\n bookStyleSheets(chunkName, clientChunkGroups, true);\n return () => freeStyleSheets(chunkName, clientChunkGroups);\n }, []);\n\n return (\n <Component ref={ref} {...rest as ComponentPropsT}>\n {children}\n </Component>\n );\n });\n\n return { default: Wrapper };\n });\n\n const CodeSplit: React.FunctionComponent<ComponentPropsT> = ({\n children,\n ...rest\n }: ComponentPropsT) => (\n <Suspense fallback={placeholder}>\n <LazyComponent {...rest as Parameters<typeof LazyComponent>[0]}>\n {children}\n </LazyComponent>\n </Suspense>\n );\n\n CodeSplit.prop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AAMkD,eAAe,CAACb,SAAS,EAAErC,iBAAiB,CAAC;MAC5D,CAAC,EAAE,EAAE,CAAC;MAEN,oBACE,IAAAD,WAAA,CAAAuE,GAAA,EAACX,SAAS;QAACK,GAAG,EAAEA,GAAI;QAAA,GAAKD,IAAI;QAAAD,QAAA,EAC1BA;MAAQ,CACA,CAAC;IAEhB,CAAC,CAAC;IAEF,OAAO;MAAE5D,OAAO,EAAE0D;IAAQ,CAAC;EAC7B,CAAC,CAAC;EAEF,MAAMW,SAAmD,GAAGA,CAAC;IAC3DT,QAAQ;IACR,GAAGC;EACY,CAAC,kBAChB,IAAAhE,WAAA,CAAAuE,GAAA,EAAC3E,MAAA,CAAA6E,QAAQ;IAACC,QAAQ,EAAElB,WAAY;IAAAO,QAAA,eAC9B,IAAA/D,WAAA,CAAAuE,GAAA,EAACd,aAAa;MAAA,GAAKO,IAAI;MAAAD,QAAA,EACpBA;IAAQ,CACI;EAAC,CACR,CACX;EAEDS,SAAS,CAACG,SAAS,GAAG;IACpBZ,QAAQ,EAAEa,kBAAE,CAACC;EACf,CAA0C;EAE1C,OAAOL,SAAS;AAClB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"splitComponent.js","names":["_propTypes","_interopRequireDefault","require","_react","_jsUtils","_globalState","_isomorphy","_jsxRuntime","cachedClientChunkGroups","getClientChunkGroups","IS_CLIENT_SIDE","default","CHUNK_GROUPS","Error","refCounts","getPublicPath","getBuildInfo","publicPath","bookStyleSheet","name","loadedSheets","refCount","res","path","fullPath","document","location","origin","has","link","querySelector","createElement","setAttribute","head","appendChild","Barrier","addEventListener","resolve","current","getLoadedStyleSheets","Set","styleSheets","i","length","href","add","assertChunkName","chunkName","chunkGroups","bookStyleSheets","promises","assets","asset","endsWith","promise","push","Promise","allSettled","then","freeStyleSheets","remove","usedChunkNames","splitComponent","getComponent","placeholder","LazyComponent","lazy","resolved","Component","Wrapper","forwardRef","children","rest","ref","IS_SERVER_SIDE","chunks","getSsrContext","includes","useInsertionEffect","jsx","CodeSplit","Suspense","fallback","propTypes","PT","node"],"sources":["../../../../src/shared/utils/splitComponent.tsx"],"sourcesContent":["/* eslint-disable react/jsx-props-no-spreading */\n/* global document */\n\nimport PT from 'prop-types';\n\nimport {\n type ComponentType,\n type ReactNode,\n forwardRef,\n lazy,\n Suspense,\n useInsertionEffect,\n} from 'react';\n\nimport { Barrier } from '@dr.pogodin/js-utils';\n\nimport { type ChunkGroupsT, getSsrContext } from './globalState';\n\nimport {\n IS_CLIENT_SIDE,\n IS_SERVER_SIDE,\n getBuildInfo,\n} from './isomorphy';\n\n// NOTE: At the client-side we get chunk groups the first time they are needed\n// (we used to get them eagerly when this module loaded, but it did not work well\n// alongside custom chunk info injection in server-less scenario);\n// at the server-side we only can get them within React render flow.\n// Thus, we set and use the following variable at the client-side, and then when\n// needed on the server side, we'll fetch it differently.\nlet cachedClientChunkGroups: ChunkGroupsT | undefined;\n\nfunction getClientChunkGroups(): ChunkGroupsT {\n if (IS_CLIENT_SIDE && !cachedClientChunkGroups) {\n // eslint-disable-next-line global-require\n cachedClientChunkGroups = require('client/getInj').default().CHUNK_GROUPS || {};\n }\n\n if (!cachedClientChunkGroups) throw Error('Internal error');\n\n return cachedClientChunkGroups;\n}\n\nconst refCounts: { [path: 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', () => res!.resolve());\n link.addEventListener('error', () => res!.resolve());\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 (let i = 0; i < styleSheets.length; ++i) {\n const { href } = styleSheets[i];\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 function bookStyleSheets(\n chunkName: string,\n chunkGroups: ChunkGroupsT,\n refCount: boolean,\n): Promise<void> {\n const promises = [];\n const assets = chunkGroups[chunkName];\n const loadedSheets = getLoadedStyleSheets();\n\n for (let i = 0; i < assets.length; ++i) {\n const asset = assets[i];\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) {\n const assets = chunkGroups[chunkName];\n for (let i = 0; i < assets.length; ++i) {\n const asset = assets[i];\n if (asset.endsWith('.css')) {\n const path = `${getPublicPath()}/${asset}`;\n if (--refCounts[path] <= 0) {\n document.head.querySelector(`link[href=\"${path}\"]`)!.remove();\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\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 { children?: ReactNode },\n>({\n chunkName,\n getComponent,\n placeholder,\n}: {\n chunkName: string;\n getComponent: () => Promise<ComponentOrModule<ComponentPropsT>>,\n placeholder?: ReactNode,\n}) {\n // On the client side we can check right away if the chunk name is known.\n if (IS_CLIENT_SIDE) assertChunkName(chunkName, getClientChunkGroups());\n\n // The correct usage of splitComponent() assumes a single call per chunk.\n if (usedChunkNames.has(chunkName)) {\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 await bookStyleSheets(chunkName, getClientChunkGroups(), false);\n }\n\n const Wrapper = forwardRef((\n { children, ...rest }: ComponentPropsT,\n ref,\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 const { chunkGroups, chunks } = getSsrContext()!;\n assertChunkName(chunkName, chunkGroups);\n if (!chunks.includes(chunkName)) chunks.push(chunkName);\n }\n\n // This takes care about stylesheets management every time an instance of\n // this component is mounted / unmounted.\n useInsertionEffect(() => {\n bookStyleSheets(chunkName, getClientChunkGroups(), true);\n return () => freeStyleSheets(chunkName, getClientChunkGroups());\n }, []);\n\n return (\n <Component ref={ref} {...rest as ComponentPropsT}>\n {children}\n </Component>\n );\n });\n\n return { default: Wrapper };\n });\n\n const CodeSplit: React.FunctionComponent<ComponentPropsT> = ({\n children,\n ...rest\n }: ComponentPropsT) => (\n <Suspense fallback={placeholder}>\n <LazyComponent {...rest as Parameters<typeof LazyComponent>[0]}>\n {children}\n </LazyComponent>\n </Suspense>\n );\n\n CodeSplit.propTypes = {\n children: PT.node,\n } as PT.WeakValidationMap<ComponentPropsT>;\n\n return CodeSplit;\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AASA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAH,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AAIqB,IAAAK,WAAA,GAAAL,OAAA;AAtBrB;AACA;;AAuBA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIM,uBAAiD;AAErD,SAASC,oBAAoBA,CAAA,EAAiB;EAC5C,IAAIC,yBAAc,IAAI,CAACF,uBAAuB,EAAE;IAC9C;IACAA,uBAAuB,GAAGN,OAAO,sBAAgB,CAAC,CAACS,OAAO,CAAC,CAAC,CAACC,YAAY,IAAI,CAAC,CAAC;EACjF;EAEA,IAAI,CAACJ,uBAAuB,EAAE,MAAMK,KAAK,CAAC,gBAAgB,CAAC;EAE3D,OAAOL,uBAAuB;AAChC;AAEA,MAAMM,SAAqC,GAAG,CAAC,CAAC;AAEhD,SAASC,aAAaA,CAAA,EAAG;EACvB,OAAO,IAAAC,uBAAY,EAAC,CAAC,CAACC,UAAU;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,cAAcA,CACrBC,IAAY,EACZC,YAAyB,EACzBC,QAAiB,EACU;EAC3B,IAAIC,GAA8B;EAClC,MAAMC,IAAI,GAAG,GAAGR,aAAa,CA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return /******/ (function() { // webpackBootstrap
|
|
|
26
26
|
\******************************/
|
|
27
27
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
28
28
|
|
|
29
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": function() { return /* binding */ getInj; }\n/* harmony export */ });\n/* harmony import */ var node_forge_lib_forge__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node-forge/lib/forge */ \"node-forge/lib/forge\");\n/* harmony import */ var node_forge_lib_forge__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(node_forge_lib_forge__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var node_forge_lib_aes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! node-forge/lib/aes */ \"node-forge/lib/aes\");\n/* harmony import */ var node_forge_lib_aes__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(node_forge_lib_aes__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _shared_utils_isomorphy_buildInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../shared/utils/isomorphy/buildInfo */ \"./src/shared/utils/isomorphy/buildInfo.ts\");\n// Encapsulates retrieval of server-side data injection into HTML template.\n\n/* global document */\n\n// Note: this way, only required part of \"node-forge\": AES, and some utils,\n// is bundled into client-side code.\n\n\n\n\n// Safeguard is needed here, because the server-side version of Docusaurus docs\n// is compiled (at least now) with settings suggesting it is a client-side\n// environment, but there is no document.\nlet inj = {};\nconst metaElement = typeof document !== 'undefined' ? document.querySelector('meta[itemprop=\"drpruinj\"]') : null;\nif (metaElement) {\n metaElement.remove();\n let data = node_forge_lib_forge__WEBPACK_IMPORTED_MODULE_0___default().util.decode64(metaElement.content);\n const {\n key\n } = (0,_shared_utils_isomorphy_buildInfo__WEBPACK_IMPORTED_MODULE_2__.getBuildInfo)();\n const d = node_forge_lib_forge__WEBPACK_IMPORTED_MODULE_0___default().cipher.createDecipher('AES-CBC', key);\n d.start({\n iv: data.slice(0, key.length)\n });\n d.update(node_forge_lib_forge__WEBPACK_IMPORTED_MODULE_0___default().util.createBuffer(data.slice(key.length)));\n d.finish();\n data = node_forge_lib_forge__WEBPACK_IMPORTED_MODULE_0___default().util.decodeUtf8(d.output.data);\n inj = eval(`(${data})`); // eslint-disable-line no-eval\n} else {\n // Otherwise, a bunch of dependent stuff will easily fail in non-standard\n // environments, where no client-side initialization is performed. Like tests,\n // Docusaurus examples, etc.\n inj = {};\n}\nfunction getInj() {\n return inj;\n}\n\n//# sourceURL=webpack://@dr.pogodin/react-utils/./src/client/getInj.ts?");
|
|
29
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": function() { return /* binding */ getInj; },\n/* harmony export */ setInj: function() { return /* binding */ setInj; }\n/* harmony export */ });\n/* harmony import */ var node_forge_lib_forge__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node-forge/lib/forge */ \"node-forge/lib/forge\");\n/* harmony import */ var node_forge_lib_forge__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(node_forge_lib_forge__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var node_forge_lib_aes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! node-forge/lib/aes */ \"node-forge/lib/aes\");\n/* harmony import */ var node_forge_lib_aes__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(node_forge_lib_aes__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _shared_utils_isomorphy_buildInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../shared/utils/isomorphy/buildInfo */ \"./src/shared/utils/isomorphy/buildInfo.ts\");\n// Encapsulates retrieval of server-side data injection into HTML template.\n\n/* global document */\n\n// Note: this way, only required part of \"node-forge\": AES, and some utils,\n// is bundled into client-side code.\n\n\n\n\n// Safeguard is needed here, because the server-side version of Docusaurus docs\n// is compiled (at least now) with settings suggesting it is a client-side\n// environment, but there is no document.\nlet inj = {};\nconst metaElement = typeof document !== 'undefined' ? document.querySelector('meta[itemprop=\"drpruinj\"]') : null;\nif (metaElement) {\n metaElement.remove();\n let data = node_forge_lib_forge__WEBPACK_IMPORTED_MODULE_0___default().util.decode64(metaElement.content);\n const {\n key\n } = (0,_shared_utils_isomorphy_buildInfo__WEBPACK_IMPORTED_MODULE_2__.getBuildInfo)();\n const d = node_forge_lib_forge__WEBPACK_IMPORTED_MODULE_0___default().cipher.createDecipher('AES-CBC', key);\n d.start({\n iv: data.slice(0, key.length)\n });\n d.update(node_forge_lib_forge__WEBPACK_IMPORTED_MODULE_0___default().util.createBuffer(data.slice(key.length)));\n d.finish();\n data = node_forge_lib_forge__WEBPACK_IMPORTED_MODULE_0___default().util.decodeUtf8(d.output.data);\n inj = eval(`(${data})`); // eslint-disable-line no-eval\n} else {\n // Otherwise, a bunch of dependent stuff will easily fail in non-standard\n // environments, where no client-side initialization is performed. Like tests,\n // Docusaurus examples, etc.\n inj = {};\n}\nfunction getInj() {\n return inj;\n}\n\n/**\n * Allows to set a custom injection object instance,\n * for server-less scenarios, for example, where it is not auto-injected\n * into generated pages from the server side.\n */\nfunction setInj(value) {\n inj = value;\n}\n\n//# sourceURL=webpack://@dr.pogodin/react-utils/./src/client/getInj.ts?");
|
|
30
30
|
|
|
31
31
|
/***/ }),
|
|
32
32
|
|
|
@@ -36,7 +36,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
36
36
|
\******************************/
|
|
37
37
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
38
38
|
|
|
39
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": function() { return /* binding */ Launch; }\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @dr.pogodin/react-global-state */ \"@dr.pogodin/react-global-state\");\n/* harmony import */ var _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var react_dom_client__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-dom/client */ \"react-dom/client\");\n/* harmony import */ var react_dom_client__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_dom_client__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-router-dom */ \"react-router-dom\");\n/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _getInj__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./getInj */ \"./src/client/getInj.ts\");\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\n// Initialization of client-side code.\n/* global document */\n\n\n\n\n\n\n\n/**\n * Prepares and launches the app at client side.\n * @param Application Root application component\n * @param [options={}] Optional. Additional settings.\n */\nfunction Launch(Application) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n const container = document.getElementById('react-view');\n if (!container) throw Error('Failed to find container for React app');\n const scene = /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_1__.GlobalStateProvider, {\n initialState: (0,_getInj__WEBPACK_IMPORTED_MODULE_4__[\"default\"])().ISTATE || options.initialState,\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(react_router_dom__WEBPACK_IMPORTED_MODULE_3__.BrowserRouter, {\n future: {\n v7_relativeSplatPath: true\n },\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(Application, {})\n })\n });\n if (options.dontHydrate) {\n const root = (0,react_dom_client__WEBPACK_IMPORTED_MODULE_2__.createRoot)(container);\n root.render(scene);\n } else (0,react_dom_client__WEBPACK_IMPORTED_MODULE_2__.hydrateRoot)(container, scene);\n}\n\n//# sourceURL=webpack://@dr.pogodin/react-utils/./src/client/index.tsx?");
|
|
39
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": function() { return /* binding */ Launch; },\n/* harmony export */ setInj: function() { return /* reexport safe */ _getInj__WEBPACK_IMPORTED_MODULE_4__.setInj; }\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @dr.pogodin/react-global-state */ \"@dr.pogodin/react-global-state\");\n/* harmony import */ var _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var react_dom_client__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-dom/client */ \"react-dom/client\");\n/* harmony import */ var react_dom_client__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_dom_client__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-router-dom */ \"react-router-dom\");\n/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _getInj__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./getInj */ \"./src/client/getInj.ts\");\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\n// Initialization of client-side code.\n/* global document */\n\n\n\n\n\n\n\n\n\n/**\n * Prepares and launches the app at client side.\n * @param Application Root application component\n * @param [options={}] Optional. Additional settings.\n */\nfunction Launch(Application) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n const container = document.getElementById('react-view');\n if (!container) throw Error('Failed to find container for React app');\n const scene = /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_1__.GlobalStateProvider, {\n initialState: (0,_getInj__WEBPACK_IMPORTED_MODULE_4__[\"default\"])().ISTATE || options.initialState,\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(react_router_dom__WEBPACK_IMPORTED_MODULE_3__.BrowserRouter, {\n future: {\n v7_relativeSplatPath: true\n },\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(Application, {})\n })\n });\n if (options.dontHydrate) {\n const root = (0,react_dom_client__WEBPACK_IMPORTED_MODULE_2__.createRoot)(container);\n root.render(scene);\n } else (0,react_dom_client__WEBPACK_IMPORTED_MODULE_2__.hydrateRoot)(container, scene);\n}\n\n//# sourceURL=webpack://@dr.pogodin/react-utils/./src/client/index.tsx?");
|
|
40
40
|
|
|
41
41
|
/***/ }),
|
|
42
42
|
|
|
@@ -46,7 +46,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
46
46
|
\**********************/
|
|
47
47
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
48
48
|
|
|
49
|
-
eval("var __dirname = \"/\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Barrier: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.Barrier; },\n/* harmony export */ BaseButton: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.BaseButton; },\n/* harmony export */ BaseModal: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.BaseModal; },\n/* harmony export */ Button: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Button; },\n/* harmony export */ Checkbox: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Checkbox; },\n/* harmony export */ CustomDropdown: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.CustomDropdown; },\n/* harmony export */ Dropdown: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Dropdown; },\n/* harmony export */ Emitter: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.Emitter; },\n/* harmony export */ GlobalStateProvider: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.GlobalStateProvider; },\n/* harmony export */ Input: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Input; },\n/* harmony export */ Link: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Link; },\n/* harmony export */ MetaTags: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.MetaTags; },\n/* harmony export */ Modal: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Modal; },\n/* harmony export */ NavLink: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.NavLink; },\n/* harmony export */ PT: function() { return /* reexport module object */ prop_types__WEBPACK_IMPORTED_MODULE_3__; },\n/* harmony export */ PageLayout: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.PageLayout; },\n/* harmony export */ Semaphore: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.Semaphore; },\n/* harmony export */ Switch: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Switch; },\n/* harmony export */ TextArea: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.TextArea; },\n/* harmony export */ ThemeProvider: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.ThemeProvider; },\n/* harmony export */ Throbber: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Throbber; },\n/* harmony export */ WithTooltip: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.WithTooltip; },\n/* harmony export */ YouTubeVideo: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.YouTubeVideo; },\n/* harmony export */ api: function() { return /* reexport default from dynamic */ axios__WEBPACK_IMPORTED_MODULE_2___default.a; },\n/* harmony export */ client: function() { return /* binding */ client; },\n/* harmony export */ config: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.config; },\n/* harmony export */ getGlobalState: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.getGlobalState; },\n/* harmony export */ getSsrContext: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.getSsrContext; },\n/* harmony export */ isomorphy: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.isomorphy; },\n/* harmony export */ newAsyncDataEnvelope: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.newAsyncDataEnvelope; },\n/* harmony export */ optionValidator: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.optionValidator; },\n/* harmony export */ optionsValidator: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.optionsValidator; },\n/* harmony export */ server: function() { return /* binding */ server; },\n/* harmony export */ splitComponent: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.splitComponent; },\n/* harmony export */ themed: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.themed; },\n/* harmony export */ time: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.time; },\n/* harmony export */ useAsyncCollection: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.useAsyncCollection; },\n/* harmony export */ useAsyncData: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.useAsyncData; },\n/* harmony export */ useGlobalState: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.useGlobalState; },\n/* harmony export */ webpack: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.webpack; },\n/* harmony export */ withGlobalStateType: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.withGlobalStateType; },\n/* harmony export */ withRetries: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.withRetries; }\n/* harmony export */ });\n/* harmony import */ var _styles_global_scss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./styles/global.scss */ \"./src/styles/global.scss\");\n/* harmony import */ var _shared_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shared/utils */ \"./src/shared/utils/index.ts\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! axios */ \"axios\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! prop-types */ \"prop-types\");\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @dr.pogodin/react-global-state */ \"@dr.pogodin/react-global-state\");\n/* harmony import */ var _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _shared_components__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shared/components */ \"./src/shared/components/index.ts\");\n\n\nconst server = _shared_utils__WEBPACK_IMPORTED_MODULE_1__.webpack.requireWeak('./server', __dirname);\
|
|
49
|
+
eval("var __dirname = \"/\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Barrier: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.Barrier; },\n/* harmony export */ BaseButton: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.BaseButton; },\n/* harmony export */ BaseModal: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.BaseModal; },\n/* harmony export */ Button: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Button; },\n/* harmony export */ Checkbox: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Checkbox; },\n/* harmony export */ CustomDropdown: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.CustomDropdown; },\n/* harmony export */ Dropdown: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Dropdown; },\n/* harmony export */ Emitter: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.Emitter; },\n/* harmony export */ GlobalStateProvider: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.GlobalStateProvider; },\n/* harmony export */ Input: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Input; },\n/* harmony export */ Link: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Link; },\n/* harmony export */ MetaTags: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.MetaTags; },\n/* harmony export */ Modal: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Modal; },\n/* harmony export */ NavLink: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.NavLink; },\n/* harmony export */ PT: function() { return /* reexport module object */ prop_types__WEBPACK_IMPORTED_MODULE_3__; },\n/* harmony export */ PageLayout: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.PageLayout; },\n/* harmony export */ Semaphore: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.Semaphore; },\n/* harmony export */ Switch: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Switch; },\n/* harmony export */ TextArea: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.TextArea; },\n/* harmony export */ ThemeProvider: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.ThemeProvider; },\n/* harmony export */ Throbber: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.Throbber; },\n/* harmony export */ WithTooltip: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.WithTooltip; },\n/* harmony export */ YouTubeVideo: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.YouTubeVideo; },\n/* harmony export */ api: function() { return /* reexport default from dynamic */ axios__WEBPACK_IMPORTED_MODULE_2___default.a; },\n/* harmony export */ client: function() { return /* binding */ client; },\n/* harmony export */ config: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.config; },\n/* harmony export */ getGlobalState: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.getGlobalState; },\n/* harmony export */ getSsrContext: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.getSsrContext; },\n/* harmony export */ isomorphy: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.isomorphy; },\n/* harmony export */ newAsyncDataEnvelope: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.newAsyncDataEnvelope; },\n/* harmony export */ optionValidator: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.optionValidator; },\n/* harmony export */ optionsValidator: function() { return /* reexport safe */ _shared_components__WEBPACK_IMPORTED_MODULE_5__.optionsValidator; },\n/* harmony export */ server: function() { return /* binding */ server; },\n/* harmony export */ splitComponent: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.splitComponent; },\n/* harmony export */ themed: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.themed; },\n/* harmony export */ time: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.time; },\n/* harmony export */ useAsyncCollection: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.useAsyncCollection; },\n/* harmony export */ useAsyncData: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.useAsyncData; },\n/* harmony export */ useGlobalState: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.useGlobalState; },\n/* harmony export */ webpack: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.webpack; },\n/* harmony export */ withGlobalStateType: function() { return /* reexport safe */ _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__.withGlobalStateType; },\n/* harmony export */ withRetries: function() { return /* reexport safe */ _shared_utils__WEBPACK_IMPORTED_MODULE_1__.withRetries; }\n/* harmony export */ });\n/* harmony import */ var _styles_global_scss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./styles/global.scss */ \"./src/styles/global.scss\");\n/* harmony import */ var _shared_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shared/utils */ \"./src/shared/utils/index.ts\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! axios */ \"axios\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! prop-types */ \"prop-types\");\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @dr.pogodin/react-global-state */ \"@dr.pogodin/react-global-state\");\n/* harmony import */ var _dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_dr_pogodin_react_global_state__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _shared_components__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shared/components */ \"./src/shared/components/index.ts\");\n\n\nconst server = _shared_utils__WEBPACK_IMPORTED_MODULE_1__.webpack.requireWeak('./server', __dirname);\n\n// TODO: Should be done in a cleaner way, but technically it is fine\n// for this scenario.\n// eslint-disable-next-line import/no-mutable-exports\nlet client = server ? undefined : __webpack_require__(/*! ./client */ \"./src/client/index.tsx\");\nif (client) {\n client.default.setInj = client.setInj;\n client = client.default;\n}\n\n\n\n\n\n\n\n\n//# sourceURL=webpack://@dr.pogodin/react-utils/./src/index.ts?");
|
|
50
50
|
|
|
51
51
|
/***/ }),
|
|
52
52
|
|
|
@@ -326,7 +326,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
326
326
|
\*********************************************/
|
|
327
327
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
328
328
|
|
|
329
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ bookStyleSheets: function() { return /* binding */ bookStyleSheets; },\n/* harmony export */ \"default\": function() { return /* binding */ splitComponent; },\n/* harmony export */ freeStyleSheets: function() { return /* binding */ freeStyleSheets; }\n/* harmony export */ });\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! prop-types */ \"prop-types\");\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @dr.pogodin/js-utils */ \"@dr.pogodin/js-utils\");\n/* harmony import */ var _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _globalState__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./globalState */ \"./src/shared/utils/globalState.ts\");\n/* harmony import */ var _isomorphy__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./isomorphy */ \"./src/shared/utils/isomorphy/index.ts\");\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\n/* eslint-disable react/jsx-props-no-spreading */\n/* global document */\n\n\n\n\n\n\n\n//
|
|
329
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ bookStyleSheets: function() { return /* binding */ bookStyleSheets; },\n/* harmony export */ \"default\": function() { return /* binding */ splitComponent; },\n/* harmony export */ freeStyleSheets: function() { return /* binding */ freeStyleSheets; }\n/* harmony export */ });\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! prop-types */ \"prop-types\");\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @dr.pogodin/js-utils */ \"@dr.pogodin/js-utils\");\n/* harmony import */ var _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _globalState__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./globalState */ \"./src/shared/utils/globalState.ts\");\n/* harmony import */ var _isomorphy__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./isomorphy */ \"./src/shared/utils/isomorphy/index.ts\");\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/react/jsx-runtime.js\");\n/* eslint-disable react/jsx-props-no-spreading */\n/* global document */\n\n\n\n\n\n\n\n// NOTE: At the client-side we get chunk groups the first time they are needed\n// (we used to get them eagerly when this module loaded, but it did not work well\n// alongside custom chunk info injection in server-less scenario);\n// at the server-side we only can get them within React render flow.\n// Thus, we set and use the following variable at the client-side, and then when\n// needed on the server side, we'll fetch it differently.\n\nlet cachedClientChunkGroups;\nfunction getClientChunkGroups() {\n if (_isomorphy__WEBPACK_IMPORTED_MODULE_4__.IS_CLIENT_SIDE && !cachedClientChunkGroups) {\n // eslint-disable-next-line global-require\n cachedClientChunkGroups = (__webpack_require__(/*! ../../client/getInj */ \"./src/client/getInj.ts\")[\"default\"])().CHUNK_GROUPS || {};\n }\n if (!cachedClientChunkGroups) throw Error('Internal error');\n return cachedClientChunkGroups;\n}\nconst refCounts = {};\nfunction getPublicPath() {\n return (0,_isomorphy__WEBPACK_IMPORTED_MODULE_4__.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(name, loadedSheets, refCount) {\n let res;\n const path = `${getPublicPath()}/${name}`;\n const fullPath = `${document.location.origin}${path}`;\n if (!loadedSheets.has(fullPath)) {\n let link = document.querySelector(`link[href=\"${path}\"]`);\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 res = new _dr_pogodin_js_utils__WEBPACK_IMPORTED_MODULE_2__.Barrier();\n link.addEventListener('load', () => res.resolve());\n link.addEventListener('error', () => res.resolve());\n }\n if (refCount) {\n const current = refCounts[path] || 0;\n refCounts[path] = 1 + current;\n }\n return res;\n}\n\n/**\n * Generates the set of URLs for currently loaded, linked stylesheets.\n * @return\n */\nfunction getLoadedStyleSheets() {\n const res = new Set();\n const {\n styleSheets\n } = document;\n for (let i = 0; i < styleSheets.length; ++i) {\n const {\n href\n } = styleSheets[i];\n if (href) res.add(href);\n }\n return res;\n}\nfunction assertChunkName(chunkName, chunkGroups) {\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 */\nfunction bookStyleSheets(chunkName, chunkGroups, refCount) {\n const promises = [];\n const assets = chunkGroups[chunkName];\n const loadedSheets = getLoadedStyleSheets();\n for (let i = 0; i < assets.length; ++i) {\n const asset = assets[i];\n if (asset.endsWith('.css')) {\n const promise = bookStyleSheet(asset, loadedSheets, refCount);\n if (promise) promises.push(promise);\n }\n }\n return promises.length ? Promise.allSettled(promises).then() : 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 */\nfunction freeStyleSheets(chunkName, chunkGroups) {\n const assets = chunkGroups[chunkName];\n for (let i = 0; i < assets.length; ++i) {\n const asset = assets[i];\n if (asset.endsWith('.css')) {\n const path = `${getPublicPath()}/${asset}`;\n if (--refCounts[path] <= 0) {\n document.head.querySelector(`link[href=\"${path}\"]`).remove();\n }\n }\n }\n}\n\n// Holds the set of chunk names already used for splitComponent() calls.\nconst usedChunkNames = new Set();\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 */\nfunction splitComponent(_ref) {\n let {\n chunkName,\n getComponent,\n placeholder\n } = _ref;\n // On the client side we can check right away if the chunk name is known.\n if (_isomorphy__WEBPACK_IMPORTED_MODULE_4__.IS_CLIENT_SIDE) assertChunkName(chunkName, getClientChunkGroups());\n\n // The correct usage of splitComponent() assumes a single call per chunk.\n if (usedChunkNames.has(chunkName)) {\n throw Error(`Repeated splitComponent() call for the chunk \"${chunkName}\"`);\n } else usedChunkNames.add(chunkName);\n const LazyComponent = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_1__.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 (_isomorphy__WEBPACK_IMPORTED_MODULE_4__.IS_CLIENT_SIDE) {\n await bookStyleSheets(chunkName, getClientChunkGroups(), false);\n }\n const Wrapper = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_1__.forwardRef)((_ref2, ref) => {\n let {\n children,\n ...rest\n } = _ref2;\n // On the server side we'll assert the chunk name here,\n // and also push it to the SSR chunks array.\n if (_isomorphy__WEBPACK_IMPORTED_MODULE_4__.IS_SERVER_SIDE) {\n const {\n chunkGroups,\n chunks\n } = (0,_globalState__WEBPACK_IMPORTED_MODULE_3__.getSsrContext)();\n assertChunkName(chunkName, chunkGroups);\n if (!chunks.includes(chunkName)) chunks.push(chunkName);\n }\n\n // This takes care about stylesheets management every time an instance of\n // this component is mounted / unmounted.\n (0,react__WEBPACK_IMPORTED_MODULE_1__.useInsertionEffect)(() => {\n bookStyleSheets(chunkName, getClientChunkGroups(), true);\n return () => freeStyleSheets(chunkName, getClientChunkGroups());\n }, []);\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(Component, {\n ref: ref,\n ...rest,\n children: children\n });\n });\n return {\n default: Wrapper\n };\n });\n const CodeSplit = _ref3 => {\n let {\n children,\n ...rest\n } = _ref3;\n return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(react__WEBPACK_IMPORTED_MODULE_1__.Suspense, {\n fallback: placeholder,\n children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(LazyComponent, {\n ...rest,\n children: children\n })\n });\n };\n CodeSplit.propTypes = {\n children: (prop_types__WEBPACK_IMPORTED_MODULE_0___default().node)\n };\n return CodeSplit;\n}\n\n//# sourceURL=webpack://@dr.pogodin/react-utils/./src/shared/utils/splitComponent.tsx?");
|
|
330
330
|
|
|
331
331
|
/***/ }),
|
|
332
332
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=getInj;var _forge=_interopRequireDefault(require("node-forge/lib/forge"));require("node-forge/lib/aes");var _buildInfo=require("../shared/utils/isomorphy/buildInfo");// Encapsulates retrieval of server-side data injection into HTML template.
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=getInj;exports.setInj=setInj;var _forge=_interopRequireDefault(require("node-forge/lib/forge"));require("node-forge/lib/aes");var _buildInfo=require("../shared/utils/isomorphy/buildInfo");// Encapsulates retrieval of server-side data injection into HTML template.
|
|
2
2
|
/* global document */ // Note: this way, only required part of "node-forge": AES, and some utils,
|
|
3
3
|
// is bundled into client-side code.
|
|
4
4
|
// Safeguard is needed here, because the server-side version of Docusaurus docs
|
|
@@ -8,5 +8,9 @@ let inj={};const metaElement=typeof document!=="undefined"?document.querySelecto
|
|
|
8
8
|
}else{// Otherwise, a bunch of dependent stuff will easily fail in non-standard
|
|
9
9
|
// environments, where no client-side initialization is performed. Like tests,
|
|
10
10
|
// Docusaurus examples, etc.
|
|
11
|
-
inj={}}function getInj(){return inj}
|
|
11
|
+
inj={}}function getInj(){return inj}/**
|
|
12
|
+
* Allows to set a custom injection object instance,
|
|
13
|
+
* for server-less scenarios, for example, where it is not auto-injected
|
|
14
|
+
* into generated pages from the server side.
|
|
15
|
+
*/function setInj(value){inj=value}
|
|
12
16
|
//# sourceMappingURL=getInj.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getInj.js","names":["_forge","_interopRequireDefault","require","_buildInfo","inj","metaElement","document","querySelector","remove","data","forge","util","decode64","content","key","getBuildInfo","d","cipher","createDecipher","start","iv","slice","length","update","createBuffer","finish","decodeUtf8","output","eval","getInj"],"sources":["../../../src/client/getInj.ts"],"sourcesContent":["// Encapsulates retrieval of server-side data injection into HTML template.\n\n/* global document */\n\n// Note: this way, only required part of \"node-forge\": AES, and some utils,\n// is bundled into client-side code.\nimport forge from 'node-forge/lib/forge';\nimport 'node-forge/lib/aes';\n\nimport type { InjT } from 'utils/globalState';\n\nimport { getBuildInfo } from 'utils/isomorphy/buildInfo';\n\n// Safeguard is needed here, because the server-side version of Docusaurus docs\n// is compiled (at least now) with settings suggesting it is a client-side\n// environment, but there is no document.\nlet inj: InjT = {};\n\nconst metaElement: HTMLMetaElement | null = typeof document !== 'undefined'\n ? document.querySelector('meta[itemprop=\"drpruinj\"]') : null;\n\nif (metaElement) {\n metaElement.remove();\n let data = forge.util.decode64(metaElement.content);\n\n const { key } = getBuildInfo();\n const d = forge.cipher.createDecipher('AES-CBC', key);\n d.start({ iv: data.slice(0, key.length) });\n d.update(forge.util.createBuffer(data.slice(key.length)));\n d.finish();\n\n data = forge.util.decodeUtf8(d.output.data);\n inj = eval(`(${data})`); // eslint-disable-line no-eval\n} else {\n // Otherwise, a bunch of dependent stuff will easily fail in non-standard\n // environments, where no client-side initialization is performed. Like tests,\n // Docusaurus examples, etc.\n inj = {};\n}\n\nexport default function getInj(): InjT {\n return inj;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getInj.js","names":["_forge","_interopRequireDefault","require","_buildInfo","inj","metaElement","document","querySelector","remove","data","forge","util","decode64","content","key","getBuildInfo","d","cipher","createDecipher","start","iv","slice","length","update","createBuffer","finish","decodeUtf8","output","eval","getInj","setInj","value"],"sources":["../../../src/client/getInj.ts"],"sourcesContent":["// Encapsulates retrieval of server-side data injection into HTML template.\n\n/* global document */\n\n// Note: this way, only required part of \"node-forge\": AES, and some utils,\n// is bundled into client-side code.\nimport forge from 'node-forge/lib/forge';\nimport 'node-forge/lib/aes';\n\nimport type { InjT } from 'utils/globalState';\n\nimport { getBuildInfo } from 'utils/isomorphy/buildInfo';\n\n// Safeguard is needed here, because the server-side version of Docusaurus docs\n// is compiled (at least now) with settings suggesting it is a client-side\n// environment, but there is no document.\nlet inj: InjT = {};\n\nconst metaElement: HTMLMetaElement | null = typeof document !== 'undefined'\n ? document.querySelector('meta[itemprop=\"drpruinj\"]') : null;\n\nif (metaElement) {\n metaElement.remove();\n let data = forge.util.decode64(metaElement.content);\n\n const { key } = getBuildInfo();\n const d = forge.cipher.createDecipher('AES-CBC', key);\n d.start({ iv: data.slice(0, key.length) });\n d.update(forge.util.createBuffer(data.slice(key.length)));\n d.finish();\n\n data = forge.util.decodeUtf8(d.output.data);\n inj = eval(`(${data})`); // eslint-disable-line no-eval\n} else {\n // Otherwise, a bunch of dependent stuff will easily fail in non-standard\n // environments, where no client-side initialization is performed. Like tests,\n // Docusaurus examples, etc.\n inj = {};\n}\n\nexport default function getInj(): InjT {\n return inj;\n}\n\n/**\n * Allows to set a custom injection object instance,\n * for server-less scenarios, for example, where it is not auto-injected\n * into generated pages from the server side.\n */\nexport function setInj(value: InjT) {\n inj = value;\n}\n"],"mappings":"sMAMA,IAAAA,MAAA,CAAAC,sBAAA,CAAAC,OAAA,0BACAA,OAAA,uBAIA,IAAAC,UAAA,CAAAD,OAAA,wCAXA;AAEA,sBAEA;AACA;AAQA;AACA;AACA;AACA,GAAI,CAAAE,GAAS,CAAG,CAAC,CAAC,CAElB,KAAM,CAAAC,WAAmC,CAAG,MAAO,CAAAC,QAAQ,GAAK,WAAW,CACvEA,QAAQ,CAACC,aAAa,CAAC,6BAA2B,CAAC,CAAG,IAAI,CAE9D,GAAIF,WAAW,CAAE,CACfA,WAAW,CAACG,MAAM,CAAC,CAAC,CACpB,GAAI,CAAAC,IAAI,CAAGC,cAAK,CAACC,IAAI,CAACC,QAAQ,CAACP,WAAW,CAACQ,OAAO,CAAC,CAEnD,KAAM,CAAEC,GAAI,CAAC,CAAG,GAAAC,uBAAY,EAAC,CAAC,CAC9B,KAAM,CAAAC,CAAC,CAAGN,cAAK,CAACO,MAAM,CAACC,cAAc,CAAC,SAAS,CAAEJ,GAAG,CAAC,CACrDE,CAAC,CAACG,KAAK,CAAC,CAAEC,EAAE,CAAEX,IAAI,CAACY,KAAK,CAAC,CAAC,CAAEP,GAAG,CAACQ,MAAM,CAAE,CAAC,CAAC,CAC1CN,CAAC,CAACO,MAAM,CAACb,cAAK,CAACC,IAAI,CAACa,YAAY,CAACf,IAAI,CAACY,KAAK,CAACP,GAAG,CAACQ,MAAM,CAAC,CAAC,CAAC,CACzDN,CAAC,CAACS,MAAM,CAAC,CAAC,CAEVhB,IAAI,CAAGC,cAAK,CAACC,IAAI,CAACe,UAAU,CAACV,CAAC,CAACW,MAAM,CAAClB,IAAI,CAAC,CAC3CL,GAAG,CAAGwB,IAAI,CAAC,IAAInB,IAAI,GAAG,CAAC,CAAE;AAC3B,CAAC,IAAM,CACL;AACA;AACA;AACAL,GAAG,CAAG,CAAC,CACT,CAEe,QAAS,CAAAyB,MAAMA,CAAA,CAAS,CACrC,MAAO,CAAAzB,GACT,CAEA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAA0B,MAAMA,CAACC,KAAW,CAAE,CAClC3B,GAAG,CAAG2B,KACR","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=Launch;Object.defineProperty(exports,"setInj",{enumerable:true,get:function(){return _getInj.setInj}});require("react");var _reactGlobalState=require("@dr.pogodin/react-global-state");var _client=require("react-dom/client");var _reactRouterDom=require("react-router-dom");var _getInj=_interopRequireWildcard(require("./getInj"));var _jsxRuntime=require("react/jsx-runtime");function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap,t=new WeakMap;return(_getRequireWildcardCache=function(e){return e?t:r})(e)}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u]}return n.default=e,t&&t.set(e,n),n}// Initialization of client-side code.
|
|
2
2
|
/* global document */ /**
|
|
3
3
|
* Prepares and launches the app at client side.
|
|
4
4
|
* @param Application Root application component
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["require","_reactGlobalState","_client","_reactRouterDom","_getInj","
|
|
1
|
+
{"version":3,"file":"index.js","names":["require","_reactGlobalState","_client","_reactRouterDom","_getInj","_interopRequireWildcard","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Launch","Application","options","arguments","length","undefined","container","document","getElementById","Error","scene","jsx","GlobalStateProvider","initialState","getInj","ISTATE","children","BrowserRouter","future","v7_relativeSplatPath","dontHydrate","root","createRoot","render","hydrateRoot"],"sources":["../../../src/client/index.tsx"],"sourcesContent":["// Initialization of client-side code.\n/* global document */\n\nimport { type ComponentType } from 'react';\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\n\nimport { createRoot, hydrateRoot } from 'react-dom/client';\nimport { BrowserRouter } from 'react-router-dom';\n\nimport getInj, { setInj } from './getInj';\n\ntype OptionsT = {\n dontHydrate?: boolean;\n initialState?: any;\n};\n\nexport { setInj };\n\n/**\n * Prepares and launches the app at client side.\n * @param Application Root application component\n * @param [options={}] Optional. Additional settings.\n */\nexport default function Launch(\n Application: ComponentType,\n options: OptionsT = {},\n) {\n const container = document.getElementById('react-view');\n if (!container) throw Error('Failed to find container for React app');\n const scene = (\n <GlobalStateProvider initialState={getInj().ISTATE || options.initialState}>\n <BrowserRouter future={{ v7_relativeSplatPath: true }}>\n <Application />\n </BrowserRouter>\n </GlobalStateProvider>\n );\n\n if (options.dontHydrate) {\n const root = createRoot(container);\n root.render(scene);\n } else hydrateRoot(container, scene);\n}\n"],"mappings":"6LAGAA,OAAA,UAEA,IAAAC,iBAAA,CAAAD,OAAA,mCAEA,IAAAE,OAAA,CAAAF,OAAA,qBACA,IAAAG,eAAA,CAAAH,OAAA,qBAEA,IAAAI,OAAA,CAAAC,uBAAA,CAAAL,OAAA,cAA0C,IAAAM,WAAA,CAAAN,OAAA,+BAAAO,yBAAAC,CAAA,wBAAAC,OAAA,iBAAAC,CAAA,KAAAD,OAAA,CAAAE,CAAA,KAAAF,OAAA,QAAAF,wBAAA,SAAAA,CAAAC,CAAA,SAAAA,CAAA,CAAAG,CAAA,CAAAD,CAAA,GAAAF,CAAA,WAAAH,wBAAAG,CAAA,CAAAE,CAAA,MAAAA,CAAA,EAAAF,CAAA,EAAAA,C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AmB,EAACC,YAAY,CAAE,GAAAC,eAAM,EAAC,CAAC,CAACC,MAAM,EAAIb,OAAO,CAACW,YAAa,CAAAG,QAAA,cACzE,GAAArC,WAAA,CAAAgC,GAAA,EAACnC,eAAA,CAAAyC,aAAa,EAACC,MAAM,CAAE,CAAEC,oBAAoB,CAAE,IAAK,CAAE,CAAAH,QAAA,cACpD,GAAArC,WAAA,CAAAgC,GAAA,EAACV,WAAW,GAAE,CAAC,CACF,CAAC,CACG,CACtB,CAED,GAAIC,OAAO,CAACkB,WAAW,CAAE,CACvB,KAAM,CAAAC,IAAI,CAAG,GAAAC,kBAAU,EAAChB,SAAS,CAAC,CAClCe,IAAI,CAACE,MAAM,CAACb,KAAK,CACnB,CAAC,IAAM,GAAAc,mBAAW,EAAClB,SAAS,CAAEI,KAAK,CACrC","ignoreList":[]}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});var _exportNames={client:true,server:true,config:true,Barrier:true,Emitter:true,isomorphy:true,getSsrContext:true,Semaphore:true,splitComponent:true,themed:true,ThemeProvider:true,time:true,webpack:true,withRetries:true,api:true,PT:true,getGlobalState:true,GlobalStateProvider:true,newAsyncDataEnvelope:true,useAsyncCollection:true,useAsyncData:true,useGlobalState:true,withGlobalStateType:true};Object.defineProperty(exports,"Barrier",{enumerable:true,get:function(){return _utils.Barrier}});Object.defineProperty(exports,"Emitter",{enumerable:true,get:function(){return _utils.Emitter}});Object.defineProperty(exports,"GlobalStateProvider",{enumerable:true,get:function(){return _reactGlobalState.GlobalStateProvider}});exports.PT=void 0;Object.defineProperty(exports,"Semaphore",{enumerable:true,get:function(){return _utils.Semaphore}});Object.defineProperty(exports,"ThemeProvider",{enumerable:true,get:function(){return _utils.ThemeProvider}});Object.defineProperty(exports,"api",{enumerable:true,get:function(){return _axios.default}});exports.client=void 0;Object.defineProperty(exports,"config",{enumerable:true,get:function(){return _utils.config}});Object.defineProperty(exports,"getGlobalState",{enumerable:true,get:function(){return _reactGlobalState.getGlobalState}});Object.defineProperty(exports,"getSsrContext",{enumerable:true,get:function(){return _utils.getSsrContext}});Object.defineProperty(exports,"isomorphy",{enumerable:true,get:function(){return _utils.isomorphy}});Object.defineProperty(exports,"newAsyncDataEnvelope",{enumerable:true,get:function(){return _reactGlobalState.newAsyncDataEnvelope}});exports.server=void 0;Object.defineProperty(exports,"splitComponent",{enumerable:true,get:function(){return _utils.splitComponent}});Object.defineProperty(exports,"themed",{enumerable:true,get:function(){return _utils.themed}});Object.defineProperty(exports,"time",{enumerable:true,get:function(){return _utils.time}});Object.defineProperty(exports,"useAsyncCollection",{enumerable:true,get:function(){return _reactGlobalState.useAsyncCollection}});Object.defineProperty(exports,"useAsyncData",{enumerable:true,get:function(){return _reactGlobalState.useAsyncData}});Object.defineProperty(exports,"useGlobalState",{enumerable:true,get:function(){return _reactGlobalState.useGlobalState}});Object.defineProperty(exports,"webpack",{enumerable:true,get:function(){return _utils.webpack}});Object.defineProperty(exports,"withGlobalStateType",{enumerable:true,get:function(){return _reactGlobalState.withGlobalStateType}});Object.defineProperty(exports,"withRetries",{enumerable:true,get:function(){return _utils.withRetries}});var _utils=require("./shared/utils");var _axios=_interopRequireDefault(require("axios"));var _PT=_interopRequireWildcard(require("prop-types"));exports.PT=_PT;var _reactGlobalState=require("@dr.pogodin/react-global-state");var _components=require("./shared/components");Object.keys(_components).forEach(function(key){if(key==="default"||key==="__esModule")return;if(Object.prototype.hasOwnProperty.call(_exportNames,key))return;if(key in exports&&exports[key]===_components[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function(){return _components[key]}})});function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap,t=new WeakMap;return(_getRequireWildcardCache=function(e){return e?t:r})(e)}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u]}return n.default=e,t&&t.set(e,n),n}const server=exports.server=_utils.webpack.requireWeak("./server",__dirname)
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});var _exportNames={client:true,server:true,config:true,Barrier:true,Emitter:true,isomorphy:true,getSsrContext:true,Semaphore:true,splitComponent:true,themed:true,ThemeProvider:true,time:true,webpack:true,withRetries:true,api:true,PT:true,getGlobalState:true,GlobalStateProvider:true,newAsyncDataEnvelope:true,useAsyncCollection:true,useAsyncData:true,useGlobalState:true,withGlobalStateType:true};Object.defineProperty(exports,"Barrier",{enumerable:true,get:function(){return _utils.Barrier}});Object.defineProperty(exports,"Emitter",{enumerable:true,get:function(){return _utils.Emitter}});Object.defineProperty(exports,"GlobalStateProvider",{enumerable:true,get:function(){return _reactGlobalState.GlobalStateProvider}});exports.PT=void 0;Object.defineProperty(exports,"Semaphore",{enumerable:true,get:function(){return _utils.Semaphore}});Object.defineProperty(exports,"ThemeProvider",{enumerable:true,get:function(){return _utils.ThemeProvider}});Object.defineProperty(exports,"api",{enumerable:true,get:function(){return _axios.default}});exports.client=void 0;Object.defineProperty(exports,"config",{enumerable:true,get:function(){return _utils.config}});Object.defineProperty(exports,"getGlobalState",{enumerable:true,get:function(){return _reactGlobalState.getGlobalState}});Object.defineProperty(exports,"getSsrContext",{enumerable:true,get:function(){return _utils.getSsrContext}});Object.defineProperty(exports,"isomorphy",{enumerable:true,get:function(){return _utils.isomorphy}});Object.defineProperty(exports,"newAsyncDataEnvelope",{enumerable:true,get:function(){return _reactGlobalState.newAsyncDataEnvelope}});exports.server=void 0;Object.defineProperty(exports,"splitComponent",{enumerable:true,get:function(){return _utils.splitComponent}});Object.defineProperty(exports,"themed",{enumerable:true,get:function(){return _utils.themed}});Object.defineProperty(exports,"time",{enumerable:true,get:function(){return _utils.time}});Object.defineProperty(exports,"useAsyncCollection",{enumerable:true,get:function(){return _reactGlobalState.useAsyncCollection}});Object.defineProperty(exports,"useAsyncData",{enumerable:true,get:function(){return _reactGlobalState.useAsyncData}});Object.defineProperty(exports,"useGlobalState",{enumerable:true,get:function(){return _reactGlobalState.useGlobalState}});Object.defineProperty(exports,"webpack",{enumerable:true,get:function(){return _utils.webpack}});Object.defineProperty(exports,"withGlobalStateType",{enumerable:true,get:function(){return _reactGlobalState.withGlobalStateType}});Object.defineProperty(exports,"withRetries",{enumerable:true,get:function(){return _utils.withRetries}});var _utils=require("./shared/utils");var _axios=_interopRequireDefault(require("axios"));var _PT=_interopRequireWildcard(require("prop-types"));exports.PT=_PT;var _reactGlobalState=require("@dr.pogodin/react-global-state");var _components=require("./shared/components");Object.keys(_components).forEach(function(key){if(key==="default"||key==="__esModule")return;if(Object.prototype.hasOwnProperty.call(_exportNames,key))return;if(key in exports&&exports[key]===_components[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function(){return _components[key]}})});function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap,t=new WeakMap;return(_getRequireWildcardCache=function(e){return e?t:r})(e)}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u]}return n.default=e,t&&t.set(e,n),n}const server=exports.server=_utils.webpack.requireWeak("./server",__dirname);// TODO: Should be done in a cleaner way, but technically it is fine
|
|
2
|
+
// for this scenario.
|
|
3
|
+
// eslint-disable-next-line import/no-mutable-exports
|
|
4
|
+
let client=exports.client=server?undefined:require("./client");if(client){client.default.setInj=client.setInj;exports.client=client=client.default}
|
|
2
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_utils","require","_axios","_interopRequireDefault","_PT","_interopRequireWildcard","exports","PT","_reactGlobalState","_components","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","defineProperty","enumerable","get","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set","server","webpack","requireWeak","__dirname","client","undefined"],"sources":["../../src/index.ts"],"sourcesContent":["import 'styles/global.scss';\n\nimport { webpack } from 'utils';\n\nimport type ServerT from './server';\n\nconst server = webpack.requireWeak('./server', __dirname) as (typeof ServerT) | null;\n\
|
|
1
|
+
{"version":3,"file":"index.js","names":["_utils","require","_axios","_interopRequireDefault","_PT","_interopRequireWildcard","exports","PT","_reactGlobalState","_components","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","defineProperty","enumerable","get","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set","server","webpack","requireWeak","__dirname","client","undefined","setInj"],"sources":["../../src/index.ts"],"sourcesContent":["import 'styles/global.scss';\n\nimport { webpack } from 'utils';\n\nimport type ServerT from './server';\n\nconst server = webpack.requireWeak('./server', __dirname) as (typeof ServerT) | null;\n\n// TODO: Should be done in a cleaner way, but technically it is fine\n// for this scenario.\n// eslint-disable-next-line import/no-mutable-exports\nlet client = server ? undefined : require('./client');\n\nif (client) {\n client.default.setInj = client.setInj;\n client = client.default;\n}\n\nexport { default as api } from 'axios';\nexport * as PT from 'prop-types';\n\nexport {\n type AsyncCollectionLoaderT,\n type AsyncDataEnvelopeT,\n type AsyncDataLoaderT,\n type ForceT,\n type UseAsyncDataOptionsT,\n type UseAsyncDataResT,\n type UseGlobalStateResT,\n type ValueOrInitializerT,\n getGlobalState,\n GlobalStateProvider,\n newAsyncDataEnvelope,\n useAsyncCollection,\n useAsyncData,\n useGlobalState,\n withGlobalStateType,\n} from '@dr.pogodin/react-global-state';\n\nexport * from 'components';\n\nexport {\n type Listener,\n type Theme,\n config,\n Barrier,\n Emitter,\n isomorphy,\n getSsrContext,\n Semaphore,\n splitComponent,\n themed,\n ThemeProvider,\n time,\n webpack,\n withRetries,\n} from 'utils';\n\nexport { client, server };\n"],"mappings":"kvFAEA,IAAAA,MAAA,CAAAC,OAAA,mBAgBA,IAAAC,MAAA,CAAAC,sBAAA,CAAAF,OAAA,WAAuC,IAAAG,GAAA,CAAAC,uBAAA,CAAAJ,OAAA,gBAAAK,OAAA,CAAAC,EAAA,CAAAH,GAAA,CAGvC,IAAAI,iBAAA,CAAAP,OAAA,mCAkBA,IAAAQ,WAAA,CAAAR,OAAA,wBAAAS,MAAA,CAAAC,IAAA,CAAAF,WAAA,EAAAG,OAAA,UAAAC,GAAA,KAAAA,GAAA,cAAAA,GAAA,0BAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,CAAAJ,GAAA,YAAAA,GAAA,IAAAP,OAAA,EAAAA,OAAA,CAAAO,GAAA,IAAAJ,WAAA,CAAAI,GAAA,SAAAH,MAAA,CAAAQ,cAAA,CAAAZ,OAAA,CAAAO,GAAA,EAAAM,UAAA,MAAAC,GAAA,SAAAA,CAAA,SAAAX,WAAA,CAAAI,GAAA,OAA2B,SAAAQ,yBAAAC,CAAA,wBAAAC,OAAA,iBAAAC,CAAA,KAAAD,OAAA,CAAAE,CAAA,KAAAF,OAAA,QAAAF,wBAAA,SAAAA,CAAAC,CAAA,SAAAA,CAAA,CAAAG,CAAA,CAAAD,CAAA,GAAAF,CAAA,WAAAjB,wBAAAiB,CAAA,CAAAE,CAAA,MAAAA,CAAA,EAAAF,CAAA,EAAAA,CAAA,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|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.bookStyleSheets=bookStyleSheets;exports.default=splitComponent;exports.freeStyleSheets=freeStyleSheets;var _propTypes=_interopRequireDefault(require("prop-types"));var _react=require("react");var _jsUtils=require("@dr.pogodin/js-utils");var _globalState=require("./globalState");var _isomorphy=require("./isomorphy");var _jsxRuntime=require("react/jsx-runtime");/* eslint-disable react/jsx-props-no-spreading */ /* global document */ //
|
|
2
|
-
//
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.bookStyleSheets=bookStyleSheets;exports.default=splitComponent;exports.freeStyleSheets=freeStyleSheets;var _propTypes=_interopRequireDefault(require("prop-types"));var _react=require("react");var _jsUtils=require("@dr.pogodin/js-utils");var _globalState=require("./globalState");var _isomorphy=require("./isomorphy");var _jsxRuntime=require("react/jsx-runtime");/* eslint-disable react/jsx-props-no-spreading */ /* global document */ // NOTE: At the client-side we get chunk groups the first time they are needed
|
|
2
|
+
// (we used to get them eagerly when this module loaded, but it did not work well
|
|
3
|
+
// alongside custom chunk info injection in server-less scenario);
|
|
4
|
+
// at the server-side we only can get them within React render flow.
|
|
3
5
|
// Thus, we set and use the following variable at the client-side, and then when
|
|
4
6
|
// needed on the server side, we'll fetch it differently.
|
|
5
|
-
let
|
|
6
|
-
|
|
7
|
+
let cachedClientChunkGroups;function getClientChunkGroups(){if(_isomorphy.IS_CLIENT_SIDE&&!cachedClientChunkGroups){// eslint-disable-next-line global-require
|
|
8
|
+
cachedClientChunkGroups=require("../../client/getInj").default().CHUNK_GROUPS||{}}if(!cachedClientChunkGroups)throw Error("Internal error");return cachedClientChunkGroups}const refCounts={};function getPublicPath(){return(0,_isomorphy.getBuildInfo)().publicPath}/**
|
|
7
9
|
* Client-side only! Ensures the specified CSS stylesheet is loaded into
|
|
8
10
|
* the document; loads if it is missing; and does simple reference counting
|
|
9
11
|
* to facilitate future clean-up.
|
|
@@ -39,13 +41,13 @@ const usedChunkNames=new Set;/**
|
|
|
39
41
|
* @param {React.Element} [options.placeholder]
|
|
40
42
|
* @return {React.ElementType}
|
|
41
43
|
*/function splitComponent({chunkName,getComponent,placeholder}){// On the client side we can check right away if the chunk name is known.
|
|
42
|
-
if(_isomorphy.IS_CLIENT_SIDE)assertChunkName(chunkName,
|
|
44
|
+
if(_isomorphy.IS_CLIENT_SIDE)assertChunkName(chunkName,getClientChunkGroups());// The correct usage of splitComponent() assumes a single call per chunk.
|
|
43
45
|
if(usedChunkNames.has(chunkName)){throw Error(`Repeated splitComponent() call for the chunk "${chunkName}"`)}else usedChunkNames.add(chunkName);const LazyComponent=/*#__PURE__*/(0,_react.lazy)(async()=>{const resolved=await getComponent();const Component="default"in resolved?resolved.default:resolved;// This pre-loads necessary stylesheets prior to the first mount of
|
|
44
46
|
// the component (the lazy load function is executed by React one at
|
|
45
47
|
// the frist mount).
|
|
46
|
-
if(_isomorphy.IS_CLIENT_SIDE){await bookStyleSheets(chunkName,
|
|
48
|
+
if(_isomorphy.IS_CLIENT_SIDE){await bookStyleSheets(chunkName,getClientChunkGroups(),false)}const Wrapper=/*#__PURE__*/(0,_react.forwardRef)(({children,...rest},ref)=>{// On the server side we'll assert the chunk name here,
|
|
47
49
|
// and also push it to the SSR chunks array.
|
|
48
50
|
if(_isomorphy.IS_SERVER_SIDE){const{chunkGroups,chunks}=(0,_globalState.getSsrContext)();assertChunkName(chunkName,chunkGroups);if(!chunks.includes(chunkName))chunks.push(chunkName)}// This takes care about stylesheets management every time an instance of
|
|
49
51
|
// this component is mounted / unmounted.
|
|
50
|
-
(0,_react.useInsertionEffect)(()=>{bookStyleSheets(chunkName,
|
|
52
|
+
(0,_react.useInsertionEffect)(()=>{bookStyleSheets(chunkName,getClientChunkGroups(),true);return()=>freeStyleSheets(chunkName,getClientChunkGroups())},[]);return/*#__PURE__*/(0,_jsxRuntime.jsx)(Component,{ref:ref,...rest,children:children})});return{default:Wrapper}});const CodeSplit=({children,...rest})=>/*#__PURE__*/(0,_jsxRuntime.jsx)(_react.Suspense,{fallback:placeholder,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(LazyComponent,{...rest,children:children})});CodeSplit.propTypes={children:_propTypes.default.node};return CodeSplit}
|
|
51
53
|
//# sourceMappingURL=splitComponent.js.map
|