@theaiplatform/miniapp-sdk 0.0.0 → 0.0.2

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/web.d.ts CHANGED
@@ -7,6 +7,8 @@ export declare const app: MiniAppPlatformApi;
7
7
 
8
8
  export declare function applyMiniAppTheme(theme: MiniAppTheme): void;
9
9
 
10
+ export declare function applyMiniAppUiScale(scale: MiniAppUiScale): void;
11
+
10
12
  declare type CreateChannelOptions = {
11
13
  workspaceId?: string;
12
14
  name: string;
@@ -61,6 +63,8 @@ declare type GetChannelTimelineResult = {
61
63
 
62
64
  export declare function getMiniAppThemeFromSearch(search?: string | URLSearchParams): MiniAppTheme;
63
65
 
66
+ export declare function getMiniAppUiScaleFromSearch(search?: string | URLSearchParams): MiniAppUiScale;
67
+
64
68
  /** Returns the public miniapp API proxy, which fails only when it is used. */
65
69
  export declare function getPlatform(): MiniAppPlatform;
66
70
 
@@ -73,6 +77,13 @@ declare type GetProjectResult = {
73
77
  project: MiniAppProject | null;
74
78
  };
75
79
 
80
+ /** Synchronizes both theme and UI scale from the exact parent miniapp host. */
81
+ export declare function installMiniAppAppearanceSync({ applyTheme, applyUiScale, search, }?: InstallMiniAppAppearanceSyncOptions): () => void;
82
+
83
+ export declare type InstallMiniAppAppearanceSyncOptions = InstallMiniAppThemeSyncOptions & {
84
+ applyUiScale?: (scale: MiniAppUiScale) => void;
85
+ };
86
+
76
87
  export declare function installMiniAppThemeSync({ applyTheme, search, }?: InstallMiniAppThemeSyncOptions): () => void;
77
88
 
78
89
  export declare type InstallMiniAppThemeSyncOptions = {
@@ -115,12 +126,18 @@ declare type ListWorkflowsResult = {
115
126
  workflows: MiniAppWorkflow[];
116
127
  };
117
128
 
129
+ export declare const MINIAPP_UI_SCALE_DEFAULT = 16;
130
+
131
+ export declare const MINIAPP_UI_SCALE_MAX = 20;
132
+
133
+ export declare const MINIAPP_UI_SCALE_MIN = 12;
134
+
118
135
  declare type MiniAppAuthApi = {
119
136
  getUserProfile(): MiniAppMaybePromise<MiniAppUserProfile | null>;
120
137
  };
121
138
 
122
139
  /**
123
- * @capability integrations-and-marketplace
140
+ * @capability miniapp-platform
124
141
  */
125
142
  declare type MiniAppChannel = {
126
143
  roomId: string;
@@ -164,6 +181,85 @@ declare type MiniAppCreateSpecialistResult = {
164
181
  isActive: boolean;
165
182
  };
166
183
 
184
+ /** Metadata-only access to host-managed credentials in the active workspace. */
185
+ declare type MiniAppCredentialsApi = {
186
+ listHttp(): MiniAppMaybePromise<MiniAppHttpCredentialMetadata[]>;
187
+ };
188
+
189
+ /** Host-mediated bounded HTTP(S); browser fetch is not the authority. */
190
+ declare type MiniAppHttpApi = {
191
+ request(input: MiniAppHttpRequestInput, options?: MiniAppHttpRequestOptions): MiniAppMaybePromise<MiniAppHttpResponse>;
192
+ };
193
+
194
+ /** Metadata-only stored HTTP credential. Secret fields never cross IPC. */
195
+ declare type MiniAppHttpCredentialMetadata = {
196
+ id: string;
197
+ credentialType: MiniAppHttpCredentialType;
198
+ displayName: string;
199
+ metadataFields: Record<string, string>;
200
+ };
201
+
202
+ declare type MiniAppHttpCredentialType = 'http_bearer' | 'http_basic' | 'http_header_auth' | 'http_api_key';
203
+
204
+ declare type MiniAppHttpHeader = {
205
+ name: string;
206
+ value: string;
207
+ };
208
+
209
+ declare type MiniAppHttpHeaderInput = {
210
+ name: string;
211
+ value: string;
212
+ /** Defaults to true when omitted. */
213
+ enabled?: boolean;
214
+ };
215
+
216
+ declare type MiniAppHttpQueryInput = {
217
+ name: string;
218
+ value: string;
219
+ /** Defaults to true when omitted. */
220
+ enabled?: boolean;
221
+ };
222
+
223
+ declare type MiniAppHttpRequestInput = {
224
+ method: string;
225
+ url: string;
226
+ query?: MiniAppHttpQueryInput[];
227
+ headers?: MiniAppHttpHeaderInput[];
228
+ body?: string | null;
229
+ /** Defaults to 30 seconds and is capped by the host at 120 seconds. */
230
+ timeoutMs?: number | null;
231
+ /** Defaults to 5 MiB and is capped by the host at 10 MiB. */
232
+ responseBodyLimitBytes?: number | null;
233
+ /**
234
+ * Defaults to false. The host follows at most ten same-origin redirects;
235
+ * cross-origin redirects require a separate request and grant.
236
+ */
237
+ followRedirects?: boolean | null;
238
+ };
239
+
240
+ declare type MiniAppHttpRequestOptions = {
241
+ /**
242
+ * Opaque host-managed credential reference. Secret material never enters
243
+ * miniapp JavaScript.
244
+ */
245
+ credentialRef?: string;
246
+ };
247
+
248
+ declare type MiniAppHttpResponse = {
249
+ finalUrl: string;
250
+ status: number;
251
+ statusText: string;
252
+ /** Ordered entries; duplicate response header names remain separate. */
253
+ headers: MiniAppHttpHeader[];
254
+ bodyText: string | null;
255
+ bodyBase64: string | null;
256
+ bodyKind: 'text' | 'binary';
257
+ bodyTruncated: boolean;
258
+ sizeBytes: number;
259
+ elapsedMs: number;
260
+ contentType: string | null;
261
+ };
262
+
167
263
  /** JSON-compatible values accepted by public miniapp operations. */
168
264
  declare type MiniAppJsonValue = null | boolean | number | string | MiniAppJsonValue[] | {
169
265
  [key: string]: MiniAppJsonValue;
@@ -258,6 +354,12 @@ export declare type MiniAppPlatformApi = {
258
354
  open(options: OpenNavigationOptions): void | Promise<void>;
259
355
  };
260
356
  chat: MiniAppChatApi;
357
+ storage: MiniAppStorageApi;
358
+ presence: MiniAppPresenceApi;
359
+ /** Desktop host capability; feature-detect before use on portable targets. */
360
+ http?: MiniAppHttpApi;
361
+ /** Desktop host capability; feature-detect before use on portable targets. */
362
+ credentials?: MiniAppCredentialsApi;
261
363
  /** Browser capabilities appear only when the selected target supports them. */
262
364
  auth?: MiniAppAuthApi;
263
365
  vfs?: MiniAppVfsApi;
@@ -266,6 +368,41 @@ export declare type MiniAppPlatformApi = {
266
368
  hasHostHttpRequest?: boolean;
267
369
  };
268
370
 
371
+ declare type MiniAppPresenceAddress = {
372
+ namespace: string;
373
+ room: string;
374
+ };
375
+
376
+ /**
377
+ * Ephemeral realtime presence scoped by the host to the active workspace and
378
+ * exact package. Participant identity is stamped by the host, not the app.
379
+ */
380
+ declare type MiniAppPresenceApi = {
381
+ join(options: MiniAppPresenceUpdateOptions): MiniAppMaybePromise<MiniAppPresenceSnapshot>;
382
+ update(options: MiniAppPresenceUpdateOptions): MiniAppMaybePromise<MiniAppPresenceSnapshot>;
383
+ leave(options: MiniAppPresenceAddress): MiniAppMaybePromise<void>;
384
+ subscribe(options: MiniAppPresenceAddress, listener: MiniAppPresenceListener): () => void;
385
+ };
386
+
387
+ declare type MiniAppPresenceListener = (snapshot: MiniAppPresenceSnapshot) => void;
388
+
389
+ declare type MiniAppPresenceParticipant = {
390
+ /** Host-derived, ephemeral participant identity. */
391
+ participantId: string;
392
+ displayName: string;
393
+ state: MiniAppJsonValue;
394
+ updatedAtMs: number;
395
+ };
396
+
397
+ declare type MiniAppPresenceSnapshot = MiniAppPresenceAddress & {
398
+ selfParticipantId: string;
399
+ participants: MiniAppPresenceParticipant[];
400
+ };
401
+
402
+ declare type MiniAppPresenceUpdateOptions = MiniAppPresenceAddress & {
403
+ state: MiniAppJsonValue;
404
+ };
405
+
269
406
  declare type MiniAppProject = {
270
407
  id: string;
271
408
  name: string;
@@ -365,8 +502,47 @@ declare type MiniAppSpecialistTurnResult = {
365
502
  };
366
503
  };
367
504
 
505
+ /** Caller-selected partition inside the host-derived workspace/package scope. */
506
+ declare type MiniAppStorageAddress = {
507
+ namespace: string;
508
+ key: string;
509
+ };
510
+
511
+ /**
512
+ * Durable, non-secret JSON storage. The host derives workspace and package
513
+ * identity from the authenticated frame; apps control only the namespace and
514
+ * key inside that scope.
515
+ */
516
+ declare type MiniAppStorageApi = {
517
+ get(options: MiniAppStorageAddress): MiniAppMaybePromise<MiniAppStorageEntry>;
518
+ set(options: MiniAppStorageSetOptions): MiniAppMaybePromise<MiniAppStorageMutationResult>;
519
+ delete(options: MiniAppStorageDeleteOptions): MiniAppMaybePromise<void>;
520
+ };
521
+
522
+ declare type MiniAppStorageDeleteOptions = MiniAppStorageAddress & {
523
+ expectedRevision: number;
524
+ };
525
+
526
+ declare type MiniAppStorageEntry = {
527
+ value: MiniAppJsonValue | null;
528
+ /** Null means that no value currently exists at this address. */
529
+ revision: number | null;
530
+ };
531
+
532
+ declare type MiniAppStorageMutationResult = {
533
+ revision: number;
534
+ };
535
+
536
+ declare type MiniAppStorageSetOptions = MiniAppStorageAddress & {
537
+ value: MiniAppJsonValue;
538
+ /** Optimistic concurrency token returned by `get`; null creates a missing key. */
539
+ expectedRevision: number | null;
540
+ };
541
+
368
542
  export declare type MiniAppTheme = 'light' | 'dark';
369
543
 
544
+ export declare type MiniAppUiScale = number;
545
+
370
546
  declare type MiniAppUserProfile = {
371
547
  sub: string;
372
548
  name?: string | null;
package/dist/web.js CHANGED
@@ -101,10 +101,14 @@ async function openEditorProject(options) {
101
101
  if ("u" < typeof window) throw new Error('The miniapp host is unavailable.');
102
102
  await requestHostAction(OPEN_EDITOR_PROJECT_ACTION, options);
103
103
  }
104
+ const MINIAPP_UI_SCALE_MIN = 12;
105
+ const MINIAPP_UI_SCALE_MAX = 20;
106
+ const MINIAPP_UI_SCALE_DEFAULT = 16;
104
107
  const MINIAPP_THEME_CHANGED_EVENTS = new Set([
105
108
  'zephyr-app-theme-changed',
106
109
  'tap-miniapp-theme-changed'
107
110
  ]);
111
+ const MINIAPP_UI_SCALE_CHANGED_EVENT = 'zephyr-app-ui-scale-changed';
108
112
  function isMiniAppTheme(value) {
109
113
  return 'light' === value || 'dark' === value;
110
114
  }
@@ -123,6 +127,21 @@ function applyMiniAppTheme(theme) {
123
127
  document.documentElement.classList.toggle('light', 'light' === theme);
124
128
  document.documentElement.style.colorScheme = theme;
125
129
  }
130
+ function isMiniAppUiScale(value) {
131
+ return 'number' == typeof value && Number.isInteger(value) && value >= MINIAPP_UI_SCALE_MIN && value <= MINIAPP_UI_SCALE_MAX;
132
+ }
133
+ function getMiniAppUiScaleFromSearch(search = "u" < typeof window ? '' : window.location.search) {
134
+ const params = 'string' == typeof search ? new URLSearchParams(search.startsWith('?') ? search.slice(1) : search) : search;
135
+ const rawScale = params.get('appUiScale');
136
+ if (null === rawScale || '' === rawScale.trim()) return MINIAPP_UI_SCALE_DEFAULT;
137
+ const scale = Number(rawScale);
138
+ return isMiniAppUiScale(scale) ? scale : MINIAPP_UI_SCALE_DEFAULT;
139
+ }
140
+ function applyMiniAppUiScale(scale) {
141
+ if ("u" < typeof document || !isMiniAppUiScale(scale)) return;
142
+ document.documentElement.dataset.uiScale = String(scale);
143
+ document.documentElement.style.setProperty('--app-font-size', `${scale}px`);
144
+ }
126
145
  function installMiniAppThemeSync({ applyTheme = applyMiniAppTheme, search } = {}) {
127
146
  applyTheme(getMiniAppThemeFromSearch(search));
128
147
  if ("u" < typeof window) return ()=>void 0;
@@ -142,5 +161,22 @@ function installMiniAppThemeSync({ applyTheme = applyMiniAppTheme, search } = {}
142
161
  window.removeEventListener('message', handleMessage);
143
162
  };
144
163
  }
164
+ function installMiniAppAppearanceSync({ applyTheme = applyMiniAppTheme, applyUiScale = applyMiniAppUiScale, search } = {}) {
165
+ applyTheme(getMiniAppThemeFromSearch(search));
166
+ applyUiScale(getMiniAppUiScaleFromSearch(search));
167
+ if ("u" < typeof window) return ()=>void 0;
168
+ const hostOrigin = getHostOrigin();
169
+ const parent = window.parent;
170
+ if (!hostOrigin || !parent || parent === window) return ()=>void 0;
171
+ const handleMessage = (event)=>{
172
+ if (event.source !== parent || event.origin !== hostOrigin) return;
173
+ if ('object' != typeof event.data || null === event.data) return;
174
+ const record = event.data;
175
+ if ('string' == typeof record.type && MINIAPP_THEME_CHANGED_EVENTS.has(record.type) && isMiniAppTheme(record.appTheme)) return void applyTheme(record.appTheme);
176
+ if (record.type === MINIAPP_UI_SCALE_CHANGED_EVENT && isMiniAppUiScale(record.appUiScale)) applyUiScale(record.appUiScale);
177
+ };
178
+ window.addEventListener('message', handleMessage);
179
+ return ()=>window.removeEventListener('message', handleMessage);
180
+ }
145
181
  export { sdk as app } from "./sdk.js";
146
- export { applyMiniAppTheme, getMiniAppThemeFromSearch, getPlatform, installMiniAppThemeSync, openEditorProject, platformSatisfiesApp };
182
+ export { MINIAPP_UI_SCALE_DEFAULT, MINIAPP_UI_SCALE_MAX, MINIAPP_UI_SCALE_MIN, applyMiniAppTheme, applyMiniAppUiScale, getMiniAppThemeFromSearch, getMiniAppUiScaleFromSearch, getPlatform, installMiniAppAppearanceSync, installMiniAppThemeSync, openEditorProject, platformSatisfiesApp };
@@ -0,0 +1,248 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "bumpalo"
7
+ version = "3.20.3"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
10
+
11
+ [[package]]
12
+ name = "cfg-if"
13
+ version = "1.0.4"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
16
+
17
+ [[package]]
18
+ name = "futures-core"
19
+ version = "0.3.33"
20
+ source = "registry+https://github.com/rust-lang/crates.io-index"
21
+ checksum = "2cd50c473c80f6d7c3670a752354b8e569b1a7cbfdc0419ec88e5edad85e0dc7"
22
+
23
+ [[package]]
24
+ name = "futures-task"
25
+ version = "0.3.33"
26
+ source = "registry+https://github.com/rust-lang/crates.io-index"
27
+ checksum = "b231ed28831efb4a61a08580c4bc233ec56bc009f4cd8f52da2c3cb97df0c109"
28
+
29
+ [[package]]
30
+ name = "futures-util"
31
+ version = "0.3.33"
32
+ source = "registry+https://github.com/rust-lang/crates.io-index"
33
+ checksum = "a77a90a256fce34da66415271e30f94ee91c57b04b8a2c042d9cf3220179deaa"
34
+ dependencies = [
35
+ "futures-core",
36
+ "futures-task",
37
+ "pin-project-lite",
38
+ "slab",
39
+ ]
40
+
41
+ [[package]]
42
+ name = "itoa"
43
+ version = "1.0.18"
44
+ source = "registry+https://github.com/rust-lang/crates.io-index"
45
+ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
46
+
47
+ [[package]]
48
+ name = "js-sys"
49
+ version = "0.3.103"
50
+ source = "registry+https://github.com/rust-lang/crates.io-index"
51
+ checksum = "53b44bfcdb3f8d5837a46dae1ca9660a837176eee74a28b229bc626816589102"
52
+ dependencies = [
53
+ "cfg-if",
54
+ "futures-util",
55
+ "wasm-bindgen",
56
+ ]
57
+
58
+ [[package]]
59
+ name = "memchr"
60
+ version = "2.8.3"
61
+ source = "registry+https://github.com/rust-lang/crates.io-index"
62
+ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
63
+
64
+ [[package]]
65
+ name = "miniapp-sdk-wasm-ui-example"
66
+ version = "0.1.0"
67
+ dependencies = [
68
+ "js-sys",
69
+ "serde",
70
+ "serde-wasm-bindgen",
71
+ "serde_json",
72
+ "wasm-bindgen",
73
+ "web-sys",
74
+ ]
75
+
76
+ [[package]]
77
+ name = "once_cell"
78
+ version = "1.21.4"
79
+ source = "registry+https://github.com/rust-lang/crates.io-index"
80
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
81
+
82
+ [[package]]
83
+ name = "pin-project-lite"
84
+ version = "0.2.17"
85
+ source = "registry+https://github.com/rust-lang/crates.io-index"
86
+ checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
87
+
88
+ [[package]]
89
+ name = "proc-macro2"
90
+ version = "1.0.106"
91
+ source = "registry+https://github.com/rust-lang/crates.io-index"
92
+ checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
93
+ dependencies = [
94
+ "unicode-ident",
95
+ ]
96
+
97
+ [[package]]
98
+ name = "quote"
99
+ version = "1.0.46"
100
+ source = "registry+https://github.com/rust-lang/crates.io-index"
101
+ checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368"
102
+ dependencies = [
103
+ "proc-macro2",
104
+ ]
105
+
106
+ [[package]]
107
+ name = "rustversion"
108
+ version = "1.0.23"
109
+ source = "registry+https://github.com/rust-lang/crates.io-index"
110
+ checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
111
+
112
+ [[package]]
113
+ name = "serde"
114
+ version = "1.0.228"
115
+ source = "registry+https://github.com/rust-lang/crates.io-index"
116
+ checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
117
+ dependencies = [
118
+ "serde_core",
119
+ "serde_derive",
120
+ ]
121
+
122
+ [[package]]
123
+ name = "serde-wasm-bindgen"
124
+ version = "0.6.5"
125
+ source = "registry+https://github.com/rust-lang/crates.io-index"
126
+ checksum = "8302e169f0eddcc139c70f139d19d6467353af16f9fce27e8c30158036a1e16b"
127
+ dependencies = [
128
+ "js-sys",
129
+ "serde",
130
+ "wasm-bindgen",
131
+ ]
132
+
133
+ [[package]]
134
+ name = "serde_core"
135
+ version = "1.0.228"
136
+ source = "registry+https://github.com/rust-lang/crates.io-index"
137
+ checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
138
+ dependencies = [
139
+ "serde_derive",
140
+ ]
141
+
142
+ [[package]]
143
+ name = "serde_derive"
144
+ version = "1.0.228"
145
+ source = "registry+https://github.com/rust-lang/crates.io-index"
146
+ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
147
+ dependencies = [
148
+ "proc-macro2",
149
+ "quote",
150
+ "syn",
151
+ ]
152
+
153
+ [[package]]
154
+ name = "serde_json"
155
+ version = "1.0.150"
156
+ source = "registry+https://github.com/rust-lang/crates.io-index"
157
+ checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9"
158
+ dependencies = [
159
+ "itoa",
160
+ "memchr",
161
+ "serde",
162
+ "serde_core",
163
+ "zmij",
164
+ ]
165
+
166
+ [[package]]
167
+ name = "slab"
168
+ version = "0.4.12"
169
+ source = "registry+https://github.com/rust-lang/crates.io-index"
170
+ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
171
+
172
+ [[package]]
173
+ name = "syn"
174
+ version = "2.0.119"
175
+ source = "registry+https://github.com/rust-lang/crates.io-index"
176
+ checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
177
+ dependencies = [
178
+ "proc-macro2",
179
+ "quote",
180
+ "unicode-ident",
181
+ ]
182
+
183
+ [[package]]
184
+ name = "unicode-ident"
185
+ version = "1.0.24"
186
+ source = "registry+https://github.com/rust-lang/crates.io-index"
187
+ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
188
+
189
+ [[package]]
190
+ name = "wasm-bindgen"
191
+ version = "0.2.126"
192
+ source = "registry+https://github.com/rust-lang/crates.io-index"
193
+ checksum = "4b067c0c11094aef6b7a801c1e34a26affafdf3d051dba08456b868789aaf9a4"
194
+ dependencies = [
195
+ "cfg-if",
196
+ "once_cell",
197
+ "rustversion",
198
+ "wasm-bindgen-macro",
199
+ "wasm-bindgen-shared",
200
+ ]
201
+
202
+ [[package]]
203
+ name = "wasm-bindgen-macro"
204
+ version = "0.2.126"
205
+ source = "registry+https://github.com/rust-lang/crates.io-index"
206
+ checksum = "167ce5e579f6bcf889c4f7175a8a5a585de84e8ff93976ce393efa5f2837aab1"
207
+ dependencies = [
208
+ "quote",
209
+ "wasm-bindgen-macro-support",
210
+ ]
211
+
212
+ [[package]]
213
+ name = "wasm-bindgen-macro-support"
214
+ version = "0.2.126"
215
+ source = "registry+https://github.com/rust-lang/crates.io-index"
216
+ checksum = "f3997c7839262f4ef12cf90b818d6340c18e80f263f1a94bf157d0ec4420380e"
217
+ dependencies = [
218
+ "bumpalo",
219
+ "proc-macro2",
220
+ "quote",
221
+ "syn",
222
+ "wasm-bindgen-shared",
223
+ ]
224
+
225
+ [[package]]
226
+ name = "wasm-bindgen-shared"
227
+ version = "0.2.126"
228
+ source = "registry+https://github.com/rust-lang/crates.io-index"
229
+ checksum = "dc1b4cb0cc549fcf58d7dfc081778139b3d283a081644e833e84682ad71cea24"
230
+ dependencies = [
231
+ "unicode-ident",
232
+ ]
233
+
234
+ [[package]]
235
+ name = "web-sys"
236
+ version = "0.3.103"
237
+ source = "registry+https://github.com/rust-lang/crates.io-index"
238
+ checksum = "8622dcb61c0bcc9fffa6938bed81210af2da9a7e4a1a834b2e37a59b6dfb6141"
239
+ dependencies = [
240
+ "js-sys",
241
+ "wasm-bindgen",
242
+ ]
243
+
244
+ [[package]]
245
+ name = "zmij"
246
+ version = "1.0.23"
247
+ source = "registry+https://github.com/rust-lang/crates.io-index"
248
+ checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
@@ -0,0 +1,18 @@
1
+ [package]
2
+ name = "miniapp-sdk-wasm-ui-example"
3
+ version = "0.1.0"
4
+ edition = "2024"
5
+ publish = false
6
+
7
+ [lib]
8
+ crate-type = ["cdylib", "rlib"]
9
+
10
+ [dependencies]
11
+ js-sys = "0.3.98"
12
+ serde = { version = "1.0.228", features = ["derive"] }
13
+ serde-wasm-bindgen = "0.6.5"
14
+ serde_json = "1.0.149"
15
+ wasm-bindgen = "0.2.121"
16
+ web-sys = { version = "0.3.98", features = ["Element"] }
17
+
18
+ [workspace]
@@ -0,0 +1,19 @@
1
+ # Rust/WASM UI example
2
+
3
+ This crate is a clean wasm-bindgen consumer of
4
+ `@theaiplatform/miniapp-sdk/ui/wasm`. It demonstrates the full lifecycle:
5
+ mount, controlled revision updates, focus, action validation, replay/stale
6
+ rejection, and idempotent teardown.
7
+
8
+ Build it with:
9
+
10
+ ```bash
11
+ cargo check --target wasm32-unknown-unknown
12
+ ```
13
+
14
+ The JavaScript application that loads the generated wasm must import the SDK
15
+ styles once:
16
+
17
+ ```ts
18
+ import '@theaiplatform/miniapp-sdk/ui/styles.css';
19
+ ```