@luv1211/dsh-pet 0.1.1-rc.2

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.
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Global desktop-pet domain: durable user preferences and a live,
3
+ * session-event-derived activity read model for companion clients.
4
+ * @module @luv1211/dsh-pet
5
+ */
6
+ import type { Context } from '@deepseek-ai/cordis';
7
+ import z from '@deepseek-ai/schemastery';
8
+ import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
9
+ import { type PetCatalogOptions } from './catalog.ts';
10
+ import type { PetFolderResult, PetImportResult, PetSnapshot, PetCatalog } from './types.ts';
11
+ export type * from './types.ts';
12
+ export type * from './renderer.ts';
13
+ export { DEFAULT_PET_ID, DEFAULT_PET_SIZE_PX, MAX_PET_SIZE_PX, MIN_PET_SIZE_PX, PET_PREFERENCE_VERSION, comparePetActivities, defaultPetPreference, isDragMovement, petStatusForHostActivity, petWidthForSize, resolvePetPreference, selectLookDirection, selectPetPresentation, validatePetSize, validatePetPackage, } from './runtime.ts';
14
+ export { petSpriteAvatar, petSpriteFrame } from './renderer.ts';
15
+ declare module '@deepseek-ai/cordis' {
16
+ interface Context {
17
+ pets: PetService;
18
+ }
19
+ }
20
+ /** Host configuration for the DSH-owned package root and validation limits. */
21
+ export interface Config extends PetCatalogOptions {
22
+ }
23
+ /** Pet service (`ctx.pets`): one durable preference writer and activity aggregator. */
24
+ export declare class PetService extends TypertRemoteService {
25
+ static inject: string[];
26
+ static Config: z<Config>;
27
+ private readonly scope;
28
+ private preference;
29
+ private readonly catalogStore;
30
+ private catalog;
31
+ private readonly activities;
32
+ private tail;
33
+ constructor(ctx: Context, config?: Config);
34
+ /**
35
+ * The host-native operations the current composition provides. Resolved
36
+ * per access, not captured at construction: the `petNative` provider mounts
37
+ * as a later tree row than this service, and the composed directory picker
38
+ * can also enter the context later. An explicit `petNative` provider wins;
39
+ * otherwise the actions derive from the composed directory picker when it
40
+ * serves the native backend.
41
+ * @returns the native operations, or `undefined` in browser-only compositions.
42
+ */
43
+ private get nativeActions();
44
+ /**
45
+ * Read the latest durable preference and every current activity record.
46
+ * @returns a detached, deterministically ordered snapshot.
47
+ */
48
+ getSnapshot(): PetSnapshot;
49
+ /**
50
+ * Read the current validated built-in and user package descriptors.
51
+ * @returns a detached catalog of validated package descriptors.
52
+ */
53
+ getCatalog(): PetCatalog;
54
+ /**
55
+ * Import one validated package selected by the native host, without accepting a client path.
56
+ * @returns the publication, cancellation, or host-availability result.
57
+ */
58
+ importPetPackage(): Promise<PetImportResult>;
59
+ /**
60
+ * Rescan the user package root and republish the catalog, so packages added
61
+ * or removed on disk appear without a restart.
62
+ * @returns the fresh snapshot after the rescan.
63
+ */
64
+ refreshCatalog(): PetSnapshot;
65
+ /**
66
+ * Replace one existing user package's content with bytes selected by the
67
+ * native host. The picked manifest must name the requested package, and a
68
+ * mismatch or a non-user target fails before anything is written.
69
+ * @param petId - user package identifier to replace.
70
+ * @returns the replacement, cancellation, or host-availability result.
71
+ */
72
+ updatePetPackage(petId: string): Promise<PetImportResult>;
73
+ /**
74
+ * Ask the native host to open the configured DSH pet directory.
75
+ * @returns the opened or host-availability result.
76
+ */
77
+ openPetFolder(): Promise<PetFolderResult>;
78
+ /**
79
+ * Select a built-in or previously imported pet package.
80
+ * @param selectedPetId - non-empty package identifier.
81
+ * @returns the committed fresh snapshot.
82
+ */
83
+ selectPet(selectedPetId: string): Promise<PetSnapshot>;
84
+ /**
85
+ * Persist one validated logical CSS height for the selected companion.
86
+ * @param sizePx - logical CSS height between the configured pet limits.
87
+ * @returns the committed fresh snapshot.
88
+ */
89
+ setSize(sizePx: number): Promise<PetSnapshot>;
90
+ /**
91
+ * Wake or tuck the selected companion.
92
+ * @param awake - whether companion clients render the selected pet awake.
93
+ * @returns the committed fresh snapshot.
94
+ */
95
+ setAwake(awake: boolean): Promise<PetSnapshot>;
96
+ /**
97
+ * Serve the companion page's one awake write (`POST {awake: boolean}`),
98
+ * answering with the committed snapshot so the page applies it immediately.
99
+ * The cross-site write fence matches the API gateway: only the JSON media
100
+ * type is accepted, which forces a CORS preflight this loopback server never
101
+ * answers, so a "simple" cross-site POST cannot tuck the pet blind.
102
+ * @param req - the raw request; method, media type, and body are validated here.
103
+ * @param res - the raw response; every failure path answers a status without a body.
104
+ */
105
+ private handleOverlayAwake;
106
+ /** Replace the local adapter state from one detached host projection. */
107
+ private applyActivity;
108
+ /** Serialize one preference write and return only after durable persistence. */
109
+ private commit;
110
+ /** Publish a detached read model after a preference commit or activity transition. */
111
+ private publish;
112
+ }
113
+ export default PetService;
114
+ //# sourceMappingURL=index.d.ts.map