@tscircuit/pcb-viewer 1.11.89 → 1.11.91
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/dist/index.d.ts +1 -4
- package/dist/index.js +11 -55
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -32,9 +32,7 @@ type StateProps = {
|
|
|
32
32
|
type EditEvent = ManualEditEvent;
|
|
33
33
|
|
|
34
34
|
type Props = {
|
|
35
|
-
children?: any;
|
|
36
35
|
circuitJson?: AnyCircuitElement[];
|
|
37
|
-
soup?: any;
|
|
38
36
|
height?: number;
|
|
39
37
|
allowEditing?: boolean;
|
|
40
38
|
editEvents?: EditEvent[];
|
|
@@ -42,10 +40,9 @@ type Props = {
|
|
|
42
40
|
onEditEventsChanged?: (editEvents: EditEvent[]) => void;
|
|
43
41
|
focusOnHover?: boolean;
|
|
44
42
|
clickToInteractEnabled?: boolean;
|
|
45
|
-
disableAutoFocus?: boolean;
|
|
46
43
|
debugGraphics?: GraphicsObject | null;
|
|
47
44
|
};
|
|
48
|
-
declare const PCBViewer: ({
|
|
45
|
+
declare const PCBViewer: ({ circuitJson, debugGraphics, height, initialState, allowEditing, editEvents: editEventsProp, onEditEventsChanged, focusOnHover, clickToInteractEnabled, }: Props) => react_jsx_runtime.JSX.Element;
|
|
49
46
|
|
|
50
47
|
declare const applyEditEvents: (soup: AnyCircuitElement[], edit_events: EditEvent[]) => AnyCircuitElement[];
|
|
51
48
|
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,6 @@ var __export = (target, all) => {
|
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
// src/PCBViewer.tsx
|
|
8
|
-
import { useRenderedCircuit } from "@tscircuit/core";
|
|
9
|
-
|
|
10
7
|
// node_modules/circuit-json/dist/index.mjs
|
|
11
8
|
var dist_exports = {};
|
|
12
9
|
__export(dist_exports, {
|
|
@@ -9187,7 +9184,7 @@ import { css as css3 } from "@emotion/css";
|
|
|
9187
9184
|
// package.json
|
|
9188
9185
|
var package_default = {
|
|
9189
9186
|
name: "@tscircuit/pcb-viewer",
|
|
9190
|
-
version: "1.11.
|
|
9187
|
+
version: "1.11.90",
|
|
9191
9188
|
main: "dist/index.js",
|
|
9192
9189
|
type: "module",
|
|
9193
9190
|
repository: "tscircuit/pcb-viewer",
|
|
@@ -9738,8 +9735,6 @@ var CanvasElementsRenderer = (props) => {
|
|
|
9738
9735
|
import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
9739
9736
|
var defaultTransform = compose4(translate5(400, 300), scale2(40, -40));
|
|
9740
9737
|
var PCBViewer = ({
|
|
9741
|
-
children,
|
|
9742
|
-
soup,
|
|
9743
9738
|
circuitJson,
|
|
9744
9739
|
debugGraphics,
|
|
9745
9740
|
height = 600,
|
|
@@ -9748,16 +9743,8 @@ var PCBViewer = ({
|
|
|
9748
9743
|
editEvents: editEventsProp,
|
|
9749
9744
|
onEditEventsChanged,
|
|
9750
9745
|
focusOnHover = false,
|
|
9751
|
-
clickToInteractEnabled = false
|
|
9752
|
-
disableAutoFocus = false
|
|
9746
|
+
clickToInteractEnabled = false
|
|
9753
9747
|
}) => {
|
|
9754
|
-
circuitJson ??= soup;
|
|
9755
|
-
const {
|
|
9756
|
-
circuitJson: circuitJsonFromChildren,
|
|
9757
|
-
error: errorFromChildren,
|
|
9758
|
-
isLoading
|
|
9759
|
-
} = useRenderedCircuit(children);
|
|
9760
|
-
circuitJson ??= circuitJsonFromChildren ?? [];
|
|
9761
9748
|
const [isInteractionEnabled, setIsInteractionEnabled] = useState10(
|
|
9762
9749
|
!clickToInteractEnabled
|
|
9763
9750
|
);
|
|
@@ -9775,8 +9762,8 @@ var PCBViewer = ({
|
|
|
9775
9762
|
let [editEvents, setEditEvents] = useState10([]);
|
|
9776
9763
|
editEvents = editEventsProp ?? editEvents;
|
|
9777
9764
|
const initialRenderCompleted = useRef8(false);
|
|
9778
|
-
const circuitJsonKey = `${circuitJson?.length || 0}
|
|
9779
|
-
const resetTransform = (
|
|
9765
|
+
const circuitJsonKey = `${circuitJson?.length || 0}`;
|
|
9766
|
+
const resetTransform = () => {
|
|
9780
9767
|
const elmBounds = refDimensions?.width > 0 ? refDimensions : { width: 500, height: 500 };
|
|
9781
9768
|
const { center, width, height: height2 } = elements.some(
|
|
9782
9769
|
(e) => e.type.startsWith("pcb_")
|
|
@@ -9793,49 +9780,18 @@ var PCBViewer = ({
|
|
|
9793
9780
|
scale2(scaleFactor, -scaleFactor, 0, 0),
|
|
9794
9781
|
translate5(-center.x, -center.y)
|
|
9795
9782
|
);
|
|
9796
|
-
|
|
9797
|
-
|
|
9798
|
-
return;
|
|
9799
|
-
}
|
|
9800
|
-
const startTransform = { ...transform };
|
|
9801
|
-
const startTime = Date.now();
|
|
9802
|
-
const duration = 1e3;
|
|
9803
|
-
const animateTransform = () => {
|
|
9804
|
-
const elapsed = Date.now() - startTime;
|
|
9805
|
-
const progress = Math.min(elapsed / duration, 1);
|
|
9806
|
-
const easeProgress = 1 - Math.pow(1 - progress, 3);
|
|
9807
|
-
const newTransform = {
|
|
9808
|
-
a: startTransform.a + (targetTransform.a - startTransform.a) * easeProgress,
|
|
9809
|
-
b: startTransform.b + (targetTransform.b - startTransform.b) * easeProgress,
|
|
9810
|
-
c: startTransform.c + (targetTransform.c - startTransform.c) * easeProgress,
|
|
9811
|
-
d: startTransform.d + (targetTransform.d - startTransform.d) * easeProgress,
|
|
9812
|
-
e: startTransform.e + (targetTransform.e - startTransform.e) * easeProgress,
|
|
9813
|
-
f: startTransform.f + (targetTransform.f - startTransform.f) * easeProgress
|
|
9814
|
-
};
|
|
9815
|
-
setTransform(newTransform);
|
|
9816
|
-
if (progress < 1) {
|
|
9817
|
-
requestAnimationFrame(animateTransform);
|
|
9818
|
-
}
|
|
9819
|
-
};
|
|
9820
|
-
requestAnimationFrame(animateTransform);
|
|
9783
|
+
setTransform(targetTransform);
|
|
9784
|
+
return;
|
|
9821
9785
|
};
|
|
9822
9786
|
useEffect13(() => {
|
|
9823
|
-
if (disableAutoFocus) return;
|
|
9824
9787
|
if (!refDimensions?.width) return;
|
|
9825
|
-
if (!
|
|
9826
|
-
if (
|
|
9788
|
+
if (!circuitJson) return;
|
|
9789
|
+
if (circuitJson.length === 0) return;
|
|
9827
9790
|
if (!initialRenderCompleted.current) {
|
|
9828
|
-
resetTransform(
|
|
9791
|
+
resetTransform();
|
|
9829
9792
|
initialRenderCompleted.current = true;
|
|
9830
9793
|
}
|
|
9831
|
-
}, [
|
|
9832
|
-
children,
|
|
9833
|
-
circuitJson,
|
|
9834
|
-
refDimensions,
|
|
9835
|
-
clickToInteractEnabled,
|
|
9836
|
-
isInteractionEnabled,
|
|
9837
|
-
disableAutoFocus
|
|
9838
|
-
]);
|
|
9794
|
+
}, [circuitJson, refDimensions]);
|
|
9839
9795
|
const pcbElmsPreEdit = useMemo6(() => {
|
|
9840
9796
|
return circuitJson?.filter(
|
|
9841
9797
|
(e) => e.type.startsWith("pcb_") || e.type.startsWith("source_")
|
|
@@ -9889,7 +9845,7 @@ var PCBViewer = ({
|
|
|
9889
9845
|
{
|
|
9890
9846
|
onClick: () => {
|
|
9891
9847
|
setIsInteractionEnabled(true);
|
|
9892
|
-
resetTransform(
|
|
9848
|
+
resetTransform();
|
|
9893
9849
|
},
|
|
9894
9850
|
style: {
|
|
9895
9851
|
position: "absolute",
|