@alwith/module-auth 0.1.0 → 0.1.4
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/LICENSE +2 -2
- package/README.md +35 -1
- package/THIRD_PARTY_NOTICES.md +32 -2
- package/assets/pets/assets/fonts/GrowYear.woff2 +0 -0
- package/assets/pets/assets/fonts/Outfit-Variable.woff2 +0 -0
- package/assets/pets/card-draw/add-to-album-active.png +0 -0
- package/assets/pets/card-draw/add-to-album-default.png +0 -0
- package/assets/pets/card-draw/add-to-album-hover.png +0 -0
- package/assets/pets/card-draw/album-bg.webp +0 -0
- package/assets/pets/card-draw/album-icon.png +0 -0
- package/assets/pets/card-draw/card-back.webp +0 -0
- package/assets/pets/card-draw/card-star.svg +13 -0
- package/assets/pets/card-draw/dialog-close.png +0 -0
- package/assets/pets/card-draw/download.svg +3 -0
- package/assets/pets/card-draw/empty-pet.png +0 -0
- package/assets/pets/card-draw/gem-plus.svg +4 -0
- package/assets/pets/card-draw/gem.svg +23 -0
- package/assets/pets/card-draw/new-tag.svg +14 -0
- package/assets/pets/card-draw/not-enough-dialog.png +0 -0
- package/assets/pets/card-draw/placeholder-card.png +0 -0
- package/assets/pets/card-draw/proceed-active.png +0 -0
- package/assets/pets/card-draw/proceed-default.png +0 -0
- package/assets/pets/card-draw/proceed-hover.png +0 -0
- package/assets/pets/card-draw/pull-0-active.png +0 -0
- package/assets/pets/card-draw/pull-0-default.png +0 -0
- package/assets/pets/card-draw/pull-0-hover.png +0 -0
- package/assets/pets/card-draw/pull-160-active.png +0 -0
- package/assets/pets/card-draw/pull-160-default.png +0 -0
- package/assets/pets/card-draw/pull-160-hover.png +0 -0
- package/assets/pets/card-draw/pull-1600-active.png +0 -0
- package/assets/pets/card-draw/pull-1600-default.png +0 -0
- package/assets/pets/card-draw/pull-1600-hover.png +0 -0
- package/assets/pets/card-draw/pull-album-icon-transparent.png +0 -0
- package/assets/pets/card-draw/pull-back-transparent.png +0 -0
- package/assets/pets/card-draw/pull-gem.svg +27 -0
- package/assets/pets/card-draw/pull-page-background.png +0 -0
- package/assets/pets/card-draw/pull-texture.png +0 -0
- package/assets/pets/card-draw/pull-vibemon-icon-transparent.png +0 -0
- package/assets/pets/card-draw/rarity-bg-sr.webp +0 -0
- package/assets/pets/card-draw/rarity-bg-ssr.webp +0 -0
- package/assets/pets/card-draw/result-aura.webp +0 -0
- package/assets/pets/card-draw/stage.webp +0 -0
- package/assets/pets/card-draw/wish-default.png +0 -0
- package/assets/pets/card-draw/wish.webp +0 -0
- package/assets/pets/vibemon/album/arrow.svg +12 -0
- package/assets/pets/vibemon/album/book.webp +0 -0
- package/assets/pets/vibemon/album/logo.webp +0 -0
- package/assets/pets/vibemon/album/page-bg.webp +0 -0
- package/assets/pets/vibemon/burst-sheet.png +0 -0
- package/assets/pets/vibemon/chick-armor/config.json +61 -0
- package/assets/pets/vibemon/chick-armor/sprite-sheet.webp +0 -0
- package/assets/pets/vibemon/chick-classic/config.json +61 -0
- package/assets/pets/vibemon/chick-classic/sprite-sheet.webp +0 -0
- package/assets/pets/vibemon/default-cat/config.json +37 -0
- package/assets/pets/vibemon/default-cat/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/dino-cole-f/config.json +137 -0
- package/assets/pets/vibemon/dino-cole-f/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/dino-cole-m/config.json +137 -0
- package/assets/pets/vibemon/dino-cole-m/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/dino-doux-f/config.json +137 -0
- package/assets/pets/vibemon/dino-doux-f/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/dino-kira-f/config.json +137 -0
- package/assets/pets/vibemon/dino-kira-f/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/dino-kira-m/config.json +137 -0
- package/assets/pets/vibemon/dino-kira-m/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/dino-kuro-f/config.json +137 -0
- package/assets/pets/vibemon/dino-kuro-f/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/dino-kuro-m/config.json +137 -0
- package/assets/pets/vibemon/dino-kuro-m/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/dino-loki-f/config.json +137 -0
- package/assets/pets/vibemon/dino-loki-f/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/dino-loki-m/config.json +137 -0
- package/assets/pets/vibemon/dino-loki-m/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/dino-mono-f/config.json +137 -0
- package/assets/pets/vibemon/dino-mono-f/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/dino-mono-m/config.json +137 -0
- package/assets/pets/vibemon/dino-mono-m/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/dino-mort-f/config.json +137 -0
- package/assets/pets/vibemon/dino-mort-f/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/dino-nico-f/config.json +137 -0
- package/assets/pets/vibemon/dino-nico-f/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/dino-nico-m/config.json +137 -0
- package/assets/pets/vibemon/dino-nico-m/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/dino-olaf-f/config.json +137 -0
- package/assets/pets/vibemon/dino-olaf-f/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/dino-olaf-m/config.json +137 -0
- package/assets/pets/vibemon/dino-olaf-m/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/dino-purple-horn/config.json +35 -0
- package/assets/pets/vibemon/dino-purple-horn/sprite-sheet.webp +0 -0
- package/assets/pets/vibemon/dino-sena-f/config.json +137 -0
- package/assets/pets/vibemon/dino-sena-f/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/dino-sena-m/config.json +137 -0
- package/assets/pets/vibemon/dino-sena-m/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/dino-tard-f/config.json +137 -0
- package/assets/pets/vibemon/dino-tard-f/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/dino-vita-f/config.json +137 -0
- package/assets/pets/vibemon/dino-vita-f/sprite-sheet.png +0 -0
- package/assets/pets/vibemon/equip/page-bg.webp +0 -0
- package/assets/pets/vibemon/equip/single-pet-toast.png +0 -0
- package/assets/pets/vibemon/guide/arrow.svg +29 -0
- package/assets/pets/vibemon/guide/bubble-texture-home.png +0 -0
- package/assets/pets/vibemon/guide/bubble-texture-pull.png +0 -0
- package/assets/pets/vibemon/guide/hand-shape.svg +3 -0
- package/assets/pets/vibemon/guide/hand-sheen.png +0 -0
- package/assets/pets/vibemon/guide/hand.svg +10 -0
- package/assets/pets/vibemon/guide/mascot.png +0 -0
- package/assets/pets/vibemon/guide/ring.svg +41 -0
- package/assets/pets/vibemon/home/album-icon-hover.png +0 -0
- package/assets/pets/vibemon/home/album-icon.png +0 -0
- package/assets/pets/vibemon/home/album-text.png +0 -0
- package/assets/pets/vibemon/home/home-bg-bak.webp +0 -0
- package/assets/pets/vibemon/home/home-bg.webp +0 -0
- package/assets/pets/vibemon/home/intro.mp4 +0 -0
- package/assets/pets/vibemon/home/pull.mp4 +0 -0
- package/assets/pets/vibemon/home/pull.webm +0 -0
- package/assets/pets/vibemon/home/vibemon-icon-hover.png +0 -0
- package/assets/pets/vibemon/home/vibemon-icon.png +0 -0
- package/assets/pets/vibemon/home/vibemon-text.png +0 -0
- package/assets/pets/vibemon/home/wish-icon-hover.png +0 -0
- package/assets/pets/vibemon/home/wish-icon.png +0 -0
- package/assets/pets/vibemon/home/wish-text.png +0 -0
- package/assets/pets/vibemon/loading/background.webp +0 -0
- package/assets/pets/vibemon/loading/logo.webp +0 -0
- package/assets/pets/vibemon/multi-draw/bg-sr.png +0 -0
- package/assets/pets/vibemon/multi-draw/bg-ssr.png +0 -0
- package/dist/client.d.ts +1 -1
- package/dist/pets/assets.d.ts +35 -0
- package/dist/pets/assets.js +1 -0
- package/dist/pets/client.d.ts +12 -0
- package/dist/pets/client.js +1 -0
- package/dist/pets/core/engine.d.ts +63 -0
- package/dist/pets/core/engine.js +1 -0
- package/dist/pets/core/host.d.ts +112 -0
- package/dist/pets/core/host.js +1 -0
- package/dist/pets/core/index.d.ts +11 -0
- package/dist/pets/core/index.js +1 -0
- package/dist/pets/core/lib/account-state.d.ts +6 -0
- package/dist/pets/core/lib/account-state.js +1 -0
- package/dist/pets/core/lib/bubble-outline.d.ts +18 -0
- package/dist/pets/core/lib/bubble-outline.js +1 -0
- package/dist/pets/core/lib/draw-result.d.ts +22 -0
- package/dist/pets/core/lib/draw-result.js +1 -0
- package/dist/pets/core/lib/endpoints.d.ts +9 -0
- package/dist/pets/core/lib/endpoints.js +1 -0
- package/dist/pets/core/lib/gacha-pools.d.ts +28 -0
- package/dist/pets/core/lib/gacha-pools.js +1 -0
- package/dist/pets/core/lib/loading-progress.d.ts +2 -0
- package/dist/pets/core/lib/loading-progress.js +1 -0
- package/dist/pets/core/lib/pet-animation-sync.d.ts +20 -0
- package/dist/pets/core/lib/pet-animation-sync.js +1 -0
- package/dist/pets/core/lib/pet-bubble-state.d.ts +22 -0
- package/dist/pets/core/lib/pet-bubble-state.js +1 -0
- package/dist/pets/core/lib/pet-drag.d.ts +3 -0
- package/dist/pets/core/lib/pet-drag.js +1 -0
- package/dist/pets/core/lib/pet-presentation.d.ts +6 -0
- package/dist/pets/core/lib/pet-presentation.js +1 -0
- package/dist/pets/core/lib/pet-session-context.d.ts +14 -0
- package/dist/pets/core/lib/pet-session-context.js +1 -0
- package/dist/pets/core/lib/preload-images.d.ts +1 -0
- package/dist/pets/core/lib/preload-images.js +1 -0
- package/dist/pets/core/lib/presentation-readiness.d.ts +15 -0
- package/dist/pets/core/lib/presentation-readiness.js +1 -0
- package/dist/pets/core/lib/rarity.d.ts +2 -0
- package/dist/pets/core/lib/rarity.js +1 -0
- package/dist/pets/core/lib/recharge.d.ts +1 -0
- package/dist/pets/core/lib/recharge.js +1 -0
- package/dist/pets/core/lib/reply-submission.d.ts +10 -0
- package/dist/pets/core/lib/reply-submission.js +1 -0
- package/dist/pets/core/lib/resource-sync.d.ts +8 -0
- package/dist/pets/core/lib/resource-sync.js +1 -0
- package/dist/pets/core/lib/runtime-types.d.ts +1 -0
- package/dist/pets/core/lib/runtime-types.js +0 -0
- package/dist/pets/core/lib/settings.d.ts +22 -0
- package/dist/pets/core/lib/settings.js +1 -0
- package/dist/pets/core/lib/sprite-config.d.ts +4 -0
- package/dist/pets/core/lib/sprite-config.js +1 -0
- package/dist/pets/core/lib/vibemon-resources.d.ts +3 -0
- package/dist/pets/core/lib/vibemon-resources.js +1 -0
- package/dist/pets/core/lib/view-request.d.ts +4 -0
- package/dist/pets/core/lib/view-request.js +1 -0
- package/dist/pets/core/lib/window-frame.d.ts +14 -0
- package/dist/pets/core/lib/window-frame.js +1 -0
- package/dist/pets/core/lib/window-manager.d.ts +3 -0
- package/dist/pets/core/lib/window-manager.js +1 -0
- package/dist/pets/core/session-icon.d.ts +2 -0
- package/dist/pets/core/session-icon.js +5 -0
- package/dist/pets/core/types.d.ts +68 -0
- package/dist/pets/core/types.js +1 -0
- package/dist/pets/host.d.ts +25 -0
- package/dist/pets/host.js +1 -0
- package/dist/pets/index.d.ts +6 -0
- package/dist/pets/index.js +1 -0
- package/dist/pets/react/assets.d.ts +60 -0
- package/dist/pets/react/assets.js +1 -0
- package/dist/pets/react/components/album-view.d.ts +10 -0
- package/dist/pets/react/components/album-view.js +1 -0
- package/dist/pets/react/components/back-to-home.d.ts +7 -0
- package/dist/pets/react/components/back-to-home.js +1 -0
- package/dist/pets/react/components/equip-view.d.ts +18 -0
- package/dist/pets/react/components/equip-view.js +1 -0
- package/dist/pets/react/components/gem-balance.d.ts +7 -0
- package/dist/pets/react/components/gem-balance.js +1 -0
- package/dist/pets/react/components/home-view.d.ts +6 -0
- package/dist/pets/react/components/home-view.js +1 -0
- package/dist/pets/react/components/insufficient-points-dialog.d.ts +4 -0
- package/dist/pets/react/components/insufficient-points-dialog.js +1 -0
- package/dist/pets/react/components/intro-overlay.d.ts +5 -0
- package/dist/pets/react/components/intro-overlay.js +1 -0
- package/dist/pets/react/components/loading-view.d.ts +4 -0
- package/dist/pets/react/components/loading-view.js +1 -0
- package/dist/pets/react/components/lounge-burst.css +38 -0
- package/dist/pets/react/components/onboarding-guide.d.ts +3 -0
- package/dist/pets/react/components/onboarding-guide.js +1 -0
- package/dist/pets/react/components/pet-bubble-background.d.ts +7 -0
- package/dist/pets/react/components/pet-bubble-background.js +1 -0
- package/dist/pets/react/components/pet-mode-button.d.ts +4 -0
- package/dist/pets/react/components/pet-mode-button.js +1 -0
- package/dist/pets/react/components/pet-window.d.ts +2 -0
- package/dist/pets/react/components/pet-window.js +1 -0
- package/dist/pets/react/components/pull-overlay.d.ts +9 -0
- package/dist/pets/react/components/pull-overlay.js +1 -0
- package/dist/pets/react/components/pull-video.d.ts +7 -0
- package/dist/pets/react/components/pull-video.js +1 -0
- package/dist/pets/react/components/pull-view.d.ts +16 -0
- package/dist/pets/react/components/pull-view.js +1 -0
- package/dist/pets/react/components/quick-reply.d.ts +3 -0
- package/dist/pets/react/components/quick-reply.js +2 -0
- package/dist/pets/react/components/session-icon.d.ts +6 -0
- package/dist/pets/react/components/session-icon.js +1 -0
- package/dist/pets/react/components/single-pet-toast.d.ts +6 -0
- package/dist/pets/react/components/single-pet-toast.js +1 -0
- package/dist/pets/react/components/sprite-renderer.d.ts +16 -0
- package/dist/pets/react/components/sprite-renderer.js +1 -0
- package/dist/pets/react/components/vibemon-empty-state.d.ts +3 -0
- package/dist/pets/react/components/vibemon-empty-state.js +1 -0
- package/dist/pets/react/components/vibemon-header.d.ts +16 -0
- package/dist/pets/react/components/vibemon-header.js +1 -0
- package/dist/pets/react/components/vibemon-page.d.ts +1 -0
- package/dist/pets/react/components/vibemon-page.js +1 -0
- package/dist/pets/react/components/vibemon-scene.d.ts +5 -0
- package/dist/pets/react/components/vibemon-scene.js +1 -0
- package/dist/pets/react/components/video-fader.d.ts +23 -0
- package/dist/pets/react/components/video-fader.js +1 -0
- package/dist/pets/react/components/wish-button.d.ts +4 -0
- package/dist/pets/react/components/wish-button.js +1 -0
- package/dist/pets/react/index.d.ts +4 -0
- package/dist/pets/react/index.js +1 -0
- package/dist/pets/react/lib/account-state.d.ts +2 -0
- package/dist/pets/react/lib/account-state.js +1 -0
- package/dist/pets/react/lib/card-image.d.ts +1 -0
- package/dist/pets/react/lib/card-image.js +1 -0
- package/dist/pets/react/lib/resource-sync.d.ts +5 -0
- package/dist/pets/react/lib/resource-sync.js +1 -0
- package/dist/pets/react/lib/utils.d.ts +1 -0
- package/dist/pets/react/lib/utils.js +1 -0
- package/dist/pets/react/locales.d.ts +144 -0
- package/dist/pets/react/locales.js +1 -0
- package/dist/pets/react/styles.css +15 -0
- package/dist/pets/react/ui/button.d.ts +8 -0
- package/dist/pets/react/ui/button.js +1 -0
- package/dist/pets/react/ui/card.d.ts +11 -0
- package/dist/pets/react/ui/card.js +1 -0
- package/dist/pets/react/ui/input-group.d.ts +16 -0
- package/dist/pets/react/ui/input-group.js +1 -0
- package/dist/pets/react/ui/textarea.d.ts +3 -0
- package/dist/pets/react/ui/textarea.js +1 -0
- package/dist/pets/resources.d.ts +30 -0
- package/dist/pets/resources.js +1 -0
- package/dist/pets/selection.d.ts +7 -0
- package/dist/pets/selection.js +1 -0
- package/dist/pets/types.d.ts +221 -0
- package/dist/pets/types.js +0 -0
- package/package.json +52 -4
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/client.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface AuthClientHost {
|
|
|
9
9
|
onLogoutError: (error: unknown) => void;
|
|
10
10
|
logInfo: (message: string) => void | Promise<void>;
|
|
11
11
|
}
|
|
12
|
-
export declare function createAuthClient({ publicPost, apiPost, platform, arch, getDeviceId, onLogoutError, logInfo
|
|
12
|
+
export declare function createAuthClient({ publicPost, apiPost, platform, arch, getDeviceId, onLogoutError, logInfo }: AuthClientHost): {
|
|
13
13
|
sendVerificationCode: (email: string, purpose?: SendCodePurpose) => Promise<void>;
|
|
14
14
|
loginWithCode: (email: string, code: string) => Promise<LoginResponse>;
|
|
15
15
|
loginWithPassword: (email: string, password: string) => Promise<LoginResponse>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type PetAssetsHost } from "./host.js";
|
|
2
|
+
import type { MyVibemonItem, VibemonCatalogItem } from "./types.js";
|
|
3
|
+
export declare function createPetAssets(host: PetAssetsHost): {
|
|
4
|
+
getMyVibemons: (params?: Parameters<(params?: import("./types").GetMyVibemonsParams) => Promise<MyVibemonItem[]>>[0]) => Promise<MyVibemonItem[]>;
|
|
5
|
+
getVibemonCatalog: () => Promise<VibemonCatalogItem[]>;
|
|
6
|
+
resources: {
|
|
7
|
+
inspect: (petId: string) => Promise<import("./resources").CachedPetMetadata | null>;
|
|
8
|
+
cached: (petId: string) => Promise<import("./resources").CachedPetResource | null>;
|
|
9
|
+
ensure: (item: VibemonCatalogItem) => Promise<import("./resources").CachedPetResource>;
|
|
10
|
+
cancel: () => void;
|
|
11
|
+
dispose(): void;
|
|
12
|
+
};
|
|
13
|
+
restoreOwned: () => Promise<MyVibemonItem[] | null>;
|
|
14
|
+
revision: number;
|
|
15
|
+
snapshot: () => {
|
|
16
|
+
account: import("./host").PetAccount | null;
|
|
17
|
+
owned: MyVibemonItem[] | null;
|
|
18
|
+
catalog: VibemonCatalogItem[] | null;
|
|
19
|
+
};
|
|
20
|
+
invalidate(): void;
|
|
21
|
+
subscribe(listener: () => void): () => void;
|
|
22
|
+
selection: {
|
|
23
|
+
get: () => Promise<string | null>;
|
|
24
|
+
select(id: string | null): Promise<void>;
|
|
25
|
+
};
|
|
26
|
+
ensureResource(id: string): Promise<import("./resources").CachedPetResource>;
|
|
27
|
+
dispose(): void;
|
|
28
|
+
markVibemonFirstVisit: () => Promise<import("./types").VibemonFirstVisitResponse>;
|
|
29
|
+
getGachaFirstDraw: () => Promise<import("./types").GachaFirstDrawResponse>;
|
|
30
|
+
getActiveGachaPools: () => Promise<import("./types").GachaPoolSummary[]>;
|
|
31
|
+
getGachaPoolDetail: (id: string) => Promise<import("./types").GachaPoolDetailResponse>;
|
|
32
|
+
getPointAccount: () => Promise<import("./types").PointAccountData>;
|
|
33
|
+
drawGachaPool(poolId: string, drawType: import("./types").DrawType): Promise<import("./types").DrawResponse>;
|
|
34
|
+
};
|
|
35
|
+
export type PetAssets = ReturnType<typeof createPetAssets>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createPetClient as R}from"./client.js";import{accountKey as g,assertAccount as c}from"./host.js";import{createPetResources as h}from"./resources.js";import{createPetSelection as q}from"./selection.js";function F(t){let d=R(t),u=h(t),o=null,l=!1,a=0,s=null,y="",v=!1,V=0,f=new Set;function i(){V++;for(let e of f)e()}function r(){if(v)throw Error("Vibemon asset service disposed");let e=t.account(),n=e===null?"":`${g(e)}/${e.revision}`;if(y!==n)y=n,o=null,l=!1,a++,s=null,u.cancel();return e}async function m(e){let n=r(),S=e===void 0?++a:a,w=await d.getMyVibemons(e);if(n===null)throw Error("Sign in to use Vibemon");if(c(t,n),r(),e===void 0&&S===a)o=w,l=!0,await t.storage.set(`vibemon.owned.${g(n)}`,w),c(t,n),i();return w}async function C(){let e=r();if(e===null)return null;if(l)return o;let n=await t.storage.get(`vibemon.owned.${g(e)}`);return c(t,e),o=n??null,i(),o}async function p(){let e=r(),n=await d.getVibemonCatalog();if(e===null)throw Error("Sign in to use Vibemon");return c(t,e),r(),s=n,i(),n}let E=q(t,async(e)=>{if(r(),l&&o!==null&&o.some((n)=>n.vibemon_uuid===e))return o;return m()});return{...d,getMyVibemons:m,getVibemonCatalog:p,resources:u,restoreOwned:C,get revision(){return V},snapshot:()=>({account:r(),owned:o,catalog:s}),invalidate(){r(),i()},subscribe(e){return f.add(e),()=>{f.delete(e)}},selection:{get:E.get,async select(e){r(),await E.select(e),i()}},async ensureResource(e){let n=r();if(n===null)throw Error("Sign in to use Vibemon");if(!(o??await m()).some((b)=>b.vibemon_uuid===e))throw Error("This account does not own this Vibemon");let P=(s??await p()).find((b)=>b.uuid===e);if(!P)throw Error("Vibemon resource is not in the catalog");return c(t,n),u.ensure(P)},dispose(){v=!0,o=null,s=null,u.dispose(),i(),f.clear()}}}export{F as createPetAssets};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type PetAssetsHost } from "./host.js";
|
|
2
|
+
import type { DrawResponse, DrawType, GachaFirstDrawResponse, GachaPoolDetailResponse, GachaPoolSummary, GetMyVibemonsParams, MyVibemonItem, PointAccountData, VibemonCatalogItem, VibemonFirstVisitResponse } from "./types.js";
|
|
3
|
+
export declare function createPetClient(host: Pick<PetAssetsHost, "account" | "request">): {
|
|
4
|
+
getVibemonCatalog: () => Promise<VibemonCatalogItem[]>;
|
|
5
|
+
getMyVibemons: (params?: GetMyVibemonsParams) => Promise<MyVibemonItem[]>;
|
|
6
|
+
markVibemonFirstVisit: () => Promise<VibemonFirstVisitResponse>;
|
|
7
|
+
getGachaFirstDraw: () => Promise<GachaFirstDrawResponse>;
|
|
8
|
+
getActiveGachaPools: () => Promise<GachaPoolSummary[]>;
|
|
9
|
+
getGachaPoolDetail: (id: string) => Promise<GachaPoolDetailResponse>;
|
|
10
|
+
getPointAccount: () => Promise<PointAccountData>;
|
|
11
|
+
drawGachaPool(poolId: string, drawType: DrawType): Promise<DrawResponse>;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{assertAccount as s}from"./host.js";function l(o){async function a(e,t,c){let i=o.account();if(i===null)throw Error("Sign in to use Vibemon");let n=await o.request(e,t,c);return s(o,i),n}let r=!1;return{getVibemonCatalog:()=>a("/api/v1/vibemons/catalog","GET"),getMyVibemons:(e={})=>{let t=new URLSearchParams;for(let[i,n]of Object.entries(e))if(n!==void 0)t.set(i,String(n));let c=t.size>0?`?${t}`:"";return a(`/api/v1/vibemons/mine${c}`,"GET")},markVibemonFirstVisit:()=>a("/api/v1/vibemons/first-visit","POST"),getGachaFirstDraw:()=>a("/api/v1/gacha/first-draw","GET"),getActiveGachaPools:()=>a("/api/v1/gacha/pools","GET"),getGachaPoolDetail:(e)=>a(`/api/v1/gacha/pools/${encodeURIComponent(e)}`,"GET"),getPointAccount:()=>a("/api/v1/points/account","GET"),async drawGachaPool(e,t){if(r)throw Error("A draw is already pending");r=!0;try{return await a("/api/v1/gacha/draw","POST",{pool_uuid:e,draw_type:t})}finally{r=!1}}}}export{l as createPetClient};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { RunState } from "./lib/runtime-types.js";
|
|
2
|
+
import type { VibemonNotification, VibemonSpriteConfig } from "./types.js";
|
|
3
|
+
interface Position {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
}
|
|
7
|
+
type StateChangeCallback = (stateId: string, flipped: boolean, restart: boolean) => void;
|
|
8
|
+
type NotificationCallback = (notification: VibemonNotification) => void;
|
|
9
|
+
export declare class VibemonEngine {
|
|
10
|
+
private currentBehavior;
|
|
11
|
+
private flipped;
|
|
12
|
+
private position;
|
|
13
|
+
private targetPosition;
|
|
14
|
+
private screenBounds;
|
|
15
|
+
private behaviorTimer;
|
|
16
|
+
private sleepTimer;
|
|
17
|
+
private moveTimerId;
|
|
18
|
+
private isDragging;
|
|
19
|
+
private isPresenting;
|
|
20
|
+
private isHatching;
|
|
21
|
+
private destroyed;
|
|
22
|
+
private suspended;
|
|
23
|
+
private behaviorBeforeDrag;
|
|
24
|
+
private working;
|
|
25
|
+
private sessionAnimation;
|
|
26
|
+
private onStateChange;
|
|
27
|
+
private onNotification;
|
|
28
|
+
private config;
|
|
29
|
+
constructor(config: VibemonSpriteConfig, onStateChange: StateChangeCallback, onNotification: NotificationCallback);
|
|
30
|
+
private stateOf;
|
|
31
|
+
start(savedPos?: {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
} | null): Promise<void>;
|
|
35
|
+
destroy(): void;
|
|
36
|
+
suspend(): void;
|
|
37
|
+
resume(): void;
|
|
38
|
+
presentAt(operation: () => Promise<Position>): Promise<void>;
|
|
39
|
+
private restBehavior;
|
|
40
|
+
setWorking(working: boolean): void;
|
|
41
|
+
setSessionState(sessionId: string | null, state: RunState | null, failed: boolean): void;
|
|
42
|
+
private applySessionAnimation;
|
|
43
|
+
handleNotification(notification: VibemonNotification): void;
|
|
44
|
+
handleClick(): void;
|
|
45
|
+
dismissError(): void;
|
|
46
|
+
private flipForDirection;
|
|
47
|
+
handleDragStart(movingLeft?: boolean): void;
|
|
48
|
+
setFacing(movingLeft: boolean): void;
|
|
49
|
+
handleDragEnd(): void;
|
|
50
|
+
private debugSpeed;
|
|
51
|
+
setDebugSpeed(speed: number): void;
|
|
52
|
+
stop(): void;
|
|
53
|
+
debugSetBehavior(behavior: string): void;
|
|
54
|
+
getDebugSpeed(): number;
|
|
55
|
+
debugRun(): Promise<void>;
|
|
56
|
+
private setBehavior;
|
|
57
|
+
private syncPositionFromWindow;
|
|
58
|
+
private updateScreenBounds;
|
|
59
|
+
private startMovement;
|
|
60
|
+
private cancelMovement;
|
|
61
|
+
private resetSleepTimer;
|
|
62
|
+
}
|
|
63
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{availableMonitors as a,getCurrentWindow as o}from"./lib/window-frame.js";import{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.sqrt(s*s+n*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};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { PetAccount, PetAssets, PetStorage } from "../index.js";
|
|
2
|
+
import type { SessionIcons } from "./session-icon.js";
|
|
3
|
+
import type { VibemonSpriteConfig } from "./types.js";
|
|
4
|
+
export type RunState = "running" | "requires_action" | "done" | "idle";
|
|
5
|
+
export interface PetBinding {
|
|
6
|
+
connectionEpoch: string;
|
|
7
|
+
agentId: string;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
incarnation: string;
|
|
10
|
+
bindingRevision: number;
|
|
11
|
+
}
|
|
12
|
+
export interface PetObservation {
|
|
13
|
+
binding: PetBinding;
|
|
14
|
+
source: "snapshot" | "event";
|
|
15
|
+
revision: number;
|
|
16
|
+
state: RunState;
|
|
17
|
+
since: number;
|
|
18
|
+
title: string;
|
|
19
|
+
cwd: string;
|
|
20
|
+
windowLabel: "main" | "chat";
|
|
21
|
+
candidates: PetSessionChoice[];
|
|
22
|
+
owner: string;
|
|
23
|
+
executionId: string | null;
|
|
24
|
+
executionRole: string | null;
|
|
25
|
+
access: "writable" | "readOnly" | "unavailable";
|
|
26
|
+
surfaceVisible: boolean;
|
|
27
|
+
error: string | null;
|
|
28
|
+
reply: {
|
|
29
|
+
messageId: string;
|
|
30
|
+
text: string;
|
|
31
|
+
} | null;
|
|
32
|
+
userMessage: {
|
|
33
|
+
messageId: string;
|
|
34
|
+
text: string;
|
|
35
|
+
timestamp: number;
|
|
36
|
+
} | null;
|
|
37
|
+
prompt: PetPrompt | null;
|
|
38
|
+
}
|
|
39
|
+
export interface PetSessionChoice {
|
|
40
|
+
sessionId: string;
|
|
41
|
+
title: string;
|
|
42
|
+
cwd: string;
|
|
43
|
+
windowLabel: "main" | "chat";
|
|
44
|
+
}
|
|
45
|
+
export interface PetPrompt {
|
|
46
|
+
kind: "permission" | "question";
|
|
47
|
+
token: string;
|
|
48
|
+
title: string;
|
|
49
|
+
detail: string;
|
|
50
|
+
options: {
|
|
51
|
+
id: string;
|
|
52
|
+
label: string;
|
|
53
|
+
}[];
|
|
54
|
+
}
|
|
55
|
+
export interface PetSessionHost {
|
|
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
|
+
}
|
|
64
|
+
export interface Monitor {
|
|
65
|
+
position: {
|
|
66
|
+
x: number;
|
|
67
|
+
y: number;
|
|
68
|
+
};
|
|
69
|
+
size: {
|
|
70
|
+
width: number;
|
|
71
|
+
height: number;
|
|
72
|
+
};
|
|
73
|
+
scaleFactor: number;
|
|
74
|
+
}
|
|
75
|
+
export interface PetWindowHost {
|
|
76
|
+
call<T>(action: string, payload?: Record<string, unknown>): Promise<T>;
|
|
77
|
+
openPet(options?: {
|
|
78
|
+
trusted?: boolean;
|
|
79
|
+
}): Promise<"shown" | "unavailable">;
|
|
80
|
+
closePet(): Promise<void>;
|
|
81
|
+
openRecharge(): Promise<void>;
|
|
82
|
+
geometry(listener: () => void): Promise<() => void>;
|
|
83
|
+
moved(listener: (position: {
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
}) => void): Promise<() => void>;
|
|
87
|
+
commands(listener: (command: {
|
|
88
|
+
type: "present" | "reload" | "suspend" | "bubble-close" | "bubble-open" | "bubble-interact" | "close";
|
|
89
|
+
petId: string;
|
|
90
|
+
requestId: string;
|
|
91
|
+
}) => Promise<void>): () => void;
|
|
92
|
+
}
|
|
93
|
+
export interface VibemonHost {
|
|
94
|
+
sessionIcons?: SessionIcons;
|
|
95
|
+
account(): PetAccount | null;
|
|
96
|
+
assets: PetAssets;
|
|
97
|
+
storage: PetStorage;
|
|
98
|
+
subscribeStorage(listener: () => void): () => void;
|
|
99
|
+
sessions: PetSessionHost;
|
|
100
|
+
windows: PetWindowHost;
|
|
101
|
+
synchronizeResources?(): Promise<void>;
|
|
102
|
+
resourcesSynchronized?(updated: ReadonlySet<string>): Promise<void>;
|
|
103
|
+
onError(error: unknown): void;
|
|
104
|
+
}
|
|
105
|
+
export declare function configureVibemon(value: VibemonHost): () => void;
|
|
106
|
+
export declare function vibemonHost(): VibemonHost;
|
|
107
|
+
export declare function sameBinding(left: PetBinding, right: PetBinding): boolean;
|
|
108
|
+
export interface SpriteResource {
|
|
109
|
+
config: VibemonSpriteConfig;
|
|
110
|
+
spriteUrl: string;
|
|
111
|
+
dispose(): void;
|
|
112
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=null;function e(n){if(i!==null)throw Error("Vibemon already initialized in this window");return i=n,()=>{if(i===n)i=null}}function r(){if(i===null)throw Error("Vibemon has not initialized");return i}function t(n,o){return n.connectionEpoch===o.connectionEpoch&&n.agentId===o.agentId&&n.sessionId===o.sessionId&&n.incarnation===o.incarnation&&n.bindingRevision===o.bindingRevision}export{e as configureVibemon,t as sameBinding,r as vibemonHost};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./host.js";
|
|
2
|
+
export { initializeSettings, refreshSettings } from "./lib/settings.js";
|
|
3
|
+
export { getVibemonState, updateVibemonState } from "./lib/account-state.js";
|
|
4
|
+
export { syncVibemonResources, resourceSyncStatus, observeResourceSync, subscribeResourceSync, type ResourceSyncStatus } from "./lib/resource-sync.js";
|
|
5
|
+
export { loadVibemonResource } from "./lib/vibemon-resources.js";
|
|
6
|
+
export { requestVibemonView } from "./lib/view-request.js";
|
|
7
|
+
export { sessionIconSvg, type SessionIcons } from "./session-icon.js";
|
|
8
|
+
export { PetSessionContext, type PetSurface, type PetSurfaceLabel } from "./lib/pet-session-context.js";
|
|
9
|
+
export { createSpriteConfig, spriteConfig } from "./lib/sprite-config.js";
|
|
10
|
+
export { VibemonEngine } from "./engine.js";
|
|
11
|
+
export type * from "./types.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./host.js";import{initializeSettings as t,refreshSettings as i}from"./lib/settings.js";import{getVibemonState as s,updateVibemonState as m}from"./lib/account-state.js";import{syncVibemonResources as p,resourceSyncStatus as c,observeResourceSync as x,subscribeResourceSync as S}from"./lib/resource-sync.js";import{loadVibemonResource as u}from"./lib/vibemon-resources.js";import{requestVibemonView as g}from"./lib/view-request.js";import{sessionIconSvg as y}from"./session-icon.js";import{PetSessionContext as C}from"./lib/pet-session-context.js";import{createSpriteConfig as l,spriteConfig as v}from"./lib/sprite-config.js";import{VibemonEngine as q}from"./engine.js";export{C as PetSessionContext,q as VibemonEngine,l as createSpriteConfig,s as getVibemonState,t as initializeSettings,u as loadVibemonResource,x as observeResourceSync,i as refreshSettings,g as requestVibemonView,c as resourceSyncStatus,y as sessionIconSvg,v as spriteConfig,S as subscribeResourceSync,p as syncVibemonResources,m as updateVibemonState};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type PetAccountState } from "./settings.js";
|
|
2
|
+
export declare function getVibemonScopeSync(): string | null;
|
|
3
|
+
export declare function currentState(): PetAccountState;
|
|
4
|
+
export declare const getVibemonState: () => Promise<PetAccountState>;
|
|
5
|
+
export declare function updateVibemonState(patch: Partial<PetAccountState>): Promise<void>;
|
|
6
|
+
export declare function equipVibemonAfterDraw(id: string, firstDraw: boolean): Promise<void>;
|
|
@@ -0,0 +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=async()=>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};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type BackdropPathCommand = {
|
|
2
|
+
kind: "move" | "line";
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
} | {
|
|
6
|
+
kind: "curve";
|
|
7
|
+
control1X: number;
|
|
8
|
+
control1Y: number;
|
|
9
|
+
control2X: number;
|
|
10
|
+
control2Y: number;
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
} | {
|
|
14
|
+
kind: "close";
|
|
15
|
+
};
|
|
16
|
+
export declare function bubbleOutline(left: number, top: number, width: number, height: number, radius: number, tailHeight: number): BackdropPathCommand[];
|
|
17
|
+
export declare function backdropSvgPath(path: BackdropPathCommand[]): string;
|
|
18
|
+
export declare function scaleBackdropPath(path: BackdropPathCommand[], scale: number): BackdropPathCommand[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function v(n,o,k,y,r,l){let t=n+k,c=o+y,x=n+k/2;r=Math.min(r,k/2,y/2);let e=r*0.5522847498307936;return[{kind:"move",x:n+r,y:o},{kind:"line",x:t-r,y:o},{kind:"curve",control1X:t-r+e,control1Y:o,control2X:t,control2Y:o+r-e,x:t,y:o+r},{kind:"line",x:t,y:c-r},{kind:"curve",control1X:t,control1Y:c-r+e,control2X:t-r+e,control2Y:c,x:t-r,y:c},{kind:"line",x:x+l,y:c},{kind:"line",x:x+1,y:c+l-1},{kind:"curve",control1X:x+0.5,control1Y:c+l-0.5,control2X:x-0.5,control2Y:c+l-0.5,x:x-1,y:c+l-1},{kind:"line",x:x-l,y:c},{kind:"line",x:n+r,y:c},{kind:"curve",control1X:n+r-e,control1Y:c,control2X:n,control2Y:c-r+e,x:n,y:c-r},{kind:"line",x:n,y:o+r},{kind:"curve",control1X:n,control1Y:o+r-e,control2X:n+r-e,control2Y:o,x:n+r,y:o},{kind:"close"}]}function i(n){return n.map(X).join(" ")}function X(n){switch(n.kind){case"move":return`M${n.x},${n.y}`;case"line":return`L${n.x},${n.y}`;case"curve":return`C${n.control1X},${n.control1Y} ${n.control2X},${n.control2Y} ${n.x},${n.y}`;case"close":return"Z"}}function u(n,o){return n.map((k)=>Y(k,o))}function Y(n,o){switch(n.kind){case"move":case"line":return{kind:n.kind,x:n.x*o,y:n.y*o};case"curve":return{kind:"curve",control1X:n.control1X*o,control1Y:n.control1Y*o,control2X:n.control2X*o,control2Y:n.control2Y*o,x:n.x*o,y:n.y*o};case"close":return n}}export{i as backdropSvgPath,v as bubbleOutline,u as scaleBackdropPath};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DrawResultItem } from "./endpoints.js";
|
|
2
|
+
export type DrawResultRarity = "R" | "SR" | "SSR";
|
|
3
|
+
export interface CardDrawRewardViewModel {
|
|
4
|
+
kind: "card";
|
|
5
|
+
drawIndex: number;
|
|
6
|
+
vibemonUuid: string;
|
|
7
|
+
vibemonName: string;
|
|
8
|
+
singleImageUrl: string;
|
|
9
|
+
multiImageUrl: string;
|
|
10
|
+
rarity: DrawResultRarity;
|
|
11
|
+
isNew: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface WhiteCardDrawRewardViewModel {
|
|
14
|
+
kind: "white-card";
|
|
15
|
+
drawIndex: number;
|
|
16
|
+
rarity: "UC" | "C";
|
|
17
|
+
exchangePoints: number;
|
|
18
|
+
singleImageUrl: string;
|
|
19
|
+
multiImageUrl: string;
|
|
20
|
+
}
|
|
21
|
+
export type DrawRewardViewModel = CardDrawRewardViewModel | WhiteCardDrawRewardViewModel;
|
|
22
|
+
export declare const createDrawReward: (item: DrawResultItem) => DrawRewardViewModel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=(r)=>{if(r==="R"||r==="SR"||r==="SSR")return r;throw Error(`[vibemon] unsupported draw rarity: ${r}`)},e=(r,a,n)=>{if(r===null)throw Error(`[vibemon] drawn Vibemon ${a.vibemon_uuid} is missing ${n}`);return r},i=(r,a,n)=>{if(r===null)throw Error(`[vibemon] drawn white card at index ${a.draw_index} is missing ${n}`);return r},u=(r)=>({kind:"card",drawIndex:r.draw_index,vibemonUuid:r.vibemon_uuid,vibemonName:r.vibemon_name,singleImageUrl:e(r.gacha_url,r,"gacha_url"),multiImageUrl:e(r.multi_draw_url,r,"multi_draw_url"),rarity:d(r.rarity_code),isNew:!r.is_duplicate}),w=(r)=>{if(r==="UC"||r==="C")return r;throw Error(`[vibemon] unsupported white-card rarity: ${r}`)},l=(r)=>{if(r.reward_type==="VIBEMON")return u(r);return{kind:"white-card",drawIndex:r.draw_index,rarity:w(r.rarity_code),exchangePoints:r.exchange_points,singleImageUrl:i(r.gacha_url,r,"gacha_url"),multiImageUrl:i(r.multi_draw_url,r,"multi_draw_url")}};export{l as createDrawReward};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type * from "../../index.js";
|
|
2
|
+
export declare const getMyVibemons: () => Promise<import("./endpoints").MyVibemonItem[]>;
|
|
3
|
+
export declare const getVibemonCatalog: () => Promise<import("./endpoints").VibemonCatalogItem[]>;
|
|
4
|
+
export declare const getPointAccount: () => Promise<import("./endpoints").PointAccountData>;
|
|
5
|
+
export declare const getGachaFirstDraw: () => Promise<import("./endpoints").GachaFirstDrawResponse>;
|
|
6
|
+
export declare const markVibemonFirstVisit: () => Promise<import("./endpoints").VibemonFirstVisitResponse>;
|
|
7
|
+
export declare const getActiveGachaPools: () => Promise<import("./endpoints").GachaPoolSummary[]>;
|
|
8
|
+
export declare const getGachaPoolDetail: (id: string) => Promise<import("./endpoints").GachaPoolDetailResponse>;
|
|
9
|
+
export declare const drawGachaPool: (id: string, type: import("../../index").DrawType) => Promise<import("./endpoints").DrawResponse>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{vibemonHost as t}from"../host.js";var a=()=>t().assets.getMyVibemons(),c=()=>t().assets.getVibemonCatalog(),i=()=>t().assets.getPointAccount(),r=()=>t().assets.getGachaFirstDraw(),n=()=>t().assets.markVibemonFirstVisit(),g=()=>t().assets.getActiveGachaPools(),m=(o)=>t().assets.getGachaPoolDetail(o),l=(o,s)=>t().assets.drawGachaPool(o,s);export{l as drawGachaPool,g as getActiveGachaPools,r as getGachaFirstDraw,m as getGachaPoolDetail,a as getMyVibemons,i as getPointAccount,c as getVibemonCatalog,n as markVibemonFirstVisit};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type GachaPoolDetailResponse, type GachaPoolSummary } from "./endpoints.js";
|
|
2
|
+
export type GachaPoolStatus = "UPCOMING" | "ACTIVE" | "ENDED" | "UNAVAILABLE";
|
|
3
|
+
export interface GachaPoolViewModel {
|
|
4
|
+
poolUuid: string;
|
|
5
|
+
name: string;
|
|
6
|
+
sidebarSelectedImageUrl: string;
|
|
7
|
+
sidebarHoverImageUrl: string;
|
|
8
|
+
sidebarUnselectedImageUrl: string;
|
|
9
|
+
pageBackgroundImageUrl: string;
|
|
10
|
+
poolCardImageUrl: string;
|
|
11
|
+
status: GachaPoolStatus;
|
|
12
|
+
startsAt: string | null;
|
|
13
|
+
endsAt: string | null;
|
|
14
|
+
singlePrice: number;
|
|
15
|
+
multiPrice: number;
|
|
16
|
+
currencyType: string;
|
|
17
|
+
canDraw: boolean;
|
|
18
|
+
isDefault: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface GachaPoolCatalogViewModel {
|
|
21
|
+
pools: GachaPoolViewModel[];
|
|
22
|
+
}
|
|
23
|
+
export declare function createGachaPoolCatalog(summaries: GachaPoolSummary[], details: GachaPoolDetailResponse[]): GachaPoolCatalogViewModel;
|
|
24
|
+
export declare function gachaPoolImageUrls(catalog: GachaPoolCatalogViewModel): string[];
|
|
25
|
+
export declare function loadGachaPoolCatalog(): Promise<GachaPoolCatalogViewModel>;
|
|
26
|
+
export declare function resolveGachaPoolStatus(pool: GachaPoolViewModel, nowMs: number): GachaPoolStatus;
|
|
27
|
+
export declare function getDefaultGachaPool(visiblePools: GachaPoolViewModel[]): GachaPoolViewModel;
|
|
28
|
+
export declare function getVisibleGachaPools(pools: GachaPoolViewModel[], nowMs: number): GachaPoolViewModel[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getActiveGachaPools as c,getGachaPoolDetail as l}from"./endpoints.js";var s={SSR:5,SR:4,R:3,UC:2,C:1};function d(r){let e=r.items.filter((o)=>o.reward_type==="VIBEMON"&&o.status===1),t=e[0];if(t===void 0)throw Error(`[vibemon] gacha pool ${r.uuid} has no active Vibemon item`);return e.slice(1).reduce((o,n)=>{if(s[n.rarity_code]-s[o.rarity_code]>0)return n;return o},t)}function a(r,e,t){if(r===null)throw Error(`[vibemon] gacha pool ${e} featured Vibemon is missing ${t}`);return r}function _(r,e){if(e.uuid!==r.uuid)throw Error(`[vibemon] gacha pool detail UUID ${e.uuid} does not match catalog UUID ${r.uuid}`);if(e.multi_count!==10)throw Error(`[vibemon] gacha pool ${e.uuid} multi_count must be 10, received ${e.multi_count}`);let t=d(e);return{poolUuid:e.uuid,name:e.name,sidebarSelectedImageUrl:a(t.vibemon_sidebar_selected_url,e.uuid,"vibemon_sidebar_selected_url"),sidebarHoverImageUrl:a(t.vibemon_sidebar_hover_url,e.uuid,"vibemon_sidebar_hover_url"),sidebarUnselectedImageUrl:a(t.vibemon_sidebar_unselected_url,e.uuid,"vibemon_sidebar_unselected_url"),pageBackgroundImageUrl:a(t.vibemon_background_url,e.uuid,"vibemon_background_url"),poolCardImageUrl:a(t.vibemon_pool_card_url,e.uuid,"vibemon_pool_card_url"),status:e.status===1?"ACTIVE":"UNAVAILABLE",startsAt:r.start_time,endsAt:r.end_time,singlePrice:e.next_single_actual_cost??r.single_cost,multiPrice:e.next_multi_actual_cost??r.multi_cost,currencyType:r.currency_type,canDraw:e.status===1,isDefault:r.is_default===1}}function f(r,e){if(r.length===0)throw Error("[vibemon] active gacha pool catalog is empty");let t=new Map(e.map((n)=>[n.uuid,n]));return{pools:[...r].sort((n,i)=>n.sort_order-i.sort_order).map((n)=>{let i=t.get(n.uuid);if(i===void 0)throw Error(`[vibemon] gacha pool ${n.uuid} is missing its detail response`);return _(n,i)})}}function b(r){let e=r.pools.flatMap((t)=>[t.sidebarSelectedImageUrl,t.sidebarHoverImageUrl,t.sidebarUnselectedImageUrl,t.poolCardImageUrl]);return[...new Set(e)]}async function h(){let e=[...await c()].sort((o,n)=>o.sort_order-n.sort_order),t=await Promise.all(e.map((o)=>l(o.uuid)));return f(e,t)}function u(r,e,t){let o=Date.parse(e);if(Number.isNaN(o))throw Error(`[vibemon] gacha pool ${r.poolUuid} has invalid ${t}: ${e}`);return o}function m(r,e){if(r.status==="UNAVAILABLE")return r.status;if(r.startsAt!==null&&e<u(r,r.startsAt,"startsAt"))return"UPCOMING";if(r.endsAt!==null&&e>=u(r,r.endsAt,"endsAt"))return"ENDED";return r.status}function v(r){let e=r.find((o)=>o.isDefault);if(e!==void 0)return e;let t=r[0];if(t===void 0)throw Error("[vibemon] gacha pool catalog has no visible pools");return t}function p(r,e){return r.filter((t)=>m(t,e)!=="ENDED")}export{f as createGachaPoolCatalog,b as gachaPoolImageUrls,v as getDefaultGachaPool,p as getVisibleGachaPools,h as loadGachaPoolCatalog,m as resolveGachaPoolStatus};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var N=0.99;function c(I,S,t){if(S>=1){let n=I+(1-I)*12*t;return n>=0.999?1:n}let E=Math.max(0,S-I)*5,o=I<0.8?1:(0.99-I)*0.5;return Math.min(0.99,I+Math.max(E,o)*t)}export{N as LOADING_PROGRESS_CEILING,c as advanceLoadingProgress};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RunState } from "./runtime-types.js";
|
|
2
|
+
import type { VibemonEngine } from "../engine.js";
|
|
3
|
+
export declare class PetAnimationSync {
|
|
4
|
+
private engine;
|
|
5
|
+
private states;
|
|
6
|
+
private sessionId;
|
|
7
|
+
private failed;
|
|
8
|
+
private bindingRevision;
|
|
9
|
+
private historicalDone;
|
|
10
|
+
private pendingPrompt;
|
|
11
|
+
attach(engine: Pick<VibemonEngine, "setSessionState"> | null): void;
|
|
12
|
+
bind(sessionId: string | null, failed: boolean, bindingRevision?: number): void;
|
|
13
|
+
prompt(sessionId: string, bindingRevision: number, pending: boolean): void;
|
|
14
|
+
update(states: ReadonlyArray<{
|
|
15
|
+
sessionId: string;
|
|
16
|
+
state: RunState;
|
|
17
|
+
}>, source?: "snapshot" | "event"): void;
|
|
18
|
+
private state;
|
|
19
|
+
private apply;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class n{engine=null;states=[];sessionId=null;failed=!1;bindingRevision=-1;historicalDone=!1;pendingPrompt=!1;attach(s){this.engine=s,this.historicalDone=this.state()==="done",this.apply()}bind(s,i,t=0){let e=this.sessionId!==s||this.bindingRevision!==t;if(this.sessionId=s,this.failed=i,this.bindingRevision=t,e)this.pendingPrompt=!1,this.engine?.setSessionState(null,null,!1),this.historicalDone=this.state()==="done";this.apply()}prompt(s,i,t){if(s!==this.sessionId||i!==this.bindingRevision)return;this.pendingPrompt=t,this.apply()}update(s,i="event"){let t=this.state();if(this.states=s,this.state()!==t)this.historicalDone=i==="snapshot"&&this.state()==="done";this.apply()}state(){return this.states.find((s)=>s.sessionId===this.sessionId)?.state??null}apply(){let s=this.state();this.engine?.setSessionState(this.sessionId,this.pendingPrompt?"requires_action":s==="done"&&this.historicalDone?"idle":s,this.pendingPrompt?!1:this.failed)}}export{n as PetAnimationSync};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { RunState } from "./runtime-types.js";
|
|
2
|
+
export declare class PetBubbleState {
|
|
3
|
+
private readonly apply;
|
|
4
|
+
private requested;
|
|
5
|
+
private interacting;
|
|
6
|
+
private visible;
|
|
7
|
+
private state;
|
|
8
|
+
private prompt;
|
|
9
|
+
private sessionId;
|
|
10
|
+
private revision;
|
|
11
|
+
private ownerLabel;
|
|
12
|
+
private observed;
|
|
13
|
+
constructor(apply: (open: boolean) => void);
|
|
14
|
+
bind(sessionId: string | null, revision: number): void;
|
|
15
|
+
owner(label: string): void;
|
|
16
|
+
private reset;
|
|
17
|
+
update(state: RunState | null, prompt: string | null, visible: boolean | null): void;
|
|
18
|
+
open(): void;
|
|
19
|
+
interact(): void;
|
|
20
|
+
close(): void;
|
|
21
|
+
private publish;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class r{apply;requested=!1;interacting=!1;visible=null;state=null;prompt=null;sessionId=null;revision=-1;ownerLabel="";observed=!1;constructor(e){this.apply=e}bind(e,s){if(this.sessionId===e&&this.revision===s)return;let t=this.requested&&e!==null;this.sessionId=e,this.revision=s,this.ownerLabel="",this.reset(),this.requested=t}owner(e){if(this.ownerLabel!==""&&this.ownerLabel!==e)this.reset();this.ownerLabel=e}reset(){this.requested=!1,this.interacting=!1,this.visible=null,this.state=null,this.prompt=null,this.observed=!1,this.publish()}update(e,s,t){if(e!==null&&t!==null){let i=this.observed&&(e!==this.state||s!==this.prompt);if(this.state=e,this.prompt=s,this.observed=!0,i&&(e==="running"||e==="requires_action"||s!==null))this.requested=!0}if(this.visible=t,t&&!this.interacting)this.requested=!1;this.publish()}open(){if(this.sessionId===null)return;this.requested=!0,this.interacting=!0,this.publish()}interact(){if(!this.requested)return;this.interacting=!0,this.publish()}close(){this.requested=!1,this.interacting=!1,this.publish()}publish(){this.apply(this.requested&&(this.interacting||this.visible===!1))}}export{r as PetBubbleState};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PetWindowHost } from "../host.js";
|
|
2
|
+
import type { VibemonEngine } from "../engine.js";
|
|
3
|
+
export declare function dragPet(windows: Pick<PetWindowHost, "call" | "moved">, engine: Pick<VibemonEngine, "handleDragStart" | "setFacing" | "handleDragEnd">, movingLeft: boolean): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function r(a,t,c){t.handleDragStart(c);let l=null;try{let i=(await a.call("position")).x;l=await a.moved((o)=>{let s=o.x-i;if(Math.abs(s)>2)t.setFacing(s<0),i=o.x}),await a.call("drag")}finally{l?.(),t.handleDragEnd()}}export{r as dragPet};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PetWindowHost } from "../host.js";
|
|
2
|
+
import type { VibemonEngine } from "../engine.js";
|
|
3
|
+
import type { PresentationReadiness } from "./presentation-readiness.js";
|
|
4
|
+
type PresentationEngine = Pick<VibemonEngine, "resume" | "presentAt">;
|
|
5
|
+
export declare function presentVibemon<T extends PresentationEngine>(ready: PresentationReadiness<T>, windows: Pick<PetWindowHost, "call">, petId: string): Promise<void>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function i(a,n,t){let e=await a.wait(t,Date.now()+15000);await e.presentAt(async()=>(e.resume(),a.requireFreshFrame(t),await a.wait(t,Date.now()+15000),a.assertReady(t,e),await n.call("present"),n.call("position")))}export{i as presentVibemon};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type PetSurface = {
|
|
2
|
+
sessionId: string | null;
|
|
3
|
+
visible: boolean;
|
|
4
|
+
};
|
|
5
|
+
export type PetSurfaceLabel = "main" | "chat";
|
|
6
|
+
export declare class PetSessionContext {
|
|
7
|
+
readonly surfaces: Record<PetSurfaceLabel, PetSurface>;
|
|
8
|
+
private selectedWindow;
|
|
9
|
+
target(): string | null;
|
|
10
|
+
surface(label: PetSurfaceLabel, value: PetSurface): void;
|
|
11
|
+
select(sessionId: string): void;
|
|
12
|
+
collapse(sessionId: string | null): void;
|
|
13
|
+
reset(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class t{surfaces={main:{sessionId:null,visible:!1},chat:{sessionId:null,visible:!1}};selectedWindow=null;target(){if(this.selectedWindow!==null){let s=this.surfaces[this.selectedWindow].sessionId;if(s!==null)return s;this.selectedWindow=null}return this.surfaces.chat.sessionId??this.surfaces.main.sessionId}surface(s,e){this.surfaces[s]=e,this.target()}select(s){if(this.surfaces.chat.sessionId===s)this.selectedWindow="chat";else if(this.surfaces.main.sessionId===s)this.selectedWindow="main";else throw Error("The conversation is no longer current")}collapse(s){this.surfaces.chat={...this.surfaces.chat,sessionId:s},this.selectedWindow=null}reset(){this.selectedWindow=null}}export{t as PetSessionContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function preloadImages(urls: string[], onProgress: (done: number) => void): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function t(c,n){let a=0;await Promise.all(c.map(async(e)=>{let o=new Image;o.src=e;try{await o.decode()}catch(r){throw Error(`[vibemon] preload failed: ${e}`,{cause:r})}a++,n(a)}))}export{t as preloadImages};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class PresentationReadiness<T> {
|
|
2
|
+
private current;
|
|
3
|
+
private listeners;
|
|
4
|
+
begin(petId: string, generation: number): void;
|
|
5
|
+
positioned(petId: string, generation: number, value: T): void;
|
|
6
|
+
drawn(petId: string, generation: number): void;
|
|
7
|
+
requireFreshFrame(petId: string): void;
|
|
8
|
+
fail(petId: string, generation: number, error: Error): void;
|
|
9
|
+
invalidate(): void;
|
|
10
|
+
reset(): void;
|
|
11
|
+
assertReady(petId: string, value: T): void;
|
|
12
|
+
private notify;
|
|
13
|
+
waitingStage(): string;
|
|
14
|
+
wait(petId: string, deadline: number): Promise<T>;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class c{current=null;listeners=new Set;begin(r,n){this.current={petId:r,generation:n,value:null,drawn:!1,error:null},this.notify()}positioned(r,n,e){let t=this.current;if(t===null||t.petId!==r||t.generation!==n)return;t.value=e,this.notify()}drawn(r,n){let e=this.current;if(e===null||e.petId!==r||e.generation!==n||e.drawn)return;e.drawn=!0,this.notify()}requireFreshFrame(r){if(this.current===null||this.current.petId!==r)throw Error("Vibemon resource changed");this.current.drawn=!1,this.notify()}fail(r,n,e){let t=this.current;if(t===null||t.petId!==r||t.generation!==n)return;t.error=e,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(r,n){let e=this.current;if(e===null||e.petId!==r||e.value!==n||!e.drawn||e.error!==null)throw Error("Vibemon resource changed during presentation")}notify(){for(let r of this.listeners)r()}waitingStage(){let r=this.current;if(r===null)return"resource-loading";if(r.value===null)return"initial-position";if(!r.drawn)return"canvas-frame";return"ready"}wait(r,n){let e=this.current?.generation;return new Promise((t,a)=>{let u=()=>{clearTimeout(l),this.listeners.delete(o)},s=(i)=>{u(),a(i)},o=()=>{if(Date.now()>=n){s(Error(`Vibemon presentation timed out [stage=${this.waitingStage()}]`));return}let i=this.current;if(!i)return;if(e===void 0)e=i.generation;if(i.petId!==r||e!==void 0&&e!==i.generation)s(Error("Vibemon resource changed during presentation"));else if(i.error)s(i.error);else if(i.drawn&&i.value!==null)u(),t(i.value)},l=setTimeout(()=>s(Error(`Vibemon presentation timed out [stage=${this.waitingStage()}]`)),Math.max(0,n-Date.now()));this.listeners.add(o),o()})}}export{c as PresentationReadiness};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n=["SSR","SR","R","UC","C"],e=(t)=>{let r=n.indexOf(t);return r===-1?n.length:r};function R(t){return[...t].sort((r,o)=>e(r.rarity_code)-e(o.rarity_code))}export{R as sortByRarityDesc};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const openAccountUrl: () => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{vibemonHost as o}from"../host.js";var n=()=>o().windows.openRecharge();export{n as openAccountUrl};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RunState } from "./runtime-types.js";
|
|
2
|
+
export interface PetSubmission {
|
|
3
|
+
sessionId: string;
|
|
4
|
+
text: string;
|
|
5
|
+
startedAt: number;
|
|
6
|
+
accepted: boolean;
|
|
7
|
+
sawRunning: boolean;
|
|
8
|
+
completed: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function advancePetSubmission(submission: PetSubmission, state: RunState, since: number): PetSubmission;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(e,r,n){if(n<e.startedAt)return e;if(r==="running")return{...e,sawRunning:!0,completed:!1};if(r==="requires_action")return{...e,completed:!1};if(r==="done"||r==="idle"&&e.sawRunning)return{...e,completed:!0};return e}export{t as advancePetSubmission};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type ResourceSyncStatus = "idle" | "checking" | "updating" | "done" | "error";
|
|
2
|
+
export declare const vibemonSyncStore: import("zustand").StoreApi<{
|
|
3
|
+
status: ResourceSyncStatus;
|
|
4
|
+
}>;
|
|
5
|
+
export declare const resourceSyncStatus: () => ResourceSyncStatus;
|
|
6
|
+
export declare const observeResourceSync: (status: ResourceSyncStatus) => void;
|
|
7
|
+
export declare const subscribeResourceSync: (listener: (status: ResourceSyncStatus) => void) => () => void;
|
|
8
|
+
export declare function syncVibemonResources(): Promise<void>;
|
|
@@ -0,0 +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};
|