@napplet/sdk 0.3.0 → 0.5.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/README.md +57 -46
- package/dist/index.d.ts +44 -60
- package/dist/index.js +58 -20
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -65,7 +65,8 @@ const keySub = keys.onAction('editor.save', () => {
|
|
|
65
65
|
|
|
66
66
|
// Create a media session
|
|
67
67
|
const { sessionId } = await media.createSession({
|
|
68
|
-
|
|
68
|
+
owner: 'napplet',
|
|
69
|
+
metadata: { title: 'My Song', artist: 'The Artist' },
|
|
69
70
|
});
|
|
70
71
|
media.reportState(sessionId, { status: 'playing', position: 42.5, duration: 240 });
|
|
71
72
|
|
|
@@ -93,14 +94,14 @@ const handle = resource.bytesAsObjectURL('blossom:sha256:e3b0c44298fc1c149afbf4c
|
|
|
93
94
|
imgEl.src = handle.url;
|
|
94
95
|
// handle.revoke() when done
|
|
95
96
|
|
|
96
|
-
// Check shell-assigned class (v0.29.0,
|
|
97
|
+
// Check shell-assigned class (v0.29.0, NAP-CLASS)
|
|
97
98
|
import { getClass, CLASS_DOMAIN } from '@napplet/sdk';
|
|
98
|
-
if (window.napplet.shell.supports(`
|
|
99
|
+
if (window.napplet.shell.supports(`nap:${CLASS_DOMAIN}`)) {
|
|
99
100
|
const cls = getClass(); // number | undefined
|
|
100
|
-
if (cls === 2) { /*
|
|
101
|
+
if (cls === 2) { /* NAP-CLASS-2 posture */ }
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
// Use direct network access if the user approved `connect` origins (v0.29.0,
|
|
104
|
+
// Use direct network access if the user approved `connect` origins (v0.29.0, NAP-CONNECT)
|
|
104
105
|
import { connectGranted, connectOrigins } from '@napplet/sdk';
|
|
105
106
|
if (connectGranted()) {
|
|
106
107
|
const res = await fetch(`${connectOrigins()[0]}/items`);
|
|
@@ -151,16 +152,19 @@ Sandboxed key-value storage. Mirrors `window.napplet.storage`. 512 KB quota per
|
|
|
151
152
|
|
|
152
153
|
### `media`
|
|
153
154
|
|
|
154
|
-
|
|
155
|
+
Ownership-aware media sessions. Napplet-owned sessions let your app play media and report state to the shell; shell-owned sessions provide a `source` so the shell fetches, plays, and reports state back.
|
|
155
156
|
|
|
156
157
|
| Method | Returns | Description |
|
|
157
158
|
|--------|---------|-------------|
|
|
158
|
-
| `createSession(
|
|
159
|
+
| `createSession(options)` | `Promise<{ sessionId?, owner?, error? }>` | Create a napplet- or shell-owned media session |
|
|
159
160
|
| `updateSession(sessionId, metadata)` | `void` | Update metadata for an existing session |
|
|
160
161
|
| `destroySession(sessionId)` | `void` | Destroy a session |
|
|
161
162
|
| `reportState(sessionId, state)` | `void` | Report playback state |
|
|
162
163
|
| `reportCapabilities(sessionId, actions)` | `void` | Declare supported media actions |
|
|
164
|
+
| `sendCommand(sessionId, action, value?)` | `void` | Request a control action from the current playback owner |
|
|
163
165
|
| `onCommand(sessionId, callback)` | `{ close(): void }` | Listen for shell media commands |
|
|
166
|
+
| `onState(sessionId, callback)` | `{ close(): void }` | Listen for shell-reported state on shell-owned sessions |
|
|
167
|
+
| `onCapabilities(sessionId, callback)` | `{ close(): void }` | Listen for shell-reported capabilities on shell-owned sessions |
|
|
164
168
|
| `onControls(sessionId, callback)` | `{ close(): void }` | Listen for the shell's supported control list |
|
|
165
169
|
|
|
166
170
|
### `notify`
|
|
@@ -181,7 +185,7 @@ Shell-rendered notifications. Mirrors `window.napplet.notify`.
|
|
|
181
185
|
|
|
182
186
|
### `config`
|
|
183
187
|
|
|
184
|
-
Per-napplet declarative configuration (
|
|
188
|
+
Per-napplet declarative configuration (NAP-CONFIG). Mirrors `window.napplet.config`.
|
|
185
189
|
|
|
186
190
|
| Method | Returns | Description |
|
|
187
191
|
|--------|---------|-------------|
|
|
@@ -192,7 +196,7 @@ Per-napplet declarative configuration (NUB-CONFIG). Mirrors `window.napplet.conf
|
|
|
192
196
|
| `onSchemaError(callback)` | `() => void` | Listen for `config.schemaError` pushes (returns plain teardown fn) |
|
|
193
197
|
| `schema` (accessor) | `Record<string, unknown> \| null` | Readonly current schema |
|
|
194
198
|
|
|
195
|
-
### FromSchema type inference (
|
|
199
|
+
### FromSchema type inference (NAP-CONFIG)
|
|
196
200
|
|
|
197
201
|
`json-schema-to-ts` is declared as an optional `peerDependency` of `@napplet/nub` (scoped to the `@napplet/nub/config` domain's `FromSchema` typing). Install it in your napplet to get `FromSchema<typeof schema>` typing for your `config.subscribe` callback -- the `values` parameter is inferred directly from your schema (enums, required fields, defaults all flow through). Authors who skip `json-schema-to-ts` pay no install cost and `config.subscribe` still works with the default `Record<string, unknown>` typing.
|
|
198
202
|
|
|
@@ -224,7 +228,7 @@ npm install --save-dev json-schema-to-ts
|
|
|
224
228
|
|
|
225
229
|
### `resource`
|
|
226
230
|
|
|
227
|
-
Sandboxed byte fetching (
|
|
231
|
+
Sandboxed byte fetching (NAP-RESOURCE). Mirrors `window.napplet.resource`. Required because the iframe sandbox + strict CSP block direct `fetch()` / `<img src=externalUrl>` / `XMLHttpRequest`.
|
|
228
232
|
|
|
229
233
|
| Method | Returns | Description |
|
|
230
234
|
|--------|---------|-------------|
|
|
@@ -244,7 +248,7 @@ const handle = resourceBytesAsObjectURL('blossom:sha256:...');
|
|
|
244
248
|
|
|
245
249
|
### `connect` (v0.29.0)
|
|
246
250
|
|
|
247
|
-
User-gated direct network access (
|
|
251
|
+
User-gated direct network access (NAP-CONNECT). State-only — no method namespace, no wire messages. The SDK re-exports the `NappletConnect` type, the `CONNECT_DOMAIN` constant, the `installConnectShim` installer, and the `connectGranted` / `connectOrigins` / `normalizeConnectOrigin` helper functions.
|
|
248
252
|
|
|
249
253
|
```ts
|
|
250
254
|
import type { NappletConnect } from '@napplet/sdk';
|
|
@@ -271,17 +275,17 @@ const normalized = normalizeConnectOrigin('https://api.example.com'); // retur
|
|
|
271
275
|
|
|
272
276
|
### `class` (v0.29.0)
|
|
273
277
|
|
|
274
|
-
Shell-assigned integer class (
|
|
278
|
+
Shell-assigned integer class (NAP-CLASS). Wire-only — the shell sends exactly one `class.assigned` envelope per napplet lifecycle; the shim writes the integer to `window.napplet.class`. The SDK re-exports the wire type, the domain constant, the installer, and a `getClass()` helper.
|
|
275
279
|
|
|
276
280
|
```ts
|
|
277
281
|
import type { ClassAssignedMessage, NappletClass, ClassNubMessage } from '@napplet/sdk';
|
|
278
282
|
import { CLASS_DOMAIN, installClassShim, getClass } from '@napplet/sdk';
|
|
279
283
|
|
|
280
|
-
if (window.napplet.shell.supports(`
|
|
284
|
+
if (window.napplet.shell.supports(`nap:${CLASS_DOMAIN}`)) {
|
|
281
285
|
const cls = getClass(); // number | undefined
|
|
282
|
-
// cls === 1
|
|
283
|
-
// cls === 2
|
|
284
|
-
// cls === undefined
|
|
286
|
+
// cls === 1 -> NAP-CLASS-1 (strict baseline)
|
|
287
|
+
// cls === 2 -> NAP-CLASS-2 (user-approved explicit-origin)
|
|
288
|
+
// cls === undefined -> shell doesn't implement nap:class OR envelope hasn't arrived yet
|
|
285
289
|
}
|
|
286
290
|
```
|
|
287
291
|
|
|
@@ -306,30 +310,29 @@ Keyboard forwarding and action keybindings. Mirrors `window.napplet.keys`.
|
|
|
306
310
|
|
|
307
311
|
### `identity`
|
|
308
312
|
|
|
309
|
-
Read-only user queries
|
|
313
|
+
Read-only user identity queries (NAP-IDENTITY). The identity namespace
|
|
310
314
|
is NOT exported as a top-level SDK object — use `window.napplet.identity.*` directly
|
|
311
315
|
after importing `@napplet/shim`, or use the bare-name helpers below.
|
|
312
316
|
|
|
313
317
|
| Method | Returns | Description |
|
|
314
318
|
|--------|---------|-------------|
|
|
315
|
-
| `window.napplet.identity.getPublicKey()` | `Promise<string>` | Shell-
|
|
316
|
-
| `window.napplet.identity.
|
|
319
|
+
| `window.napplet.identity.getPublicKey()` | `Promise<string>` | Shell-user pubkey, or `""` when no user/signer is connected |
|
|
320
|
+
| `window.napplet.identity.onChanged(handler)` | `{ close(): void }` | Listen for shell-pushed identity changes; handler receives a pubkey or `""` |
|
|
317
321
|
|
|
318
322
|
Bare helper aliases are also re-exported for consumers that prefer functional imports:
|
|
319
323
|
|
|
320
324
|
```ts
|
|
321
|
-
import { identityGetPublicKey,
|
|
322
|
-
import type { Rumor } from '@napplet/sdk';
|
|
325
|
+
import { identityGetPublicKey, identityOnChanged } from '@napplet/sdk';
|
|
323
326
|
|
|
324
327
|
const pubkey = await identityGetPublicKey();
|
|
325
|
-
const
|
|
328
|
+
const sub = identityOnChanged((nextPubkey) => {
|
|
329
|
+
console.log(nextPubkey || 'signed out');
|
|
330
|
+
});
|
|
326
331
|
```
|
|
327
332
|
|
|
328
|
-
|
|
329
|
-
(
|
|
330
|
-
|
|
331
|
-
for the 8-code error vocabulary, auto-detect behavior, and the rationale for
|
|
332
|
-
class-gating this API.
|
|
333
|
+
NAP-IDENTITY is strictly read-only. Signing remains delegated through
|
|
334
|
+
`relay.publish()`, encryption through `relay.publishEncrypted()`, and identity
|
|
335
|
+
changes arrive through `identity.changed` rather than polling.
|
|
333
336
|
|
|
334
337
|
### `shell`
|
|
335
338
|
|
|
@@ -339,19 +342,22 @@ Namespaced capability query. Access via `window.napplet.shell.supports()` after
|
|
|
339
342
|
|
|
340
343
|
| Method | Returns | Description |
|
|
341
344
|
|--------|---------|-------------|
|
|
342
|
-
| `supports(capability)` | `boolean` | Check shell support for a
|
|
345
|
+
| `supports(capability, protocol?)` | `boolean` | Check shell support for a NAP (`nap:relay`), permission (`perm:popups`), or numbered NAP-NN protocol over an interface (`ifc`, `NAP-01`). Bare NAP names also accepted (`relay`); `nub:`/`NUB-*` remain deprecated aliases. |
|
|
343
346
|
|
|
344
347
|
**Example:**
|
|
345
348
|
|
|
346
349
|
```ts
|
|
347
350
|
import '@napplet/shim';
|
|
348
351
|
|
|
349
|
-
//
|
|
352
|
+
// NAP domains (bare shorthand or nap: prefix)
|
|
350
353
|
if (window.napplet.shell.supports('relay')) { /* ... */ }
|
|
351
|
-
if (window.napplet.shell.supports('
|
|
354
|
+
if (window.napplet.shell.supports('nap:identity')) { /* ... */ }
|
|
352
355
|
|
|
353
356
|
// Permissions
|
|
354
357
|
if (window.napplet.shell.supports('perm:popups')) { /* ... */ }
|
|
358
|
+
|
|
359
|
+
// Numbered NAP-NN message protocols
|
|
360
|
+
if (window.napplet.shell.supports('ifc', 'NAP-01')) { /* ... */ }
|
|
355
361
|
```
|
|
356
362
|
|
|
357
363
|
### Namespace Import
|
|
@@ -378,8 +384,11 @@ import type {
|
|
|
378
384
|
Subscription,
|
|
379
385
|
EventTemplate,
|
|
380
386
|
NappletMessage,
|
|
387
|
+
NapDomain,
|
|
381
388
|
NubDomain,
|
|
382
389
|
NamespacedCapability,
|
|
390
|
+
NapProtocolId,
|
|
391
|
+
NubProtocolId,
|
|
383
392
|
ShellSupports,
|
|
384
393
|
// NUB message types (re-exported from NUB packages)
|
|
385
394
|
RelayNubMessage,
|
|
@@ -400,13 +409,15 @@ import type {
|
|
|
400
409
|
| `Subscription` | Handle with `close()` method |
|
|
401
410
|
| `EventTemplate` | Unsigned event for `relay.publish()` |
|
|
402
411
|
| `NappletMessage` | Base JSON envelope type for all protocol messages |
|
|
403
|
-
| `
|
|
404
|
-
| `NamespacedCapability` | Union of `
|
|
412
|
+
| `NapDomain` | String literal union of NAP domain names |
|
|
413
|
+
| `NamespacedCapability` | Union of `NapDomain \| nap:* \| nub:* \| perm:*` for `supports()` |
|
|
414
|
+
| `NapProtocolId` | Numbered NAP protocol id such as `NAP-01` for the optional second `supports()` argument |
|
|
415
|
+
| `NubDomain` / `NubProtocolId` | Deprecated aliases retained during the NAP rename |
|
|
405
416
|
| `ShellSupports` | Interface for the shell capability query API |
|
|
406
417
|
|
|
407
418
|
### NUB Message Types
|
|
408
419
|
|
|
409
|
-
These are discriminated union types covering all messages in each
|
|
420
|
+
These are discriminated union types covering all messages in each NAP domain. Useful for writing typed message
|
|
410
421
|
handlers in shell implementations or protocol-aware code.
|
|
411
422
|
|
|
412
423
|
| Type | NUB Package | Description |
|
|
@@ -416,57 +427,57 @@ handlers in shell implementations or protocol-aware code.
|
|
|
416
427
|
| `StorageNubMessage` | `@napplet/nub/storage` | Discriminated union of all storage domain messages |
|
|
417
428
|
| `IfcNubMessage` | `@napplet/nub/ifc` | Discriminated union of all IFC domain messages |
|
|
418
429
|
| `KeysNubMessage` | `@napplet/nub/keys` | Discriminated union of all keys domain messages |
|
|
419
|
-
| `
|
|
430
|
+
| `MediaNapMessage` | `@napplet/nub/media` | Discriminated union of all media domain messages |
|
|
420
431
|
| `NotifyNubMessage` | `@napplet/nub/notify` | Discriminated union of all notify domain messages |
|
|
421
432
|
| `ConfigNubMessage` | `@napplet/nub/config` | Discriminated union of all config domain messages |
|
|
422
433
|
| `ResourceNubMessage` | `@napplet/nub/resource` | Discriminated union of all resource domain messages |
|
|
423
434
|
| `ConnectNubMessage` * | `@napplet/nub/connect` | State-only NUB — no wire messages. The `NappletConnect` runtime state type is the consumer-facing import. |
|
|
424
435
|
| `ClassNubMessage` | `@napplet/nub/class` | Discriminated union of all class domain messages (v1: only `ClassAssignedMessage`) |
|
|
425
436
|
|
|
426
|
-
\* There is no `ConnectNubMessage` type;
|
|
437
|
+
\* There is no `ConnectNubMessage` type; NAP-CONNECT has no postMessage wire. The consumer-facing import is the `NappletConnect` runtime state interface.
|
|
427
438
|
|
|
428
439
|
Individual message types (e.g., `RelaySubscribeMessage`, `IdentityGetPublicKeyMessage`) are also re-exported from
|
|
429
440
|
`@napplet/sdk` for fine-grained typing.
|
|
430
441
|
|
|
431
442
|
## NUB Domain Constants
|
|
432
443
|
|
|
433
|
-
Each
|
|
444
|
+
Each NAP domain has a string constant re-exported from its package:
|
|
434
445
|
|
|
435
446
|
```ts
|
|
436
447
|
import { RELAY_DOMAIN, IDENTITY_DOMAIN, STORAGE_DOMAIN, IFC_DOMAIN, THEME_DOMAIN, KEYS_DOMAIN, MEDIA_DOMAIN, NOTIFY_DOMAIN, CONFIG_DOMAIN, RESOURCE_DOMAIN, CONNECT_DOMAIN, CLASS_DOMAIN } from '@napplet/sdk';
|
|
437
448
|
// Values: 'relay', 'identity', 'storage', 'ifc', 'theme', 'keys', 'media', 'notify', 'config', 'resource', 'connect', 'class'
|
|
438
449
|
```
|
|
439
450
|
|
|
440
|
-
These constants are re-exported from the individual
|
|
451
|
+
These constants are re-exported from the individual domain packages. Use them with the shell capability query
|
|
441
452
|
API for type-safe conditional logic:
|
|
442
453
|
|
|
443
454
|
```ts
|
|
444
|
-
if (window.napplet.shell.supports('
|
|
455
|
+
if (window.napplet.shell.supports('nap:relay')) {
|
|
445
456
|
// relay operations are available
|
|
446
457
|
}
|
|
447
458
|
|
|
448
|
-
if (window.napplet.shell.supports('
|
|
459
|
+
if (window.napplet.shell.supports('nap:identity')) {
|
|
449
460
|
// identity queries are available
|
|
450
461
|
}
|
|
451
462
|
|
|
452
|
-
if (window.napplet.shell.supports('
|
|
453
|
-
//
|
|
463
|
+
if (window.napplet.shell.supports('nap:config')) {
|
|
464
|
+
// NAP-CONFIG is available -- schema registration and subscribe()
|
|
454
465
|
}
|
|
455
466
|
|
|
456
|
-
if (window.napplet.shell.supports('
|
|
467
|
+
if (window.napplet.shell.supports('nap:resource')) {
|
|
457
468
|
// resource.bytes(url) is available; check per-scheme too:
|
|
458
469
|
if (window.napplet.shell.supports('resource:scheme:blossom')) { /* ... */ }
|
|
459
470
|
}
|
|
460
471
|
|
|
461
|
-
if (window.napplet.shell.supports('
|
|
462
|
-
//
|
|
472
|
+
if (window.napplet.shell.supports('nap:connect')) {
|
|
473
|
+
// NAP-CONNECT is available -- window.napplet.connect reflects shell grant state
|
|
463
474
|
// Check per-scheme operator policy:
|
|
464
475
|
if (window.napplet.shell.supports('connect:scheme:http')) { /* cleartext http: origins permitted */ }
|
|
465
476
|
if (window.napplet.shell.supports('connect:scheme:ws')) { /* cleartext ws: origins permitted */ }
|
|
466
477
|
}
|
|
467
478
|
|
|
468
|
-
if (window.napplet.shell.supports('
|
|
469
|
-
//
|
|
479
|
+
if (window.napplet.shell.supports('nap:class')) {
|
|
480
|
+
// NAP-CLASS is available -- window.napplet.class will be populated by class.assigned
|
|
470
481
|
}
|
|
471
482
|
```
|
|
472
483
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { EventTemplate, NUB_DOMAINS, NamespacedCapability, NappletMessage, NostrEvent, NostrFilter, NubDomain,
|
|
1
|
+
import { Subscription, NostrEvent, NostrFilter, EventTemplate } from '@napplet/core';
|
|
2
|
+
export { EventTemplate, NAP_DOMAINS, NUB_DOMAINS, NamespacedCapability, NapDomain, NapProtocolId, NappletMessage, NostrEvent, NostrFilter, NubDomain, NubProtocolId, ProtocolId, ShellSupports, Subscription } from '@napplet/core';
|
|
3
|
+
import { MediaSessionCreate, MediaSessionResult, MediaMetadata, MediaState, MediaAction } from '@napplet/nub/media';
|
|
4
|
+
export { DOMAIN as MEDIA_DOMAIN, MediaAction, MediaArtwork, MediaCapabilitiesMessage, MediaCommandMessage, MediaControlsMessage, MediaMessage, MediaMetadata, MediaNapMessage, MediaNubMessage, MediaPlaybackOwner, MediaRequestMessage, MediaResultMessage, MediaSessionCreate, MediaSessionCreateMessage, MediaSessionCreateResultMessage, MediaSessionDestroyMessage, MediaSessionResult, MediaSessionUpdateMessage, MediaSourceRef, MediaState, MediaStateMessage, installMediaShim, mediaCreateSession, mediaDestroySession, mediaOnCapabilities, mediaOnCommand, mediaOnControls, mediaOnState, mediaReportCapabilities, mediaReportState, mediaSendCommand, mediaUpdateSession } from '@napplet/nub/media';
|
|
3
5
|
export { DOMAIN as RELAY_DOMAIN, RelayCloseMessage, RelayClosedMessage, RelayEoseMessage, RelayEventMessage, RelayInboundMessage, RelayMessage, RelayNubMessage, RelayOutboundMessage, RelayPublishEncryptedMessage, RelayPublishEncryptedResultMessage, RelayPublishMessage, RelayPublishResultMessage, RelayQueryMessage, RelayQueryResultMessage, RelaySubscribeMessage, installRelayShim, relayPublish, relayPublishEncrypted, relayQuery, relaySubscribe } from '@napplet/nub/relay';
|
|
4
|
-
export { Badge, DOMAIN as IDENTITY_DOMAIN,
|
|
6
|
+
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, IdentityNubMessage, RelayPermission as IdentityRelayPermission, IdentityRequestMessage, IdentityResultMessage, ProfileData, ZapReceipt, identityGetBadges, identityGetBlocked, identityGetFollows, identityGetList, identityGetMutes, identityGetProfile, identityGetPublicKey, identityGetRelays, identityGetZaps, identityOnChanged, installIdentityShim } from '@napplet/nub/identity';
|
|
5
7
|
export { DOMAIN as STORAGE_DOMAIN, StorageGetMessage, StorageGetResultMessage, StorageKeysMessage, StorageKeysResultMessage, StorageMessage, StorageNubMessage, StorageRemoveMessage, StorageRemoveResultMessage, StorageRequestMessage, StorageResultMessage, StorageSetMessage, StorageSetResultMessage, installStorageShim, storageGetItem, storageKeys, storageRemoveItem, storageSetItem } from '@napplet/nub/storage';
|
|
6
8
|
export { DOMAIN as IFC_DOMAIN, IfcChannelBroadcastMessage, IfcChannelCloseMessage, IfcChannelClosedMessage, IfcChannelEmitMessage, IfcChannelEventMessage, IfcChannelListMessage, IfcChannelListResultMessage, IfcChannelMessage, IfcChannelOpenMessage, IfcChannelOpenResultMessage, IfcEmitMessage, IfcEventMessage, IfcInboundMessage, IfcMessage, IfcNubMessage, IfcOutboundMessage, IfcSubscribeMessage, IfcSubscribeResultMessage, IfcTopicMessage, IfcUnsubscribeMessage, ifcEmit, ifcOn, installIfcShim } from '@napplet/nub/ifc';
|
|
7
9
|
export { DOMAIN as THEME_DOMAIN, Theme, ThemeBackground, ThemeChangedMessage, ThemeColors, ThemeFont, ThemeGetMessage, ThemeGetResultMessage, ThemeMessage, ThemeNubMessage, ThemeRequestMessage, ThemeResultMessage } from '@napplet/nub/theme';
|
|
8
10
|
export { Action, DOMAIN as KEYS_DOMAIN, KeyBinding, KeysActionMessage, KeysBindingsMessage, KeysForwardMessage, KeysMessage, KeysNubMessage, KeysRegisterActionMessage, KeysRegisterActionResultMessage, KeysRequestMessage, KeysResultMessage, KeysUnregisterActionMessage, RegisterResult, installKeysShim, keysOnAction, keysRegister, keysRegisterAction, keysUnregisterAction } from '@napplet/nub/keys';
|
|
9
|
-
export { DOMAIN as MEDIA_DOMAIN, MediaAction, MediaArtwork, MediaCapabilitiesMessage, MediaCommandMessage, MediaControlsMessage, MediaMessage, MediaMetadata, MediaNubMessage, MediaRequestMessage, MediaResultMessage, MediaSessionCreateMessage, MediaSessionCreateResultMessage, MediaSessionDestroyMessage, MediaSessionUpdateMessage, MediaState, MediaStateMessage, installMediaShim, mediaCreateSession, mediaDestroySession, mediaOnCommand, mediaOnControls, mediaReportCapabilities, mediaReportState, mediaUpdateSession } from '@napplet/nub/media';
|
|
10
11
|
export { DOMAIN as NOTIFY_DOMAIN, NotificationAction, NotificationChannel, NotificationPriority, NotifyActionMessage, NotifyBadgeMessage, NotifyChannelRegisterMessage, NotifyClickedMessage, NotifyControl, NotifyControlsMessage, NotifyDismissMessage, NotifyDismissedMessage, NotifyMessage, NotifyNubMessage, NotifyPermissionRequestMessage, NotifyPermissionResultMessage, NotifyRequestMessage, NotifyResultMessage, NotifySendMessage, NotifySendResultMessage, installNotifyShim, notifyBadge, notifyDismiss, notifyOnAction, notifyOnClicked, notifyOnControls, notifyOnDismissed, notifyRegisterChannel, notifyRequestPermission, notifySend } from '@napplet/nub/notify';
|
|
11
12
|
export { DOMAIN as CONFIG_DOMAIN, ConfigGetMessage, ConfigMessage, ConfigNubMessage, ConfigOpenSettingsMessage, ConfigRegisterSchemaMessage, ConfigRegisterSchemaResultMessage, ConfigRequestMessage, ConfigResultMessage, ConfigSchema, ConfigSchemaErrorCode, ConfigSchemaErrorMessage, ConfigSubscribeMessage, ConfigUnsubscribeMessage, ConfigValues, ConfigValuesMessage, NappletConfigSchema, NappletConfigSchemaExtensions, installConfigShim } from '@napplet/nub/config';
|
|
12
13
|
export { DOMAIN as RESOURCE_DOMAIN, ResourceBytesErrorMessage, ResourceBytesMessage, ResourceBytesResultMessage, ResourceCancelMessage, ResourceErrorCode, ResourceMessage, ResourceNubMessage, ResourceRequestMessage, ResourceResultMessage, ResourceScheme, ResourceSidecarEntry, installResourceShim, resourceBytes, resourceBytesAsObjectURL } from '@napplet/nub/resource';
|
|
@@ -36,11 +37,6 @@ export { DOMAIN as CLASS_DOMAIN, ClassAssignedMessage, ClassMessage, ClassNubMes
|
|
|
36
37
|
* @packageDocumentation
|
|
37
38
|
*/
|
|
38
39
|
|
|
39
|
-
declare global {
|
|
40
|
-
interface Window {
|
|
41
|
-
napplet: NappletGlobal;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
40
|
/**
|
|
45
41
|
* NIP-01 relay operations: subscribe to events, publish events, one-shot queries.
|
|
46
42
|
*
|
|
@@ -170,7 +166,8 @@ declare const storage: {
|
|
|
170
166
|
* import { media } from '@napplet/sdk';
|
|
171
167
|
*
|
|
172
168
|
* const { sessionId } = await media.createSession({
|
|
173
|
-
*
|
|
169
|
+
* owner: 'napplet',
|
|
170
|
+
* metadata: { title: 'My Song', artist: 'The Artist' },
|
|
174
171
|
* });
|
|
175
172
|
*
|
|
176
173
|
* media.reportState(sessionId, { status: 'playing', position: 42.5 });
|
|
@@ -179,38 +176,16 @@ declare const storage: {
|
|
|
179
176
|
declare const media: {
|
|
180
177
|
/**
|
|
181
178
|
* Create a new media session with the shell.
|
|
182
|
-
* @param
|
|
183
|
-
* @returns The
|
|
184
|
-
*/
|
|
185
|
-
createSession(
|
|
186
|
-
title?: string;
|
|
187
|
-
artist?: string;
|
|
188
|
-
album?: string;
|
|
189
|
-
artwork?: {
|
|
190
|
-
url?: string;
|
|
191
|
-
hash?: string;
|
|
192
|
-
};
|
|
193
|
-
duration?: number;
|
|
194
|
-
mediaType?: "audio" | "video";
|
|
195
|
-
}): Promise<{
|
|
196
|
-
sessionId: string;
|
|
197
|
-
}>;
|
|
179
|
+
* @param options Ownership-aware session options
|
|
180
|
+
* @returns The shell result with canonical sessionId and owner, or error
|
|
181
|
+
*/
|
|
182
|
+
createSession(options: MediaSessionCreate): Promise<MediaSessionResult>;
|
|
198
183
|
/**
|
|
199
184
|
* Update metadata for an existing session.
|
|
200
185
|
* @param sessionId The session to update
|
|
201
186
|
* @param metadata Partial metadata fields to update
|
|
202
187
|
*/
|
|
203
|
-
updateSession(sessionId: string, metadata:
|
|
204
|
-
title?: string;
|
|
205
|
-
artist?: string;
|
|
206
|
-
album?: string;
|
|
207
|
-
artwork?: {
|
|
208
|
-
url?: string;
|
|
209
|
-
hash?: string;
|
|
210
|
-
};
|
|
211
|
-
duration?: number;
|
|
212
|
-
mediaType?: "audio" | "video";
|
|
213
|
-
}): void;
|
|
188
|
+
updateSession(sessionId: string, metadata: Partial<MediaMetadata>): void;
|
|
214
189
|
/**
|
|
215
190
|
* Destroy a media session.
|
|
216
191
|
* @param sessionId The session to destroy
|
|
@@ -221,32 +196,48 @@ declare const media: {
|
|
|
221
196
|
* @param sessionId The session to report state for
|
|
222
197
|
* @param state Current playback state
|
|
223
198
|
*/
|
|
224
|
-
reportState(sessionId: string, state:
|
|
225
|
-
status: "playing" | "paused" | "stopped" | "buffering";
|
|
226
|
-
position?: number;
|
|
227
|
-
duration?: number;
|
|
228
|
-
volume?: number;
|
|
229
|
-
}): void;
|
|
199
|
+
reportState(sessionId: string, state: MediaState): void;
|
|
230
200
|
/**
|
|
231
201
|
* Declare which media actions the session currently supports.
|
|
232
202
|
* @param sessionId The session to update capabilities for
|
|
233
203
|
* @param actions Currently supported actions
|
|
234
204
|
*/
|
|
235
|
-
reportCapabilities(sessionId: string, actions:
|
|
205
|
+
reportCapabilities(sessionId: string, actions: MediaAction[]): void;
|
|
206
|
+
/**
|
|
207
|
+
* Send a command to the current playback owner.
|
|
208
|
+
* @param sessionId The session to control
|
|
209
|
+
* @param action The media action to request
|
|
210
|
+
* @param value Optional value for seek/volume
|
|
211
|
+
*/
|
|
212
|
+
sendCommand(sessionId: string, action: MediaAction, value?: number): void;
|
|
236
213
|
/**
|
|
237
214
|
* Listen for media commands from the shell.
|
|
238
215
|
* @param sessionId The session to listen for commands on
|
|
239
216
|
* @param callback Called with (action, value?) when a command is received
|
|
240
217
|
* @returns A Subscription with `close()` to stop listening
|
|
241
218
|
*/
|
|
242
|
-
onCommand(sessionId: string, callback: (action:
|
|
219
|
+
onCommand(sessionId: string, callback: (action: MediaAction, value?: number) => void): Subscription;
|
|
220
|
+
/**
|
|
221
|
+
* Listen for shell-reported playback state for shell-owned sessions.
|
|
222
|
+
* @param sessionId The session to listen for state on
|
|
223
|
+
* @param callback Called with playback state
|
|
224
|
+
* @returns A Subscription with `close()` to stop listening
|
|
225
|
+
*/
|
|
226
|
+
onState(sessionId: string, callback: (state: MediaState) => void): Subscription;
|
|
227
|
+
/**
|
|
228
|
+
* Listen for shell-reported capabilities for shell-owned sessions.
|
|
229
|
+
* @param sessionId The session to listen for capabilities on
|
|
230
|
+
* @param callback Called with available actions
|
|
231
|
+
* @returns A Subscription with `close()` to stop listening
|
|
232
|
+
*/
|
|
233
|
+
onCapabilities(sessionId: string, callback: (actions: MediaAction[]) => void): Subscription;
|
|
243
234
|
/**
|
|
244
235
|
* Listen for the shell's media control list.
|
|
245
236
|
* @param sessionId The session to associate controls with
|
|
246
237
|
* @param callback Called with the shell's supported controls
|
|
247
238
|
* @returns A Subscription with `close()` to stop listening
|
|
248
239
|
*/
|
|
249
|
-
onControls(sessionId: string, callback: (controls:
|
|
240
|
+
onControls(sessionId: string, callback: (controls: MediaAction[]) => void): Subscription;
|
|
250
241
|
};
|
|
251
242
|
/**
|
|
252
243
|
* Shell-rendered notifications: send notifications, set badge counts,
|
|
@@ -431,6 +422,12 @@ declare const identity: {
|
|
|
431
422
|
* @returns Hex-encoded public key string
|
|
432
423
|
*/
|
|
433
424
|
getPublicKey(): Promise<string>;
|
|
425
|
+
/**
|
|
426
|
+
* Listen for shell-pushed user identity changes.
|
|
427
|
+
* @param handler Called with a hex pubkey, or "" when no user/signer is connected
|
|
428
|
+
* @returns Subscription with close() to detach the handler
|
|
429
|
+
*/
|
|
430
|
+
onChanged(handler: (pubkey: string) => void): Subscription;
|
|
434
431
|
/**
|
|
435
432
|
* Get the user's relay list (NIP-65).
|
|
436
433
|
* @returns Record mapping relay URLs to read/write permissions
|
|
@@ -496,22 +493,9 @@ declare const identity: {
|
|
|
496
493
|
thumbs?: string[];
|
|
497
494
|
awardedBy: string;
|
|
498
495
|
}[]>;
|
|
499
|
-
/**
|
|
500
|
-
* Decrypt a received Nostr event (NIP-04 / direct NIP-44 / NIP-17 gift-wrap).
|
|
501
|
-
*
|
|
502
|
-
* Shape is auto-detected by the shell; napplets do NOT select encryption mode.
|
|
503
|
-
* Only legal for napplets assigned class: 1 per NUB-CLASS-1 (shell-enforced).
|
|
504
|
-
*
|
|
505
|
-
* @param event The received event (outer wrap for NIP-17, kind-4 for NIP-04, etc.)
|
|
506
|
-
* @returns Promise resolving to { rumor, sender }; rejects with Error on failure.
|
|
507
|
-
*/
|
|
508
|
-
decrypt(event: NostrEvent): Promise<{
|
|
509
|
-
rumor: Rumor;
|
|
510
|
-
sender: string;
|
|
511
|
-
}>;
|
|
512
496
|
};
|
|
513
497
|
/**
|
|
514
|
-
* Per-napplet declarative configuration (
|
|
498
|
+
* Per-napplet declarative configuration (NAP-CONFIG): register a schema,
|
|
515
499
|
* read current values, subscribe to live updates, deep-link into the
|
|
516
500
|
* shell-owned settings UI, and listen for schema errors.
|
|
517
501
|
*
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { NUB_DOMAINS } from "@napplet/core";
|
|
2
|
+
import { NAP_DOMAINS, NUB_DOMAINS } from "@napplet/core";
|
|
3
3
|
import { DOMAIN } from "@napplet/nub/relay";
|
|
4
4
|
import { DOMAIN as DOMAIN2 } from "@napplet/nub/identity";
|
|
5
5
|
import { DOMAIN as DOMAIN3 } from "@napplet/nub/storage";
|
|
@@ -24,11 +24,22 @@ import { installResourceShim } from "@napplet/nub/resource";
|
|
|
24
24
|
import { installConnectShim } from "@napplet/nub/connect";
|
|
25
25
|
import { installClassShim } from "@napplet/nub/class";
|
|
26
26
|
import { relaySubscribe, relayPublish, relayPublishEncrypted, relayQuery } from "@napplet/nub/relay";
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
identityGetPublicKey,
|
|
29
|
+
identityOnChanged,
|
|
30
|
+
identityGetRelays,
|
|
31
|
+
identityGetProfile,
|
|
32
|
+
identityGetFollows,
|
|
33
|
+
identityGetList,
|
|
34
|
+
identityGetZaps,
|
|
35
|
+
identityGetMutes,
|
|
36
|
+
identityGetBlocked,
|
|
37
|
+
identityGetBadges
|
|
38
|
+
} from "@napplet/nub/identity";
|
|
28
39
|
import { storageGetItem, storageSetItem, storageRemoveItem, storageKeys } from "@napplet/nub/storage";
|
|
29
40
|
import { ifcEmit, ifcOn } from "@napplet/nub/ifc";
|
|
30
41
|
import { keysRegisterAction, keysUnregisterAction, keysOnAction, keysRegister } from "@napplet/nub/keys";
|
|
31
|
-
import { mediaCreateSession, mediaUpdateSession, mediaDestroySession, mediaReportState, mediaReportCapabilities, mediaOnCommand, mediaOnControls } from "@napplet/nub/media";
|
|
42
|
+
import { mediaCreateSession, mediaUpdateSession, mediaDestroySession, mediaReportState, mediaReportCapabilities, mediaSendCommand, mediaOnCommand, mediaOnState, mediaOnCapabilities, mediaOnControls } from "@napplet/nub/media";
|
|
32
43
|
import { notifySend, notifyDismiss, notifyBadge, notifyRegisterChannel, notifyRequestPermission, notifyOnAction, notifyOnClicked, notifyOnDismissed, notifyOnControls } from "@napplet/nub/notify";
|
|
33
44
|
import { resourceBytes, resourceBytesAsObjectURL } from "@napplet/nub/resource";
|
|
34
45
|
import { connectGranted, connectOrigins, normalizeConnectOrigin } from "@napplet/nub/connect";
|
|
@@ -135,11 +146,11 @@ var storage = {
|
|
|
135
146
|
var media = {
|
|
136
147
|
/**
|
|
137
148
|
* Create a new media session with the shell.
|
|
138
|
-
* @param
|
|
139
|
-
* @returns The
|
|
149
|
+
* @param options Ownership-aware session options
|
|
150
|
+
* @returns The shell result with canonical sessionId and owner, or error
|
|
140
151
|
*/
|
|
141
|
-
createSession(
|
|
142
|
-
return requireNapplet().media.createSession(
|
|
152
|
+
createSession(options) {
|
|
153
|
+
return requireNapplet().media.createSession(options);
|
|
143
154
|
},
|
|
144
155
|
/**
|
|
145
156
|
* Update metadata for an existing session.
|
|
@@ -172,6 +183,15 @@ var media = {
|
|
|
172
183
|
reportCapabilities(sessionId, actions) {
|
|
173
184
|
requireNapplet().media.reportCapabilities(sessionId, actions);
|
|
174
185
|
},
|
|
186
|
+
/**
|
|
187
|
+
* Send a command to the current playback owner.
|
|
188
|
+
* @param sessionId The session to control
|
|
189
|
+
* @param action The media action to request
|
|
190
|
+
* @param value Optional value for seek/volume
|
|
191
|
+
*/
|
|
192
|
+
sendCommand(sessionId, action, value) {
|
|
193
|
+
requireNapplet().media.sendCommand(sessionId, action, value);
|
|
194
|
+
},
|
|
175
195
|
/**
|
|
176
196
|
* Listen for media commands from the shell.
|
|
177
197
|
* @param sessionId The session to listen for commands on
|
|
@@ -181,6 +201,24 @@ var media = {
|
|
|
181
201
|
onCommand(sessionId, callback) {
|
|
182
202
|
return requireNapplet().media.onCommand(sessionId, callback);
|
|
183
203
|
},
|
|
204
|
+
/**
|
|
205
|
+
* Listen for shell-reported playback state for shell-owned sessions.
|
|
206
|
+
* @param sessionId The session to listen for state on
|
|
207
|
+
* @param callback Called with playback state
|
|
208
|
+
* @returns A Subscription with `close()` to stop listening
|
|
209
|
+
*/
|
|
210
|
+
onState(sessionId, callback) {
|
|
211
|
+
return requireNapplet().media.onState(sessionId, callback);
|
|
212
|
+
},
|
|
213
|
+
/**
|
|
214
|
+
* Listen for shell-reported capabilities for shell-owned sessions.
|
|
215
|
+
* @param sessionId The session to listen for capabilities on
|
|
216
|
+
* @param callback Called with available actions
|
|
217
|
+
* @returns A Subscription with `close()` to stop listening
|
|
218
|
+
*/
|
|
219
|
+
onCapabilities(sessionId, callback) {
|
|
220
|
+
return requireNapplet().media.onCapabilities(sessionId, callback);
|
|
221
|
+
},
|
|
184
222
|
/**
|
|
185
223
|
* Listen for the shell's media control list.
|
|
186
224
|
* @param sessionId The session to associate controls with
|
|
@@ -330,6 +368,14 @@ var identity = {
|
|
|
330
368
|
getPublicKey() {
|
|
331
369
|
return requireNapplet().identity.getPublicKey();
|
|
332
370
|
},
|
|
371
|
+
/**
|
|
372
|
+
* Listen for shell-pushed user identity changes.
|
|
373
|
+
* @param handler Called with a hex pubkey, or "" when no user/signer is connected
|
|
374
|
+
* @returns Subscription with close() to detach the handler
|
|
375
|
+
*/
|
|
376
|
+
onChanged(handler) {
|
|
377
|
+
return requireNapplet().identity.onChanged(handler);
|
|
378
|
+
},
|
|
333
379
|
/**
|
|
334
380
|
* Get the user's relay list (NIP-65).
|
|
335
381
|
* @returns Record mapping relay URLs to read/write permissions
|
|
@@ -386,18 +432,6 @@ var identity = {
|
|
|
386
432
|
*/
|
|
387
433
|
getBadges() {
|
|
388
434
|
return requireNapplet().identity.getBadges();
|
|
389
|
-
},
|
|
390
|
-
/**
|
|
391
|
-
* Decrypt a received Nostr event (NIP-04 / direct NIP-44 / NIP-17 gift-wrap).
|
|
392
|
-
*
|
|
393
|
-
* Shape is auto-detected by the shell; napplets do NOT select encryption mode.
|
|
394
|
-
* Only legal for napplets assigned class: 1 per NUB-CLASS-1 (shell-enforced).
|
|
395
|
-
*
|
|
396
|
-
* @param event The received event (outer wrap for NIP-17, kind-4 for NIP-04, etc.)
|
|
397
|
-
* @returns Promise resolving to { rumor, sender }; rejects with Error on failure.
|
|
398
|
-
*/
|
|
399
|
-
decrypt(event) {
|
|
400
|
-
return requireNapplet().identity.decrypt(event);
|
|
401
435
|
}
|
|
402
436
|
};
|
|
403
437
|
var config = {
|
|
@@ -479,6 +513,7 @@ export {
|
|
|
479
513
|
DOMAIN4 as IFC_DOMAIN,
|
|
480
514
|
DOMAIN6 as KEYS_DOMAIN,
|
|
481
515
|
DOMAIN7 as MEDIA_DOMAIN,
|
|
516
|
+
NAP_DOMAINS,
|
|
482
517
|
DOMAIN8 as NOTIFY_DOMAIN,
|
|
483
518
|
NUB_DOMAINS,
|
|
484
519
|
DOMAIN as RELAY_DOMAIN,
|
|
@@ -490,7 +525,6 @@ export {
|
|
|
490
525
|
connectOrigins,
|
|
491
526
|
getClass,
|
|
492
527
|
identity,
|
|
493
|
-
identityDecrypt,
|
|
494
528
|
identityGetBadges,
|
|
495
529
|
identityGetBlocked,
|
|
496
530
|
identityGetFollows,
|
|
@@ -500,6 +534,7 @@ export {
|
|
|
500
534
|
identityGetPublicKey,
|
|
501
535
|
identityGetRelays,
|
|
502
536
|
identityGetZaps,
|
|
537
|
+
identityOnChanged,
|
|
503
538
|
ifc,
|
|
504
539
|
ifcEmit,
|
|
505
540
|
ifcOn,
|
|
@@ -522,10 +557,13 @@ export {
|
|
|
522
557
|
media,
|
|
523
558
|
mediaCreateSession,
|
|
524
559
|
mediaDestroySession,
|
|
560
|
+
mediaOnCapabilities,
|
|
525
561
|
mediaOnCommand,
|
|
526
562
|
mediaOnControls,
|
|
563
|
+
mediaOnState,
|
|
527
564
|
mediaReportCapabilities,
|
|
528
565
|
mediaReportState,
|
|
566
|
+
mediaSendCommand,
|
|
529
567
|
mediaUpdateSession,
|
|
530
568
|
normalizeConnectOrigin,
|
|
531
569
|
notify,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @napplet/sdk -- Typed named exports wrapping window.napplet.\n *\n * Provides `relay`, `ifc`, `storage`, and `keys` objects that delegate\n * to `window.napplet.*` at call time. Developers using a bundler can import\n * individual namespaces without depending on the shim's side-effect install:\n *\n * ```ts\n * import { relay, ifc } from '@napplet/sdk';\n * ```\n *\n * The shim must still be imported somewhere in the application to install\n * the `window.napplet` global. The SDK only wraps it -- it does not install it.\n *\n * Domain-specific SDK helpers are also available directly from NUB packages:\n * ```ts\n * import { relaySubscribe } from '@napplet/nub/relay';\n * import { storageGetItem } from '@napplet/nub/storage';\n * ```\n *\n * @packageDocumentation\n */\n\nimport type {\n NappletGlobal,\n NostrEvent,\n NostrFilter,\n Rumor,\n Subscription,\n EventTemplate,\n} from '@napplet/core';\n\n// ─── Global type augmentation ────────────────────────────────────────────────\n// Provides window.napplet autocompletion for TypeScript consumers who import\n// only the SDK (not the shim). Both shim and SDK reference NappletGlobal from\n// @napplet/core -- no duplication.\n\ndeclare global {\n interface Window {\n napplet: NappletGlobal;\n }\n}\n\n// ─── Runtime guard ──────────────────────────────────────────────────────────\n\n/**\n * Retrieve the `window.napplet` global, throwing a clear error if it is absent.\n *\n * Every SDK method calls this at invocation time -- not at module load time --\n * so the shim can be imported in any order relative to the SDK.\n */\nfunction requireNapplet(): NappletGlobal {\n const w = window as Window & { napplet?: NappletGlobal };\n if (!w.napplet) {\n throw new Error('window.napplet not installed -- import @napplet/shim first');\n }\n return w.napplet;\n}\n\n// ─── Relay namespace ────────────────────────────────────────────────────────\n\n/**\n * NIP-01 relay operations: subscribe to events, publish events, one-shot queries.\n *\n * Each method delegates to `window.napplet.relay.*` at call time, which in turn\n * routes through the shell's relay pool via postMessage.\n *\n * @example\n * ```ts\n * import { relay } from '@napplet/sdk';\n *\n * const sub = relay.subscribe(\n * { kinds: [1], limit: 10 },\n * (event) => console.log(event),\n * () => console.log('EOSE'),\n * );\n * ```\n */\nexport const relay = {\n /**\n * Open a live NIP-01 subscription through the shell's relay pool.\n * @param filters One or more NIP-01 subscription filters\n * @param onEvent Called for each matching event\n * @param onEose Called when the shell signals end of stored events (EOSE)\n * @param options Optional: `{ relay, group }` for NIP-29 scoped relay subscriptions\n * @returns A Subscription handle with a `close()` method\n */\n subscribe(\n filters: NostrFilter | NostrFilter[],\n onEvent: (event: NostrEvent) => void,\n onEose: () => void,\n options?: { relay?: string; group?: string },\n ): Subscription {\n return requireNapplet().relay.subscribe(filters, onEvent, onEose, options);\n },\n\n /**\n * Sign and publish a Nostr event through the shell.\n * @param template Unsigned event template\n * @param options Optional: `{ relay: true }` to publish via scoped relay\n * @returns The signed NostrEvent after successful publication\n */\n publish(\n template: EventTemplate,\n options?: { relay?: boolean },\n ): Promise<NostrEvent> {\n return requireNapplet().relay.publish(template, options);\n },\n\n /**\n * Publish an encrypted Nostr event through the shell.\n * @param template Unsigned event template\n * @param recipient Hex-encoded recipient public key\n * @param encryption Encryption scheme: 'nip44' (default) or 'nip04'\n * @returns The signed encrypted NostrEvent after successful publication\n */\n publishEncrypted(\n template: EventTemplate,\n recipient: string,\n encryption: 'nip44' | 'nip04' = 'nip44',\n ): Promise<NostrEvent> {\n return requireNapplet().relay.publishEncrypted(template, recipient, encryption);\n },\n\n /**\n * One-shot query: subscribe, collect events until EOSE, then resolve.\n * @param filters NIP-01 subscription filters\n * @returns Promise resolving to array of matching NostrEvent objects\n */\n query(filters: NostrFilter | NostrFilter[]): Promise<NostrEvent[]> {\n return requireNapplet().relay.query(filters);\n },\n};\n\n// ─── IFC namespace ──────────────────────────────────────────────────────────\n\n/**\n * Inter-frame pubsub: broadcast and receive IFC-PEER events through the shell.\n *\n * @example\n * ```ts\n * import { ifc } from '@napplet/sdk';\n *\n * ifc.emit('profile:open', [], JSON.stringify({ pubkey: '...' }));\n *\n * const sub = ifc.on('profile:open', (payload) => {\n * console.log('Profile requested:', payload);\n * });\n * ```\n */\nexport const ifc = {\n /**\n * Broadcast an IFC-PEER event to other napplets via the shell.\n * @param topic The 't' tag value (e.g., 'profile:open')\n * @param extraTags Additional NIP-01 tags beyond the 't' tag (default: [])\n * @param content Event content (default: empty string)\n */\n emit(topic: string, extraTags?: string[][], content?: string): void {\n requireNapplet().ifc.emit(topic, extraTags, content);\n },\n\n /**\n * Subscribe to IFC-PEER events on a specific topic.\n * @param topic The 't' tag value to listen for\n * @param callback Called with `(payload, event)` for each matching event\n * @returns A Subscription handle with a `close()` method\n */\n on(\n topic: string,\n callback: (payload: unknown, event: NostrEvent) => void,\n ): Subscription {\n return requireNapplet().ifc.on(topic, callback);\n },\n};\n\n// ─── Services namespace ─────────────────────────────────────────────────────\n\n// ─── Storage namespace ──────────────────────────────────────────────────────\n\n/**\n * Napplet-scoped storage: async localStorage-like API proxied through the shell.\n * Each napplet's storage is isolated by identity.\n *\n * @example\n * ```ts\n * import { storage } from '@napplet/sdk';\n *\n * await storage.setItem('theme', 'dark');\n * const theme = await storage.getItem('theme'); // 'dark'\n * ```\n */\nexport const storage = {\n /**\n * Retrieve a stored value by key. Returns null if the key does not exist.\n * @param key The storage key\n * @returns The stored string value, or null if not found\n */\n getItem(key: string): Promise<string | null> {\n return requireNapplet().storage.getItem(key);\n },\n\n /**\n * Store a key-value pair.\n * @param key The storage key\n * @param value The string value to store\n */\n setItem(key: string, value: string): Promise<void> {\n return requireNapplet().storage.setItem(key, value);\n },\n\n /**\n * Remove a stored key.\n * @param key The storage key to remove\n */\n removeItem(key: string): Promise<void> {\n return requireNapplet().storage.removeItem(key);\n },\n\n /**\n * List all keys stored by this napplet.\n * @returns Array of storage key strings\n */\n keys(): Promise<string[]> {\n return requireNapplet().storage.keys();\n },\n};\n\n// ─── Media namespace ───────────────────────────────────────────────────────\n\n/**\n * Media session control: create sessions, report state and metadata,\n * declare capabilities, receive commands from the shell.\n *\n * @example\n * ```ts\n * import { media } from '@napplet/sdk';\n *\n * const { sessionId } = await media.createSession({\n * title: 'My Song', artist: 'The Artist',\n * });\n *\n * media.reportState(sessionId, { status: 'playing', position: 42.5 });\n * ```\n */\nexport const media = {\n /**\n * Create a new media session with the shell.\n * @param metadata Optional initial metadata\n * @returns The confirmed session result with sessionId\n */\n createSession(metadata?: {\n title?: string;\n artist?: string;\n album?: string;\n artwork?: { url?: string; hash?: string };\n duration?: number;\n mediaType?: 'audio' | 'video';\n }): Promise<{ sessionId: string }> {\n return requireNapplet().media.createSession(metadata);\n },\n\n /**\n * Update metadata for an existing session.\n * @param sessionId The session to update\n * @param metadata Partial metadata fields to update\n */\n updateSession(sessionId: string, metadata: {\n title?: string;\n artist?: string;\n album?: string;\n artwork?: { url?: string; hash?: string };\n duration?: number;\n mediaType?: 'audio' | 'video';\n }): void {\n requireNapplet().media.updateSession(sessionId, metadata);\n },\n\n /**\n * Destroy a media session.\n * @param sessionId The session to destroy\n */\n destroySession(sessionId: string): void {\n requireNapplet().media.destroySession(sessionId);\n },\n\n /**\n * Report current playback state for a session.\n * @param sessionId The session to report state for\n * @param state Current playback state\n */\n reportState(sessionId: string, state: {\n status: 'playing' | 'paused' | 'stopped' | 'buffering';\n position?: number;\n duration?: number;\n volume?: number;\n }): void {\n requireNapplet().media.reportState(sessionId, state);\n },\n\n /**\n * Declare which media actions the session currently supports.\n * @param sessionId The session to update capabilities for\n * @param actions Currently supported actions\n */\n reportCapabilities(sessionId: string, actions: ('play' | 'pause' | 'stop' | 'next' | 'prev' | 'seek' | 'volume')[]): void {\n requireNapplet().media.reportCapabilities(sessionId, actions);\n },\n\n /**\n * Listen for media commands from the shell.\n * @param sessionId The session to listen for commands on\n * @param callback Called with (action, value?) when a command is received\n * @returns A Subscription with `close()` to stop listening\n */\n onCommand(\n sessionId: string,\n callback: (action: 'play' | 'pause' | 'stop' | 'next' | 'prev' | 'seek' | 'volume', value?: number) => void,\n ): Subscription {\n return requireNapplet().media.onCommand(sessionId, callback);\n },\n\n /**\n * Listen for the shell's media control list.\n * @param sessionId The session to associate controls with\n * @param callback Called with the shell's supported controls\n * @returns A Subscription with `close()` to stop listening\n */\n onControls(\n sessionId: string,\n callback: (controls: ('play' | 'pause' | 'stop' | 'next' | 'prev' | 'seek' | 'volume')[]) => void,\n ): Subscription {\n return requireNapplet().media.onControls(sessionId, callback);\n },\n};\n\n// ─── Notify namespace ──────────────────────────────────────────────────────\n\n/**\n * Shell-rendered notifications: send notifications, set badge counts,\n * register channels, request permission, listen for user interaction.\n *\n * @example\n * ```ts\n * import { notify } from '@napplet/sdk';\n *\n * const { notificationId } = await notify.send({\n * title: 'New message', body: 'Alice: hey!',\n * });\n *\n * notify.badge(3);\n * ```\n */\nexport const notify = {\n /**\n * Send a notification to the shell.\n * @param notification Notification payload (title required)\n * @returns The shell-assigned notificationId\n */\n send(notification: {\n title: string;\n body?: string;\n icon?: string;\n actions?: { id: string; label: string }[];\n channel?: string;\n priority?: 'low' | 'normal' | 'high' | 'urgent';\n }): Promise<{ notificationId: string }> {\n return requireNapplet().notify.send(notification);\n },\n\n /**\n * Dismiss a notification by ID.\n * @param notificationId The notification to dismiss\n */\n dismiss(notificationId: string): void {\n requireNapplet().notify.dismiss(notificationId);\n },\n\n /**\n * Set the badge count for this napplet. Pass 0 to clear.\n * @param count Badge count\n */\n badge(count: number): void {\n requireNapplet().notify.badge(count);\n },\n\n /**\n * Register a notification channel.\n * @param channel Channel definition\n */\n registerChannel(channel: {\n channelId: string;\n label: string;\n description?: string;\n defaultPriority?: 'low' | 'normal' | 'high' | 'urgent';\n }): void {\n requireNapplet().notify.registerChannel(channel);\n },\n\n /**\n * Request permission to send notifications.\n * @param channel Optional channel to request permission for\n * @returns Whether permission was granted\n */\n requestPermission(channel?: string): Promise<{ granted: boolean }> {\n return requireNapplet().notify.requestPermission(channel);\n },\n\n /**\n * Listen for action button clicks on notifications.\n * @param callback Called with (notificationId, actionId)\n * @returns A Subscription with `close()` to stop listening\n */\n onAction(\n callback: (notificationId: string, actionId: string) => void,\n ): Subscription {\n return requireNapplet().notify.onAction(callback);\n },\n\n /**\n * Listen for notification body clicks.\n * @param callback Called with (notificationId)\n * @returns A Subscription with `close()` to stop listening\n */\n onClicked(\n callback: (notificationId: string) => void,\n ): Subscription {\n return requireNapplet().notify.onClicked(callback);\n },\n\n /**\n * Listen for notification dismissals.\n * @param callback Called with (notificationId, reason?)\n * @returns A Subscription with `close()` to stop listening\n */\n onDismissed(\n callback: (notificationId: string, reason?: string) => void,\n ): Subscription {\n return requireNapplet().notify.onDismissed(callback);\n },\n\n /**\n * Listen for the shell's notification capability list.\n * @param callback Called with supported controls\n * @returns A Subscription with `close()` to stop listening\n */\n onControls(\n callback: (controls: ('toasts' | 'badges' | 'actions' | 'channels' | 'system')[]) => void,\n ): Subscription {\n return requireNapplet().notify.onControls(callback);\n },\n};\n\n// ─── Keys namespace ────────────────────────────────────────────────────────\n\n/**\n * Keyboard forwarding and action keybindings: register named actions the shell\n * can bind to keys, listen for shell-triggered actions locally.\n *\n * @example\n * ```ts\n * import { keys } from '@napplet/sdk';\n *\n * const result = await keys.registerAction({\n * id: 'editor.save',\n * label: 'Save',\n * defaultKey: 'Ctrl+S',\n * });\n *\n * const sub = keys.onAction('editor.save', () => {\n * console.log('Save triggered!');\n * });\n * ```\n */\nexport const keys = {\n /**\n * Declare a named action that the shell can bind to a key.\n * @param action The action to register (id, label, optional defaultKey)\n * @returns The assigned binding, if any\n */\n registerAction(action: {\n id: string;\n label: string;\n defaultKey?: string;\n }): Promise<{ actionId: string; binding?: string }> {\n return requireNapplet().keys.registerAction(action);\n },\n\n /**\n * Remove a previously registered action.\n * @param actionId The action to unregister\n */\n unregisterAction(actionId: string): void {\n requireNapplet().keys.unregisterAction(actionId);\n },\n\n /**\n * Register a local handler for when a bound key is pressed.\n * @param actionId The action to listen for\n * @param callback Called when the action is triggered\n * @returns A Subscription with `close()` to stop listening\n */\n onAction(actionId: string, callback: () => void): Subscription {\n return requireNapplet().keys.onAction(actionId, callback);\n },\n\n /**\n * Convenience: register a named action AND wire a local handler in one call.\n * Returns a handle whose `close()` both unregisters the action and removes\n * the onAction listener.\n *\n * @param action The action to register (id, label, optional defaultKey)\n * @param handler Called when the shell triggers this action\n * @returns The assigned binding plus a `close()` teardown function\n *\n * @example\n * ```ts\n * import { keys } from '@napplet/sdk';\n *\n * const handle = await keys.register(\n * { id: 'editor.save', label: 'Save', defaultKey: 'Ctrl+S' },\n * () => saveDocument(),\n * );\n *\n * // Later, tear down both registration and listener:\n * handle.close();\n * ```\n */\n async register(\n action: { id: string; label: string; defaultKey?: string },\n handler: () => void,\n ): Promise<{ actionId: string; binding?: string; close: () => void }> {\n const n = requireNapplet();\n const result = await n.keys.registerAction(action);\n const sub = n.keys.onAction(action.id, handler);\n return {\n ...result,\n close() {\n sub.close();\n n.keys.unregisterAction(action.id);\n },\n };\n },\n};\n\n// ─── Identity namespace ───────────────────────────────────────────────────\n\n/**\n * Read-only user identity queries: public key, profile, follows, relays,\n * lists, zaps, mutes, blocked, badges.\n *\n * @example\n * ```ts\n * import { identity } from '@napplet/sdk';\n *\n * const pubkey = await identity.getPublicKey();\n * const profile = await identity.getProfile();\n * const follows = await identity.getFollows();\n * ```\n */\nexport const identity = {\n /**\n * Get the user's hex-encoded public key. Always succeeds.\n * @returns Hex-encoded public key string\n */\n getPublicKey(): Promise<string> {\n return requireNapplet().identity.getPublicKey();\n },\n\n /**\n * Get the user's relay list (NIP-65).\n * @returns Record mapping relay URLs to read/write permissions\n */\n getRelays(): Promise<Record<string, { read: boolean; write: boolean }>> {\n return requireNapplet().identity.getRelays();\n },\n\n /**\n * Get the user's profile metadata (kind 0).\n * @returns Profile data, or null if not found\n */\n getProfile(): Promise<{\n name?: string;\n displayName?: string;\n about?: string;\n picture?: string;\n banner?: string;\n nip05?: string;\n lud16?: string;\n website?: string;\n } | null> {\n return requireNapplet().identity.getProfile();\n },\n\n /**\n * Get the user's follow list (kind 3 contact list).\n * @returns Array of hex-encoded public keys\n */\n getFollows(): Promise<string[]> {\n return requireNapplet().identity.getFollows();\n },\n\n /**\n * Get entries from a user's categorized list.\n * @param listType List category (e.g., \"bookmarks\", \"interests\", \"pins\")\n * @returns Array of list entry values\n */\n getList(listType: string): Promise<string[]> {\n return requireNapplet().identity.getList(listType);\n },\n\n /**\n * Get zap receipts sent to the user.\n * @returns Array of zap receipt objects\n */\n getZaps(): Promise<{\n eventId: string;\n sender: string;\n amount: number;\n content?: string;\n }[]> {\n return requireNapplet().identity.getZaps();\n },\n\n /**\n * Get the user's mute list (kind 10000).\n * @returns Array of hex-encoded muted public keys\n */\n getMutes(): Promise<string[]> {\n return requireNapplet().identity.getMutes();\n },\n\n /**\n * Get the user's block list.\n * @returns Array of hex-encoded blocked public keys\n */\n getBlocked(): Promise<string[]> {\n return requireNapplet().identity.getBlocked();\n },\n\n /**\n * Get badges awarded to the user (NIP-58).\n * @returns Array of badge objects\n */\n getBadges(): Promise<{\n id: string;\n name?: string;\n description?: string;\n image?: string;\n thumbs?: string[];\n awardedBy: string;\n }[]> {\n return requireNapplet().identity.getBadges();\n },\n\n /**\n * Decrypt a received Nostr event (NIP-04 / direct NIP-44 / NIP-17 gift-wrap).\n *\n * Shape is auto-detected by the shell; napplets do NOT select encryption mode.\n * Only legal for napplets assigned class: 1 per NUB-CLASS-1 (shell-enforced).\n *\n * @param event The received event (outer wrap for NIP-17, kind-4 for NIP-04, etc.)\n * @returns Promise resolving to { rumor, sender }; rejects with Error on failure.\n */\n decrypt(event: NostrEvent): Promise<{ rumor: Rumor; sender: string }> {\n return requireNapplet().identity.decrypt(event);\n },\n};\n\n// ─── Config namespace ──────────────────────────────────────────────────────\n\n/**\n * Per-napplet declarative configuration (NUB-CONFIG): register a schema,\n * read current values, subscribe to live updates, deep-link into the\n * shell-owned settings UI, and listen for schema errors.\n *\n * @example\n * ```ts\n * import { config } from '@napplet/sdk';\n *\n * await config.registerSchema({\n * type: 'object',\n * properties: { theme: { type: 'string', enum: ['light', 'dark'], default: 'dark' } },\n * });\n *\n * const sub = config.subscribe((values) => { applyTheme(values.theme); });\n *\n * config.openSettings({ section: 'appearance' });\n * ```\n */\nexport const config = {\n /**\n * Snapshot current validated + defaulted config values.\n * @returns A one-shot ConfigValues object.\n */\n get(): Promise<Record<string, unknown>> {\n return requireNapplet().config.get();\n },\n\n /**\n * Subscribe to live configuration updates.\n * First delivery is an immediate snapshot; subsequent deliveries fire on change.\n * @param callback Invoked with the full ConfigValues on every change.\n * @returns A Subscription with close() to stop listening.\n */\n subscribe(\n callback: (values: Record<string, unknown>) => void,\n ): Subscription {\n return requireNapplet().config.subscribe(callback);\n },\n\n /**\n * Request the shell open its settings UI for this napplet.\n * @param options Optional { section } to deep-link by x-napplet-section name.\n */\n openSettings(options?: { section?: string }): void {\n requireNapplet().config.openSettings(options);\n },\n\n /**\n * Register a napplet configuration schema at runtime (escape hatch;\n * prefer manifest-declared via @napplet/vite-plugin's configSchema option).\n * @param schema JSON Schema (draft-07+) describing the config surface.\n * @param version Optional `$version` migration hint.\n */\n registerSchema(\n schema: Record<string, unknown>,\n version?: number,\n ): Promise<void> {\n return requireNapplet().config.registerSchema(schema, version);\n },\n\n /**\n * Listen for schema-registration errors pushed by the shell\n * (manifest parse failure, no-schema on subscribe-before-schema, etc.).\n * @param callback Invoked with { code, error } on every push.\n * @returns A plain teardown function that detaches the listener.\n */\n onSchemaError(\n callback: (err: { code: string; error: string }) => void,\n ): () => void {\n return requireNapplet().config.onSchemaError(callback);\n },\n\n /**\n * Current schema snapshot (readonly). Populated from the\n * `<meta name=\"napplet-config-schema\">` manifest tag at shim install,\n * updated on successful registerSchema responses.\n * @returns The registered schema, or null if none.\n */\n get schema(): Record<string, unknown> | null {\n return requireNapplet().config.schema;\n },\n};\n\n// ─── Resource namespace ────────────────────────────────────────────────────\n\n/**\n * Browser-enforced byte-fetching primitive: napplets request bytes by URL,\n * shell fetches and returns a Blob. URL space is scheme-pluggable\n * (`data:`, `https:`, `blossom:`, `nostr:`).\n *\n * @example\n * ```ts\n * import { resource } from '@napplet/sdk';\n *\n * const blob = await resource.bytes('https://example.com/avatar.png');\n * const handle = resource.bytesAsObjectURL('blossom:abc123...');\n * imgEl.src = handle.url;\n * imgEl.onload = () => handle.revoke();\n * ```\n */\nexport const resource = {\n /**\n * Fetch bytes for a URL through the shell's resource pipeline.\n * @param url URL identifying the resource (any registered scheme).\n * @returns Promise resolving to the fetched bytes as a Blob.\n */\n bytes(url: string): Promise<Blob> {\n return requireNapplet().resource.bytes(url);\n },\n\n /**\n * Fetch bytes and return a managed object URL handle.\n * Call `revoke()` to release the underlying Blob URL.\n * @param url URL identifying the resource.\n * @returns Synchronous handle `{ url, revoke }`.\n */\n bytesAsObjectURL(url: string): { url: string; revoke: () => void } {\n return requireNapplet().resource.bytesAsObjectURL(url);\n },\n};\n\n// ─── Type re-exports from @napplet/core ─────────────────────────────────────\n\nexport type { NostrEvent } from '@napplet/core';\nexport type { NostrFilter } from '@napplet/core';\nexport type { Subscription } from '@napplet/core';\nexport type { EventTemplate } from '@napplet/core';\nexport type { Rumor } from '@napplet/core';\nexport type { UnsignedEvent } from '@napplet/core';\n\n// ─── Core envelope types ───────────────────────────────────────────────────\n\nexport type { NappletMessage, NubDomain, NamespacedCapability, ShellSupports } from '@napplet/core';\nexport { NUB_DOMAINS } from '@napplet/core';\n\n// ─── NUB Message Type Re-exports ───────────────────────────────────────────\n// These types let SDK consumers work with typed envelope messages directly.\n// Import from '@napplet/sdk' instead of individual NUB packages.\n\n// Relay NUB\nexport type {\n RelayMessage,\n RelaySubscribeMessage,\n RelayCloseMessage,\n RelayPublishMessage,\n RelayPublishEncryptedMessage,\n RelayQueryMessage,\n RelayEventMessage,\n RelayEoseMessage,\n RelayClosedMessage,\n RelayPublishResultMessage,\n RelayPublishEncryptedResultMessage,\n RelayQueryResultMessage,\n RelayOutboundMessage,\n RelayInboundMessage,\n RelayNubMessage,\n} from '@napplet/nub/relay';\n\n// Identity NUB\nexport type {\n ProfileData,\n ZapReceipt,\n Badge,\n RelayPermission as IdentityRelayPermission,\n IdentityMessage,\n IdentityGetPublicKeyMessage,\n IdentityGetRelaysMessage,\n IdentityGetProfileMessage,\n IdentityGetFollowsMessage,\n IdentityGetListMessage,\n IdentityGetZapsMessage,\n IdentityGetMutesMessage,\n IdentityGetBlockedMessage,\n IdentityGetBadgesMessage,\n IdentityGetPublicKeyResultMessage,\n IdentityGetRelaysResultMessage,\n IdentityGetProfileResultMessage,\n IdentityGetFollowsResultMessage,\n IdentityGetListResultMessage,\n IdentityGetZapsResultMessage,\n IdentityGetMutesResultMessage,\n IdentityGetBlockedResultMessage,\n IdentityGetBadgesResultMessage,\n IdentityRequestMessage,\n IdentityResultMessage,\n IdentityNubMessage,\n IdentityDecryptMessage,\n IdentityDecryptResultMessage,\n IdentityDecryptErrorMessage,\n IdentityDecryptErrorCode,\n} from '@napplet/nub/identity';\n\n// Storage NUB\nexport type {\n StorageMessage,\n StorageGetMessage,\n StorageSetMessage,\n StorageRemoveMessage,\n StorageKeysMessage,\n StorageGetResultMessage,\n StorageSetResultMessage,\n StorageRemoveResultMessage,\n StorageKeysResultMessage,\n StorageRequestMessage,\n StorageResultMessage,\n StorageNubMessage,\n} from '@napplet/nub/storage';\n\n// IFC NUB\nexport type {\n IfcMessage,\n IfcEmitMessage,\n IfcSubscribeMessage,\n IfcSubscribeResultMessage,\n IfcUnsubscribeMessage,\n IfcEventMessage,\n IfcChannelOpenMessage,\n IfcChannelOpenResultMessage,\n IfcChannelEmitMessage,\n IfcChannelEventMessage,\n IfcChannelBroadcastMessage,\n IfcChannelListMessage,\n IfcChannelListResultMessage,\n IfcChannelCloseMessage,\n IfcChannelClosedMessage,\n IfcTopicMessage,\n IfcChannelMessage,\n IfcOutboundMessage,\n IfcInboundMessage,\n IfcNubMessage,\n} from '@napplet/nub/ifc';\n\n// Theme NUB\nexport type {\n ThemeColors,\n ThemeFont,\n ThemeBackground,\n Theme,\n ThemeMessage,\n ThemeGetMessage,\n ThemeGetResultMessage,\n ThemeChangedMessage,\n ThemeRequestMessage,\n ThemeResultMessage,\n ThemeNubMessage,\n} from '@napplet/nub/theme';\n\n// Keys NUB\nexport type {\n Action,\n RegisterResult,\n KeyBinding,\n KeysMessage,\n KeysForwardMessage,\n KeysRegisterActionMessage,\n KeysRegisterActionResultMessage,\n KeysUnregisterActionMessage,\n KeysBindingsMessage,\n KeysActionMessage,\n KeysRequestMessage,\n KeysResultMessage,\n KeysNubMessage,\n} from '@napplet/nub/keys';\n\n// Media NUB\nexport type {\n MediaMetadata,\n MediaArtwork,\n MediaState,\n MediaAction,\n MediaMessage,\n MediaSessionCreateMessage,\n MediaSessionCreateResultMessage,\n MediaSessionUpdateMessage,\n MediaSessionDestroyMessage,\n MediaStateMessage,\n MediaCapabilitiesMessage,\n MediaCommandMessage,\n MediaControlsMessage,\n MediaRequestMessage,\n MediaResultMessage,\n MediaNubMessage,\n} from '@napplet/nub/media';\n\n// Notify NUB\nexport type {\n NotificationPriority,\n NotificationAction,\n NotificationChannel,\n NotifyControl,\n NotifyMessage,\n NotifySendMessage,\n NotifySendResultMessage,\n NotifyDismissMessage,\n NotifyBadgeMessage,\n NotifyChannelRegisterMessage,\n NotifyPermissionRequestMessage,\n NotifyPermissionResultMessage,\n NotifyActionMessage,\n NotifyClickedMessage,\n NotifyDismissedMessage,\n NotifyControlsMessage,\n NotifyRequestMessage,\n NotifyResultMessage,\n NotifyNubMessage,\n} from '@napplet/nub/notify';\n\n// Config NUB\nexport type {\n NappletConfigSchema,\n ConfigSchema,\n ConfigValues,\n ConfigSchemaErrorCode,\n NappletConfigSchemaExtensions,\n ConfigMessage,\n ConfigRegisterSchemaMessage,\n ConfigGetMessage,\n ConfigSubscribeMessage,\n ConfigUnsubscribeMessage,\n ConfigOpenSettingsMessage,\n ConfigRegisterSchemaResultMessage,\n ConfigValuesMessage,\n ConfigSchemaErrorMessage,\n ConfigRequestMessage,\n ConfigResultMessage,\n ConfigNubMessage,\n} from '@napplet/nub/config';\n\n// Resource NUB\nexport type {\n ResourceErrorCode,\n ResourceScheme,\n ResourceMessage,\n ResourceBytesMessage,\n ResourceCancelMessage,\n ResourceBytesResultMessage,\n ResourceBytesErrorMessage,\n ResourceSidecarEntry,\n ResourceRequestMessage,\n ResourceResultMessage,\n ResourceNubMessage,\n} from '@napplet/nub/resource';\n\n// Connect NUB\nexport type {\n NappletConnect,\n} from '@napplet/nub/connect';\n\n// Class NUB\nexport type {\n ClassMessage,\n ClassAssignedMessage,\n NappletClass,\n ClassNubMessage,\n} from '@napplet/nub/class';\n\n// ─── NUB Domain Constants ──────────────────────────────────────────────────\n\nexport { DOMAIN as RELAY_DOMAIN } from '@napplet/nub/relay';\nexport { DOMAIN as IDENTITY_DOMAIN } from '@napplet/nub/identity';\nexport { DOMAIN as STORAGE_DOMAIN } from '@napplet/nub/storage';\nexport { DOMAIN as IFC_DOMAIN } from '@napplet/nub/ifc';\nexport { DOMAIN as THEME_DOMAIN } from '@napplet/nub/theme';\nexport { DOMAIN as KEYS_DOMAIN } from '@napplet/nub/keys';\nexport { DOMAIN as MEDIA_DOMAIN } from '@napplet/nub/media';\nexport { DOMAIN as NOTIFY_DOMAIN } from '@napplet/nub/notify';\nexport { DOMAIN as CONFIG_DOMAIN } from '@napplet/nub/config';\nexport { DOMAIN as RESOURCE_DOMAIN } from '@napplet/nub/resource';\nexport { DOMAIN as CONNECT_DOMAIN } from '@napplet/nub/connect';\nexport { DOMAIN as CLASS_DOMAIN } from '@napplet/nub/class';\n\n// ─── NUB Shim Installer Re-exports ─────────────────────────────────────────\n// Allow consumers to cherry-pick shim installers per domain.\n\nexport { installRelayShim } from '@napplet/nub/relay';\nexport { installIdentityShim } from '@napplet/nub/identity';\nexport { installStorageShim } from '@napplet/nub/storage';\nexport { installIfcShim } from '@napplet/nub/ifc';\nexport { installKeysShim } from '@napplet/nub/keys';\nexport { installMediaShim } from '@napplet/nub/media';\nexport { installNotifyShim } from '@napplet/nub/notify';\nexport { installConfigShim } from '@napplet/nub/config';\nexport { installResourceShim } from '@napplet/nub/resource';\nexport { installConnectShim } from '@napplet/nub/connect';\nexport { installClassShim } from '@napplet/nub/class';\n\n// ─── NUB SDK Helper Re-exports ──────────────────────────────────────────────\n// Allow consumers to use domain-specific SDK functions from @napplet/sdk.\n\nexport { relaySubscribe, relayPublish, relayPublishEncrypted, relayQuery } from '@napplet/nub/relay';\nexport { identityGetPublicKey, identityGetRelays, identityGetProfile, identityGetFollows, identityGetList, identityGetZaps, identityGetMutes, identityGetBlocked, identityGetBadges, identityDecrypt } from '@napplet/nub/identity';\nexport { storageGetItem, storageSetItem, storageRemoveItem, storageKeys } from '@napplet/nub/storage';\nexport { ifcEmit, ifcOn } from '@napplet/nub/ifc';\nexport { keysRegisterAction, keysUnregisterAction, keysOnAction, keysRegister } from '@napplet/nub/keys';\nexport { mediaCreateSession, mediaUpdateSession, mediaDestroySession, mediaReportState, mediaReportCapabilities, mediaOnCommand, mediaOnControls } from '@napplet/nub/media';\nexport { notifySend, notifyDismiss, notifyBadge, notifyRegisterChannel, notifyRequestPermission, notifyOnAction, notifyOnClicked, notifyOnDismissed, notifyOnControls } from '@napplet/nub/notify';\nexport { resourceBytes, resourceBytesAsObjectURL } from '@napplet/nub/resource';\nexport { connectGranted, connectOrigins, normalizeConnectOrigin } from '@napplet/nub/connect';\nexport { getClass } from '@napplet/nub/class';\n"],"mappings":";AAoyBA,SAAS,mBAAmB;AAiO5B,SAAmB,cAAoB;AACvC,SAAmB,UAAVA,eAAiC;AAC1C,SAAmB,UAAVA,eAAgC;AACzC,SAAmB,UAAVA,eAA4B;AACrC,SAAmB,UAAVA,eAA8B;AACvC,SAAmB,UAAVA,eAA6B;AACtC,SAAmB,UAAVA,eAA8B;AACvC,SAAmB,UAAVA,eAA+B;AACxC,SAAmB,UAAVA,eAA+B;AACxC,SAAmB,UAAVA,gBAAiC;AAC1C,SAAmB,UAAVA,gBAAgC;AACzC,SAAmB,UAAVA,gBAA8B;AAKvC,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,S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,QAAQ,OAAO;AAAA,EAC/D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,cACE,UACY;AACZ,WAAO,eAAe,EAAE,OAAO,cAAc,QAAQ;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAI,SAAyC;AAC3C,WAAO,eAAe,EAAE,OAAO;AAAA,EACjC;AACF;AAmBO,IAAM,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMtB,MAAM,KAA4B;AAChC,WAAO,eAAe,EAAE,SAAS,MAAM,GAAG;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,iBAAiB,KAAkD;AACjE,WAAO,eAAe,EAAE,SAAS,iBAAiB,GAAG;AAAA,EACvD;AACF;","names":["DOMAIN"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @napplet/sdk -- Typed named exports wrapping window.napplet.\n *\n * Provides `relay`, `ifc`, `storage`, and `keys` objects that delegate\n * to `window.napplet.*` at call time. Developers using a bundler can import\n * individual namespaces without depending on the shim's side-effect install:\n *\n * ```ts\n * import { relay, ifc } from '@napplet/sdk';\n * ```\n *\n * The shim must still be imported somewhere in the application to install\n * the `window.napplet` global. The SDK only wraps it -- it does not install it.\n *\n * Domain-specific SDK helpers are also available directly from NUB packages:\n * ```ts\n * import { relaySubscribe } from '@napplet/nub/relay';\n * import { storageGetItem } from '@napplet/nub/storage';\n * ```\n *\n * @packageDocumentation\n */\n\nimport type {\n NappletGlobal,\n NostrEvent,\n NostrFilter,\n Subscription,\n EventTemplate,\n} from '@napplet/core';\nimport type {\n MediaSessionCreate,\n MediaSessionResult,\n MediaMetadata,\n MediaState,\n MediaAction,\n} from '@napplet/nub/media';\n\n/**\n * Retrieve the `window.napplet` global, throwing a clear error if it is absent.\n *\n * Every SDK method calls this at invocation time -- not at module load time --\n * so the shim can be imported in any order relative to the SDK.\n */\nfunction requireNapplet(): NappletGlobal {\n const w = window as Window & { napplet?: NappletGlobal };\n if (!w.napplet) {\n throw new Error('window.napplet not installed -- import @napplet/shim first');\n }\n return w.napplet;\n}\n\n/**\n * NIP-01 relay operations: subscribe to events, publish events, one-shot queries.\n *\n * Each method delegates to `window.napplet.relay.*` at call time, which in turn\n * routes through the shell's relay pool via postMessage.\n *\n * @example\n * ```ts\n * import { relay } from '@napplet/sdk';\n *\n * const sub = relay.subscribe(\n * { kinds: [1], limit: 10 },\n * (event) => console.log(event),\n * () => console.log('EOSE'),\n * );\n * ```\n */\nexport const relay = {\n /**\n * Open a live NIP-01 subscription through the shell's relay pool.\n * @param filters One or more NIP-01 subscription filters\n * @param onEvent Called for each matching event\n * @param onEose Called when the shell signals end of stored events (EOSE)\n * @param options Optional: `{ relay, group }` for NIP-29 scoped relay subscriptions\n * @returns A Subscription handle with a `close()` method\n */\n subscribe(\n filters: NostrFilter | NostrFilter[],\n onEvent: (event: NostrEvent) => void,\n onEose: () => void,\n options?: { relay?: string; group?: string },\n ): Subscription {\n return requireNapplet().relay.subscribe(filters, onEvent, onEose, options);\n },\n\n /**\n * Sign and publish a Nostr event through the shell.\n * @param template Unsigned event template\n * @param options Optional: `{ relay: true }` to publish via scoped relay\n * @returns The signed NostrEvent after successful publication\n */\n publish(\n template: EventTemplate,\n options?: { relay?: boolean },\n ): Promise<NostrEvent> {\n return requireNapplet().relay.publish(template, options);\n },\n\n /**\n * Publish an encrypted Nostr event through the shell.\n * @param template Unsigned event template\n * @param recipient Hex-encoded recipient public key\n * @param encryption Encryption scheme: 'nip44' (default) or 'nip04'\n * @returns The signed encrypted NostrEvent after successful publication\n */\n publishEncrypted(\n template: EventTemplate,\n recipient: string,\n encryption: 'nip44' | 'nip04' = 'nip44',\n ): Promise<NostrEvent> {\n return requireNapplet().relay.publishEncrypted(template, recipient, encryption);\n },\n\n /**\n * One-shot query: subscribe, collect events until EOSE, then resolve.\n * @param filters NIP-01 subscription filters\n * @returns Promise resolving to array of matching NostrEvent objects\n */\n query(filters: NostrFilter | NostrFilter[]): Promise<NostrEvent[]> {\n return requireNapplet().relay.query(filters);\n },\n};\n\n/**\n * Inter-frame pubsub: broadcast and receive IFC-PEER events through the shell.\n *\n * @example\n * ```ts\n * import { ifc } from '@napplet/sdk';\n *\n * ifc.emit('profile:open', [], JSON.stringify({ pubkey: '...' }));\n *\n * const sub = ifc.on('profile:open', (payload) => {\n * console.log('Profile requested:', payload);\n * });\n * ```\n */\nexport const ifc = {\n /**\n * Broadcast an IFC-PEER event to other napplets via the shell.\n * @param topic The 't' tag value (e.g., 'profile:open')\n * @param extraTags Additional NIP-01 tags beyond the 't' tag (default: [])\n * @param content Event content (default: empty string)\n */\n emit(topic: string, extraTags?: string[][], content?: string): void {\n requireNapplet().ifc.emit(topic, extraTags, content);\n },\n\n /**\n * Subscribe to IFC-PEER events on a specific topic.\n * @param topic The 't' tag value to listen for\n * @param callback Called with `(payload, event)` for each matching event\n * @returns A Subscription handle with a `close()` method\n */\n on(\n topic: string,\n callback: (payload: unknown, event: NostrEvent) => void,\n ): Subscription {\n return requireNapplet().ifc.on(topic, callback);\n },\n};\n\n/**\n * Napplet-scoped storage: async localStorage-like API proxied through the shell.\n * Each napplet's storage is isolated by identity.\n *\n * @example\n * ```ts\n * import { storage } from '@napplet/sdk';\n *\n * await storage.setItem('theme', 'dark');\n * const theme = await storage.getItem('theme'); // 'dark'\n * ```\n */\nexport const storage = {\n /**\n * Retrieve a stored value by key. Returns null if the key does not exist.\n * @param key The storage key\n * @returns The stored string value, or null if not found\n */\n getItem(key: string): Promise<string | null> {\n return requireNapplet().storage.getItem(key);\n },\n\n /**\n * Store a key-value pair.\n * @param key The storage key\n * @param value The string value to store\n */\n setItem(key: string, value: string): Promise<void> {\n return requireNapplet().storage.setItem(key, value);\n },\n\n /**\n * Remove a stored key.\n * @param key The storage key to remove\n */\n removeItem(key: string): Promise<void> {\n return requireNapplet().storage.removeItem(key);\n },\n\n /**\n * List all keys stored by this napplet.\n * @returns Array of storage key strings\n */\n keys(): Promise<string[]> {\n return requireNapplet().storage.keys();\n },\n};\n\n/**\n * Media session control: create sessions, report state and metadata,\n * declare capabilities, receive commands from the shell.\n *\n * @example\n * ```ts\n * import { media } from '@napplet/sdk';\n *\n * const { sessionId } = await media.createSession({\n * owner: 'napplet',\n * metadata: { title: 'My Song', artist: 'The Artist' },\n * });\n *\n * media.reportState(sessionId, { status: 'playing', position: 42.5 });\n * ```\n */\nexport const media = {\n /**\n * Create a new media session with the shell.\n * @param options Ownership-aware session options\n * @returns The shell result with canonical sessionId and owner, or error\n */\n createSession(options: MediaSessionCreate): Promise<MediaSessionResult> {\n return requireNapplet().media.createSession(options);\n },\n\n /**\n * Update metadata for an existing session.\n * @param sessionId The session to update\n * @param metadata Partial metadata fields to update\n */\n updateSession(sessionId: string, metadata: Partial<MediaMetadata>): void {\n requireNapplet().media.updateSession(sessionId, metadata);\n },\n\n /**\n * Destroy a media session.\n * @param sessionId The session to destroy\n */\n destroySession(sessionId: string): void {\n requireNapplet().media.destroySession(sessionId);\n },\n\n /**\n * Report current playback state for a session.\n * @param sessionId The session to report state for\n * @param state Current playback state\n */\n reportState(sessionId: string, state: MediaState): void {\n requireNapplet().media.reportState(sessionId, state);\n },\n\n /**\n * Declare which media actions the session currently supports.\n * @param sessionId The session to update capabilities for\n * @param actions Currently supported actions\n */\n reportCapabilities(sessionId: string, actions: MediaAction[]): void {\n requireNapplet().media.reportCapabilities(sessionId, actions);\n },\n\n /**\n * Send a command to the current playback owner.\n * @param sessionId The session to control\n * @param action The media action to request\n * @param value Optional value for seek/volume\n */\n sendCommand(sessionId: string, action: MediaAction, value?: number): void {\n requireNapplet().media.sendCommand(sessionId, action, value);\n },\n\n /**\n * Listen for media commands from the shell.\n * @param sessionId The session to listen for commands on\n * @param callback Called with (action, value?) when a command is received\n * @returns A Subscription with `close()` to stop listening\n */\n onCommand(\n sessionId: string,\n callback: (action: MediaAction, value?: number) => void,\n ): Subscription {\n return requireNapplet().media.onCommand(sessionId, callback);\n },\n\n /**\n * Listen for shell-reported playback state for shell-owned sessions.\n * @param sessionId The session to listen for state on\n * @param callback Called with playback state\n * @returns A Subscription with `close()` to stop listening\n */\n onState(\n sessionId: string,\n callback: (state: MediaState) => void,\n ): Subscription {\n return requireNapplet().media.onState(sessionId, callback);\n },\n\n /**\n * Listen for shell-reported capabilities for shell-owned sessions.\n * @param sessionId The session to listen for capabilities on\n * @param callback Called with available actions\n * @returns A Subscription with `close()` to stop listening\n */\n onCapabilities(\n sessionId: string,\n callback: (actions: MediaAction[]) => void,\n ): Subscription {\n return requireNapplet().media.onCapabilities(sessionId, callback);\n },\n\n /**\n * Listen for the shell's media control list.\n * @param sessionId The session to associate controls with\n * @param callback Called with the shell's supported controls\n * @returns A Subscription with `close()` to stop listening\n */\n onControls(\n sessionId: string,\n callback: (controls: MediaAction[]) => void,\n ): Subscription {\n return requireNapplet().media.onControls(sessionId, callback);\n },\n};\n\n/**\n * Shell-rendered notifications: send notifications, set badge counts,\n * register channels, request permission, listen for user interaction.\n *\n * @example\n * ```ts\n * import { notify } from '@napplet/sdk';\n *\n * const { notificationId } = await notify.send({\n * title: 'New message', body: 'Alice: hey!',\n * });\n *\n * notify.badge(3);\n * ```\n */\nexport const notify = {\n /**\n * Send a notification to the shell.\n * @param notification Notification payload (title required)\n * @returns The shell-assigned notificationId\n */\n send(notification: {\n title: string;\n body?: string;\n icon?: string;\n actions?: { id: string; label: string }[];\n channel?: string;\n priority?: 'low' | 'normal' | 'high' | 'urgent';\n }): Promise<{ notificationId: string }> {\n return requireNapplet().notify.send(notification);\n },\n\n /**\n * Dismiss a notification by ID.\n * @param notificationId The notification to dismiss\n */\n dismiss(notificationId: string): void {\n requireNapplet().notify.dismiss(notificationId);\n },\n\n /**\n * Set the badge count for this napplet. Pass 0 to clear.\n * @param count Badge count\n */\n badge(count: number): void {\n requireNapplet().notify.badge(count);\n },\n\n /**\n * Register a notification channel.\n * @param channel Channel definition\n */\n registerChannel(channel: {\n channelId: string;\n label: string;\n description?: string;\n defaultPriority?: 'low' | 'normal' | 'high' | 'urgent';\n }): void {\n requireNapplet().notify.registerChannel(channel);\n },\n\n /**\n * Request permission to send notifications.\n * @param channel Optional channel to request permission for\n * @returns Whether permission was granted\n */\n requestPermission(channel?: string): Promise<{ granted: boolean }> {\n return requireNapplet().notify.requestPermission(channel);\n },\n\n /**\n * Listen for action button clicks on notifications.\n * @param callback Called with (notificationId, actionId)\n * @returns A Subscription with `close()` to stop listening\n */\n onAction(\n callback: (notificationId: string, actionId: string) => void,\n ): Subscription {\n return requireNapplet().notify.onAction(callback);\n },\n\n /**\n * Listen for notification body clicks.\n * @param callback Called with (notificationId)\n * @returns A Subscription with `close()` to stop listening\n */\n onClicked(\n callback: (notificationId: string) => void,\n ): Subscription {\n return requireNapplet().notify.onClicked(callback);\n },\n\n /**\n * Listen for notification dismissals.\n * @param callback Called with (notificationId, reason?)\n * @returns A Subscription with `close()` to stop listening\n */\n onDismissed(\n callback: (notificationId: string, reason?: string) => void,\n ): Subscription {\n return requireNapplet().notify.onDismissed(callback);\n },\n\n /**\n * Listen for the shell's notification capability list.\n * @param callback Called with supported controls\n * @returns A Subscription with `close()` to stop listening\n */\n onControls(\n callback: (controls: ('toasts' | 'badges' | 'actions' | 'channels' | 'system')[]) => void,\n ): Subscription {\n return requireNapplet().notify.onControls(callback);\n },\n};\n\n/**\n * Keyboard forwarding and action keybindings: register named actions the shell\n * can bind to keys, listen for shell-triggered actions locally.\n *\n * @example\n * ```ts\n * import { keys } from '@napplet/sdk';\n *\n * const result = await keys.registerAction({\n * id: 'editor.save',\n * label: 'Save',\n * defaultKey: 'Ctrl+S',\n * });\n *\n * const sub = keys.onAction('editor.save', () => {\n * console.log('Save triggered!');\n * });\n * ```\n */\nexport const keys = {\n /**\n * Declare a named action that the shell can bind to a key.\n * @param action The action to register (id, label, optional defaultKey)\n * @returns The assigned binding, if any\n */\n registerAction(action: {\n id: string;\n label: string;\n defaultKey?: string;\n }): Promise<{ actionId: string; binding?: string }> {\n return requireNapplet().keys.registerAction(action);\n },\n\n /**\n * Remove a previously registered action.\n * @param actionId The action to unregister\n */\n unregisterAction(actionId: string): void {\n requireNapplet().keys.unregisterAction(actionId);\n },\n\n /**\n * Register a local handler for when a bound key is pressed.\n * @param actionId The action to listen for\n * @param callback Called when the action is triggered\n * @returns A Subscription with `close()` to stop listening\n */\n onAction(actionId: string, callback: () => void): Subscription {\n return requireNapplet().keys.onAction(actionId, callback);\n },\n\n /**\n * Convenience: register a named action AND wire a local handler in one call.\n * Returns a handle whose `close()` both unregisters the action and removes\n * the onAction listener.\n *\n * @param action The action to register (id, label, optional defaultKey)\n * @param handler Called when the shell triggers this action\n * @returns The assigned binding plus a `close()` teardown function\n *\n * @example\n * ```ts\n * import { keys } from '@napplet/sdk';\n *\n * const handle = await keys.register(\n * { id: 'editor.save', label: 'Save', defaultKey: 'Ctrl+S' },\n * () => saveDocument(),\n * );\n *\n * // Later, tear down both registration and listener:\n * handle.close();\n * ```\n */\n async register(\n action: { id: string; label: string; defaultKey?: string },\n handler: () => void,\n ): Promise<{ actionId: string; binding?: string; close: () => void }> {\n const n = requireNapplet();\n const result = await n.keys.registerAction(action);\n const sub = n.keys.onAction(action.id, handler);\n return {\n ...result,\n close() {\n sub.close();\n n.keys.unregisterAction(action.id);\n },\n };\n },\n};\n\n/**\n * Read-only user identity queries: public key, profile, follows, relays,\n * lists, zaps, mutes, blocked, badges.\n *\n * @example\n * ```ts\n * import { identity } from '@napplet/sdk';\n *\n * const pubkey = await identity.getPublicKey();\n * const profile = await identity.getProfile();\n * const follows = await identity.getFollows();\n * ```\n */\nexport const identity = {\n /**\n * Get the user's hex-encoded public key. Always succeeds.\n * @returns Hex-encoded public key string\n */\n getPublicKey(): Promise<string> {\n return requireNapplet().identity.getPublicKey();\n },\n\n /**\n * Listen for shell-pushed user identity changes.\n * @param handler Called with a hex pubkey, or \"\" when no user/signer is connected\n * @returns Subscription with close() to detach the handler\n */\n onChanged(handler: (pubkey: string) => void): Subscription {\n return requireNapplet().identity.onChanged(handler);\n },\n\n /**\n * Get the user's relay list (NIP-65).\n * @returns Record mapping relay URLs to read/write permissions\n */\n getRelays(): Promise<Record<string, { read: boolean; write: boolean }>> {\n return requireNapplet().identity.getRelays();\n },\n\n /**\n * Get the user's profile metadata (kind 0).\n * @returns Profile data, or null if not found\n */\n getProfile(): Promise<{\n name?: string;\n displayName?: string;\n about?: string;\n picture?: string;\n banner?: string;\n nip05?: string;\n lud16?: string;\n website?: string;\n } | null> {\n return requireNapplet().identity.getProfile();\n },\n\n /**\n * Get the user's follow list (kind 3 contact list).\n * @returns Array of hex-encoded public keys\n */\n getFollows(): Promise<string[]> {\n return requireNapplet().identity.getFollows();\n },\n\n /**\n * Get entries from a user's categorized list.\n * @param listType List category (e.g., \"bookmarks\", \"interests\", \"pins\")\n * @returns Array of list entry values\n */\n getList(listType: string): Promise<string[]> {\n return requireNapplet().identity.getList(listType);\n },\n\n /**\n * Get zap receipts sent to the user.\n * @returns Array of zap receipt objects\n */\n getZaps(): Promise<{\n eventId: string;\n sender: string;\n amount: number;\n content?: string;\n }[]> {\n return requireNapplet().identity.getZaps();\n },\n\n /**\n * Get the user's mute list (kind 10000).\n * @returns Array of hex-encoded muted public keys\n */\n getMutes(): Promise<string[]> {\n return requireNapplet().identity.getMutes();\n },\n\n /**\n * Get the user's block list.\n * @returns Array of hex-encoded blocked public keys\n */\n getBlocked(): Promise<string[]> {\n return requireNapplet().identity.getBlocked();\n },\n\n /**\n * Get badges awarded to the user (NIP-58).\n * @returns Array of badge objects\n */\n getBadges(): Promise<{\n id: string;\n name?: string;\n description?: string;\n image?: string;\n thumbs?: string[];\n awardedBy: string;\n }[]> {\n return requireNapplet().identity.getBadges();\n },\n};\n\n/**\n * Per-napplet declarative configuration (NAP-CONFIG): register a schema,\n * read current values, subscribe to live updates, deep-link into the\n * shell-owned settings UI, and listen for schema errors.\n *\n * @example\n * ```ts\n * import { config } from '@napplet/sdk';\n *\n * await config.registerSchema({\n * type: 'object',\n * properties: { theme: { type: 'string', enum: ['light', 'dark'], default: 'dark' } },\n * });\n *\n * const sub = config.subscribe((values) => { applyTheme(values.theme); });\n *\n * config.openSettings({ section: 'appearance' });\n * ```\n */\nexport const config = {\n /**\n * Snapshot current validated + defaulted config values.\n * @returns A one-shot ConfigValues object.\n */\n get(): Promise<Record<string, unknown>> {\n return requireNapplet().config.get();\n },\n\n /**\n * Subscribe to live configuration updates.\n * First delivery is an immediate snapshot; subsequent deliveries fire on change.\n * @param callback Invoked with the full ConfigValues on every change.\n * @returns A Subscription with close() to stop listening.\n */\n subscribe(\n callback: (values: Record<string, unknown>) => void,\n ): Subscription {\n return requireNapplet().config.subscribe(callback);\n },\n\n /**\n * Request the shell open its settings UI for this napplet.\n * @param options Optional { section } to deep-link by x-napplet-section name.\n */\n openSettings(options?: { section?: string }): void {\n requireNapplet().config.openSettings(options);\n },\n\n /**\n * Register a napplet configuration schema at runtime (escape hatch;\n * prefer manifest-declared via @napplet/vite-plugin's configSchema option).\n * @param schema JSON Schema (draft-07+) describing the config surface.\n * @param version Optional `$version` migration hint.\n */\n registerSchema(\n schema: Record<string, unknown>,\n version?: number,\n ): Promise<void> {\n return requireNapplet().config.registerSchema(schema, version);\n },\n\n /**\n * Listen for schema-registration errors pushed by the shell\n * (manifest parse failure, no-schema on subscribe-before-schema, etc.).\n * @param callback Invoked with { code, error } on every push.\n * @returns A plain teardown function that detaches the listener.\n */\n onSchemaError(\n callback: (err: { code: string; error: string }) => void,\n ): () => void {\n return requireNapplet().config.onSchemaError(callback);\n },\n\n /**\n * Current schema snapshot (readonly). Populated from the\n * `<meta name=\"napplet-config-schema\">` manifest tag at shim install,\n * updated on successful registerSchema responses.\n * @returns The registered schema, or null if none.\n */\n get schema(): Record<string, unknown> | null {\n return requireNapplet().config.schema;\n },\n};\n\n/**\n * Browser-enforced byte-fetching primitive: napplets request bytes by URL,\n * shell fetches and returns a Blob. URL space is scheme-pluggable\n * (`data:`, `https:`, `blossom:`, `nostr:`).\n *\n * @example\n * ```ts\n * import { resource } from '@napplet/sdk';\n *\n * const blob = await resource.bytes('https://example.com/avatar.png');\n * const handle = resource.bytesAsObjectURL('blossom:abc123...');\n * imgEl.src = handle.url;\n * imgEl.onload = () => handle.revoke();\n * ```\n */\nexport const resource = {\n /**\n * Fetch bytes for a URL through the shell's resource pipeline.\n * @param url URL identifying the resource (any registered scheme).\n * @returns Promise resolving to the fetched bytes as a Blob.\n */\n bytes(url: string): Promise<Blob> {\n return requireNapplet().resource.bytes(url);\n },\n\n /**\n * Fetch bytes and return a managed object URL handle.\n * Call `revoke()` to release the underlying Blob URL.\n * @param url URL identifying the resource.\n * @returns Synchronous handle `{ url, revoke }`.\n */\n bytesAsObjectURL(url: string): { url: string; revoke: () => void } {\n return requireNapplet().resource.bytesAsObjectURL(url);\n },\n};\n\nexport type { NostrEvent } from '@napplet/core';\nexport type { NostrFilter } from '@napplet/core';\nexport type { Subscription } from '@napplet/core';\nexport type { EventTemplate } from '@napplet/core';\n\nexport type {\n NappletMessage,\n NapDomain,\n NubDomain,\n NamespacedCapability,\n NapProtocolId,\n NubProtocolId,\n ProtocolId,\n ShellSupports,\n} from '@napplet/core';\nexport { NAP_DOMAINS, NUB_DOMAINS } from '@napplet/core';\n\n// Relay NUB\nexport type {\n RelayMessage,\n RelaySubscribeMessage,\n RelayCloseMessage,\n RelayPublishMessage,\n RelayPublishEncryptedMessage,\n RelayQueryMessage,\n RelayEventMessage,\n RelayEoseMessage,\n RelayClosedMessage,\n RelayPublishResultMessage,\n RelayPublishEncryptedResultMessage,\n RelayQueryResultMessage,\n RelayOutboundMessage,\n RelayInboundMessage,\n RelayNubMessage,\n} from '@napplet/nub/relay';\n\n// Identity NUB\nexport type {\n ProfileData,\n ZapReceipt,\n Badge,\n RelayPermission as IdentityRelayPermission,\n IdentityMessage,\n IdentityGetPublicKeyMessage,\n IdentityGetRelaysMessage,\n IdentityGetProfileMessage,\n IdentityGetFollowsMessage,\n IdentityGetListMessage,\n IdentityGetZapsMessage,\n IdentityGetMutesMessage,\n IdentityGetBlockedMessage,\n IdentityGetBadgesMessage,\n IdentityGetPublicKeyResultMessage,\n IdentityGetRelaysResultMessage,\n IdentityGetProfileResultMessage,\n IdentityGetFollowsResultMessage,\n IdentityGetListResultMessage,\n IdentityGetZapsResultMessage,\n IdentityGetMutesResultMessage,\n IdentityGetBlockedResultMessage,\n IdentityGetBadgesResultMessage,\n IdentityChangedMessage,\n IdentityRequestMessage,\n IdentityResultMessage,\n IdentityNapMessage,\n IdentityNubMessage,\n} from '@napplet/nub/identity';\n\n// Storage NUB\nexport type {\n StorageMessage,\n StorageGetMessage,\n StorageSetMessage,\n StorageRemoveMessage,\n StorageKeysMessage,\n StorageGetResultMessage,\n StorageSetResultMessage,\n StorageRemoveResultMessage,\n StorageKeysResultMessage,\n StorageRequestMessage,\n StorageResultMessage,\n StorageNubMessage,\n} from '@napplet/nub/storage';\n\n// IFC NUB\nexport type {\n IfcMessage,\n IfcEmitMessage,\n IfcSubscribeMessage,\n IfcSubscribeResultMessage,\n IfcUnsubscribeMessage,\n IfcEventMessage,\n IfcChannelOpenMessage,\n IfcChannelOpenResultMessage,\n IfcChannelEmitMessage,\n IfcChannelEventMessage,\n IfcChannelBroadcastMessage,\n IfcChannelListMessage,\n IfcChannelListResultMessage,\n IfcChannelCloseMessage,\n IfcChannelClosedMessage,\n IfcTopicMessage,\n IfcChannelMessage,\n IfcOutboundMessage,\n IfcInboundMessage,\n IfcNubMessage,\n} from '@napplet/nub/ifc';\n\n// Theme NUB\nexport type {\n ThemeColors,\n ThemeFont,\n ThemeBackground,\n Theme,\n ThemeMessage,\n ThemeGetMessage,\n ThemeGetResultMessage,\n ThemeChangedMessage,\n ThemeRequestMessage,\n ThemeResultMessage,\n ThemeNubMessage,\n} from '@napplet/nub/theme';\n\n// Keys NUB\nexport type {\n Action,\n RegisterResult,\n KeyBinding,\n KeysMessage,\n KeysForwardMessage,\n KeysRegisterActionMessage,\n KeysRegisterActionResultMessage,\n KeysUnregisterActionMessage,\n KeysBindingsMessage,\n KeysActionMessage,\n KeysRequestMessage,\n KeysResultMessage,\n KeysNubMessage,\n} from '@napplet/nub/keys';\n\n// Media NAP\nexport type {\n MediaMetadata,\n MediaArtwork,\n MediaPlaybackOwner,\n MediaSourceRef,\n MediaSessionCreate,\n MediaSessionResult,\n MediaState,\n MediaAction,\n MediaMessage,\n MediaSessionCreateMessage,\n MediaSessionCreateResultMessage,\n MediaSessionUpdateMessage,\n MediaSessionDestroyMessage,\n MediaStateMessage,\n MediaCapabilitiesMessage,\n MediaCommandMessage,\n MediaControlsMessage,\n MediaRequestMessage,\n MediaResultMessage,\n MediaNapMessage,\n MediaNubMessage,\n} from '@napplet/nub/media';\n\n// Notify NUB\nexport type {\n NotificationPriority,\n NotificationAction,\n NotificationChannel,\n NotifyControl,\n NotifyMessage,\n NotifySendMessage,\n NotifySendResultMessage,\n NotifyDismissMessage,\n NotifyBadgeMessage,\n NotifyChannelRegisterMessage,\n NotifyPermissionRequestMessage,\n NotifyPermissionResultMessage,\n NotifyActionMessage,\n NotifyClickedMessage,\n NotifyDismissedMessage,\n NotifyControlsMessage,\n NotifyRequestMessage,\n NotifyResultMessage,\n NotifyNubMessage,\n} from '@napplet/nub/notify';\n\n// Config NUB\nexport type {\n NappletConfigSchema,\n ConfigSchema,\n ConfigValues,\n ConfigSchemaErrorCode,\n NappletConfigSchemaExtensions,\n ConfigMessage,\n ConfigRegisterSchemaMessage,\n ConfigGetMessage,\n ConfigSubscribeMessage,\n ConfigUnsubscribeMessage,\n ConfigOpenSettingsMessage,\n ConfigRegisterSchemaResultMessage,\n ConfigValuesMessage,\n ConfigSchemaErrorMessage,\n ConfigRequestMessage,\n ConfigResultMessage,\n ConfigNubMessage,\n} from '@napplet/nub/config';\n\n// Resource NUB\nexport type {\n ResourceErrorCode,\n ResourceScheme,\n ResourceMessage,\n ResourceBytesMessage,\n ResourceCancelMessage,\n ResourceBytesResultMessage,\n ResourceBytesErrorMessage,\n ResourceSidecarEntry,\n ResourceRequestMessage,\n ResourceResultMessage,\n ResourceNubMessage,\n} from '@napplet/nub/resource';\n\n// Connect NUB\nexport type {\n NappletConnect,\n} from '@napplet/nub/connect';\n\n// Class NUB\nexport type {\n ClassMessage,\n ClassAssignedMessage,\n NappletClass,\n ClassNubMessage,\n} from '@napplet/nub/class';\n\nexport { DOMAIN as RELAY_DOMAIN } from '@napplet/nub/relay';\nexport { DOMAIN as IDENTITY_DOMAIN } from '@napplet/nub/identity';\nexport { DOMAIN as STORAGE_DOMAIN } from '@napplet/nub/storage';\nexport { DOMAIN as IFC_DOMAIN } from '@napplet/nub/ifc';\nexport { DOMAIN as THEME_DOMAIN } from '@napplet/nub/theme';\nexport { DOMAIN as KEYS_DOMAIN } from '@napplet/nub/keys';\nexport { DOMAIN as MEDIA_DOMAIN } from '@napplet/nub/media';\nexport { DOMAIN as NOTIFY_DOMAIN } from '@napplet/nub/notify';\nexport { DOMAIN as CONFIG_DOMAIN } from '@napplet/nub/config';\nexport { DOMAIN as RESOURCE_DOMAIN } from '@napplet/nub/resource';\nexport { DOMAIN as CONNECT_DOMAIN } from '@napplet/nub/connect';\nexport { DOMAIN as CLASS_DOMAIN } from '@napplet/nub/class';\n\nexport { installRelayShim } from '@napplet/nub/relay';\nexport { installIdentityShim } from '@napplet/nub/identity';\nexport { installStorageShim } from '@napplet/nub/storage';\nexport { installIfcShim } from '@napplet/nub/ifc';\nexport { installKeysShim } from '@napplet/nub/keys';\nexport { installMediaShim } from '@napplet/nub/media';\nexport { installNotifyShim } from '@napplet/nub/notify';\nexport { installConfigShim } from '@napplet/nub/config';\nexport { installResourceShim } from '@napplet/nub/resource';\nexport { installConnectShim } from '@napplet/nub/connect';\nexport { installClassShim } from '@napplet/nub/class';\n\nexport { relaySubscribe, relayPublish, relayPublishEncrypted, relayQuery } from '@napplet/nub/relay';\nexport {\n identityGetPublicKey,\n identityOnChanged,\n identityGetRelays,\n identityGetProfile,\n identityGetFollows,\n identityGetList,\n identityGetZaps,\n identityGetMutes,\n identityGetBlocked,\n identityGetBadges,\n} from '@napplet/nub/identity';\nexport { storageGetItem, storageSetItem, storageRemoveItem, storageKeys } from '@napplet/nub/storage';\nexport { ifcEmit, ifcOn } from '@napplet/nub/ifc';\nexport { keysRegisterAction, keysUnregisterAction, keysOnAction, keysRegister } from '@napplet/nub/keys';\nexport { mediaCreateSession, mediaUpdateSession, mediaDestroySession, mediaReportState, mediaReportCapabilities, mediaSendCommand, mediaOnCommand, mediaOnState, mediaOnCapabilities, mediaOnControls } from '@napplet/nub/media';\nexport { notifySend, notifyDismiss, notifyBadge, notifyRegisterChannel, notifyRequestPermission, notifyOnAction, notifyOnClicked, notifyOnDismissed, notifyOnControls } from '@napplet/nub/notify';\nexport { resourceBytes, resourceBytesAsObjectURL } from '@napplet/nub/resource';\nexport { connectGranted, connectOrigins, normalizeConnectOrigin } from '@napplet/nub/connect';\nexport { getClass } from '@napplet/nub/class';\n"],"mappings":";AA0xBA,SAAS,aAAa,mBAAmB;AA8NzC,SAAmB,cAAoB;AACvC,SAAmB,UAAVA,eAAiC;AAC1C,SAAmB,UAAVA,eAAgC;AACzC,SAAmB,UAAVA,eAA4B;AACrC,SAAmB,UAAVA,eAA8B;AACvC,SAAmB,UAAVA,eAA6B;AACtC,SAAmB,UAAVA,eAA8B;AACvC,SAAmB,UAAVA,eAA+B;AACxC,SAAmB,UAAVA,eAA+B;AACxC,SAAmB,UAAVA,gBAAiC;AAC1C,SAAmB,UAAVA,gBAAgC;AACzC,SAAmB,UAAVA,gBAA8B;AAEvC,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AAEjC,SAAS,gBAAgB,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E,OAAO,UAAU,QAAQ;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,aAAa,SAAsC;AACjD,mBAAe,EAAE,OAAO,aAAa,OAAO;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,eACE,QACA,SACe;AACf,WAAO,eAAe,EAAE,OAAO,eAAe,QAAQ,OAAO;AAAA,EAC/D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,cACE,UACY;AACZ,WAAO,eAAe,EAAE,OAAO,cAAc,QAAQ;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAI,SAAyC;AAC3C,WAAO,eAAe,EAAE,OAAO;AAAA,EACjC;AACF;AAiBO,IAAM,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMtB,MAAM,KAA4B;AAChC,WAAO,eAAe,EAAE,SAAS,MAAM,GAAG;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,iBAAiB,KAAkD;AACjE,WAAO,eAAe,EAAE,SAAS,iBAAiB,GAAG;AAAA,EACvD;AACF;","names":["DOMAIN"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@napplet/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Typed named exports wrapping window.napplet for bundler-consuming napplet developers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@napplet/core": "0.
|
|
24
|
-
"@napplet/nub": "0.
|
|
23
|
+
"@napplet/core": "0.5.0",
|
|
24
|
+
"@napplet/nub": "0.5.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"tsup": "^8.5.0",
|