@alwith/module-auth 0.1.5 → 0.1.7
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 +21 -1
- package/THIRD_PARTY_NOTICES.md +3 -2
- package/dist/oauth.js +1 -1
- package/dist/pets/assets.d.ts +34 -3
- package/dist/pets/assets.js +1 -1
- package/dist/pets/client.d.ts +1 -0
- package/dist/pets/client.js +1 -1
- package/dist/pets/core/engine.js +1 -1
- package/dist/pets/core/host.d.ts +26 -25
- package/dist/pets/core/lib/account-state.js +1 -1
- package/dist/pets/core/lib/draw-result.js +1 -1
- package/dist/pets/core/lib/endpoints.d.ts +28 -1
- package/dist/pets/core/lib/gacha-pools.js +1 -1
- package/dist/pets/core/lib/loading-progress.d.ts +0 -1
- package/dist/pets/core/lib/loading-progress.js +1 -1
- package/dist/pets/core/lib/pet-animation-sync.d.ts +1 -1
- package/dist/pets/core/lib/pet-drag.d.ts +1 -1
- package/dist/pets/core/lib/pet-presentation.d.ts +1 -1
- package/dist/pets/core/lib/preload-images.js +1 -1
- package/dist/pets/core/lib/presentation-readiness.js +1 -1
- package/dist/pets/core/lib/rarity.js +1 -1
- package/dist/pets/core/lib/resource-sync.js +1 -1
- package/dist/pets/core/lib/settings.js +1 -1
- package/dist/pets/core/lib/sprite-config.js +1 -1
- package/dist/pets/core/lib/vibemon-resources.js +1 -1
- package/dist/pets/core/types.d.ts +2 -4
- package/dist/pets/host.d.ts +13 -10
- package/dist/pets/react/assets.js +1 -1
- package/dist/pets/react/components/album-view.js +1 -1
- package/dist/pets/react/components/back-to-home.js +1 -1
- package/dist/pets/react/components/equip-view.js +1 -1
- package/dist/pets/react/components/gem-balance.js +1 -1
- package/dist/pets/react/components/home-view.js +1 -1
- package/dist/pets/react/components/insufficient-points-dialog.js +1 -1
- package/dist/pets/react/components/loading-view.js +1 -1
- package/dist/pets/react/components/lounge-burst.css +0 -2
- package/dist/pets/react/components/onboarding-guide.js +1 -1
- package/dist/pets/react/components/pet-bubble-background.js +1 -1
- package/dist/pets/react/components/pet-window.js +1 -1
- package/dist/pets/react/components/pull-overlay.js +1 -1
- package/dist/pets/react/components/pull-view.js +1 -1
- package/dist/pets/react/components/quick-reply.js +2 -2
- package/dist/pets/react/components/single-pet-toast.js +1 -1
- package/dist/pets/react/components/sprite-renderer.d.ts +2 -1
- package/dist/pets/react/components/sprite-renderer.js +1 -1
- package/dist/pets/react/components/vibemon-header.js +1 -1
- package/dist/pets/react/components/vibemon-page.js +1 -1
- package/dist/pets/react/components/video-fader.d.ts +1 -4
- package/dist/pets/react/components/video-fader.js +1 -1
- package/dist/pets/react/components/wish-button.js +1 -1
- package/dist/pets/react/ui/button.d.ts +1 -1
- package/dist/pets/react/ui/button.js +1 -1
- package/dist/pets/react/ui/card.d.ts +1 -1
- package/dist/pets/react/ui/card.js +1 -1
- package/dist/pets/react/ui/input-group.d.ts +1 -1
- package/dist/pets/react/ui/input-group.js +1 -1
- package/dist/pets/resource-package.d.ts +27 -0
- package/dist/pets/resource-package.js +1 -0
- package/dist/pets/resources.d.ts +16 -16
- package/dist/pets/resources.js +1 -1
- package/dist/pets/selection.d.ts +1 -1
- package/dist/pets/selection.js +1 -1
- package/dist/pets/sheet-layout.d.ts +10 -0
- package/dist/pets/sheet-layout.js +1 -0
- package/dist/pets/types.d.ts +21 -9
- package/dist/state.d.ts +1 -1
- package/dist/state.js +1 -1
- package/dist/token-storage.d.ts +9 -9
- package/dist/token-storage.js +1 -1
- package/licenses/fflate-MIT.txt +21 -0
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -49,7 +49,27 @@ the UI thread must remain available to render animation frames during dragging.
|
|
|
49
49
|
Prompt responses acknowledge acceptance; runtime state establishes completion.
|
|
50
50
|
Only live transitions trigger completion animation, not replayed snapshots.
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
Format 1 resources are downloaded from `resource_url` as complete ZIP packages.
|
|
53
|
+
The cache retains the ZIP, manifest, images and animation together, and compares
|
|
54
|
+
format, revision and source URL against a fresh API descriptor before reuse.
|
|
55
|
+
Paths, SHA-256 hashes, image decoding and animation bounds are validated before
|
|
56
|
+
replacing the installed directory. Failed updates retain the previous package;
|
|
57
|
+
missing optional images and animation use static placeholders.
|
|
58
|
+
|
|
59
|
+
Fresh gacha pool items can supply `vibemon_resource_url`: an unchanged immutable
|
|
60
|
+
URL reuses a validated format-1 cache without another detail request. Cold caches,
|
|
61
|
+
changed URLs and legacy resources still fetch the descriptor to determine format
|
|
62
|
+
and revision. Entry loading includes the home and Wish images so opening Wish
|
|
63
|
+
does not start a second loading screen.
|
|
64
|
+
Draw results fetch
|
|
65
|
+
`/api/v1/vibemons/{uuid}` to obtain the full package descriptor. Format 0 and
|
|
66
|
+
missing format fields continue to use legacy sheet resources.
|
|
67
|
+
|
|
68
|
+
Hosts may supply `resources.url` to serve cached images directly and
|
|
69
|
+
`validateImage` to validate their platform decoder before installation.
|
|
70
|
+
`onResourceError` reports failed updates without discarding existing resources.
|
|
71
|
+
|
|
72
|
+
Legacy asset caches store layout, sheet identity and resource version. Playback defaults
|
|
53
73
|
are generated by `createSpriteConfig` in the core entry. `spriteConfig` preserves
|
|
54
74
|
legacy `config.json` timing, crop, facing and behavior overrides without rewriting
|
|
55
75
|
existing caches. Storage keys and account cache paths remain unchanged.
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -11,8 +11,9 @@ artifact. Versions below record the local release-preparation inventory; declare
|
|
|
11
11
|
ranges can resolve to different versions. Keep the notices from the versions
|
|
12
12
|
actually distributed by your application, including transitive dependencies.
|
|
13
13
|
|
|
14
|
-
| Package | Inspected version | License | Included license copy
|
|
15
|
-
| ------- | ----------------- | ------- |
|
|
14
|
+
| Package | Inspected version | License | Included license copy |
|
|
15
|
+
| ------- | ----------------- | ------- | ----------------------- |
|
|
16
|
+
| fflate | 0.8.3 | MIT | licenses/fflate-MIT.txt |
|
|
16
17
|
|
|
17
18
|
The pet React entry uses the external dependencies and optional React peers declared in `package.json`. Asset and core entries do not load React.
|
|
18
19
|
|
package/dist/oauth.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function r(e){let n="";for(let o of e)n+=String.fromCharCode(o);return btoa(n).
|
|
1
|
+
function r(e){let n="";for(let o of e)n+=String.fromCharCode(o);return btoa(n).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}function a(){let e=new Uint8Array(32);return crypto.getRandomValues(e),r(e)}async function u(e){let n=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return r(new Uint8Array(n))}var t=null;function l(e){t=e}function c(){let e=t;return t=null,e}function s(){t=null}var i=[["OAUTH_SESSION_EXPIRED","signIn.oauthSessionExpired"],["OAUTH_VERIFICATION_FAILED","signIn.oauthVerificationFailed"],["OAUTH_EMAIL_REQUIRED","signIn.oauthEmailRequired"],["OAUTH_IDENTITY_CONFLICT","signIn.oauthIdentityConflict"],["OAUTH_RATE_LIMITED","signIn.tooManyRequests"],["OAUTH_PROVIDER_UNAVAILABLE","signIn.oauthProviderUnavailable"],["OAUTH_CONFIG_UNAVAILABLE","signIn.oauthConfigUnavailable"],["ACCOUNT_DISABLED","signIn.accountDisabled"]];function I(e){for(let[n,o]of i)if(e.includes(n))return o;return"signIn.signInFailed"}export{s as clearOAuthState,u as computeCodeChallenge,a as generateCodeVerifier,I as oauthErrorKey,l as storeOAuthState,c as takeOAuthState};
|
package/dist/pets/assets.d.ts
CHANGED
|
@@ -1,12 +1,43 @@
|
|
|
1
1
|
import { type PetAssetsHost } from "./host.js";
|
|
2
|
-
import type { MyVibemonItem, VibemonCatalogItem } from "./types.js";
|
|
2
|
+
import type { MyVibemonItem, VibemonCatalogItem, VibemonResourceDescriptor } from "./types.js";
|
|
3
3
|
export declare function createPetAssets(host: PetAssetsHost): {
|
|
4
|
-
getMyVibemons: (params?: Parameters<(params?: import("./types").GetMyVibemonsParams) => Promise<MyVibemonItem[]>>[0]) => Promise<
|
|
4
|
+
getMyVibemons: (params?: Parameters<(params?: import("./types").GetMyVibemonsParams) => Promise<MyVibemonItem[]>>[0]) => Promise<{
|
|
5
|
+
resource_url?: string | null;
|
|
6
|
+
resource_package_format?: number | null;
|
|
7
|
+
resource_version?: number | null;
|
|
8
|
+
sheet_url?: string | null;
|
|
9
|
+
layout?: string | null;
|
|
10
|
+
multi_draw_url?: string | null;
|
|
11
|
+
vibemon_uuid: string;
|
|
12
|
+
name: string;
|
|
13
|
+
description: string | null;
|
|
14
|
+
rarity_code: string;
|
|
15
|
+
rarity_name: string;
|
|
16
|
+
rarity_color: string;
|
|
17
|
+
category_code: string;
|
|
18
|
+
category_name: string;
|
|
19
|
+
cover_url: string;
|
|
20
|
+
gacha_url: string | null;
|
|
21
|
+
icon_url: string | null;
|
|
22
|
+
background_url: string | null;
|
|
23
|
+
pool_card_url: string | null;
|
|
24
|
+
sidebar_selected_url: string | null;
|
|
25
|
+
sidebar_hover_url: string | null;
|
|
26
|
+
sidebar_unselected_url: string | null;
|
|
27
|
+
is_limited: number;
|
|
28
|
+
is_equipped: boolean;
|
|
29
|
+
obtained_time: string;
|
|
30
|
+
duplicate_count: number;
|
|
31
|
+
}[]>;
|
|
5
32
|
getVibemonCatalog: () => Promise<VibemonCatalogItem[]>;
|
|
33
|
+
getVibemonDetail: (id: string) => Promise<VibemonCatalogItem>;
|
|
34
|
+
resolveImages: (id: string, resourceUrl?: string | null) => Promise<Record<string, string | null>>;
|
|
6
35
|
resources: {
|
|
7
36
|
inspect: (petId: string) => Promise<import("./resources").CachedPetMetadata | null>;
|
|
37
|
+
visuals: (metadata: import("./resources").CachedPetMetadata) => Promise<Partial<Record<import("./resource-package").ImageAsset, string | null>>>;
|
|
38
|
+
preview(metadata: import("./resources").CachedPetMetadata): Promise<Uint8Array<ArrayBufferLike> | null>;
|
|
8
39
|
cached: (petId: string) => Promise<import("./resources").CachedPetResource | null>;
|
|
9
|
-
ensure: (item:
|
|
40
|
+
ensure: (item: VibemonResourceDescriptor) => Promise<import("./resources").CachedPetResource>;
|
|
10
41
|
cancel: () => void;
|
|
11
42
|
dispose(): void;
|
|
12
43
|
};
|
package/dist/pets/assets.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createPetClient as
|
|
1
|
+
import{createPetClient as k}from"./client.js";import{accountKey as V,assertAccount as s}from"./host.js";import{IMAGE_ASSETS as q}from"./resource-package.js";import{createPetResources as C}from"./resources.js";import{createPetSelection as x}from"./selection.js";function N(o){let w=k(o),a=C(o),p=new Map,f=new Map,u=null,m=!1,g=0,d=null,y="",S=!1,_=0,b=new Set;function l(){_++;for(let e of b)e()}function c(){if(S)throw Error("Vibemon asset service disposed");let e=o.account(),n=e===null?"":`${V(e)}/${e.revision}`;if(y!==n)y=n,u=null,m=!1,g++,d=null,a.cancel();return e}async function v(e){let n=c(),r=e===void 0?++g:g,t=await w.getMyVibemons(e);if(n===null)throw Error("Sign in to use Vibemon");if(s(o,n),c(),e===void 0&&r===g)u=t,m=!0,await o.storage.set(`vibemon.owned.${V(n)}`,t),s(o,n),l();return Promise.all(t.map(async(i)=>({...i,...await h({...i,uuid:i.vibemon_uuid})})))}async function I(){let e=c();if(e===null)return null;if(m)return u;let n=await o.storage.get(`vibemon.owned.${V(e)}`);return s(o,e),u=n??null,l(),u}async function M(){let e=c(),n=await w.getVibemonCatalog();if(e===null)throw Error("Sign in to use Vibemon");return s(o,e),c(),d=n,l(),n}async function E(e){let n=(p.get(e)??0)+1;p.set(e,n);let r=await w.getVibemonDetail(e);if(p.get(e)!==n)throw Error("Vibemon detail request superseded");if(r.uuid!==e)throw Error("Vibemon detail ID mismatch");return r}async function R(e){let n=c();if(n===null)throw Error("Sign in to use Vibemon");try{return await a.ensure(e)}catch(r){s(o,n),o.onResourceError?.(r,e.uuid);let t=await a.cached(e.uuid);if(t!==null)return t;throw r}}async function h(e){if((e.resource_package_format??0)===0)return{};let n=c();if(n===null)throw Error("Sign in to use Vibemon");try{let r=await R(e),t=await a.visuals(r);return s(o,n),Object.fromEntries(q.filter((i)=>(i in t)).map((i)=>[`${i}_url`,t[i]??null]))}catch{return s(o,n),Object.fromEntries(q.map((r)=>[`${r}_url`,null]))}}async function P(e){let n=c();if(n===null)throw Error("Sign in to use Vibemon");try{let r=await E(e);return await h(r)}catch(r){s(o,n),o.onResourceError?.(r,e);let t=await a.inspect(e);if(t===null)return{};let i=await a.visuals(t);return Object.fromEntries(Object.entries(i).map(([A,D])=>[`${A}_url`,D]))}}function j(e,n){c();let r=JSON.stringify([y,e,n??null]),t=f.get(r);if(t)return t;let i=P(e).finally(()=>{if(f.get(r)===i)f.delete(r)});return f.set(r,i),i}let O=x(o,async(e)=>{if(c(),m&&u?.some((n)=>n.vibemon_uuid===e))return u;return v()});return{...w,getMyVibemons:v,getVibemonCatalog:M,getVibemonDetail:E,resolveImages:j,resources:a,restoreOwned:I,get revision(){return _},snapshot:()=>({account:c(),owned:u,catalog:d}),invalidate(){c(),l()},subscribe(e){return b.add(e),()=>{b.delete(e)}},selection:{get:O.get,async select(e){c(),await O.select(e),l()}},async ensureResource(e){let n=c();if(n===null)throw Error("Sign in to use Vibemon");if(!(u??await v()).some((t)=>t.vibemon_uuid===e))throw Error("This account does not own this Vibemon");try{let t=await E(e);return s(o,n),await R(t)}catch(t){s(o,n);let i=await a.cached(e);if(i!==null)return o.onResourceError?.(t,e),i;throw t}},dispose(){S=!0,u=null,d=null,a.dispose(),l(),b.clear()}}}export{N as createPetAssets};
|
package/dist/pets/client.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type PetAssetsHost } from "./host.js";
|
|
2
2
|
import type { DrawResponse, DrawType, GachaFirstDrawResponse, GachaPoolDetailResponse, GachaPoolSummary, GetMyVibemonsParams, MyVibemonItem, PointAccountData, VibemonCatalogItem, VibemonFirstVisitResponse } from "./types.js";
|
|
3
3
|
export declare function createPetClient(host: Pick<PetAssetsHost, "account" | "request">): {
|
|
4
|
+
getVibemonDetail: (id: string) => Promise<VibemonCatalogItem>;
|
|
4
5
|
getVibemonCatalog: () => Promise<VibemonCatalogItem[]>;
|
|
5
6
|
getMyVibemons: (params?: GetMyVibemonsParams) => Promise<MyVibemonItem[]>;
|
|
6
7
|
markVibemonFirstVisit: () => Promise<VibemonFirstVisitResponse>;
|
package/dist/pets/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{assertAccount as s}from"./host.js";function l(o){async function a
|
|
1
|
+
import{assertAccount as s}from"./host.js";function l(o){async function e(a,t,c){let i=o.account();if(i===null)throw Error("Sign in to use Vibemon");let n=await o.request(a,t,c);return s(o,i),n}let r=!1;return{getVibemonDetail:(a)=>e(`/api/v1/vibemons/${encodeURIComponent(a)}`,"GET"),getVibemonCatalog:()=>e("/api/v1/vibemons/catalog","GET"),getMyVibemons:(a={})=>{let t=new URLSearchParams;for(let[i,n]of Object.entries(a))if(n!==void 0)t.set(i,String(n));let c=t.size>0?`?${t}`:"";return e(`/api/v1/vibemons/mine${c}`,"GET")},markVibemonFirstVisit:()=>e("/api/v1/vibemons/first-visit","POST"),getGachaFirstDraw:()=>e("/api/v1/gacha/first-draw","GET"),getActiveGachaPools:()=>e("/api/v1/gacha/pools","GET"),getGachaPoolDetail:(a)=>e(`/api/v1/gacha/pools/${encodeURIComponent(a)}`,"GET"),getPointAccount:()=>e("/api/v1/points/account","GET"),async drawGachaPool(a,t){if(r)throw Error("A draw is already pending");r=!0;try{return await e("/api/v1/gacha/draw","POST",{pool_uuid:a,draw_type:t})}finally{r=!1}}}}export{l as createPetClient};
|
package/dist/pets/core/engine.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{availableMonitors as a,getCurrentWindow as o
|
|
1
|
+
import{availableMonitors as a,getCurrentWindow as o,moveVibemonWindow as h}from"./lib/window-frame.js";var d=60000,l=24,u=90;class c{currentBehavior="idle";flipped=!1;position={x:200,y:200};targetPosition=null;screenBounds={x:0,y:0,width:1920,height:1080};behaviorTimer=null;sleepTimer=null;moveTimerId=null;isDragging=!1;isPresenting=!1;isHatching=!1;destroyed=!1;suspended=!1;behaviorBeforeDrag="idle";working=!1;sessionAnimation=null;onStateChange;onNotification;config;constructor(i,e,t){this.config=i,this.onStateChange=e,this.onNotification=t}stateOf(i){return this.config.behaviorMap[i]??this.config.behaviorMap.idle}async start(i){if(await this.updateScreenBounds(),i===void 0){let e=await o().outerPosition();this.position={x:e.x,y:e.y}}else if(i){let e=await o().outerSize();if((await a()).some((n)=>i.x+e.width>n.position.x&&i.x<n.position.x+n.size.width&&i.y+e.height>n.position.y&&i.y<n.position.y+n.size.height))this.position={x:i.x,y:i.y};else{let n=this.screenBounds.x+this.screenBounds.width-e.width,r=this.screenBounds.y+this.screenBounds.height-e.height;this.position={x:Math.min(Math.max(i.x,this.screenBounds.x),n),y:Math.min(Math.max(i.y,this.screenBounds.y),r)}}await h(this.position.x,this.position.y)}else{let e=await o().outerSize(),t=await o().scaleFactor(),s=Math.round(l*t),n=Math.round(u*t);this.position={x:this.screenBounds.x+this.screenBounds.width-e.width-s,y:this.screenBounds.y+this.screenBounds.height-e.height-n},await h(this.position.x,this.position.y)}if(this.setBehavior("idle"),this.sessionAnimation!==null)this.applySessionAnimation();this.resetSleepTimer()}destroy(){if(this.destroyed=!0,this.behaviorTimer)clearTimeout(this.behaviorTimer);if(this.sleepTimer)clearTimeout(this.sleepTimer);if(this.moveTimerId)clearInterval(this.moveTimerId)}suspend(){if(this.suspended=!0,this.cancelMovement(),this.targetPosition=null,this.sleepTimer)clearTimeout(this.sleepTimer);this.sleepTimer=null}resume(){if(this.destroyed)throw Error("Cannot resume a destroyed Vibemon engine");if(this.suspended=!1,this.sessionAnimation!==null)this.applySessionAnimation();else this.setBehavior(this.restBehavior());this.resetSleepTimer()}async presentAt(i){if(this.isDragging||this.isPresenting||this.destroyed)throw Error("Vibemon cannot be presented right now");this.isPresenting=!0,this.cancelMovement(),this.targetPosition=null;try{if(this.position=await i(),this.destroyed)throw Error("Vibemon engine changed during presentation")}finally{if(this.isPresenting=!1,!this.destroyed&&!this.suspended){if(this.sessionAnimation!==null)this.applySessionAnimation();else if(this.currentBehavior!=="wait"&&this.currentBehavior!=="error")this.setBehavior(this.restBehavior());this.resetSleepTimer()}}}restBehavior(){return this.working?"sit":"idle"}setWorking(i){if(this.working===i)return;if(this.working=i,this.destroyed||this.suspended||this.isDragging)return;let e=this.currentBehavior==="idle"||this.currentBehavior==="sit"||this.currentBehavior==="sleep",t=this.restBehavior();if(e&&t!==this.currentBehavior)this.setBehavior(t),this.resetSleepTimer()}setSessionState(i,e,t){let s=this.sessionAnimation;if(s!==null&&s.sessionId===i&&s.state===e&&s.failed===t)return;if(this.sessionAnimation={sessionId:i,state:e,failed:t},this.setWorking(e==="running"&&!t),s!==null&&s.sessionId===i&&s.state==="done"&&e==="idle"&&!t&&this.currentBehavior==="jump"&&this.behaviorTimer!==null)return;if(!this.destroyed&&!this.suspended&&!this.isDragging&&!this.isPresenting)this.applySessionAnimation()}applySessionAnimation(){let i=this.sessionAnimation;if(i===null)throw Error("Session animation requires a Runtime snapshot");let e=i.failed?"task-error":i.state==="running"?"running":i.state==="requires_action"?"info":i.state==="done"?"task-complete":"idle";this.handleNotification({type:e,message:"",sourceWindow:""})}handleNotification(i){if(this.suspended)return;if(this.isHatching)return;if(this.onNotification(i),this.resetSleepTimer(),this.behaviorTimer)clearTimeout(this.behaviorTimer);if(this.currentBehavior==="sleep"){this.setBehavior("scared"),this.behaviorTimer=setTimeout(()=>{if(!this.destroyed&&!this.isDragging&&!this.isPresenting)if(this.sessionAnimation!==null)this.applySessionAnimation();else this.handleNotification(i)},500);return}if(this.cancelMovement(),i.type==="info"){this.setBehavior("wait");return}if(i.type==="task-error"){this.setBehavior(this.config.behaviorMap.error?"error":"wait");return}if(i.type==="running"){this.setBehavior("sit");return}if(i.type==="task-complete"){this.setBehavior("jump");let e=this.config.states.find((s)=>s.id===this.stateOf("jump")),t=e?e.frames/e.fps*1000:800;this.behaviorTimer=setTimeout(()=>{if(!this.destroyed&&!this.isDragging)this.setBehavior(this.restBehavior())},t);return}this.setBehavior(this.restBehavior())}handleClick(){if(this.isHatching)return;this.resetSleepTimer()}dismissError(){if(this.currentBehavior!=="error")return;this.cancelMovement(),this.setBehavior(this.restBehavior()),this.resetSleepTimer()}flipForDirection(i){return this.config.facing==="left"?!i:i}handleDragStart(i){if(this.isPresenting)throw Error("Vibemon presentation is in progress");if(this.isHatching)return;if(this.behaviorBeforeDrag=this.currentBehavior,this.isDragging=!0,this.cancelMovement(),this.resetSleepTimer(),i!==void 0)this.flipped=this.flipForDirection(i);this.setBehavior("scared")}setFacing(i){let e=this.flipForDirection(i);if(this.flipped===e)return;this.flipped=e,this.onStateChange(this.stateOf(this.currentBehavior),this.flipped,!1)}handleDragEnd(){if(this.destroyed)return;if(this.isDragging=!1,this.cancelMovement(),this.flipped=!1,this.sessionAnimation!==null)this.applySessionAnimation();else if(this.behaviorBeforeDrag==="wait"||this.behaviorBeforeDrag==="error")this.setBehavior(this.behaviorBeforeDrag);else this.setBehavior(this.restBehavior());this.syncPositionFromWindow()}debugSpeed=8;setDebugSpeed(i){this.debugSpeed=i}stop(){this.cancelMovement(),this.setBehavior("idle")}debugSetBehavior(i){if(this.cancelMovement(),i in this.config.behaviorMap)this.setBehavior(i);else this.currentBehavior="idle",this.onStateChange(i,this.flipped,!0)}getDebugSpeed(){return this.debugSpeed}async debugRun(){this.cancelMovement(),await this.syncPositionFromWindow();let i=await o().outerSize(),e=[{x:this.screenBounds.x,y:this.screenBounds.y},{x:this.screenBounds.x+this.screenBounds.width-i.width,y:this.screenBounds.y},{x:this.screenBounds.x+this.screenBounds.width-i.width,y:this.screenBounds.y+this.screenBounds.height-i.height},{x:this.screenBounds.x,y:this.screenBounds.y+this.screenBounds.height-i.height}],t=0,s=()=>{if(this.destroyed)return;let n=e[t%e.length];t++;let r=n.x-this.position.x;if(Math.abs(r)>1)this.flipped=r<0;this.setBehavior("run"),this.startMovement(n,this.debugSpeed,s)};s()}setBehavior(i){this.currentBehavior=i,this.onStateChange(this.stateOf(i),this.flipped,!0)}async syncPositionFromWindow(){if(this.destroyed)return;let i;try{i=await o().outerPosition()}catch(e){if(this.destroyed)return;throw e}if(this.destroyed)return;this.position={x:i.x,y:i.y}}async updateScreenBounds(){let i=await a();if(i.length>0){let e=i[0];this.screenBounds={x:e.position.x,y:e.position.y,width:e.size.width,height:e.size.height}}}startMovement(i,e,t){if(this.isPresenting||this.suspended)return;this.cancelMovement(),this.targetPosition=i,this.moveTimerId=setInterval(()=>{if(this.destroyed||this.isDragging||!this.targetPosition||this.currentBehavior!=="run"){if(this.moveTimerId)clearInterval(this.moveTimerId);this.moveTimerId=null;return}let s=this.targetPosition.x-this.position.x,n=this.targetPosition.y-this.position.y,r=Math.hypot(s,n);if(r<e){if(this.position={...this.targetPosition},this.targetPosition=null,this.moveTimerId)clearInterval(this.moveTimerId),this.moveTimerId=null;if(h(this.position.x,this.position.y),t)t();else this.setBehavior("idle");return}this.position.x+=s/r*e,this.position.y+=n/r*e,h(this.position.x,this.position.y)},16)}cancelMovement(){if(this.moveTimerId)clearInterval(this.moveTimerId),this.moveTimerId=null;if(this.behaviorTimer)clearTimeout(this.behaviorTimer),this.behaviorTimer=null}resetSleepTimer(){if(this.sleepTimer)clearTimeout(this.sleepTimer);if(this.suspended)return;this.sleepTimer=setTimeout(()=>{if(!this.destroyed&&!this.isDragging&&this.currentBehavior==="idle")this.cancelMovement(),this.setBehavior("sleep")},d)}}export{c as VibemonEngine};
|
package/dist/pets/core/host.d.ts
CHANGED
|
@@ -53,13 +53,13 @@ export interface PetPrompt {
|
|
|
53
53
|
}[];
|
|
54
54
|
}
|
|
55
55
|
export interface PetSessionHost {
|
|
56
|
-
snapshot()
|
|
57
|
-
subscribe(listener: (value: PetObservation | null) => void)
|
|
58
|
-
send(binding: PetBinding, requestId: string, text: string)
|
|
59
|
-
answer(binding: PetBinding, requestId: string, token: string, optionId: string)
|
|
60
|
-
openChat(binding: PetBinding | null)
|
|
61
|
-
activate()
|
|
62
|
-
select(binding: PetBinding, sessionId: string)
|
|
56
|
+
snapshot: () => PetObservation | null;
|
|
57
|
+
subscribe: (listener: (value: PetObservation | null) => void) => () => void;
|
|
58
|
+
send: (binding: PetBinding, requestId: string, text: string) => Promise<void>;
|
|
59
|
+
answer: (binding: PetBinding, requestId: string, token: string, optionId: string) => Promise<void>;
|
|
60
|
+
openChat: (binding: PetBinding | null) => Promise<void>;
|
|
61
|
+
activate: () => Promise<void>;
|
|
62
|
+
select: (binding: PetBinding, sessionId: string) => Promise<void>;
|
|
63
63
|
}
|
|
64
64
|
export interface Monitor {
|
|
65
65
|
position: {
|
|
@@ -73,44 +73,45 @@ export interface Monitor {
|
|
|
73
73
|
scaleFactor: number;
|
|
74
74
|
}
|
|
75
75
|
export interface PetWindowHost {
|
|
76
|
-
call<T>(action: string, payload?: Record<string, unknown>)
|
|
77
|
-
openPet(options?: {
|
|
76
|
+
call: <T>(action: string, payload?: Record<string, unknown>) => Promise<T>;
|
|
77
|
+
openPet: (options?: {
|
|
78
78
|
trusted?: boolean;
|
|
79
|
-
})
|
|
80
|
-
closePet()
|
|
81
|
-
openRecharge()
|
|
82
|
-
geometry(listener: () => void)
|
|
83
|
-
moved(listener: (position: {
|
|
79
|
+
}) => Promise<"shown" | "unavailable">;
|
|
80
|
+
closePet: () => Promise<void>;
|
|
81
|
+
openRecharge: () => Promise<void>;
|
|
82
|
+
geometry: (listener: () => void) => Promise<() => void>;
|
|
83
|
+
moved: (listener: (position: {
|
|
84
84
|
x: number;
|
|
85
85
|
y: number;
|
|
86
|
-
}) => void)
|
|
87
|
-
commands(listener: (command: {
|
|
86
|
+
}) => void) => Promise<() => void>;
|
|
87
|
+
commands: (listener: (command: {
|
|
88
88
|
type: "present" | "reload" | "suspend" | "bubble-close" | "bubble-open" | "bubble-interact" | "close";
|
|
89
89
|
petId: string;
|
|
90
90
|
requestId: string;
|
|
91
|
-
}) => Promise<void>)
|
|
91
|
+
}) => Promise<void>) => () => void;
|
|
92
92
|
}
|
|
93
93
|
export interface VibemonHost {
|
|
94
94
|
sessionIcons?: SessionIcons;
|
|
95
|
-
account()
|
|
95
|
+
account: () => PetAccount | null;
|
|
96
96
|
assets: PetAssets;
|
|
97
97
|
storage: PetStorage;
|
|
98
|
-
subscribeStorage(listener: () => void)
|
|
98
|
+
subscribeStorage: (listener: () => void) => () => void;
|
|
99
99
|
sessions: PetSessionHost;
|
|
100
100
|
windows: PetWindowHost;
|
|
101
|
-
synchronizeResources
|
|
102
|
-
resourcesSynchronized
|
|
103
|
-
onResourceSyncError
|
|
101
|
+
synchronizeResources?: () => Promise<void>;
|
|
102
|
+
resourcesSynchronized?: (updated: ReadonlySet<string>) => Promise<void>;
|
|
103
|
+
onResourceSyncError?: (error: unknown, context: {
|
|
104
104
|
phase: "catalog" | "resource";
|
|
105
105
|
petId?: string;
|
|
106
|
-
})
|
|
107
|
-
onError(error: unknown)
|
|
106
|
+
}) => void;
|
|
107
|
+
onError: (error: unknown) => void;
|
|
108
108
|
}
|
|
109
109
|
export declare function configureVibemon(value: VibemonHost): () => void;
|
|
110
110
|
export declare function vibemonHost(): VibemonHost;
|
|
111
111
|
export declare function sameBinding(left: PetBinding, right: PetBinding): boolean;
|
|
112
112
|
export interface SpriteResource {
|
|
113
|
+
staticImage?: boolean;
|
|
113
114
|
config: VibemonSpriteConfig;
|
|
114
115
|
spriteUrl: string;
|
|
115
|
-
dispose()
|
|
116
|
+
dispose: () => void;
|
|
116
117
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{accountKey as m,assertAccount as r}from"../../index.js";import{vibemonHost as l}from"../host.js";import{getSettingSync as a,refreshSettings as d,setSetting as b,updateSettingCache as S}from"./settings.js";var c={pet:"",enabled:!1,position:null};function f(){let n=l().account();return n===null?null:m(n)}function p(){let n=f();return n===null?c:a("vibemon.accounts")[n]??c}var x=
|
|
1
|
+
import{accountKey as m,assertAccount as r}from"../../index.js";import{vibemonHost as l}from"../host.js";import{getSettingSync as a,refreshSettings as d,setSetting as b,updateSettingCache as S}from"./settings.js";var c={pet:"",enabled:!1,position:null};function f(){let n=l().account();return n===null?null:m(n)}function p(){let n=f();return n===null?c:a("vibemon.accounts")[n]??c}var x=()=>Promise.try(()=>p());async function g(n){let t=l(),i=t.account(),e=f();if(i===null||e===null)throw Error("Sign in to use Vibemon");if(n.pet!==void 0){let o=a("vibemon.accounts");S("vibemon.accounts",{...o,[e]:{...o[e]??c,pet:n.pet}});try{await t.assets.selection.select(n.pet||null)}finally{await d()}}r(t,i);let{enabled:s,position:u}=n;if(s!==void 0||u!==void 0){let o=a("vibemon.accounts");await b("vibemon.accounts",{...o,[e]:{...o[e]??c,...s!==void 0?{enabled:s}:{},...u!==void 0?{position:u}:{}}})}r(t,i)}async function V(n,t){if(t||p().pet==="")await g({pet:n})}export{p as currentState,V as equipVibemonAfterDraw,f as getVibemonScopeSync,x as getVibemonState,g as updateVibemonState};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var i=(r)=>{if(r==="R"||r==="SR"||r==="SSR")return r;throw Error(`[vibemon] unsupported draw rarity: ${r}`)},a=(r,n,e)=>{if(r===null)throw Error(`[vibemon] drawn white card at index ${n.draw_index} is missing ${e}`);return r},d=(r)=>({kind:"card",drawIndex:r.draw_index,vibemonUuid:r.vibemon_uuid,vibemonName:r.vibemon_name,singleImageUrl:r.gacha_url??"",multiImageUrl:r.multi_draw_url??"",rarity:i(r.rarity_code),isNew:!r.is_duplicate}),u=(r)=>{if(r==="UC"||r==="C")return r;throw Error(`[vibemon] unsupported white-card rarity: ${r}`)},w=(r)=>{if(r.reward_type!=="WHITE_CARD"){if(!r.vibemon_uuid)throw Error("Vibemon draw result is missing its ID");return d(r)}return{kind:"white-card",drawIndex:r.draw_index,rarity:u(r.rarity_code),exchangePoints:r.exchange_points,singleImageUrl:a(r.gacha_url,r,"gacha_url"),multiImageUrl:a(r.multi_draw_url,r,"multi_draw_url")}};export{w as createDrawReward};
|
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
export type * from "../../index.js";
|
|
2
|
-
export declare const getMyVibemons: () => Promise<
|
|
2
|
+
export declare const getMyVibemons: () => Promise<{
|
|
3
|
+
resource_url?: string | null;
|
|
4
|
+
resource_package_format?: number | null;
|
|
5
|
+
resource_version?: number | null;
|
|
6
|
+
sheet_url?: string | null;
|
|
7
|
+
layout?: string | null;
|
|
8
|
+
multi_draw_url?: string | null;
|
|
9
|
+
vibemon_uuid: string;
|
|
10
|
+
name: string;
|
|
11
|
+
description: string | null;
|
|
12
|
+
rarity_code: string;
|
|
13
|
+
rarity_name: string;
|
|
14
|
+
rarity_color: string;
|
|
15
|
+
category_code: string;
|
|
16
|
+
category_name: string;
|
|
17
|
+
cover_url: string;
|
|
18
|
+
gacha_url: string | null;
|
|
19
|
+
icon_url: string | null;
|
|
20
|
+
background_url: string | null;
|
|
21
|
+
pool_card_url: string | null;
|
|
22
|
+
sidebar_selected_url: string | null;
|
|
23
|
+
sidebar_hover_url: string | null;
|
|
24
|
+
sidebar_unselected_url: string | null;
|
|
25
|
+
is_limited: number;
|
|
26
|
+
is_equipped: boolean;
|
|
27
|
+
obtained_time: string;
|
|
28
|
+
duplicate_count: number;
|
|
29
|
+
}[]>;
|
|
3
30
|
export declare const getVibemonCatalog: () => Promise<import("./endpoints").VibemonCatalogItem[]>;
|
|
4
31
|
export declare const getPointAccount: () => Promise<import("./endpoints").PointAccountData>;
|
|
5
32
|
export declare const getGachaFirstDraw: () => Promise<import("./endpoints").GachaFirstDrawResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getActiveGachaPools as
|
|
1
|
+
import{vibemonHost as d}from"../host.js";import{getActiveGachaPools as f,getGachaPoolDetail as m}from"./endpoints.js";var i={SSR:5,SR:4,R:3,UC:2,C:1};function u(e){let t=e.items.filter((o)=>(o.reward_type==="VIBEMON"||o.reward_type==null)&&Boolean(o.vibemon_uuid)&&o.status===1),r=t[0];if(r===void 0)throw Error(`[vibemon] gacha pool ${e.uuid} has no active Vibemon item`);return t.slice(1).reduce((o,a)=>{if(i[a.rarity_code]-i[o.rarity_code]>0)return a;return o},r)}function _(e,t){if(t.uuid!==e.uuid)throw Error(`[vibemon] gacha pool detail UUID ${t.uuid} does not match catalog UUID ${e.uuid}`);if(t.multi_count!==10)throw Error(`[vibemon] gacha pool ${t.uuid} multi_count must be 10, received ${t.multi_count}`);let r=u(t);return{poolUuid:t.uuid,name:t.name,sidebarSelectedImageUrl:r.vibemon_sidebar_selected_url??"",sidebarHoverImageUrl:r.vibemon_sidebar_hover_url??"",sidebarUnselectedImageUrl:r.vibemon_sidebar_unselected_url??"",pageBackgroundImageUrl:r.vibemon_background_url??"",poolCardImageUrl:r.vibemon_pool_card_url??"",status:t.status===1?"ACTIVE":"UNAVAILABLE",startsAt:e.start_time,endsAt:e.end_time,singlePrice:t.next_single_actual_cost??e.single_cost,multiPrice:t.next_multi_actual_cost??e.multi_cost,currencyType:e.currency_type,canDraw:t.status===1,isDefault:e.is_default===1}}function g(e,t){if(e.length===0)throw Error("[vibemon] active gacha pool catalog is empty");let r=new Map(t.map((a)=>[a.uuid,a]));return{pools:[...e].toSorted((a,n)=>a.sort_order-n.sort_order).map((a)=>{let n=r.get(a.uuid);if(n===void 0)throw Error(`[vibemon] gacha pool ${a.uuid} is missing its detail response`);return _(a,n)})}}function h(e){let t=e.pools.flatMap((r)=>[r.sidebarSelectedImageUrl,r.sidebarHoverImageUrl,r.sidebarUnselectedImageUrl,r.poolCardImageUrl,r.pageBackgroundImageUrl]);return[...new Set(t.filter(Boolean))]}async function U(){let t=[...await f()].toSorted((o,a)=>o.sort_order-a.sort_order),r=await Promise.all(t.map((o)=>m(o.uuid)));return await Promise.all(r.map(async(o)=>{let a=u(o),n=await d().assets.resolveImages(a.vibemon_uuid,a.vibemon_resource_url);for(let[c,l]of Object.entries(n))Object.assign(a,{[`vibemon_${c}`]:l})})),g(t,r)}function s(e,t,r){let o=Date.parse(t);if(Number.isNaN(o))throw Error(`[vibemon] gacha pool ${e.poolUuid} has invalid ${r}: ${t}`);return o}function b(e,t){if(e.status==="UNAVAILABLE")return e.status;if(e.startsAt!==null&&t<s(e,e.startsAt,"startsAt"))return"UPCOMING";if(e.endsAt!==null&&t>=s(e,e.endsAt,"endsAt"))return"ENDED";return e.status}function w(e){let t=e.find((o)=>o.isDefault);if(t!==void 0)return t;let r=e[0];if(r===void 0)throw Error("[vibemon] gacha pool catalog has no visible pools");return r}function I(e,t){return e.filter((r)=>b(r,t)!=="ENDED")}export{g as createGachaPoolCatalog,h as gachaPoolImageUrls,w as getDefaultGachaPool,I as getVisibleGachaPools,U as loadGachaPoolCatalog,b as resolveGachaPoolStatus};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function r(n,o,c){let t=Math.min(1,Math.max(0,o)),a=Math.min(t,n+Math.max(0,t-n)*12*c);return t===1&&a>=0.999?1:a}export{r as advanceLoadingProgress};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { PetWindowHost } from "../host.js";
|
|
2
1
|
import type { VibemonEngine } from "../engine.js";
|
|
2
|
+
import type { PetWindowHost } from "../host.js";
|
|
3
3
|
export declare function dragPet(windows: Pick<PetWindowHost, "call" | "moved">, engine: Pick<VibemonEngine, "handleDragStart" | "setFacing" | "handleDragEnd">, movingLeft: boolean): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PetWindowHost } from "../host.js";
|
|
2
1
|
import type { VibemonEngine } from "../engine.js";
|
|
2
|
+
import type { PetWindowHost } from "../host.js";
|
|
3
3
|
import type { PresentationReadiness } from "./presentation-readiness.js";
|
|
4
4
|
type PresentationEngine = Pick<VibemonEngine, "resume" | "presentAt">;
|
|
5
5
|
export declare function presentVibemon<T extends PresentationEngine>(ready: PresentationReadiness<T>, windows: Pick<PetWindowHost, "call">, petId: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var t=new Map;function i(e){let n=t.get(e);if(n)return t.delete(e),t.set(e,n),n;let a=new Image;a.src=e;let o=a.decode().then(()=>a).catch((s)=>{if(t.get(e)===o)t.delete(e);throw Error(`[vibemon] preload failed: ${e}`,{cause:s})});if(t.set(e,o),t.size>64)t.delete(t.keys().next().value);return o}async function c(e,n){let a=0;await Promise.all(e.map(async(o)=>{await i(o),n(++a)}))}export{c as preloadImages};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
class
|
|
1
|
+
class l{current=null;listeners=new Set;begin(e,t){this.current={petId:e,generation:t,value:null,drawn:!1,error:null},this.notify()}positioned(e,t,r){let i=this.current;if(i?.petId!==e||i.generation!==t)return;i.value=r,this.notify()}drawn(e,t){let r=this.current;if(r?.petId!==e||r.generation!==t||r.drawn)return;r.drawn=!0,this.notify()}requireFreshFrame(e){if(this.current?.petId!==e)throw Error("Vibemon resource changed");this.current.drawn=!1,this.notify()}fail(e,t,r){let i=this.current;if(i?.petId!==e||i.generation!==t)return;i.error=r,this.notify()}invalidate(){if(this.current===null)return;this.current.error=Error("Vibemon resource was unloaded"),this.notify()}reset(){this.invalidate(),this.current=null,this.notify()}assertReady(e,t){let r=this.current;if(r?.petId!==e||r.value!==t||!r.drawn||r.error!==null)throw Error("Vibemon resource changed during presentation")}notify(){for(let e of this.listeners)e()}waitingStage(){let e=this.current;if(e===null)return"resource-loading";if(e.value===null)return"initial-position";if(!e.drawn)return"canvas-frame";return"ready"}wait(e,t){let r=this.current?.generation;return new Promise((i,u)=>{let a=()=>{clearTimeout(c),this.listeners.delete(o)},s=(n)=>{a(),u(n)},o=()=>{if(Date.now()>=t){s(Error(`Vibemon presentation timed out [stage=${this.waitingStage()}]`));return}let n=this.current;if(!n)return;if(r??=n.generation,n.petId!==e||r!==void 0&&r!==n.generation)s(Error("Vibemon resource changed during presentation"));else if(n.error)s(n.error);else if(n.drawn&&n.value!==null)a(),i(n.value)},c=setTimeout(()=>s(Error(`Vibemon presentation timed out [stage=${this.waitingStage()}]`)),Math.max(0,t-Date.now()));this.listeners.add(o),o()})}}export{l as PresentationReadiness};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var n=["SSR","SR","R","UC","C"],e=(
|
|
1
|
+
var n=["SSR","SR","R","UC","C"],e=(r)=>{let t=n.indexOf(r);return t===-1?n.length:t};function R(r){return[...r].toSorted((t,o)=>e(t.rarity_code)-e(o.rarity_code))}export{R as sortByRarityDesc};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createStore as m}from"zustand/vanilla";import{accountKey as h}from"../../index.js";import{vibemonHost as
|
|
1
|
+
import{createStore as m}from"zustand/vanilla";import{accountKey as h,matchesResource as S}from"../../index.js";import{vibemonHost as g}from"../host.js";var f=m(()=>({status:"idle"})),x=()=>f.getState().status,b=(e)=>f.setState({status:e}),z=(e)=>f.subscribe((n)=>e(n.status)),c=null;async function E(){let e=g();if(e.synchronizeResources!==void 0)return e.synchronizeResources();let n=e.account();if(n===null)return;let u=`${h(n)}/${n.revision}`,o=()=>{let t=e.account();return t!==null&&`${h(t)}/${t.revision}`===u};if(c?.scope===u)return c.operation;let a=(t)=>{if(o())b(t)},p=(t,s)=>{if(!o())return;if(e.onResourceSyncError)e.onResourceSyncError(t,s);else console.warn("[vibemon] resource sync failed",s,t)},l=(async()=>{a("checking");try{let t=await e.assets.getVibemonCatalog();if(!o())return;let s=new Set,y=0,d=!1;if(await Promise.all(Array.from({length:Math.min(6,t.length)},async()=>{while(o()&&y<t.length){let r=t[y++];try{let i=await e.assets.resources.inspect(r.uuid);if(i&&S(i,r))continue;a("updating"),await e.assets.resources.ensure(r),s.add(r.uuid)}catch(i){d=!0,p(i,{phase:"resource",petId:r.uuid})}}})),o())try{await e.resourcesSynchronized?.(s)}catch(r){if(o())e.onError(r)}a(d?"error":s.size===0?"idle":"done")}catch(t){a("error"),p(t,{phase:"catalog"})}})();c={scope:u,operation:l};try{await l}finally{if(c?.operation===l)c=null}}export{b as observeResourceSync,x as resourceSyncStatus,z as subscribeResourceSync,E as syncVibemonResources,f as vibemonSyncStore};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{vibemonHost as s}from"../host.js";var e={"vibemon.accounts":{},"vibemon.introSeen":{},"vibemon.albumHasUnseen":{},"vibemon.onboardingStep":{}},i=new Set,r=0;async function c(){let t=++r,n=s(),a=await Promise.all(Object.keys(e).map(async(o)=>[o,await n.storage.get(o)??{}]));if(r!==t)return;e=Object.fromEntries(a);for(let o of i)o()}async function p(){let t=s().subscribeStorage(()=>{c().catch(s().onError)});return await c(),()=>{r++,t()}}var b=(t)=>(i.add(t),()=>{i.delete(t)}),u=(t)=>e[t],f=
|
|
1
|
+
import{vibemonHost as s}from"../host.js";var e={"vibemon.accounts":{},"vibemon.introSeen":{},"vibemon.albumHasUnseen":{},"vibemon.onboardingStep":{}},i=new Set,r=0;async function c(){let t=++r,n=s(),a=await Promise.all(Object.keys(e).map(async(o)=>[o,await n.storage.get(o)??{}]));if(r!==t)return;e=Object.fromEntries(a);for(let o of i)o()}async function p(){let t=s().subscribeStorage(()=>{c().catch(s().onError)});return await c(),()=>{r++,t()}}var b=(t)=>(i.add(t),()=>{i.delete(t)}),u=(t)=>e[t],f=(t)=>Promise.resolve(e[t]);function m(t,n){r++,e={...e,[t]:n};for(let a of i)a()}async function S(t,n){await s().storage.set(t,n),await c()}export{f as getSetting,u as getSettingSync,p as initializeSettings,c as refreshSettings,S as setSetting,b as subscribeSettings,m as updateSettingCache};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var f={working:{fps:7,loop:!0},empty:{fps:6,loop:!0},done:{fps:7,loop:!1},wait:{fps:7,loop:!0},drag:{fps:7,loop:!0},error:{fps:7,loop:!0},hover:{fps:6,loop:!0}};function s(i,t,r){let n=r.states.map((o)=>o.id),e=(...o)=>o.find((m)=>n.includes(m))??n[0],a={idle:e("empty","working"),"idle-alt":e("empty","working"),groom:e("empty","working"),"groom-alt":e("empty","working"),run:e("drag","working"),sleep:e("empty","working"),sit:e("working","empty"),interact:e("done","hover","empty"),jump:e("done","empty"),scared:e("drag","empty"),wait:e("wait","empty"),error:e("error","wait","empty"),hover:e("hover","empty")},p=r.frameWidth;return{name:i,frameSize:p,frameHeight:r.frameHeight,renderSize:p,cropX:0,cropY:0,cropW:p,cropH:r.frameHeight,spritesheet:t,facing:"right",behaviorMap:a,states:r.states.map((o)=>({...o,...f[o.id]??{fps:6,loop:!0}}))}}function g(i,t){if(t.config!==void 0)return t.config;if(t.sheetName===null||t.layout===null)throw Error("Vibemon has no animation");return s(t.name??i,t.sheetName,t.layout)}export{s as createSpriteConfig,g as spriteConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{vibemonHost as c}from"../host.js";import{spriteConfig as
|
|
1
|
+
import{imageInfo as f}from"../../resource-package.js";import{vibemonHost as c}from"../host.js";import{createSpriteConfig as m,spriteConfig as p}from"./sprite-config.js";async function U(e){return await c().assets.resources.inspect(e)!==null}async function g(e){let r=c().assets,t=await r.resources.cached(e)??await r.ensureResource(e);if(t.sheet===null){let o=await r.resources.preview(t),n=o?URL.createObjectURL(new Blob([new Uint8Array(o).buffer],{type:f(o).mime})):"";return{config:m(t.name??e,"",{frameWidth:256,frameHeight:256,states:[{id:"static",row:0,frames:1}]}),spriteUrl:n,staticImage:!0,dispose:()=>{if(n)URL.revokeObjectURL(n)}}}let s=t.sheet,a=s[0]===137&&s[1]===80,i=URL.createObjectURL(new Blob([new Uint8Array(s).buffer],{type:a?"image/png":"image/webp"}));return{config:p(e,t),spriteUrl:i,dispose:()=>URL.revokeObjectURL(i)}}export{g as loadVibemonResource,U as verifyVibemonResource};
|
|
@@ -24,6 +24,7 @@ export declare const DEFAULT_VIBEMON_WINDOW_SIZE = 200;
|
|
|
24
24
|
export declare const DEFAULT_VIBEMON_BUBBLE_HEIGHT = 320;
|
|
25
25
|
export interface VibemonSpriteConfig {
|
|
26
26
|
name: string;
|
|
27
|
+
frameHeight?: number;
|
|
27
28
|
frameSize: number;
|
|
28
29
|
renderSize: number;
|
|
29
30
|
cropX: number;
|
|
@@ -38,10 +39,7 @@ export interface VibemonSpriteConfig {
|
|
|
38
39
|
license?: string;
|
|
39
40
|
attribution?: string;
|
|
40
41
|
behaviorMap: VibemonBehaviorMap;
|
|
41
|
-
hatchSequence?: [
|
|
42
|
-
string,
|
|
43
|
-
number
|
|
44
|
-
][];
|
|
42
|
+
hatchSequence?: [string, number][];
|
|
45
43
|
states: VibemonSpriteState[];
|
|
46
44
|
}
|
|
47
45
|
export interface VibemonNotification {
|
package/dist/pets/host.d.ts
CHANGED
|
@@ -4,22 +4,25 @@ export interface PetAccount {
|
|
|
4
4
|
revision: number;
|
|
5
5
|
}
|
|
6
6
|
export interface PetStorage {
|
|
7
|
-
get<T>(key: string)
|
|
8
|
-
set(key: string, value: unknown)
|
|
7
|
+
get: <T>(key: string) => Promise<T | null | undefined>;
|
|
8
|
+
set: (key: string, value: unknown) => Promise<void>;
|
|
9
9
|
}
|
|
10
10
|
export interface PetResourceIO {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
url?: (path: string) => Promise<string>;
|
|
12
|
+
exists: (path: string) => Promise<boolean>;
|
|
13
|
+
read: (path: string) => Promise<Uint8Array | null>;
|
|
14
|
+
write: (path: string, bytes: Uint8Array) => Promise<void>;
|
|
15
|
+
replace: (temporary: string, destination: string) => Promise<void>;
|
|
16
|
+
remove: (path: string) => Promise<void>;
|
|
16
17
|
}
|
|
17
18
|
export interface PetAssetsHost {
|
|
18
|
-
account()
|
|
19
|
-
request<T>(path: string, method: "GET" | "POST", body?: unknown)
|
|
19
|
+
account: () => PetAccount | null;
|
|
20
|
+
request: <T>(path: string, method: "GET" | "POST", body?: unknown) => Promise<T>;
|
|
20
21
|
storage: PetStorage;
|
|
21
22
|
resources: PetResourceIO;
|
|
22
|
-
|
|
23
|
+
onResourceError?: (error: unknown, petId: string) => void;
|
|
24
|
+
validateImage?: (bytes: Uint8Array, mime: string) => Promise<void>;
|
|
25
|
+
download: (url: string, signal: AbortSignal) => Promise<Uint8Array>;
|
|
23
26
|
}
|
|
24
27
|
export declare function accountKey(account: PetAccount): string;
|
|
25
28
|
export declare function assertAccount(host: Pick<PetAssetsHost, "account">, expected: PetAccount): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import o from"../../../assets/pets/
|
|
1
|
+
import o from"../../../assets/pets/card-draw/album-icon.png?url";import r from"../../../assets/pets/card-draw/dialog-close.png?url";import t from"../../../assets/pets/card-draw/empty-pet.png?url";import e from"../../../assets/pets/card-draw/gem-plus.svg?url";import m from"../../../assets/pets/card-draw/gem.svg?url";import p from"../../../assets/pets/card-draw/new-tag.svg?url";import i from"../../../assets/pets/card-draw/not-enough-dialog.png?url";import l from"../../../assets/pets/card-draw/placeholder-card.png?url";import n from"../../../assets/pets/card-draw/proceed-active.png?url";import u from"../../../assets/pets/card-draw/proceed-default.png?url";import c from"../../../assets/pets/card-draw/proceed-hover.png?url";import s from"../../../assets/pets/card-draw/pull-album-icon-transparent.png?url";import a from"../../../assets/pets/card-draw/pull-back-transparent.png?url";import f from"../../../assets/pets/card-draw/pull-gem.svg?url";import d from"../../../assets/pets/card-draw/pull-page-background.png?url";import g from"../../../assets/pets/card-draw/pull-texture.png?url";import x from"../../../assets/pets/card-draw/pull-vibemon-icon-transparent.png?url";import U from"../../../assets/pets/card-draw/result-aura.webp?url";import h from"../../../assets/pets/card-draw/wish-default.png?url";import b from"../../../assets/pets/card-draw/wish.webp?url";import B from"../../../assets/pets/vibemon/album/arrow.svg?url";import k from"../../../assets/pets/vibemon/album/book.webp?url";import P from"../../../assets/pets/vibemon/album/page-bg.webp?url";import w from"../../../assets/pets/vibemon/equip/page-bg.webp?url";import H from"../../../assets/pets/vibemon/equip/single-pet-toast.png?url";import A from"../../../assets/pets/vibemon/guide/arrow.svg?url";import v from"../../../assets/pets/vibemon/guide/bubble-texture-home.png?url";import T from"../../../assets/pets/vibemon/guide/bubble-texture-pull.png?url";import I from"../../../assets/pets/vibemon/guide/hand-shape.svg?url";import V from"../../../assets/pets/vibemon/guide/hand-sheen.png?url";import D from"../../../assets/pets/vibemon/guide/hand.svg?url";import S from"../../../assets/pets/vibemon/guide/mascot.png?url";import W from"../../../assets/pets/vibemon/guide/ring.svg?url";import C from"../../../assets/pets/vibemon/home/album-icon-hover.png?url";import M from"../../../assets/pets/vibemon/home/album-icon.png?url";import q from"../../../assets/pets/vibemon/home/album-text.png?url";import y from"../../../assets/pets/vibemon/home/home-bg.webp?url";import G from"../../../assets/pets/vibemon/home/intro.mp4?url&no-inline";import L from"../../../assets/pets/vibemon/home/pull.mp4?url&no-inline";import R from"../../../assets/pets/vibemon/home/pull.webm?url&no-inline";import j from"../../../assets/pets/vibemon/home/vibemon-icon-hover.png?url";import z from"../../../assets/pets/vibemon/home/vibemon-icon.png?url";import E from"../../../assets/pets/vibemon/home/vibemon-text.png?url";import F from"../../../assets/pets/vibemon/home/wish-icon-hover.png?url";import J from"../../../assets/pets/vibemon/home/wish-icon.png?url";import K from"../../../assets/pets/vibemon/home/wish-text.png?url";import N from"../../../assets/pets/vibemon/loading/background.webp?url";import O from"../../../assets/pets/vibemon/loading/logo.webp?url";import Q from"../../../assets/pets/vibemon/multi-draw/bg-sr.png?url";import X from"../../../assets/pets/vibemon/multi-draw/bg-ssr.png?url";var Qo={vibemon:{icon:z,hover:j,text:E},wish:{icon:J,hover:F,text:K},album:{icon:M,hover:C,text:q}},Xo={default:u,hover:c,active:n},Yo=y,Zo=G,_o=L,$o=R,or=A,rr=v,tr=T,er=S,mr=D,pr=I,ir=V,lr=W,nr=B,ur=k,cr=P,sr=w,ar=H,fr=N,dr=O,gr=Q,xr=X,Ur=b,hr=h,br=p,Br=i,kr=r,Pr=t,wr=m,Hr=e,Ar=g,vr=f,Tr=d,Ir=a,Vr=x,Dr=s,Sr=o,Wr=l,Cr=U;export{nr as albumArrow,ur as albumBook,Sr as albumIcon,cr as albumPageBackground,kr as dialogClose,Pr as emptyPet,sr as equipPageBackground,wr as gem,Hr as gemPlus,or as guideArrow,mr as guideHand,pr as guideHandShape,ir as guideHandSheen,rr as guideHomeTexture,er as guideMascot,tr as guidePullTexture,lr as guideRing,Yo as homeBackground,Qo as homeHotspotAssets,Br as insufficientPointsDialog,Zo as introVideo,fr as loadingBackground,dr as loadingLogo,gr as multiDrawSrBackground,xr as multiDrawSsrBackground,br as newTag,Wr as placeholderCard,Xo as proceedButtonAssets,Dr as pullAlbumIcon,Ir as pullBack,vr as pullGem,Tr as pullPageBackground,Ar as pullTexture,Vr as pullVibemonIcon,_o as pullVideoMp4,$o as pullVideoWebm,Cr as resultAura,ar as singlePetToast,hr as wishDefault,Ur as wishHover};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as i,Fragment as c}from"react/jsx-runtime";import{
|
|
1
|
+
import{jsx as e,jsxs as i,Fragment as c}from"react/jsx-runtime";import{Loader2 as C}from"lucide-react";import{useMemo as x,useState as k}from"react";import{sortByRarityDesc as y}from"../../core/lib/rarity.js";import{albumArrow as N,albumBook as V,albumPageBackground as _}from"../assets.js";import{cardThumb as A}from"../lib/card-image.js";import{cn as f}from"../lib/utils.js";import{Button as P}from"../ui/button.js";import{VibemonEmptyState as B}from"./vibemon-empty-state.js";import{VibemonHeader as M}from"./vibemon-header.js";import{VibemonScene as j}from"./vibemon-scene.js";var l=8;function h({direction:r,disabled:t,onClick:a}){let o=r==="previous";return e(P,{"aria-label":o?"Previous album page":"Next album page",disabled:t,onClick:a,className:f("absolute top-[55.870%] z-20 size-[2.917cqw] bg-transparent p-0 shadow-none transition-none hover:bg-transparent disabled:opacity-100",o?"left-[20.521%]":"left-[76.563%]"),children:e("img",{src:N,alt:"",className:f("h-[63.9%] w-[46.2%] max-w-none select-none",o&&"-scale-x-100",t&&"opacity-50")})})}function E(){return i("div",{className:"relative h-full w-full",children:[e("svg",{viewBox:"0 0 200 288",preserveAspectRatio:"none","aria-hidden":!0,className:"absolute inset-0 h-full w-full opacity-25",children:e("rect",{x:"6.16",y:"7.76",width:"187.69",height:"272.47",rx:"14",fill:"none",stroke:"#8687CE",strokeWidth:"5",strokeDasharray:"25 25"})}),e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"67",height:"80",viewBox:"0 0 67 80",fill:"none",className:"absolute top-[50%] left-[50%] h-[27.5%] w-[33.1%] max-w-none translate-x-[-50%] translate-y-[-50%] select-none",children:e("path",{d:"M46.2449 32.0803V22.6882C46.2449 15.4054 40.3462 9.50669 33.0634 9.50669C25.7807 9.50669 19.882 15.415 19.882 22.6977V32.0899H46.2449V32.0803ZM9.69759 32.1853L9.68804 31.8894V21.5714C9.68804 15.854 11.9597 10.3657 16.0067 6.3187C20.0538 2.27168 25.5325 0 31.2595 0H34.877C46.789 0 56.4388 9.65941 56.4388 21.5619V32.1853C61.9939 32.9584 66.1269 37.7118 66.1269 43.3242V67.9786C66.1269 74.1923 61.0967 79.2224 54.883 79.2224H11.2439C5.03015 79.2224 0 74.1923 0 67.9786V43.3337C0 37.7213 4.13293 32.968 9.69759 32.1853ZM30.4672 57.5747V64.9242C30.4672 66.3559 31.6317 67.5204 33.0634 67.5204C34.4952 67.5204 35.6596 66.3559 35.6596 64.9242V57.5747C38.8572 56.3243 40.7184 52.974 40.0789 49.6047C39.4394 46.2258 36.4996 43.7823 33.0634 43.7823C29.6273 43.7823 26.6779 46.2258 26.048 49.6047C25.4084 52.974 27.2697 56.3243 30.4672 57.5747Z",fill:"#8687CE",fillOpacity:"0.25"})})]})}function S({cards:r}){return i(c,{children:[e("img",{src:V,alt:"","aria-hidden":!0,className:"pointer-events-none absolute top-[14.158%] left-[14.583%] h-[79.313%] w-[74.067%] max-w-none select-none",style:{maskImage:"linear-gradient(to bottom, rgba(255,255,255,0.8) 0%, #fff 25.66%, #fff 93.71%, rgba(255,255,255,0.2) 100%)",WebkitMaskImage:"linear-gradient(to bottom, rgba(255,255,255,0.8) 0%, #fff 25.66%, #fff 93.71%, rgba(255,255,255,0.2) 100%)"}}),e("div",{"data-testid":"album-book",className:"absolute top-[32.917%] left-[25.729%] grid h-[50.574%] w-[48.542%] grid-cols-4 grid-rows-2 gap-x-[4.721%] gap-y-[4.943%]",children:r.map((t,a)=>e("div",{className:"relative",children:t?e("img",{src:A(t.gacha_url??t.cover_url),alt:`${t.name} ${t.rarity_name} card`,className:"h-full w-full object-contain drop-shadow-[0_8px_9px_rgba(15,8,64,0.24)] select-none"}):e(E,{})},t?`${t.vibemon_uuid}-${a}`:`locked-${a}`))})]})}function T({onBack:r,onWish:t,onEquip:a,ownedCards:o,ownedLoaded:g,availablePoints:b,pointsLoaded:w}){let[v,u]=k(0),m=x(()=>y(o).flatMap((p)=>Array.from({length:p.duplicate_count},()=>p)),[o]),s=Math.ceil(m.length/l),n=s===0?0:Math.min(v,s-1),d=[...m.slice(n*l,(n+1)*l)];while(d.length<l)d.push(null);return i(j,{backdrop:i(c,{children:[e("img",{src:_,alt:"","aria-hidden":!0,className:"pointer-events-none absolute inset-0 h-full w-full object-cover select-none"}),e("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 bg-[#422053]/20"})]}),children:[e(M,{onBack:r,onWish:t,sectionAction:{kind:"equip",onClick:a},availablePoints:b,pointsLoaded:w}),!g?e("div",{"data-testid":"vibemon-owned-loading",className:"absolute inset-0 flex items-center justify-center text-[#DCC9FF]",children:e(C,{className:"size-8 animate-spin"})}):m.length===0?e(B,{onWish:t}):i(c,{children:[e(S,{cards:d}),s>1&&i(c,{children:[e(h,{direction:"previous",disabled:n===0,onClick:()=>u(n-1)}),e(h,{direction:"next",disabled:n>=s-1,onClick:()=>u(n+1)})]})]})]})}export{T as AlbumView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as r}from"react/jsx-runtime";import{
|
|
1
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import{cn as i}from"../lib/utils.js";import{Button as l}from"../ui/button.js";function d({onClick:n,className:a,disabled:t=!1,label:o="Home",iconSrc:s}){return r(l,{variant:"ghost",className:i("h-auto gap-2 p-0 text-[#8A55C5]/80 hover:bg-transparent hover:text-[#8A55C5]/80",a),disabled:t,onClick:n,children:[s===void 0?e("svg",{viewBox:"0 0 28 28",fill:"none","aria-hidden":"true",className:"size-7 shrink-0",children:e("path",{d:"M12.5709 8.57642V3.93455C12.5867 3.8165 12.5756 3.69641 12.5382 3.5833C12.5009 3.4702 12.4384 3.36704 12.3555 3.28158C12.2055 3.1325 12.0026 3.04883 11.7911 3.04883C11.5796 3.04883 11.3767 3.1325 11.2267 3.28158L3.36348 11.9028C3.21724 12.0686 3.13655 12.2821 3.13655 12.5031C3.13655 12.7242 3.21724 12.9377 3.36348 13.1035L11.1838 21.6749C11.4769 21.9248 12.0112 22.0656 12.3557 21.7208C12.534 21.5431 12.6114 21.3927 12.5857 21.1608V16.4383C17.0974 16.4383 21.2356 19.2604 22.8549 23.2291C23.0887 23.8033 23.9213 23.7437 24.066 23.1416C24.2809 22.2415 24.3892 21.3193 24.3886 20.3938C24.3908 13.8674 19.1001 8.57642 12.5709 8.57642Z",fill:"currentColor"})}):e("img",{src:s,alt:"",className:"size-7 shrink-0"}),e("span",{className:"text-[20px] leading-none font-semibold select-none",children:o})]})}export{d as BackToHome};
|