@napplet/sdk 0.24.2 → 0.24.3
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.ts +41 -897
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NappletGlobal } from '@napplet/core';
|
|
2
2
|
export { EventTemplate, NAP_DOMAINS, NapDomain, NappletMessage, NostrEvent, NostrFilter, RelayEventResult, RelayEventSidecar, Subscription } from '@napplet/core';
|
|
3
|
-
import { MediaSessionCreate, MediaSessionResult, MediaMetadata, MediaState, MediaAction } from '@napplet/nap/media';
|
|
4
|
-
export { DOMAIN as MEDIA_DOMAIN, MediaAction, MediaArtwork, MediaCapabilitiesMessage, MediaCommandMessage, MediaContextLink, MediaControlsMessage, MediaMessage, MediaMetadata, MediaNapMessage, MediaNostrRef, MediaPlaybackOwner, MediaRequestMessage, MediaResultMessage, MediaSessionContext, MediaSessionCreate, MediaSessionCreateMessage, MediaSessionCreateResultMessage, MediaSessionDestroyMessage, MediaSessionResult, MediaSessionUpdateMessage, MediaSourceRef, MediaState, MediaStateMessage, installMediaShim, mediaCreateSession, mediaDestroySession, mediaOnCapabilities, mediaOnCommand, mediaOnControls, mediaOnState, mediaReportCapabilities, mediaReportState, mediaSendCommand, mediaUpdateSession } from '@napplet/nap/media';
|
|
5
3
|
export { DOMAIN as RELAY_DOMAIN, RelayCloseMessage, RelayClosedMessage, RelayEoseMessage, RelayEventMessage, RelayInboundMessage, RelayMessage, RelayNapMessage, RelayOutboundMessage, RelayPublishEncryptedMessage, RelayPublishEncryptedResultMessage, RelayPublishMessage, RelayPublishResultMessage, RelayQueryMessage, RelayQueryResultMessage, RelaySubscribeMessage, installRelayShim, relayPublish, relayPublishEncrypted, relayQuery, relaySubscribe } from '@napplet/nap/relay';
|
|
6
4
|
export { Badge, DOMAIN as IDENTITY_DOMAIN, IdentityChangedMessage, IdentityGetBadgesMessage, IdentityGetBadgesResultMessage, IdentityGetBlockedMessage, IdentityGetBlockedResultMessage, IdentityGetFollowsMessage, IdentityGetFollowsResultMessage, IdentityGetListMessage, IdentityGetListResultMessage, IdentityGetMutesMessage, IdentityGetMutesResultMessage, IdentityGetProfileMessage, IdentityGetProfileResultMessage, IdentityGetPublicKeyMessage, IdentityGetPublicKeyResultMessage, IdentityGetRelaysMessage, IdentityGetRelaysResultMessage, IdentityGetZapsMessage, IdentityGetZapsResultMessage, IdentityMessage, IdentityNapMessage, RelayPermission as IdentityRelayPermission, IdentityRequestMessage, IdentityResultMessage, ProfileData, ZapReceipt, identityGetBadges, identityGetBlocked, identityGetFollows, identityGetList, identityGetMutes, identityGetProfile, identityGetPublicKey, identityGetRelays, identityGetZaps, identityOnChanged, installIdentityShim } from '@napplet/nap/identity';
|
|
7
5
|
export { DOMAIN as STORAGE_DOMAIN, StorageGetMessage, StorageGetResultMessage, StorageKeysMessage, StorageKeysResultMessage, StorageMessage, StorageNapMessage, StorageRemoveMessage, StorageRemoveResultMessage, StorageRequestMessage, StorageResultMessage, StorageSetMessage, StorageSetResultMessage, installStorageShim, storageGetItem, storageInstanceGetItem, storageInstanceKeys, storageInstanceRemoveItem, storageInstanceSetItem, storageKeys, storageRemoveItem, storageSetItem } from '@napplet/nap/storage';
|
|
@@ -9,6 +7,7 @@ export { DOMAIN as INC_DOMAIN, IncChannelBroadcastMessage, IncChannelCloseMessag
|
|
|
9
7
|
export { DOMAIN as IFC_DOMAIN, IfcChannelBroadcastMessage, IfcChannelCloseMessage, IfcChannelClosedMessage, IfcChannelEmitMessage, IfcChannelEventMessage, IfcChannelListMessage, IfcChannelListResultMessage, IfcChannelMessage, IfcChannelOpenMessage, IfcChannelOpenResultMessage, IfcEmitMessage, IfcEventMessage, IfcInboundMessage, IfcMessage, IfcNapMessage, IfcOutboundMessage, IfcSubscribeMessage, IfcSubscribeResultMessage, IfcTopicMessage, IfcUnsubscribeMessage, ifcEmit, ifcOn, installIfcShim } from '@napplet/nap/ifc';
|
|
10
8
|
export { DOMAIN as THEME_DOMAIN, Theme, ThemeBackground, ThemeChangedMessage, ThemeColors, ThemeFont, ThemeGetMessage, ThemeGetResultMessage, ThemeMessage, ThemeNapMessage, ThemeRequestMessage, ThemeResultMessage, installThemeShim, themeGet, themeOnChanged } from '@napplet/nap/theme';
|
|
11
9
|
export { Action, DOMAIN as KEYS_DOMAIN, KeyBinding, KeysActionMessage, KeysBindingsMessage, KeysForwardMessage, KeysMessage, KeysNapMessage, KeysRegisterActionMessage, KeysRegisterActionResultMessage, KeysRequestMessage, KeysResultMessage, KeysUnregisterActionMessage, RegisterResult, installKeysShim, keysOnAction, keysRegister, keysRegisterAction, keysUnregisterAction } from '@napplet/nap/keys';
|
|
10
|
+
export { DOMAIN as MEDIA_DOMAIN, MediaAction, MediaArtwork, MediaCapabilitiesMessage, MediaCommandMessage, MediaContextLink, MediaControlsMessage, MediaMessage, MediaMetadata, MediaNapMessage, MediaNostrRef, MediaPlaybackOwner, MediaRequestMessage, MediaResultMessage, MediaSessionContext, MediaSessionCreate, MediaSessionCreateMessage, MediaSessionCreateResultMessage, MediaSessionDestroyMessage, MediaSessionResult, MediaSessionUpdateMessage, MediaSourceRef, MediaState, MediaStateMessage, installMediaShim, mediaCreateSession, mediaDestroySession, mediaOnCapabilities, mediaOnCommand, mediaOnControls, mediaOnState, mediaReportCapabilities, mediaReportState, mediaSendCommand, mediaUpdateSession } from '@napplet/nap/media';
|
|
12
11
|
export { DOMAIN as NOTIFY_DOMAIN, NotificationAction, NotificationChannel, NotificationPriority, NotifyActionMessage, NotifyBadgeMessage, NotifyChannelRegisterMessage, NotifyClickedMessage, NotifyControl, NotifyControlsMessage, NotifyDismissMessage, NotifyDismissedMessage, NotifyMessage, NotifyNapMessage, NotifyPermissionRequestMessage, NotifyPermissionResultMessage, NotifyRequestMessage, NotifyResultMessage, NotifySendMessage, NotifySendResultMessage, installNotifyShim, notifyBadge, notifyDismiss, notifyOnAction, notifyOnClicked, notifyOnControls, notifyOnDismissed, notifyRegisterChannel, notifyRequestPermission, notifySend } from '@napplet/nap/notify';
|
|
13
12
|
export { DOMAIN as CONFIG_DOMAIN, ConfigGetMessage, ConfigMessage, ConfigNapMessage, ConfigOpenSettingsMessage, ConfigRegisterSchemaMessage, ConfigRegisterSchemaResultMessage, ConfigRequestMessage, ConfigResultMessage, ConfigSchema, ConfigSchemaErrorCode, ConfigSchemaErrorMessage, ConfigSubscribeMessage, ConfigUnsubscribeMessage, ConfigValues, ConfigValuesMessage, NappletConfigSchema, NappletConfigSchemaExtensions, installConfigShim } from '@napplet/nap/config';
|
|
14
13
|
export { DOMAIN as RESOURCE_DOMAIN, ResourceBytesErrorItem, ResourceBytesErrorMessage, ResourceBytesItem, ResourceBytesManyErrorMessage, ResourceBytesManyMessage, ResourceBytesManyResultMessage, ResourceBytesMessage, ResourceBytesOkItem, ResourceBytesResultMessage, ResourceCancelMessage, ResourceErrorCode, ResourceMessage, ResourceNapMessage, ResourceRequestMessage, ResourceResultMessage, ResourceScheme, ResourceSidecarEntry, installResourceShim, resourceBytes, resourceBytesAsObjectURL, resourceBytesMany, resourceInfo } from '@napplet/nap/resource';
|
|
@@ -31,6 +30,7 @@ export { DOMAIN as DM_DOMAIN, DmConversation, DmConversationPage, DmConversation
|
|
|
31
30
|
* @packageDocumentation
|
|
32
31
|
*/
|
|
33
32
|
|
|
33
|
+
type SdkDomain$5<K extends keyof NappletGlobal> = NonNullable<NappletGlobal[K]>;
|
|
34
34
|
/**
|
|
35
35
|
* NIP-01 relay operations: subscribe to events, publish events, one-shot queries.
|
|
36
36
|
*
|
|
@@ -48,43 +48,7 @@ export { DOMAIN as DM_DOMAIN, DmConversation, DmConversationPage, DmConversation
|
|
|
48
48
|
* );
|
|
49
49
|
* ```
|
|
50
50
|
*/
|
|
51
|
-
declare const relay:
|
|
52
|
-
/**
|
|
53
|
-
* Open a live NIP-01 subscription through the shell's relay pool.
|
|
54
|
-
* @param filters One or more NIP-01 subscription filters
|
|
55
|
-
* @param onEvent Called for each matching event result
|
|
56
|
-
* @param onEose Called when the shell signals end of stored events (EOSE)
|
|
57
|
-
* @param options Optional: `{ relay, group }` for NIP-29 scoped relay subscriptions
|
|
58
|
-
* @returns A Subscription handle with a `close()` method
|
|
59
|
-
*/
|
|
60
|
-
subscribe(filters: NostrFilter | NostrFilter[], onEvent: (result: RelayEventResult) => void, onEose: () => void, options?: {
|
|
61
|
-
relay?: string;
|
|
62
|
-
group?: string;
|
|
63
|
-
}): Subscription;
|
|
64
|
-
/**
|
|
65
|
-
* Sign and publish a Nostr event through the shell.
|
|
66
|
-
* @param template Unsigned event template
|
|
67
|
-
* @param options Optional: `{ relay: true }` to publish via scoped relay
|
|
68
|
-
* @returns The signed NostrEvent after successful publication
|
|
69
|
-
*/
|
|
70
|
-
publish(template: EventTemplate, options?: {
|
|
71
|
-
relay?: boolean;
|
|
72
|
-
}): Promise<NostrEvent>;
|
|
73
|
-
/**
|
|
74
|
-
* Publish an encrypted Nostr event through the shell.
|
|
75
|
-
* @param template Unsigned event template
|
|
76
|
-
* @param recipient Hex-encoded recipient public key
|
|
77
|
-
* @param encryption Encryption scheme: 'nip44' (default) or 'nip04'
|
|
78
|
-
* @returns The signed encrypted NostrEvent after successful publication
|
|
79
|
-
*/
|
|
80
|
-
publishEncrypted(template: EventTemplate, recipient: string, encryption?: "nip44" | "nip04"): Promise<NostrEvent>;
|
|
81
|
-
/**
|
|
82
|
-
* One-shot query: subscribe, collect events until EOSE, then resolve.
|
|
83
|
-
* @param filters NIP-01 subscription filters
|
|
84
|
-
* @returns Promise resolving to array of matching event results
|
|
85
|
-
*/
|
|
86
|
-
query(filters: NostrFilter | NostrFilter[]): Promise<RelayEventResult[]>;
|
|
87
|
-
};
|
|
51
|
+
declare const relay: SdkDomain$5<'relay'>;
|
|
88
52
|
/**
|
|
89
53
|
* Inter-napplet pubsub: broadcast and receive INC-PEER events through the shell.
|
|
90
54
|
*
|
|
@@ -99,42 +63,12 @@ declare const relay: {
|
|
|
99
63
|
* });
|
|
100
64
|
* ```
|
|
101
65
|
*/
|
|
102
|
-
declare const inc:
|
|
103
|
-
/**
|
|
104
|
-
* Broadcast an INC-PEER event to other napplets via the shell.
|
|
105
|
-
* @param topic The 't' tag value (e.g., 'profile:open')
|
|
106
|
-
* @param extraTags Additional NIP-01 tags beyond the 't' tag (default: [])
|
|
107
|
-
* @param content Event content (default: empty string)
|
|
108
|
-
*/
|
|
109
|
-
emit(topic: string, extraTags?: string[][], content?: string): void;
|
|
110
|
-
/**
|
|
111
|
-
* Subscribe to INC-PEER events on a specific topic.
|
|
112
|
-
* @param topic The 't' tag value to listen for
|
|
113
|
-
* @param callback Called with `(payload, event)` for each matching event
|
|
114
|
-
* @returns A Subscription handle with a `close()` method
|
|
115
|
-
*/
|
|
116
|
-
on(topic: string, callback: (payload: unknown, event: NostrEvent) => void): Subscription;
|
|
117
|
-
};
|
|
66
|
+
declare const inc: SdkDomain$5<'inc'>;
|
|
118
67
|
/**
|
|
119
68
|
* @deprecated Use {@link inc}. NAP-IFC was renamed to NAP-INC; this package
|
|
120
69
|
* alias is kept only to ease downstream migration.
|
|
121
70
|
*/
|
|
122
|
-
declare const ifc:
|
|
123
|
-
/**
|
|
124
|
-
* Broadcast an INC-PEER event to other napplets via the shell.
|
|
125
|
-
* @param topic The 't' tag value (e.g., 'profile:open')
|
|
126
|
-
* @param extraTags Additional NIP-01 tags beyond the 't' tag (default: [])
|
|
127
|
-
* @param content Event content (default: empty string)
|
|
128
|
-
*/
|
|
129
|
-
emit(topic: string, extraTags?: string[][], content?: string): void;
|
|
130
|
-
/**
|
|
131
|
-
* Subscribe to INC-PEER events on a specific topic.
|
|
132
|
-
* @param topic The 't' tag value to listen for
|
|
133
|
-
* @param callback Called with `(payload, event)` for each matching event
|
|
134
|
-
* @returns A Subscription handle with a `close()` method
|
|
135
|
-
*/
|
|
136
|
-
on(topic: string, callback: (payload: unknown, event: NostrEvent) => void): Subscription;
|
|
137
|
-
};
|
|
71
|
+
declare const ifc: SdkDomain$5<'inc'>;
|
|
138
72
|
/**
|
|
139
73
|
* Napplet-scoped storage: async localStorage-like API proxied through the shell.
|
|
140
74
|
* Each napplet's storage is isolated by identity.
|
|
@@ -147,58 +81,7 @@ declare const ifc: {
|
|
|
147
81
|
* const theme = await storage.getItem('theme'); // 'dark'
|
|
148
82
|
* ```
|
|
149
83
|
*/
|
|
150
|
-
declare const storage:
|
|
151
|
-
/**
|
|
152
|
-
* Retrieve a stored value by key. Returns null if the key does not exist.
|
|
153
|
-
* @param key The storage key
|
|
154
|
-
* @returns The stored string value, or null if not found
|
|
155
|
-
*/
|
|
156
|
-
getItem(key: string): Promise<string | null>;
|
|
157
|
-
/**
|
|
158
|
-
* Store a key-value pair.
|
|
159
|
-
* @param key The storage key
|
|
160
|
-
* @param value The string value to store
|
|
161
|
-
*/
|
|
162
|
-
setItem(key: string, value: string): Promise<void>;
|
|
163
|
-
/**
|
|
164
|
-
* Remove a stored key.
|
|
165
|
-
* @param key The storage key to remove
|
|
166
|
-
*/
|
|
167
|
-
removeItem(key: string): Promise<void>;
|
|
168
|
-
/**
|
|
169
|
-
* List all keys stored by this napplet.
|
|
170
|
-
* @returns Array of storage key strings
|
|
171
|
-
*/
|
|
172
|
-
keys(): Promise<string[]>;
|
|
173
|
-
/**
|
|
174
|
-
* Per-instance storage: same surface as the shared methods, but scoped to this
|
|
175
|
-
* napplet instance (sets `scope: "instance"` on the wire) rather than shared
|
|
176
|
-
* across instances. Defer to NAP-STORAGE (napplet/naps) for scope semantics.
|
|
177
|
-
*/
|
|
178
|
-
instance: {
|
|
179
|
-
/**
|
|
180
|
-
* Retrieve a per-instance value by key. Returns null if not found.
|
|
181
|
-
* @param key The storage key
|
|
182
|
-
*/
|
|
183
|
-
getItem(key: string): Promise<string | null>;
|
|
184
|
-
/**
|
|
185
|
-
* Store a per-instance key-value pair.
|
|
186
|
-
* @param key The storage key
|
|
187
|
-
* @param value The string value to store
|
|
188
|
-
*/
|
|
189
|
-
setItem(key: string, value: string): Promise<void>;
|
|
190
|
-
/**
|
|
191
|
-
* Remove a per-instance key.
|
|
192
|
-
* @param key The storage key to remove
|
|
193
|
-
*/
|
|
194
|
-
removeItem(key: string): Promise<void>;
|
|
195
|
-
/**
|
|
196
|
-
* List all per-instance keys for this napplet instance.
|
|
197
|
-
* @returns Array of storage key strings
|
|
198
|
-
*/
|
|
199
|
-
keys(): Promise<string[]>;
|
|
200
|
-
};
|
|
201
|
-
};
|
|
84
|
+
declare const storage: SdkDomain$5<'storage'>;
|
|
202
85
|
|
|
203
86
|
/**
|
|
204
87
|
* @napplet/sdk -- Media session and notification wrapper objects.
|
|
@@ -206,6 +89,7 @@ declare const storage: {
|
|
|
206
89
|
* @packageDocumentation
|
|
207
90
|
*/
|
|
208
91
|
|
|
92
|
+
type SdkDomain$4<K extends keyof NappletGlobal> = NonNullable<NappletGlobal[K]>;
|
|
209
93
|
/**
|
|
210
94
|
* Media session control: create sessions, report state and metadata,
|
|
211
95
|
* declare capabilities, receive commands from the shell.
|
|
@@ -222,72 +106,7 @@ declare const storage: {
|
|
|
222
106
|
* media.reportState(sessionId, { status: 'playing', position: 42.5 });
|
|
223
107
|
* ```
|
|
224
108
|
*/
|
|
225
|
-
declare const media:
|
|
226
|
-
/**
|
|
227
|
-
* Create a new media session with the shell.
|
|
228
|
-
* @param options Ownership-aware session options
|
|
229
|
-
* @returns The shell result with canonical sessionId and owner, or error
|
|
230
|
-
*/
|
|
231
|
-
createSession(options: MediaSessionCreate): Promise<MediaSessionResult>;
|
|
232
|
-
/**
|
|
233
|
-
* Update metadata for an existing session.
|
|
234
|
-
* @param sessionId The session to update
|
|
235
|
-
* @param metadata Partial metadata fields to update
|
|
236
|
-
*/
|
|
237
|
-
updateSession(sessionId: string, metadata: Partial<MediaMetadata>): void;
|
|
238
|
-
/**
|
|
239
|
-
* Destroy a media session.
|
|
240
|
-
* @param sessionId The session to destroy
|
|
241
|
-
*/
|
|
242
|
-
destroySession(sessionId: string): void;
|
|
243
|
-
/**
|
|
244
|
-
* Report current playback state for a session.
|
|
245
|
-
* @param sessionId The session to report state for
|
|
246
|
-
* @param state Current playback state
|
|
247
|
-
*/
|
|
248
|
-
reportState(sessionId: string, state: MediaState): void;
|
|
249
|
-
/**
|
|
250
|
-
* Declare which media actions the session currently supports.
|
|
251
|
-
* @param sessionId The session to update capabilities for
|
|
252
|
-
* @param actions Currently supported actions
|
|
253
|
-
*/
|
|
254
|
-
reportCapabilities(sessionId: string, actions: MediaAction[]): void;
|
|
255
|
-
/**
|
|
256
|
-
* Send a command to the current playback owner.
|
|
257
|
-
* @param sessionId The session to control
|
|
258
|
-
* @param action The media action to request
|
|
259
|
-
* @param value Optional value for seek/volume
|
|
260
|
-
*/
|
|
261
|
-
sendCommand(sessionId: string, action: MediaAction, value?: number): void;
|
|
262
|
-
/**
|
|
263
|
-
* Listen for media commands from the shell.
|
|
264
|
-
* @param sessionId The session to listen for commands on
|
|
265
|
-
* @param callback Called with (action, value?) when a command is received
|
|
266
|
-
* @returns A Subscription with `close()` to stop listening
|
|
267
|
-
*/
|
|
268
|
-
onCommand(sessionId: string, callback: (action: MediaAction, value?: number) => void): Subscription;
|
|
269
|
-
/**
|
|
270
|
-
* Listen for shell-reported playback state for shell-owned sessions.
|
|
271
|
-
* @param sessionId The session to listen for state on
|
|
272
|
-
* @param callback Called with playback state
|
|
273
|
-
* @returns A Subscription with `close()` to stop listening
|
|
274
|
-
*/
|
|
275
|
-
onState(sessionId: string, callback: (state: MediaState) => void): Subscription;
|
|
276
|
-
/**
|
|
277
|
-
* Listen for shell-reported capabilities for shell-owned sessions.
|
|
278
|
-
* @param sessionId The session to listen for capabilities on
|
|
279
|
-
* @param callback Called with available actions
|
|
280
|
-
* @returns A Subscription with `close()` to stop listening
|
|
281
|
-
*/
|
|
282
|
-
onCapabilities(sessionId: string, callback: (actions: MediaAction[]) => void): Subscription;
|
|
283
|
-
/**
|
|
284
|
-
* Listen for the shell's media control list.
|
|
285
|
-
* @param sessionId The session to associate controls with
|
|
286
|
-
* @param callback Called with the shell's supported controls
|
|
287
|
-
* @returns A Subscription with `close()` to stop listening
|
|
288
|
-
*/
|
|
289
|
-
onControls(sessionId: string, callback: (controls: MediaAction[]) => void): Subscription;
|
|
290
|
-
};
|
|
109
|
+
declare const media: SdkDomain$4<'media'>;
|
|
291
110
|
/**
|
|
292
111
|
* Shell-rendered notifications: send notifications, set badge counts,
|
|
293
112
|
* register channels, request permission, listen for user interaction.
|
|
@@ -303,78 +122,7 @@ declare const media: {
|
|
|
303
122
|
* notify.badge(3);
|
|
304
123
|
* ```
|
|
305
124
|
*/
|
|
306
|
-
declare const notify:
|
|
307
|
-
/**
|
|
308
|
-
* Send a notification to the shell.
|
|
309
|
-
* @param notification Notification payload (title required)
|
|
310
|
-
* @returns The shell-assigned notificationId
|
|
311
|
-
*/
|
|
312
|
-
send(notification: {
|
|
313
|
-
title: string;
|
|
314
|
-
body?: string;
|
|
315
|
-
icon?: string;
|
|
316
|
-
actions?: {
|
|
317
|
-
id: string;
|
|
318
|
-
label: string;
|
|
319
|
-
}[];
|
|
320
|
-
channel?: string;
|
|
321
|
-
priority?: "low" | "normal" | "high" | "urgent";
|
|
322
|
-
}): Promise<{
|
|
323
|
-
notificationId: string;
|
|
324
|
-
}>;
|
|
325
|
-
/**
|
|
326
|
-
* Dismiss a notification by ID.
|
|
327
|
-
* @param notificationId The notification to dismiss
|
|
328
|
-
*/
|
|
329
|
-
dismiss(notificationId: string): void;
|
|
330
|
-
/**
|
|
331
|
-
* Set the badge count for this napplet. Pass 0 to clear.
|
|
332
|
-
* @param count Badge count
|
|
333
|
-
*/
|
|
334
|
-
badge(count: number): void;
|
|
335
|
-
/**
|
|
336
|
-
* Register a notification channel.
|
|
337
|
-
* @param channel Channel definition
|
|
338
|
-
*/
|
|
339
|
-
registerChannel(channel: {
|
|
340
|
-
channelId: string;
|
|
341
|
-
label: string;
|
|
342
|
-
description?: string;
|
|
343
|
-
defaultPriority?: "low" | "normal" | "high" | "urgent";
|
|
344
|
-
}): void;
|
|
345
|
-
/**
|
|
346
|
-
* Request permission to send notifications.
|
|
347
|
-
* @param channel Optional channel to request permission for
|
|
348
|
-
* @returns Whether permission was granted
|
|
349
|
-
*/
|
|
350
|
-
requestPermission(channel?: string): Promise<{
|
|
351
|
-
granted: boolean;
|
|
352
|
-
}>;
|
|
353
|
-
/**
|
|
354
|
-
* Listen for action button clicks on notifications.
|
|
355
|
-
* @param callback Called with (notificationId, actionId)
|
|
356
|
-
* @returns A Subscription with `close()` to stop listening
|
|
357
|
-
*/
|
|
358
|
-
onAction(callback: (notificationId: string, actionId: string) => void): Subscription;
|
|
359
|
-
/**
|
|
360
|
-
* Listen for notification body clicks.
|
|
361
|
-
* @param callback Called with (notificationId)
|
|
362
|
-
* @returns A Subscription with `close()` to stop listening
|
|
363
|
-
*/
|
|
364
|
-
onClicked(callback: (notificationId: string) => void): Subscription;
|
|
365
|
-
/**
|
|
366
|
-
* Listen for notification dismissals.
|
|
367
|
-
* @param callback Called with (notificationId, reason?)
|
|
368
|
-
* @returns A Subscription with `close()` to stop listening
|
|
369
|
-
*/
|
|
370
|
-
onDismissed(callback: (notificationId: string, reason?: string) => void): Subscription;
|
|
371
|
-
/**
|
|
372
|
-
* Listen for the shell's notification capability list.
|
|
373
|
-
* @param callback Called with supported controls
|
|
374
|
-
* @returns A Subscription with `close()` to stop listening
|
|
375
|
-
*/
|
|
376
|
-
onControls(callback: (controls: ("toasts" | "badges" | "actions" | "channels" | "system")[]) => void): Subscription;
|
|
377
|
-
};
|
|
125
|
+
declare const notify: SdkDomain$4<'notify'>;
|
|
378
126
|
|
|
379
127
|
/**
|
|
380
128
|
* @napplet/sdk -- Keyboard action and read-only identity wrapper objects.
|
|
@@ -382,6 +130,18 @@ declare const notify: {
|
|
|
382
130
|
* @packageDocumentation
|
|
383
131
|
*/
|
|
384
132
|
|
|
133
|
+
type SdkDomain$3<K extends keyof NappletGlobal> = NonNullable<NappletGlobal[K]>;
|
|
134
|
+
interface KeysSdk extends SdkDomain$3<'keys'> {
|
|
135
|
+
register(action: {
|
|
136
|
+
id: string;
|
|
137
|
+
label: string;
|
|
138
|
+
defaultKey?: string;
|
|
139
|
+
}, handler: () => void): Promise<{
|
|
140
|
+
actionId: string;
|
|
141
|
+
binding?: string;
|
|
142
|
+
close: () => void;
|
|
143
|
+
}>;
|
|
144
|
+
}
|
|
385
145
|
/**
|
|
386
146
|
* Keyboard forwarding and action keybindings: register named actions the shell
|
|
387
147
|
* can bind to keys, listen for shell-triggered actions locally.
|
|
@@ -401,64 +161,7 @@ declare const notify: {
|
|
|
401
161
|
* });
|
|
402
162
|
* ```
|
|
403
163
|
*/
|
|
404
|
-
declare const keys:
|
|
405
|
-
/**
|
|
406
|
-
* Declare a named action that the shell can bind to a key.
|
|
407
|
-
* @param action The action to register (id, label, optional defaultKey)
|
|
408
|
-
* @returns The assigned binding, if any
|
|
409
|
-
*/
|
|
410
|
-
registerAction(action: {
|
|
411
|
-
id: string;
|
|
412
|
-
label: string;
|
|
413
|
-
defaultKey?: string;
|
|
414
|
-
}): Promise<{
|
|
415
|
-
actionId: string;
|
|
416
|
-
binding?: string;
|
|
417
|
-
}>;
|
|
418
|
-
/**
|
|
419
|
-
* Remove a previously registered action.
|
|
420
|
-
* @param actionId The action to unregister
|
|
421
|
-
*/
|
|
422
|
-
unregisterAction(actionId: string): void;
|
|
423
|
-
/**
|
|
424
|
-
* Register a local handler for when a bound key is pressed.
|
|
425
|
-
* @param actionId The action to listen for
|
|
426
|
-
* @param callback Called when the action is triggered
|
|
427
|
-
* @returns A Subscription with `close()` to stop listening
|
|
428
|
-
*/
|
|
429
|
-
onAction(actionId: string, callback: () => void): Subscription;
|
|
430
|
-
/**
|
|
431
|
-
* Convenience: register a named action AND wire a local handler in one call.
|
|
432
|
-
* Returns a handle whose `close()` both unregisters the action and removes
|
|
433
|
-
* the onAction listener.
|
|
434
|
-
*
|
|
435
|
-
* @param action The action to register (id, label, optional defaultKey)
|
|
436
|
-
* @param handler Called when the shell triggers this action
|
|
437
|
-
* @returns The assigned binding plus a `close()` teardown function
|
|
438
|
-
*
|
|
439
|
-
* @example
|
|
440
|
-
* ```ts
|
|
441
|
-
* import { keys } from '@napplet/sdk';
|
|
442
|
-
*
|
|
443
|
-
* const handle = await keys.register(
|
|
444
|
-
* { id: 'editor.save', label: 'Save', defaultKey: 'Ctrl+S' },
|
|
445
|
-
* () => saveDocument(),
|
|
446
|
-
* );
|
|
447
|
-
*
|
|
448
|
-
* // Later, tear down both registration and listener:
|
|
449
|
-
* handle.close();
|
|
450
|
-
* ```
|
|
451
|
-
*/
|
|
452
|
-
register(action: {
|
|
453
|
-
id: string;
|
|
454
|
-
label: string;
|
|
455
|
-
defaultKey?: string;
|
|
456
|
-
}, handler: () => void): Promise<{
|
|
457
|
-
actionId: string;
|
|
458
|
-
binding?: string;
|
|
459
|
-
close: () => void;
|
|
460
|
-
}>;
|
|
461
|
-
};
|
|
164
|
+
declare const keys: KeysSdk;
|
|
462
165
|
/**
|
|
463
166
|
* Read-only user identity queries: public key, profile, follows, relays,
|
|
464
167
|
* lists, zaps, mutes, blocked, badges.
|
|
@@ -472,84 +175,7 @@ declare const keys: {
|
|
|
472
175
|
* const follows = await identity.getFollows();
|
|
473
176
|
* ```
|
|
474
177
|
*/
|
|
475
|
-
declare const identity:
|
|
476
|
-
/**
|
|
477
|
-
* Get the user's hex-encoded public key. Always succeeds.
|
|
478
|
-
* @returns Hex-encoded public key string
|
|
479
|
-
*/
|
|
480
|
-
getPublicKey(): Promise<string>;
|
|
481
|
-
/**
|
|
482
|
-
* Listen for shell-pushed user identity changes.
|
|
483
|
-
* @param handler Called with a hex pubkey, or "" when no user/signer is connected
|
|
484
|
-
* @returns Subscription with close() to detach the handler
|
|
485
|
-
*/
|
|
486
|
-
onChanged(handler: (pubkey: string) => void): Subscription;
|
|
487
|
-
/**
|
|
488
|
-
* Get the user's relay list (NIP-65).
|
|
489
|
-
* @returns Record mapping relay URLs to read/write permissions
|
|
490
|
-
*/
|
|
491
|
-
getRelays(): Promise<Record<string, {
|
|
492
|
-
read: boolean;
|
|
493
|
-
write: boolean;
|
|
494
|
-
}>>;
|
|
495
|
-
/**
|
|
496
|
-
* Get the user's profile metadata (kind 0).
|
|
497
|
-
* @returns Profile data, or null if not found
|
|
498
|
-
*/
|
|
499
|
-
getProfile(): Promise<{
|
|
500
|
-
name?: string;
|
|
501
|
-
displayName?: string;
|
|
502
|
-
about?: string;
|
|
503
|
-
picture?: string;
|
|
504
|
-
banner?: string;
|
|
505
|
-
nip05?: string;
|
|
506
|
-
lud16?: string;
|
|
507
|
-
website?: string;
|
|
508
|
-
} | null>;
|
|
509
|
-
/**
|
|
510
|
-
* Get the user's follow list (kind 3 contact list).
|
|
511
|
-
* @returns Array of hex-encoded public keys
|
|
512
|
-
*/
|
|
513
|
-
getFollows(): Promise<string[]>;
|
|
514
|
-
/**
|
|
515
|
-
* Get entries from a user's categorized list.
|
|
516
|
-
* @param listType List category (e.g., "bookmarks", "interests", "pins")
|
|
517
|
-
* @returns Array of list entry values
|
|
518
|
-
*/
|
|
519
|
-
getList(listType: string): Promise<string[]>;
|
|
520
|
-
/**
|
|
521
|
-
* Get zap receipts sent to the user.
|
|
522
|
-
* @returns Array of zap receipt objects
|
|
523
|
-
*/
|
|
524
|
-
getZaps(): Promise<{
|
|
525
|
-
eventId: string;
|
|
526
|
-
sender: string;
|
|
527
|
-
amount: number;
|
|
528
|
-
content?: string;
|
|
529
|
-
}[]>;
|
|
530
|
-
/**
|
|
531
|
-
* Get the user's mute list (kind 10000).
|
|
532
|
-
* @returns Array of hex-encoded muted public keys
|
|
533
|
-
*/
|
|
534
|
-
getMutes(): Promise<string[]>;
|
|
535
|
-
/**
|
|
536
|
-
* Get the user's block list.
|
|
537
|
-
* @returns Array of hex-encoded blocked public keys
|
|
538
|
-
*/
|
|
539
|
-
getBlocked(): Promise<string[]>;
|
|
540
|
-
/**
|
|
541
|
-
* Get badges awarded to the user (NIP-58).
|
|
542
|
-
* @returns Array of badge objects
|
|
543
|
-
*/
|
|
544
|
-
getBadges(): Promise<{
|
|
545
|
-
id: string;
|
|
546
|
-
name?: string;
|
|
547
|
-
description?: string;
|
|
548
|
-
image?: string;
|
|
549
|
-
thumbs?: string[];
|
|
550
|
-
awardedBy: string;
|
|
551
|
-
}[]>;
|
|
552
|
-
};
|
|
178
|
+
declare const identity: SdkDomain$3<'identity'>;
|
|
553
179
|
|
|
554
180
|
/**
|
|
555
181
|
* @napplet/sdk -- Declarative config and resource byte-fetch wrapper objects.
|
|
@@ -557,6 +183,7 @@ declare const identity: {
|
|
|
557
183
|
* @packageDocumentation
|
|
558
184
|
*/
|
|
559
185
|
|
|
186
|
+
type SdkDomain$2<K extends keyof NappletGlobal> = NonNullable<NappletGlobal[K]>;
|
|
560
187
|
/**
|
|
561
188
|
* Per-napplet declarative configuration (NAP-CONFIG): register a schema,
|
|
562
189
|
* read current values, subscribe to live updates, deep-link into the
|
|
@@ -576,51 +203,7 @@ declare const identity: {
|
|
|
576
203
|
* config.openSettings({ section: 'appearance' });
|
|
577
204
|
* ```
|
|
578
205
|
*/
|
|
579
|
-
declare const config:
|
|
580
|
-
/**
|
|
581
|
-
* Snapshot current validated + defaulted config values.
|
|
582
|
-
* @returns A one-shot ConfigValues object.
|
|
583
|
-
*/
|
|
584
|
-
get(): Promise<Record<string, unknown>>;
|
|
585
|
-
/**
|
|
586
|
-
* Subscribe to live configuration updates.
|
|
587
|
-
* First delivery is an immediate snapshot; subsequent deliveries fire on change.
|
|
588
|
-
* @param callback Invoked with the full ConfigValues on every change.
|
|
589
|
-
* @returns A Subscription with close() to stop listening.
|
|
590
|
-
*/
|
|
591
|
-
subscribe(callback: (values: Record<string, unknown>) => void): Subscription;
|
|
592
|
-
/**
|
|
593
|
-
* Request the shell open its settings UI for this napplet.
|
|
594
|
-
* @param options Optional { section } to deep-link by x-napplet-section name.
|
|
595
|
-
*/
|
|
596
|
-
openSettings(options?: {
|
|
597
|
-
section?: string;
|
|
598
|
-
}): void;
|
|
599
|
-
/**
|
|
600
|
-
* Register a napplet configuration schema at runtime (escape hatch;
|
|
601
|
-
* prefer manifest-declared via @napplet/vite-plugin's configSchema option).
|
|
602
|
-
* @param schema JSON Schema (draft-07+) describing the config surface.
|
|
603
|
-
* @param version Optional `$version` migration hint.
|
|
604
|
-
*/
|
|
605
|
-
registerSchema(schema: Record<string, unknown>, version?: number): Promise<void>;
|
|
606
|
-
/**
|
|
607
|
-
* Listen for schema-registration errors pushed by the shell
|
|
608
|
-
* (manifest parse failure, no-schema on subscribe-before-schema, etc.).
|
|
609
|
-
* @param callback Invoked with { code, error } on every push.
|
|
610
|
-
* @returns A plain teardown function that detaches the listener.
|
|
611
|
-
*/
|
|
612
|
-
onSchemaError(callback: (err: {
|
|
613
|
-
code: string;
|
|
614
|
-
error: string;
|
|
615
|
-
}) => void): () => void;
|
|
616
|
-
/**
|
|
617
|
-
* Current schema snapshot (readonly). Populated from the
|
|
618
|
-
* `<meta name="napplet-config-schema">` manifest tag at shim install,
|
|
619
|
-
* updated on successful registerSchema responses.
|
|
620
|
-
* @returns The registered schema, or null if none.
|
|
621
|
-
*/
|
|
622
|
-
readonly schema: Record<string, unknown> | null;
|
|
623
|
-
};
|
|
206
|
+
declare const config: SdkDomain$2<'config'>;
|
|
624
207
|
/**
|
|
625
208
|
* Browser-enforced byte-fetching primitive: napplets request bytes by URL,
|
|
626
209
|
* shell fetches and returns a Blob. URL space is scheme-pluggable
|
|
@@ -640,40 +223,7 @@ declare const config: {
|
|
|
640
223
|
* imgEl.onload = () => handle.revoke();
|
|
641
224
|
* ```
|
|
642
225
|
*/
|
|
643
|
-
declare const resource:
|
|
644
|
-
/**
|
|
645
|
-
* Inspect resource schemes and coarse runtime policy limits.
|
|
646
|
-
* @returns Promise resolving to advisory resource info.
|
|
647
|
-
*/
|
|
648
|
-
info(): Promise<ResourceInfo>;
|
|
649
|
-
/**
|
|
650
|
-
* Fetch bytes for a URL through the shell's resource pipeline.
|
|
651
|
-
* @param url URL identifying the resource (any registered scheme).
|
|
652
|
-
* @returns Promise resolving to the fetched bytes as a Blob.
|
|
653
|
-
*/
|
|
654
|
-
bytes(url: string, opts?: {
|
|
655
|
-
signal?: AbortSignal;
|
|
656
|
-
}): Promise<Blob>;
|
|
657
|
-
/**
|
|
658
|
-
* Fetch bytes for many URLs through one shell envelope.
|
|
659
|
-
* @param urls Non-empty URL list.
|
|
660
|
-
* @param opts Optional AbortController signal.
|
|
661
|
-
* @returns Promise resolving to ordered per-URL result items.
|
|
662
|
-
*/
|
|
663
|
-
bytesMany(urls: string[], opts?: {
|
|
664
|
-
signal?: AbortSignal;
|
|
665
|
-
}): Promise<ResourceBytesItem[]>;
|
|
666
|
-
/**
|
|
667
|
-
* Fetch bytes and return a managed object URL handle.
|
|
668
|
-
* Call `revoke()` to release the underlying Blob URL.
|
|
669
|
-
* @param url URL identifying the resource.
|
|
670
|
-
* @returns Synchronous handle `{ url, revoke }`.
|
|
671
|
-
*/
|
|
672
|
-
bytesAsObjectURL(url: string): {
|
|
673
|
-
url: string;
|
|
674
|
-
revoke: () => void;
|
|
675
|
-
};
|
|
676
|
-
};
|
|
226
|
+
declare const resource: SdkDomain$2<'resource'>;
|
|
677
227
|
|
|
678
228
|
/**
|
|
679
229
|
* @napplet/sdk -- ContextVM bridge, outbox routing, upload, intent, and WebRTC
|
|
@@ -682,6 +232,7 @@ declare const resource: {
|
|
|
682
232
|
* @packageDocumentation
|
|
683
233
|
*/
|
|
684
234
|
|
|
235
|
+
type SdkDomain$1<K extends keyof NappletGlobal> = NonNullable<NappletGlobal[K]>;
|
|
685
236
|
/**
|
|
686
237
|
* Native ContextVM bridge (NAP-CVM): MCP-over-Nostr access mediated by the shell.
|
|
687
238
|
* The shell owns ContextVM transport, signing, encryption, correlation, policy,
|
|
@@ -696,88 +247,7 @@ declare const resource: {
|
|
|
696
247
|
* const result = await cvm.callTool(servers[0], tools[0].name, {});
|
|
697
248
|
* ```
|
|
698
249
|
*/
|
|
699
|
-
declare const cvm:
|
|
700
|
-
/**
|
|
701
|
-
* Discover public ContextVM servers known to the shell.
|
|
702
|
-
* @param query Optional discovery filter
|
|
703
|
-
* @returns Promise resolving to the discovered servers
|
|
704
|
-
*/
|
|
705
|
-
discover(query?: CvmDiscoverQuery): Promise<CvmServer[]>;
|
|
706
|
-
/**
|
|
707
|
-
* Send a raw MCP JSON-RPC message to a ContextVM server.
|
|
708
|
-
* @param server Target ContextVM server
|
|
709
|
-
* @param message MCP JSON-RPC message
|
|
710
|
-
* @param options Optional per-request options
|
|
711
|
-
* @returns Promise resolving to the MCP response message
|
|
712
|
-
*/
|
|
713
|
-
request(server: CvmServerRef, message: McpMessage, options?: CvmRequestOptions): Promise<McpMessage>;
|
|
714
|
-
/**
|
|
715
|
-
* List the tools exposed by a ContextVM server (MCP `tools/list`).
|
|
716
|
-
* @param server Target ContextVM server
|
|
717
|
-
* @param options Optional per-request options
|
|
718
|
-
*/
|
|
719
|
-
listTools(server: CvmServerRef, options?: CvmRequestOptions): Promise<McpTool[]>;
|
|
720
|
-
/**
|
|
721
|
-
* Call a tool on a ContextVM server (MCP `tools/call`).
|
|
722
|
-
* @param server Target ContextVM server
|
|
723
|
-
* @param name Tool name
|
|
724
|
-
* @param args Tool arguments
|
|
725
|
-
* @param options Optional per-request options
|
|
726
|
-
*/
|
|
727
|
-
callTool(server: CvmServerRef, name: string, args?: Record<string, unknown>, options?: CvmRequestOptions): Promise<McpToolResult>;
|
|
728
|
-
/**
|
|
729
|
-
* List the resources exposed by a ContextVM server (MCP `resources/list`).
|
|
730
|
-
* @param server Target ContextVM server
|
|
731
|
-
* @param options Optional per-request options
|
|
732
|
-
*/
|
|
733
|
-
listResources(server: CvmServerRef, options?: CvmRequestOptions): Promise<McpResource[]>;
|
|
734
|
-
/**
|
|
735
|
-
* Read a resource from a ContextVM server (MCP `resources/read`).
|
|
736
|
-
* @param server Target ContextVM server
|
|
737
|
-
* @param uri Resource URI
|
|
738
|
-
* @param options Optional per-request options
|
|
739
|
-
*/
|
|
740
|
-
readResource(server: CvmServerRef, uri: string, options?: CvmRequestOptions): Promise<McpResourceContent>;
|
|
741
|
-
/**
|
|
742
|
-
* Close shell-maintained session state for a server.
|
|
743
|
-
* @param server Server whose session should be torn down
|
|
744
|
-
*/
|
|
745
|
-
close(server: CvmServerRef): Promise<void>;
|
|
746
|
-
/**
|
|
747
|
-
* Listen for server-pushed MCP messages (`cvm.event`).
|
|
748
|
-
* @param callback Called with `(server, message)` for each server event
|
|
749
|
-
* @returns A Subscription with `close()` to stop listening
|
|
750
|
-
*/
|
|
751
|
-
onEvent(callback: (server: CvmServerRef, message: McpMessage) => void): Subscription;
|
|
752
|
-
/** Shell-curated ContextVM registry families. */
|
|
753
|
-
registry: {
|
|
754
|
-
/**
|
|
755
|
-
* List registry families known to the shell.
|
|
756
|
-
* @param query Optional family/search/schema filter
|
|
757
|
-
*/
|
|
758
|
-
list(query?: CvmRegistryQuery): Promise<CvmRegistryEntry[]>;
|
|
759
|
-
/**
|
|
760
|
-
* Test whether the shell can call a registry family.
|
|
761
|
-
* @param family Registry family name
|
|
762
|
-
* @param options Optional schema/provider constraints
|
|
763
|
-
*/
|
|
764
|
-
has(family: string, options?: CvmRegistryOptions): Promise<boolean>;
|
|
765
|
-
/**
|
|
766
|
-
* Describe the shell-selected registry family entry.
|
|
767
|
-
* @param family Registry family name
|
|
768
|
-
* @param options Optional schema/provider constraints
|
|
769
|
-
*/
|
|
770
|
-
describe(family: string, options?: CvmRegistryOptions): Promise<CvmRegistryEntry>;
|
|
771
|
-
/**
|
|
772
|
-
* Call a tool on the shell-selected provider for a registry family.
|
|
773
|
-
* @param family Registry family name
|
|
774
|
-
* @param tool Tool name inside the family
|
|
775
|
-
* @param args Tool arguments
|
|
776
|
-
* @param options Optional schema/provider/cache/payment constraints
|
|
777
|
-
*/
|
|
778
|
-
call(family: string, tool: string, args?: JsonObject, options?: CvmRegistryCallOptions): Promise<McpToolResult>;
|
|
779
|
-
};
|
|
780
|
-
};
|
|
250
|
+
declare const cvm: SdkDomain$1<'cvm'>;
|
|
781
251
|
/**
|
|
782
252
|
* Outbox-aware relay routing (NAP-OUTBOX): supply Nostr filters and intent and
|
|
783
253
|
* let the shell discover the correct relays (NIP-65 write/read relays, fallbacks,
|
|
@@ -796,42 +266,7 @@ declare const cvm: {
|
|
|
796
266
|
* sub.on('event', (result) => render(result.event, result.sidecar?.relayHints));
|
|
797
267
|
* ```
|
|
798
268
|
*/
|
|
799
|
-
declare const outbox:
|
|
800
|
-
/**
|
|
801
|
-
* Fetch one event by ID through shell-owned outbox routing.
|
|
802
|
-
* @param eventId Event id to fetch
|
|
803
|
-
* @param options Optional author/relay hints and timeout
|
|
804
|
-
* @returns Promise resolving to the outbox event result
|
|
805
|
-
*/
|
|
806
|
-
getEvent(eventId: string, options?: OutboxEventOptions): Promise<OutboxEventResult>;
|
|
807
|
-
/**
|
|
808
|
-
* Perform a one-shot outbox-aware query.
|
|
809
|
-
* @param filters NIP-01 filter or filters
|
|
810
|
-
* @param options Optional query options
|
|
811
|
-
* @returns Promise resolving to the outbox result
|
|
812
|
-
*/
|
|
813
|
-
query(filters: NostrFilter | NostrFilter[], options?: OutboxQueryOptions): Promise<OutboxResult>;
|
|
814
|
-
/**
|
|
815
|
-
* Open a live outbox-aware subscription.
|
|
816
|
-
* @param filters NIP-01 filter or filters
|
|
817
|
-
* @param options Optional subscribe options
|
|
818
|
-
* @returns An OutboxSubscription handle with `on(...)` and `close()`
|
|
819
|
-
*/
|
|
820
|
-
subscribe(filters: NostrFilter | NostrFilter[], options?: OutboxSubscribeOptions): OutboxSubscription;
|
|
821
|
-
/**
|
|
822
|
-
* Publish a shell-signed event using outbox-aware relay fanout.
|
|
823
|
-
* @param template Unsigned event template
|
|
824
|
-
* @param options Optional publish options
|
|
825
|
-
* @returns Promise resolving to the outbox publish result
|
|
826
|
-
*/
|
|
827
|
-
publish(template: EventTemplate, options?: OutboxPublishOptions): Promise<OutboxPublishResult>;
|
|
828
|
-
/**
|
|
829
|
-
* Resolve the relay plan the shell would use for a read/write target.
|
|
830
|
-
* @param target The read/write target
|
|
831
|
-
* @returns Promise resolving to the relay plan
|
|
832
|
-
*/
|
|
833
|
-
resolveRelays(target: OutboxTarget): Promise<OutboxRelayPlan>;
|
|
834
|
-
};
|
|
269
|
+
declare const outbox: SdkDomain$1<'outbox'>;
|
|
835
270
|
/**
|
|
836
271
|
* Shell-mediated file/blob upload (NAP-UPLOAD): hand the shell raw bytes plus
|
|
837
272
|
* upload intent; the shell selects a server, signs the rail authorization
|
|
@@ -847,31 +282,7 @@ declare const outbox: {
|
|
|
847
282
|
* if (result.status === 'complete') attach(result.url, result.nip94);
|
|
848
283
|
* ```
|
|
849
284
|
*/
|
|
850
|
-
declare const upload:
|
|
851
|
-
/**
|
|
852
|
-
* Inspect upload rails and coarse runtime policy limits.
|
|
853
|
-
* @returns Promise resolving to advisory upload info.
|
|
854
|
-
*/
|
|
855
|
-
info(): Promise<UploadInfo>;
|
|
856
|
-
/**
|
|
857
|
-
* Upload bytes through the shell's storage pipeline.
|
|
858
|
-
* @param request The upload request (Blob/ArrayBuffer bytes + intent)
|
|
859
|
-
* @returns Promise resolving to the initial upload result
|
|
860
|
-
*/
|
|
861
|
-
upload(request: UploadRequest): Promise<UploadResult>;
|
|
862
|
-
/**
|
|
863
|
-
* Get the latest known status for a prior upload.
|
|
864
|
-
* @param uploadId The shell-generated upload id
|
|
865
|
-
* @returns Promise resolving to the latest status
|
|
866
|
-
*/
|
|
867
|
-
status(uploadId: string): Promise<UploadStatus>;
|
|
868
|
-
/**
|
|
869
|
-
* Register for shell-pushed upload status updates.
|
|
870
|
-
* @param handler Called with each new UploadStatus
|
|
871
|
-
* @returns A Subscription with `close()` to stop listening
|
|
872
|
-
*/
|
|
873
|
-
onStatus(handler: (status: UploadStatus) => void): Subscription;
|
|
874
|
-
};
|
|
285
|
+
declare const upload: SdkDomain$1<'upload'>;
|
|
875
286
|
/**
|
|
876
287
|
* Archetype intent dispatch (NAP-INTENT): invoke another napplet by its role
|
|
877
288
|
* without addressing it directly. The shell resolves the role to an installed
|
|
@@ -888,40 +299,7 @@ declare const upload: {
|
|
|
888
299
|
* }
|
|
889
300
|
* ```
|
|
890
301
|
*/
|
|
891
|
-
declare const intent:
|
|
892
|
-
/**
|
|
893
|
-
* Invoke a napplet by archetype.
|
|
894
|
-
* @param request The intent request (archetype + action + payload + routing)
|
|
895
|
-
* @returns Promise resolving to the invocation result
|
|
896
|
-
*/
|
|
897
|
-
invoke(request: IntentRequest): Promise<IntentResult>;
|
|
898
|
-
/**
|
|
899
|
-
* Open a napplet by archetype (sugar for `action: "open"`).
|
|
900
|
-
* @param archetype Role slug to open
|
|
901
|
-
* @param payload Opaque payload (typed by the resolved protocol)
|
|
902
|
-
* @param opts Extra request fields (protocol, handler, behavior)
|
|
903
|
-
* @returns Promise resolving to the invocation result
|
|
904
|
-
*/
|
|
905
|
-
open(archetype: string, payload?: unknown, opts?: Omit<IntentRequest, "archetype" | "action" | "payload">): Promise<IntentResult>;
|
|
906
|
-
/**
|
|
907
|
-
* Check whether the runtime can currently satisfy an archetype and expose the
|
|
908
|
-
* manifest-derived contracts each candidate serves.
|
|
909
|
-
* @param archetype Role slug to check
|
|
910
|
-
* @returns Promise resolving to the archetype availability
|
|
911
|
-
*/
|
|
912
|
-
available(archetype: string): Promise<IntentAvailability>;
|
|
913
|
-
/**
|
|
914
|
-
* Get availability for every archetype the runtime can satisfy.
|
|
915
|
-
* @returns Promise resolving to availability for each satisfiable archetype
|
|
916
|
-
*/
|
|
917
|
-
handlers(): Promise<IntentAvailability[]>;
|
|
918
|
-
/**
|
|
919
|
-
* Register for shell-pushed availability updates.
|
|
920
|
-
* @param handler Called with each updated IntentAvailability
|
|
921
|
-
* @returns A Subscription with `close()` to stop listening
|
|
922
|
-
*/
|
|
923
|
-
onChanged(handler: (availability: IntentAvailability) => void): Subscription;
|
|
924
|
-
};
|
|
302
|
+
declare const intent: SdkDomain$1<'intent'>;
|
|
925
303
|
/**
|
|
926
304
|
* Runtime-mediated WebRTC sessions (NAP-WEBRTC). The shell owns signaling,
|
|
927
305
|
* signing/encryption, SDP, ICE, and peer-connection lifecycle; napplets exchange
|
|
@@ -935,32 +313,7 @@ declare const intent: {
|
|
|
935
313
|
* await webrtc.send(session.id, { body: 'hello' });
|
|
936
314
|
* ```
|
|
937
315
|
*/
|
|
938
|
-
declare const webrtc:
|
|
939
|
-
/**
|
|
940
|
-
* Open a runtime-owned WebRTC session.
|
|
941
|
-
* @param request Session scope and channel/protocol labels
|
|
942
|
-
* @returns Promise resolving to the opened session result
|
|
943
|
-
*/
|
|
944
|
-
open(request: WebrtcOpenRequest): Promise<WebrtcOpenResult>;
|
|
945
|
-
/**
|
|
946
|
-
* Send an opaque application payload over a session.
|
|
947
|
-
* @param sessionId WebRTC session id
|
|
948
|
-
* @param payload Application payload
|
|
949
|
-
*/
|
|
950
|
-
send(sessionId: string, payload: unknown): Promise<void>;
|
|
951
|
-
/**
|
|
952
|
-
* Close a WebRTC session.
|
|
953
|
-
* @param sessionId WebRTC session id
|
|
954
|
-
* @param reason Optional close reason
|
|
955
|
-
*/
|
|
956
|
-
close(sessionId: string, reason?: string): Promise<void>;
|
|
957
|
-
/**
|
|
958
|
-
* Subscribe to runtime-pushed WebRTC events.
|
|
959
|
-
* @param handler Event handler
|
|
960
|
-
* @returns Subscription handle
|
|
961
|
-
*/
|
|
962
|
-
onEvent(handler: (event: WebrtcEvent) => void): Subscription;
|
|
963
|
-
};
|
|
316
|
+
declare const webrtc: SdkDomain$1<'webrtc'>;
|
|
964
317
|
|
|
965
318
|
/**
|
|
966
319
|
* @napplet/sdk -- Link, lists, common, BLE, and serial wrapper objects.
|
|
@@ -968,6 +321,7 @@ declare const webrtc: {
|
|
|
968
321
|
* @packageDocumentation
|
|
969
322
|
*/
|
|
970
323
|
|
|
324
|
+
type SdkDomain<K extends keyof NappletGlobal> = NonNullable<NappletGlobal[K]>;
|
|
971
325
|
/**
|
|
972
326
|
* Shell-mediated link opening (NAP-LINK): ask the shell to open an external URL
|
|
973
327
|
* for user-visible navigation. The shell owns prompting, policy, opener
|
|
@@ -980,15 +334,7 @@ declare const webrtc: {
|
|
|
980
334
|
* const result = await link.open('https://example.com/post/123', { label: 'Read post' });
|
|
981
335
|
* ```
|
|
982
336
|
*/
|
|
983
|
-
declare const link:
|
|
984
|
-
/**
|
|
985
|
-
* Request that the shell open an external URL for the user.
|
|
986
|
-
* @param url Absolute URL to open
|
|
987
|
-
* @param options Optional prompt/display hints
|
|
988
|
-
* @returns Promise resolving to the shell's open/deny status
|
|
989
|
-
*/
|
|
990
|
-
open(url: string, options?: LinkOpenOptions): Promise<LinkOpenResult>;
|
|
991
|
-
};
|
|
337
|
+
declare const link: SdkDomain<'link'>;
|
|
992
338
|
/**
|
|
993
339
|
* Runtime-mediated event counts (NAP-COUNT): ask the runtime to count NIP-01
|
|
994
340
|
* filter matches without returning matching event payloads. The runtime owns
|
|
@@ -1002,15 +348,7 @@ declare const link: {
|
|
|
1002
348
|
* const result = await count.query({ kinds: [7], '#e': [eventId] });
|
|
1003
349
|
* ```
|
|
1004
350
|
*/
|
|
1005
|
-
declare const count:
|
|
1006
|
-
/**
|
|
1007
|
-
* Count events matching one or more NIP-01 filters.
|
|
1008
|
-
* @param filters One NIP-01 filter or a non-empty array of filters
|
|
1009
|
-
* @param options Optional approximation and HyperLogLog hints
|
|
1010
|
-
* @returns Promise resolving to the runtime count result
|
|
1011
|
-
*/
|
|
1012
|
-
query(filters: CountFilter | CountFilter[], options?: CountOptions): Promise<CountResult>;
|
|
1013
|
-
};
|
|
351
|
+
declare const count: SdkDomain<'count'>;
|
|
1014
352
|
/**
|
|
1015
353
|
* Runtime-mediated NIP-51 list mutations (NAP-LISTS): add or remove semantic
|
|
1016
354
|
* items from supported NIP-51 lists while the runtime owns lookup, merge,
|
|
@@ -1025,27 +363,7 @@ declare const count: {
|
|
|
1025
363
|
* ]);
|
|
1026
364
|
* ```
|
|
1027
365
|
*/
|
|
1028
|
-
declare const lists:
|
|
1029
|
-
/**
|
|
1030
|
-
* Return the NIP-51 list kinds/types this runtime supports.
|
|
1031
|
-
* @returns Promise resolving to supported list descriptions
|
|
1032
|
-
*/
|
|
1033
|
-
supported(): Promise<ListSupport[]>;
|
|
1034
|
-
/**
|
|
1035
|
-
* Add items to a runtime-supported NIP-51 list.
|
|
1036
|
-
* @param list List reference by kind or derived type
|
|
1037
|
-
* @param items Items to add
|
|
1038
|
-
* @param options Optional create/metadata hints
|
|
1039
|
-
*/
|
|
1040
|
-
add(list: ListRef, items: ListItem[], options?: ListOptions): Promise<ListMutationResult>;
|
|
1041
|
-
/**
|
|
1042
|
-
* Remove items from a runtime-supported NIP-51 list.
|
|
1043
|
-
* @param list List reference by kind or derived type
|
|
1044
|
-
* @param items Items to remove
|
|
1045
|
-
* @param options Optional runtime hints
|
|
1046
|
-
*/
|
|
1047
|
-
remove(list: ListRef, items: ListItem[], options?: ListOptions): Promise<ListMutationResult>;
|
|
1048
|
-
};
|
|
366
|
+
declare const lists: SdkDomain<'lists'>;
|
|
1049
367
|
/**
|
|
1050
368
|
* Common social actions (NAP-COMMON): shell-mediated public NIP-19 helpers,
|
|
1051
369
|
* profile lookup, follows, follow/unfollow, reactions, and reports. The shell
|
|
@@ -1060,59 +378,7 @@ declare const lists: {
|
|
|
1060
378
|
* await common.react(noteId, '+');
|
|
1061
379
|
* ```
|
|
1062
380
|
*/
|
|
1063
|
-
declare const common:
|
|
1064
|
-
/**
|
|
1065
|
-
* Encode a supported public NIP-19 value.
|
|
1066
|
-
* @param input Structured NIP-19 encode input
|
|
1067
|
-
* @returns Promise resolving to the shell encode result
|
|
1068
|
-
*/
|
|
1069
|
-
encodeNip19(input: CommonNip19EncodeInput): Promise<CommonNip19EncodeResult>;
|
|
1070
|
-
/**
|
|
1071
|
-
* Decode a supported public NIP-19 value.
|
|
1072
|
-
* @param value NIP-19 value to decode
|
|
1073
|
-
* @returns Promise resolving to normalized decoded fields
|
|
1074
|
-
*/
|
|
1075
|
-
decodeNip19(value: string): Promise<CommonNip19DecodeResult>;
|
|
1076
|
-
/**
|
|
1077
|
-
* Resolve a profile by hex pubkey, npub, or nprofile.
|
|
1078
|
-
* @param target Profile target
|
|
1079
|
-
* @returns Promise resolving to latest profile data when available
|
|
1080
|
-
*/
|
|
1081
|
-
getProfile(target: CommonProfileTarget): Promise<CommonProfileResult>;
|
|
1082
|
-
/**
|
|
1083
|
-
* Return the shell user's followed pubkeys as hex.
|
|
1084
|
-
* @returns Promise resolving to followed pubkeys
|
|
1085
|
-
*/
|
|
1086
|
-
follows(): Promise<CommonFollowsResult>;
|
|
1087
|
-
/**
|
|
1088
|
-
* Ask the shell to follow one or more npub targets.
|
|
1089
|
-
* @param pubkeys Npub targets to follow
|
|
1090
|
-
* @returns Promise resolving to the action result
|
|
1091
|
-
*/
|
|
1092
|
-
follow(...pubkeys: string[]): Promise<CommonActionResult>;
|
|
1093
|
-
/**
|
|
1094
|
-
* Ask the shell to unfollow one or more npub targets.
|
|
1095
|
-
* @param pubkeys Npub targets to unfollow
|
|
1096
|
-
* @returns Promise resolving to the action result
|
|
1097
|
-
*/
|
|
1098
|
-
unfollow(...pubkeys: string[]): Promise<CommonActionResult>;
|
|
1099
|
-
/**
|
|
1100
|
-
* React to a native Nostr event.
|
|
1101
|
-
* @param targetEventId Event id to react to
|
|
1102
|
-
* @param reaction Reaction content
|
|
1103
|
-
* @param customEmojiHref Optional custom emoji URL
|
|
1104
|
-
* @returns Promise resolving to the action result
|
|
1105
|
-
*/
|
|
1106
|
-
react(targetEventId: string, reaction: CommonReaction, customEmojiHref?: string): Promise<CommonActionResult>;
|
|
1107
|
-
/**
|
|
1108
|
-
* Report an event or pubkey with a NIP-56 reason.
|
|
1109
|
-
* @param target Structured report target
|
|
1110
|
-
* @param reason NIP-56 report reason
|
|
1111
|
-
* @param text Report text
|
|
1112
|
-
* @returns Promise resolving to the action result
|
|
1113
|
-
*/
|
|
1114
|
-
report(target: CommonReportTarget, reason: CommonReportReason, text: string): Promise<CommonActionResult>;
|
|
1115
|
-
};
|
|
381
|
+
declare const common: SdkDomain<'common'>;
|
|
1116
382
|
/**
|
|
1117
383
|
* Runtime-mediated Bluetooth LE/GATT sessions (NAP-BLE): ask the shell to
|
|
1118
384
|
* select a user-approved BLE device, expose opaque sessions and GATT
|
|
@@ -1127,60 +393,7 @@ declare const common: {
|
|
|
1127
393
|
* const services = await ble.services(session.id);
|
|
1128
394
|
* ```
|
|
1129
395
|
*/
|
|
1130
|
-
declare const ble:
|
|
1131
|
-
/**
|
|
1132
|
-
* Ask the runtime to select and open a BLE session.
|
|
1133
|
-
* @param request Device selection and optional service request
|
|
1134
|
-
* @returns Promise resolving to the runtime-assigned BLE open result
|
|
1135
|
-
*/
|
|
1136
|
-
open(request: BleOpenRequest): Promise<BleOpenResult>;
|
|
1137
|
-
/**
|
|
1138
|
-
* List exposed GATT services for a session.
|
|
1139
|
-
* @param sessionId Runtime-assigned BLE session id
|
|
1140
|
-
* @returns Promise resolving to exposed services
|
|
1141
|
-
*/
|
|
1142
|
-
services(sessionId: string): Promise<BleService[]>;
|
|
1143
|
-
/**
|
|
1144
|
-
* Read a characteristic or descriptor value.
|
|
1145
|
-
* @param sessionId Runtime-assigned BLE session id
|
|
1146
|
-
* @param target GATT attribute target
|
|
1147
|
-
* @returns Promise resolving to bytes
|
|
1148
|
-
*/
|
|
1149
|
-
read(sessionId: string, target: BleAttribute): Promise<number[]>;
|
|
1150
|
-
/**
|
|
1151
|
-
* Write bytes to a characteristic or descriptor.
|
|
1152
|
-
* @param sessionId Runtime-assigned BLE session id
|
|
1153
|
-
* @param target GATT attribute target
|
|
1154
|
-
* @param data Byte values to write
|
|
1155
|
-
* @param options Optional write mode preference
|
|
1156
|
-
* @returns Promise resolving after the runtime acknowledges the write
|
|
1157
|
-
*/
|
|
1158
|
-
write(sessionId: string, target: BleAttribute, data: number[], options?: BleWriteOptions): Promise<void>;
|
|
1159
|
-
/**
|
|
1160
|
-
* Start notifications or indications for a characteristic.
|
|
1161
|
-
* @param sessionId Runtime-assigned BLE session id
|
|
1162
|
-
* @param target GATT characteristic target
|
|
1163
|
-
*/
|
|
1164
|
-
subscribe(sessionId: string, target: BleAttribute): Promise<void>;
|
|
1165
|
-
/**
|
|
1166
|
-
* Stop notifications or indications for a characteristic.
|
|
1167
|
-
* @param sessionId Runtime-assigned BLE session id
|
|
1168
|
-
* @param target GATT characteristic target
|
|
1169
|
-
*/
|
|
1170
|
-
unsubscribe(sessionId: string, target: BleAttribute): Promise<void>;
|
|
1171
|
-
/**
|
|
1172
|
-
* Close an open BLE session.
|
|
1173
|
-
* @param sessionId Runtime-assigned BLE session id
|
|
1174
|
-
* @param reason Optional reason for the close request
|
|
1175
|
-
*/
|
|
1176
|
-
close(sessionId: string, reason?: string): Promise<void>;
|
|
1177
|
-
/**
|
|
1178
|
-
* Register for shell-pushed BLE events.
|
|
1179
|
-
* @param handler Called with each BLE event
|
|
1180
|
-
* @returns A Subscription with `close()` to stop listening
|
|
1181
|
-
*/
|
|
1182
|
-
onEvent(handler: (event: BleEvent) => void): Subscription;
|
|
1183
|
-
};
|
|
396
|
+
declare const ble: SdkDomain<'ble'>;
|
|
1184
397
|
/**
|
|
1185
398
|
* Runtime-mediated serial device access (NAP-SERIAL): ask the shell to select
|
|
1186
399
|
* and open a user-approved serial session, write byte arrays to that session,
|
|
@@ -1195,34 +408,7 @@ declare const ble: {
|
|
|
1195
408
|
* await serial.write(session.id, [112, 105, 110, 103, 10]);
|
|
1196
409
|
* ```
|
|
1197
410
|
*/
|
|
1198
|
-
declare const serial:
|
|
1199
|
-
/**
|
|
1200
|
-
* Ask the runtime to select and open a serial session.
|
|
1201
|
-
* @param request Filters, options, and optional chooser label
|
|
1202
|
-
* @returns Promise resolving to the runtime-assigned serial open result
|
|
1203
|
-
*/
|
|
1204
|
-
open(request: SerialOpenRequest): Promise<SerialOpenResult>;
|
|
1205
|
-
/**
|
|
1206
|
-
* Write bytes to an open serial session.
|
|
1207
|
-
* @param sessionId Runtime-assigned serial session id
|
|
1208
|
-
* @param data Byte values to write
|
|
1209
|
-
* @returns Promise resolving after the runtime acknowledges the write
|
|
1210
|
-
*/
|
|
1211
|
-
write(sessionId: string, data: Uint8Array | number[]): Promise<void>;
|
|
1212
|
-
/**
|
|
1213
|
-
* Close an open serial session.
|
|
1214
|
-
* @param sessionId Runtime-assigned serial session id
|
|
1215
|
-
* @param reason Optional reason for the close request
|
|
1216
|
-
* @returns Promise resolving after the runtime acknowledges the close
|
|
1217
|
-
*/
|
|
1218
|
-
close(sessionId: string, reason?: string): Promise<void>;
|
|
1219
|
-
/**
|
|
1220
|
-
* Register for shell-pushed serial events.
|
|
1221
|
-
* @param handler Called with each serial event
|
|
1222
|
-
* @returns A Subscription with `close()` to stop listening
|
|
1223
|
-
*/
|
|
1224
|
-
onEvent(handler: (event: SerialEvent) => void): Subscription;
|
|
1225
|
-
};
|
|
411
|
+
declare const serial: SdkDomain<'serial'>;
|
|
1226
412
|
/**
|
|
1227
413
|
* Runtime-mediated direct messages (NAP-DM): present DM UI while the runtime
|
|
1228
414
|
* owns signing, encryption, relay routing, storage, key/session state, and
|
|
@@ -1236,48 +422,6 @@ declare const serial: {
|
|
|
1236
422
|
* dm.onMessage((message) => render(message));
|
|
1237
423
|
* ```
|
|
1238
424
|
*/
|
|
1239
|
-
declare const dm:
|
|
1240
|
-
/**
|
|
1241
|
-
* Get current DM availability and advisory runtime labels.
|
|
1242
|
-
* @returns Promise resolving to the runtime DM status
|
|
1243
|
-
*/
|
|
1244
|
-
status(): Promise<DmStatus>;
|
|
1245
|
-
/**
|
|
1246
|
-
* Fetch normalized conversations visible to this napplet.
|
|
1247
|
-
* @param query Optional cursor and limit
|
|
1248
|
-
* @returns Promise resolving to a page of conversations
|
|
1249
|
-
*/
|
|
1250
|
-
conversations(query?: DmConversationQuery): Promise<DmConversationPage>;
|
|
1251
|
-
/**
|
|
1252
|
-
* Fetch normalized message history for one conversation.
|
|
1253
|
-
* @param query Conversation id plus optional cursor and limit
|
|
1254
|
-
* @returns Promise resolving to a page of messages
|
|
1255
|
-
*/
|
|
1256
|
-
messages(query: DmMessageQuery): Promise<DmMessagePage>;
|
|
1257
|
-
/**
|
|
1258
|
-
* Ask the runtime to send a direct message.
|
|
1259
|
-
* @param request Recipients, content, and optional conversation/client ids
|
|
1260
|
-
* @returns Promise resolving to the normalized send result
|
|
1261
|
-
*/
|
|
1262
|
-
send(request: DmSendRequest): Promise<DmSendResult>;
|
|
1263
|
-
/**
|
|
1264
|
-
* Start live delivery for one conversation or all visible conversations.
|
|
1265
|
-
* @param request Optional conversation scope
|
|
1266
|
-
* @returns Promise resolving to the runtime subscription id
|
|
1267
|
-
*/
|
|
1268
|
-
subscribe(request?: DmSubscribeRequest): Promise<DmSubscription>;
|
|
1269
|
-
/**
|
|
1270
|
-
* Stop a live DM subscription.
|
|
1271
|
-
* @param subscriptionId Runtime subscription id from subscribe()
|
|
1272
|
-
* @returns Promise resolving to the runtime acknowledgement
|
|
1273
|
-
*/
|
|
1274
|
-
unsubscribe(subscriptionId: string): Promise<DmOk>;
|
|
1275
|
-
/**
|
|
1276
|
-
* Register for shell-pushed `dm.message` deliveries.
|
|
1277
|
-
* @param handler Called with each message and its runtime subscription id
|
|
1278
|
-
* @returns A Subscription with `close()` to stop listening
|
|
1279
|
-
*/
|
|
1280
|
-
onMessage(handler: (message: DmMessage, subscriptionId: string) => void): Subscription;
|
|
1281
|
-
};
|
|
425
|
+
declare const dm: SdkDomain<'dm'>;
|
|
1282
426
|
|
|
1283
427
|
export { ble, common, config, count, cvm, dm, identity, ifc, inc, intent, keys, link, lists, media, notify, outbox, relay, resource, serial, storage, upload, webrtc };
|