@alien_org/react 0.1.3 → 0.1.4

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/index.d.cts CHANGED
@@ -33,6 +33,41 @@ type UnionKeys<T> = T extends T ? keyof T : never;
33
33
  * // Empty = {}
34
34
  */
35
35
  type Empty = Record<string, never>;
36
+ /**
37
+ * Client-side payment error codes (pre-broadcast failures).
38
+ * Returned when `status` is `'failed'` in `payment:response`.
39
+ * These errors occur before transaction broadcast, so no webhook is sent.
40
+ * @since 0.1.1
41
+ * @schema
42
+ */
43
+ type PaymentErrorCode$1 = 'insufficient_balance' | 'network_error' | 'pre_checkout_rejected' | 'pre_checkout_timeout' | 'unknown';
44
+ /**
45
+ * Payment test scenarios for simulating different payment outcomes.
46
+ *
47
+ * | Scenario | Client sees | Webhook |
48
+ * |----------|-------------|---------|
49
+ * | `'paid'` | `paid` | `{ status: 'finalized' }` |
50
+ * | `'paid:failed'` | `paid` | `{ status: 'failed' }` |
51
+ * | `'cancelled'` | `cancelled` | none |
52
+ * | `'error:*'` | `failed` | none (pre-broadcast) |
53
+ *
54
+ * @example
55
+ * // Happy path: client paid, tx finalized
56
+ * test: 'paid'
57
+ *
58
+ * // On-chain failure: client paid, tx failed
59
+ * test: 'paid:failed'
60
+ *
61
+ * // User cancelled before confirming
62
+ * test: 'cancelled'
63
+ *
64
+ * // Pre-broadcast error (no tx, no webhook)
65
+ * test: 'error:insufficient_balance'
66
+ *
67
+ * @since 0.1.2
68
+ * @schema
69
+ */
70
+ type PaymentTestScenario = 'paid' | 'paid:failed' | 'cancelled' | `error:${PaymentErrorCode$1}`;
36
71
  //#endregion
37
72
  //#region ../contract/src/events/types/payload.d.ts
38
73
  /**
@@ -80,7 +115,7 @@ interface Events {
80
115
  * Payment status.
81
116
  * - `paid`: Success
82
117
  * - `cancelled`: User rejected
83
- * - `failed`: Error (check `errorCode`)
118
+ * - `failed`: Sending transaction failed (check `errorCode`)
84
119
  * @since 0.1.1
85
120
  * @schema
86
121
  */
@@ -101,7 +136,7 @@ interface Events {
101
136
  * @since 0.1.1
102
137
  * @schema
103
138
  */
104
- errorCode?: 'insufficient_balance' | 'network_error' | 'pre_checkout_rejected' | 'pre_checkout_timeout' | 'unknown';
139
+ errorCode?: PaymentErrorCode$1;
105
140
  }>>;
106
141
  /**
107
142
  * Clipboard read response.
@@ -253,37 +288,62 @@ interface Methods {
253
288
  */
254
289
  invoice: string;
255
290
  /**
256
- * Item title shown on the approval screen.
257
- * @since 0.1.1
258
- * @schema
259
- */
260
- title?: string;
261
- /**
262
- * Item description/caption shown on the approval screen.
263
- * @since 0.1.1
264
- * @schema
265
- */
266
- caption?: string;
267
- /**
268
- * Item icon URL shown on the approval screen.
269
- * @since 0.1.1
270
- * @schema
271
- */
272
- iconUrl?: string;
273
- /**
274
- * Quantity of items being purchased.
291
+ * Optional item details shown on the approval screen.
275
292
  * @since 0.1.1
276
293
  * @schema
277
294
  */
278
- quantity?: number;
295
+ item?: {
296
+ /**
297
+ * Item title shown on the approval screen.
298
+ * @since 0.1.1
299
+ * @schema
300
+ */
301
+ title: string;
302
+ /**
303
+ * Item icon URL shown on the approval screen.
304
+ * @since 0.1.1
305
+ * @schema
306
+ */
307
+ iconUrl: string;
308
+ /**
309
+ * Quantity of items being purchased.
310
+ * @since 0.1.1
311
+ * @schema
312
+ */
313
+ quantity: number;
314
+ };
279
315
  /**
280
- * Test mode flag. When true, no real payment is processed.
281
- * The approval screen shows a test indicator, and webhooks
282
- * include `test: true`. Use for development and testing.
316
+ * Test mode. Simulates payment outcomes without real transactions.
317
+ *
318
+ * | Scenario | Client | Webhook |
319
+ * |----------|--------|---------|
320
+ * | `true` / `'paid'` | `paid` | `finalized` |
321
+ * | `'paid:failed'` | `paid` | `failed` |
322
+ * | `'cancelled'` | `cancelled` | none |
323
+ * | `'error:*'` | `failed` | none |
324
+ *
325
+ * **Pre-broadcast errors** (no webhook):
326
+ * `'error:insufficient_balance'`, `'error:network_error'`,
327
+ * `'error:pre_checkout_rejected'`, `'error:pre_checkout_timeout'`,
328
+ * `'error:unknown'`
329
+ *
330
+ * @example
331
+ * // Happy path
332
+ * test: 'paid'
333
+ *
334
+ * // Client shows success, but tx failed on-chain
335
+ * test: 'paid:failed'
336
+ *
337
+ * // User cancelled
338
+ * test: 'cancelled'
339
+ *
340
+ * // Pre-broadcast failure
341
+ * test: 'error:insufficient_balance'
342
+ *
283
343
  * @since 0.1.1
284
344
  * @schema
285
345
  */
286
- test?: boolean;
346
+ test?: boolean | PaymentTestScenario;
287
347
  }>>;
288
348
  /**
289
349
  * Write text to the system clipboard.
@@ -304,6 +364,44 @@ interface Methods {
304
364
  * @schema
305
365
  */
306
366
  'clipboard:read': CreateMethodPayload<WithReqId<Empty>>;
367
+ /**
368
+ * Open a URL.
369
+ *
370
+ * The host app acts as middleware: parses the URL, checks permissions/auth,
371
+ * and routes to the appropriate handler based on URL and `openMode`.
372
+ *
373
+ * **`external`** (default) - Open outside the host app:
374
+ * - Custom schemes (`solana:`, `mailto:`) → system handler
375
+ * - HTTPS → system browser
376
+ *
377
+ * **`internal`** - Open within the host app:
378
+ * - Miniapp links → open miniapp (handles auth if required)
379
+ * - Other links → in-app webview
380
+ *
381
+ * @example
382
+ * emit('link:open', { url: 'solana:...' });
383
+ * emit('link:open', { url: 'mailto:hi@example.com' });
384
+ * emit('link:open', { url: 'https://example.com', openMode: 'internal' });
385
+ *
386
+ * @since 0.1.3
387
+ * @schema
388
+ */
389
+ 'link:open': CreateMethodPayload<{
390
+ /**
391
+ * The URL to open.
392
+ * @since 0.1.3
393
+ * @schema
394
+ */
395
+ url: string;
396
+ /**
397
+ * Where to open the URL.
398
+ * - `external` (default): System browser or app handler
399
+ * - `internal`: Within the host app (miniapps, webviews)
400
+ * @since 0.1.3
401
+ * @schema
402
+ */
403
+ openMode?: 'external' | 'internal';
404
+ }>;
307
405
  }
308
406
  //#endregion
309
407
  //#region ../contract/src/methods/types/method-types.d.ts
package/dist/index.d.mts CHANGED
@@ -33,6 +33,41 @@ type UnionKeys<T> = T extends T ? keyof T : never;
33
33
  * // Empty = {}
34
34
  */
35
35
  type Empty = Record<string, never>;
36
+ /**
37
+ * Client-side payment error codes (pre-broadcast failures).
38
+ * Returned when `status` is `'failed'` in `payment:response`.
39
+ * These errors occur before transaction broadcast, so no webhook is sent.
40
+ * @since 0.1.1
41
+ * @schema
42
+ */
43
+ type PaymentErrorCode$1 = 'insufficient_balance' | 'network_error' | 'pre_checkout_rejected' | 'pre_checkout_timeout' | 'unknown';
44
+ /**
45
+ * Payment test scenarios for simulating different payment outcomes.
46
+ *
47
+ * | Scenario | Client sees | Webhook |
48
+ * |----------|-------------|---------|
49
+ * | `'paid'` | `paid` | `{ status: 'finalized' }` |
50
+ * | `'paid:failed'` | `paid` | `{ status: 'failed' }` |
51
+ * | `'cancelled'` | `cancelled` | none |
52
+ * | `'error:*'` | `failed` | none (pre-broadcast) |
53
+ *
54
+ * @example
55
+ * // Happy path: client paid, tx finalized
56
+ * test: 'paid'
57
+ *
58
+ * // On-chain failure: client paid, tx failed
59
+ * test: 'paid:failed'
60
+ *
61
+ * // User cancelled before confirming
62
+ * test: 'cancelled'
63
+ *
64
+ * // Pre-broadcast error (no tx, no webhook)
65
+ * test: 'error:insufficient_balance'
66
+ *
67
+ * @since 0.1.2
68
+ * @schema
69
+ */
70
+ type PaymentTestScenario = 'paid' | 'paid:failed' | 'cancelled' | `error:${PaymentErrorCode$1}`;
36
71
  //#endregion
37
72
  //#region ../contract/src/events/types/payload.d.ts
38
73
  /**
@@ -80,7 +115,7 @@ interface Events {
80
115
  * Payment status.
81
116
  * - `paid`: Success
82
117
  * - `cancelled`: User rejected
83
- * - `failed`: Error (check `errorCode`)
118
+ * - `failed`: Sending transaction failed (check `errorCode`)
84
119
  * @since 0.1.1
85
120
  * @schema
86
121
  */
@@ -101,7 +136,7 @@ interface Events {
101
136
  * @since 0.1.1
102
137
  * @schema
103
138
  */
104
- errorCode?: 'insufficient_balance' | 'network_error' | 'pre_checkout_rejected' | 'pre_checkout_timeout' | 'unknown';
139
+ errorCode?: PaymentErrorCode$1;
105
140
  }>>;
106
141
  /**
107
142
  * Clipboard read response.
@@ -253,37 +288,62 @@ interface Methods {
253
288
  */
254
289
  invoice: string;
255
290
  /**
256
- * Item title shown on the approval screen.
257
- * @since 0.1.1
258
- * @schema
259
- */
260
- title?: string;
261
- /**
262
- * Item description/caption shown on the approval screen.
263
- * @since 0.1.1
264
- * @schema
265
- */
266
- caption?: string;
267
- /**
268
- * Item icon URL shown on the approval screen.
269
- * @since 0.1.1
270
- * @schema
271
- */
272
- iconUrl?: string;
273
- /**
274
- * Quantity of items being purchased.
291
+ * Optional item details shown on the approval screen.
275
292
  * @since 0.1.1
276
293
  * @schema
277
294
  */
278
- quantity?: number;
295
+ item?: {
296
+ /**
297
+ * Item title shown on the approval screen.
298
+ * @since 0.1.1
299
+ * @schema
300
+ */
301
+ title: string;
302
+ /**
303
+ * Item icon URL shown on the approval screen.
304
+ * @since 0.1.1
305
+ * @schema
306
+ */
307
+ iconUrl: string;
308
+ /**
309
+ * Quantity of items being purchased.
310
+ * @since 0.1.1
311
+ * @schema
312
+ */
313
+ quantity: number;
314
+ };
279
315
  /**
280
- * Test mode flag. When true, no real payment is processed.
281
- * The approval screen shows a test indicator, and webhooks
282
- * include `test: true`. Use for development and testing.
316
+ * Test mode. Simulates payment outcomes without real transactions.
317
+ *
318
+ * | Scenario | Client | Webhook |
319
+ * |----------|--------|---------|
320
+ * | `true` / `'paid'` | `paid` | `finalized` |
321
+ * | `'paid:failed'` | `paid` | `failed` |
322
+ * | `'cancelled'` | `cancelled` | none |
323
+ * | `'error:*'` | `failed` | none |
324
+ *
325
+ * **Pre-broadcast errors** (no webhook):
326
+ * `'error:insufficient_balance'`, `'error:network_error'`,
327
+ * `'error:pre_checkout_rejected'`, `'error:pre_checkout_timeout'`,
328
+ * `'error:unknown'`
329
+ *
330
+ * @example
331
+ * // Happy path
332
+ * test: 'paid'
333
+ *
334
+ * // Client shows success, but tx failed on-chain
335
+ * test: 'paid:failed'
336
+ *
337
+ * // User cancelled
338
+ * test: 'cancelled'
339
+ *
340
+ * // Pre-broadcast failure
341
+ * test: 'error:insufficient_balance'
342
+ *
283
343
  * @since 0.1.1
284
344
  * @schema
285
345
  */
286
- test?: boolean;
346
+ test?: boolean | PaymentTestScenario;
287
347
  }>>;
288
348
  /**
289
349
  * Write text to the system clipboard.
@@ -304,6 +364,44 @@ interface Methods {
304
364
  * @schema
305
365
  */
306
366
  'clipboard:read': CreateMethodPayload<WithReqId<Empty>>;
367
+ /**
368
+ * Open a URL.
369
+ *
370
+ * The host app acts as middleware: parses the URL, checks permissions/auth,
371
+ * and routes to the appropriate handler based on URL and `openMode`.
372
+ *
373
+ * **`external`** (default) - Open outside the host app:
374
+ * - Custom schemes (`solana:`, `mailto:`) → system handler
375
+ * - HTTPS → system browser
376
+ *
377
+ * **`internal`** - Open within the host app:
378
+ * - Miniapp links → open miniapp (handles auth if required)
379
+ * - Other links → in-app webview
380
+ *
381
+ * @example
382
+ * emit('link:open', { url: 'solana:...' });
383
+ * emit('link:open', { url: 'mailto:hi@example.com' });
384
+ * emit('link:open', { url: 'https://example.com', openMode: 'internal' });
385
+ *
386
+ * @since 0.1.3
387
+ * @schema
388
+ */
389
+ 'link:open': CreateMethodPayload<{
390
+ /**
391
+ * The URL to open.
392
+ * @since 0.1.3
393
+ * @schema
394
+ */
395
+ url: string;
396
+ /**
397
+ * Where to open the URL.
398
+ * - `external` (default): System browser or app handler
399
+ * - `internal`: Within the host app (miniapps, webviews)
400
+ * @since 0.1.3
401
+ * @schema
402
+ */
403
+ openMode?: 'external' | 'internal';
404
+ }>;
307
405
  }
308
406
  //#endregion
309
407
  //#region ../contract/src/methods/types/method-types.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alien_org/react",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -34,8 +34,8 @@
34
34
  "prepublishOnly": "bun run build"
35
35
  },
36
36
  "dependencies": {
37
- "@alien_org/bridge": "0.1.1",
38
- "@alien_org/contract": "0.1.1"
37
+ "@alien_org/bridge": "0.1.2",
38
+ "@alien_org/contract": "0.1.4"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "react": "^18 || ^19",