@webority/web-core 0.89.0 → 0.91.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,10 +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
+ | `static` | `staticUrl(key)`: the versioned address of an authored static file (a video, a sample document) listed in the `staticAssets.assets` object of the one deployable carrying `staticAssets` in the repo's `.webority/infra/deployables.json` |
27
27
  | `storage` | `Storage` (async, the same API as mobile) and `syncStorage` (synchronous, web only) over `localStorage` |
28
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 |
29
+ | `vite` | `weborityStatic`, a Vite plugin that compiles the `staticAssets` list of `.webority/infra/deployables.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 |
30
30
 
31
31
  ## Install
32
32
 
@@ -239,7 +239,7 @@ write returns `false`.
239
239
  ## Static assets
240
240
 
241
241
  Large files a person adds to a product (a hero video, sample PDFs) are listed in the repo's
242
- `.webority/static.json` and served from a static host. Link one by its key, never by a bare path:
242
+ `staticAssets.assets` object of the one deployable carrying `staticAssets` in the repo's `.webority/infra/deployables.json`, and served from a static host. Link one by its key, never by a bare path:
243
243
 
244
244
  ```js
245
245
  import { staticUrl } from "@webority/web-core/static";
@@ -270,8 +270,10 @@ initWebority({ baseUrl: settings.apiUrl, staticAssets });
270
270
 
271
271
  - Both origins are `"/"` (this host) or an absolute `https://` origin with no path and no trailing
272
272
  slash. A blank value counts as unset.
273
- - The plugin finds the nearest `.webority/static.json` above the Vite root (`manifest` names another
274
- path). With no list, the virtual module is `null`, `staticUrl` throws, and nothing else changes.
273
+ - The plugin finds the nearest `.webority/infra/deployables.json` above the Vite root (`manifest` names
274
+ another path). With no carrier and no `authoredOrigin`, the virtual module is `null`, `staticUrl`
275
+ throws, and nothing else changes. With `authoredOrigin` set and no carrier, or with two or more
276
+ carriers, the build fails.
275
277
  - When a list is found, `authoredOrigin` is required. The build fails without it, and on an origin in
276
278
  the wrong shape or a list entry without a 64-character sha256.
277
279
  - `buildOrigin` is optional. Unset, the site serves the build exactly as Vite writes it. Set, a
@@ -1 +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};
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 the static asset list (.webority/infra/deployables.json).`);return`${n.authoredOrigin===`/`?``:n.authoredOrigin}/${t}?v=${n.versions[t]}`}export{t as staticUrl};
@@ -49,7 +49,7 @@ export interface Config {
49
49
  */
50
50
  correlationIdHeader: string | null;
51
51
  /**
52
- * The authored static assets the portal links by key, compiled from `.webority/static.json` by the
52
+ * The authored static assets the portal links by key, compiled from the static deployable in `.webority/infra/deployables.json` by the
53
53
  * `weborityStatic` Vite plugin. `staticUrl` reads it. `null` when the portal has no list. Web only.
54
54
  */
55
55
  staticAssets: StaticAssetsConfig | null;
@@ -1,4 +1,4 @@
1
- /** Authored static assets, compiled from the repo's .webority/static.json by the Vite plugin (web) or mobile-tools prebuild (mobile). */
1
+ /** Authored static assets, compiled by the Vite plugin from the deployable carrying staticAssets in the repo's .webority/infra/deployables.json. */
2
2
  export interface StaticAssetsConfig {
3
3
  /** "/" or an absolute https origin, no trailing slash. */
4
4
  authoredOrigin: string;
@@ -1,11 +1,11 @@
1
1
  /** The virtual module the plugin serves: `export default StaticAssetsConfig | null`. */
2
2
  export declare const STATIC_ASSETS_MODULE_ID = "virtual:webority-static-assets";
3
3
  export interface WeborityStaticOptions {
4
- /** "/" or an absolute https origin; required when a .webority/static.json is found above the Vite root. */
4
+ /** "/" or an absolute https origin; required when the deployables file found above the Vite root has a deployable carrying staticAssets. */
5
5
  authoredOrigin?: string | null;
6
6
  /** null: the site serves its build; "/" or an absolute https origin: hashed assets resolve to <origin>/_static/<head>/<file>. */
7
7
  buildOrigin?: string | null;
8
- /** Path to static.json; default the nearest .webority/static.json above the Vite root. */
8
+ /** Path to deployables.json; default the nearest .webority/infra/deployables.json above the Vite root. */
9
9
  manifest?: string;
10
10
  }
11
11
  /** A Vite plugin (structural type; vite is not a dependency). head = the Vite root folder name, lowercased, dots to dashes. */
@@ -1 +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};
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`,`infra`,`deployables.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(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function h(t){let n=i(t,c);if(e(n))return n;let a=r(t);return a===t?null:h(a)}function g(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=m(n)?n.deployables:void 0;if(!m(r))throw Error(`weborityStatic: ${e} has no "deployables" object.`);let i=Object.entries(r).filter(([,e])=>m(e)&&`staticAssets`in e);if(i.length===0)return null;if(i.length>1)throw Error(`weborityStatic: ${e} must have exactly one deployable with "staticAssets"; it has ${i.length}.`);let[[a,o]]=i,s=o.staticAssets,c=m(s)?s.assets:void 0;if(!m(c))throw Error(`weborityStatic: ${e}: deployable '${a}' has no "staticAssets.assets" object.`);let l={};for(let[t,n]of Object.entries(c)){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.`);l[t]=r.slice(0,d)}return{carrier:a,versions:l}}function _(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):h(c),u=l===null?null:g(l);if(u===null){if(t!==null)throw Error(`weborityStatic: authoredOrigin is set but ${l??`no .webority/infra/deployables.json above the Vite root`} has no deployable carrying "staticAssets".`);o=f;return}if(t===null)throw Error(`weborityStatic: ${l} has a deployable carrying staticAssets, so authoredOrigin is required ("/" or an https origin).`);o=`export default ${JSON.stringify({authoredOrigin:t,versions:u.versions})};`},resolveId(e){return e===`virtual:webority-static-assets`?s:null},load(e){return e===s?o:null}}}export{o as STATIC_ASSETS_MODULE_ID,_ as weborityStatic};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/web-core",
3
- "version": "0.89.0",
3
+ "version": "0.91.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",