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 +1 -1
- package/src/dom.ts +24 -7
- package/src/index.ts +1 -0
package/package.json
CHANGED
package/src/dom.ts
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
import type { RequestInitDTO } from "./api";
|
|
2
|
+
|
|
3
|
+
/** DOM helper API provided to frontend extension modules. */
|
|
2
4
|
export interface SpindleDOMHelper {
|
|
3
|
-
/**
|
|
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
|
|
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
|
-
/**
|
|
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
|
|
23
|
+
/** Query all matches inside the extension-owned host DOM. */
|
|
16
24
|
queryAll(selector: string): Element[];
|
|
17
25
|
|
|
18
|
-
/** Remove all DOM created
|
|
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():
|
|
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. */
|