@farcaster/frame-core 0.0.22 → 0.0.24

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.
Files changed (46) hide show
  1. package/dist/actions/ViewProfile.d.ts +4 -0
  2. package/dist/actions/ViewProfile.js +2 -0
  3. package/dist/actions/index.d.ts +1 -0
  4. package/dist/actions/index.js +2 -1
  5. package/dist/context.d.ts +72 -0
  6. package/dist/context.js +2 -0
  7. package/dist/index.d.ts +2 -1
  8. package/dist/index.js +25 -1
  9. package/dist/types.d.ts +5 -54
  10. package/esm/actions/AddFrame.d.ts +23 -27
  11. package/esm/actions/AddFrame.js +9 -9
  12. package/esm/actions/SignIn.d.ts +33 -35
  13. package/esm/actions/SignIn.js +5 -5
  14. package/esm/actions/ViewProfile.d.ts +4 -0
  15. package/esm/actions/ViewProfile.js +1 -0
  16. package/esm/actions/index.d.ts +3 -2
  17. package/esm/actions/index.js +3 -2
  18. package/esm/context.d.ts +72 -0
  19. package/esm/context.js +1 -0
  20. package/esm/errors.d.ts +7 -9
  21. package/esm/errors.js +6 -6
  22. package/esm/index.d.ts +4 -3
  23. package/esm/index.js +4 -3
  24. package/esm/internal/types.d.ts +7 -18
  25. package/esm/internal/types.js +1 -1
  26. package/esm/schemas/embeds.d.ts +169 -231
  27. package/esm/schemas/embeds.js +18 -24
  28. package/esm/schemas/events.d.ts +129 -225
  29. package/esm/schemas/events.js +17 -17
  30. package/esm/schemas/index.d.ts +5 -5
  31. package/esm/schemas/index.js +5 -5
  32. package/esm/schemas/manifest.d.ts +110 -154
  33. package/esm/schemas/manifest.js +23 -29
  34. package/esm/schemas/notifications.d.ts +58 -86
  35. package/esm/schemas/notifications.js +17 -17
  36. package/esm/schemas/shared.d.ts +33 -49
  37. package/esm/schemas/shared.js +19 -20
  38. package/esm/tsconfig.tsbuildinfo +1 -1
  39. package/esm/types.d.ts +101 -179
  40. package/esm/types.js +2 -2
  41. package/package.json +1 -1
  42. package/src/actions/ViewProfile.ts +5 -0
  43. package/src/actions/index.ts +1 -0
  44. package/src/context.ts +90 -0
  45. package/src/index.ts +2 -1
  46. package/src/types.ts +4 -64
package/esm/types.d.ts CHANGED
@@ -1,195 +1,117 @@
1
- import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox'
2
- import type { AddFrame, SignIn } from './actions'
3
- import type {
4
- EventFrameAdded,
5
- EventFrameRemoved,
6
- EventNotificationsDisabled,
7
- EventNotificationsEnabled,
8
- FrameNotificationDetails,
9
- } from './schemas'
1
+ import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox';
2
+ import type { AddFrame, SignIn, ViewProfile } from './actions';
3
+ import type { FrameContext } from './context';
4
+ import type { EventFrameAdded, EventFrameRemoved, EventNotificationsDisabled, EventNotificationsEnabled } from './schemas';
10
5
  export type SetPrimaryButtonOptions = {
11
- text: string
12
- loading?: boolean
13
- disabled?: boolean
14
- hidden?: boolean
15
- }
16
- export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void
17
- export type EthProviderRequest = Provider.RequestFn<RpcSchema.Default>
18
- export type AccountLocation = {
19
- placeId: string
20
- /**
21
- * Human-readable string describing the location
22
- */
23
- description: string
24
- }
25
- export type FrameLocationContextCastEmbed = {
26
- type: 'cast_embed'
27
- embed: string
28
- cast: {
29
- fid: number
30
- hash: string
31
- }
32
- }
33
- export type FrameLocationContextNotification = {
34
- type: 'notification'
35
- notification: {
36
- notificationId: string
37
- title: string
38
- body: string
39
- }
40
- }
41
- export type FrameLocationContextLauncher = {
42
- type: 'launcher'
43
- }
44
- export type FrameLocationContext =
45
- | FrameLocationContextCastEmbed
46
- | FrameLocationContextNotification
47
- | FrameLocationContextLauncher
48
- export type SafeAreaInsets = {
49
- top: number
50
- bottom: number
51
- left: number
52
- right: number
53
- }
54
- export type FrameContext = {
55
- user: {
56
- fid: number
57
- username?: string
58
- displayName?: string
6
+ text: string;
7
+ loading?: boolean;
8
+ disabled?: boolean;
9
+ hidden?: boolean;
10
+ };
11
+ export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void;
12
+ export type EthProviderRequest = Provider.RequestFn<RpcSchema.Default>;
13
+ export type ReadyOptions = {
59
14
  /**
60
- * Profile image URL
15
+ * Disable native gestures. Use this option if your frame uses gestures
16
+ * that conflict with native gestures.
17
+ *
18
+ * @defaultValue false
61
19
  */
62
- pfpUrl?: string
63
- location?: AccountLocation
64
- }
65
- location?: FrameLocationContext
66
- client: {
67
- clientFid: number
68
- added: boolean
69
- notificationDetails?: FrameNotificationDetails
70
- safeAreaInsets?: SafeAreaInsets
71
- }
72
- }
73
- export type ReadyOptions = {
74
- /**
75
- * Disable native gestures. Use this option if your frame uses gestures
76
- * that conflict with native gestures.
77
- *
78
- * @defaultValue false
79
- */
80
- disableNativeGestures: boolean
81
- }
82
- export declare const DEFAULT_READY_OPTIONS: ReadyOptions
20
+ disableNativeGestures: boolean;
21
+ };
22
+ export declare const DEFAULT_READY_OPTIONS: ReadyOptions;
83
23
  export type SignInOptions = {
84
- /**
85
- * A random string used to prevent replay attacks.
86
- */
87
- nonce: string
88
- /**
89
- * Start time at which the signature becomes valid.
90
- * ISO 8601 datetime.
91
- */
92
- notBefore?: string
93
- /**
94
- * Expiration time at which the signature is no longer valid.
95
- * ISO 8601 datetime.
96
- */
97
- expirationTime?: string
98
- }
24
+ /**
25
+ * A random string used to prevent replay attacks.
26
+ */
27
+ nonce: string;
28
+ /**
29
+ * Start time at which the signature becomes valid.
30
+ * ISO 8601 datetime.
31
+ */
32
+ notBefore?: string;
33
+ /**
34
+ * Expiration time at which the signature is no longer valid.
35
+ * ISO 8601 datetime.
36
+ */
37
+ expirationTime?: string;
38
+ };
99
39
  export type WireFrameHost = {
100
- context: FrameContext
101
- close: () => void
102
- ready: (options?: Partial<ReadyOptions>) => void
103
- openUrl: (url: string) => void
104
- signIn: SignIn.WireSignIn
105
- setPrimaryButton: SetPrimaryButton
106
- ethProviderRequest: EthProviderRequest
107
- ethProviderRequestV2: RpcTransport
108
- eip6963RequestProvider: () => void
109
- addFrame: AddFrame.WireAddFrame
110
- }
40
+ context: FrameContext;
41
+ close: () => void;
42
+ ready: (options?: Partial<ReadyOptions>) => void;
43
+ openUrl: (url: string) => void;
44
+ signIn: SignIn.WireSignIn;
45
+ setPrimaryButton: SetPrimaryButton;
46
+ ethProviderRequest: EthProviderRequest;
47
+ ethProviderRequestV2: RpcTransport;
48
+ eip6963RequestProvider: () => void;
49
+ addFrame: AddFrame.WireAddFrame;
50
+ viewProfile: ViewProfile.ViewProfile;
51
+ };
111
52
  export type FrameHost = {
112
- context: FrameContext
113
- close: () => void
114
- ready: (options?: Partial<ReadyOptions>) => void
115
- openUrl: (url: string) => void
116
- signIn: SignIn.SignIn
117
- setPrimaryButton: SetPrimaryButton
118
- ethProviderRequest: EthProviderRequest
119
- ethProviderRequestV2: RpcTransport
120
- /**
121
- * Receive forwarded eip6963:requestProvider events from the frame document.
122
- * Hosts must emit an EventEip6963AnnounceProvider in response.
123
- */
124
- eip6963RequestProvider: () => void
125
- addFrame: AddFrame.AddFrame
126
- }
53
+ context: FrameContext;
54
+ close: () => void;
55
+ ready: (options?: Partial<ReadyOptions>) => void;
56
+ openUrl: (url: string) => void;
57
+ signIn: SignIn.SignIn;
58
+ setPrimaryButton: SetPrimaryButton;
59
+ ethProviderRequest: EthProviderRequest;
60
+ ethProviderRequestV2: RpcTransport;
61
+ /**
62
+ * Receive forwarded eip6963:requestProvider events from the frame document.
63
+ * Hosts must emit an EventEip6963AnnounceProvider in response.
64
+ */
65
+ eip6963RequestProvider: () => void;
66
+ addFrame: AddFrame.AddFrame;
67
+ viewProfile: ViewProfile.ViewProfile;
68
+ };
127
69
  export type FrameEthProviderEventData = {
128
- type: 'frame_eth_provider_event'
129
- } & EthProviderWireEvent
130
- export type RpcTransport = (
131
- request: RpcRequest.RpcRequest,
132
- ) => Promise<RpcResponse.RpcResponse>
70
+ type: 'frame_eth_provider_event';
71
+ } & EthProviderWireEvent;
72
+ export type RpcTransport = (request: RpcRequest.RpcRequest) => Promise<RpcResponse.RpcResponse>;
133
73
  export type ProviderRpcError = {
134
- code: number
135
- details?: string
136
- message?: string
137
- }
138
- export type EthProviderWireEvent =
139
- | {
140
- event: 'accountsChanged'
141
- params: [readonly Address.Address[]]
142
- }
143
- | {
144
- event: 'chainChanged'
145
- params: [string]
146
- }
147
- | {
148
- event: 'connect'
149
- params: [Provider.ConnectInfo]
150
- }
151
- | {
152
- event: 'disconnect'
153
- params: [ProviderRpcError]
154
- }
155
- | {
156
- event: 'message'
157
- params: [Provider.Message]
158
- }
159
- export type EmitEthProvider = <event extends EthProviderWireEvent['event']>(
160
- event: event,
161
- params: Extract<
162
- EthProviderWireEvent,
163
- {
164
- event: event
165
- }
166
- >['params'],
167
- ) => void
74
+ code: number;
75
+ details?: string;
76
+ message?: string;
77
+ };
78
+ export type EthProviderWireEvent = {
79
+ event: 'accountsChanged';
80
+ params: [readonly Address.Address[]];
81
+ } | {
82
+ event: 'chainChanged';
83
+ params: [string];
84
+ } | {
85
+ event: 'connect';
86
+ params: [Provider.ConnectInfo];
87
+ } | {
88
+ event: 'disconnect';
89
+ params: [ProviderRpcError];
90
+ } | {
91
+ event: 'message';
92
+ params: [Provider.Message];
93
+ };
94
+ export type EmitEthProvider = <event extends EthProviderWireEvent['event']>(event: event, params: Extract<EthProviderWireEvent, {
95
+ event: event;
96
+ }>['params']) => void;
168
97
  export type EventFrameAddRejected = {
169
- event: 'frame_add_rejected'
170
- reason: AddFrame.AddFrameRejectedReason
171
- }
98
+ event: 'frame_add_rejected';
99
+ reason: AddFrame.AddFrameRejectedReason;
100
+ };
172
101
  export type EventPrimaryButtonClicked = {
173
- event: 'primary_button_clicked'
174
- }
102
+ event: 'primary_button_clicked';
103
+ };
175
104
  /**
176
105
  * Metadata of the EIP-1193 Provider.
177
106
  */
178
107
  export interface EIP6963ProviderInfo {
179
- icon: `data:image/${string}`
180
- name: string
181
- rdns: string
182
- uuid: string
108
+ icon: `data:image/${string}`;
109
+ name: string;
110
+ rdns: string;
111
+ uuid: string;
183
112
  }
184
113
  export type EventEip6963AnnounceProvider = {
185
- event: 'eip6963:announceProvider'
186
- info: EIP6963ProviderInfo
187
- }
188
- export type FrameClientEvent =
189
- | EventFrameAdded
190
- | EventFrameAddRejected
191
- | EventFrameRemoved
192
- | EventNotificationsEnabled
193
- | EventNotificationsDisabled
194
- | EventPrimaryButtonClicked
195
- | EventEip6963AnnounceProvider
114
+ event: 'eip6963:announceProvider';
115
+ info: EIP6963ProviderInfo;
116
+ };
117
+ export type FrameClientEvent = EventFrameAdded | EventFrameAddRejected | EventFrameRemoved | EventNotificationsEnabled | EventNotificationsDisabled | EventPrimaryButtonClicked | EventEip6963AnnounceProvider;
package/esm/types.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export const DEFAULT_READY_OPTIONS = {
2
- disableNativeGestures: false,
3
- }
2
+ disableNativeGestures: false,
3
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farcaster/frame-core",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "main": "dist/index.js",
5
5
  "module": "esm/index.js",
6
6
  "files": [
@@ -0,0 +1,5 @@
1
+ export type ViewProfileOptions = {
2
+ fid: number
3
+ }
4
+
5
+ export type ViewProfile = (options: ViewProfileOptions) => Promise<void>
@@ -1,2 +1,3 @@
1
1
  export * as AddFrame from './AddFrame'
2
+ export * as ViewProfile from './ViewProfile'
2
3
  export * as SignIn from './SignIn'
package/src/context.ts ADDED
@@ -0,0 +1,90 @@
1
+ import type { FrameNotificationDetails } from './schemas'
2
+
3
+ export type CastEmbedLocationContext = {
4
+ type: 'cast_embed'
5
+ embed: string
6
+ cast: {
7
+ fid: number
8
+ hash: string
9
+ }
10
+ }
11
+
12
+ export type NotificationLocationContext = {
13
+ type: 'notification'
14
+ notification: {
15
+ notificationId: string
16
+ title: string
17
+ body: string
18
+ }
19
+ }
20
+
21
+ export type LauncherLocationContext = {
22
+ type: 'launcher'
23
+ }
24
+
25
+ export type ChannelLocationContext = {
26
+ type: 'channel'
27
+ channel: {
28
+ /**
29
+ * Channel key identifier
30
+ */
31
+ key: string
32
+
33
+ /**
34
+ * Channel name
35
+ */
36
+ name: string
37
+
38
+ /**
39
+ * Channel profile image URL
40
+ */
41
+ imageUrl?: string
42
+ }
43
+ }
44
+
45
+ export type LocationContext =
46
+ | CastEmbedLocationContext
47
+ | NotificationLocationContext
48
+ | LauncherLocationContext
49
+ | ChannelLocationContext
50
+
51
+ export type AccountLocation = {
52
+ placeId: string
53
+
54
+ /**
55
+ * Human-readable string describing the location
56
+ */
57
+ description: string
58
+ }
59
+
60
+ export type UserContext = {
61
+ fid: number
62
+ username?: string
63
+ displayName?: string
64
+
65
+ /**
66
+ * Profile image URL
67
+ */
68
+ pfpUrl?: string
69
+ location?: AccountLocation
70
+ }
71
+
72
+ export type SafeAreaInsets = {
73
+ top: number
74
+ bottom: number
75
+ left: number
76
+ right: number
77
+ }
78
+
79
+ export type ClientContext = {
80
+ clientFid: number
81
+ added: boolean
82
+ notificationDetails?: FrameNotificationDetails
83
+ safeAreaInsets?: SafeAreaInsets
84
+ }
85
+
86
+ export type FrameContext = {
87
+ client: ClientContext
88
+ user: UserContext
89
+ location?: LocationContext
90
+ }
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './actions'
2
- export * from './schemas'
2
+ export * as Context from './context'
3
3
  export * from './types'
4
+ export * from './schemas'
package/src/types.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox'
2
- import type { AddFrame, SignIn } from './actions'
2
+ import type { AddFrame, SignIn, ViewProfile } from './actions'
3
+ import type { FrameContext } from './context'
3
4
  import type {
4
5
  EventFrameAdded,
5
6
  EventFrameRemoved,
6
7
  EventNotificationsDisabled,
7
8
  EventNotificationsEnabled,
8
- FrameNotificationDetails,
9
9
  } from './schemas'
10
10
 
11
11
  export type SetPrimaryButtonOptions = {
@@ -19,68 +19,6 @@ export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void
19
19
 
20
20
  export type EthProviderRequest = Provider.RequestFn<RpcSchema.Default>
21
21
 
22
- export type AccountLocation = {
23
- placeId: string
24
- /**
25
- * Human-readable string describing the location
26
- */
27
- description: string
28
- }
29
-
30
- export type FrameLocationContextCastEmbed = {
31
- type: 'cast_embed'
32
- embed: string
33
- cast: {
34
- fid: number
35
- hash: string
36
- }
37
- }
38
-
39
- export type FrameLocationContextNotification = {
40
- type: 'notification'
41
- notification: {
42
- notificationId: string
43
- title: string
44
- body: string
45
- }
46
- }
47
-
48
- export type FrameLocationContextLauncher = {
49
- type: 'launcher'
50
- }
51
-
52
- export type FrameLocationContext =
53
- | FrameLocationContextCastEmbed
54
- | FrameLocationContextNotification
55
- | FrameLocationContextLauncher
56
-
57
- export type SafeAreaInsets = {
58
- top: number
59
- bottom: number
60
- left: number
61
- right: number
62
- }
63
-
64
- export type FrameContext = {
65
- user: {
66
- fid: number
67
- username?: string
68
- displayName?: string
69
- /**
70
- * Profile image URL
71
- */
72
- pfpUrl?: string
73
- location?: AccountLocation
74
- }
75
- location?: FrameLocationContext
76
- client: {
77
- clientFid: number
78
- added: boolean
79
- notificationDetails?: FrameNotificationDetails
80
- safeAreaInsets?: SafeAreaInsets
81
- }
82
- }
83
-
84
22
  export type ReadyOptions = {
85
23
  /**
86
24
  * Disable native gestures. Use this option if your frame uses gestures
@@ -125,6 +63,7 @@ export type WireFrameHost = {
125
63
  ethProviderRequestV2: RpcTransport
126
64
  eip6963RequestProvider: () => void
127
65
  addFrame: AddFrame.WireAddFrame
66
+ viewProfile: ViewProfile.ViewProfile
128
67
  }
129
68
 
130
69
  export type FrameHost = {
@@ -142,6 +81,7 @@ export type FrameHost = {
142
81
  */
143
82
  eip6963RequestProvider: () => void
144
83
  addFrame: AddFrame.AddFrame
84
+ viewProfile: ViewProfile.ViewProfile
145
85
  }
146
86
 
147
87
  export type FrameEthProviderEventData = {