@theaiplatform/miniapp-sdk 0.3.2 → 0.4.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.
@@ -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,147 @@
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
+ * Host-owned entropy for release-scoped identifiers.
15
+ *
16
+ * Ordinary TAP surfaces use the browser's cryptographically strong UUID
17
+ * source. Test Lab mounts derive a deterministic stream from the selected
18
+ * profile seed and exact frame identity, then reset it before each mount so
19
+ * app-owned state is reproducible without weakening production identifiers,
20
+ * colliding across retained remounts, or relying on ambient test globals.
21
+ */
22
+ declare interface TapFederatedSurfaceEntropy {
23
+ randomUUID(): string;
24
+ }
25
+
26
+ /**
27
+ * Read-only authority projected by TAP for the exact package release/frame.
28
+ * A candidate frame starts without authority and may only perform host-backed
29
+ * work after the host confirms that release. Subscribers are notified only
30
+ * when the boolean snapshot changes.
31
+ */
32
+ declare interface TapFederatedSurfaceHostAuthority {
33
+ getSnapshot(): boolean;
34
+ subscribe(listener: () => void): () => void;
35
+ }
36
+
37
+ /** Cleanup handle returned by a federated surface mount. */
38
+ declare interface TapFederatedSurfaceMount {
39
+ unmount(): void | Promise<void>;
40
+ }
41
+
42
+ /** Context supplied by TAP's isolated webview surface runtime. */
43
+ declare interface TapFederatedSurfaceMountContext {
44
+ readonly packageId: string;
45
+ readonly packageNamespace: string;
46
+ readonly releaseId: string;
47
+ readonly installationId: string;
48
+ readonly contributionId: string;
49
+ readonly instanceId: string;
50
+ readonly hostOrigin: string;
51
+ readonly packageAssetBaseUrl: string;
52
+ readonly workspaceId?: string;
53
+ readonly channelId?: string;
54
+ readonly conversationId?: string;
55
+ readonly events: TapPackageEventPublisher;
56
+ readonly entropy: TapFederatedSurfaceEntropy;
57
+ readonly hostAuthority: TapFederatedSurfaceHostAuthority;
58
+ }
59
+
60
+ /**
61
+ * @capability miniapp-platform
62
+ */
63
+ /** Declared package-event channel supplied to an isolated UI contribution. */
64
+ declare interface TapPackageEventPublisher {
65
+ publish(name: string, payload: Readonly<Record<string, unknown>>): void | Promise<void>;
66
+ subscribe(name: string, listener: (payload: unknown, envelope: Readonly<Record<string, unknown>>) => void | Promise<void>): () => void;
67
+ }
68
+
69
+ export declare interface TapVsCodeWebviewBootstrapBinding {
70
+ /** Path to read in the stored JSON value. */
71
+ statePath: readonly string[];
72
+ /** Path to update in the bootstrap JSON value. */
73
+ bootstrapPath: readonly string[];
74
+ transform?: Exclude<TapVsCodeWebviewValueTransform, 'byte-array-to-base64'>;
75
+ }
76
+
77
+ export declare interface TapVsCodeWebviewBootstrapOptions {
78
+ selector: string;
79
+ attribute: string;
80
+ encoding: 'base64-json';
81
+ value: MiniAppJsonValue;
82
+ }
83
+
84
+ export declare interface TapVsCodeWebviewBridgeOptions {
85
+ title: string;
86
+ entryPath: string;
87
+ /** Browser runtime emitted from `tapVsCodeWebviewRuntimeSource`. */
88
+ runtimePath: string;
89
+ bootstrap?: TapVsCodeWebviewBootstrapOptions;
90
+ storage?: TapVsCodeWebviewStorageOptions;
91
+ session?: TapVsCodeWebviewSessionOptions;
92
+ network?: TapVsCodeWebviewNetworkOptions;
93
+ onMessage?: (message: unknown) => void | Promise<void>;
94
+ onError?: (error: Error) => void;
95
+ }
96
+
97
+ export declare interface TapVsCodeWebviewMessageBinding {
98
+ /** Exact value of the message discriminator (normally `message.type`). */
99
+ messageType: string;
100
+ /** Path to the value in the webview message. */
101
+ messageValuePath: readonly string[];
102
+ /** Path to update in the JSON value stored by `sdk.storage`. */
103
+ statePath: readonly string[];
104
+ transform?: Exclude<TapVsCodeWebviewValueTransform, 'base64-to-byte-array'>;
105
+ }
106
+
107
+ export declare interface TapVsCodeWebviewMount extends TapFederatedSurfaceMount {
108
+ postMessage(message: unknown): void;
109
+ }
110
+
111
+ export declare interface TapVsCodeWebviewNetworkOptions {
112
+ /** Exact HTTPS origins approved by the conversion recipe. */
113
+ allowedOrigins: readonly string[];
114
+ }
115
+
116
+ /**
117
+ * Self-contained browser runtime written next to a converted webview by the
118
+ * conversion CLI. Keeping this byte string in the SDK prevents generated
119
+ * adapters from growing a second, incompatible bridge implementation.
120
+ */
121
+ export declare const tapVsCodeWebviewRuntimeSource: string;
122
+
123
+ export declare interface TapVsCodeWebviewSessionOptions {
124
+ /**
125
+ * Field inside the installation-scoped `sdk.session` object. The iframe gets
126
+ * a synchronous in-memory localStorage facade backed by this field.
127
+ */
128
+ namespace: string;
129
+ }
130
+
131
+ export declare interface TapVsCodeWebviewStorageOptions {
132
+ namespace: string;
133
+ key: string;
134
+ initialValue: MiniAppJsonValue;
135
+ messageTypePath?: readonly string[];
136
+ messageBindings?: readonly TapVsCodeWebviewMessageBinding[];
137
+ bootstrapBindings?: readonly TapVsCodeWebviewBootstrapBinding[];
138
+ /**
139
+ * Optional path used for the synchronous `acquireVsCodeApi().getState()` and
140
+ * `setState()` compatibility value.
141
+ */
142
+ vscodeStatePath?: readonly string[];
143
+ }
144
+
145
+ export declare type TapVsCodeWebviewValueTransform = 'identity' | 'byte-array-to-base64' | 'base64-to-byte-array';
146
+
147
+ export { }