@salesforce/sf-embedding-bridge 2.2.2 → 2.2.3-rc.0
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/dist/bootstrap-session.d.ts +44 -11
- package/dist/index.cjs.js +546 -38
- package/dist/index.d.ts +666 -13
- package/dist/index.esm.js +521 -34
- package/package.json +10 -3
- package/dist/bootstrap-envelope.d.ts.map +0 -1
- package/dist/bootstrap-listener.d.ts.map +0 -1
- package/dist/bootstrap-session.d.ts.map +0 -1
- package/dist/embedding-info.d.ts.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/host-meta-data.d.ts.map +0 -1
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.esm.js.map +0 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type HostMetaData } from "@salesforce/sf-embedding-contract";
|
|
1
|
+
import { type JsonRpcMeta, type Transport } from "@salesforce/jsonrpc";
|
|
2
|
+
import { type EventsDispatchParams, type EventsSubscribeResult, type HostMetaData, type ResizeParams, type UiStateChangedParams, type UiStateSubscribeResult } from "@salesforce/sf-embedding-contract";
|
|
3
|
+
import { EmbeddingResizer, JsonRpcRouter, type RequestHandler, type Unregister } from "utils";
|
|
3
4
|
import { type BootstrapFailureReason } from "./bootstrap-listener";
|
|
4
5
|
export type HostInitializedPayload = Record<string, unknown>;
|
|
5
6
|
export interface SessionHandle {
|
|
6
|
-
|
|
7
|
+
bridge: EmbeddingBridge;
|
|
7
8
|
hostMetaData: HostMetaData;
|
|
8
9
|
hostInitialized: HostInitializedPayload;
|
|
9
10
|
}
|
|
@@ -13,17 +14,49 @@ export declare class SessionFailureError extends Error {
|
|
|
13
14
|
constructor(reason: SessionFailureReason, cause?: unknown);
|
|
14
15
|
}
|
|
15
16
|
export interface BootstrapSessionOptions {
|
|
16
|
-
/**
|
|
17
|
-
* Cancellation signal. The browser MessagePort API has no port-close event,
|
|
18
|
-
* so the consumer owns the deadline (e.g. AbortSignal.timeout(30_000)).
|
|
19
|
-
* Honored only on the first call; subsequent calls return the cached promise.
|
|
20
|
-
*/
|
|
17
|
+
/** Cancellation signal. Consumer owns the deadline (e.g. AbortSignal.timeout(30_000)). */
|
|
21
18
|
signal?: AbortSignal;
|
|
22
19
|
}
|
|
23
20
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
21
|
+
* Embedding-side peer. One object that routes inbound requests (via
|
|
22
|
+
* `JsonRpcRouter`), handles inbound notifications, and exposes named methods
|
|
23
|
+
* for the embedding's outbound traffic. Register inbound handlers in the
|
|
24
|
+
* constructor; add outbound methods as the protocol grows.
|
|
27
25
|
*/
|
|
26
|
+
export declare class EmbeddingBridge extends JsonRpcRouter {
|
|
27
|
+
private readonly hostInitialized;
|
|
28
|
+
private resizer;
|
|
29
|
+
constructor(transport: Transport);
|
|
30
|
+
/** Await the host's `host-initialized` notification. */
|
|
31
|
+
waitForHostInitialized(): Promise<HostInitializedPayload>;
|
|
32
|
+
/** Announce that the embedding has initialized. */
|
|
33
|
+
sendInitializedNotification(): void;
|
|
34
|
+
/** Subscribe to host UI-state. Returns the initial snapshot + active subscription id. */
|
|
35
|
+
sendUiStateSubscribe(): Promise<UiStateSubscribeResult>;
|
|
36
|
+
/** Tear down an active UI-state subscription. */
|
|
37
|
+
sendUiStateUnsubscribe(subscriptionId: string): Promise<void>;
|
|
38
|
+
/** Register a handler for `ui/notifications/ui-state-changed`. */
|
|
39
|
+
onUiStateChanged(handler: (params: UiStateChangedParams, meta?: JsonRpcMeta) => void): void;
|
|
40
|
+
/** Fire-and-forget dispatch of a custom event (bidirectional `ui/events/dispatch`).
|
|
41
|
+
* `options` controls DOM-event flags on the receiving side; defaults bubble + composed = true. */
|
|
42
|
+
sendEventDispatch(eventType: string, detail: unknown, options?: {
|
|
43
|
+
bubbles?: boolean;
|
|
44
|
+
composed?: boolean;
|
|
45
|
+
cancelable?: boolean;
|
|
46
|
+
}): void;
|
|
47
|
+
/** Subscribe to host-driven events. One subscription per session — local fan-out by eventType is the SDK's job. */
|
|
48
|
+
sendEventSubscribe(): Promise<EventsSubscribeResult>;
|
|
49
|
+
/** Tear down a host-event subscription. */
|
|
50
|
+
sendEventUnsubscribe(subscriptionId: string): Promise<void>;
|
|
51
|
+
/** Register a handler for inbound `ui/events/dispatch` (host → embedding). */
|
|
52
|
+
onEventDispatch(handler: (params: EventsDispatchParams, meta?: JsonRpcMeta) => void): void;
|
|
53
|
+
/** Fire-and-forget resize hint (`ui/notifications/resize`). */
|
|
54
|
+
sendResize(dimensions: ResizeParams): void;
|
|
55
|
+
/** Attach an auto-emit resizer; stopped on dispose. Replaces any prior resizer. */
|
|
56
|
+
attachResizer(resizer: EmbeddingResizer): void;
|
|
57
|
+
dispose(): void;
|
|
58
|
+
}
|
|
59
|
+
export type { RequestHandler, Unregister };
|
|
60
|
+
/** Single-attempt per iframe; recovery from failure requires a host-driven remount. */
|
|
28
61
|
export declare function bootstrapSession(options?: BootstrapSessionOptions): Promise<SessionHandle>;
|
|
29
62
|
//# sourceMappingURL=bootstrap-session.d.ts.map
|