for real now
This commit is contained in:
parent
f05d462a73
commit
b22d4622ed
|
@ -17,7 +17,7 @@ export const SYM_LAZY_COMPONENT_INNER = Symbol.for("vencord.lazyComponent.inner"
|
||||||
* @param attempts How many times to try to get the component before giving up
|
* @param attempts How many times to try to get the component before giving up
|
||||||
* @returns Result of factory function
|
* @returns Result of factory function
|
||||||
*/
|
*/
|
||||||
export function LazyComponent<T extends object = any>(factory: () => LazyComponentType<T>, attempts = 5) {
|
export function LazyComponent<T extends object = any>(factory: () => LazyComponentType<T>, attempts = 5, errMsg: string | (() => string) = `LazyComponent factory failed:\n\n${factory}`) {
|
||||||
const get = makeLazy(factory, attempts, { isIndirect: true });
|
const get = makeLazy(factory, attempts, { isIndirect: true });
|
||||||
|
|
||||||
let InnerComponent = null as LazyComponentType<T> | null;
|
let InnerComponent = null as LazyComponentType<T> | null;
|
||||||
|
@ -37,7 +37,7 @@ export function LazyComponent<T extends object = any>(factory: () => LazyCompone
|
||||||
lazyFailedLogged = true;
|
lazyFailedLogged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.error(`LazyComponent factory failed:\n\n${factory}`);
|
console.error(typeof errMsg === "string" ? errMsg : errMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
return InnerComponent && <InnerComponent {...props} />;
|
return InnerComponent && <InnerComponent {...props} />;
|
||||||
|
|
|
@ -588,7 +588,7 @@ export function webpackDependantLazy<T = any>(factory: () => T, attempts?: numbe
|
||||||
export function webpackDependantLazyComponent<T extends object = any>(factory: () => any, attempts?: number) {
|
export function webpackDependantLazyComponent<T extends object = any>(factory: () => any, attempts?: number) {
|
||||||
if (IS_REPORTER) webpackSearchHistory.push(["webpackDependantLazyComponent", [factory]]);
|
if (IS_REPORTER) webpackSearchHistory.push(["webpackDependantLazyComponent", [factory]]);
|
||||||
|
|
||||||
return LazyComponent<T>(factory, attempts);
|
return LazyComponent<T>(factory, attempts, `Webpack dependant LazyComponent factory failed:\n\n${factory}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DefaultExtractAndLoadChunksRegex = /(?:(?:Promise\.all\(\[)?(\i\.e\("?[^)]+?"?\)[^\]]*?)(?:\]\))?|Promise\.resolve\(\))\.then\(\i\.bind\(\i,"?([^)]+?)"?\)\)/;
|
export const DefaultExtractAndLoadChunksRegex = /(?:(?:Promise\.all\(\[)?(\i\.e\("?[^)]+?"?\)[^\]]*?)(?:\]\))?|Promise\.resolve\(\))\.then\(\i\.bind\(\i,"?([^)]+?)"?\)\)/;
|
||||||
|
|
Loading…
Reference in a new issue