@farcaster/snap 2.0.1 → 2.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.
@@ -24,18 +24,21 @@ export function SnapActionButton({ element, emit, }) {
24
24
  const [hovered, setHovered] = useState(false);
25
25
  const Icon = iconName ? ICON_MAP[iconName] : undefined;
26
26
  const showExternalIcon = isExternalLinkAction(element.on);
27
- const style = isPrimary
28
- ? {
29
- backgroundColor: hovered ? colors.accentHover : colors.accent,
30
- color: colors.accentFg,
31
- borderColor: "transparent",
32
- }
33
- : {
34
- backgroundColor: hovered
35
- ? `color-mix(in srgb, ${colors.accent} 15%, transparent)`
36
- : colors.muted,
37
- color: colors.text,
38
- borderColor: "transparent",
39
- };
27
+ const style = {
28
+ cursor: "pointer",
29
+ ...(isPrimary
30
+ ? {
31
+ backgroundColor: hovered ? colors.accentHover : colors.accent,
32
+ color: colors.accentFg,
33
+ borderColor: "transparent",
34
+ }
35
+ : {
36
+ backgroundColor: hovered
37
+ ? `color-mix(in srgb, ${colors.accent} 15%, transparent)`
38
+ : colors.muted,
39
+ color: colors.text,
40
+ borderColor: "transparent",
41
+ }),
42
+ };
40
43
  return (_jsx("div", { className: "w-full min-w-0 flex-1", children: _jsxs(Button, { type: "button", variant: isPrimary ? "default" : "secondary", className: cn("w-full gap-2"), style: style, onClick: () => emit("press"), onPointerEnter: () => setHovered(true), onPointerLeave: () => setHovered(false), children: [Icon && _jsx(Icon, { size: 16 }), label, showExternalIcon && (_jsx(ExternalLink, { size: 14, style: { opacity: 0.6 } }))] }) }));
41
44
  }
@@ -177,6 +177,9 @@ export function SnapViewCore({ snap, handlers, loading = false, appearance = "da
177
177
  case "open_url":
178
178
  handlers.open_url(String(p.target ?? ""));
179
179
  break;
180
+ case "open_snap":
181
+ handlers.open_snap(String(p.target ?? ""));
182
+ break;
180
183
  case "open_mini_app":
181
184
  handlers.open_mini_app(String(p.target ?? ""));
182
185
  break;
@@ -92,6 +92,9 @@ export function SnapViewCoreInner({ snap, handlers, loading = false, }) {
92
92
  case "open_url":
93
93
  h.open_url(String(p.target ?? ""));
94
94
  break;
95
+ case "open_snap":
96
+ h.open_snap(String(p.target ?? ""));
97
+ break;
95
98
  case "open_mini_app":
96
99
  h.open_mini_app(String(p.target ?? ""));
97
100
  break;
package/dist/validator.js CHANGED
@@ -3,7 +3,12 @@ import { MAX_CHILDREN, MAX_DEPTH, MAX_ELEMENTS, MAX_ROOT_CHILDREN, SPEC_VERSION_
3
3
  import { snapJsonRenderCatalog } from "./ui/catalog.js";
4
4
  // ─── Helpers ──────────────────────────────────────────
5
5
  /** Actions whose `params.target` must be a valid URL. */
6
- const URL_TARGET_ACTIONS = new Set(["submit", "open_url", "open_mini_app"]);
6
+ const URL_TARGET_ACTIONS = new Set([
7
+ "submit",
8
+ "open_url",
9
+ "open_snap",
10
+ "open_mini_app",
11
+ ]);
7
12
  /** Image file extensions allowed in image URLs. */
8
13
  const ALLOWED_IMAGE_EXTENSIONS = new Set(["jpg", "jpeg", "png", "gif", "webp"]);
9
14
  /**
@@ -129,7 +134,7 @@ function validateStructure(ui) {
129
134
  /**
130
135
  * Validate all URLs in the snap:
131
136
  * - image.url: must be HTTPS with allowed extension
132
- * - action target URLs (submit, open_url, open_mini_app): must be HTTPS
137
+ * - action target URLs (submit, open_url, open_snap, open_mini_app): must be HTTPS
133
138
  */
134
139
  function validateUrls(elements) {
135
140
  const issues = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farcaster/snap",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Farcaster Snaps 🫰",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,19 +39,22 @@ export function SnapActionButton({
39
39
  const Icon = iconName ? ICON_MAP[iconName] : undefined;
40
40
  const showExternalIcon = isExternalLinkAction(element.on);
41
41
 
42
- const style = isPrimary
43
- ? {
44
- backgroundColor: hovered ? colors.accentHover : colors.accent,
45
- color: colors.accentFg,
46
- borderColor: "transparent",
47
- }
48
- : {
49
- backgroundColor: hovered
50
- ? `color-mix(in srgb, ${colors.accent} 15%, transparent)`
51
- : colors.muted,
52
- color: colors.text,
53
- borderColor: "transparent",
54
- };
42
+ const style = {
43
+ cursor: "pointer" as const,
44
+ ...(isPrimary
45
+ ? {
46
+ backgroundColor: hovered ? colors.accentHover : colors.accent,
47
+ color: colors.accentFg,
48
+ borderColor: "transparent",
49
+ }
50
+ : {
51
+ backgroundColor: hovered
52
+ ? `color-mix(in srgb, ${colors.accent} 15%, transparent)`
53
+ : colors.muted,
54
+ color: colors.text,
55
+ borderColor: "transparent",
56
+ }),
57
+ };
55
58
 
56
59
  return (
57
60
  <div className="w-full min-w-0 flex-1">
@@ -265,6 +265,9 @@ export function SnapViewCore({
265
265
  case "open_url":
266
266
  handlers.open_url(String(p.target ?? ""));
267
267
  break;
268
+ case "open_snap":
269
+ handlers.open_snap(String(p.target ?? ""));
270
+ break;
268
271
  case "open_mini_app":
269
272
  handlers.open_mini_app(String(p.target ?? ""));
270
273
  break;
@@ -127,6 +127,9 @@ export function SnapViewCoreInner({
127
127
  case "open_url":
128
128
  h.open_url(String(p.target ?? ""));
129
129
  break;
130
+ case "open_snap":
131
+ h.open_snap(String(p.target ?? ""));
132
+ break;
130
133
  case "open_mini_app":
131
134
  h.open_mini_app(String(p.target ?? ""));
132
135
  break;
package/src/validator.ts CHANGED
@@ -11,7 +11,12 @@ export type ValidationResult = {
11
11
  // ─── Helpers ──────────────────────────────────────────
12
12
 
13
13
  /** Actions whose `params.target` must be a valid URL. */
14
- const URL_TARGET_ACTIONS = new Set(["submit", "open_url", "open_mini_app"]);
14
+ const URL_TARGET_ACTIONS = new Set([
15
+ "submit",
16
+ "open_url",
17
+ "open_snap",
18
+ "open_mini_app",
19
+ ]);
15
20
 
16
21
  /** Image file extensions allowed in image URLs. */
17
22
  const ALLOWED_IMAGE_EXTENSIONS = new Set(["jpg", "jpeg", "png", "gif", "webp"]);
@@ -169,7 +174,7 @@ function validateStructure(
169
174
  /**
170
175
  * Validate all URLs in the snap:
171
176
  * - image.url: must be HTTPS with allowed extension
172
- * - action target URLs (submit, open_url, open_mini_app): must be HTTPS
177
+ * - action target URLs (submit, open_url, open_snap, open_mini_app): must be HTTPS
173
178
  */
174
179
  function validateUrls(
175
180
  elements: Record<string, unknown>,