@farcaster/snap 1.20.0 → 1.21.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.
- package/dist/react/components/action-button.js +2 -2
- package/dist/react/index.d.ts +1 -0
- package/dist/react-native/components/snap-action-button.js +2 -2
- package/dist/react-native/types.d.ts +1 -0
- package/dist/ui/catalog.d.ts +6 -0
- package/dist/ui/catalog.js +6 -4
- package/llms.txt +3 -2
- package/package.json +1 -1
- package/src/react/components/action-button.tsx +2 -2
- package/src/react/index.tsx +1 -0
- package/src/react-native/components/snap-action-button.tsx +2 -2
- package/src/react-native/types.ts +1 -0
- package/src/ui/catalog.ts +6 -4
|
@@ -10,9 +10,9 @@ function isExternalLinkAction(on) {
|
|
|
10
10
|
if (!on)
|
|
11
11
|
return false;
|
|
12
12
|
const press = on.press;
|
|
13
|
-
if (!press
|
|
13
|
+
if (!press)
|
|
14
14
|
return false;
|
|
15
|
-
return press.
|
|
15
|
+
return press.action === "open_url";
|
|
16
16
|
}
|
|
17
17
|
export function SnapActionButton({ element, emit, }) {
|
|
18
18
|
const { props } = element;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export type SnapPage = {
|
|
|
15
15
|
export type SnapActionHandlers = {
|
|
16
16
|
submit: (target: string, inputs: Record<string, JsonValue>) => void;
|
|
17
17
|
open_url: (target: string) => void;
|
|
18
|
+
open_snap: (target: string) => void;
|
|
18
19
|
open_mini_app: (target: string) => void;
|
|
19
20
|
view_cast: (params: {
|
|
20
21
|
hash: string;
|
|
@@ -8,9 +8,9 @@ function isExternalLinkAction(on) {
|
|
|
8
8
|
if (!on)
|
|
9
9
|
return false;
|
|
10
10
|
const press = on.press;
|
|
11
|
-
if (!press
|
|
11
|
+
if (!press)
|
|
12
12
|
return false;
|
|
13
|
-
return press.
|
|
13
|
+
return press.action === "open_url";
|
|
14
14
|
}
|
|
15
15
|
export function SnapActionButton({ element, emit, }) {
|
|
16
16
|
const { accentHex } = useSnapPalette();
|
|
@@ -13,6 +13,7 @@ export type SnapPage = {
|
|
|
13
13
|
export type SnapActionHandlers = {
|
|
14
14
|
submit: (target: string, inputs: Record<string, JsonValue>) => void;
|
|
15
15
|
open_url: (target: string) => void;
|
|
16
|
+
open_snap: (target: string) => void;
|
|
16
17
|
open_mini_app: (target: string) => void;
|
|
17
18
|
view_cast: (params: {
|
|
18
19
|
hash: string;
|
package/dist/ui/catalog.d.ts
CHANGED
|
@@ -420,6 +420,12 @@ export declare const snapJsonRenderCatalog: import("@json-render/core").Catalog<
|
|
|
420
420
|
target: z.ZodString;
|
|
421
421
|
}, z.core.$strip>;
|
|
422
422
|
};
|
|
423
|
+
open_snap: {
|
|
424
|
+
description: string;
|
|
425
|
+
params: z.ZodObject<{
|
|
426
|
+
target: z.ZodString;
|
|
427
|
+
}, z.core.$strip>;
|
|
428
|
+
};
|
|
423
429
|
open_mini_app: {
|
|
424
430
|
description: string;
|
|
425
431
|
params: z.ZodObject<{
|
package/dist/ui/catalog.js
CHANGED
|
@@ -99,10 +99,12 @@ export const snapJsonRenderCatalog = defineCatalog(snapJsonRenderSchema, {
|
|
|
99
99
|
params: z.object({ target: z.string() }),
|
|
100
100
|
},
|
|
101
101
|
open_url: {
|
|
102
|
-
description: "Open URL in browser.",
|
|
103
|
-
params: z.object({
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
description: "Open external URL in browser.",
|
|
103
|
+
params: z.object({ target: z.string() }),
|
|
104
|
+
},
|
|
105
|
+
open_snap: {
|
|
106
|
+
description: "Open a snap URL inline. The client renders the target as a snap rather than opening a browser.",
|
|
107
|
+
params: z.object({ target: z.string() }),
|
|
106
108
|
},
|
|
107
109
|
open_mini_app: {
|
|
108
110
|
description: "Open target URL as a Farcaster mini app.",
|
package/llms.txt
CHANGED
|
@@ -153,14 +153,15 @@ Field values are sent in POST `inputs[name]` when a `submit` action fires.
|
|
|
153
153
|
- `label` (string, optional, max 60)
|
|
154
154
|
- POST value: string (single) or string[] (multiple)
|
|
155
155
|
|
|
156
|
-
## Actions (
|
|
156
|
+
## Actions (10 types)
|
|
157
157
|
|
|
158
158
|
Bound to buttons via `on.press`:
|
|
159
159
|
|
|
160
160
|
| Action | Params | Description |
|
|
161
161
|
|--------|--------|-------------|
|
|
162
162
|
| `submit` | `target` (URL) | POST to server, get next page |
|
|
163
|
-
| `open_url` | `target` (URL) | Open in
|
|
163
|
+
| `open_url` | `target` (URL) | Open external URL in browser |
|
|
164
|
+
| `open_snap` | `target` (URL) | Open a snap URL inline |
|
|
164
165
|
| `open_mini_app` | `target` (URL) | Open as Farcaster mini app |
|
|
165
166
|
| `view_cast` | `hash` (string) | Navigate to a cast |
|
|
166
167
|
| `view_profile` | `fid` (number) | Navigate to a profile |
|
package/package.json
CHANGED
|
@@ -14,8 +14,8 @@ function isExternalLinkAction(
|
|
|
14
14
|
const press = on.press as
|
|
15
15
|
| { action?: string; params?: Record<string, unknown> }
|
|
16
16
|
| undefined;
|
|
17
|
-
if (!press
|
|
18
|
-
return press.
|
|
17
|
+
if (!press) return false;
|
|
18
|
+
return press.action === "open_url";
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export function SnapActionButton({
|
package/src/react/index.tsx
CHANGED
|
@@ -27,6 +27,7 @@ export type SnapPage = {
|
|
|
27
27
|
export type SnapActionHandlers = {
|
|
28
28
|
submit: (target: string, inputs: Record<string, JsonValue>) => void;
|
|
29
29
|
open_url: (target: string) => void;
|
|
30
|
+
open_snap: (target: string) => void;
|
|
30
31
|
open_mini_app: (target: string) => void;
|
|
31
32
|
view_cast: (params: { hash: string }) => void;
|
|
32
33
|
view_profile: (params: { fid: number }) => void;
|
|
@@ -14,8 +14,8 @@ function isExternalLinkAction(
|
|
|
14
14
|
const press = on.press as
|
|
15
15
|
| { action?: string; params?: Record<string, unknown> }
|
|
16
16
|
| undefined;
|
|
17
|
-
if (!press
|
|
18
|
-
return press.
|
|
17
|
+
if (!press) return false;
|
|
18
|
+
return press.action === "open_url";
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export function SnapActionButton({
|
|
@@ -18,6 +18,7 @@ export type SnapPage = {
|
|
|
18
18
|
export type SnapActionHandlers = {
|
|
19
19
|
submit: (target: string, inputs: Record<string, JsonValue>) => void;
|
|
20
20
|
open_url: (target: string) => void;
|
|
21
|
+
open_snap: (target: string) => void;
|
|
21
22
|
open_mini_app: (target: string) => void;
|
|
22
23
|
view_cast: (params: { hash: string }) => void;
|
|
23
24
|
view_profile: (params: { fid: number }) => void;
|
package/src/ui/catalog.ts
CHANGED
|
@@ -117,10 +117,12 @@ export const snapJsonRenderCatalog = defineCatalog(snapJsonRenderSchema, {
|
|
|
117
117
|
params: z.object({ target: z.string() }),
|
|
118
118
|
},
|
|
119
119
|
open_url: {
|
|
120
|
-
description: "Open URL in browser.",
|
|
121
|
-
params: z.object({
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
description: "Open external URL in browser.",
|
|
121
|
+
params: z.object({ target: z.string() }),
|
|
122
|
+
},
|
|
123
|
+
open_snap: {
|
|
124
|
+
description: "Open a snap URL inline. The client renders the target as a snap rather than opening a browser.",
|
|
125
|
+
params: z.object({ target: z.string() }),
|
|
124
126
|
},
|
|
125
127
|
open_mini_app: {
|
|
126
128
|
description: "Open target URL as a Farcaster mini app.",
|