@rapidaai/react 1.1.27

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.
Files changed (60) hide show
  1. package/LICENSE +21 -0
  2. package/dist/chunk-32YFHJN5.mjs +59 -0
  3. package/dist/chunk-32YFHJN5.mjs.map +1 -0
  4. package/dist/chunk-3YJ3G4GZ.mjs +77 -0
  5. package/dist/chunk-3YJ3G4GZ.mjs.map +1 -0
  6. package/dist/chunk-AB3ZXSEN.mjs +27569 -0
  7. package/dist/chunk-AB3ZXSEN.mjs.map +1 -0
  8. package/dist/chunk-GFACTURU.mjs +50 -0
  9. package/dist/chunk-GFACTURU.mjs.map +1 -0
  10. package/dist/chunk-Q4OXFE34.mjs +88 -0
  11. package/dist/chunk-Q4OXFE34.mjs.map +1 -0
  12. package/dist/chunk-WT7OUEDJ.mjs +50 -0
  13. package/dist/chunk-WT7OUEDJ.mjs.map +1 -0
  14. package/dist/components/connection-status.d.mts +7 -0
  15. package/dist/components/connection-status.d.ts +7 -0
  16. package/dist/components/connection-status.js +25321 -0
  17. package/dist/components/connection-status.js.map +1 -0
  18. package/dist/components/connection-status.mjs +34 -0
  19. package/dist/components/connection-status.mjs.map +1 -0
  20. package/dist/components/device-selector.d.mts +5 -0
  21. package/dist/components/device-selector.d.ts +5 -0
  22. package/dist/components/device-selector.js +26800 -0
  23. package/dist/components/device-selector.js.map +1 -0
  24. package/dist/components/device-selector.mjs +99 -0
  25. package/dist/components/device-selector.mjs.map +1 -0
  26. package/dist/components/live-transcript.d.mts +16 -0
  27. package/dist/components/live-transcript.d.ts +16 -0
  28. package/dist/components/live-transcript.js +25376 -0
  29. package/dist/components/live-transcript.js.map +1 -0
  30. package/dist/components/live-transcript.mjs +9 -0
  31. package/dist/components/live-transcript.mjs.map +1 -0
  32. package/dist/components/text/conversations/index.d.mts +2 -0
  33. package/dist/components/text/conversations/index.d.ts +2 -0
  34. package/dist/components/text/conversations/index.js +25344 -0
  35. package/dist/components/text/conversations/index.js.map +1 -0
  36. package/dist/components/text/conversations/index.mjs +9 -0
  37. package/dist/components/text/conversations/index.mjs.map +1 -0
  38. package/dist/components/text/index.d.mts +2 -0
  39. package/dist/components/text/index.d.ts +2 -0
  40. package/dist/components/text/index.js +25344 -0
  41. package/dist/components/text/index.js.map +1 -0
  42. package/dist/components/text/index.mjs +9 -0
  43. package/dist/components/text/index.mjs.map +1 -0
  44. package/dist/components/visualization/agent-multiband-audio-visualizer.d.mts +18 -0
  45. package/dist/components/visualization/agent-multiband-audio-visualizer.d.ts +18 -0
  46. package/dist/components/visualization/agent-multiband-audio-visualizer.js +119 -0
  47. package/dist/components/visualization/agent-multiband-audio-visualizer.js.map +1 -0
  48. package/dist/components/visualization/agent-multiband-audio-visualizer.mjs +8 -0
  49. package/dist/components/visualization/agent-multiband-audio-visualizer.mjs.map +1 -0
  50. package/dist/index-0bkcyQsE.d.mts +79 -0
  51. package/dist/index-0bkcyQsE.d.ts +79 -0
  52. package/dist/index.d.mts +17707 -0
  53. package/dist/index.d.ts +17707 -0
  54. package/dist/index.js +66000 -0
  55. package/dist/index.js.map +1 -0
  56. package/dist/index.mjs +38213 -0
  57. package/dist/index.mjs.map +1 -0
  58. package/dist/styles/index.css +656 -0
  59. package/package.json +117 -0
  60. package/readme.md +127 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 rapida.ai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,59 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
12
+ });
13
+ var __commonJS = (cb, mod) => function __require2() {
14
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
32
+
33
+ // src/styles/index.ts
34
+ import { clsx } from "clsx";
35
+ import { twMerge } from "tailwind-merge";
36
+ var sizes = {
37
+ small: 600,
38
+ medium: 1024,
39
+ large: 1440,
40
+ xlarge: 1920
41
+ };
42
+ var media = Object.keys(sizes).reduce(
43
+ (acc, size) => {
44
+ acc[size] = () => `@media (min-width:${sizes[size]}px)`;
45
+ return acc;
46
+ },
47
+ {}
48
+ );
49
+ function cn(...inputs) {
50
+ return twMerge(clsx(inputs));
51
+ }
52
+
53
+ export {
54
+ __require,
55
+ __commonJS,
56
+ __toESM,
57
+ cn
58
+ };
59
+ //# sourceMappingURL=chunk-32YFHJN5.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/styles/index.ts"],"sourcesContent":["/*\n * Copyright (c) 2024. Rapida\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *\n * Author: Prashant <prashant@rapida.ai>\n *\n */\nimport { ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/*\n * Media queries utility\n */\n\n/*\n * Inspired by https://github.com/DefinitelyTyped/DefinitelyTyped/issues/32914\n */\n\n// Update your breakpoints if you want\nexport const sizes = {\n small: 600,\n medium: 1024,\n large: 1440,\n xlarge: 1920,\n};\n\n// Iterate through the sizes and create min-width media queries\nexport const media = (Object.keys(sizes) as Array<keyof typeof sizes>).reduce(\n (acc, size) => {\n acc[size] = () => `@media (min-width:${sizes[size]}px)`;\n return acc;\n },\n {} as { [key in keyof typeof sizes]: () => string }\n);\n\n/* Example\nconst SomeDiv = styled.div`\n display: flex;\n ....\n ${media.medium} {\n display: block\n }\n`;\n*/\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAqB,YAAY;AACjC,SAAS,eAAe;AAWjB,IAAM,QAAQ;AAAA,EACnB,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,QAAQ;AACV;AAGO,IAAM,QAAS,OAAO,KAAK,KAAK,EAAgC;AAAA,EACrE,CAAC,KAAK,SAAS;AACb,QAAI,IAAI,IAAI,MAAM,qBAAqB,MAAM,IAAI,CAAC;AAClD,WAAO;AAAA,EACT;AAAA,EACA,CAAC;AACH;AAYO,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;","names":[]}
@@ -0,0 +1,77 @@
1
+ import {
2
+ cn
3
+ } from "./chunk-32YFHJN5.mjs";
4
+
5
+ // src/components/visualization/agent-multiband-audio-visualizer.tsx
6
+ import { useEffect, useState } from "react";
7
+ import { jsx } from "react/jsx-runtime";
8
+ var AgentMultibandAudioVisualizer = ({
9
+ classNames,
10
+ state,
11
+ barWidth,
12
+ minBarHeight,
13
+ maxBarHeight,
14
+ barColor = "bg-white",
15
+ frequencies
16
+ }) => {
17
+ const summedFrequencies = frequencies.map((bandFrequencies) => {
18
+ const sum = bandFrequencies.reduce((a, b) => a + b, 0);
19
+ return Math.sqrt(sum / bandFrequencies.length);
20
+ });
21
+ const [thinkingIndex, setThinkingIndex] = useState(
22
+ Math.floor(summedFrequencies.length / 2)
23
+ );
24
+ const [thinkingDirection, setThinkingDirection] = useState(
25
+ "right"
26
+ );
27
+ useEffect(() => {
28
+ if (state !== "thinking") {
29
+ setThinkingIndex(Math.floor(summedFrequencies.length / 2));
30
+ return;
31
+ }
32
+ const timeout = setTimeout(() => {
33
+ if (thinkingDirection === "right") {
34
+ if (thinkingIndex === summedFrequencies.length - 1) {
35
+ setThinkingDirection("left");
36
+ setThinkingIndex((prev) => prev - 1);
37
+ } else {
38
+ setThinkingIndex((prev) => prev + 1);
39
+ }
40
+ } else {
41
+ if (thinkingIndex === 0) {
42
+ setThinkingDirection("right");
43
+ setThinkingIndex((prev) => prev + 1);
44
+ } else {
45
+ setThinkingIndex((prev) => prev - 1);
46
+ }
47
+ }
48
+ }, 200);
49
+ return () => clearTimeout(timeout);
50
+ }, [state, summedFrequencies.length, thinkingDirection, thinkingIndex]);
51
+ return /* @__PURE__ */ jsx("div", { className: cn(classNames, "flex flex-row items-center"), children: summedFrequencies.map((frequency, index) => {
52
+ const isCenter = index === Math.floor(summedFrequencies.length / 2);
53
+ let transform;
54
+ return /* @__PURE__ */ jsx(
55
+ "div",
56
+ {
57
+ className: cn(
58
+ barColor,
59
+ "rounded-full",
60
+ isCenter && state === "listening" ? "animate-pulse" : ""
61
+ ),
62
+ style: {
63
+ height: minBarHeight + frequency * (maxBarHeight - minBarHeight) + "px",
64
+ width: barWidth + "px",
65
+ transition: "background-color 0.35s ease-out, transform 0.25s ease-out",
66
+ transform
67
+ }
68
+ },
69
+ "frequency-" + index
70
+ );
71
+ }) });
72
+ };
73
+
74
+ export {
75
+ AgentMultibandAudioVisualizer
76
+ };
77
+ //# sourceMappingURL=chunk-3YJ3G4GZ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/visualization/agent-multiband-audio-visualizer.tsx"],"sourcesContent":["/*\n * Copyright (c) 2024. Rapida\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *\n * Author: Prashant <prashant@rapida.ai>\n *\n */\nimport { cn } from \"@/rapida/styles\";\nimport { useEffect, useState } from \"react\";\n\n/**\n * @beta\n */\nexport type AgentState =\n | \"disconnected\"\n | \"connecting\"\n | \"initializing\"\n | \"listening\"\n | \"thinking\"\n | \"speaking\";\n\ntype AgentMultibandAudioVisualizerProps = {\n classNames?: string;\n state: AgentState;\n barWidth: number;\n minBarHeight: number;\n maxBarHeight: number;\n barColor?: string;\n frequencies: Float32Array[] | number[][];\n};\n\nexport const AgentMultibandAudioVisualizer = ({\n classNames,\n state,\n barWidth,\n minBarHeight,\n maxBarHeight,\n barColor = \"bg-white\",\n frequencies,\n}: AgentMultibandAudioVisualizerProps) => {\n const summedFrequencies = frequencies.map((bandFrequencies) => {\n const sum = (bandFrequencies as number[]).reduce((a, b) => a + b, 0);\n return Math.sqrt(sum / bandFrequencies.length);\n });\n\n const [thinkingIndex, setThinkingIndex] = useState(\n Math.floor(summedFrequencies.length / 2)\n );\n const [thinkingDirection, setThinkingDirection] = useState<\"left\" | \"right\">(\n \"right\"\n );\n\n useEffect(() => {\n if (state !== \"thinking\") {\n setThinkingIndex(Math.floor(summedFrequencies.length / 2));\n return;\n }\n const timeout = setTimeout(() => {\n if (thinkingDirection === \"right\") {\n if (thinkingIndex === summedFrequencies.length - 1) {\n setThinkingDirection(\"left\");\n setThinkingIndex((prev) => prev - 1);\n } else {\n setThinkingIndex((prev) => prev + 1);\n }\n } else {\n if (thinkingIndex === 0) {\n setThinkingDirection(\"right\");\n setThinkingIndex((prev) => prev + 1);\n } else {\n setThinkingIndex((prev) => prev - 1);\n }\n }\n }, 200);\n\n return () => clearTimeout(timeout);\n }, [state, summedFrequencies.length, thinkingDirection, thinkingIndex]);\n\n return (\n <div className={cn(classNames, \"flex flex-row items-center\")}>\n {summedFrequencies.map((frequency, index) => {\n const isCenter = index === Math.floor(summedFrequencies.length / 2);\n let transform;\n\n return (\n <div\n className={cn(\n barColor,\n \"rounded-full\",\n isCenter && state === \"listening\" ? \"animate-pulse\" : \"\"\n )}\n key={\"frequency-\" + index}\n style={{\n height:\n minBarHeight + frequency * (maxBarHeight - minBarHeight) + \"px\",\n width: barWidth + \"px\",\n transition:\n \"background-color 0.35s ease-out, transform 0.25s ease-out\",\n transform: transform,\n }}\n ></div>\n );\n })}\n </div>\n );\n};\n"],"mappings":";;;;;AAyBA,SAAS,WAAW,gBAAgB;AA6E1B;AAtDH,IAAM,gCAAgC,CAAC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AACF,MAA0C;AACxC,QAAM,oBAAoB,YAAY,IAAI,CAAC,oBAAoB;AAC7D,UAAM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