@tscircuit/3d-viewer 0.0.440 → 0.0.441
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.js +44 -49
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28113,12 +28113,6 @@ var defaultVisibility = {
|
|
|
28113
28113
|
var LayerVisibilityContext = createContext3(void 0);
|
|
28114
28114
|
var LayerVisibilityProvider = ({ children }) => {
|
|
28115
28115
|
const [visibility, setVisibility] = useState5(defaultVisibility);
|
|
28116
|
-
const toggleLayer = useCallback2((layer) => {
|
|
28117
|
-
setVisibility((prev) => ({
|
|
28118
|
-
...prev,
|
|
28119
|
-
[layer]: !prev[layer]
|
|
28120
|
-
}));
|
|
28121
|
-
}, []);
|
|
28122
28116
|
const setLayerVisibility = useCallback2(
|
|
28123
28117
|
(layer, visible) => {
|
|
28124
28118
|
setVisibility((prev) => ({
|
|
@@ -28134,11 +28128,10 @@ var LayerVisibilityProvider = ({ children }) => {
|
|
|
28134
28128
|
const value = useMemo6(
|
|
28135
28129
|
() => ({
|
|
28136
28130
|
visibility,
|
|
28137
|
-
toggleLayer,
|
|
28138
28131
|
setLayerVisibility,
|
|
28139
28132
|
resetToDefaults
|
|
28140
28133
|
}),
|
|
28141
|
-
[visibility,
|
|
28134
|
+
[visibility, setLayerVisibility, resetToDefaults]
|
|
28142
28135
|
);
|
|
28143
28136
|
return /* @__PURE__ */ jsx8(LayerVisibilityContext.Provider, { value, children });
|
|
28144
28137
|
};
|
|
@@ -28288,7 +28281,7 @@ import * as THREE15 from "three";
|
|
|
28288
28281
|
// package.json
|
|
28289
28282
|
var package_default = {
|
|
28290
28283
|
name: "@tscircuit/3d-viewer",
|
|
28291
|
-
version: "0.0.
|
|
28284
|
+
version: "0.0.440",
|
|
28292
28285
|
main: "./dist/index.js",
|
|
28293
28286
|
module: "./dist/index.js",
|
|
28294
28287
|
type: "module",
|
|
@@ -34508,23 +34501,26 @@ import { useEffect as useEffect25, useMemo as useMemo21, useRef as useRef11, use
|
|
|
34508
34501
|
var hotkeyRegistry = /* @__PURE__ */ new Map();
|
|
34509
34502
|
var subscribers = /* @__PURE__ */ new Set();
|
|
34510
34503
|
var isListenerAttached = false;
|
|
34511
|
-
var
|
|
34512
|
-
|
|
34513
|
-
|
|
34514
|
-
|
|
34515
|
-
|
|
34516
|
-
|
|
34517
|
-
|
|
34518
|
-
|
|
34519
|
-
|
|
34520
|
-
|
|
34521
|
-
|
|
34522
|
-
|
|
34523
|
-
|
|
34524
|
-
|
|
34525
|
-
|
|
34526
|
-
|
|
34527
|
-
|
|
34504
|
+
var parseShortcut = (shortcut) => {
|
|
34505
|
+
const parts = shortcut.toLowerCase().split("+");
|
|
34506
|
+
const key = parts[parts.length - 1];
|
|
34507
|
+
const modifierParts = parts.slice(0, -1);
|
|
34508
|
+
return {
|
|
34509
|
+
key,
|
|
34510
|
+
ctrl: modifierParts.includes("ctrl"),
|
|
34511
|
+
cmd: modifierParts.includes("cmd"),
|
|
34512
|
+
shift: modifierParts.includes("shift"),
|
|
34513
|
+
alt: modifierParts.includes("alt")
|
|
34514
|
+
};
|
|
34515
|
+
};
|
|
34516
|
+
var matchesShortcut = (event, shortcut) => {
|
|
34517
|
+
const parsed = parseShortcut(shortcut);
|
|
34518
|
+
const keyMatches = event.key.toLowerCase() === parsed.key;
|
|
34519
|
+
const ctrlMatches = parsed.ctrl === event.ctrlKey;
|
|
34520
|
+
const cmdMatches = parsed.cmd === event.metaKey;
|
|
34521
|
+
const shiftMatches = parsed.shift === event.shiftKey;
|
|
34522
|
+
const altMatches = parsed.alt === event.altKey;
|
|
34523
|
+
return keyMatches && ctrlMatches && cmdMatches && shiftMatches && altMatches;
|
|
34528
34524
|
};
|
|
34529
34525
|
var isEditableTarget = (target) => {
|
|
34530
34526
|
if (!target || typeof target !== "object") return false;
|
|
@@ -34541,7 +34537,7 @@ var handleKeydown = (event) => {
|
|
|
34541
34537
|
return;
|
|
34542
34538
|
}
|
|
34543
34539
|
hotkeyRegistry.forEach((entry) => {
|
|
34544
|
-
if (
|
|
34540
|
+
if (matchesShortcut(event, entry.shortcut)) {
|
|
34545
34541
|
event.preventDefault();
|
|
34546
34542
|
entry.invoke();
|
|
34547
34543
|
}
|
|
@@ -34579,11 +34575,10 @@ var useRegisteredHotkey = (id, handler, metadata) => {
|
|
|
34579
34575
|
handlerRef.current = handler;
|
|
34580
34576
|
const normalizedMetadata = useMemo21(
|
|
34581
34577
|
() => ({
|
|
34582
|
-
|
|
34583
|
-
description: metadata.description
|
|
34584
|
-
modifiers: metadata.modifiers
|
|
34578
|
+
shortcut: metadata.shortcut,
|
|
34579
|
+
description: metadata.description
|
|
34585
34580
|
}),
|
|
34586
|
-
[metadata.
|
|
34581
|
+
[metadata.shortcut, metadata.description]
|
|
34587
34582
|
);
|
|
34588
34583
|
useEffect25(() => {
|
|
34589
34584
|
const registration = {
|
|
@@ -40065,7 +40060,7 @@ var iconContainerStyles = {
|
|
|
40065
40060
|
flexShrink: 0
|
|
40066
40061
|
};
|
|
40067
40062
|
var AppearanceMenu = () => {
|
|
40068
|
-
const { visibility,
|
|
40063
|
+
const { visibility, setLayerVisibility } = useLayerVisibility();
|
|
40069
40064
|
const [appearanceSubOpen, setAppearanceSubOpen] = useState33(false);
|
|
40070
40065
|
const [hoveredItem, setHoveredItem] = useState33(null);
|
|
40071
40066
|
return /* @__PURE__ */ jsxs7(Fragment9, { children: [
|
|
@@ -40116,7 +40111,7 @@ var AppearanceMenu = () => {
|
|
|
40116
40111
|
onSelect: (e) => e.preventDefault(),
|
|
40117
40112
|
onPointerDown: (e) => {
|
|
40118
40113
|
e.preventDefault();
|
|
40119
|
-
|
|
40114
|
+
setLayerVisibility("boardBody", !visibility.boardBody);
|
|
40120
40115
|
},
|
|
40121
40116
|
onMouseEnter: () => setHoveredItem("boardBody"),
|
|
40122
40117
|
onMouseLeave: () => setHoveredItem(null),
|
|
@@ -40137,7 +40132,7 @@ var AppearanceMenu = () => {
|
|
|
40137
40132
|
onSelect: (e) => e.preventDefault(),
|
|
40138
40133
|
onPointerDown: (e) => {
|
|
40139
40134
|
e.preventDefault();
|
|
40140
|
-
|
|
40135
|
+
setLayerVisibility("topCopper", !visibility.topCopper);
|
|
40141
40136
|
},
|
|
40142
40137
|
onMouseEnter: () => setHoveredItem("topCopper"),
|
|
40143
40138
|
onMouseLeave: () => setHoveredItem(null),
|
|
@@ -40158,7 +40153,7 @@ var AppearanceMenu = () => {
|
|
|
40158
40153
|
onSelect: (e) => e.preventDefault(),
|
|
40159
40154
|
onPointerDown: (e) => {
|
|
40160
40155
|
e.preventDefault();
|
|
40161
|
-
|
|
40156
|
+
setLayerVisibility("bottomCopper", !visibility.bottomCopper);
|
|
40162
40157
|
},
|
|
40163
40158
|
onMouseEnter: () => setHoveredItem("bottomCopper"),
|
|
40164
40159
|
onMouseLeave: () => setHoveredItem(null),
|
|
@@ -40179,7 +40174,7 @@ var AppearanceMenu = () => {
|
|
|
40179
40174
|
onSelect: (e) => e.preventDefault(),
|
|
40180
40175
|
onPointerDown: (e) => {
|
|
40181
40176
|
e.preventDefault();
|
|
40182
|
-
|
|
40177
|
+
setLayerVisibility("topSilkscreen", !visibility.topSilkscreen);
|
|
40183
40178
|
},
|
|
40184
40179
|
onMouseEnter: () => setHoveredItem("topSilkscreen"),
|
|
40185
40180
|
onMouseLeave: () => setHoveredItem(null),
|
|
@@ -40200,7 +40195,10 @@ var AppearanceMenu = () => {
|
|
|
40200
40195
|
onSelect: (e) => e.preventDefault(),
|
|
40201
40196
|
onPointerDown: (e) => {
|
|
40202
40197
|
e.preventDefault();
|
|
40203
|
-
|
|
40198
|
+
setLayerVisibility(
|
|
40199
|
+
"bottomSilkscreen",
|
|
40200
|
+
!visibility.bottomSilkscreen
|
|
40201
|
+
);
|
|
40204
40202
|
},
|
|
40205
40203
|
onMouseEnter: () => setHoveredItem("bottomSilkscreen"),
|
|
40206
40204
|
onMouseLeave: () => setHoveredItem(null),
|
|
@@ -40221,7 +40219,7 @@ var AppearanceMenu = () => {
|
|
|
40221
40219
|
onSelect: (e) => e.preventDefault(),
|
|
40222
40220
|
onPointerDown: (e) => {
|
|
40223
40221
|
e.preventDefault();
|
|
40224
|
-
|
|
40222
|
+
setLayerVisibility("smtModels", !visibility.smtModels);
|
|
40225
40223
|
},
|
|
40226
40224
|
onMouseEnter: () => setHoveredItem("smtModels"),
|
|
40227
40225
|
onMouseLeave: () => setHoveredItem(null),
|
|
@@ -40584,7 +40582,7 @@ var ContextMenu = ({
|
|
|
40584
40582
|
|
|
40585
40583
|
// src/components/KeyboardShortcutsDialog.tsx
|
|
40586
40584
|
import { useEffect as useEffect41, useMemo as useMemo27, useRef as useRef25, useState as useState35 } from "react";
|
|
40587
|
-
import {
|
|
40585
|
+
import { jsx as jsx35, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
40588
40586
|
var KeyboardShortcutsDialog = ({
|
|
40589
40587
|
open,
|
|
40590
40588
|
onClose
|
|
@@ -40616,7 +40614,7 @@ var KeyboardShortcutsDialog = ({
|
|
|
40616
40614
|
return hotkeys;
|
|
40617
40615
|
}
|
|
40618
40616
|
return hotkeys.filter((hotkey) => {
|
|
40619
|
-
const haystack = `${hotkey.
|
|
40617
|
+
const haystack = `${hotkey.shortcut} ${hotkey.description}`;
|
|
40620
40618
|
return haystack.toLowerCase().includes(normalizedQuery);
|
|
40621
40619
|
});
|
|
40622
40620
|
}, [hotkeys, query]);
|
|
@@ -40751,12 +40749,10 @@ var KeyboardShortcutsDialog = ({
|
|
|
40751
40749
|
minWidth: 36,
|
|
40752
40750
|
padding: "4px 8px",
|
|
40753
40751
|
fontFamily: "monospace",
|
|
40754
|
-
fontSize: "0.95rem"
|
|
40752
|
+
fontSize: "0.95rem",
|
|
40753
|
+
textTransform: "capitalize"
|
|
40755
40754
|
},
|
|
40756
|
-
children: hotkey.
|
|
40757
|
-
hotkey.modifiers.map((mod) => `${mod}+`).join(""),
|
|
40758
|
-
hotkey.key.toUpperCase()
|
|
40759
|
-
] }) : hotkey.key.toUpperCase()
|
|
40755
|
+
children: hotkey.shortcut
|
|
40760
40756
|
}
|
|
40761
40757
|
) }),
|
|
40762
40758
|
/* @__PURE__ */ jsx35("td", { style: { padding: "12px 24px" }, children: hotkey.description })
|
|
@@ -40790,7 +40786,7 @@ var CadViewerInner = (props) => {
|
|
|
40790
40786
|
});
|
|
40791
40787
|
const [cameraPreset, setCameraPreset] = useState36("Custom");
|
|
40792
40788
|
const { cameraType, setCameraType } = useCameraController();
|
|
40793
|
-
const { visibility,
|
|
40789
|
+
const { visibility, setLayerVisibility } = useLayerVisibility();
|
|
40794
40790
|
const cameraControllerRef = useRef26(null);
|
|
40795
40791
|
const externalCameraControllerReady = props.onCameraControllerReady;
|
|
40796
40792
|
const {
|
|
@@ -40849,9 +40845,8 @@ var CadViewerInner = (props) => {
|
|
|
40849
40845
|
setIsKeyboardShortcutsDialogOpen(true);
|
|
40850
40846
|
},
|
|
40851
40847
|
{
|
|
40852
|
-
|
|
40853
|
-
description: "Open keyboard shortcuts"
|
|
40854
|
-
modifiers: ["Shift"]
|
|
40848
|
+
shortcut: "shift+?",
|
|
40849
|
+
description: "Open keyboard shortcuts"
|
|
40855
40850
|
}
|
|
40856
40851
|
);
|
|
40857
40852
|
useEffect42(() => {
|