@4399ywkf/cli 0.0.22 → 1.0.2

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 (803) hide show
  1. package/dist/cli.js +19 -638
  2. package/dist/templates/404/index.tsx +5 -0
  3. package/dist/templates/404/page.tsx +27 -0
  4. package/dist/templates/404.png +0 -0
  5. package/dist/templates/404.tsx +5 -0
  6. package/dist/templates/BaseLayout.tsx +15 -0
  7. package/dist/templates/ColorScales/ScaleRow.tsx +74 -0
  8. package/dist/templates/ColorScales/index.md +168 -0
  9. package/dist/templates/ColorScales/index.tsx +70 -0
  10. package/dist/templates/ColorScales/style.ts +42 -0
  11. package/dist/templates/ConfigProvider/index.md +63 -0
  12. package/dist/templates/ConfigProvider/index.tsx +42 -0
  13. package/dist/templates/ContentFormWrapper.tsx +11 -0
  14. package/dist/templates/ContentWrapper.module.less +137 -0
  15. package/dist/templates/ContentWrapper.tsx +13 -0
  16. package/dist/templates/ErrorBoundary/index.tsx +506 -0
  17. package/dist/templates/FontLoader/index.md +12 -0
  18. package/dist/templates/FontLoader/index.tsx +41 -0
  19. package/dist/templates/GlobalStyle/antdOverride.ts +89 -0
  20. package/dist/templates/GlobalStyle/global.ts +61 -0
  21. package/dist/templates/GlobalStyle/index.ts +10 -0
  22. package/dist/templates/Loading/__tests__/Loading.test.tsx +23 -0
  23. package/dist/templates/Loading/index.tsx +21 -0
  24. package/dist/templates/Loading.test.tsx +23 -0
  25. package/dist/templates/Locale.tsx +89 -0
  26. package/dist/templates/MainContentWrap.tsx +68 -0
  27. package/dist/templates/ManualSlave/ManualSlavePage.module.less +25 -0
  28. package/dist/templates/ManualSlave/ManualSlavePage.tsx +45 -0
  29. package/dist/templates/ManualSlave/index.ts +1 -0
  30. package/dist/templates/ManualSlavePage.module.less +25 -0
  31. package/dist/templates/ManualSlavePage.tsx +45 -0
  32. package/dist/templates/Meta.tsx +75 -0
  33. package/dist/templates/RequireAuth/RequireAuth.tsx +76 -0
  34. package/dist/templates/RequireAuth/index.ts +1 -0
  35. package/dist/templates/RequireAuth.tsx +76 -0
  36. package/dist/templates/RoutesConventionsRspackPlugin.js +100 -0
  37. package/dist/templates/ScaleRow.tsx +74 -0
  38. package/dist/templates/ThemeContext.tsx +132 -0
  39. package/dist/templates/ThemeProvider/GlobalStyle/antdOverride.ts +89 -0
  40. package/dist/templates/ThemeProvider/GlobalStyle/global.ts +61 -0
  41. package/dist/templates/ThemeProvider/GlobalStyle/index.ts +10 -0
  42. package/dist/templates/ThemeProvider/Meta.tsx +75 -0
  43. package/dist/templates/ThemeProvider/ThemeProvider.tsx +109 -0
  44. package/dist/templates/ThemeProvider/index.md +69 -0
  45. package/dist/templates/ThemeProvider/index.ts +3 -0
  46. package/dist/templates/ThemeProvider/type.ts +28 -0
  47. package/dist/templates/ThemeProvider.tsx +109 -0
  48. package/dist/templates/__mocks__/fileMock.js +1 -0
  49. package/dist/templates/__mocks__/styleMock.ts +1 -0
  50. package/dist/templates/__tests__/Loading.test.tsx +23 -0
  51. package/dist/templates/__tests__/example.test.ts +7 -0
  52. package/dist/templates/actions.ts +23 -0
  53. package/dist/templates/algorithms/darkAlgorithm.ts +47 -0
  54. package/dist/templates/algorithms/lightAlgorithm.ts +44 -0
  55. package/dist/templates/antdOverride.ts +89 -0
  56. package/dist/templates/antdTheme.ts +62 -0
  57. package/dist/templates/api.ts +5 -0
  58. package/dist/templates/app/.browserslistrc +5 -0
  59. package/dist/templates/app/.gitignore.tpl +30 -0
  60. package/dist/templates/app/.npmrc.tpl +2 -0
  61. package/dist/templates/app/.nvmrc +1 -0
  62. package/dist/templates/app/.vscode/settings.json +88 -0
  63. package/dist/templates/app/config/env/.env.development +5 -0
  64. package/dist/templates/app/config/env/.env.production +2 -0
  65. package/dist/templates/app/config/env/.env.public.tpl +31 -0
  66. package/dist/templates/app/config/jwt/index.ts +31 -0
  67. package/dist/templates/app/config/public/404.png +0 -0
  68. package/dist/templates/app/config/public/favicon.ico +0 -0
  69. package/dist/templates/app/config/public/images/banner_market_modal.webp +0 -0
  70. package/dist/templates/app/config/public/images/chatmode_chat_dark.webp +0 -0
  71. package/dist/templates/app/config/public/images/chatmode_chat_light.webp +0 -0
  72. package/dist/templates/app/config/public/images/chatmode_docs_dark.webp +0 -0
  73. package/dist/templates/app/config/public/images/chatmode_docs_light.webp +0 -0
  74. package/dist/templates/app/config/public/images/empty_topic_dark.webp +0 -0
  75. package/dist/templates/app/config/public/images/empty_topic_light.webp +0 -0
  76. package/dist/templates/app/config/public/images/screenshot_background.webp +0 -0
  77. package/dist/templates/app/config/public/images/theme_auto.webp +0 -0
  78. package/dist/templates/app/config/public/images/theme_dark.webp +0 -0
  79. package/dist/templates/app/config/public/images/theme_light.webp +0 -0
  80. package/dist/templates/app/config/public/index.html +29 -0
  81. package/dist/templates/app/config/request/index.ts +174 -0
  82. package/dist/templates/app/config/router/index.tsx +26 -0
  83. package/dist/templates/app/config/rspack/paths.js +12 -0
  84. package/dist/templates/app/config/rspack/plugins/RoutesConventionsRspackPlugin.js +100 -0
  85. package/dist/templates/app/config/rspack/rspack.config.mjs +186 -0
  86. package/dist/templates/app/config/rspack/rspack.dev.mjs +219 -0
  87. package/dist/templates/app/config/rspack/rspack.prod.mjs +254 -0
  88. package/dist/templates/app/config/sentry/sentry.config.ts +188 -0
  89. package/dist/templates/app/locales/en-US/common.json +74 -0
  90. package/dist/templates/app/locales/en-US/generate.json +71 -0
  91. package/dist/templates/app/locales/en-US/nav.json +10 -0
  92. package/dist/templates/app/locales/en-US/overview.json +6 -0
  93. package/dist/templates/app/locales/en-US/retopology.json +4 -0
  94. package/dist/templates/app/locales/en-US/rigging.json +21 -0
  95. package/dist/templates/app/locales/en-US/segmentation.json +4 -0
  96. package/dist/templates/app/locales/en-US/stylization.json +11 -0
  97. package/dist/templates/app/locales/en-US/texture.json +4 -0
  98. package/dist/templates/app/locales/en-US/threeModel.json +9 -0
  99. package/dist/templates/app/locales/en-US/toolbox.json +11 -0
  100. package/dist/templates/app/locales/zh-CN/common.json +74 -0
  101. package/dist/templates/app/locales/zh-CN/generate.json +71 -0
  102. package/dist/templates/app/locales/zh-CN/nav.json +10 -0
  103. package/dist/templates/app/locales/zh-CN/overview.json +6 -0
  104. package/dist/templates/app/locales/zh-CN/retopology.json +4 -0
  105. package/dist/templates/app/locales/zh-CN/rigging.json +21 -0
  106. package/dist/templates/app/locales/zh-CN/segmentation.json +4 -0
  107. package/dist/templates/app/locales/zh-CN/stylization.json +11 -0
  108. package/dist/templates/app/locales/zh-CN/texture.json +4 -0
  109. package/dist/templates/app/locales/zh-CN/threeModel.json +9 -0
  110. package/dist/templates/app/locales/zh-CN/toolbox.json +11 -0
  111. package/dist/templates/app/package.json.tpl +145 -0
  112. package/dist/templates/app/postcss.config.js +6 -0
  113. package/dist/templates/app/react-app-env.d.ts +14 -0
  114. package/dist/templates/app/scripts/convert-locales-to-json.js +47 -0
  115. package/dist/templates/app/src/__mocks__/fileMock.js +1 -0
  116. package/dist/templates/app/src/__mocks__/styleMock.ts +1 -0
  117. package/dist/templates/app/src/color/ColorScales/ScaleRow.tsx +74 -0
  118. package/dist/templates/app/src/color/ColorScales/index.md +168 -0
  119. package/dist/templates/app/src/color/ColorScales/index.tsx +70 -0
  120. package/dist/templates/app/src/color/ColorScales/style.ts +42 -0
  121. package/dist/templates/app/src/color/colors/blue.ts +66 -0
  122. package/dist/templates/app/src/color/colors/cyan.ts +66 -0
  123. package/dist/templates/app/src/color/colors/geekblue.ts +66 -0
  124. package/dist/templates/app/src/color/colors/gold.ts +66 -0
  125. package/dist/templates/app/src/color/colors/gray.ts +66 -0
  126. package/dist/templates/app/src/color/colors/green.ts +66 -0
  127. package/dist/templates/app/src/color/colors/index.ts +66 -0
  128. package/dist/templates/app/src/color/colors/lime.ts +66 -0
  129. package/dist/templates/app/src/color/colors/magenta.ts +66 -0
  130. package/dist/templates/app/src/color/colors/orange.ts +66 -0
  131. package/dist/templates/app/src/color/colors/primary.ts +66 -0
  132. package/dist/templates/app/src/color/colors/purple.ts +66 -0
  133. package/dist/templates/app/src/color/colors/red.ts +66 -0
  134. package/dist/templates/app/src/color/colors/volcano.ts +66 -0
  135. package/dist/templates/app/src/color/colors/yellow.ts +66 -0
  136. package/dist/templates/app/src/color/index.ts +4 -0
  137. package/dist/templates/app/src/color/neutrals/index.ts +30 -0
  138. package/dist/templates/app/src/color/neutrals/mauve.ts +66 -0
  139. package/dist/templates/app/src/color/neutrals/olive.ts +66 -0
  140. package/dist/templates/app/src/color/neutrals/sage.ts +66 -0
  141. package/dist/templates/app/src/color/neutrals/sand.ts +66 -0
  142. package/dist/templates/app/src/color/neutrals/slate.ts +66 -0
  143. package/dist/templates/app/src/color/types.ts +21 -0
  144. package/dist/templates/app/src/components/ConfigProvider/index.md +63 -0
  145. package/dist/templates/app/src/components/ConfigProvider/index.tsx +42 -0
  146. package/dist/templates/app/src/components/ErrorBoundary/index.tsx +506 -0
  147. package/dist/templates/app/src/components/FontLoader/index.md +12 -0
  148. package/dist/templates/app/src/components/FontLoader/index.tsx +41 -0
  149. package/dist/templates/app/src/components/Loading/__tests__/Loading.test.tsx +23 -0
  150. package/dist/templates/app/src/components/Loading/index.tsx +21 -0
  151. package/dist/templates/app/src/components/ManualSlave/ManualSlavePage.module.less +25 -0
  152. package/dist/templates/app/src/components/ManualSlave/ManualSlavePage.tsx +45 -0
  153. package/dist/templates/app/src/components/ManualSlave/index.ts +1 -0
  154. package/dist/templates/app/src/components/RequireAuth/RequireAuth.tsx +76 -0
  155. package/dist/templates/app/src/components/RequireAuth/index.ts +1 -0
  156. package/dist/templates/app/src/components/ThemeProvider/GlobalStyle/antdOverride.ts +89 -0
  157. package/dist/templates/app/src/components/ThemeProvider/GlobalStyle/global.ts +61 -0
  158. package/dist/templates/app/src/components/ThemeProvider/GlobalStyle/index.ts +10 -0
  159. package/dist/templates/app/src/components/ThemeProvider/Meta.tsx +75 -0
  160. package/dist/templates/app/src/components/ThemeProvider/ThemeProvider.tsx +109 -0
  161. package/dist/templates/app/src/components/ThemeProvider/index.md +69 -0
  162. package/dist/templates/app/src/components/ThemeProvider/index.ts +3 -0
  163. package/dist/templates/app/src/components/ThemeProvider/type.ts +28 -0
  164. package/dist/templates/app/src/const/constants.ts +0 -0
  165. package/dist/templates/app/src/const/locale.ts +9 -0
  166. package/dist/templates/app/src/const/system.ts +1 -0
  167. package/dist/templates/app/src/const/theme.ts +5 -0
  168. package/dist/templates/app/src/const/url.ts +1 -0
  169. package/dist/templates/app/src/hooks/useRouteTitle.tsx +36 -0
  170. package/dist/templates/app/src/hooks/useSentry.ts +92 -0
  171. package/dist/templates/app/src/index.css +2 -0
  172. package/dist/templates/app/src/index.tsx +56 -0
  173. package/dist/templates/app/src/layout/BaseLayout.tsx +15 -0
  174. package/dist/templates/app/src/layout/ContentFormWrapper.tsx +11 -0
  175. package/dist/templates/app/src/layout/ContentWrapper.module.less +137 -0
  176. package/dist/templates/app/src/layout/ContentWrapper.tsx +13 -0
  177. package/dist/templates/app/src/layout/Locale.tsx +89 -0
  178. package/dist/templates/app/src/layout/MainContentWrap.tsx +68 -0
  179. package/dist/templates/app/src/layout/ThemeContext.tsx +132 -0
  180. package/dist/templates/app/src/loading.tsx +52 -0
  181. package/dist/templates/app/src/locales/create.ts +56 -0
  182. package/dist/templates/app/src/locales/default/chat.ts +455 -0
  183. package/dist/templates/app/src/locales/default/index.ts +7 -0
  184. package/dist/templates/app/src/locales/resources.ts +104 -0
  185. package/dist/templates/app/src/pages/404/index.tsx +5 -0
  186. package/dist/templates/app/src/pages/404/page.tsx +27 -0
  187. package/dist/templates/app/src/pages/404.tsx +5 -0
  188. package/dist/templates/app/src/pages/base/index.tsx +32 -0
  189. package/dist/templates/app/src/pages/base/layout.tsx +6 -0
  190. package/dist/templates/app/src/pages/base/page.tsx +25 -0
  191. package/dist/templates/app/src/pages/index.css +282 -0
  192. package/dist/templates/app/src/pages/index.tsx +5 -0
  193. package/dist/templates/app/src/routes.tsx +18 -0
  194. package/dist/templates/app/src/setupTests.ts +39 -0
  195. package/dist/templates/app/src/styles/antdOverride.ts +24 -0
  196. package/dist/templates/app/src/styles/customTheme.ts +70 -0
  197. package/dist/templates/app/src/styles/global.ts +53 -0
  198. package/dist/templates/app/src/styles/highlighter.ts +34 -0
  199. package/dist/templates/app/src/styles/index.ts +23 -0
  200. package/dist/templates/app/src/styles/mermaid.ts +7 -0
  201. package/dist/templates/app/src/styles/text.ts +10 -0
  202. package/dist/templates/app/src/styles/theme/algorithms/darkAlgorithm.ts +47 -0
  203. package/dist/templates/app/src/styles/theme/algorithms/lightAlgorithm.ts +44 -0
  204. package/dist/templates/app/src/styles/theme/antdTheme.ts +62 -0
  205. package/dist/templates/app/src/styles/theme/customStylish.ts +189 -0
  206. package/dist/templates/app/src/styles/theme/customToken.ts +93 -0
  207. package/dist/templates/app/src/styles/theme/generateColorPalette.ts +59 -0
  208. package/dist/templates/app/src/styles/theme/token/base.ts +16 -0
  209. package/dist/templates/app/src/styles/theme/token/dark.ts +60 -0
  210. package/dist/templates/app/src/styles/theme/token/light.ts +60 -0
  211. package/dist/templates/app/src/test-utils.tsx +18 -0
  212. package/dist/templates/app/src/types/customStylish.ts +20 -0
  213. package/dist/templates/app/src/types/customToken.ts +70 -0
  214. package/dist/templates/app/src/types/index.ts +21 -0
  215. package/dist/templates/app/src/types/routes.ts +70 -0
  216. package/dist/templates/app/src/utils/__tests__/example.test.ts +7 -0
  217. package/dist/templates/app/src/utils/convert.ts +40 -0
  218. package/dist/templates/app/src/utils/cookie.ts +25 -0
  219. package/dist/templates/app/src/utils/copyToClipboard.ts +13 -0
  220. package/dist/templates/app/src/utils/difference.ts +26 -0
  221. package/dist/templates/app/src/utils/env.ts +3 -0
  222. package/dist/templates/app/src/utils/format.ts +21 -0
  223. package/dist/templates/app/src/utils/genCdnUrl.ts +30 -0
  224. package/dist/templates/app/src/utils/getMicroApp.ts +39 -0
  225. package/dist/templates/app/src/utils/index.ts +1 -0
  226. package/dist/templates/app/src/utils/locale.ts +46 -0
  227. package/dist/templates/app/src/utils/sentry.ts +187 -0
  228. package/dist/templates/app/src/utils/sentryDecorators.ts +34 -0
  229. package/dist/templates/app/src/utils/updateVersion.ts +186 -0
  230. package/dist/templates/app/store/auth/index.tsx +82 -0
  231. package/dist/templates/app/store/auth/indexApi.tsx +11 -0
  232. package/dist/templates/app/store/global/index.tsx +133 -0
  233. package/dist/templates/app/store/global/indexApi.tsx +19 -0
  234. package/dist/templates/app/store/global/types.ts +62 -0
  235. package/dist/templates/app/store/middleware/createDevtools.ts +23 -0
  236. package/dist/templates/app/store/middleware/createHyperStorage/index.ts +127 -0
  237. package/dist/templates/app/store/middleware/createHyperStorage/indexedDB.ts +31 -0
  238. package/dist/templates/app/store/middleware/createHyperStorage/keyMapper.ts +57 -0
  239. package/dist/templates/app/store/middleware/createHyperStorage/localStorage.ts +23 -0
  240. package/dist/templates/app/store/middleware/createHyperStorage/type.ts +27 -0
  241. package/dist/templates/app/store/middleware/createHyperStorage/urlStorage.ts +85 -0
  242. package/dist/templates/app/store/theme/index.ts +25 -0
  243. package/dist/templates/app/store/types.ts +83 -0
  244. package/dist/templates/app/store/user/index.tsx +1 -0
  245. package/dist/templates/app/store/user/indexApi.tsx +5 -0
  246. package/dist/templates/app/store/user/initialState.ts +15 -0
  247. package/dist/templates/app/store/user/slices/profile/actions.ts +20 -0
  248. package/dist/templates/app/store/user/slices/profile/api.ts +5 -0
  249. package/dist/templates/app/store/user/slices/profile/initialState.ts +14 -0
  250. package/dist/templates/app/store/user/slices/settings/actions.ts +23 -0
  251. package/dist/templates/app/store/user/slices/settings/initialState.ts +32 -0
  252. package/dist/templates/app/store/user/store.ts +39 -0
  253. package/dist/templates/app/tailwind.config.js +13 -0
  254. package/dist/templates/app/tsconfig.json +27 -0
  255. package/dist/templates/app//347/277/273/350/257/221.md +9 -0
  256. package/dist/templates/auth/index.tsx +82 -0
  257. package/dist/templates/auth/indexApi.tsx +11 -0
  258. package/dist/templates/banner_market_modal.webp +0 -0
  259. package/dist/templates/base/index.tsx +32 -0
  260. package/dist/templates/base/layout.tsx +6 -0
  261. package/dist/templates/base/page.tsx +25 -0
  262. package/dist/templates/base.ts +16 -0
  263. package/dist/templates/blue.ts +66 -0
  264. package/dist/templates/chat.ts +455 -0
  265. package/dist/templates/chatmode_chat_dark.webp +0 -0
  266. package/dist/templates/chatmode_chat_light.webp +0 -0
  267. package/dist/templates/chatmode_docs_dark.webp +0 -0
  268. package/dist/templates/chatmode_docs_light.webp +0 -0
  269. package/dist/templates/color/ColorScales/ScaleRow.tsx +74 -0
  270. package/dist/templates/color/ColorScales/index.md +168 -0
  271. package/dist/templates/color/ColorScales/index.tsx +70 -0
  272. package/dist/templates/color/ColorScales/style.ts +42 -0
  273. package/dist/templates/color/colors/blue.ts +66 -0
  274. package/dist/templates/color/colors/cyan.ts +66 -0
  275. package/dist/templates/color/colors/geekblue.ts +66 -0
  276. package/dist/templates/color/colors/gold.ts +66 -0
  277. package/dist/templates/color/colors/gray.ts +66 -0
  278. package/dist/templates/color/colors/green.ts +66 -0
  279. package/dist/templates/color/colors/index.ts +66 -0
  280. package/dist/templates/color/colors/lime.ts +66 -0
  281. package/dist/templates/color/colors/magenta.ts +66 -0
  282. package/dist/templates/color/colors/orange.ts +66 -0
  283. package/dist/templates/color/colors/primary.ts +66 -0
  284. package/dist/templates/color/colors/purple.ts +66 -0
  285. package/dist/templates/color/colors/red.ts +66 -0
  286. package/dist/templates/color/colors/volcano.ts +66 -0
  287. package/dist/templates/color/colors/yellow.ts +66 -0
  288. package/dist/templates/color/index.ts +4 -0
  289. package/dist/templates/color/neutrals/index.ts +30 -0
  290. package/dist/templates/color/neutrals/mauve.ts +66 -0
  291. package/dist/templates/color/neutrals/olive.ts +66 -0
  292. package/dist/templates/color/neutrals/sage.ts +66 -0
  293. package/dist/templates/color/neutrals/sand.ts +66 -0
  294. package/dist/templates/color/neutrals/slate.ts +66 -0
  295. package/dist/templates/color/types.ts +21 -0
  296. package/dist/templates/colors/blue.ts +66 -0
  297. package/dist/templates/colors/cyan.ts +66 -0
  298. package/dist/templates/colors/geekblue.ts +66 -0
  299. package/dist/templates/colors/gold.ts +66 -0
  300. package/dist/templates/colors/gray.ts +66 -0
  301. package/dist/templates/colors/green.ts +66 -0
  302. package/dist/templates/colors/index.ts +66 -0
  303. package/dist/templates/colors/lime.ts +66 -0
  304. package/dist/templates/colors/magenta.ts +66 -0
  305. package/dist/templates/colors/orange.ts +66 -0
  306. package/dist/templates/colors/primary.ts +66 -0
  307. package/dist/templates/colors/purple.ts +66 -0
  308. package/dist/templates/colors/red.ts +66 -0
  309. package/dist/templates/colors/volcano.ts +66 -0
  310. package/dist/templates/colors/yellow.ts +66 -0
  311. package/dist/templates/common.json +74 -0
  312. package/dist/templates/components/ConfigProvider/index.md +63 -0
  313. package/dist/templates/components/ConfigProvider/index.tsx +42 -0
  314. package/dist/templates/components/ErrorBoundary/index.tsx +506 -0
  315. package/dist/templates/components/FontLoader/index.md +12 -0
  316. package/dist/templates/components/FontLoader/index.tsx +41 -0
  317. package/dist/templates/components/Loading/__tests__/Loading.test.tsx +23 -0
  318. package/dist/templates/components/Loading/index.tsx +21 -0
  319. package/dist/templates/components/ManualSlave/ManualSlavePage.module.less +25 -0
  320. package/dist/templates/components/ManualSlave/ManualSlavePage.tsx +45 -0
  321. package/dist/templates/components/ManualSlave/index.ts +1 -0
  322. package/dist/templates/components/RequireAuth/RequireAuth.tsx +76 -0
  323. package/dist/templates/components/RequireAuth/index.ts +1 -0
  324. package/dist/templates/components/ThemeProvider/GlobalStyle/antdOverride.ts +89 -0
  325. package/dist/templates/components/ThemeProvider/GlobalStyle/global.ts +61 -0
  326. package/dist/templates/components/ThemeProvider/GlobalStyle/index.ts +10 -0
  327. package/dist/templates/components/ThemeProvider/Meta.tsx +75 -0
  328. package/dist/templates/components/ThemeProvider/ThemeProvider.tsx +109 -0
  329. package/dist/templates/components/ThemeProvider/index.md +69 -0
  330. package/dist/templates/components/ThemeProvider/index.ts +3 -0
  331. package/dist/templates/components/ThemeProvider/type.ts +28 -0
  332. package/dist/templates/config/env/.env.development +5 -0
  333. package/dist/templates/config/env/.env.production +2 -0
  334. package/dist/templates/config/env/.env.public.tpl +31 -0
  335. package/dist/templates/config/jwt/index.ts +31 -0
  336. package/dist/templates/config/public/404.png +0 -0
  337. package/dist/templates/config/public/favicon.ico +0 -0
  338. package/dist/templates/config/public/images/banner_market_modal.webp +0 -0
  339. package/dist/templates/config/public/images/chatmode_chat_dark.webp +0 -0
  340. package/dist/templates/config/public/images/chatmode_chat_light.webp +0 -0
  341. package/dist/templates/config/public/images/chatmode_docs_dark.webp +0 -0
  342. package/dist/templates/config/public/images/chatmode_docs_light.webp +0 -0
  343. package/dist/templates/config/public/images/empty_topic_dark.webp +0 -0
  344. package/dist/templates/config/public/images/empty_topic_light.webp +0 -0
  345. package/dist/templates/config/public/images/screenshot_background.webp +0 -0
  346. package/dist/templates/config/public/images/theme_auto.webp +0 -0
  347. package/dist/templates/config/public/images/theme_dark.webp +0 -0
  348. package/dist/templates/config/public/images/theme_light.webp +0 -0
  349. package/dist/templates/config/public/index.html +29 -0
  350. package/dist/templates/config/request/index.ts +174 -0
  351. package/dist/templates/config/router/index.tsx +26 -0
  352. package/dist/templates/config/rspack/paths.js +12 -0
  353. package/dist/templates/config/rspack/plugins/RoutesConventionsRspackPlugin.js +100 -0
  354. package/dist/templates/config/rspack/rspack.config.mjs +186 -0
  355. package/dist/templates/config/rspack/rspack.dev.mjs +219 -0
  356. package/dist/templates/config/rspack/rspack.prod.mjs +254 -0
  357. package/dist/templates/config/sentry/sentry.config.ts +188 -0
  358. package/dist/templates/const/constants.ts +0 -0
  359. package/dist/templates/const/locale.ts +9 -0
  360. package/dist/templates/const/system.ts +1 -0
  361. package/dist/templates/const/theme.ts +5 -0
  362. package/dist/templates/const/url.ts +1 -0
  363. package/dist/templates/constants.ts +0 -0
  364. package/dist/templates/convert-locales-to-json.js +47 -0
  365. package/dist/templates/convert.ts +40 -0
  366. package/dist/templates/cookie.ts +25 -0
  367. package/dist/templates/copyToClipboard.ts +13 -0
  368. package/dist/templates/create.ts +56 -0
  369. package/dist/templates/createDevtools.ts +23 -0
  370. package/dist/templates/createHyperStorage/index.ts +127 -0
  371. package/dist/templates/createHyperStorage/indexedDB.ts +31 -0
  372. package/dist/templates/createHyperStorage/keyMapper.ts +57 -0
  373. package/dist/templates/createHyperStorage/localStorage.ts +23 -0
  374. package/dist/templates/createHyperStorage/type.ts +27 -0
  375. package/dist/templates/createHyperStorage/urlStorage.ts +85 -0
  376. package/dist/templates/customStylish.ts +189 -0
  377. package/dist/templates/customTheme.ts +70 -0
  378. package/dist/templates/customToken.ts +93 -0
  379. package/dist/templates/cyan.ts +66 -0
  380. package/dist/templates/dark.ts +60 -0
  381. package/dist/templates/darkAlgorithm.ts +47 -0
  382. package/dist/templates/default/chat.ts +455 -0
  383. package/dist/templates/default/index.ts +7 -0
  384. package/dist/templates/difference.ts +26 -0
  385. package/dist/templates/empty_topic_dark.webp +0 -0
  386. package/dist/templates/empty_topic_light.webp +0 -0
  387. package/dist/templates/en-US/common.json +74 -0
  388. package/dist/templates/en-US/generate.json +71 -0
  389. package/dist/templates/en-US/nav.json +10 -0
  390. package/dist/templates/en-US/overview.json +6 -0
  391. package/dist/templates/en-US/retopology.json +4 -0
  392. package/dist/templates/en-US/rigging.json +21 -0
  393. package/dist/templates/en-US/segmentation.json +4 -0
  394. package/dist/templates/en-US/stylization.json +11 -0
  395. package/dist/templates/en-US/texture.json +4 -0
  396. package/dist/templates/en-US/threeModel.json +9 -0
  397. package/dist/templates/en-US/toolbox.json +11 -0
  398. package/dist/templates/env/.env.development +5 -0
  399. package/dist/templates/env/.env.production +2 -0
  400. package/dist/templates/env/.env.public.tpl +31 -0
  401. package/dist/templates/env.ts +3 -0
  402. package/dist/templates/example.test.ts +7 -0
  403. package/dist/templates/favicon.ico +0 -0
  404. package/dist/templates/fileMock.js +1 -0
  405. package/dist/templates/format.ts +21 -0
  406. package/dist/templates/geekblue.ts +66 -0
  407. package/dist/templates/genCdnUrl.ts +30 -0
  408. package/dist/templates/generate.json +71 -0
  409. package/dist/templates/generateColorPalette.ts +59 -0
  410. package/dist/templates/getMicroApp.ts +39 -0
  411. package/dist/templates/global/index.tsx +133 -0
  412. package/dist/templates/global/indexApi.tsx +19 -0
  413. package/dist/templates/global/types.ts +62 -0
  414. package/dist/templates/global.ts +61 -0
  415. package/dist/templates/gold.ts +66 -0
  416. package/dist/templates/gray.ts +66 -0
  417. package/dist/templates/green.ts +66 -0
  418. package/dist/templates/highlighter.ts +34 -0
  419. package/dist/templates/hooks/useRouteTitle.tsx +36 -0
  420. package/dist/templates/hooks/useSentry.ts +92 -0
  421. package/dist/templates/images/banner_market_modal.webp +0 -0
  422. package/dist/templates/images/chatmode_chat_dark.webp +0 -0
  423. package/dist/templates/images/chatmode_chat_light.webp +0 -0
  424. package/dist/templates/images/chatmode_docs_dark.webp +0 -0
  425. package/dist/templates/images/chatmode_docs_light.webp +0 -0
  426. package/dist/templates/images/empty_topic_dark.webp +0 -0
  427. package/dist/templates/images/empty_topic_light.webp +0 -0
  428. package/dist/templates/images/screenshot_background.webp +0 -0
  429. package/dist/templates/images/theme_auto.webp +0 -0
  430. package/dist/templates/images/theme_dark.webp +0 -0
  431. package/dist/templates/images/theme_light.webp +0 -0
  432. package/dist/templates/index.css +282 -0
  433. package/dist/templates/index.html +29 -0
  434. package/dist/templates/index.md +69 -0
  435. package/dist/templates/index.ts +10 -0
  436. package/dist/templates/index.tsx +32 -0
  437. package/dist/templates/indexApi.tsx +5 -0
  438. package/dist/templates/indexedDB.ts +31 -0
  439. package/dist/templates/initialState.ts +32 -0
  440. package/dist/templates/jwt/index.ts +31 -0
  441. package/dist/templates/keyMapper.ts +57 -0
  442. package/dist/templates/layout/BaseLayout.tsx +15 -0
  443. package/dist/templates/layout/ContentFormWrapper.tsx +11 -0
  444. package/dist/templates/layout/ContentWrapper.module.less +137 -0
  445. package/dist/templates/layout/ContentWrapper.tsx +13 -0
  446. package/dist/templates/layout/Locale.tsx +89 -0
  447. package/dist/templates/layout/MainContentWrap.tsx +68 -0
  448. package/dist/templates/layout/ThemeContext.tsx +132 -0
  449. package/dist/templates/layout.tsx +6 -0
  450. package/dist/templates/light.ts +60 -0
  451. package/dist/templates/lightAlgorithm.ts +44 -0
  452. package/dist/templates/lime.ts +66 -0
  453. package/dist/templates/loading.tsx +52 -0
  454. package/dist/templates/localStorage.ts +23 -0
  455. package/dist/templates/locale.ts +46 -0
  456. package/dist/templates/locales/create.ts +56 -0
  457. package/dist/templates/locales/default/chat.ts +455 -0
  458. package/dist/templates/locales/default/index.ts +7 -0
  459. package/dist/templates/locales/en-US/common.json +74 -0
  460. package/dist/templates/locales/en-US/generate.json +71 -0
  461. package/dist/templates/locales/en-US/nav.json +10 -0
  462. package/dist/templates/locales/en-US/overview.json +6 -0
  463. package/dist/templates/locales/en-US/retopology.json +4 -0
  464. package/dist/templates/locales/en-US/rigging.json +21 -0
  465. package/dist/templates/locales/en-US/segmentation.json +4 -0
  466. package/dist/templates/locales/en-US/stylization.json +11 -0
  467. package/dist/templates/locales/en-US/texture.json +4 -0
  468. package/dist/templates/locales/en-US/threeModel.json +9 -0
  469. package/dist/templates/locales/en-US/toolbox.json +11 -0
  470. package/dist/templates/locales/resources.ts +104 -0
  471. package/dist/templates/locales/zh-CN/common.json +74 -0
  472. package/dist/templates/locales/zh-CN/generate.json +71 -0
  473. package/dist/templates/locales/zh-CN/nav.json +10 -0
  474. package/dist/templates/locales/zh-CN/overview.json +6 -0
  475. package/dist/templates/locales/zh-CN/retopology.json +4 -0
  476. package/dist/templates/locales/zh-CN/rigging.json +21 -0
  477. package/dist/templates/locales/zh-CN/segmentation.json +4 -0
  478. package/dist/templates/locales/zh-CN/stylization.json +11 -0
  479. package/dist/templates/locales/zh-CN/texture.json +4 -0
  480. package/dist/templates/locales/zh-CN/threeModel.json +9 -0
  481. package/dist/templates/locales/zh-CN/toolbox.json +11 -0
  482. package/dist/templates/magenta.ts +66 -0
  483. package/dist/templates/mauve.ts +66 -0
  484. package/dist/templates/mermaid.ts +7 -0
  485. package/dist/templates/middleware/createDevtools.ts +23 -0
  486. package/dist/templates/middleware/createHyperStorage/index.ts +127 -0
  487. package/dist/templates/middleware/createHyperStorage/indexedDB.ts +31 -0
  488. package/dist/templates/middleware/createHyperStorage/keyMapper.ts +57 -0
  489. package/dist/templates/middleware/createHyperStorage/localStorage.ts +23 -0
  490. package/dist/templates/middleware/createHyperStorage/type.ts +27 -0
  491. package/dist/templates/middleware/createHyperStorage/urlStorage.ts +85 -0
  492. package/dist/templates/nav.json +10 -0
  493. package/dist/templates/neutrals/index.ts +30 -0
  494. package/dist/templates/neutrals/mauve.ts +66 -0
  495. package/dist/templates/neutrals/olive.ts +66 -0
  496. package/dist/templates/neutrals/sage.ts +66 -0
  497. package/dist/templates/neutrals/sand.ts +66 -0
  498. package/dist/templates/neutrals/slate.ts +66 -0
  499. package/dist/templates/olive.ts +66 -0
  500. package/dist/templates/orange.ts +66 -0
  501. package/dist/templates/overview.json +6 -0
  502. package/dist/templates/package.json.tpl +145 -0
  503. package/dist/templates/page.tsx +25 -0
  504. package/dist/templates/pages/404/index.tsx +5 -0
  505. package/dist/templates/pages/404/page.tsx +27 -0
  506. package/dist/templates/pages/404.tsx +5 -0
  507. package/dist/templates/pages/base/index.tsx +32 -0
  508. package/dist/templates/pages/base/layout.tsx +6 -0
  509. package/dist/templates/pages/base/page.tsx +25 -0
  510. package/dist/templates/pages/index.css +282 -0
  511. package/dist/templates/pages/index.tsx +5 -0
  512. package/dist/templates/paths.js +12 -0
  513. package/dist/templates/plugins/RoutesConventionsRspackPlugin.js +100 -0
  514. package/dist/templates/postcss.config.js +6 -0
  515. package/dist/templates/primary.ts +66 -0
  516. package/dist/templates/profile/actions.ts +20 -0
  517. package/dist/templates/profile/api.ts +5 -0
  518. package/dist/templates/profile/initialState.ts +14 -0
  519. package/dist/templates/public/404.png +0 -0
  520. package/dist/templates/public/favicon.ico +0 -0
  521. package/dist/templates/public/images/banner_market_modal.webp +0 -0
  522. package/dist/templates/public/images/chatmode_chat_dark.webp +0 -0
  523. package/dist/templates/public/images/chatmode_chat_light.webp +0 -0
  524. package/dist/templates/public/images/chatmode_docs_dark.webp +0 -0
  525. package/dist/templates/public/images/chatmode_docs_light.webp +0 -0
  526. package/dist/templates/public/images/empty_topic_dark.webp +0 -0
  527. package/dist/templates/public/images/empty_topic_light.webp +0 -0
  528. package/dist/templates/public/images/screenshot_background.webp +0 -0
  529. package/dist/templates/public/images/theme_auto.webp +0 -0
  530. package/dist/templates/public/images/theme_dark.webp +0 -0
  531. package/dist/templates/public/images/theme_light.webp +0 -0
  532. package/dist/templates/public/index.html +29 -0
  533. package/dist/templates/purple.ts +66 -0
  534. package/dist/templates/react-app-env.d.ts +14 -0
  535. package/dist/templates/red.ts +66 -0
  536. package/dist/templates/request/index.ts +174 -0
  537. package/dist/templates/resources.ts +104 -0
  538. package/dist/templates/retopology.json +4 -0
  539. package/dist/templates/rigging.json +21 -0
  540. package/dist/templates/router/index.tsx +26 -0
  541. package/dist/templates/routes.ts +70 -0
  542. package/dist/templates/routes.tsx +18 -0
  543. package/dist/templates/rspack/paths.js +12 -0
  544. package/dist/templates/rspack/plugins/RoutesConventionsRspackPlugin.js +100 -0
  545. package/dist/templates/rspack/rspack.config.mjs +186 -0
  546. package/dist/templates/rspack/rspack.dev.mjs +219 -0
  547. package/dist/templates/rspack/rspack.prod.mjs +254 -0
  548. package/dist/templates/rspack.config.mjs +186 -0
  549. package/dist/templates/rspack.dev.mjs +219 -0
  550. package/dist/templates/rspack.prod.mjs +254 -0
  551. package/dist/templates/sage.ts +66 -0
  552. package/dist/templates/sand.ts +66 -0
  553. package/dist/templates/screenshot_background.webp +0 -0
  554. package/dist/templates/scripts/convert-locales-to-json.js +47 -0
  555. package/dist/templates/segmentation.json +4 -0
  556. package/dist/templates/sentry/sentry.config.ts +188 -0
  557. package/dist/templates/sentry.config.ts +188 -0
  558. package/dist/templates/sentry.ts +187 -0
  559. package/dist/templates/sentryDecorators.ts +34 -0
  560. package/dist/templates/settings/actions.ts +23 -0
  561. package/dist/templates/settings/initialState.ts +32 -0
  562. package/dist/templates/setupTests.ts +39 -0
  563. package/dist/templates/slate.ts +66 -0
  564. package/dist/templates/slices/profile/actions.ts +20 -0
  565. package/dist/templates/slices/profile/api.ts +5 -0
  566. package/dist/templates/slices/profile/initialState.ts +14 -0
  567. package/dist/templates/slices/settings/actions.ts +23 -0
  568. package/dist/templates/slices/settings/initialState.ts +32 -0
  569. package/dist/templates/src/__mocks__/fileMock.js +1 -0
  570. package/dist/templates/src/__mocks__/styleMock.ts +1 -0
  571. package/dist/templates/src/color/ColorScales/ScaleRow.tsx +74 -0
  572. package/dist/templates/src/color/ColorScales/index.md +168 -0
  573. package/dist/templates/src/color/ColorScales/index.tsx +70 -0
  574. package/dist/templates/src/color/ColorScales/style.ts +42 -0
  575. package/dist/templates/src/color/colors/blue.ts +66 -0
  576. package/dist/templates/src/color/colors/cyan.ts +66 -0
  577. package/dist/templates/src/color/colors/geekblue.ts +66 -0
  578. package/dist/templates/src/color/colors/gold.ts +66 -0
  579. package/dist/templates/src/color/colors/gray.ts +66 -0
  580. package/dist/templates/src/color/colors/green.ts +66 -0
  581. package/dist/templates/src/color/colors/index.ts +66 -0
  582. package/dist/templates/src/color/colors/lime.ts +66 -0
  583. package/dist/templates/src/color/colors/magenta.ts +66 -0
  584. package/dist/templates/src/color/colors/orange.ts +66 -0
  585. package/dist/templates/src/color/colors/primary.ts +66 -0
  586. package/dist/templates/src/color/colors/purple.ts +66 -0
  587. package/dist/templates/src/color/colors/red.ts +66 -0
  588. package/dist/templates/src/color/colors/volcano.ts +66 -0
  589. package/dist/templates/src/color/colors/yellow.ts +66 -0
  590. package/dist/templates/src/color/index.ts +4 -0
  591. package/dist/templates/src/color/neutrals/index.ts +30 -0
  592. package/dist/templates/src/color/neutrals/mauve.ts +66 -0
  593. package/dist/templates/src/color/neutrals/olive.ts +66 -0
  594. package/dist/templates/src/color/neutrals/sage.ts +66 -0
  595. package/dist/templates/src/color/neutrals/sand.ts +66 -0
  596. package/dist/templates/src/color/neutrals/slate.ts +66 -0
  597. package/dist/templates/src/color/types.ts +21 -0
  598. package/dist/templates/src/components/ConfigProvider/index.md +63 -0
  599. package/dist/templates/src/components/ConfigProvider/index.tsx +42 -0
  600. package/dist/templates/src/components/ErrorBoundary/index.tsx +506 -0
  601. package/dist/templates/src/components/FontLoader/index.md +12 -0
  602. package/dist/templates/src/components/FontLoader/index.tsx +41 -0
  603. package/dist/templates/src/components/Loading/__tests__/Loading.test.tsx +23 -0
  604. package/dist/templates/src/components/Loading/index.tsx +21 -0
  605. package/dist/templates/src/components/ManualSlave/ManualSlavePage.module.less +25 -0
  606. package/dist/templates/src/components/ManualSlave/ManualSlavePage.tsx +45 -0
  607. package/dist/templates/src/components/ManualSlave/index.ts +1 -0
  608. package/dist/templates/src/components/RequireAuth/RequireAuth.tsx +76 -0
  609. package/dist/templates/src/components/RequireAuth/index.ts +1 -0
  610. package/dist/templates/src/components/ThemeProvider/GlobalStyle/antdOverride.ts +89 -0
  611. package/dist/templates/src/components/ThemeProvider/GlobalStyle/global.ts +61 -0
  612. package/dist/templates/src/components/ThemeProvider/GlobalStyle/index.ts +10 -0
  613. package/dist/templates/src/components/ThemeProvider/Meta.tsx +75 -0
  614. package/dist/templates/src/components/ThemeProvider/ThemeProvider.tsx +109 -0
  615. package/dist/templates/src/components/ThemeProvider/index.md +69 -0
  616. package/dist/templates/src/components/ThemeProvider/index.ts +3 -0
  617. package/dist/templates/src/components/ThemeProvider/type.ts +28 -0
  618. package/dist/templates/src/const/constants.ts +0 -0
  619. package/dist/templates/src/const/locale.ts +9 -0
  620. package/dist/templates/src/const/system.ts +1 -0
  621. package/dist/templates/src/const/theme.ts +5 -0
  622. package/dist/templates/src/const/url.ts +1 -0
  623. package/dist/templates/src/hooks/useRouteTitle.tsx +36 -0
  624. package/dist/templates/src/hooks/useSentry.ts +92 -0
  625. package/dist/templates/src/index.css +2 -0
  626. package/dist/templates/src/index.tsx +56 -0
  627. package/dist/templates/src/layout/BaseLayout.tsx +15 -0
  628. package/dist/templates/src/layout/ContentFormWrapper.tsx +11 -0
  629. package/dist/templates/src/layout/ContentWrapper.module.less +137 -0
  630. package/dist/templates/src/layout/ContentWrapper.tsx +13 -0
  631. package/dist/templates/src/layout/Locale.tsx +89 -0
  632. package/dist/templates/src/layout/MainContentWrap.tsx +68 -0
  633. package/dist/templates/src/layout/ThemeContext.tsx +132 -0
  634. package/dist/templates/src/loading.tsx +52 -0
  635. package/dist/templates/src/locales/create.ts +56 -0
  636. package/dist/templates/src/locales/default/chat.ts +455 -0
  637. package/dist/templates/src/locales/default/index.ts +7 -0
  638. package/dist/templates/src/locales/resources.ts +104 -0
  639. package/dist/templates/src/pages/404/index.tsx +5 -0
  640. package/dist/templates/src/pages/404/page.tsx +27 -0
  641. package/dist/templates/src/pages/404.tsx +5 -0
  642. package/dist/templates/src/pages/base/index.tsx +32 -0
  643. package/dist/templates/src/pages/base/layout.tsx +6 -0
  644. package/dist/templates/src/pages/base/page.tsx +25 -0
  645. package/dist/templates/src/pages/index.css +282 -0
  646. package/dist/templates/src/pages/index.tsx +5 -0
  647. package/dist/templates/src/routes.tsx +18 -0
  648. package/dist/templates/src/setupTests.ts +39 -0
  649. package/dist/templates/src/styles/antdOverride.ts +24 -0
  650. package/dist/templates/src/styles/customTheme.ts +70 -0
  651. package/dist/templates/src/styles/global.ts +53 -0
  652. package/dist/templates/src/styles/highlighter.ts +34 -0
  653. package/dist/templates/src/styles/index.ts +23 -0
  654. package/dist/templates/src/styles/mermaid.ts +7 -0
  655. package/dist/templates/src/styles/text.ts +10 -0
  656. package/dist/templates/src/styles/theme/algorithms/darkAlgorithm.ts +47 -0
  657. package/dist/templates/src/styles/theme/algorithms/lightAlgorithm.ts +44 -0
  658. package/dist/templates/src/styles/theme/antdTheme.ts +62 -0
  659. package/dist/templates/src/styles/theme/customStylish.ts +189 -0
  660. package/dist/templates/src/styles/theme/customToken.ts +93 -0
  661. package/dist/templates/src/styles/theme/generateColorPalette.ts +59 -0
  662. package/dist/templates/src/styles/theme/token/base.ts +16 -0
  663. package/dist/templates/src/styles/theme/token/dark.ts +60 -0
  664. package/dist/templates/src/styles/theme/token/light.ts +60 -0
  665. package/dist/templates/src/test-utils.tsx +18 -0
  666. package/dist/templates/src/types/customStylish.ts +20 -0
  667. package/dist/templates/src/types/customToken.ts +70 -0
  668. package/dist/templates/src/types/index.ts +21 -0
  669. package/dist/templates/src/types/routes.ts +70 -0
  670. package/dist/templates/src/utils/__tests__/example.test.ts +7 -0
  671. package/dist/templates/src/utils/convert.ts +40 -0
  672. package/dist/templates/src/utils/cookie.ts +25 -0
  673. package/dist/templates/src/utils/copyToClipboard.ts +13 -0
  674. package/dist/templates/src/utils/difference.ts +26 -0
  675. package/dist/templates/src/utils/env.ts +3 -0
  676. package/dist/templates/src/utils/format.ts +21 -0
  677. package/dist/templates/src/utils/genCdnUrl.ts +30 -0
  678. package/dist/templates/src/utils/getMicroApp.ts +39 -0
  679. package/dist/templates/src/utils/index.ts +1 -0
  680. package/dist/templates/src/utils/locale.ts +46 -0
  681. package/dist/templates/src/utils/sentry.ts +187 -0
  682. package/dist/templates/src/utils/sentryDecorators.ts +34 -0
  683. package/dist/templates/src/utils/updateVersion.ts +186 -0
  684. package/dist/templates/store/auth/index.tsx +82 -0
  685. package/dist/templates/store/auth/indexApi.tsx +11 -0
  686. package/dist/templates/store/global/index.tsx +133 -0
  687. package/dist/templates/store/global/indexApi.tsx +19 -0
  688. package/dist/templates/store/global/types.ts +62 -0
  689. package/dist/templates/store/middleware/createDevtools.ts +23 -0
  690. package/dist/templates/store/middleware/createHyperStorage/index.ts +127 -0
  691. package/dist/templates/store/middleware/createHyperStorage/indexedDB.ts +31 -0
  692. package/dist/templates/store/middleware/createHyperStorage/keyMapper.ts +57 -0
  693. package/dist/templates/store/middleware/createHyperStorage/localStorage.ts +23 -0
  694. package/dist/templates/store/middleware/createHyperStorage/type.ts +27 -0
  695. package/dist/templates/store/middleware/createHyperStorage/urlStorage.ts +85 -0
  696. package/dist/templates/store/theme/index.ts +25 -0
  697. package/dist/templates/store/types.ts +83 -0
  698. package/dist/templates/store/user/index.tsx +1 -0
  699. package/dist/templates/store/user/indexApi.tsx +5 -0
  700. package/dist/templates/store/user/initialState.ts +15 -0
  701. package/dist/templates/store/user/slices/profile/actions.ts +20 -0
  702. package/dist/templates/store/user/slices/profile/api.ts +5 -0
  703. package/dist/templates/store/user/slices/profile/initialState.ts +14 -0
  704. package/dist/templates/store/user/slices/settings/actions.ts +23 -0
  705. package/dist/templates/store/user/slices/settings/initialState.ts +32 -0
  706. package/dist/templates/store/user/store.ts +39 -0
  707. package/dist/templates/store.ts +39 -0
  708. package/dist/templates/style.ts +42 -0
  709. package/dist/templates/styleMock.ts +1 -0
  710. package/dist/templates/styles/antdOverride.ts +24 -0
  711. package/dist/templates/styles/customTheme.ts +70 -0
  712. package/dist/templates/styles/global.ts +53 -0
  713. package/dist/templates/styles/highlighter.ts +34 -0
  714. package/dist/templates/styles/index.ts +23 -0
  715. package/dist/templates/styles/mermaid.ts +7 -0
  716. package/dist/templates/styles/text.ts +10 -0
  717. package/dist/templates/styles/theme/algorithms/darkAlgorithm.ts +47 -0
  718. package/dist/templates/styles/theme/algorithms/lightAlgorithm.ts +44 -0
  719. package/dist/templates/styles/theme/antdTheme.ts +62 -0
  720. package/dist/templates/styles/theme/customStylish.ts +189 -0
  721. package/dist/templates/styles/theme/customToken.ts +93 -0
  722. package/dist/templates/styles/theme/generateColorPalette.ts +59 -0
  723. package/dist/templates/styles/theme/token/base.ts +16 -0
  724. package/dist/templates/styles/theme/token/dark.ts +60 -0
  725. package/dist/templates/styles/theme/token/light.ts +60 -0
  726. package/dist/templates/stylization.json +11 -0
  727. package/dist/templates/system.ts +1 -0
  728. package/dist/templates/tailwind.config.js +13 -0
  729. package/dist/templates/test-utils.tsx +18 -0
  730. package/dist/templates/text.ts +10 -0
  731. package/dist/templates/texture.json +4 -0
  732. package/dist/templates/theme/algorithms/darkAlgorithm.ts +47 -0
  733. package/dist/templates/theme/algorithms/lightAlgorithm.ts +44 -0
  734. package/dist/templates/theme/antdTheme.ts +62 -0
  735. package/dist/templates/theme/customStylish.ts +189 -0
  736. package/dist/templates/theme/customToken.ts +93 -0
  737. package/dist/templates/theme/generateColorPalette.ts +59 -0
  738. package/dist/templates/theme/index.ts +25 -0
  739. package/dist/templates/theme/token/base.ts +16 -0
  740. package/dist/templates/theme/token/dark.ts +60 -0
  741. package/dist/templates/theme/token/light.ts +60 -0
  742. package/dist/templates/theme.ts +5 -0
  743. package/dist/templates/theme_auto.webp +0 -0
  744. package/dist/templates/theme_dark.webp +0 -0
  745. package/dist/templates/theme_light.webp +0 -0
  746. package/dist/templates/threeModel.json +9 -0
  747. package/dist/templates/token/base.ts +16 -0
  748. package/dist/templates/token/dark.ts +60 -0
  749. package/dist/templates/token/light.ts +60 -0
  750. package/dist/templates/toolbox.json +11 -0
  751. package/dist/templates/tsconfig.json +27 -0
  752. package/dist/templates/type.ts +28 -0
  753. package/dist/templates/types/customStylish.ts +20 -0
  754. package/dist/templates/types/customToken.ts +70 -0
  755. package/dist/templates/types/index.ts +21 -0
  756. package/dist/templates/types/routes.ts +70 -0
  757. package/dist/templates/types.ts +21 -0
  758. package/dist/templates/updateVersion.ts +186 -0
  759. package/dist/templates/url.ts +1 -0
  760. package/dist/templates/urlStorage.ts +85 -0
  761. package/dist/templates/useRouteTitle.tsx +36 -0
  762. package/dist/templates/useSentry.ts +92 -0
  763. package/dist/templates/user/index.tsx +1 -0
  764. package/dist/templates/user/indexApi.tsx +5 -0
  765. package/dist/templates/user/initialState.ts +15 -0
  766. package/dist/templates/user/slices/profile/actions.ts +20 -0
  767. package/dist/templates/user/slices/profile/api.ts +5 -0
  768. package/dist/templates/user/slices/profile/initialState.ts +14 -0
  769. package/dist/templates/user/slices/settings/actions.ts +23 -0
  770. package/dist/templates/user/slices/settings/initialState.ts +32 -0
  771. package/dist/templates/user/store.ts +39 -0
  772. package/dist/templates/utils/__tests__/example.test.ts +7 -0
  773. package/dist/templates/utils/convert.ts +40 -0
  774. package/dist/templates/utils/cookie.ts +25 -0
  775. package/dist/templates/utils/copyToClipboard.ts +13 -0
  776. package/dist/templates/utils/difference.ts +26 -0
  777. package/dist/templates/utils/env.ts +3 -0
  778. package/dist/templates/utils/format.ts +21 -0
  779. package/dist/templates/utils/genCdnUrl.ts +30 -0
  780. package/dist/templates/utils/getMicroApp.ts +39 -0
  781. package/dist/templates/utils/index.ts +1 -0
  782. package/dist/templates/utils/locale.ts +46 -0
  783. package/dist/templates/utils/sentry.ts +187 -0
  784. package/dist/templates/utils/sentryDecorators.ts +34 -0
  785. package/dist/templates/utils/updateVersion.ts +186 -0
  786. package/dist/templates/volcano.ts +66 -0
  787. package/dist/templates/yellow.ts +66 -0
  788. package/dist/templates/zh-CN/common.json +74 -0
  789. package/dist/templates/zh-CN/generate.json +71 -0
  790. package/dist/templates/zh-CN/nav.json +10 -0
  791. package/dist/templates/zh-CN/overview.json +6 -0
  792. package/dist/templates/zh-CN/retopology.json +4 -0
  793. package/dist/templates/zh-CN/rigging.json +21 -0
  794. package/dist/templates/zh-CN/segmentation.json +4 -0
  795. package/dist/templates/zh-CN/stylization.json +11 -0
  796. package/dist/templates/zh-CN/texture.json +4 -0
  797. package/dist/templates/zh-CN/threeModel.json +9 -0
  798. package/dist/templates/zh-CN/toolbox.json +11 -0
  799. package/dist/templates//347/277/273/350/257/221.md +9 -0
  800. package/package.json +29 -21
  801. package/README.md +0 -180
  802. package/dist/api.js +0 -44
  803. package/dist/templates.js +0 -87
@@ -0,0 +1,47 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ const sourceDir = path.join(__dirname, "../src/locales/default");
5
+
6
+ // 动态读取源目录下所有 .ts 文件(排除 index.ts)
7
+ const files = fs
8
+ .readdirSync(sourceDir)
9
+ .filter((file) => {
10
+ return (
11
+ file.endsWith(".ts") && // 只处理 .ts 文件
12
+ file !== "index.ts" // 排除 index.ts
13
+ );
14
+ })
15
+ .map((file) => path.basename(file, ".ts")); // 去掉 .ts 扩展名
16
+
17
+ // 使用 ts-node 加载 TypeScript 文件
18
+ require("ts-node/register");
19
+
20
+ const targetDir = path.join(__dirname, "../locales/zh-CN");
21
+
22
+ // 确保目标目录存在
23
+ if (!fs.existsSync(targetDir)) {
24
+ fs.mkdirSync(targetDir, { recursive: true });
25
+ }
26
+
27
+ console.log("开始转换 TypeScript 文件到 JSON...\n");
28
+
29
+ files.forEach((fileName) => {
30
+ try {
31
+ // 动态导入 TypeScript 模块
32
+ const modulePath = path.join(sourceDir, `${fileName}.ts`);
33
+ delete require.cache[require.resolve(modulePath)]; // 清除缓存
34
+ const moduleContent = require(modulePath).default;
35
+
36
+ // 转换为 JSON 并保存
37
+ const jsonContent = JSON.stringify(moduleContent, null, 2);
38
+ const targetPath = path.join(targetDir, `${fileName}.json`);
39
+
40
+ fs.writeFileSync(targetPath, jsonContent, "utf8");
41
+ console.log(`✅ ${fileName}.ts → ${fileName}.json`);
42
+ } catch (error) {
43
+ console.error(`❌ 转换 ${fileName}.ts 失败:`, error.message);
44
+ }
45
+ });
46
+
47
+ console.log("\n✨ 转换完成!");
@@ -0,0 +1,40 @@
1
+ /**
2
+ * 将文件大小从一个单位转换为另一个单位。
3
+ *
4
+ * @param {number} size 文件大小。
5
+ * @param {string} fromUnit 初始单位('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB')。
6
+ * @param {string} toUnit 目标单位('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB')。
7
+ * @param {number} [decimalPoint=2] 结果保留的小数位数,默认为2。
8
+ * @return {string} 转换后的文件大小,带单位。
9
+ */
10
+ export const convertFileSize = (
11
+ size: number,
12
+ fromUnit: string,
13
+ toUnit: string,
14
+ decimalPoint = 2,
15
+ ): string => {
16
+ // 定义单位与字节之间的转换关系
17
+ const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
18
+ // 获取初始单位和目标单位的索引
19
+ const fromIndex = units.indexOf(fromUnit);
20
+ const toIndex = units.indexOf(toUnit);
21
+
22
+ // 如果单位不在列表中,抛出错误
23
+ if (fromIndex === -1 || toIndex === -1) {
24
+ throw new Error('Invalid units');
25
+ }
26
+
27
+ // 计算初始单位与目标单位之间的转换系数
28
+ const exponent = toIndex - fromIndex;
29
+ // 计算结果大小
30
+ const resultSize = size / 1024 ** exponent;
31
+
32
+ // 返回格式化后的结果
33
+ return `${Number.parseFloat(resultSize.toFixed(decimalPoint))} ${toUnit}`;
34
+ };
35
+
36
+ // // 示例使用
37
+ // console.log(convertFileSize(1, 'GB', 'MB')); // 输出: 1024.00 MB
38
+ // console.log(convertFileSize(1, 'MB', 'KB')); // 输出: 1024.00 KB
39
+ // console.log(convertFileSize(1, 'KB', 'B')); // 输出: 1024.00 B
40
+ // console.log(convertFileSize(1, 'MB', 'GB', 5)); // 输出: 0.00098 GB
@@ -0,0 +1,25 @@
1
+ import dayjs from 'dayjs';
2
+
3
+ export const COOKIE_CACHE_DAYS = 30;
4
+
5
+ export const setCookie = (
6
+ key: string,
7
+ value: string | undefined,
8
+ expireDays: string | number = COOKIE_CACHE_DAYS,
9
+ ) => {
10
+ if (typeof value === 'undefined') {
11
+ // Set the expiration time to yesterday (expire immediately)
12
+ const expiredDate = new Date(0).toUTCString(); // 1970-01-01T00:00:00Z
13
+
14
+ // eslint-disable-next-line unicorn/no-document-cookie
15
+ document.cookie = `${key}=; expires=${expiredDate}; path=/;`;
16
+ } else {
17
+ const expires =
18
+ typeof expireDays === 'string'
19
+ ? expireDays
20
+ : dayjs().add(expireDays, 'day').toDate().toUTCString();
21
+
22
+ // eslint-disable-next-line unicorn/no-document-cookie
23
+ document.cookie = `${key}=${value};expires=${expires};path=/;`;
24
+ }
25
+ };
@@ -0,0 +1,13 @@
1
+ export const copyToClipboard = async (text: string) => {
2
+ try {
3
+ await navigator.clipboard.writeText(text);
4
+ } catch {
5
+ const textArea = document.createElement('textarea');
6
+ textArea.value = text;
7
+ document.body.append(textArea);
8
+ textArea.focus();
9
+ textArea.select();
10
+ document.execCommand('copy');
11
+ textArea.remove();
12
+ }
13
+ };
@@ -0,0 +1,56 @@
1
+ import i18n from 'i18next';
2
+ import LanguageDetector from 'i18next-browser-languagedetector';
3
+ import resourcesToBackend from 'i18next-resources-to-backend';
4
+ import { initReactI18next } from 'react-i18next';
5
+ import { isRtlLang } from 'rtl-detect';
6
+
7
+ import { DEFAULT_LANG } from '@/const/locale';
8
+ import { normalizeLocale } from '@/locales/resources';
9
+
10
+ const isDev = process.env.NODE_ENV === 'development';
11
+ const debugMode = isDev;
12
+
13
+ export const createI18nNext = (lang?: string) => {
14
+ const instance = i18n
15
+ .use(initReactI18next)
16
+ .use(LanguageDetector)
17
+ .use(
18
+ resourcesToBackend(async (lng: string, ns: string) => {
19
+ return import(`@locales/${normalizeLocale(lng)}/${ns}.json`);
20
+ }),
21
+ );
22
+ // Dynamically set HTML direction on language change
23
+ instance.on('languageChanged', (lng) => {
24
+ if (typeof window !== 'undefined') {
25
+ const direction = isRtlLang(lng) ? 'rtl' : 'ltr';
26
+ document.documentElement.dir = direction;
27
+ }
28
+ });
29
+ return {
30
+ init: () =>
31
+ instance.init({
32
+ debug: debugMode,
33
+ defaultNS: ['error', 'common', 'chat'],
34
+ // detection: {
35
+ // caches: ['cookie'],
36
+ // cookieMinutes: 60 * 24 * COOKIE_CACHE_DAYS,
37
+ // /**
38
+ // Set `sameSite` to `lax` so that the i18n cookie can be passed to the
39
+ // server side when returning from the OAuth authorization website.
40
+ // ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
41
+ // discussion: https://github.com/lobehub/lobe-chat/pull/1474
42
+ // */
43
+ // cookieOptions: {
44
+ // sameSite: 'lax',
45
+ // },
46
+ // lookupCookie: LOBE_LOCALE_COOKIE,
47
+ // },
48
+ fallbackLng: DEFAULT_LANG,
49
+ interpolation: {
50
+ escapeValue: false,
51
+ },
52
+ lng: lang,
53
+ }),
54
+ instance,
55
+ };
56
+ };
@@ -0,0 +1,23 @@
1
+ import { optionalDevtools } from 'zustand-utils';
2
+ import type { devtools as _devtools } from 'zustand/middleware';
3
+
4
+ import { isDev } from '@/utils/env';
5
+
6
+ export const createDevtools =
7
+ (name: string): typeof _devtools =>
8
+ initializer => {
9
+ let showDevtools = false;
10
+
11
+ // check url to show devtools
12
+ if (typeof window !== 'undefined') {
13
+ const url = new URL(window.location.href);
14
+ const debug = url.searchParams.get('debug');
15
+ if (debug?.includes(name)) {
16
+ showDevtools = true;
17
+ }
18
+ }
19
+
20
+ return optionalDevtools(showDevtools)(initializer, {
21
+ name: `LobeChat_${name}${isDev ? '_DEV' : ''}`,
22
+ });
23
+ };
@@ -0,0 +1,127 @@
1
+ import type { PersistStorage, StorageValue } from 'zustand/middleware';
2
+
3
+ import { createIndexedDB } from './indexedDB';
4
+ import { createKeyMapper } from './keyMapper';
5
+ import { createLocalStorage } from './localStorage';
6
+ import type { HyperStorageOptions } from './type';
7
+ import { creatUrlStorage } from './urlStorage';
8
+
9
+ export const createHyperStorage = <T extends object>(
10
+ options: HyperStorageOptions,
11
+ ): PersistStorage<T> => {
12
+ const optionsObj = typeof options === 'function' ? options() : options;
13
+
14
+ const getLocalStorageConfig = () => {
15
+ if (optionsObj.localStorage === false) {
16
+ return { dbName: '', skipLocalStorage: true, useIndexedDB: false };
17
+ }
18
+
19
+ const useIndexedDB = optionsObj.localStorage?.mode === 'indexedDB';
20
+ const dbName = optionsObj.localStorage?.dbName || 'indexedDB';
21
+
22
+ return { dbName, skipLocalStorage: false, useIndexedDB };
23
+ };
24
+
25
+ const hasUrl = !!optionsObj.url;
26
+
27
+ const { skipLocalStorage, useIndexedDB, dbName } = getLocalStorageConfig();
28
+
29
+ const { mapStateKeyToStorageKey, getStateKeyFromStorageKey } =
30
+ createKeyMapper(optionsObj);
31
+
32
+ const indexedDB = createIndexedDB(dbName);
33
+ const localStorage = createLocalStorage();
34
+ const urlStorage = creatUrlStorage(optionsObj.url?.mode);
35
+ return {
36
+ getItem: async (name): Promise<StorageValue<T>> => {
37
+ const state: any = {};
38
+ let version: number | undefined;
39
+
40
+ // ============== 处理 Local Storage ============== //
41
+ if (!skipLocalStorage) {
42
+ let localState: StorageValue<T> | undefined;
43
+
44
+ // 如果使用 indexedDB,优先从 indexedDB 中获取
45
+ if (useIndexedDB) {
46
+ localState = await indexedDB.getItem(name);
47
+ }
48
+ // 如果 indexedDB 中不存在,则再试试 localStorage
49
+ if (!localState) localState = localStorage.getItem(name);
50
+
51
+ if (localState) {
52
+ version = localState.version;
53
+ for (const [k, v] of Object.entries(localState.state)) {
54
+ const key = getStateKeyFromStorageKey(k, 'localStorage');
55
+ if (key) state[key] = v;
56
+ }
57
+ }
58
+ }
59
+
60
+ // ============== 处理 URL Storage ============== //
61
+ // 不从 URL 中获取 version,由于 url 状态是临时态 不作为版本控制的依据
62
+ if (hasUrl) {
63
+ const urlState = urlStorage.getItem();
64
+
65
+ if (urlState) {
66
+ for (const [k, v] of Object.entries(urlState.state)) {
67
+ const key = getStateKeyFromStorageKey(k, 'url');
68
+ // 当存在 UrlSelector 逻辑,且 key 有效时,才将状态加入终态 state
69
+ if (hasUrl && key) {
70
+ state[key] = v;
71
+ }
72
+ }
73
+ }
74
+ }
75
+
76
+ return { state, version };
77
+ },
78
+ removeItem: async key => {
79
+ // ============== 处理 Local Storage ============== //
80
+ if (!skipLocalStorage) {
81
+ if (useIndexedDB) {
82
+ await indexedDB.removeItem(key);
83
+ } else {
84
+ localStorage.removeItem(key);
85
+ }
86
+ }
87
+
88
+ // ============== 处理 URL Storage ============== //
89
+ if (hasUrl) {
90
+ const storageKey = getStateKeyFromStorageKey(key, 'url');
91
+
92
+ urlStorage.removeItem(storageKey);
93
+ }
94
+ },
95
+
96
+ setItem: async (name, newValue) => {
97
+ // ============== 处理 Local Storage ============== //
98
+ const localState: Record<string, any> = {};
99
+ for (const [k, v] of Object.entries(newValue.state)) {
100
+ const localKey = mapStateKeyToStorageKey(k, 'localStorage');
101
+ if (localKey) localState[localKey] = v;
102
+ }
103
+
104
+ if (!skipLocalStorage) {
105
+ if (useIndexedDB) {
106
+ await indexedDB.setItem(name, localState, newValue.version);
107
+ } else {
108
+ localStorage.setItem(name, localState, newValue.version);
109
+ }
110
+ }
111
+
112
+ // ============== 处理 URL Storage ============== //
113
+ if (hasUrl) {
114
+ // 转换 key 为目标 key
115
+ const finalEntries = Object.entries(newValue.state)
116
+ .map(([k, v]) => {
117
+ const urlKey = mapStateKeyToStorageKey(k, 'url');
118
+ if (!urlKey) return undefined;
119
+ return [urlKey, v];
120
+ })
121
+ .filter(Boolean) as [string, any][];
122
+
123
+ urlStorage.setItem(name, Object.fromEntries(finalEntries));
124
+ }
125
+ },
126
+ };
127
+ };
@@ -0,0 +1,31 @@
1
+ import { createStore, delMany, getMany, setMany } from 'idb-keyval';
2
+ import type { StorageValue } from 'zustand/middleware';
3
+
4
+ export const createIndexedDB = <State>(dbName = 'indexedDB') => ({
5
+ getItem: async <T extends State>(
6
+ name: string,
7
+ ): Promise<StorageValue<T> | undefined> => {
8
+ const [version, state] = await getMany(
9
+ ['version', 'state'],
10
+ createStore(dbName, name),
11
+ );
12
+
13
+ if (!state) return undefined;
14
+
15
+ return { state, version };
16
+ },
17
+ removeItem: async (name: string) => {
18
+ await delMany(['version', 'state'], createStore(dbName, name));
19
+ },
20
+ setItem: async (name: string, state: any, version: number | undefined) => {
21
+ const store = createStore(dbName, name);
22
+
23
+ await setMany(
24
+ [
25
+ ['version', version],
26
+ ['state', state],
27
+ ],
28
+ store,
29
+ );
30
+ },
31
+ });
@@ -0,0 +1,57 @@
1
+ import type { HyperStorageOptionsObj } from './type';
2
+
3
+ export const createKeyMapper = (options: HyperStorageOptionsObj) => {
4
+ const mapStateKeyToStorageKey = (
5
+ key: string,
6
+ mode: keyof HyperStorageOptionsObj = 'localStorage',
7
+ ) => {
8
+ const media = options[mode];
9
+ if (media === false) return key;
10
+
11
+ const selectors = media?.selectors;
12
+ if (!selectors) return key;
13
+
14
+ let storageKey: string | undefined;
15
+
16
+ for (const selector of selectors) {
17
+ if (typeof selector === 'string') {
18
+ if (selector === key) storageKey = key;
19
+ } else {
20
+ if (selector[key]) storageKey = selector[key];
21
+ }
22
+ }
23
+
24
+ return storageKey;
25
+ };
26
+
27
+ const getStateKeyFromStorageKey = (
28
+ key: string,
29
+ mode: keyof HyperStorageOptionsObj = 'localStorage',
30
+ ) => {
31
+ const media = options[mode];
32
+ if (media === false) return key;
33
+
34
+ const selectors = media?.selectors;
35
+ if (!selectors) return key;
36
+
37
+ let stateKey: string | undefined;
38
+
39
+ for (const item of selectors) {
40
+ // 对象如果是 字符串,直接返回该 item key
41
+ if (typeof item === 'string') {
42
+ if (item === key) stateKey = key;
43
+ } else {
44
+ for (const [k, v] of Object.entries(item)) {
45
+ if (v === key) stateKey = k;
46
+ }
47
+ }
48
+ }
49
+
50
+ return stateKey;
51
+ };
52
+
53
+ return {
54
+ getStateKeyFromStorageKey,
55
+ mapStateKeyToStorageKey,
56
+ };
57
+ };
@@ -0,0 +1,23 @@
1
+ import type { StorageValue } from 'zustand/middleware';
2
+
3
+ export const createLocalStorage = <State>() => ({
4
+ getItem: <T extends State>(name: string): StorageValue<T> | undefined => {
5
+ if (!global.localStorage) return undefined;
6
+ const string = localStorage.getItem(name);
7
+
8
+ if (string) return JSON.parse(string) as StorageValue<T>;
9
+
10
+ return undefined;
11
+ },
12
+ removeItem: (name: string) => {
13
+ if (global.localStorage) localStorage.removeItem(name);
14
+ },
15
+ setItem: <T extends State>(
16
+ name: string,
17
+ state: T,
18
+ version: number | undefined,
19
+ ) => {
20
+ if (global.localStorage)
21
+ localStorage.setItem(name, JSON.stringify({ state, version }));
22
+ },
23
+ });
@@ -0,0 +1,27 @@
1
+ export type StorageSelector = string | Record<string, string>;
2
+
3
+ export interface LocalStorageOptions {
4
+ dbName?: string;
5
+ /**
6
+ * @default 'localStorage'
7
+ */
8
+ mode?: 'indexedDB' | 'localStorage';
9
+ selectors: StorageSelector[];
10
+ }
11
+
12
+ export type HyperStorageOptionsObj = {
13
+ localStorage?: LocalStorageOptions | false;
14
+ url?: {
15
+ /**
16
+ * @default 'hash'
17
+ */
18
+ mode?: 'hash' | 'search';
19
+ selectors: StorageSelector[];
20
+ };
21
+ };
22
+
23
+ export type HyperStorageOptionsFn = () => HyperStorageOptionsObj;
24
+
25
+ export type HyperStorageOptions =
26
+ | HyperStorageOptionsObj
27
+ | HyperStorageOptionsFn;
@@ -0,0 +1,85 @@
1
+ import { isEmpty } from 'lodash-es';
2
+ import type { StorageValue } from 'zustand/middleware';
3
+
4
+ interface UrlSearchHelper {
5
+ getUrlSearch: () => string;
6
+ setUrlSearch: (params: URLSearchParams) => void;
7
+ }
8
+
9
+ const createUrlSearch = (mode: 'search' | 'hash' = 'hash'): UrlSearchHelper => {
10
+ if (mode === 'hash')
11
+ return {
12
+ getUrlSearch: () => location.hash.slice(1),
13
+ setUrlSearch: (params: URLSearchParams) => {
14
+ location.hash = params.toString();
15
+ },
16
+ };
17
+
18
+ return {
19
+ getUrlSearch: () => location.search.slice(1),
20
+ setUrlSearch: (params: URLSearchParams) => {
21
+ if (params.size === 0) return;
22
+
23
+ history.replaceState({}, '', `?${params.toString()}`);
24
+ },
25
+ };
26
+ };
27
+
28
+ export const creatUrlStorage = <State extends object>(
29
+ mode: 'hash' | 'search' = 'hash',
30
+ ) => {
31
+ const { setUrlSearch, getUrlSearch } = createUrlSearch(mode);
32
+
33
+ return {
34
+ getItem: <T extends State>(): StorageValue<T> | undefined => {
35
+ const searchParameters = new URLSearchParams(getUrlSearch());
36
+
37
+ if (searchParameters.size === 0) return undefined;
38
+
39
+ const state = Object.fromEntries(searchParameters.entries()) as T;
40
+
41
+ return { state };
42
+ },
43
+ removeItem: (key?: string) => {
44
+ const searchParameters = new URLSearchParams(getUrlSearch());
45
+ if (key) searchParameters.delete(key);
46
+
47
+ setUrlSearch(searchParameters);
48
+ },
49
+ setItem: <T extends State>(name: string, state: T) => {
50
+ const searchParameters = new URLSearchParams(getUrlSearch());
51
+
52
+ for (const [urlKey, v] of Object.entries(state)) {
53
+ switch (typeof v) {
54
+ case 'boolean': {
55
+ searchParameters.set(urlKey, (v ? 1 : 0).toString());
56
+ break;
57
+ }
58
+
59
+ case 'bigint':
60
+ case 'number': {
61
+ searchParameters.set(urlKey, v.toString());
62
+ break;
63
+ }
64
+
65
+ case 'string': {
66
+ searchParameters.set(urlKey, v);
67
+ break;
68
+ }
69
+
70
+ case 'object': {
71
+ if (isEmpty(v)) {
72
+ searchParameters.delete(urlKey);
73
+ continue;
74
+ }
75
+
76
+ searchParameters.set(urlKey, JSON.stringify(v));
77
+ break;
78
+ }
79
+ }
80
+ }
81
+
82
+ setUrlSearch(searchParameters);
83
+ },
84
+ };
85
+ };