@theaiplatform/miniapp-sdk 0.3.1 → 0.3.3

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.
@@ -0,0 +1,12 @@
1
+ /*! Bundled license information:
2
+
3
+ prismjs/prism.js:
4
+ (**
5
+ * Prism: Lightweight, robust, elegant syntax highlighting
6
+ *
7
+ * @license MIT <https://opensource.org/licenses/MIT>
8
+ * @author Lea Verou <https://lea.verou.me>
9
+ * @namespace
10
+ * @public
11
+ *)
12
+ */
@@ -0,0 +1,133 @@
1
+ /** JSON-compatible values accepted by public miniapp operations. */
2
+ declare type MiniAppJsonValue = null | boolean | number | string | MiniAppJsonValue[] | {
3
+ [key: string]: MiniAppJsonValue;
4
+ };
5
+
6
+ /**
7
+ * Mount a converted VS Code webview while retaining all TAP authority in the
8
+ * outer federated surface. The imported page receives only the explicitly
9
+ * configured compatibility operations.
10
+ */
11
+ export declare function mountVsCodeWebview(container: HTMLElement, context: TapFederatedSurfaceMountContext, options: TapVsCodeWebviewBridgeOptions): TapVsCodeWebviewMount;
12
+
13
+ /**
14
+ * Read-only authority projected by TAP for the exact package release/frame.
15
+ * A candidate frame starts without authority and may only perform host-backed
16
+ * work after the host confirms that release. Subscribers are notified only
17
+ * when the boolean snapshot changes.
18
+ */
19
+ declare interface TapFederatedSurfaceHostAuthority {
20
+ getSnapshot(): boolean;
21
+ subscribe(listener: () => void): () => void;
22
+ }
23
+
24
+ /** Cleanup handle returned by a federated surface mount. */
25
+ declare interface TapFederatedSurfaceMount {
26
+ unmount(): void | Promise<void>;
27
+ }
28
+
29
+ /** Context supplied by TAP's isolated webview surface runtime. */
30
+ declare interface TapFederatedSurfaceMountContext {
31
+ readonly packageId: string;
32
+ readonly packageNamespace: string;
33
+ readonly releaseId: string;
34
+ readonly installationId: string;
35
+ readonly contributionId: string;
36
+ readonly instanceId: string;
37
+ readonly hostOrigin: string;
38
+ readonly packageAssetBaseUrl: string;
39
+ readonly workspaceId?: string;
40
+ readonly channelId?: string;
41
+ readonly conversationId?: string;
42
+ readonly events: TapPackageEventPublisher;
43
+ readonly hostAuthority: TapFederatedSurfaceHostAuthority;
44
+ }
45
+
46
+ /**
47
+ * @capability miniapp-platform
48
+ */
49
+ /** Declared package-event channel supplied to an isolated UI contribution. */
50
+ declare interface TapPackageEventPublisher {
51
+ publish(name: string, payload: Readonly<Record<string, unknown>>): void | Promise<void>;
52
+ subscribe(name: string, listener: (payload: unknown, envelope: Readonly<Record<string, unknown>>) => void | Promise<void>): () => void;
53
+ }
54
+
55
+ export declare interface TapVsCodeWebviewBootstrapBinding {
56
+ /** Path to read in the stored JSON value. */
57
+ statePath: readonly string[];
58
+ /** Path to update in the bootstrap JSON value. */
59
+ bootstrapPath: readonly string[];
60
+ transform?: Exclude<TapVsCodeWebviewValueTransform, 'byte-array-to-base64'>;
61
+ }
62
+
63
+ export declare interface TapVsCodeWebviewBootstrapOptions {
64
+ selector: string;
65
+ attribute: string;
66
+ encoding: 'base64-json';
67
+ value: MiniAppJsonValue;
68
+ }
69
+
70
+ export declare interface TapVsCodeWebviewBridgeOptions {
71
+ title: string;
72
+ entryPath: string;
73
+ /** Browser runtime emitted from `tapVsCodeWebviewRuntimeSource`. */
74
+ runtimePath: string;
75
+ bootstrap?: TapVsCodeWebviewBootstrapOptions;
76
+ storage?: TapVsCodeWebviewStorageOptions;
77
+ session?: TapVsCodeWebviewSessionOptions;
78
+ network?: TapVsCodeWebviewNetworkOptions;
79
+ onMessage?: (message: unknown) => void | Promise<void>;
80
+ onError?: (error: Error) => void;
81
+ }
82
+
83
+ export declare interface TapVsCodeWebviewMessageBinding {
84
+ /** Exact value of the message discriminator (normally `message.type`). */
85
+ messageType: string;
86
+ /** Path to the value in the webview message. */
87
+ messageValuePath: readonly string[];
88
+ /** Path to update in the JSON value stored by `sdk.storage`. */
89
+ statePath: readonly string[];
90
+ transform?: Exclude<TapVsCodeWebviewValueTransform, 'base64-to-byte-array'>;
91
+ }
92
+
93
+ export declare interface TapVsCodeWebviewMount extends TapFederatedSurfaceMount {
94
+ postMessage(message: unknown): void;
95
+ }
96
+
97
+ export declare interface TapVsCodeWebviewNetworkOptions {
98
+ /** Exact HTTPS origins approved by the conversion recipe. */
99
+ allowedOrigins: readonly string[];
100
+ }
101
+
102
+ /**
103
+ * Self-contained browser runtime written next to a converted webview by the
104
+ * conversion CLI. Keeping this byte string in the SDK prevents generated
105
+ * adapters from growing a second, incompatible bridge implementation.
106
+ */
107
+ export declare const tapVsCodeWebviewRuntimeSource: string;
108
+
109
+ export declare interface TapVsCodeWebviewSessionOptions {
110
+ /**
111
+ * Field inside the installation-scoped `sdk.session` object. The iframe gets
112
+ * a synchronous in-memory localStorage facade backed by this field.
113
+ */
114
+ namespace: string;
115
+ }
116
+
117
+ export declare interface TapVsCodeWebviewStorageOptions {
118
+ namespace: string;
119
+ key: string;
120
+ initialValue: MiniAppJsonValue;
121
+ messageTypePath?: readonly string[];
122
+ messageBindings?: readonly TapVsCodeWebviewMessageBinding[];
123
+ bootstrapBindings?: readonly TapVsCodeWebviewBootstrapBinding[];
124
+ /**
125
+ * Optional path used for the synchronous `acquireVsCodeApi().getState()` and
126
+ * `setState()` compatibility value.
127
+ */
128
+ vscodeStatePath?: readonly string[];
129
+ }
130
+
131
+ export declare type TapVsCodeWebviewValueTransform = 'identity' | 'byte-array-to-base64' | 'base64-to-byte-array';
132
+
133
+ export { }