lumiverse-spindle-types 0.4.48 → 0.4.50

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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/src/dom.ts +35 -23
  3. package/src/index.ts +4 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lumiverse-spindle-types",
3
- "version": "0.4.48",
3
+ "version": "0.4.50",
4
4
  "types": "./src/index.ts",
5
5
  "keywords": [
6
6
  "lumiverse",
package/src/dom.ts CHANGED
@@ -1,37 +1,21 @@
1
- /** DOM helper API provided to frontend extension modules */
1
+ /** DOM helper API provided inside isolated frontend extension modules. */
2
2
  export interface SpindleDOMHelper {
3
- /** Inject sanitized HTML into a target area */
4
- inject(
5
- target: string | Element,
6
- html: string,
7
- position?: InsertPosition
8
- ): Element;
9
-
10
- /** Create a scoped style element. Returns a removal function. */
3
+ /** Create a style element inside the extension sandbox document. Returns a removal function. */
11
4
  addStyle(css: string): () => void;
12
5
 
13
- /** Create an element safely with optional attributes */
6
+ /** Create an element inside the extension sandbox document with optional attributes. */
14
7
  createElement<K extends keyof HTMLElementTagNameMap>(
15
8
  tag: K,
16
9
  attrs?: Record<string, string>
17
10
  ): HTMLElementTagNameMap[K];
18
11
 
19
- /**
20
- * Create a host-managed sandboxed iframe for extension-owned HTML/CSS/JS.
21
- *
22
- * The host always applies `sandbox="allow-scripts"` without
23
- * `allow-same-origin`, plus a strict child-document CSP and a narrow
24
- * postMessage bridge. Use this instead of creating raw iframes.
25
- */
26
- createSandboxFrame(options: SpindleSandboxFrameOptions): SpindleSandboxFrameHandle;
27
-
28
- /** Query within this extension's own injected elements only */
12
+ /** Query inside the extension sandbox document. */
29
13
  query(selector: string): Element | null;
30
14
 
31
- /** Query all within this extension's own injected elements only */
15
+ /** Query all matches inside the extension sandbox document. */
32
16
  queryAll(selector: string): Element[];
33
17
 
34
- /** Remove all DOM injections by this extension */
18
+ /** Remove all DOM created inside the extension sandbox document. */
35
19
  cleanup(): void;
36
20
  }
37
21
 
@@ -223,6 +207,19 @@ export interface SpindleMessageTagInterceptorOptions {
223
207
  removeFromMessage?: boolean;
224
208
  }
225
209
 
210
+ export interface SpindleMessageWidgetOptions {
211
+ /** Message ID that should host the widget. */
212
+ messageId: string;
213
+ /** Stable extension-defined widget ID, unique within the target message. */
214
+ widgetId: string;
215
+ /** HTML document or fragment rendered inside a host-managed opaque-origin iframe. */
216
+ html: string;
217
+ /** Minimum iframe height in CSS pixels. Default: 40. */
218
+ minHeight?: number;
219
+ /** Maximum iframe height in CSS pixels. Default: 4000. */
220
+ maxHeight?: number;
221
+ }
222
+
226
223
  /** Options for `permissions.request()` — displayed in the system confirmation modal. */
227
224
  export interface PermissionRequestOptions {
228
225
  /** Human-readable explanation of why the extension needs these permissions.
@@ -497,7 +494,7 @@ export interface SpindleFrontendContext {
497
494
  * }
498
495
  * ```
499
496
  */
500
- getActiveChat(): { chatId: string | null; characterId: string | null };
497
+ getActiveChat(): Promise<{ chatId: string | null; characterId: string | null }>;
501
498
  sendToBackend(payload: unknown): void;
502
499
  onBackendMessage(handler: (payload: unknown) => void): () => void;
503
500
  /** Structured lifecycle hooks for backend-spawned frontend processes. */
@@ -507,6 +504,21 @@ export interface SpindleFrontendContext {
507
504
  options: SpindleMessageTagInterceptorOptions,
508
505
  handler: (payload: SpindleMessageTagIntercept) => void
509
506
  ): () => void;
507
+ /** Render or replace a sandboxed widget below a message. Returns a cleanup function. */
508
+ renderWidget(
509
+ options: SpindleMessageWidgetOptions,
510
+ handler?: (payload: unknown) => void,
511
+ ): () => void;
512
+ /** Remove a previously rendered message widget. */
513
+ removeWidget(messageId: string, widgetId: string): void;
514
+ };
515
+ characters: {
516
+ /** Read a character through the host app's authenticated API. */
517
+ get(characterId: string): Promise<unknown>;
518
+ };
519
+ chats: {
520
+ /** Update a message through the host app's authenticated API. */
521
+ updateMessage(chatId: string, messageId: string, input: { content?: string }): Promise<unknown>;
510
522
  };
511
523
  manifest: import("./manifest").SpindleManifest;
512
524
  }
package/src/index.ts CHANGED
@@ -123,9 +123,10 @@ export type {
123
123
  SpindleDOMHelper,
124
124
  SpindleMountPoint,
125
125
  SpindleUploadFile,
126
- SpindleMessageTagIntercept,
127
- SpindleMessageTagInterceptorOptions,
128
- PermissionRequestOptions,
126
+ SpindleMessageTagIntercept,
127
+ SpindleMessageTagInterceptorOptions,
128
+ SpindleMessageWidgetOptions,
129
+ PermissionRequestOptions,
129
130
  SpindleFrontendContext,
130
131
  SpindleFrontendModule,
131
132
  SpindleDrawerTabOptions,