@everfur/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +74 -0
- package/LICENSE +21 -0
- package/README.md +161 -0
- package/animations/package.json +8 -0
- package/chat/package.json +8 -0
- package/client/package.json +8 -0
- package/core/package.json +8 -0
- package/dist/CameraPort-Cv31Pz7g.d.cts +29 -0
- package/dist/CameraPort-Cv31Pz7g.d.ts +29 -0
- package/dist/ChatController-CKdBvPj2.d.ts +146 -0
- package/dist/ChatController-CpUMvvZf.d.cts +146 -0
- package/dist/EverfurResult-D92-uL82.d.cts +240 -0
- package/dist/EverfurResult-D92-uL82.d.ts +240 -0
- package/dist/FilePort-BabWrv7I.d.cts +22 -0
- package/dist/FilePort-BabWrv7I.d.ts +22 -0
- package/dist/PhotoController-BItt5M7u.d.cts +43 -0
- package/dist/PhotoController-D8zMTdcW.d.ts +43 -0
- package/dist/TelemetryPort-BDNr00hu.d.cts +12 -0
- package/dist/TelemetryPort-BDNr00hu.d.ts +12 -0
- package/dist/animations/index.cjs +1997 -0
- package/dist/animations/index.d.cts +517 -0
- package/dist/animations/index.d.ts +517 -0
- package/dist/animations/index.js +1972 -0
- package/dist/cacheEpoch-DknKn3S0.d.cts +36 -0
- package/dist/cacheEpoch-DknKn3S0.d.ts +36 -0
- package/dist/chat/index.cjs +1170 -0
- package/dist/chat/index.d.cts +59 -0
- package/dist/chat/index.d.ts +59 -0
- package/dist/chat/index.js +1167 -0
- package/dist/client/index.cjs +2317 -0
- package/dist/client/index.d.cts +65 -0
- package/dist/client/index.d.ts +65 -0
- package/dist/client/index.js +2217 -0
- package/dist/config-BSjBdxrZ.d.cts +501 -0
- package/dist/config-CiJ0PVBB.d.ts +501 -0
- package/dist/core/index.cjs +3175 -0
- package/dist/core/index.d.cts +70 -0
- package/dist/core/index.d.ts +70 -0
- package/dist/core/index.js +3163 -0
- package/dist/identity-Brl-lDd6.d.cts +91 -0
- package/dist/identity-DK9zORrG.d.ts +91 -0
- package/dist/ids-CJ1S6adf.d.cts +46 -0
- package/dist/ids-CJ1S6adf.d.ts +46 -0
- package/dist/index.cjs +4488 -0
- package/dist/index.d.cts +156 -0
- package/dist/index.d.ts +156 -0
- package/dist/index.js +4464 -0
- package/dist/petsRepository-BEGb97M9.d.cts +326 -0
- package/dist/petsRepository-Bu18r2kK.d.ts +326 -0
- package/dist/photo/index.cjs +2189 -0
- package/dist/photo/index.d.cts +43 -0
- package/dist/photo/index.d.ts +43 -0
- package/dist/photo/index.js +2186 -0
- package/dist/projection-CeIUsbSk.d.cts +8 -0
- package/dist/projection-CeIUsbSk.d.ts +8 -0
- package/dist/records/index.cjs +2840 -0
- package/dist/records/index.d.cts +224 -0
- package/dist/records/index.d.ts +224 -0
- package/dist/records/index.js +2834 -0
- package/dist/requestFunnel-DuUH-kAe.d.cts +28 -0
- package/dist/requestFunnel-dio5OmR9.d.ts +28 -0
- package/dist/resolve-Dq_4_agU.d.cts +86 -0
- package/dist/resolve-Dq_4_agU.d.ts +86 -0
- package/dist/runtime-BgQnA594.d.cts +349 -0
- package/dist/runtime-CBA-LvdM.d.ts +349 -0
- package/dist/server/index.cjs +533 -0
- package/dist/server/index.d.cts +48 -0
- package/dist/server/index.d.ts +48 -0
- package/dist/server/index.js +530 -0
- package/dist/testing/index.cjs +825 -0
- package/dist/testing/index.d.cts +113 -0
- package/dist/testing/index.d.ts +113 -0
- package/dist/testing/index.js +822 -0
- package/dist/testing/rn/index.cjs +449 -0
- package/dist/testing/rn/index.d.cts +49 -0
- package/dist/testing/rn/index.d.ts +49 -0
- package/dist/testing/rn/index.js +444 -0
- package/dist/video/index.cjs +1941 -0
- package/dist/video/index.d.cts +66 -0
- package/dist/video/index.d.ts +66 -0
- package/dist/video/index.js +1938 -0
- package/package.json +311 -0
- package/photo/package.json +8 -0
- package/records/package.json +8 -0
- package/server/device-blocked.cjs +15 -0
- package/server/package.json +9 -0
- package/testing/package.json +8 -0
- package/testing/rn/package.json +8 -0
- package/video/package.json +8 -0
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { E as EverfurResult, f as EverfurError } from '../EverfurResult-D92-uL82.cjs';
|
|
4
|
+
export { g as EverfurErrorCategory, a as EverfurErrorCode } from '../EverfurResult-D92-uL82.cjs';
|
|
5
|
+
import { A as AuthContext } from '../identity-Brl-lDd6.cjs';
|
|
6
|
+
export { I as IdentityProvider, n as newSessionId } from '../identity-Brl-lDd6.cjs';
|
|
7
|
+
import { P as PetRef } from '../ids-CJ1S6adf.cjs';
|
|
8
|
+
export { B as Brand, U as UserRef, _ as __brand } from '../ids-CJ1S6adf.cjs';
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { K as KvPort, C as CacheEpochGuard, I as ImageCachePort } from '../cacheEpoch-DknKn3S0.cjs';
|
|
11
|
+
export { a as CACHE_EPOCH_STORAGE_KEY, c as createCacheEpochGuard } from '../cacheEpoch-DknKn3S0.cjs';
|
|
12
|
+
import { T as TelemetryPort } from '../TelemetryPort-BDNr00hu.cjs';
|
|
13
|
+
import { c as DisabledLevel, C as CapabilityDecision } from '../resolve-Dq_4_agU.cjs';
|
|
14
|
+
export { a as CapabilityDisabled, b as CapabilityName } from '../resolve-Dq_4_agU.cjs';
|
|
15
|
+
export { A as AcceptedFrame, b as AnalysisCompleteFrame, c as AnalysisStartedFrame, f as DeltaFrame, g as DoneFrame, j as ErrorFrame, E as EverfurRequest, p as EverfurRequestBase, F as Frame, s as FrameBase, t as FrameKind, H as HeartbeatFrame, u as HttpMethod, M as MultipartBody, T as TransportPort, U as UnknownFrame, G as UrgencyLevel } from '../config-BSjBdxrZ.cjs';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The full /state payload. `degraded` + `cache_epoch` + `cache_key` are additive fields an older backend
|
|
19
|
+
* omits; the schema defaults them identically to the reference client so one parser serves either revision.
|
|
20
|
+
*/
|
|
21
|
+
declare const petStateResponseWireSchema: z.ZodObject<{
|
|
22
|
+
category: z.ZodEnum<["health", "attention", "moment", "activity", "mood", "idle"]>;
|
|
23
|
+
tiers: z.ZodDefault<z.ZodObject<{
|
|
24
|
+
animation: z.ZodOptional<z.ZodObject<{
|
|
25
|
+
url: z.ZodString;
|
|
26
|
+
kind: z.ZodDefault<z.ZodEnum<["webp", "video"]>>;
|
|
27
|
+
loop_duration_ms: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
28
|
+
expires_at: z.ZodString;
|
|
29
|
+
cache_key: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
kind: "webp" | "video";
|
|
32
|
+
url: string;
|
|
33
|
+
expires_at: string;
|
|
34
|
+
loop_duration_ms?: number | null | undefined;
|
|
35
|
+
cache_key?: string | null | undefined;
|
|
36
|
+
}, {
|
|
37
|
+
url: string;
|
|
38
|
+
expires_at: string;
|
|
39
|
+
kind?: "webp" | "video" | undefined;
|
|
40
|
+
loop_duration_ms?: number | null | undefined;
|
|
41
|
+
cache_key?: string | null | undefined;
|
|
42
|
+
}>>;
|
|
43
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
44
|
+
url: z.ZodString;
|
|
45
|
+
kind: z.ZodDefault<z.ZodEnum<["webp", "video"]>>;
|
|
46
|
+
loop_duration_ms: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
47
|
+
expires_at: z.ZodString;
|
|
48
|
+
cache_key: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
kind: "webp" | "video";
|
|
51
|
+
url: string;
|
|
52
|
+
expires_at: string;
|
|
53
|
+
loop_duration_ms?: number | null | undefined;
|
|
54
|
+
cache_key?: string | null | undefined;
|
|
55
|
+
}, {
|
|
56
|
+
url: string;
|
|
57
|
+
expires_at: string;
|
|
58
|
+
kind?: "webp" | "video" | undefined;
|
|
59
|
+
loop_duration_ms?: number | null | undefined;
|
|
60
|
+
cache_key?: string | null | undefined;
|
|
61
|
+
}>>;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
animation?: {
|
|
64
|
+
kind: "webp" | "video";
|
|
65
|
+
url: string;
|
|
66
|
+
expires_at: string;
|
|
67
|
+
loop_duration_ms?: number | null | undefined;
|
|
68
|
+
cache_key?: string | null | undefined;
|
|
69
|
+
} | undefined;
|
|
70
|
+
image?: {
|
|
71
|
+
kind: "webp" | "video";
|
|
72
|
+
url: string;
|
|
73
|
+
expires_at: string;
|
|
74
|
+
loop_duration_ms?: number | null | undefined;
|
|
75
|
+
cache_key?: string | null | undefined;
|
|
76
|
+
} | undefined;
|
|
77
|
+
}, {
|
|
78
|
+
animation?: {
|
|
79
|
+
url: string;
|
|
80
|
+
expires_at: string;
|
|
81
|
+
kind?: "webp" | "video" | undefined;
|
|
82
|
+
loop_duration_ms?: number | null | undefined;
|
|
83
|
+
cache_key?: string | null | undefined;
|
|
84
|
+
} | undefined;
|
|
85
|
+
image?: {
|
|
86
|
+
url: string;
|
|
87
|
+
expires_at: string;
|
|
88
|
+
kind?: "webp" | "video" | undefined;
|
|
89
|
+
loop_duration_ms?: number | null | undefined;
|
|
90
|
+
cache_key?: string | null | undefined;
|
|
91
|
+
} | undefined;
|
|
92
|
+
}>>;
|
|
93
|
+
overlays: z.ZodDefault<z.ZodObject<{
|
|
94
|
+
weather_alert: z.ZodOptional<z.ZodObject<{
|
|
95
|
+
url: z.ZodString;
|
|
96
|
+
kind: z.ZodDefault<z.ZodEnum<["webp", "video"]>>;
|
|
97
|
+
loop_duration_ms: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
98
|
+
expires_at: z.ZodString;
|
|
99
|
+
cache_key: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
100
|
+
}, "strip", z.ZodTypeAny, {
|
|
101
|
+
kind: "webp" | "video";
|
|
102
|
+
url: string;
|
|
103
|
+
expires_at: string;
|
|
104
|
+
loop_duration_ms?: number | null | undefined;
|
|
105
|
+
cache_key?: string | null | undefined;
|
|
106
|
+
}, {
|
|
107
|
+
url: string;
|
|
108
|
+
expires_at: string;
|
|
109
|
+
kind?: "webp" | "video" | undefined;
|
|
110
|
+
loop_duration_ms?: number | null | undefined;
|
|
111
|
+
cache_key?: string | null | undefined;
|
|
112
|
+
}>>;
|
|
113
|
+
}, "strip", z.ZodTypeAny, {
|
|
114
|
+
weather_alert?: {
|
|
115
|
+
kind: "webp" | "video";
|
|
116
|
+
url: string;
|
|
117
|
+
expires_at: string;
|
|
118
|
+
loop_duration_ms?: number | null | undefined;
|
|
119
|
+
cache_key?: string | null | undefined;
|
|
120
|
+
} | undefined;
|
|
121
|
+
}, {
|
|
122
|
+
weather_alert?: {
|
|
123
|
+
url: string;
|
|
124
|
+
expires_at: string;
|
|
125
|
+
kind?: "webp" | "video" | undefined;
|
|
126
|
+
loop_duration_ms?: number | null | undefined;
|
|
127
|
+
cache_key?: string | null | undefined;
|
|
128
|
+
} | undefined;
|
|
129
|
+
}>>;
|
|
130
|
+
idle: z.ZodDefault<z.ZodLiteral<"bundled">>;
|
|
131
|
+
ttl_seconds: z.ZodNumber;
|
|
132
|
+
degraded: z.ZodDefault<z.ZodBoolean>;
|
|
133
|
+
cache_epoch: z.ZodDefault<z.ZodNumber>;
|
|
134
|
+
}, "strip", z.ZodTypeAny, {
|
|
135
|
+
category: "health" | "attention" | "moment" | "activity" | "mood" | "idle";
|
|
136
|
+
idle: "bundled";
|
|
137
|
+
tiers: {
|
|
138
|
+
animation?: {
|
|
139
|
+
kind: "webp" | "video";
|
|
140
|
+
url: string;
|
|
141
|
+
expires_at: string;
|
|
142
|
+
loop_duration_ms?: number | null | undefined;
|
|
143
|
+
cache_key?: string | null | undefined;
|
|
144
|
+
} | undefined;
|
|
145
|
+
image?: {
|
|
146
|
+
kind: "webp" | "video";
|
|
147
|
+
url: string;
|
|
148
|
+
expires_at: string;
|
|
149
|
+
loop_duration_ms?: number | null | undefined;
|
|
150
|
+
cache_key?: string | null | undefined;
|
|
151
|
+
} | undefined;
|
|
152
|
+
};
|
|
153
|
+
overlays: {
|
|
154
|
+
weather_alert?: {
|
|
155
|
+
kind: "webp" | "video";
|
|
156
|
+
url: string;
|
|
157
|
+
expires_at: string;
|
|
158
|
+
loop_duration_ms?: number | null | undefined;
|
|
159
|
+
cache_key?: string | null | undefined;
|
|
160
|
+
} | undefined;
|
|
161
|
+
};
|
|
162
|
+
ttl_seconds: number;
|
|
163
|
+
degraded: boolean;
|
|
164
|
+
cache_epoch: number;
|
|
165
|
+
}, {
|
|
166
|
+
category: "health" | "attention" | "moment" | "activity" | "mood" | "idle";
|
|
167
|
+
ttl_seconds: number;
|
|
168
|
+
idle?: "bundled" | undefined;
|
|
169
|
+
tiers?: {
|
|
170
|
+
animation?: {
|
|
171
|
+
url: string;
|
|
172
|
+
expires_at: string;
|
|
173
|
+
kind?: "webp" | "video" | undefined;
|
|
174
|
+
loop_duration_ms?: number | null | undefined;
|
|
175
|
+
cache_key?: string | null | undefined;
|
|
176
|
+
} | undefined;
|
|
177
|
+
image?: {
|
|
178
|
+
url: string;
|
|
179
|
+
expires_at: string;
|
|
180
|
+
kind?: "webp" | "video" | undefined;
|
|
181
|
+
loop_duration_ms?: number | null | undefined;
|
|
182
|
+
cache_key?: string | null | undefined;
|
|
183
|
+
} | undefined;
|
|
184
|
+
} | undefined;
|
|
185
|
+
overlays?: {
|
|
186
|
+
weather_alert?: {
|
|
187
|
+
url: string;
|
|
188
|
+
expires_at: string;
|
|
189
|
+
kind?: "webp" | "video" | undefined;
|
|
190
|
+
loop_duration_ms?: number | null | undefined;
|
|
191
|
+
cache_key?: string | null | undefined;
|
|
192
|
+
} | undefined;
|
|
193
|
+
} | undefined;
|
|
194
|
+
degraded?: boolean | undefined;
|
|
195
|
+
cache_epoch?: number | undefined;
|
|
196
|
+
}>;
|
|
197
|
+
type PetStateWire = z.infer<typeof petStateResponseWireSchema>;
|
|
198
|
+
/**
|
|
199
|
+
* Parse an untrusted /state body into the wire shape. Settles: returns null on a parse failure rather than
|
|
200
|
+
* throwing, so the repository degrades to the bundled idle instead of surfacing a crash. Additive unknown
|
|
201
|
+
* keys are stripped (zod `.object` default), so a newer backend never trips this.
|
|
202
|
+
*/
|
|
203
|
+
declare function parsePetStateWire(raw: unknown): PetStateWire | null;
|
|
204
|
+
|
|
205
|
+
type MediaKind = 'webp' | 'video';
|
|
206
|
+
type PetStateCategory = 'health' | 'attention' | 'moment' | 'activity' | 'mood' | 'idle';
|
|
207
|
+
interface PetStateTier {
|
|
208
|
+
readonly url: string;
|
|
209
|
+
readonly kind: MediaKind;
|
|
210
|
+
readonly loopDurationMs?: number;
|
|
211
|
+
readonly expiresAt: string;
|
|
212
|
+
/**
|
|
213
|
+
* Verbatim cache identity `{s3_key}@r{asset_revision}`; NEVER derived from `url`. Absent -> the renderer
|
|
214
|
+
* falls back to the presign-stripped path (`stableMediaKey`).
|
|
215
|
+
*/
|
|
216
|
+
readonly cacheKey?: string;
|
|
217
|
+
}
|
|
218
|
+
interface PetStateResponse {
|
|
219
|
+
readonly category: PetStateCategory;
|
|
220
|
+
readonly tiers: {
|
|
221
|
+
readonly animation?: PetStateTier;
|
|
222
|
+
readonly image?: PetStateTier;
|
|
223
|
+
};
|
|
224
|
+
readonly overlays: {
|
|
225
|
+
readonly weatherAlert?: PetStateTier;
|
|
226
|
+
};
|
|
227
|
+
readonly idle: 'bundled';
|
|
228
|
+
readonly ttlSeconds: number;
|
|
229
|
+
/** true => transient idle: keep last-good, re-poll on the short ttl (don't-clobber). */
|
|
230
|
+
readonly degraded: boolean;
|
|
231
|
+
/** monotonic; on ANY increase the client drops its whole image cache once. */
|
|
232
|
+
readonly cacheEpoch?: number;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* The total, never-throwing snake->camel projection. Identical defaults to the reference client so the SDK
|
|
236
|
+
* parses against a backend at either contract revision. Returns a frozen value.
|
|
237
|
+
*/
|
|
238
|
+
declare function mapPetStateResponse(wire: PetStateWire): PetStateResponse;
|
|
239
|
+
|
|
240
|
+
interface PetStateRepository {
|
|
241
|
+
/**
|
|
242
|
+
* GET /widget/v1/pets/{pet_ref}/state. Settles to:
|
|
243
|
+
* - `ok(PetStateResponse)` on a 200 that parses;
|
|
244
|
+
* - `ok(null)` on a 404 (dark surface / revoked / not-in-namespace) - an EXPECTED terminal outcome the
|
|
245
|
+
* controller degrades to the bundled idle;
|
|
246
|
+
* - `err(EverfurError)` for transient (5xx/timeout) or terminal-auth (403 accessDenied, second-401
|
|
247
|
+
* authRejected) failures, plus an unparseable 200 (internalError).
|
|
248
|
+
*/
|
|
249
|
+
getState(petRef: PetRef, opts?: {
|
|
250
|
+
signal?: AbortSignal;
|
|
251
|
+
}): Promise<EverfurResult<PetStateResponse | null>>;
|
|
252
|
+
}
|
|
253
|
+
/** Build the repository over a device AuthContext (personalized bearer XOR anonymous pk). */
|
|
254
|
+
declare function createPetStateRepository(auth: AuthContext): PetStateRepository;
|
|
255
|
+
|
|
256
|
+
/** A compiled-in bundled asset (the neutral, org-agnostic idle). Rendered by the platform via its id. */
|
|
257
|
+
interface BundledAsset {
|
|
258
|
+
readonly kind: 'bundled';
|
|
259
|
+
readonly id: string;
|
|
260
|
+
}
|
|
261
|
+
/** A remote presigned source with its revision-bound cache identity. */
|
|
262
|
+
interface UriSource {
|
|
263
|
+
readonly kind: 'uri';
|
|
264
|
+
readonly uri: string;
|
|
265
|
+
/** expo-image cacheKey: server `cacheKey` when present, else the presign-stripped path. */
|
|
266
|
+
readonly cacheKey: string;
|
|
267
|
+
}
|
|
268
|
+
/** What the view renders. ALWAYS resolvable - a dead tier degrades to the bundled idle, never blank. */
|
|
269
|
+
type MediaSource = UriSource | BundledAsset;
|
|
270
|
+
/**
|
|
271
|
+
* Object identity with the presign query stripped (`?`-onwards removed). A re-signed URL for the SAME
|
|
272
|
+
* object yields the SAME key (no remount / no animation restart). A bundled asset keys as `bundled:<id>`.
|
|
273
|
+
* Never derived when a server `cacheKey` is present (that is revision-bound); this is the fallback only.
|
|
274
|
+
*/
|
|
275
|
+
declare function stableMediaKey(source: number | {
|
|
276
|
+
uri: string;
|
|
277
|
+
} | BundledAsset | undefined): string;
|
|
278
|
+
/** Ordered high->low: the pet's own photo outranks every server tier; idle is the total floor. */
|
|
279
|
+
type AnimationTier = 'photo' | 'animation' | 'image' | 'idle';
|
|
280
|
+
interface TierInputs {
|
|
281
|
+
readonly hasPhoto: boolean;
|
|
282
|
+
readonly photoFailed: boolean;
|
|
283
|
+
/** animation present && kind==='webp' && !reducedMotion (the #6 non-webp guard). */
|
|
284
|
+
readonly canAnimate: boolean;
|
|
285
|
+
readonly animationFailed: boolean;
|
|
286
|
+
readonly hasImage: boolean;
|
|
287
|
+
readonly imageFailed: boolean;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* photo -> animation -> image -> idle. Pure. Returns the highest surviving (present-and-unfailed) tier.
|
|
291
|
+
* `idle` is always available, so this is total and never yields a broken tier.
|
|
292
|
+
*/
|
|
293
|
+
declare function selectTier(i: TierInputs): AnimationTier;
|
|
294
|
+
type FallbackReason = 'none' | 'network_error' | 'anim_cutoff' | 'dark_or_missing' | 'idle_asset_failed';
|
|
295
|
+
interface FailedTiers {
|
|
296
|
+
readonly photo: boolean;
|
|
297
|
+
readonly animation: boolean;
|
|
298
|
+
readonly image: boolean;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* onError transition: retire `current`, set the reason. Retiring `idle` is the truly-terminal
|
|
302
|
+
* `idle_asset_failed` (no lower rung), kept DISTINCT from a recoverable `network_error` downgrade so an
|
|
303
|
+
* alarm can fire only on the terminal floor failure.
|
|
304
|
+
*/
|
|
305
|
+
declare function retireTier(current: AnimationTier, failed: FailedTiers): {
|
|
306
|
+
failed: FailedTiers;
|
|
307
|
+
reason: FallbackReason;
|
|
308
|
+
};
|
|
309
|
+
declare const NO_FAILURES: FailedTiers;
|
|
310
|
+
/**
|
|
311
|
+
* A loader (walk splash, pet-switch splash) may surface ONLY the gentle bands. health + attention are
|
|
312
|
+
* SUPPRESSED - a splash must never show a concern or a med reminder. True for activity | mood | moment | idle.
|
|
313
|
+
*/
|
|
314
|
+
declare function isLoaderSafeCategory(category: PetStateCategory): boolean;
|
|
315
|
+
|
|
316
|
+
/** The manifest schema this build understands. A live manifest above this is refused (forward-compat). */
|
|
317
|
+
declare const SUPPORTED_SCHEMA_VERSION = 1;
|
|
318
|
+
/** KvPort key for the last-accepted manifest (last-known-good). Non-secret durable state only. */
|
|
319
|
+
declare const MANIFEST_LKG_STORAGE_KEY = "everfur.manifest.lastKnownGood";
|
|
320
|
+
/** The neutral, org-agnostic compiled-in idle silhouette. A partner's real art arrives only from config. */
|
|
321
|
+
declare const COMPILED_DEFAULT_IDLE: BundledAsset;
|
|
322
|
+
/** The animations surface: whether the surface renders live tiers, and the neutral idle fallback. */
|
|
323
|
+
interface AnimationsSurface {
|
|
324
|
+
readonly enabled: boolean;
|
|
325
|
+
readonly idle: BundledAsset;
|
|
326
|
+
}
|
|
327
|
+
/** The whole surface manifest. `revision` + `schemaVersion` select live vs last-known-good vs compiled. */
|
|
328
|
+
interface CapabilityManifest {
|
|
329
|
+
readonly schemaVersion: number;
|
|
330
|
+
readonly revision: string;
|
|
331
|
+
readonly surfaces: {
|
|
332
|
+
readonly animations?: AnimationsSurface;
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
type ManifestSource = 'live' | 'last-known-good' | 'compiled-default';
|
|
336
|
+
/** The compiled default baked into the build; its animations surface references the neutral idle. */
|
|
337
|
+
declare const COMPILED_DEFAULT_MANIFEST: CapabilityManifest;
|
|
338
|
+
type ParseManifestResult = {
|
|
339
|
+
readonly ok: true;
|
|
340
|
+
readonly manifest: CapabilityManifest;
|
|
341
|
+
} | {
|
|
342
|
+
readonly ok: false;
|
|
343
|
+
readonly reason: 'unparseable' | 'newer_schema';
|
|
344
|
+
};
|
|
345
|
+
/**
|
|
346
|
+
* Parse an untrusted manifest block. REFUSES a schema_version above SUPPORTED (structural forward-compat)
|
|
347
|
+
* and rejects a body that does not parse. Strips unknown surfaces / tokens / a `disclaimer` override.
|
|
348
|
+
* Never throws.
|
|
349
|
+
*/
|
|
350
|
+
declare function parseManifest(raw: unknown): ParseManifestResult;
|
|
351
|
+
interface ResolvedManifest {
|
|
352
|
+
readonly manifest: CapabilityManifest;
|
|
353
|
+
readonly source: ManifestSource;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Resolve the surface manifest via the never-blank ladder. `liveRaw` is the `.manifest` block off the
|
|
357
|
+
* client-config channel (or null when that fetch failed). Accepts live only when it parses and is not a
|
|
358
|
+
* newer schema, writing it to last-known-good; else falls to the last accepted manifest, else to the
|
|
359
|
+
* compiled default. Every KvPort failure is swallowed (a cosmetic persistence miss never blocks a render).
|
|
360
|
+
*/
|
|
361
|
+
declare function resolveManifest(liveRaw: unknown, kv: KvPort, tel: TelemetryPort): Promise<ResolvedManifest>;
|
|
362
|
+
/** Read the animations surface from a resolved manifest, or the compiled default when the surface is absent. */
|
|
363
|
+
declare function animationsSurfaceOf(manifest: CapabilityManifest): AnimationsSurface;
|
|
364
|
+
|
|
365
|
+
/** Injectable timers so the SWR window is testable with a fake clock (no direct setTimeout). */
|
|
366
|
+
interface StoreTimers {
|
|
367
|
+
setTimeout(handler: () => void, ms: number): unknown;
|
|
368
|
+
clearTimeout(handle: unknown): void;
|
|
369
|
+
now(): number;
|
|
370
|
+
}
|
|
371
|
+
interface PetStateSnapshot {
|
|
372
|
+
/** Current render data - may be the kept-previous pet during a switch (C2). null => no data yet / dark. */
|
|
373
|
+
readonly data: PetStateResponse | null;
|
|
374
|
+
/** true during the initial cold resolve for the current pet (no data to show). */
|
|
375
|
+
readonly isPending: boolean;
|
|
376
|
+
/** true while a transient error is being retried; last-good `data` stays on screen. */
|
|
377
|
+
readonly isError: boolean;
|
|
378
|
+
readonly error: EverfurError | null;
|
|
379
|
+
/** Settled terminal dark (404) or access-denied (403): render the idle, no spinner, no further fetch. */
|
|
380
|
+
readonly isDark: boolean;
|
|
381
|
+
}
|
|
382
|
+
interface PetStateStore {
|
|
383
|
+
observe(petRef: PetRef | null, opts: {
|
|
384
|
+
readonly isFocused: boolean;
|
|
385
|
+
}): void;
|
|
386
|
+
getSnapshot(): PetStateSnapshot;
|
|
387
|
+
subscribe(listener: () => void): () => void;
|
|
388
|
+
/** Freshness-gated synchronous read: the warm entry ONLY while younger than its ttl; else null. */
|
|
389
|
+
getCachedPetStateMedia(petRef: PetRef): PetStateResponse | null;
|
|
390
|
+
dispose(): void;
|
|
391
|
+
}
|
|
392
|
+
declare function createPetStateStore(deps: {
|
|
393
|
+
readonly repo: PetStateRepository;
|
|
394
|
+
readonly cacheEpoch: CacheEpochGuard;
|
|
395
|
+
readonly timers: StoreTimers;
|
|
396
|
+
}): PetStateStore;
|
|
397
|
+
/**
|
|
398
|
+
* Terminal iff the settled error is a 403 or 404 (duck-typed on `status` / `httpStatus`). A 404 is folded to
|
|
399
|
+
* `ok(null)` at the repository, so at the store this fires for a 403; the predicate stays general for the
|
|
400
|
+
* parity vectors that feed a bare `{ status: 404 }`.
|
|
401
|
+
*/
|
|
402
|
+
declare function isTerminalPetStateError(error: unknown): boolean;
|
|
403
|
+
|
|
404
|
+
interface PetStateViewProps {
|
|
405
|
+
readonly petRef: PetRef | null;
|
|
406
|
+
readonly repo: PetStateRepository;
|
|
407
|
+
readonly cache: ImageCachePort;
|
|
408
|
+
readonly kv: KvPort;
|
|
409
|
+
readonly isFocused?: boolean;
|
|
410
|
+
readonly photoUrl?: string | null;
|
|
411
|
+
readonly telemetry?: TelemetryPort;
|
|
412
|
+
readonly reducedMotion?: () => boolean;
|
|
413
|
+
readonly manifest?: () => CapabilityManifest;
|
|
414
|
+
readonly timers?: StoreTimers;
|
|
415
|
+
readonly now?: () => number;
|
|
416
|
+
readonly style?: StyleProp<ViewStyle>;
|
|
417
|
+
/** Accessible label for the media node; omit + set `decorative` to hide it from the a11y tree. */
|
|
418
|
+
readonly accessibilityLabel?: string;
|
|
419
|
+
/** Decorative-only: hide the media from assistive tech without leaving a focusable blank gap. */
|
|
420
|
+
readonly decorative?: boolean;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Entitlement-gated, never-blank pet-state media. Denied / pending-entitlement render the bundled idle via
|
|
424
|
+
* the CapabilityGate slots; otherwise the body maps the controller view state to a deliberate state.
|
|
425
|
+
*/
|
|
426
|
+
declare function PetStateView(props: PetStateViewProps): ReactNode;
|
|
427
|
+
|
|
428
|
+
interface AnimationControllerDeps {
|
|
429
|
+
readonly repo: PetStateRepository;
|
|
430
|
+
readonly cache: ImageCachePort;
|
|
431
|
+
/** Non-secret durable KV, backing the cache-epoch guard's one-time purge latch. */
|
|
432
|
+
readonly kv: KvPort;
|
|
433
|
+
readonly telemetry?: TelemetryPort;
|
|
434
|
+
readonly reducedMotion: () => boolean;
|
|
435
|
+
readonly now: () => number;
|
|
436
|
+
/** Already-resolved surface manifest getter (RN resolves via resolveManifest once). Defaults to compiled. */
|
|
437
|
+
readonly manifest?: () => CapabilityManifest;
|
|
438
|
+
/** Injectable timers for the SWR window (tests drive a fake clock). */
|
|
439
|
+
readonly timers?: StoreTimers;
|
|
440
|
+
}
|
|
441
|
+
type AnimationViewState = {
|
|
442
|
+
readonly kind: 'pending';
|
|
443
|
+
readonly showSkeleton: true;
|
|
444
|
+
readonly source: MediaSource;
|
|
445
|
+
} | {
|
|
446
|
+
readonly kind: 'disabled';
|
|
447
|
+
readonly reason: string;
|
|
448
|
+
readonly level: DisabledLevel;
|
|
449
|
+
readonly source: MediaSource;
|
|
450
|
+
readonly idle: BundledAsset;
|
|
451
|
+
} | {
|
|
452
|
+
readonly kind: 'ready';
|
|
453
|
+
readonly tier: AnimationTier;
|
|
454
|
+
readonly source: MediaSource;
|
|
455
|
+
readonly recyclingKey: string;
|
|
456
|
+
readonly category: PetStateCategory;
|
|
457
|
+
readonly loopDurationMs: number | null;
|
|
458
|
+
readonly paused: boolean;
|
|
459
|
+
readonly reducedMotion: boolean;
|
|
460
|
+
readonly cacheHit: boolean;
|
|
461
|
+
readonly fallbackReason: FallbackReason;
|
|
462
|
+
/** Settled dark (404) surface: the genuine bundled idle, no spinner. */
|
|
463
|
+
readonly isDark: boolean;
|
|
464
|
+
/** A transient 5xx/offline error is being retried; last-good media stays on screen. */
|
|
465
|
+
readonly isTransientError: boolean;
|
|
466
|
+
};
|
|
467
|
+
interface AnimationController {
|
|
468
|
+
observe(petRef: PetRef | null, opts: {
|
|
469
|
+
readonly isFocused: boolean;
|
|
470
|
+
readonly photoUrl?: string | null;
|
|
471
|
+
}): void;
|
|
472
|
+
getState(): AnimationViewState;
|
|
473
|
+
subscribe(listener: () => void): () => void;
|
|
474
|
+
/** The view calls this from the media node's onError -> retire the current tier (§5.1). */
|
|
475
|
+
onMediaError(): void;
|
|
476
|
+
/** Decoupled from `tier`: pausing never remounts. */
|
|
477
|
+
setPaused(paused: boolean): void;
|
|
478
|
+
dispose(): void;
|
|
479
|
+
}
|
|
480
|
+
declare function createAnimationController(deps: AnimationControllerDeps): AnimationController;
|
|
481
|
+
|
|
482
|
+
interface UseAnimationsParams {
|
|
483
|
+
readonly petRef: PetRef | null;
|
|
484
|
+
/**
|
|
485
|
+
* INTERNAL / TESTING override: the /state read layer. When `repo`, `cache`, and `kv` are ALL supplied the
|
|
486
|
+
* hook constructs the controller locally from them; otherwise it acquires one from the runtime registry.
|
|
487
|
+
*/
|
|
488
|
+
readonly repo?: PetStateRepository;
|
|
489
|
+
/** INTERNAL / TESTING override: platform image-cache seam for the fleet-wide epoch purge (see `repo`). */
|
|
490
|
+
readonly cache?: ImageCachePort;
|
|
491
|
+
/** INTERNAL / TESTING override: non-secret durable KV backing the cache-epoch purge latch (see `repo`). */
|
|
492
|
+
readonly kv?: KvPort;
|
|
493
|
+
/** Focus gates the SWR poll (§4.2). Defaults to true. */
|
|
494
|
+
readonly isFocused?: boolean;
|
|
495
|
+
/** The pet's own real photo (top tier when present + unfailed). */
|
|
496
|
+
readonly photoUrl?: string | null;
|
|
497
|
+
readonly telemetry?: TelemetryPort;
|
|
498
|
+
/** System reduced-motion read; defaults to a fail-safe AccessibilityInfo reader (reduced until known). */
|
|
499
|
+
readonly reducedMotion?: () => boolean;
|
|
500
|
+
/** Already-resolved surface manifest (RN resolves via resolveManifest once). Defaults to compiled. */
|
|
501
|
+
readonly manifest?: () => CapabilityManifest;
|
|
502
|
+
readonly timers?: StoreTimers;
|
|
503
|
+
readonly now?: () => number;
|
|
504
|
+
}
|
|
505
|
+
interface UseAnimationsResult {
|
|
506
|
+
/** The server-resolved 'animations' verdict (render-of-verdict). */
|
|
507
|
+
readonly capability: CapabilityDecision;
|
|
508
|
+
/** The current frozen view state; ALWAYS carries a resolvable source (never blank). */
|
|
509
|
+
readonly state: AnimationViewState;
|
|
510
|
+
/** Forward the media node's onError -> retire the current tier. */
|
|
511
|
+
readonly onMediaError: () => void;
|
|
512
|
+
/** Pause / resume without remounting the media node. */
|
|
513
|
+
readonly setPaused: (paused: boolean) => void;
|
|
514
|
+
}
|
|
515
|
+
declare function useAnimations(params: UseAnimationsParams): UseAnimationsResult;
|
|
516
|
+
|
|
517
|
+
export { type AnimationController, type AnimationControllerDeps, type AnimationTier, type AnimationViewState, type AnimationsSurface, AuthContext, type BundledAsset, COMPILED_DEFAULT_IDLE, COMPILED_DEFAULT_MANIFEST, CacheEpochGuard, CapabilityDecision, type CapabilityManifest, DisabledLevel, EverfurError, EverfurResult, type FailedTiers, type FallbackReason, ImageCachePort, KvPort, MANIFEST_LKG_STORAGE_KEY, type ManifestSource, type MediaKind, type MediaSource, NO_FAILURES, type ParseManifestResult, PetRef, type PetStateCategory, type PetStateRepository, type PetStateResponse, type PetStateSnapshot, type PetStateStore, type PetStateTier, PetStateView, type PetStateViewProps, type PetStateWire, type ResolvedManifest, SUPPORTED_SCHEMA_VERSION, type StoreTimers, TelemetryPort, type TierInputs, type UriSource, type UseAnimationsParams, type UseAnimationsResult, animationsSurfaceOf, createAnimationController, createPetStateRepository, createPetStateStore, isLoaderSafeCategory, isTerminalPetStateError, mapPetStateResponse, parseManifest, parsePetStateWire, petStateResponseWireSchema, resolveManifest, retireTier, selectTier, stableMediaKey, useAnimations };
|