lumiverse-spindle-types 0.3.5 → 0.3.6
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 +1 -0
- package/src/dom.ts +61 -0
- package/src/index.ts +3 -0
- package/src/spindle-api.ts +41 -0
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -867,6 +867,7 @@ export type WorkerToHost =
|
|
|
867
867
|
| { type: "text_editor_open"; requestId: string; title?: string; value?: string; placeholder?: string; userId?: string }
|
|
868
868
|
// ─── Modal (free tier) ────────────────────────────────────────────
|
|
869
869
|
| { type: "modal_open"; requestId: string; title: string; items: SpindleModalItemDTO[]; width?: number; maxHeight?: number; persistent?: boolean; userId?: string }
|
|
870
|
+
| { type: "confirm_open"; requestId: string; title: string; message: string; variant?: "info" | "warning" | "danger" | "success"; confirmLabel?: string; cancelLabel?: string; userId?: string }
|
|
870
871
|
// ─── Macro Resolution (free tier) ──────────────────────────────────
|
|
871
872
|
| { type: "macros_resolve"; requestId: string; template: string; chatId?: string; characterId?: string; userId?: string }
|
|
872
873
|
// ─── Image Generation (gated: "image_gen") ──────────────────────────
|
package/src/dom.ts
CHANGED
|
@@ -261,6 +261,43 @@ export interface SpindleModalHandle {
|
|
|
261
261
|
onDismiss(handler: () => void): () => void;
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
+
// ── Confirmation Modal ──
|
|
265
|
+
|
|
266
|
+
/** Visual variant for confirmation modals. Controls the accent color of the confirm button. */
|
|
267
|
+
export type SpindleConfirmVariant = "info" | "warning" | "danger" | "success";
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Options for `ctx.ui.showConfirm()`.
|
|
271
|
+
* The host renders a system-themed confirmation modal with a message,
|
|
272
|
+
* variant-colored accent, and actionable buttons.
|
|
273
|
+
*/
|
|
274
|
+
export interface SpindleConfirmOptions {
|
|
275
|
+
/** Modal title displayed in the header. */
|
|
276
|
+
title: string;
|
|
277
|
+
/** Body text explaining what the user is confirming. */
|
|
278
|
+
message: string;
|
|
279
|
+
/**
|
|
280
|
+
* Visual variant that controls the confirm button's accent color.
|
|
281
|
+
* - `'info'` — neutral/blue (default)
|
|
282
|
+
* - `'warning'` — yellow/amber
|
|
283
|
+
* - `'danger'` — red — use for destructive or irreversible actions
|
|
284
|
+
* - `'success'` — green
|
|
285
|
+
*/
|
|
286
|
+
variant?: SpindleConfirmVariant;
|
|
287
|
+
/** Label for the confirm (primary) button. Default: `"Confirm"`. */
|
|
288
|
+
confirmLabel?: string;
|
|
289
|
+
/** Label for the cancel (secondary) button. Default: `"Cancel"`. */
|
|
290
|
+
cancelLabel?: string;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Result returned by `ctx.ui.showConfirm()`.
|
|
295
|
+
*/
|
|
296
|
+
export interface SpindleConfirmResult {
|
|
297
|
+
/** `true` if the user clicked the confirm button, `false` if they cancelled or dismissed. */
|
|
298
|
+
confirmed: boolean;
|
|
299
|
+
}
|
|
300
|
+
|
|
264
301
|
/** Context object provided to frontend extension modules */
|
|
265
302
|
export interface SpindleFrontendContext {
|
|
266
303
|
dom: SpindleDOMHelper;
|
|
@@ -295,6 +332,30 @@ export interface SpindleFrontendContext {
|
|
|
295
332
|
* ```
|
|
296
333
|
*/
|
|
297
334
|
showModal(options: SpindleModalOptions): SpindleModalHandle;
|
|
335
|
+
/**
|
|
336
|
+
* Show a system-themed confirmation modal and wait for the user's response.
|
|
337
|
+
* Returns `{ confirmed: true }` if the user clicks the confirm button,
|
|
338
|
+
* or `{ confirmed: false }` if they cancel or dismiss the modal.
|
|
339
|
+
*
|
|
340
|
+
* The confirm button is styled according to the `variant` option
|
|
341
|
+
* (info, warning, danger, success) to signal intent to the user.
|
|
342
|
+
*
|
|
343
|
+
* Counts toward the **2 stacked modals** limit per extension.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```ts
|
|
347
|
+
* const { confirmed } = await ctx.ui.showConfirm({
|
|
348
|
+
* title: 'Delete History',
|
|
349
|
+
* message: 'This will permanently erase all nudge history for this character.',
|
|
350
|
+
* variant: 'danger',
|
|
351
|
+
* confirmLabel: 'Delete',
|
|
352
|
+
* })
|
|
353
|
+
* if (confirmed) {
|
|
354
|
+
* ctx.sendToBackend({ type: 'delete_history', characterId })
|
|
355
|
+
* }
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
358
|
+
showConfirm(options: SpindleConfirmOptions): Promise<SpindleConfirmResult>;
|
|
298
359
|
};
|
|
299
360
|
uploads: {
|
|
300
361
|
pickFile(options?: {
|
package/src/index.ts
CHANGED
package/src/spindle-api.ts
CHANGED
|
@@ -685,6 +685,47 @@ export interface SpindleAPI {
|
|
|
685
685
|
/** How the modal was dismissed. */
|
|
686
686
|
dismissedBy: "user" | "extension" | "cleanup";
|
|
687
687
|
}>;
|
|
688
|
+
/**
|
|
689
|
+
* Show a confirmation modal and wait for the user's response.
|
|
690
|
+
* The host renders a themed dialog with a message, variant-colored
|
|
691
|
+
* confirm button, and a cancel button. The call blocks until the
|
|
692
|
+
* user responds.
|
|
693
|
+
*
|
|
694
|
+
* Counts toward the 2 stacked modals limit per extension.
|
|
695
|
+
*
|
|
696
|
+
* @example
|
|
697
|
+
* ```ts
|
|
698
|
+
* const { confirmed } = await spindle.modal.confirm({
|
|
699
|
+
* title: 'Clear History',
|
|
700
|
+
* message: 'This will delete all nudge history. This action cannot be undone.',
|
|
701
|
+
* variant: 'danger',
|
|
702
|
+
* confirmLabel: 'Delete',
|
|
703
|
+
* })
|
|
704
|
+
* if (confirmed) {
|
|
705
|
+
* await clearHistory()
|
|
706
|
+
* }
|
|
707
|
+
* ```
|
|
708
|
+
*/
|
|
709
|
+
confirm(options: {
|
|
710
|
+
/** Header title. */
|
|
711
|
+
title: string;
|
|
712
|
+
/** Body text explaining what the user is confirming. */
|
|
713
|
+
message: string;
|
|
714
|
+
/**
|
|
715
|
+
* Visual variant for the confirm button.
|
|
716
|
+
* `'info'` (default) | `'warning'` | `'danger'` | `'success'`
|
|
717
|
+
*/
|
|
718
|
+
variant?: "info" | "warning" | "danger" | "success";
|
|
719
|
+
/** Label for the confirm button. Default: `"Confirm"`. */
|
|
720
|
+
confirmLabel?: string;
|
|
721
|
+
/** Label for the cancel button. Default: `"Cancel"`. */
|
|
722
|
+
cancelLabel?: string;
|
|
723
|
+
/** For operator-scoped extensions only. */
|
|
724
|
+
userId?: string;
|
|
725
|
+
}): Promise<{
|
|
726
|
+
/** `true` if the user clicked confirm, `false` if cancelled or dismissed. */
|
|
727
|
+
confirmed: boolean;
|
|
728
|
+
}>;
|
|
688
729
|
};
|
|
689
730
|
|
|
690
731
|
/** This extension's manifest */
|