@napplet/sdk 0.20.1 → 0.21.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/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,17 +493,24 @@ 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 = {
500
+ /**
501
+ * Inspect resource schemes and coarse runtime policy limits.
502
+ * @returns Promise resolving to advisory resource info.
503
+ */
504
+ info() {
505
+ return requireDomain("resource").info();
506
+ },
490
507
  /**
491
508
  * Fetch bytes for a URL through the shell's resource pipeline.
492
509
  * @param url URL identifying the resource (any registered scheme).
493
510
  * @returns Promise resolving to the fetched bytes as a Blob.
494
511
  */
495
512
  bytes(url, opts) {
496
- return requireNapplet().resource.bytes(url, opts);
513
+ return requireDomain("resource").bytes(url, opts);
497
514
  },
498
515
  /**
499
516
  * Fetch bytes for many URLs through one shell envelope.
@@ -502,7 +519,7 @@ var resource = {
502
519
  * @returns Promise resolving to ordered per-URL result items.
503
520
  */
504
521
  bytesMany(urls, opts) {
505
- return requireNapplet().resource.bytesMany(urls, opts);
522
+ return requireDomain("resource").bytesMany(urls, opts);
506
523
  },
507
524
  /**
508
525
  * Fetch bytes and return a managed object URL handle.
@@ -511,7 +528,7 @@ var resource = {
511
528
  * @returns Synchronous handle `{ url, revoke }`.
512
529
  */
513
530
  bytesAsObjectURL(url) {
514
- return requireNapplet().resource.bytesAsObjectURL(url);
531
+ return requireDomain("resource").bytesAsObjectURL(url);
515
532
  }
516
533
  };
517
534
 
@@ -523,7 +540,7 @@ var cvm = {
523
540
  * @returns Promise resolving to the discovered servers
524
541
  */
525
542
  discover(query) {
526
- return requireNapplet().cvm.discover(query);
543
+ return requireDomain("cvm").discover(query);
527
544
  },
528
545
  /**
529
546
  * Send a raw MCP JSON-RPC message to a ContextVM server.
@@ -533,7 +550,7 @@ var cvm = {
533
550
  * @returns Promise resolving to the MCP response message
534
551
  */
535
552
  request(server, message, options) {
536
- return requireNapplet().cvm.request(server, message, options);
553
+ return requireDomain("cvm").request(server, message, options);
537
554
  },
538
555
  /**
539
556
  * List the tools exposed by a ContextVM server (MCP `tools/list`).
@@ -541,7 +558,7 @@ var cvm = {
541
558
  * @param options Optional per-request options
542
559
  */
543
560
  listTools(server, options) {
544
- return requireNapplet().cvm.listTools(server, options);
561
+ return requireDomain("cvm").listTools(server, options);
545
562
  },
546
563
  /**
547
564
  * Call a tool on a ContextVM server (MCP `tools/call`).
@@ -551,7 +568,7 @@ var cvm = {
551
568
  * @param options Optional per-request options
552
569
  */
553
570
  callTool(server, name, args, options) {
554
- return requireNapplet().cvm.callTool(server, name, args, options);
571
+ return requireDomain("cvm").callTool(server, name, args, options);
555
572
  },
556
573
  /**
557
574
  * List the resources exposed by a ContextVM server (MCP `resources/list`).
@@ -559,7 +576,7 @@ var cvm = {
559
576
  * @param options Optional per-request options
560
577
  */
561
578
  listResources(server, options) {
562
- return requireNapplet().cvm.listResources(server, options);
579
+ return requireDomain("cvm").listResources(server, options);
563
580
  },
564
581
  /**
565
582
  * Read a resource from a ContextVM server (MCP `resources/read`).
@@ -568,14 +585,14 @@ var cvm = {
568
585
  * @param options Optional per-request options
569
586
  */
570
587
  readResource(server, uri, options) {
571
- return requireNapplet().cvm.readResource(server, uri, options);
588
+ return requireDomain("cvm").readResource(server, uri, options);
572
589
  },
573
590
  /**
574
591
  * Close shell-maintained session state for a server.
575
592
  * @param server Server whose session should be torn down
576
593
  */
577
594
  close(server) {
578
- return requireNapplet().cvm.close(server);
595
+ return requireDomain("cvm").close(server);
579
596
  },
580
597
  /**
581
598
  * Listen for server-pushed MCP messages (`cvm.event`).
@@ -583,10 +600,19 @@ var cvm = {
583
600
  * @returns A Subscription with `close()` to stop listening
584
601
  */
585
602
  onEvent(callback) {
586
- return requireNapplet().cvm.onEvent(callback);
603
+ return requireDomain("cvm").onEvent(callback);
587
604
  }
588
605
  };
589
606
  var outbox = {
607
+ /**
608
+ * Fetch one event by ID through shell-owned outbox routing.
609
+ * @param eventId Event id to fetch
610
+ * @param options Optional author/relay hints, strategy, and timeout
611
+ * @returns Promise resolving to the outbox event result
612
+ */
613
+ getEvent(eventId, options) {
614
+ return requireDomain("outbox").getEvent(eventId, options);
615
+ },
590
616
  /**
591
617
  * Perform a one-shot outbox-aware query.
592
618
  * @param filters NIP-01 filter or filters
@@ -594,7 +620,7 @@ var outbox = {
594
620
  * @returns Promise resolving to the outbox result
595
621
  */
596
622
  query(filters, options) {
597
- return requireNapplet().outbox.query(filters, options);
623
+ return requireDomain("outbox").query(filters, options);
598
624
  },
599
625
  /**
600
626
  * Open a live outbox-aware subscription.
@@ -603,7 +629,7 @@ var outbox = {
603
629
  * @returns An OutboxSubscription handle with `on(...)` and `close()`
604
630
  */
605
631
  subscribe(filters, options) {
606
- return requireNapplet().outbox.subscribe(filters, options);
632
+ return requireDomain("outbox").subscribe(filters, options);
607
633
  },
608
634
  /**
609
635
  * Publish a shell-signed event using outbox-aware relay fanout.
@@ -612,7 +638,7 @@ var outbox = {
612
638
  * @returns Promise resolving to the outbox publish result
613
639
  */
614
640
  publish(template, options) {
615
- return requireNapplet().outbox.publish(template, options);
641
+ return requireDomain("outbox").publish(template, options);
616
642
  },
617
643
  /**
618
644
  * Resolve the relay plan the shell would use for a read/write target.
@@ -620,17 +646,24 @@ var outbox = {
620
646
  * @returns Promise resolving to the relay plan
621
647
  */
622
648
  resolveRelays(target) {
623
- return requireNapplet().outbox.resolveRelays(target);
649
+ return requireDomain("outbox").resolveRelays(target);
624
650
  }
625
651
  };
626
652
  var upload = {
653
+ /**
654
+ * Inspect upload rails and coarse runtime policy limits.
655
+ * @returns Promise resolving to advisory upload info.
656
+ */
657
+ info() {
658
+ return requireDomain("upload").info();
659
+ },
627
660
  /**
628
661
  * Upload bytes through the shell's storage pipeline.
629
662
  * @param request The upload request (Blob/ArrayBuffer bytes + intent)
630
663
  * @returns Promise resolving to the initial upload result
631
664
  */
632
665
  upload(request) {
633
- return requireNapplet().upload.upload(request);
666
+ return requireDomain("upload").upload(request);
634
667
  },
635
668
  /**
636
669
  * Get the latest known status for a prior upload.
@@ -638,7 +671,7 @@ var upload = {
638
671
  * @returns Promise resolving to the latest status
639
672
  */
640
673
  status(uploadId) {
641
- return requireNapplet().upload.status(uploadId);
674
+ return requireDomain("upload").status(uploadId);
642
675
  },
643
676
  /**
644
677
  * Register for shell-pushed upload status updates.
@@ -646,7 +679,7 @@ var upload = {
646
679
  * @returns A Subscription with `close()` to stop listening
647
680
  */
648
681
  onStatus(handler) {
649
- return requireNapplet().upload.onStatus(handler);
682
+ return requireDomain("upload").onStatus(handler);
650
683
  }
651
684
  };
652
685
  var intent = {
@@ -656,7 +689,7 @@ var intent = {
656
689
  * @returns Promise resolving to the invocation result
657
690
  */
658
691
  invoke(request) {
659
- return requireNapplet().intent.invoke(request);
692
+ return requireDomain("intent").invoke(request);
660
693
  },
661
694
  /**
662
695
  * Open a napplet by archetype (sugar for `action: "open"`).
@@ -666,7 +699,7 @@ var intent = {
666
699
  * @returns Promise resolving to the invocation result
667
700
  */
668
701
  open(archetype, payload, opts) {
669
- return requireNapplet().intent.open(archetype, payload, opts);
702
+ return requireDomain("intent").open(archetype, payload, opts);
670
703
  },
671
704
  /**
672
705
  * Check whether the runtime can currently satisfy an archetype and expose the
@@ -675,14 +708,14 @@ var intent = {
675
708
  * @returns Promise resolving to the archetype availability
676
709
  */
677
710
  available(archetype) {
678
- return requireNapplet().intent.available(archetype);
711
+ return requireDomain("intent").available(archetype);
679
712
  },
680
713
  /**
681
714
  * Get availability for every archetype the runtime can satisfy.
682
715
  * @returns Promise resolving to availability for each satisfiable archetype
683
716
  */
684
717
  handlers() {
685
- return requireNapplet().intent.handlers();
718
+ return requireDomain("intent").handlers();
686
719
  },
687
720
  /**
688
721
  * Register for shell-pushed availability updates.
@@ -690,7 +723,7 @@ var intent = {
690
723
  * @returns A Subscription with `close()` to stop listening
691
724
  */
692
725
  onChanged(handler) {
693
- return requireNapplet().intent.onChanged(handler);
726
+ return requireDomain("intent").onChanged(handler);
694
727
  }
695
728
  };
696
729
  var webrtc = {
@@ -700,7 +733,7 @@ var webrtc = {
700
733
  * @returns Promise resolving to the opened session result
701
734
  */
702
735
  open(request) {
703
- return requireNapplet().webrtc.open(request);
736
+ return requireDomain("webrtc").open(request);
704
737
  },
705
738
  /**
706
739
  * Send an opaque application payload over a session.
@@ -708,7 +741,7 @@ var webrtc = {
708
741
  * @param payload Application payload
709
742
  */
710
743
  send(sessionId, payload) {
711
- return requireNapplet().webrtc.send(sessionId, payload);
744
+ return requireDomain("webrtc").send(sessionId, payload);
712
745
  },
713
746
  /**
714
747
  * Close a WebRTC session.
@@ -716,7 +749,7 @@ var webrtc = {
716
749
  * @param reason Optional close reason
717
750
  */
718
751
  close(sessionId, reason) {
719
- return requireNapplet().webrtc.close(sessionId, reason);
752
+ return requireDomain("webrtc").close(sessionId, reason);
720
753
  },
721
754
  /**
722
755
  * Subscribe to runtime-pushed WebRTC events.
@@ -724,7 +757,7 @@ var webrtc = {
724
757
  * @returns Subscription handle
725
758
  */
726
759
  onEvent(handler) {
727
- return requireNapplet().webrtc.onEvent(handler);
760
+ return requireDomain("webrtc").onEvent(handler);
728
761
  }
729
762
  };
730
763
 
@@ -737,7 +770,7 @@ var link = {
737
770
  * @returns Promise resolving to the shell's open/deny status
738
771
  */
739
772
  open(url, options) {
740
- return requireNapplet().link.open(url, options);
773
+ return requireDomain("link").open(url, options);
741
774
  }
742
775
  };
743
776
  var lists = {
@@ -746,7 +779,7 @@ var lists = {
746
779
  * @returns Promise resolving to supported list descriptions
747
780
  */
748
781
  supported() {
749
- return requireNapplet().lists.supported();
782
+ return requireDomain("lists").supported();
750
783
  },
751
784
  /**
752
785
  * Add items to a runtime-supported NIP-51 list.
@@ -755,7 +788,7 @@ var lists = {
755
788
  * @param options Optional create/metadata hints
756
789
  */
757
790
  add(list, items, options) {
758
- return requireNapplet().lists.add(list, items, options);
791
+ return requireDomain("lists").add(list, items, options);
759
792
  },
760
793
  /**
761
794
  * Remove items from a runtime-supported NIP-51 list.
@@ -764,7 +797,7 @@ var lists = {
764
797
  * @param options Optional runtime hints
765
798
  */
766
799
  remove(list, items, options) {
767
- return requireNapplet().lists.remove(list, items, options);
800
+ return requireDomain("lists").remove(list, items, options);
768
801
  }
769
802
  };
770
803
  var common = {
@@ -774,7 +807,7 @@ var common = {
774
807
  * @returns Promise resolving to the shell encode result
775
808
  */
776
809
  encodeNip19(input) {
777
- return requireNapplet().common.encodeNip19(input);
810
+ return requireDomain("common").encodeNip19(input);
778
811
  },
779
812
  /**
780
813
  * Decode a supported public NIP-19 value.
@@ -782,7 +815,7 @@ var common = {
782
815
  * @returns Promise resolving to normalized decoded fields
783
816
  */
784
817
  decodeNip19(value) {
785
- return requireNapplet().common.decodeNip19(value);
818
+ return requireDomain("common").decodeNip19(value);
786
819
  },
787
820
  /**
788
821
  * Resolve a profile by hex pubkey, npub, or nprofile.
@@ -790,14 +823,14 @@ var common = {
790
823
  * @returns Promise resolving to latest profile data when available
791
824
  */
792
825
  getProfile(target) {
793
- return requireNapplet().common.getProfile(target);
826
+ return requireDomain("common").getProfile(target);
794
827
  },
795
828
  /**
796
829
  * Return the shell user's followed pubkeys as hex.
797
830
  * @returns Promise resolving to followed pubkeys
798
831
  */
799
832
  follows() {
800
- return requireNapplet().common.follows();
833
+ return requireDomain("common").follows();
801
834
  },
802
835
  /**
803
836
  * Ask the shell to follow one or more npub targets.
@@ -805,7 +838,7 @@ var common = {
805
838
  * @returns Promise resolving to the action result
806
839
  */
807
840
  follow(...pubkeys) {
808
- return requireNapplet().common.follow(...pubkeys);
841
+ return requireDomain("common").follow(...pubkeys);
809
842
  },
810
843
  /**
811
844
  * Ask the shell to unfollow one or more npub targets.
@@ -813,7 +846,7 @@ var common = {
813
846
  * @returns Promise resolving to the action result
814
847
  */
815
848
  unfollow(...pubkeys) {
816
- return requireNapplet().common.unfollow(...pubkeys);
849
+ return requireDomain("common").unfollow(...pubkeys);
817
850
  },
818
851
  /**
819
852
  * React to a native Nostr event.
@@ -823,7 +856,7 @@ var common = {
823
856
  * @returns Promise resolving to the action result
824
857
  */
825
858
  react(targetEventId, reaction, customEmojiHref) {
826
- return requireNapplet().common.react(targetEventId, reaction, customEmojiHref);
859
+ return requireDomain("common").react(targetEventId, reaction, customEmojiHref);
827
860
  },
828
861
  /**
829
862
  * Report an event or pubkey with a NIP-56 reason.
@@ -833,7 +866,7 @@ var common = {
833
866
  * @returns Promise resolving to the action result
834
867
  */
835
868
  report(target, reason, text) {
836
- return requireNapplet().common.report(target, reason, text);
869
+ return requireDomain("common").report(target, reason, text);
837
870
  }
838
871
  };
839
872
  var ble = {
@@ -843,7 +876,7 @@ var ble = {
843
876
  * @returns Promise resolving to the runtime-assigned BLE open result
844
877
  */
845
878
  open(request) {
846
- return requireNapplet().ble.open(request);
879
+ return requireDomain("ble").open(request);
847
880
  },
848
881
  /**
849
882
  * List exposed GATT services for a session.
@@ -851,7 +884,7 @@ var ble = {
851
884
  * @returns Promise resolving to exposed services
852
885
  */
853
886
  services(sessionId) {
854
- return requireNapplet().ble.services(sessionId);
887
+ return requireDomain("ble").services(sessionId);
855
888
  },
856
889
  /**
857
890
  * Read a characteristic or descriptor value.
@@ -860,7 +893,7 @@ var ble = {
860
893
  * @returns Promise resolving to bytes
861
894
  */
862
895
  read(sessionId, target) {
863
- return requireNapplet().ble.read(sessionId, target);
896
+ return requireDomain("ble").read(sessionId, target);
864
897
  },
865
898
  /**
866
899
  * Write bytes to a characteristic or descriptor.
@@ -871,7 +904,7 @@ var ble = {
871
904
  * @returns Promise resolving after the runtime acknowledges the write
872
905
  */
873
906
  write(sessionId, target, data, options) {
874
- return requireNapplet().ble.write(sessionId, target, data, options);
907
+ return requireDomain("ble").write(sessionId, target, data, options);
875
908
  },
876
909
  /**
877
910
  * Start notifications or indications for a characteristic.
@@ -879,7 +912,7 @@ var ble = {
879
912
  * @param target GATT characteristic target
880
913
  */
881
914
  subscribe(sessionId, target) {
882
- return requireNapplet().ble.subscribe(sessionId, target);
915
+ return requireDomain("ble").subscribe(sessionId, target);
883
916
  },
884
917
  /**
885
918
  * Stop notifications or indications for a characteristic.
@@ -887,7 +920,7 @@ var ble = {
887
920
  * @param target GATT characteristic target
888
921
  */
889
922
  unsubscribe(sessionId, target) {
890
- return requireNapplet().ble.unsubscribe(sessionId, target);
923
+ return requireDomain("ble").unsubscribe(sessionId, target);
891
924
  },
892
925
  /**
893
926
  * Close an open BLE session.
@@ -895,7 +928,7 @@ var ble = {
895
928
  * @param reason Optional reason for the close request
896
929
  */
897
930
  close(sessionId, reason) {
898
- return requireNapplet().ble.close(sessionId, reason);
931
+ return requireDomain("ble").close(sessionId, reason);
899
932
  },
900
933
  /**
901
934
  * Register for shell-pushed BLE events.
@@ -903,7 +936,7 @@ var ble = {
903
936
  * @returns A Subscription with `close()` to stop listening
904
937
  */
905
938
  onEvent(handler) {
906
- return requireNapplet().ble.onEvent(handler);
939
+ return requireDomain("ble").onEvent(handler);
907
940
  }
908
941
  };
909
942
  var serial = {
@@ -913,7 +946,7 @@ var serial = {
913
946
  * @returns Promise resolving to the runtime-assigned serial open result
914
947
  */
915
948
  open(request) {
916
- return requireNapplet().serial.open(request);
949
+ return requireDomain("serial").open(request);
917
950
  },
918
951
  /**
919
952
  * Write bytes to an open serial session.
@@ -922,7 +955,7 @@ var serial = {
922
955
  * @returns Promise resolving after the runtime acknowledges the write
923
956
  */
924
957
  write(sessionId, data) {
925
- return requireNapplet().serial.write(sessionId, data);
958
+ return requireDomain("serial").write(sessionId, data);
926
959
  },
927
960
  /**
928
961
  * Close an open serial session.
@@ -931,7 +964,7 @@ var serial = {
931
964
  * @returns Promise resolving after the runtime acknowledges the close
932
965
  */
933
966
  close(sessionId, reason) {
934
- return requireNapplet().serial.close(sessionId, reason);
967
+ return requireDomain("serial").close(sessionId, reason);
935
968
  },
936
969
  /**
937
970
  * Register for shell-pushed serial events.
@@ -939,7 +972,7 @@ var serial = {
939
972
  * @returns A Subscription with `close()` to stop listening
940
973
  */
941
974
  onEvent(handler) {
942
- return requireNapplet().serial.onEvent(handler);
975
+ return requireDomain("serial").onEvent(handler);
943
976
  }
944
977
  };
945
978
  var dm = {
@@ -948,7 +981,7 @@ var dm = {
948
981
  * @returns Promise resolving to the runtime DM status
949
982
  */
950
983
  status() {
951
- return requireNapplet().dm.status();
984
+ return requireDomain("dm").status();
952
985
  },
953
986
  /**
954
987
  * Fetch normalized conversations visible to this napplet.
@@ -956,7 +989,7 @@ var dm = {
956
989
  * @returns Promise resolving to a page of conversations
957
990
  */
958
991
  conversations(query) {
959
- return requireNapplet().dm.conversations(query);
992
+ return requireDomain("dm").conversations(query);
960
993
  },
961
994
  /**
962
995
  * Fetch normalized message history for one conversation.
@@ -964,7 +997,7 @@ var dm = {
964
997
  * @returns Promise resolving to a page of messages
965
998
  */
966
999
  messages(query) {
967
- return requireNapplet().dm.messages(query);
1000
+ return requireDomain("dm").messages(query);
968
1001
  },
969
1002
  /**
970
1003
  * Ask the runtime to send a direct message.
@@ -972,7 +1005,7 @@ var dm = {
972
1005
  * @returns Promise resolving to the normalized send result
973
1006
  */
974
1007
  send(request) {
975
- return requireNapplet().dm.send(request);
1008
+ return requireDomain("dm").send(request);
976
1009
  },
977
1010
  /**
978
1011
  * Start live delivery for one conversation or all visible conversations.
@@ -980,7 +1013,7 @@ var dm = {
980
1013
  * @returns Promise resolving to the runtime subscription id
981
1014
  */
982
1015
  subscribe(request) {
983
- return requireNapplet().dm.subscribe(request);
1016
+ return requireDomain("dm").subscribe(request);
984
1017
  },
985
1018
  /**
986
1019
  * Stop a live DM subscription.
@@ -988,7 +1021,7 @@ var dm = {
988
1021
  * @returns Promise resolving to the runtime acknowledgement
989
1022
  */
990
1023
  unsubscribe(subscriptionId) {
991
- return requireNapplet().dm.unsubscribe(subscriptionId);
1024
+ return requireDomain("dm").unsubscribe(subscriptionId);
992
1025
  },
993
1026
  /**
994
1027
  * Register for shell-pushed `dm.message` deliveries.
@@ -996,7 +1029,7 @@ var dm = {
996
1029
  * @returns A Subscription with `close()` to stop listening
997
1030
  */
998
1031
  onMessage(handler) {
999
- return requireNapplet().dm.onMessage(handler);
1032
+ return requireDomain("dm").onMessage(handler);
1000
1033
  }
1001
1034
  };
1002
1035
 
@@ -1075,7 +1108,12 @@ import { ifcEmit, ifcOn } from "@napplet/nap/ifc";
1075
1108
  import { keysRegisterAction, keysUnregisterAction, keysOnAction, keysRegister } from "@napplet/nap/keys";
1076
1109
  import { mediaCreateSession, mediaUpdateSession, mediaDestroySession, mediaReportState, mediaReportCapabilities, mediaSendCommand, mediaOnCommand, mediaOnState, mediaOnCapabilities, mediaOnControls } from "@napplet/nap/media";
1077
1110
  import { notifySend, notifyDismiss, notifyBadge, notifyRegisterChannel, notifyRequestPermission, notifyOnAction, notifyOnClicked, notifyOnDismissed, notifyOnControls } from "@napplet/nap/notify";
1078
- import { resourceBytes, resourceBytesMany, resourceBytesAsObjectURL } from "@napplet/nap/resource";
1111
+ import {
1112
+ resourceInfo,
1113
+ resourceBytes,
1114
+ resourceBytesMany,
1115
+ resourceBytesAsObjectURL
1116
+ } from "@napplet/nap/resource";
1079
1117
  import {
1080
1118
  cvmDiscover,
1081
1119
  cvmRequest,
@@ -1087,12 +1125,14 @@ import {
1087
1125
  cvmOnEvent
1088
1126
  } from "@napplet/nap/cvm";
1089
1127
  import {
1128
+ outboxGetEvent,
1090
1129
  outboxQuery,
1091
1130
  outboxSubscribe,
1092
1131
  outboxPublish,
1093
1132
  outboxResolveRelays
1094
1133
  } from "@napplet/nap/outbox";
1095
1134
  import {
1135
+ uploadInfo,
1096
1136
  uploadFile,
1097
1137
  uploadStatus,
1098
1138
  uploadOnStatus
@@ -1289,6 +1329,7 @@ export {
1289
1329
  notifyRequestPermission,
1290
1330
  notifySend,
1291
1331
  outbox,
1332
+ outboxGetEvent,
1292
1333
  outboxPublish,
1293
1334
  outboxQuery,
1294
1335
  outboxResolveRelays,
@@ -1302,6 +1343,7 @@ export {
1302
1343
  resourceBytes,
1303
1344
  resourceBytesAsObjectURL,
1304
1345
  resourceBytesMany,
1346
+ resourceInfo,
1305
1347
  serial,
1306
1348
  serialClose,
1307
1349
  serialOnEvent,
@@ -1320,6 +1362,7 @@ export {
1320
1362
  themeOnChanged,
1321
1363
  upload,
1322
1364
  uploadFile,
1365
+ uploadInfo,
1323
1366
  uploadOnStatus,
1324
1367
  uploadStatus,
1325
1368
  webrtc,