@alwith/module-auth 0.1.4 → 0.1.5

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.
@@ -100,6 +100,10 @@ export interface VibemonHost {
100
100
  windows: PetWindowHost;
101
101
  synchronizeResources?(): Promise<void>;
102
102
  resourcesSynchronized?(updated: ReadonlySet<string>): Promise<void>;
103
+ onResourceSyncError?(error: unknown, context: {
104
+ phase: "catalog" | "resource";
105
+ petId?: string;
106
+ }): void;
103
107
  onError(error: unknown): void;
104
108
  }
105
109
  export declare function configureVibemon(value: VibemonHost): () => void;
@@ -1 +1 @@
1
- import{createStore as h}from"zustand/vanilla";import{accountKey as y}from"../../index.js";import{vibemonHost as m}from"../host.js";var l=h(()=>({status:"idle"})),w=()=>l.getState().status,S=(e)=>l.setState({status:e}),x=(e)=>l.subscribe((o)=>e(o.status)),n=null;async function R(){let e=m();if(e.synchronizeResources!==void 0)return e.synchronizeResources();let o=e.account();if(o===null)return;let i=`${y(o)}/${o.revision}`,r=()=>{let t=e.account();return t!==null&&`${y(t)}/${t.revision}`===i};if(n?.scope===i)return n.operation;let s=(t)=>{if(r())S(t)},a=(async()=>{s("checking");try{let t=await e.assets.getVibemonCatalog();if(!r())return;let u=new Set,f=0,d=!1;if(await Promise.all(Array.from({length:Math.min(6,t.length)},async()=>{while(r()&&f<t.length){let c=t[f++];try{if((await e.assets.resources.inspect(c.uuid))?.version===c.resource_version)continue;s("updating"),await e.assets.resources.ensure(c),u.add(c.uuid)}catch(p){if(d=!0,r())e.onError(p)}}})),r())await e.resourcesSynchronized?.(u);s(d?"error":u.size===0?"idle":"done")}catch(t){if(s("error"),r())e.onError(t)}})();n={scope:i,operation:a};try{await a}finally{if(n?.operation===a)n=null}}export{S as observeResourceSync,w as resourceSyncStatus,x as subscribeResourceSync,R as syncVibemonResources,l as vibemonSyncStore};
1
+ import{createStore as m}from"zustand/vanilla";import{accountKey as h}from"../../index.js";import{vibemonHost as S}from"../host.js";var l=m(()=>({status:"idle"})),R=()=>l.getState().status,g=(e)=>l.setState({status:e}),x=(e)=>l.subscribe((s)=>e(s.status)),c=null;async function z(){let e=S();if(e.synchronizeResources!==void 0)return e.synchronizeResources();let s=e.account();if(s===null)return;let a=`${h(s)}/${s.revision}`,o=()=>{let r=e.account();return r!==null&&`${h(r)}/${r.revision}`===a};if(c?.scope===a)return c.operation;let i=(r)=>{if(o())g(r)},d=(r,n)=>{if(!o())return;if(e.onResourceSyncError)e.onResourceSyncError(r,n);else console.warn("[vibemon] resource sync failed",n,r)},u=(async()=>{i("checking");try{let r=await e.assets.getVibemonCatalog();if(!o())return;let n=new Set,f=0,p=!1;if(await Promise.all(Array.from({length:Math.min(6,r.length)},async()=>{while(o()&&f<r.length){let t=r[f++];try{if((await e.assets.resources.inspect(t.uuid))?.version===t.resource_version)continue;i("updating"),await e.assets.resources.ensure(t),n.add(t.uuid)}catch(y){p=!0,d(y,{phase:"resource",petId:t.uuid})}}})),o())try{await e.resourcesSynchronized?.(n)}catch(t){if(o())e.onError(t)}i(p?"error":n.size===0?"idle":"done")}catch(r){i("error"),d(r,{phase:"catalog"})}})();c={scope:a,operation:u};try{await u}finally{if(c?.operation===u)c=null}}export{g as observeResourceSync,R as resourceSyncStatus,x as subscribeResourceSync,z as syncVibemonResources,l as vibemonSyncStore};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alwith/module-auth",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {