@rannah-labs/react-voice-orb 1.1.3

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/README.md +240 -0
  2. package/assets/orb-ss.png +0 -0
  3. package/assets/thing.png +0 -0
  4. package/dist/bun-server/src/types/index.d.ts +37 -0
  5. package/dist/bun-server/src/types/index.js +2 -0
  6. package/dist/src/app/Types/TranscriberStuff.d.ts +0 -0
  7. package/dist/src/app/Types/TranscriberStuff.js +1 -0
  8. package/dist/src/app/Types/apiModels.d.ts +31 -0
  9. package/dist/src/app/Types/apiModels.js +2 -0
  10. package/dist/src/app/Types/api_types.d.ts +34 -0
  11. package/dist/src/app/Types/api_types.js +2 -0
  12. package/dist/src/app/Types/better-trpc.d.ts +5 -0
  13. package/dist/src/app/Types/better-trpc.js +23 -0
  14. package/dist/src/app/Types/browser-only.d.ts +1 -0
  15. package/dist/src/app/Types/browser-only.js +12 -0
  16. package/dist/src/app/Types/builltInNodesTemplates.d.ts +1070 -0
  17. package/dist/src/app/Types/builltInNodesTemplates.js +1341 -0
  18. package/dist/src/app/Types/defaults.d.ts +7 -0
  19. package/dist/src/app/Types/defaults.js +210 -0
  20. package/dist/src/app/Types/demo_extension.d.ts +11 -0
  21. package/dist/src/app/Types/demo_extension.js +190 -0
  22. package/dist/src/app/Types/envObject.d.ts +97 -0
  23. package/dist/src/app/Types/envObject.js +5 -0
  24. package/dist/src/app/Types/firebase.d.ts +30413 -0
  25. package/dist/src/app/Types/firebase.js +6696 -0
  26. package/dist/src/app/Types/gen_openapi.d.ts +130 -0
  27. package/dist/src/app/Types/gen_openapi.js +2 -0
  28. package/dist/src/app/Types/global_types.d.ts +254 -0
  29. package/dist/src/app/Types/global_types.js +6 -0
  30. package/dist/src/app/Types/messages_types.d.ts +76 -0
  31. package/dist/src/app/Types/messages_types.js +1 -0
  32. package/dist/src/app/Types/vapi_types.d.ts +358 -0
  33. package/dist/src/app/Types/vapi_types.js +2 -0
  34. package/dist/src/app/Types/vf_types.d.ts +33 -0
  35. package/dist/src/app/Types/vf_types.js +2 -0
  36. package/dist/src/public_packages/react-voice-orb/src/animation-orb.d.ts +11 -0
  37. package/dist/src/public_packages/react-voice-orb/src/animation-orb.js +397 -0
  38. package/dist/src/public_packages/react-voice-orb/src/index.d.ts +5 -0
  39. package/dist/src/public_packages/react-voice-orb/src/index.js +16 -0
  40. package/dist/src/public_packages/react-voice-orb/src/providers/AIAudioProvider.d.ts +21 -0
  41. package/dist/src/public_packages/react-voice-orb/src/providers/AIAudioProvider.js +81 -0
  42. package/dist/src/public_packages/react-voice-orb/src/providers/ThemeProvider.d.ts +23 -0
  43. package/dist/src/public_packages/react-voice-orb/src/providers/ThemeProvider.js +202 -0
  44. package/dist/src/public_packages/react-voice-orb/src/scripts/same-script.d.ts +1 -0
  45. package/dist/src/public_packages/react-voice-orb/src/scripts/same-script.js +79 -0
  46. package/dist/src/public_packages/react-voice-orb/src/spinner.d.ts +3 -0
  47. package/dist/src/public_packages/react-voice-orb/src/spinner.js +17 -0
  48. package/dist/src/public_packages/react-voice-orb/tsconfig.tsbuildinfo +1 -0
  49. package/dist/vg-docker/src/+global_consts/client.d.ts +84 -0
  50. package/dist/vg-docker/src/+global_consts/client.js +105 -0
  51. package/package.json +46 -0
  52. package/scripts/post-tsc.ts +74 -0
  53. package/src/animation-orb.tsx +441 -0
  54. package/src/index.ts +5 -0
  55. package/src/providers/AIAudioProvider.tsx +100 -0
  56. package/src/providers/ThemeProvider.tsx +211 -0
  57. package/src/scripts/same-script.ts +73 -0
  58. package/src/spinner.tsx +19 -0
  59. package/tsconfig.json +34 -0
  60. package/webpack.config.js +141 -0
@@ -0,0 +1,211 @@
1
+ "use client";
2
+ import React, { createContext, ReactNode, useContext, useState } from "react";
3
+ declare module "react" {
4
+ interface CSSProperties {
5
+ [key: `--${string}`]: string | number;
6
+ }
7
+ }
8
+ import colorConvert from "color-convert";
9
+ const ThemeContext = createContext<any>("blue-light");
10
+
11
+ export type ThemeProviderProps = {
12
+ children: ReactNode;
13
+ setCustomStyles?: (styles: React.CSSProperties) => void;
14
+ customStyles?: React.CSSProperties;
15
+ target?: string;
16
+ initTheme?: string;
17
+ useLocalStorage?: boolean;
18
+ getColor: (colorToGet: string, opacity?: number) => string;
19
+ };
20
+
21
+ export function useOrbTheme() {
22
+ const context = useContext<ThemeProviderProps>(ThemeContext);
23
+ if (!context) {
24
+ throw new Error("use orb theme must be used within a theme provider");
25
+ }
26
+ return context;
27
+ }
28
+
29
+ const OrbThemeProvider = (props: {
30
+ children: ReactNode;
31
+ customStyles?: React.CSSProperties;
32
+ isDark?: boolean;
33
+ primaryColor?: string;
34
+ }) => {
35
+ const [customStyles, setCustomStyles] = useState(props.customStyles || {});
36
+
37
+ React.useEffect(() => {
38
+ // no keys in the customStyles object
39
+ if (Object.keys(customStyles)?.length === 0) {
40
+ // handle autogenerate by the primary color
41
+ if (props.primaryColor) {
42
+ switchCustomColorPallet(props.primaryColor);
43
+ } else {
44
+ // handle default theme
45
+ switchCustomColorPallet("#0000FF");
46
+ }
47
+ }
48
+ }, [customStyles, props.primaryColor, props.isDark]);
49
+
50
+ function getColor(colorToGet: string, opacity?: number) {
51
+ const element = document.getElementById("vg-theme-container");
52
+ if (!element) return;
53
+ const styles = window.getComputedStyle(element);
54
+ const mainColorRaw = styles.getPropertyValue(`--vg-${colorToGet}`);
55
+ const mainColorHsl = mainColorRaw
56
+ .split(" ")
57
+ .map((item) => Number(item.replaceAll(`%`, "")));
58
+ if (opacity) {
59
+ return `rgba(${colorConvert.hsl
60
+ .rgb(mainColorHsl as any)
61
+ .join(`,`)}, ${opacity})`;
62
+ }
63
+ const mainColorHex = colorConvert.hsl.hex(mainColorHsl as any);
64
+ return `#${mainColorHex}`;
65
+ }
66
+
67
+ const handleAutoGenPallet = (rootColor: string, themeType?: string) => {
68
+ const baseColorHSL: any = colorConvert.hex.hsl(rootColor);
69
+ // console.log(baseColorHSL);
70
+ if (baseColorHSL?.length) {
71
+ const newHSLColorsArray: any = [];
72
+ for (let i = 10; i > 0; i--) {
73
+ const changePerIndex = 10;
74
+ let newHslColor = baseColorHSL.slice(0, 2);
75
+ const finalLuinousValue =
76
+ i * changePerIndex === 100 ? 95 : i * changePerIndex || 5;
77
+ newHslColor[2] = finalLuinousValue;
78
+ newHSLColorsArray.push(newHslColor);
79
+ }
80
+ const nineColorPalletFinale =
81
+ themeType === "light"
82
+ ? newHSLColorsArray.slice().reverse()
83
+ : newHSLColorsArray;
84
+ return nineColorPalletFinale;
85
+ }
86
+ };
87
+
88
+ function switchCustomColorPallet(customThemeJSONString: string) {
89
+ let themeObject: {
90
+ primary: string;
91
+ } = {
92
+ primary: props.primaryColor || "#0000FF",
93
+ };
94
+ try {
95
+ themeObject = JSON.parse(customThemeJSONString);
96
+ } catch (error) {
97
+ themeObject = {
98
+ primary: props.primaryColor || "#0000FF",
99
+ };
100
+ }
101
+ try {
102
+ // themeObject = JSON.parse(customThemeJSONString);
103
+ // console.log(themeObject)
104
+ const primaryHSL = colorConvert.hex.hsl(themeObject.primary);
105
+ const nineCollorPallet = handleAutoGenPallet(
106
+ themeObject.primary,
107
+ props.isDark ? "dark" : "light"
108
+ );
109
+ // console.log(nineCollorPallet)
110
+ setCustomStyles({
111
+ "--vg-primary": primaryHSL
112
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
113
+ .join(` `),
114
+ "--vg-primary-50": nineCollorPallet[0]
115
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
116
+ .join(` `),
117
+ "--vg-primary-100": nineCollorPallet[1]
118
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
119
+ .join(` `),
120
+ "--vg-primary-200": nineCollorPallet[2]
121
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
122
+ .join(` `),
123
+ "--vg-primary-300": nineCollorPallet[3]
124
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
125
+ .join(` `),
126
+ "--vg-primary-400": nineCollorPallet[4]
127
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
128
+ .join(` `),
129
+ "--vg-primary-500": nineCollorPallet[5]
130
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
131
+ .join(` `),
132
+ "--vg-primary-600": nineCollorPallet[6]
133
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
134
+ .join(` `),
135
+ "--vg-primary-700": nineCollorPallet[7]
136
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
137
+ .join(` `),
138
+ "--vg-primary-800": nineCollorPallet[8]
139
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
140
+ .join(` `),
141
+ "--vg-primary-900": nineCollorPallet[9]
142
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
143
+ .join(` `),
144
+ } as any);
145
+ } catch (error) {
146
+ console.error(`Error parsing custom theme JSON: `, error);
147
+ }
148
+ }
149
+
150
+ const setCustomTheme = (primaryHSL: any, nineCollorPallet?: any) => {
151
+ // console.log(`custom theme triggered:: `, primaryHSL, nineCollorPallet)
152
+ if (primaryHSL === false && !nineCollorPallet.length) {
153
+ setCustomStyles({});
154
+ }
155
+ if (nineCollorPallet?.length) {
156
+ // console.log('SETTING CUSTOM STYLES ')
157
+ setCustomStyles({
158
+ "--vg-primary": primaryHSL
159
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
160
+ .join(` `),
161
+ "--vg-primary-50": nineCollorPallet[0]
162
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
163
+ .join(` `),
164
+ "--vg-primary-100": nineCollorPallet[1]
165
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
166
+ .join(` `),
167
+ "--vg-primary-200": nineCollorPallet[2]
168
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
169
+ .join(` `),
170
+ "--vg-primary-300": nineCollorPallet[3]
171
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
172
+ .join(` `),
173
+ "--vg-primary-400": nineCollorPallet[4]
174
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
175
+ .join(` `),
176
+ "--vg-primary-500": nineCollorPallet[5]
177
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
178
+ .join(` `),
179
+ "--vg-primary-600": nineCollorPallet[6]
180
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
181
+ .join(` `),
182
+ "--vg-primary-700": nineCollorPallet[7]
183
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
184
+ .join(` `),
185
+ "--vg-primary-800": nineCollorPallet[8]
186
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
187
+ .join(` `),
188
+ "--vg-primary-900": nineCollorPallet[9]
189
+ .map((item: any, index: number) => (index === 0 ? item : `${item}%`))
190
+ .join(` `),
191
+ } as any);
192
+ }
193
+ };
194
+
195
+ const value = {
196
+ customStyles,
197
+ setCustomTheme,
198
+ getColor,
199
+ switchCustomColorPallet,
200
+ };
201
+
202
+ return (
203
+ <ThemeContext.Provider value={value}>
204
+ <div id={"vg-theme-container"} style={customStyles}>
205
+ {props.children}
206
+ </div>
207
+ </ThemeContext.Provider>
208
+ );
209
+ };
210
+
211
+ export default OrbThemeProvider;
@@ -0,0 +1,73 @@
1
+ import * as fs from "fs/promises";
2
+ import * as path from "path";
3
+
4
+ /**
5
+ * Deletes all files and folders inside `rootPath` except for those
6
+ * whose relative paths (from rootPath) appear in the `exceptions` array.
7
+ *
8
+ * @param rootPath - The directory to process.
9
+ * @param exceptions - An array of paths (relative to rootPath) to keep.
10
+ */
11
+ async function deleteAllExcept(
12
+ rootPath: string,
13
+ exceptions: string[]
14
+ ): Promise<void> {
15
+ // Normalize exception paths for consistent matching.
16
+ const exceptionsSet = new Set(exceptions.map((e) => path.normalize(e)));
17
+
18
+ /**
19
+ * Recursively processes the directory at `currentPath`.
20
+ *
21
+ * @param currentPath - Absolute path of the current directory.
22
+ * @param relativePath - The path relative to the original rootPath.
23
+ */
24
+ async function processDirectory(
25
+ currentPath: string,
26
+ relativePath: string
27
+ ): Promise<void> {
28
+ // Read the directory entries.
29
+ const items = await fs.readdir(currentPath);
30
+
31
+ for (const item of items) {
32
+ // Build the relative path for the item.
33
+ const itemRelPath = relativePath ? path.join(relativePath, item) : item;
34
+ const fullItemPath = path.join(currentPath, item);
35
+
36
+ // If the item is in the exceptions list, skip processing it.
37
+ if (exceptionsSet.has(path.normalize(itemRelPath))) {
38
+ // Do not process inside an exception folder (or delete an exception file).
39
+ continue;
40
+ }
41
+
42
+ const stats = await fs.lstat(fullItemPath);
43
+ if (stats.isDirectory()) {
44
+ // Process the contents of the directory.
45
+ await processDirectory(fullItemPath, itemRelPath);
46
+ // After processing, check if the directory is now empty.
47
+ const remaining = await fs.readdir(fullItemPath);
48
+ if (remaining.length === 0) {
49
+ await fs.rmdir(fullItemPath);
50
+ }
51
+ } else {
52
+ // Delete the file.
53
+ await fs.unlink(fullItemPath);
54
+ }
55
+ }
56
+ }
57
+
58
+ // Process the root directory but never remove the root itself.
59
+ await processDirectory(rootPath, "");
60
+ }
61
+
62
+ // --- Example usage ---
63
+ // This call will delete everything under './dist/vg-docker/src'
64
+ // except for the folder "+global_consts" and any file/folder whose
65
+ // relative path matches one of the entries in the exceptions array.
66
+ deleteAllExcept("./dist", [
67
+ "vg-docker/src/+global_consts/client.js",
68
+ "vg-docker/src/+global_consts/client.d.ts",
69
+ "src/app/Types",
70
+ "src/app/Types",
71
+ "bun-server",
72
+ "src/public_packages/react-voice-orb",
73
+ ]).catch(console.error);
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+
3
+ const Spinner = () => {
4
+ return (
5
+ <div
6
+ className="pulse"
7
+ style={{
8
+ width: "50px",
9
+ height: "50px",
10
+ backgroundColor: "white",
11
+ borderRadius: "50%",
12
+ animation: "pulse 1.5s infinite",
13
+ margin: " auto",
14
+ }}
15
+ />
16
+ );
17
+ };
18
+
19
+ export default Spinner;
package/tsconfig.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "esnext",
4
+ "module": "CommonJS",
5
+ "baseUrl": "./",
6
+ "composite": true,
7
+ "strict": true,
8
+ "jsx": "react",
9
+ "noEmit": false,
10
+ "allowJs": true,
11
+ "outDir": "dist",
12
+ "rootDir": "../../../",
13
+ "skipLibCheck": true,
14
+ "preserveSymlinks": false,
15
+ "sourceMap": false,
16
+ "esModuleInterop": true,
17
+ "declaration": true,
18
+ "isolatedModules": true
19
+ },
20
+ "include": [
21
+ "src/**/*.tsx",
22
+ "src/**/*.ts",
23
+ "../../../src/app/Types/*.ts"
24
+ ],
25
+ "exclude": [
26
+ "node_modules",
27
+ "dist",
28
+ "packages/*",
29
+ "vg-docker",
30
+ "call-service/*",
31
+ "bun-server/*",
32
+ "../../../src/*.tsx"
33
+ ]
34
+ }
@@ -0,0 +1,141 @@
1
+ const MiniCssExtractPlugin = require("mini-css-extract-plugin");
2
+ const TerserPlugin = require("terser-webpack-plugin");
3
+ const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
4
+ // const removeDuplicates = require("./remove-dups.js"); // Adjust the path as necessary
5
+ const path = require("path");
6
+ // const million = require("million/compiler");
7
+ // const { millionConfig } = require('./next.config.js');
8
+ const webpack = require("webpack");
9
+ // const AddImportantPlugin = require("./add-important-styles.js"); // Import the custom plugin
10
+
11
+ module.exports = (env) => {
12
+ const dir = env.dir || `/tmp/replace_me`;
13
+
14
+ return {
15
+ mode: "production",
16
+ entry: "./src/app/Components/root_build.js",
17
+ output: {
18
+ path: dir,
19
+ filename: "vg_bundle.js",
20
+ },
21
+ resolve: {
22
+ alias: {
23
+ "@vg-edge": path.resolve(__dirname, "vg-edge"),
24
+ "@main": path.resolve(__dirname, "vg-docker/src"),
25
+ "@monorepo": path.resolve(__dirname),
26
+ "@": path.resolve(__dirname, "src"),
27
+ "@server": path.resolve(__dirname, "vg-docker"),
28
+ "@nextui-org/react": path.resolve(
29
+ __dirname,
30
+ `src`,
31
+ `nextui-fork`,
32
+ `nextui`,
33
+ `packages`,
34
+ `core`,
35
+ `react`
36
+ ),
37
+ "@nextui-org/theme": path.resolve(
38
+ __dirname,
39
+ `src`,
40
+ `nextui-fork`,
41
+ `nextui`,
42
+ `packages`,
43
+ `core`,
44
+ `theme`
45
+ ),
46
+ react: path.resolve(__dirname, `node_modules`, `react`),
47
+ // "react-dom/test-utils": "preact/test-utils",
48
+ "react-dom": path.resolve(__dirname, `node_modules`, `react-dom`),
49
+ // "react/jsx-runtime": "preact/jsx-runtime"
50
+ },
51
+ extensions: [".ts", ".tsx", ".js", ".jsx"],
52
+ },
53
+ module: {
54
+ rules: [
55
+ {
56
+ test: /\.(js|jsx|ts|tsx)$/,
57
+ exclude: /node_modules/,
58
+ loader: "babel-loader",
59
+ options: {
60
+ presets: [
61
+ "@babel/preset-env",
62
+ "@babel/preset-react",
63
+ "@babel/preset-typescript",
64
+ "next/babel",
65
+ ],
66
+ plugins: [
67
+ "./babel-react-prefix-classnames.js",
68
+ // ["@babel/plugin-transform-react-jsx", {
69
+ // "pragma": "h",
70
+ // "pragmaFrag": "Fragment",
71
+ // }]
72
+ ],
73
+ },
74
+ },
75
+ {
76
+ test: /\.css$/,
77
+ use: [
78
+ MiniCssExtractPlugin.loader,
79
+ "css-loader",
80
+ {
81
+ loader: "postcss-loader",
82
+ options: {
83
+ postcssOptions: {
84
+ plugins: [
85
+ require("autoprefixer"),
86
+ require("tailwindcss"),
87
+ require("postcss-prefixer")({
88
+ prefix: "vg-",
89
+ }),
90
+ require("postcss-selector-namespace")({
91
+ namespace: ".vg-render-container", // Replace with your desired ID
92
+ }),
93
+ // require('postcss-safe-important')(), // This will add !important to all styles
94
+ ],
95
+ },
96
+ },
97
+ },
98
+ ],
99
+ },
100
+ ],
101
+ },
102
+ optimization: {
103
+ minimizer: [
104
+ new TerserPlugin({
105
+ terserOptions: {
106
+ // Enable/disable options as needed
107
+ compress: {
108
+ drop_console: true, // Remove console.* calls
109
+ },
110
+ output: {
111
+ comments: false, // Remove comments
112
+ },
113
+ },
114
+ extractComments: false, // Don't extract comments to a separate file
115
+ }),
116
+ new CssMinimizerPlugin(),
117
+ ],
118
+ },
119
+ plugins: [
120
+ new MiniCssExtractPlugin({
121
+ filename: "styles.css",
122
+ }),
123
+ new AddImportantPlugin(), // Add the custom plugin
124
+ new webpack.DefinePlugin({
125
+ "process.env": {
126
+ NODE_ENV: JSON.stringify("production"),
127
+ WORKER_ENV: JSON.stringify("production"),
128
+ },
129
+ }),
130
+ // million.webpack({
131
+ // auto: {
132
+ // rsc: true,
133
+ // threshold: 0.25, // default: 0.1,
134
+ // skip: [/nextui/g],
135
+ // mute: true
136
+ // },
137
+ // mute: true
138
+ // })
139
+ ],
140
+ };
141
+ };