@authing/react-ui-components 3.0.0-alpha → 3.0.0-rc.11

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 (235) hide show
  1. package/dist/index.min.css +2 -0
  2. package/dist/index.min.js +2 -0
  3. package/dist/index.min.js.LICENSE.txt +71 -0
  4. package/{components/ShieldSpin/loading.svg → dist/static/media/loading.4a67a5f3.svg} +0 -0
  5. package/lib/index.d.ts +2108 -118
  6. package/lib/index.min.css +2 -2
  7. package/lib/index.min.js +1 -1
  8. package/lib/index.min.js.LICENSE.txt +2 -0
  9. package/package.json +32 -10
  10. package/.eslintignore +0 -6
  11. package/.eslintrc.js +0 -7
  12. package/.prettierrc +0 -5
  13. package/.vscode/settings.json +0 -31
  14. package/build/favicon.ico +0 -0
  15. package/build/logo192.png +0 -0
  16. package/build/logo512.png +0 -0
  17. package/build/manifest.json +0 -25
  18. package/build/robots.txt +0 -3
  19. package/components/AuthingDropdown/index.tsx +0 -52
  20. package/components/AuthingDropdown/style.less +0 -43
  21. package/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
  22. package/components/AuthingGuard/AppMFALayout/style.less +0 -12
  23. package/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
  24. package/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
  25. package/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
  26. package/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
  27. package/components/AuthingGuard/Forms/Agreements/style.less +0 -44
  28. package/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
  29. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -84
  30. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
  31. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
  32. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
  33. package/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
  34. package/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
  35. package/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -166
  36. package/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
  37. package/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
  38. package/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
  39. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
  40. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
  41. package/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
  42. package/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
  43. package/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
  44. package/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
  45. package/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
  46. package/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
  47. package/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
  48. package/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -59
  49. package/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
  50. package/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
  51. package/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
  52. package/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
  53. package/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
  54. package/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
  55. package/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
  56. package/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
  57. package/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
  58. package/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
  59. package/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
  60. package/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
  61. package/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
  62. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
  63. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
  64. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
  65. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
  66. package/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
  67. package/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
  68. package/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
  69. package/components/AuthingGuard/Forms/index.ts +0 -13
  70. package/components/AuthingGuard/GuardLayout/index.tsx +0 -474
  71. package/components/AuthingGuard/GuardLayout/style.less +0 -111
  72. package/components/AuthingGuard/Header/index.tsx +0 -25
  73. package/components/AuthingGuard/Header/style.less +0 -52
  74. package/components/AuthingGuard/IconFont/iconfont.js +0 -74
  75. package/components/AuthingGuard/IconFont/index.tsx +0 -19
  76. package/components/AuthingGuard/IconFont/style.less +0 -6
  77. package/components/AuthingGuard/IconFont/svg.js +0 -2
  78. package/components/AuthingGuard/LoginLayout/index.tsx +0 -161
  79. package/components/AuthingGuard/LoginLayout/style.less +0 -0
  80. package/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
  81. package/components/AuthingGuard/MfaLayout/index.tsx +0 -49
  82. package/components/AuthingGuard/MfaLayout/style.less +0 -3
  83. package/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
  84. package/components/AuthingGuard/RegisterLayout/style.less +0 -0
  85. package/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
  86. package/components/AuthingGuard/ToggleLang/index.tsx +0 -51
  87. package/components/AuthingGuard/api/appConfig.ts +0 -146
  88. package/components/AuthingGuard/api/index.ts +0 -3
  89. package/components/AuthingGuard/api/sso.ts +0 -29
  90. package/components/AuthingGuard/api/userPoolConfig.ts +0 -111
  91. package/components/AuthingGuard/constants.ts +0 -105
  92. package/components/AuthingGuard/hooks/index.tsx +0 -70
  93. package/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
  94. package/components/AuthingGuard/index.tsx +0 -126
  95. package/components/AuthingGuard/style.less +0 -103
  96. package/components/AuthingGuard/types/Forms.ts +0 -94
  97. package/components/AuthingGuard/types/GuardConfig.ts +0 -420
  98. package/components/AuthingGuard/types/GuardState.ts +0 -7
  99. package/components/AuthingGuard/types/Locales.ts +0 -12
  100. package/components/AuthingGuard/types/index.ts +0 -4
  101. package/components/AuthingTabs/index.tsx +0 -98
  102. package/components/AuthingTabs/style.less +0 -135
  103. package/components/BindTotp/core/bindSuccess.tsx +0 -61
  104. package/components/BindTotp/core/securityCode.tsx +0 -119
  105. package/components/BindTotp/index.tsx +0 -134
  106. package/components/BindTotp/props.ts +0 -30
  107. package/components/BindTotp/styles.less +0 -56
  108. package/components/ChangeLanguage/index.tsx +0 -35
  109. package/components/ChangePassword/core/firstLoginReset.tsx +0 -104
  110. package/components/ChangePassword/core/rotateReset.tsx +0 -114
  111. package/components/ChangePassword/index.tsx +0 -59
  112. package/components/CompleteInfo/core/completeInfo.tsx +0 -155
  113. package/components/CompleteInfo/index.tsx +0 -45
  114. package/components/CompleteInfo/props.ts +0 -40
  115. package/components/CompleteInfo/styles.less +0 -7
  116. package/components/CompleteUserInfo/index.tsx +0 -49
  117. package/components/CompleteUserInfo/props.ts +0 -25
  118. package/components/ComponentsRender/index.back +0 -64
  119. package/components/CopyAbleText/index.tsx +0 -54
  120. package/components/CopyAbleText/style.less +0 -13
  121. package/components/DownloadAuthenticator/index.tsx +0 -97
  122. package/components/DownloadAuthenticator/props.ts +0 -22
  123. package/components/DownloadAuthenticator/styles.less +0 -52
  124. package/components/ForgetPassword/core/resetPassword.tsx +0 -150
  125. package/components/ForgetPassword/index.tsx +0 -51
  126. package/components/Guard/Guard.tsx +0 -226
  127. package/components/Guard/authClient.ts +0 -55
  128. package/components/Guard/config.ts +0 -19
  129. package/components/Guard/event.ts +0 -18
  130. package/components/Guard/index.tsx +0 -10
  131. package/components/Guard/module.ts +0 -19
  132. package/components/Guard/stateMachine.ts +0 -133
  133. package/components/Guard/styles.less +0 -444
  134. package/components/IconFont/iconfont.js +0 -74
  135. package/components/IconFont/index.tsx +0 -16
  136. package/components/IconFont/style.less +0 -6
  137. package/components/IconFont/svg.js +0 -2
  138. package/components/ImagePro/index.tsx +0 -52
  139. package/components/ImagePro/styles.less +0 -40
  140. package/components/Login/codemap.ts +0 -35
  141. package/components/Login/core/withAD.tsx +0 -9
  142. package/components/Login/core/withAppQrcode.tsx +0 -49
  143. package/components/Login/core/withLDAP.tsx +0 -145
  144. package/components/Login/core/withPassword.tsx +0 -176
  145. package/components/Login/core/withPhonecode.tsx +0 -135
  146. package/components/Login/core/withWechatMiniQrcode.tsx +0 -60
  147. package/components/Login/core/withWechatmpQrcode.tsx +0 -53
  148. package/components/Login/index.tsx +0 -359
  149. package/components/Login/props.ts +0 -90
  150. package/components/Login/socialLogin/index.tsx +0 -413
  151. package/components/Login/socialLogin/style.less +0 -61
  152. package/components/Login/styles.less +0 -53
  153. package/components/MFA/codemap.ts +0 -21
  154. package/components/MFA/core/email.tsx +0 -226
  155. package/components/MFA/core/face.tsx +0 -297
  156. package/components/MFA/core/face_deps.tsx +0 -37
  157. package/components/MFA/core/sms.tsx +0 -222
  158. package/components/MFA/core/totp.tsx +0 -137
  159. package/components/MFA/index.tsx +0 -135
  160. package/components/MFA/mfaMethods/index.tsx +0 -81
  161. package/components/MFA/mfaMethods/style.less +0 -39
  162. package/components/MFA/props.ts +0 -51
  163. package/components/MFA/styles.less +0 -92
  164. package/components/NeedHelpView/core/describeQuestions.tsx +0 -227
  165. package/components/NeedHelpView/index.tsx +0 -99
  166. package/components/RecoveryCode/core/useCode.tsx +0 -71
  167. package/components/RecoveryCode/index.tsx +0 -27
  168. package/components/RecoveryCode/interface.ts +0 -31
  169. package/components/RecoveryCode/style.less +0 -13
  170. package/components/Register/codemap.ts +0 -16
  171. package/components/Register/components/Agreements/index.tsx +0 -81
  172. package/components/Register/components/Agreements/style.less +0 -44
  173. package/components/Register/core/WithEmail.tsx +0 -250
  174. package/components/Register/core/WithPhone.tsx +0 -190
  175. package/components/Register/index.tsx +0 -122
  176. package/components/Register/props.ts +0 -50
  177. package/components/SendCode/SendCodeBtn.tsx +0 -96
  178. package/components/SendCode/index.tsx +0 -98
  179. package/components/SendCode/style.less +0 -31
  180. package/components/ShieldSpin/index.tsx +0 -27
  181. package/components/SubmitButton/index.tsx +0 -50
  182. package/components/Type/index.ts +0 -61
  183. package/components/VerifyCodeInput/index.tsx +0 -76
  184. package/components/VerifyCodeInput/style.less +0 -24
  185. package/components/_utils/GuardErrorCode.ts +0 -8
  186. package/components/_utils/clipboard.ts +0 -27
  187. package/components/_utils/config.ts +0 -123
  188. package/components/_utils/guradHttp.ts +0 -93
  189. package/components/_utils/hooks/index.ts +0 -56
  190. package/components/_utils/http.ts +0 -85
  191. package/components/_utils/index.ts +0 -310
  192. package/components/_utils/locales/en/common.json +0 -218
  193. package/components/_utils/locales/en/index.ts +0 -6
  194. package/components/_utils/locales/en/login.json +0 -95
  195. package/components/_utils/locales/en/map.json +0 -4
  196. package/components/_utils/locales/en/user.json +0 -82
  197. package/components/_utils/locales/index.ts +0 -45
  198. package/components/_utils/locales/zh/common.json +0 -218
  199. package/components/_utils/locales/zh/index.ts +0 -6
  200. package/components/_utils/locales/zh/login.json +0 -95
  201. package/components/_utils/locales/zh/map.json +0 -4
  202. package/components/_utils/locales/zh/user.json +0 -82
  203. package/components/_utils/popupCenter.ts +0 -48
  204. package/components/context/base.tsx +0 -28
  205. package/components/context/global/context.tsx +0 -39
  206. package/components/context/global/reducer.tsx +0 -56
  207. package/components/context/module/context.tsx +0 -23
  208. package/components/index.ts +0 -10
  209. package/config/antdReplacer.js +0 -51
  210. package/config/env.js +0 -104
  211. package/config/getHttpsConfig.js +0 -66
  212. package/config/jest/cssTransform.js +0 -14
  213. package/config/jest/fileTransform.js +0 -40
  214. package/config/modules.js +0 -134
  215. package/config/paths.js +0 -71
  216. package/config/pnpTs.js +0 -35
  217. package/config/webpack.config.js +0 -835
  218. package/config/webpackDevServer.config.js +0 -130
  219. package/examples.tsx +0 -100
  220. package/index.js +0 -1
  221. package/logo.svg +0 -7
  222. package/public/favicon.ico +0 -0
  223. package/public/index.html +0 -43
  224. package/public/logo192.png +0 -0
  225. package/public/logo512.png +0 -0
  226. package/public/manifest.json +0 -25
  227. package/public/robots.txt +0 -3
  228. package/react-app-env.d.ts +0 -71
  229. package/reportWebVitals.ts +0 -15
  230. package/scripts/build.js +0 -208
  231. package/scripts/lib.js +0 -200
  232. package/scripts/start.js +0 -162
  233. package/scripts/test.js +0 -49
  234. package/setupTests.ts +0 -5
  235. package/tsconfig.json +0 -30
@@ -1,48 +0,0 @@
1
- /**
2
- * 在屏幕中心弹出新窗口加载 url
3
- * @param url
4
- * @param param1
5
- */
6
- export const popupCenter = (
7
- url: string,
8
- { w, h }: { w: number; h: number } = { w: 585, h: 649 }
9
- ) => {
10
- // Fixes dual-screen position Most browsers Firefox
11
- const dualScreenLeft =
12
- window.screenLeft !== undefined ? window.screenLeft : window.screenX
13
- const dualScreenTop =
14
- window.screenTop !== undefined ? window.screenTop : window.screenY
15
-
16
- const width = window.innerWidth
17
- ? window.innerWidth
18
- : document.documentElement.clientWidth
19
- ? document.documentElement.clientWidth
20
- : window.screen.width
21
- const height = window.innerHeight
22
- ? window.innerHeight
23
- : document.documentElement.clientHeight
24
- ? document.documentElement.clientHeight
25
- : window.screen.height
26
-
27
- const systemZoom = width / window.screen.availWidth
28
- const left = (width - w) / 2 / systemZoom + dualScreenLeft
29
- const top = (height - h) / 2 / systemZoom + dualScreenTop
30
- const newWindow = window.open(
31
- url,
32
- '_blank',
33
- `
34
- toolbar=no,
35
- menubar=no,
36
- scrollbars=no,
37
- resizable=no,
38
- location=no,
39
- status=no
40
- width=${w / systemZoom},
41
- height=${h / systemZoom},
42
- top=${top},
43
- left=${left}
44
- `
45
- )
46
-
47
- newWindow?.focus()
48
- }
@@ -1,28 +0,0 @@
1
- import React from 'react'
2
-
3
- // create context with no upfront defaultValue
4
- // without having to do undefined check all the time
5
- export function createBaseContext<C>() {
6
- const ctx = React.createContext<C | undefined>(undefined)
7
- function useBaseContext() {
8
- const ctxConst = React.useContext(ctx)
9
- if (!ctxConst)
10
- throw new Error('useBaseContext must be inside a Provider with a value')
11
- return ctxConst
12
- }
13
- // make TypeScript infer a tuple, not an array of union types
14
- return [ctx, useBaseContext] as const
15
- }
16
-
17
- export interface IBaseAction<ActionType = string> {
18
- type: ActionType & string
19
- payload?: any
20
- [key: string]: string
21
- }
22
-
23
- export interface IBaseContext<S> {
24
- state: S
25
- [k: string]: any
26
- }
27
-
28
- export type BaseContextComponent<Props> = React.PropsWithChildren<Props>
@@ -1,39 +0,0 @@
1
- import React, { useCallback, useReducer } from 'react'
2
- import { createBaseContext, IBaseContext, BaseContextComponent } from '../base'
3
- import { reducer, IState } from './reducer'
4
-
5
- // 页面上下文,除了状态外还有公开的方法
6
- export interface IGuardContext extends IBaseContext<IState> {
7
- dispatch: Function
8
- getValue: (key: keyof IState) => any
9
- setValue: (key: keyof IState, value: any) => void
10
- }
11
-
12
- // 实例化上下文,这里避免了为空检查
13
- const [Context, useBaseContext] = createBaseContext<IGuardContext>()
14
-
15
- export function useGuardContext(): IGuardContext {
16
- const guardContext = useBaseContext()
17
- // TODO: custom some
18
- return guardContext
19
- }
20
-
21
- export function GuardContext({
22
- children = null,
23
- value,
24
- }: BaseContextComponent<Record<string, any>>) {
25
- const [state, dispatch] = useReducer(reducer, value)
26
- const getValue = (key: keyof IState) => state[key]
27
- const setValue = useCallback((key: keyof IState, value: any) => {
28
- dispatch({ type: 'SET_VALUE', key, value })
29
- }, [])
30
-
31
- let ctx: IGuardContext = {
32
- state,
33
- dispatch,
34
- getValue,
35
- setValue,
36
- }
37
-
38
- return <Context.Provider value={ctx}>{children}</Context.Provider>
39
- }
@@ -1,56 +0,0 @@
1
- import {
2
- GuardConfig,
3
- ActiveTabs,
4
- GuardScenes,
5
- UserConfig,
6
- GuardEventsHandler,
7
- LocalesConfig,
8
- Lang,
9
- } from '../../AuthingGuard/types'
10
- import { AuthenticationClient } from 'authing-js-sdk'
11
- import { IBaseAction } from '../base'
12
- import { ApplicationMfaType } from '../../AuthingGuard/api/appConfig'
13
-
14
- export type IState = {
15
- config: GuardConfig // 处理后的 Guard 配置
16
- userConfig: UserConfig // 用户传入的配置
17
- authClient: AuthenticationClient
18
- activeTabs: ActiveTabs // 登录、注册方式
19
- guardScenes: GuardScenes // 当前在哪个界面
20
- guardTitle: string
21
- // 需要 mfa 登录时后端返回的错误信息
22
- mfaData: {
23
- mfaToken: string
24
- phone?: string
25
- email?: string
26
- applicationMfa?: {
27
- status: 0 | 1
28
- mfaPolicy: ApplicationMfaType
29
- sort: number
30
- }[]
31
- }
32
- userPoolId: string
33
- appId: string
34
- guardEvents: GuardEventsHandler
35
- localesConfig: LocalesConfig
36
- lang?: Lang
37
- realHost: string
38
- }
39
-
40
- const handlers: any = {
41
- // eslint-disable-next-line
42
- ['SET_VALUE']: (state: IState, payloads: any) => {
43
- return {
44
- ...state,
45
- [payloads.key]: payloads.value,
46
- }
47
- },
48
- }
49
-
50
- export const reducer = (state: IState, { type, ...payloads }: IBaseAction) => {
51
- const handler = handlers[type]
52
- if (handler) {
53
- return handler(state, payloads)
54
- }
55
- return state
56
- }
@@ -1,23 +0,0 @@
1
- import React, { FC } from 'react'
2
- import { GuardModuleType } from '../../Guard/module'
3
- import { createBaseContext } from '../base'
4
-
5
- export interface IModuleContext {
6
- module: string
7
- changeModule: React.Dispatch<GuardModuleType>
8
- setInitData: React.Dispatch<any>
9
- }
10
-
11
- const [Context, useBaseContext] = createBaseContext<IModuleContext>()
12
-
13
- export const useModule: () => IModuleContext = () => {
14
- const guardContext = useBaseContext()
15
-
16
- return guardContext
17
- }
18
-
19
- export const ModuleContext: FC<{
20
- value: IModuleContext
21
- }> = ({ children = null, value }) => {
22
- return <Context.Provider value={value}>{children}</Context.Provider>
23
- }
@@ -1,10 +0,0 @@
1
- import { AuthingGuard } from './AuthingGuard'
2
-
3
- export * from './AuthingGuard/types'
4
- export * from './AuthingGuard/hooks'
5
- export type { AuthenticationClientOptions } from 'authing-js-sdk'
6
-
7
- export { AuthingGuard }
8
-
9
- export type { GuardProps } from './Guard'
10
- export { default as Guard } from './Guard'
@@ -1,51 +0,0 @@
1
- /**
2
- * 全面提高 antd 样式优先级
3
- * https://juejin.cn/post/6844904116288749581#heading-8
4
- * https://github.com/fi3ework/postcss-rename-selector/blob/master/src/presets/antd.ts
5
- * */
6
-
7
- const parser = require('postcss-selector-parser')
8
-
9
- function antdScopeReplacerFn(node) {
10
- if (node.type !== 'selector') return
11
-
12
- const firstAntClassNodeIndex = node.nodes.findIndex((n) => {
13
- return n.type === 'class' && n.value.startsWith('authing-')
14
- })
15
- if (firstAntClassNodeIndex < 0) return
16
-
17
- const firstAntClassNode = node.nodes[firstAntClassNodeIndex]
18
- const prevNode = node.nodes[firstAntClassNodeIndex - 1]
19
-
20
- // preserve line break
21
- const spaces = {
22
- before: firstAntClassNode.rawSpaceBefore,
23
- after: firstAntClassNode.rawSpaceAfter,
24
- }
25
-
26
- firstAntClassNode.setPropertyWithoutEscape('rawSpaceBefore', '')
27
- const toInsert = []
28
-
29
- if (firstAntClassNodeIndex === 0 || prevNode.type === 'combinator') {
30
- const universal = parser.universal({
31
- value: '*',
32
- })
33
- toInsert.push(universal)
34
- }
35
-
36
- const attr = parser.attribute({
37
- attribute: 'class',
38
- operator: '*=',
39
- value: `"authing-"`,
40
- raws: {},
41
- })
42
-
43
- toInsert.push(attr)
44
- toInsert[0].spaces = spaces
45
-
46
- firstAntClassNode.parent.nodes.splice(firstAntClassNodeIndex, 0, ...toInsert)
47
- }
48
-
49
- module.exports = {
50
- antdScopeReplacerFn,
51
- }
package/config/env.js DELETED
@@ -1,104 +0,0 @@
1
- const fs = require('fs')
2
- const path = require('path')
3
- const paths = require('./paths')
4
-
5
- // Make sure that including paths.js after env.js will read .env variables.
6
- delete require.cache[require.resolve('./paths')]
7
-
8
- const NODE_ENV = process.env.NODE_ENV
9
- if (!NODE_ENV) {
10
- throw new Error(
11
- 'The NODE_ENV environment variable is required but was not specified.'
12
- )
13
- }
14
-
15
- // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
16
- const dotenvFiles = [
17
- `${paths.dotenv}.${NODE_ENV}.local`,
18
- // Don't include `.env.local` for `test` environment
19
- // since normally you expect tests to produce the same
20
- // results for everyone
21
- NODE_ENV !== 'test' && `${paths.dotenv}.local`,
22
- `${paths.dotenv}.${NODE_ENV}`,
23
- paths.dotenv,
24
- ].filter(Boolean)
25
-
26
- // Load environment variables from .env* files. Suppress warnings using silent
27
- // if this file is missing. dotenv will never modify any environment variables
28
- // that have already been set. Variable expansion is supported in .env files.
29
- // https://github.com/motdotla/dotenv
30
- // https://github.com/motdotla/dotenv-expand
31
- dotenvFiles.forEach((dotenvFile) => {
32
- if (fs.existsSync(dotenvFile)) {
33
- require('dotenv-expand')(
34
- require('dotenv').config({
35
- path: dotenvFile,
36
- })
37
- )
38
- }
39
- })
40
-
41
- // We support resolving modules according to `NODE_PATH`.
42
- // This lets you use absolute paths in imports inside large monorepos:
43
- // https://github.com/facebook/create-react-app/issues/253.
44
- // It works similar to `NODE_PATH` in Node itself:
45
- // https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
46
- // Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
47
- // Otherwise, we risk importing Node.js core modules into an app instead of webpack shims.
48
- // https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
49
- // We also resolve them to make sure all tools using them work consistently.
50
- const appDirectory = fs.realpathSync(process.cwd())
51
- process.env.NODE_PATH = (process.env.NODE_PATH || '')
52
- .split(path.delimiter)
53
- .filter((folder) => folder && !path.isAbsolute(folder))
54
- .map((folder) => path.resolve(appDirectory, folder))
55
- .join(path.delimiter)
56
-
57
- // Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
58
- // injected into the application via DefinePlugin in webpack configuration.
59
- const REACT_APP = /^REACT_APP_/i
60
-
61
- function getClientEnvironment(publicUrl) {
62
- const raw = Object.keys(process.env)
63
- .filter((key) => REACT_APP.test(key))
64
- .reduce(
65
- (env, key) => {
66
- env[key] = process.env[key]
67
- return env
68
- },
69
- {
70
- // Useful for determining whether we’re running in production mode.
71
- // Most importantly, it switches React into the correct mode.
72
- NODE_ENV: process.env.NODE_ENV || 'development',
73
- // Useful for resolving the correct path to static assets in `public`.
74
- // For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
75
- // This should only be used as an escape hatch. Normally you would put
76
- // images into the `src` and `import` them in code to get their paths.
77
- PUBLIC_URL: publicUrl,
78
- // We support configuring the sockjs pathname during development.
79
- // These settings let a developer run multiple simultaneous projects.
80
- // They are used as the connection `hostname`, `pathname` and `port`
81
- // in webpackHotDevClient. They are used as the `sockHost`, `sockPath`
82
- // and `sockPort` options in webpack-dev-server.
83
- WDS_SOCKET_HOST: process.env.WDS_SOCKET_HOST,
84
- WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH,
85
- WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT,
86
- // Whether or not react-refresh is enabled.
87
- // react-refresh is not 100% stable at this time,
88
- // which is why it's disabled by default.
89
- // It is defined here so it is available in the webpackHotDevClient.
90
- FAST_REFRESH: process.env.FAST_REFRESH !== 'false',
91
- }
92
- )
93
- // Stringify all values so we can feed into webpack DefinePlugin
94
- const stringified = {
95
- 'process.env': Object.keys(raw).reduce((env, key) => {
96
- env[key] = JSON.stringify(raw[key])
97
- return env
98
- }, {}),
99
- }
100
-
101
- return { raw, stringified }
102
- }
103
-
104
- module.exports = getClientEnvironment
@@ -1,66 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const crypto = require('crypto');
6
- const chalk = require('react-dev-utils/chalk');
7
- const paths = require('./paths');
8
-
9
- // Ensure the certificate and key provided are valid and if not
10
- // throw an easy to debug error
11
- function validateKeyAndCerts({ cert, key, keyFile, crtFile }) {
12
- let encrypted;
13
- try {
14
- // publicEncrypt will throw an error with an invalid cert
15
- encrypted = crypto.publicEncrypt(cert, Buffer.from('test'));
16
- } catch (err) {
17
- throw new Error(
18
- `The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}`
19
- );
20
- }
21
-
22
- try {
23
- // privateDecrypt will throw an error with an invalid key
24
- crypto.privateDecrypt(key, encrypted);
25
- } catch (err) {
26
- throw new Error(
27
- `The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${
28
- err.message
29
- }`
30
- );
31
- }
32
- }
33
-
34
- // Read file and throw an error if it doesn't exist
35
- function readEnvFile(file, type) {
36
- if (!fs.existsSync(file)) {
37
- throw new Error(
38
- `You specified ${chalk.cyan(
39
- type
40
- )} in your env, but the file "${chalk.yellow(file)}" can't be found.`
41
- );
42
- }
43
- return fs.readFileSync(file);
44
- }
45
-
46
- // Get the https config
47
- // Return cert files if provided in env, otherwise just true or false
48
- function getHttpsConfig() {
49
- const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env;
50
- const isHttps = HTTPS === 'true';
51
-
52
- if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) {
53
- const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE);
54
- const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE);
55
- const config = {
56
- cert: readEnvFile(crtFile, 'SSL_CRT_FILE'),
57
- key: readEnvFile(keyFile, 'SSL_KEY_FILE'),
58
- };
59
-
60
- validateKeyAndCerts({ ...config, keyFile, crtFile });
61
- return config;
62
- }
63
- return isHttps;
64
- }
65
-
66
- module.exports = getHttpsConfig;
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- // This is a custom Jest transformer turning style imports into empty objects.
4
- // http://facebook.github.io/jest/docs/en/webpack.html
5
-
6
- module.exports = {
7
- process() {
8
- return 'module.exports = {};';
9
- },
10
- getCacheKey() {
11
- // The output is always the same.
12
- return 'cssTransform';
13
- },
14
- };
@@ -1,40 +0,0 @@
1
- 'use strict';
2
-
3
- const path = require('path');
4
- const camelcase = require('camelcase');
5
-
6
- // This is a custom Jest transformer turning file imports into filenames.
7
- // http://facebook.github.io/jest/docs/en/webpack.html
8
-
9
- module.exports = {
10
- process(src, filename) {
11
- const assetFilename = JSON.stringify(path.basename(filename));
12
-
13
- if (filename.match(/\.svg$/)) {
14
- // Based on how SVGR generates a component name:
15
- // https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6
16
- const pascalCaseFilename = camelcase(path.parse(filename).name, {
17
- pascalCase: true,
18
- });
19
- const componentName = `Svg${pascalCaseFilename}`;
20
- return `const React = require('react');
21
- module.exports = {
22
- __esModule: true,
23
- default: ${assetFilename},
24
- ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
25
- return {
26
- $$typeof: Symbol.for('react.element'),
27
- type: 'svg',
28
- ref: ref,
29
- key: null,
30
- props: Object.assign({}, props, {
31
- children: ${assetFilename}
32
- })
33
- };
34
- }),
35
- };`;
36
- }
37
-
38
- return `module.exports = ${assetFilename};`;
39
- },
40
- };
package/config/modules.js DELETED
@@ -1,134 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const paths = require('./paths');
6
- const chalk = require('react-dev-utils/chalk');
7
- const resolve = require('resolve');
8
-
9
- /**
10
- * Get additional module paths based on the baseUrl of a compilerOptions object.
11
- *
12
- * @param {Object} options
13
- */
14
- function getAdditionalModulePaths(options = {}) {
15
- const baseUrl = options.baseUrl;
16
-
17
- if (!baseUrl) {
18
- return '';
19
- }
20
-
21
- const baseUrlResolved = path.resolve(paths.appPath, baseUrl);
22
-
23
- // We don't need to do anything if `baseUrl` is set to `node_modules`. This is
24
- // the default behavior.
25
- if (path.relative(paths.appNodeModules, baseUrlResolved) === '') {
26
- return null;
27
- }
28
-
29
- // Allow the user set the `baseUrl` to `appSrc`.
30
- if (path.relative(paths.appSrc, baseUrlResolved) === '') {
31
- return [paths.appSrc];
32
- }
33
-
34
- // If the path is equal to the root directory we ignore it here.
35
- // We don't want to allow importing from the root directly as source files are
36
- // not transpiled outside of `src`. We do allow importing them with the
37
- // absolute path (e.g. `src/Components/Button.js`) but we set that up with
38
- // an alias.
39
- if (path.relative(paths.appPath, baseUrlResolved) === '') {
40
- return null;
41
- }
42
-
43
- // Otherwise, throw an error.
44
- throw new Error(
45
- chalk.red.bold(
46
- "Your project's `baseUrl` can only be set to `src` or `node_modules`." +
47
- ' Create React App does not support other values at this time.'
48
- )
49
- );
50
- }
51
-
52
- /**
53
- * Get webpack aliases based on the baseUrl of a compilerOptions object.
54
- *
55
- * @param {*} options
56
- */
57
- function getWebpackAliases(options = {}) {
58
- const baseUrl = options.baseUrl;
59
-
60
- if (!baseUrl) {
61
- return {};
62
- }
63
-
64
- const baseUrlResolved = path.resolve(paths.appPath, baseUrl);
65
-
66
- if (path.relative(paths.appPath, baseUrlResolved) === '') {
67
- return {
68
- src: paths.appSrc,
69
- };
70
- }
71
- }
72
-
73
- /**
74
- * Get jest aliases based on the baseUrl of a compilerOptions object.
75
- *
76
- * @param {*} options
77
- */
78
- function getJestAliases(options = {}) {
79
- const baseUrl = options.baseUrl;
80
-
81
- if (!baseUrl) {
82
- return {};
83
- }
84
-
85
- const baseUrlResolved = path.resolve(paths.appPath, baseUrl);
86
-
87
- if (path.relative(paths.appPath, baseUrlResolved) === '') {
88
- return {
89
- '^src/(.*)$': '<rootDir>/src/$1',
90
- };
91
- }
92
- }
93
-
94
- function getModules() {
95
- // Check if TypeScript is setup
96
- const hasTsConfig = fs.existsSync(paths.appTsConfig);
97
- const hasJsConfig = fs.existsSync(paths.appJsConfig);
98
-
99
- if (hasTsConfig && hasJsConfig) {
100
- throw new Error(
101
- 'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.'
102
- );
103
- }
104
-
105
- let config;
106
-
107
- // If there's a tsconfig.json we assume it's a
108
- // TypeScript project and set up the config
109
- // based on tsconfig.json
110
- if (hasTsConfig) {
111
- const ts = require(resolve.sync('typescript', {
112
- basedir: paths.appNodeModules,
113
- }));
114
- config = ts.readConfigFile(paths.appTsConfig, ts.sys.readFile).config;
115
- // Otherwise we'll check if there is jsconfig.json
116
- // for non TS projects.
117
- } else if (hasJsConfig) {
118
- config = require(paths.appJsConfig);
119
- }
120
-
121
- config = config || {};
122
- const options = config.compilerOptions || {};
123
-
124
- const additionalModulePaths = getAdditionalModulePaths(options);
125
-
126
- return {
127
- additionalModulePaths: additionalModulePaths,
128
- webpackAliases: getWebpackAliases(options),
129
- jestAliases: getJestAliases(options),
130
- hasTsConfig,
131
- };
132
- }
133
-
134
- module.exports = getModules();
package/config/paths.js DELETED
@@ -1,71 +0,0 @@
1
- const path = require('path')
2
- const fs = require('fs')
3
- const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath')
4
-
5
- // Make sure any symlinks in the project folder are resolved:
6
- // https://github.com/facebook/create-react-app/issues/637
7
- const appDirectory = fs.realpathSync(process.cwd())
8
- const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath)
9
-
10
- // We use `PUBLIC_URL` environment variable or "homepage" field to infer
11
- // "public path" at which the app is served.
12
- // webpack needs to know it to put the right <script> hrefs into HTML even in
13
- // single-page apps that may serve index.html for nested URLs like /todos/42.
14
- // We can't use a relative path in HTML because we don't want to load something
15
- // like /todos/42/static/js/bundle.7289d.js. We have to know the root.
16
- const publicUrlOrPath = getPublicUrlOrPath(
17
- process.env.NODE_ENV === 'development',
18
- require(resolveApp('package.json')).homepage,
19
- process.env.PUBLIC_URL
20
- )
21
-
22
- const moduleFileExtensions = [
23
- 'web.mjs',
24
- 'mjs',
25
- 'web.js',
26
- 'js',
27
- 'web.ts',
28
- 'ts',
29
- 'web.tsx',
30
- 'tsx',
31
- 'json',
32
- 'web.jsx',
33
- 'jsx',
34
- ]
35
-
36
- // Resolve file paths in the same order as webpack
37
- const resolveModule = (resolveFn, filePath) => {
38
- const extension = moduleFileExtensions.find((extension) =>
39
- fs.existsSync(resolveFn(`${filePath}.${extension}`))
40
- )
41
-
42
- if (extension) {
43
- return resolveFn(`${filePath}.${extension}`)
44
- }
45
-
46
- return resolveFn(`${filePath}.js`)
47
- }
48
-
49
- // config after eject: we're in ./config/
50
- module.exports = {
51
- dotenv: resolveApp('.env'),
52
- appPath: resolveApp('.'),
53
- appBuild: resolveApp('build'),
54
- appPublic: resolveApp('public'),
55
- appHtml: resolveApp('public/index.html'),
56
- appIndexJs: resolveModule(resolveApp, 'examples'),
57
- appPackageJson: resolveApp('package.json'),
58
- appSrc: resolveApp(''),
59
- appTsConfig: resolveApp('tsconfig.json'),
60
- appJsConfig: resolveApp('jsconfig.json'),
61
- yarnLockFile: resolveApp('yarn.lock'),
62
- testsSetup: resolveModule(resolveApp, 'src/setupTests'),
63
- proxySetup: resolveApp('src/setupProxy.js'),
64
- appNodeModules: resolveApp('node_modules'),
65
- swSrc: resolveModule(resolveApp, 'src/service-worker'),
66
- componentsIndexJs: resolveApp('components/index'),
67
- libBuild: resolveApp('lib'),
68
- publicUrlOrPath,
69
- }
70
-
71
- module.exports.moduleFileExtensions = moduleFileExtensions