lumiverse-spindle-types 0.4.56 → 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 +1 -1
- package/src/dom.ts +78 -0
- package/src/index.ts +12 -5
package/package.json
CHANGED
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
|
@@ -156,11 +156,18 @@ export type {
|
|
|
156
156
|
SpindleModalOptions,
|
|
157
157
|
SpindleModalHandle,
|
|
158
158
|
SpindleConfirmVariant,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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";
|
|
164
171
|
|
|
165
172
|
export type { ExtensionInfo } from "./extension-info";
|
|
166
173
|
|