@omniaura/solid-pulse 0.1.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.
@@ -0,0 +1,175 @@
1
+ import { j as Rect, c as ComponentRef, g as PulseController, E as ElementRef, d as EventBus, e as Feature } from './controller-3akN6Qi0.js';
2
+ export { a as CommandResult, C as CommandSpec, f as Filters, P as PulseEvent, i as PulseEventKind } from './controller-3akN6Qi0.js';
3
+
4
+ /**
5
+ * Visual layer. One fixed, pointer-events:none container holds every flash
6
+ * rectangle and badge, so the overlay can never shift layout, take focus or
7
+ * intercept input. Everything is plain DOM (no Solid) so it produces no
8
+ * reactive events of its own and works with any Solid version.
9
+ */
10
+
11
+ type FlashKind = "dom" | "mount" | "reattach" | "query" | "highlight";
12
+ declare class FlashOverlay {
13
+ private root;
14
+ private live;
15
+ private badges;
16
+ private reduced;
17
+ mount(): void;
18
+ unmount(): void;
19
+ get mounted(): boolean;
20
+ /** Flash rectangles in viewport coordinates. Drops extras beyond the live cap. */
21
+ flash(rects: readonly Rect[], kind: FlashKind, opts?: {
22
+ ms?: number;
23
+ label?: string;
24
+ }): number;
25
+ /**
26
+ * Transient badge centred on `at` (or the viewport when null). Used for the
27
+ * Solid Query overlay: "<Component> observing ['todos', 1]".
28
+ */
29
+ badge(html: {
30
+ title: string;
31
+ body?: string;
32
+ }, at: Rect | null, opts?: {
33
+ ms?: number;
34
+ kind?: FlashKind;
35
+ }): boolean;
36
+ }
37
+
38
+ /**
39
+ * Solid instrumentation through the official dev hooks (`DEV.hooks`), which
40
+ * exist only in Solid's development build. In a production build `DEV` is
41
+ * undefined and this module becomes a no-op — nothing is patched.
42
+ *
43
+ * What we see, precisely:
44
+ * - `afterCreateOwner(owner)` fires for every root, computation and (in dev)
45
+ * every component: dev components are computations carrying `.component`.
46
+ * - We wrap each non-component computation's `fn` so we know when a memo /
47
+ * effect / render-effect actually re-runs. Solid never re-runs component
48
+ * bodies, so there is no "rerender" to report — only these.
49
+ * - `afterUpdate()` marks the end of a synchronous update; together with a
50
+ * microtask fallback it closes a "flush" group used to attribute DOM
51
+ * mutations to the computations that produced them.
52
+ * - `sharedConfig.context` is set while hydrating, so mounts during hydration
53
+ * are labelled as such.
54
+ */
55
+
56
+ interface ComponentInfo {
57
+ id: number;
58
+ name: string;
59
+ parent: number | null;
60
+ hydrated: boolean;
61
+ mountedAt: number;
62
+ mountedWall: number;
63
+ flush: number;
64
+ disposedAt: number | null;
65
+ }
66
+ interface SolidInstrumentation {
67
+ readonly available: boolean;
68
+ flushId(): number;
69
+ /** Components whose computations ran in the most recently closed flush. */
70
+ lastFlushComponents(): ComponentRef[];
71
+ componentFor(owner: unknown): ComponentRef | null;
72
+ currentComponent(): ComponentRef | null;
73
+ components(): ComponentInfo[];
74
+ attachElement(componentId: number, el: Element): void;
75
+ rectFor(component: ComponentRef): Rect | null;
76
+ elementsFor(componentId: number): Element[];
77
+ dispose(): void;
78
+ }
79
+
80
+ /**
81
+ * Page-side bridge transport. Streams events to the bridge server in ≤50 ms
82
+ * batches and executes commands the server relays from the CLI/agents. Any
83
+ * command is just `controller.run(name, args)` — the same call the panel makes.
84
+ */
85
+
86
+ interface BridgeClientOptions {
87
+ /** ws(s):// URL. Default: same origin + /__pulse/ws. */
88
+ url?: string;
89
+ /** Reconnect delay in ms (default 2000). */
90
+ reconnectMs?: number;
91
+ /** Stable client id (default: random per page load, persisted in sessionStorage). */
92
+ clientId?: string;
93
+ }
94
+ declare class BridgeClient {
95
+ private controller;
96
+ private options;
97
+ private ws;
98
+ private timer;
99
+ private queue;
100
+ private flushTimer;
101
+ private unsubscribe;
102
+ private closed;
103
+ private NativeWebSocket;
104
+ readonly url: string;
105
+ readonly clientId: string;
106
+ connected: boolean;
107
+ constructor(controller: PulseController, options?: BridgeClientOptions);
108
+ connect(): void;
109
+ disconnect(): void;
110
+ private scheduleFlush;
111
+ private flush;
112
+ private send;
113
+ private onMessage;
114
+ }
115
+
116
+ /**
117
+ * DOM observation. A MutationObserver tells us what actually changed on
118
+ * screen; nothing here infers "rerenders". Beyond plain mutations it detects
119
+ * the pattern that costs people days: a subtree is removed and the *same node
120
+ * instance* is re-inserted moments later (a Suspense boundary flipping to its
121
+ * fallback and back, a keyed <Show>/<Switch> toggling). That detach/reattach
122
+ * silently resets scroll positions to 0 and drops focus to <body>, with no
123
+ * component cleanup running — so we record scrollTop and focus at detach time
124
+ * and compare after reattach.
125
+ */
126
+
127
+ declare function describeElement(el: Element, withRect?: boolean): ElementRef;
128
+ declare function toSelector(el: Element): string;
129
+
130
+ /**
131
+ * @omniaura/solid-pulse — runtime entry.
132
+ *
133
+ * import { initPulse } from "@omniaura/solid-pulse";
134
+ * if (import.meta.env.DEV) initPulse({ bridge: true });
135
+ *
136
+ * or let `@omniaura/solid-pulse/vite` auto-import it in dev. Never ship it in
137
+ * production: the Vite plugin is `apply: "serve"` and `initPulse` refuses to
138
+ * run twice. Instrumentation is dev-only and everything is bounded (ring
139
+ * buffer, per-frame flash caps, per-stream message caps).
140
+ */
141
+
142
+ interface PulseOptions {
143
+ /** Ring-buffer capacity (default 2000 events). */
144
+ bufferSize?: number;
145
+ /** Initial feature flags. */
146
+ features?: Partial<Record<Feature, boolean>>;
147
+ /** Mount the flash/badge overlay (default true). */
148
+ overlay?: boolean;
149
+ /**
150
+ * Connect to a bridge. `true` uses the same origin at `/__pulse/ws` (the
151
+ * Vite plugin mounts one there); a string is an explicit ws:// URL.
152
+ */
153
+ bridge?: boolean | string | BridgeClientOptions;
154
+ /** Print a console banner (default true). */
155
+ banner?: boolean;
156
+ }
157
+ interface Pulse {
158
+ controller: PulseController;
159
+ bus: EventBus;
160
+ overlay: FlashOverlay | null;
161
+ solid: SolidInstrumentation | null;
162
+ bridge: BridgeClient | null;
163
+ /** Run a command exactly as the CLI would. */
164
+ run: PulseController["run"];
165
+ destroy(): void;
166
+ }
167
+ declare function getPulse(): Pulse | null;
168
+ declare function initPulse(options?: PulseOptions): Pulse;
169
+ declare global {
170
+ interface Window {
171
+ __SOLID_PULSE__?: Pulse;
172
+ }
173
+ }
174
+
175
+ export { ComponentRef, ElementRef, EventBus, Feature, FlashOverlay, type Pulse, PulseController, type PulseOptions, Rect, type SolidInstrumentation, describeElement, getPulse, initPulse, toSelector };