@webority/web-core 0.43.0 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{Logger as e}from"../logger/logger.js";import{lazy as t}from"react";var n=`webority.chunkReloadAt`,r=6e4,i=[/failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/importing a module script failed/i,/unable to preload css/i,/loading (css )?chunk [\w-]+ failed/i],a=e=>{if(!e||typeof e!=`object`)return!1;let{name:t,message:n}=e;return t===`ChunkLoadError`||typeof n==`string`&&i.some(e=>e.test(n))},o=()=>{try{let e=Number(globalThis.sessionStorage.getItem(n));return e>0&&Date.now()-e<r}catch{return!0}},s=()=>{try{return globalThis.sessionStorage.setItem(n,String(Date.now())),!0}catch{return!1}},c=()=>!o()&&s(),l=t=>()=>t().catch(t=>{if(!a(t)||!c())throw t;return e.warn(`[router] a code chunk failed to load; reloading once for the new build`,t),globalThis.location.reload(),new Promise(()=>void 0)}),u=e=>t(l(e));export{o as hasRecentlyReloaded,l as importWithReload,a as isChunkLoadError,u as lazyWithReload,s as markReloaded};
1
+ import{Logger as e}from"../logger/logger.js";import{lazy as t}from"react";var n=`webority.chunkReloadAt`,r=6e4,i=[/failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/importing a module script failed/i,/unable to preload css/i,/loading (css )?chunk [\w-]+ failed/i],a=e=>{if(!e||typeof e!=`object`)return!1;let{name:t,message:n}=e;return t===`ChunkLoadError`||typeof n==`string`&&i.some(e=>e.test(n))},o=()=>{try{let e=Number(globalThis.sessionStorage.getItem(n));return e>0&&Date.now()-e<r}catch{return!0}},s=()=>{try{return globalThis.sessionStorage.setItem(n,String(Date.now())),!0}catch{return!1}},c=()=>!o()&&s(),l=t=>()=>t().catch(t=>{if(!a(t)||!c())throw t;return e.warn(`[router] a code chunk failed to load; reloading once for the new build`,t),globalThis.location.reload(),new Promise(()=>void 0)}),u=e=>()=>l(e)().catch(e=>({Component(){throw e}})),d=e=>t(l(e));export{o as hasRecentlyReloaded,u as importWithReload,a as isChunkLoadError,d as lazyWithReload,s as markReloaded};
@@ -14,12 +14,17 @@ export declare const hasRecentlyReloaded: () => boolean;
14
14
  */
15
15
  export declare const markReloaded: () => boolean;
16
16
  /**
17
- * Wraps a dynamic import so a stale-deploy chunk failure reloads the page once.
18
- * Use it for a route object's `lazy` (`lazy: importWithReload(() => import('./routes/projects'))`);
19
- * `lazyWithReload` is the same for `React.lazy`.
17
+ * A route object's `lazy` (`lazy: importWithReload(() => import('./routes/projects'))`) that
18
+ * reloads the page once on a stale-deploy chunk failure.
19
+ *
20
+ * Any failure it cannot recover resolves to a route whose Component throws that error, so the
21
+ * route's errorElement shows it. Rejecting instead leaves react-router holding the route as still
22
+ * lazy, and it renders nothing below the nearest HydrateFallback: a blank page.
20
23
  */
21
- export declare const importWithReload: <T>(importFn: () => Promise<T>) => (() => Promise<T>);
22
- /** `React.lazy` with `importWithReload`: a lazy screen that recovers a tab opened before a deploy. */
24
+ export declare const importWithReload: <T extends object>(importFn: () => Promise<T>) => (() => Promise<T | {
25
+ Component: ComponentType;
26
+ }>);
27
+ /** `React.lazy` with the same one reload: a lazy screen that recovers a tab opened before a deploy. */
23
28
  export declare const lazyWithReload: <C extends ComponentType<any>>(importFn: () => Promise<{
24
29
  default: C;
25
30
  }>) => LazyExoticComponent<C>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/web-core",
3
- "version": "0.43.0",
3
+ "version": "0.45.0",
4
4
  "description": "Platform layer for Webority React web portals: HTTP clients with single-flight token refresh, auth store, API error extraction, RTK Query base query, logger, formatters, storage, version check and route guards. No UI.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",