bee-ladybug 0.2.0 → 0.4.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/src/index.d.ts CHANGED
@@ -14,7 +14,8 @@ export const WELL_KNOWN_TYPES: readonly [
14
14
  'error',
15
15
  'state',
16
16
  'sys',
17
- 'clear'
17
+ 'clear',
18
+ 'telemetry'
18
19
  ];
19
20
 
20
21
  export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
@@ -58,6 +59,8 @@ export interface CoreState {
58
59
  hud: Record<string, HudEntry>;
59
60
  mode: string;
60
61
  assistant: string | null;
62
+ assistants: string[];
63
+ adapters: AdapterInfo[];
61
64
  }
62
65
 
63
66
  export interface CoreOptions {
@@ -105,6 +108,18 @@ export interface AssistantProvider {
105
108
  complete(input: { question: string; snapshot: AssistantSnapshot }): unknown;
106
109
  }
107
110
 
111
+ export interface AdapterHooks {
112
+ enable(): void;
113
+ disable(): void;
114
+ label?: string;
115
+ }
116
+
117
+ export interface AdapterInfo {
118
+ name: string;
119
+ label: string;
120
+ enabled: boolean;
121
+ }
122
+
108
123
  export function formatSimTime(ms: number): string;
109
124
 
110
125
  export class BeeLadybugCore {
@@ -148,9 +163,17 @@ export class BeeLadybugCore {
148
163
  getLatest(type: string): BeePacket | null;
149
164
  readonly hasAssistant: boolean;
150
165
  readonly assistantBusy: boolean;
166
+ getAssistants(): string[];
167
+ registerAssistant(provider: AssistantProvider): this;
168
+ setActiveAssistant(name: string): this;
151
169
  setAssistant(provider: AssistantProvider): this;
152
- clearAssistant(): this;
170
+ clearAssistant(name?: string): this;
153
171
  ask(question?: string): Promise<string | null>;
172
+ registerAdapter(name: string, hooks: AdapterHooks): this;
173
+ unregisterAdapter(name: string): this;
174
+ getAdapters(): AdapterInfo[];
175
+ toggleAdapter(name: string): this;
176
+ setAdapterEnabled(name: string, enabled: boolean): this;
154
177
  }
155
178
 
156
179
  export class UIOverlay {
@@ -189,6 +212,7 @@ export interface CanvasAdapterOptions {
189
212
  entities?: CanvasEntity[];
190
213
  overlay?: boolean;
191
214
  computeCollisions?: boolean;
215
+ autoPump?: boolean;
192
216
  colorActive?: string;
193
217
  colorColliding?: string;
194
218
  colorInactive?: string;
@@ -205,11 +229,13 @@ export class CanvasAdapter {
205
229
  entities: CanvasEntity[];
206
230
  overlayEnabled: boolean;
207
231
  computeCollisions: boolean;
232
+ autoPump: boolean;
208
233
  frozen: boolean;
209
234
  timeScale: number;
210
235
  constructor(core: BeeLadybugCore, options?: CanvasAdapterOptions);
211
236
  attach(): this;
212
237
  detach(): this;
238
+ startAutoPump(): this;
213
239
  setCanvas(canvas: HTMLCanvasElement | null): this;
214
240
  setEntities(entities: CanvasEntity[]): this;
215
241
  pump(ctx?: CanvasRenderingContext2D): this;
@@ -246,6 +272,44 @@ export class WebDOMAdapter {
246
272
  pump(): this;
247
273
  }
248
274
 
275
+ export interface AntAdapterOptions {
276
+ root?: ParentNode | null;
277
+ threshold?: number;
278
+ windowMs?: number;
279
+ source?: string;
280
+ }
281
+
282
+ export const ANT_ADAPTER_DEFAULTS: Required<Omit<AntAdapterOptions, 'root'>>;
283
+
284
+ export class AntAdapter {
285
+ core: BeeLadybugCore | null;
286
+ root: ParentNode | null;
287
+ threshold: number;
288
+ windowMs: number;
289
+ source: string;
290
+ constructor(core: BeeLadybugCore, options?: AntAdapterOptions);
291
+ attach(): this;
292
+ detach(): this;
293
+ }
294
+
295
+ export interface SpiderAdapterOptions {
296
+ longTaskThreshold?: number;
297
+ resourceThreshold?: number;
298
+ source?: string;
299
+ }
300
+
301
+ export const SPIDER_ADAPTER_DEFAULTS: Required<SpiderAdapterOptions>;
302
+
303
+ export class SpiderAdapter {
304
+ core: BeeLadybugCore | null;
305
+ longTaskThreshold: number;
306
+ resourceThreshold: number;
307
+ source: string;
308
+ constructor(core: BeeLadybugCore, options?: SpiderAdapterOptions);
309
+ attach(): this;
310
+ detach(): this;
311
+ }
312
+
249
313
  export type PythonBridgeStatus = 'idle' | 'connecting' | 'open' | 'closed';
250
314
 
251
315
  export interface PythonBridgeOptions {
package/src/index.js CHANGED
@@ -2,4 +2,6 @@ export { BeeLadybugCore, BEE_LADYBUG_VERSION, CORE_DEFAULTS, WELL_KNOWN_TYPES, f
2
2
  export { UIOverlay } from './core/UIOverlay.js';
3
3
  export { CanvasAdapter, CANVAS_ADAPTER_DEFAULTS } from './adapters/CanvasAdapter.js';
4
4
  export { WebDOMAdapter, WEB_DOM_ADAPTER_DEFAULTS } from './adapters/WebDOMAdapter.js';
5
+ export { AntAdapter, ANT_ADAPTER_DEFAULTS } from './adapters/AntAdapter.js';
6
+ export { SpiderAdapter, SPIDER_ADAPTER_DEFAULTS } from './adapters/SpiderAdapter.js';
5
7
  export { PythonBridge, PYTHON_BRIDGE_DEFAULTS } from './adapters/python/PythonBridge.js';