@assistant-ui/react 0.15.22 → 0.15.23
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/LICENSE +1 -1
- package/dist/primitives/message/MessageIf.d.ts.map +1 -1
- package/dist/primitives/message/MessageIf.js +6 -3
- package/dist/primitives/message/MessageIf.js.map +1 -1
- package/dist/primitives/thread/ThreadRoot.d.ts +3 -2
- package/dist/primitives/thread/ThreadRoot.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadRoot.js +47 -27
- package/dist/primitives/thread/ThreadRoot.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.js +1 -0
- package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.d.ts.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.js +1 -0
- package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.d.ts.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.js +1 -0
- package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.js.map +1 -1
- package/dist/unstable/webmcp/WebMcpRegistrationResource.d.ts +1 -0
- package/dist/unstable/webmcp/WebMcpRegistrationResource.d.ts.map +1 -1
- package/dist/unstable/webmcp/WebMcpRegistrationResource.js +27 -39
- package/dist/unstable/webmcp/WebMcpRegistrationResource.js.map +1 -1
- package/dist/unstable/webmcp/useWebMcpProvider.d.ts.map +1 -1
- package/dist/unstable/webmcp/useWebMcpProvider.js +22 -13
- package/dist/unstable/webmcp/useWebMcpProvider.js.map +1 -1
- package/package.json +10 -7
- package/src/primitives/message/MessageIf.test.tsx +72 -0
- package/src/primitives/message/MessageIf.ts +8 -3
- package/src/primitives/thread/ThreadRoot.test.tsx +130 -0
- package/src/primitives/thread/ThreadRoot.tsx +30 -3
- package/src/primitives/threadListItem/ThreadListItemRoot.tsx +2 -0
- package/src/primitives/threadListItem/ThreadListKeyboardNav.test.tsx +65 -0
- package/src/primitives/threadListItemMore/ThreadListItemMoreContent.tsx +7 -0
- package/src/primitives/threadListItemMore/ThreadListItemMoreTrigger.tsx +2 -0
- package/src/tests/RemoteThreadListRuntime.reloadMainThread.test.tsx +8 -13
- package/src/tests/remote-thread-list-test-helpers.ts +15 -0
- package/src/tests/threadListItemIsRunning.test.tsx +10 -7
- package/src/unstable/webmcp/WebMcpRegistrationResource.ts +9 -8
- package/src/unstable/webmcp/useWebMcpProvider.test.tsx +36 -2
- package/src/unstable/webmcp/useWebMcpProvider.ts +40 -13
package/LICENSE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageIf.d.ts","sourceRoot":"","sources":["../../../src/primitives/message/MessageIf.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,yCAAsC;AAEvE,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1B,SAAS,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,cAAc,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,UAAU,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,iBAAiB,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;CAC/D,CAAC;AACF,KAAK,iBAAiB,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"MessageIf.d.ts","sourceRoot":"","sources":["../../../src/primitives/message/MessageIf.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,yCAAsC;AAEvE,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1B,SAAS,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,cAAc,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,UAAU,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,iBAAiB,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;CAC/D,CAAC;AACF,KAAK,iBAAiB,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;AA6D7D,yBAAiB,kBAAkB,CAAC;IAClC,KAAY,KAAK,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;CAC1D;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAM3D,CAAC"}
|
|
@@ -9,9 +9,12 @@ const useMessageIf = (props) => {
|
|
|
9
9
|
t0 = (s) => {
|
|
10
10
|
const { role, attachments, parts, branchCount, isLast, speech, isCopied, isHovering } = s.message;
|
|
11
11
|
if (props.hasBranches === true && branchCount < 2) return false;
|
|
12
|
-
if (props.user && role !== "user") return false;
|
|
13
|
-
if (props.
|
|
14
|
-
if (props.
|
|
12
|
+
if (props.user === true && role !== "user") return false;
|
|
13
|
+
if (props.user === false && role === "user") return false;
|
|
14
|
+
if (props.assistant === true && role !== "assistant") return false;
|
|
15
|
+
if (props.assistant === false && role === "assistant") return false;
|
|
16
|
+
if (props.system === true && role !== "system") return false;
|
|
17
|
+
if (props.system === false && role === "system") return false;
|
|
15
18
|
if (props.lastOrHover === true && !isHovering && !isLast) return false;
|
|
16
19
|
if (props.last !== void 0 && props.last !== isLast) return false;
|
|
17
20
|
if (props.copied === true && !isCopied) return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageIf.js","names":["c","_c","FC","PropsWithChildren","useAuiState","RequireAtLeastOne","MessageIfFilters","user","assistant","system","hasBranches","copied","lastOrHover","last","speaking","hasAttachments","hasContent","submittedFeedback","UseMessageIfProps","useMessageIf","props","$","t0","s","role","attachments","parts","branchCount","isLast","speech","isCopied","isHovering","message","undefined","length","metadata","type","MessagePrimitiveIf","Props","children","query","result","displayName"],"sources":["../../../src/primitives/message/MessageIf.ts"],"sourcesContent":["\"use client\";\n\nimport type { FC, PropsWithChildren } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport type { RequireAtLeastOne } from \"../../utils/RequireAtLeastOne\";\n\ntype MessageIfFilters = {\n user: boolean | undefined;\n assistant: boolean | undefined;\n system: boolean | undefined;\n hasBranches: boolean | undefined;\n copied: boolean | undefined;\n lastOrHover: boolean | undefined;\n last: boolean | undefined;\n speaking: boolean | undefined;\n hasAttachments: boolean | undefined;\n hasContent: boolean | undefined;\n submittedFeedback: \"positive\" | \"negative\" | null | undefined;\n};\ntype UseMessageIfProps = RequireAtLeastOne<MessageIfFilters>;\n\nconst useMessageIf = (props: UseMessageIfProps) => {\n return useAuiState((s) => {\n const {\n role,\n attachments,\n parts,\n branchCount,\n isLast,\n speech,\n isCopied,\n isHovering,\n } = s.message;\n\n if (props.hasBranches === true && branchCount < 2) return false;\n\n if (props.user && role !== \"user\") return false;\n if (props.assistant && role !== \"assistant\") return false;\n if (props.system && role !== \"system\") return false;\n\n if (props.lastOrHover === true && !isHovering && !isLast) return false;\n if (props.last !== undefined && props.last !== isLast) return false;\n\n if (props.copied === true && !isCopied) return false;\n if (props.copied === false && isCopied) return false;\n\n if (props.speaking === true && speech == null) return false;\n if (props.speaking === false && speech != null) return false;\n\n if (\n props.hasAttachments === true &&\n (role !== \"user\" || !attachments?.length)\n )\n return false;\n if (\n props.hasAttachments === false &&\n role === \"user\" &&\n attachments?.length\n )\n return false;\n\n if (props.hasContent === true && parts.length === 0) return false;\n if (props.hasContent === false && parts.length > 0) return false;\n\n if (\n props.submittedFeedback !== undefined &&\n (s.message.metadata.submittedFeedback?.type ?? null) !==\n props.submittedFeedback\n )\n return false;\n\n return true;\n });\n};\n\nexport namespace MessagePrimitiveIf {\n export type Props = PropsWithChildren<UseMessageIfProps>;\n}\n\n/**\n * @deprecated Use `<AuiIf condition={(s) => s.message...} />` instead.\n */\nexport const MessagePrimitiveIf: FC<MessagePrimitiveIf.Props> = ({\n children,\n ...query\n}) => {\n const result = useMessageIf(query);\n return result ? children : null;\n};\n\nMessagePrimitiveIf.displayName = \"MessagePrimitive.If\";\n"],"mappings":";;;;AAqBA,MAAMmB,gBAAeC,UAAA;CAAA,MAAAC,IAAApB,EAAA,EAAA;CAAA,IAAAqB;CAAA,IAAAD,EAAA,OAAAD,MAAAZ,aAAAa,EAAA,OAAAD,MAAAT,UAAAU,EAAA,OAAAD,MAAAL,kBAAAM,EAAA,OAAAD,MAAAV,eAAAW,EAAA,OAAAD,MAAAJ,cAAAK,EAAA,OAAAD,MAAAP,QAAAQ,EAAA,OAAAD,MAAAR,eAAAS,EAAA,OAAAD,MAAAN,YAAAO,EAAA,OAAAD,MAAAH,qBAAAI,EAAA,OAAAD,MAAAX,UAAAY,EAAA,QAAAD,MAAAb,MAAA;EACAe,MAAAC,MAAA;GACjB,MAAA,EAAAC,MAAAC,aAAAC,OAAAC,aAAAC,QAAAC,QAAAC,UAAAC,eASIR,EAACS;GAEL,IAAIZ,MAAKV,gBAAiB,QAAQiB,cAAc,GAAC,OAAS;GAE1D,IAAIP,MAAKb,
|
|
1
|
+
{"version":3,"file":"MessageIf.js","names":["c","_c","FC","PropsWithChildren","useAuiState","RequireAtLeastOne","MessageIfFilters","user","assistant","system","hasBranches","copied","lastOrHover","last","speaking","hasAttachments","hasContent","submittedFeedback","UseMessageIfProps","useMessageIf","props","$","t0","s","role","attachments","parts","branchCount","isLast","speech","isCopied","isHovering","message","undefined","length","metadata","type","MessagePrimitiveIf","Props","children","query","result","displayName"],"sources":["../../../src/primitives/message/MessageIf.ts"],"sourcesContent":["\"use client\";\n\nimport type { FC, PropsWithChildren } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport type { RequireAtLeastOne } from \"../../utils/RequireAtLeastOne\";\n\ntype MessageIfFilters = {\n user: boolean | undefined;\n assistant: boolean | undefined;\n system: boolean | undefined;\n hasBranches: boolean | undefined;\n copied: boolean | undefined;\n lastOrHover: boolean | undefined;\n last: boolean | undefined;\n speaking: boolean | undefined;\n hasAttachments: boolean | undefined;\n hasContent: boolean | undefined;\n submittedFeedback: \"positive\" | \"negative\" | null | undefined;\n};\ntype UseMessageIfProps = RequireAtLeastOne<MessageIfFilters>;\n\nconst useMessageIf = (props: UseMessageIfProps) => {\n return useAuiState((s) => {\n const {\n role,\n attachments,\n parts,\n branchCount,\n isLast,\n speech,\n isCopied,\n isHovering,\n } = s.message;\n\n if (props.hasBranches === true && branchCount < 2) return false;\n\n if (props.user === true && role !== \"user\") return false;\n if (props.user === false && role === \"user\") return false;\n\n if (props.assistant === true && role !== \"assistant\") return false;\n if (props.assistant === false && role === \"assistant\") return false;\n\n if (props.system === true && role !== \"system\") return false;\n if (props.system === false && role === \"system\") return false;\n\n if (props.lastOrHover === true && !isHovering && !isLast) return false;\n if (props.last !== undefined && props.last !== isLast) return false;\n\n if (props.copied === true && !isCopied) return false;\n if (props.copied === false && isCopied) return false;\n\n if (props.speaking === true && speech == null) return false;\n if (props.speaking === false && speech != null) return false;\n\n if (\n props.hasAttachments === true &&\n (role !== \"user\" || !attachments?.length)\n )\n return false;\n if (\n props.hasAttachments === false &&\n role === \"user\" &&\n attachments?.length\n )\n return false;\n\n if (props.hasContent === true && parts.length === 0) return false;\n if (props.hasContent === false && parts.length > 0) return false;\n\n if (\n props.submittedFeedback !== undefined &&\n (s.message.metadata.submittedFeedback?.type ?? null) !==\n props.submittedFeedback\n )\n return false;\n\n return true;\n });\n};\n\nexport namespace MessagePrimitiveIf {\n export type Props = PropsWithChildren<UseMessageIfProps>;\n}\n\n/**\n * @deprecated Use `<AuiIf condition={(s) => s.message...} />` instead.\n */\nexport const MessagePrimitiveIf: FC<MessagePrimitiveIf.Props> = ({\n children,\n ...query\n}) => {\n const result = useMessageIf(query);\n return result ? children : null;\n};\n\nMessagePrimitiveIf.displayName = \"MessagePrimitive.If\";\n"],"mappings":";;;;AAqBA,MAAMmB,gBAAeC,UAAA;CAAA,MAAAC,IAAApB,EAAA,EAAA;CAAA,IAAAqB;CAAA,IAAAD,EAAA,OAAAD,MAAAZ,aAAAa,EAAA,OAAAD,MAAAT,UAAAU,EAAA,OAAAD,MAAAL,kBAAAM,EAAA,OAAAD,MAAAV,eAAAW,EAAA,OAAAD,MAAAJ,cAAAK,EAAA,OAAAD,MAAAP,QAAAQ,EAAA,OAAAD,MAAAR,eAAAS,EAAA,OAAAD,MAAAN,YAAAO,EAAA,OAAAD,MAAAH,qBAAAI,EAAA,OAAAD,MAAAX,UAAAY,EAAA,QAAAD,MAAAb,MAAA;EACAe,MAAAC,MAAA;GACjB,MAAA,EAAAC,MAAAC,aAAAC,OAAAC,aAAAC,QAAAC,QAAAC,UAAAC,eASIR,EAACS;GAEL,IAAIZ,MAAKV,gBAAiB,QAAQiB,cAAc,GAAC,OAAS;GAE1D,IAAIP,MAAKb,SAAU,QAAQiB,SAAS,QAAM,OAAS;GACnD,IAAIJ,MAAKb,SAAU,SAASiB,SAAS,QAAM,OAAS;GAEpD,IAAIJ,MAAKZ,cAAe,QAAQgB,SAAS,aAAW,OAAS;GAC7D,IAAIJ,MAAKZ,cAAe,SAASgB,SAAS,aAAW,OAAS;GAE9D,IAAIJ,MAAKX,WAAY,QAAQe,SAAS,UAAQ,OAAS;GACvD,IAAIJ,MAAKX,WAAY,SAASe,SAAS,UAAQ,OAAS;GAExD,IAAIJ,MAAKR,gBAAiB,QAAtB,CAA+BmB,cAA/B,CAA8CH,QAAM,OAAS;GACjE,IAAIR,MAAKP,SAAUoB,KAAAA,KAAab,MAAKP,SAAUe,QAAM,OAAS;GAE9D,IAAIR,MAAKT,WAAY,QAAjB,CAA0BmB,UAAQ,OAAS;GAC/C,IAAIV,MAAKT,WAAY,SAAjBmB,UAAkC,OAAS;GAE/C,IAAIV,MAAKN,aAAc,QAAQe,UAAU,MAAI,OAAS;GACtD,IAAIT,MAAKN,aAAc,SAASe,UAAU,MAAI,OAAS;GAEvD,IACET,MAAKL,mBAAoB,SACxBS,SAAS,UAAT,CAAoBC,aAAWS,SAAS,OAElC;GACT,IACEd,MAAKL,mBAAoB,SACzBS,SAAS,UACTC,aAAWS,QAAQ,OAEZ;GAET,IAAId,MAAKJ,eAAgB,QAAQU,MAAKQ,WAAY,GAAC,OAAS;GAC5D,IAAId,MAAKJ,eAAgB,SAASU,MAAKQ,SAAU,GAAC,OAAS;GAE3D,IACEd,MAAKH,sBAAuBgB,KAAAA,MAC3BV,EAACS,QAAQG,SAASlB,mBAAwBmB,QAA1C,UACChB,MAAKH,mBAAkB,OAElB;GAAM,OAER;EAAI;EACZI,EAAA,KAAAD,MAAAZ;EAAAa,EAAA,KAAAD,MAAAT;EAAAU,EAAA,KAAAD,MAAAL;EAAAM,EAAA,KAAAD,MAAAV;EAAAW,EAAA,KAAAD,MAAAJ;EAAAK,EAAA,KAAAD,MAAAP;EAAAQ,EAAA,KAAAD,MAAAR;EAAAS,EAAA,KAAAD,MAAAN;EAAAO,EAAA,KAAAD,MAAAH;EAAAI,EAAA,KAAAD,MAAAX;EAAAY,EAAA,MAAAD,MAAAb;EAAAc,EAAA,MAAAC;CAAA,OAAAA,KAAAD,EAAA;CAAA,OAvDMjB,YAAYkB,EAuDlB;AAAC;;;;AAUJ,MAAae,sBAAmDf,OAAA;CAAA,MAAAD,IAAApB,EAAA,CAAA;CAAA,IAAAsC;CAAA,IAAAC;CAAA,IAAAnB,EAAA,OAAAC,IAAA;EAAC,CAAA,CAAAiB,UAAA,GAAAC,SAAAlB;EAGhED,EAAA,KAAAC;EAAAD,EAAA,KAAAkB;EAAAlB,EAAA,KAAAmB;CAAA,OAAA;EAAAD,WAAAlB,EAAA;EAAAmB,QAAAnB,EAAA;CAAA;CACoC,OAApBF,aAAaqB,KACrBC,IAAAF,WAAA;AAAwB;AAGjCF,mBAAmBK,cAAc"}
|
|
@@ -14,8 +14,9 @@ export declare namespace ThreadPrimitiveRoot {
|
|
|
14
14
|
* This component serves as the foundational wrapper for all thread-related components.
|
|
15
15
|
* It provides the basic structure and context needed for thread functionality.
|
|
16
16
|
*
|
|
17
|
-
* While this component is mounted, an unhandled Escape keydown
|
|
18
|
-
* the action bar that started it is no longer mounted.
|
|
17
|
+
* While this component is mounted, an unhandled Escape keydown inside this thread stops its
|
|
18
|
+
* active speech, even if the action bar that started it is no longer mounted. Escape outside
|
|
19
|
+
* every thread retains the document-level fallback.
|
|
19
20
|
*
|
|
20
21
|
* @example
|
|
21
22
|
* ```tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadRoot.d.ts","sourceRoot":"","sources":["../../../src/primitives/thread/ThreadRoot.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,iCAA8B;AAClD,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,wBAAwB,
|
|
1
|
+
{"version":3,"file":"ThreadRoot.d.ts","sourceRoot":"","sources":["../../../src/primitives/thread/ThreadRoot.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,iCAA8B;AAClD,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,wBAAwB,EAI9B,MAAM,OAAO,CAAC;AAOf,yBAAiB,mBAAmB,CAAC;IACnC,KAAY,OAAO,GAAG,YAAY,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;IACzD;;;OAGG;IACH,KAAY,KAAK,GAAG,wBAAwB,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;CACpE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,mBAAmB;;;;0GA8D9B,CAAC"}
|
|
@@ -7,14 +7,16 @@ import { useAui } from "@assistant-ui/store";
|
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
import { useComposedRefs } from "radix-ui/internal";
|
|
9
9
|
//#region src/primitives/thread/ThreadRoot.tsx
|
|
10
|
+
const escapeEventThreadRoots = /* @__PURE__ */ new WeakMap();
|
|
10
11
|
/**
|
|
11
12
|
* The root container component for a thread.
|
|
12
13
|
*
|
|
13
14
|
* This component serves as the foundational wrapper for all thread-related components.
|
|
14
15
|
* It provides the basic structure and context needed for thread functionality.
|
|
15
16
|
*
|
|
16
|
-
* While this component is mounted, an unhandled Escape keydown
|
|
17
|
-
* the action bar that started it is no longer mounted.
|
|
17
|
+
* While this component is mounted, an unhandled Escape keydown inside this thread stops its
|
|
18
|
+
* active speech, even if the action bar that started it is no longer mounted. Escape outside
|
|
19
|
+
* every thread retains the document-level fallback.
|
|
18
20
|
*
|
|
19
21
|
* @example
|
|
20
22
|
* ```tsx
|
|
@@ -28,23 +30,35 @@ import { useComposedRefs } from "radix-ui/internal";
|
|
|
28
30
|
* ```
|
|
29
31
|
*/
|
|
30
32
|
const ThreadPrimitiveRoot = forwardRef((props, ref) => {
|
|
31
|
-
const $ = c(
|
|
33
|
+
const $ = c(9);
|
|
32
34
|
const aui = useAui();
|
|
33
35
|
const rootRef = useRef(null);
|
|
34
36
|
const composedRef = useComposedRefs(ref, rootRef);
|
|
35
37
|
let t0;
|
|
38
|
+
if ($[0] !== props) {
|
|
39
|
+
t0 = (event) => {
|
|
40
|
+
if (event.key === "Escape" && rootRef.current) escapeEventThreadRoots.set(event.nativeEvent, rootRef.current);
|
|
41
|
+
props.onKeyDown?.(event);
|
|
42
|
+
};
|
|
43
|
+
$[0] = props;
|
|
44
|
+
$[1] = t0;
|
|
45
|
+
} else t0 = $[1];
|
|
46
|
+
const handleRootKeyDown = t0;
|
|
36
47
|
let t1;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (
|
|
48
|
+
let t2;
|
|
49
|
+
if ($[2] !== aui) {
|
|
50
|
+
t1 = () => {
|
|
51
|
+
const handleKeyDown = (event_0) => {
|
|
52
|
+
if (event_0.key !== "Escape") return;
|
|
53
|
+
if (event_0.defaultPrevented || aui.thread.source === null) return;
|
|
54
|
+
const eventThreadRoot = escapeEventThreadRoots.get(event_0) ?? event_0.composedPath().find(_temp);
|
|
55
|
+
if (eventThreadRoot && eventThreadRoot !== rootRef.current) return;
|
|
42
56
|
if (aui.thread.getState().speech == null) return;
|
|
43
|
-
|
|
57
|
+
event_0.preventDefault();
|
|
44
58
|
try {
|
|
45
59
|
aui.thread.stopSpeaking();
|
|
46
|
-
} catch (
|
|
47
|
-
const error =
|
|
60
|
+
} catch (t3) {
|
|
61
|
+
const error = t3;
|
|
48
62
|
if (!(error instanceof Error) || error.message !== "No message is being spoken") throw error;
|
|
49
63
|
}
|
|
50
64
|
};
|
|
@@ -53,31 +67,37 @@ const ThreadPrimitiveRoot = forwardRef((props, ref) => {
|
|
|
53
67
|
document.removeEventListener("keydown", handleKeyDown);
|
|
54
68
|
};
|
|
55
69
|
};
|
|
56
|
-
|
|
57
|
-
$[
|
|
58
|
-
$[
|
|
59
|
-
$[
|
|
70
|
+
t2 = [aui];
|
|
71
|
+
$[2] = aui;
|
|
72
|
+
$[3] = t1;
|
|
73
|
+
$[4] = t2;
|
|
60
74
|
} else {
|
|
61
|
-
|
|
62
|
-
|
|
75
|
+
t1 = $[3];
|
|
76
|
+
t2 = $[4];
|
|
63
77
|
}
|
|
64
|
-
useEffect(
|
|
65
|
-
let
|
|
66
|
-
if ($[
|
|
67
|
-
|
|
78
|
+
useEffect(t1, t2);
|
|
79
|
+
let t3;
|
|
80
|
+
if ($[5] !== composedRef || $[6] !== handleRootKeyDown || $[7] !== props) {
|
|
81
|
+
t3 = /* @__PURE__ */ jsx(ThreadRootElementContext.Provider, {
|
|
68
82
|
value: rootRef,
|
|
69
83
|
children: /* @__PURE__ */ jsx(Primitive$1.div, {
|
|
70
84
|
...props,
|
|
71
|
-
|
|
85
|
+
"data-aui-thread-root": "",
|
|
86
|
+
ref: composedRef,
|
|
87
|
+
onKeyDown: handleRootKeyDown
|
|
72
88
|
})
|
|
73
89
|
});
|
|
74
|
-
$[
|
|
75
|
-
$[
|
|
76
|
-
$[
|
|
77
|
-
|
|
78
|
-
|
|
90
|
+
$[5] = composedRef;
|
|
91
|
+
$[6] = handleRootKeyDown;
|
|
92
|
+
$[7] = props;
|
|
93
|
+
$[8] = t3;
|
|
94
|
+
} else t3 = $[8];
|
|
95
|
+
return t3;
|
|
79
96
|
});
|
|
80
97
|
ThreadPrimitiveRoot.displayName = "ThreadPrimitive.Root";
|
|
98
|
+
function _temp(target) {
|
|
99
|
+
return target instanceof Element && target.hasAttribute("data-aui-thread-root");
|
|
100
|
+
}
|
|
81
101
|
//#endregion
|
|
82
102
|
export { ThreadPrimitiveRoot };
|
|
83
103
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadRoot.js","names":["c","_c","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","useEffect","useRef","useAui","useComposedRefs","ThreadRootElementContext","
|
|
1
|
+
{"version":3,"file":"ThreadRoot.js","names":["c","_c","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","KeyboardEventHandler","useEffect","useRef","useAui","useComposedRefs","ThreadRootElementContext","escapeEventThreadRoots","WeakMap","KeyboardEvent","Element","ThreadPrimitiveRoot","div","Props","props","ref","$","aui","rootRef","composedRef","t0","event","key","current","set","nativeEvent","onKeyDown","handleRootKeyDown","t1","t2","handleKeyDown","event_0","defaultPrevented","thread","source","eventThreadRoot","get","composedPath","find","_temp","getState","speech","preventDefault","stopSpeaking","t3","error","Error","message","document","addEventListener","removeEventListener","displayName","target","hasAttribute"],"sources":["../../../src/primitives/thread/ThreadRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n type KeyboardEventHandler,\n useEffect,\n useRef,\n} from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useComposedRefs } from \"radix-ui/internal\";\nimport { ThreadRootElementContext } from \"./ThreadRootElementContext\";\n\nconst escapeEventThreadRoots = new WeakMap<KeyboardEvent, Element>();\n\nexport namespace ThreadPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n /**\n * Props for the ThreadPrimitive.Root component.\n * Accepts all standard div element props.\n */\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;\n}\n\n/**\n * The root container component for a thread.\n *\n * This component serves as the foundational wrapper for all thread-related components.\n * It provides the basic structure and context needed for thread functionality.\n *\n * While this component is mounted, an unhandled Escape keydown inside this thread stops its\n * active speech, even if the action bar that started it is no longer mounted. Escape outside\n * every thread retains the document-level fallback.\n *\n * @example\n * ```tsx\n * <ThreadPrimitive.Root>\n * <ThreadPrimitive.Viewport>\n * <ThreadPrimitive.Messages>\n * {() => <MyMessage />}\n * </ThreadPrimitive.Messages>\n * </ThreadPrimitive.Viewport>\n * </ThreadPrimitive.Root>\n * ```\n */\nexport const ThreadPrimitiveRoot = forwardRef<\n ThreadPrimitiveRoot.Element,\n ThreadPrimitiveRoot.Props\n>((props, ref) => {\n const aui = useAui();\n const rootRef = useRef<ThreadPrimitiveRoot.Element>(null);\n const composedRef = useComposedRefs(ref, rootRef);\n const handleRootKeyDown: KeyboardEventHandler<ThreadPrimitiveRoot.Element> = (\n event,\n ) => {\n if (event.key === \"Escape\" && rootRef.current) {\n escapeEventThreadRoots.set(event.nativeEvent, rootRef.current);\n }\n props.onKeyDown?.(event);\n };\n\n useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key !== \"Escape\") return;\n if (event.defaultPrevented || aui.thread.source === null) return;\n const eventThreadRoot =\n escapeEventThreadRoots.get(event) ??\n event\n .composedPath()\n .find(\n (target) =>\n target instanceof Element &&\n target.hasAttribute(\"data-aui-thread-root\"),\n );\n if (eventThreadRoot && eventThreadRoot !== rootRef.current) return;\n if (aui.thread.getState().speech == null) return;\n event.preventDefault();\n try {\n aui.thread.stopSpeaking();\n } catch (error) {\n // getState() is the last rendered snapshot, so speech can finish before this call.\n if (\n !(error instanceof Error) ||\n error.message !== \"No message is being spoken\"\n ) {\n throw error;\n }\n }\n };\n\n // Bubble phase lets capture-phase Escape handlers consume the event first.\n document.addEventListener(\"keydown\", handleKeyDown);\n return () => {\n document.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, [aui]);\n\n return (\n <ThreadRootElementContext.Provider value={rootRef}>\n <Primitive.div\n {...props}\n data-aui-thread-root=\"\"\n ref={composedRef}\n onKeyDown={handleRootKeyDown}\n />\n </ThreadRootElementContext.Provider>\n );\n});\n\nThreadPrimitiveRoot.displayName = \"ThreadPrimitive.Root\";\n"],"mappings":";;;;;;;;;AAeA,MAAMY,yCAAyB,IAAIC,QAAgC;;;;;;;;;;;;;;;;;;;;;;AAgCnE,MAAaG,sBAAsBZ,YAGjCe,OAAAC,QAAA;CAAA,MAAAC,IAAApB,EAAA,CAAA;CACA,MAAAqB,MAAYb,OAAO;CACnB,MAAAc,UAAgBf,OAAoC,IAAI;CACxD,MAAAgB,cAAoBd,gBAAgBU,KAAKG,OAAO;CAAE,IAAAE;CAAA,IAAAJ,EAAA,OAAAF,OAAA;EAC2BM,MAAAC,UAAA;GAG3E,IAAIA,MAAKC,QAAS,YAAYJ,QAAOK,SACnChB,uBAAsBiB,IAAKH,MAAKI,aAAcP,QAAOK,OAAQ;GAE/DT,MAAKY,YAAaL,KAAK;EAAC;EACzBL,EAAA,KAAAF;EAAAE,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAPD,MAAAW,oBAA6EP;CAO3E,IAAAQ;CAAA,IAAAC;CAAA,IAAAb,EAAA,OAAAC,KAAA;EAEQW,WAAA;GACR,MAAAE,iBAAsBC,YAAA;IACpB,IAAIV,QAAKC,QAAS,UAAQ;IAC1B,IAAID,QAAKW,oBAAqBf,IAAGgB,OAAOC,WAAY,MAAI;IACxD,MAAAC,kBACE5B,uBAAsB6B,IAAKf,OAOzB,KANFA,QAAKgB,aACW,CAAC,CAAAC,KAEbC,KAGF;IACJ,IAAIJ,mBAAmBA,oBAAoBjB,QAAOK,SAAQ;IAC1D,IAAIN,IAAGgB,OAAOO,SAAU,CAAC,CAAAC,UAAW,MAAI;IACxCpB,QAAKqB,eAAgB;IACrB,IAAA;KACEzB,IAAGgB,OAAOU,aAAc;IAAC,SAAAC,IAAA;KAClBC,MAAAA,QAAAA;KAEP,IACE,EAAEA,iBAAiBC,UACnBD,MAAKE,YAAa,8BAElB,MAAMF;IACP;GACF;GAIHG,SAAQC,iBAAkB,WAAWnB,aAAa;GAAC,aAC5C;IACLkB,SAAQE,oBAAqB,WAAWpB,aAAa;GAAC;EACvD;EACAD,KAAA,CAACZ,GAAG;EAACD,EAAA,KAAAC;EAAAD,EAAA,KAAAY;EAAAZ,EAAA,KAAAa;CAAA,OAAA;EAAAD,KAAAZ,EAAA;EAAAa,KAAAb,EAAA;CAAA;CAlCRd,UAAU0B,IAkCPC,EAAK;CAAC,IAAAe;CAAA,IAAA5B,EAAA,OAAAG,eAAAH,EAAA,OAAAW,qBAAAX,EAAA,OAAAF,OAAA;EAGP8B,KAAA,oBAAA,yBAAA,UAAA;GAA0C1B,OAAAA;GACxC,UAAA,oBAAA,YAAA,KAAA;IAAA,GACMJ;IACiB,wBAAA;IAChBK,KAAAA;IACMQ,WAAAA;GAAiB,CAAA;EAEhC,CAAA;EAAoCX,EAAA,KAAAG;EAAAH,EAAA,KAAAW;EAAAX,EAAA,KAAAF;EAAAE,EAAA,KAAA4B;CAAA,OAAAA,KAAA5B,EAAA;CAAA,OAPpC4B;AAOoC,CAEvC;AAEDjC,oBAAoBwC,cAAc;AA7DhC,SAAAZ,MAAAa,QAAA;CAAA,OAuBYA,kBAAkB1C,WAClB0C,OAAMC,aAAc,sBAAsB;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadListItemRoot.d.ts","sourceRoot":"","sources":["../../../src/primitives/threadListItem/ThreadListItemRoot.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,iCAA8B;AAClD,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,wBAAwB,EAI9B,MAAM,OAAO,CAAC;AASf,KAAK,iBAAiB,GAAG,wBAAwB,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;AAExE,yBAAiB,2BAA2B,CAAC;IAC3C,KAAY,OAAO,GAAG,YAAY,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;IACzD,KAAY,KAAK,GAAG,iBAAiB,CAAC;CACvC;AAED,eAAO,MAAM,2BAA2B;;;;
|
|
1
|
+
{"version":3,"file":"ThreadListItemRoot.d.ts","sourceRoot":"","sources":["../../../src/primitives/threadListItem/ThreadListItemRoot.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,iCAA8B;AAClD,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,wBAAwB,EAI9B,MAAM,OAAO,CAAC;AASf,KAAK,iBAAiB,GAAG,wBAAwB,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;AAExE,yBAAiB,2BAA2B,CAAC;IAC3C,KAAY,OAAO,GAAG,YAAY,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;IACzD,KAAY,KAAK,GAAG,iBAAiB,CAAC;CACvC;AAED,eAAO,MAAM,2BAA2B;;;;0GAwDtC,CAAC"}
|
|
@@ -18,6 +18,7 @@ const ThreadListItemPrimitiveRoot = forwardRef((props, ref) => {
|
|
|
18
18
|
const getItems = useThreadListCollection(void 0);
|
|
19
19
|
const direction = Direction.useDirection();
|
|
20
20
|
const onKeyDown = (event) => {
|
|
21
|
+
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;
|
|
21
22
|
const forwardKey = direction === "rtl" ? "ArrowLeft" : "ArrowRight";
|
|
22
23
|
const backKey = direction === "rtl" ? "ArrowRight" : "ArrowLeft";
|
|
23
24
|
const trigger = triggerRef.current;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadListItemRoot.js","names":["Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","KeyboardEvent","useMemo","useRef","useAuiState","composeEventHandlers","Direction","ThreadListItemFocusProvider","useThreadListCollection","PrimitiveDivProps","div","ThreadListItemPrimitiveRoot","Element","Props","props","ref","isMain","s","threads","mainThreadId","threadListItem","id","triggerRef","HTMLButtonElement","moreRef","focus","getItems","undefined","direction","useDirection","onKeyDown","event","HTMLDivElement","forwardKey","backKey","trigger","current","more","target","key","triggers","map","item","filter","node","next","indexOf","preventDefault","displayName"],"sources":["../../../src/primitives/threadListItem/ThreadListItemRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n type KeyboardEvent,\n useMemo,\n useRef,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport { Direction } from \"radix-ui\";\nimport {\n ThreadListItemFocusProvider,\n useThreadListCollection,\n} from \"../threadListFocusGroup\";\n\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport namespace ThreadListItemPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = PrimitiveDivProps;\n}\n\nexport const ThreadListItemPrimitiveRoot = forwardRef<\n ThreadListItemPrimitiveRoot.Element,\n ThreadListItemPrimitiveRoot.Props\n>((props, ref) => {\n const isMain = useAuiState(\n (s) => s.threads.mainThreadId === s.threadListItem.id,\n );\n\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const moreRef = useRef<HTMLButtonElement | null>(null);\n const focus = useMemo(() => ({ triggerRef, moreRef }), []);\n\n const getItems = useThreadListCollection(undefined);\n const direction = Direction.useDirection();\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const forwardKey = direction === \"rtl\" ? \"ArrowLeft\" : \"ArrowRight\";\n const backKey = direction === \"rtl\" ? \"ArrowRight\" : \"ArrowLeft\";\n const trigger = triggerRef.current;\n const more = moreRef.current;\n\n if (trigger && event.target === trigger) {\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n const triggers = getItems()\n .map((item) => item.ref.current)\n .filter((node): node is HTMLButtonElement => node !== null);\n const next =\n triggers[\n triggers.indexOf(trigger) + (event.key === \"ArrowDown\" ? 1 : -1)\n ];\n if (next) {\n next.focus();\n event.preventDefault();\n }\n } else if (event.key === forwardKey && more) {\n more.focus();\n event.preventDefault();\n }\n } else if (more && event.target === more && event.key === backKey) {\n trigger?.focus();\n event.preventDefault();\n }\n };\n\n return (\n <ThreadListItemFocusProvider value={focus}>\n <Primitive.div\n {...(isMain ? { \"data-active\": \"true\", \"aria-current\": \"true\" } : null)}\n {...props}\n onKeyDown={composeEventHandlers(props.onKeyDown, onKeyDown)}\n ref={ref}\n />\n </ThreadListItemFocusProvider>\n );\n});\n\nThreadListItemPrimitiveRoot.displayName = \"ThreadListItemPrimitive.Root\";\n"],"mappings":";;;;;;;;;AA0BA,MAAac,8BAA8BZ,YAGxCe,OAAOC,QAAQ;CAChB,MAAMC,SAASZ,aACZa,MAAMA,EAAEC,QAAQC,iBAAiBF,EAAEG,eAAeC,EACrD;CAEA,MAAMC,aAAanB,OAAiC,IAAI;CACxD,MAAMqB,UAAUrB,OAAiC,IAAI;CACrD,MAAMsB,QAAQvB,eAAe;EAAEoB;EAAYE;CAAQ,IAAI,CAAA,CAAE;CAEzD,MAAME,WAAWlB,wBAAwBmB,KAAAA,CAAS;CAClD,MAAMC,YAAYtB,UAAUuB,aAAa;CAEzC,MAAMC,aAAaC,UAAyC;EAC1D,MAAME,
|
|
1
|
+
{"version":3,"file":"ThreadListItemRoot.js","names":["Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","KeyboardEvent","useMemo","useRef","useAuiState","composeEventHandlers","Direction","ThreadListItemFocusProvider","useThreadListCollection","PrimitiveDivProps","div","ThreadListItemPrimitiveRoot","Element","Props","props","ref","isMain","s","threads","mainThreadId","threadListItem","id","triggerRef","HTMLButtonElement","moreRef","focus","getItems","undefined","direction","useDirection","onKeyDown","event","HTMLDivElement","altKey","ctrlKey","metaKey","shiftKey","forwardKey","backKey","trigger","current","more","target","key","triggers","map","item","filter","node","next","indexOf","preventDefault","displayName"],"sources":["../../../src/primitives/threadListItem/ThreadListItemRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n type KeyboardEvent,\n useMemo,\n useRef,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport { Direction } from \"radix-ui\";\nimport {\n ThreadListItemFocusProvider,\n useThreadListCollection,\n} from \"../threadListFocusGroup\";\n\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport namespace ThreadListItemPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = PrimitiveDivProps;\n}\n\nexport const ThreadListItemPrimitiveRoot = forwardRef<\n ThreadListItemPrimitiveRoot.Element,\n ThreadListItemPrimitiveRoot.Props\n>((props, ref) => {\n const isMain = useAuiState(\n (s) => s.threads.mainThreadId === s.threadListItem.id,\n );\n\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const moreRef = useRef<HTMLButtonElement | null>(null);\n const focus = useMemo(() => ({ triggerRef, moreRef }), []);\n\n const getItems = useThreadListCollection(undefined);\n const direction = Direction.useDirection();\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)\n return;\n const forwardKey = direction === \"rtl\" ? \"ArrowLeft\" : \"ArrowRight\";\n const backKey = direction === \"rtl\" ? \"ArrowRight\" : \"ArrowLeft\";\n const trigger = triggerRef.current;\n const more = moreRef.current;\n\n if (trigger && event.target === trigger) {\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n const triggers = getItems()\n .map((item) => item.ref.current)\n .filter((node): node is HTMLButtonElement => node !== null);\n const next =\n triggers[\n triggers.indexOf(trigger) + (event.key === \"ArrowDown\" ? 1 : -1)\n ];\n if (next) {\n next.focus();\n event.preventDefault();\n }\n } else if (event.key === forwardKey && more) {\n more.focus();\n event.preventDefault();\n }\n } else if (more && event.target === more && event.key === backKey) {\n trigger?.focus();\n event.preventDefault();\n }\n };\n\n return (\n <ThreadListItemFocusProvider value={focus}>\n <Primitive.div\n {...(isMain ? { \"data-active\": \"true\", \"aria-current\": \"true\" } : null)}\n {...props}\n onKeyDown={composeEventHandlers(props.onKeyDown, onKeyDown)}\n ref={ref}\n />\n </ThreadListItemFocusProvider>\n );\n});\n\nThreadListItemPrimitiveRoot.displayName = \"ThreadListItemPrimitive.Root\";\n"],"mappings":";;;;;;;;;AA0BA,MAAac,8BAA8BZ,YAGxCe,OAAOC,QAAQ;CAChB,MAAMC,SAASZ,aACZa,MAAMA,EAAEC,QAAQC,iBAAiBF,EAAEG,eAAeC,EACrD;CAEA,MAAMC,aAAanB,OAAiC,IAAI;CACxD,MAAMqB,UAAUrB,OAAiC,IAAI;CACrD,MAAMsB,QAAQvB,eAAe;EAAEoB;EAAYE;CAAQ,IAAI,CAAA,CAAE;CAEzD,MAAME,WAAWlB,wBAAwBmB,KAAAA,CAAS;CAClD,MAAMC,YAAYtB,UAAUuB,aAAa;CAEzC,MAAMC,aAAaC,UAAyC;EAC1D,IAAIA,MAAME,UAAUF,MAAMG,WAAWH,MAAMI,WAAWJ,MAAMK,UAC1D;EACF,MAAMC,aAAaT,cAAc,QAAQ,cAAc;EACvD,MAAMU,UAAUV,cAAc,QAAQ,eAAe;EACrD,MAAMW,UAAUjB,WAAWkB;EAC3B,MAAMC,OAAOjB,QAAQgB;EAErB,IAAID,WAAWR,MAAMW,WAAWH,SAAS;GACvC,IAAIR,MAAMY,QAAQ,eAAeZ,MAAMY,QAAQ,WAAW;IACxD,MAAMC,WAAWlB,SAAS,CAAC,CACxBmB,KAAKC,SAASA,KAAK/B,IAAIyB,OAAO,CAAC,CAC/BO,QAAQC,SAAoCA,SAAS,IAAI;IAC5D,MAAMC,OACJL,SACEA,SAASM,QAAQX,OAAO,KAAKR,MAAMY,QAAQ,cAAc,IAAI;IAEjE,IAAIM,MAAM;KACRA,KAAKxB,MAAM;KACXM,MAAMoB,eAAe;IACvB;GACF,OAAO,IAAIpB,MAAMY,QAAQN,cAAcI,MAAM;IAC3CA,KAAKhB,MAAM;IACXM,MAAMoB,eAAe;GACvB;EACF,OAAO,IAAIV,QAAQV,MAAMW,WAAWD,QAAQV,MAAMY,QAAQL,SAAS;GACjEC,SAASd,MAAM;GACfM,MAAMoB,eAAe;EACvB;CACF;CAEA,OACE,oBAAC,6BAAD;EAA6B,OAAO1B;EAClC,UAAA,oBAAC,YAAU,KAAX;GACE,GAAKT,SAAS;IAAE,eAAe;IAAQ,gBAAgB;GAAO,IAAI;GAClE,GAAIF;GACJ,WAAWT,qBAAqBS,MAAMgB,WAAWA,SAAS;GACrDf;EAAI,CAAA;CAEgB,CAAA;AAEjC,CAAC;AAEDJ,4BAA4ByC,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadListItemMoreContent.d.ts","sourceRoot":"","sources":["../../../src/primitives/threadListItemMore/ThreadListItemMoreContent.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,YAAY,EAElB,MAAM,OAAO,CAAC;AACf,OAAO,EAAa,YAAY,IAAI,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAE5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,iCAA8B;AASjE,yBAAiB,kCAAkC,CAAC;IAClD,KAAY,OAAO,GAAG,YAAY,CAAC,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACzE,KAAY,KAAK,GAAG,mBAAmB,CACrC,OAAO,qBAAqB,CAAC,OAAO,CACrC,GAAG;QACF,WAAW,CAAC,EACR,wBAAwB,CAAC,OAAO,qBAAqB,CAAC,MAAM,CAAC,GAC7D,SAAS,CAAC;KACf,CAAC;CACH;AAED,eAAO,MAAM,kCAAkC;;;kBALvC,wBAAwB,CAAC,OAAO,qBAAqB,CAAC,MAAM,CAAC,GAC7D,SAAS;
|
|
1
|
+
{"version":3,"file":"ThreadListItemMoreContent.d.ts","sourceRoot":"","sources":["../../../src/primitives/threadListItemMore/ThreadListItemMoreContent.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,YAAY,EAElB,MAAM,OAAO,CAAC;AACf,OAAO,EAAa,YAAY,IAAI,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAE5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,iCAA8B;AASjE,yBAAiB,kCAAkC,CAAC;IAClD,KAAY,OAAO,GAAG,YAAY,CAAC,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACzE,KAAY,KAAK,GAAG,mBAAmB,CACrC,OAAO,qBAAqB,CAAC,OAAO,CACrC,GAAG;QACF,WAAW,CAAC,EACR,wBAAwB,CAAC,OAAO,qBAAqB,CAAC,MAAM,CAAC,GAC7D,SAAS,CAAC;KACf,CAAC;CACH;AAED,eAAO,MAAM,kCAAkC;;;kBALvC,wBAAwB,CAAC,OAAO,qBAAqB,CAAC,MAAM,CAAC,GAC7D,SAAS;kDAoDhB,CAAC"}
|
|
@@ -24,6 +24,7 @@ const ThreadListItemMorePrimitiveContent = forwardRef((t0, forwardedRef) => {
|
|
|
24
24
|
if ($[0] !== closeKey || $[1] !== focus?.moreRef || $[2] !== setOpen || $[3] !== sharedFocusGroup) {
|
|
25
25
|
t3 = (event) => {
|
|
26
26
|
if (!sharedFocusGroup || event.key !== closeKey) return;
|
|
27
|
+
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;
|
|
27
28
|
event.preventDefault();
|
|
28
29
|
setOpen(false);
|
|
29
30
|
focus?.moreRef.current?.focus();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadListItemMoreContent.js","names":["c","_c","ComponentPropsWithoutRef","ComponentRef","forwardRef","Direction","DropdownMenu","DropdownMenuPrimitive","composeEventHandlers","WithRenderPropProps","DropdownMenuRenderContent","useThreadListItemFocus","useThreadListItemMoreSharedFocusGroup","useThreadListItemMoreSetOpen","ScopedProps","useDropdownMenuScope","ThreadListItemMorePrimitiveContent","Element","Content","Props","portalProps","Portal","t0","forwardedRef","$","__scopeThreadListItemMore","sideOffset","t1","props","undefined","scope","setOpen","focus","sharedFocusGroup","direction","useDirection","closeKey","t2","T0","t3","moreRef","event","key","preventDefault","current","t4","onKeyDown","t5","t6","onEscapeKeyDown","t7","t8","displayName"],"sources":["../../../src/primitives/threadListItemMore/ThreadListItemMoreContent.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n} from \"react\";\nimport { Direction, DropdownMenu as DropdownMenuPrimitive } from \"radix-ui\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport type { WithRenderPropProps } from \"../../utils/Primitive\";\nimport { DropdownMenuRenderContent } from \"../dropdownMenuRenderPrimitives\";\nimport { useThreadListItemFocus } from \"../threadListFocusGroup\";\nimport {\n useThreadListItemMoreSharedFocusGroup,\n useThreadListItemMoreSetOpen,\n} from \"./ThreadListItemMoreRoot\";\nimport { type ScopedProps, useDropdownMenuScope } from \"./scope\";\n\nexport namespace ThreadListItemMorePrimitiveContent {\n export type Element = ComponentRef<typeof DropdownMenuPrimitive.Content>;\n export type Props = WithRenderPropProps<\n typeof DropdownMenuPrimitive.Content\n > & {\n portalProps?:\n | ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Portal>\n | undefined;\n };\n}\n\nexport const ThreadListItemMorePrimitiveContent = forwardRef<\n ThreadListItemMorePrimitiveContent.Element,\n ThreadListItemMorePrimitiveContent.Props\n>(\n (\n {\n __scopeThreadListItemMore,\n portalProps,\n sideOffset = 4,\n ...props\n }: ScopedProps<ThreadListItemMorePrimitiveContent.Props>,\n forwardedRef,\n ) => {\n const scope = useDropdownMenuScope(__scopeThreadListItemMore);\n const setOpen = useThreadListItemMoreSetOpen();\n const focus = useThreadListItemFocus();\n const sharedFocusGroup = useThreadListItemMoreSharedFocusGroup();\n const direction = Direction.useDirection();\n const closeKey = direction === \"rtl\" ? \"ArrowRight\" : \"ArrowLeft\";\n\n return (\n <DropdownMenuPrimitive.Portal {...scope} {...portalProps}>\n <DropdownMenuRenderContent\n {...scope}\n {...props}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n if (!sharedFocusGroup || event.key !== closeKey) return;\n event.preventDefault();\n setOpen(false);\n focus?.moreRef.current?.focus();\n })}\n onEscapeKeyDown={composeEventHandlers(props.onEscapeKeyDown, () => {\n if (!sharedFocusGroup) return;\n focus?.moreRef.current?.focus();\n })}\n ref={forwardedRef}\n sideOffset={sideOffset}\n />\n </DropdownMenuPrimitive.Portal>\n );\n },\n);\n\nThreadListItemMorePrimitiveContent.displayName =\n \"ThreadListItemMorePrimitive.Content\";\n"],"mappings":";;;;;;;;;;;AA6BA,MAAagB,qCAAqCZ,YAIhDkB,IAAAC,iBAAA;CAAA,MAAAC,IAAAvB,EAAA,EAAA;CACE,MAAA,EAAAwB,2BAAAL,aAAAM,YAAAC,IAAA,GAAAC,UAAAN;CAGE,MAAAI,aAAAC,OAAAE,KAAAA,IAAA,IAAAF;CAKF,MAAAG,QAAcf,qBAAqBU,yBAAyB;CAC5D,MAAAM,UAAgBlB,6BAA6B;CAC7C,MAAAmB,QAAcrB,uBAAuB;CACrC,MAAAsB,mBAAyBrB,sCAAsC;CAE/D,MAAAwB,WADkB/B,UAAS8B,aACVD,MAAc,QAAd,eAAA;CAGd,MAAAG,KAAA9B;CACE,MAAA+B,KAAA5B;CAAyB,IAAA6B;CAAA,IAAAf,EAAA,OAAAY,YAAAZ,EAAA,OAAAQ,OAAAQ,WAAAhB,EAAA,OAAAO,WAAAP,EAAA,OAAAS,kBAAA;EAGyBM,MAAAE,UAAA;GAC/C,IAAI,CAACR,oBAAoBQ,MAAKC,QAASN,UAAQ;GAC/
|
|
1
|
+
{"version":3,"file":"ThreadListItemMoreContent.js","names":["c","_c","ComponentPropsWithoutRef","ComponentRef","forwardRef","Direction","DropdownMenu","DropdownMenuPrimitive","composeEventHandlers","WithRenderPropProps","DropdownMenuRenderContent","useThreadListItemFocus","useThreadListItemMoreSharedFocusGroup","useThreadListItemMoreSetOpen","ScopedProps","useDropdownMenuScope","ThreadListItemMorePrimitiveContent","Element","Content","Props","portalProps","Portal","t0","forwardedRef","$","__scopeThreadListItemMore","sideOffset","t1","props","undefined","scope","setOpen","focus","sharedFocusGroup","direction","useDirection","closeKey","t2","T0","t3","moreRef","event","key","altKey","ctrlKey","metaKey","shiftKey","preventDefault","current","t4","onKeyDown","t5","t6","onEscapeKeyDown","t7","t8","displayName"],"sources":["../../../src/primitives/threadListItemMore/ThreadListItemMoreContent.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n} from \"react\";\nimport { Direction, DropdownMenu as DropdownMenuPrimitive } from \"radix-ui\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport type { WithRenderPropProps } from \"../../utils/Primitive\";\nimport { DropdownMenuRenderContent } from \"../dropdownMenuRenderPrimitives\";\nimport { useThreadListItemFocus } from \"../threadListFocusGroup\";\nimport {\n useThreadListItemMoreSharedFocusGroup,\n useThreadListItemMoreSetOpen,\n} from \"./ThreadListItemMoreRoot\";\nimport { type ScopedProps, useDropdownMenuScope } from \"./scope\";\n\nexport namespace ThreadListItemMorePrimitiveContent {\n export type Element = ComponentRef<typeof DropdownMenuPrimitive.Content>;\n export type Props = WithRenderPropProps<\n typeof DropdownMenuPrimitive.Content\n > & {\n portalProps?:\n | ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Portal>\n | undefined;\n };\n}\n\nexport const ThreadListItemMorePrimitiveContent = forwardRef<\n ThreadListItemMorePrimitiveContent.Element,\n ThreadListItemMorePrimitiveContent.Props\n>(\n (\n {\n __scopeThreadListItemMore,\n portalProps,\n sideOffset = 4,\n ...props\n }: ScopedProps<ThreadListItemMorePrimitiveContent.Props>,\n forwardedRef,\n ) => {\n const scope = useDropdownMenuScope(__scopeThreadListItemMore);\n const setOpen = useThreadListItemMoreSetOpen();\n const focus = useThreadListItemFocus();\n const sharedFocusGroup = useThreadListItemMoreSharedFocusGroup();\n const direction = Direction.useDirection();\n const closeKey = direction === \"rtl\" ? \"ArrowRight\" : \"ArrowLeft\";\n\n return (\n <DropdownMenuPrimitive.Portal {...scope} {...portalProps}>\n <DropdownMenuRenderContent\n {...scope}\n {...props}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n if (!sharedFocusGroup || event.key !== closeKey) return;\n if (\n event.altKey ||\n event.ctrlKey ||\n event.metaKey ||\n event.shiftKey\n )\n return;\n event.preventDefault();\n setOpen(false);\n focus?.moreRef.current?.focus();\n })}\n onEscapeKeyDown={composeEventHandlers(props.onEscapeKeyDown, () => {\n if (!sharedFocusGroup) return;\n focus?.moreRef.current?.focus();\n })}\n ref={forwardedRef}\n sideOffset={sideOffset}\n />\n </DropdownMenuPrimitive.Portal>\n );\n },\n);\n\nThreadListItemMorePrimitiveContent.displayName =\n \"ThreadListItemMorePrimitive.Content\";\n"],"mappings":";;;;;;;;;;;AA6BA,MAAagB,qCAAqCZ,YAIhDkB,IAAAC,iBAAA;CAAA,MAAAC,IAAAvB,EAAA,EAAA;CACE,MAAA,EAAAwB,2BAAAL,aAAAM,YAAAC,IAAA,GAAAC,UAAAN;CAGE,MAAAI,aAAAC,OAAAE,KAAAA,IAAA,IAAAF;CAKF,MAAAG,QAAcf,qBAAqBU,yBAAyB;CAC5D,MAAAM,UAAgBlB,6BAA6B;CAC7C,MAAAmB,QAAcrB,uBAAuB;CACrC,MAAAsB,mBAAyBrB,sCAAsC;CAE/D,MAAAwB,WADkB/B,UAAS8B,aACVD,MAAc,QAAd,eAAA;CAGd,MAAAG,KAAA9B;CACE,MAAA+B,KAAA5B;CAAyB,IAAA6B;CAAA,IAAAf,EAAA,OAAAY,YAAAZ,EAAA,OAAAQ,OAAAQ,WAAAhB,EAAA,OAAAO,WAAAP,EAAA,OAAAS,kBAAA;EAGyBM,MAAAE,UAAA;GAC/C,IAAI,CAACR,oBAAoBQ,MAAKC,QAASN,UAAQ;GAC/C,IACEK,MAAKE,UACLF,MAAKG,WACLH,MAAKI,WACLJ,MAAKK,UAAS;GAGhBL,MAAKM,eAAgB;GACrBhB,QAAQ,KAAK;GACbC,OAAKQ,QAAiBQ,SAAOhB,MAAC;EAAC;EAChCR,EAAA,KAAAY;EAAAZ,EAAA,KAAAQ,OAAAQ;EAAAhB,EAAA,KAAAO;EAAAP,EAAA,KAAAS;EAAAT,EAAA,KAAAe;CAAA,OAAAA,KAAAf,EAAA;CAZU,MAAAyB,KAAAzC,qBAAqBoB,MAAKsB,WAAYX,EAYhD;CAAC,IAAAY;CAAA,IAAA3B,EAAA,OAAAQ,OAAAQ,WAAAhB,EAAA,OAAAS,kBAAA;EAC2DkB,WAAA;GAC3D,IAAI,CAAClB,kBAAgB;GACrBD,OAAKQ,QAAiBQ,SAAOhB,MAAC;EAAC;EAChCR,EAAA,KAAAQ,OAAAQ;EAAAhB,EAAA,KAAAS;EAAAT,EAAA,KAAA2B;CAAA,OAAAA,KAAA3B,EAAA;CAHgB,MAAA4B,KAAA5C,qBAAqBoB,MAAKyB,iBAAkBF,EAG5D;CAAC,IAAAG;CAAA,IAAA9B,EAAA,OAAAc,MAAAd,EAAA,OAAAD,gBAAAC,EAAA,QAAAI,SAAAJ,EAAA,QAAAM,SAAAN,EAAA,QAAAE,cAAAF,EAAA,QAAAyB,MAAAzB,EAAA,QAAA4B,IAAA;EAnBJE,KAAA,oBAAC,IAAD;GAA0B,GACpBxB;GAAK,GACLF;GACO,WAAAqB;GAaM,iBAAAG;GAIZ7B,KAAAA;GACOG;EAAU,CAAA;EACtBF,EAAA,KAAAc;EAAAd,EAAA,KAAAD;EAAAC,EAAA,MAAAI;EAAAJ,EAAA,MAAAM;EAAAN,EAAA,MAAAE;EAAAF,EAAA,MAAAyB;EAAAzB,EAAA,MAAA4B;EAAA5B,EAAA,MAAA8B;CAAA,OAAAA,KAAA9B,EAAA;CAAA,IAAA+B;CAAA,IAAA/B,EAAA,QAAAJ,eAAAI,EAAA,QAAAM,SAAAN,EAAA,QAAAa,GAAAhB,UAAAG,EAAA,QAAA8B,IAAA;EAvBJC,KAAA,oBAAA,GAAA,QAAA;GAAA,GAAkCzB;GAAK,GAAMV;GAC3CkC,UAAAA;EAuBF,CAAA;EAA+B9B,EAAA,MAAAJ;EAAAI,EAAA,MAAAM;EAAAN,EAAA,MAAAa,GAAAhB;EAAAG,EAAA,MAAA8B;EAAA9B,EAAA,MAAA+B;CAAA,OAAAA,KAAA/B,EAAA;CAAA,OAxB/B+B;AAwB+B,CAGrC;AAEAvC,mCAAmCwC,cACjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadListItemMoreTrigger.d.ts","sourceRoot":"","sources":["../../../src/primitives/threadListItemMore/ThreadListItemMoreTrigger.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAc,MAAM,OAAO,CAAC;AACtD,OAAO,EAEL,KAAK,YAAY,IAAI,qBAAqB,EAC3C,MAAM,UAAU,CAAC;AAGlB,OAAO,KAAK,EAAE,mBAAmB,EAAE,iCAA8B;AASjE,yBAAiB,kCAAkC,CAAC;IAClD,KAAY,OAAO,GAAG,YAAY,CAAC,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACzE,KAAY,KAAK,GAAG,mBAAmB,CAAC,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;CAC/E;AAED,eAAO,MAAM,kCAAkC;;
|
|
1
|
+
{"version":3,"file":"ThreadListItemMoreTrigger.d.ts","sourceRoot":"","sources":["../../../src/primitives/threadListItemMore/ThreadListItemMoreTrigger.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAc,MAAM,OAAO,CAAC;AACtD,OAAO,EAEL,KAAK,YAAY,IAAI,qBAAqB,EAC3C,MAAM,UAAU,CAAC;AAGlB,OAAO,KAAK,EAAE,mBAAmB,EAAE,iCAA8B;AASjE,yBAAiB,kCAAkC,CAAC;IAClD,KAAY,OAAO,GAAG,YAAY,CAAC,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACzE,KAAY,KAAK,GAAG,mBAAmB,CAAC,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;CAC/E;AAED,eAAO,MAAM,kCAAkC;;qDAkC9C,CAAC"}
|
|
@@ -23,6 +23,7 @@ const ThreadListItemMorePrimitiveTrigger = forwardRef((t0, ref) => {
|
|
|
23
23
|
if ($[0] !== openKey || $[1] !== setOpen || $[2] !== sharedFocusGroup) {
|
|
24
24
|
t1 = (event) => {
|
|
25
25
|
if (!sharedFocusGroup || event.key !== openKey) return;
|
|
26
|
+
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;
|
|
26
27
|
event.preventDefault();
|
|
27
28
|
setOpen(true);
|
|
28
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadListItemMoreTrigger.js","names":["c","_c","ComponentRef","forwardRef","Direction","DropdownMenu","DropdownMenuPrimitive","useComposedRefs","composeEventHandlers","WithRenderPropProps","DropdownMenuRenderTrigger","useThreadListItemFocus","useThreadListItemMoreSharedFocusGroup","useThreadListItemMoreSetOpen","ScopedProps","useDropdownMenuScope","ThreadListItemMorePrimitiveTrigger","Element","Trigger","Props","t0","ref","$","__scopeThreadListItemMore","rest","scope","focus","setOpen","sharedFocusGroup","composedRef","moreRef","direction","useDirection","openKey","T0","t1","event","key","preventDefault","t2","onKeyDown","t3","displayName"],"sources":["../../../src/primitives/threadListItemMore/ThreadListItemMoreTrigger.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ComponentRef, forwardRef } from \"react\";\nimport {\n Direction,\n type DropdownMenu as DropdownMenuPrimitive,\n} from \"radix-ui\";\nimport { useComposedRefs } from \"radix-ui/internal\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport type { WithRenderPropProps } from \"../../utils/Primitive\";\nimport { DropdownMenuRenderTrigger } from \"../dropdownMenuRenderPrimitives\";\nimport { useThreadListItemFocus } from \"../threadListFocusGroup\";\nimport {\n useThreadListItemMoreSharedFocusGroup,\n useThreadListItemMoreSetOpen,\n} from \"./ThreadListItemMoreRoot\";\nimport { type ScopedProps, useDropdownMenuScope } from \"./scope\";\n\nexport namespace ThreadListItemMorePrimitiveTrigger {\n export type Element = ComponentRef<typeof DropdownMenuPrimitive.Trigger>;\n export type Props = WithRenderPropProps<typeof DropdownMenuPrimitive.Trigger>;\n}\n\nexport const ThreadListItemMorePrimitiveTrigger = forwardRef<\n ThreadListItemMorePrimitiveTrigger.Element,\n ThreadListItemMorePrimitiveTrigger.Props\n>(\n (\n {\n __scopeThreadListItemMore,\n ...rest\n }: ScopedProps<ThreadListItemMorePrimitiveTrigger.Props>,\n ref,\n ) => {\n const scope = useDropdownMenuScope(__scopeThreadListItemMore);\n const focus = useThreadListItemFocus();\n const setOpen = useThreadListItemMoreSetOpen();\n const sharedFocusGroup = useThreadListItemMoreSharedFocusGroup();\n const composedRef = useComposedRefs(ref, focus?.moreRef);\n const direction = Direction.useDirection();\n const openKey = direction === \"rtl\" ? \"ArrowLeft\" : \"ArrowRight\";\n\n return (\n <DropdownMenuRenderTrigger\n {...scope}\n {...rest}\n onKeyDown={composeEventHandlers(rest.onKeyDown, (event) => {\n if (!sharedFocusGroup || event.key !== openKey) return;\n event.preventDefault();\n setOpen(true);\n })}\n ref={composedRef}\n />\n );\n },\n);\n\nThreadListItemMorePrimitiveTrigger.displayName =\n \"ThreadListItemMorePrimitive.Trigger\";\n"],"mappings":";;;;;;;;;;;AAuBA,MAAagB,qCAAqCb,YAIhDiB,IAAAC,QAAA;CAAA,MAAAC,IAAArB,EAAA,EAAA;CACE,MAAA,EAAAsB,2BAAA,GAAAC,SAAAJ;CAMA,MAAAK,QAAcV,qBAAqBQ,yBAAyB;CAC5D,MAAAG,QAAcf,uBAAuB;CACrC,MAAAgB,UAAgBd,6BAA6B;CAC7C,MAAAe,mBAAyBhB,sCAAsC;CAC/D,MAAAiB,cAAoBtB,gBAAgBc,KAAKK,OAAKI,OAAS;CAEvD,MAAAG,UADkB7B,UAAS4B,aACXD,MAAc,QAAd,cAAA;CAGb,MAAAG,KAAAxB;CAAyB,IAAAyB;CAAA,IAAAb,EAAA,OAAAW,WAAAX,EAAA,OAAAK,WAAAL,EAAA,OAAAM,kBAAA;EAGwBO,MAAAC,UAAA;GAC9C,IAAI,CAACR,oBAAoBQ,MAAKC,QAASJ,SAAO;
|
|
1
|
+
{"version":3,"file":"ThreadListItemMoreTrigger.js","names":["c","_c","ComponentRef","forwardRef","Direction","DropdownMenu","DropdownMenuPrimitive","useComposedRefs","composeEventHandlers","WithRenderPropProps","DropdownMenuRenderTrigger","useThreadListItemFocus","useThreadListItemMoreSharedFocusGroup","useThreadListItemMoreSetOpen","ScopedProps","useDropdownMenuScope","ThreadListItemMorePrimitiveTrigger","Element","Trigger","Props","t0","ref","$","__scopeThreadListItemMore","rest","scope","focus","setOpen","sharedFocusGroup","composedRef","moreRef","direction","useDirection","openKey","T0","t1","event","key","altKey","ctrlKey","metaKey","shiftKey","preventDefault","t2","onKeyDown","t3","displayName"],"sources":["../../../src/primitives/threadListItemMore/ThreadListItemMoreTrigger.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ComponentRef, forwardRef } from \"react\";\nimport {\n Direction,\n type DropdownMenu as DropdownMenuPrimitive,\n} from \"radix-ui\";\nimport { useComposedRefs } from \"radix-ui/internal\";\nimport { composeEventHandlers } from \"radix-ui/internal\";\nimport type { WithRenderPropProps } from \"../../utils/Primitive\";\nimport { DropdownMenuRenderTrigger } from \"../dropdownMenuRenderPrimitives\";\nimport { useThreadListItemFocus } from \"../threadListFocusGroup\";\nimport {\n useThreadListItemMoreSharedFocusGroup,\n useThreadListItemMoreSetOpen,\n} from \"./ThreadListItemMoreRoot\";\nimport { type ScopedProps, useDropdownMenuScope } from \"./scope\";\n\nexport namespace ThreadListItemMorePrimitiveTrigger {\n export type Element = ComponentRef<typeof DropdownMenuPrimitive.Trigger>;\n export type Props = WithRenderPropProps<typeof DropdownMenuPrimitive.Trigger>;\n}\n\nexport const ThreadListItemMorePrimitiveTrigger = forwardRef<\n ThreadListItemMorePrimitiveTrigger.Element,\n ThreadListItemMorePrimitiveTrigger.Props\n>(\n (\n {\n __scopeThreadListItemMore,\n ...rest\n }: ScopedProps<ThreadListItemMorePrimitiveTrigger.Props>,\n ref,\n ) => {\n const scope = useDropdownMenuScope(__scopeThreadListItemMore);\n const focus = useThreadListItemFocus();\n const setOpen = useThreadListItemMoreSetOpen();\n const sharedFocusGroup = useThreadListItemMoreSharedFocusGroup();\n const composedRef = useComposedRefs(ref, focus?.moreRef);\n const direction = Direction.useDirection();\n const openKey = direction === \"rtl\" ? \"ArrowLeft\" : \"ArrowRight\";\n\n return (\n <DropdownMenuRenderTrigger\n {...scope}\n {...rest}\n onKeyDown={composeEventHandlers(rest.onKeyDown, (event) => {\n if (!sharedFocusGroup || event.key !== openKey) return;\n if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)\n return;\n event.preventDefault();\n setOpen(true);\n })}\n ref={composedRef}\n />\n );\n },\n);\n\nThreadListItemMorePrimitiveTrigger.displayName =\n \"ThreadListItemMorePrimitive.Trigger\";\n"],"mappings":";;;;;;;;;;;AAuBA,MAAagB,qCAAqCb,YAIhDiB,IAAAC,QAAA;CAAA,MAAAC,IAAArB,EAAA,EAAA;CACE,MAAA,EAAAsB,2BAAA,GAAAC,SAAAJ;CAMA,MAAAK,QAAcV,qBAAqBQ,yBAAyB;CAC5D,MAAAG,QAAcf,uBAAuB;CACrC,MAAAgB,UAAgBd,6BAA6B;CAC7C,MAAAe,mBAAyBhB,sCAAsC;CAC/D,MAAAiB,cAAoBtB,gBAAgBc,KAAKK,OAAKI,OAAS;CAEvD,MAAAG,UADkB7B,UAAS4B,aACXD,MAAc,QAAd,cAAA;CAGb,MAAAG,KAAAxB;CAAyB,IAAAyB;CAAA,IAAAb,EAAA,OAAAW,WAAAX,EAAA,OAAAK,WAAAL,EAAA,OAAAM,kBAAA;EAGwBO,MAAAC,UAAA;GAC9C,IAAI,CAACR,oBAAoBQ,MAAKC,QAASJ,SAAO;GAC9C,IAAIG,MAAKE,UAAWF,MAAKG,WAAYH,MAAKI,WAAYJ,MAAKK,UAAS;GAEpEL,MAAKM,eAAgB;GACrBf,QAAQ,IAAI;EAAC;EACdL,EAAA,KAAAW;EAAAX,EAAA,KAAAK;EAAAL,EAAA,KAAAM;EAAAN,EAAA,KAAAa;CAAA,OAAAA,KAAAb,EAAA;CANU,MAAAqB,KAAAnC,qBAAqBgB,KAAIoB,WAAYT,EAM/C;CAAC,IAAAU;CAAA,IAAAvB,EAAA,OAAAY,MAAAZ,EAAA,OAAAO,eAAAP,EAAA,OAAAE,QAAAF,EAAA,OAAAG,SAAAH,EAAA,OAAAqB,IAAA;EATJE,KAAA,oBAAC,IAAD;GAA0B,GACpBpB;GAAK,GACLD;GACO,WAAAmB;GAONd,KAAAA;EAAW,CAAA;EAChBP,EAAA,KAAAY;EAAAZ,EAAA,KAAAO;EAAAP,EAAA,KAAAE;EAAAF,EAAA,KAAAG;EAAAH,EAAA,KAAAqB;EAAArB,EAAA,KAAAuB;CAAA,OAAAA,KAAAvB,EAAA;CAAA,OAXFuB;AAWE,CAGR;AAEA7B,mCAAmC8B,cACjC"}
|
|
@@ -6,6 +6,7 @@ export type WebMcpRegistrationProps = {
|
|
|
6
6
|
/** Re-registers when it changes; an execute-only edit reads through instead. */
|
|
7
7
|
signature: string;
|
|
8
8
|
tool: Tool<any, any>;
|
|
9
|
+
getCurrentTool: (name: string) => Tool<any, any> | undefined;
|
|
9
10
|
};
|
|
10
11
|
export declare const WebMcpRegistrationResource: import("@assistant-ui/tap").Resource<string | null, [WebMcpRegistrationProps]>;
|
|
11
12
|
//# sourceMappingURL=WebMcpRegistrationResource.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebMcpRegistrationResource.d.ts","sourceRoot":"","sources":["../../../src/unstable/webmcp/WebMcpRegistrationResource.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAsB;AAEhD,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"WebMcpRegistrationResource.d.ts","sourceRoot":"","sources":["../../../src/unstable/webmcp/WebMcpRegistrationResource.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAsB;AAEhD,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACrB,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;CAC9D,CAAC;AA+EF,eAAO,MAAM,0BAA0B,gFAAkC,CAAC"}
|
|
@@ -6,28 +6,13 @@ import { resource } from "@assistant-ui/tap";
|
|
|
6
6
|
const notPermitted = (error) => error?.name === "NotAllowedError";
|
|
7
7
|
const notPermittedMessage = (name) => `[assistant-ui] WebMCP registration for tool "${name}" was not permitted; the page's tools permission is disabled.`;
|
|
8
8
|
const useWebMcpRegistration = (t0) => {
|
|
9
|
-
const $ = c(
|
|
10
|
-
const { host, name, signature, tool } = t0;
|
|
9
|
+
const $ = c(11);
|
|
10
|
+
const { host, name, signature, tool, getCurrentTool } = t0;
|
|
11
11
|
const [refused, setRefused] = useState(false);
|
|
12
|
-
const
|
|
12
|
+
const fallbackToolRef = useRef(tool);
|
|
13
13
|
let t1;
|
|
14
|
-
|
|
15
|
-
if ($[0] !== tool) {
|
|
14
|
+
if ($[0] !== getCurrentTool || $[1] !== host || $[2] !== name || $[3] !== refused) {
|
|
16
15
|
t1 = () => {
|
|
17
|
-
toolRef.current = tool;
|
|
18
|
-
};
|
|
19
|
-
t2 = [tool];
|
|
20
|
-
$[0] = tool;
|
|
21
|
-
$[1] = t1;
|
|
22
|
-
$[2] = t2;
|
|
23
|
-
} else {
|
|
24
|
-
t1 = $[1];
|
|
25
|
-
t2 = $[2];
|
|
26
|
-
}
|
|
27
|
-
useEffect(t1, t2);
|
|
28
|
-
let t3;
|
|
29
|
-
if ($[3] !== host || $[4] !== name || $[5] !== refused) {
|
|
30
|
-
t3 = () => {
|
|
31
16
|
if (refused) return;
|
|
32
17
|
const lifecycle = new AbortController();
|
|
33
18
|
let live = true;
|
|
@@ -39,9 +24,9 @@ const useWebMcpRegistration = (t0) => {
|
|
|
39
24
|
console.warn(message, error);
|
|
40
25
|
};
|
|
41
26
|
try {
|
|
42
|
-
dispose = host.registerTool(toWebMcpTool(name, () =>
|
|
43
|
-
} catch (
|
|
44
|
-
const error_0 =
|
|
27
|
+
dispose = host.registerTool(toWebMcpTool(name, () => getCurrentTool(name) ?? fallbackToolRef.current, lifecycle.signal), (error_1) => refuse(notPermitted(error_1) ? notPermittedMessage(name) : `[assistant-ui] WebMCP registration for tool "${name}" failed (name may already be registered).`, error_1));
|
|
28
|
+
} catch (t2) {
|
|
29
|
+
const error_0 = t2;
|
|
45
30
|
refuse(notPermitted(error_0) ? notPermittedMessage(name) : `[assistant-ui] Skipping WebMCP registration for tool "${name}": registerTool failed (name may already be registered).`, error_0);
|
|
46
31
|
return;
|
|
47
32
|
}
|
|
@@ -50,32 +35,35 @@ const useWebMcpRegistration = (t0) => {
|
|
|
50
35
|
lifecycle.abort();
|
|
51
36
|
try {
|
|
52
37
|
dispose();
|
|
53
|
-
} catch (
|
|
54
|
-
const error_2 =
|
|
38
|
+
} catch (t3) {
|
|
39
|
+
const error_2 = t3;
|
|
55
40
|
console.warn(`[assistant-ui] Unregistering WebMCP tool "${name}" failed.`, error_2);
|
|
56
41
|
}
|
|
57
42
|
};
|
|
58
43
|
};
|
|
59
|
-
$[
|
|
60
|
-
$[
|
|
61
|
-
$[
|
|
62
|
-
$[
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
44
|
+
$[0] = getCurrentTool;
|
|
45
|
+
$[1] = host;
|
|
46
|
+
$[2] = name;
|
|
47
|
+
$[3] = refused;
|
|
48
|
+
$[4] = t1;
|
|
49
|
+
} else t1 = $[4];
|
|
50
|
+
let t2;
|
|
51
|
+
if ($[5] !== getCurrentTool || $[6] !== host || $[7] !== name || $[8] !== refused || $[9] !== signature) {
|
|
52
|
+
t2 = [
|
|
53
|
+
getCurrentTool,
|
|
67
54
|
host,
|
|
68
55
|
name,
|
|
69
56
|
signature,
|
|
70
57
|
refused
|
|
71
58
|
];
|
|
72
|
-
$[
|
|
73
|
-
$[
|
|
74
|
-
$[
|
|
75
|
-
$[
|
|
76
|
-
$[
|
|
77
|
-
|
|
78
|
-
|
|
59
|
+
$[5] = getCurrentTool;
|
|
60
|
+
$[6] = host;
|
|
61
|
+
$[7] = name;
|
|
62
|
+
$[8] = refused;
|
|
63
|
+
$[9] = signature;
|
|
64
|
+
$[10] = t2;
|
|
65
|
+
} else t2 = $[10];
|
|
66
|
+
useEffect(t1, t2);
|
|
79
67
|
return refused ? null : name;
|
|
80
68
|
};
|
|
81
69
|
const WebMcpRegistrationResource = resource(useWebMcpRegistration);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebMcpRegistrationResource.js","names":["useEffect","useRef","useState","resource","Tool","toWebMcpTool","WebMcpHost","WebMcpRegistrationProps","host","name","signature","tool","notPermitted","error","notPermittedMessage","useWebMcpRegistration","t0","$","_c","refused","setRefused","
|
|
1
|
+
{"version":3,"file":"WebMcpRegistrationResource.js","names":["useEffect","useRef","useState","resource","Tool","toWebMcpTool","WebMcpHost","WebMcpRegistrationProps","host","name","signature","tool","getCurrentTool","notPermitted","error","notPermittedMessage","useWebMcpRegistration","t0","$","_c","refused","setRefused","fallbackToolRef","t1","lifecycle","AbortController","live","dispose","refuse","message","console","warn","registerTool","current","signal","error_1","t2","abort","t3","WebMcpRegistrationResource"],"sources":["../../../src/unstable/webmcp/WebMcpRegistrationResource.ts"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport { resource } from \"@assistant-ui/tap\";\nimport type { Tool } from \"assistant-stream\";\nimport { toWebMcpTool } from \"./convertTools\";\nimport type { WebMcpHost } from \"./webmcp-host\";\n\nexport type WebMcpRegistrationProps = {\n host: WebMcpHost;\n name: string;\n /** Re-registers when it changes; an execute-only edit reads through instead. */\n signature: string;\n tool: Tool<any, any>;\n getCurrentTool: (name: string) => Tool<any, any> | undefined;\n};\n\n// The explainer specifies NotAllowedError for a page whose tools permission is\n// off, which a cross-origin iframe without allow=\"tools\" reaches routinely. It\n// documents no rejection for a name already taken, so that stays a hedge.\nconst notPermitted = (error: unknown) =>\n (error as { name?: unknown } | null | undefined)?.name === \"NotAllowedError\";\n\nconst notPermittedMessage = (name: string) =>\n `[assistant-ui] WebMCP registration for tool \"${name}\" was not permitted; the page's tools permission is disabled.`;\n\nconst useWebMcpRegistration = ({\n host,\n name,\n signature,\n tool,\n getCurrentTool,\n}: WebMcpRegistrationProps): string | null => {\n // A refused name is remembered for as long as the tool stays in the model\n // context, so a permanent collision warns once rather than on every sync.\n const [refused, setRefused] = useState(false);\n const fallbackToolRef = useRef(tool);\n\n useEffect(() => {\n if (refused) return undefined;\n\n const lifecycle = new AbortController();\n let live = true;\n let dispose: (() => void) | undefined;\n\n const refuse = (message: string, error: unknown) => {\n if (!live) return;\n live = false;\n setRefused(true);\n console.warn(message, error);\n };\n\n try {\n dispose = host.registerTool(\n toWebMcpTool(\n name,\n () => getCurrentTool(name) ?? fallbackToolRef.current,\n lifecycle.signal,\n ),\n (error) =>\n refuse(\n notPermitted(error)\n ? notPermittedMessage(name)\n : `[assistant-ui] WebMCP registration for tool \"${name}\" failed (name may already be registered).`,\n error,\n ),\n );\n } catch (error) {\n refuse(\n notPermitted(error)\n ? notPermittedMessage(name)\n : `[assistant-ui] Skipping WebMCP registration for tool \"${name}\": registerTool failed (name may already be registered).`,\n error,\n );\n return undefined;\n }\n\n return () => {\n live = false;\n lifecycle.abort();\n try {\n dispose();\n } catch (error) {\n console.warn(\n `[assistant-ui] Unregistering WebMCP tool \"${name}\" failed.`,\n error,\n );\n }\n };\n }, [getCurrentTool, host, name, signature, refused]);\n\n return refused ? null : name;\n};\n\nexport const WebMcpRegistrationResource = resource(useWebMcpRegistration);\n"],"mappings":";;;;;AAkBA,MAAMa,gBAAgBC,UACnBA,OAAiDL,SAAS;AAE7D,MAAMM,uBAAuBN,SAC3B,gDAAgDA,KAAI;AAEtD,MAAMO,yBAAwBC,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAC,MAAA,EAAAX,MAAAC,MAAAC,WAAAC,MAAAC,mBAAAK;CAS7B,MAAA,CAAAG,SAAAC,cAA8BnB,SAAS,KAAK;CAC5C,MAAAoB,kBAAwBrB,OAAOU,IAAI;CAAE,IAAAY;CAAA,IAAAL,EAAA,OAAAN,kBAAAM,EAAA,OAAAV,QAAAU,EAAA,OAAAT,QAAAS,EAAA,OAAAE,SAAA;EAE3BG,WAAA;GACR,IAAIH,SAAO;GAEX,MAAAI,YAAkB,IAAIC,gBAAgB;GACtC,IAAAC,OAAW;GACPC,IAAAA;GAEJ,MAAAC,UAAeC,SAAAf,UAAA;IACb,IAAI,CAACY,MAAI;IACTA,OAAOA;IACPL,WAAW,IAAI;IACfS,QAAOC,KAAMF,SAASf,KAAK;GAAC;GAG9B,IAAA;IACEa,UAAUnB,KAAIwB,aACZ3B,aACEI,YACMG,eAAeH,IAA+B,KAAtBa,gBAAeW,SAC7CT,UAASU,MACX,IACAC,YACEP,OACEf,aAAaC,OAEsF,IAD/FC,oBAAoBN,IAC2E,IAFnG,gDAEoDA,KAAI,6CACxDK,OACF,CACJ;GAbO,SAAAsB,IAAA;IAcAtB,MAAAA,UAAAA;IACPc,OACEf,aAAaC,OAE6G,IADtHC,oBAAoBN,IACkG,IAF1H,yDAE6DA,KAAI,2DACjEK,OACF;IAAC;GAAA;GAEF,aAEM;IACLY,OAAOA;IACPF,UAASa,MAAO;IAChB,IAAA;KACEV,QAAQ;IAAC,SAAAW,IAAA;KACFxB,MAAAA,UAAAA;KACPgB,QAAOC,KACL,6CAA6CtB,KAAI,YACjDK,OACF;IAAC;GACF;EACF;EACFI,EAAA,KAAAN;EAAAM,EAAA,KAAAV;EAAAU,EAAA,KAAAT;EAAAS,EAAA,KAAAE;EAAAF,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,IAAAkB;CAAA,IAAAlB,EAAA,OAAAN,kBAAAM,EAAA,OAAAV,QAAAU,EAAA,OAAAT,QAAAS,EAAA,OAAAE,WAAAF,EAAA,OAAAR,WAAA;EAAE0B,KAAA;GAACxB;GAAgBJ;GAAMC;GAAMC;GAAWU;EAAO;EAACF,EAAA,KAAAN;EAAAM,EAAA,KAAAV;EAAAU,EAAA,KAAAT;EAAAS,EAAA,KAAAE;EAAAF,EAAA,KAAAR;EAAAQ,EAAA,MAAAkB;CAAA,OAAAA,KAAAlB,EAAA;CAnDnDlB,UAAUuB,IAmDPa,EAAgD;CAAC,OAE7ChB,UAAA,OAAAX;AAAqB;AAG9B,MAAa8B,6BAA6BpC,SAASa,qBAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWebMcpProvider.d.ts","sourceRoot":"","sources":["../../../src/unstable/webmcp/useWebMcpProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useWebMcpProvider.d.ts","sourceRoot":"","sources":["../../../src/unstable/webmcp/useWebMcpProvider.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAU7C,MAAM,MAAM,8BAA8B,GAAG;IAC3C,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC;CAC1D,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,EAAE,aAAa,GAAG,QAAQ,CAAC;IACjC,mBAAmB,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC,CAAC;AA8FF;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,GACrC,UAAS,8BAAmC,KAC3C,6BAyCF,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { getDefaultWebMcpHost } from "./webmcp-host.js";
|
|
|
4
4
|
import { defaultWebMcpFilter, toWebMcpInputSchema } from "./convertTools.js";
|
|
5
5
|
import { WebMcpRegistrationResource } from "./WebMcpRegistrationResource.js";
|
|
6
6
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
7
|
-
import { useEffect, useState, useSyncExternalStore } from "@assistant-ui/tap/react-shim";
|
|
7
|
+
import { useCallback, useEffect, useInsertionEffect, useRef, useState, useSyncExternalStore } from "@assistant-ui/tap/react-shim";
|
|
8
8
|
import { useAui } from "@assistant-ui/store";
|
|
9
9
|
import { useResources, useTapRoot, withKey } from "@assistant-ui/tap";
|
|
10
10
|
import { shallowEqual } from "@assistant-ui/store/internal";
|
|
@@ -38,11 +38,10 @@ const useStableNames = (names) => {
|
|
|
38
38
|
return next;
|
|
39
39
|
};
|
|
40
40
|
const useWebMcpRegistry = (t0) => {
|
|
41
|
-
const $ = c(
|
|
42
|
-
const {
|
|
43
|
-
const tools = useModelContextSnapshot(aui, host.available, modelContextToolSource);
|
|
41
|
+
const $ = c(5);
|
|
42
|
+
const { host, filter, tools, getCurrentTool } = t0;
|
|
44
43
|
let elements;
|
|
45
|
-
if ($[0] !== filter || $[1] !==
|
|
44
|
+
if ($[0] !== filter || $[1] !== getCurrentTool || $[2] !== host || $[3] !== tools) {
|
|
46
45
|
elements = [];
|
|
47
46
|
for (const [name, tool] of Object.entries(tools)) try {
|
|
48
47
|
if (!filter(name, tool)) continue;
|
|
@@ -51,12 +50,14 @@ const useWebMcpRegistry = (t0) => {
|
|
|
51
50
|
host,
|
|
52
51
|
name,
|
|
53
52
|
signature,
|
|
54
|
-
tool
|
|
53
|
+
tool,
|
|
54
|
+
getCurrentTool
|
|
55
55
|
}), [
|
|
56
56
|
host,
|
|
57
57
|
name,
|
|
58
58
|
signature,
|
|
59
|
-
tool
|
|
59
|
+
tool,
|
|
60
|
+
getCurrentTool
|
|
60
61
|
]));
|
|
61
62
|
} catch (t1) {
|
|
62
63
|
const error = t1;
|
|
@@ -65,10 +66,11 @@ const useWebMcpRegistry = (t0) => {
|
|
|
65
66
|
console.warn(`[assistant-ui] Skipping WebMCP registration for tool "${name}": filter or schema conversion failed.`, error);
|
|
66
67
|
}
|
|
67
68
|
$[0] = filter;
|
|
68
|
-
$[1] =
|
|
69
|
-
$[2] =
|
|
70
|
-
$[3] =
|
|
71
|
-
|
|
69
|
+
$[1] = getCurrentTool;
|
|
70
|
+
$[2] = host;
|
|
71
|
+
$[3] = tools;
|
|
72
|
+
$[4] = elements;
|
|
73
|
+
} else elements = $[4];
|
|
72
74
|
return useStableNames(useResources(elements));
|
|
73
75
|
};
|
|
74
76
|
/**
|
|
@@ -83,11 +85,18 @@ const unstable_useWebMcpProvider = (options = {}) => {
|
|
|
83
85
|
const aui = useAui();
|
|
84
86
|
const [host] = useState(getDefaultWebMcpHost);
|
|
85
87
|
const filter = options.filter ?? defaultWebMcpFilter;
|
|
88
|
+
const tools = useModelContextSnapshot(aui, host.available, modelContextToolSource);
|
|
89
|
+
const currentToolsRef = useRef(tools);
|
|
90
|
+
useInsertionEffect(() => {
|
|
91
|
+
currentToolsRef.current = tools;
|
|
92
|
+
}, [tools]);
|
|
93
|
+
const getCurrentTool = useCallback((name) => currentToolsRef.current[name], []);
|
|
86
94
|
const root = useTapRoot(function WebMcpProviderRoot() {
|
|
87
95
|
return useWebMcpRegistry({
|
|
88
|
-
aui,
|
|
89
96
|
host,
|
|
90
|
-
filter
|
|
97
|
+
filter,
|
|
98
|
+
tools,
|
|
99
|
+
getCurrentTool
|
|
91
100
|
});
|
|
92
101
|
});
|
|
93
102
|
const registeredToolNames = useSyncExternalStore(root.subscribe, root.getValue, () => EMPTY_NAMES);
|