bibot 1.0.3 → 1.0.5

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 (95) hide show
  1. package/dist/components/bibot.js +171 -0
  2. package/dist/components/bibot.js.map +1 -0
  3. package/dist/config/appStateEnums.js +5 -10
  4. package/dist/config/endpointEnums.js +22 -27
  5. package/dist/config/index.js +5 -38
  6. package/dist/config/statusCode.js +44 -49
  7. package/dist/context/AppContext.js +56 -73
  8. package/dist/context/index.js +3 -16
  9. package/dist/hooks/index.d.ts +0 -1
  10. package/dist/hooks/index.js +4 -38
  11. package/dist/hooks/index.js.map +1 -1
  12. package/dist/hooks/mobileView.js +18 -33
  13. package/dist/hooks/usePluginFactory.js +77 -60
  14. package/dist/index.d.ts +2 -1
  15. package/dist/index.js +6 -9
  16. package/dist/index.js.map +1 -1
  17. package/dist/reducers/appReducer.js +22 -24
  18. package/dist/reducers/index.js +3 -16
  19. package/dist/services/index.js +3 -16
  20. package/dist/services/plugin-api.js +182 -179
  21. package/dist/types/coreInterfaces.d.ts +10 -1
  22. package/dist/types/coreInterfaces.js +2 -5
  23. package/dist/types/index.js +3 -16
  24. package/dist/utils/index.js +3 -27
  25. package/dist/utils/sessionManager.js +12 -16
  26. package/dist/utils/trimWhitespace.js +11 -15
  27. package/package.json +54 -50
  28. package/.babelrc +0 -7
  29. package/.vscode/settings.json +0 -5
  30. package/dist/bibot.js +0 -173
  31. package/dist/bibot.js.map +0 -1
  32. package/dist/hooks/useBiBotChatBot.d.ts +0 -29
  33. package/dist/hooks/useBiBotChatBot.js +0 -206
  34. package/dist/hooks/useBiBotChatBot.js.map +0 -1
  35. package/dist/index.css +0 -36
  36. package/dist/styles/RegisterPageStyle.css +0 -63
  37. package/dist/styles/adminPortal.css +0 -26
  38. package/dist/styles/appConfig.css +0 -90
  39. package/dist/styles/buttonStyle.css +0 -27
  40. package/dist/styles/chatStyle.css +0 -140
  41. package/dist/styles/index.css +0 -82
  42. package/dist/styles/predefinedStyle.css +0 -35
  43. package/dist/styles/themeStyle.css +0 -42
  44. package/dist/styles/training.css +0 -86
  45. package/example/README.md +0 -46
  46. package/example/package-lock.json +0 -18173
  47. package/example/package.json +0 -47
  48. package/example/public/favicon.ico +0 -0
  49. package/example/public/index.html +0 -43
  50. package/example/public/logo192.png +0 -0
  51. package/example/public/logo512.png +0 -0
  52. package/example/public/manifest.json +0 -25
  53. package/example/public/robots.txt +0 -3
  54. package/example/src/App.css +0 -38
  55. package/example/src/App.test.tsx +0 -9
  56. package/example/src/App.tsx +0 -28
  57. package/example/src/index.css +0 -13
  58. package/example/src/index.tsx +0 -13
  59. package/example/src/logo.svg +0 -1
  60. package/example/src/react-app-env.d.ts +0 -1
  61. package/example/tsconfig.json +0 -26
  62. package/src/bibot.tsx +0 -111
  63. package/src/config/appStateEnums.ts +0 -3
  64. package/src/config/endpointEnums.ts +0 -28
  65. package/src/config/index.ts +0 -5
  66. package/src/config/statusCode.ts +0 -49
  67. package/src/context/AppContext.tsx +0 -66
  68. package/src/context/index.ts +0 -3
  69. package/src/hooks/index.ts +0 -5
  70. package/src/hooks/mobileView.tsx +0 -17
  71. package/src/hooks/useBiBotChatBot.tsx +0 -107
  72. package/src/hooks/usePluginFactory.tsx +0 -38
  73. package/src/index.css +0 -36
  74. package/src/index.tsx +0 -3
  75. package/src/reducers/appReducer.ts +0 -16
  76. package/src/reducers/index.ts +0 -4
  77. package/src/services/index.ts +0 -2
  78. package/src/services/plugin-api.tsx +0 -120
  79. package/src/styles/RegisterPageStyle.css +0 -63
  80. package/src/styles/adminPortal.css +0 -26
  81. package/src/styles/appConfig.css +0 -90
  82. package/src/styles/buttonStyle.css +0 -27
  83. package/src/styles/chatStyle.css +0 -140
  84. package/src/styles/index.css +0 -82
  85. package/src/styles/predefinedStyle.css +0 -35
  86. package/src/styles/themeStyle.css +0 -42
  87. package/src/styles/training.css +0 -86
  88. package/src/types/coreInterfaces.ts +0 -69
  89. package/src/types/index.ts +0 -4
  90. package/src/utils/index.ts +0 -2
  91. package/src/utils/sessionManager.tsx +0 -15
  92. package/src/utils/trimWhitespace.ts +0 -11
  93. package/tsconfig.json +0 -25
  94. package/webpack.config.js +0 -19
  95. /package/dist/{bibot.d.ts → components/bibot.d.ts} +0 -0
@@ -1,47 +0,0 @@
1
- {
2
- "name": "example",
3
- "version": "0.1.0",
4
- "private": true,
5
- "dependencies": {
6
- "@testing-library/jest-dom": "^5.17.0",
7
- "@testing-library/react": "^13.4.0",
8
- "@testing-library/user-event": "^13.5.0",
9
- "@types/jest": "^27.5.2",
10
- "@types/node": "^16.18.97",
11
- "@types/react": "^18.3.1",
12
- "@types/react-dom": "^18.3.0",
13
- "bibot": "^1.0.1",
14
- "react": "^18.3.1",
15
- "react-dom": "^18.3.1",
16
- "react-scripts": "5.0.1",
17
- "typescript": "^4.9.5",
18
- "web-vitals": "^2.1.4"
19
- },
20
- "scripts": {
21
- "start": "react-scripts start",
22
- "build": "react-scripts build",
23
- "test": "react-scripts test",
24
- "eject": "react-scripts eject"
25
- },
26
- "eslintConfig": {
27
- "extends": [
28
- "react-app",
29
- "react-app/jest"
30
- ]
31
- },
32
- "browserslist": {
33
- "production": [
34
- ">0.2%",
35
- "not dead",
36
- "not op_mini all"
37
- ],
38
- "development": [
39
- "last 1 chrome version",
40
- "last 1 firefox version",
41
- "last 1 safari version"
42
- ]
43
- },
44
- "devDependencies": {
45
- "@babel/plugin-proposal-private-property-in-object": "^7.21.11"
46
- }
47
- }
Binary file
@@ -1,43 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1" />
7
- <meta name="theme-color" content="#000000" />
8
- <meta
9
- name="description"
10
- content="Web site created using create-react-app"
11
- />
12
- <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13
- <!--
14
- manifest.json provides metadata used when your web app is installed on a
15
- user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16
- -->
17
- <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18
- <!--
19
- Notice the use of %PUBLIC_URL% in the tags above.
20
- It will be replaced with the URL of the `public` folder during the build.
21
- Only files inside the `public` folder can be referenced from the HTML.
22
-
23
- Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24
- work correctly both with client-side routing and a non-root public URL.
25
- Learn how to configure a non-root public URL by running `npm run build`.
26
- -->
27
- <title>React App</title>
28
- </head>
29
- <body>
30
- <noscript>You need to enable JavaScript to run this app.</noscript>
31
- <div id="root"></div>
32
- <!--
33
- This HTML file is a template.
34
- If you open it directly in the browser, you will see an empty page.
35
-
36
- You can add webfonts, meta tags, or analytics to this file.
37
- The build step will place the bundled scripts into the <body> tag.
38
-
39
- To begin the development, run `npm start` or `yarn start`.
40
- To create a production bundle, use `npm run build` or `yarn build`.
41
- -->
42
- </body>
43
- </html>
Binary file
Binary file
@@ -1,25 +0,0 @@
1
- {
2
- "short_name": "React App",
3
- "name": "Create React App Sample",
4
- "icons": [
5
- {
6
- "src": "favicon.ico",
7
- "sizes": "64x64 32x32 24x24 16x16",
8
- "type": "image/x-icon"
9
- },
10
- {
11
- "src": "logo192.png",
12
- "type": "image/png",
13
- "sizes": "192x192"
14
- },
15
- {
16
- "src": "logo512.png",
17
- "type": "image/png",
18
- "sizes": "512x512"
19
- }
20
- ],
21
- "start_url": ".",
22
- "display": "standalone",
23
- "theme_color": "#000000",
24
- "background_color": "#ffffff"
25
- }
@@ -1,3 +0,0 @@
1
- # https://www.robotstxt.org/robotstxt.html
2
- User-agent: *
3
- Disallow:
@@ -1,38 +0,0 @@
1
- .App {
2
- text-align: center;
3
- }
4
-
5
- .App-logo {
6
- height: 40vmin;
7
- pointer-events: none;
8
- }
9
-
10
- @media (prefers-reduced-motion: no-preference) {
11
- .App-logo {
12
- animation: App-logo-spin infinite 20s linear;
13
- }
14
- }
15
-
16
- .App-header {
17
- background-color: #282c34;
18
- min-height: 100vh;
19
- display: flex;
20
- flex-direction: column;
21
- align-items: center;
22
- justify-content: center;
23
- font-size: calc(10px + 2vmin);
24
- color: white;
25
- }
26
-
27
- .App-link {
28
- color: #61dafb;
29
- }
30
-
31
- @keyframes App-logo-spin {
32
- from {
33
- transform: rotate(0deg);
34
- }
35
- to {
36
- transform: rotate(360deg);
37
- }
38
- }
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
- import App from './App';
4
-
5
- test('renders learn react link', () => {
6
- render(<App />);
7
- const linkElement = screen.getByText(/learn react/i);
8
- expect(linkElement).toBeInTheDocument();
9
- });
@@ -1,28 +0,0 @@
1
- import React from 'react';
2
- import logo from './logo.svg';
3
- import './App.css';
4
- import BiBot from 'bibot'
5
-
6
- function App() {
7
- return (
8
- <div className="App">
9
- <header className="App-header">
10
- <img src={logo} className="App-logo" alt="logo" />
11
- <p>
12
- Edit <code>src/App.tsx</code> and save to reload.
13
- </p>
14
- <a
15
- className="App-link"
16
- href="https://reactjs.org"
17
- target="_blank"
18
- rel="noopener noreferrer"
19
- >
20
- Learn React
21
- </a>
22
- </header>
23
- <BiBot clientId='6c74b4bb-0395-4751-a55f-7d065d67c56b' />
24
- </div>
25
- );
26
- }
27
-
28
- export default App;
@@ -1,13 +0,0 @@
1
- body {
2
- margin: 0;
3
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4
- 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5
- sans-serif;
6
- -webkit-font-smoothing: antialiased;
7
- -moz-osx-font-smoothing: grayscale;
8
- }
9
-
10
- code {
11
- font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12
- monospace;
13
- }
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import ReactDOM from 'react-dom/client';
3
- import './index.css';
4
- import App from './App';
5
-
6
- const root = ReactDOM.createRoot(
7
- document.getElementById('root') as HTMLElement
8
- );
9
- root.render(
10
- <React.StrictMode>
11
- <App />
12
- </React.StrictMode>
13
- );
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
@@ -1 +0,0 @@
1
- /// <reference types="react-scripts" />
@@ -1,26 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es5",
4
- "lib": [
5
- "dom",
6
- "dom.iterable",
7
- "esnext"
8
- ],
9
- "allowJs": true,
10
- "skipLibCheck": true,
11
- "esModuleInterop": true,
12
- "allowSyntheticDefaultImports": true,
13
- "strict": true,
14
- "forceConsistentCasingInFileNames": true,
15
- "noFallthroughCasesInSwitch": true,
16
- "module": "esnext",
17
- "moduleResolution": "node",
18
- "resolveJsonModule": true,
19
- "isolatedModules": true,
20
- "noEmit": true,
21
- "jsx": "react-jsx"
22
- },
23
- "include": [
24
- "src"
25
- ]
26
- }
package/src/bibot.tsx DELETED
@@ -1,111 +0,0 @@
1
- import { Avatar, Indicator } from '@mantine/core'
2
- import { useNetwork } from '@mantine/hooks'
3
- import { Close, SendRounded } from '@mui/icons-material'
4
- import ChatIcon from '@mui/icons-material/Chat'
5
- import { Button } from 'antd'
6
- import { useBiBotChatBot } from './hooks'
7
- import { AppProvider } from './context/AppContext'
8
- import React from 'react';
9
- interface bubbleProps {
10
- clientId: string
11
- }
12
-
13
- interface PredefinedQuestionsProps {
14
- onSelect: (question: string) => void
15
- questions: string[]
16
- }
17
-
18
- const PredefinedQuestions = ({ questions, onSelect }: PredefinedQuestionsProps) => {
19
- return (
20
- <div className="predefined-questions">
21
- {questions.map((question, index) => (
22
- <div key={index} className="predefined-question" onClick={() => onSelect(question)}>
23
- {question}
24
- </div>
25
- ))}
26
- </div>
27
- );
28
- };
29
-
30
- const BiBot = ({ clientId }: bubbleProps) => {
31
- const {
32
- chatIsOpen,
33
- messages,
34
- isLoading,
35
- messageEndRef,
36
- userInput,
37
- handleUserInput,
38
- handleKeyPress,
39
- sendInputInquiry,
40
- toggleChat,
41
- chatBubbleConfig,
42
- showPredefinedQuestions,
43
- predefinedQuestions,
44
- handlePredefinedQuestionSelect,
45
- } = useBiBotChatBot({clientId})
46
- const networkStatus = useNetwork()
47
-
48
-
49
-
50
- return (
51
- <AppProvider>
52
- {/* <div>
53
- Hello World
54
- </div> */}
55
- <div className={`chat-bubble ${chatIsOpen ? 'open' : ''}`}>
56
- {chatIsOpen && (
57
- <div className="chat-window" style={{ backgroundColor: chatBubbleConfig?.bgColor }}>
58
- <div className="chat-header" style={{ backgroundColor: chatBubbleConfig?.color ?? '#dedede' }}>
59
- <div style={{ alignItems: 'center', display: 'flex', color: '#fff', fontWeight: 'bold' }}>
60
- <Indicator inline size={12} offset={7} position="bottom-end" color={ networkStatus.online ? 'green' : 'gray'}>
61
- <Avatar color="white" src={chatBubbleConfig?.logo_url} alt="profile" />
62
- </Indicator>
63
- </div>
64
- <div style={{ display: 'flex', flexDirection: 'column', textAlign: 'left', paddingLeft: '10px', justifyContent: 'flex-start', color: '#fff' }}>
65
- <span style={{ fontWeight: 'bold' }}>{chatBubbleConfig?.title}</span>
66
- {}
67
- {isLoading ? <span style={{ fontSize: '12px', lineHeight: '0.5' }}>Typing...</span> : <span style={{ fontSize: '12px', lineHeight: '0.5' }}>{networkStatus.online ? 'Online' : 'Offline'}</span>}
68
- </div>
69
- </div>
70
- <div className="message-list">
71
- {messages.map((message: { sender: 'user' | 'bot', text: string }, index: number) => (
72
- message.sender === 'user'
73
- ? <div key={index} className={`message ${message.sender}`}>
74
- {message.text}
75
- </div>
76
- : <div key={index} style={{ display: 'flex' }}>
77
- <Avatar color="white" src={chatBubbleConfig?.logo_url} size={25} alt="profile" />
78
- <div className={`message ${message.sender}`}>
79
- {message.text}
80
- </div>
81
- </div>
82
- ))}
83
- {showPredefinedQuestions && predefinedQuestions && predefinedQuestions.length > 0 && (
84
- <PredefinedQuestions questions={predefinedQuestions} onSelect={handlePredefinedQuestionSelect} />
85
- )}
86
- {isLoading && <div style={{marginLeft: '20px'}} className='message'> <div className="loader"></div> </div> }
87
- <div ref={messageEndRef} />
88
- </div>
89
- <div className="input-area">
90
- <input
91
- autoFocus={true}
92
- type="text"
93
- value={userInput}
94
- onChange={handleUserInput}
95
- onKeyPress={handleKeyPress}
96
- placeholder="Ask a question"
97
- />
98
- <Button disabled={isLoading ?? true} style={{ backgroundColor: 'transparent', color: isLoading ? '#dedede' : chatBubbleConfig?.color }} size='middle' icon={<SendRounded />} onClick={sendInputInquiry}/>
99
- </div>
100
- </div>
101
- )}
102
- <Button type='link' onClick={toggleChat} className="chat-toggle" style={{ backgroundColor: chatBubbleConfig?.color ?? '#dedede' }}>
103
- {chatIsOpen ? <Close style={{ width: 30, height: 30, color: '#fff' }} /> : <ChatIcon style={{ width: 30, height: 30, color: '#fff' }}/>}
104
- </Button>
105
- </div>
106
- </AppProvider>
107
-
108
- )
109
- }
110
-
111
- export default BiBot
@@ -1,3 +0,0 @@
1
- export enum appStateEnums {
2
- BIBOT = 'BIBOT'
3
- }
@@ -1,28 +0,0 @@
1
-
2
- export const APP_DATA = {
3
- APP_NAME: 'Bibot'
4
- }
5
-
6
- const baseUrls = {
7
- inference: 'https://inference.dev.bibot.thespuka.com/v0',
8
- }
9
-
10
- export const endpoints = {
11
- get inference () {
12
- return baseUrls.inference
13
- },
14
- } as const
15
-
16
- export enum domain {
17
- app = '/app',
18
- bibot = '/bibot',
19
- inference = '/inference',
20
- }
21
-
22
- export enum resources {
23
- chatBubble = '/chat-bubble-config',
24
- predefinedQ = '/predefined-q',
25
- localQ = '/local-q',
26
- timedOutLocalQ = '/t-local-q',
27
- q = '/q'
28
- }
@@ -1,5 +0,0 @@
1
- // created from 'create-ts-index'
2
- export * from './appStateEnums'
3
- export * from './endpointEnums'
4
- export * from './statusCode'
5
-
@@ -1,49 +0,0 @@
1
- export enum statusCode {
2
- ok = 200
3
- , created = 201
4
- , accepted = 202
5
-
6
- // 3xx codes
7
- , unmodified = 304
8
-
9
- // 4xx Client Error
10
- , sucMsg = 'success'
11
- , badReq = 400
12
- , unauthorized = 401
13
- , paymentReq = 402
14
- , forbidden = 403
15
- , notFound = 404
16
- , methodNotAllowed = 405
17
- , notAcceptable = 406
18
- , pxyAuthReq = 407
19
- , reqTimeOut = 408
20
- , conflict = 409
21
- , gone = 410
22
- , lengthReq = 411
23
- , preConFailed = 412
24
- , payloadTooLarge = 413
25
- , urlTooLong = 414
26
- , unsupportedMediaType = 415
27
- , rangeNotSatisfiable = 416
28
- , expectationFailed = 417
29
-
30
- , misdirectedReq = 421
31
- , unprocessableEntity = 422
32
- , locked = 423
33
- , failedDependency = 424
34
- , tooLarge = 425
35
- , upgradeRequired = 426
36
- , preconReq = 428
37
- , tooManyReq = 429
38
- , reqHeaderTooLarge = 431
39
- , unavailableForLegalReasons = 451
40
-
41
- // 5xx Server Error
42
- , internalServerError = 500
43
- , notImplemented = 501
44
- , badGateway = 502
45
- , svcUnavalable = 503
46
- , gtwayTimeout = 504
47
- , httpVNotSupported = 505
48
- , networkAuthReq = 511
49
- }
@@ -1,66 +0,0 @@
1
- import { appStateEnums } from '../config/appStateEnums'
2
- import React, { type ReactNode, createContext, useReducer, useEffect } from 'react'
3
- import { appReducer } from '../reducers/appReducer'
4
- import type { AppContextProps, AppStates } from '../types/coreInterfaces'
5
- import { getSessionId } from '../utils/sessionManager'
6
-
7
- interface AppProps {
8
- children: ReactNode
9
- }
10
-
11
- const dummyDispatch = () => {} // A no-op function.
12
-
13
- const defaultContextValue: AppContextProps = {
14
- state: {
15
- chatIsOpen: false,
16
- sessionId: getSessionId()
17
- },
18
- dispatch: dummyDispatch
19
- }
20
-
21
- const AppContext = createContext<AppContextProps>(defaultContextValue)
22
-
23
- const AppProvider: React.FC<AppProps> = ({ children }) => {
24
- const APP_STATE_KEY = 'app_states'
25
- const initialState: AppStates = {
26
- chatIsOpen: false,
27
- sessionId: getSessionId()
28
- }
29
-
30
- const [state, dispatch] = useReducer(appReducer, initialState)
31
-
32
- useEffect(() => {
33
- // Pool the initial states from local storage
34
- const storedStates = localStorage.getItem(APP_STATE_KEY)
35
-
36
- if (storedStates) {
37
- try {
38
- const parsedStates = JSON.parse(storedStates)
39
-
40
- // Merge stored states with initial states
41
- const updatedStates = {
42
- ...initialState,
43
- ...parsedStates
44
- }
45
- console.log(initialState, parsedStates, updatedStates)
46
- // Dispatch action to update the states
47
- dispatch({ type: appStateEnums.BIBOT, ...updatedStates })
48
- } catch (error) {
49
- console.error('Failed to parse app states from local storage:', error)
50
- }
51
- }
52
- }, [])
53
-
54
- useEffect(() => {
55
- console.log('Changes in state: ', state)
56
- localStorage.setItem(APP_STATE_KEY, JSON.stringify(state))
57
- }, [state])
58
-
59
- return (
60
- <AppContext.Provider value={{ state, dispatch }}>
61
- {children}
62
- </AppContext.Provider>
63
- )
64
- }
65
-
66
- export { AppContext, AppProvider }
@@ -1,3 +0,0 @@
1
- // created from 'create-ts-index'
2
-
3
- export * from './AppContext'
@@ -1,5 +0,0 @@
1
- // created from 'create-ts-index'
2
-
3
- export * from './usePluginFactory'
4
- export * from './useBiBotChatBot'
5
- export * from './mobileView'
@@ -1,17 +0,0 @@
1
- import React, { useState, useEffect } from 'react'
2
- export default function MobileView () {
3
- const [isMobile, setIsMobile] = useState<boolean>(false)
4
- useEffect(() => {
5
- const isMobileDevice = () => {
6
- const screenWidth = window.innerWidth
7
- const mobileThreshold = 768
8
- setIsMobile(screenWidth < mobileThreshold)
9
- }
10
- isMobileDevice()
11
- window.addEventListener('resize', isMobileDevice)
12
- return () => { // clean up event listner on when component unmount
13
- window.removeEventListener('resize', isMobileDevice)
14
- }
15
- }, [])
16
- return isMobile
17
- }