@oyerinde/caliper 0.1.3 → 0.1.4
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 +10 -0
- package/dist/index.cjs +33 -33
- package/dist/index.global.js +32 -32
- package/dist/index.js +33 -33
- package/dist/version.json +2 -2
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.1.4] - 2026-01-16
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Fixed selection triggering underlying element click events (buttons, links, etc.).
|
|
10
|
+
|
|
11
|
+
### Removed
|
|
12
|
+
|
|
13
|
+
- Removed double-click to remove rulers (use Delete/Backspace instead).
|
|
14
|
+
|
|
5
15
|
## [0.1.3] - 2026-01-13
|
|
6
16
|
|
|
7
17
|
### Improved
|
package/dist/index.cjs
CHANGED
|
@@ -2151,7 +2151,7 @@ function createProjectionSystem() {
|
|
|
2151
2151
|
};
|
|
2152
2152
|
const listeners = /* @__PURE__ */ new Set();
|
|
2153
2153
|
const notify = () => {
|
|
2154
|
-
listeners.forEach((
|
|
2154
|
+
listeners.forEach((listener) => listener({ ...state }));
|
|
2155
2155
|
};
|
|
2156
2156
|
return {
|
|
2157
2157
|
getState: () => ({ ...state }),
|
|
@@ -2210,7 +2210,7 @@ function createRulerSystem() {
|
|
|
2210
2210
|
};
|
|
2211
2211
|
const listeners = /* @__PURE__ */ new Set();
|
|
2212
2212
|
const notify = () => {
|
|
2213
|
-
listeners.forEach((
|
|
2213
|
+
listeners.forEach((listener) => listener({ lines: [...state.lines] }));
|
|
2214
2214
|
};
|
|
2215
2215
|
return {
|
|
2216
2216
|
getState: () => ({ lines: [...state.lines] }),
|
|
@@ -2231,14 +2231,14 @@ function createRulerSystem() {
|
|
|
2231
2231
|
return vLine.id;
|
|
2232
2232
|
},
|
|
2233
2233
|
updateLine: (id, position) => {
|
|
2234
|
-
const index = state.lines.findIndex((
|
|
2234
|
+
const index = state.lines.findIndex((line) => line.id === id);
|
|
2235
2235
|
if (index !== -1 && state.lines[index]) {
|
|
2236
2236
|
state.lines[index] = { ...state.lines[index], position };
|
|
2237
2237
|
notify();
|
|
2238
2238
|
}
|
|
2239
2239
|
},
|
|
2240
2240
|
removeLine: (id) => {
|
|
2241
|
-
state.lines = state.lines.filter((
|
|
2241
|
+
state.lines = state.lines.filter((line) => line.id !== id);
|
|
2242
2242
|
notify();
|
|
2243
2243
|
},
|
|
2244
2244
|
clear: () => {
|
|
@@ -3600,7 +3600,7 @@ function RulerOverlay(props) {
|
|
|
3600
3600
|
const currentIds = selectedIds();
|
|
3601
3601
|
const validIds = /* @__PURE__ */ new Set();
|
|
3602
3602
|
currentIds.forEach((id) => {
|
|
3603
|
-
if (lines.find((
|
|
3603
|
+
if (lines.find((line) => line.id === id)) {
|
|
3604
3604
|
validIds.add(id);
|
|
3605
3605
|
}
|
|
3606
3606
|
});
|
|
@@ -3623,7 +3623,7 @@ function RulerOverlay(props) {
|
|
|
3623
3623
|
updated = true;
|
|
3624
3624
|
}
|
|
3625
3625
|
});
|
|
3626
|
-
const lineIds = new Set(lines.map((
|
|
3626
|
+
const lineIds = new Set(lines.map((line) => line.id));
|
|
3627
3627
|
newOrigins.forEach((_, id) => {
|
|
3628
3628
|
if (!lineIds.has(id)) {
|
|
3629
3629
|
newOrigins.delete(id);
|
|
@@ -3708,7 +3708,7 @@ function RulerOverlay(props) {
|
|
|
3708
3708
|
return;
|
|
3709
3709
|
}
|
|
3710
3710
|
const lines = props.state().lines;
|
|
3711
|
-
const activeLines = lines.filter((
|
|
3711
|
+
const activeLines = lines.filter((line) => activeIds.has(line.id));
|
|
3712
3712
|
if (activeLines.length === 0) return;
|
|
3713
3713
|
let step = 1;
|
|
3714
3714
|
if (e.shiftKey) step = 10;
|
|
@@ -3777,7 +3777,7 @@ function RulerOverlay(props) {
|
|
|
3777
3777
|
setDraggingId(id);
|
|
3778
3778
|
target.setPointerCapture(e.pointerId);
|
|
3779
3779
|
const vp = props.viewport();
|
|
3780
|
-
const line = props.state().lines.find((
|
|
3780
|
+
const line = props.state().lines.find((line2) => line2.id === id);
|
|
3781
3781
|
if (line) {
|
|
3782
3782
|
const currentPos = getProportionalPosition(line);
|
|
3783
3783
|
setRulerOrigins((prev) => {
|
|
@@ -3820,18 +3820,6 @@ function RulerOverlay(props) {
|
|
|
3820
3820
|
window.addEventListener("pointermove", onPointerMove);
|
|
3821
3821
|
window.addEventListener("pointerup", onPointerUp);
|
|
3822
3822
|
};
|
|
3823
|
-
const handleDoubleClick = (e) => {
|
|
3824
|
-
const target = e.target;
|
|
3825
|
-
const id = target.getAttribute("data-ruler-id");
|
|
3826
|
-
if (id) {
|
|
3827
|
-
props.onRemove(id);
|
|
3828
|
-
setSelectedIds((prev) => {
|
|
3829
|
-
const next = new Set(prev);
|
|
3830
|
-
next.delete(id);
|
|
3831
|
-
return next;
|
|
3832
|
-
});
|
|
3833
|
-
}
|
|
3834
|
-
};
|
|
3835
3823
|
const handlePointerOver = (e) => {
|
|
3836
3824
|
const target = e.target;
|
|
3837
3825
|
const id = target.getAttribute("data-ruler-id");
|
|
@@ -3844,14 +3832,14 @@ function RulerOverlay(props) {
|
|
|
3844
3832
|
const bridges = createMemo(() => {
|
|
3845
3833
|
const ids = selectedIds();
|
|
3846
3834
|
if (ids.size < 2) return [];
|
|
3847
|
-
const lines = props.state().lines.filter((
|
|
3848
|
-
const vLinesWithPos = lines.filter((
|
|
3849
|
-
line
|
|
3850
|
-
pos: getProportionalPosition(
|
|
3835
|
+
const lines = props.state().lines.filter((line) => ids.has(line.id));
|
|
3836
|
+
const vLinesWithPos = lines.filter((line) => line.type === "vertical").map((line) => ({
|
|
3837
|
+
line,
|
|
3838
|
+
pos: getProportionalPosition(line)
|
|
3851
3839
|
})).sort((a, b) => a.pos - b.pos);
|
|
3852
|
-
const hLinesWithPos = lines.filter((
|
|
3853
|
-
line
|
|
3854
|
-
pos: getProportionalPosition(
|
|
3840
|
+
const hLinesWithPos = lines.filter((line) => line.type === "horizontal").map((line) => ({
|
|
3841
|
+
line,
|
|
3842
|
+
pos: getProportionalPosition(line)
|
|
3855
3843
|
})).sort((a, b) => a.pos - b.pos);
|
|
3856
3844
|
const result = [];
|
|
3857
3845
|
const vp = props.viewport();
|
|
@@ -3911,7 +3899,6 @@ function RulerOverlay(props) {
|
|
|
3911
3899
|
var _el$ = _tmpl$10(), _el$2 = _el$.firstChild;
|
|
3912
3900
|
_el$.$$pointerout = handlePointerOut;
|
|
3913
3901
|
_el$.$$pointerover = handlePointerOver;
|
|
3914
|
-
_el$.$$dblclick = handleDoubleClick;
|
|
3915
3902
|
_el$.$$pointerdown = handlePointerDown;
|
|
3916
3903
|
className(_el$, `${PREFIX}ruler-layer`);
|
|
3917
3904
|
setAttribute(_el$2, "class", `${PREFIX}viewport-fixed`);
|
|
@@ -4088,7 +4075,7 @@ function RulerLineItem(props) {
|
|
|
4088
4075
|
}
|
|
4089
4076
|
})];
|
|
4090
4077
|
}
|
|
4091
|
-
delegateEvents(["pointerdown", "
|
|
4078
|
+
delegateEvents(["pointerdown", "pointerover", "pointerout", "click"]);
|
|
4092
4079
|
var _tmpl$11 = /* @__PURE__ */ template(`<div>`);
|
|
4093
4080
|
function Overlay(props) {
|
|
4094
4081
|
const resultData = createMemo(() => {
|
|
@@ -4452,6 +4439,7 @@ function Root(config) {
|
|
|
4452
4439
|
};
|
|
4453
4440
|
if (isCommandActive(e)) {
|
|
4454
4441
|
e.preventDefault();
|
|
4442
|
+
e.stopImmediatePropagation();
|
|
4455
4443
|
if (selectionTimeoutId) window.clearTimeout(selectionTimeoutId);
|
|
4456
4444
|
selectionTimeoutId = window.setTimeout(() => {
|
|
4457
4445
|
performSelection(lastPointerPos.x, lastPointerPos.y);
|
|
@@ -4461,6 +4449,12 @@ function Root(config) {
|
|
|
4461
4449
|
if (selectionTimeoutId) window.clearTimeout(selectionTimeoutId);
|
|
4462
4450
|
}
|
|
4463
4451
|
};
|
|
4452
|
+
const handleClick = (e) => {
|
|
4453
|
+
if (isCommandActive(e)) {
|
|
4454
|
+
e.preventDefault();
|
|
4455
|
+
e.stopImmediatePropagation();
|
|
4456
|
+
}
|
|
4457
|
+
};
|
|
4464
4458
|
const handlePointerUp = (e) => {
|
|
4465
4459
|
if (selectionTimeoutId) {
|
|
4466
4460
|
window.clearTimeout(selectionTimeoutId);
|
|
@@ -4688,7 +4682,7 @@ function Root(config) {
|
|
|
4688
4682
|
const targetType = typeMap[key];
|
|
4689
4683
|
if (targetType) {
|
|
4690
4684
|
const currentLines = result()?.lines || [];
|
|
4691
|
-
const targetLine = currentLines.find((
|
|
4685
|
+
const targetLine = currentLines.find((line) => line.type === targetType);
|
|
4692
4686
|
if (targetLine) {
|
|
4693
4687
|
e.preventDefault();
|
|
4694
4688
|
e.stopImmediatePropagation();
|
|
@@ -4732,6 +4726,9 @@ function Root(config) {
|
|
|
4732
4726
|
window.addEventListener("pointerup", handlePointerUp, {
|
|
4733
4727
|
capture: true
|
|
4734
4728
|
});
|
|
4729
|
+
window.addEventListener("click", handleClick, {
|
|
4730
|
+
capture: true
|
|
4731
|
+
});
|
|
4735
4732
|
window.addEventListener("mousemove", handleMouseMove);
|
|
4736
4733
|
window.addEventListener("keydown", handleKeyDown, {
|
|
4737
4734
|
capture: true
|
|
@@ -4751,6 +4748,9 @@ function Root(config) {
|
|
|
4751
4748
|
window.removeEventListener("pointerup", handlePointerUp, {
|
|
4752
4749
|
capture: true
|
|
4753
4750
|
});
|
|
4751
|
+
window.removeEventListener("click", handleClick, {
|
|
4752
|
+
capture: true
|
|
4753
|
+
});
|
|
4754
4754
|
window.removeEventListener("mousemove", handleMouseMove);
|
|
4755
4755
|
window.removeEventListener("keydown", handleKeyDown, {
|
|
4756
4756
|
capture: true
|
|
@@ -4919,7 +4919,7 @@ function Root(config) {
|
|
|
4919
4919
|
const state = untrack(() => calculatorState());
|
|
4920
4920
|
if (state?.isActive) {
|
|
4921
4921
|
viewport().version;
|
|
4922
|
-
const matchingLine = currentResult.lines.find((
|
|
4922
|
+
const matchingLine = currentResult.lines.find((line) => line.type === calcLine.type);
|
|
4923
4923
|
if (matchingLine) {
|
|
4924
4924
|
const liveValue = getLiveLineValue(matchingLine, currentResult);
|
|
4925
4925
|
const calc = system.getCalculator();
|
|
@@ -5120,12 +5120,12 @@ function createOverlay(config) {
|
|
|
5120
5120
|
return instance;
|
|
5121
5121
|
}
|
|
5122
5122
|
if (IS_BROWSER2) {
|
|
5123
|
-
showVersionInfo("0.1.
|
|
5123
|
+
showVersionInfo("0.1.4").catch(() => {
|
|
5124
5124
|
});
|
|
5125
5125
|
}
|
|
5126
5126
|
|
|
5127
5127
|
// src/index.ts
|
|
5128
|
-
var VERSION = "0.1.
|
|
5128
|
+
var VERSION = "0.1.4";
|
|
5129
5129
|
|
|
5130
5130
|
exports.VERSION = VERSION;
|
|
5131
5131
|
exports.getConfig = getConfig;
|
package/dist/index.global.js
CHANGED
|
@@ -2152,7 +2152,7 @@
|
|
|
2152
2152
|
};
|
|
2153
2153
|
const listeners = /* @__PURE__ */ new Set();
|
|
2154
2154
|
const notify = () => {
|
|
2155
|
-
listeners.forEach((
|
|
2155
|
+
listeners.forEach((listener) => listener({ ...state }));
|
|
2156
2156
|
};
|
|
2157
2157
|
return {
|
|
2158
2158
|
getState: () => ({ ...state }),
|
|
@@ -2211,7 +2211,7 @@
|
|
|
2211
2211
|
};
|
|
2212
2212
|
const listeners = /* @__PURE__ */ new Set();
|
|
2213
2213
|
const notify = () => {
|
|
2214
|
-
listeners.forEach((
|
|
2214
|
+
listeners.forEach((listener) => listener({ lines: [...state.lines] }));
|
|
2215
2215
|
};
|
|
2216
2216
|
return {
|
|
2217
2217
|
getState: () => ({ lines: [...state.lines] }),
|
|
@@ -2232,14 +2232,14 @@
|
|
|
2232
2232
|
return vLine.id;
|
|
2233
2233
|
},
|
|
2234
2234
|
updateLine: (id, position) => {
|
|
2235
|
-
const index = state.lines.findIndex((
|
|
2235
|
+
const index = state.lines.findIndex((line) => line.id === id);
|
|
2236
2236
|
if (index !== -1 && state.lines[index]) {
|
|
2237
2237
|
state.lines[index] = { ...state.lines[index], position };
|
|
2238
2238
|
notify();
|
|
2239
2239
|
}
|
|
2240
2240
|
},
|
|
2241
2241
|
removeLine: (id) => {
|
|
2242
|
-
state.lines = state.lines.filter((
|
|
2242
|
+
state.lines = state.lines.filter((line) => line.id !== id);
|
|
2243
2243
|
notify();
|
|
2244
2244
|
},
|
|
2245
2245
|
clear: () => {
|
|
@@ -3596,7 +3596,7 @@
|
|
|
3596
3596
|
const currentIds = selectedIds();
|
|
3597
3597
|
const validIds = /* @__PURE__ */ new Set();
|
|
3598
3598
|
currentIds.forEach((id) => {
|
|
3599
|
-
if (lines.find((
|
|
3599
|
+
if (lines.find((line) => line.id === id)) {
|
|
3600
3600
|
validIds.add(id);
|
|
3601
3601
|
}
|
|
3602
3602
|
});
|
|
@@ -3619,7 +3619,7 @@
|
|
|
3619
3619
|
updated = true;
|
|
3620
3620
|
}
|
|
3621
3621
|
});
|
|
3622
|
-
const lineIds = new Set(lines.map((
|
|
3622
|
+
const lineIds = new Set(lines.map((line) => line.id));
|
|
3623
3623
|
newOrigins.forEach((_, id) => {
|
|
3624
3624
|
if (!lineIds.has(id)) {
|
|
3625
3625
|
newOrigins.delete(id);
|
|
@@ -3704,7 +3704,7 @@
|
|
|
3704
3704
|
return;
|
|
3705
3705
|
}
|
|
3706
3706
|
const lines = props.state().lines;
|
|
3707
|
-
const activeLines = lines.filter((
|
|
3707
|
+
const activeLines = lines.filter((line) => activeIds.has(line.id));
|
|
3708
3708
|
if (activeLines.length === 0) return;
|
|
3709
3709
|
let step = 1;
|
|
3710
3710
|
if (e.shiftKey) step = 10;
|
|
@@ -3773,7 +3773,7 @@
|
|
|
3773
3773
|
setDraggingId(id);
|
|
3774
3774
|
target.setPointerCapture(e.pointerId);
|
|
3775
3775
|
const vp = props.viewport();
|
|
3776
|
-
const line = props.state().lines.find((
|
|
3776
|
+
const line = props.state().lines.find((line2) => line2.id === id);
|
|
3777
3777
|
if (line) {
|
|
3778
3778
|
const currentPos = getProportionalPosition(line);
|
|
3779
3779
|
setRulerOrigins((prev) => {
|
|
@@ -3816,18 +3816,6 @@
|
|
|
3816
3816
|
window.addEventListener("pointermove", onPointerMove);
|
|
3817
3817
|
window.addEventListener("pointerup", onPointerUp);
|
|
3818
3818
|
};
|
|
3819
|
-
const handleDoubleClick = (e) => {
|
|
3820
|
-
const target = e.target;
|
|
3821
|
-
const id = target.getAttribute("data-ruler-id");
|
|
3822
|
-
if (id) {
|
|
3823
|
-
props.onRemove(id);
|
|
3824
|
-
setSelectedIds((prev) => {
|
|
3825
|
-
const next = new Set(prev);
|
|
3826
|
-
next.delete(id);
|
|
3827
|
-
return next;
|
|
3828
|
-
});
|
|
3829
|
-
}
|
|
3830
|
-
};
|
|
3831
3819
|
const handlePointerOver = (e) => {
|
|
3832
3820
|
const target = e.target;
|
|
3833
3821
|
const id = target.getAttribute("data-ruler-id");
|
|
@@ -3840,14 +3828,14 @@
|
|
|
3840
3828
|
const bridges = createMemo(() => {
|
|
3841
3829
|
const ids = selectedIds();
|
|
3842
3830
|
if (ids.size < 2) return [];
|
|
3843
|
-
const lines = props.state().lines.filter((
|
|
3844
|
-
const vLinesWithPos = lines.filter((
|
|
3845
|
-
line
|
|
3846
|
-
pos: getProportionalPosition(
|
|
3831
|
+
const lines = props.state().lines.filter((line) => ids.has(line.id));
|
|
3832
|
+
const vLinesWithPos = lines.filter((line) => line.type === "vertical").map((line) => ({
|
|
3833
|
+
line,
|
|
3834
|
+
pos: getProportionalPosition(line)
|
|
3847
3835
|
})).sort((a, b) => a.pos - b.pos);
|
|
3848
|
-
const hLinesWithPos = lines.filter((
|
|
3849
|
-
line
|
|
3850
|
-
pos: getProportionalPosition(
|
|
3836
|
+
const hLinesWithPos = lines.filter((line) => line.type === "horizontal").map((line) => ({
|
|
3837
|
+
line,
|
|
3838
|
+
pos: getProportionalPosition(line)
|
|
3851
3839
|
})).sort((a, b) => a.pos - b.pos);
|
|
3852
3840
|
const result = [];
|
|
3853
3841
|
const vp = props.viewport();
|
|
@@ -3907,7 +3895,6 @@
|
|
|
3907
3895
|
var _el$ = _tmpl$10(), _el$2 = _el$.firstChild;
|
|
3908
3896
|
_el$.$$pointerout = handlePointerOut;
|
|
3909
3897
|
_el$.$$pointerover = handlePointerOver;
|
|
3910
|
-
_el$.$$dblclick = handleDoubleClick;
|
|
3911
3898
|
_el$.$$pointerdown = handlePointerDown;
|
|
3912
3899
|
className(_el$, `${PREFIX}ruler-layer`);
|
|
3913
3900
|
setAttribute(_el$2, "class", `${PREFIX}viewport-fixed`);
|
|
@@ -4084,7 +4071,7 @@
|
|
|
4084
4071
|
}
|
|
4085
4072
|
})];
|
|
4086
4073
|
}
|
|
4087
|
-
delegateEvents(["pointerdown", "
|
|
4074
|
+
delegateEvents(["pointerdown", "pointerover", "pointerout", "click"]);
|
|
4088
4075
|
var _tmpl$11 = /* @__PURE__ */ template(`<div>`);
|
|
4089
4076
|
function Overlay(props) {
|
|
4090
4077
|
const resultData = createMemo(() => {
|
|
@@ -4448,6 +4435,7 @@
|
|
|
4448
4435
|
};
|
|
4449
4436
|
if (isCommandActive(e)) {
|
|
4450
4437
|
e.preventDefault();
|
|
4438
|
+
e.stopImmediatePropagation();
|
|
4451
4439
|
if (selectionTimeoutId) window.clearTimeout(selectionTimeoutId);
|
|
4452
4440
|
selectionTimeoutId = window.setTimeout(() => {
|
|
4453
4441
|
performSelection(lastPointerPos.x, lastPointerPos.y);
|
|
@@ -4457,6 +4445,12 @@
|
|
|
4457
4445
|
if (selectionTimeoutId) window.clearTimeout(selectionTimeoutId);
|
|
4458
4446
|
}
|
|
4459
4447
|
};
|
|
4448
|
+
const handleClick = (e) => {
|
|
4449
|
+
if (isCommandActive(e)) {
|
|
4450
|
+
e.preventDefault();
|
|
4451
|
+
e.stopImmediatePropagation();
|
|
4452
|
+
}
|
|
4453
|
+
};
|
|
4460
4454
|
const handlePointerUp = (e) => {
|
|
4461
4455
|
if (selectionTimeoutId) {
|
|
4462
4456
|
window.clearTimeout(selectionTimeoutId);
|
|
@@ -4684,7 +4678,7 @@
|
|
|
4684
4678
|
const targetType = typeMap[key];
|
|
4685
4679
|
if (targetType) {
|
|
4686
4680
|
const currentLines = result()?.lines || [];
|
|
4687
|
-
const targetLine = currentLines.find((
|
|
4681
|
+
const targetLine = currentLines.find((line) => line.type === targetType);
|
|
4688
4682
|
if (targetLine) {
|
|
4689
4683
|
e.preventDefault();
|
|
4690
4684
|
e.stopImmediatePropagation();
|
|
@@ -4728,6 +4722,9 @@
|
|
|
4728
4722
|
window.addEventListener("pointerup", handlePointerUp, {
|
|
4729
4723
|
capture: true
|
|
4730
4724
|
});
|
|
4725
|
+
window.addEventListener("click", handleClick, {
|
|
4726
|
+
capture: true
|
|
4727
|
+
});
|
|
4731
4728
|
window.addEventListener("mousemove", handleMouseMove);
|
|
4732
4729
|
window.addEventListener("keydown", handleKeyDown, {
|
|
4733
4730
|
capture: true
|
|
@@ -4747,6 +4744,9 @@
|
|
|
4747
4744
|
window.removeEventListener("pointerup", handlePointerUp, {
|
|
4748
4745
|
capture: true
|
|
4749
4746
|
});
|
|
4747
|
+
window.removeEventListener("click", handleClick, {
|
|
4748
|
+
capture: true
|
|
4749
|
+
});
|
|
4750
4750
|
window.removeEventListener("mousemove", handleMouseMove);
|
|
4751
4751
|
window.removeEventListener("keydown", handleKeyDown, {
|
|
4752
4752
|
capture: true
|
|
@@ -4915,7 +4915,7 @@
|
|
|
4915
4915
|
const state = untrack(() => calculatorState());
|
|
4916
4916
|
if (state?.isActive) {
|
|
4917
4917
|
viewport().version;
|
|
4918
|
-
const matchingLine = currentResult.lines.find((
|
|
4918
|
+
const matchingLine = currentResult.lines.find((line) => line.type === calcLine.type);
|
|
4919
4919
|
if (matchingLine) {
|
|
4920
4920
|
const liveValue = getLiveLineValue(matchingLine, currentResult);
|
|
4921
4921
|
const calc = system.getCalculator();
|
|
@@ -5116,7 +5116,7 @@
|
|
|
5116
5116
|
return instance;
|
|
5117
5117
|
}
|
|
5118
5118
|
if (IS_BROWSER2) {
|
|
5119
|
-
showVersionInfo("0.1.
|
|
5119
|
+
showVersionInfo("0.1.4").catch(() => {
|
|
5120
5120
|
});
|
|
5121
5121
|
}
|
|
5122
5122
|
|
package/dist/index.js
CHANGED
|
@@ -2149,7 +2149,7 @@ function createProjectionSystem() {
|
|
|
2149
2149
|
};
|
|
2150
2150
|
const listeners = /* @__PURE__ */ new Set();
|
|
2151
2151
|
const notify = () => {
|
|
2152
|
-
listeners.forEach((
|
|
2152
|
+
listeners.forEach((listener) => listener({ ...state }));
|
|
2153
2153
|
};
|
|
2154
2154
|
return {
|
|
2155
2155
|
getState: () => ({ ...state }),
|
|
@@ -2208,7 +2208,7 @@ function createRulerSystem() {
|
|
|
2208
2208
|
};
|
|
2209
2209
|
const listeners = /* @__PURE__ */ new Set();
|
|
2210
2210
|
const notify = () => {
|
|
2211
|
-
listeners.forEach((
|
|
2211
|
+
listeners.forEach((listener) => listener({ lines: [...state.lines] }));
|
|
2212
2212
|
};
|
|
2213
2213
|
return {
|
|
2214
2214
|
getState: () => ({ lines: [...state.lines] }),
|
|
@@ -2229,14 +2229,14 @@ function createRulerSystem() {
|
|
|
2229
2229
|
return vLine.id;
|
|
2230
2230
|
},
|
|
2231
2231
|
updateLine: (id, position) => {
|
|
2232
|
-
const index = state.lines.findIndex((
|
|
2232
|
+
const index = state.lines.findIndex((line) => line.id === id);
|
|
2233
2233
|
if (index !== -1 && state.lines[index]) {
|
|
2234
2234
|
state.lines[index] = { ...state.lines[index], position };
|
|
2235
2235
|
notify();
|
|
2236
2236
|
}
|
|
2237
2237
|
},
|
|
2238
2238
|
removeLine: (id) => {
|
|
2239
|
-
state.lines = state.lines.filter((
|
|
2239
|
+
state.lines = state.lines.filter((line) => line.id !== id);
|
|
2240
2240
|
notify();
|
|
2241
2241
|
},
|
|
2242
2242
|
clear: () => {
|
|
@@ -3598,7 +3598,7 @@ function RulerOverlay(props) {
|
|
|
3598
3598
|
const currentIds = selectedIds();
|
|
3599
3599
|
const validIds = /* @__PURE__ */ new Set();
|
|
3600
3600
|
currentIds.forEach((id) => {
|
|
3601
|
-
if (lines.find((
|
|
3601
|
+
if (lines.find((line) => line.id === id)) {
|
|
3602
3602
|
validIds.add(id);
|
|
3603
3603
|
}
|
|
3604
3604
|
});
|
|
@@ -3621,7 +3621,7 @@ function RulerOverlay(props) {
|
|
|
3621
3621
|
updated = true;
|
|
3622
3622
|
}
|
|
3623
3623
|
});
|
|
3624
|
-
const lineIds = new Set(lines.map((
|
|
3624
|
+
const lineIds = new Set(lines.map((line) => line.id));
|
|
3625
3625
|
newOrigins.forEach((_, id) => {
|
|
3626
3626
|
if (!lineIds.has(id)) {
|
|
3627
3627
|
newOrigins.delete(id);
|
|
@@ -3706,7 +3706,7 @@ function RulerOverlay(props) {
|
|
|
3706
3706
|
return;
|
|
3707
3707
|
}
|
|
3708
3708
|
const lines = props.state().lines;
|
|
3709
|
-
const activeLines = lines.filter((
|
|
3709
|
+
const activeLines = lines.filter((line) => activeIds.has(line.id));
|
|
3710
3710
|
if (activeLines.length === 0) return;
|
|
3711
3711
|
let step = 1;
|
|
3712
3712
|
if (e.shiftKey) step = 10;
|
|
@@ -3775,7 +3775,7 @@ function RulerOverlay(props) {
|
|
|
3775
3775
|
setDraggingId(id);
|
|
3776
3776
|
target.setPointerCapture(e.pointerId);
|
|
3777
3777
|
const vp = props.viewport();
|
|
3778
|
-
const line = props.state().lines.find((
|
|
3778
|
+
const line = props.state().lines.find((line2) => line2.id === id);
|
|
3779
3779
|
if (line) {
|
|
3780
3780
|
const currentPos = getProportionalPosition(line);
|
|
3781
3781
|
setRulerOrigins((prev) => {
|
|
@@ -3818,18 +3818,6 @@ function RulerOverlay(props) {
|
|
|
3818
3818
|
window.addEventListener("pointermove", onPointerMove);
|
|
3819
3819
|
window.addEventListener("pointerup", onPointerUp);
|
|
3820
3820
|
};
|
|
3821
|
-
const handleDoubleClick = (e) => {
|
|
3822
|
-
const target = e.target;
|
|
3823
|
-
const id = target.getAttribute("data-ruler-id");
|
|
3824
|
-
if (id) {
|
|
3825
|
-
props.onRemove(id);
|
|
3826
|
-
setSelectedIds((prev) => {
|
|
3827
|
-
const next = new Set(prev);
|
|
3828
|
-
next.delete(id);
|
|
3829
|
-
return next;
|
|
3830
|
-
});
|
|
3831
|
-
}
|
|
3832
|
-
};
|
|
3833
3821
|
const handlePointerOver = (e) => {
|
|
3834
3822
|
const target = e.target;
|
|
3835
3823
|
const id = target.getAttribute("data-ruler-id");
|
|
@@ -3842,14 +3830,14 @@ function RulerOverlay(props) {
|
|
|
3842
3830
|
const bridges = createMemo(() => {
|
|
3843
3831
|
const ids = selectedIds();
|
|
3844
3832
|
if (ids.size < 2) return [];
|
|
3845
|
-
const lines = props.state().lines.filter((
|
|
3846
|
-
const vLinesWithPos = lines.filter((
|
|
3847
|
-
line
|
|
3848
|
-
pos: getProportionalPosition(
|
|
3833
|
+
const lines = props.state().lines.filter((line) => ids.has(line.id));
|
|
3834
|
+
const vLinesWithPos = lines.filter((line) => line.type === "vertical").map((line) => ({
|
|
3835
|
+
line,
|
|
3836
|
+
pos: getProportionalPosition(line)
|
|
3849
3837
|
})).sort((a, b) => a.pos - b.pos);
|
|
3850
|
-
const hLinesWithPos = lines.filter((
|
|
3851
|
-
line
|
|
3852
|
-
pos: getProportionalPosition(
|
|
3838
|
+
const hLinesWithPos = lines.filter((line) => line.type === "horizontal").map((line) => ({
|
|
3839
|
+
line,
|
|
3840
|
+
pos: getProportionalPosition(line)
|
|
3853
3841
|
})).sort((a, b) => a.pos - b.pos);
|
|
3854
3842
|
const result = [];
|
|
3855
3843
|
const vp = props.viewport();
|
|
@@ -3909,7 +3897,6 @@ function RulerOverlay(props) {
|
|
|
3909
3897
|
var _el$ = _tmpl$10(), _el$2 = _el$.firstChild;
|
|
3910
3898
|
_el$.$$pointerout = handlePointerOut;
|
|
3911
3899
|
_el$.$$pointerover = handlePointerOver;
|
|
3912
|
-
_el$.$$dblclick = handleDoubleClick;
|
|
3913
3900
|
_el$.$$pointerdown = handlePointerDown;
|
|
3914
3901
|
className(_el$, `${PREFIX}ruler-layer`);
|
|
3915
3902
|
setAttribute(_el$2, "class", `${PREFIX}viewport-fixed`);
|
|
@@ -4086,7 +4073,7 @@ function RulerLineItem(props) {
|
|
|
4086
4073
|
}
|
|
4087
4074
|
})];
|
|
4088
4075
|
}
|
|
4089
|
-
delegateEvents(["pointerdown", "
|
|
4076
|
+
delegateEvents(["pointerdown", "pointerover", "pointerout", "click"]);
|
|
4090
4077
|
var _tmpl$11 = /* @__PURE__ */ template(`<div>`);
|
|
4091
4078
|
function Overlay(props) {
|
|
4092
4079
|
const resultData = createMemo(() => {
|
|
@@ -4450,6 +4437,7 @@ function Root(config) {
|
|
|
4450
4437
|
};
|
|
4451
4438
|
if (isCommandActive(e)) {
|
|
4452
4439
|
e.preventDefault();
|
|
4440
|
+
e.stopImmediatePropagation();
|
|
4453
4441
|
if (selectionTimeoutId) window.clearTimeout(selectionTimeoutId);
|
|
4454
4442
|
selectionTimeoutId = window.setTimeout(() => {
|
|
4455
4443
|
performSelection(lastPointerPos.x, lastPointerPos.y);
|
|
@@ -4459,6 +4447,12 @@ function Root(config) {
|
|
|
4459
4447
|
if (selectionTimeoutId) window.clearTimeout(selectionTimeoutId);
|
|
4460
4448
|
}
|
|
4461
4449
|
};
|
|
4450
|
+
const handleClick = (e) => {
|
|
4451
|
+
if (isCommandActive(e)) {
|
|
4452
|
+
e.preventDefault();
|
|
4453
|
+
e.stopImmediatePropagation();
|
|
4454
|
+
}
|
|
4455
|
+
};
|
|
4462
4456
|
const handlePointerUp = (e) => {
|
|
4463
4457
|
if (selectionTimeoutId) {
|
|
4464
4458
|
window.clearTimeout(selectionTimeoutId);
|
|
@@ -4686,7 +4680,7 @@ function Root(config) {
|
|
|
4686
4680
|
const targetType = typeMap[key];
|
|
4687
4681
|
if (targetType) {
|
|
4688
4682
|
const currentLines = result()?.lines || [];
|
|
4689
|
-
const targetLine = currentLines.find((
|
|
4683
|
+
const targetLine = currentLines.find((line) => line.type === targetType);
|
|
4690
4684
|
if (targetLine) {
|
|
4691
4685
|
e.preventDefault();
|
|
4692
4686
|
e.stopImmediatePropagation();
|
|
@@ -4730,6 +4724,9 @@ function Root(config) {
|
|
|
4730
4724
|
window.addEventListener("pointerup", handlePointerUp, {
|
|
4731
4725
|
capture: true
|
|
4732
4726
|
});
|
|
4727
|
+
window.addEventListener("click", handleClick, {
|
|
4728
|
+
capture: true
|
|
4729
|
+
});
|
|
4733
4730
|
window.addEventListener("mousemove", handleMouseMove);
|
|
4734
4731
|
window.addEventListener("keydown", handleKeyDown, {
|
|
4735
4732
|
capture: true
|
|
@@ -4749,6 +4746,9 @@ function Root(config) {
|
|
|
4749
4746
|
window.removeEventListener("pointerup", handlePointerUp, {
|
|
4750
4747
|
capture: true
|
|
4751
4748
|
});
|
|
4749
|
+
window.removeEventListener("click", handleClick, {
|
|
4750
|
+
capture: true
|
|
4751
|
+
});
|
|
4752
4752
|
window.removeEventListener("mousemove", handleMouseMove);
|
|
4753
4753
|
window.removeEventListener("keydown", handleKeyDown, {
|
|
4754
4754
|
capture: true
|
|
@@ -4917,7 +4917,7 @@ function Root(config) {
|
|
|
4917
4917
|
const state = untrack(() => calculatorState());
|
|
4918
4918
|
if (state?.isActive) {
|
|
4919
4919
|
viewport().version;
|
|
4920
|
-
const matchingLine = currentResult.lines.find((
|
|
4920
|
+
const matchingLine = currentResult.lines.find((line) => line.type === calcLine.type);
|
|
4921
4921
|
if (matchingLine) {
|
|
4922
4922
|
const liveValue = getLiveLineValue(matchingLine, currentResult);
|
|
4923
4923
|
const calc = system.getCalculator();
|
|
@@ -5118,11 +5118,11 @@ function createOverlay(config) {
|
|
|
5118
5118
|
return instance;
|
|
5119
5119
|
}
|
|
5120
5120
|
if (IS_BROWSER2) {
|
|
5121
|
-
showVersionInfo("0.1.
|
|
5121
|
+
showVersionInfo("0.1.4").catch(() => {
|
|
5122
5122
|
});
|
|
5123
5123
|
}
|
|
5124
5124
|
|
|
5125
5125
|
// src/index.ts
|
|
5126
|
-
var VERSION = "0.1.
|
|
5126
|
+
var VERSION = "0.1.4";
|
|
5127
5127
|
|
|
5128
5128
|
export { VERSION, getConfig, createOverlay as init, setConfig };
|
package/dist/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oyerinde/caliper",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "High-precision browser measurements, projections, and layout auditing",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "dist/index.
|
|
6
|
+
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"author": "Daniel Oyerinde <oyerinde.daniel@yahoo.com> (https://danieloyerinde.com)",
|
|
@@ -84,9 +84,9 @@
|
|
|
84
84
|
"solid-js": "^1.9.10",
|
|
85
85
|
"tsup": "^8.5.1",
|
|
86
86
|
"typescript": "5.9.3",
|
|
87
|
-
"@repo/eslint-config": "0.0.0",
|
|
88
|
-
"@caliper/core": "0.0.0",
|
|
89
87
|
"@caliper/overlay": "0.0.0",
|
|
88
|
+
"@caliper/core": "0.0.0",
|
|
89
|
+
"@repo/eslint-config": "0.0.0",
|
|
90
90
|
"@repo/typescript-config": "0.0.0"
|
|
91
91
|
},
|
|
92
92
|
"scripts": {
|