test-chat-sdk 0.0.0

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 (208) hide show
  1. package/.prettierrc.js +24 -0
  2. package/README.md +46 -0
  3. package/config/env.js +104 -0
  4. package/config/getHttpsConfig.js +66 -0
  5. package/config/jest/babelTransform.js +29 -0
  6. package/config/jest/cssTransform.js +14 -0
  7. package/config/jest/fileTransform.js +40 -0
  8. package/config/modules.js +134 -0
  9. package/config/paths.js +77 -0
  10. package/config/webpack/persistentCache/createEnvironmentHash.js +9 -0
  11. package/config/webpack.config.js +785 -0
  12. package/config/webpackDevServer.config.js +127 -0
  13. package/dist/Chat/AgentList/index.d.ts +9 -0
  14. package/dist/Chat/ChatFooter/index.d.ts +17 -0
  15. package/dist/Chat/Conversation/index.d.ts +11 -0
  16. package/dist/Chat/MessageContainer/index.d.ts +19 -0
  17. package/dist/Chat/MobileAgents/index.d.ts +11 -0
  18. package/dist/Chat/components/AgentTip/index.d.ts +8 -0
  19. package/dist/Chat/components/ConversationModal/index.d.ts +10 -0
  20. package/dist/Chat/components/CopilotAvatar/index.d.ts +2 -0
  21. package/dist/Chat/components/Message.d.ts +10 -0
  22. package/dist/Chat/components/RecommendQuestions/index.d.ts +6 -0
  23. package/dist/Chat/components/Text.d.ts +9 -0
  24. package/dist/Chat/constants.d.ts +19 -0
  25. package/dist/Chat/index.d.ts +17 -0
  26. package/dist/Chat/service.d.ts +11 -0
  27. package/dist/Chat/type.d.ts +97 -0
  28. package/dist/Copilot/constants.d.ts +11 -0
  29. package/dist/Copilot/index.d.ts +13 -0
  30. package/dist/ShowCase/index.d.ts +8 -0
  31. package/dist/ShowCase/service.d.ts +2 -0
  32. package/dist/ShowCase/type.d.ts +11 -0
  33. package/dist/common/constants.d.ts +58 -0
  34. package/dist/common/env.d.ts +3 -0
  35. package/dist/common/type.d.ts +247 -0
  36. package/dist/components/ChatItem/ExecuteItem.d.ts +25 -0
  37. package/dist/components/ChatItem/ExpandParseTip.d.ts +20 -0
  38. package/dist/components/ChatItem/FilterItem.d.ts +17 -0
  39. package/dist/components/ChatItem/Loading.d.ts +2 -0
  40. package/dist/components/ChatItem/ParseTip.d.ts +26 -0
  41. package/dist/components/ChatItem/ParseTipUtils.d.ts +10 -0
  42. package/dist/components/ChatItem/SimilarQuestionItem.d.ts +10 -0
  43. package/dist/components/ChatItem/SqlItem.d.ts +17 -0
  44. package/dist/components/ChatItem/SwitchEntity.d.ts +9 -0
  45. package/dist/components/ChatItem/Text.d.ts +6 -0
  46. package/dist/components/ChatItem/Typing.d.ts +2 -0
  47. package/dist/components/ChatItem/index.d.ts +33 -0
  48. package/dist/components/ChatMsg/ApplyAuth/index.d.ts +7 -0
  49. package/dist/components/ChatMsg/Bar/index.d.ts +13 -0
  50. package/dist/components/ChatMsg/DateOptions/index.d.ts +9 -0
  51. package/dist/components/ChatMsg/FilterSection/index.d.ts +8 -0
  52. package/dist/components/ChatMsg/MarkDown/index.d.ts +10 -0
  53. package/dist/components/ChatMsg/Message/index.d.ts +18 -0
  54. package/dist/components/ChatMsg/MetricCard/PeriodCompareItem.d.ts +7 -0
  55. package/dist/components/ChatMsg/MetricCard/index.d.ts +10 -0
  56. package/dist/components/ChatMsg/MetricTrend/MetricInfo.d.ts +8 -0
  57. package/dist/components/ChatMsg/MetricTrend/MetricTrendChart.d.ts +14 -0
  58. package/dist/components/ChatMsg/MetricTrend/MultiMetricsTrendChart.d.ts +12 -0
  59. package/dist/components/ChatMsg/MetricTrend/index.d.ts +16 -0
  60. package/dist/components/ChatMsg/NoPermissionChart/index.d.ts +8 -0
  61. package/dist/components/ChatMsg/Pie/PieChart.d.ts +11 -0
  62. package/dist/components/ChatMsg/Pie/index.d.ts +14 -0
  63. package/dist/components/ChatMsg/Table/index.d.ts +12 -0
  64. package/dist/components/ChatMsg/Text/index.d.ts +9 -0
  65. package/dist/components/ChatMsg/WebPage/index.d.ts +8 -0
  66. package/dist/components/ChatMsg/index.d.ts +15 -0
  67. package/dist/components/DrillDownDimensions/DimensionSection.d.ts +11 -0
  68. package/dist/components/DrillDownDimensions/index.d.ts +13 -0
  69. package/dist/components/IconFont/index.d.ts +3 -0
  70. package/dist/components/MetricOptions/index.d.ts +11 -0
  71. package/dist/components/RecommendOptions/index.d.ts +9 -0
  72. package/dist/components/Tools/FeedbackModal.d.ts +9 -0
  73. package/dist/components/Tools/index.d.ts +12 -0
  74. package/dist/demo/Chat.d.ts +2 -0
  75. package/dist/demo/ChatDemo.d.ts +4 -0
  76. package/dist/demo/CopilotDemo.d.ts +2 -0
  77. package/dist/hooks/index.d.ts +3 -0
  78. package/dist/hooks/useComposing.d.ts +5 -0
  79. package/dist/hooks/useExportByEcharts.d.ts +10 -0
  80. package/dist/hooks/useMethodRegister.d.ts +4 -0
  81. package/dist/index.d.ts +10 -0
  82. package/dist/index.es.js +1 -0
  83. package/dist/service/axiosInstance.d.ts +3 -0
  84. package/dist/service/index.d.ts +25 -0
  85. package/dist/utils/utils.d.ts +45 -0
  86. package/package.json +214 -0
  87. package/public/favicon.ico +0 -0
  88. package/public/index.html +43 -0
  89. package/public/manifest.json +15 -0
  90. package/public/robots.txt +3 -0
  91. package/rollup/rollup.config.mjs +37 -0
  92. package/rollup/rollup.esm.config.mjs +21 -0
  93. package/rollup/rollup.umd.config.mjs +30 -0
  94. package/scripts/build.js +217 -0
  95. package/scripts/start.js +154 -0
  96. package/scripts/test.js +52 -0
  97. package/src/Chat/AgentList/index.tsx +52 -0
  98. package/src/Chat/AgentList/style.module.less +83 -0
  99. package/src/Chat/ChatFooter/index.tsx +423 -0
  100. package/src/Chat/ChatFooter/style.module.less +225 -0
  101. package/src/Chat/Conversation/index.tsx +236 -0
  102. package/src/Chat/Conversation/style.module.less +171 -0
  103. package/src/Chat/MessageContainer/index.tsx +145 -0
  104. package/src/Chat/MessageContainer/style.module.less +53 -0
  105. package/src/Chat/MobileAgents/index.tsx +62 -0
  106. package/src/Chat/MobileAgents/style.module.less +55 -0
  107. package/src/Chat/components/AgentTip/index.tsx +48 -0
  108. package/src/Chat/components/AgentTip/style.module.less +44 -0
  109. package/src/Chat/components/ConversationModal/index.tsx +65 -0
  110. package/src/Chat/components/CopilotAvatar/index.tsx +8 -0
  111. package/src/Chat/components/CopilotAvatar/style.module.less +13 -0
  112. package/src/Chat/components/Message.tsx +38 -0
  113. package/src/Chat/components/RecommendQuestions/index.tsx +64 -0
  114. package/src/Chat/components/RecommendQuestions/style.module.less +36 -0
  115. package/src/Chat/components/Text.tsx +42 -0
  116. package/src/Chat/components/style.module.less +311 -0
  117. package/src/Chat/constants.ts +37 -0
  118. package/src/Chat/index.tsx +526 -0
  119. package/src/Chat/service.ts +49 -0
  120. package/src/Chat/style.module.less +119 -0
  121. package/src/Chat/type.ts +107 -0
  122. package/src/Copilot/constants.ts +11 -0
  123. package/src/Copilot/index.tsx +149 -0
  124. package/src/Copilot/style.module.less +151 -0
  125. package/src/ShowCase/index.tsx +120 -0
  126. package/src/ShowCase/service.ts +12 -0
  127. package/src/ShowCase/style.module.less +46 -0
  128. package/src/ShowCase/type.ts +14 -0
  129. package/src/common/constants.ts +93 -0
  130. package/src/common/env.ts +5 -0
  131. package/src/common/type.ts +270 -0
  132. package/src/components/ChatItem/ExecuteItem.tsx +210 -0
  133. package/src/components/ChatItem/ExpandParseTip.tsx +333 -0
  134. package/src/components/ChatItem/FilterItem.tsx +209 -0
  135. package/src/components/ChatItem/Loading.tsx +14 -0
  136. package/src/components/ChatItem/ParseTip.tsx +322 -0
  137. package/src/components/ChatItem/ParseTipUtils.tsx +205 -0
  138. package/src/components/ChatItem/SimilarQuestionItem.tsx +84 -0
  139. package/src/components/ChatItem/SqlItem.tsx +410 -0
  140. package/src/components/ChatItem/SwitchEntity.tsx +52 -0
  141. package/src/components/ChatItem/Text.tsx +17 -0
  142. package/src/components/ChatItem/Typing.tsx +19 -0
  143. package/src/components/ChatItem/index.tsx +843 -0
  144. package/src/components/ChatItem/style.less +670 -0
  145. package/src/components/ChatMsg/ApplyAuth/index.tsx +30 -0
  146. package/src/components/ChatMsg/ApplyAuth/style.less +13 -0
  147. package/src/components/ChatMsg/Bar/index.tsx +208 -0
  148. package/src/components/ChatMsg/Bar/style.less +60 -0
  149. package/src/components/ChatMsg/DateOptions/index.tsx +46 -0
  150. package/src/components/ChatMsg/DateOptions/style.less +43 -0
  151. package/src/components/ChatMsg/FilterSection/index.tsx +42 -0
  152. package/src/components/ChatMsg/FilterSection/style.less +37 -0
  153. package/src/components/ChatMsg/MarkDown/index.tsx +26 -0
  154. package/src/components/ChatMsg/MarkDown/style.less +9 -0
  155. package/src/components/ChatMsg/Message/index.tsx +105 -0
  156. package/src/components/ChatMsg/Message/style.less +119 -0
  157. package/src/components/ChatMsg/MetricCard/PeriodCompareItem.tsx +29 -0
  158. package/src/components/ChatMsg/MetricCard/index.tsx +80 -0
  159. package/src/components/ChatMsg/MetricCard/style.less +126 -0
  160. package/src/components/ChatMsg/MetricTrend/MetricInfo.tsx +60 -0
  161. package/src/components/ChatMsg/MetricTrend/MetricTrendChart.tsx +235 -0
  162. package/src/components/ChatMsg/MetricTrend/MultiMetricsTrendChart.tsx +162 -0
  163. package/src/components/ChatMsg/MetricTrend/index.tsx +127 -0
  164. package/src/components/ChatMsg/MetricTrend/style.less +195 -0
  165. package/src/components/ChatMsg/NoPermissionChart/index.tsx +28 -0
  166. package/src/components/ChatMsg/NoPermissionChart/style.less +26 -0
  167. package/src/components/ChatMsg/Pie/PieChart.tsx +120 -0
  168. package/src/components/ChatMsg/Pie/index.tsx +88 -0
  169. package/src/components/ChatMsg/Pie/style.less +43 -0
  170. package/src/components/ChatMsg/Table/index.tsx +103 -0
  171. package/src/components/ChatMsg/Table/style.less +131 -0
  172. package/src/components/ChatMsg/Text/index.tsx +70 -0
  173. package/src/components/ChatMsg/Text/style.less +38 -0
  174. package/src/components/ChatMsg/WebPage/index.tsx +125 -0
  175. package/src/components/ChatMsg/index.tsx +428 -0
  176. package/src/components/ChatMsg/style.less +28 -0
  177. package/src/components/DrillDownDimensions/DimensionSection.tsx +99 -0
  178. package/src/components/DrillDownDimensions/index.tsx +76 -0
  179. package/src/components/DrillDownDimensions/style.less +64 -0
  180. package/src/components/IconFont/index.tsx +7 -0
  181. package/src/components/MetricOptions/index.tsx +75 -0
  182. package/src/components/MetricOptions/style.less +69 -0
  183. package/src/components/RecommendOptions/index.tsx +126 -0
  184. package/src/components/RecommendOptions/style.less +24 -0
  185. package/src/components/Tools/FeedbackModal.tsx +55 -0
  186. package/src/components/Tools/index.tsx +126 -0
  187. package/src/components/Tools/style.less +67 -0
  188. package/src/demo/Chat.tsx +73 -0
  189. package/src/demo/ChatDemo.tsx +14 -0
  190. package/src/demo/CopilotDemo.tsx +43 -0
  191. package/src/demo/style.module.less +19 -0
  192. package/src/hooks/index.ts +3 -0
  193. package/src/hooks/useComposing.ts +31 -0
  194. package/src/hooks/useExportByEcharts.ts +41 -0
  195. package/src/hooks/useMethodRegister.ts +25 -0
  196. package/src/index.tsx +44 -0
  197. package/src/service/axiosInstance.ts +58 -0
  198. package/src/service/index.ts +174 -0
  199. package/src/setupProxy.js +18 -0
  200. package/src/setupTests.ts +5 -0
  201. package/src/styles/global.less +52 -0
  202. package/src/styles/index.less +39 -0
  203. package/src/styles/reboot.less +14 -0
  204. package/src/styles/variables.less +80 -0
  205. package/src/typings.d.ts +179 -0
  206. package/src/utils/utils.ts +346 -0
  207. package/tsconfig.build.json +20 -0
  208. package/tsconfig.json +27 -0
package/package.json ADDED
@@ -0,0 +1,214 @@
1
+ {
2
+ "name": "test-chat-sdk",
3
+ "version": "0.0.0",
4
+ "main": "dist/index.es.js",
5
+ "module": "dist/index.es.js",
6
+ "unpkg": "dist/index.umd.js",
7
+ "types": "dist/index.d.ts",
8
+ "dependencies": {
9
+ "@ant-design/icons": "^4.7.0",
10
+ "@uiw/react-watermark": "^0.0.5",
11
+ "ahooks": "^3.7.8",
12
+ "antd": "^5.17.4",
13
+ "axios": "^1.10.0",
14
+ "classnames": "^2.3.2",
15
+ "dayjs": "^1.11.10",
16
+ "echarts": "^5.4.2",
17
+ "github-markdown-css": "^5.5.1",
18
+ "highlight.js": "^11.9.0",
19
+ "lodash": "^4.17.11",
20
+ "moment": "^2.29.4",
21
+ "react-copy-to-clipboard": "^5.1.0",
22
+ "react-grid-layout": "^1.4.4",
23
+ "react-markdown": "^9.0.1",
24
+ "react-spinners": "^0.13.8",
25
+ "react-syntax-highlighter": "^15.5.0",
26
+ "rehype-highlight": "^7.0.0",
27
+ "remark-gfm": "^4.0.0",
28
+ "sql-formatter": "^15.3.2",
29
+ "tslib": "^2.5.2"
30
+ },
31
+ "peerDependencies": {
32
+ "react": "^18.3.1",
33
+ "react-dom": "^18.3.1"
34
+ },
35
+ "scripts": {
36
+ "start": "npm run start:dev",
37
+ "start:dev": "node scripts/start.js",
38
+ "watch": "rollup -c rollup/rollup.esm.config.mjs --watch",
39
+ "watch:bg": "rollup -c rollup/rollup.esm.config.mjs --watch &",
40
+ "clean": "rimraf ./dist",
41
+ "build": "npm run clean && npm run build-es",
42
+ "test": "node scripts/test.js",
43
+ "build-ts": "tsc -p tsconfig.build.json",
44
+ "build-css": "lessc ./src/styles/index.less ./dist/index.css",
45
+ "build-es": "rollup --config rollup/rollup.esm.config.mjs",
46
+ "build-umd": "rollup --config rollup/rollup.umd.config.mjs"
47
+ },
48
+ "eslintConfig": {
49
+ "extends": [
50
+ "react-app",
51
+ "react-app/jest"
52
+ ],
53
+ "rules": {
54
+ "react-hooks/exhaustive-deps": 0
55
+ }
56
+ },
57
+ "browserslist": {
58
+ "production": [
59
+ ">0.2%",
60
+ "not dead",
61
+ "not op_mini all",
62
+ "defaults",
63
+ "not ie < 8",
64
+ "last 2 versions",
65
+ "> 1%",
66
+ "iOS 7",
67
+ "last 3 iOS versions"
68
+ ],
69
+ "development": [
70
+ "last 1 chrome version",
71
+ "last 1 firefox version",
72
+ "last 1 safari version"
73
+ ]
74
+ },
75
+ "devDependencies": {
76
+ "@babel/core": "^7.16.0",
77
+ "@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
78
+ "@rollup/plugin-commonjs": "^25.0.0",
79
+ "@rollup/plugin-json": "^6.0.0",
80
+ "@rollup/plugin-node-resolve": "^15.0.2",
81
+ "@rollup/plugin-replace": "^5.0.2",
82
+ "@rollup/plugin-terser": "^0.4.3",
83
+ "@svgr/webpack": "^5.5.0",
84
+ "@testing-library/jest-dom": "^5.16.5",
85
+ "@testing-library/react": "^13.4.0",
86
+ "@testing-library/user-event": "^13.5.0",
87
+ "@types/jest": "^27.5.2",
88
+ "@types/lodash": "^4.14.198",
89
+ "@types/node": "^16.18.31",
90
+ "@types/react": "^18.3.0",
91
+ "@types/react-dom": "^18.3.0",
92
+ "autoprefixer": "^10.4.14",
93
+ "babel-jest": "^27.4.2",
94
+ "babel-loader": "^8.2.3",
95
+ "babel-plugin-named-asset-import": "^0.3.8",
96
+ "babel-preset-react-app": "^10.0.1",
97
+ "bfj": "^7.0.2",
98
+ "browserslist": "^4.18.1",
99
+ "camelcase": "^6.2.1",
100
+ "case-sensitive-paths-webpack-plugin": "^2.4.0",
101
+ "css-loader": "^6.5.1",
102
+ "css-minimizer-webpack-plugin": "^3.2.0",
103
+ "cssnano": "^6.0.1",
104
+ "dotenv": "^10.0.0",
105
+ "dotenv-expand": "^5.1.0",
106
+ "eslint": "^8.3.0",
107
+ "eslint-config-react-app": "^7.0.1",
108
+ "eslint-webpack-plugin": "^3.1.1",
109
+ "file-loader": "^6.2.0",
110
+ "fs-extra": "^10.0.0",
111
+ "html-webpack-plugin": "^5.5.0",
112
+ "http-proxy-middleware": "^2.0.6",
113
+ "identity-obj-proxy": "^3.0.0",
114
+ "jest": "^27.4.3",
115
+ "jest-resolve": "^27.4.2",
116
+ "jest-watch-typeahead": "^1.0.0",
117
+ "less": "^4.1.3",
118
+ "less-loader": "^11.1.0",
119
+ "mini-css-extract-plugin": "^2.4.5",
120
+ "postcss": "^8.4.4",
121
+ "postcss-flexbugs-fixes": "^5.0.2",
122
+ "postcss-loader": "^6.2.1",
123
+ "postcss-modules": "^6.0.0",
124
+ "postcss-normalize": "^10.0.1",
125
+ "postcss-preset-env": "^7.0.1",
126
+ "prompts": "^2.4.2",
127
+ "react": "^18.3.1",
128
+ "react-app-polyfill": "^3.0.0",
129
+ "react-dev-utils": "^12.0.1",
130
+ "react-dom": "^18.3.1",
131
+ "react-refresh": "^0.11.0",
132
+ "resolve": "^1.20.0",
133
+ "resolve-url-loader": "^4.0.0",
134
+ "rimraf": "^5.0.1",
135
+ "rollup": "^3.22.1",
136
+ "rollup-plugin-exclude-dependencies-from-bundle": "^1.1.23",
137
+ "rollup-plugin-less": "^1.1.3",
138
+ "rollup-plugin-postcss": "^4.0.2",
139
+ "rollup-plugin-styles": "^4.0.0",
140
+ "rollup-plugin-typescript2": "^0.36.0",
141
+ "sass-loader": "^12.3.0",
142
+ "semver": "^7.3.5",
143
+ "source-map-loader": "^3.0.0",
144
+ "style-loader": "^3.3.1",
145
+ "tailwindcss": "^3.0.2",
146
+ "terser-webpack-plugin": "^5.2.5",
147
+ "typescript": "^4.9.5",
148
+ "web-vitals": "^2.1.4",
149
+ "webpack": "^5.64.4",
150
+ "webpack-dev-server": "^4.6.0",
151
+ "webpack-manifest-plugin": "^4.0.2",
152
+ "workbox-webpack-plugin": "^6.4.1"
153
+ },
154
+ "jest": {
155
+ "roots": [
156
+ "<rootDir>/src"
157
+ ],
158
+ "collectCoverageFrom": [
159
+ "src/**/*.{js,jsx,ts,tsx}",
160
+ "!src/**/*.d.ts"
161
+ ],
162
+ "setupFiles": [
163
+ "react-app-polyfill/jsdom"
164
+ ],
165
+ "setupFilesAfterEnv": [
166
+ "<rootDir>/src/setupTests.ts"
167
+ ],
168
+ "testMatch": [
169
+ "<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
170
+ "<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
171
+ ],
172
+ "testEnvironment": "jsdom",
173
+ "transform": {
174
+ "^.+\\.(js|jsx|mjs|cjs|ts|tsx)$": "<rootDir>/config/jest/babelTransform.js",
175
+ "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
176
+ "^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
177
+ },
178
+ "transformIgnorePatterns": [
179
+ "[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$",
180
+ "^.+\\.module\\.(css|sass|scss)$"
181
+ ],
182
+ "modulePaths": [],
183
+ "moduleNameMapper": {
184
+ "^react-native$": "react-native-web",
185
+ "^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
186
+ },
187
+ "moduleFileExtensions": [
188
+ "web.js",
189
+ "js",
190
+ "web.ts",
191
+ "ts",
192
+ "web.tsx",
193
+ "tsx",
194
+ "json",
195
+ "web.jsx",
196
+ "jsx",
197
+ "node"
198
+ ],
199
+ "watchPlugins": [
200
+ "jest-watch-typeahead/filename",
201
+ "jest-watch-typeahead/testname"
202
+ ],
203
+ "resetMocks": true
204
+ },
205
+ "babel": {
206
+ "presets": [
207
+ "react-app"
208
+ ]
209
+ },
210
+ "engines": {
211
+ "node": ">=16"
212
+ },
213
+ "packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee"
214
+ }
Binary file
@@ -0,0 +1,43 @@
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>Supersonic chat</title>
28
+ </head>
29
+ <body>
30
+ <noscript>You need to enable JavaScript to run this app.</noscript>
31
+ <div id="root" style="height: 100vh;"></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>
@@ -0,0 +1,15 @@
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
+ "start_url": ".",
12
+ "display": "standalone",
13
+ "theme_color": "#000000",
14
+ "background_color": "#ffffff"
15
+ }
@@ -0,0 +1,3 @@
1
+ # https://www.robotstxt.org/robotstxt.html
2
+ User-agent: *
3
+ Disallow:
@@ -0,0 +1,37 @@
1
+ import typescript from 'rollup-plugin-typescript2'
2
+ import { nodeResolve } from '@rollup/plugin-node-resolve'
3
+ import commonjs from '@rollup/plugin-commonjs'
4
+ import json from '@rollup/plugin-json'
5
+ import less from 'rollup-plugin-less'
6
+ import styles from "rollup-plugin-styles";
7
+ import postcss from 'rollup-plugin-postcss'
8
+ import cssnano from 'cssnano'
9
+
10
+ const overrides = {
11
+ compilerOptions: { declaration: true },
12
+ exclude: ["src/**/*.test.tsx", "src/**/*.stories.tsx", "src/**/*.stories.mdx", "src/setupTests.ts"]
13
+ }
14
+
15
+ const config = {
16
+ input: 'src/index.tsx',
17
+ plugins: [
18
+ nodeResolve(),
19
+ commonjs(),
20
+ json(),
21
+ typescript({ tsconfigOverride: overrides }),
22
+ styles({
23
+ // mode: ["extract"],
24
+ // modules: true,
25
+ autoModules: id => id.includes(".module."),
26
+ }),
27
+ // less({ output: 'dist/index.css' }),
28
+ // postcss({
29
+ // plugins: [
30
+ // cssnano()
31
+ // ]
32
+ // })
33
+ ],
34
+ }
35
+
36
+ export default config
37
+
@@ -0,0 +1,21 @@
1
+ import basicConfig from './rollup.config.mjs'
2
+ import excludeDependenciesFromBundle from "rollup-plugin-exclude-dependencies-from-bundle"
3
+ import terser from '@rollup/plugin-terser'
4
+
5
+ const config = {
6
+ ...basicConfig,
7
+ output: [
8
+ {
9
+ file: 'dist/index.es.js',
10
+ format: 'es',
11
+ },
12
+ ],
13
+ plugins: [
14
+ ...basicConfig.plugins,
15
+ excludeDependenciesFromBundle(),
16
+ terser()
17
+ ]
18
+ }
19
+
20
+ export default config
21
+
@@ -0,0 +1,30 @@
1
+ import basicConfig from './rollup.config.mjs';
2
+ import terser from '@rollup/plugin-terser';
3
+ import replace from '@rollup/plugin-replace';
4
+
5
+ const config = {
6
+ ...basicConfig,
7
+ output: [
8
+ {
9
+ name: 'chat-sdk',
10
+ file: 'dist/index.umd.js',
11
+ format: 'umd',
12
+ exports: 'named',
13
+ globals: {
14
+ react: 'React',
15
+ 'react-dom': 'ReactDOM',
16
+ axios: 'Axios',
17
+ },
18
+ plugins: [terser()],
19
+ },
20
+ ],
21
+ plugins: [
22
+ replace({
23
+ 'process.env.NODE_ENV': JSON.stringify('production'),
24
+ }),
25
+ ...basicConfig.plugins,
26
+ ],
27
+ external: ['react', 'react-dom', 'axios'],
28
+ };
29
+
30
+ export default config;
@@ -0,0 +1,217 @@
1
+ 'use strict';
2
+
3
+ // Do this as the first thing so that any code reading it knows the right env.
4
+ process.env.BABEL_ENV = 'production';
5
+ process.env.NODE_ENV = 'production';
6
+
7
+ // Makes the script crash on unhandled rejections instead of silently
8
+ // ignoring them. In the future, promise rejections that are not handled will
9
+ // terminate the Node.js process with a non-zero exit code.
10
+ process.on('unhandledRejection', err => {
11
+ throw err;
12
+ });
13
+
14
+ // Ensure environment variables are read.
15
+ require('../config/env');
16
+
17
+ const path = require('path');
18
+ const chalk = require('react-dev-utils/chalk');
19
+ const fs = require('fs-extra');
20
+ const bfj = require('bfj');
21
+ const webpack = require('webpack');
22
+ const configFactory = require('../config/webpack.config');
23
+ const paths = require('../config/paths');
24
+ const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
25
+ const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
26
+ const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
27
+ const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
28
+ const printBuildError = require('react-dev-utils/printBuildError');
29
+
30
+ const measureFileSizesBeforeBuild =
31
+ FileSizeReporter.measureFileSizesBeforeBuild;
32
+ const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
33
+ const useYarn = fs.existsSync(paths.yarnLockFile);
34
+
35
+ // These sizes are pretty large. We'll warn for bundles exceeding them.
36
+ const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
37
+ const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
38
+
39
+ const isInteractive = process.stdout.isTTY;
40
+
41
+ // Warn and crash if required files are missing
42
+ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
43
+ process.exit(1);
44
+ }
45
+
46
+ const argv = process.argv.slice(2);
47
+ const writeStatsJson = argv.indexOf('--stats') !== -1;
48
+
49
+ // Generate configuration
50
+ const config = configFactory('production');
51
+
52
+ // We require that you explicitly set browsers and do not fall back to
53
+ // browserslist defaults.
54
+ const { checkBrowsers } = require('react-dev-utils/browsersHelper');
55
+ checkBrowsers(paths.appPath, isInteractive)
56
+ .then(() => {
57
+ // First, read the current file sizes in build directory.
58
+ // This lets us display how much they changed later.
59
+ return measureFileSizesBeforeBuild(paths.appBuild);
60
+ })
61
+ .then(previousFileSizes => {
62
+ // Remove all content but keep the directory so that
63
+ // if you're in it, you don't end up in Trash
64
+ fs.emptyDirSync(paths.appBuild);
65
+ // Merge with the public folder
66
+ copyPublicFolder();
67
+ // Start the webpack build
68
+ return build(previousFileSizes);
69
+ })
70
+ .then(
71
+ ({ stats, previousFileSizes, warnings }) => {
72
+ if (warnings.length) {
73
+ console.log(chalk.yellow('Compiled with warnings.\n'));
74
+ console.log(warnings.join('\n\n'));
75
+ console.log(
76
+ '\nSearch for the ' +
77
+ chalk.underline(chalk.yellow('keywords')) +
78
+ ' to learn more about each warning.'
79
+ );
80
+ console.log(
81
+ 'To ignore, add ' +
82
+ chalk.cyan('// eslint-disable-next-line') +
83
+ ' to the line before.\n'
84
+ );
85
+ } else {
86
+ console.log(chalk.green('Compiled successfully.\n'));
87
+ }
88
+
89
+ console.log('File sizes after gzip:\n');
90
+ printFileSizesAfterBuild(
91
+ stats,
92
+ previousFileSizes,
93
+ paths.appBuild,
94
+ WARN_AFTER_BUNDLE_GZIP_SIZE,
95
+ WARN_AFTER_CHUNK_GZIP_SIZE
96
+ );
97
+ console.log();
98
+
99
+ const appPackage = require(paths.appPackageJson);
100
+ const publicUrl = paths.publicUrlOrPath;
101
+ const publicPath = config.output.publicPath;
102
+ const buildFolder = path.relative(process.cwd(), paths.appBuild);
103
+ printHostingInstructions(
104
+ appPackage,
105
+ publicUrl,
106
+ publicPath,
107
+ buildFolder,
108
+ useYarn
109
+ );
110
+ },
111
+ err => {
112
+ const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true';
113
+ if (tscCompileOnError) {
114
+ console.log(
115
+ chalk.yellow(
116
+ 'Compiled with the following type errors (you may want to check these before deploying your app):\n'
117
+ )
118
+ );
119
+ printBuildError(err);
120
+ } else {
121
+ console.log(chalk.red('Failed to compile.\n'));
122
+ printBuildError(err);
123
+ process.exit(1);
124
+ }
125
+ }
126
+ )
127
+ .catch(err => {
128
+ if (err && err.message) {
129
+ console.log(err.message);
130
+ }
131
+ process.exit(1);
132
+ });
133
+
134
+ // Create the production build and print the deployment instructions.
135
+ function build(previousFileSizes) {
136
+ console.log('Creating an optimized production build...');
137
+
138
+ const compiler = webpack(config);
139
+ return new Promise((resolve, reject) => {
140
+ compiler.run((err, stats) => {
141
+ let messages;
142
+ if (err) {
143
+ if (!err.message) {
144
+ return reject(err);
145
+ }
146
+
147
+ let errMessage = err.message;
148
+
149
+ // Add additional information for postcss errors
150
+ if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
151
+ errMessage +=
152
+ '\nCompileError: Begins at CSS selector ' +
153
+ err['postcssNode'].selector;
154
+ }
155
+
156
+ messages = formatWebpackMessages({
157
+ errors: [errMessage],
158
+ warnings: [],
159
+ });
160
+ } else {
161
+ messages = formatWebpackMessages(
162
+ stats.toJson({ all: false, warnings: true, errors: true })
163
+ );
164
+ }
165
+ if (messages.errors.length) {
166
+ // Only keep the first error. Others are often indicative
167
+ // of the same problem, but confuse the reader with noise.
168
+ if (messages.errors.length > 1) {
169
+ messages.errors.length = 1;
170
+ }
171
+ return reject(new Error(messages.errors.join('\n\n')));
172
+ }
173
+ if (
174
+ process.env.CI &&
175
+ (typeof process.env.CI !== 'string' ||
176
+ process.env.CI.toLowerCase() !== 'false') &&
177
+ messages.warnings.length
178
+ ) {
179
+ // Ignore sourcemap warnings in CI builds. See #8227 for more info.
180
+ const filteredWarnings = messages.warnings.filter(
181
+ w => !/Failed to parse source map/.test(w)
182
+ );
183
+ if (filteredWarnings.length) {
184
+ console.log(
185
+ chalk.yellow(
186
+ '\nTreating warnings as errors because process.env.CI = true.\n' +
187
+ 'Most CI servers set it automatically.\n'
188
+ )
189
+ );
190
+ return reject(new Error(filteredWarnings.join('\n\n')));
191
+ }
192
+ }
193
+
194
+ const resolveArgs = {
195
+ stats,
196
+ previousFileSizes,
197
+ warnings: messages.warnings,
198
+ };
199
+
200
+ if (writeStatsJson) {
201
+ return bfj
202
+ .write(paths.appBuild + '/bundle-stats.json', stats.toJson())
203
+ .then(() => resolve(resolveArgs))
204
+ .catch(error => reject(new Error(error)));
205
+ }
206
+
207
+ return resolve(resolveArgs);
208
+ });
209
+ });
210
+ }
211
+
212
+ function copyPublicFolder() {
213
+ fs.copySync(paths.appPublic, paths.appBuild, {
214
+ dereference: true,
215
+ filter: file => file !== paths.appHtml,
216
+ });
217
+ }