@superatomai/application-react 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +40 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -11
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var React6 = require('react');
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var shim = require('use-sync-external-store/shim');
|
|
5
6
|
var reactDom = require('react-dom');
|
|
6
7
|
|
|
7
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -69475,7 +69476,7 @@ function setSigningIn(value) {
|
|
|
69475
69476
|
listeners.forEach((l) => l());
|
|
69476
69477
|
}
|
|
69477
69478
|
function useSigningIn() {
|
|
69478
|
-
return
|
|
69479
|
+
return shim.useSyncExternalStore(
|
|
69479
69480
|
(l) => {
|
|
69480
69481
|
listeners.add(l);
|
|
69481
69482
|
return () => listeners.delete(l);
|
|
@@ -69490,7 +69491,7 @@ function setChatReady(value) {
|
|
|
69490
69491
|
listeners.forEach((l) => l());
|
|
69491
69492
|
}
|
|
69492
69493
|
function useStartingUp() {
|
|
69493
|
-
return
|
|
69494
|
+
return shim.useSyncExternalStore(
|
|
69494
69495
|
(l) => {
|
|
69495
69496
|
listeners.add(l);
|
|
69496
69497
|
return () => listeners.delete(l);
|
|
@@ -69500,7 +69501,7 @@ function useStartingUp() {
|
|
|
69500
69501
|
);
|
|
69501
69502
|
}
|
|
69502
69503
|
function useRetryingStatus() {
|
|
69503
|
-
return
|
|
69504
|
+
return shim.useSyncExternalStore(
|
|
69504
69505
|
(l) => {
|
|
69505
69506
|
listeners.add(l);
|
|
69506
69507
|
return () => listeners.delete(l);
|
|
@@ -69510,7 +69511,7 @@ function useRetryingStatus() {
|
|
|
69510
69511
|
);
|
|
69511
69512
|
}
|
|
69512
69513
|
function useAuthStatus() {
|
|
69513
|
-
return
|
|
69514
|
+
return shim.useSyncExternalStore(
|
|
69514
69515
|
(l) => {
|
|
69515
69516
|
listeners.add(l);
|
|
69516
69517
|
return () => listeners.delete(l);
|
|
@@ -69561,7 +69562,7 @@ function setMessageActions(actions) {
|
|
|
69561
69562
|
listeners2.forEach((l) => l());
|
|
69562
69563
|
}
|
|
69563
69564
|
function useMessageActions() {
|
|
69564
|
-
return
|
|
69565
|
+
return shim.useSyncExternalStore(
|
|
69565
69566
|
(l) => {
|
|
69566
69567
|
listeners2.add(l);
|
|
69567
69568
|
return () => listeners2.delete(l);
|
|
@@ -70398,8 +70399,9 @@ function useSuperAtom({
|
|
|
70398
70399
|
removed.add(msg.id);
|
|
70399
70400
|
}
|
|
70400
70401
|
setMessages((prev) => prev.filter((m) => !removed.has(m.id)));
|
|
70402
|
+
refreshThreads();
|
|
70401
70403
|
return { success: true };
|
|
70402
|
-
}, [resolvedUserId]);
|
|
70404
|
+
}, [resolvedUserId, refreshThreads]);
|
|
70403
70405
|
React6.useEffect(() => {
|
|
70404
70406
|
setMessageActions({ deleteMessage });
|
|
70405
70407
|
return () => setMessageActions({});
|
|
@@ -70562,15 +70564,38 @@ function ChatInput({
|
|
|
70562
70564
|
window.addEventListener("keydown", onKeyDown);
|
|
70563
70565
|
return () => window.removeEventListener("keydown", onKeyDown);
|
|
70564
70566
|
}, [showStop, onStop]);
|
|
70565
|
-
React6.
|
|
70567
|
+
const resize = React6.useCallback(() => {
|
|
70566
70568
|
const textarea = textareaRef.current;
|
|
70567
70569
|
if (!textarea) return;
|
|
70568
70570
|
textarea.style.height = "auto";
|
|
70569
70571
|
const newHeight = Math.min(textarea.scrollHeight, 200);
|
|
70570
70572
|
textarea.style.height = `${newHeight}px`;
|
|
70571
|
-
|
|
70572
|
-
|
|
70573
|
-
|
|
70573
|
+
setIsMultiline(newHeight > 60);
|
|
70574
|
+
}, []);
|
|
70575
|
+
React6.useEffect(resize, [input, resize]);
|
|
70576
|
+
React6.useEffect(() => {
|
|
70577
|
+
const frame = requestAnimationFrame(resize);
|
|
70578
|
+
document.fonts?.ready.then(resize).catch(() => {
|
|
70579
|
+
});
|
|
70580
|
+
const textarea = textareaRef.current;
|
|
70581
|
+
if (!textarea || typeof ResizeObserver === "undefined") {
|
|
70582
|
+
return () => cancelAnimationFrame(frame);
|
|
70583
|
+
}
|
|
70584
|
+
let width = textarea.clientWidth;
|
|
70585
|
+
let pending = 0;
|
|
70586
|
+
const observer = new ResizeObserver(() => {
|
|
70587
|
+
if (textarea.clientWidth === width) return;
|
|
70588
|
+
width = textarea.clientWidth;
|
|
70589
|
+
cancelAnimationFrame(pending);
|
|
70590
|
+
pending = requestAnimationFrame(resize);
|
|
70591
|
+
});
|
|
70592
|
+
observer.observe(textarea);
|
|
70593
|
+
return () => {
|
|
70594
|
+
cancelAnimationFrame(frame);
|
|
70595
|
+
cancelAnimationFrame(pending);
|
|
70596
|
+
observer.disconnect();
|
|
70597
|
+
};
|
|
70598
|
+
}, [resize]);
|
|
70574
70599
|
const setCursorToEnd = (textarea) => {
|
|
70575
70600
|
setTimeout(() => {
|
|
70576
70601
|
textarea.setSelectionRange(textarea.value.length, textarea.value.length);
|
|
@@ -70814,7 +70839,7 @@ function MessageBubble({ message, onStop }) {
|
|
|
70814
70839
|
setConfirmOpen(false);
|
|
70815
70840
|
if (!res.success) console.error("[SuperAtom] Could not delete the message:", res.error);
|
|
70816
70841
|
};
|
|
70817
|
-
const deleteButton = deleteMessage && responseComplete && !isAborted ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
70842
|
+
const deleteButton = deleteMessage && responseComplete && !isAborted ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute bottom-2 right-2 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity duration-200", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
70818
70843
|
"button",
|
|
70819
70844
|
{
|
|
70820
70845
|
onClick: () => setConfirmOpen(true),
|
|
@@ -70910,12 +70935,12 @@ function MessageBubble({ message, onStop }) {
|
|
|
70910
70935
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-base-content/70", children: "Generating component..." })
|
|
70911
70936
|
] })
|
|
70912
70937
|
] }) }),
|
|
70913
|
-
hasComponent && /* @__PURE__ */ jsxRuntime.
|
|
70938
|
+
hasComponent && /* @__PURE__ */ jsxRuntime.jsx("div", { id: `box-${message.id}`, className: "w-full px-4 lg:px-16 xl:px-24 2xl:px-32", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group relative", children: [
|
|
70914
70939
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl shadow-sm bg-base-100 border-2 border-base-300 min-h-[85vh] overflow-auto flex items-center justify-center p-5", children: /* @__PURE__ */ jsxRuntime.jsx(DSLRenderer, { dsl: message.schema.ui, data: message.schema.data ?? {} }) }),
|
|
70915
70940
|
deleteButton
|
|
70916
|
-
] }),
|
|
70917
|
-
!isStreaming && !hasComponent && hasText && isTextOnly && !isAborted && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center w-full px-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full md:w-[60vw]", children: [
|
|
70918
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl shadow-sm bg-base-100 border-2 border-base-300 p-4 text-base-content", children: /* @__PURE__ */ jsxRuntime.jsx(Markdown_default, { content: fullText, isStreaming: false }) }),
|
|
70941
|
+
] }) }),
|
|
70942
|
+
!isStreaming && !hasComponent && hasText && isTextOnly && !isAborted && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center w-full px-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full md:w-[60vw] group relative", children: [
|
|
70943
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl shadow-sm bg-base-100 border-2 border-base-300 p-4 pb-10 text-base-content", children: /* @__PURE__ */ jsxRuntime.jsx(Markdown_default, { content: fullText, isStreaming: false }) }),
|
|
70919
70944
|
deleteButton
|
|
70920
70945
|
] }) }),
|
|
70921
70946
|
/* @__PURE__ */ jsxRuntime.jsx(
|