@tambo-ai/react 0.15.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/use-current-message.d.ts.map +1 -1
- package/dist/hooks/use-current-message.js +4 -1
- package/dist/hooks/use-current-message.js.map +1 -1
- package/esm/hooks/use-current-message.d.ts.map +1 -1
- package/esm/hooks/use-current-message.js +4 -1
- package/esm/hooks/use-current-message.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-current-message.d.ts","sourceRoot":"","sources":["../../src/hooks/use-current-message.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiB,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAQ5E,sFAAsF;AACtF,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CACzC,iBAAiB,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"use-current-message.d.ts","sourceRoot":"","sources":["../../src/hooks/use-current-message.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiB,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAQ5E,sFAAsF;AACtF,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CACzC,iBAAiB,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAa3D,CAAC;AAEF;sCACsC;AACtC,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,qBAOlB;AACD;gCACgC;AAEhC,eAAO,MAAM,sBAAsB;cArCvB,MAAM;eACL,MAAM;CA4ClB,CAAC;AAEF;yBACyB;AACzB,eAAO,MAAM,sBAAsB,mDASlC,CAAC"}
|
|
@@ -40,7 +40,10 @@ const providers_1 = require("../providers");
|
|
|
40
40
|
const TamboMessageContext = (0, react_1.createContext)({});
|
|
41
41
|
/** Wraps all components, so that they can find what thread and message they are in */
|
|
42
42
|
const TamboMessageProvider = ({ children, threadId, messageId }) => {
|
|
43
|
-
|
|
43
|
+
// Use a unique key={...} to force a re-render when the messageId changes - this
|
|
44
|
+
// make sure that if the rendered component is swapped into a tree (like if
|
|
45
|
+
// you always show the last rendered component) then the state/etc is correct
|
|
46
|
+
return (react_1.default.createElement(TamboMessageContext.Provider, { value: { threadId, messageId }, key: `${threadId}-${messageId}` }, children));
|
|
44
47
|
};
|
|
45
48
|
exports.TamboMessageProvider = TamboMessageProvider;
|
|
46
49
|
/** Wraps a component with a ComponentMessageProvider - this allows the provider
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-current-message.js","sourceRoot":"","sources":["../../src/hooks/use-current-message.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"use-current-message.js","sourceRoot":"","sources":["../../src/hooks/use-current-message.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,oEAUC;AArCD,+CAA4E;AAC5E,4CAA8C;AAE9C,MAAM,mBAAmB,GAAG,IAAA,qBAAa,EAGtC,EAA6C,CAAC,CAAC;AAElD,sFAAsF;AAC/E,MAAM,oBAAoB,GAE7B,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE;IACxC,gFAAgF;IAChF,2EAA2E;IAC3E,6EAA6E;IAC7E,OAAO,CACL,8BAAC,mBAAmB,CAAC,QAAQ,IAC3B,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,EAC9B,GAAG,EAAE,GAAG,QAAQ,IAAI,SAAS,EAAE,IAE9B,QAAQ,CACoB,CAChC,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,oBAAoB,wBAc/B;AAEF;sCACsC;AACtC,SAAgB,4BAA4B,CAC1C,QAAyB,EACzB,QAAgB,EAChB,SAAiB;IAEjB,OAAO,CACL,8BAAC,4BAAoB,IAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,IAC3D,QAAQ,CACY,CACxB,CAAC;AACJ,CAAC;AACD;gCACgC;AAEzB,MAAM,sBAAsB,GAAG,GAAG,EAAE;IACzC,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,mBAAmB,CAAC,CAAC;IAChD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AARW,QAAA,sBAAsB,0BAQjC;AAEF;yBACyB;AAClB,MAAM,sBAAsB,GAAG,GAAG,EAAE;IACzC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAA,8BAAsB,GAAE,CAAC;IACzD,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,0BAAc,GAAE,CAAC;IACpC,IAAI,MAAM,CAAC,EAAE,IAAI,QAAQ,IAAI,MAAM,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;QACpD,OAAO,CAAC,IAAI,CAAC,sBAAsB,MAAM,CAAC,EAAE,QAAQ,QAAQ,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC;IAChE,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AATW,QAAA,sBAAsB,0BASjC","sourcesContent":["import React, { createContext, PropsWithChildren, useContext } from \"react\";\nimport { useTamboThread } from \"../providers\";\n\nconst TamboMessageContext = createContext<{\n threadId: string;\n messageId: string;\n}>({} as { threadId: string; messageId: string });\n\n/** Wraps all components, so that they can find what thread and message they are in */\nexport const TamboMessageProvider: React.FC<\n PropsWithChildren<{ threadId: string; messageId: string }>\n> = ({ children, threadId, messageId }) => {\n // Use a unique key={...} to force a re-render when the messageId changes - this\n // make sure that if the rendered component is swapped into a tree (like if\n // you always show the last rendered component) then the state/etc is correct\n return (\n <TamboMessageContext.Provider\n value={{ threadId, messageId }}\n key={`${threadId}-${messageId}`}\n >\n {children}\n </TamboMessageContext.Provider>\n );\n};\n\n/** Wraps a component with a ComponentMessageProvider - this allows the provider\n * to be used outside of a TSX file */\nexport function wrapWithTamboMessageProvider(\n children: React.ReactNode,\n threadId: string,\n messageId: string,\n) {\n return (\n <TamboMessageProvider threadId={threadId} messageId={messageId}>\n {children}\n </TamboMessageProvider>\n );\n}\n/** Hook used inside a component wrapped with ComponentMessageProvider, to get\n * the threadId and messageId */\n\nexport const useTamboMessageContext = () => {\n const context = useContext(TamboMessageContext);\n if (!context) {\n throw new Error(\n \"useTamboMessageContext must be used within a TamboMessageProvider\",\n );\n }\n return context;\n};\n\n/** Hook used inside a component wrapped with ComponentMessageProvider, to get\n * the current message */\nexport const useTamboCurrentMessage = () => {\n const { messageId, threadId } = useTamboMessageContext();\n const { thread } = useTamboThread();\n if (thread.id && threadId && thread.id !== threadId) {\n console.warn(`Thread ID mismatch ${thread.id} !== ${threadId}`);\n }\n\n const message = thread.messages.find((m) => m.id === messageId);\n return message;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-current-message.d.ts","sourceRoot":"","sources":["../../src/hooks/use-current-message.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiB,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAQ5E,sFAAsF;AACtF,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CACzC,iBAAiB,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"use-current-message.d.ts","sourceRoot":"","sources":["../../src/hooks/use-current-message.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiB,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAQ5E,sFAAsF;AACtF,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CACzC,iBAAiB,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAa3D,CAAC;AAEF;sCACsC;AACtC,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,qBAOlB;AACD;gCACgC;AAEhC,eAAO,MAAM,sBAAsB;cArCvB,MAAM;eACL,MAAM;CA4ClB,CAAC;AAEF;yBACyB;AACzB,eAAO,MAAM,sBAAsB,mDASlC,CAAC"}
|
|
@@ -3,7 +3,10 @@ import { useTamboThread } from "../providers";
|
|
|
3
3
|
const TamboMessageContext = createContext({});
|
|
4
4
|
/** Wraps all components, so that they can find what thread and message they are in */
|
|
5
5
|
export const TamboMessageProvider = ({ children, threadId, messageId }) => {
|
|
6
|
-
|
|
6
|
+
// Use a unique key={...} to force a re-render when the messageId changes - this
|
|
7
|
+
// make sure that if the rendered component is swapped into a tree (like if
|
|
8
|
+
// you always show the last rendered component) then the state/etc is correct
|
|
9
|
+
return (React.createElement(TamboMessageContext.Provider, { value: { threadId, messageId }, key: `${threadId}-${messageId}` }, children));
|
|
7
10
|
};
|
|
8
11
|
/** Wraps a component with a ComponentMessageProvider - this allows the provider
|
|
9
12
|
* to be used outside of a TSX file */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-current-message.js","sourceRoot":"","sources":["../../src/hooks/use-current-message.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAqB,UAAU,EAAE,MAAM,OAAO,CAAC;AAC5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AAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;yBACyB;AACzB,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,EAAE;IACzC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,sBAAsB,EAAE,CAAC;IACzD,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,CAAC;IACpC,IAAI,MAAM,CAAC,EAAE,IAAI,QAAQ,IAAI,MAAM,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;QACpD,OAAO,CAAC,IAAI,CAAC,sBAAsB,MAAM,CAAC,EAAE,QAAQ,QAAQ,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC;IAChE,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["import React, { createContext, PropsWithChildren, useContext } from \"react\";\nimport { useTamboThread } from \"../providers\";\n\nconst TamboMessageContext = createContext<{\n threadId: string;\n messageId: string;\n}>({} as { threadId: string; messageId: string });\n\n/** Wraps all components, so that they can find what thread and message they are in */\nexport const TamboMessageProvider: React.FC<\n PropsWithChildren<{ threadId: string; messageId: string }>\n> = ({ children, threadId, messageId }) => {\n // Use a unique key={...} to force a re-render when the messageId changes - this\n // make sure that if the rendered component is swapped into a tree (like if\n // you always show the last rendered component) then the state/etc is correct\n return (\n <TamboMessageContext.Provider\n value={{ threadId, messageId }}\n key={`${threadId}-${messageId}`}\n >\n {children}\n </TamboMessageContext.Provider>\n );\n};\n\n/** Wraps a component with a ComponentMessageProvider - this allows the provider\n * to be used outside of a TSX file */\nexport function wrapWithTamboMessageProvider(\n children: React.ReactNode,\n threadId: string,\n messageId: string,\n) {\n return (\n <TamboMessageProvider threadId={threadId} messageId={messageId}>\n {children}\n </TamboMessageProvider>\n );\n}\n/** Hook used inside a component wrapped with ComponentMessageProvider, to get\n * the threadId and messageId */\n\nexport const useTamboMessageContext = () => {\n const context = useContext(TamboMessageContext);\n if (!context) {\n throw new Error(\n \"useTamboMessageContext must be used within a TamboMessageProvider\",\n );\n }\n return context;\n};\n\n/** Hook used inside a component wrapped with ComponentMessageProvider, to get\n * the current message */\nexport const useTamboCurrentMessage = () => {\n const { messageId, threadId } = useTamboMessageContext();\n const { thread } = useTamboThread();\n if (thread.id && threadId && thread.id !== threadId) {\n console.warn(`Thread ID mismatch ${thread.id} !== ${threadId}`);\n }\n\n const message = thread.messages.find((m) => m.id === messageId);\n return message;\n};\n"]}
|