11import propTypes from "prop-types" ;
22import { WeakValidationMap , useEffect , useMemo } from "react" ;
3-
4- import {
5- PyConfigInterpreters ,
6- PyConfigSplashscreen ,
7- } from "~root/source/library/components/py-config/py-config.types" ;
8-
93import type {
104 PyConfigFetch ,
5+ PyConfigFetchItem ,
6+ PyConfigInterpreters ,
117 PyConfigProperties ,
128 PyConfigPropertiesBase ,
9+ PyConfigSplashscreen ,
1310 PyConfigTag ,
1411} from "./py-config.types" ;
1512
@@ -54,10 +51,6 @@ const PyConfig: PyConfigTag = <T extends object>({
5451 // eslint-disable-next-line sonarjs/cognitive-complexity
5552 const config : string = useMemo ( ( ) : string => {
5653 if ( type === "json" ) {
57- const transformedFiles : string [ ] = [
58- ...( fetch ?. files || [ ] ) ,
59- ...( children ?. fetch ?. files || [ ] ) ,
60- ] ;
6154 const transformedPlugins : string [ ] = [
6255 ...( plugins || [ ] ) ,
6356 ...( children ?. plugins || [ ] ) ,
@@ -66,10 +59,16 @@ const PyConfig: PyConfigTag = <T extends object>({
6659 ...( packages || [ ] ) ,
6760 ...( children ?. packages || [ ] ) ,
6861 ] ;
69- const transformedFetch : PyConfigFetch = {
70- files : transformedFiles . length ? transformedFiles : undefined ,
71- ...children ?. fetch ,
72- } ;
62+ const transformedFetch : PyConfigFetch = [
63+ ...( fetch || [ ] ) ,
64+ ...( children ?. fetch || [ ] ) ,
65+ ] . map ( ( { files, ...restItem } : PyConfigFetchItem ) : PyConfigFetchItem => {
66+ const transformedFiles : string [ ] = [ ...( files || [ ] ) ] ;
67+ return {
68+ files : transformedFiles . length ? transformedFiles : undefined ,
69+ ...restItem ,
70+ } ;
71+ } ) ;
7372 const transformedInterpreters : Omit < PyConfigInterpreters , "source" > & {
7473 src ?: string ;
7574 } = {
@@ -89,7 +88,7 @@ const PyConfig: PyConfigTag = <T extends object>({
8988 interpreters : checkForAnyKey ( transformedInterpreters )
9089 ? transformedInterpreters
9190 : undefined ,
92- fetch : checkForAnyKey ( transformedFetch ) ? transformedFetch : undefined ,
91+ fetch : transformedFetch . length ? transformedFetch : undefined ,
9392 packages : transformedPackages . length ? transformedPackages : undefined ,
9493 plugins : transformedPlugins . length ? transformedPlugins : undefined ,
9594 ...children ,
@@ -127,10 +126,18 @@ PyConfig.propTypes = {
127126 name : propTypes . string ,
128127 language : propTypes . string ,
129128 } ) ,
130- fetch : propTypes . shape ( {
131- files : propTypes . arrayOf ( propTypes . string ) ,
132- } ) ,
133- packages : propTypes . arrayOf ( propTypes . string ) ,
129+ fetch : propTypes . arrayOf (
130+ propTypes . shape ( {
131+ files : propTypes . oneOfType ( [
132+ propTypes . arrayOf ( propTypes . string ) ,
133+ propTypes . instanceOf ( Set ) ,
134+ ] ) ,
135+ } ) ,
136+ ) ,
137+ packages : propTypes . oneOfType ( [
138+ propTypes . arrayOf ( propTypes . string ) ,
139+ propTypes . instanceOf ( Set ) ,
140+ ] ) ,
134141 plugins : propTypes . arrayOf ( propTypes . string ) ,
135142} as WeakValidationMap < PyConfigPropertiesBase > ;
136143
0 commit comments