@duct-sdk/sdk 0.4.1 → 0.4.3
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/adapters/react/shell.d.ts +1 -1
- package/dist/adapters/react/shell.js +86 -18
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
Public release notes for the Duct SDK. Versioning follows [semver](https://semver.org).
|
|
4
4
|
|
|
5
|
+
## [0.4.3] — 2026-07-03
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- **`DuctShell` launcher icon when the shell host is unreachable** — bubble icon tries the host app's `/duct-text-no-bg.png` before the shell host URL; removed the nonexistent `duct-logo.png` candidate; final fallback is the `duↄt` wordmark instead of a broken orange SVG.
|
|
9
|
+
|
|
10
|
+
## [0.4.2] — 2026-07-03
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- **`DuctShell` drag position after handoff** — panel drag position is now persisted in `localStorage` alongside the launcher bubble, so deeplink/sign-in navigations no longer reset a repositioned embed. Legacy `{ x, y }` bubble-only storage remains supported.
|
|
14
|
+
|
|
5
15
|
## [0.4.1] — 2026-07-03
|
|
6
16
|
|
|
7
17
|
### Added
|
|
@@ -97,7 +97,7 @@ export interface DuctShellProps {
|
|
|
97
97
|
className?: string;
|
|
98
98
|
/**
|
|
99
99
|
* Optional launcher icon source.
|
|
100
|
-
* When omitted, the SDK tries
|
|
100
|
+
* When omitted, the SDK tries the host app's /duct-text-no-bg.png, then the shell host URL, then /assets/logo.png.
|
|
101
101
|
*/
|
|
102
102
|
launcherIconSrc?: string;
|
|
103
103
|
/**
|
|
@@ -116,6 +116,46 @@ function ShellDragHandle({ onPointerDown, isDragging, isDark, label = "Drag to m
|
|
|
116
116
|
: "0 8px 24px rgba(12,11,9,0.12)",
|
|
117
117
|
}, children: label }))] }));
|
|
118
118
|
}
|
|
119
|
+
function shellLayoutStorageKey(shellId) {
|
|
120
|
+
return `duct-shell-pos:${shellId}`;
|
|
121
|
+
}
|
|
122
|
+
/** Read persisted bubble/panel positions (supports legacy `{ x, y }` bubble-only blobs). */
|
|
123
|
+
function readStoredShellLayout(shellId) {
|
|
124
|
+
if (typeof window === "undefined")
|
|
125
|
+
return {};
|
|
126
|
+
try {
|
|
127
|
+
const raw = window.localStorage.getItem(shellLayoutStorageKey(shellId));
|
|
128
|
+
if (!raw)
|
|
129
|
+
return {};
|
|
130
|
+
const parsed = JSON.parse(raw);
|
|
131
|
+
if (!parsed || typeof parsed !== "object")
|
|
132
|
+
return {};
|
|
133
|
+
if ("x" in parsed && "y" in parsed) {
|
|
134
|
+
const legacy = parsed;
|
|
135
|
+
if (typeof legacy.x === "number" && typeof legacy.y === "number") {
|
|
136
|
+
return { bubble: { x: legacy.x, y: legacy.y } };
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const layout = parsed;
|
|
140
|
+
const out = {};
|
|
141
|
+
if (layout.bubble && typeof layout.bubble.x === "number" && typeof layout.bubble.y === "number") {
|
|
142
|
+
out.bubble = layout.bubble;
|
|
143
|
+
}
|
|
144
|
+
if (layout.panel && typeof layout.panel.x === "number" && typeof layout.panel.y === "number") {
|
|
145
|
+
out.panel = layout.panel;
|
|
146
|
+
}
|
|
147
|
+
return out;
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
return {};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function writeStoredShellLayout(shellId, layout) {
|
|
154
|
+
try {
|
|
155
|
+
window.localStorage.setItem(shellLayoutStorageKey(shellId), JSON.stringify(layout));
|
|
156
|
+
}
|
|
157
|
+
catch { /* ignore quota / private mode */ }
|
|
158
|
+
}
|
|
119
159
|
/** Keep a dragged panel visible inside the viewport. */
|
|
120
160
|
function clampPanel(x, y, width, height) {
|
|
121
161
|
if (typeof window === "undefined")
|
|
@@ -230,7 +270,11 @@ export function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, on
|
|
|
230
270
|
})();
|
|
231
271
|
const iconCandidates = launcherIconSrc
|
|
232
272
|
? [launcherIconSrc]
|
|
233
|
-
: [
|
|
273
|
+
: [
|
|
274
|
+
"/duct-text-no-bg.png",
|
|
275
|
+
`${shellOrigin}/duct-text-no-bg.png`,
|
|
276
|
+
DUCT_LAUNCHER_ICON_LOCAL_FALLBACK,
|
|
277
|
+
];
|
|
234
278
|
const currentIconSrc = iconCandidates[Math.min(iconCandidateIndex, iconCandidates.length - 1)];
|
|
235
279
|
// Send a message to the iframe
|
|
236
280
|
const postToShell = useCallback((message) => {
|
|
@@ -407,21 +451,35 @@ export function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, on
|
|
|
407
451
|
mq.addEventListener("change", handler);
|
|
408
452
|
return () => mq.removeEventListener("change", handler);
|
|
409
453
|
}, [theme]);
|
|
410
|
-
// Restore a
|
|
454
|
+
// Restore bubble position saved from a prior visit (survives deeplink handoff navigations).
|
|
411
455
|
useEffect(() => {
|
|
412
456
|
if (!draggable || typeof window === "undefined")
|
|
413
457
|
return;
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
const parsed = JSON.parse(raw);
|
|
418
|
-
if (typeof parsed.x === "number" && typeof parsed.y === "number") {
|
|
419
|
-
setBubblePos(clampBubble(parsed.x, parsed.y));
|
|
420
|
-
}
|
|
421
|
-
}
|
|
458
|
+
const layout = readStoredShellLayout(shellId);
|
|
459
|
+
if (layout.bubble) {
|
|
460
|
+
setBubblePos(clampBubble(layout.bubble.x, layout.bubble.y));
|
|
422
461
|
}
|
|
423
|
-
catch { /* ignore corrupt storage */ }
|
|
424
462
|
}, [shellId, draggable]);
|
|
463
|
+
// Restore or re-clamp panel position when dimensions change (e.g. manifest widget preset).
|
|
464
|
+
useEffect(() => {
|
|
465
|
+
if (!draggable || typeof window === "undefined")
|
|
466
|
+
return;
|
|
467
|
+
const dims = resolveShellDimensions({
|
|
468
|
+
preset: dynamicPreset ?? preset,
|
|
469
|
+
width: dynamicWidth ?? panelWidth,
|
|
470
|
+
height: dynamicHeight ?? panelHeight,
|
|
471
|
+
});
|
|
472
|
+
const w = typeof dims.width === "number" ? dims.width : panelWidth;
|
|
473
|
+
const h = typeof dims.height === "number" ? dims.height : panelHeight;
|
|
474
|
+
setPanelPos((prev) => {
|
|
475
|
+
if (prev)
|
|
476
|
+
return clampPanel(prev.x, prev.y, w, h);
|
|
477
|
+
const stored = readStoredShellLayout(shellId).panel;
|
|
478
|
+
if (!stored)
|
|
479
|
+
return null;
|
|
480
|
+
return clampPanel(stored.x, stored.y, w, h);
|
|
481
|
+
});
|
|
482
|
+
}, [shellId, draggable, dynamicPreset, preset, dynamicWidth, panelWidth, dynamicHeight, panelHeight]);
|
|
425
483
|
// Launcher bubble: pointer stays default until the user actually drags (4px threshold).
|
|
426
484
|
// A tap opens; a drag repositions — no separate handle or grab cursor on hover.
|
|
427
485
|
const onBubblePointerDown = useCallback((e) => {
|
|
@@ -471,10 +529,7 @@ export function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, on
|
|
|
471
529
|
const pos = finalPos ?? bubbleDragPending.current;
|
|
472
530
|
if (pos) {
|
|
473
531
|
setBubblePos(pos);
|
|
474
|
-
|
|
475
|
-
window.localStorage.setItem(`duct-shell-pos:${shellId}`, JSON.stringify(pos));
|
|
476
|
-
}
|
|
477
|
-
catch { /* ignore */ }
|
|
532
|
+
writeStoredShellLayout(shellId, { bubble: pos });
|
|
478
533
|
}
|
|
479
534
|
setPanelPos(null);
|
|
480
535
|
}
|
|
@@ -519,11 +574,16 @@ export function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, on
|
|
|
519
574
|
window.removeEventListener("pointerup", onUp);
|
|
520
575
|
panelDragState.current = null;
|
|
521
576
|
setIsPanelDragging(false);
|
|
522
|
-
cancelRafUpdate(panelDragRaf, panelDragPending, commitPanelPos);
|
|
577
|
+
const finalPos = cancelRafUpdate(panelDragRaf, panelDragPending, commitPanelPos);
|
|
578
|
+
if (finalPos) {
|
|
579
|
+
setPanelPos(finalPos);
|
|
580
|
+
const layout = readStoredShellLayout(shellId);
|
|
581
|
+
writeStoredShellLayout(shellId, { ...layout, panel: finalPos });
|
|
582
|
+
}
|
|
523
583
|
};
|
|
524
584
|
window.addEventListener("pointermove", onMove);
|
|
525
585
|
window.addEventListener("pointerup", onUp);
|
|
526
|
-
}, [draggable]);
|
|
586
|
+
}, [draggable, shellId]);
|
|
527
587
|
if (!shellId) {
|
|
528
588
|
console.error("[DuctShell] shellId prop is required");
|
|
529
589
|
return null;
|
|
@@ -606,7 +666,15 @@ export function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, on
|
|
|
606
666
|
padding: 0,
|
|
607
667
|
transition: isDragging ? "none" : "transform 150ms ease, box-shadow 150ms ease",
|
|
608
668
|
};
|
|
609
|
-
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("
|
|
669
|
+
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("span", { "aria-hidden": "true", style: {
|
|
670
|
+
color: "#E8622A",
|
|
671
|
+
fontSize: 11,
|
|
672
|
+
fontWeight: 600,
|
|
673
|
+
letterSpacing: "-0.02em",
|
|
674
|
+
lineHeight: 1,
|
|
675
|
+
pointerEvents: "none",
|
|
676
|
+
userSelect: "none",
|
|
677
|
+
}, children: "du\u2184t" }));
|
|
610
678
|
return (_jsxs(_Fragment, { children: [!panelOpen && (_jsx("button", { type: "button", style: {
|
|
611
679
|
...bubbleStyle,
|
|
612
680
|
...bubbleLauncherStyle,
|