@dr.pogodin/react-utils 1.58.1 → 1.58.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.
@@ -0,0 +1,9 @@
1
+ import { expect, test } from 'tstyche';
2
+
3
+ import { getConfig } from 'utils';
4
+
5
+ type T = { key: 'value' };
6
+
7
+ test('Syncronous config type', () => {
8
+ expect(getConfig<T>(true)).type.toBe<T>();
9
+ });
@@ -17,7 +17,9 @@ function injectCsrfToken(cfg) {
17
17
  cfg.CSRF = parseCookie(document.cookie).csrfToken;
18
18
  }
19
19
  return cfg;
20
- }
20
+ } // BEWARE: Removing generic type from this override messes up
21
+ // type resolution in the host code in some scenarios.
22
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
21
23
  export function getConfig(sync) {
22
24
  if (!config) {
23
25
  if (IS_CLIENT_SIDE) {
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":[],"sources":["../../../../src/shared/utils/config.ts"],"sourcesContent":["/* global document */\n\nimport { parseCookie } from 'cookie';\n\nimport clientGetInj from '../../client/getInj';\n\nimport { IS_CLIENT_SIDE } from './isomorphy/environment-check';\nimport { requireWeak } from './webpack';\n\ntype ConfigT = Record<string, unknown>;\n\nlet config: ConfigT | Promise<ConfigT> | undefined;\n\n/**\n * Injects CSRF token into config (on client-side only).\n *\n * BEWARE: It mutates the argument, and also returns it as the result,\n * for chaining.\n */\nfunction injectCsrfToken(cfg: ConfigT): ConfigT {\n // The safeguard for \"document\" is necessary because in non-Node environments,\n // like React Native, IS_CLIENT_SIDE is \"true\", however \"document\" and a bunch\n // of other browser-world features are not available.\n if (IS_CLIENT_SIDE && typeof document !== 'undefined') {\n // eslint-disable-next-line no-param-reassign\n cfg.CSRF = parseCookie(document.cookie).csrfToken;\n }\n\n return cfg;\n}\n\nexport function getConfig(sync: true): ConfigT;\n\nexport function getConfig<T extends ConfigT>(sync?: boolean): Promise<T> | T;\n\nexport function getConfig<T extends ConfigT>(sync?: boolean): Promise<T> | T {\n if (!config) {\n if (IS_CLIENT_SIDE) {\n const inj = clientGetInj();\n config = inj instanceof Promise\n ? inj.then((injection) => {\n const res = injectCsrfToken(injection.CONFIG ?? {});\n config = res;\n return res;\n })\n : injectCsrfToken(inj.CONFIG ?? {});\n } else {\n const weak = requireWeak<ConfigT>('config');\n if (!weak) throw Error('Internal error');\n config = weak;\n }\n }\n\n if (sync && (config instanceof Promise)) {\n throw Error('The config is not available yet');\n }\n\n return config as T;\n}\n"],"mappings":"AAAA,qBAEA,SAAS,WAAW,QAAQ,QAAQ;AAAC,OAE9B,YAAY;AAAA,SAEV,cAAc;AAAA,SACd,WAAW;AAIpB,IAAI,MAA8C,CAElD;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,eAAe,CAAC,GAAY,EAAW;EAC9C;EACA;EACA;EACA,IAAI,cAAc,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;IACrD;IACA,GAAG,CAAC,IAAI,GAAG,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,SAAS;EACnD;EAEA,OAAO,GAAG;AACZ;AAMA,OAAO,SAAS,SAAS,CAAoB,IAAc,EAAkB;EAC3E,IAAI,CAAC,MAAM,EAAE;IACX,IAAI,cAAc,EAAE;MAClB,MAAM,GAAG,GAAG,YAAY,CAAC,CAAC;MAC1B,MAAM,GAAG,GAAG,YAAY,OAAO,GAC3B,GAAG,CAAC,IAAI,CAAE,SAAS,IAAK;QACxB,MAAM,GAAG,GAAG,eAAe,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;QACnD,MAAM,GAAG,GAAG;QACZ,OAAO,GAAG;MACZ,CAAC,CAAC,GACA,eAAe,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;IACvC,CAAC,MAAM;MACL,MAAM,IAAI,GAAG,WAAW,CAAU,QAAQ,CAAC;MAC3C,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,CAAC,gBAAgB,CAAC;MACxC,MAAM,GAAG,IAAI;IACf;EACF;EAEA,IAAI,IAAI,IAAK,MAAM,YAAY,OAAQ,EAAE;IACvC,MAAM,KAAK,CAAC,iCAAiC,CAAC;EAChD;EAEA,OAAO,MAAM;AACf","ignoreList":[]}
1
+ {"version":3,"file":"config.js","names":[],"sources":["../../../../src/shared/utils/config.ts"],"sourcesContent":["/* global document */\n\nimport { parseCookie } from 'cookie';\n\nimport clientGetInj from '../../client/getInj';\n\nimport { IS_CLIENT_SIDE } from './isomorphy/environment-check';\nimport { requireWeak } from './webpack';\n\ntype ConfigT = Record<string, unknown>;\n\nlet config: ConfigT | Promise<ConfigT> | undefined;\n\n/**\n * Injects CSRF token into config (on client-side only).\n *\n * BEWARE: It mutates the argument, and also returns it as the result,\n * for chaining.\n */\nfunction injectCsrfToken(cfg: ConfigT): ConfigT {\n // The safeguard for \"document\" is necessary because in non-Node environments,\n // like React Native, IS_CLIENT_SIDE is \"true\", however \"document\" and a bunch\n // of other browser-world features are not available.\n if (IS_CLIENT_SIDE && typeof document !== 'undefined') {\n // eslint-disable-next-line no-param-reassign\n cfg.CSRF = parseCookie(document.cookie).csrfToken;\n }\n\n return cfg;\n}\n\n// BEWARE: Removing generic type from this override messes up\n// type resolution in the host code in some scenarios.\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters\nexport function getConfig<T extends ConfigT>(sync: true): T;\n\nexport function getConfig<T extends ConfigT>(sync?: boolean): Promise<T> | T;\n\nexport function getConfig<T extends ConfigT>(sync?: boolean): Promise<T> | T {\n if (!config) {\n if (IS_CLIENT_SIDE) {\n const inj = clientGetInj();\n config = inj instanceof Promise\n ? inj.then((injection) => {\n const res = injectCsrfToken(injection.CONFIG ?? {});\n config = res;\n return res;\n })\n : injectCsrfToken(inj.CONFIG ?? {});\n } else {\n const weak = requireWeak<ConfigT>('config');\n if (!weak) throw Error('Internal error');\n config = weak;\n }\n }\n\n if (sync && (config instanceof Promise)) {\n throw Error('The config is not available yet');\n }\n\n return config as T;\n}\n"],"mappings":"AAAA,qBAEA,SAAS,WAAW,QAAQ,QAAQ;AAAC,OAE9B,YAAY;AAAA,SAEV,cAAc;AAAA,SACd,WAAW;AAIpB,IAAI,MAA8C,CAElD;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,eAAe,CAAC,GAAY,EAAW;EAC9C;EACA;EACA;EACA,IAAI,cAAc,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;IACrD;IACA,GAAG,CAAC,IAAI,GAAG,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,SAAS;EACnD;EAEA,OAAO,GAAG;AACZ,CAEA;AACA;AACA;AAKA,OAAO,SAAS,SAAS,CAAoB,IAAc,EAAkB;EAC3E,IAAI,CAAC,MAAM,EAAE;IACX,IAAI,cAAc,EAAE;MAClB,MAAM,GAAG,GAAG,YAAY,CAAC,CAAC;MAC1B,MAAM,GAAG,GAAG,YAAY,OAAO,GAC3B,GAAG,CAAC,IAAI,CAAE,SAAS,IAAK;QACxB,MAAM,GAAG,GAAG,eAAe,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;QACnD,MAAM,GAAG,GAAG;QACZ,OAAO,GAAG;MACZ,CAAC,CAAC,GACA,eAAe,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;IACvC,CAAC,MAAM;MACL,MAAM,IAAI,GAAG,WAAW,CAAU,QAAQ,CAAC;MAC3C,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,CAAC,gBAAgB,CAAC;MACxC,MAAM,GAAG,IAAI;IACf;EACF;EAEA,IAAI,IAAI,IAAK,MAAM,YAAY,OAAQ,EAAE;IACvC,MAAM,KAAK,CAAC,iCAAiC,CAAC;EAChD;EAEA,OAAO,MAAM;AACf","ignoreList":[]}
@@ -7,5 +7,8 @@
7
7
  // like React Native, IS_CLIENT_SIDE is "true", however "document" and a bunch
8
8
  // of other browser-world features are not available.
9
9
  if(IS_CLIENT_SIDE&&typeof document!=="undefined"){// eslint-disable-next-line no-param-reassign
10
- cfg.CSRF=parseCookie(document.cookie).csrfToken;}return cfg;}export function getConfig(sync){if(!config){if(IS_CLIENT_SIDE){const inj=clientGetInj();config=inj instanceof Promise?inj.then(injection=>{const res=injectCsrfToken(injection.CONFIG??{});config=res;return res;}):injectCsrfToken(inj.CONFIG??{});}else{const weak=requireWeak("config");if(!weak)throw Error("Internal error");config=weak;}}if(sync&&config instanceof Promise){throw Error("The config is not available yet");}return config;}
10
+ cfg.CSRF=parseCookie(document.cookie).csrfToken;}return cfg;}// BEWARE: Removing generic type from this override messes up
11
+ // type resolution in the host code in some scenarios.
12
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
13
+ export function getConfig(sync){if(!config){if(IS_CLIENT_SIDE){const inj=clientGetInj();config=inj instanceof Promise?inj.then(injection=>{const res=injectCsrfToken(injection.CONFIG??{});config=res;return res;}):injectCsrfToken(inj.CONFIG??{});}else{const weak=requireWeak("config");if(!weak)throw Error("Internal error");config=weak;}}if(sync&&config instanceof Promise){throw Error("The config is not available yet");}return config;}
11
14
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":[],"sources":["../../../../src/shared/utils/config.ts"],"sourcesContent":["/* global document */\n\nimport { parseCookie } from 'cookie';\n\nimport clientGetInj from '../../client/getInj';\n\nimport { IS_CLIENT_SIDE } from './isomorphy/environment-check';\nimport { requireWeak } from './webpack';\n\ntype ConfigT = Record<string, unknown>;\n\nlet config: ConfigT | Promise<ConfigT> | undefined;\n\n/**\n * Injects CSRF token into config (on client-side only).\n *\n * BEWARE: It mutates the argument, and also returns it as the result,\n * for chaining.\n */\nfunction injectCsrfToken(cfg: ConfigT): ConfigT {\n // The safeguard for \"document\" is necessary because in non-Node environments,\n // like React Native, IS_CLIENT_SIDE is \"true\", however \"document\" and a bunch\n // of other browser-world features are not available.\n if (IS_CLIENT_SIDE && typeof document !== 'undefined') {\n // eslint-disable-next-line no-param-reassign\n cfg.CSRF = parseCookie(document.cookie).csrfToken;\n }\n\n return cfg;\n}\n\nexport function getConfig(sync: true): ConfigT;\n\nexport function getConfig<T extends ConfigT>(sync?: boolean): Promise<T> | T;\n\nexport function getConfig<T extends ConfigT>(sync?: boolean): Promise<T> | T {\n if (!config) {\n if (IS_CLIENT_SIDE) {\n const inj = clientGetInj();\n config = inj instanceof Promise\n ? inj.then((injection) => {\n const res = injectCsrfToken(injection.CONFIG ?? {});\n config = res;\n return res;\n })\n : injectCsrfToken(inj.CONFIG ?? {});\n } else {\n const weak = requireWeak<ConfigT>('config');\n if (!weak) throw Error('Internal error');\n config = weak;\n }\n }\n\n if (sync && (config instanceof Promise)) {\n throw Error('The config is not available yet');\n }\n\n return config as T;\n}\n"],"mappings":"AAAA,qBAEA,OAAS,WAAW,KAAQ,QAAQ,CAAC,MAE9B,aAAY,qCAEV,cAAc,+CACd,WAAW,oBAIpB,GAAI,OAA8C,CAElD;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,gBAAe,CAAC,GAAY,CAAW,CAC9C;AACA;AACA;AACA,GAAI,cAAc,EAAI,MAAO,SAAQ,GAAK,WAAW,CAAE,CACrD;AACA,GAAG,CAAC,IAAI,CAAG,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,SAAS,CACnD,CAEA,MAAO,IAAG,CACZ,CAMA,MAAO,SAAS,UAAS,CAAoB,IAAc,CAAkB,CAC3E,GAAI,CAAC,MAAM,CAAE,CACX,GAAI,cAAc,CAAE,CAClB,KAAM,IAAG,CAAG,YAAY,CAAC,CAAC,CAC1B,MAAM,CAAG,GAAG,WAAY,QAAO,CAC3B,GAAG,CAAC,IAAI,CAAE,SAAS,EAAK,CACxB,KAAM,IAAG,CAAG,eAAe,CAAC,SAAS,CAAC,MAAM,EAAI,CAAC,CAAC,CAAC,CACnD,MAAM,CAAG,GAAG,CACZ,MAAO,IAAG,CACZ,CAAC,CAAC,CACA,eAAe,CAAC,GAAG,CAAC,MAAM,EAAI,CAAC,CAAC,CAAC,CACvC,CAAC,IAAM,CACL,KAAM,KAAI,CAAG,WAAW,CAAU,QAAQ,CAAC,CAC3C,GAAI,CAAC,IAAI,CAAE,KAAM,MAAK,CAAC,gBAAgB,CAAC,CACxC,MAAM,CAAG,IAAI,CACf,CACF,CAEA,GAAI,IAAI,EAAK,MAAM,WAAY,QAAQ,CAAE,CACvC,KAAM,MAAK,CAAC,iCAAiC,CAAC,CAChD,CAEA,MAAO,OAAM,CACf","ignoreList":[]}
1
+ {"version":3,"file":"config.js","names":[],"sources":["../../../../src/shared/utils/config.ts"],"sourcesContent":["/* global document */\n\nimport { parseCookie } from 'cookie';\n\nimport clientGetInj from '../../client/getInj';\n\nimport { IS_CLIENT_SIDE } from './isomorphy/environment-check';\nimport { requireWeak } from './webpack';\n\ntype ConfigT = Record<string, unknown>;\n\nlet config: ConfigT | Promise<ConfigT> | undefined;\n\n/**\n * Injects CSRF token into config (on client-side only).\n *\n * BEWARE: It mutates the argument, and also returns it as the result,\n * for chaining.\n */\nfunction injectCsrfToken(cfg: ConfigT): ConfigT {\n // The safeguard for \"document\" is necessary because in non-Node environments,\n // like React Native, IS_CLIENT_SIDE is \"true\", however \"document\" and a bunch\n // of other browser-world features are not available.\n if (IS_CLIENT_SIDE && typeof document !== 'undefined') {\n // eslint-disable-next-line no-param-reassign\n cfg.CSRF = parseCookie(document.cookie).csrfToken;\n }\n\n return cfg;\n}\n\n// BEWARE: Removing generic type from this override messes up\n// type resolution in the host code in some scenarios.\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters\nexport function getConfig<T extends ConfigT>(sync: true): T;\n\nexport function getConfig<T extends ConfigT>(sync?: boolean): Promise<T> | T;\n\nexport function getConfig<T extends ConfigT>(sync?: boolean): Promise<T> | T {\n if (!config) {\n if (IS_CLIENT_SIDE) {\n const inj = clientGetInj();\n config = inj instanceof Promise\n ? inj.then((injection) => {\n const res = injectCsrfToken(injection.CONFIG ?? {});\n config = res;\n return res;\n })\n : injectCsrfToken(inj.CONFIG ?? {});\n } else {\n const weak = requireWeak<ConfigT>('config');\n if (!weak) throw Error('Internal error');\n config = weak;\n }\n }\n\n if (sync && (config instanceof Promise)) {\n throw Error('The config is not available yet');\n }\n\n return config as T;\n}\n"],"mappings":"AAAA,qBAEA,OAAS,WAAW,KAAQ,QAAQ,CAAC,MAE9B,aAAY,qCAEV,cAAc,+CACd,WAAW,oBAIpB,GAAI,OAA8C,CAElD;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,gBAAe,CAAC,GAAY,CAAW,CAC9C;AACA;AACA;AACA,GAAI,cAAc,EAAI,MAAO,SAAQ,GAAK,WAAW,CAAE,CACrD;AACA,GAAG,CAAC,IAAI,CAAG,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,SAAS,CACnD,CAEA,MAAO,IAAG,CACZ,CAEA;AACA;AACA;AAKA,MAAO,SAAS,UAAS,CAAoB,IAAc,CAAkB,CAC3E,GAAI,CAAC,MAAM,CAAE,CACX,GAAI,cAAc,CAAE,CAClB,KAAM,IAAG,CAAG,YAAY,CAAC,CAAC,CAC1B,MAAM,CAAG,GAAG,WAAY,QAAO,CAC3B,GAAG,CAAC,IAAI,CAAE,SAAS,EAAK,CACxB,KAAM,IAAG,CAAG,eAAe,CAAC,SAAS,CAAC,MAAM,EAAI,CAAC,CAAC,CAAC,CACnD,MAAM,CAAG,GAAG,CACZ,MAAO,IAAG,CACZ,CAAC,CAAC,CACA,eAAe,CAAC,GAAG,CAAC,MAAM,EAAI,CAAC,CAAC,CAAC,CACvC,CAAC,IAAM,CACL,KAAM,KAAI,CAAG,WAAW,CAAU,QAAQ,CAAC,CAC3C,GAAI,CAAC,IAAI,CAAE,KAAM,MAAK,CAAC,gBAAgB,CAAC,CACxC,MAAM,CAAG,IAAI,CACf,CACF,CAEA,GAAI,IAAI,EAAK,MAAM,WAAY,QAAQ,CAAE,CACvC,KAAM,MAAK,CAAC,iCAAiC,CAAC,CAChD,CAEA,MAAO,OAAM,CACf","ignoreList":[]}
@@ -1,4 +1,4 @@
1
1
  type ConfigT = Record<string, unknown>;
2
- export declare function getConfig(sync: true): ConfigT;
2
+ export declare function getConfig<T extends ConfigT>(sync: true): T;
3
3
  export declare function getConfig<T extends ConfigT>(sync?: boolean): Promise<T> | T;
4
4
  export {};
@@ -7,5 +7,8 @@
7
7
  // like React Native, IS_CLIENT_SIDE is "true", however "document" and a bunch
8
8
  // of other browser-world features are not available.
9
9
  if(IS_CLIENT_SIDE&&typeof document!=="undefined"){// eslint-disable-next-line no-param-reassign
10
- cfg.CSRF=parseCookie(document.cookie).csrfToken;}return cfg;}export function getConfig(sync){if(!config){if(IS_CLIENT_SIDE){const inj=clientGetInj();config=inj instanceof Promise?inj.then(injection=>{const res=injectCsrfToken(injection.CONFIG??{});config=res;return res;}):injectCsrfToken(inj.CONFIG??{});}else{const weak=requireWeak("config");if(!weak)throw Error("Internal error");config=weak;}}if(sync&&config instanceof Promise){throw Error("The config is not available yet");}return config;}
10
+ cfg.CSRF=parseCookie(document.cookie).csrfToken;}return cfg;}// BEWARE: Removing generic type from this override messes up
11
+ // type resolution in the host code in some scenarios.
12
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
13
+ export function getConfig(sync){if(!config){if(IS_CLIENT_SIDE){const inj=clientGetInj();config=inj instanceof Promise?inj.then(injection=>{const res=injectCsrfToken(injection.CONFIG??{});config=res;return res;}):injectCsrfToken(inj.CONFIG??{});}else{const weak=requireWeak("config");if(!weak)throw Error("Internal error");config=weak;}}if(sync&&config instanceof Promise){throw Error("The config is not available yet");}return config;}
11
14
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":[],"sources":["../../../../src/shared/utils/config.ts"],"sourcesContent":["/* global document */\n\nimport { parseCookie } from 'cookie';\n\nimport clientGetInj from '../../client/getInj';\n\nimport { IS_CLIENT_SIDE } from './isomorphy/environment-check';\nimport { requireWeak } from './webpack';\n\ntype ConfigT = Record<string, unknown>;\n\nlet config: ConfigT | Promise<ConfigT> | undefined;\n\n/**\n * Injects CSRF token into config (on client-side only).\n *\n * BEWARE: It mutates the argument, and also returns it as the result,\n * for chaining.\n */\nfunction injectCsrfToken(cfg: ConfigT): ConfigT {\n // The safeguard for \"document\" is necessary because in non-Node environments,\n // like React Native, IS_CLIENT_SIDE is \"true\", however \"document\" and a bunch\n // of other browser-world features are not available.\n if (IS_CLIENT_SIDE && typeof document !== 'undefined') {\n // eslint-disable-next-line no-param-reassign\n cfg.CSRF = parseCookie(document.cookie).csrfToken;\n }\n\n return cfg;\n}\n\nexport function getConfig(sync: true): ConfigT;\n\nexport function getConfig<T extends ConfigT>(sync?: boolean): Promise<T> | T;\n\nexport function getConfig<T extends ConfigT>(sync?: boolean): Promise<T> | T {\n if (!config) {\n if (IS_CLIENT_SIDE) {\n const inj = clientGetInj();\n config = inj instanceof Promise\n ? inj.then((injection) => {\n const res = injectCsrfToken(injection.CONFIG ?? {});\n config = res;\n return res;\n })\n : injectCsrfToken(inj.CONFIG ?? {});\n } else {\n const weak = requireWeak<ConfigT>('config');\n if (!weak) throw Error('Internal error');\n config = weak;\n }\n }\n\n if (sync && (config instanceof Promise)) {\n throw Error('The config is not available yet');\n }\n\n return config as T;\n}\n"],"mappings":"AAAA,qBAEA,OAAS,WAAW,KAAQ,QAAQ,CAAC,MAE9B,aAAY,qCAEV,cAAc,+CACd,WAAW,oBAIpB,GAAI,OAA8C,CAElD;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,gBAAe,CAAC,GAAY,CAAW,CAC9C;AACA;AACA;AACA,GAAI,cAAc,EAAI,MAAO,SAAQ,GAAK,WAAW,CAAE,CACrD;AACA,GAAG,CAAC,IAAI,CAAG,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,SAAS,CACnD,CAEA,MAAO,IAAG,CACZ,CAMA,MAAO,SAAS,UAAS,CAAoB,IAAc,CAAkB,CAC3E,GAAI,CAAC,MAAM,CAAE,CACX,GAAI,cAAc,CAAE,CAClB,KAAM,IAAG,CAAG,YAAY,CAAC,CAAC,CAC1B,MAAM,CAAG,GAAG,WAAY,QAAO,CAC3B,GAAG,CAAC,IAAI,CAAE,SAAS,EAAK,CACxB,KAAM,IAAG,CAAG,eAAe,CAAC,SAAS,CAAC,MAAM,EAAI,CAAC,CAAC,CAAC,CACnD,MAAM,CAAG,GAAG,CACZ,MAAO,IAAG,CACZ,CAAC,CAAC,CACA,eAAe,CAAC,GAAG,CAAC,MAAM,EAAI,CAAC,CAAC,CAAC,CACvC,CAAC,IAAM,CACL,KAAM,KAAI,CAAG,WAAW,CAAU,QAAQ,CAAC,CAC3C,GAAI,CAAC,IAAI,CAAE,KAAM,MAAK,CAAC,gBAAgB,CAAC,CACxC,MAAM,CAAG,IAAI,CACf,CACF,CAEA,GAAI,IAAI,EAAK,MAAM,WAAY,QAAQ,CAAE,CACvC,KAAM,MAAK,CAAC,iCAAiC,CAAC,CAChD,CAEA,MAAO,OAAM,CACf","ignoreList":[]}
1
+ {"version":3,"file":"config.js","names":[],"sources":["../../../../src/shared/utils/config.ts"],"sourcesContent":["/* global document */\n\nimport { parseCookie } from 'cookie';\n\nimport clientGetInj from '../../client/getInj';\n\nimport { IS_CLIENT_SIDE } from './isomorphy/environment-check';\nimport { requireWeak } from './webpack';\n\ntype ConfigT = Record<string, unknown>;\n\nlet config: ConfigT | Promise<ConfigT> | undefined;\n\n/**\n * Injects CSRF token into config (on client-side only).\n *\n * BEWARE: It mutates the argument, and also returns it as the result,\n * for chaining.\n */\nfunction injectCsrfToken(cfg: ConfigT): ConfigT {\n // The safeguard for \"document\" is necessary because in non-Node environments,\n // like React Native, IS_CLIENT_SIDE is \"true\", however \"document\" and a bunch\n // of other browser-world features are not available.\n if (IS_CLIENT_SIDE && typeof document !== 'undefined') {\n // eslint-disable-next-line no-param-reassign\n cfg.CSRF = parseCookie(document.cookie).csrfToken;\n }\n\n return cfg;\n}\n\n// BEWARE: Removing generic type from this override messes up\n// type resolution in the host code in some scenarios.\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters\nexport function getConfig<T extends ConfigT>(sync: true): T;\n\nexport function getConfig<T extends ConfigT>(sync?: boolean): Promise<T> | T;\n\nexport function getConfig<T extends ConfigT>(sync?: boolean): Promise<T> | T {\n if (!config) {\n if (IS_CLIENT_SIDE) {\n const inj = clientGetInj();\n config = inj instanceof Promise\n ? inj.then((injection) => {\n const res = injectCsrfToken(injection.CONFIG ?? {});\n config = res;\n return res;\n })\n : injectCsrfToken(inj.CONFIG ?? {});\n } else {\n const weak = requireWeak<ConfigT>('config');\n if (!weak) throw Error('Internal error');\n config = weak;\n }\n }\n\n if (sync && (config instanceof Promise)) {\n throw Error('The config is not available yet');\n }\n\n return config as T;\n}\n"],"mappings":"AAAA,qBAEA,OAAS,WAAW,KAAQ,QAAQ,CAAC,MAE9B,aAAY,qCAEV,cAAc,+CACd,WAAW,oBAIpB,GAAI,OAA8C,CAElD;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,gBAAe,CAAC,GAAY,CAAW,CAC9C;AACA;AACA;AACA,GAAI,cAAc,EAAI,MAAO,SAAQ,GAAK,WAAW,CAAE,CACrD;AACA,GAAG,CAAC,IAAI,CAAG,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,SAAS,CACnD,CAEA,MAAO,IAAG,CACZ,CAEA;AACA;AACA;AAKA,MAAO,SAAS,UAAS,CAAoB,IAAc,CAAkB,CAC3E,GAAI,CAAC,MAAM,CAAE,CACX,GAAI,cAAc,CAAE,CAClB,KAAM,IAAG,CAAG,YAAY,CAAC,CAAC,CAC1B,MAAM,CAAG,GAAG,WAAY,QAAO,CAC3B,GAAG,CAAC,IAAI,CAAE,SAAS,EAAK,CACxB,KAAM,IAAG,CAAG,eAAe,CAAC,SAAS,CAAC,MAAM,EAAI,CAAC,CAAC,CAAC,CACnD,MAAM,CAAG,GAAG,CACZ,MAAO,IAAG,CACZ,CAAC,CAAC,CACA,eAAe,CAAC,GAAG,CAAC,MAAM,EAAI,CAAC,CAAC,CAAC,CACvC,CAAC,IAAM,CACL,KAAM,KAAI,CAAG,WAAW,CAAU,QAAQ,CAAC,CAC3C,GAAI,CAAC,IAAI,CAAE,KAAM,MAAK,CAAC,gBAAgB,CAAC,CACxC,MAAM,CAAG,IAAI,CACf,CACF,CAEA,GAAI,IAAI,EAAK,MAAM,WAAY,QAAQ,CAAE,CACvC,KAAM,MAAK,CAAC,iCAAiC,CAAC,CAChD,CAEA,MAAO,OAAM,CACf","ignoreList":[]}
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.58.1",
2
+ "version": "1.58.3",
3
3
  "bin": {
4
4
  "react-utils-build": "bin/build.js",
5
5
  "react-utils-run-with-babel": "bin/run-with-babel.js",
@@ -36,7 +36,7 @@
36
36
  "raf": "^3.4.1",
37
37
  "react": "^19.3.1",
38
38
  "react-dom": "^19.3.1",
39
- "react-router": "^8.4.0",
39
+ "react-router": "^8.5.0",
40
40
  "request-ip": "^3.3.0",
41
41
  "rimraf": "^6.1.3",
42
42
  "serialize-javascript": "^7.1.2",
@@ -56,7 +56,7 @@
56
56
  "@dr.pogodin/babel-plugin-add-import-extension": "^3.0.2",
57
57
  "@dr.pogodin/babel-plugin-transform-assets": "^2.0.0",
58
58
  "@dr.pogodin/babel-preset-svgr": "^2.0.0",
59
- "@dr.pogodin/eslint-configs": "^0.3.9",
59
+ "@dr.pogodin/eslint-configs": "^0.3.10",
60
60
  "@jest/globals": "^30.5.2",
61
61
  "@pmmmwh/react-refresh-webpack-plugin": "^0.6.3",
62
62
  "@standard-schema/spec": "^1.1.0",
@@ -70,7 +70,7 @@
70
70
  "@types/cookie-parser": "^1.4.10",
71
71
  "@types/express": "^5.0.6",
72
72
  "@types/jest": "^30.0.0",
73
- "@types/lodash": "^4.17.26",
73
+ "@types/lodash": "^4.17.27",
74
74
  "@types/lodash-es": "^4.17.12",
75
75
  "@types/morgan": "^1.9.10",
76
76
  "@types/pretty": "^2.0.3",
@@ -100,9 +100,9 @@
100
100
  "postcss-scss": "^4.0.9",
101
101
  "pretty": "^2.0.0",
102
102
  "react-refresh": "^0.19.0",
103
- "sass": "^1.105.2",
103
+ "sass": "^1.106.0",
104
104
  "sass-loader": "^17.0.1",
105
- "sitemap": "^9.0.1",
105
+ "sitemap": "^10.0.0",
106
106
  "source-map-loader": "^5.0.0",
107
107
  "stylelint": "^17.16.0",
108
108
  "stylelint-config-standard-scss": "^17.0.0",