@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.
@@ -3030,10 +3030,12 @@ var Logger = class {
3030
3030
  isGlobalEnabled = enabled;
3031
3031
  }
3032
3032
  debug(...args) {
3033
- return;
3033
+ if (!isGlobalEnabled) return;
3034
+ console.debug(this.prefix, ...args);
3034
3035
  }
3035
3036
  info(...args) {
3036
- return;
3037
+ if (!isGlobalEnabled) return;
3038
+ console.info(this.prefix, ...args);
3037
3039
  }
3038
3040
  warn(...args) {
3039
3041
  if (!isGlobalEnabled) return;
@@ -3044,7 +3046,8 @@ var Logger = class {
3044
3046
  console.error(this.prefix, ...args);
3045
3047
  }
3046
3048
  log(...args) {
3047
- return;
3049
+ if (!isGlobalEnabled) return;
3050
+ console.log(this.prefix, ...args);
3048
3051
  }
3049
3052
  };
3050
3053
  var logger = new Logger({ prefix: "Caliper" });
@@ -3433,11 +3436,11 @@ function MeasurementLinesWithCalculator(props) {
3433
3436
  };
3434
3437
  }
3435
3438
  if (line.type === "top" || line.type === "bottom") {
3436
- if (line.startSync === "primary") end.x = start.x;
3437
- else start.x = end.x;
3439
+ if (line.type === "top") start.x = end.x;
3440
+ else end.x = start.x;
3438
3441
  } else if (line.type === "left" || line.type === "right") {
3439
- if (line.startSync === "primary") end.y = start.y;
3440
- else start.y = end.y;
3442
+ if (line.type === "left") start.y = end.y;
3443
+ else end.y = start.y;
3441
3444
  }
3442
3445
  let liveValue = 0;
3443
3446
  if (line.type === "top" || line.type === "bottom") {
@@ -3535,11 +3538,11 @@ function MeasurementLabels(props) {
3535
3538
  };
3536
3539
  }
3537
3540
  if (line.type === "top" || line.type === "bottom") {
3538
- if (line.startSync === "primary") end.x = start.x;
3539
- else start.x = end.x;
3541
+ if (line.type === "top") start.x = end.x;
3542
+ else end.x = start.x;
3540
3543
  } else if (line.type === "left" || line.type === "right") {
3541
- if (line.startSync === "primary") end.y = start.y;
3542
- else start.y = end.y;
3544
+ if (line.type === "left") start.y = end.y;
3545
+ else end.y = start.y;
3543
3546
  }
3544
3547
  const naturalX = (start.x + end.x) / 2;
3545
3548
  const naturalY = (start.y + end.y) / 2;
@@ -5103,27 +5106,48 @@ function Root(config) {
5103
5106
  contextEvent.preventDefault();
5104
5107
  contextEvent.stopImmediatePropagation();
5105
5108
  let clipboardContent = "";
5106
- if (contextEvent.shiftKey && selectedElement) {
5107
- clipboardContent = selectedElement.getAttribute("data-caliper-agent-id") || "";
5108
- } else if (measurementResult && system && selectionSystem) {
5109
- const primaryElement = selectionSystem.getSelected();
5110
- const secondaryElement = system.getSecondaryElement();
5111
- if (primaryElement && secondaryElement) {
5112
- clipboardContent = JSON.stringify({
5113
- primary: buildSelectorInfo(primaryElement, selectionMetadata()),
5114
- secondary: buildSelectorInfo(secondaryElement, {
5115
- rect: measurementResult.secondary,
5116
- scrollHierarchy: measurementResult.secondaryHierarchy,
5117
- position: measurementResult.secondaryPosition,
5118
- stickyConfig: measurementResult.secondarySticky,
5119
- initialWindowX: measurementResult.secondaryWinX,
5120
- initialWindowY: measurementResult.secondaryWinY,
5121
- hasContainingBlock: measurementResult.secondaryHasContainingBlock
5122
- })
5123
- });
5109
+ if (contextEvent.shiftKey) {
5110
+ 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
+ });
5126
+ }
5127
+ } else if (selectedElement) {
5128
+ clipboardContent = JSON.stringify(buildSelectorInfo(selectedElement, selectionMetadata()));
5129
+ }
5130
+ } else {
5131
+ const ensureAgentId = (el) => {
5132
+ let id = el.getAttribute("data-caliper-agent-id");
5133
+ if (!id) {
5134
+ id = generateId("caliper");
5135
+ el.setAttribute("data-caliper-agent-id", id);
5136
+ }
5137
+ return id;
5138
+ };
5139
+ if (measurementResult && system && selectionSystem) {
5140
+ const primaryElement = selectionSystem.getSelected();
5141
+ const secondaryElement = system.getSecondaryElement();
5142
+ if (primaryElement && secondaryElement) {
5143
+ clipboardContent = JSON.stringify({
5144
+ primary: ensureAgentId(primaryElement),
5145
+ secondary: ensureAgentId(secondaryElement)
5146
+ });
5147
+ }
5148
+ } else if (selectedElement) {
5149
+ clipboardContent = ensureAgentId(selectedElement);
5124
5150
  }
5125
- } else if (selectedElement) {
5126
- clipboardContent = JSON.stringify(buildSelectorInfo(selectedElement, selectionMetadata()));
5127
5151
  }
5128
5152
  if (clipboardContent) {
5129
5153
  navigator.clipboard.writeText(clipboardContent).then(() => {
@@ -5886,11 +5910,11 @@ function createOverlay(config) {
5886
5910
  return instance;
5887
5911
  }
5888
5912
  if (IS_BROWSER2) {
5889
- showVersionInfo("0.2.1").catch(() => {
5913
+ showVersionInfo("0.2.2").catch(() => {
5890
5914
  });
5891
5915
  }
5892
5916
 
5893
5917
  // src/index.ts
5894
- var VERSION = "0.2.1";
5918
+ var VERSION = "0.2.2";
5895
5919
 
5896
5920
  export { VERSION, caliperProps, createOverlay, getConfig, setConfig };
package/dist/index.cjs CHANGED
@@ -1,26 +1,26 @@
1
1
  'use strict';
2
2
 
3
- var chunkP37B6G5P_cjs = require('./chunk-P37B6G5P.cjs');
3
+ var chunkAHX2GS7J_cjs = require('./chunk-AHX2GS7J.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "VERSION", {
8
8
  enumerable: true,
9
- get: function () { return chunkP37B6G5P_cjs.VERSION; }
9
+ get: function () { return chunkAHX2GS7J_cjs.VERSION; }
10
10
  });
11
11
  Object.defineProperty(exports, "caliperProps", {
12
12
  enumerable: true,
13
- get: function () { return chunkP37B6G5P_cjs.caliperProps; }
13
+ get: function () { return chunkAHX2GS7J_cjs.caliperProps; }
14
14
  });
15
15
  Object.defineProperty(exports, "getConfig", {
16
16
  enumerable: true,
17
- get: function () { return chunkP37B6G5P_cjs.getConfig; }
17
+ get: function () { return chunkAHX2GS7J_cjs.getConfig; }
18
18
  });
19
19
  Object.defineProperty(exports, "init", {
20
20
  enumerable: true,
21
- get: function () { return chunkP37B6G5P_cjs.createOverlay; }
21
+ get: function () { return chunkAHX2GS7J_cjs.createOverlay; }
22
22
  });
23
23
  Object.defineProperty(exports, "setConfig", {
24
24
  enumerable: true,
25
- get: function () { return chunkP37B6G5P_cjs.setConfig; }
25
+ get: function () { return chunkAHX2GS7J_cjs.setConfig; }
26
26
  });