lumiverse-spindle-types 0.4.55 → 0.4.57

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lumiverse-spindle-types",
3
- "version": "0.4.55",
3
+ "version": "0.4.57",
4
4
  "types": "./src/index.ts",
5
5
  "keywords": [
6
6
  "lumiverse",
package/src/api.ts CHANGED
@@ -1593,6 +1593,14 @@ export interface TokenCountResultDTO {
1593
1593
  approximate: boolean;
1594
1594
  }
1595
1595
 
1596
+ /** Context delivered to an on-request shared RPC endpoint handler. */
1597
+ export interface SharedRpcRequestContextDTO {
1598
+ /** Fully-qualified endpoint name (for example `weather_ext.status.current`). */
1599
+ endpoint: string;
1600
+ /** Identifier of the extension requesting the value. */
1601
+ requesterExtensionId: string;
1602
+ }
1603
+
1596
1604
  // ─── Worker → Host messages ──────────────────────────────────────────────
1597
1605
 
1598
1606
  export type WorkerToHost =
@@ -1675,6 +1683,16 @@ export type WorkerToHost =
1675
1683
  reservationId: string;
1676
1684
  }
1677
1685
  | { type: "permissions_get_granted"; requestId: string }
1686
+ | { type: "rpc_pool_sync"; endpoint: string; value: unknown }
1687
+ | { type: "rpc_pool_register_handler"; endpoint: string }
1688
+ | { type: "rpc_pool_unregister"; endpoint: string }
1689
+ | { type: "rpc_pool_read"; requestId: string; endpoint: string }
1690
+ | {
1691
+ type: "rpc_pool_handler_result";
1692
+ requestId: string;
1693
+ result?: unknown;
1694
+ error?: string;
1695
+ }
1678
1696
  | { type: "connections_list"; requestId: string; userId?: string }
1679
1697
  | { type: "connections_get"; requestId: string; connectionId: string; userId?: string }
1680
1698
  | { type: "chat_get_messages"; requestId: string; chatId: string }
@@ -2010,6 +2028,12 @@ export type WorkerToHost =
2010
2028
  export type HostToWorker =
2011
2029
  | { type: "init"; manifest: SpindleManifest; storagePath: string }
2012
2030
  | { type: "event"; event: string; payload: unknown; userId?: string }
2031
+ | {
2032
+ type: "rpc_pool_request";
2033
+ requestId: string;
2034
+ endpoint: string;
2035
+ requesterExtensionId: string;
2036
+ }
2013
2037
  | {
2014
2038
  type: "intercept_request";
2015
2039
  requestId: string;
package/src/dom.ts CHANGED
@@ -377,6 +377,83 @@ export interface SpindleConfirmResult {
377
377
  confirmed: boolean;
378
378
  }
379
379
 
380
+ // ── UI Event Helpers ──
381
+
382
+ export type SpindleUIDomActionEventType = "click" | "pointerdown" | "pointerup";
383
+
384
+ export interface SpindleUIKeyboardState {
385
+ /** True when the host believes a virtual keyboard is currently visible. */
386
+ visible: boolean;
387
+ /** Safe bottom inset in CSS pixels that keeps content above the keyboard. */
388
+ insetBottom: number;
389
+ /** Current visual viewport width in CSS pixels. */
390
+ viewportWidth: number;
391
+ /** Current visual viewport height in CSS pixels. */
392
+ viewportHeight: number;
393
+ }
394
+
395
+ export interface SpindleUIDrawerState {
396
+ /** Whether the side drawer is currently visible. */
397
+ open: boolean;
398
+ /** Active drawer tab, if any. */
399
+ tabId: string | null;
400
+ }
401
+
402
+ export interface SpindleUISettingsState {
403
+ /** Whether the settings modal is currently visible. */
404
+ open: boolean;
405
+ /** Active settings view identifier. */
406
+ view: string;
407
+ }
408
+
409
+ export interface SpindleUIDomActionDetail {
410
+ /** Matched action identifier read from the target element. */
411
+ actionId: string;
412
+ /** DOM event type that triggered the callback. */
413
+ eventType: SpindleUIDomActionEventType;
414
+ /** Matched descendant element that carried the action identifier. */
415
+ element: HTMLElement;
416
+ /** Bound extension-owned root used for delegation. */
417
+ root: Element;
418
+ /** Native DOM event from the host document. */
419
+ originalEvent: Event;
420
+ }
421
+
422
+ export interface SpindleUIDomActionBindingOptions {
423
+ /** Attribute used to resolve action IDs. Default: `id`. */
424
+ attribute?: string;
425
+ /** Event types to listen for. Default: `["click"]`. */
426
+ events?: SpindleUIDomActionEventType[];
427
+ }
428
+
429
+ export interface SpindleUIEventsHelper {
430
+ /** Read the current virtual keyboard snapshot. */
431
+ getKeyboardState(): SpindleUIKeyboardState;
432
+ /** Subscribe to keyboard visibility / safe-area changes. */
433
+ onKeyboardChange(handler: (state: SpindleUIKeyboardState) => void): () => void;
434
+ /** Read the current side drawer snapshot. */
435
+ getDrawerState(): SpindleUIDrawerState;
436
+ /** Subscribe to side drawer open/close and tab changes. */
437
+ onDrawerChange(handler: (state: SpindleUIDrawerState) => void): () => void;
438
+ /** Read the current settings modal snapshot. */
439
+ getSettingsState(): SpindleUISettingsState;
440
+ /** Subscribe to settings modal open/close and active-view changes. */
441
+ onSettingsChange(handler: (state: SpindleUISettingsState) => void): () => void;
442
+ /**
443
+ * Delegate action handlers from extension-owned DOM.
444
+ *
445
+ * This is intended for non-sandbox UI where the extension injects or mounts
446
+ * host DOM directly and wants to react to user interaction without wiring
447
+ * global document listeners. By default the helper matches descendant
448
+ * elements by `id`, but `options.attribute` can be used instead.
449
+ */
450
+ bindActionHandlers(
451
+ target: string | Element,
452
+ handlers: Record<string, (detail: SpindleUIDomActionDetail) => void>,
453
+ options?: SpindleUIDomActionBindingOptions,
454
+ ): () => void;
455
+ }
456
+
380
457
  // ── Frontend Process Lifecycle ──
381
458
 
382
459
  /** Controller passed to a frontend process instance spawned by the backend runtime. */
@@ -432,6 +509,7 @@ export interface SpindleFrontendContext {
432
509
  emit(event: string, payload: unknown): void;
433
510
  };
434
511
  ui: {
512
+ events: SpindleUIEventsHelper;
435
513
  mount(point: SpindleMountPoint): Element;
436
514
  registerDrawerTab(options: SpindleDrawerTabOptions): SpindleDrawerTabHandle;
437
515
  createFloatWidget(options?: SpindleFloatWidgetOptions): SpindleFloatWidgetHandle;
package/src/index.ts CHANGED
@@ -111,6 +111,7 @@ export type {
111
111
  TokenModelSourceDTO,
112
112
  TokenCountOptionsDTO,
113
113
  TokenCountResultDTO,
114
+ SharedRpcRequestContextDTO,
114
115
  MacroInterceptorPhase,
115
116
  MacroInterceptorEnvDTO,
116
117
  MacroInterceptorCtxDTO,
@@ -155,11 +156,18 @@ export type {
155
156
  SpindleModalOptions,
156
157
  SpindleModalHandle,
157
158
  SpindleConfirmVariant,
158
- SpindleConfirmOptions,
159
- SpindleConfirmResult,
160
- SpindleFrontendProcessContext,
161
- SpindleFrontendProcessRegistry,
162
- } from "./dom";
159
+ SpindleConfirmOptions,
160
+ SpindleConfirmResult,
161
+ SpindleUIDomActionEventType,
162
+ SpindleUIKeyboardState,
163
+ SpindleUIDrawerState,
164
+ SpindleUISettingsState,
165
+ SpindleUIDomActionDetail,
166
+ SpindleUIDomActionBindingOptions,
167
+ SpindleUIEventsHelper,
168
+ SpindleFrontendProcessContext,
169
+ SpindleFrontendProcessRegistry,
170
+ } from "./dom";
163
171
 
164
172
  export type { ExtensionInfo } from "./extension-info";
165
173
 
@@ -83,6 +83,7 @@ import type {
83
83
  MacroInterceptorResultDTO,
84
84
  MessageContentProcessorCtxDTO,
85
85
  MessageContentProcessorResultDTO,
86
+ SharedRpcRequestContextDTO,
86
87
  } from "./api";
87
88
 
88
89
  export interface FrontendProcessHandle {
@@ -816,6 +817,37 @@ export interface SpindleAPI {
816
817
  onChanged(handler: (detail: PermissionChangedDetail) => void): () => void;
817
818
  };
818
819
 
820
+ /**
821
+ * Shared RPC pool (free tier).
822
+ *
823
+ * Use this to expose lightweight cross-extension state behind a stable
824
+ * `<extension_id>.<channel>` endpoint. Owner methods accept either the bare
825
+ * channel suffix (`status.current`) or the fully-qualified endpoint.
826
+ */
827
+ rpcPool: {
828
+ /**
829
+ * Publish the latest value for an endpoint. Replaces any previous on-demand
830
+ * handler for the same endpoint.
831
+ *
832
+ * Returns the fully-qualified endpoint name.
833
+ */
834
+ sync(endpoint: string, value: unknown): string;
835
+ /**
836
+ * Register an on-demand endpoint handler. Replaces any previously synced
837
+ * value or handler for the same endpoint.
838
+ *
839
+ * Returns the fully-qualified endpoint name.
840
+ */
841
+ handle(
842
+ endpoint: string,
843
+ handler: (ctx: SharedRpcRequestContextDTO) => unknown | Promise<unknown>
844
+ ): string;
845
+ /** Read the latest value from another extension's fully-qualified endpoint. */
846
+ read<T = unknown>(endpoint: string): Promise<T>;
847
+ /** Remove an endpoint owned by this extension. */
848
+ unregister(endpoint: string): void;
849
+ };
850
+
819
851
  /** Make a CORS-proxied HTTP request */
820
852
  cors(url: string, options?: RequestInitDTO): Promise<unknown>;
821
853