lumiverse-spindle-types 0.4.18 → 0.4.20
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/package.json +1 -1
- package/src/api.ts +2 -2
- package/src/spindle-api.ts +21 -8
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -1077,7 +1077,7 @@ export type WorkerToHost =
|
|
|
1077
1077
|
result?: string;
|
|
1078
1078
|
error?: string;
|
|
1079
1079
|
}
|
|
1080
|
-
| { type: "frontend_message"; payload: unknown }
|
|
1080
|
+
| { type: "frontend_message"; payload: unknown; userId?: string }
|
|
1081
1081
|
| { type: "user_storage_read"; requestId: string; path: string; userId?: string }
|
|
1082
1082
|
| { type: "user_storage_write"; requestId: string; path: string; data: string; userId?: string }
|
|
1083
1083
|
| { type: "user_storage_delete"; requestId: string; path: string; userId?: string }
|
|
@@ -1193,7 +1193,7 @@ export type WorkerToHost =
|
|
|
1193
1193
|
|
|
1194
1194
|
export type HostToWorker =
|
|
1195
1195
|
| { type: "init"; manifest: SpindleManifest; storagePath: string }
|
|
1196
|
-
| { type: "event"; event: string; payload: unknown }
|
|
1196
|
+
| { type: "event"; event: string; payload: unknown; userId?: string }
|
|
1197
1197
|
| {
|
|
1198
1198
|
type: "intercept_request";
|
|
1199
1199
|
requestId: string;
|
package/src/spindle-api.ts
CHANGED
|
@@ -50,21 +50,21 @@ import type {
|
|
|
50
50
|
/** The global `spindle` object available in backend extension workers */
|
|
51
51
|
export interface SpindleAPI {
|
|
52
52
|
/** Subscribe to generation-started events (requires `generation` permission). */
|
|
53
|
-
on(event: "GENERATION_STARTED", handler: (payload: GenerationStartedPayloadDTO) => void): () => void;
|
|
53
|
+
on(event: "GENERATION_STARTED", handler: (payload: GenerationStartedPayloadDTO, userId?: string) => void): () => void;
|
|
54
54
|
/** Subscribe to streamed token events (requires `generation` permission). */
|
|
55
|
-
on(event: "STREAM_TOKEN_RECEIVED", handler: (payload: StreamTokenPayloadDTO) => void): () => void;
|
|
55
|
+
on(event: "STREAM_TOKEN_RECEIVED", handler: (payload: StreamTokenPayloadDTO, userId?: string) => void): () => void;
|
|
56
56
|
/** Subscribe to generation-ended events (requires `generation` permission). */
|
|
57
|
-
on(event: "GENERATION_ENDED", handler: (payload: GenerationEndedPayloadDTO) => void): () => void;
|
|
57
|
+
on(event: "GENERATION_ENDED", handler: (payload: GenerationEndedPayloadDTO, userId?: string) => void): () => void;
|
|
58
58
|
/** Subscribe to generation-stopped events (requires `generation` permission). */
|
|
59
|
-
on(event: "GENERATION_STOPPED", handler: (payload: GenerationStoppedPayloadDTO) => void): () => void;
|
|
59
|
+
on(event: "GENERATION_STOPPED", handler: (payload: GenerationStoppedPayloadDTO, userId?: string) => void): () => void;
|
|
60
60
|
/**
|
|
61
61
|
* Subscribe to swipe lifecycle events. The payload's `action` discriminator
|
|
62
62
|
* tells you whether a swipe was added, updated, deleted, or navigated, and
|
|
63
63
|
* `swipeId` identifies which slot the event concerns.
|
|
64
64
|
*/
|
|
65
|
-
on(event: "MESSAGE_SWIPED", handler: (payload: MessageSwipedPayloadDTO) => void): () => void;
|
|
65
|
+
on(event: "MESSAGE_SWIPED", handler: (payload: MessageSwipedPayloadDTO, userId?: string) => void): () => void;
|
|
66
66
|
/** Subscribe to a Lumiverse event. */
|
|
67
|
-
on(event: string, handler: (payload: unknown) => void): () => void;
|
|
67
|
+
on(event: string, handler: (payload: unknown, userId?: string) => void): () => void;
|
|
68
68
|
|
|
69
69
|
/** Register a macro */
|
|
70
70
|
registerMacro(def: MacroDefinitionDTO): void;
|
|
@@ -515,8 +515,21 @@ export interface SpindleAPI {
|
|
|
515
515
|
priority?: number
|
|
516
516
|
): void;
|
|
517
517
|
|
|
518
|
-
/**
|
|
519
|
-
|
|
518
|
+
/**
|
|
519
|
+
* Send a message to the frontend module.
|
|
520
|
+
*
|
|
521
|
+
* @param payload Arbitrary JSON-serializable data delivered to the
|
|
522
|
+
* extension's frontend module via the `SPINDLE_FRONTEND_MSG`
|
|
523
|
+
* WebSocket event.
|
|
524
|
+
* @param userId Optional target user. When omitted on operator-scoped
|
|
525
|
+
* extensions the message is broadcast to **every connected
|
|
526
|
+
* user**, which is rarely what you want — pass the userId
|
|
527
|
+
* from the original `onFrontendMessage` handler (or any
|
|
528
|
+
* other API call site that surfaced one) to route the reply
|
|
529
|
+
* only to that user. User-scoped extensions always deliver
|
|
530
|
+
* to their installer regardless of this argument.
|
|
531
|
+
*/
|
|
532
|
+
sendToFrontend(payload: unknown, userId?: string): void;
|
|
520
533
|
/** Receive messages from the frontend module (userId is the sender) */
|
|
521
534
|
onFrontendMessage(handler: (payload: unknown, userId: string) => void): () => void;
|
|
522
535
|
|