lumiverse-spindle-types 0.4.47 → 0.4.49

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 +62 -13
  3. package/src/index.ts +11 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lumiverse-spindle-types",
3
- "version": "0.4.47",
3
+ "version": "0.4.49",
4
4
  "types": "./src/index.ts",
5
5
  "keywords": [
6
6
  "lumiverse",
package/src/dom.ts CHANGED
@@ -1,28 +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
- /** Query within this extension's own injected elements only */
12
+ /** Query inside the extension sandbox document. */
20
13
  query(selector: string): Element | null;
21
14
 
22
- /** Query all within this extension's own injected elements only */
15
+ /** Query all matches inside the extension sandbox document. */
23
16
  queryAll(selector: string): Element[];
24
17
 
25
- /** Remove all DOM injections by this extension */
18
+ /** Remove all DOM created inside the extension sandbox document. */
26
19
  cleanup(): void;
27
20
  }
28
21
 
@@ -161,6 +154,34 @@ export interface SpindleInputBarActionHandle {
161
154
  destroy(): void;
162
155
  }
163
156
 
157
+ // ── Sandboxed Frame ──
158
+
159
+ export interface SpindleSandboxFrameOptions {
160
+ /** HTML document or fragment rendered inside the sandboxed iframe. */
161
+ html: string;
162
+ /** Automatically resize the host iframe to fit the child content. Default: `true`. */
163
+ autoResize?: boolean;
164
+ /** Initial host iframe height in CSS pixels. Default: `minHeight` or `40`. */
165
+ initialHeight?: number;
166
+ /** Minimum host iframe height in CSS pixels. Default: `40`. */
167
+ minHeight?: number;
168
+ /** Maximum host iframe height in CSS pixels. Default: `4000`. */
169
+ maxHeight?: number;
170
+ }
171
+
172
+ export interface SpindleSandboxFrameHandle {
173
+ /** The sandboxed iframe element. Extensions may place and style it like any other element. */
174
+ element: HTMLIFrameElement;
175
+ /** Replace the child document contents. */
176
+ setContent(html: string): void;
177
+ /** Send a message payload into the child sandbox runtime. */
178
+ postMessage(payload: unknown): void;
179
+ /** Receive payloads sent from the child sandbox runtime. */
180
+ onMessage(handler: (payload: unknown) => void): () => void;
181
+ /** Destroy the sandbox and remove the iframe from the DOM. */
182
+ destroy(): void;
183
+ }
184
+
164
185
  export interface SpindleUploadFile {
165
186
  name: string;
166
187
  mimeType: string;
@@ -186,6 +207,19 @@ export interface SpindleMessageTagInterceptorOptions {
186
207
  removeFromMessage?: boolean;
187
208
  }
188
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
+
189
223
  /** Options for `permissions.request()` — displayed in the system confirmation modal. */
190
224
  export interface PermissionRequestOptions {
191
225
  /** Human-readable explanation of why the extension needs these permissions.
@@ -470,6 +504,21 @@ export interface SpindleFrontendContext {
470
504
  options: SpindleMessageTagInterceptorOptions,
471
505
  handler: (payload: SpindleMessageTagIntercept) => void
472
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>;
473
522
  };
474
523
  manifest: import("./manifest").SpindleManifest;
475
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,
@@ -137,11 +138,13 @@ export type {
137
138
  SpindleDockPanelHandle,
138
139
  SpindleAppMountOptions,
139
140
  SpindleAppMountHandle,
140
- SpindleInputBarActionOptions,
141
- SpindleInputBarActionHandle,
142
- SpindleContextMenuOptions,
143
- SpindleContextMenuItemDef,
144
- SpindleContextMenuResult,
141
+ SpindleInputBarActionOptions,
142
+ SpindleInputBarActionHandle,
143
+ SpindleSandboxFrameOptions,
144
+ SpindleSandboxFrameHandle,
145
+ SpindleContextMenuOptions,
146
+ SpindleContextMenuItemDef,
147
+ SpindleContextMenuResult,
145
148
  SpindleModalOptions,
146
149
  SpindleModalHandle,
147
150
  SpindleConfirmVariant,