@duct-sdk/sdk 0.3.5 → 0.3.6
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 +6 -0
- package/dist/adapters/react/shell.js +84 -62
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Public release notes for the Duct SDK. Versioning follows [semver](https://semver.org).
|
|
4
4
|
|
|
5
|
+
## [0.3.6] — 2026-06-10
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- **Launcher drag UX** — closed bubble drags from the icon itself (4px threshold); no grab cursor or extra handle on hover. Tap still opens.
|
|
9
|
+
- **Panel drag handle** — grab bar only renders while the panel is open; themed “Drag to move” tooltip replaces the native browser title.
|
|
10
|
+
|
|
5
11
|
## [0.3.5] — 2026-06-10
|
|
6
12
|
|
|
7
13
|
### Fixed
|
|
@@ -62,10 +62,12 @@ function clampBubble(x, y) {
|
|
|
62
62
|
y: Math.min(Math.max(margin, y), Math.max(margin, maxY)),
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
/**
|
|
66
|
-
function ShellDragHandle({ onPointerDown, isDragging, isDark,
|
|
65
|
+
/** Top grab handle for the open panel — with theme-aware hover tooltip. */
|
|
66
|
+
function ShellDragHandle({ onPointerDown, isDragging, isDark, label = "Drag to move", style, }) {
|
|
67
|
+
const [hovered, setHovered] = useState(false);
|
|
67
68
|
const barColor = isDark ? "rgba(255,255,255,0.28)" : "rgba(12,11,9,0.20)";
|
|
68
|
-
|
|
69
|
+
const showTip = hovered && !isDragging;
|
|
70
|
+
return (_jsxs("div", { role: "button", tabIndex: -1, onPointerDown: onPointerDown, "aria-label": label, onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), style: {
|
|
69
71
|
position: "absolute",
|
|
70
72
|
top: 6,
|
|
71
73
|
left: "50%",
|
|
@@ -80,12 +82,32 @@ function ShellDragHandle({ onPointerDown, isDragging, isDark, title = "Drag", st
|
|
|
80
82
|
touchAction: "none",
|
|
81
83
|
borderRadius: 11,
|
|
82
84
|
...style,
|
|
83
|
-
}, children: _jsx("div", { "aria-hidden": "true", style: {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
}, children: [_jsx("div", { "aria-hidden": "true", style: {
|
|
86
|
+
width: 32,
|
|
87
|
+
height: 4,
|
|
88
|
+
borderRadius: 2,
|
|
89
|
+
backgroundColor: barColor,
|
|
90
|
+
} }), showTip && (_jsx("div", { role: "tooltip", style: {
|
|
91
|
+
position: "absolute",
|
|
92
|
+
top: "100%",
|
|
93
|
+
left: "50%",
|
|
94
|
+
transform: "translateX(-50%)",
|
|
95
|
+
marginTop: 6,
|
|
96
|
+
padding: "5px 10px",
|
|
97
|
+
fontSize: 11,
|
|
98
|
+
fontWeight: 500,
|
|
99
|
+
lineHeight: 1.3,
|
|
100
|
+
letterSpacing: "0.01em",
|
|
101
|
+
whiteSpace: "nowrap",
|
|
102
|
+
pointerEvents: "none",
|
|
103
|
+
borderRadius: 8,
|
|
104
|
+
backgroundColor: isDark ? "#1A1816" : "#FFFFFF",
|
|
105
|
+
color: isDark ? "#9C9790" : "#635F59",
|
|
106
|
+
border: isDark ? "1px solid rgba(255,255,255,0.08)" : "1px solid rgba(12,11,9,0.10)",
|
|
107
|
+
boxShadow: isDark
|
|
108
|
+
? "0 8px 24px rgba(0,0,0,0.45)"
|
|
109
|
+
: "0 8px 24px rgba(12,11,9,0.12)",
|
|
110
|
+
}, children: label }))] }));
|
|
89
111
|
}
|
|
90
112
|
/** Keep a dragged panel visible inside the viewport. */
|
|
91
113
|
function clampPanel(x, y, width, height) {
|
|
@@ -366,40 +388,6 @@ export function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, on
|
|
|
366
388
|
}
|
|
367
389
|
catch { /* ignore corrupt storage */ }
|
|
368
390
|
}, [shellId, draggable]);
|
|
369
|
-
// Free drag — pointer move/up handlers attached to window during a drag.
|
|
370
|
-
useEffect(() => {
|
|
371
|
-
if (!isDragging)
|
|
372
|
-
return;
|
|
373
|
-
const onMove = (e) => {
|
|
374
|
-
const st = dragState.current;
|
|
375
|
-
if (!st)
|
|
376
|
-
return;
|
|
377
|
-
if (Math.abs(e.clientX - st.startX) > 4 || Math.abs(e.clientY - st.startY) > 4) {
|
|
378
|
-
st.moved = true;
|
|
379
|
-
}
|
|
380
|
-
setBubblePos(clampBubble(e.clientX - st.dx, e.clientY - st.dy));
|
|
381
|
-
};
|
|
382
|
-
const onUp = () => {
|
|
383
|
-
setIsDragging(false);
|
|
384
|
-
const st = dragState.current;
|
|
385
|
-
dragState.current = null;
|
|
386
|
-
if (st?.moved) {
|
|
387
|
-
try {
|
|
388
|
-
window.localStorage.setItem(`duct-shell-pos:${shellId}`, JSON.stringify(bubblePos));
|
|
389
|
-
}
|
|
390
|
-
catch { /* ignore */ }
|
|
391
|
-
// Bubble moved to a new location — clear any panel position so the panel
|
|
392
|
-
// re-anchors near the bubble on the next open instead of the old dragged spot.
|
|
393
|
-
setPanelPos(null);
|
|
394
|
-
}
|
|
395
|
-
};
|
|
396
|
-
window.addEventListener("pointermove", onMove);
|
|
397
|
-
window.addEventListener("pointerup", onUp);
|
|
398
|
-
return () => {
|
|
399
|
-
window.removeEventListener("pointermove", onMove);
|
|
400
|
-
window.removeEventListener("pointerup", onUp);
|
|
401
|
-
};
|
|
402
|
-
}, [isDragging, bubblePos, shellId]);
|
|
403
391
|
// Free-drag the open panel using a top handle. The handle sits outside the
|
|
404
392
|
// iframe so dragging works without relying on iframe internals.
|
|
405
393
|
useEffect(() => {
|
|
@@ -422,15 +410,57 @@ export function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, on
|
|
|
422
410
|
window.removeEventListener("pointerup", onUp);
|
|
423
411
|
};
|
|
424
412
|
}, [isPanelDragging]);
|
|
413
|
+
// Launcher bubble: pointer stays default until the user actually drags (4px threshold).
|
|
414
|
+
// A tap opens; a drag repositions — no separate handle or grab cursor on hover.
|
|
425
415
|
const onBubblePointerDown = useCallback((e) => {
|
|
426
416
|
if (!draggable)
|
|
427
417
|
return;
|
|
428
418
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
429
|
-
|
|
430
|
-
|
|
419
|
+
const st = {
|
|
420
|
+
dx: e.clientX - rect.left,
|
|
421
|
+
dy: e.clientY - rect.top,
|
|
422
|
+
startX: e.clientX,
|
|
423
|
+
startY: e.clientY,
|
|
424
|
+
moved: false,
|
|
425
|
+
};
|
|
426
|
+
dragState.current = st;
|
|
431
427
|
setBubblePos((prev) => prev ?? clampBubble(rect.left, rect.top));
|
|
432
|
-
|
|
433
|
-
|
|
428
|
+
const onMove = (ev) => {
|
|
429
|
+
if (!dragState.current)
|
|
430
|
+
return;
|
|
431
|
+
if (!st.moved
|
|
432
|
+
&& Math.abs(ev.clientX - st.startX) <= 4
|
|
433
|
+
&& Math.abs(ev.clientY - st.startY) <= 4) {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
st.moved = true;
|
|
437
|
+
setIsDragging(true);
|
|
438
|
+
setBubblePos(clampBubble(ev.clientX - st.dx, ev.clientY - st.dy));
|
|
439
|
+
};
|
|
440
|
+
const onUp = () => {
|
|
441
|
+
window.removeEventListener("pointermove", onMove);
|
|
442
|
+
window.removeEventListener("pointerup", onUp);
|
|
443
|
+
dragState.current = null;
|
|
444
|
+
setIsDragging(false);
|
|
445
|
+
if (st.moved) {
|
|
446
|
+
setBubblePos((pos) => {
|
|
447
|
+
if (pos) {
|
|
448
|
+
try {
|
|
449
|
+
window.localStorage.setItem(`duct-shell-pos:${shellId}`, JSON.stringify(pos));
|
|
450
|
+
}
|
|
451
|
+
catch { /* ignore */ }
|
|
452
|
+
}
|
|
453
|
+
return pos;
|
|
454
|
+
});
|
|
455
|
+
setPanelPos(null);
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
openPanel();
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
window.addEventListener("pointermove", onMove);
|
|
462
|
+
window.addEventListener("pointerup", onUp);
|
|
463
|
+
}, [draggable, openPanel, shellId]);
|
|
434
464
|
const onPanelPointerDown = useCallback((e) => {
|
|
435
465
|
if (!draggable || !panelRef.current)
|
|
436
466
|
return;
|
|
@@ -524,30 +554,22 @@ export function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, on
|
|
|
524
554
|
transition: isDragging ? "none" : "transform 150ms ease, box-shadow 150ms ease",
|
|
525
555
|
};
|
|
526
556
|
const bubbleIcon = !iconLoadFailed ? (_jsx("img", { src: currentIconSrc, alt: "Duct", width: 30, height: 30, draggable: false, onError: handleIconError, style: { width: "30px", height: "30px", objectFit: "contain", pointerEvents: "none" } })) : (_jsx("svg", { width: "28", height: "28", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "M18 12c0-3.3-2.2-5.5-5.5-5.5C9 6.5 7 8.7 7 12s2 5.5 5.5 5.5c2 0 3.6-.8 4.6-2.2l-2.2-1.6c-.6.8-1.4 1.3-2.4 1.3-1.6 0-2.8-1.2-2.8-3s1.2-3 2.8-3c1 0 1.8.5 2.3 1.3L18 12z", fill: "#E8622A" }) }));
|
|
527
|
-
return (_jsxs(_Fragment, { children: [!panelOpen && (
|
|
528
|
-
...bubbleStyle,
|
|
529
|
-
position: "fixed",
|
|
530
|
-
zIndex: 9999,
|
|
531
|
-
width: `${BUBBLE_SIZE}px`,
|
|
532
|
-
height: `${BUBBLE_SIZE}px`,
|
|
533
|
-
}, className: className, children: [_jsx(ShellDragHandle, { onPointerDown: onBubblePointerDown, isDragging: isDragging, isDark: isDarkChrome, title: "Drag launcher", style: { top: -4, zIndex: 3 } }), _jsx("button", { type: "button", style: bubbleLauncherStyle, onClick: () => openPanel(), "aria-label": "Open Duct Shell", onMouseEnter: (e) => {
|
|
534
|
-
if (isDragging)
|
|
535
|
-
return;
|
|
536
|
-
e.currentTarget.style.transform = "scale(1.07)";
|
|
537
|
-
}, onMouseLeave: (e) => {
|
|
538
|
-
e.currentTarget.style.transform = "scale(1)";
|
|
539
|
-
}, children: bubbleIcon })] })) : (_jsx("button", { type: "button", style: {
|
|
557
|
+
return (_jsxs(_Fragment, { children: [!panelOpen && (_jsx("button", { type: "button", style: {
|
|
540
558
|
...bubbleStyle,
|
|
541
559
|
...bubbleLauncherStyle,
|
|
542
560
|
position: "fixed",
|
|
543
561
|
zIndex: 9999,
|
|
544
562
|
width: `${BUBBLE_SIZE}px`,
|
|
545
563
|
height: `${BUBBLE_SIZE}px`,
|
|
546
|
-
|
|
564
|
+
cursor: isDragging ? "grabbing" : "pointer",
|
|
565
|
+
touchAction: draggable ? "none" : undefined,
|
|
566
|
+
}, onPointerDown: draggable ? onBubblePointerDown : undefined, onClick: draggable ? undefined : () => openPanel(), "aria-label": "Open Duct Shell", className: className, onMouseEnter: (e) => {
|
|
567
|
+
if (isDragging)
|
|
568
|
+
return;
|
|
547
569
|
e.currentTarget.style.transform = "scale(1.07)";
|
|
548
570
|
}, onMouseLeave: (e) => {
|
|
549
571
|
e.currentTarget.style.transform = "scale(1)";
|
|
550
|
-
}, children: bubbleIcon }))
|
|
572
|
+
}, children: bubbleIcon })), _jsxs("div", { ref: panelRef, style: panelStyle, "data-duct-shell": shellId, children: [draggable && panelOpen && (_jsx(ShellDragHandle, { onPointerDown: onPanelPointerDown, isDragging: isPanelDragging, isDark: isDarkChrome, label: "Drag to move" })), _jsx("iframe", { ref: iframeRef, src: shellUrl, title: "Duct Shell", sandbox: "allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox", allow: "clipboard-write", referrerPolicy: "no-referrer-when-downgrade", style: {
|
|
551
573
|
width: "100%",
|
|
552
574
|
height: "100%",
|
|
553
575
|
border: "none",
|