@napplet/sdk 0.20.1 → 0.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2,10 +2,20 @@
2
2
  function requireNapplet() {
3
3
  const w = window;
4
4
  if (!w.napplet) {
5
- throw new Error("window.napplet not installed -- import @napplet/shim first");
5
+ throw new Error("window.napplet is unavailable -- runtime did not inject the napplet namespace");
6
6
  }
7
7
  return w.napplet;
8
8
  }
9
+ function requireDomain(domain) {
10
+ const napplet = requireNapplet();
11
+ const value = napplet[domain];
12
+ if (!value) {
13
+ throw new Error(
14
+ `window.napplet.${String(domain)} is unavailable -- runtime did not inject this domain`
15
+ );
16
+ }
17
+ return value;
18
+ }
9
19
 
10
20
  // src/relay.ts
11
21
  var relay = {
@@ -18,7 +28,7 @@ var relay = {
18
28
  * @returns A Subscription handle with a `close()` method
19
29
  */
20
30
  subscribe(filters, onEvent, onEose, options) {
21
- return requireNapplet().relay.subscribe(filters, onEvent, onEose, options);
31
+ return requireDomain("relay").subscribe(filters, onEvent, onEose, options);
22
32
  },
23
33
  /**
24
34
  * Sign and publish a Nostr event through the shell.
@@ -27,7 +37,7 @@ var relay = {
27
37
  * @returns The signed NostrEvent after successful publication
28
38
  */
29
39
  publish(template, options) {
30
- return requireNapplet().relay.publish(template, options);
40
+ return requireDomain("relay").publish(template, options);
31
41
  },
32
42
  /**
33
43
  * Publish an encrypted Nostr event through the shell.
@@ -37,7 +47,7 @@ var relay = {
37
47
  * @returns The signed encrypted NostrEvent after successful publication
38
48
  */
39
49
  publishEncrypted(template, recipient, encryption = "nip44") {
40
- return requireNapplet().relay.publishEncrypted(template, recipient, encryption);
50
+ return requireDomain("relay").publishEncrypted(template, recipient, encryption);
41
51
  },
42
52
  /**
43
53
  * One-shot query: subscribe, collect events until EOSE, then resolve.
@@ -45,7 +55,7 @@ var relay = {
45
55
  * @returns Promise resolving to array of matching NostrEvent objects
46
56
  */
47
57
  query(filters) {
48
- return requireNapplet().relay.query(filters);
58
+ return requireDomain("relay").query(filters);
49
59
  }
50
60
  };
51
61
  var inc = {
@@ -56,7 +66,7 @@ var inc = {
56
66
  * @param content Event content (default: empty string)
57
67
  */
58
68
  emit(topic, extraTags, content) {
59
- requireNapplet().inc.emit(topic, extraTags, content);
69
+ requireDomain("inc").emit(topic, extraTags, content);
60
70
  },
61
71
  /**
62
72
  * Subscribe to INC-PEER events on a specific topic.
@@ -65,7 +75,7 @@ var inc = {
65
75
  * @returns A Subscription handle with a `close()` method
66
76
  */
67
77
  on(topic, callback) {
68
- return requireNapplet().inc.on(topic, callback);
78
+ return requireDomain("inc").on(topic, callback);
69
79
  }
70
80
  };
71
81
  var ifc = inc;
@@ -76,7 +86,7 @@ var storage = {
76
86
  * @returns The stored string value, or null if not found
77
87
  */
78
88
  getItem(key) {
79
- return requireNapplet().storage.getItem(key);
89
+ return requireDomain("storage").getItem(key);
80
90
  },
81
91
  /**
82
92
  * Store a key-value pair.
@@ -84,21 +94,21 @@ var storage = {
84
94
  * @param value The string value to store
85
95
  */
86
96
  setItem(key, value) {
87
- return requireNapplet().storage.setItem(key, value);
97
+ return requireDomain("storage").setItem(key, value);
88
98
  },
89
99
  /**
90
100
  * Remove a stored key.
91
101
  * @param key The storage key to remove
92
102
  */
93
103
  removeItem(key) {
94
- return requireNapplet().storage.removeItem(key);
104
+ return requireDomain("storage").removeItem(key);
95
105
  },
96
106
  /**
97
107
  * List all keys stored by this napplet.
98
108
  * @returns Array of storage key strings
99
109
  */
100
110
  keys() {
101
- return requireNapplet().storage.keys();
111
+ return requireDomain("storage").keys();
102
112
  },
103
113
  /**
104
114
  * Per-instance storage: same surface as the shared methods, but scoped to this
@@ -111,7 +121,7 @@ var storage = {
111
121
  * @param key The storage key
112
122
  */
113
123
  getItem(key) {
114
- return requireNapplet().storage.instance.getItem(key);
124
+ return requireDomain("storage").instance.getItem(key);
115
125
  },
116
126
  /**
117
127
  * Store a per-instance key-value pair.
@@ -119,21 +129,21 @@ var storage = {
119
129
  * @param value The string value to store
120
130
  */
121
131
  setItem(key, value) {
122
- return requireNapplet().storage.instance.setItem(key, value);
132
+ return requireDomain("storage").instance.setItem(key, value);
123
133
  },
124
134
  /**
125
135
  * Remove a per-instance key.
126
136
  * @param key The storage key to remove
127
137
  */
128
138
  removeItem(key) {
129
- return requireNapplet().storage.instance.removeItem(key);
139
+ return requireDomain("storage").instance.removeItem(key);
130
140
  },
131
141
  /**
132
142
  * List all per-instance keys for this napplet instance.
133
143
  * @returns Array of storage key strings
134
144
  */
135
145
  keys() {
136
- return requireNapplet().storage.instance.keys();
146
+ return requireDomain("storage").instance.keys();
137
147
  }
138
148
  }
139
149
  };
@@ -146,7 +156,7 @@ var media = {
146
156
  * @returns The shell result with canonical sessionId and owner, or error
147
157
  */
148
158
  createSession(options) {
149
- return requireNapplet().media.createSession(options);
159
+ return requireDomain("media").createSession(options);
150
160
  },
151
161
  /**
152
162
  * Update metadata for an existing session.
@@ -154,14 +164,14 @@ var media = {
154
164
  * @param metadata Partial metadata fields to update
155
165
  */
156
166
  updateSession(sessionId, metadata) {
157
- requireNapplet().media.updateSession(sessionId, metadata);
167
+ requireDomain("media").updateSession(sessionId, metadata);
158
168
  },
159
169
  /**
160
170
  * Destroy a media session.
161
171
  * @param sessionId The session to destroy
162
172
  */
163
173
  destroySession(sessionId) {
164
- requireNapplet().media.destroySession(sessionId);
174
+ requireDomain("media").destroySession(sessionId);
165
175
  },
166
176
  /**
167
177
  * Report current playback state for a session.
@@ -169,7 +179,7 @@ var media = {
169
179
  * @param state Current playback state
170
180
  */
171
181
  reportState(sessionId, state) {
172
- requireNapplet().media.reportState(sessionId, state);
182
+ requireDomain("media").reportState(sessionId, state);
173
183
  },
174
184
  /**
175
185
  * Declare which media actions the session currently supports.
@@ -177,7 +187,7 @@ var media = {
177
187
  * @param actions Currently supported actions
178
188
  */
179
189
  reportCapabilities(sessionId, actions) {
180
- requireNapplet().media.reportCapabilities(sessionId, actions);
190
+ requireDomain("media").reportCapabilities(sessionId, actions);
181
191
  },
182
192
  /**
183
193
  * Send a command to the current playback owner.
@@ -186,7 +196,7 @@ var media = {
186
196
  * @param value Optional value for seek/volume
187
197
  */
188
198
  sendCommand(sessionId, action, value) {
189
- requireNapplet().media.sendCommand(sessionId, action, value);
199
+ requireDomain("media").sendCommand(sessionId, action, value);
190
200
  },
191
201
  /**
192
202
  * Listen for media commands from the shell.
@@ -195,7 +205,7 @@ var media = {
195
205
  * @returns A Subscription with `close()` to stop listening
196
206
  */
197
207
  onCommand(sessionId, callback) {
198
- return requireNapplet().media.onCommand(sessionId, callback);
208
+ return requireDomain("media").onCommand(sessionId, callback);
199
209
  },
200
210
  /**
201
211
  * Listen for shell-reported playback state for shell-owned sessions.
@@ -204,7 +214,7 @@ var media = {
204
214
  * @returns A Subscription with `close()` to stop listening
205
215
  */
206
216
  onState(sessionId, callback) {
207
- return requireNapplet().media.onState(sessionId, callback);
217
+ return requireDomain("media").onState(sessionId, callback);
208
218
  },
209
219
  /**
210
220
  * Listen for shell-reported capabilities for shell-owned sessions.
@@ -213,7 +223,7 @@ var media = {
213
223
  * @returns A Subscription with `close()` to stop listening
214
224
  */
215
225
  onCapabilities(sessionId, callback) {
216
- return requireNapplet().media.onCapabilities(sessionId, callback);
226
+ return requireDomain("media").onCapabilities(sessionId, callback);
217
227
  },
218
228
  /**
219
229
  * Listen for the shell's media control list.
@@ -222,7 +232,7 @@ var media = {
222
232
  * @returns A Subscription with `close()` to stop listening
223
233
  */
224
234
  onControls(sessionId, callback) {
225
- return requireNapplet().media.onControls(sessionId, callback);
235
+ return requireDomain("media").onControls(sessionId, callback);
226
236
  }
227
237
  };
228
238
  var notify = {
@@ -232,28 +242,28 @@ var notify = {
232
242
  * @returns The shell-assigned notificationId
233
243
  */
234
244
  send(notification) {
235
- return requireNapplet().notify.send(notification);
245
+ return requireDomain("notify").send(notification);
236
246
  },
237
247
  /**
238
248
  * Dismiss a notification by ID.
239
249
  * @param notificationId The notification to dismiss
240
250
  */
241
251
  dismiss(notificationId) {
242
- requireNapplet().notify.dismiss(notificationId);
252
+ requireDomain("notify").dismiss(notificationId);
243
253
  },
244
254
  /**
245
255
  * Set the badge count for this napplet. Pass 0 to clear.
246
256
  * @param count Badge count
247
257
  */
248
258
  badge(count) {
249
- requireNapplet().notify.badge(count);
259
+ requireDomain("notify").badge(count);
250
260
  },
251
261
  /**
252
262
  * Register a notification channel.
253
263
  * @param channel Channel definition
254
264
  */
255
265
  registerChannel(channel) {
256
- requireNapplet().notify.registerChannel(channel);
266
+ requireDomain("notify").registerChannel(channel);
257
267
  },
258
268
  /**
259
269
  * Request permission to send notifications.
@@ -261,7 +271,7 @@ var notify = {
261
271
  * @returns Whether permission was granted
262
272
  */
263
273
  requestPermission(channel) {
264
- return requireNapplet().notify.requestPermission(channel);
274
+ return requireDomain("notify").requestPermission(channel);
265
275
  },
266
276
  /**
267
277
  * Listen for action button clicks on notifications.
@@ -269,7 +279,7 @@ var notify = {
269
279
  * @returns A Subscription with `close()` to stop listening
270
280
  */
271
281
  onAction(callback) {
272
- return requireNapplet().notify.onAction(callback);
282
+ return requireDomain("notify").onAction(callback);
273
283
  },
274
284
  /**
275
285
  * Listen for notification body clicks.
@@ -277,7 +287,7 @@ var notify = {
277
287
  * @returns A Subscription with `close()` to stop listening
278
288
  */
279
289
  onClicked(callback) {
280
- return requireNapplet().notify.onClicked(callback);
290
+ return requireDomain("notify").onClicked(callback);
281
291
  },
282
292
  /**
283
293
  * Listen for notification dismissals.
@@ -285,7 +295,7 @@ var notify = {
285
295
  * @returns A Subscription with `close()` to stop listening
286
296
  */
287
297
  onDismissed(callback) {
288
- return requireNapplet().notify.onDismissed(callback);
298
+ return requireDomain("notify").onDismissed(callback);
289
299
  },
290
300
  /**
291
301
  * Listen for the shell's notification capability list.
@@ -293,7 +303,7 @@ var notify = {
293
303
  * @returns A Subscription with `close()` to stop listening
294
304
  */
295
305
  onControls(callback) {
296
- return requireNapplet().notify.onControls(callback);
306
+ return requireDomain("notify").onControls(callback);
297
307
  }
298
308
  };
299
309
 
@@ -305,14 +315,14 @@ var keys = {
305
315
  * @returns The assigned binding, if any
306
316
  */
307
317
  registerAction(action) {
308
- return requireNapplet().keys.registerAction(action);
318
+ return requireDomain("keys").registerAction(action);
309
319
  },
310
320
  /**
311
321
  * Remove a previously registered action.
312
322
  * @param actionId The action to unregister
313
323
  */
314
324
  unregisterAction(actionId) {
315
- requireNapplet().keys.unregisterAction(actionId);
325
+ requireDomain("keys").unregisterAction(actionId);
316
326
  },
317
327
  /**
318
328
  * Register a local handler for when a bound key is pressed.
@@ -321,7 +331,7 @@ var keys = {
321
331
  * @returns A Subscription with `close()` to stop listening
322
332
  */
323
333
  onAction(actionId, callback) {
324
- return requireNapplet().keys.onAction(actionId, callback);
334
+ return requireDomain("keys").onAction(actionId, callback);
325
335
  },
326
336
  /**
327
337
  * Convenience: register a named action AND wire a local handler in one call.
@@ -346,14 +356,14 @@ var keys = {
346
356
  * ```
347
357
  */
348
358
  async register(action, handler) {
349
- const n = requireNapplet();
350
- const result = await n.keys.registerAction(action);
351
- const sub = n.keys.onAction(action.id, handler);
359
+ const n = requireDomain("keys");
360
+ const result = await n.registerAction(action);
361
+ const sub = n.onAction(action.id, handler);
352
362
  return {
353
363
  ...result,
354
364
  close() {
355
365
  sub.close();
356
- n.keys.unregisterAction(action.id);
366
+ n.unregisterAction(action.id);
357
367
  }
358
368
  };
359
369
  }
@@ -364,7 +374,7 @@ var identity = {
364
374
  * @returns Hex-encoded public key string
365
375
  */
366
376
  getPublicKey() {
367
- return requireNapplet().identity.getPublicKey();
377
+ return requireDomain("identity").getPublicKey();
368
378
  },
369
379
  /**
370
380
  * Listen for shell-pushed user identity changes.
@@ -372,28 +382,28 @@ var identity = {
372
382
  * @returns Subscription with close() to detach the handler
373
383
  */
374
384
  onChanged(handler) {
375
- return requireNapplet().identity.onChanged(handler);
385
+ return requireDomain("identity").onChanged(handler);
376
386
  },
377
387
  /**
378
388
  * Get the user's relay list (NIP-65).
379
389
  * @returns Record mapping relay URLs to read/write permissions
380
390
  */
381
391
  getRelays() {
382
- return requireNapplet().identity.getRelays();
392
+ return requireDomain("identity").getRelays();
383
393
  },
384
394
  /**
385
395
  * Get the user's profile metadata (kind 0).
386
396
  * @returns Profile data, or null if not found
387
397
  */
388
398
  getProfile() {
389
- return requireNapplet().identity.getProfile();
399
+ return requireDomain("identity").getProfile();
390
400
  },
391
401
  /**
392
402
  * Get the user's follow list (kind 3 contact list).
393
403
  * @returns Array of hex-encoded public keys
394
404
  */
395
405
  getFollows() {
396
- return requireNapplet().identity.getFollows();
406
+ return requireDomain("identity").getFollows();
397
407
  },
398
408
  /**
399
409
  * Get entries from a user's categorized list.
@@ -401,35 +411,35 @@ var identity = {
401
411
  * @returns Array of list entry values
402
412
  */
403
413
  getList(listType) {
404
- return requireNapplet().identity.getList(listType);
414
+ return requireDomain("identity").getList(listType);
405
415
  },
406
416
  /**
407
417
  * Get zap receipts sent to the user.
408
418
  * @returns Array of zap receipt objects
409
419
  */
410
420
  getZaps() {
411
- return requireNapplet().identity.getZaps();
421
+ return requireDomain("identity").getZaps();
412
422
  },
413
423
  /**
414
424
  * Get the user's mute list (kind 10000).
415
425
  * @returns Array of hex-encoded muted public keys
416
426
  */
417
427
  getMutes() {
418
- return requireNapplet().identity.getMutes();
428
+ return requireDomain("identity").getMutes();
419
429
  },
420
430
  /**
421
431
  * Get the user's block list.
422
432
  * @returns Array of hex-encoded blocked public keys
423
433
  */
424
434
  getBlocked() {
425
- return requireNapplet().identity.getBlocked();
435
+ return requireDomain("identity").getBlocked();
426
436
  },
427
437
  /**
428
438
  * Get badges awarded to the user (NIP-58).
429
439
  * @returns Array of badge objects
430
440
  */
431
441
  getBadges() {
432
- return requireNapplet().identity.getBadges();
442
+ return requireDomain("identity").getBadges();
433
443
  }
434
444
  };
435
445
 
@@ -440,7 +450,7 @@ var config = {
440
450
  * @returns A one-shot ConfigValues object.
441
451
  */
442
452
  get() {
443
- return requireNapplet().config.get();
453
+ return requireDomain("config").get();
444
454
  },
445
455
  /**
446
456
  * Subscribe to live configuration updates.
@@ -449,14 +459,14 @@ var config = {
449
459
  * @returns A Subscription with close() to stop listening.
450
460
  */
451
461
  subscribe(callback) {
452
- return requireNapplet().config.subscribe(callback);
462
+ return requireDomain("config").subscribe(callback);
453
463
  },
454
464
  /**
455
465
  * Request the shell open its settings UI for this napplet.
456
466
  * @param options Optional { section } to deep-link by x-napplet-section name.
457
467
  */
458
468
  openSettings(options) {
459
- requireNapplet().config.openSettings(options);
469
+ requireDomain("config").openSettings(options);
460
470
  },
461
471
  /**
462
472
  * Register a napplet configuration schema at runtime (escape hatch;
@@ -465,7 +475,7 @@ var config = {
465
475
  * @param version Optional `$version` migration hint.
466
476
  */
467
477
  registerSchema(schema, version) {
468
- return requireNapplet().config.registerSchema(schema, version);
478
+ return requireDomain("config").registerSchema(schema, version);
469
479
  },
470
480
  /**
471
481
  * Listen for schema-registration errors pushed by the shell
@@ -474,7 +484,7 @@ var config = {
474
484
  * @returns A plain teardown function that detaches the listener.
475
485
  */
476
486
  onSchemaError(callback) {
477
- return requireNapplet().config.onSchemaError(callback);
487
+ return requireDomain("config").onSchemaError(callback);
478
488
  },
479
489
  /**
480
490
  * Current schema snapshot (readonly). Populated from the
@@ -483,7 +493,7 @@ var config = {
483
493
  * @returns The registered schema, or null if none.
484
494
  */
485
495
  get schema() {
486
- return requireNapplet().config.schema;
496
+ return requireDomain("config").schema;
487
497
  }
488
498
  };
489
499
  var resource = {
@@ -493,7 +503,7 @@ var resource = {
493
503
  * @returns Promise resolving to the fetched bytes as a Blob.
494
504
  */
495
505
  bytes(url, opts) {
496
- return requireNapplet().resource.bytes(url, opts);
506
+ return requireDomain("resource").bytes(url, opts);
497
507
  },
498
508
  /**
499
509
  * Fetch bytes for many URLs through one shell envelope.
@@ -502,7 +512,7 @@ var resource = {
502
512
  * @returns Promise resolving to ordered per-URL result items.
503
513
  */
504
514
  bytesMany(urls, opts) {
505
- return requireNapplet().resource.bytesMany(urls, opts);
515
+ return requireDomain("resource").bytesMany(urls, opts);
506
516
  },
507
517
  /**
508
518
  * Fetch bytes and return a managed object URL handle.
@@ -511,7 +521,7 @@ var resource = {
511
521
  * @returns Synchronous handle `{ url, revoke }`.
512
522
  */
513
523
  bytesAsObjectURL(url) {
514
- return requireNapplet().resource.bytesAsObjectURL(url);
524
+ return requireDomain("resource").bytesAsObjectURL(url);
515
525
  }
516
526
  };
517
527
 
@@ -523,7 +533,7 @@ var cvm = {
523
533
  * @returns Promise resolving to the discovered servers
524
534
  */
525
535
  discover(query) {
526
- return requireNapplet().cvm.discover(query);
536
+ return requireDomain("cvm").discover(query);
527
537
  },
528
538
  /**
529
539
  * Send a raw MCP JSON-RPC message to a ContextVM server.
@@ -533,7 +543,7 @@ var cvm = {
533
543
  * @returns Promise resolving to the MCP response message
534
544
  */
535
545
  request(server, message, options) {
536
- return requireNapplet().cvm.request(server, message, options);
546
+ return requireDomain("cvm").request(server, message, options);
537
547
  },
538
548
  /**
539
549
  * List the tools exposed by a ContextVM server (MCP `tools/list`).
@@ -541,7 +551,7 @@ var cvm = {
541
551
  * @param options Optional per-request options
542
552
  */
543
553
  listTools(server, options) {
544
- return requireNapplet().cvm.listTools(server, options);
554
+ return requireDomain("cvm").listTools(server, options);
545
555
  },
546
556
  /**
547
557
  * Call a tool on a ContextVM server (MCP `tools/call`).
@@ -551,7 +561,7 @@ var cvm = {
551
561
  * @param options Optional per-request options
552
562
  */
553
563
  callTool(server, name, args, options) {
554
- return requireNapplet().cvm.callTool(server, name, args, options);
564
+ return requireDomain("cvm").callTool(server, name, args, options);
555
565
  },
556
566
  /**
557
567
  * List the resources exposed by a ContextVM server (MCP `resources/list`).
@@ -559,7 +569,7 @@ var cvm = {
559
569
  * @param options Optional per-request options
560
570
  */
561
571
  listResources(server, options) {
562
- return requireNapplet().cvm.listResources(server, options);
572
+ return requireDomain("cvm").listResources(server, options);
563
573
  },
564
574
  /**
565
575
  * Read a resource from a ContextVM server (MCP `resources/read`).
@@ -568,14 +578,14 @@ var cvm = {
568
578
  * @param options Optional per-request options
569
579
  */
570
580
  readResource(server, uri, options) {
571
- return requireNapplet().cvm.readResource(server, uri, options);
581
+ return requireDomain("cvm").readResource(server, uri, options);
572
582
  },
573
583
  /**
574
584
  * Close shell-maintained session state for a server.
575
585
  * @param server Server whose session should be torn down
576
586
  */
577
587
  close(server) {
578
- return requireNapplet().cvm.close(server);
588
+ return requireDomain("cvm").close(server);
579
589
  },
580
590
  /**
581
591
  * Listen for server-pushed MCP messages (`cvm.event`).
@@ -583,7 +593,7 @@ var cvm = {
583
593
  * @returns A Subscription with `close()` to stop listening
584
594
  */
585
595
  onEvent(callback) {
586
- return requireNapplet().cvm.onEvent(callback);
596
+ return requireDomain("cvm").onEvent(callback);
587
597
  }
588
598
  };
589
599
  var outbox = {
@@ -594,7 +604,7 @@ var outbox = {
594
604
  * @returns Promise resolving to the outbox result
595
605
  */
596
606
  query(filters, options) {
597
- return requireNapplet().outbox.query(filters, options);
607
+ return requireDomain("outbox").query(filters, options);
598
608
  },
599
609
  /**
600
610
  * Open a live outbox-aware subscription.
@@ -603,7 +613,7 @@ var outbox = {
603
613
  * @returns An OutboxSubscription handle with `on(...)` and `close()`
604
614
  */
605
615
  subscribe(filters, options) {
606
- return requireNapplet().outbox.subscribe(filters, options);
616
+ return requireDomain("outbox").subscribe(filters, options);
607
617
  },
608
618
  /**
609
619
  * Publish a shell-signed event using outbox-aware relay fanout.
@@ -612,7 +622,7 @@ var outbox = {
612
622
  * @returns Promise resolving to the outbox publish result
613
623
  */
614
624
  publish(template, options) {
615
- return requireNapplet().outbox.publish(template, options);
625
+ return requireDomain("outbox").publish(template, options);
616
626
  },
617
627
  /**
618
628
  * Resolve the relay plan the shell would use for a read/write target.
@@ -620,7 +630,7 @@ var outbox = {
620
630
  * @returns Promise resolving to the relay plan
621
631
  */
622
632
  resolveRelays(target) {
623
- return requireNapplet().outbox.resolveRelays(target);
633
+ return requireDomain("outbox").resolveRelays(target);
624
634
  }
625
635
  };
626
636
  var upload = {
@@ -630,7 +640,7 @@ var upload = {
630
640
  * @returns Promise resolving to the initial upload result
631
641
  */
632
642
  upload(request) {
633
- return requireNapplet().upload.upload(request);
643
+ return requireDomain("upload").upload(request);
634
644
  },
635
645
  /**
636
646
  * Get the latest known status for a prior upload.
@@ -638,7 +648,7 @@ var upload = {
638
648
  * @returns Promise resolving to the latest status
639
649
  */
640
650
  status(uploadId) {
641
- return requireNapplet().upload.status(uploadId);
651
+ return requireDomain("upload").status(uploadId);
642
652
  },
643
653
  /**
644
654
  * Register for shell-pushed upload status updates.
@@ -646,7 +656,7 @@ var upload = {
646
656
  * @returns A Subscription with `close()` to stop listening
647
657
  */
648
658
  onStatus(handler) {
649
- return requireNapplet().upload.onStatus(handler);
659
+ return requireDomain("upload").onStatus(handler);
650
660
  }
651
661
  };
652
662
  var intent = {
@@ -656,7 +666,7 @@ var intent = {
656
666
  * @returns Promise resolving to the invocation result
657
667
  */
658
668
  invoke(request) {
659
- return requireNapplet().intent.invoke(request);
669
+ return requireDomain("intent").invoke(request);
660
670
  },
661
671
  /**
662
672
  * Open a napplet by archetype (sugar for `action: "open"`).
@@ -666,7 +676,7 @@ var intent = {
666
676
  * @returns Promise resolving to the invocation result
667
677
  */
668
678
  open(archetype, payload, opts) {
669
- return requireNapplet().intent.open(archetype, payload, opts);
679
+ return requireDomain("intent").open(archetype, payload, opts);
670
680
  },
671
681
  /**
672
682
  * Check whether the runtime can currently satisfy an archetype and expose the
@@ -675,14 +685,14 @@ var intent = {
675
685
  * @returns Promise resolving to the archetype availability
676
686
  */
677
687
  available(archetype) {
678
- return requireNapplet().intent.available(archetype);
688
+ return requireDomain("intent").available(archetype);
679
689
  },
680
690
  /**
681
691
  * Get availability for every archetype the runtime can satisfy.
682
692
  * @returns Promise resolving to availability for each satisfiable archetype
683
693
  */
684
694
  handlers() {
685
- return requireNapplet().intent.handlers();
695
+ return requireDomain("intent").handlers();
686
696
  },
687
697
  /**
688
698
  * Register for shell-pushed availability updates.
@@ -690,7 +700,7 @@ var intent = {
690
700
  * @returns A Subscription with `close()` to stop listening
691
701
  */
692
702
  onChanged(handler) {
693
- return requireNapplet().intent.onChanged(handler);
703
+ return requireDomain("intent").onChanged(handler);
694
704
  }
695
705
  };
696
706
  var webrtc = {
@@ -700,7 +710,7 @@ var webrtc = {
700
710
  * @returns Promise resolving to the opened session result
701
711
  */
702
712
  open(request) {
703
- return requireNapplet().webrtc.open(request);
713
+ return requireDomain("webrtc").open(request);
704
714
  },
705
715
  /**
706
716
  * Send an opaque application payload over a session.
@@ -708,7 +718,7 @@ var webrtc = {
708
718
  * @param payload Application payload
709
719
  */
710
720
  send(sessionId, payload) {
711
- return requireNapplet().webrtc.send(sessionId, payload);
721
+ return requireDomain("webrtc").send(sessionId, payload);
712
722
  },
713
723
  /**
714
724
  * Close a WebRTC session.
@@ -716,7 +726,7 @@ var webrtc = {
716
726
  * @param reason Optional close reason
717
727
  */
718
728
  close(sessionId, reason) {
719
- return requireNapplet().webrtc.close(sessionId, reason);
729
+ return requireDomain("webrtc").close(sessionId, reason);
720
730
  },
721
731
  /**
722
732
  * Subscribe to runtime-pushed WebRTC events.
@@ -724,7 +734,7 @@ var webrtc = {
724
734
  * @returns Subscription handle
725
735
  */
726
736
  onEvent(handler) {
727
- return requireNapplet().webrtc.onEvent(handler);
737
+ return requireDomain("webrtc").onEvent(handler);
728
738
  }
729
739
  };
730
740
 
@@ -737,7 +747,7 @@ var link = {
737
747
  * @returns Promise resolving to the shell's open/deny status
738
748
  */
739
749
  open(url, options) {
740
- return requireNapplet().link.open(url, options);
750
+ return requireDomain("link").open(url, options);
741
751
  }
742
752
  };
743
753
  var lists = {
@@ -746,7 +756,7 @@ var lists = {
746
756
  * @returns Promise resolving to supported list descriptions
747
757
  */
748
758
  supported() {
749
- return requireNapplet().lists.supported();
759
+ return requireDomain("lists").supported();
750
760
  },
751
761
  /**
752
762
  * Add items to a runtime-supported NIP-51 list.
@@ -755,7 +765,7 @@ var lists = {
755
765
  * @param options Optional create/metadata hints
756
766
  */
757
767
  add(list, items, options) {
758
- return requireNapplet().lists.add(list, items, options);
768
+ return requireDomain("lists").add(list, items, options);
759
769
  },
760
770
  /**
761
771
  * Remove items from a runtime-supported NIP-51 list.
@@ -764,7 +774,7 @@ var lists = {
764
774
  * @param options Optional runtime hints
765
775
  */
766
776
  remove(list, items, options) {
767
- return requireNapplet().lists.remove(list, items, options);
777
+ return requireDomain("lists").remove(list, items, options);
768
778
  }
769
779
  };
770
780
  var common = {
@@ -774,7 +784,7 @@ var common = {
774
784
  * @returns Promise resolving to the shell encode result
775
785
  */
776
786
  encodeNip19(input) {
777
- return requireNapplet().common.encodeNip19(input);
787
+ return requireDomain("common").encodeNip19(input);
778
788
  },
779
789
  /**
780
790
  * Decode a supported public NIP-19 value.
@@ -782,7 +792,7 @@ var common = {
782
792
  * @returns Promise resolving to normalized decoded fields
783
793
  */
784
794
  decodeNip19(value) {
785
- return requireNapplet().common.decodeNip19(value);
795
+ return requireDomain("common").decodeNip19(value);
786
796
  },
787
797
  /**
788
798
  * Resolve a profile by hex pubkey, npub, or nprofile.
@@ -790,14 +800,14 @@ var common = {
790
800
  * @returns Promise resolving to latest profile data when available
791
801
  */
792
802
  getProfile(target) {
793
- return requireNapplet().common.getProfile(target);
803
+ return requireDomain("common").getProfile(target);
794
804
  },
795
805
  /**
796
806
  * Return the shell user's followed pubkeys as hex.
797
807
  * @returns Promise resolving to followed pubkeys
798
808
  */
799
809
  follows() {
800
- return requireNapplet().common.follows();
810
+ return requireDomain("common").follows();
801
811
  },
802
812
  /**
803
813
  * Ask the shell to follow one or more npub targets.
@@ -805,7 +815,7 @@ var common = {
805
815
  * @returns Promise resolving to the action result
806
816
  */
807
817
  follow(...pubkeys) {
808
- return requireNapplet().common.follow(...pubkeys);
818
+ return requireDomain("common").follow(...pubkeys);
809
819
  },
810
820
  /**
811
821
  * Ask the shell to unfollow one or more npub targets.
@@ -813,7 +823,7 @@ var common = {
813
823
  * @returns Promise resolving to the action result
814
824
  */
815
825
  unfollow(...pubkeys) {
816
- return requireNapplet().common.unfollow(...pubkeys);
826
+ return requireDomain("common").unfollow(...pubkeys);
817
827
  },
818
828
  /**
819
829
  * React to a native Nostr event.
@@ -823,7 +833,7 @@ var common = {
823
833
  * @returns Promise resolving to the action result
824
834
  */
825
835
  react(targetEventId, reaction, customEmojiHref) {
826
- return requireNapplet().common.react(targetEventId, reaction, customEmojiHref);
836
+ return requireDomain("common").react(targetEventId, reaction, customEmojiHref);
827
837
  },
828
838
  /**
829
839
  * Report an event or pubkey with a NIP-56 reason.
@@ -833,7 +843,7 @@ var common = {
833
843
  * @returns Promise resolving to the action result
834
844
  */
835
845
  report(target, reason, text) {
836
- return requireNapplet().common.report(target, reason, text);
846
+ return requireDomain("common").report(target, reason, text);
837
847
  }
838
848
  };
839
849
  var ble = {
@@ -843,7 +853,7 @@ var ble = {
843
853
  * @returns Promise resolving to the runtime-assigned BLE open result
844
854
  */
845
855
  open(request) {
846
- return requireNapplet().ble.open(request);
856
+ return requireDomain("ble").open(request);
847
857
  },
848
858
  /**
849
859
  * List exposed GATT services for a session.
@@ -851,7 +861,7 @@ var ble = {
851
861
  * @returns Promise resolving to exposed services
852
862
  */
853
863
  services(sessionId) {
854
- return requireNapplet().ble.services(sessionId);
864
+ return requireDomain("ble").services(sessionId);
855
865
  },
856
866
  /**
857
867
  * Read a characteristic or descriptor value.
@@ -860,7 +870,7 @@ var ble = {
860
870
  * @returns Promise resolving to bytes
861
871
  */
862
872
  read(sessionId, target) {
863
- return requireNapplet().ble.read(sessionId, target);
873
+ return requireDomain("ble").read(sessionId, target);
864
874
  },
865
875
  /**
866
876
  * Write bytes to a characteristic or descriptor.
@@ -871,7 +881,7 @@ var ble = {
871
881
  * @returns Promise resolving after the runtime acknowledges the write
872
882
  */
873
883
  write(sessionId, target, data, options) {
874
- return requireNapplet().ble.write(sessionId, target, data, options);
884
+ return requireDomain("ble").write(sessionId, target, data, options);
875
885
  },
876
886
  /**
877
887
  * Start notifications or indications for a characteristic.
@@ -879,7 +889,7 @@ var ble = {
879
889
  * @param target GATT characteristic target
880
890
  */
881
891
  subscribe(sessionId, target) {
882
- return requireNapplet().ble.subscribe(sessionId, target);
892
+ return requireDomain("ble").subscribe(sessionId, target);
883
893
  },
884
894
  /**
885
895
  * Stop notifications or indications for a characteristic.
@@ -887,7 +897,7 @@ var ble = {
887
897
  * @param target GATT characteristic target
888
898
  */
889
899
  unsubscribe(sessionId, target) {
890
- return requireNapplet().ble.unsubscribe(sessionId, target);
900
+ return requireDomain("ble").unsubscribe(sessionId, target);
891
901
  },
892
902
  /**
893
903
  * Close an open BLE session.
@@ -895,7 +905,7 @@ var ble = {
895
905
  * @param reason Optional reason for the close request
896
906
  */
897
907
  close(sessionId, reason) {
898
- return requireNapplet().ble.close(sessionId, reason);
908
+ return requireDomain("ble").close(sessionId, reason);
899
909
  },
900
910
  /**
901
911
  * Register for shell-pushed BLE events.
@@ -903,7 +913,7 @@ var ble = {
903
913
  * @returns A Subscription with `close()` to stop listening
904
914
  */
905
915
  onEvent(handler) {
906
- return requireNapplet().ble.onEvent(handler);
916
+ return requireDomain("ble").onEvent(handler);
907
917
  }
908
918
  };
909
919
  var serial = {
@@ -913,7 +923,7 @@ var serial = {
913
923
  * @returns Promise resolving to the runtime-assigned serial open result
914
924
  */
915
925
  open(request) {
916
- return requireNapplet().serial.open(request);
926
+ return requireDomain("serial").open(request);
917
927
  },
918
928
  /**
919
929
  * Write bytes to an open serial session.
@@ -922,7 +932,7 @@ var serial = {
922
932
  * @returns Promise resolving after the runtime acknowledges the write
923
933
  */
924
934
  write(sessionId, data) {
925
- return requireNapplet().serial.write(sessionId, data);
935
+ return requireDomain("serial").write(sessionId, data);
926
936
  },
927
937
  /**
928
938
  * Close an open serial session.
@@ -931,7 +941,7 @@ var serial = {
931
941
  * @returns Promise resolving after the runtime acknowledges the close
932
942
  */
933
943
  close(sessionId, reason) {
934
- return requireNapplet().serial.close(sessionId, reason);
944
+ return requireDomain("serial").close(sessionId, reason);
935
945
  },
936
946
  /**
937
947
  * Register for shell-pushed serial events.
@@ -939,7 +949,7 @@ var serial = {
939
949
  * @returns A Subscription with `close()` to stop listening
940
950
  */
941
951
  onEvent(handler) {
942
- return requireNapplet().serial.onEvent(handler);
952
+ return requireDomain("serial").onEvent(handler);
943
953
  }
944
954
  };
945
955
  var dm = {
@@ -948,7 +958,7 @@ var dm = {
948
958
  * @returns Promise resolving to the runtime DM status
949
959
  */
950
960
  status() {
951
- return requireNapplet().dm.status();
961
+ return requireDomain("dm").status();
952
962
  },
953
963
  /**
954
964
  * Fetch normalized conversations visible to this napplet.
@@ -956,7 +966,7 @@ var dm = {
956
966
  * @returns Promise resolving to a page of conversations
957
967
  */
958
968
  conversations(query) {
959
- return requireNapplet().dm.conversations(query);
969
+ return requireDomain("dm").conversations(query);
960
970
  },
961
971
  /**
962
972
  * Fetch normalized message history for one conversation.
@@ -964,7 +974,7 @@ var dm = {
964
974
  * @returns Promise resolving to a page of messages
965
975
  */
966
976
  messages(query) {
967
- return requireNapplet().dm.messages(query);
977
+ return requireDomain("dm").messages(query);
968
978
  },
969
979
  /**
970
980
  * Ask the runtime to send a direct message.
@@ -972,7 +982,7 @@ var dm = {
972
982
  * @returns Promise resolving to the normalized send result
973
983
  */
974
984
  send(request) {
975
- return requireNapplet().dm.send(request);
985
+ return requireDomain("dm").send(request);
976
986
  },
977
987
  /**
978
988
  * Start live delivery for one conversation or all visible conversations.
@@ -980,7 +990,7 @@ var dm = {
980
990
  * @returns Promise resolving to the runtime subscription id
981
991
  */
982
992
  subscribe(request) {
983
- return requireNapplet().dm.subscribe(request);
993
+ return requireDomain("dm").subscribe(request);
984
994
  },
985
995
  /**
986
996
  * Stop a live DM subscription.
@@ -988,7 +998,7 @@ var dm = {
988
998
  * @returns Promise resolving to the runtime acknowledgement
989
999
  */
990
1000
  unsubscribe(subscriptionId) {
991
- return requireNapplet().dm.unsubscribe(subscriptionId);
1001
+ return requireDomain("dm").unsubscribe(subscriptionId);
992
1002
  },
993
1003
  /**
994
1004
  * Register for shell-pushed `dm.message` deliveries.
@@ -996,7 +1006,7 @@ var dm = {
996
1006
  * @returns A Subscription with `close()` to stop listening
997
1007
  */
998
1008
  onMessage(handler) {
999
- return requireNapplet().dm.onMessage(handler);
1009
+ return requireDomain("dm").onMessage(handler);
1000
1010
  }
1001
1011
  };
1002
1012