@alien_org/contract 1.1.0-alpha → 1.3.0-alpha
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/README.md +46 -14
- package/dist/index.cjs +27 -4
- package/dist/index.d.cts +38 -74
- package/dist/index.d.mts +38 -74
- package/dist/index.mjs +27 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@ import type {
|
|
|
33
33
|
// Launch parameters
|
|
34
34
|
LaunchParams, // Host-injected params (authToken, contractVersion, etc.)
|
|
35
35
|
Platform, // 'ios' | 'android'
|
|
36
|
+
DisplayMode, // 'standard' | 'fullscreen' | 'immersive'
|
|
36
37
|
|
|
37
38
|
// Utilities
|
|
38
39
|
Version, // Semantic version string type
|
|
@@ -42,10 +43,11 @@ import type {
|
|
|
42
43
|
### Constants
|
|
43
44
|
|
|
44
45
|
```typescript
|
|
45
|
-
import { PLATFORMS, releases } from '@alien_org/contract';
|
|
46
|
+
import { DISPLAY_MODES, PLATFORMS, releases } from '@alien_org/contract';
|
|
46
47
|
|
|
47
|
-
PLATFORMS
|
|
48
|
-
|
|
48
|
+
PLATFORMS // ['ios', 'android']
|
|
49
|
+
DISPLAY_MODES // ['standard', 'fullscreen', 'immersive']
|
|
50
|
+
releases // Record<Version, MethodName[]> - version to methods mapping
|
|
49
51
|
```
|
|
50
52
|
|
|
51
53
|
### Version Utilities
|
|
@@ -63,7 +65,7 @@ isMethodSupported('payment:request', '0.0.9'); // false
|
|
|
63
65
|
|
|
64
66
|
// Get minimum version that supports a method
|
|
65
67
|
getMethodMinVersion('app:ready'); // '0.0.9'
|
|
66
|
-
getMethodMinVersion('payment:request'); // '0.
|
|
68
|
+
getMethodMinVersion('payment:request'); // '0.1.1'
|
|
67
69
|
|
|
68
70
|
// Get version where a method was introduced
|
|
69
71
|
getReleaseVersion('app:ready'); // '0.0.9'
|
|
@@ -74,17 +76,33 @@ getReleaseVersion('app:ready'); // '0.0.9'
|
|
|
74
76
|
| Method | Since | Description |
|
|
75
77
|
|--------|-------|-------------|
|
|
76
78
|
| `app:ready` | 0.0.9 | Notify host that miniapp is ready |
|
|
77
|
-
| `
|
|
78
|
-
| `
|
|
79
|
-
| `
|
|
79
|
+
| `payment:request` | 0.1.1 | Request payment |
|
|
80
|
+
| `clipboard:write` | 0.1.1 | Write text to clipboard |
|
|
81
|
+
| `clipboard:read` | 0.1.1 | Read text from clipboard |
|
|
82
|
+
| `link:open` | 0.1.3 | Open a URL |
|
|
83
|
+
| `haptic:impact` | 0.2.4 | Trigger haptic impact feedback |
|
|
84
|
+
| `haptic:notification` | 0.2.4 | Trigger haptic notification feedback |
|
|
85
|
+
| `haptic:selection` | 0.2.4 | Trigger haptic selection feedback |
|
|
86
|
+
| `wallet.solana:connect` | 1.0.0 | Request Solana wallet connection |
|
|
87
|
+
| `wallet.solana:disconnect` | 1.0.0 | Disconnect from Solana wallet |
|
|
88
|
+
| `wallet.solana:sign.transaction` | 1.0.0 | Sign a Solana transaction |
|
|
89
|
+
| `wallet.solana:sign.message` | 1.0.0 | Sign a Solana message |
|
|
90
|
+
| `wallet.solana:sign.send` | 1.0.0 | Sign and send a Solana transaction |
|
|
91
|
+
| `app:close` | 1.0.0 | Request host to close the miniapp |
|
|
92
|
+
| `host.back.button:toggle` | 1.0.0 | Show/hide back button |
|
|
80
93
|
|
|
81
94
|
## Available Events
|
|
82
95
|
|
|
83
96
|
| Event | Since | Description |
|
|
84
97
|
|-------|-------|-------------|
|
|
85
98
|
| `miniapp:close` | 0.0.14 | Host is closing miniapp |
|
|
86
|
-
| `host.back.button:clicked` | 0.0
|
|
87
|
-
| `payment:response` | 0.
|
|
99
|
+
| `host.back.button:clicked` | 1.0.0 | Back button was clicked |
|
|
100
|
+
| `payment:response` | 0.1.1 | Payment result |
|
|
101
|
+
| `clipboard:response` | 0.1.1 | Clipboard read result |
|
|
102
|
+
| `wallet.solana:connect.response` | 1.0.0 | Wallet connection result |
|
|
103
|
+
| `wallet.solana:sign.transaction.response` | 1.0.0 | Transaction signing result |
|
|
104
|
+
| `wallet.solana:sign.message.response` | 1.0.0 | Message signing result |
|
|
105
|
+
| `wallet.solana:sign.send.response` | 1.0.0 | Sign and send result |
|
|
88
106
|
|
|
89
107
|
## LaunchParams
|
|
90
108
|
|
|
@@ -92,14 +110,28 @@ Parameters injected by the host app:
|
|
|
92
110
|
|
|
93
111
|
```typescript
|
|
94
112
|
interface LaunchParams {
|
|
95
|
-
authToken: string | undefined;
|
|
96
|
-
contractVersion: Version | undefined;
|
|
97
|
-
hostAppVersion: string | undefined;
|
|
98
|
-
platform: Platform | undefined;
|
|
99
|
-
|
|
113
|
+
authToken: string | undefined; // JWT auth token
|
|
114
|
+
contractVersion: Version | undefined; // Host's contract version
|
|
115
|
+
hostAppVersion: string | undefined; // Host app version
|
|
116
|
+
platform: Platform | undefined; // 'ios' | 'android'
|
|
117
|
+
safeAreaInsets: SafeAreaInsets | undefined; // System UI insets (CSS px)
|
|
118
|
+
startParam: string | undefined; // Custom param (referrals, etc.)
|
|
119
|
+
displayMode: DisplayMode; // 'standard' | 'fullscreen' | 'immersive'
|
|
100
120
|
}
|
|
101
121
|
```
|
|
102
122
|
|
|
123
|
+
### DisplayMode
|
|
124
|
+
|
|
125
|
+
Controls how the host app renders the miniapp webview.
|
|
126
|
+
|
|
127
|
+
| Mode | Header | Close / Options | WebView area | Use case |
|
|
128
|
+
| ---- | ------ | --------------- | ------------ | -------- |
|
|
129
|
+
| `standard` | Visible (title, close, options) | In header | Below header | Default for most miniapps |
|
|
130
|
+
| `fullscreen` | Hidden | Floating overlay | Entire screen | Games, media, maps |
|
|
131
|
+
| `immersive` | Hidden | **None** | Entire screen | Custom UIs that provide their own exit (must call `app:close`) |
|
|
132
|
+
|
|
133
|
+
In all modes the miniapp receives `safeAreaInsets` and should respect them for system UI (status bar, notch, home indicator).
|
|
134
|
+
|
|
103
135
|
## Adding New Methods/Events
|
|
104
136
|
|
|
105
137
|
1. Define in `src/methods/definitions/methods.ts` or `src/events/definitions/events.ts`
|
package/dist/index.cjs
CHANGED
|
@@ -4,12 +4,33 @@
|
|
|
4
4
|
* Supported platforms for miniapps.
|
|
5
5
|
*/
|
|
6
6
|
const PLATFORMS = ["ios", "android"];
|
|
7
|
+
/**
|
|
8
|
+
* Supported display modes for miniapps.
|
|
9
|
+
*
|
|
10
|
+
* - `standard` — Default. Native header with close button, options menu, and
|
|
11
|
+
* miniapp title is visible. WebView is inset below the header. Safe area
|
|
12
|
+
* insets account for the header height.
|
|
13
|
+
*
|
|
14
|
+
* - `fullscreen` — WebView occupies the entire screen. The native close button
|
|
15
|
+
* and options menu remain as floating overlays so the user can always exit.
|
|
16
|
+
* The miniapp must respect safe area insets for system UI (status bar, notch,
|
|
17
|
+
* home indicator).
|
|
18
|
+
*
|
|
19
|
+
* - `immersive` — WebView occupies the entire screen with zero native UI.
|
|
20
|
+
* No close button, no options menu, no header — the miniapp owns the full
|
|
21
|
+
* viewport. The miniapp is responsible for providing its own exit mechanism
|
|
22
|
+
* (e.g. calling `app:close`). Safe area insets still apply for system UI.
|
|
23
|
+
*/
|
|
24
|
+
const DISPLAY_MODES = [
|
|
25
|
+
"standard",
|
|
26
|
+
"fullscreen",
|
|
27
|
+
"immersive"
|
|
28
|
+
];
|
|
7
29
|
|
|
8
30
|
//#endregion
|
|
9
31
|
//#region src/methods/versions/releases.ts
|
|
10
32
|
const releases = {
|
|
11
33
|
"0.0.9": ["app:ready"],
|
|
12
|
-
"0.0.14": ["miniapp:close.ack", "host.back.button:toggle"],
|
|
13
34
|
"0.1.1": [
|
|
14
35
|
"payment:request",
|
|
15
36
|
"clipboard:write",
|
|
@@ -26,9 +47,10 @@ const releases = {
|
|
|
26
47
|
"wallet.solana:disconnect",
|
|
27
48
|
"wallet.solana:sign.transaction",
|
|
28
49
|
"wallet.solana:sign.message",
|
|
29
|
-
"wallet.solana:sign.send"
|
|
30
|
-
|
|
31
|
-
|
|
50
|
+
"wallet.solana:sign.send",
|
|
51
|
+
"app:close",
|
|
52
|
+
"host.back.button:toggle"
|
|
53
|
+
]
|
|
32
54
|
};
|
|
33
55
|
|
|
34
56
|
//#endregion
|
|
@@ -115,6 +137,7 @@ const WALLET_ERROR = {
|
|
|
115
137
|
};
|
|
116
138
|
|
|
117
139
|
//#endregion
|
|
140
|
+
exports.DISPLAY_MODES = DISPLAY_MODES;
|
|
118
141
|
exports.PLATFORMS = PLATFORMS;
|
|
119
142
|
exports.WALLET_ERROR = WALLET_ERROR;
|
|
120
143
|
exports.getMethodMinVersion = getMethodMinVersion;
|
package/dist/index.d.cts
CHANGED
|
@@ -87,14 +87,6 @@ type PaymentWebhookStatus = 'finalized' | 'failed';
|
|
|
87
87
|
* @schema
|
|
88
88
|
*/
|
|
89
89
|
type PaymentTestScenario = 'paid' | 'paid:failed' | 'cancelled' | `error:${PaymentErrorCode}`;
|
|
90
|
-
/**
|
|
91
|
-
* Fullscreen error codes.
|
|
92
|
-
* Returned in `fullscreen:failed` event when fullscreen request fails.
|
|
93
|
-
* - `ALREADY_FULLSCREEN`: Miniapp is already in fullscreen mode
|
|
94
|
-
* @since 1.1.0
|
|
95
|
-
* @schema
|
|
96
|
-
*/
|
|
97
|
-
type FullscreenErrorCode = 'ALREADY_FULLSCREEN';
|
|
98
90
|
/**
|
|
99
91
|
* Haptic impact feedback styles.
|
|
100
92
|
* Maps to UIImpactFeedbackGenerator styles on iOS
|
|
@@ -190,7 +182,7 @@ interface Events {
|
|
|
190
182
|
'miniapp:close': CreateEventPayload<Empty>;
|
|
191
183
|
/**
|
|
192
184
|
* Host app's back button clicked event.
|
|
193
|
-
* @since 0.0
|
|
185
|
+
* @since 1.0.0
|
|
194
186
|
* @schema
|
|
195
187
|
*/
|
|
196
188
|
'host.back.button:clicked': CreateEventPayload<Empty>;
|
|
@@ -259,35 +251,6 @@ interface Events {
|
|
|
259
251
|
*/
|
|
260
252
|
errorCode?: 'permission_denied' | 'unavailable';
|
|
261
253
|
}>>;
|
|
262
|
-
/**
|
|
263
|
-
* Fullscreen state changed, fired by the host app
|
|
264
|
-
* after `fullscreen:request` or `fullscreen:exit`.
|
|
265
|
-
* @since 1.1.0
|
|
266
|
-
* @schema
|
|
267
|
-
*/
|
|
268
|
-
'fullscreen:changed': CreateEventPayload<{
|
|
269
|
-
/**
|
|
270
|
-
* Whether the miniapp is currently in fullscreen mode.
|
|
271
|
-
* @since 1.1.0
|
|
272
|
-
* @schema
|
|
273
|
-
*/
|
|
274
|
-
isFullscreen: boolean;
|
|
275
|
-
}>;
|
|
276
|
-
/**
|
|
277
|
-
* Fullscreen request failed.
|
|
278
|
-
* Fired by the host app when `fullscreen:request` cannot be fulfilled
|
|
279
|
-
* (e.g., the miniapp is already in fullscreen mode).
|
|
280
|
-
* @since 1.1.0
|
|
281
|
-
* @schema
|
|
282
|
-
*/
|
|
283
|
-
'fullscreen:failed': CreateEventPayload<{
|
|
284
|
-
/**
|
|
285
|
-
* Error code indicating why the fullscreen request failed.
|
|
286
|
-
* @since 1.1.0
|
|
287
|
-
* @schema
|
|
288
|
-
*/
|
|
289
|
-
error: FullscreenErrorCode;
|
|
290
|
-
}>;
|
|
291
254
|
/**
|
|
292
255
|
* Solana wallet connection response.
|
|
293
256
|
* @since 1.0.0
|
|
@@ -357,6 +320,28 @@ declare const PLATFORMS: readonly ["ios", "android"];
|
|
|
357
320
|
* Platform the miniapp is running on.
|
|
358
321
|
*/
|
|
359
322
|
type Platform = (typeof PLATFORMS)[number];
|
|
323
|
+
/**
|
|
324
|
+
* Supported display modes for miniapps.
|
|
325
|
+
*
|
|
326
|
+
* - `standard` — Default. Native header with close button, options menu, and
|
|
327
|
+
* miniapp title is visible. WebView is inset below the header. Safe area
|
|
328
|
+
* insets account for the header height.
|
|
329
|
+
*
|
|
330
|
+
* - `fullscreen` — WebView occupies the entire screen. The native close button
|
|
331
|
+
* and options menu remain as floating overlays so the user can always exit.
|
|
332
|
+
* The miniapp must respect safe area insets for system UI (status bar, notch,
|
|
333
|
+
* home indicator).
|
|
334
|
+
*
|
|
335
|
+
* - `immersive` — WebView occupies the entire screen with zero native UI.
|
|
336
|
+
* No close button, no options menu, no header — the miniapp owns the full
|
|
337
|
+
* viewport. The miniapp is responsible for providing its own exit mechanism
|
|
338
|
+
* (e.g. calling `app:close`). Safe area insets still apply for system UI.
|
|
339
|
+
*/
|
|
340
|
+
declare const DISPLAY_MODES: readonly ["standard", "fullscreen", "immersive"];
|
|
341
|
+
/**
|
|
342
|
+
* Display mode for the miniapp webview.
|
|
343
|
+
*/
|
|
344
|
+
type DisplayMode = (typeof DISPLAY_MODES)[number];
|
|
360
345
|
/**
|
|
361
346
|
* Safe area insets in CSS pixels, injected by the host app.
|
|
362
347
|
* Accounts for system UI (status bar, notch, home indicator, nav bar).
|
|
@@ -387,10 +372,11 @@ interface LaunchParams {
|
|
|
387
372
|
*/
|
|
388
373
|
startParam: string | undefined;
|
|
389
374
|
/**
|
|
390
|
-
*
|
|
391
|
-
*
|
|
375
|
+
* Display mode for the miniapp webview.
|
|
376
|
+
* Defaults to `'standard'` when not provided by the host app.
|
|
377
|
+
* @since 1.0.0
|
|
392
378
|
*/
|
|
393
|
-
|
|
379
|
+
displayMode: DisplayMode;
|
|
394
380
|
}
|
|
395
381
|
//#endregion
|
|
396
382
|
//#region src/methods/types/payload.d.ts
|
|
@@ -411,27 +397,27 @@ interface Methods {
|
|
|
411
397
|
/**
|
|
412
398
|
* Miniapp ready method.
|
|
413
399
|
* Sent by the miniapp to notify the host app that it has loaded and is ready to be displayed.
|
|
414
|
-
* @since 0.0.
|
|
400
|
+
* @since 0.0.9
|
|
415
401
|
* @schema
|
|
416
402
|
*/
|
|
417
403
|
'app:ready': CreateMethodPayload<Empty>;
|
|
418
404
|
/**
|
|
419
|
-
*
|
|
420
|
-
* Sent by the miniapp to
|
|
421
|
-
*
|
|
422
|
-
* @since 0.0
|
|
405
|
+
* Close the miniapp.
|
|
406
|
+
* Sent by the miniapp to request the host app to close it.
|
|
407
|
+
* Fire-and-forget — no response expected.
|
|
408
|
+
* @since 1.0.0
|
|
423
409
|
* @schema
|
|
424
410
|
*/
|
|
425
|
-
'
|
|
411
|
+
'app:close': CreateMethodPayload<Empty>;
|
|
426
412
|
/**
|
|
427
413
|
* Toggle host app's back button visibility.
|
|
428
|
-
* @since 0.0
|
|
414
|
+
* @since 1.0.0
|
|
429
415
|
* @schema
|
|
430
416
|
*/
|
|
431
417
|
'host.back.button:toggle': CreateMethodPayload<{
|
|
432
418
|
/**
|
|
433
419
|
* Whether to show or hide the back button.
|
|
434
|
-
* @since 0.0
|
|
420
|
+
* @since 1.0.0
|
|
435
421
|
* @schema
|
|
436
422
|
*/
|
|
437
423
|
visible: boolean;
|
|
@@ -443,8 +429,8 @@ interface Methods {
|
|
|
443
429
|
* Your backend receives a webhook when user pays - fulfill the order
|
|
444
430
|
* immediately without waiting for chain confirmation.
|
|
445
431
|
*
|
|
446
|
-
* Optional
|
|
447
|
-
*
|
|
432
|
+
* Optional `item` object (`title`, `iconUrl`, `quantity`)
|
|
433
|
+
* is shown on the payment approval screen.
|
|
448
434
|
*
|
|
449
435
|
* Set `test` to a scenario string (e.g. `'paid'`, `'error:insufficient_balance'`)
|
|
450
436
|
* for test mode - no real payment is made, but the specified scenario is
|
|
@@ -700,28 +686,6 @@ interface Methods {
|
|
|
700
686
|
maxRetries?: number;
|
|
701
687
|
};
|
|
702
688
|
}>>;
|
|
703
|
-
/**
|
|
704
|
-
* Request fullscreen mode.
|
|
705
|
-
* Fire-and-forget — host app responds with `fullscreen:changed` or `fullscreen:failed` event.
|
|
706
|
-
*
|
|
707
|
-
* @example
|
|
708
|
-
* send('fullscreen:request', {});
|
|
709
|
-
*
|
|
710
|
-
* @since 1.1.0
|
|
711
|
-
* @schema
|
|
712
|
-
*/
|
|
713
|
-
'fullscreen:request': CreateMethodPayload<Empty>;
|
|
714
|
-
/**
|
|
715
|
-
* Exit fullscreen mode.
|
|
716
|
-
* Fire-and-forget — host app responds with `fullscreen:changed` event.
|
|
717
|
-
*
|
|
718
|
-
* @example
|
|
719
|
-
* send('fullscreen:exit', {});
|
|
720
|
-
*
|
|
721
|
-
* @since 1.1.0
|
|
722
|
-
* @schema
|
|
723
|
-
*/
|
|
724
|
-
'fullscreen:exit': CreateMethodPayload<Empty>;
|
|
725
689
|
}
|
|
726
690
|
//#endregion
|
|
727
691
|
//#region src/methods/types/method-types.d.ts
|
|
@@ -776,4 +740,4 @@ declare function isMethodSupported(method: MethodName, version: Version): boolea
|
|
|
776
740
|
*/
|
|
777
741
|
declare function getMethodMinVersion(method: MethodName): Version | undefined;
|
|
778
742
|
//#endregion
|
|
779
|
-
export { type CreateEventPayload, type CreateMethodPayload, type
|
|
743
|
+
export { type CreateEventPayload, type CreateMethodPayload, DISPLAY_MODES, type DisplayMode, type EventName, type EventPayload, type Events, type HapticImpactStyle, type HapticNotificationType, type LaunchParams, type MethodName, type MethodNameWithVersionedPayload, type MethodPayload, type MethodVersionedPayload, type Methods, PLATFORMS, type PaymentErrorCode, type PaymentTestScenario, type PaymentWebhookStatus, type Platform, type SafeAreaInsets, type SolanaChain, type SolanaCommitment, type Version, WALLET_ERROR, type WalletSolanaErrorCode, getMethodMinVersion, getReleaseVersion, isMethodSupported, releases };
|
package/dist/index.d.mts
CHANGED
|
@@ -87,14 +87,6 @@ type PaymentWebhookStatus = 'finalized' | 'failed';
|
|
|
87
87
|
* @schema
|
|
88
88
|
*/
|
|
89
89
|
type PaymentTestScenario = 'paid' | 'paid:failed' | 'cancelled' | `error:${PaymentErrorCode}`;
|
|
90
|
-
/**
|
|
91
|
-
* Fullscreen error codes.
|
|
92
|
-
* Returned in `fullscreen:failed` event when fullscreen request fails.
|
|
93
|
-
* - `ALREADY_FULLSCREEN`: Miniapp is already in fullscreen mode
|
|
94
|
-
* @since 1.1.0
|
|
95
|
-
* @schema
|
|
96
|
-
*/
|
|
97
|
-
type FullscreenErrorCode = 'ALREADY_FULLSCREEN';
|
|
98
90
|
/**
|
|
99
91
|
* Haptic impact feedback styles.
|
|
100
92
|
* Maps to UIImpactFeedbackGenerator styles on iOS
|
|
@@ -190,7 +182,7 @@ interface Events {
|
|
|
190
182
|
'miniapp:close': CreateEventPayload<Empty>;
|
|
191
183
|
/**
|
|
192
184
|
* Host app's back button clicked event.
|
|
193
|
-
* @since 0.0
|
|
185
|
+
* @since 1.0.0
|
|
194
186
|
* @schema
|
|
195
187
|
*/
|
|
196
188
|
'host.back.button:clicked': CreateEventPayload<Empty>;
|
|
@@ -259,35 +251,6 @@ interface Events {
|
|
|
259
251
|
*/
|
|
260
252
|
errorCode?: 'permission_denied' | 'unavailable';
|
|
261
253
|
}>>;
|
|
262
|
-
/**
|
|
263
|
-
* Fullscreen state changed, fired by the host app
|
|
264
|
-
* after `fullscreen:request` or `fullscreen:exit`.
|
|
265
|
-
* @since 1.1.0
|
|
266
|
-
* @schema
|
|
267
|
-
*/
|
|
268
|
-
'fullscreen:changed': CreateEventPayload<{
|
|
269
|
-
/**
|
|
270
|
-
* Whether the miniapp is currently in fullscreen mode.
|
|
271
|
-
* @since 1.1.0
|
|
272
|
-
* @schema
|
|
273
|
-
*/
|
|
274
|
-
isFullscreen: boolean;
|
|
275
|
-
}>;
|
|
276
|
-
/**
|
|
277
|
-
* Fullscreen request failed.
|
|
278
|
-
* Fired by the host app when `fullscreen:request` cannot be fulfilled
|
|
279
|
-
* (e.g., the miniapp is already in fullscreen mode).
|
|
280
|
-
* @since 1.1.0
|
|
281
|
-
* @schema
|
|
282
|
-
*/
|
|
283
|
-
'fullscreen:failed': CreateEventPayload<{
|
|
284
|
-
/**
|
|
285
|
-
* Error code indicating why the fullscreen request failed.
|
|
286
|
-
* @since 1.1.0
|
|
287
|
-
* @schema
|
|
288
|
-
*/
|
|
289
|
-
error: FullscreenErrorCode;
|
|
290
|
-
}>;
|
|
291
254
|
/**
|
|
292
255
|
* Solana wallet connection response.
|
|
293
256
|
* @since 1.0.0
|
|
@@ -357,6 +320,28 @@ declare const PLATFORMS: readonly ["ios", "android"];
|
|
|
357
320
|
* Platform the miniapp is running on.
|
|
358
321
|
*/
|
|
359
322
|
type Platform = (typeof PLATFORMS)[number];
|
|
323
|
+
/**
|
|
324
|
+
* Supported display modes for miniapps.
|
|
325
|
+
*
|
|
326
|
+
* - `standard` — Default. Native header with close button, options menu, and
|
|
327
|
+
* miniapp title is visible. WebView is inset below the header. Safe area
|
|
328
|
+
* insets account for the header height.
|
|
329
|
+
*
|
|
330
|
+
* - `fullscreen` — WebView occupies the entire screen. The native close button
|
|
331
|
+
* and options menu remain as floating overlays so the user can always exit.
|
|
332
|
+
* The miniapp must respect safe area insets for system UI (status bar, notch,
|
|
333
|
+
* home indicator).
|
|
334
|
+
*
|
|
335
|
+
* - `immersive` — WebView occupies the entire screen with zero native UI.
|
|
336
|
+
* No close button, no options menu, no header — the miniapp owns the full
|
|
337
|
+
* viewport. The miniapp is responsible for providing its own exit mechanism
|
|
338
|
+
* (e.g. calling `app:close`). Safe area insets still apply for system UI.
|
|
339
|
+
*/
|
|
340
|
+
declare const DISPLAY_MODES: readonly ["standard", "fullscreen", "immersive"];
|
|
341
|
+
/**
|
|
342
|
+
* Display mode for the miniapp webview.
|
|
343
|
+
*/
|
|
344
|
+
type DisplayMode = (typeof DISPLAY_MODES)[number];
|
|
360
345
|
/**
|
|
361
346
|
* Safe area insets in CSS pixels, injected by the host app.
|
|
362
347
|
* Accounts for system UI (status bar, notch, home indicator, nav bar).
|
|
@@ -387,10 +372,11 @@ interface LaunchParams {
|
|
|
387
372
|
*/
|
|
388
373
|
startParam: string | undefined;
|
|
389
374
|
/**
|
|
390
|
-
*
|
|
391
|
-
*
|
|
375
|
+
* Display mode for the miniapp webview.
|
|
376
|
+
* Defaults to `'standard'` when not provided by the host app.
|
|
377
|
+
* @since 1.0.0
|
|
392
378
|
*/
|
|
393
|
-
|
|
379
|
+
displayMode: DisplayMode;
|
|
394
380
|
}
|
|
395
381
|
//#endregion
|
|
396
382
|
//#region src/methods/types/payload.d.ts
|
|
@@ -411,27 +397,27 @@ interface Methods {
|
|
|
411
397
|
/**
|
|
412
398
|
* Miniapp ready method.
|
|
413
399
|
* Sent by the miniapp to notify the host app that it has loaded and is ready to be displayed.
|
|
414
|
-
* @since 0.0.
|
|
400
|
+
* @since 0.0.9
|
|
415
401
|
* @schema
|
|
416
402
|
*/
|
|
417
403
|
'app:ready': CreateMethodPayload<Empty>;
|
|
418
404
|
/**
|
|
419
|
-
*
|
|
420
|
-
* Sent by the miniapp to
|
|
421
|
-
*
|
|
422
|
-
* @since 0.0
|
|
405
|
+
* Close the miniapp.
|
|
406
|
+
* Sent by the miniapp to request the host app to close it.
|
|
407
|
+
* Fire-and-forget — no response expected.
|
|
408
|
+
* @since 1.0.0
|
|
423
409
|
* @schema
|
|
424
410
|
*/
|
|
425
|
-
'
|
|
411
|
+
'app:close': CreateMethodPayload<Empty>;
|
|
426
412
|
/**
|
|
427
413
|
* Toggle host app's back button visibility.
|
|
428
|
-
* @since 0.0
|
|
414
|
+
* @since 1.0.0
|
|
429
415
|
* @schema
|
|
430
416
|
*/
|
|
431
417
|
'host.back.button:toggle': CreateMethodPayload<{
|
|
432
418
|
/**
|
|
433
419
|
* Whether to show or hide the back button.
|
|
434
|
-
* @since 0.0
|
|
420
|
+
* @since 1.0.0
|
|
435
421
|
* @schema
|
|
436
422
|
*/
|
|
437
423
|
visible: boolean;
|
|
@@ -443,8 +429,8 @@ interface Methods {
|
|
|
443
429
|
* Your backend receives a webhook when user pays - fulfill the order
|
|
444
430
|
* immediately without waiting for chain confirmation.
|
|
445
431
|
*
|
|
446
|
-
* Optional
|
|
447
|
-
*
|
|
432
|
+
* Optional `item` object (`title`, `iconUrl`, `quantity`)
|
|
433
|
+
* is shown on the payment approval screen.
|
|
448
434
|
*
|
|
449
435
|
* Set `test` to a scenario string (e.g. `'paid'`, `'error:insufficient_balance'`)
|
|
450
436
|
* for test mode - no real payment is made, but the specified scenario is
|
|
@@ -700,28 +686,6 @@ interface Methods {
|
|
|
700
686
|
maxRetries?: number;
|
|
701
687
|
};
|
|
702
688
|
}>>;
|
|
703
|
-
/**
|
|
704
|
-
* Request fullscreen mode.
|
|
705
|
-
* Fire-and-forget — host app responds with `fullscreen:changed` or `fullscreen:failed` event.
|
|
706
|
-
*
|
|
707
|
-
* @example
|
|
708
|
-
* send('fullscreen:request', {});
|
|
709
|
-
*
|
|
710
|
-
* @since 1.1.0
|
|
711
|
-
* @schema
|
|
712
|
-
*/
|
|
713
|
-
'fullscreen:request': CreateMethodPayload<Empty>;
|
|
714
|
-
/**
|
|
715
|
-
* Exit fullscreen mode.
|
|
716
|
-
* Fire-and-forget — host app responds with `fullscreen:changed` event.
|
|
717
|
-
*
|
|
718
|
-
* @example
|
|
719
|
-
* send('fullscreen:exit', {});
|
|
720
|
-
*
|
|
721
|
-
* @since 1.1.0
|
|
722
|
-
* @schema
|
|
723
|
-
*/
|
|
724
|
-
'fullscreen:exit': CreateMethodPayload<Empty>;
|
|
725
689
|
}
|
|
726
690
|
//#endregion
|
|
727
691
|
//#region src/methods/types/method-types.d.ts
|
|
@@ -776,4 +740,4 @@ declare function isMethodSupported(method: MethodName, version: Version): boolea
|
|
|
776
740
|
*/
|
|
777
741
|
declare function getMethodMinVersion(method: MethodName): Version | undefined;
|
|
778
742
|
//#endregion
|
|
779
|
-
export { type CreateEventPayload, type CreateMethodPayload, type
|
|
743
|
+
export { type CreateEventPayload, type CreateMethodPayload, DISPLAY_MODES, type DisplayMode, type EventName, type EventPayload, type Events, type HapticImpactStyle, type HapticNotificationType, type LaunchParams, type MethodName, type MethodNameWithVersionedPayload, type MethodPayload, type MethodVersionedPayload, type Methods, PLATFORMS, type PaymentErrorCode, type PaymentTestScenario, type PaymentWebhookStatus, type Platform, type SafeAreaInsets, type SolanaChain, type SolanaCommitment, type Version, WALLET_ERROR, type WalletSolanaErrorCode, getMethodMinVersion, getReleaseVersion, isMethodSupported, releases };
|
package/dist/index.mjs
CHANGED
|
@@ -3,12 +3,33 @@
|
|
|
3
3
|
* Supported platforms for miniapps.
|
|
4
4
|
*/
|
|
5
5
|
const PLATFORMS = ["ios", "android"];
|
|
6
|
+
/**
|
|
7
|
+
* Supported display modes for miniapps.
|
|
8
|
+
*
|
|
9
|
+
* - `standard` — Default. Native header with close button, options menu, and
|
|
10
|
+
* miniapp title is visible. WebView is inset below the header. Safe area
|
|
11
|
+
* insets account for the header height.
|
|
12
|
+
*
|
|
13
|
+
* - `fullscreen` — WebView occupies the entire screen. The native close button
|
|
14
|
+
* and options menu remain as floating overlays so the user can always exit.
|
|
15
|
+
* The miniapp must respect safe area insets for system UI (status bar, notch,
|
|
16
|
+
* home indicator).
|
|
17
|
+
*
|
|
18
|
+
* - `immersive` — WebView occupies the entire screen with zero native UI.
|
|
19
|
+
* No close button, no options menu, no header — the miniapp owns the full
|
|
20
|
+
* viewport. The miniapp is responsible for providing its own exit mechanism
|
|
21
|
+
* (e.g. calling `app:close`). Safe area insets still apply for system UI.
|
|
22
|
+
*/
|
|
23
|
+
const DISPLAY_MODES = [
|
|
24
|
+
"standard",
|
|
25
|
+
"fullscreen",
|
|
26
|
+
"immersive"
|
|
27
|
+
];
|
|
6
28
|
|
|
7
29
|
//#endregion
|
|
8
30
|
//#region src/methods/versions/releases.ts
|
|
9
31
|
const releases = {
|
|
10
32
|
"0.0.9": ["app:ready"],
|
|
11
|
-
"0.0.14": ["miniapp:close.ack", "host.back.button:toggle"],
|
|
12
33
|
"0.1.1": [
|
|
13
34
|
"payment:request",
|
|
14
35
|
"clipboard:write",
|
|
@@ -25,9 +46,10 @@ const releases = {
|
|
|
25
46
|
"wallet.solana:disconnect",
|
|
26
47
|
"wallet.solana:sign.transaction",
|
|
27
48
|
"wallet.solana:sign.message",
|
|
28
|
-
"wallet.solana:sign.send"
|
|
29
|
-
|
|
30
|
-
|
|
49
|
+
"wallet.solana:sign.send",
|
|
50
|
+
"app:close",
|
|
51
|
+
"host.back.button:toggle"
|
|
52
|
+
]
|
|
31
53
|
};
|
|
32
54
|
|
|
33
55
|
//#endregion
|
|
@@ -114,4 +136,4 @@ const WALLET_ERROR = {
|
|
|
114
136
|
};
|
|
115
137
|
|
|
116
138
|
//#endregion
|
|
117
|
-
export { PLATFORMS, WALLET_ERROR, getMethodMinVersion, getReleaseVersion, isMethodSupported, releases };
|
|
139
|
+
export { DISPLAY_MODES, PLATFORMS, WALLET_ERROR, getMethodMinVersion, getReleaseVersion, isMethodSupported, releases };
|