@duct-sdk/sdk 0.5.1 → 0.5.2
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 +5 -0
- package/dist/adapters/react/shell.js +17 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog — @duct-sdk/sdk
|
|
2
2
|
|
|
3
|
+
## [0.5.2] — 2026-07-12
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- **`DUCT_TOKEN_PUSH`** — `DuctShell` pushes a fresh `onTokenRequest` token when the iframe is ready and whenever the panel opens, so host login reconnects the chat without a hard refresh.
|
|
7
|
+
|
|
3
8
|
## [0.5.1] — 2026-07-09
|
|
4
9
|
|
|
5
10
|
### Changed
|
|
@@ -311,18 +311,31 @@ export function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, on
|
|
|
311
311
|
const postToShell = useCallback((message) => {
|
|
312
312
|
iframeRef.current?.contentWindow?.postMessage(message, shellOrigin);
|
|
313
313
|
}, [shellOrigin]);
|
|
314
|
+
/** Push a fresh host session token into the iframe (no round-trip request). */
|
|
315
|
+
const pushTokenToShell = useCallback(async () => {
|
|
316
|
+
if (!onTokenRequest)
|
|
317
|
+
return;
|
|
318
|
+
try {
|
|
319
|
+
const token = await onTokenRequest(shellId);
|
|
320
|
+
postToShell({ type: "DUCT_TOKEN_PUSH", token: token ?? "" });
|
|
321
|
+
}
|
|
322
|
+
catch {
|
|
323
|
+
// Host mint failed — shell retries on the next user message.
|
|
324
|
+
}
|
|
325
|
+
}, [onTokenRequest, shellId, postToShell]);
|
|
314
326
|
// Toggle open state
|
|
315
327
|
const setOpen = useCallback((next) => {
|
|
316
328
|
if (!controlled)
|
|
317
329
|
setIsOpen(next);
|
|
318
330
|
onOpenChange?.(next);
|
|
319
331
|
}, [controlled, onOpenChange]);
|
|
320
|
-
// Animate open
|
|
332
|
+
// Animate open — also reconnect session token so login does not need a hard refresh.
|
|
321
333
|
const openPanel = useCallback(() => {
|
|
322
334
|
setIsAnimating(true);
|
|
323
335
|
setOpen(true);
|
|
324
336
|
requestAnimationFrame(() => requestAnimationFrame(() => setIsAnimating(false)));
|
|
325
|
-
|
|
337
|
+
void pushTokenToShell();
|
|
338
|
+
}, [setOpen, pushTokenToShell]);
|
|
326
339
|
// Animate close
|
|
327
340
|
const closePanel = useCallback(() => {
|
|
328
341
|
setIsAnimating(true);
|
|
@@ -367,6 +380,7 @@ export function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, on
|
|
|
367
380
|
if (userContext && Object.keys(userContext).length > 0) {
|
|
368
381
|
postToShell({ type: "DUCT_USER_CONTEXT", context: userContext });
|
|
369
382
|
}
|
|
383
|
+
void pushTokenToShell();
|
|
370
384
|
break;
|
|
371
385
|
}
|
|
372
386
|
case "DUCT_REQUEST_TOKEN": {
|
|
@@ -440,7 +454,7 @@ export function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, on
|
|
|
440
454
|
break;
|
|
441
455
|
}
|
|
442
456
|
}
|
|
443
|
-
}, [shellOrigin, isAllowedDeeplinkUrl, userContext, onTokenRequest, onPageContext, postToShell, onNavigate, openPanel, closePanel]);
|
|
457
|
+
}, [shellOrigin, isAllowedDeeplinkUrl, userContext, onTokenRequest, onPageContext, postToShell, onNavigate, openPanel, closePanel, pushTokenToShell]);
|
|
444
458
|
useEffect(() => {
|
|
445
459
|
window.addEventListener("message", handleMessage);
|
|
446
460
|
return () => window.removeEventListener("message", handleMessage);
|