lumiverse-spindle-types 0.4.50 → 0.4.52

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lumiverse-spindle-types",
3
- "version": "0.4.50",
3
+ "version": "0.4.52",
4
4
  "types": "./src/index.ts",
5
5
  "keywords": [
6
6
  "lumiverse",
package/src/dom.ts CHANGED
@@ -1,21 +1,29 @@
1
- /** DOM helper API provided inside isolated frontend extension modules. */
1
+ import type { RequestInitDTO } from "./api";
2
+
3
+ /** DOM helper API provided to frontend extension modules. */
2
4
  export interface SpindleDOMHelper {
3
- /** Create a style element inside the extension sandbox document. Returns a removal function. */
5
+ /** Inject sanitized HTML into the host document at the given target. */
6
+ inject(target: string | Element, html: string, position?: InsertPosition): Element;
7
+
8
+ /** Create a style element in the host document. Returns a removal function. */
4
9
  addStyle(css: string): () => void;
5
10
 
6
- /** Create an element inside the extension sandbox document with optional attributes. */
11
+ /** Create an element in the host document with optional attributes. */
7
12
  createElement<K extends keyof HTMLElementTagNameMap>(
8
13
  tag: K,
9
14
  attrs?: Record<string, string>
10
15
  ): HTMLElementTagNameMap[K];
11
16
 
12
- /** Query inside the extension sandbox document. */
17
+ /** Create a host-managed sandboxed iframe for isolated scriptable content. */
18
+ createSandboxFrame(options: SpindleSandboxFrameOptions): SpindleSandboxFrameHandle;
19
+
20
+ /** Query inside the extension-owned host DOM. */
13
21
  query(selector: string): Element | null;
14
22
 
15
- /** Query all matches inside the extension sandbox document. */
23
+ /** Query all matches inside the extension-owned host DOM. */
16
24
  queryAll(selector: string): Element[];
17
25
 
18
- /** Remove all DOM created inside the extension sandbox document. */
26
+ /** Remove all DOM created by the extension helper. */
19
27
  cleanup(): void;
20
28
  }
21
29
 
@@ -182,6 +190,15 @@ export interface SpindleSandboxFrameHandle {
182
190
  destroy(): void;
183
191
  }
184
192
 
193
+ /** API exposed inside the sandboxed iframe as `window.spindleSandbox`. */
194
+ export interface SpindleSandboxAPI {
195
+ postMessage(payload: unknown): void;
196
+ onMessage(handler: (payload: unknown) => void): () => void;
197
+ requestResize(height?: number): void;
198
+ /** Fetch a URL through the extension's CORS proxy. Requires the `cors_proxy` permission. */
199
+ corsProxy(url: string, options?: RequestInitDTO): Promise<unknown>;
200
+ }
201
+
185
202
  export interface SpindleUploadFile {
186
203
  name: string;
187
204
  mimeType: string;
@@ -494,7 +511,7 @@ export interface SpindleFrontendContext {
494
511
  * }
495
512
  * ```
496
513
  */
497
- getActiveChat(): Promise<{ chatId: string | null; characterId: string | null }>;
514
+ getActiveChat(): { chatId: string | null; characterId: string | null };
498
515
  sendToBackend(payload: unknown): void;
499
516
  onBackendMessage(handler: (payload: unknown) => void): () => void;
500
517
  /** Structured lifecycle hooks for backend-spawned frontend processes. */
package/src/index.ts CHANGED
@@ -142,6 +142,7 @@ export type {
142
142
  SpindleInputBarActionHandle,
143
143
  SpindleSandboxFrameOptions,
144
144
  SpindleSandboxFrameHandle,
145
+ SpindleSandboxAPI,
145
146
  SpindleContextMenuOptions,
146
147
  SpindleContextMenuItemDef,
147
148
  SpindleContextMenuResult,