@webority/web-core 0.58.1 → 0.59.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.
package/README.md CHANGED
@@ -23,8 +23,10 @@ store.
23
23
  | `query` | the RTK Query base query over `userClient`, the `createAppApi` preset, paged-list and tag helpers |
24
24
  | `redux` | `errorToastMiddleware`, `createRootReducer` with `resetState` (clears every slice on sign-out), the serializable-check paths |
25
25
  | `router` | loader guards (`requireAuth`, `publicOnly`, `requirePermission`, `withGuards`), element guards (`RequireAuth`, `PublicOnly`, `RequirePermission`), chunk-reload retry with its shared window (`hasRecentlyReloaded`, `markReloaded`), route error classification |
26
+ | `static` | `staticUrl(key)`: the versioned address of an authored static file (a video, a sample document) listed in the repo's `.webority/static.json` |
26
27
  | `storage` | `Storage` (async, the same API as mobile) and `syncStorage` (synchronous, web only) over `localStorage` |
27
28
  | `versionCheck` | `useVersionCheck` and `installReloadOnNavigate`: tells the portal a newer build is live |
29
+ | `vite` | `weborityStatic`, a Vite plugin that compiles `.webority/static.json` for `staticUrl` and can point the build's hashed files at a static host. Node only: import it in `vite.config`, never in app code |
28
30
 
29
31
  ## Install
30
32
 
@@ -233,6 +235,53 @@ web only: `getItem`, `setItem`, `removeItem`, `getJson`, `setJson` straight on `
233
235
  preference a first render cannot wait for. Neither throws: a blocked store reads as empty and a
234
236
  write returns `false`.
235
237
 
238
+ ## Static assets
239
+
240
+ Large files a person adds to a product (a hero video, sample PDFs) are listed in the repo's
241
+ `.webority/static.json` and served from a static host. Link one by its key, never by a bare path:
242
+
243
+ ```js
244
+ import { staticUrl } from "@webority/web-core/static";
245
+
246
+ staticUrl("samples/report.pdf"); // "/samples/report.pdf?v=0123456789ab"
247
+ ```
248
+
249
+ `staticUrl` returns `authoredOrigin + "/" + key + "?v=" + the first 12 hex of the file's sha256`, and
250
+ throws on a key that is not in the list. A same-origin `authoredOrigin` of `"/"` gives `/samples/...`.
251
+ The list is compiled into the bundle by the Vite plugin:
252
+
253
+ ```js
254
+ // vite.config.js
255
+ import { weborityStatic } from "@webority/web-core/vite";
256
+
257
+ export default defineConfig({
258
+ plugins: [weborityStatic({ authoredOrigin: settings.STATIC_AUTHORED_ORIGIN, buildOrigin: settings.STATIC_BUILD_ORIGIN })],
259
+ });
260
+ ```
261
+
262
+ ```js
263
+ // before the app renders
264
+ import staticAssets from "virtual:webority-static-assets";
265
+ import { initWebority } from "@webority/web-core";
266
+
267
+ initWebority({ baseUrl: settings.apiUrl, staticAssets });
268
+ ```
269
+
270
+ - Both origins are `"/"` (this host) or an absolute `https://` origin with no path and no trailing
271
+ slash. A blank value counts as unset.
272
+ - The plugin finds the nearest `.webority/static.json` above the Vite root (`manifest` names another
273
+ path). With no list, the virtual module is `null`, `staticUrl` throws, and nothing else changes.
274
+ - When a list is found, `authoredOrigin` is required. The build fails without it, and on an origin in
275
+ the wrong shape or a list entry without a 64-character sha256.
276
+ - `buildOrigin` is optional. Unset, the site serves the build exactly as Vite writes it. Set, a
277
+ `vite build` rewrites the URL of every hashed file in `index.html`, scripts and styles to
278
+ `<buildOrigin>/_static/<head>/<file>`, where `<head>` is the Vite root folder name lowercased with
279
+ dots turned into dashes. Files copied from `public/` stay on the site, and `vite` in development
280
+ keeps its own URLs. An absolute `buildOrigin` needs CORS headers, because module scripts load
281
+ cross-origin.
282
+ - Types for the virtual module: `declare module "virtual:webority-static-assets"` with a default
283
+ export of `StaticAssetsConfig | null`.
284
+
236
285
  ## Chunk reload
237
286
 
238
287
  `importWithReload` reloads once when a lazy chunk from an older deploy fails, and reloads the page
@@ -1 +1 @@
1
- var e=`warn`,t=3e4,n=3,r=`X-Correlation-Id`,i={baseUrl:null,loggingEnabled:!0,logLevel:e,environment:`Development`,appVersion:null,commit:null,appBuild:null,timeoutMs:t,retries:3,correlationIdHeader:r},a={...i},o=e=>{a={...a,...e}},s=()=>a;function c(e,t){let n=a[e];return n===null?t:n}var l=()=>{a={...i}};export{r as DEFAULT_CORRELATION_ID_HEADER,e as DEFAULT_LOG_LEVEL,n as DEFAULT_RETRIES,t as DEFAULT_TIMEOUT_MS,s as getConfig,c as getConfigValue,l as resetConfig,o as setConfig};
1
+ var e=`warn`,t=3e4,n=3,r=`X-Correlation-Id`,i={baseUrl:null,loggingEnabled:!0,logLevel:e,environment:`Development`,appVersion:null,commit:null,appBuild:null,timeoutMs:t,retries:3,correlationIdHeader:r,staticAssets:null},a={...i},o=e=>{a={...a,...e}},s=()=>a;function c(e,t){let n=a[e];return n===null?t:n}var l=()=>{a={...i}};export{r as DEFAULT_CORRELATION_ID_HEADER,e as DEFAULT_LOG_LEVEL,n as DEFAULT_RETRIES,t as DEFAULT_TIMEOUT_MS,s as getConfig,c as getConfigValue,l as resetConfig,o as setConfig};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{DEFAULT_CORRELATION_ID_HEADER as e,DEFAULT_LOG_LEVEL as t,DEFAULT_RETRIES as n,DEFAULT_TIMEOUT_MS as r,getConfig as i,getConfigValue as a,resetConfig as o,setConfig as s}from"./config/index.js";import{Logger as c,configureLogger as l,getDeviceContext as u,setDeviceContext as d,setRemoteLogger as f}from"./logger/logger.js";import{decodeJWT as p,getJWTExpiry as m,isJWTExpired as h}from"./auth/jwt.js";import{ACCESS_TOKEN_KEY as g,LEGACY_REFRESH_TOKEN_LIFETIME_MS as _,REFRESH_TOKEN_KEY as v,SESSION_USER_KEY as y,addSessionEndedListener as b,clearSession as x,getKeepSignedIn as S,getSessionUser as C,getToken as w,hasSession as T,hasSessionEndedInTab as E,removeSessionUser as D,removeToken as O,setKeepSignedIn as k,setLegacyTokenKeys as A,storeSessionUser as j,storeToken as M}from"./auth/authStore.js";import{addNetworkStatusListener as N,getNetworkStatus as P,setNetworkStatusImplementation as F,useNetworkStatus as I}from"./network/networkStatus.js";import{ACCOUNT_ID_HEADER as L,CLIENT_BUILD_HEADER as R,CLIENT_KIND as z,CLIENT_KIND_HEADER as B,getClientBuild as V}from"./api/clientHeaders.js";import{MIN_APP_VERSION_HEADER as H,addMinAppVersionListener as U,getMinAppVersion as W}from"./api/minAppVersion.js";import{applyRequestDefaults as G,newCorrelationId as K}from"./api/requestDefaults.js";import{WORKSPACE_CHANGED_CODE as q,WorkspaceChangedError as J,isWorkspaceChangedError as Y}from"./api/workspaceChanged.js";import{IDEMPOTENCY_KEY_HEADER as X,attachRetry as Z,isNeverSentError as Q,isRetryableFailure as $,isRetryableStatus as ee,retryAfterMs as te}from"./api/retry.js";import{REFRESH_LOCK_NAME as ne,withCrossTabRefreshLock as re}from"./api/crossTabRefreshLock.js";import ie from"./api/publicClient.js";import{SIGN_OUT_REASON_HEADER as ae,injectStore as oe,injectUserAuth as se,refreshAccessToken as ce,resetRefreshState as le}from"./api/tokenRefresh.js";import ue,{RequestOfflineError as de,SESSION_TERMINATION_CODES as fe}from"./api/userClient.js";import{initUserAuth as pe}from"./initUserAuth.js";import{CONTRACT_ERROR_CODE as me,NETWORK_CODE as he,OFFLINE_MESSAGE as ge,REQUEST_CANCELED_CODE as _e,SERVER_FAILURE_MESSAGE as ve,TIMEOUT_CODE as ye,TIMEOUT_MESSAGE as be,UNEXPECTED_MESSAGE as xe,apiErrorMessage as Se,extractApiError as Ce,isApiError as we,isNoResponse as Te,toFieldPath as Ee}from"./errors/extractApiError.js";import{configureFormatters as De,getFormatterConfig as Oe}from"./formatters/formatConfig.js";import{formatCurrency as ke}from"./formatters/currency.js";import{addDays as Ae}from"./formatters/dateMath.js";import{formatDate as je,formatDateTime as Me,formatMinor as Ne,formatNumber as Pe,formatPercent as Fe,formatRelative as Ie,formatTime as Le}from"./formatters/house.js";import{initWebority as Re}from"./initSDK.js";import{createApiBaseQuery as ze}from"./query/apiBaseQuery.js";import{APP_API_DEFAULTS as Be,createAppApi as Ve}from"./query/createAppApi.js";import{setupApiListeners as He}from"./query/listeners.js";import{buildListQuery as Ue,getNextPageParam as We,getPreviousPageParam as Ge,hasNextPage as Ke,hasPreviousPage as qe}from"./query/paging.js";import{LIST_TAG_ID as Je,itemTag as Ye,listTag as Xe,providesList as Ze,providesPagedList as Qe}from"./query/tags.js";import{errorToastMiddleware as $e,isSilentRejection as et}from"./redux/errorToastMiddleware.js";import{createRootReducer as tt,resetState as nt}from"./redux/rootReducer.js";import{SERIALIZABLE_IGNORED_ACTION_PATHS as rt}from"./redux/serializableCheck.js";import{hasRecentlyReloaded as it,importWithReload as at,isChunkLoadError as ot,lazyWithReload as st,markReloaded as ct}from"./router/chunkReload.js";import{hasPermission as lt}from"./router/permissions.js";import{RETURN_TO_PARAM as ut,buildLoginPath as dt,getReturnTo as ft,toSafeReturnTo as pt}from"./router/returnTo.js";import{PublicOnly as mt,RequireAuth as ht,RequirePermission as gt}from"./router/guards.js";import{publicOnly as _t,requireAuth as vt,requirePermission as yt,withGuards as bt}from"./router/loaders.js";import{classifyRouteError as xt,useRouteErrorReport as St}from"./router/routeError.js";import{Storage as Ct,isStorageAvailable as wt,setStorageImplementation as Tt,syncStorage as Et}from"./storage/index.js";import{isBuildBelowMinimum as Dt,parseBuildNumber as Ot}from"./versionCheck/buildNumber.js";import{installReloadOnNavigate as kt,isUpdateAvailable as At,useVersionCheck as jt}from"./versionCheck/index.js";export{g as ACCESS_TOKEN_KEY,L as ACCOUNT_ID_HEADER,Be as APP_API_DEFAULTS,R as CLIENT_BUILD_HEADER,z as CLIENT_KIND,B as CLIENT_KIND_HEADER,me as CONTRACT_ERROR_CODE,e as DEFAULT_CORRELATION_ID_HEADER,t as DEFAULT_LOG_LEVEL,n as DEFAULT_RETRIES,r as DEFAULT_TIMEOUT_MS,X as IDEMPOTENCY_KEY_HEADER,_ as LEGACY_REFRESH_TOKEN_LIFETIME_MS,Je as LIST_TAG_ID,c as Logger,H as MIN_APP_VERSION_HEADER,he as NETWORK_CODE,ge as OFFLINE_MESSAGE,mt as PublicOnly,ne as REFRESH_LOCK_NAME,v as REFRESH_TOKEN_KEY,_e as REQUEST_CANCELED_CODE,ut as RETURN_TO_PARAM,de as RequestOfflineError,ht as RequireAuth,gt as RequirePermission,rt as SERIALIZABLE_IGNORED_ACTION_PATHS,ve as SERVER_FAILURE_MESSAGE,fe as SESSION_TERMINATION_CODES,y as SESSION_USER_KEY,ae as SIGN_OUT_REASON_HEADER,Ct as Storage,ye as TIMEOUT_CODE,be as TIMEOUT_MESSAGE,xe as UNEXPECTED_MESSAGE,q as WORKSPACE_CHANGED_CODE,J as WorkspaceChangedError,Ae as addDays,U as addMinAppVersionListener,N as addNetworkStatusListener,b as addSessionEndedListener,Se as apiErrorMessage,G as applyRequestDefaults,Z as attachRetry,Ue as buildListQuery,dt as buildLoginPath,xt as classifyRouteError,x as clearSession,De as configureFormatters,l as configureLogger,ze as createApiBaseQuery,Ve as createAppApi,tt as createRootReducer,p as decodeJWT,$e as errorToastMiddleware,Ce as extractApiError,ke as formatCurrency,je as formatDate,Me as formatDateTime,Ne as formatMinor,Pe as formatNumber,Fe as formatPercent,Ie as formatRelative,Le as formatTime,V as getClientBuild,i as getConfig,a as getConfigValue,u as getDeviceContext,Oe as getFormatterConfig,m as getJWTExpiry,S as getKeepSignedIn,W as getMinAppVersion,P as getNetworkStatus,We as getNextPageParam,Ge as getPreviousPageParam,ft as getReturnTo,C as getSessionUser,w as getToken,Ke as hasNextPage,lt as hasPermission,qe as hasPreviousPage,it as hasRecentlyReloaded,T as hasSession,E as hasSessionEndedInTab,at as importWithReload,pe as initUserAuth,Re as initWebority,oe as injectStore,se as injectUserAuth,kt as installReloadOnNavigate,we as isApiError,Dt as isBuildBelowMinimum,ot as isChunkLoadError,h as isJWTExpired,Q as isNeverSentError,Te as isNoResponse,$ as isRetryableFailure,ee as isRetryableStatus,et as isSilentRejection,wt as isStorageAvailable,At as isUpdateAvailable,Y as isWorkspaceChangedError,Ye as itemTag,st as lazyWithReload,Xe as listTag,ct as markReloaded,K as newCorrelationId,Ot as parseBuildNumber,Ze as providesList,Qe as providesPagedList,ie as publicClient,_t as publicOnly,ce as refreshAccessToken,D as removeSessionUser,O as removeToken,vt as requireAuth,yt as requirePermission,o as resetConfig,le as resetRefreshState,nt as resetState,te as retryAfterMs,s as setConfig,d as setDeviceContext,k as setKeepSignedIn,A as setLegacyTokenKeys,F as setNetworkStatusImplementation,f as setRemoteLogger,Tt as setStorageImplementation,He as setupApiListeners,j as storeSessionUser,M as storeToken,Et as syncStorage,Ee as toFieldPath,pt as toSafeReturnTo,I as useNetworkStatus,St as useRouteErrorReport,jt as useVersionCheck,ue as userClient,re as withCrossTabRefreshLock,bt as withGuards};
1
+ import{DEFAULT_CORRELATION_ID_HEADER as e,DEFAULT_LOG_LEVEL as t,DEFAULT_RETRIES as n,DEFAULT_TIMEOUT_MS as r,getConfig as i,getConfigValue as a,resetConfig as o,setConfig as s}from"./config/index.js";import{Logger as c,configureLogger as l,getDeviceContext as u,setDeviceContext as d,setRemoteLogger as f}from"./logger/logger.js";import{decodeJWT as p,getJWTExpiry as m,isJWTExpired as h}from"./auth/jwt.js";import{ACCESS_TOKEN_KEY as g,LEGACY_REFRESH_TOKEN_LIFETIME_MS as _,REFRESH_TOKEN_KEY as v,SESSION_USER_KEY as y,addSessionEndedListener as b,clearSession as x,getKeepSignedIn as S,getSessionUser as C,getToken as w,hasSession as T,hasSessionEndedInTab as E,removeSessionUser as D,removeToken as O,setKeepSignedIn as k,setLegacyTokenKeys as A,storeSessionUser as j,storeToken as M}from"./auth/authStore.js";import{addNetworkStatusListener as N,getNetworkStatus as P,setNetworkStatusImplementation as F,useNetworkStatus as I}from"./network/networkStatus.js";import{ACCOUNT_ID_HEADER as L,CLIENT_BUILD_HEADER as R,CLIENT_KIND as z,CLIENT_KIND_HEADER as B,getClientBuild as V}from"./api/clientHeaders.js";import{MIN_APP_VERSION_HEADER as H,addMinAppVersionListener as U,getMinAppVersion as W}from"./api/minAppVersion.js";import{applyRequestDefaults as G,newCorrelationId as K}from"./api/requestDefaults.js";import{WORKSPACE_CHANGED_CODE as q,WorkspaceChangedError as J,isWorkspaceChangedError as Y}from"./api/workspaceChanged.js";import{IDEMPOTENCY_KEY_HEADER as X,attachRetry as Z,isNeverSentError as Q,isRetryableFailure as $,isRetryableStatus as ee,retryAfterMs as te}from"./api/retry.js";import{REFRESH_LOCK_NAME as ne,withCrossTabRefreshLock as re}from"./api/crossTabRefreshLock.js";import ie from"./api/publicClient.js";import{SIGN_OUT_REASON_HEADER as ae,injectStore as oe,injectUserAuth as se,refreshAccessToken as ce,resetRefreshState as le}from"./api/tokenRefresh.js";import ue,{RequestOfflineError as de,SESSION_TERMINATION_CODES as fe}from"./api/userClient.js";import{initUserAuth as pe}from"./initUserAuth.js";import{CONTRACT_ERROR_CODE as me,NETWORK_CODE as he,OFFLINE_MESSAGE as ge,REQUEST_CANCELED_CODE as _e,SERVER_FAILURE_MESSAGE as ve,TIMEOUT_CODE as ye,TIMEOUT_MESSAGE as be,UNEXPECTED_MESSAGE as xe,apiErrorMessage as Se,extractApiError as Ce,isApiError as we,isNoResponse as Te,toFieldPath as Ee}from"./errors/extractApiError.js";import{configureFormatters as De,getFormatterConfig as Oe}from"./formatters/formatConfig.js";import{formatCurrency as ke}from"./formatters/currency.js";import{addDays as Ae}from"./formatters/dateMath.js";import{formatDate as je,formatDateTime as Me,formatMinor as Ne,formatNumber as Pe,formatPercent as Fe,formatRelative as Ie,formatTime as Le}from"./formatters/house.js";import{initWebority as Re}from"./initSDK.js";import{createApiBaseQuery as ze}from"./query/apiBaseQuery.js";import{APP_API_DEFAULTS as Be,createAppApi as Ve}from"./query/createAppApi.js";import{setupApiListeners as He}from"./query/listeners.js";import{buildListQuery as Ue,getNextPageParam as We,getPreviousPageParam as Ge,hasNextPage as Ke,hasPreviousPage as qe}from"./query/paging.js";import{LIST_TAG_ID as Je,itemTag as Ye,listTag as Xe,providesList as Ze,providesPagedList as Qe}from"./query/tags.js";import{errorToastMiddleware as $e,isSilentRejection as et}from"./redux/errorToastMiddleware.js";import{createRootReducer as tt,resetState as nt}from"./redux/rootReducer.js";import{SERIALIZABLE_IGNORED_ACTION_PATHS as rt}from"./redux/serializableCheck.js";import{hasRecentlyReloaded as it,importWithReload as at,isChunkLoadError as ot,lazyWithReload as st,markReloaded as ct}from"./router/chunkReload.js";import{hasPermission as lt}from"./router/permissions.js";import{RETURN_TO_PARAM as ut,buildLoginPath as dt,getReturnTo as ft,toSafeReturnTo as pt}from"./router/returnTo.js";import{PublicOnly as mt,RequireAuth as ht,RequirePermission as gt}from"./router/guards.js";import{publicOnly as _t,requireAuth as vt,requirePermission as yt,withGuards as bt}from"./router/loaders.js";import{classifyRouteError as xt,useRouteErrorReport as St}from"./router/routeError.js";import{staticUrl as Ct}from"./static/index.js";import{Storage as wt,isStorageAvailable as Tt,setStorageImplementation as Et,syncStorage as Dt}from"./storage/index.js";import{isBuildBelowMinimum as Ot,parseBuildNumber as kt}from"./versionCheck/buildNumber.js";import{installReloadOnNavigate as At,isUpdateAvailable as jt,useVersionCheck as Mt}from"./versionCheck/index.js";export{g as ACCESS_TOKEN_KEY,L as ACCOUNT_ID_HEADER,Be as APP_API_DEFAULTS,R as CLIENT_BUILD_HEADER,z as CLIENT_KIND,B as CLIENT_KIND_HEADER,me as CONTRACT_ERROR_CODE,e as DEFAULT_CORRELATION_ID_HEADER,t as DEFAULT_LOG_LEVEL,n as DEFAULT_RETRIES,r as DEFAULT_TIMEOUT_MS,X as IDEMPOTENCY_KEY_HEADER,_ as LEGACY_REFRESH_TOKEN_LIFETIME_MS,Je as LIST_TAG_ID,c as Logger,H as MIN_APP_VERSION_HEADER,he as NETWORK_CODE,ge as OFFLINE_MESSAGE,mt as PublicOnly,ne as REFRESH_LOCK_NAME,v as REFRESH_TOKEN_KEY,_e as REQUEST_CANCELED_CODE,ut as RETURN_TO_PARAM,de as RequestOfflineError,ht as RequireAuth,gt as RequirePermission,rt as SERIALIZABLE_IGNORED_ACTION_PATHS,ve as SERVER_FAILURE_MESSAGE,fe as SESSION_TERMINATION_CODES,y as SESSION_USER_KEY,ae as SIGN_OUT_REASON_HEADER,wt as Storage,ye as TIMEOUT_CODE,be as TIMEOUT_MESSAGE,xe as UNEXPECTED_MESSAGE,q as WORKSPACE_CHANGED_CODE,J as WorkspaceChangedError,Ae as addDays,U as addMinAppVersionListener,N as addNetworkStatusListener,b as addSessionEndedListener,Se as apiErrorMessage,G as applyRequestDefaults,Z as attachRetry,Ue as buildListQuery,dt as buildLoginPath,xt as classifyRouteError,x as clearSession,De as configureFormatters,l as configureLogger,ze as createApiBaseQuery,Ve as createAppApi,tt as createRootReducer,p as decodeJWT,$e as errorToastMiddleware,Ce as extractApiError,ke as formatCurrency,je as formatDate,Me as formatDateTime,Ne as formatMinor,Pe as formatNumber,Fe as formatPercent,Ie as formatRelative,Le as formatTime,V as getClientBuild,i as getConfig,a as getConfigValue,u as getDeviceContext,Oe as getFormatterConfig,m as getJWTExpiry,S as getKeepSignedIn,W as getMinAppVersion,P as getNetworkStatus,We as getNextPageParam,Ge as getPreviousPageParam,ft as getReturnTo,C as getSessionUser,w as getToken,Ke as hasNextPage,lt as hasPermission,qe as hasPreviousPage,it as hasRecentlyReloaded,T as hasSession,E as hasSessionEndedInTab,at as importWithReload,pe as initUserAuth,Re as initWebority,oe as injectStore,se as injectUserAuth,At as installReloadOnNavigate,we as isApiError,Ot as isBuildBelowMinimum,ot as isChunkLoadError,h as isJWTExpired,Q as isNeverSentError,Te as isNoResponse,$ as isRetryableFailure,ee as isRetryableStatus,et as isSilentRejection,Tt as isStorageAvailable,jt as isUpdateAvailable,Y as isWorkspaceChangedError,Ye as itemTag,st as lazyWithReload,Xe as listTag,ct as markReloaded,K as newCorrelationId,kt as parseBuildNumber,Ze as providesList,Qe as providesPagedList,ie as publicClient,_t as publicOnly,ce as refreshAccessToken,D as removeSessionUser,O as removeToken,vt as requireAuth,yt as requirePermission,o as resetConfig,le as resetRefreshState,nt as resetState,te as retryAfterMs,s as setConfig,d as setDeviceContext,k as setKeepSignedIn,A as setLegacyTokenKeys,F as setNetworkStatusImplementation,f as setRemoteLogger,Et as setStorageImplementation,He as setupApiListeners,Ct as staticUrl,j as storeSessionUser,M as storeToken,Dt as syncStorage,Ee as toFieldPath,pt as toSafeReturnTo,I as useNetworkStatus,St as useRouteErrorReport,Mt as useVersionCheck,ue as userClient,re as withCrossTabRefreshLock,bt as withGuards};
package/dist/initSDK.js CHANGED
@@ -1 +1 @@
1
- import{DEFAULT_CORRELATION_ID_HEADER as e,setConfig as t}from"./config/index.js";import{Logger as n}from"./logger/logger.js";var r=r=>{if(typeof r.baseUrl!=`string`)throw Error(`baseUrl is required for Webority packages initialization`);t({baseUrl:r.baseUrl,loggingEnabled:r.loggingEnabled??!0,logLevel:r.logLevel??`warn`,environment:r.environment??`Development`,appVersion:r.appVersion??null,commit:r.commit??null,appBuild:r.appBuild??null,timeoutMs:r.timeoutMs??3e4,retries:r.retries??3,correlationIdHeader:r.correlationIdHeader===void 0?e:r.correlationIdHeader}),n.info(`[@webority/web-core] initialized`)};export{r as initWebority};
1
+ import{DEFAULT_CORRELATION_ID_HEADER as e,setConfig as t}from"./config/index.js";import{Logger as n}from"./logger/logger.js";var r=r=>{if(typeof r.baseUrl!=`string`)throw Error(`baseUrl is required for Webority packages initialization`);t({baseUrl:r.baseUrl,loggingEnabled:r.loggingEnabled??!0,logLevel:r.logLevel??`warn`,environment:r.environment??`Development`,appVersion:r.appVersion??null,commit:r.commit??null,appBuild:r.appBuild??null,timeoutMs:r.timeoutMs??3e4,retries:r.retries??3,correlationIdHeader:r.correlationIdHeader===void 0?e:r.correlationIdHeader,staticAssets:r.staticAssets??null}),n.info(`[@webority/web-core] initialized`)};export{r as initWebority};
@@ -0,0 +1 @@
1
+ import{getConfig as e}from"../config/index.js";function t(t){let n=e().staticAssets;if(n===null)throw Error(`staticUrl("${t}"): config.staticAssets is not set. Add weborityStatic() to the Vite config and pass its virtual module to initWebority.`);if(!Object.hasOwn(n.versions,t))throw Error(`staticUrl("${t}"): the key is not in .webority/static.json.`);return`${n.authoredOrigin===`/`?``:n.authoredOrigin}/${t}?v=${n.versions[t]}`}export{t as staticUrl};
@@ -2,8 +2,10 @@
2
2
  * Configuration for Webority packages. The app sets it once at startup
3
3
  * (`initWebority` or `setConfig`); every module reads it on use, so a value set
4
4
  * after import still applies. Names and shape mirror `@webority/mobile-core`;
5
- * the store keys (`country`, `appId`, `appStoreId`, `logCurl`) stay mobile only.
5
+ * the store keys (`country`, `appId`, `appStoreId`, `logCurl`) stay mobile only, and `staticAssets`
6
+ * is web only.
6
7
  */
8
+ import type { StaticAssetsConfig } from "../static";
7
9
  export type LogLevel = "debug" | "info" | "warn" | "error";
8
10
  export type Environment = "Development" | "Production" | "Staging";
9
11
  export interface Config {
@@ -37,6 +39,11 @@ export interface Config {
37
39
  * sends none. Default `'X-Correlation-Id'`.
38
40
  */
39
41
  correlationIdHeader: string | null;
42
+ /**
43
+ * The authored static assets the portal links by key, compiled from `.webority/static.json` by the
44
+ * `weborityStatic` Vite plugin. `staticUrl` reads it. `null` when the portal has no list. Web only.
45
+ */
46
+ staticAssets: StaticAssetsConfig | null;
40
47
  }
41
48
  /**
42
49
  * A library build has no reliable development signal, so the default is the
@@ -16,5 +16,6 @@ export * from "./network";
16
16
  export * from "./query";
17
17
  export * from "./redux";
18
18
  export * from "./router";
19
+ export * from "./static";
19
20
  export * from "./storage";
20
21
  export * from "./versionCheck";
@@ -1,4 +1,5 @@
1
1
  import { type Environment, type LogLevel } from "./config";
2
+ import type { StaticAssetsConfig } from "./static";
2
3
  export interface InitConfig {
3
4
  /**
4
5
  * Your API base URL (required). `""` sends every request to the page's own origin, for an
@@ -23,6 +24,8 @@ export interface InitConfig {
23
24
  retries?: number;
24
25
  /** Header for the per-request correlation id. Defaults to `'X-Correlation-Id'`; `null` sends none. */
25
26
  correlationIdHeader?: string | null;
27
+ /** The default export of `virtual:webority-static-assets` (the `weborityStatic` Vite plugin); `staticUrl` reads it. Defaults to `null`. Web only. */
28
+ staticAssets?: StaticAssetsConfig | null;
26
29
  }
27
30
  /**
28
31
  * Initialize Webority packages with the portal's configuration. Same name and
@@ -0,0 +1,9 @@
1
+ /** Authored static assets, compiled from the repo's .webority/static.json by the Vite plugin (web) or mobile-tools prebuild (mobile). */
2
+ export interface StaticAssetsConfig {
3
+ /** "/" or an absolute https origin, no trailing slash. */
4
+ authoredOrigin: string;
5
+ /** key -> the first 12 hex of the asset's sha256. */
6
+ versions: Readonly<Record<string, string>>;
7
+ }
8
+ /** authoredOrigin + "/" + key + "?v=" + version. Throws on an unknown key, or when config.staticAssets is null. */
9
+ export declare function staticUrl(key: string): string;
@@ -0,0 +1,15 @@
1
+ /** The virtual module the plugin serves: `export default StaticAssetsConfig | null`. */
2
+ export declare const STATIC_ASSETS_MODULE_ID = "virtual:webority-static-assets";
3
+ export interface WeborityStaticOptions {
4
+ /** "/" or an absolute https origin; required when a .webority/static.json is found above the Vite root. */
5
+ authoredOrigin?: string | null;
6
+ /** null: the site serves its build; "/" or an absolute https origin: hashed assets resolve to <origin>/_static/<head>/<file>. */
7
+ buildOrigin?: string | null;
8
+ /** Path to static.json; default the nearest .webority/static.json above the Vite root. */
9
+ manifest?: string;
10
+ }
11
+ /** A Vite plugin (structural type; vite is not a dependency). head = the Vite root folder name, lowercased, dots to dashes. */
12
+ export declare function weborityStatic(options?: WeborityStaticOptions): {
13
+ name: string;
14
+ enforce?: "pre";
15
+ } & Record<string, unknown>;
@@ -0,0 +1 @@
1
+ import{existsSync as e,readFileSync as t}from"node:fs";import{basename as n,dirname as r,join as i,resolve as a}from"node:path";var o=`virtual:webority-static-assets`,s=`\0${o}`,c=i(`.webority`,`static.json`),l=/^https:\/\/[a-z0-9.-]+(:\d+)?$/,u=/^[0-9a-f]{64}$/,d=12,f=`export default null;`;function p(e,t){let n=t?.trim();if(!n)return null;if(n!==`/`&&!l.test(n))throw Error(`weborityStatic: ${e} must be "/" or an https origin with no path and no trailing slash, got "${n}".`);return n}function m(t){let n=i(t,c);if(e(n))return n;let a=r(t);return a===t?null:m(a)}function h(e){let n;try{n=JSON.parse(t(e,`utf8`))}catch(t){throw Error(`weborityStatic: cannot read ${e}: ${t instanceof Error?t.message:String(t)}`)}let r=n?.assets;if(typeof r!=`object`||!r||Array.isArray(r))throw Error(`weborityStatic: ${e} has no "assets" object.`);let i={};for(let[t,n]of Object.entries(r)){let r=n?.sha256;if(typeof r!=`string`||!u.test(r))throw Error(`weborityStatic: ${e} asset "${t}" needs a sha256 of 64 lowercase hex characters.`);i[t]=r.slice(0,d)}return i}function g(e={}){let t=p(`authoredOrigin`,e.authoredOrigin),r=p(`buildOrigin`,e.buildOrigin),i=``,o=f;return{name:`webority-static`,enforce:`pre`,config(e,t){if(r===null||t.command!==`build`)return;let n=r===`/`?``:r;return{experimental:{renderBuiltUrl:(e,t)=>t.type===`public`?void 0:`${n}/_static/${i}/${e.replace(/^\/+/,``)}`}}},configResolved(s){let c=a(s.root);if(i=n(c).toLowerCase().replaceAll(`.`,`-`),r!==null&&i===``)throw Error(`weborityStatic: cannot name the head from the Vite root "${c}".`);let l=e.manifest?a(c,e.manifest):m(c);if(l===null){o=f;return}if(t===null)throw Error(`weborityStatic: ${l} exists, so authoredOrigin is required ("/" or an https origin).`);o=`export default ${JSON.stringify({authoredOrigin:t,versions:h(l)})};`},resolveId(e){return e===`virtual:webority-static-assets`?s:null},load(e){return e===s?o:null}}}export{o as STATIC_ASSETS_MODULE_ID,g as weborityStatic};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/web-core",
3
- "version": "0.58.1",
3
+ "version": "0.59.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",
@@ -62,6 +62,10 @@
62
62
  "types": "./dist/types/router/index.d.ts",
63
63
  "default": "./dist/router/index.js"
64
64
  },
65
+ "./static": {
66
+ "types": "./dist/types/static/index.d.ts",
67
+ "default": "./dist/static/index.js"
68
+ },
65
69
  "./storage": {
66
70
  "types": "./dist/types/storage/index.d.ts",
67
71
  "default": "./dist/storage/index.js"
@@ -70,6 +74,10 @@
70
74
  "types": "./dist/types/versionCheck/index.d.ts",
71
75
  "default": "./dist/versionCheck/index.js"
72
76
  },
77
+ "./vite": {
78
+ "types": "./dist/types/vite/index.d.ts",
79
+ "default": "./dist/vite/index.js"
80
+ },
73
81
  "./package.json": "./package.json"
74
82
  },
75
83
  "sideEffects": false,