@oyerinde/caliper 0.2.1 → 0.2.2

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,18 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.2.2] - 2026-03-05
6
+
7
+ ### Improved
8
+
9
+ - **Context Menu**: Swapped copy shortcuts. Right-click now copies the `data-caliper-agent-id`; `Shift + Right-Click` copies the full JSON fingerprint.
10
+
11
+ ### Fixed
12
+
13
+ - **Geometry Engine**: Fixed measurement breakout on sticky elements during scroll.
14
+ - **Logger**: Fixed `__DEV__` guard in production builds preventing `debug`, `info`, and `log` from appearing when enabled.
15
+ - **MCP Server**: Fixed `console.log` usage on startup to ensure `stdout` is reserved exclusively for the JSON-RPC protocol.
16
+
5
17
  ## [0.2.1] - 2026-02-16
6
18
 
7
19
  ### Refactored
@@ -15,7 +27,7 @@ All notable changes to this project will be documented in this file.
15
27
 
16
28
  ### Fixed
17
29
 
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.
30
+ - **Boundary Box Snapping**: Fixed boxes snapping to (0,0) by retaining last known position for detached or animating elements.
19
31
 
20
32
  ## [0.2.0] - 2026-02-12
21
33
 
package/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  <img src="https://raw.githubusercontent.com/oyerindedaniel/caliper/main/apps/web/public/caliper_logo.svg" width="144" alt="Caliper Logo" style="margin-bottom: 24px;" />
2
2
 
3
- [![Unpkg Bundle Size](https://img.shields.io/bundlephobia/minzip/@oyerinde/caliper?style=flat-square&color=black&labelColor=black)](https://bundlephobia.com/package/@oyerinde/caliper)
4
3
  [![NPM Version](https://img.shields.io/npm/v/@oyerinde/caliper?style=flat-square&color=black&labelColor=black)](https://www.npmjs.com/package/@oyerinde/caliper)
5
4
 
6
5
  **Essential tooling for detail-obsessed design engineers.**
@@ -320,9 +319,6 @@ For AI agents to reliably rediscover elements across re-renders (like HMR), we r
320
319
 
321
320
  This project is licensed under the **MIT License**.
322
321
 
323
- - **Allowed**: Personal and commercial use, modification, and distribution.
324
- - **Open**: Completely permissive with no restrictions on derivative works or competition.
325
-
326
322
  ---
327
323
 
328
324
  ## Author & Acknowledgement 👤
package/dist/bridge.cjs CHANGED
@@ -1,50 +1,50 @@
1
1
  'use strict';
2
2
 
3
- var chunkPYAVLOZM_cjs = require('./chunk-PYAVLOZM.cjs');
3
+ var chunk2SVFU7M3_cjs = require('./chunk-2SVFU7M3.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "CALIPER_METHODS", {
8
8
  enumerable: true,
9
- get: function () { return chunkPYAVLOZM_cjs.CALIPER_METHODS; }
9
+ get: function () { return chunk2SVFU7M3_cjs.CALIPER_METHODS; }
10
10
  });
11
11
  Object.defineProperty(exports, "CaliperActionResultSchema", {
12
12
  enumerable: true,
13
- get: function () { return chunkPYAVLOZM_cjs.CaliperActionResultSchema; }
13
+ get: function () { return chunk2SVFU7M3_cjs.CaliperActionResultSchema; }
14
14
  });
15
15
  Object.defineProperty(exports, "CaliperAgentStateSchema", {
16
16
  enumerable: true,
17
- get: function () { return chunkPYAVLOZM_cjs.CaliperAgentStateSchema; }
17
+ get: function () { return chunk2SVFU7M3_cjs.CaliperAgentStateSchema; }
18
18
  });
19
19
  Object.defineProperty(exports, "CaliperBridge", {
20
20
  enumerable: true,
21
- get: function () { return chunkPYAVLOZM_cjs.CaliperBridge; }
21
+ get: function () { return chunk2SVFU7M3_cjs.CaliperBridge; }
22
22
  });
23
23
  Object.defineProperty(exports, "CaliperGetContextPayloadSchema", {
24
24
  enumerable: true,
25
- get: function () { return chunkPYAVLOZM_cjs.CaliperGetContextPayloadSchema; }
25
+ get: function () { return chunk2SVFU7M3_cjs.CaliperGetContextPayloadSchema; }
26
26
  });
27
27
  Object.defineProperty(exports, "CaliperInspectPayloadSchema", {
28
28
  enumerable: true,
29
- get: function () { return chunkPYAVLOZM_cjs.CaliperInspectPayloadSchema; }
29
+ get: function () { return chunk2SVFU7M3_cjs.CaliperInspectPayloadSchema; }
30
30
  });
31
31
  Object.defineProperty(exports, "CaliperMeasurePayloadSchema", {
32
32
  enumerable: true,
33
- get: function () { return chunkPYAVLOZM_cjs.CaliperMeasurePayloadSchema; }
33
+ get: function () { return chunk2SVFU7M3_cjs.CaliperMeasurePayloadSchema; }
34
34
  });
35
35
  Object.defineProperty(exports, "CaliperSelectPayloadSchema", {
36
36
  enumerable: true,
37
- get: function () { return chunkPYAVLOZM_cjs.CaliperSelectPayloadSchema; }
37
+ get: function () { return chunk2SVFU7M3_cjs.CaliperSelectPayloadSchema; }
38
38
  });
39
39
  Object.defineProperty(exports, "CaliperWalkAndMeasurePayloadSchema", {
40
40
  enumerable: true,
41
- get: function () { return chunkPYAVLOZM_cjs.CaliperWalkAndMeasurePayloadSchema; }
41
+ get: function () { return chunk2SVFU7M3_cjs.CaliperWalkAndMeasurePayloadSchema; }
42
42
  });
43
43
  Object.defineProperty(exports, "CaliperWalkDomPayloadSchema", {
44
44
  enumerable: true,
45
- get: function () { return chunkPYAVLOZM_cjs.CaliperWalkDomPayloadSchema; }
45
+ get: function () { return chunk2SVFU7M3_cjs.CaliperWalkDomPayloadSchema; }
46
46
  });
47
47
  Object.defineProperty(exports, "dispatchCaliperIntent", {
48
48
  enumerable: true,
49
- get: function () { return chunkPYAVLOZM_cjs.dispatchCaliperIntent; }
49
+ get: function () { return chunk2SVFU7M3_cjs.dispatchCaliperIntent; }
50
50
  });
package/dist/bridge.d.cts CHANGED
@@ -884,7 +884,7 @@ export declare const CaliperAgentStateSchema: z.ZodObject<{
884
884
  * When installed, this plugin:
885
885
  * 1. Starts a local WebSocket server (or connects to one) to receive agent commands.
886
886
  * 2. Exposes `window.dispatchCaliperIntent` for manual/in-page agentic calls.
887
- * 3. Syncs the overlay state (camera, selection, measurements) back to the agent.
887
+ * 3. Syncs the overlay state (selection, measurements) back to the agent.
888
888
  *
889
889
  * @example
890
890
  * ```ts
package/dist/bridge.d.ts CHANGED
@@ -884,7 +884,7 @@ export declare const CaliperAgentStateSchema: z.ZodObject<{
884
884
  * When installed, this plugin:
885
885
  * 1. Starts a local WebSocket server (or connects to one) to receive agent commands.
886
886
  * 2. Exposes `window.dispatchCaliperIntent` for manual/in-page agentic calls.
887
- * 3. Syncs the overlay state (camera, selection, measurements) back to the agent.
887
+ * 3. Syncs the overlay state (selection, measurements) back to the agent.
888
888
  *
889
889
  * @example
890
890
  * ```ts
package/dist/bridge.js CHANGED
@@ -1 +1 @@
1
- export { CALIPER_METHODS, CaliperActionResultSchema, CaliperAgentStateSchema, CaliperBridge, CaliperGetContextPayloadSchema, CaliperInspectPayloadSchema, CaliperMeasurePayloadSchema, CaliperSelectPayloadSchema, CaliperWalkAndMeasurePayloadSchema, CaliperWalkDomPayloadSchema, dispatchCaliperIntent } from './chunk-L47FGEH6.js';
1
+ export { CALIPER_METHODS, CaliperActionResultSchema, CaliperAgentStateSchema, CaliperBridge, CaliperGetContextPayloadSchema, CaliperInspectPayloadSchema, CaliperMeasurePayloadSchema, CaliperSelectPayloadSchema, CaliperWalkAndMeasurePayloadSchema, CaliperWalkDomPayloadSchema, dispatchCaliperIntent } from './chunk-PRUCSUJA.js';
@@ -230,7 +230,6 @@ var WalkOptionsSchema = zod.z.object({
230
230
  minElementSize: zod.z.number().optional(),
231
231
  ignoreSelectors: zod.z.array(zod.z.string()).optional()
232
232
  });
233
- var JSONRPCResultResponseSchema = types_js.JSONRPCResultResponseSchema;
234
233
  var JSONRPCErrorResponseSchema = types_js.JSONRPCErrorResponseSchema;
235
234
  var ViewportSchema = zod.z.object({
236
235
  width: zod.z.number(),
@@ -290,8 +289,20 @@ var SourceHintsSchema = zod.z.object({
290
289
  tagName: zod.z.string()
291
290
  });
292
291
  var CaliperActionResultSchema = zod.z.union([
293
- zod.z.object({ success: zod.z.literal(true), method: zod.z.literal(CALIPER_METHODS.SELECT), selector: zod.z.string(), selection: SelectionMetadataSchema, timestamp: zod.z.number() }),
294
- zod.z.object({ success: zod.z.literal(true), method: zod.z.literal(CALIPER_METHODS.MEASURE), selector: zod.z.string(), measurement: MeasurementResultSchema, timestamp: zod.z.number() }),
292
+ zod.z.object({
293
+ success: zod.z.literal(true),
294
+ method: zod.z.literal(CALIPER_METHODS.SELECT),
295
+ selector: zod.z.string(),
296
+ selection: SelectionMetadataSchema,
297
+ timestamp: zod.z.number()
298
+ }),
299
+ zod.z.object({
300
+ success: zod.z.literal(true),
301
+ method: zod.z.literal(CALIPER_METHODS.MEASURE),
302
+ selector: zod.z.string(),
303
+ measurement: MeasurementResultSchema,
304
+ timestamp: zod.z.number()
305
+ }),
295
306
  zod.z.object({
296
307
  success: zod.z.literal(true),
297
308
  method: zod.z.literal(CALIPER_METHODS.INSPECT),
@@ -312,8 +323,16 @@ var CaliperActionResultSchema = zod.z.union([
312
323
  sourceHints: SourceHintsSchema.optional(),
313
324
  timestamp: zod.z.number()
314
325
  }),
315
- zod.z.object({ success: zod.z.literal(true), method: zod.z.literal(CALIPER_METHODS.FREEZE), timestamp: zod.z.number() }),
316
- zod.z.object({ success: zod.z.literal(true), method: zod.z.literal(CALIPER_METHODS.CLEAR), timestamp: zod.z.number() }),
326
+ zod.z.object({
327
+ success: zod.z.literal(true),
328
+ method: zod.z.literal(CALIPER_METHODS.FREEZE),
329
+ timestamp: zod.z.number()
330
+ }),
331
+ zod.z.object({
332
+ success: zod.z.literal(true),
333
+ method: zod.z.literal(CALIPER_METHODS.CLEAR),
334
+ timestamp: zod.z.number()
335
+ }),
317
336
  zod.z.object({
318
337
  success: zod.z.literal(true),
319
338
  method: zod.z.literal(CALIPER_METHODS.WALK_DOM),
@@ -400,11 +419,7 @@ var CaliperNotificationSchema = zod.z.union([
400
419
  params: CaliperAgentStateSchema
401
420
  })
402
421
  ]);
403
- zod.z.union([
404
- CaliperResponseSchema,
405
- CaliperNotificationSchema,
406
- JSONRPCResultResponseSchema
407
- ]);
422
+ zod.z.union([CaliperResponseSchema, CaliperNotificationSchema]);
408
423
  var CaliperSelectPayloadSchema = zod.z.object({
409
424
  selector: zod.z.string()
410
425
  });
@@ -1362,10 +1377,12 @@ var Logger = class {
1362
1377
  isGlobalEnabled = enabled;
1363
1378
  }
1364
1379
  debug(...args) {
1365
- return;
1380
+ if (!isGlobalEnabled) return;
1381
+ console.debug(this.prefix, ...args);
1366
1382
  }
1367
1383
  info(...args) {
1368
- return;
1384
+ if (!isGlobalEnabled) return;
1385
+ console.info(this.prefix, ...args);
1369
1386
  }
1370
1387
  warn(...args) {
1371
1388
  if (!isGlobalEnabled) return;
@@ -1376,7 +1393,8 @@ var Logger = class {
1376
1393
  console.error(this.prefix, ...args);
1377
1394
  }
1378
1395
  log(...args) {
1379
- return;
1396
+ if (!isGlobalEnabled) return;
1397
+ console.log(this.prefix, ...args);
1380
1398
  }
1381
1399
  };
1382
1400
  new Logger({ prefix: "Caliper" });
@@ -15074,7 +15092,7 @@ var JSONRPCNotificationSchema = object({
15074
15092
  jsonrpc: literal(JSONRPC_VERSION),
15075
15093
  ...NotificationSchema.shape
15076
15094
  }).strict();
15077
- var JSONRPCResultResponseSchema2 = object({
15095
+ var JSONRPCResultResponseSchema = object({
15078
15096
  jsonrpc: literal(JSONRPC_VERSION),
15079
15097
  id: RequestIdSchema,
15080
15098
  result: ResultSchema
@@ -15111,10 +15129,10 @@ var JSONRPCErrorResponseSchema2 = object({
15111
15129
  union([
15112
15130
  JSONRPCRequestSchema,
15113
15131
  JSONRPCNotificationSchema,
15114
- JSONRPCResultResponseSchema2,
15132
+ JSONRPCResultResponseSchema,
15115
15133
  JSONRPCErrorResponseSchema2
15116
15134
  ]);
15117
- union([JSONRPCResultResponseSchema2, JSONRPCErrorResponseSchema2]);
15135
+ union([JSONRPCResultResponseSchema, JSONRPCErrorResponseSchema2]);
15118
15136
  var EmptyResultSchema = ResultSchema.strict();
15119
15137
  var CancelledNotificationParamsSchema = NotificationsParamsSchema.extend({
15120
15138
  /**
@@ -16678,7 +16696,7 @@ var WalkOptionsSchema2 = external_exports.object({
16678
16696
  });
16679
16697
  var JSONRPCRequestSchema2 = JSONRPCRequestSchema;
16680
16698
  var JSONRPCNotificationSchema2 = JSONRPCNotificationSchema;
16681
- var JSONRPCResultResponseSchema22 = JSONRPCResultResponseSchema2;
16699
+ var JSONRPCResultResponseSchema2 = JSONRPCResultResponseSchema;
16682
16700
  var JSONRPCErrorResponseSchema22 = JSONRPCErrorResponseSchema2;
16683
16701
  var ViewportSchema2 = external_exports.object({
16684
16702
  width: external_exports.number(),
@@ -16738,8 +16756,20 @@ var SourceHintsSchema2 = external_exports.object({
16738
16756
  tagName: external_exports.string()
16739
16757
  });
16740
16758
  var CaliperActionResultSchema2 = external_exports.union([
16741
- external_exports.object({ success: external_exports.literal(true), method: external_exports.literal(CALIPER_METHODS2.SELECT), selector: external_exports.string(), selection: SelectionMetadataSchema2, timestamp: external_exports.number() }),
16742
- external_exports.object({ success: external_exports.literal(true), method: external_exports.literal(CALIPER_METHODS2.MEASURE), selector: external_exports.string(), measurement: MeasurementResultSchema2, timestamp: external_exports.number() }),
16759
+ external_exports.object({
16760
+ success: external_exports.literal(true),
16761
+ method: external_exports.literal(CALIPER_METHODS2.SELECT),
16762
+ selector: external_exports.string(),
16763
+ selection: SelectionMetadataSchema2,
16764
+ timestamp: external_exports.number()
16765
+ }),
16766
+ external_exports.object({
16767
+ success: external_exports.literal(true),
16768
+ method: external_exports.literal(CALIPER_METHODS2.MEASURE),
16769
+ selector: external_exports.string(),
16770
+ measurement: MeasurementResultSchema2,
16771
+ timestamp: external_exports.number()
16772
+ }),
16743
16773
  external_exports.object({
16744
16774
  success: external_exports.literal(true),
16745
16775
  method: external_exports.literal(CALIPER_METHODS2.INSPECT),
@@ -16760,8 +16790,16 @@ var CaliperActionResultSchema2 = external_exports.union([
16760
16790
  sourceHints: SourceHintsSchema2.optional(),
16761
16791
  timestamp: external_exports.number()
16762
16792
  }),
16763
- external_exports.object({ success: external_exports.literal(true), method: external_exports.literal(CALIPER_METHODS2.FREEZE), timestamp: external_exports.number() }),
16764
- external_exports.object({ success: external_exports.literal(true), method: external_exports.literal(CALIPER_METHODS2.CLEAR), timestamp: external_exports.number() }),
16793
+ external_exports.object({
16794
+ success: external_exports.literal(true),
16795
+ method: external_exports.literal(CALIPER_METHODS2.FREEZE),
16796
+ timestamp: external_exports.number()
16797
+ }),
16798
+ external_exports.object({
16799
+ success: external_exports.literal(true),
16800
+ method: external_exports.literal(CALIPER_METHODS2.CLEAR),
16801
+ timestamp: external_exports.number()
16802
+ }),
16765
16803
  external_exports.object({
16766
16804
  success: external_exports.literal(true),
16767
16805
  method: external_exports.literal(CALIPER_METHODS2.WALK_DOM),
@@ -16821,13 +16859,21 @@ var RpcFactory = class {
16821
16859
  return JSONRPCRequestSchema2.parse({ jsonrpc: "2.0", method, params, id });
16822
16860
  }
16823
16861
  static response(id, result) {
16824
- return JSONRPCResultResponseSchema22.parse({ jsonrpc: "2.0", id, result });
16862
+ return JSONRPCResultResponseSchema2.parse({ jsonrpc: "2.0", id, result });
16825
16863
  }
16826
16864
  static error(id, code, message, data) {
16827
- return JSONRPCErrorResponseSchema22.parse({ jsonrpc: "2.0", id, error: { code, message, data } });
16865
+ return JSONRPCErrorResponseSchema22.parse({
16866
+ jsonrpc: "2.0",
16867
+ id,
16868
+ error: { code, message, data }
16869
+ });
16828
16870
  }
16829
16871
  static notification(method, params) {
16830
- return JSONRPCNotificationSchema2.parse({ jsonrpc: "2.0", method, params });
16872
+ return JSONRPCNotificationSchema2.parse({
16873
+ jsonrpc: "2.0",
16874
+ method,
16875
+ params
16876
+ });
16831
16877
  }
16832
16878
  };
16833
16879
  var CaliperResponseSchema2 = external_exports.union([
@@ -16862,11 +16908,7 @@ var CaliperNotificationSchema2 = external_exports.union([
16862
16908
  params: CaliperAgentStateSchema2
16863
16909
  })
16864
16910
  ]);
16865
- external_exports.union([
16866
- CaliperResponseSchema2,
16867
- CaliperNotificationSchema2,
16868
- JSONRPCResultResponseSchema22
16869
- ]);
16911
+ external_exports.union([CaliperResponseSchema2, CaliperNotificationSchema2]);
16870
16912
  external_exports.object({
16871
16913
  selector: external_exports.string()
16872
16914
  });
@@ -3032,10 +3032,12 @@ var Logger = class {
3032
3032
  isGlobalEnabled = enabled;
3033
3033
  }
3034
3034
  debug(...args) {
3035
- return;
3035
+ if (!isGlobalEnabled) return;
3036
+ console.debug(this.prefix, ...args);
3036
3037
  }
3037
3038
  info(...args) {
3038
- return;
3039
+ if (!isGlobalEnabled) return;
3040
+ console.info(this.prefix, ...args);
3039
3041
  }
3040
3042
  warn(...args) {
3041
3043
  if (!isGlobalEnabled) return;
@@ -3046,7 +3048,8 @@ var Logger = class {
3046
3048
  console.error(this.prefix, ...args);
3047
3049
  }
3048
3050
  log(...args) {
3049
- return;
3051
+ if (!isGlobalEnabled) return;
3052
+ console.log(this.prefix, ...args);
3050
3053
  }
3051
3054
  };
3052
3055
  var logger = new Logger({ prefix: "Caliper" });
@@ -3435,11 +3438,11 @@ function MeasurementLinesWithCalculator(props) {
3435
3438
  };
3436
3439
  }
3437
3440
  if (line.type === "top" || line.type === "bottom") {
3438
- if (line.startSync === "primary") end.x = start.x;
3439
- else start.x = end.x;
3441
+ if (line.type === "top") start.x = end.x;
3442
+ else end.x = start.x;
3440
3443
  } else if (line.type === "left" || line.type === "right") {
3441
- if (line.startSync === "primary") end.y = start.y;
3442
- else start.y = end.y;
3444
+ if (line.type === "left") start.y = end.y;
3445
+ else end.y = start.y;
3443
3446
  }
3444
3447
  let liveValue = 0;
3445
3448
  if (line.type === "top" || line.type === "bottom") {
@@ -3537,11 +3540,11 @@ function MeasurementLabels(props) {
3537
3540
  };
3538
3541
  }
3539
3542
  if (line.type === "top" || line.type === "bottom") {
3540
- if (line.startSync === "primary") end.x = start.x;
3541
- else start.x = end.x;
3543
+ if (line.type === "top") start.x = end.x;
3544
+ else end.x = start.x;
3542
3545
  } else if (line.type === "left" || line.type === "right") {
3543
- if (line.startSync === "primary") end.y = start.y;
3544
- else start.y = end.y;
3546
+ if (line.type === "left") start.y = end.y;
3547
+ else end.y = start.y;
3545
3548
  }
3546
3549
  const naturalX = (start.x + end.x) / 2;
3547
3550
  const naturalY = (start.y + end.y) / 2;
@@ -5105,27 +5108,48 @@ function Root(config) {
5105
5108
  contextEvent.preventDefault();
5106
5109
  contextEvent.stopImmediatePropagation();
5107
5110
  let clipboardContent = "";
5108
- if (contextEvent.shiftKey && selectedElement) {
5109
- clipboardContent = selectedElement.getAttribute("data-caliper-agent-id") || "";
5110
- } else if (measurementResult && system && selectionSystem) {
5111
- const primaryElement = selectionSystem.getSelected();
5112
- const secondaryElement = system.getSecondaryElement();
5113
- if (primaryElement && secondaryElement) {
5114
- clipboardContent = JSON.stringify({
5115
- primary: buildSelectorInfo(primaryElement, selectionMetadata()),
5116
- secondary: buildSelectorInfo(secondaryElement, {
5117
- rect: measurementResult.secondary,
5118
- scrollHierarchy: measurementResult.secondaryHierarchy,
5119
- position: measurementResult.secondaryPosition,
5120
- stickyConfig: measurementResult.secondarySticky,
5121
- initialWindowX: measurementResult.secondaryWinX,
5122
- initialWindowY: measurementResult.secondaryWinY,
5123
- hasContainingBlock: measurementResult.secondaryHasContainingBlock
5124
- })
5125
- });
5111
+ if (contextEvent.shiftKey) {
5112
+ if (measurementResult && system && selectionSystem) {
5113
+ const primaryElement = selectionSystem.getSelected();
5114
+ const secondaryElement = system.getSecondaryElement();
5115
+ if (primaryElement && secondaryElement) {
5116
+ clipboardContent = JSON.stringify({
5117
+ primary: buildSelectorInfo(primaryElement, selectionMetadata()),
5118
+ secondary: buildSelectorInfo(secondaryElement, {
5119
+ rect: measurementResult.secondary,
5120
+ scrollHierarchy: measurementResult.secondaryHierarchy,
5121
+ position: measurementResult.secondaryPosition,
5122
+ stickyConfig: measurementResult.secondarySticky,
5123
+ initialWindowX: measurementResult.secondaryWinX,
5124
+ initialWindowY: measurementResult.secondaryWinY,
5125
+ hasContainingBlock: measurementResult.secondaryHasContainingBlock
5126
+ })
5127
+ });
5128
+ }
5129
+ } else if (selectedElement) {
5130
+ clipboardContent = JSON.stringify(buildSelectorInfo(selectedElement, selectionMetadata()));
5131
+ }
5132
+ } else {
5133
+ const ensureAgentId = (el) => {
5134
+ let id = el.getAttribute("data-caliper-agent-id");
5135
+ if (!id) {
5136
+ id = generateId("caliper");
5137
+ el.setAttribute("data-caliper-agent-id", id);
5138
+ }
5139
+ return id;
5140
+ };
5141
+ if (measurementResult && system && selectionSystem) {
5142
+ const primaryElement = selectionSystem.getSelected();
5143
+ const secondaryElement = system.getSecondaryElement();
5144
+ if (primaryElement && secondaryElement) {
5145
+ clipboardContent = JSON.stringify({
5146
+ primary: ensureAgentId(primaryElement),
5147
+ secondary: ensureAgentId(secondaryElement)
5148
+ });
5149
+ }
5150
+ } else if (selectedElement) {
5151
+ clipboardContent = ensureAgentId(selectedElement);
5126
5152
  }
5127
- } else if (selectedElement) {
5128
- clipboardContent = JSON.stringify(buildSelectorInfo(selectedElement, selectionMetadata()));
5129
5153
  }
5130
5154
  if (clipboardContent) {
5131
5155
  navigator.clipboard.writeText(clipboardContent).then(() => {
@@ -5888,12 +5912,12 @@ function createOverlay(config) {
5888
5912
  return instance;
5889
5913
  }
5890
5914
  if (IS_BROWSER2) {
5891
- showVersionInfo("0.2.1").catch(() => {
5915
+ showVersionInfo("0.2.2").catch(() => {
5892
5916
  });
5893
5917
  }
5894
5918
 
5895
5919
  // src/index.ts
5896
- var VERSION = "0.2.1";
5920
+ var VERSION = "0.2.2";
5897
5921
 
5898
5922
  exports.VERSION = VERSION;
5899
5923
  exports.caliperProps = caliperProps;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { JSONRPCErrorResponseSchema as JSONRPCErrorResponseSchema$1, JSONRPCResultResponseSchema as JSONRPCResultResponseSchema$1 } from '@modelcontextprotocol/sdk/types.js';
2
+ import { JSONRPCErrorResponseSchema as JSONRPCErrorResponseSchema$1 } from '@modelcontextprotocol/sdk/types.js';
3
3
 
4
4
  /**
5
5
  * @name @oyerinde/caliper
@@ -228,7 +228,6 @@ var WalkOptionsSchema = z.object({
228
228
  minElementSize: z.number().optional(),
229
229
  ignoreSelectors: z.array(z.string()).optional()
230
230
  });
231
- var JSONRPCResultResponseSchema = JSONRPCResultResponseSchema$1;
232
231
  var JSONRPCErrorResponseSchema = JSONRPCErrorResponseSchema$1;
233
232
  var ViewportSchema = z.object({
234
233
  width: z.number(),
@@ -288,8 +287,20 @@ var SourceHintsSchema = z.object({
288
287
  tagName: z.string()
289
288
  });
290
289
  var CaliperActionResultSchema = z.union([
291
- z.object({ success: z.literal(true), method: z.literal(CALIPER_METHODS.SELECT), selector: z.string(), selection: SelectionMetadataSchema, timestamp: z.number() }),
292
- z.object({ success: z.literal(true), method: z.literal(CALIPER_METHODS.MEASURE), selector: z.string(), measurement: MeasurementResultSchema, timestamp: z.number() }),
290
+ z.object({
291
+ success: z.literal(true),
292
+ method: z.literal(CALIPER_METHODS.SELECT),
293
+ selector: z.string(),
294
+ selection: SelectionMetadataSchema,
295
+ timestamp: z.number()
296
+ }),
297
+ z.object({
298
+ success: z.literal(true),
299
+ method: z.literal(CALIPER_METHODS.MEASURE),
300
+ selector: z.string(),
301
+ measurement: MeasurementResultSchema,
302
+ timestamp: z.number()
303
+ }),
293
304
  z.object({
294
305
  success: z.literal(true),
295
306
  method: z.literal(CALIPER_METHODS.INSPECT),
@@ -310,8 +321,16 @@ var CaliperActionResultSchema = z.union([
310
321
  sourceHints: SourceHintsSchema.optional(),
311
322
  timestamp: z.number()
312
323
  }),
313
- z.object({ success: z.literal(true), method: z.literal(CALIPER_METHODS.FREEZE), timestamp: z.number() }),
314
- z.object({ success: z.literal(true), method: z.literal(CALIPER_METHODS.CLEAR), timestamp: z.number() }),
324
+ z.object({
325
+ success: z.literal(true),
326
+ method: z.literal(CALIPER_METHODS.FREEZE),
327
+ timestamp: z.number()
328
+ }),
329
+ z.object({
330
+ success: z.literal(true),
331
+ method: z.literal(CALIPER_METHODS.CLEAR),
332
+ timestamp: z.number()
333
+ }),
315
334
  z.object({
316
335
  success: z.literal(true),
317
336
  method: z.literal(CALIPER_METHODS.WALK_DOM),
@@ -398,11 +417,7 @@ var CaliperNotificationSchema = z.union([
398
417
  params: CaliperAgentStateSchema
399
418
  })
400
419
  ]);
401
- z.union([
402
- CaliperResponseSchema,
403
- CaliperNotificationSchema,
404
- JSONRPCResultResponseSchema
405
- ]);
420
+ z.union([CaliperResponseSchema, CaliperNotificationSchema]);
406
421
  var CaliperSelectPayloadSchema = z.object({
407
422
  selector: z.string()
408
423
  });
@@ -1360,10 +1375,12 @@ var Logger = class {
1360
1375
  isGlobalEnabled = enabled;
1361
1376
  }
1362
1377
  debug(...args) {
1363
- return;
1378
+ if (!isGlobalEnabled) return;
1379
+ console.debug(this.prefix, ...args);
1364
1380
  }
1365
1381
  info(...args) {
1366
- return;
1382
+ if (!isGlobalEnabled) return;
1383
+ console.info(this.prefix, ...args);
1367
1384
  }
1368
1385
  warn(...args) {
1369
1386
  if (!isGlobalEnabled) return;
@@ -1374,7 +1391,8 @@ var Logger = class {
1374
1391
  console.error(this.prefix, ...args);
1375
1392
  }
1376
1393
  log(...args) {
1377
- return;
1394
+ if (!isGlobalEnabled) return;
1395
+ console.log(this.prefix, ...args);
1378
1396
  }
1379
1397
  };
1380
1398
  new Logger({ prefix: "Caliper" });
@@ -15072,7 +15090,7 @@ var JSONRPCNotificationSchema = object({
15072
15090
  jsonrpc: literal(JSONRPC_VERSION),
15073
15091
  ...NotificationSchema.shape
15074
15092
  }).strict();
15075
- var JSONRPCResultResponseSchema2 = object({
15093
+ var JSONRPCResultResponseSchema = object({
15076
15094
  jsonrpc: literal(JSONRPC_VERSION),
15077
15095
  id: RequestIdSchema,
15078
15096
  result: ResultSchema
@@ -15109,10 +15127,10 @@ var JSONRPCErrorResponseSchema2 = object({
15109
15127
  union([
15110
15128
  JSONRPCRequestSchema,
15111
15129
  JSONRPCNotificationSchema,
15112
- JSONRPCResultResponseSchema2,
15130
+ JSONRPCResultResponseSchema,
15113
15131
  JSONRPCErrorResponseSchema2
15114
15132
  ]);
15115
- union([JSONRPCResultResponseSchema2, JSONRPCErrorResponseSchema2]);
15133
+ union([JSONRPCResultResponseSchema, JSONRPCErrorResponseSchema2]);
15116
15134
  var EmptyResultSchema = ResultSchema.strict();
15117
15135
  var CancelledNotificationParamsSchema = NotificationsParamsSchema.extend({
15118
15136
  /**
@@ -16676,7 +16694,7 @@ var WalkOptionsSchema2 = external_exports.object({
16676
16694
  });
16677
16695
  var JSONRPCRequestSchema2 = JSONRPCRequestSchema;
16678
16696
  var JSONRPCNotificationSchema2 = JSONRPCNotificationSchema;
16679
- var JSONRPCResultResponseSchema22 = JSONRPCResultResponseSchema2;
16697
+ var JSONRPCResultResponseSchema2 = JSONRPCResultResponseSchema;
16680
16698
  var JSONRPCErrorResponseSchema22 = JSONRPCErrorResponseSchema2;
16681
16699
  var ViewportSchema2 = external_exports.object({
16682
16700
  width: external_exports.number(),
@@ -16736,8 +16754,20 @@ var SourceHintsSchema2 = external_exports.object({
16736
16754
  tagName: external_exports.string()
16737
16755
  });
16738
16756
  var CaliperActionResultSchema2 = external_exports.union([
16739
- external_exports.object({ success: external_exports.literal(true), method: external_exports.literal(CALIPER_METHODS2.SELECT), selector: external_exports.string(), selection: SelectionMetadataSchema2, timestamp: external_exports.number() }),
16740
- external_exports.object({ success: external_exports.literal(true), method: external_exports.literal(CALIPER_METHODS2.MEASURE), selector: external_exports.string(), measurement: MeasurementResultSchema2, timestamp: external_exports.number() }),
16757
+ external_exports.object({
16758
+ success: external_exports.literal(true),
16759
+ method: external_exports.literal(CALIPER_METHODS2.SELECT),
16760
+ selector: external_exports.string(),
16761
+ selection: SelectionMetadataSchema2,
16762
+ timestamp: external_exports.number()
16763
+ }),
16764
+ external_exports.object({
16765
+ success: external_exports.literal(true),
16766
+ method: external_exports.literal(CALIPER_METHODS2.MEASURE),
16767
+ selector: external_exports.string(),
16768
+ measurement: MeasurementResultSchema2,
16769
+ timestamp: external_exports.number()
16770
+ }),
16741
16771
  external_exports.object({
16742
16772
  success: external_exports.literal(true),
16743
16773
  method: external_exports.literal(CALIPER_METHODS2.INSPECT),
@@ -16758,8 +16788,16 @@ var CaliperActionResultSchema2 = external_exports.union([
16758
16788
  sourceHints: SourceHintsSchema2.optional(),
16759
16789
  timestamp: external_exports.number()
16760
16790
  }),
16761
- external_exports.object({ success: external_exports.literal(true), method: external_exports.literal(CALIPER_METHODS2.FREEZE), timestamp: external_exports.number() }),
16762
- external_exports.object({ success: external_exports.literal(true), method: external_exports.literal(CALIPER_METHODS2.CLEAR), timestamp: external_exports.number() }),
16791
+ external_exports.object({
16792
+ success: external_exports.literal(true),
16793
+ method: external_exports.literal(CALIPER_METHODS2.FREEZE),
16794
+ timestamp: external_exports.number()
16795
+ }),
16796
+ external_exports.object({
16797
+ success: external_exports.literal(true),
16798
+ method: external_exports.literal(CALIPER_METHODS2.CLEAR),
16799
+ timestamp: external_exports.number()
16800
+ }),
16763
16801
  external_exports.object({
16764
16802
  success: external_exports.literal(true),
16765
16803
  method: external_exports.literal(CALIPER_METHODS2.WALK_DOM),
@@ -16819,13 +16857,21 @@ var RpcFactory = class {
16819
16857
  return JSONRPCRequestSchema2.parse({ jsonrpc: "2.0", method, params, id });
16820
16858
  }
16821
16859
  static response(id, result) {
16822
- return JSONRPCResultResponseSchema22.parse({ jsonrpc: "2.0", id, result });
16860
+ return JSONRPCResultResponseSchema2.parse({ jsonrpc: "2.0", id, result });
16823
16861
  }
16824
16862
  static error(id, code, message, data) {
16825
- return JSONRPCErrorResponseSchema22.parse({ jsonrpc: "2.0", id, error: { code, message, data } });
16863
+ return JSONRPCErrorResponseSchema22.parse({
16864
+ jsonrpc: "2.0",
16865
+ id,
16866
+ error: { code, message, data }
16867
+ });
16826
16868
  }
16827
16869
  static notification(method, params) {
16828
- return JSONRPCNotificationSchema2.parse({ jsonrpc: "2.0", method, params });
16870
+ return JSONRPCNotificationSchema2.parse({
16871
+ jsonrpc: "2.0",
16872
+ method,
16873
+ params
16874
+ });
16829
16875
  }
16830
16876
  };
16831
16877
  var CaliperResponseSchema2 = external_exports.union([
@@ -16860,11 +16906,7 @@ var CaliperNotificationSchema2 = external_exports.union([
16860
16906
  params: CaliperAgentStateSchema2
16861
16907
  })
16862
16908
  ]);
16863
- external_exports.union([
16864
- CaliperResponseSchema2,
16865
- CaliperNotificationSchema2,
16866
- JSONRPCResultResponseSchema22
16867
- ]);
16909
+ external_exports.union([CaliperResponseSchema2, CaliperNotificationSchema2]);
16868
16910
  external_exports.object({
16869
16911
  selector: external_exports.string()
16870
16912
  });