@oyerinde/caliper 0.2.0 → 0.2.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.2.1] - 2026-02-16
6
+
7
+ ### Refactored
8
+
9
+ - **Configuration Engine**: Renamed `OverlayConfig` to `CaliperConfig` to reflect its expanded scope.
10
+ - **Bridge Decoupling**: Moved `bridge` configuration out of the core config type. It is now exclusively a plugin concern, with specialized `IIFEConfig` handling for CDN/script-tag users.
11
+
12
+ ### Added
13
+
14
+ - **Agent Bridge Serialization**: Introduced `onStateChangeGlobal` to allow string-based callback names in `data-config` for IIFE/CDN environments.
15
+
16
+ ### Fixed
17
+
18
+ - **Boundary Box Snapping**: Fixed a bug where boxes would snap to `(0,0)` when elements animated out or were removed from the DOM. The overlay now retains the last known good position.
19
+
5
20
  ## [0.2.0] - 2026-02-12
6
21
 
7
22
  ### Added
package/README.md CHANGED
@@ -183,7 +183,7 @@ const caliper = init();
183
183
  caliper.use(
184
184
  CaliperBridge({
185
185
  enabled: true,
186
- wsUrl: "ws://localhost:9876",
186
+ wsPort: 9876,
187
187
  })
188
188
  );
189
189
  ```
@@ -263,10 +263,6 @@ init({
263
263
  enabled: true, // Smooth hover box
264
264
  lerpFactor: 0.25, // Fluidity (low = slower)
265
265
  },
266
- bridge: {
267
- enabled: true, // Connect to AI Agents
268
- wsPort: 9876, // Port for MCP relay
269
- },
270
266
  });
271
267
  ```
272
268
 
package/dist/bridge.cjs CHANGED
@@ -1,50 +1,50 @@
1
1
  'use strict';
2
2
 
3
- var chunk3W2YKDGV_cjs = require('./chunk-3W2YKDGV.cjs');
3
+ var chunkPYAVLOZM_cjs = require('./chunk-PYAVLOZM.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "CALIPER_METHODS", {
8
8
  enumerable: true,
9
- get: function () { return chunk3W2YKDGV_cjs.CALIPER_METHODS; }
9
+ get: function () { return chunkPYAVLOZM_cjs.CALIPER_METHODS; }
10
10
  });
11
11
  Object.defineProperty(exports, "CaliperActionResultSchema", {
12
12
  enumerable: true,
13
- get: function () { return chunk3W2YKDGV_cjs.CaliperActionResultSchema; }
13
+ get: function () { return chunkPYAVLOZM_cjs.CaliperActionResultSchema; }
14
14
  });
15
15
  Object.defineProperty(exports, "CaliperAgentStateSchema", {
16
16
  enumerable: true,
17
- get: function () { return chunk3W2YKDGV_cjs.CaliperAgentStateSchema; }
17
+ get: function () { return chunkPYAVLOZM_cjs.CaliperAgentStateSchema; }
18
18
  });
19
19
  Object.defineProperty(exports, "CaliperBridge", {
20
20
  enumerable: true,
21
- get: function () { return chunk3W2YKDGV_cjs.CaliperBridge; }
21
+ get: function () { return chunkPYAVLOZM_cjs.CaliperBridge; }
22
22
  });
23
23
  Object.defineProperty(exports, "CaliperGetContextPayloadSchema", {
24
24
  enumerable: true,
25
- get: function () { return chunk3W2YKDGV_cjs.CaliperGetContextPayloadSchema; }
25
+ get: function () { return chunkPYAVLOZM_cjs.CaliperGetContextPayloadSchema; }
26
26
  });
27
27
  Object.defineProperty(exports, "CaliperInspectPayloadSchema", {
28
28
  enumerable: true,
29
- get: function () { return chunk3W2YKDGV_cjs.CaliperInspectPayloadSchema; }
29
+ get: function () { return chunkPYAVLOZM_cjs.CaliperInspectPayloadSchema; }
30
30
  });
31
31
  Object.defineProperty(exports, "CaliperMeasurePayloadSchema", {
32
32
  enumerable: true,
33
- get: function () { return chunk3W2YKDGV_cjs.CaliperMeasurePayloadSchema; }
33
+ get: function () { return chunkPYAVLOZM_cjs.CaliperMeasurePayloadSchema; }
34
34
  });
35
35
  Object.defineProperty(exports, "CaliperSelectPayloadSchema", {
36
36
  enumerable: true,
37
- get: function () { return chunk3W2YKDGV_cjs.CaliperSelectPayloadSchema; }
37
+ get: function () { return chunkPYAVLOZM_cjs.CaliperSelectPayloadSchema; }
38
38
  });
39
39
  Object.defineProperty(exports, "CaliperWalkAndMeasurePayloadSchema", {
40
40
  enumerable: true,
41
- get: function () { return chunk3W2YKDGV_cjs.CaliperWalkAndMeasurePayloadSchema; }
41
+ get: function () { return chunkPYAVLOZM_cjs.CaliperWalkAndMeasurePayloadSchema; }
42
42
  });
43
43
  Object.defineProperty(exports, "CaliperWalkDomPayloadSchema", {
44
44
  enumerable: true,
45
- get: function () { return chunk3W2YKDGV_cjs.CaliperWalkDomPayloadSchema; }
45
+ get: function () { return chunkPYAVLOZM_cjs.CaliperWalkDomPayloadSchema; }
46
46
  });
47
47
  Object.defineProperty(exports, "dispatchCaliperIntent", {
48
48
  enumerable: true,
49
- get: function () { return chunk3W2YKDGV_cjs.dispatchCaliperIntent; }
49
+ get: function () { return chunkPYAVLOZM_cjs.dispatchCaliperIntent; }
50
50
  });
package/dist/bridge.d.cts CHANGED
@@ -8,6 +8,8 @@ declare interface AgentBridgeConfig {
8
8
  wsPort?: number;
9
9
  /** Callback for agent state changes */
10
10
  onStateChange?: (state: CaliperAgentState) => void;
11
+ /** Name of a global window function to call on state changes (IIFE/CDN-safe, JSON-serializable) */
12
+ onStateChangeGlobal?: string;
11
13
  }
12
14
 
13
15
  declare interface CalculatorIntegration {
package/dist/bridge.d.ts CHANGED
@@ -8,6 +8,8 @@ declare interface AgentBridgeConfig {
8
8
  wsPort?: number;
9
9
  /** Callback for agent state changes */
10
10
  onStateChange?: (state: CaliperAgentState) => void;
11
+ /** Name of a global window function to call on state changes (IIFE/CDN-safe, JSON-serializable) */
12
+ onStateChangeGlobal?: string;
11
13
  }
12
14
 
13
15
  declare interface CalculatorIntegration {
package/dist/bridge.js CHANGED
@@ -1 +1 @@
1
- export { CALIPER_METHODS, CaliperActionResultSchema, CaliperAgentStateSchema, CaliperBridge, CaliperGetContextPayloadSchema, CaliperInspectPayloadSchema, CaliperMeasurePayloadSchema, CaliperSelectPayloadSchema, CaliperWalkAndMeasurePayloadSchema, CaliperWalkDomPayloadSchema, dispatchCaliperIntent } from './chunk-ACV6FK43.js';
1
+ export { CALIPER_METHODS, CaliperActionResultSchema, CaliperAgentStateSchema, CaliperBridge, CaliperGetContextPayloadSchema, CaliperInspectPayloadSchema, CaliperMeasurePayloadSchema, CaliperSelectPayloadSchema, CaliperWalkAndMeasurePayloadSchema, CaliperWalkDomPayloadSchema, dispatchCaliperIntent } from './chunk-L47FGEH6.js';
@@ -18562,6 +18562,12 @@ function CaliperBridge(config2) {
18562
18562
  const disposeSync = initStateSync(stateStore, systems, (state) => {
18563
18563
  wsBridge.sendStateUpdate(state);
18564
18564
  config2.onStateChange?.(state);
18565
+ if (config2.onStateChangeGlobal) {
18566
+ const globalCallback = window[config2.onStateChangeGlobal];
18567
+ if (typeof globalCallback === "function") {
18568
+ globalCallback(state);
18569
+ }
18570
+ }
18565
18571
  });
18566
18572
  window.dispatchCaliperIntent = async (intent) => {
18567
18573
  if (!intentHandler) {
@@ -2850,8 +2850,7 @@ function getConfig() {
2850
2850
  ...parsed,
2851
2851
  theme: { ...windowConfig.theme, ...parsed.theme },
2852
2852
  commands: { ...windowConfig.commands, ...parsed.commands },
2853
- animation: { ...windowConfig.animation, ...parsed.animation },
2854
- bridge: { ...windowConfig.bridge, ...parsed.bridge }
2853
+ animation: { ...windowConfig.animation, ...parsed.animation }
2855
2854
  };
2856
2855
  } catch (e) {
2857
2856
  console.warn("[CALIPER] Failed to parse data-config attribute", e);
@@ -3755,16 +3754,27 @@ function BoundaryBoxes(props) {
3755
3754
  height: next.height
3756
3755
  };
3757
3756
  };
3758
- const liveSelectionTarget = createMemo(() => {
3757
+ const isDegenerate = (geo) => geo !== null && geo.width === 0 && geo.height === 0;
3758
+ const liveSelectionTarget = createMemo((prev) => {
3759
3759
  props.viewport.version;
3760
- return getLiveGeometry(props.metadata.rect, props.metadata.scrollHierarchy, props.metadata.position, props.metadata.stickyConfig, props.metadata.initialWindowX, props.metadata.initialWindowY);
3761
- });
3762
- const liveSecondaryTarget = createMemo(() => {
3760
+ if (prev && props.metadata.element && !document.contains(props.metadata.element)) {
3761
+ return prev;
3762
+ }
3763
+ const geo = getLiveGeometry(props.metadata.rect, props.metadata.scrollHierarchy, props.metadata.position, props.metadata.stickyConfig, props.metadata.initialWindowX, props.metadata.initialWindowY);
3764
+ if (isDegenerate(geo)) return prev;
3765
+ return geo;
3766
+ }, null);
3767
+ const liveSecondaryTarget = createMemo((prev) => {
3763
3768
  props.viewport.version;
3764
3769
  const res = props.result;
3765
3770
  if (!(props.isActivatePressed || props.isFrozen) || !res) return null;
3766
- return getLiveGeometry(res.secondary, res.secondaryHierarchy, res.secondaryPosition, res.secondarySticky, res.secondaryWinX, res.secondaryWinY);
3767
- });
3771
+ if (prev && res.secondaryElement && !document.contains(res.secondaryElement)) {
3772
+ return prev;
3773
+ }
3774
+ const geo = getLiveGeometry(res.secondary, res.secondaryHierarchy, res.secondaryPosition, res.secondarySticky, res.secondaryWinX, res.secondaryWinY);
3775
+ if (isDegenerate(geo)) return prev;
3776
+ return geo;
3777
+ }, null);
3768
3778
  createEffect(on([liveSelectionTarget, liveSecondaryTarget, () => props.animation.lerpFactor, () => props.metadata.element], ([selection, secondary, factor, element]) => {
3769
3779
  if (!selection) {
3770
3780
  setAnchor(null);
@@ -5170,12 +5180,13 @@ function Root(config) {
5170
5180
  if (selectedElement) {
5171
5181
  const hoveredElement = getTopElementAtPoint(e.clientX, e.clientY);
5172
5182
  const isAncestor = hoveredElement && lastHoveredElement && hoveredElement.contains(lastHoveredElement) && hoveredElement !== lastHoveredElement;
5183
+ const lastHoveredDetached = lastHoveredElement && !document.contains(lastHoveredElement);
5173
5184
  if (isAlt) {
5174
5185
  if (system) {
5175
5186
  measureDelegate.execute(!!isAncestor, selectedElement, cursorPoint, hoveredElement);
5176
5187
  }
5177
5188
  } else if (state !== "FROZEN") {
5178
- if (hoveredElement) {
5189
+ if (hoveredElement && !lastHoveredDetached) {
5179
5190
  selectionDelegate.execute(!!isAncestor, hoveredElement);
5180
5191
  }
5181
5192
  }
@@ -5553,14 +5564,14 @@ function Root(config) {
5553
5564
  let secondaryChanged = false;
5554
5565
  const runUpdates2 = () => {
5555
5566
  if (sentinelResized || primaryChanged) {
5556
- if (observedPrimary) {
5567
+ if (observedPrimary && document.contains(observedPrimary)) {
5557
5568
  const rect = observedPrimary.getBoundingClientRect();
5558
5569
  selectionSystem?.updateRect(rect);
5559
5570
  if (system) system.updatePrimaryRect(rect);
5560
5571
  }
5561
5572
  }
5562
5573
  if (sentinelResized || secondaryChanged) {
5563
- if (observedSecondary) {
5574
+ if (observedSecondary && document.contains(observedSecondary)) {
5564
5575
  const rect = observedSecondary.getBoundingClientRect();
5565
5576
  system?.updateSecondaryRect(rect);
5566
5577
  }
@@ -5875,11 +5886,11 @@ function createOverlay(config) {
5875
5886
  return instance;
5876
5887
  }
5877
5888
  if (IS_BROWSER2) {
5878
- showVersionInfo("0.2.0").catch(() => {
5889
+ showVersionInfo("0.2.1").catch(() => {
5879
5890
  });
5880
5891
  }
5881
5892
 
5882
5893
  // src/index.ts
5883
- var VERSION = "0.2.0";
5894
+ var VERSION = "0.2.1";
5884
5895
 
5885
5896
  export { VERSION, caliperProps, createOverlay, getConfig, setConfig };
@@ -2852,8 +2852,7 @@ function getConfig() {
2852
2852
  ...parsed,
2853
2853
  theme: { ...windowConfig.theme, ...parsed.theme },
2854
2854
  commands: { ...windowConfig.commands, ...parsed.commands },
2855
- animation: { ...windowConfig.animation, ...parsed.animation },
2856
- bridge: { ...windowConfig.bridge, ...parsed.bridge }
2855
+ animation: { ...windowConfig.animation, ...parsed.animation }
2857
2856
  };
2858
2857
  } catch (e) {
2859
2858
  console.warn("[CALIPER] Failed to parse data-config attribute", e);
@@ -3757,16 +3756,27 @@ function BoundaryBoxes(props) {
3757
3756
  height: next.height
3758
3757
  };
3759
3758
  };
3760
- const liveSelectionTarget = createMemo(() => {
3759
+ const isDegenerate = (geo) => geo !== null && geo.width === 0 && geo.height === 0;
3760
+ const liveSelectionTarget = createMemo((prev) => {
3761
3761
  props.viewport.version;
3762
- return getLiveGeometry(props.metadata.rect, props.metadata.scrollHierarchy, props.metadata.position, props.metadata.stickyConfig, props.metadata.initialWindowX, props.metadata.initialWindowY);
3763
- });
3764
- const liveSecondaryTarget = createMemo(() => {
3762
+ if (prev && props.metadata.element && !document.contains(props.metadata.element)) {
3763
+ return prev;
3764
+ }
3765
+ const geo = getLiveGeometry(props.metadata.rect, props.metadata.scrollHierarchy, props.metadata.position, props.metadata.stickyConfig, props.metadata.initialWindowX, props.metadata.initialWindowY);
3766
+ if (isDegenerate(geo)) return prev;
3767
+ return geo;
3768
+ }, null);
3769
+ const liveSecondaryTarget = createMemo((prev) => {
3765
3770
  props.viewport.version;
3766
3771
  const res = props.result;
3767
3772
  if (!(props.isActivatePressed || props.isFrozen) || !res) return null;
3768
- return getLiveGeometry(res.secondary, res.secondaryHierarchy, res.secondaryPosition, res.secondarySticky, res.secondaryWinX, res.secondaryWinY);
3769
- });
3773
+ if (prev && res.secondaryElement && !document.contains(res.secondaryElement)) {
3774
+ return prev;
3775
+ }
3776
+ const geo = getLiveGeometry(res.secondary, res.secondaryHierarchy, res.secondaryPosition, res.secondarySticky, res.secondaryWinX, res.secondaryWinY);
3777
+ if (isDegenerate(geo)) return prev;
3778
+ return geo;
3779
+ }, null);
3770
3780
  createEffect(on([liveSelectionTarget, liveSecondaryTarget, () => props.animation.lerpFactor, () => props.metadata.element], ([selection, secondary, factor, element]) => {
3771
3781
  if (!selection) {
3772
3782
  setAnchor(null);
@@ -5172,12 +5182,13 @@ function Root(config) {
5172
5182
  if (selectedElement) {
5173
5183
  const hoveredElement = getTopElementAtPoint(e.clientX, e.clientY);
5174
5184
  const isAncestor = hoveredElement && lastHoveredElement && hoveredElement.contains(lastHoveredElement) && hoveredElement !== lastHoveredElement;
5185
+ const lastHoveredDetached = lastHoveredElement && !document.contains(lastHoveredElement);
5175
5186
  if (isAlt) {
5176
5187
  if (system) {
5177
5188
  measureDelegate.execute(!!isAncestor, selectedElement, cursorPoint, hoveredElement);
5178
5189
  }
5179
5190
  } else if (state !== "FROZEN") {
5180
- if (hoveredElement) {
5191
+ if (hoveredElement && !lastHoveredDetached) {
5181
5192
  selectionDelegate.execute(!!isAncestor, hoveredElement);
5182
5193
  }
5183
5194
  }
@@ -5555,14 +5566,14 @@ function Root(config) {
5555
5566
  let secondaryChanged = false;
5556
5567
  const runUpdates2 = () => {
5557
5568
  if (sentinelResized || primaryChanged) {
5558
- if (observedPrimary) {
5569
+ if (observedPrimary && document.contains(observedPrimary)) {
5559
5570
  const rect = observedPrimary.getBoundingClientRect();
5560
5571
  selectionSystem?.updateRect(rect);
5561
5572
  if (system) system.updatePrimaryRect(rect);
5562
5573
  }
5563
5574
  }
5564
5575
  if (sentinelResized || secondaryChanged) {
5565
- if (observedSecondary) {
5576
+ if (observedSecondary && document.contains(observedSecondary)) {
5566
5577
  const rect = observedSecondary.getBoundingClientRect();
5567
5578
  system?.updateSecondaryRect(rect);
5568
5579
  }
@@ -5877,12 +5888,12 @@ function createOverlay(config) {
5877
5888
  return instance;
5878
5889
  }
5879
5890
  if (IS_BROWSER2) {
5880
- showVersionInfo("0.2.0").catch(() => {
5891
+ showVersionInfo("0.2.1").catch(() => {
5881
5892
  });
5882
5893
  }
5883
5894
 
5884
5895
  // src/index.ts
5885
- var VERSION = "0.2.0";
5896
+ var VERSION = "0.2.1";
5886
5897
 
5887
5898
  exports.VERSION = VERSION;
5888
5899
  exports.caliperProps = caliperProps;
@@ -18564,6 +18564,12 @@ function CaliperBridge(config2) {
18564
18564
  const disposeSync = initStateSync(stateStore, systems, (state) => {
18565
18565
  wsBridge.sendStateUpdate(state);
18566
18566
  config2.onStateChange?.(state);
18567
+ if (config2.onStateChangeGlobal) {
18568
+ const globalCallback = window[config2.onStateChangeGlobal];
18569
+ if (typeof globalCallback === "function") {
18570
+ globalCallback(state);
18571
+ }
18572
+ }
18567
18573
  });
18568
18574
  window.dispatchCaliperIntent = async (intent) => {
18569
18575
  if (!intentHandler) {
package/dist/index.cjs CHANGED
@@ -1,26 +1,26 @@
1
1
  'use strict';
2
2
 
3
- var chunkOSQHATBH_cjs = require('./chunk-OSQHATBH.cjs');
3
+ var chunkP37B6G5P_cjs = require('./chunk-P37B6G5P.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "VERSION", {
8
8
  enumerable: true,
9
- get: function () { return chunkOSQHATBH_cjs.VERSION; }
9
+ get: function () { return chunkP37B6G5P_cjs.VERSION; }
10
10
  });
11
11
  Object.defineProperty(exports, "caliperProps", {
12
12
  enumerable: true,
13
- get: function () { return chunkOSQHATBH_cjs.caliperProps; }
13
+ get: function () { return chunkP37B6G5P_cjs.caliperProps; }
14
14
  });
15
15
  Object.defineProperty(exports, "getConfig", {
16
16
  enumerable: true,
17
- get: function () { return chunkOSQHATBH_cjs.getConfig; }
17
+ get: function () { return chunkP37B6G5P_cjs.getConfig; }
18
18
  });
19
19
  Object.defineProperty(exports, "init", {
20
20
  enumerable: true,
21
- get: function () { return chunkOSQHATBH_cjs.createOverlay; }
21
+ get: function () { return chunkP37B6G5P_cjs.createOverlay; }
22
22
  });
23
23
  Object.defineProperty(exports, "setConfig", {
24
24
  enumerable: true,
25
- get: function () { return chunkOSQHATBH_cjs.setConfig; }
25
+ get: function () { return chunkP37B6G5P_cjs.setConfig; }
26
26
  });
package/dist/index.d.cts CHANGED
@@ -7,6 +7,8 @@ export declare interface AgentBridgeConfig {
7
7
  wsPort?: number;
8
8
  /** Callback for agent state changes */
9
9
  onStateChange?: (state: CaliperAgentState) => void;
10
+ /** Name of a global window function to call on state changes (IIFE/CDN-safe, JSON-serializable) */
11
+ onStateChangeGlobal?: string;
10
12
  }
11
13
 
12
14
  export declare interface AnimationConfig {
@@ -439,6 +441,17 @@ declare const CaliperAgentStateSchema: z.ZodObject<{
439
441
  lastUpdated: z.ZodNumber;
440
442
  }, z.core.$strip>;
441
443
 
444
+ export declare interface CaliperConfig {
445
+ /** Customize the visual appearance of the overlay (colors, shadows). */
446
+ theme?: ThemeConfig;
447
+ /** Customize keyboard shortcuts for all interactions. */
448
+ commands?: CommandsConfig;
449
+ /** Control the boundary box lerp animation behavior. */
450
+ animation?: AnimationConfig;
451
+ /** Enable debug logging (default: true). All logs are stripped from production builds. */
452
+ debug?: boolean;
453
+ }
454
+
442
455
  /**
443
456
  * A plugin allows extending Caliper's functionality by accessing the
444
457
  * OverlayInstance and internal systems.
@@ -491,9 +504,9 @@ export declare interface CommandsConfig {
491
504
  * 1. Global window object (`window.__CALIPER_CONFIG__`)
492
505
  * 2. `data-config` attribute on the script tag (useful for UMD/CDN usage)
493
506
  *
494
- * @returns The resolved OverlayConfig object.
507
+ * @returns The resolved CaliperConfig object.
495
508
  */
496
- export declare function getConfig(): OverlayConfig;
509
+ export declare function getConfig(): CaliperConfig;
497
510
 
498
511
  /**
499
512
  * Core factory function to create and mount the Caliper overlay.
@@ -523,7 +536,7 @@ export declare function getConfig(): OverlayConfig;
523
536
  * @param config - The initial configuration object to merge with global defaults.
524
537
  * @returns An OverlayInstance with mount, dispose, and plugin management capabilities.
525
538
  */
526
- export declare function init(config?: OverlayConfig): OverlayInstance;
539
+ export declare function init(config?: CaliperConfig): OverlayInstance;
527
540
 
528
541
  export declare type MeasurementLine = MeasurementLine_2;
529
542
 
@@ -729,18 +742,8 @@ export declare interface MeasurementSystem {
729
742
 
730
743
  export declare type MeasurementSystemListener = () => void;
731
744
 
732
- export declare interface OverlayConfig {
733
- /** Customize the visual appearance of the overlay (colors, shadows). */
734
- theme?: ThemeConfig;
735
- /** Customize keyboard shortcuts for all interactions. */
736
- commands?: CommandsConfig;
737
- /** Control the boundary box lerp animation behavior. */
738
- animation?: AnimationConfig;
739
- /** Configure the Agent Bridge for AI/MCP integration. */
740
- bridge?: AgentBridgeConfig;
741
- /** Enable debug logging (default: true). All logs are stripped from production builds. */
742
- debug?: boolean;
743
- }
745
+ /** @deprecated Use CaliperConfig instead */
746
+ export declare type OverlayConfig = CaliperConfig;
744
747
 
745
748
  /**
746
749
  * Handle to a running Caliper overlay.
@@ -948,7 +951,7 @@ export declare interface SelectionSystem {
948
951
  * });
949
952
  * ```
950
953
  */
951
- export declare function setConfig(config: OverlayConfig): void;
954
+ export declare function setConfig(config: CaliperConfig): void;
952
955
 
953
956
  export declare interface Systems {
954
957
  measurementSystem: MeasurementSystem;
package/dist/index.d.ts CHANGED
@@ -7,6 +7,8 @@ export declare interface AgentBridgeConfig {
7
7
  wsPort?: number;
8
8
  /** Callback for agent state changes */
9
9
  onStateChange?: (state: CaliperAgentState) => void;
10
+ /** Name of a global window function to call on state changes (IIFE/CDN-safe, JSON-serializable) */
11
+ onStateChangeGlobal?: string;
10
12
  }
11
13
 
12
14
  export declare interface AnimationConfig {
@@ -439,6 +441,17 @@ declare const CaliperAgentStateSchema: z.ZodObject<{
439
441
  lastUpdated: z.ZodNumber;
440
442
  }, z.core.$strip>;
441
443
 
444
+ export declare interface CaliperConfig {
445
+ /** Customize the visual appearance of the overlay (colors, shadows). */
446
+ theme?: ThemeConfig;
447
+ /** Customize keyboard shortcuts for all interactions. */
448
+ commands?: CommandsConfig;
449
+ /** Control the boundary box lerp animation behavior. */
450
+ animation?: AnimationConfig;
451
+ /** Enable debug logging (default: true). All logs are stripped from production builds. */
452
+ debug?: boolean;
453
+ }
454
+
442
455
  /**
443
456
  * A plugin allows extending Caliper's functionality by accessing the
444
457
  * OverlayInstance and internal systems.
@@ -491,9 +504,9 @@ export declare interface CommandsConfig {
491
504
  * 1. Global window object (`window.__CALIPER_CONFIG__`)
492
505
  * 2. `data-config` attribute on the script tag (useful for UMD/CDN usage)
493
506
  *
494
- * @returns The resolved OverlayConfig object.
507
+ * @returns The resolved CaliperConfig object.
495
508
  */
496
- export declare function getConfig(): OverlayConfig;
509
+ export declare function getConfig(): CaliperConfig;
497
510
 
498
511
  /**
499
512
  * Core factory function to create and mount the Caliper overlay.
@@ -523,7 +536,7 @@ export declare function getConfig(): OverlayConfig;
523
536
  * @param config - The initial configuration object to merge with global defaults.
524
537
  * @returns An OverlayInstance with mount, dispose, and plugin management capabilities.
525
538
  */
526
- export declare function init(config?: OverlayConfig): OverlayInstance;
539
+ export declare function init(config?: CaliperConfig): OverlayInstance;
527
540
 
528
541
  export declare type MeasurementLine = MeasurementLine_2;
529
542
 
@@ -729,18 +742,8 @@ export declare interface MeasurementSystem {
729
742
 
730
743
  export declare type MeasurementSystemListener = () => void;
731
744
 
732
- export declare interface OverlayConfig {
733
- /** Customize the visual appearance of the overlay (colors, shadows). */
734
- theme?: ThemeConfig;
735
- /** Customize keyboard shortcuts for all interactions. */
736
- commands?: CommandsConfig;
737
- /** Control the boundary box lerp animation behavior. */
738
- animation?: AnimationConfig;
739
- /** Configure the Agent Bridge for AI/MCP integration. */
740
- bridge?: AgentBridgeConfig;
741
- /** Enable debug logging (default: true). All logs are stripped from production builds. */
742
- debug?: boolean;
743
- }
745
+ /** @deprecated Use CaliperConfig instead */
746
+ export declare type OverlayConfig = CaliperConfig;
744
747
 
745
748
  /**
746
749
  * Handle to a running Caliper overlay.
@@ -948,7 +951,7 @@ export declare interface SelectionSystem {
948
951
  * });
949
952
  * ```
950
953
  */
951
- export declare function setConfig(config: OverlayConfig): void;
954
+ export declare function setConfig(config: CaliperConfig): void;
952
955
 
953
956
  export declare interface Systems {
954
957
  measurementSystem: MeasurementSystem;