1
- import { isDevelopmentEnvironment } from '@clerk/shared' ;
2
- import type { CustomPage } from '@clerk/types' ;
1
+ import type { CustomPage , LoadedClerk } from '@clerk/types' ;
3
2
4
3
import { isValidUrl } from '../../utils' ;
5
4
import { ORGANIZATION_PROFILE_NAVBAR_ROUTE_ID , USER_PROFILE_NAVBAR_ROUTE_ID } from '../constants' ;
6
5
import type { NavbarRoute } from '../elements' ;
7
6
import { Organization , TickShield , User , Users } from '../icons' ;
8
7
import { localizationKeys } from '../localization' ;
9
8
import { ExternalElementMounter } from './ExternalElementMounter' ;
9
+ import { isDevelopmentSDK } from './runtimeEnvironment' ;
10
10
11
11
export type CustomPageContent = {
12
12
url : string ;
@@ -47,39 +47,43 @@ type CreateCustomPagesParams = {
47
47
excludedPathsFromDuplicateWarning : string [ ] ;
48
48
} ;
49
49
50
- export const createUserProfileCustomPages = ( customPages : CustomPage [ ] ) => {
51
- return createCustomPages ( {
52
- customPages,
53
- getDefaultRoutes : getUserProfileDefaultRoutes ,
54
- setFirstPathToRoot : setFirstPathToUserProfileRoot ,
55
- excludedPathsFromDuplicateWarning : [ ] ,
56
- } ) ;
50
+ export const createUserProfileCustomPages = ( customPages : CustomPage [ ] , clerk : LoadedClerk ) => {
51
+ return createCustomPages (
52
+ {
53
+ customPages,
54
+ getDefaultRoutes : getUserProfileDefaultRoutes ,
55
+ setFirstPathToRoot : setFirstPathToUserProfileRoot ,
56
+ excludedPathsFromDuplicateWarning : [ ] ,
57
+ } ,
58
+ clerk ,
59
+ ) ;
57
60
} ;
58
61
59
- export const createOrganizationProfileCustomPages = ( customPages : CustomPage [ ] ) => {
60
- return createCustomPages ( {
61
- customPages,
62
- getDefaultRoutes : getOrganizationProfileDefaultRoutes ,
63
- setFirstPathToRoot : setFirstPathToOrganizationProfileRoot ,
64
- excludedPathsFromDuplicateWarning : [ ] ,
65
- } ) ;
62
+ export const createOrganizationProfileCustomPages = ( customPages : CustomPage [ ] , clerk : LoadedClerk ) => {
63
+ return createCustomPages (
64
+ {
65
+ customPages,
66
+ getDefaultRoutes : getOrganizationProfileDefaultRoutes ,
67
+ setFirstPathToRoot : setFirstPathToOrganizationProfileRoot ,
68
+ excludedPathsFromDuplicateWarning : [ ] ,
69
+ } ,
70
+ clerk ,
71
+ ) ;
66
72
} ;
67
73
68
- const createCustomPages = ( {
69
- customPages,
70
- getDefaultRoutes,
71
- setFirstPathToRoot,
72
- excludedPathsFromDuplicateWarning,
73
- } : CreateCustomPagesParams ) => {
74
+ const createCustomPages = (
75
+ { customPages, getDefaultRoutes, setFirstPathToRoot, excludedPathsFromDuplicateWarning } : CreateCustomPagesParams ,
76
+ clerk : LoadedClerk ,
77
+ ) => {
74
78
const { INITIAL_ROUTES , pageToRootNavbarRouteMap, validReorderItemLabels } = getDefaultRoutes ( ) ;
75
79
76
- if ( isDevelopmentEnvironment ( ) ) {
80
+ if ( isDevelopmentSDK ( clerk ) ) {
77
81
checkForDuplicateUsageOfReorderingItems ( customPages , validReorderItemLabels ) ;
78
82
}
79
83
80
84
const validCustomPages = customPages . filter ( cp => {
81
85
if ( ! isValidPageItem ( cp , validReorderItemLabels ) ) {
82
- if ( isDevelopmentEnvironment ( ) ) {
86
+ if ( isDevelopmentSDK ( clerk ) ) {
83
87
console . error ( 'Clerk: Invalid custom page data: ' , cp ) ;
84
88
}
85
89
return false ;
@@ -96,7 +100,7 @@ const createCustomPages = ({
96
100
97
101
const routes = setFirstPathToRoot ( allRoutes ) ;
98
102
99
- if ( isDevelopmentEnvironment ( ) ) {
103
+ if ( isDevelopmentSDK ( clerk ) ) {
100
104
warnForDuplicatePaths ( routes , excludedPathsFromDuplicateWarning ) ;
101
105
}
102
106
0 commit comments