@spawnco/sdk-types 0.0.54 → 0.0.56
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/dist/index.d.mts +63 -1
- package/dist/index.d.ts +63 -1
- package/package.json +1 -1
- package/src/v1.ts +55 -0
package/dist/index.d.mts
CHANGED
|
@@ -22,6 +22,51 @@ interface SoundSettings {
|
|
|
22
22
|
ambience: number;
|
|
23
23
|
voice: number;
|
|
24
24
|
}
|
|
25
|
+
type GameSpecMutation = {
|
|
26
|
+
kind: 'spawn';
|
|
27
|
+
id: string;
|
|
28
|
+
spec: Record<string, unknown>;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'destroy';
|
|
31
|
+
id: string;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'setProperty';
|
|
34
|
+
id: string;
|
|
35
|
+
key: string;
|
|
36
|
+
value: unknown;
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'replaceState';
|
|
39
|
+
id: string;
|
|
40
|
+
state: Record<string, unknown>;
|
|
41
|
+
} | {
|
|
42
|
+
kind: 'patchState';
|
|
43
|
+
id: string;
|
|
44
|
+
patch: Record<string, unknown>;
|
|
45
|
+
};
|
|
46
|
+
interface GameSpecMutationResult {
|
|
47
|
+
appId: string;
|
|
48
|
+
version: number;
|
|
49
|
+
applied: number;
|
|
50
|
+
skipped: number;
|
|
51
|
+
mutationCount: number;
|
|
52
|
+
updated: boolean;
|
|
53
|
+
}
|
|
54
|
+
interface RoomRegistrationOptions {
|
|
55
|
+
maxPlayers?: number;
|
|
56
|
+
metadata?: Record<string, unknown>;
|
|
57
|
+
}
|
|
58
|
+
interface RoomHeartbeatOptions {
|
|
59
|
+
playerCount: number;
|
|
60
|
+
metadata?: Record<string, unknown>;
|
|
61
|
+
}
|
|
62
|
+
interface RoomPlayerJoinOptions {
|
|
63
|
+
userId: string;
|
|
64
|
+
}
|
|
65
|
+
interface RoomRegistrationResult {
|
|
66
|
+
success: boolean;
|
|
67
|
+
roomId: string;
|
|
68
|
+
appId: string;
|
|
69
|
+
}
|
|
25
70
|
interface ClipThumbnailDescriptor {
|
|
26
71
|
assetUrl: string;
|
|
27
72
|
contentType: string;
|
|
@@ -217,6 +262,16 @@ interface SpawnServerSDK__V1<TConfig = any> {
|
|
|
217
262
|
success: boolean;
|
|
218
263
|
}>;
|
|
219
264
|
};
|
|
265
|
+
roomRegistry: {
|
|
266
|
+
/** Register this room with the central registry. Call once on room startup. */
|
|
267
|
+
register(options?: RoomRegistrationOptions): Promise<RoomRegistrationResult>;
|
|
268
|
+
/** Send heartbeat with current metrics. Call every 30s. */
|
|
269
|
+
heartbeat(options: RoomHeartbeatOptions): Promise<void>;
|
|
270
|
+
/** Track a player joining this room. Call when a player connects. */
|
|
271
|
+
playerJoin(options: RoomPlayerJoinOptions): Promise<void>;
|
|
272
|
+
/** Deregister this room. Call on graceful shutdown. */
|
|
273
|
+
deregister(): Promise<void>;
|
|
274
|
+
};
|
|
220
275
|
sparks: {
|
|
221
276
|
verifyPurchase({ purchaseId, price }: {
|
|
222
277
|
purchaseId: string;
|
|
@@ -287,6 +342,13 @@ interface SpawnServerSDK__V1<TConfig = any> {
|
|
|
287
342
|
version: number;
|
|
288
343
|
gameSpec: Record<string, unknown>;
|
|
289
344
|
} | null>;
|
|
345
|
+
/**
|
|
346
|
+
* Apply script-style mutations (spawn/destroy/setProperty/state) to the game spec.
|
|
347
|
+
*/
|
|
348
|
+
applyMutations(options: {
|
|
349
|
+
mutations: GameSpecMutation[];
|
|
350
|
+
appId?: string;
|
|
351
|
+
}): Promise<GameSpecMutationResult>;
|
|
290
352
|
};
|
|
291
353
|
config: {
|
|
292
354
|
get(): Promise<TConfig>;
|
|
@@ -509,4 +571,4 @@ interface JobFnEnv {
|
|
|
509
571
|
type SpawnClientSDK__V0<TConfig = any> = Omit<SpawnClientSDK__V1<TConfig>, 'economy'>;
|
|
510
572
|
type SpawnServerSDK__V0<TConfig = any> = Omit<SpawnServerSDK__V1<TConfig>, 'economy' | 'room' | 'llm'>;
|
|
511
573
|
|
|
512
|
-
export type { ClipDescriptor, ClipFormat, ClipKind, ClipListOptions, ClipLookupOptions, ClipStatus, ClipThumbnailDescriptor, InventoryItem, Item, JobDewEnv, JobFnEnv, LeaderboardEntry, LlmApi, LlmChatOptions, LlmChatResponse, LlmModel, Room, RoomInfo, RoomVisibility, SoundSettings, SpawnClientSDK__V0, SpawnClientSDK__V1, SpawnServerSDK__V0, SpawnServerSDK__V1, TokenPayload, UploadClipOptions, User };
|
|
574
|
+
export type { ClipDescriptor, ClipFormat, ClipKind, ClipListOptions, ClipLookupOptions, ClipStatus, ClipThumbnailDescriptor, GameSpecMutation, GameSpecMutationResult, InventoryItem, Item, JobDewEnv, JobFnEnv, LeaderboardEntry, LlmApi, LlmChatOptions, LlmChatResponse, LlmModel, Room, RoomHeartbeatOptions, RoomInfo, RoomPlayerJoinOptions, RoomRegistrationOptions, RoomRegistrationResult, RoomVisibility, SoundSettings, SpawnClientSDK__V0, SpawnClientSDK__V1, SpawnServerSDK__V0, SpawnServerSDK__V1, TokenPayload, UploadClipOptions, User };
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,51 @@ interface SoundSettings {
|
|
|
22
22
|
ambience: number;
|
|
23
23
|
voice: number;
|
|
24
24
|
}
|
|
25
|
+
type GameSpecMutation = {
|
|
26
|
+
kind: 'spawn';
|
|
27
|
+
id: string;
|
|
28
|
+
spec: Record<string, unknown>;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'destroy';
|
|
31
|
+
id: string;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'setProperty';
|
|
34
|
+
id: string;
|
|
35
|
+
key: string;
|
|
36
|
+
value: unknown;
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'replaceState';
|
|
39
|
+
id: string;
|
|
40
|
+
state: Record<string, unknown>;
|
|
41
|
+
} | {
|
|
42
|
+
kind: 'patchState';
|
|
43
|
+
id: string;
|
|
44
|
+
patch: Record<string, unknown>;
|
|
45
|
+
};
|
|
46
|
+
interface GameSpecMutationResult {
|
|
47
|
+
appId: string;
|
|
48
|
+
version: number;
|
|
49
|
+
applied: number;
|
|
50
|
+
skipped: number;
|
|
51
|
+
mutationCount: number;
|
|
52
|
+
updated: boolean;
|
|
53
|
+
}
|
|
54
|
+
interface RoomRegistrationOptions {
|
|
55
|
+
maxPlayers?: number;
|
|
56
|
+
metadata?: Record<string, unknown>;
|
|
57
|
+
}
|
|
58
|
+
interface RoomHeartbeatOptions {
|
|
59
|
+
playerCount: number;
|
|
60
|
+
metadata?: Record<string, unknown>;
|
|
61
|
+
}
|
|
62
|
+
interface RoomPlayerJoinOptions {
|
|
63
|
+
userId: string;
|
|
64
|
+
}
|
|
65
|
+
interface RoomRegistrationResult {
|
|
66
|
+
success: boolean;
|
|
67
|
+
roomId: string;
|
|
68
|
+
appId: string;
|
|
69
|
+
}
|
|
25
70
|
interface ClipThumbnailDescriptor {
|
|
26
71
|
assetUrl: string;
|
|
27
72
|
contentType: string;
|
|
@@ -217,6 +262,16 @@ interface SpawnServerSDK__V1<TConfig = any> {
|
|
|
217
262
|
success: boolean;
|
|
218
263
|
}>;
|
|
219
264
|
};
|
|
265
|
+
roomRegistry: {
|
|
266
|
+
/** Register this room with the central registry. Call once on room startup. */
|
|
267
|
+
register(options?: RoomRegistrationOptions): Promise<RoomRegistrationResult>;
|
|
268
|
+
/** Send heartbeat with current metrics. Call every 30s. */
|
|
269
|
+
heartbeat(options: RoomHeartbeatOptions): Promise<void>;
|
|
270
|
+
/** Track a player joining this room. Call when a player connects. */
|
|
271
|
+
playerJoin(options: RoomPlayerJoinOptions): Promise<void>;
|
|
272
|
+
/** Deregister this room. Call on graceful shutdown. */
|
|
273
|
+
deregister(): Promise<void>;
|
|
274
|
+
};
|
|
220
275
|
sparks: {
|
|
221
276
|
verifyPurchase({ purchaseId, price }: {
|
|
222
277
|
purchaseId: string;
|
|
@@ -287,6 +342,13 @@ interface SpawnServerSDK__V1<TConfig = any> {
|
|
|
287
342
|
version: number;
|
|
288
343
|
gameSpec: Record<string, unknown>;
|
|
289
344
|
} | null>;
|
|
345
|
+
/**
|
|
346
|
+
* Apply script-style mutations (spawn/destroy/setProperty/state) to the game spec.
|
|
347
|
+
*/
|
|
348
|
+
applyMutations(options: {
|
|
349
|
+
mutations: GameSpecMutation[];
|
|
350
|
+
appId?: string;
|
|
351
|
+
}): Promise<GameSpecMutationResult>;
|
|
290
352
|
};
|
|
291
353
|
config: {
|
|
292
354
|
get(): Promise<TConfig>;
|
|
@@ -509,4 +571,4 @@ interface JobFnEnv {
|
|
|
509
571
|
type SpawnClientSDK__V0<TConfig = any> = Omit<SpawnClientSDK__V1<TConfig>, 'economy'>;
|
|
510
572
|
type SpawnServerSDK__V0<TConfig = any> = Omit<SpawnServerSDK__V1<TConfig>, 'economy' | 'room' | 'llm'>;
|
|
511
573
|
|
|
512
|
-
export type { ClipDescriptor, ClipFormat, ClipKind, ClipListOptions, ClipLookupOptions, ClipStatus, ClipThumbnailDescriptor, InventoryItem, Item, JobDewEnv, JobFnEnv, LeaderboardEntry, LlmApi, LlmChatOptions, LlmChatResponse, LlmModel, Room, RoomInfo, RoomVisibility, SoundSettings, SpawnClientSDK__V0, SpawnClientSDK__V1, SpawnServerSDK__V0, SpawnServerSDK__V1, TokenPayload, UploadClipOptions, User };
|
|
574
|
+
export type { ClipDescriptor, ClipFormat, ClipKind, ClipListOptions, ClipLookupOptions, ClipStatus, ClipThumbnailDescriptor, GameSpecMutation, GameSpecMutationResult, InventoryItem, Item, JobDewEnv, JobFnEnv, LeaderboardEntry, LlmApi, LlmChatOptions, LlmChatResponse, LlmModel, Room, RoomHeartbeatOptions, RoomInfo, RoomPlayerJoinOptions, RoomRegistrationOptions, RoomRegistrationResult, RoomVisibility, SoundSettings, SpawnClientSDK__V0, SpawnClientSDK__V1, SpawnServerSDK__V0, SpawnServerSDK__V1, TokenPayload, UploadClipOptions, User };
|
package/package.json
CHANGED
package/src/v1.ts
CHANGED
|
@@ -27,6 +27,42 @@ export interface SoundSettings {
|
|
|
27
27
|
voice: number; // 0-1
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
export type GameSpecMutation =
|
|
31
|
+
| { kind: 'spawn'; id: string; spec: Record<string, unknown> }
|
|
32
|
+
| { kind: 'destroy'; id: string }
|
|
33
|
+
| { kind: 'setProperty'; id: string; key: string; value: unknown }
|
|
34
|
+
| { kind: 'replaceState'; id: string; state: Record<string, unknown> }
|
|
35
|
+
| { kind: 'patchState'; id: string; patch: Record<string, unknown> };
|
|
36
|
+
|
|
37
|
+
export interface GameSpecMutationResult {
|
|
38
|
+
appId: string;
|
|
39
|
+
version: number;
|
|
40
|
+
applied: number;
|
|
41
|
+
skipped: number;
|
|
42
|
+
mutationCount: number;
|
|
43
|
+
updated: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface RoomRegistrationOptions {
|
|
47
|
+
maxPlayers?: number;
|
|
48
|
+
metadata?: Record<string, unknown>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface RoomHeartbeatOptions {
|
|
52
|
+
playerCount: number;
|
|
53
|
+
metadata?: Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface RoomPlayerJoinOptions {
|
|
57
|
+
userId: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface RoomRegistrationResult {
|
|
61
|
+
success: boolean;
|
|
62
|
+
roomId: string;
|
|
63
|
+
appId: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
30
66
|
export interface ClipThumbnailDescriptor {
|
|
31
67
|
assetUrl: string;
|
|
32
68
|
contentType: string;
|
|
@@ -235,6 +271,20 @@ export interface SpawnServerSDK__V1<TConfig = any> {
|
|
|
235
271
|
notifyDm(options: { message: string; source?: string; entityId?: string }): Promise<{ success: boolean }>;
|
|
236
272
|
};
|
|
237
273
|
|
|
274
|
+
roomRegistry: {
|
|
275
|
+
/** Register this room with the central registry. Call once on room startup. */
|
|
276
|
+
register(options?: RoomRegistrationOptions): Promise<RoomRegistrationResult>;
|
|
277
|
+
|
|
278
|
+
/** Send heartbeat with current metrics. Call every 30s. */
|
|
279
|
+
heartbeat(options: RoomHeartbeatOptions): Promise<void>;
|
|
280
|
+
|
|
281
|
+
/** Track a player joining this room. Call when a player connects. */
|
|
282
|
+
playerJoin(options: RoomPlayerJoinOptions): Promise<void>;
|
|
283
|
+
|
|
284
|
+
/** Deregister this room. Call on graceful shutdown. */
|
|
285
|
+
deregister(): Promise<void>;
|
|
286
|
+
};
|
|
287
|
+
|
|
238
288
|
sparks: {
|
|
239
289
|
verifyPurchase({ purchaseId, price }: { purchaseId: string; price: number }): Promise<boolean>;
|
|
240
290
|
};
|
|
@@ -310,6 +360,11 @@ export interface SpawnServerSDK__V1<TConfig = any> {
|
|
|
310
360
|
version: number;
|
|
311
361
|
gameSpec: Record<string, unknown>;
|
|
312
362
|
} | null>;
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Apply script-style mutations (spawn/destroy/setProperty/state) to the game spec.
|
|
366
|
+
*/
|
|
367
|
+
applyMutations(options: { mutations: GameSpecMutation[]; appId?: string }): Promise<GameSpecMutationResult>;
|
|
313
368
|
};
|
|
314
369
|
|
|
315
370
|
config: {
|