react-dom-server-legacy.node.development.js 240 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078
  1. /**
  2. * @license React
  3. * react-dom-server-legacy.node.development.js
  4. *
  5. * Copyright (c) Facebook, Inc. and its affiliates.
  6. *
  7. * This source code is licensed under the MIT license found in the
  8. * LICENSE file in the root directory of this source tree.
  9. */
  10. 'use strict';
  11. if (process.env.NODE_ENV !== "production") {
  12. (function() {
  13. 'use strict';
  14. var React = require('react');
  15. var stream = require('stream');
  16. var ReactVersion = '18.2.0';
  17. var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
  18. // by calls to these methods by a Babel plugin.
  19. //
  20. // In PROD (or in packages without access to React internals),
  21. // they are left as they are instead.
  22. function warn(format) {
  23. {
  24. {
  25. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  26. args[_key - 1] = arguments[_key];
  27. }
  28. printWarning('warn', format, args);
  29. }
  30. }
  31. }
  32. function error(format) {
  33. {
  34. {
  35. for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  36. args[_key2 - 1] = arguments[_key2];
  37. }
  38. printWarning('error', format, args);
  39. }
  40. }
  41. }
  42. function printWarning(level, format, args) {
  43. // When changing this logic, you might want to also
  44. // update consoleWithStackDev.www.js as well.
  45. {
  46. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  47. var stack = ReactDebugCurrentFrame.getStackAddendum();
  48. if (stack !== '') {
  49. format += '%s';
  50. args = args.concat([stack]);
  51. } // eslint-disable-next-line react-internal/safe-string-coercion
  52. var argsWithFormat = args.map(function (item) {
  53. return String(item);
  54. }); // Careful: RN currently depends on this prefix
  55. argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
  56. // breaks IE9: https://github.com/facebook/react/issues/13610
  57. // eslint-disable-next-line react-internal/no-production-logging
  58. Function.prototype.apply.call(console[level], console, argsWithFormat);
  59. }
  60. }
  61. function scheduleWork(callback) {
  62. callback();
  63. }
  64. function beginWriting(destination) {}
  65. function writeChunk(destination, chunk) {
  66. writeChunkAndReturn(destination, chunk);
  67. }
  68. function writeChunkAndReturn(destination, chunk) {
  69. return destination.push(chunk);
  70. }
  71. function completeWriting(destination) {}
  72. function close(destination) {
  73. destination.push(null);
  74. }
  75. function stringToChunk(content) {
  76. return content;
  77. }
  78. function stringToPrecomputedChunk(content) {
  79. return content;
  80. }
  81. function closeWithError(destination, error) {
  82. // $FlowFixMe: This is an Error object or the destination accepts other types.
  83. destination.destroy(error);
  84. }
  85. /*
  86. * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol
  87. * and Temporal.* types. See https://github.com/facebook/react/pull/22064.
  88. *
  89. * The functions in this module will throw an easier-to-understand,
  90. * easier-to-debug exception with a clear errors message message explaining the
  91. * problem. (Instead of a confusing exception thrown inside the implementation
  92. * of the `value` object).
  93. */
  94. // $FlowFixMe only called in DEV, so void return is not possible.
  95. function typeName(value) {
  96. {
  97. // toStringTag is needed for namespaced types like Temporal.Instant
  98. var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
  99. var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';
  100. return type;
  101. }
  102. } // $FlowFixMe only called in DEV, so void return is not possible.
  103. function willCoercionThrow(value) {
  104. {
  105. try {
  106. testStringCoercion(value);
  107. return false;
  108. } catch (e) {
  109. return true;
  110. }
  111. }
  112. }
  113. function testStringCoercion(value) {
  114. // If you ended up here by following an exception call stack, here's what's
  115. // happened: you supplied an object or symbol value to React (as a prop, key,
  116. // DOM attribute, CSS property, string ref, etc.) and when React tried to
  117. // coerce it to a string using `'' + value`, an exception was thrown.
  118. //
  119. // The most common types that will cause this exception are `Symbol` instances
  120. // and Temporal objects like `Temporal.Instant`. But any object that has a
  121. // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
  122. // exception. (Library authors do this to prevent users from using built-in
  123. // numeric operators like `+` or comparison operators like `>=` because custom
  124. // methods are needed to perform accurate arithmetic or comparison.)
  125. //
  126. // To fix the problem, coerce this object or symbol value to a string before
  127. // passing it to React. The most reliable way is usually `String(value)`.
  128. //
  129. // To find which value is throwing, check the browser or debugger console.
  130. // Before this exception was thrown, there should be `console.error` output
  131. // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
  132. // problem and how that type was used: key, atrribute, input value prop, etc.
  133. // In most cases, this console output also shows the component and its
  134. // ancestor components where the exception happened.
  135. //
  136. // eslint-disable-next-line react-internal/safe-string-coercion
  137. return '' + value;
  138. }
  139. function checkAttributeStringCoercion(value, attributeName) {
  140. {
  141. if (willCoercionThrow(value)) {
  142. error('The provided `%s` attribute is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', attributeName, typeName(value));
  143. return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
  144. }
  145. }
  146. }
  147. function checkCSSPropertyStringCoercion(value, propName) {
  148. {
  149. if (willCoercionThrow(value)) {
  150. error('The provided `%s` CSS property is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', propName, typeName(value));
  151. return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
  152. }
  153. }
  154. }
  155. function checkHtmlStringCoercion(value) {
  156. {
  157. if (willCoercionThrow(value)) {
  158. error('The provided HTML markup uses a value of unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));
  159. return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
  160. }
  161. }
  162. }
  163. var hasOwnProperty = Object.prototype.hasOwnProperty;
  164. // A reserved attribute.
  165. // It is handled by React separately and shouldn't be written to the DOM.
  166. var RESERVED = 0; // A simple string attribute.
  167. // Attributes that aren't in the filter are presumed to have this type.
  168. var STRING = 1; // A string attribute that accepts booleans in React. In HTML, these are called
  169. // "enumerated" attributes with "true" and "false" as possible values.
  170. // When true, it should be set to a "true" string.
  171. // When false, it should be set to a "false" string.
  172. var BOOLEANISH_STRING = 2; // A real boolean attribute.
  173. // When true, it should be present (set either to an empty string or its name).
  174. // When false, it should be omitted.
  175. var BOOLEAN = 3; // An attribute that can be used as a flag as well as with a value.
  176. // When true, it should be present (set either to an empty string or its name).
  177. // When false, it should be omitted.
  178. // For any other value, should be present with that value.
  179. var OVERLOADED_BOOLEAN = 4; // An attribute that must be numeric or parse as a numeric.
  180. // When falsy, it should be removed.
  181. var NUMERIC = 5; // An attribute that must be positive numeric or parse as a positive numeric.
  182. // When falsy, it should be removed.
  183. var POSITIVE_NUMERIC = 6;
  184. /* eslint-disable max-len */
  185. var ATTRIBUTE_NAME_START_CHAR = ":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
  186. /* eslint-enable max-len */
  187. var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
  188. var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$');
  189. var illegalAttributeNameCache = {};
  190. var validatedAttributeNameCache = {};
  191. function isAttributeNameSafe(attributeName) {
  192. if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) {
  193. return true;
  194. }
  195. if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) {
  196. return false;
  197. }
  198. if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
  199. validatedAttributeNameCache[attributeName] = true;
  200. return true;
  201. }
  202. illegalAttributeNameCache[attributeName] = true;
  203. {
  204. error('Invalid attribute name: `%s`', attributeName);
  205. }
  206. return false;
  207. }
  208. function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) {
  209. if (propertyInfo !== null && propertyInfo.type === RESERVED) {
  210. return false;
  211. }
  212. switch (typeof value) {
  213. case 'function': // $FlowIssue symbol is perfectly valid here
  214. case 'symbol':
  215. // eslint-disable-line
  216. return true;
  217. case 'boolean':
  218. {
  219. if (isCustomComponentTag) {
  220. return false;
  221. }
  222. if (propertyInfo !== null) {
  223. return !propertyInfo.acceptsBooleans;
  224. } else {
  225. var prefix = name.toLowerCase().slice(0, 5);
  226. return prefix !== 'data-' && prefix !== 'aria-';
  227. }
  228. }
  229. default:
  230. return false;
  231. }
  232. }
  233. function getPropertyInfo(name) {
  234. return properties.hasOwnProperty(name) ? properties[name] : null;
  235. }
  236. function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL, removeEmptyString) {
  237. this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN;
  238. this.attributeName = attributeName;
  239. this.attributeNamespace = attributeNamespace;
  240. this.mustUseProperty = mustUseProperty;
  241. this.propertyName = name;
  242. this.type = type;
  243. this.sanitizeURL = sanitizeURL;
  244. this.removeEmptyString = removeEmptyString;
  245. } // When adding attributes to this list, be sure to also add them to
  246. // the `possibleStandardNames` module to ensure casing and incorrect
  247. // name warnings.
  248. var properties = {}; // These props are reserved by React. They shouldn't be written to the DOM.
  249. var reservedProps = ['children', 'dangerouslySetInnerHTML', // TODO: This prevents the assignment of defaultValue to regular
  250. // elements (not just inputs). Now that ReactDOMInput assigns to the
  251. // defaultValue property -- do we need this?
  252. 'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style'];
  253. reservedProps.forEach(function (name) {
  254. properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty
  255. name, // attributeName
  256. null, // attributeNamespace
  257. false, // sanitizeURL
  258. false);
  259. }); // A few React string attributes have a different name.
  260. // This is a mapping from React prop names to the attribute names.
  261. [['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) {
  262. var name = _ref[0],
  263. attributeName = _ref[1];
  264. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  265. attributeName, // attributeName
  266. null, // attributeNamespace
  267. false, // sanitizeURL
  268. false);
  269. }); // These are "enumerated" HTML attributes that accept "true" and "false".
  270. // In React, we let users pass `true` and `false` even though technically
  271. // these aren't boolean attributes (they are coerced to strings).
  272. ['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) {
  273. properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
  274. name.toLowerCase(), // attributeName
  275. null, // attributeNamespace
  276. false, // sanitizeURL
  277. false);
  278. }); // These are "enumerated" SVG attributes that accept "true" and "false".
  279. // In React, we let users pass `true` and `false` even though technically
  280. // these aren't boolean attributes (they are coerced to strings).
  281. // Since these are SVG attributes, their attribute names are case-sensitive.
  282. ['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) {
  283. properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
  284. name, // attributeName
  285. null, // attributeNamespace
  286. false, // sanitizeURL
  287. false);
  288. }); // These are HTML boolean attributes.
  289. ['allowFullScreen', 'async', // Note: there is a special case that prevents it from being written to the DOM
  290. // on the client side because the browsers are inconsistent. Instead we call focus().
  291. 'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'disableRemotePlayback', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', // Microdata
  292. 'itemScope'].forEach(function (name) {
  293. properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty
  294. name.toLowerCase(), // attributeName
  295. null, // attributeNamespace
  296. false, // sanitizeURL
  297. false);
  298. }); // These are the few React props that we set as DOM properties
  299. // rather than attributes. These are all booleans.
  300. ['checked', // Note: `option.selected` is not updated if `select.multiple` is
  301. // disabled with `removeAttribute`. We have special logic for handling this.
  302. 'multiple', 'muted', 'selected' // NOTE: if you add a camelCased prop to this list,
  303. // you'll need to set attributeName to name.toLowerCase()
  304. // instead in the assignment below.
  305. ].forEach(function (name) {
  306. properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty
  307. name, // attributeName
  308. null, // attributeNamespace
  309. false, // sanitizeURL
  310. false);
  311. }); // These are HTML attributes that are "overloaded booleans": they behave like
  312. // booleans, but can also accept a string value.
  313. ['capture', 'download' // NOTE: if you add a camelCased prop to this list,
  314. // you'll need to set attributeName to name.toLowerCase()
  315. // instead in the assignment below.
  316. ].forEach(function (name) {
  317. properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty
  318. name, // attributeName
  319. null, // attributeNamespace
  320. false, // sanitizeURL
  321. false);
  322. }); // These are HTML attributes that must be positive numbers.
  323. ['cols', 'rows', 'size', 'span' // NOTE: if you add a camelCased prop to this list,
  324. // you'll need to set attributeName to name.toLowerCase()
  325. // instead in the assignment below.
  326. ].forEach(function (name) {
  327. properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty
  328. name, // attributeName
  329. null, // attributeNamespace
  330. false, // sanitizeURL
  331. false);
  332. }); // These are HTML attributes that must be numbers.
  333. ['rowSpan', 'start'].forEach(function (name) {
  334. properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty
  335. name.toLowerCase(), // attributeName
  336. null, // attributeNamespace
  337. false, // sanitizeURL
  338. false);
  339. });
  340. var CAMELIZE = /[\-\:]([a-z])/g;
  341. var capitalize = function (token) {
  342. return token[1].toUpperCase();
  343. }; // This is a list of all SVG attributes that need special casing, namespacing,
  344. // or boolean value assignment. Regular attributes that just accept strings
  345. // and have the same names are omitted, just like in the HTML attribute filter.
  346. // Some of these attributes can be hard to find. This list was created by
  347. // scraping the MDN documentation.
  348. ['accent-height', 'alignment-baseline', 'arabic-form', 'baseline-shift', 'cap-height', 'clip-path', 'clip-rule', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'dominant-baseline', 'enable-background', 'fill-opacity', 'fill-rule', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-name', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'horiz-adv-x', 'horiz-origin-x', 'image-rendering', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start', 'overline-position', 'overline-thickness', 'paint-order', 'panose-1', 'pointer-events', 'rendering-intent', 'shape-rendering', 'stop-color', 'stop-opacity', 'strikethrough-position', 'strikethrough-thickness', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-decoration', 'text-rendering', 'underline-position', 'underline-thickness', 'unicode-bidi', 'unicode-range', 'units-per-em', 'v-alphabetic', 'v-hanging', 'v-ideographic', 'v-mathematical', 'vector-effect', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'word-spacing', 'writing-mode', 'xmlns:xlink', 'x-height' // NOTE: if you add a camelCased prop to this list,
  349. // you'll need to set attributeName to name.toLowerCase()
  350. // instead in the assignment below.
  351. ].forEach(function (attributeName) {
  352. var name = attributeName.replace(CAMELIZE, capitalize);
  353. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  354. attributeName, null, // attributeNamespace
  355. false, // sanitizeURL
  356. false);
  357. }); // String SVG attributes with the xlink namespace.
  358. ['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type' // NOTE: if you add a camelCased prop to this list,
  359. // you'll need to set attributeName to name.toLowerCase()
  360. // instead in the assignment below.
  361. ].forEach(function (attributeName) {
  362. var name = attributeName.replace(CAMELIZE, capitalize);
  363. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  364. attributeName, 'http://www.w3.org/1999/xlink', false, // sanitizeURL
  365. false);
  366. }); // String SVG attributes with the xml namespace.
  367. ['xml:base', 'xml:lang', 'xml:space' // NOTE: if you add a camelCased prop to this list,
  368. // you'll need to set attributeName to name.toLowerCase()
  369. // instead in the assignment below.
  370. ].forEach(function (attributeName) {
  371. var name = attributeName.replace(CAMELIZE, capitalize);
  372. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  373. attributeName, 'http://www.w3.org/XML/1998/namespace', false, // sanitizeURL
  374. false);
  375. }); // These attribute exists both in HTML and SVG.
  376. // The attribute name is case-sensitive in SVG so we can't just use
  377. // the React name like we do for attributes that exist only in HTML.
  378. ['tabIndex', 'crossOrigin'].forEach(function (attributeName) {
  379. properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
  380. attributeName.toLowerCase(), // attributeName
  381. null, // attributeNamespace
  382. false, // sanitizeURL
  383. false);
  384. }); // These attributes accept URLs. These must not allow javascript: URLS.
  385. // These will also need to accept Trusted Types object in the future.
  386. var xlinkHref = 'xlinkHref';
  387. properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty
  388. 'xlink:href', 'http://www.w3.org/1999/xlink', true, // sanitizeURL
  389. false);
  390. ['src', 'href', 'action', 'formAction'].forEach(function (attributeName) {
  391. properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
  392. attributeName.toLowerCase(), // attributeName
  393. null, // attributeNamespace
  394. true, // sanitizeURL
  395. true);
  396. });
  397. /**
  398. * CSS properties which accept numbers but are not in units of "px".
  399. */
  400. var isUnitlessNumber = {
  401. animationIterationCount: true,
  402. aspectRatio: true,
  403. borderImageOutset: true,
  404. borderImageSlice: true,
  405. borderImageWidth: true,
  406. boxFlex: true,
  407. boxFlexGroup: true,
  408. boxOrdinalGroup: true,
  409. columnCount: true,
  410. columns: true,
  411. flex: true,
  412. flexGrow: true,
  413. flexPositive: true,
  414. flexShrink: true,
  415. flexNegative: true,
  416. flexOrder: true,
  417. gridArea: true,
  418. gridRow: true,
  419. gridRowEnd: true,
  420. gridRowSpan: true,
  421. gridRowStart: true,
  422. gridColumn: true,
  423. gridColumnEnd: true,
  424. gridColumnSpan: true,
  425. gridColumnStart: true,
  426. fontWeight: true,
  427. lineClamp: true,
  428. lineHeight: true,
  429. opacity: true,
  430. order: true,
  431. orphans: true,
  432. tabSize: true,
  433. widows: true,
  434. zIndex: true,
  435. zoom: true,
  436. // SVG-related properties
  437. fillOpacity: true,
  438. floodOpacity: true,
  439. stopOpacity: true,
  440. strokeDasharray: true,
  441. strokeDashoffset: true,
  442. strokeMiterlimit: true,
  443. strokeOpacity: true,
  444. strokeWidth: true
  445. };
  446. /**
  447. * @param {string} prefix vendor-specific prefix, eg: Webkit
  448. * @param {string} key style name, eg: transitionDuration
  449. * @return {string} style name prefixed with `prefix`, properly camelCased, eg:
  450. * WebkitTransitionDuration
  451. */
  452. function prefixKey(prefix, key) {
  453. return prefix + key.charAt(0).toUpperCase() + key.substring(1);
  454. }
  455. /**
  456. * Support style names that may come passed in prefixed by adding permutations
  457. * of vendor prefixes.
  458. */
  459. var prefixes = ['Webkit', 'ms', 'Moz', 'O']; // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
  460. // infinite loop, because it iterates over the newly added props too.
  461. Object.keys(isUnitlessNumber).forEach(function (prop) {
  462. prefixes.forEach(function (prefix) {
  463. isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
  464. });
  465. });
  466. var hasReadOnlyValue = {
  467. button: true,
  468. checkbox: true,
  469. image: true,
  470. hidden: true,
  471. radio: true,
  472. reset: true,
  473. submit: true
  474. };
  475. function checkControlledValueProps(tagName, props) {
  476. {
  477. if (!(hasReadOnlyValue[props.type] || props.onChange || props.onInput || props.readOnly || props.disabled || props.value == null)) {
  478. error('You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
  479. }
  480. if (!(props.onChange || props.readOnly || props.disabled || props.checked == null)) {
  481. error('You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
  482. }
  483. }
  484. }
  485. function isCustomComponent(tagName, props) {
  486. if (tagName.indexOf('-') === -1) {
  487. return typeof props.is === 'string';
  488. }
  489. switch (tagName) {
  490. // These are reserved SVG and MathML elements.
  491. // We don't mind this list too much because we expect it to never grow.
  492. // The alternative is to track the namespace in a few places which is convoluted.
  493. // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
  494. case 'annotation-xml':
  495. case 'color-profile':
  496. case 'font-face':
  497. case 'font-face-src':
  498. case 'font-face-uri':
  499. case 'font-face-format':
  500. case 'font-face-name':
  501. case 'missing-glyph':
  502. return false;
  503. default:
  504. return true;
  505. }
  506. }
  507. var ariaProperties = {
  508. 'aria-current': 0,
  509. // state
  510. 'aria-description': 0,
  511. 'aria-details': 0,
  512. 'aria-disabled': 0,
  513. // state
  514. 'aria-hidden': 0,
  515. // state
  516. 'aria-invalid': 0,
  517. // state
  518. 'aria-keyshortcuts': 0,
  519. 'aria-label': 0,
  520. 'aria-roledescription': 0,
  521. // Widget Attributes
  522. 'aria-autocomplete': 0,
  523. 'aria-checked': 0,
  524. 'aria-expanded': 0,
  525. 'aria-haspopup': 0,
  526. 'aria-level': 0,
  527. 'aria-modal': 0,
  528. 'aria-multiline': 0,
  529. 'aria-multiselectable': 0,
  530. 'aria-orientation': 0,
  531. 'aria-placeholder': 0,
  532. 'aria-pressed': 0,
  533. 'aria-readonly': 0,
  534. 'aria-required': 0,
  535. 'aria-selected': 0,
  536. 'aria-sort': 0,
  537. 'aria-valuemax': 0,
  538. 'aria-valuemin': 0,
  539. 'aria-valuenow': 0,
  540. 'aria-valuetext': 0,
  541. // Live Region Attributes
  542. 'aria-atomic': 0,
  543. 'aria-busy': 0,
  544. 'aria-live': 0,
  545. 'aria-relevant': 0,
  546. // Drag-and-Drop Attributes
  547. 'aria-dropeffect': 0,
  548. 'aria-grabbed': 0,
  549. // Relationship Attributes
  550. 'aria-activedescendant': 0,
  551. 'aria-colcount': 0,
  552. 'aria-colindex': 0,
  553. 'aria-colspan': 0,
  554. 'aria-controls': 0,
  555. 'aria-describedby': 0,
  556. 'aria-errormessage': 0,
  557. 'aria-flowto': 0,
  558. 'aria-labelledby': 0,
  559. 'aria-owns': 0,
  560. 'aria-posinset': 0,
  561. 'aria-rowcount': 0,
  562. 'aria-rowindex': 0,
  563. 'aria-rowspan': 0,
  564. 'aria-setsize': 0
  565. };
  566. var warnedProperties = {};
  567. var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
  568. var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
  569. function validateProperty(tagName, name) {
  570. {
  571. if (hasOwnProperty.call(warnedProperties, name) && warnedProperties[name]) {
  572. return true;
  573. }
  574. if (rARIACamel.test(name)) {
  575. var ariaName = 'aria-' + name.slice(4).toLowerCase();
  576. var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null; // If this is an aria-* attribute, but is not listed in the known DOM
  577. // DOM properties, then it is an invalid aria-* attribute.
  578. if (correctName == null) {
  579. error('Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.', name);
  580. warnedProperties[name] = true;
  581. return true;
  582. } // aria-* attributes should be lowercase; suggest the lowercase version.
  583. if (name !== correctName) {
  584. error('Invalid ARIA attribute `%s`. Did you mean `%s`?', name, correctName);
  585. warnedProperties[name] = true;
  586. return true;
  587. }
  588. }
  589. if (rARIA.test(name)) {
  590. var lowerCasedName = name.toLowerCase();
  591. var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null; // If this is an aria-* attribute, but is not listed in the known DOM
  592. // DOM properties, then it is an invalid aria-* attribute.
  593. if (standardName == null) {
  594. warnedProperties[name] = true;
  595. return false;
  596. } // aria-* attributes should be lowercase; suggest the lowercase version.
  597. if (name !== standardName) {
  598. error('Unknown ARIA attribute `%s`. Did you mean `%s`?', name, standardName);
  599. warnedProperties[name] = true;
  600. return true;
  601. }
  602. }
  603. }
  604. return true;
  605. }
  606. function warnInvalidARIAProps(type, props) {
  607. {
  608. var invalidProps = [];
  609. for (var key in props) {
  610. var isValid = validateProperty(type, key);
  611. if (!isValid) {
  612. invalidProps.push(key);
  613. }
  614. }
  615. var unknownPropString = invalidProps.map(function (prop) {
  616. return '`' + prop + '`';
  617. }).join(', ');
  618. if (invalidProps.length === 1) {
  619. error('Invalid aria prop %s on <%s> tag. ' + 'For details, see https://reactjs.org/link/invalid-aria-props', unknownPropString, type);
  620. } else if (invalidProps.length > 1) {
  621. error('Invalid aria props %s on <%s> tag. ' + 'For details, see https://reactjs.org/link/invalid-aria-props', unknownPropString, type);
  622. }
  623. }
  624. }
  625. function validateProperties(type, props) {
  626. if (isCustomComponent(type, props)) {
  627. return;
  628. }
  629. warnInvalidARIAProps(type, props);
  630. }
  631. var didWarnValueNull = false;
  632. function validateProperties$1(type, props) {
  633. {
  634. if (type !== 'input' && type !== 'textarea' && type !== 'select') {
  635. return;
  636. }
  637. if (props != null && props.value === null && !didWarnValueNull) {
  638. didWarnValueNull = true;
  639. if (type === 'select' && props.multiple) {
  640. error('`value` prop on `%s` should not be null. ' + 'Consider using an empty array when `multiple` is set to `true` ' + 'to clear the component or `undefined` for uncontrolled components.', type);
  641. } else {
  642. error('`value` prop on `%s` should not be null. ' + 'Consider using an empty string to clear the component or `undefined` ' + 'for uncontrolled components.', type);
  643. }
  644. }
  645. }
  646. }
  647. // When adding attributes to the HTML or SVG allowed attribute list, be sure to
  648. // also add them to this module to ensure casing and incorrect name
  649. // warnings.
  650. var possibleStandardNames = {
  651. // HTML
  652. accept: 'accept',
  653. acceptcharset: 'acceptCharset',
  654. 'accept-charset': 'acceptCharset',
  655. accesskey: 'accessKey',
  656. action: 'action',
  657. allowfullscreen: 'allowFullScreen',
  658. alt: 'alt',
  659. as: 'as',
  660. async: 'async',
  661. autocapitalize: 'autoCapitalize',
  662. autocomplete: 'autoComplete',
  663. autocorrect: 'autoCorrect',
  664. autofocus: 'autoFocus',
  665. autoplay: 'autoPlay',
  666. autosave: 'autoSave',
  667. capture: 'capture',
  668. cellpadding: 'cellPadding',
  669. cellspacing: 'cellSpacing',
  670. challenge: 'challenge',
  671. charset: 'charSet',
  672. checked: 'checked',
  673. children: 'children',
  674. cite: 'cite',
  675. class: 'className',
  676. classid: 'classID',
  677. classname: 'className',
  678. cols: 'cols',
  679. colspan: 'colSpan',
  680. content: 'content',
  681. contenteditable: 'contentEditable',
  682. contextmenu: 'contextMenu',
  683. controls: 'controls',
  684. controlslist: 'controlsList',
  685. coords: 'coords',
  686. crossorigin: 'crossOrigin',
  687. dangerouslysetinnerhtml: 'dangerouslySetInnerHTML',
  688. data: 'data',
  689. datetime: 'dateTime',
  690. default: 'default',
  691. defaultchecked: 'defaultChecked',
  692. defaultvalue: 'defaultValue',
  693. defer: 'defer',
  694. dir: 'dir',
  695. disabled: 'disabled',
  696. disablepictureinpicture: 'disablePictureInPicture',
  697. disableremoteplayback: 'disableRemotePlayback',
  698. download: 'download',
  699. draggable: 'draggable',
  700. enctype: 'encType',
  701. enterkeyhint: 'enterKeyHint',
  702. for: 'htmlFor',
  703. form: 'form',
  704. formmethod: 'formMethod',
  705. formaction: 'formAction',
  706. formenctype: 'formEncType',
  707. formnovalidate: 'formNoValidate',
  708. formtarget: 'formTarget',
  709. frameborder: 'frameBorder',
  710. headers: 'headers',
  711. height: 'height',
  712. hidden: 'hidden',
  713. high: 'high',
  714. href: 'href',
  715. hreflang: 'hrefLang',
  716. htmlfor: 'htmlFor',
  717. httpequiv: 'httpEquiv',
  718. 'http-equiv': 'httpEquiv',
  719. icon: 'icon',
  720. id: 'id',
  721. imagesizes: 'imageSizes',
  722. imagesrcset: 'imageSrcSet',
  723. innerhtml: 'innerHTML',
  724. inputmode: 'inputMode',
  725. integrity: 'integrity',
  726. is: 'is',
  727. itemid: 'itemID',
  728. itemprop: 'itemProp',
  729. itemref: 'itemRef',
  730. itemscope: 'itemScope',
  731. itemtype: 'itemType',
  732. keyparams: 'keyParams',
  733. keytype: 'keyType',
  734. kind: 'kind',
  735. label: 'label',
  736. lang: 'lang',
  737. list: 'list',
  738. loop: 'loop',
  739. low: 'low',
  740. manifest: 'manifest',
  741. marginwidth: 'marginWidth',
  742. marginheight: 'marginHeight',
  743. max: 'max',
  744. maxlength: 'maxLength',
  745. media: 'media',
  746. mediagroup: 'mediaGroup',
  747. method: 'method',
  748. min: 'min',
  749. minlength: 'minLength',
  750. multiple: 'multiple',
  751. muted: 'muted',
  752. name: 'name',
  753. nomodule: 'noModule',
  754. nonce: 'nonce',
  755. novalidate: 'noValidate',
  756. open: 'open',
  757. optimum: 'optimum',
  758. pattern: 'pattern',
  759. placeholder: 'placeholder',
  760. playsinline: 'playsInline',
  761. poster: 'poster',
  762. preload: 'preload',
  763. profile: 'profile',
  764. radiogroup: 'radioGroup',
  765. readonly: 'readOnly',
  766. referrerpolicy: 'referrerPolicy',
  767. rel: 'rel',
  768. required: 'required',
  769. reversed: 'reversed',
  770. role: 'role',
  771. rows: 'rows',
  772. rowspan: 'rowSpan',
  773. sandbox: 'sandbox',
  774. scope: 'scope',
  775. scoped: 'scoped',
  776. scrolling: 'scrolling',
  777. seamless: 'seamless',
  778. selected: 'selected',
  779. shape: 'shape',
  780. size: 'size',
  781. sizes: 'sizes',
  782. span: 'span',
  783. spellcheck: 'spellCheck',
  784. src: 'src',
  785. srcdoc: 'srcDoc',
  786. srclang: 'srcLang',
  787. srcset: 'srcSet',
  788. start: 'start',
  789. step: 'step',
  790. style: 'style',
  791. summary: 'summary',
  792. tabindex: 'tabIndex',
  793. target: 'target',
  794. title: 'title',
  795. type: 'type',
  796. usemap: 'useMap',
  797. value: 'value',
  798. width: 'width',
  799. wmode: 'wmode',
  800. wrap: 'wrap',
  801. // SVG
  802. about: 'about',
  803. accentheight: 'accentHeight',
  804. 'accent-height': 'accentHeight',
  805. accumulate: 'accumulate',
  806. additive: 'additive',
  807. alignmentbaseline: 'alignmentBaseline',
  808. 'alignment-baseline': 'alignmentBaseline',
  809. allowreorder: 'allowReorder',
  810. alphabetic: 'alphabetic',
  811. amplitude: 'amplitude',
  812. arabicform: 'arabicForm',
  813. 'arabic-form': 'arabicForm',
  814. ascent: 'ascent',
  815. attributename: 'attributeName',
  816. attributetype: 'attributeType',
  817. autoreverse: 'autoReverse',
  818. azimuth: 'azimuth',
  819. basefrequency: 'baseFrequency',
  820. baselineshift: 'baselineShift',
  821. 'baseline-shift': 'baselineShift',
  822. baseprofile: 'baseProfile',
  823. bbox: 'bbox',
  824. begin: 'begin',
  825. bias: 'bias',
  826. by: 'by',
  827. calcmode: 'calcMode',
  828. capheight: 'capHeight',
  829. 'cap-height': 'capHeight',
  830. clip: 'clip',
  831. clippath: 'clipPath',
  832. 'clip-path': 'clipPath',
  833. clippathunits: 'clipPathUnits',
  834. cliprule: 'clipRule',
  835. 'clip-rule': 'clipRule',
  836. color: 'color',
  837. colorinterpolation: 'colorInterpolation',
  838. 'color-interpolation': 'colorInterpolation',
  839. colorinterpolationfilters: 'colorInterpolationFilters',
  840. 'color-interpolation-filters': 'colorInterpolationFilters',
  841. colorprofile: 'colorProfile',
  842. 'color-profile': 'colorProfile',
  843. colorrendering: 'colorRendering',
  844. 'color-rendering': 'colorRendering',
  845. contentscripttype: 'contentScriptType',
  846. contentstyletype: 'contentStyleType',
  847. cursor: 'cursor',
  848. cx: 'cx',
  849. cy: 'cy',
  850. d: 'd',
  851. datatype: 'datatype',
  852. decelerate: 'decelerate',
  853. descent: 'descent',
  854. diffuseconstant: 'diffuseConstant',
  855. direction: 'direction',
  856. display: 'display',
  857. divisor: 'divisor',
  858. dominantbaseline: 'dominantBaseline',
  859. 'dominant-baseline': 'dominantBaseline',
  860. dur: 'dur',
  861. dx: 'dx',
  862. dy: 'dy',
  863. edgemode: 'edgeMode',
  864. elevation: 'elevation',
  865. enablebackground: 'enableBackground',
  866. 'enable-background': 'enableBackground',
  867. end: 'end',
  868. exponent: 'exponent',
  869. externalresourcesrequired: 'externalResourcesRequired',
  870. fill: 'fill',
  871. fillopacity: 'fillOpacity',
  872. 'fill-opacity': 'fillOpacity',
  873. fillrule: 'fillRule',
  874. 'fill-rule': 'fillRule',
  875. filter: 'filter',
  876. filterres: 'filterRes',
  877. filterunits: 'filterUnits',
  878. floodopacity: 'floodOpacity',
  879. 'flood-opacity': 'floodOpacity',
  880. floodcolor: 'floodColor',
  881. 'flood-color': 'floodColor',
  882. focusable: 'focusable',
  883. fontfamily: 'fontFamily',
  884. 'font-family': 'fontFamily',
  885. fontsize: 'fontSize',
  886. 'font-size': 'fontSize',
  887. fontsizeadjust: 'fontSizeAdjust',
  888. 'font-size-adjust': 'fontSizeAdjust',
  889. fontstretch: 'fontStretch',
  890. 'font-stretch': 'fontStretch',
  891. fontstyle: 'fontStyle',
  892. 'font-style': 'fontStyle',
  893. fontvariant: 'fontVariant',
  894. 'font-variant': 'fontVariant',
  895. fontweight: 'fontWeight',
  896. 'font-weight': 'fontWeight',
  897. format: 'format',
  898. from: 'from',
  899. fx: 'fx',
  900. fy: 'fy',
  901. g1: 'g1',
  902. g2: 'g2',
  903. glyphname: 'glyphName',
  904. 'glyph-name': 'glyphName',
  905. glyphorientationhorizontal: 'glyphOrientationHorizontal',
  906. 'glyph-orientation-horizontal': 'glyphOrientationHorizontal',
  907. glyphorientationvertical: 'glyphOrientationVertical',
  908. 'glyph-orientation-vertical': 'glyphOrientationVertical',
  909. glyphref: 'glyphRef',
  910. gradienttransform: 'gradientTransform',
  911. gradientunits: 'gradientUnits',
  912. hanging: 'hanging',
  913. horizadvx: 'horizAdvX',
  914. 'horiz-adv-x': 'horizAdvX',
  915. horizoriginx: 'horizOriginX',
  916. 'horiz-origin-x': 'horizOriginX',
  917. ideographic: 'ideographic',
  918. imagerendering: 'imageRendering',
  919. 'image-rendering': 'imageRendering',
  920. in2: 'in2',
  921. in: 'in',
  922. inlist: 'inlist',
  923. intercept: 'intercept',
  924. k1: 'k1',
  925. k2: 'k2',
  926. k3: 'k3',
  927. k4: 'k4',
  928. k: 'k',
  929. kernelmatrix: 'kernelMatrix',
  930. kernelunitlength: 'kernelUnitLength',
  931. kerning: 'kerning',
  932. keypoints: 'keyPoints',
  933. keysplines: 'keySplines',
  934. keytimes: 'keyTimes',
  935. lengthadjust: 'lengthAdjust',
  936. letterspacing: 'letterSpacing',
  937. 'letter-spacing': 'letterSpacing',
  938. lightingcolor: 'lightingColor',
  939. 'lighting-color': 'lightingColor',
  940. limitingconeangle: 'limitingConeAngle',
  941. local: 'local',
  942. markerend: 'markerEnd',
  943. 'marker-end': 'markerEnd',
  944. markerheight: 'markerHeight',
  945. markermid: 'markerMid',
  946. 'marker-mid': 'markerMid',
  947. markerstart: 'markerStart',
  948. 'marker-start': 'markerStart',
  949. markerunits: 'markerUnits',
  950. markerwidth: 'markerWidth',
  951. mask: 'mask',
  952. maskcontentunits: 'maskContentUnits',
  953. maskunits: 'maskUnits',
  954. mathematical: 'mathematical',
  955. mode: 'mode',
  956. numoctaves: 'numOctaves',
  957. offset: 'offset',
  958. opacity: 'opacity',
  959. operator: 'operator',
  960. order: 'order',
  961. orient: 'orient',
  962. orientation: 'orientation',
  963. origin: 'origin',
  964. overflow: 'overflow',
  965. overlineposition: 'overlinePosition',
  966. 'overline-position': 'overlinePosition',
  967. overlinethickness: 'overlineThickness',
  968. 'overline-thickness': 'overlineThickness',
  969. paintorder: 'paintOrder',
  970. 'paint-order': 'paintOrder',
  971. panose1: 'panose1',
  972. 'panose-1': 'panose1',
  973. pathlength: 'pathLength',
  974. patterncontentunits: 'patternContentUnits',
  975. patterntransform: 'patternTransform',
  976. patternunits: 'patternUnits',
  977. pointerevents: 'pointerEvents',
  978. 'pointer-events': 'pointerEvents',
  979. points: 'points',
  980. pointsatx: 'pointsAtX',
  981. pointsaty: 'pointsAtY',
  982. pointsatz: 'pointsAtZ',
  983. prefix: 'prefix',
  984. preservealpha: 'preserveAlpha',
  985. preserveaspectratio: 'preserveAspectRatio',
  986. primitiveunits: 'primitiveUnits',
  987. property: 'property',
  988. r: 'r',
  989. radius: 'radius',
  990. refx: 'refX',
  991. refy: 'refY',
  992. renderingintent: 'renderingIntent',
  993. 'rendering-intent': 'renderingIntent',
  994. repeatcount: 'repeatCount',
  995. repeatdur: 'repeatDur',
  996. requiredextensions: 'requiredExtensions',
  997. requiredfeatures: 'requiredFeatures',
  998. resource: 'resource',
  999. restart: 'restart',
  1000. result: 'result',
  1001. results: 'results',
  1002. rotate: 'rotate',
  1003. rx: 'rx',
  1004. ry: 'ry',
  1005. scale: 'scale',
  1006. security: 'security',
  1007. seed: 'seed',
  1008. shaperendering: 'shapeRendering',
  1009. 'shape-rendering': 'shapeRendering',
  1010. slope: 'slope',
  1011. spacing: 'spacing',
  1012. specularconstant: 'specularConstant',
  1013. specularexponent: 'specularExponent',
  1014. speed: 'speed',
  1015. spreadmethod: 'spreadMethod',
  1016. startoffset: 'startOffset',
  1017. stddeviation: 'stdDeviation',
  1018. stemh: 'stemh',
  1019. stemv: 'stemv',
  1020. stitchtiles: 'stitchTiles',
  1021. stopcolor: 'stopColor',
  1022. 'stop-color': 'stopColor',
  1023. stopopacity: 'stopOpacity',
  1024. 'stop-opacity': 'stopOpacity',
  1025. strikethroughposition: 'strikethroughPosition',
  1026. 'strikethrough-position': 'strikethroughPosition',
  1027. strikethroughthickness: 'strikethroughThickness',
  1028. 'strikethrough-thickness': 'strikethroughThickness',
  1029. string: 'string',
  1030. stroke: 'stroke',
  1031. strokedasharray: 'strokeDasharray',
  1032. 'stroke-dasharray': 'strokeDasharray',
  1033. strokedashoffset: 'strokeDashoffset',
  1034. 'stroke-dashoffset': 'strokeDashoffset',
  1035. strokelinecap: 'strokeLinecap',
  1036. 'stroke-linecap': 'strokeLinecap',
  1037. strokelinejoin: 'strokeLinejoin',
  1038. 'stroke-linejoin': 'strokeLinejoin',
  1039. strokemiterlimit: 'strokeMiterlimit',
  1040. 'stroke-miterlimit': 'strokeMiterlimit',
  1041. strokewidth: 'strokeWidth',
  1042. 'stroke-width': 'strokeWidth',
  1043. strokeopacity: 'strokeOpacity',
  1044. 'stroke-opacity': 'strokeOpacity',
  1045. suppresscontenteditablewarning: 'suppressContentEditableWarning',
  1046. suppresshydrationwarning: 'suppressHydrationWarning',
  1047. surfacescale: 'surfaceScale',
  1048. systemlanguage: 'systemLanguage',
  1049. tablevalues: 'tableValues',
  1050. targetx: 'targetX',
  1051. targety: 'targetY',
  1052. textanchor: 'textAnchor',
  1053. 'text-anchor': 'textAnchor',
  1054. textdecoration: 'textDecoration',
  1055. 'text-decoration': 'textDecoration',
  1056. textlength: 'textLength',
  1057. textrendering: 'textRendering',
  1058. 'text-rendering': 'textRendering',
  1059. to: 'to',
  1060. transform: 'transform',
  1061. typeof: 'typeof',
  1062. u1: 'u1',
  1063. u2: 'u2',
  1064. underlineposition: 'underlinePosition',
  1065. 'underline-position': 'underlinePosition',
  1066. underlinethickness: 'underlineThickness',
  1067. 'underline-thickness': 'underlineThickness',
  1068. unicode: 'unicode',
  1069. unicodebidi: 'unicodeBidi',
  1070. 'unicode-bidi': 'unicodeBidi',
  1071. unicoderange: 'unicodeRange',
  1072. 'unicode-range': 'unicodeRange',
  1073. unitsperem: 'unitsPerEm',
  1074. 'units-per-em': 'unitsPerEm',
  1075. unselectable: 'unselectable',
  1076. valphabetic: 'vAlphabetic',
  1077. 'v-alphabetic': 'vAlphabetic',
  1078. values: 'values',
  1079. vectoreffect: 'vectorEffect',
  1080. 'vector-effect': 'vectorEffect',
  1081. version: 'version',
  1082. vertadvy: 'vertAdvY',
  1083. 'vert-adv-y': 'vertAdvY',
  1084. vertoriginx: 'vertOriginX',
  1085. 'vert-origin-x': 'vertOriginX',
  1086. vertoriginy: 'vertOriginY',
  1087. 'vert-origin-y': 'vertOriginY',
  1088. vhanging: 'vHanging',
  1089. 'v-hanging': 'vHanging',
  1090. videographic: 'vIdeographic',
  1091. 'v-ideographic': 'vIdeographic',
  1092. viewbox: 'viewBox',
  1093. viewtarget: 'viewTarget',
  1094. visibility: 'visibility',
  1095. vmathematical: 'vMathematical',
  1096. 'v-mathematical': 'vMathematical',
  1097. vocab: 'vocab',
  1098. widths: 'widths',
  1099. wordspacing: 'wordSpacing',
  1100. 'word-spacing': 'wordSpacing',
  1101. writingmode: 'writingMode',
  1102. 'writing-mode': 'writingMode',
  1103. x1: 'x1',
  1104. x2: 'x2',
  1105. x: 'x',
  1106. xchannelselector: 'xChannelSelector',
  1107. xheight: 'xHeight',
  1108. 'x-height': 'xHeight',
  1109. xlinkactuate: 'xlinkActuate',
  1110. 'xlink:actuate': 'xlinkActuate',
  1111. xlinkarcrole: 'xlinkArcrole',
  1112. 'xlink:arcrole': 'xlinkArcrole',
  1113. xlinkhref: 'xlinkHref',
  1114. 'xlink:href': 'xlinkHref',
  1115. xlinkrole: 'xlinkRole',
  1116. 'xlink:role': 'xlinkRole',
  1117. xlinkshow: 'xlinkShow',
  1118. 'xlink:show': 'xlinkShow',
  1119. xlinktitle: 'xlinkTitle',
  1120. 'xlink:title': 'xlinkTitle',
  1121. xlinktype: 'xlinkType',
  1122. 'xlink:type': 'xlinkType',
  1123. xmlbase: 'xmlBase',
  1124. 'xml:base': 'xmlBase',
  1125. xmllang: 'xmlLang',
  1126. 'xml:lang': 'xmlLang',
  1127. xmlns: 'xmlns',
  1128. 'xml:space': 'xmlSpace',
  1129. xmlnsxlink: 'xmlnsXlink',
  1130. 'xmlns:xlink': 'xmlnsXlink',
  1131. xmlspace: 'xmlSpace',
  1132. y1: 'y1',
  1133. y2: 'y2',
  1134. y: 'y',
  1135. ychannelselector: 'yChannelSelector',
  1136. z: 'z',
  1137. zoomandpan: 'zoomAndPan'
  1138. };
  1139. var validateProperty$1 = function () {};
  1140. {
  1141. var warnedProperties$1 = {};
  1142. var EVENT_NAME_REGEX = /^on./;
  1143. var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/;
  1144. var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
  1145. var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
  1146. validateProperty$1 = function (tagName, name, value, eventRegistry) {
  1147. if (hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) {
  1148. return true;
  1149. }
  1150. var lowerCasedName = name.toLowerCase();
  1151. if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') {
  1152. error('React uses onFocus and onBlur instead of onFocusIn and onFocusOut. ' + 'All React events are normalized to bubble, so onFocusIn and onFocusOut ' + 'are not needed/supported by React.');
  1153. warnedProperties$1[name] = true;
  1154. return true;
  1155. } // We can't rely on the event system being injected on the server.
  1156. if (eventRegistry != null) {
  1157. var registrationNameDependencies = eventRegistry.registrationNameDependencies,
  1158. possibleRegistrationNames = eventRegistry.possibleRegistrationNames;
  1159. if (registrationNameDependencies.hasOwnProperty(name)) {
  1160. return true;
  1161. }
  1162. var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null;
  1163. if (registrationName != null) {
  1164. error('Invalid event handler property `%s`. Did you mean `%s`?', name, registrationName);
  1165. warnedProperties$1[name] = true;
  1166. return true;
  1167. }
  1168. if (EVENT_NAME_REGEX.test(name)) {
  1169. error('Unknown event handler property `%s`. It will be ignored.', name);
  1170. warnedProperties$1[name] = true;
  1171. return true;
  1172. }
  1173. } else if (EVENT_NAME_REGEX.test(name)) {
  1174. // If no event plugins have been injected, we are in a server environment.
  1175. // So we can't tell if the event name is correct for sure, but we can filter
  1176. // out known bad ones like `onclick`. We can't suggest a specific replacement though.
  1177. if (INVALID_EVENT_NAME_REGEX.test(name)) {
  1178. error('Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.', name);
  1179. }
  1180. warnedProperties$1[name] = true;
  1181. return true;
  1182. } // Let the ARIA attribute hook validate ARIA attributes
  1183. if (rARIA$1.test(name) || rARIACamel$1.test(name)) {
  1184. return true;
  1185. }
  1186. if (lowerCasedName === 'innerhtml') {
  1187. error('Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.');
  1188. warnedProperties$1[name] = true;
  1189. return true;
  1190. }
  1191. if (lowerCasedName === 'aria') {
  1192. error('The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.');
  1193. warnedProperties$1[name] = true;
  1194. return true;
  1195. }
  1196. if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') {
  1197. error('Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.', typeof value);
  1198. warnedProperties$1[name] = true;
  1199. return true;
  1200. }
  1201. if (typeof value === 'number' && isNaN(value)) {
  1202. error('Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.', name);
  1203. warnedProperties$1[name] = true;
  1204. return true;
  1205. }
  1206. var propertyInfo = getPropertyInfo(name);
  1207. var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED; // Known attributes should match the casing specified in the property config.
  1208. if (possibleStandardNames.hasOwnProperty(lowerCasedName)) {
  1209. var standardName = possibleStandardNames[lowerCasedName];
  1210. if (standardName !== name) {
  1211. error('Invalid DOM property `%s`. Did you mean `%s`?', name, standardName);
  1212. warnedProperties$1[name] = true;
  1213. return true;
  1214. }
  1215. } else if (!isReserved && name !== lowerCasedName) {
  1216. // Unknown attributes should have lowercase casing since that's how they
  1217. // will be cased anyway with server rendering.
  1218. error('React does not recognize the `%s` prop on a DOM element. If you ' + 'intentionally want it to appear in the DOM as a custom ' + 'attribute, spell it as lowercase `%s` instead. ' + 'If you accidentally passed it from a parent component, remove ' + 'it from the DOM element.', name, lowerCasedName);
  1219. warnedProperties$1[name] = true;
  1220. return true;
  1221. }
  1222. if (typeof value === 'boolean' && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
  1223. if (value) {
  1224. error('Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.', value, name, name, value, name);
  1225. } else {
  1226. error('Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.\n\n' + 'If you used to conditionally omit it with %s={condition && value}, ' + 'pass %s={condition ? value : undefined} instead.', value, name, name, value, name, name, name);
  1227. }
  1228. warnedProperties$1[name] = true;
  1229. return true;
  1230. } // Now that we've validated casing, do not validate
  1231. // data types for reserved props
  1232. if (isReserved) {
  1233. return true;
  1234. } // Warn when a known attribute is a bad type
  1235. if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
  1236. warnedProperties$1[name] = true;
  1237. return false;
  1238. } // Warn when passing the strings 'false' or 'true' into a boolean prop
  1239. if ((value === 'false' || value === 'true') && propertyInfo !== null && propertyInfo.type === BOOLEAN) {
  1240. error('Received the string `%s` for the boolean attribute `%s`. ' + '%s ' + 'Did you mean %s={%s}?', value, name, value === 'false' ? 'The browser will interpret it as a truthy value.' : 'Although this works, it will not work as expected if you pass the string "false".', name, value);
  1241. warnedProperties$1[name] = true;
  1242. return true;
  1243. }
  1244. return true;
  1245. };
  1246. }
  1247. var warnUnknownProperties = function (type, props, eventRegistry) {
  1248. {
  1249. var unknownProps = [];
  1250. for (var key in props) {
  1251. var isValid = validateProperty$1(type, key, props[key], eventRegistry);
  1252. if (!isValid) {
  1253. unknownProps.push(key);
  1254. }
  1255. }
  1256. var unknownPropString = unknownProps.map(function (prop) {
  1257. return '`' + prop + '`';
  1258. }).join(', ');
  1259. if (unknownProps.length === 1) {
  1260. error('Invalid value for prop %s on <%s> tag. Either remove it from the element, ' + 'or pass a string or number value to keep it in the DOM. ' + 'For details, see https://reactjs.org/link/attribute-behavior ', unknownPropString, type);
  1261. } else if (unknownProps.length > 1) {
  1262. error('Invalid values for props %s on <%s> tag. Either remove them from the element, ' + 'or pass a string or number value to keep them in the DOM. ' + 'For details, see https://reactjs.org/link/attribute-behavior ', unknownPropString, type);
  1263. }
  1264. }
  1265. };
  1266. function validateProperties$2(type, props, eventRegistry) {
  1267. if (isCustomComponent(type, props)) {
  1268. return;
  1269. }
  1270. warnUnknownProperties(type, props, eventRegistry);
  1271. }
  1272. var warnValidStyle = function () {};
  1273. {
  1274. // 'msTransform' is correct, but the other prefixes should be capitalized
  1275. var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
  1276. var msPattern = /^-ms-/;
  1277. var hyphenPattern = /-(.)/g; // style values shouldn't contain a semicolon
  1278. var badStyleValueWithSemicolonPattern = /;\s*$/;
  1279. var warnedStyleNames = {};
  1280. var warnedStyleValues = {};
  1281. var warnedForNaNValue = false;
  1282. var warnedForInfinityValue = false;
  1283. var camelize = function (string) {
  1284. return string.replace(hyphenPattern, function (_, character) {
  1285. return character.toUpperCase();
  1286. });
  1287. };
  1288. var warnHyphenatedStyleName = function (name) {
  1289. if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
  1290. return;
  1291. }
  1292. warnedStyleNames[name] = true;
  1293. error('Unsupported style property %s. Did you mean %s?', name, // As Andi Smith suggests
  1294. // (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
  1295. // is converted to lowercase `ms`.
  1296. camelize(name.replace(msPattern, 'ms-')));
  1297. };
  1298. var warnBadVendoredStyleName = function (name) {
  1299. if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
  1300. return;
  1301. }
  1302. warnedStyleNames[name] = true;
  1303. error('Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1));
  1304. };
  1305. var warnStyleValueWithSemicolon = function (name, value) {
  1306. if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
  1307. return;
  1308. }
  1309. warnedStyleValues[value] = true;
  1310. error("Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, ''));
  1311. };
  1312. var warnStyleValueIsNaN = function (name, value) {
  1313. if (warnedForNaNValue) {
  1314. return;
  1315. }
  1316. warnedForNaNValue = true;
  1317. error('`NaN` is an invalid value for the `%s` css style property.', name);
  1318. };
  1319. var warnStyleValueIsInfinity = function (name, value) {
  1320. if (warnedForInfinityValue) {
  1321. return;
  1322. }
  1323. warnedForInfinityValue = true;
  1324. error('`Infinity` is an invalid value for the `%s` css style property.', name);
  1325. };
  1326. warnValidStyle = function (name, value) {
  1327. if (name.indexOf('-') > -1) {
  1328. warnHyphenatedStyleName(name);
  1329. } else if (badVendoredStyleNamePattern.test(name)) {
  1330. warnBadVendoredStyleName(name);
  1331. } else if (badStyleValueWithSemicolonPattern.test(value)) {
  1332. warnStyleValueWithSemicolon(name, value);
  1333. }
  1334. if (typeof value === 'number') {
  1335. if (isNaN(value)) {
  1336. warnStyleValueIsNaN(name, value);
  1337. } else if (!isFinite(value)) {
  1338. warnStyleValueIsInfinity(name, value);
  1339. }
  1340. }
  1341. };
  1342. }
  1343. var warnValidStyle$1 = warnValidStyle;
  1344. // code copied and modified from escape-html
  1345. var matchHtmlRegExp = /["'&<>]/;
  1346. /**
  1347. * Escapes special characters and HTML entities in a given html string.
  1348. *
  1349. * @param {string} string HTML string to escape for later insertion
  1350. * @return {string}
  1351. * @public
  1352. */
  1353. function escapeHtml(string) {
  1354. {
  1355. checkHtmlStringCoercion(string);
  1356. }
  1357. var str = '' + string;
  1358. var match = matchHtmlRegExp.exec(str);
  1359. if (!match) {
  1360. return str;
  1361. }
  1362. var escape;
  1363. var html = '';
  1364. var index;
  1365. var lastIndex = 0;
  1366. for (index = match.index; index < str.length; index++) {
  1367. switch (str.charCodeAt(index)) {
  1368. case 34:
  1369. // "
  1370. escape = '&quot;';
  1371. break;
  1372. case 38:
  1373. // &
  1374. escape = '&amp;';
  1375. break;
  1376. case 39:
  1377. // '
  1378. escape = '&#x27;'; // modified from escape-html; used to be '&#39'
  1379. break;
  1380. case 60:
  1381. // <
  1382. escape = '&lt;';
  1383. break;
  1384. case 62:
  1385. // >
  1386. escape = '&gt;';
  1387. break;
  1388. default:
  1389. continue;
  1390. }
  1391. if (lastIndex !== index) {
  1392. html += str.substring(lastIndex, index);
  1393. }
  1394. lastIndex = index + 1;
  1395. html += escape;
  1396. }
  1397. return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
  1398. } // end code copied and modified from escape-html
  1399. /**
  1400. * Escapes text to prevent scripting attacks.
  1401. *
  1402. * @param {*} text Text value to escape.
  1403. * @return {string} An escaped string.
  1404. */
  1405. function escapeTextForBrowser(text) {
  1406. if (typeof text === 'boolean' || typeof text === 'number') {
  1407. // this shortcircuit helps perf for types that we know will never have
  1408. // special characters, especially given that this function is used often
  1409. // for numeric dom ids.
  1410. return '' + text;
  1411. }
  1412. return escapeHtml(text);
  1413. }
  1414. var uppercasePattern = /([A-Z])/g;
  1415. var msPattern$1 = /^ms-/;
  1416. /**
  1417. * Hyphenates a camelcased CSS property name, for example:
  1418. *
  1419. * > hyphenateStyleName('backgroundColor')
  1420. * < "background-color"
  1421. * > hyphenateStyleName('MozTransition')
  1422. * < "-moz-transition"
  1423. * > hyphenateStyleName('msTransition')
  1424. * < "-ms-transition"
  1425. *
  1426. * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
  1427. * is converted to `-ms-`.
  1428. */
  1429. function hyphenateStyleName(name) {
  1430. return name.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern$1, '-ms-');
  1431. }
  1432. // and any newline or tab are filtered out as if they're not part of the URL.
  1433. // https://url.spec.whatwg.org/#url-parsing
  1434. // Tab or newline are defined as \r\n\t:
  1435. // https://infra.spec.whatwg.org/#ascii-tab-or-newline
  1436. // A C0 control is a code point in the range \u0000 NULL to \u001F
  1437. // INFORMATION SEPARATOR ONE, inclusive:
  1438. // https://infra.spec.whatwg.org/#c0-control-or-space
  1439. /* eslint-disable max-len */
  1440. var isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i;
  1441. var didWarn = false;
  1442. function sanitizeURL(url) {
  1443. {
  1444. if (!didWarn && isJavaScriptProtocol.test(url)) {
  1445. didWarn = true;
  1446. error('A future version of React will block javascript: URLs as a security precaution. ' + 'Use event handlers instead if you can. If you need to generate unsafe HTML try ' + 'using dangerouslySetInnerHTML instead. React was passed %s.', JSON.stringify(url));
  1447. }
  1448. }
  1449. }
  1450. var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
  1451. function isArray(a) {
  1452. return isArrayImpl(a);
  1453. }
  1454. var startInlineScript = stringToPrecomputedChunk('<script>');
  1455. var endInlineScript = stringToPrecomputedChunk('</script>');
  1456. var startScriptSrc = stringToPrecomputedChunk('<script src="');
  1457. var startModuleSrc = stringToPrecomputedChunk('<script type="module" src="');
  1458. var endAsyncScript = stringToPrecomputedChunk('" async=""></script>');
  1459. /**
  1460. * This escaping function is designed to work with bootstrapScriptContent only.
  1461. * because we know we are escaping the entire script. We can avoid for instance
  1462. * escaping html comment string sequences that are valid javascript as well because
  1463. * if there are no sebsequent <script sequences the html parser will never enter
  1464. * script data double escaped state (see: https://www.w3.org/TR/html53/syntax.html#script-data-double-escaped-state)
  1465. *
  1466. * While untrusted script content should be made safe before using this api it will
  1467. * ensure that the script cannot be early terminated or never terminated state
  1468. */
  1469. function escapeBootstrapScriptContent(scriptText) {
  1470. {
  1471. checkHtmlStringCoercion(scriptText);
  1472. }
  1473. return ('' + scriptText).replace(scriptRegex, scriptReplacer);
  1474. }
  1475. var scriptRegex = /(<\/|<)(s)(cript)/gi;
  1476. var scriptReplacer = function (match, prefix, s, suffix) {
  1477. return "" + prefix + (s === 's' ? "\\u0073" : "\\u0053") + suffix;
  1478. }; // Allows us to keep track of what we've already written so we can refer back to it.
  1479. function createResponseState(identifierPrefix, nonce, bootstrapScriptContent, bootstrapScripts, bootstrapModules) {
  1480. var idPrefix = identifierPrefix === undefined ? '' : identifierPrefix;
  1481. var inlineScriptWithNonce = nonce === undefined ? startInlineScript : stringToPrecomputedChunk('<script nonce="' + escapeTextForBrowser(nonce) + '">');
  1482. var bootstrapChunks = [];
  1483. if (bootstrapScriptContent !== undefined) {
  1484. bootstrapChunks.push(inlineScriptWithNonce, stringToChunk(escapeBootstrapScriptContent(bootstrapScriptContent)), endInlineScript);
  1485. }
  1486. if (bootstrapScripts !== undefined) {
  1487. for (var i = 0; i < bootstrapScripts.length; i++) {
  1488. bootstrapChunks.push(startScriptSrc, stringToChunk(escapeTextForBrowser(bootstrapScripts[i])), endAsyncScript);
  1489. }
  1490. }
  1491. if (bootstrapModules !== undefined) {
  1492. for (var _i = 0; _i < bootstrapModules.length; _i++) {
  1493. bootstrapChunks.push(startModuleSrc, stringToChunk(escapeTextForBrowser(bootstrapModules[_i])), endAsyncScript);
  1494. }
  1495. }
  1496. return {
  1497. bootstrapChunks: bootstrapChunks,
  1498. startInlineScript: inlineScriptWithNonce,
  1499. placeholderPrefix: stringToPrecomputedChunk(idPrefix + 'P:'),
  1500. segmentPrefix: stringToPrecomputedChunk(idPrefix + 'S:'),
  1501. boundaryPrefix: idPrefix + 'B:',
  1502. idPrefix: idPrefix,
  1503. nextSuspenseID: 0,
  1504. sentCompleteSegmentFunction: false,
  1505. sentCompleteBoundaryFunction: false,
  1506. sentClientRenderFunction: false
  1507. };
  1508. } // Constants for the insertion mode we're currently writing in. We don't encode all HTML5 insertion
  1509. // modes. We only include the variants as they matter for the sake of our purposes.
  1510. // We don't actually provide the namespace therefore we use constants instead of the string.
  1511. var ROOT_HTML_MODE = 0; // Used for the root most element tag.
  1512. var HTML_MODE = 1;
  1513. var SVG_MODE = 2;
  1514. var MATHML_MODE = 3;
  1515. var HTML_TABLE_MODE = 4;
  1516. var HTML_TABLE_BODY_MODE = 5;
  1517. var HTML_TABLE_ROW_MODE = 6;
  1518. var HTML_COLGROUP_MODE = 7; // We have a greater than HTML_TABLE_MODE check elsewhere. If you add more cases here, make sure it
  1519. // still makes sense
  1520. function createFormatContext(insertionMode, selectedValue) {
  1521. return {
  1522. insertionMode: insertionMode,
  1523. selectedValue: selectedValue
  1524. };
  1525. }
  1526. function getChildFormatContext(parentContext, type, props) {
  1527. switch (type) {
  1528. case 'select':
  1529. return createFormatContext(HTML_MODE, props.value != null ? props.value : props.defaultValue);
  1530. case 'svg':
  1531. return createFormatContext(SVG_MODE, null);
  1532. case 'math':
  1533. return createFormatContext(MATHML_MODE, null);
  1534. case 'foreignObject':
  1535. return createFormatContext(HTML_MODE, null);
  1536. // Table parents are special in that their children can only be created at all if they're
  1537. // wrapped in a table parent. So we need to encode that we're entering this mode.
  1538. case 'table':
  1539. return createFormatContext(HTML_TABLE_MODE, null);
  1540. case 'thead':
  1541. case 'tbody':
  1542. case 'tfoot':
  1543. return createFormatContext(HTML_TABLE_BODY_MODE, null);
  1544. case 'colgroup':
  1545. return createFormatContext(HTML_COLGROUP_MODE, null);
  1546. case 'tr':
  1547. return createFormatContext(HTML_TABLE_ROW_MODE, null);
  1548. }
  1549. if (parentContext.insertionMode >= HTML_TABLE_MODE) {
  1550. // Whatever tag this was, it wasn't a table parent or other special parent, so we must have
  1551. // entered plain HTML again.
  1552. return createFormatContext(HTML_MODE, null);
  1553. }
  1554. if (parentContext.insertionMode === ROOT_HTML_MODE) {
  1555. // We've emitted the root and is now in plain HTML mode.
  1556. return createFormatContext(HTML_MODE, null);
  1557. }
  1558. return parentContext;
  1559. }
  1560. var UNINITIALIZED_SUSPENSE_BOUNDARY_ID = null;
  1561. function assignSuspenseBoundaryID(responseState) {
  1562. var generatedID = responseState.nextSuspenseID++;
  1563. return stringToPrecomputedChunk(responseState.boundaryPrefix + generatedID.toString(16));
  1564. }
  1565. function makeId(responseState, treeId, localId) {
  1566. var idPrefix = responseState.idPrefix;
  1567. var id = ':' + idPrefix + 'R' + treeId; // Unless this is the first id at this level, append a number at the end
  1568. // that represents the position of this useId hook among all the useId
  1569. // hooks for this fiber.
  1570. if (localId > 0) {
  1571. id += 'H' + localId.toString(32);
  1572. }
  1573. return id + ':';
  1574. }
  1575. function encodeHTMLTextNode(text) {
  1576. return escapeTextForBrowser(text);
  1577. }
  1578. var textSeparator = stringToPrecomputedChunk('<!-- -->');
  1579. function pushTextInstance(target, text, responseState, textEmbedded) {
  1580. if (text === '') {
  1581. // Empty text doesn't have a DOM node representation and the hydration is aware of this.
  1582. return textEmbedded;
  1583. }
  1584. if (textEmbedded) {
  1585. target.push(textSeparator);
  1586. }
  1587. target.push(stringToChunk(encodeHTMLTextNode(text)));
  1588. return true;
  1589. } // Called when Fizz is done with a Segment. Currently the only purpose is to conditionally
  1590. // emit a text separator when we don't know for sure it is safe to omit
  1591. function pushSegmentFinale(target, responseState, lastPushedText, textEmbedded) {
  1592. if (lastPushedText && textEmbedded) {
  1593. target.push(textSeparator);
  1594. }
  1595. }
  1596. var styleNameCache = new Map();
  1597. function processStyleName(styleName) {
  1598. var chunk = styleNameCache.get(styleName);
  1599. if (chunk !== undefined) {
  1600. return chunk;
  1601. }
  1602. var result = stringToPrecomputedChunk(escapeTextForBrowser(hyphenateStyleName(styleName)));
  1603. styleNameCache.set(styleName, result);
  1604. return result;
  1605. }
  1606. var styleAttributeStart = stringToPrecomputedChunk(' style="');
  1607. var styleAssign = stringToPrecomputedChunk(':');
  1608. var styleSeparator = stringToPrecomputedChunk(';');
  1609. function pushStyle(target, responseState, style) {
  1610. if (typeof style !== 'object') {
  1611. throw new Error('The `style` prop expects a mapping from style properties to values, ' + "not a string. For example, style={{marginRight: spacing + 'em'}} when " + 'using JSX.');
  1612. }
  1613. var isFirst = true;
  1614. for (var styleName in style) {
  1615. if (!hasOwnProperty.call(style, styleName)) {
  1616. continue;
  1617. } // If you provide unsafe user data here they can inject arbitrary CSS
  1618. // which may be problematic (I couldn't repro this):
  1619. // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
  1620. // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
  1621. // This is not an XSS hole but instead a potential CSS injection issue
  1622. // which has lead to a greater discussion about how we're going to
  1623. // trust URLs moving forward. See #2115901
  1624. var styleValue = style[styleName];
  1625. if (styleValue == null || typeof styleValue === 'boolean' || styleValue === '') {
  1626. // TODO: We used to set empty string as a style with an empty value. Does that ever make sense?
  1627. continue;
  1628. }
  1629. var nameChunk = void 0;
  1630. var valueChunk = void 0;
  1631. var isCustomProperty = styleName.indexOf('--') === 0;
  1632. if (isCustomProperty) {
  1633. nameChunk = stringToChunk(escapeTextForBrowser(styleName));
  1634. {
  1635. checkCSSPropertyStringCoercion(styleValue, styleName);
  1636. }
  1637. valueChunk = stringToChunk(escapeTextForBrowser(('' + styleValue).trim()));
  1638. } else {
  1639. {
  1640. warnValidStyle$1(styleName, styleValue);
  1641. }
  1642. nameChunk = processStyleName(styleName);
  1643. if (typeof styleValue === 'number') {
  1644. if (styleValue !== 0 && !hasOwnProperty.call(isUnitlessNumber, styleName)) {
  1645. valueChunk = stringToChunk(styleValue + 'px'); // Presumes implicit 'px' suffix for unitless numbers
  1646. } else {
  1647. valueChunk = stringToChunk('' + styleValue);
  1648. }
  1649. } else {
  1650. {
  1651. checkCSSPropertyStringCoercion(styleValue, styleName);
  1652. }
  1653. valueChunk = stringToChunk(escapeTextForBrowser(('' + styleValue).trim()));
  1654. }
  1655. }
  1656. if (isFirst) {
  1657. isFirst = false; // If it's first, we don't need any separators prefixed.
  1658. target.push(styleAttributeStart, nameChunk, styleAssign, valueChunk);
  1659. } else {
  1660. target.push(styleSeparator, nameChunk, styleAssign, valueChunk);
  1661. }
  1662. }
  1663. if (!isFirst) {
  1664. target.push(attributeEnd);
  1665. }
  1666. }
  1667. var attributeSeparator = stringToPrecomputedChunk(' ');
  1668. var attributeAssign = stringToPrecomputedChunk('="');
  1669. var attributeEnd = stringToPrecomputedChunk('"');
  1670. var attributeEmptyString = stringToPrecomputedChunk('=""');
  1671. function pushAttribute(target, responseState, name, value) {
  1672. switch (name) {
  1673. case 'style':
  1674. {
  1675. pushStyle(target, responseState, value);
  1676. return;
  1677. }
  1678. case 'defaultValue':
  1679. case 'defaultChecked': // These shouldn't be set as attributes on generic HTML elements.
  1680. case 'innerHTML': // Must use dangerouslySetInnerHTML instead.
  1681. case 'suppressContentEditableWarning':
  1682. case 'suppressHydrationWarning':
  1683. // Ignored. These are built-in to React on the client.
  1684. return;
  1685. }
  1686. if ( // shouldIgnoreAttribute
  1687. // We have already filtered out null/undefined and reserved words.
  1688. name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) {
  1689. return;
  1690. }
  1691. var propertyInfo = getPropertyInfo(name);
  1692. if (propertyInfo !== null) {
  1693. // shouldRemoveAttribute
  1694. switch (typeof value) {
  1695. case 'function': // $FlowIssue symbol is perfectly valid here
  1696. case 'symbol':
  1697. // eslint-disable-line
  1698. return;
  1699. case 'boolean':
  1700. {
  1701. if (!propertyInfo.acceptsBooleans) {
  1702. return;
  1703. }
  1704. }
  1705. }
  1706. var attributeName = propertyInfo.attributeName;
  1707. var attributeNameChunk = stringToChunk(attributeName); // TODO: If it's known we can cache the chunk.
  1708. switch (propertyInfo.type) {
  1709. case BOOLEAN:
  1710. if (value) {
  1711. target.push(attributeSeparator, attributeNameChunk, attributeEmptyString);
  1712. }
  1713. return;
  1714. case OVERLOADED_BOOLEAN:
  1715. if (value === true) {
  1716. target.push(attributeSeparator, attributeNameChunk, attributeEmptyString);
  1717. } else if (value === false) ; else {
  1718. target.push(attributeSeparator, attributeNameChunk, attributeAssign, stringToChunk(escapeTextForBrowser(value)), attributeEnd);
  1719. }
  1720. return;
  1721. case NUMERIC:
  1722. if (!isNaN(value)) {
  1723. target.push(attributeSeparator, attributeNameChunk, attributeAssign, stringToChunk(escapeTextForBrowser(value)), attributeEnd);
  1724. }
  1725. break;
  1726. case POSITIVE_NUMERIC:
  1727. if (!isNaN(value) && value >= 1) {
  1728. target.push(attributeSeparator, attributeNameChunk, attributeAssign, stringToChunk(escapeTextForBrowser(value)), attributeEnd);
  1729. }
  1730. break;
  1731. default:
  1732. if (propertyInfo.sanitizeURL) {
  1733. {
  1734. checkAttributeStringCoercion(value, attributeName);
  1735. }
  1736. value = '' + value;
  1737. sanitizeURL(value);
  1738. }
  1739. target.push(attributeSeparator, attributeNameChunk, attributeAssign, stringToChunk(escapeTextForBrowser(value)), attributeEnd);
  1740. }
  1741. } else if (isAttributeNameSafe(name)) {
  1742. // shouldRemoveAttribute
  1743. switch (typeof value) {
  1744. case 'function': // $FlowIssue symbol is perfectly valid here
  1745. case 'symbol':
  1746. // eslint-disable-line
  1747. return;
  1748. case 'boolean':
  1749. {
  1750. var prefix = name.toLowerCase().slice(0, 5);
  1751. if (prefix !== 'data-' && prefix !== 'aria-') {
  1752. return;
  1753. }
  1754. }
  1755. }
  1756. target.push(attributeSeparator, stringToChunk(name), attributeAssign, stringToChunk(escapeTextForBrowser(value)), attributeEnd);
  1757. }
  1758. }
  1759. var endOfStartTag = stringToPrecomputedChunk('>');
  1760. var endOfStartTagSelfClosing = stringToPrecomputedChunk('/>');
  1761. function pushInnerHTML(target, innerHTML, children) {
  1762. if (innerHTML != null) {
  1763. if (children != null) {
  1764. throw new Error('Can only set one of `children` or `props.dangerouslySetInnerHTML`.');
  1765. }
  1766. if (typeof innerHTML !== 'object' || !('__html' in innerHTML)) {
  1767. throw new Error('`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' + 'Please visit https://reactjs.org/link/dangerously-set-inner-html ' + 'for more information.');
  1768. }
  1769. var html = innerHTML.__html;
  1770. if (html !== null && html !== undefined) {
  1771. {
  1772. checkHtmlStringCoercion(html);
  1773. }
  1774. target.push(stringToChunk('' + html));
  1775. }
  1776. }
  1777. } // TODO: Move these to ResponseState so that we warn for every request.
  1778. // It would help debugging in stateful servers (e.g. service worker).
  1779. var didWarnDefaultInputValue = false;
  1780. var didWarnDefaultChecked = false;
  1781. var didWarnDefaultSelectValue = false;
  1782. var didWarnDefaultTextareaValue = false;
  1783. var didWarnInvalidOptionChildren = false;
  1784. var didWarnInvalidOptionInnerHTML = false;
  1785. var didWarnSelectedSetOnOption = false;
  1786. function checkSelectProp(props, propName) {
  1787. {
  1788. var value = props[propName];
  1789. if (value != null) {
  1790. var array = isArray(value);
  1791. if (props.multiple && !array) {
  1792. error('The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.', propName);
  1793. } else if (!props.multiple && array) {
  1794. error('The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.', propName);
  1795. }
  1796. }
  1797. }
  1798. }
  1799. function pushStartSelect(target, props, responseState) {
  1800. {
  1801. checkControlledValueProps('select', props);
  1802. checkSelectProp(props, 'value');
  1803. checkSelectProp(props, 'defaultValue');
  1804. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnDefaultSelectValue) {
  1805. error('Select elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled select ' + 'element and remove one of these props. More info: ' + 'https://reactjs.org/link/controlled-components');
  1806. didWarnDefaultSelectValue = true;
  1807. }
  1808. }
  1809. target.push(startChunkForTag('select'));
  1810. var children = null;
  1811. var innerHTML = null;
  1812. for (var propKey in props) {
  1813. if (hasOwnProperty.call(props, propKey)) {
  1814. var propValue = props[propKey];
  1815. if (propValue == null) {
  1816. continue;
  1817. }
  1818. switch (propKey) {
  1819. case 'children':
  1820. children = propValue;
  1821. break;
  1822. case 'dangerouslySetInnerHTML':
  1823. // TODO: This doesn't really make sense for select since it can't use the controlled
  1824. // value in the innerHTML.
  1825. innerHTML = propValue;
  1826. break;
  1827. case 'defaultValue':
  1828. case 'value':
  1829. // These are set on the Context instead and applied to the nested options.
  1830. break;
  1831. default:
  1832. pushAttribute(target, responseState, propKey, propValue);
  1833. break;
  1834. }
  1835. }
  1836. }
  1837. target.push(endOfStartTag);
  1838. pushInnerHTML(target, innerHTML, children);
  1839. return children;
  1840. }
  1841. function flattenOptionChildren(children) {
  1842. var content = ''; // Flatten children and warn if they aren't strings or numbers;
  1843. // invalid types are ignored.
  1844. React.Children.forEach(children, function (child) {
  1845. if (child == null) {
  1846. return;
  1847. }
  1848. content += child;
  1849. {
  1850. if (!didWarnInvalidOptionChildren && typeof child !== 'string' && typeof child !== 'number') {
  1851. didWarnInvalidOptionChildren = true;
  1852. error('Cannot infer the option value of complex children. ' + 'Pass a `value` prop or use a plain string as children to <option>.');
  1853. }
  1854. }
  1855. });
  1856. return content;
  1857. }
  1858. var selectedMarkerAttribute = stringToPrecomputedChunk(' selected=""');
  1859. function pushStartOption(target, props, responseState, formatContext) {
  1860. var selectedValue = formatContext.selectedValue;
  1861. target.push(startChunkForTag('option'));
  1862. var children = null;
  1863. var value = null;
  1864. var selected = null;
  1865. var innerHTML = null;
  1866. for (var propKey in props) {
  1867. if (hasOwnProperty.call(props, propKey)) {
  1868. var propValue = props[propKey];
  1869. if (propValue == null) {
  1870. continue;
  1871. }
  1872. switch (propKey) {
  1873. case 'children':
  1874. children = propValue;
  1875. break;
  1876. case 'selected':
  1877. // ignore
  1878. selected = propValue;
  1879. {
  1880. // TODO: Remove support for `selected` in <option>.
  1881. if (!didWarnSelectedSetOnOption) {
  1882. error('Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.');
  1883. didWarnSelectedSetOnOption = true;
  1884. }
  1885. }
  1886. break;
  1887. case 'dangerouslySetInnerHTML':
  1888. innerHTML = propValue;
  1889. break;
  1890. // eslint-disable-next-line-no-fallthrough
  1891. case 'value':
  1892. value = propValue;
  1893. // We intentionally fallthrough to also set the attribute on the node.
  1894. // eslint-disable-next-line-no-fallthrough
  1895. default:
  1896. pushAttribute(target, responseState, propKey, propValue);
  1897. break;
  1898. }
  1899. }
  1900. }
  1901. if (selectedValue != null) {
  1902. var stringValue;
  1903. if (value !== null) {
  1904. {
  1905. checkAttributeStringCoercion(value, 'value');
  1906. }
  1907. stringValue = '' + value;
  1908. } else {
  1909. {
  1910. if (innerHTML !== null) {
  1911. if (!didWarnInvalidOptionInnerHTML) {
  1912. didWarnInvalidOptionInnerHTML = true;
  1913. error('Pass a `value` prop if you set dangerouslyInnerHTML so React knows ' + 'which value should be selected.');
  1914. }
  1915. }
  1916. }
  1917. stringValue = flattenOptionChildren(children);
  1918. }
  1919. if (isArray(selectedValue)) {
  1920. // multiple
  1921. for (var i = 0; i < selectedValue.length; i++) {
  1922. {
  1923. checkAttributeStringCoercion(selectedValue[i], 'value');
  1924. }
  1925. var v = '' + selectedValue[i];
  1926. if (v === stringValue) {
  1927. target.push(selectedMarkerAttribute);
  1928. break;
  1929. }
  1930. }
  1931. } else {
  1932. {
  1933. checkAttributeStringCoercion(selectedValue, 'select.value');
  1934. }
  1935. if ('' + selectedValue === stringValue) {
  1936. target.push(selectedMarkerAttribute);
  1937. }
  1938. }
  1939. } else if (selected) {
  1940. target.push(selectedMarkerAttribute);
  1941. }
  1942. target.push(endOfStartTag);
  1943. pushInnerHTML(target, innerHTML, children);
  1944. return children;
  1945. }
  1946. function pushInput(target, props, responseState) {
  1947. {
  1948. checkControlledValueProps('input', props);
  1949. if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnDefaultChecked) {
  1950. error('%s contains an input of type %s with both checked and defaultChecked props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the checked prop, or the defaultChecked prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://reactjs.org/link/controlled-components', 'A component', props.type);
  1951. didWarnDefaultChecked = true;
  1952. }
  1953. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnDefaultInputValue) {
  1954. error('%s contains an input of type %s with both value and defaultValue props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://reactjs.org/link/controlled-components', 'A component', props.type);
  1955. didWarnDefaultInputValue = true;
  1956. }
  1957. }
  1958. target.push(startChunkForTag('input'));
  1959. var value = null;
  1960. var defaultValue = null;
  1961. var checked = null;
  1962. var defaultChecked = null;
  1963. for (var propKey in props) {
  1964. if (hasOwnProperty.call(props, propKey)) {
  1965. var propValue = props[propKey];
  1966. if (propValue == null) {
  1967. continue;
  1968. }
  1969. switch (propKey) {
  1970. case 'children':
  1971. case 'dangerouslySetInnerHTML':
  1972. throw new Error('input' + " is a self-closing tag and must neither have `children` nor " + 'use `dangerouslySetInnerHTML`.');
  1973. // eslint-disable-next-line-no-fallthrough
  1974. case 'defaultChecked':
  1975. defaultChecked = propValue;
  1976. break;
  1977. case 'defaultValue':
  1978. defaultValue = propValue;
  1979. break;
  1980. case 'checked':
  1981. checked = propValue;
  1982. break;
  1983. case 'value':
  1984. value = propValue;
  1985. break;
  1986. default:
  1987. pushAttribute(target, responseState, propKey, propValue);
  1988. break;
  1989. }
  1990. }
  1991. }
  1992. if (checked !== null) {
  1993. pushAttribute(target, responseState, 'checked', checked);
  1994. } else if (defaultChecked !== null) {
  1995. pushAttribute(target, responseState, 'checked', defaultChecked);
  1996. }
  1997. if (value !== null) {
  1998. pushAttribute(target, responseState, 'value', value);
  1999. } else if (defaultValue !== null) {
  2000. pushAttribute(target, responseState, 'value', defaultValue);
  2001. }
  2002. target.push(endOfStartTagSelfClosing);
  2003. return null;
  2004. }
  2005. function pushStartTextArea(target, props, responseState) {
  2006. {
  2007. checkControlledValueProps('textarea', props);
  2008. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnDefaultTextareaValue) {
  2009. error('Textarea elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled textarea ' + 'and remove one of these props. More info: ' + 'https://reactjs.org/link/controlled-components');
  2010. didWarnDefaultTextareaValue = true;
  2011. }
  2012. }
  2013. target.push(startChunkForTag('textarea'));
  2014. var value = null;
  2015. var defaultValue = null;
  2016. var children = null;
  2017. for (var propKey in props) {
  2018. if (hasOwnProperty.call(props, propKey)) {
  2019. var propValue = props[propKey];
  2020. if (propValue == null) {
  2021. continue;
  2022. }
  2023. switch (propKey) {
  2024. case 'children':
  2025. children = propValue;
  2026. break;
  2027. case 'value':
  2028. value = propValue;
  2029. break;
  2030. case 'defaultValue':
  2031. defaultValue = propValue;
  2032. break;
  2033. case 'dangerouslySetInnerHTML':
  2034. throw new Error('`dangerouslySetInnerHTML` does not make sense on <textarea>.');
  2035. // eslint-disable-next-line-no-fallthrough
  2036. default:
  2037. pushAttribute(target, responseState, propKey, propValue);
  2038. break;
  2039. }
  2040. }
  2041. }
  2042. if (value === null && defaultValue !== null) {
  2043. value = defaultValue;
  2044. }
  2045. target.push(endOfStartTag); // TODO (yungsters): Remove support for children content in <textarea>.
  2046. if (children != null) {
  2047. {
  2048. error('Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.');
  2049. }
  2050. if (value != null) {
  2051. throw new Error('If you supply `defaultValue` on a <textarea>, do not pass children.');
  2052. }
  2053. if (isArray(children)) {
  2054. if (children.length > 1) {
  2055. throw new Error('<textarea> can only have at most one child.');
  2056. } // TODO: remove the coercion and the DEV check below because it will
  2057. // always be overwritten by the coercion several lines below it. #22309
  2058. {
  2059. checkHtmlStringCoercion(children[0]);
  2060. }
  2061. value = '' + children[0];
  2062. }
  2063. {
  2064. checkHtmlStringCoercion(children);
  2065. }
  2066. value = '' + children;
  2067. }
  2068. if (typeof value === 'string' && value[0] === '\n') {
  2069. // text/html ignores the first character in these tags if it's a newline
  2070. // Prefer to break application/xml over text/html (for now) by adding
  2071. // a newline specifically to get eaten by the parser. (Alternately for
  2072. // textareas, replacing "^\n" with "\r\n" doesn't get eaten, and the first
  2073. // \r is normalized out by HTMLTextAreaElement#value.)
  2074. // See: <http://www.w3.org/TR/html-polyglot/#newlines-in-textarea-and-pre>
  2075. // See: <http://www.w3.org/TR/html5/syntax.html#element-restrictions>
  2076. // See: <http://www.w3.org/TR/html5/syntax.html#newlines>
  2077. // See: Parsing of "textarea" "listing" and "pre" elements
  2078. // from <http://www.w3.org/TR/html5/syntax.html#parsing-main-inbody>
  2079. target.push(leadingNewline);
  2080. } // ToString and push directly instead of recurse over children.
  2081. // We don't really support complex children in the value anyway.
  2082. // This also currently avoids a trailing comment node which breaks textarea.
  2083. if (value !== null) {
  2084. {
  2085. checkAttributeStringCoercion(value, 'value');
  2086. }
  2087. target.push(stringToChunk(encodeHTMLTextNode('' + value)));
  2088. }
  2089. return null;
  2090. }
  2091. function pushSelfClosing(target, props, tag, responseState) {
  2092. target.push(startChunkForTag(tag));
  2093. for (var propKey in props) {
  2094. if (hasOwnProperty.call(props, propKey)) {
  2095. var propValue = props[propKey];
  2096. if (propValue == null) {
  2097. continue;
  2098. }
  2099. switch (propKey) {
  2100. case 'children':
  2101. case 'dangerouslySetInnerHTML':
  2102. throw new Error(tag + " is a self-closing tag and must neither have `children` nor " + 'use `dangerouslySetInnerHTML`.');
  2103. // eslint-disable-next-line-no-fallthrough
  2104. default:
  2105. pushAttribute(target, responseState, propKey, propValue);
  2106. break;
  2107. }
  2108. }
  2109. }
  2110. target.push(endOfStartTagSelfClosing);
  2111. return null;
  2112. }
  2113. function pushStartMenuItem(target, props, responseState) {
  2114. target.push(startChunkForTag('menuitem'));
  2115. for (var propKey in props) {
  2116. if (hasOwnProperty.call(props, propKey)) {
  2117. var propValue = props[propKey];
  2118. if (propValue == null) {
  2119. continue;
  2120. }
  2121. switch (propKey) {
  2122. case 'children':
  2123. case 'dangerouslySetInnerHTML':
  2124. throw new Error('menuitems cannot have `children` nor `dangerouslySetInnerHTML`.');
  2125. // eslint-disable-next-line-no-fallthrough
  2126. default:
  2127. pushAttribute(target, responseState, propKey, propValue);
  2128. break;
  2129. }
  2130. }
  2131. }
  2132. target.push(endOfStartTag);
  2133. return null;
  2134. }
  2135. function pushStartTitle(target, props, responseState) {
  2136. target.push(startChunkForTag('title'));
  2137. var children = null;
  2138. for (var propKey in props) {
  2139. if (hasOwnProperty.call(props, propKey)) {
  2140. var propValue = props[propKey];
  2141. if (propValue == null) {
  2142. continue;
  2143. }
  2144. switch (propKey) {
  2145. case 'children':
  2146. children = propValue;
  2147. break;
  2148. case 'dangerouslySetInnerHTML':
  2149. throw new Error('`dangerouslySetInnerHTML` does not make sense on <title>.');
  2150. // eslint-disable-next-line-no-fallthrough
  2151. default:
  2152. pushAttribute(target, responseState, propKey, propValue);
  2153. break;
  2154. }
  2155. }
  2156. }
  2157. target.push(endOfStartTag);
  2158. {
  2159. var child = Array.isArray(children) && children.length < 2 ? children[0] || null : children;
  2160. if (Array.isArray(children) && children.length > 1) {
  2161. error('A title element received an array with more than 1 element as children. ' + 'In browsers title Elements can only have Text Nodes as children. If ' + 'the children being rendered output more than a single text node in aggregate the browser ' + 'will display markup and comments as text in the title and hydration will likely fail and ' + 'fall back to client rendering');
  2162. } else if (child != null && child.$$typeof != null) {
  2163. error('A title element received a React element for children. ' + 'In the browser title Elements can only have Text Nodes as children. If ' + 'the children being rendered output more than a single text node in aggregate the browser ' + 'will display markup and comments as text in the title and hydration will likely fail and ' + 'fall back to client rendering');
  2164. } else if (child != null && typeof child !== 'string' && typeof child !== 'number') {
  2165. error('A title element received a value that was not a string or number for children. ' + 'In the browser title Elements can only have Text Nodes as children. If ' + 'the children being rendered output more than a single text node in aggregate the browser ' + 'will display markup and comments as text in the title and hydration will likely fail and ' + 'fall back to client rendering');
  2166. }
  2167. }
  2168. return children;
  2169. }
  2170. function pushStartGenericElement(target, props, tag, responseState) {
  2171. target.push(startChunkForTag(tag));
  2172. var children = null;
  2173. var innerHTML = null;
  2174. for (var propKey in props) {
  2175. if (hasOwnProperty.call(props, propKey)) {
  2176. var propValue = props[propKey];
  2177. if (propValue == null) {
  2178. continue;
  2179. }
  2180. switch (propKey) {
  2181. case 'children':
  2182. children = propValue;
  2183. break;
  2184. case 'dangerouslySetInnerHTML':
  2185. innerHTML = propValue;
  2186. break;
  2187. default:
  2188. pushAttribute(target, responseState, propKey, propValue);
  2189. break;
  2190. }
  2191. }
  2192. }
  2193. target.push(endOfStartTag);
  2194. pushInnerHTML(target, innerHTML, children);
  2195. if (typeof children === 'string') {
  2196. // Special case children as a string to avoid the unnecessary comment.
  2197. // TODO: Remove this special case after the general optimization is in place.
  2198. target.push(stringToChunk(encodeHTMLTextNode(children)));
  2199. return null;
  2200. }
  2201. return children;
  2202. }
  2203. function pushStartCustomElement(target, props, tag, responseState) {
  2204. target.push(startChunkForTag(tag));
  2205. var children = null;
  2206. var innerHTML = null;
  2207. for (var propKey in props) {
  2208. if (hasOwnProperty.call(props, propKey)) {
  2209. var propValue = props[propKey];
  2210. if (propValue == null) {
  2211. continue;
  2212. }
  2213. switch (propKey) {
  2214. case 'children':
  2215. children = propValue;
  2216. break;
  2217. case 'dangerouslySetInnerHTML':
  2218. innerHTML = propValue;
  2219. break;
  2220. case 'style':
  2221. pushStyle(target, responseState, propValue);
  2222. break;
  2223. case 'suppressContentEditableWarning':
  2224. case 'suppressHydrationWarning':
  2225. // Ignored. These are built-in to React on the client.
  2226. break;
  2227. default:
  2228. if (isAttributeNameSafe(propKey) && typeof propValue !== 'function' && typeof propValue !== 'symbol') {
  2229. target.push(attributeSeparator, stringToChunk(propKey), attributeAssign, stringToChunk(escapeTextForBrowser(propValue)), attributeEnd);
  2230. }
  2231. break;
  2232. }
  2233. }
  2234. }
  2235. target.push(endOfStartTag);
  2236. pushInnerHTML(target, innerHTML, children);
  2237. return children;
  2238. }
  2239. var leadingNewline = stringToPrecomputedChunk('\n');
  2240. function pushStartPreformattedElement(target, props, tag, responseState) {
  2241. target.push(startChunkForTag(tag));
  2242. var children = null;
  2243. var innerHTML = null;
  2244. for (var propKey in props) {
  2245. if (hasOwnProperty.call(props, propKey)) {
  2246. var propValue = props[propKey];
  2247. if (propValue == null) {
  2248. continue;
  2249. }
  2250. switch (propKey) {
  2251. case 'children':
  2252. children = propValue;
  2253. break;
  2254. case 'dangerouslySetInnerHTML':
  2255. innerHTML = propValue;
  2256. break;
  2257. default:
  2258. pushAttribute(target, responseState, propKey, propValue);
  2259. break;
  2260. }
  2261. }
  2262. }
  2263. target.push(endOfStartTag); // text/html ignores the first character in these tags if it's a newline
  2264. // Prefer to break application/xml over text/html (for now) by adding
  2265. // a newline specifically to get eaten by the parser. (Alternately for
  2266. // textareas, replacing "^\n" with "\r\n" doesn't get eaten, and the first
  2267. // \r is normalized out by HTMLTextAreaElement#value.)
  2268. // See: <http://www.w3.org/TR/html-polyglot/#newlines-in-textarea-and-pre>
  2269. // See: <http://www.w3.org/TR/html5/syntax.html#element-restrictions>
  2270. // See: <http://www.w3.org/TR/html5/syntax.html#newlines>
  2271. // See: Parsing of "textarea" "listing" and "pre" elements
  2272. // from <http://www.w3.org/TR/html5/syntax.html#parsing-main-inbody>
  2273. // TODO: This doesn't deal with the case where the child is an array
  2274. // or component that returns a string.
  2275. if (innerHTML != null) {
  2276. if (children != null) {
  2277. throw new Error('Can only set one of `children` or `props.dangerouslySetInnerHTML`.');
  2278. }
  2279. if (typeof innerHTML !== 'object' || !('__html' in innerHTML)) {
  2280. throw new Error('`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' + 'Please visit https://reactjs.org/link/dangerously-set-inner-html ' + 'for more information.');
  2281. }
  2282. var html = innerHTML.__html;
  2283. if (html !== null && html !== undefined) {
  2284. if (typeof html === 'string' && html.length > 0 && html[0] === '\n') {
  2285. target.push(leadingNewline, stringToChunk(html));
  2286. } else {
  2287. {
  2288. checkHtmlStringCoercion(html);
  2289. }
  2290. target.push(stringToChunk('' + html));
  2291. }
  2292. }
  2293. }
  2294. if (typeof children === 'string' && children[0] === '\n') {
  2295. target.push(leadingNewline);
  2296. }
  2297. return children;
  2298. } // We accept any tag to be rendered but since this gets injected into arbitrary
  2299. // HTML, we want to make sure that it's a safe tag.
  2300. // http://www.w3.org/TR/REC-xml/#NT-Name
  2301. var VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/; // Simplified subset
  2302. var validatedTagCache = new Map();
  2303. function startChunkForTag(tag) {
  2304. var tagStartChunk = validatedTagCache.get(tag);
  2305. if (tagStartChunk === undefined) {
  2306. if (!VALID_TAG_REGEX.test(tag)) {
  2307. throw new Error("Invalid tag: " + tag);
  2308. }
  2309. tagStartChunk = stringToPrecomputedChunk('<' + tag);
  2310. validatedTagCache.set(tag, tagStartChunk);
  2311. }
  2312. return tagStartChunk;
  2313. }
  2314. var DOCTYPE = stringToPrecomputedChunk('<!DOCTYPE html>');
  2315. function pushStartInstance(target, type, props, responseState, formatContext) {
  2316. {
  2317. validateProperties(type, props);
  2318. validateProperties$1(type, props);
  2319. validateProperties$2(type, props, null);
  2320. if (!props.suppressContentEditableWarning && props.contentEditable && props.children != null) {
  2321. error('A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.');
  2322. }
  2323. if (formatContext.insertionMode !== SVG_MODE && formatContext.insertionMode !== MATHML_MODE) {
  2324. if (type.indexOf('-') === -1 && typeof props.is !== 'string' && type.toLowerCase() !== type) {
  2325. error('<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', type);
  2326. }
  2327. }
  2328. }
  2329. switch (type) {
  2330. // Special tags
  2331. case 'select':
  2332. return pushStartSelect(target, props, responseState);
  2333. case 'option':
  2334. return pushStartOption(target, props, responseState, formatContext);
  2335. case 'textarea':
  2336. return pushStartTextArea(target, props, responseState);
  2337. case 'input':
  2338. return pushInput(target, props, responseState);
  2339. case 'menuitem':
  2340. return pushStartMenuItem(target, props, responseState);
  2341. case 'title':
  2342. return pushStartTitle(target, props, responseState);
  2343. // Newline eating tags
  2344. case 'listing':
  2345. case 'pre':
  2346. {
  2347. return pushStartPreformattedElement(target, props, type, responseState);
  2348. }
  2349. // Omitted close tags
  2350. case 'area':
  2351. case 'base':
  2352. case 'br':
  2353. case 'col':
  2354. case 'embed':
  2355. case 'hr':
  2356. case 'img':
  2357. case 'keygen':
  2358. case 'link':
  2359. case 'meta':
  2360. case 'param':
  2361. case 'source':
  2362. case 'track':
  2363. case 'wbr':
  2364. {
  2365. return pushSelfClosing(target, props, type, responseState);
  2366. }
  2367. // These are reserved SVG and MathML elements, that are never custom elements.
  2368. // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
  2369. case 'annotation-xml':
  2370. case 'color-profile':
  2371. case 'font-face':
  2372. case 'font-face-src':
  2373. case 'font-face-uri':
  2374. case 'font-face-format':
  2375. case 'font-face-name':
  2376. case 'missing-glyph':
  2377. {
  2378. return pushStartGenericElement(target, props, type, responseState);
  2379. }
  2380. case 'html':
  2381. {
  2382. if (formatContext.insertionMode === ROOT_HTML_MODE) {
  2383. // If we're rendering the html tag and we're at the root (i.e. not in foreignObject)
  2384. // then we also emit the DOCTYPE as part of the root content as a convenience for
  2385. // rendering the whole document.
  2386. target.push(DOCTYPE);
  2387. }
  2388. return pushStartGenericElement(target, props, type, responseState);
  2389. }
  2390. default:
  2391. {
  2392. if (type.indexOf('-') === -1 && typeof props.is !== 'string') {
  2393. // Generic element
  2394. return pushStartGenericElement(target, props, type, responseState);
  2395. } else {
  2396. // Custom element
  2397. return pushStartCustomElement(target, props, type, responseState);
  2398. }
  2399. }
  2400. }
  2401. }
  2402. var endTag1 = stringToPrecomputedChunk('</');
  2403. var endTag2 = stringToPrecomputedChunk('>');
  2404. function pushEndInstance(target, type, props) {
  2405. switch (type) {
  2406. // Omitted close tags
  2407. // TODO: Instead of repeating this switch we could try to pass a flag from above.
  2408. // That would require returning a tuple. Which might be ok if it gets inlined.
  2409. case 'area':
  2410. case 'base':
  2411. case 'br':
  2412. case 'col':
  2413. case 'embed':
  2414. case 'hr':
  2415. case 'img':
  2416. case 'input':
  2417. case 'keygen':
  2418. case 'link':
  2419. case 'meta':
  2420. case 'param':
  2421. case 'source':
  2422. case 'track':
  2423. case 'wbr':
  2424. {
  2425. // No close tag needed.
  2426. break;
  2427. }
  2428. default:
  2429. {
  2430. target.push(endTag1, stringToChunk(type), endTag2);
  2431. }
  2432. }
  2433. }
  2434. function writeCompletedRoot(destination, responseState) {
  2435. var bootstrapChunks = responseState.bootstrapChunks;
  2436. var i = 0;
  2437. for (; i < bootstrapChunks.length - 1; i++) {
  2438. writeChunk(destination, bootstrapChunks[i]);
  2439. }
  2440. if (i < bootstrapChunks.length) {
  2441. return writeChunkAndReturn(destination, bootstrapChunks[i]);
  2442. }
  2443. return true;
  2444. } // Structural Nodes
  2445. // A placeholder is a node inside a hidden partial tree that can be filled in later, but before
  2446. // display. It's never visible to users. We use the template tag because it can be used in every
  2447. // type of parent. <script> tags also work in every other tag except <colgroup>.
  2448. var placeholder1 = stringToPrecomputedChunk('<template id="');
  2449. var placeholder2 = stringToPrecomputedChunk('"></template>');
  2450. function writePlaceholder(destination, responseState, id) {
  2451. writeChunk(destination, placeholder1);
  2452. writeChunk(destination, responseState.placeholderPrefix);
  2453. var formattedID = stringToChunk(id.toString(16));
  2454. writeChunk(destination, formattedID);
  2455. return writeChunkAndReturn(destination, placeholder2);
  2456. } // Suspense boundaries are encoded as comments.
  2457. var startCompletedSuspenseBoundary = stringToPrecomputedChunk('<!--$-->');
  2458. var startPendingSuspenseBoundary1 = stringToPrecomputedChunk('<!--$?--><template id="');
  2459. var startPendingSuspenseBoundary2 = stringToPrecomputedChunk('"></template>');
  2460. var startClientRenderedSuspenseBoundary = stringToPrecomputedChunk('<!--$!-->');
  2461. var endSuspenseBoundary = stringToPrecomputedChunk('<!--/$-->');
  2462. var clientRenderedSuspenseBoundaryError1 = stringToPrecomputedChunk('<template');
  2463. var clientRenderedSuspenseBoundaryErrorAttrInterstitial = stringToPrecomputedChunk('"');
  2464. var clientRenderedSuspenseBoundaryError1A = stringToPrecomputedChunk(' data-dgst="');
  2465. var clientRenderedSuspenseBoundaryError1B = stringToPrecomputedChunk(' data-msg="');
  2466. var clientRenderedSuspenseBoundaryError1C = stringToPrecomputedChunk(' data-stck="');
  2467. var clientRenderedSuspenseBoundaryError2 = stringToPrecomputedChunk('></template>');
  2468. function writeStartCompletedSuspenseBoundary(destination, responseState) {
  2469. return writeChunkAndReturn(destination, startCompletedSuspenseBoundary);
  2470. }
  2471. function writeStartPendingSuspenseBoundary(destination, responseState, id) {
  2472. writeChunk(destination, startPendingSuspenseBoundary1);
  2473. if (id === null) {
  2474. throw new Error('An ID must have been assigned before we can complete the boundary.');
  2475. }
  2476. writeChunk(destination, id);
  2477. return writeChunkAndReturn(destination, startPendingSuspenseBoundary2);
  2478. }
  2479. function writeStartClientRenderedSuspenseBoundary(destination, responseState, errorDigest, errorMesssage, errorComponentStack) {
  2480. var result;
  2481. result = writeChunkAndReturn(destination, startClientRenderedSuspenseBoundary);
  2482. writeChunk(destination, clientRenderedSuspenseBoundaryError1);
  2483. if (errorDigest) {
  2484. writeChunk(destination, clientRenderedSuspenseBoundaryError1A);
  2485. writeChunk(destination, stringToChunk(escapeTextForBrowser(errorDigest)));
  2486. writeChunk(destination, clientRenderedSuspenseBoundaryErrorAttrInterstitial);
  2487. }
  2488. {
  2489. if (errorMesssage) {
  2490. writeChunk(destination, clientRenderedSuspenseBoundaryError1B);
  2491. writeChunk(destination, stringToChunk(escapeTextForBrowser(errorMesssage)));
  2492. writeChunk(destination, clientRenderedSuspenseBoundaryErrorAttrInterstitial);
  2493. }
  2494. if (errorComponentStack) {
  2495. writeChunk(destination, clientRenderedSuspenseBoundaryError1C);
  2496. writeChunk(destination, stringToChunk(escapeTextForBrowser(errorComponentStack)));
  2497. writeChunk(destination, clientRenderedSuspenseBoundaryErrorAttrInterstitial);
  2498. }
  2499. }
  2500. result = writeChunkAndReturn(destination, clientRenderedSuspenseBoundaryError2);
  2501. return result;
  2502. }
  2503. function writeEndCompletedSuspenseBoundary(destination, responseState) {
  2504. return writeChunkAndReturn(destination, endSuspenseBoundary);
  2505. }
  2506. function writeEndPendingSuspenseBoundary(destination, responseState) {
  2507. return writeChunkAndReturn(destination, endSuspenseBoundary);
  2508. }
  2509. function writeEndClientRenderedSuspenseBoundary(destination, responseState) {
  2510. return writeChunkAndReturn(destination, endSuspenseBoundary);
  2511. }
  2512. var startSegmentHTML = stringToPrecomputedChunk('<div hidden id="');
  2513. var startSegmentHTML2 = stringToPrecomputedChunk('">');
  2514. var endSegmentHTML = stringToPrecomputedChunk('</div>');
  2515. var startSegmentSVG = stringToPrecomputedChunk('<svg aria-hidden="true" style="display:none" id="');
  2516. var startSegmentSVG2 = stringToPrecomputedChunk('">');
  2517. var endSegmentSVG = stringToPrecomputedChunk('</svg>');
  2518. var startSegmentMathML = stringToPrecomputedChunk('<math aria-hidden="true" style="display:none" id="');
  2519. var startSegmentMathML2 = stringToPrecomputedChunk('">');
  2520. var endSegmentMathML = stringToPrecomputedChunk('</math>');
  2521. var startSegmentTable = stringToPrecomputedChunk('<table hidden id="');
  2522. var startSegmentTable2 = stringToPrecomputedChunk('">');
  2523. var endSegmentTable = stringToPrecomputedChunk('</table>');
  2524. var startSegmentTableBody = stringToPrecomputedChunk('<table hidden><tbody id="');
  2525. var startSegmentTableBody2 = stringToPrecomputedChunk('">');
  2526. var endSegmentTableBody = stringToPrecomputedChunk('</tbody></table>');
  2527. var startSegmentTableRow = stringToPrecomputedChunk('<table hidden><tr id="');
  2528. var startSegmentTableRow2 = stringToPrecomputedChunk('">');
  2529. var endSegmentTableRow = stringToPrecomputedChunk('</tr></table>');
  2530. var startSegmentColGroup = stringToPrecomputedChunk('<table hidden><colgroup id="');
  2531. var startSegmentColGroup2 = stringToPrecomputedChunk('">');
  2532. var endSegmentColGroup = stringToPrecomputedChunk('</colgroup></table>');
  2533. function writeStartSegment(destination, responseState, formatContext, id) {
  2534. switch (formatContext.insertionMode) {
  2535. case ROOT_HTML_MODE:
  2536. case HTML_MODE:
  2537. {
  2538. writeChunk(destination, startSegmentHTML);
  2539. writeChunk(destination, responseState.segmentPrefix);
  2540. writeChunk(destination, stringToChunk(id.toString(16)));
  2541. return writeChunkAndReturn(destination, startSegmentHTML2);
  2542. }
  2543. case SVG_MODE:
  2544. {
  2545. writeChunk(destination, startSegmentSVG);
  2546. writeChunk(destination, responseState.segmentPrefix);
  2547. writeChunk(destination, stringToChunk(id.toString(16)));
  2548. return writeChunkAndReturn(destination, startSegmentSVG2);
  2549. }
  2550. case MATHML_MODE:
  2551. {
  2552. writeChunk(destination, startSegmentMathML);
  2553. writeChunk(destination, responseState.segmentPrefix);
  2554. writeChunk(destination, stringToChunk(id.toString(16)));
  2555. return writeChunkAndReturn(destination, startSegmentMathML2);
  2556. }
  2557. case HTML_TABLE_MODE:
  2558. {
  2559. writeChunk(destination, startSegmentTable);
  2560. writeChunk(destination, responseState.segmentPrefix);
  2561. writeChunk(destination, stringToChunk(id.toString(16)));
  2562. return writeChunkAndReturn(destination, startSegmentTable2);
  2563. }
  2564. // TODO: For the rest of these, there will be extra wrapper nodes that never
  2565. // get deleted from the document. We need to delete the table too as part
  2566. // of the injected scripts. They are invisible though so it's not too terrible
  2567. // and it's kind of an edge case to suspend in a table. Totally supported though.
  2568. case HTML_TABLE_BODY_MODE:
  2569. {
  2570. writeChunk(destination, startSegmentTableBody);
  2571. writeChunk(destination, responseState.segmentPrefix);
  2572. writeChunk(destination, stringToChunk(id.toString(16)));
  2573. return writeChunkAndReturn(destination, startSegmentTableBody2);
  2574. }
  2575. case HTML_TABLE_ROW_MODE:
  2576. {
  2577. writeChunk(destination, startSegmentTableRow);
  2578. writeChunk(destination, responseState.segmentPrefix);
  2579. writeChunk(destination, stringToChunk(id.toString(16)));
  2580. return writeChunkAndReturn(destination, startSegmentTableRow2);
  2581. }
  2582. case HTML_COLGROUP_MODE:
  2583. {
  2584. writeChunk(destination, startSegmentColGroup);
  2585. writeChunk(destination, responseState.segmentPrefix);
  2586. writeChunk(destination, stringToChunk(id.toString(16)));
  2587. return writeChunkAndReturn(destination, startSegmentColGroup2);
  2588. }
  2589. default:
  2590. {
  2591. throw new Error('Unknown insertion mode. This is a bug in React.');
  2592. }
  2593. }
  2594. }
  2595. function writeEndSegment(destination, formatContext) {
  2596. switch (formatContext.insertionMode) {
  2597. case ROOT_HTML_MODE:
  2598. case HTML_MODE:
  2599. {
  2600. return writeChunkAndReturn(destination, endSegmentHTML);
  2601. }
  2602. case SVG_MODE:
  2603. {
  2604. return writeChunkAndReturn(destination, endSegmentSVG);
  2605. }
  2606. case MATHML_MODE:
  2607. {
  2608. return writeChunkAndReturn(destination, endSegmentMathML);
  2609. }
  2610. case HTML_TABLE_MODE:
  2611. {
  2612. return writeChunkAndReturn(destination, endSegmentTable);
  2613. }
  2614. case HTML_TABLE_BODY_MODE:
  2615. {
  2616. return writeChunkAndReturn(destination, endSegmentTableBody);
  2617. }
  2618. case HTML_TABLE_ROW_MODE:
  2619. {
  2620. return writeChunkAndReturn(destination, endSegmentTableRow);
  2621. }
  2622. case HTML_COLGROUP_MODE:
  2623. {
  2624. return writeChunkAndReturn(destination, endSegmentColGroup);
  2625. }
  2626. default:
  2627. {
  2628. throw new Error('Unknown insertion mode. This is a bug in React.');
  2629. }
  2630. }
  2631. } // Instruction Set
  2632. // The following code is the source scripts that we then minify and inline below,
  2633. // with renamed function names that we hope don't collide:
  2634. // const COMMENT_NODE = 8;
  2635. // const SUSPENSE_START_DATA = '$';
  2636. // const SUSPENSE_END_DATA = '/$';
  2637. // const SUSPENSE_PENDING_START_DATA = '$?';
  2638. // const SUSPENSE_FALLBACK_START_DATA = '$!';
  2639. //
  2640. // function clientRenderBoundary(suspenseBoundaryID, errorDigest, errorMsg, errorComponentStack) {
  2641. // // Find the fallback's first element.
  2642. // const suspenseIdNode = document.getElementById(suspenseBoundaryID);
  2643. // if (!suspenseIdNode) {
  2644. // // The user must have already navigated away from this tree.
  2645. // // E.g. because the parent was hydrated.
  2646. // return;
  2647. // }
  2648. // // Find the boundary around the fallback. This is always the previous node.
  2649. // const suspenseNode = suspenseIdNode.previousSibling;
  2650. // // Tag it to be client rendered.
  2651. // suspenseNode.data = SUSPENSE_FALLBACK_START_DATA;
  2652. // // assign error metadata to first sibling
  2653. // let dataset = suspenseIdNode.dataset;
  2654. // if (errorDigest) dataset.dgst = errorDigest;
  2655. // if (errorMsg) dataset.msg = errorMsg;
  2656. // if (errorComponentStack) dataset.stck = errorComponentStack;
  2657. // // Tell React to retry it if the parent already hydrated.
  2658. // if (suspenseNode._reactRetry) {
  2659. // suspenseNode._reactRetry();
  2660. // }
  2661. // }
  2662. //
  2663. // function completeBoundary(suspenseBoundaryID, contentID) {
  2664. // // Find the fallback's first element.
  2665. // const suspenseIdNode = document.getElementById(suspenseBoundaryID);
  2666. // const contentNode = document.getElementById(contentID);
  2667. // // We'll detach the content node so that regardless of what happens next we don't leave in the tree.
  2668. // // This might also help by not causing recalcing each time we move a child from here to the target.
  2669. // contentNode.parentNode.removeChild(contentNode);
  2670. // if (!suspenseIdNode) {
  2671. // // The user must have already navigated away from this tree.
  2672. // // E.g. because the parent was hydrated. That's fine there's nothing to do
  2673. // // but we have to make sure that we already deleted the container node.
  2674. // return;
  2675. // }
  2676. // // Find the boundary around the fallback. This is always the previous node.
  2677. // const suspenseNode = suspenseIdNode.previousSibling;
  2678. //
  2679. // // Clear all the existing children. This is complicated because
  2680. // // there can be embedded Suspense boundaries in the fallback.
  2681. // // This is similar to clearSuspenseBoundary in ReactDOMHostConfig.
  2682. // // TODO: We could avoid this if we never emitted suspense boundaries in fallback trees.
  2683. // // They never hydrate anyway. However, currently we support incrementally loading the fallback.
  2684. // const parentInstance = suspenseNode.parentNode;
  2685. // let node = suspenseNode.nextSibling;
  2686. // let depth = 0;
  2687. // do {
  2688. // if (node && node.nodeType === COMMENT_NODE) {
  2689. // const data = node.data;
  2690. // if (data === SUSPENSE_END_DATA) {
  2691. // if (depth === 0) {
  2692. // break;
  2693. // } else {
  2694. // depth--;
  2695. // }
  2696. // } else if (
  2697. // data === SUSPENSE_START_DATA ||
  2698. // data === SUSPENSE_PENDING_START_DATA ||
  2699. // data === SUSPENSE_FALLBACK_START_DATA
  2700. // ) {
  2701. // depth++;
  2702. // }
  2703. // }
  2704. //
  2705. // const nextNode = node.nextSibling;
  2706. // parentInstance.removeChild(node);
  2707. // node = nextNode;
  2708. // } while (node);
  2709. //
  2710. // const endOfBoundary = node;
  2711. //
  2712. // // Insert all the children from the contentNode between the start and end of suspense boundary.
  2713. // while (contentNode.firstChild) {
  2714. // parentInstance.insertBefore(contentNode.firstChild, endOfBoundary);
  2715. // }
  2716. // suspenseNode.data = SUSPENSE_START_DATA;
  2717. // if (suspenseNode._reactRetry) {
  2718. // suspenseNode._reactRetry();
  2719. // }
  2720. // }
  2721. //
  2722. // function completeSegment(containerID, placeholderID) {
  2723. // const segmentContainer = document.getElementById(containerID);
  2724. // const placeholderNode = document.getElementById(placeholderID);
  2725. // // We always expect both nodes to exist here because, while we might
  2726. // // have navigated away from the main tree, we still expect the detached
  2727. // // tree to exist.
  2728. // segmentContainer.parentNode.removeChild(segmentContainer);
  2729. // while (segmentContainer.firstChild) {
  2730. // placeholderNode.parentNode.insertBefore(
  2731. // segmentContainer.firstChild,
  2732. // placeholderNode,
  2733. // );
  2734. // }
  2735. // placeholderNode.parentNode.removeChild(placeholderNode);
  2736. // }
  2737. var completeSegmentFunction = 'function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)}';
  2738. var completeBoundaryFunction = 'function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}}';
  2739. var clientRenderFunction = 'function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())}';
  2740. var completeSegmentScript1Full = stringToPrecomputedChunk(completeSegmentFunction + ';$RS("');
  2741. var completeSegmentScript1Partial = stringToPrecomputedChunk('$RS("');
  2742. var completeSegmentScript2 = stringToPrecomputedChunk('","');
  2743. var completeSegmentScript3 = stringToPrecomputedChunk('")</script>');
  2744. function writeCompletedSegmentInstruction(destination, responseState, contentSegmentID) {
  2745. writeChunk(destination, responseState.startInlineScript);
  2746. if (!responseState.sentCompleteSegmentFunction) {
  2747. // The first time we write this, we'll need to include the full implementation.
  2748. responseState.sentCompleteSegmentFunction = true;
  2749. writeChunk(destination, completeSegmentScript1Full);
  2750. } else {
  2751. // Future calls can just reuse the same function.
  2752. writeChunk(destination, completeSegmentScript1Partial);
  2753. }
  2754. writeChunk(destination, responseState.segmentPrefix);
  2755. var formattedID = stringToChunk(contentSegmentID.toString(16));
  2756. writeChunk(destination, formattedID);
  2757. writeChunk(destination, completeSegmentScript2);
  2758. writeChunk(destination, responseState.placeholderPrefix);
  2759. writeChunk(destination, formattedID);
  2760. return writeChunkAndReturn(destination, completeSegmentScript3);
  2761. }
  2762. var completeBoundaryScript1Full = stringToPrecomputedChunk(completeBoundaryFunction + ';$RC("');
  2763. var completeBoundaryScript1Partial = stringToPrecomputedChunk('$RC("');
  2764. var completeBoundaryScript2 = stringToPrecomputedChunk('","');
  2765. var completeBoundaryScript3 = stringToPrecomputedChunk('")</script>');
  2766. function writeCompletedBoundaryInstruction(destination, responseState, boundaryID, contentSegmentID) {
  2767. writeChunk(destination, responseState.startInlineScript);
  2768. if (!responseState.sentCompleteBoundaryFunction) {
  2769. // The first time we write this, we'll need to include the full implementation.
  2770. responseState.sentCompleteBoundaryFunction = true;
  2771. writeChunk(destination, completeBoundaryScript1Full);
  2772. } else {
  2773. // Future calls can just reuse the same function.
  2774. writeChunk(destination, completeBoundaryScript1Partial);
  2775. }
  2776. if (boundaryID === null) {
  2777. throw new Error('An ID must have been assigned before we can complete the boundary.');
  2778. }
  2779. var formattedContentID = stringToChunk(contentSegmentID.toString(16));
  2780. writeChunk(destination, boundaryID);
  2781. writeChunk(destination, completeBoundaryScript2);
  2782. writeChunk(destination, responseState.segmentPrefix);
  2783. writeChunk(destination, formattedContentID);
  2784. return writeChunkAndReturn(destination, completeBoundaryScript3);
  2785. }
  2786. var clientRenderScript1Full = stringToPrecomputedChunk(clientRenderFunction + ';$RX("');
  2787. var clientRenderScript1Partial = stringToPrecomputedChunk('$RX("');
  2788. var clientRenderScript1A = stringToPrecomputedChunk('"');
  2789. var clientRenderScript2 = stringToPrecomputedChunk(')</script>');
  2790. var clientRenderErrorScriptArgInterstitial = stringToPrecomputedChunk(',');
  2791. function writeClientRenderBoundaryInstruction(destination, responseState, boundaryID, errorDigest, errorMessage, errorComponentStack) {
  2792. writeChunk(destination, responseState.startInlineScript);
  2793. if (!responseState.sentClientRenderFunction) {
  2794. // The first time we write this, we'll need to include the full implementation.
  2795. responseState.sentClientRenderFunction = true;
  2796. writeChunk(destination, clientRenderScript1Full);
  2797. } else {
  2798. // Future calls can just reuse the same function.
  2799. writeChunk(destination, clientRenderScript1Partial);
  2800. }
  2801. if (boundaryID === null) {
  2802. throw new Error('An ID must have been assigned before we can complete the boundary.');
  2803. }
  2804. writeChunk(destination, boundaryID);
  2805. writeChunk(destination, clientRenderScript1A);
  2806. if (errorDigest || errorMessage || errorComponentStack) {
  2807. writeChunk(destination, clientRenderErrorScriptArgInterstitial);
  2808. writeChunk(destination, stringToChunk(escapeJSStringsForInstructionScripts(errorDigest || '')));
  2809. }
  2810. if (errorMessage || errorComponentStack) {
  2811. writeChunk(destination, clientRenderErrorScriptArgInterstitial);
  2812. writeChunk(destination, stringToChunk(escapeJSStringsForInstructionScripts(errorMessage || '')));
  2813. }
  2814. if (errorComponentStack) {
  2815. writeChunk(destination, clientRenderErrorScriptArgInterstitial);
  2816. writeChunk(destination, stringToChunk(escapeJSStringsForInstructionScripts(errorComponentStack)));
  2817. }
  2818. return writeChunkAndReturn(destination, clientRenderScript2);
  2819. }
  2820. var regexForJSStringsInScripts = /[<\u2028\u2029]/g;
  2821. function escapeJSStringsForInstructionScripts(input) {
  2822. var escaped = JSON.stringify(input);
  2823. return escaped.replace(regexForJSStringsInScripts, function (match) {
  2824. switch (match) {
  2825. // santizing breaking out of strings and script tags
  2826. case '<':
  2827. return "\\u003c";
  2828. case "\u2028":
  2829. return "\\u2028";
  2830. case "\u2029":
  2831. return "\\u2029";
  2832. default:
  2833. {
  2834. // eslint-disable-next-line react-internal/prod-error-codes
  2835. throw new Error('escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React');
  2836. }
  2837. }
  2838. });
  2839. }
  2840. function createResponseState$1(generateStaticMarkup, identifierPrefix) {
  2841. var responseState = createResponseState(identifierPrefix, undefined);
  2842. return {
  2843. // Keep this in sync with ReactDOMServerFormatConfig
  2844. bootstrapChunks: responseState.bootstrapChunks,
  2845. startInlineScript: responseState.startInlineScript,
  2846. placeholderPrefix: responseState.placeholderPrefix,
  2847. segmentPrefix: responseState.segmentPrefix,
  2848. boundaryPrefix: responseState.boundaryPrefix,
  2849. idPrefix: responseState.idPrefix,
  2850. nextSuspenseID: responseState.nextSuspenseID,
  2851. sentCompleteSegmentFunction: responseState.sentCompleteSegmentFunction,
  2852. sentCompleteBoundaryFunction: responseState.sentCompleteBoundaryFunction,
  2853. sentClientRenderFunction: responseState.sentClientRenderFunction,
  2854. // This is an extra field for the legacy renderer
  2855. generateStaticMarkup: generateStaticMarkup
  2856. };
  2857. }
  2858. function createRootFormatContext() {
  2859. return {
  2860. insertionMode: HTML_MODE,
  2861. // We skip the root mode because we don't want to emit the DOCTYPE in legacy mode.
  2862. selectedValue: null
  2863. };
  2864. }
  2865. function pushTextInstance$1(target, text, responseState, textEmbedded) {
  2866. if (responseState.generateStaticMarkup) {
  2867. target.push(stringToChunk(escapeTextForBrowser(text)));
  2868. return false;
  2869. } else {
  2870. return pushTextInstance(target, text, responseState, textEmbedded);
  2871. }
  2872. }
  2873. function pushSegmentFinale$1(target, responseState, lastPushedText, textEmbedded) {
  2874. if (responseState.generateStaticMarkup) {
  2875. return;
  2876. } else {
  2877. return pushSegmentFinale(target, responseState, lastPushedText, textEmbedded);
  2878. }
  2879. }
  2880. function writeStartCompletedSuspenseBoundary$1(destination, responseState) {
  2881. if (responseState.generateStaticMarkup) {
  2882. // A completed boundary is done and doesn't need a representation in the HTML
  2883. // if we're not going to be hydrating it.
  2884. return true;
  2885. }
  2886. return writeStartCompletedSuspenseBoundary(destination);
  2887. }
  2888. function writeStartClientRenderedSuspenseBoundary$1(destination, responseState, // flushing these error arguments are not currently supported in this legacy streaming format.
  2889. errorDigest, errorMessage, errorComponentStack) {
  2890. if (responseState.generateStaticMarkup) {
  2891. // A client rendered boundary is done and doesn't need a representation in the HTML
  2892. // since we'll never hydrate it. This is arguably an error in static generation.
  2893. return true;
  2894. }
  2895. return writeStartClientRenderedSuspenseBoundary(destination, responseState, errorDigest, errorMessage, errorComponentStack);
  2896. }
  2897. function writeEndCompletedSuspenseBoundary$1(destination, responseState) {
  2898. if (responseState.generateStaticMarkup) {
  2899. return true;
  2900. }
  2901. return writeEndCompletedSuspenseBoundary(destination);
  2902. }
  2903. function writeEndClientRenderedSuspenseBoundary$1(destination, responseState) {
  2904. if (responseState.generateStaticMarkup) {
  2905. return true;
  2906. }
  2907. return writeEndClientRenderedSuspenseBoundary(destination);
  2908. }
  2909. var assign = Object.assign;
  2910. // ATTENTION
  2911. // When adding new symbols to this file,
  2912. // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
  2913. // The Symbol used to tag the ReactElement-like types.
  2914. var REACT_ELEMENT_TYPE = Symbol.for('react.element');
  2915. var REACT_PORTAL_TYPE = Symbol.for('react.portal');
  2916. var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
  2917. var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
  2918. var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
  2919. var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
  2920. var REACT_CONTEXT_TYPE = Symbol.for('react.context');
  2921. var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
  2922. var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
  2923. var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
  2924. var REACT_MEMO_TYPE = Symbol.for('react.memo');
  2925. var REACT_LAZY_TYPE = Symbol.for('react.lazy');
  2926. var REACT_SCOPE_TYPE = Symbol.for('react.scope');
  2927. var REACT_DEBUG_TRACING_MODE_TYPE = Symbol.for('react.debug_trace_mode');
  2928. var REACT_LEGACY_HIDDEN_TYPE = Symbol.for('react.legacy_hidden');
  2929. var REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED = Symbol.for('react.default_value');
  2930. var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
  2931. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  2932. function getIteratorFn(maybeIterable) {
  2933. if (maybeIterable === null || typeof maybeIterable !== 'object') {
  2934. return null;
  2935. }
  2936. var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
  2937. if (typeof maybeIterator === 'function') {
  2938. return maybeIterator;
  2939. }
  2940. return null;
  2941. }
  2942. function getWrappedName(outerType, innerType, wrapperName) {
  2943. var displayName = outerType.displayName;
  2944. if (displayName) {
  2945. return displayName;
  2946. }
  2947. var functionName = innerType.displayName || innerType.name || '';
  2948. return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;
  2949. } // Keep in sync with react-reconciler/getComponentNameFromFiber
  2950. function getContextName(type) {
  2951. return type.displayName || 'Context';
  2952. } // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
  2953. function getComponentNameFromType(type) {
  2954. if (type == null) {
  2955. // Host root, text node or just invalid type.
  2956. return null;
  2957. }
  2958. {
  2959. if (typeof type.tag === 'number') {
  2960. error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
  2961. }
  2962. }
  2963. if (typeof type === 'function') {
  2964. return type.displayName || type.name || null;
  2965. }
  2966. if (typeof type === 'string') {
  2967. return type;
  2968. }
  2969. switch (type) {
  2970. case REACT_FRAGMENT_TYPE:
  2971. return 'Fragment';
  2972. case REACT_PORTAL_TYPE:
  2973. return 'Portal';
  2974. case REACT_PROFILER_TYPE:
  2975. return 'Profiler';
  2976. case REACT_STRICT_MODE_TYPE:
  2977. return 'StrictMode';
  2978. case REACT_SUSPENSE_TYPE:
  2979. return 'Suspense';
  2980. case REACT_SUSPENSE_LIST_TYPE:
  2981. return 'SuspenseList';
  2982. }
  2983. if (typeof type === 'object') {
  2984. switch (type.$$typeof) {
  2985. case REACT_CONTEXT_TYPE:
  2986. var context = type;
  2987. return getContextName(context) + '.Consumer';
  2988. case REACT_PROVIDER_TYPE:
  2989. var provider = type;
  2990. return getContextName(provider._context) + '.Provider';
  2991. case REACT_FORWARD_REF_TYPE:
  2992. return getWrappedName(type, type.render, 'ForwardRef');
  2993. case REACT_MEMO_TYPE:
  2994. var outerName = type.displayName || null;
  2995. if (outerName !== null) {
  2996. return outerName;
  2997. }
  2998. return getComponentNameFromType(type.type) || 'Memo';
  2999. case REACT_LAZY_TYPE:
  3000. {
  3001. var lazyComponent = type;
  3002. var payload = lazyComponent._payload;
  3003. var init = lazyComponent._init;
  3004. try {
  3005. return getComponentNameFromType(init(payload));
  3006. } catch (x) {
  3007. return null;
  3008. }
  3009. }
  3010. // eslint-disable-next-line no-fallthrough
  3011. }
  3012. }
  3013. return null;
  3014. }
  3015. // Helpers to patch console.logs to avoid logging during side-effect free
  3016. // replaying on render function. This currently only patches the object
  3017. // lazily which won't cover if the log function was extracted eagerly.
  3018. // We could also eagerly patch the method.
  3019. var disabledDepth = 0;
  3020. var prevLog;
  3021. var prevInfo;
  3022. var prevWarn;
  3023. var prevError;
  3024. var prevGroup;
  3025. var prevGroupCollapsed;
  3026. var prevGroupEnd;
  3027. function disabledLog() {}
  3028. disabledLog.__reactDisabledLog = true;
  3029. function disableLogs() {
  3030. {
  3031. if (disabledDepth === 0) {
  3032. /* eslint-disable react-internal/no-production-logging */
  3033. prevLog = console.log;
  3034. prevInfo = console.info;
  3035. prevWarn = console.warn;
  3036. prevError = console.error;
  3037. prevGroup = console.group;
  3038. prevGroupCollapsed = console.groupCollapsed;
  3039. prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
  3040. var props = {
  3041. configurable: true,
  3042. enumerable: true,
  3043. value: disabledLog,
  3044. writable: true
  3045. }; // $FlowFixMe Flow thinks console is immutable.
  3046. Object.defineProperties(console, {
  3047. info: props,
  3048. log: props,
  3049. warn: props,
  3050. error: props,
  3051. group: props,
  3052. groupCollapsed: props,
  3053. groupEnd: props
  3054. });
  3055. /* eslint-enable react-internal/no-production-logging */
  3056. }
  3057. disabledDepth++;
  3058. }
  3059. }
  3060. function reenableLogs() {
  3061. {
  3062. disabledDepth--;
  3063. if (disabledDepth === 0) {
  3064. /* eslint-disable react-internal/no-production-logging */
  3065. var props = {
  3066. configurable: true,
  3067. enumerable: true,
  3068. writable: true
  3069. }; // $FlowFixMe Flow thinks console is immutable.
  3070. Object.defineProperties(console, {
  3071. log: assign({}, props, {
  3072. value: prevLog
  3073. }),
  3074. info: assign({}, props, {
  3075. value: prevInfo
  3076. }),
  3077. warn: assign({}, props, {
  3078. value: prevWarn
  3079. }),
  3080. error: assign({}, props, {
  3081. value: prevError
  3082. }),
  3083. group: assign({}, props, {
  3084. value: prevGroup
  3085. }),
  3086. groupCollapsed: assign({}, props, {
  3087. value: prevGroupCollapsed
  3088. }),
  3089. groupEnd: assign({}, props, {
  3090. value: prevGroupEnd
  3091. })
  3092. });
  3093. /* eslint-enable react-internal/no-production-logging */
  3094. }
  3095. if (disabledDepth < 0) {
  3096. error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
  3097. }
  3098. }
  3099. }
  3100. var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
  3101. var prefix;
  3102. function describeBuiltInComponentFrame(name, source, ownerFn) {
  3103. {
  3104. if (prefix === undefined) {
  3105. // Extract the VM specific prefix used by each line.
  3106. try {
  3107. throw Error();
  3108. } catch (x) {
  3109. var match = x.stack.trim().match(/\n( *(at )?)/);
  3110. prefix = match && match[1] || '';
  3111. }
  3112. } // We use the prefix to ensure our stacks line up with native stack frames.
  3113. return '\n' + prefix + name;
  3114. }
  3115. }
  3116. var reentry = false;
  3117. var componentFrameCache;
  3118. {
  3119. var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
  3120. componentFrameCache = new PossiblyWeakMap();
  3121. }
  3122. function describeNativeComponentFrame(fn, construct) {
  3123. // If something asked for a stack inside a fake render, it should get ignored.
  3124. if ( !fn || reentry) {
  3125. return '';
  3126. }
  3127. {
  3128. var frame = componentFrameCache.get(fn);
  3129. if (frame !== undefined) {
  3130. return frame;
  3131. }
  3132. }
  3133. var control;
  3134. reentry = true;
  3135. var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
  3136. Error.prepareStackTrace = undefined;
  3137. var previousDispatcher;
  3138. {
  3139. previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function
  3140. // for warnings.
  3141. ReactCurrentDispatcher.current = null;
  3142. disableLogs();
  3143. }
  3144. try {
  3145. // This should throw.
  3146. if (construct) {
  3147. // Something should be setting the props in the constructor.
  3148. var Fake = function () {
  3149. throw Error();
  3150. }; // $FlowFixMe
  3151. Object.defineProperty(Fake.prototype, 'props', {
  3152. set: function () {
  3153. // We use a throwing setter instead of frozen or non-writable props
  3154. // because that won't throw in a non-strict mode function.
  3155. throw Error();
  3156. }
  3157. });
  3158. if (typeof Reflect === 'object' && Reflect.construct) {
  3159. // We construct a different control for this case to include any extra
  3160. // frames added by the construct call.
  3161. try {
  3162. Reflect.construct(Fake, []);
  3163. } catch (x) {
  3164. control = x;
  3165. }
  3166. Reflect.construct(fn, [], Fake);
  3167. } else {
  3168. try {
  3169. Fake.call();
  3170. } catch (x) {
  3171. control = x;
  3172. }
  3173. fn.call(Fake.prototype);
  3174. }
  3175. } else {
  3176. try {
  3177. throw Error();
  3178. } catch (x) {
  3179. control = x;
  3180. }
  3181. fn();
  3182. }
  3183. } catch (sample) {
  3184. // This is inlined manually because closure doesn't do it for us.
  3185. if (sample && control && typeof sample.stack === 'string') {
  3186. // This extracts the first frame from the sample that isn't also in the control.
  3187. // Skipping one frame that we assume is the frame that calls the two.
  3188. var sampleLines = sample.stack.split('\n');
  3189. var controlLines = control.stack.split('\n');
  3190. var s = sampleLines.length - 1;
  3191. var c = controlLines.length - 1;
  3192. while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
  3193. // We expect at least one stack frame to be shared.
  3194. // Typically this will be the root most one. However, stack frames may be
  3195. // cut off due to maximum stack limits. In this case, one maybe cut off
  3196. // earlier than the other. We assume that the sample is longer or the same
  3197. // and there for cut off earlier. So we should find the root most frame in
  3198. // the sample somewhere in the control.
  3199. c--;
  3200. }
  3201. for (; s >= 1 && c >= 0; s--, c--) {
  3202. // Next we find the first one that isn't the same which should be the
  3203. // frame that called our sample function and the control.
  3204. if (sampleLines[s] !== controlLines[c]) {
  3205. // In V8, the first line is describing the message but other VMs don't.
  3206. // If we're about to return the first line, and the control is also on the same
  3207. // line, that's a pretty good indicator that our sample threw at same line as
  3208. // the control. I.e. before we entered the sample frame. So we ignore this result.
  3209. // This can happen if you passed a class to function component, or non-function.
  3210. if (s !== 1 || c !== 1) {
  3211. do {
  3212. s--;
  3213. c--; // We may still have similar intermediate frames from the construct call.
  3214. // The next one that isn't the same should be our match though.
  3215. if (c < 0 || sampleLines[s] !== controlLines[c]) {
  3216. // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
  3217. var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>"
  3218. // but we have a user-provided "displayName"
  3219. // splice it in to make the stack more readable.
  3220. if (fn.displayName && _frame.includes('<anonymous>')) {
  3221. _frame = _frame.replace('<anonymous>', fn.displayName);
  3222. }
  3223. {
  3224. if (typeof fn === 'function') {
  3225. componentFrameCache.set(fn, _frame);
  3226. }
  3227. } // Return the line we found.
  3228. return _frame;
  3229. }
  3230. } while (s >= 1 && c >= 0);
  3231. }
  3232. break;
  3233. }
  3234. }
  3235. }
  3236. } finally {
  3237. reentry = false;
  3238. {
  3239. ReactCurrentDispatcher.current = previousDispatcher;
  3240. reenableLogs();
  3241. }
  3242. Error.prepareStackTrace = previousPrepareStackTrace;
  3243. } // Fallback to just using the name if we couldn't make it throw.
  3244. var name = fn ? fn.displayName || fn.name : '';
  3245. var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
  3246. {
  3247. if (typeof fn === 'function') {
  3248. componentFrameCache.set(fn, syntheticFrame);
  3249. }
  3250. }
  3251. return syntheticFrame;
  3252. }
  3253. function describeClassComponentFrame(ctor, source, ownerFn) {
  3254. {
  3255. return describeNativeComponentFrame(ctor, true);
  3256. }
  3257. }
  3258. function describeFunctionComponentFrame(fn, source, ownerFn) {
  3259. {
  3260. return describeNativeComponentFrame(fn, false);
  3261. }
  3262. }
  3263. function shouldConstruct(Component) {
  3264. var prototype = Component.prototype;
  3265. return !!(prototype && prototype.isReactComponent);
  3266. }
  3267. function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
  3268. if (type == null) {
  3269. return '';
  3270. }
  3271. if (typeof type === 'function') {
  3272. {
  3273. return describeNativeComponentFrame(type, shouldConstruct(type));
  3274. }
  3275. }
  3276. if (typeof type === 'string') {
  3277. return describeBuiltInComponentFrame(type);
  3278. }
  3279. switch (type) {
  3280. case REACT_SUSPENSE_TYPE:
  3281. return describeBuiltInComponentFrame('Suspense');
  3282. case REACT_SUSPENSE_LIST_TYPE:
  3283. return describeBuiltInComponentFrame('SuspenseList');
  3284. }
  3285. if (typeof type === 'object') {
  3286. switch (type.$$typeof) {
  3287. case REACT_FORWARD_REF_TYPE:
  3288. return describeFunctionComponentFrame(type.render);
  3289. case REACT_MEMO_TYPE:
  3290. // Memo may contain any component type so we recursively resolve it.
  3291. return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
  3292. case REACT_LAZY_TYPE:
  3293. {
  3294. var lazyComponent = type;
  3295. var payload = lazyComponent._payload;
  3296. var init = lazyComponent._init;
  3297. try {
  3298. // Lazy may contain any component type so we recursively resolve it.
  3299. return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
  3300. } catch (x) {}
  3301. }
  3302. }
  3303. }
  3304. return '';
  3305. }
  3306. var loggedTypeFailures = {};
  3307. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  3308. function setCurrentlyValidatingElement(element) {
  3309. {
  3310. if (element) {
  3311. var owner = element._owner;
  3312. var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
  3313. ReactDebugCurrentFrame.setExtraStackFrame(stack);
  3314. } else {
  3315. ReactDebugCurrentFrame.setExtraStackFrame(null);
  3316. }
  3317. }
  3318. }
  3319. function checkPropTypes(typeSpecs, values, location, componentName, element) {
  3320. {
  3321. // $FlowFixMe This is okay but Flow doesn't know it.
  3322. var has = Function.call.bind(hasOwnProperty);
  3323. for (var typeSpecName in typeSpecs) {
  3324. if (has(typeSpecs, typeSpecName)) {
  3325. var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
  3326. // fail the render phase where it didn't fail before. So we log it.
  3327. // After these have been cleaned up, we'll let them throw.
  3328. try {
  3329. // This is intentionally an invariant that gets caught. It's the same
  3330. // behavior as without this statement except with a better message.
  3331. if (typeof typeSpecs[typeSpecName] !== 'function') {
  3332. // eslint-disable-next-line react-internal/prod-error-codes
  3333. var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
  3334. err.name = 'Invariant Violation';
  3335. throw err;
  3336. }
  3337. error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
  3338. } catch (ex) {
  3339. error$1 = ex;
  3340. }
  3341. if (error$1 && !(error$1 instanceof Error)) {
  3342. setCurrentlyValidatingElement(element);
  3343. error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
  3344. setCurrentlyValidatingElement(null);
  3345. }
  3346. if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
  3347. // Only monitor this failure once because there tends to be a lot of the
  3348. // same error.
  3349. loggedTypeFailures[error$1.message] = true;
  3350. setCurrentlyValidatingElement(element);
  3351. error('Failed %s type: %s', location, error$1.message);
  3352. setCurrentlyValidatingElement(null);
  3353. }
  3354. }
  3355. }
  3356. }
  3357. }
  3358. var warnedAboutMissingGetChildContext;
  3359. {
  3360. warnedAboutMissingGetChildContext = {};
  3361. }
  3362. var emptyContextObject = {};
  3363. {
  3364. Object.freeze(emptyContextObject);
  3365. }
  3366. function getMaskedContext(type, unmaskedContext) {
  3367. {
  3368. var contextTypes = type.contextTypes;
  3369. if (!contextTypes) {
  3370. return emptyContextObject;
  3371. }
  3372. var context = {};
  3373. for (var key in contextTypes) {
  3374. context[key] = unmaskedContext[key];
  3375. }
  3376. {
  3377. var name = getComponentNameFromType(type) || 'Unknown';
  3378. checkPropTypes(contextTypes, context, 'context', name);
  3379. }
  3380. return context;
  3381. }
  3382. }
  3383. function processChildContext(instance, type, parentContext, childContextTypes) {
  3384. {
  3385. // TODO (bvaughn) Replace this behavior with an invariant() in the future.
  3386. // It has only been added in Fiber to match the (unintentional) behavior in Stack.
  3387. if (typeof instance.getChildContext !== 'function') {
  3388. {
  3389. var componentName = getComponentNameFromType(type) || 'Unknown';
  3390. if (!warnedAboutMissingGetChildContext[componentName]) {
  3391. warnedAboutMissingGetChildContext[componentName] = true;
  3392. error('%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName);
  3393. }
  3394. }
  3395. return parentContext;
  3396. }
  3397. var childContext = instance.getChildContext();
  3398. for (var contextKey in childContext) {
  3399. if (!(contextKey in childContextTypes)) {
  3400. throw new Error((getComponentNameFromType(type) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes.");
  3401. }
  3402. }
  3403. {
  3404. var name = getComponentNameFromType(type) || 'Unknown';
  3405. checkPropTypes(childContextTypes, childContext, 'child context', name);
  3406. }
  3407. return assign({}, parentContext, childContext);
  3408. }
  3409. }
  3410. var rendererSigil;
  3411. {
  3412. // Use this to detect multiple renderers using the same context
  3413. rendererSigil = {};
  3414. } // Used to store the parent path of all context overrides in a shared linked list.
  3415. // Forming a reverse tree.
  3416. var rootContextSnapshot = null; // We assume that this runtime owns the "current" field on all ReactContext instances.
  3417. // This global (actually thread local) state represents what state all those "current",
  3418. // fields are currently in.
  3419. var currentActiveSnapshot = null;
  3420. function popNode(prev) {
  3421. {
  3422. prev.context._currentValue2 = prev.parentValue;
  3423. }
  3424. }
  3425. function pushNode(next) {
  3426. {
  3427. next.context._currentValue2 = next.value;
  3428. }
  3429. }
  3430. function popToNearestCommonAncestor(prev, next) {
  3431. if (prev === next) ; else {
  3432. popNode(prev);
  3433. var parentPrev = prev.parent;
  3434. var parentNext = next.parent;
  3435. if (parentPrev === null) {
  3436. if (parentNext !== null) {
  3437. throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
  3438. }
  3439. } else {
  3440. if (parentNext === null) {
  3441. throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
  3442. }
  3443. popToNearestCommonAncestor(parentPrev, parentNext);
  3444. } // On the way back, we push the new ones that weren't common.
  3445. pushNode(next);
  3446. }
  3447. }
  3448. function popAllPrevious(prev) {
  3449. popNode(prev);
  3450. var parentPrev = prev.parent;
  3451. if (parentPrev !== null) {
  3452. popAllPrevious(parentPrev);
  3453. }
  3454. }
  3455. function pushAllNext(next) {
  3456. var parentNext = next.parent;
  3457. if (parentNext !== null) {
  3458. pushAllNext(parentNext);
  3459. }
  3460. pushNode(next);
  3461. }
  3462. function popPreviousToCommonLevel(prev, next) {
  3463. popNode(prev);
  3464. var parentPrev = prev.parent;
  3465. if (parentPrev === null) {
  3466. throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.');
  3467. }
  3468. if (parentPrev.depth === next.depth) {
  3469. // We found the same level. Now we just need to find a shared ancestor.
  3470. popToNearestCommonAncestor(parentPrev, next);
  3471. } else {
  3472. // We must still be deeper.
  3473. popPreviousToCommonLevel(parentPrev, next);
  3474. }
  3475. }
  3476. function popNextToCommonLevel(prev, next) {
  3477. var parentNext = next.parent;
  3478. if (parentNext === null) {
  3479. throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.');
  3480. }
  3481. if (prev.depth === parentNext.depth) {
  3482. // We found the same level. Now we just need to find a shared ancestor.
  3483. popToNearestCommonAncestor(prev, parentNext);
  3484. } else {
  3485. // We must still be deeper.
  3486. popNextToCommonLevel(prev, parentNext);
  3487. }
  3488. pushNode(next);
  3489. } // Perform context switching to the new snapshot.
  3490. // To make it cheap to read many contexts, while not suspending, we make the switch eagerly by
  3491. // updating all the context's current values. That way reads, always just read the current value.
  3492. // At the cost of updating contexts even if they're never read by this subtree.
  3493. function switchContext(newSnapshot) {
  3494. // The basic algorithm we need to do is to pop back any contexts that are no longer on the stack.
  3495. // We also need to update any new contexts that are now on the stack with the deepest value.
  3496. // The easiest way to update new contexts is to just reapply them in reverse order from the
  3497. // perspective of the backpointers. To avoid allocating a lot when switching, we use the stack
  3498. // for that. Therefore this algorithm is recursive.
  3499. // 1) First we pop which ever snapshot tree was deepest. Popping old contexts as we go.
  3500. // 2) Then we find the nearest common ancestor from there. Popping old contexts as we go.
  3501. // 3) Then we reapply new contexts on the way back up the stack.
  3502. var prev = currentActiveSnapshot;
  3503. var next = newSnapshot;
  3504. if (prev !== next) {
  3505. if (prev === null) {
  3506. // $FlowFixMe: This has to be non-null since it's not equal to prev.
  3507. pushAllNext(next);
  3508. } else if (next === null) {
  3509. popAllPrevious(prev);
  3510. } else if (prev.depth === next.depth) {
  3511. popToNearestCommonAncestor(prev, next);
  3512. } else if (prev.depth > next.depth) {
  3513. popPreviousToCommonLevel(prev, next);
  3514. } else {
  3515. popNextToCommonLevel(prev, next);
  3516. }
  3517. currentActiveSnapshot = next;
  3518. }
  3519. }
  3520. function pushProvider(context, nextValue) {
  3521. var prevValue;
  3522. {
  3523. prevValue = context._currentValue2;
  3524. context._currentValue2 = nextValue;
  3525. {
  3526. if (context._currentRenderer2 !== undefined && context._currentRenderer2 !== null && context._currentRenderer2 !== rendererSigil) {
  3527. error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.');
  3528. }
  3529. context._currentRenderer2 = rendererSigil;
  3530. }
  3531. }
  3532. var prevNode = currentActiveSnapshot;
  3533. var newNode = {
  3534. parent: prevNode,
  3535. depth: prevNode === null ? 0 : prevNode.depth + 1,
  3536. context: context,
  3537. parentValue: prevValue,
  3538. value: nextValue
  3539. };
  3540. currentActiveSnapshot = newNode;
  3541. return newNode;
  3542. }
  3543. function popProvider(context) {
  3544. var prevSnapshot = currentActiveSnapshot;
  3545. if (prevSnapshot === null) {
  3546. throw new Error('Tried to pop a Context at the root of the app. This is a bug in React.');
  3547. }
  3548. {
  3549. if (prevSnapshot.context !== context) {
  3550. error('The parent context is not the expected context. This is probably a bug in React.');
  3551. }
  3552. }
  3553. {
  3554. var _value = prevSnapshot.parentValue;
  3555. if (_value === REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED) {
  3556. prevSnapshot.context._currentValue2 = prevSnapshot.context._defaultValue;
  3557. } else {
  3558. prevSnapshot.context._currentValue2 = _value;
  3559. }
  3560. {
  3561. if (context._currentRenderer2 !== undefined && context._currentRenderer2 !== null && context._currentRenderer2 !== rendererSigil) {
  3562. error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.');
  3563. }
  3564. context._currentRenderer2 = rendererSigil;
  3565. }
  3566. }
  3567. return currentActiveSnapshot = prevSnapshot.parent;
  3568. }
  3569. function getActiveContext() {
  3570. return currentActiveSnapshot;
  3571. }
  3572. function readContext(context) {
  3573. var value = context._currentValue2;
  3574. return value;
  3575. }
  3576. /**
  3577. * `ReactInstanceMap` maintains a mapping from a public facing stateful
  3578. * instance (key) and the internal representation (value). This allows public
  3579. * methods to accept the user facing instance as an argument and map them back
  3580. * to internal methods.
  3581. *
  3582. * Note that this module is currently shared and assumed to be stateless.
  3583. * If this becomes an actual Map, that will break.
  3584. */
  3585. function get(key) {
  3586. return key._reactInternals;
  3587. }
  3588. function set(key, value) {
  3589. key._reactInternals = value;
  3590. }
  3591. var didWarnAboutNoopUpdateForComponent = {};
  3592. var didWarnAboutDeprecatedWillMount = {};
  3593. var didWarnAboutUninitializedState;
  3594. var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate;
  3595. var didWarnAboutLegacyLifecyclesAndDerivedState;
  3596. var didWarnAboutUndefinedDerivedState;
  3597. var warnOnUndefinedDerivedState;
  3598. var warnOnInvalidCallback;
  3599. var didWarnAboutDirectlyAssigningPropsToState;
  3600. var didWarnAboutContextTypeAndContextTypes;
  3601. var didWarnAboutInvalidateContextType;
  3602. {
  3603. didWarnAboutUninitializedState = new Set();
  3604. didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set();
  3605. didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
  3606. didWarnAboutDirectlyAssigningPropsToState = new Set();
  3607. didWarnAboutUndefinedDerivedState = new Set();
  3608. didWarnAboutContextTypeAndContextTypes = new Set();
  3609. didWarnAboutInvalidateContextType = new Set();
  3610. var didWarnOnInvalidCallback = new Set();
  3611. warnOnInvalidCallback = function (callback, callerName) {
  3612. if (callback === null || typeof callback === 'function') {
  3613. return;
  3614. }
  3615. var key = callerName + '_' + callback;
  3616. if (!didWarnOnInvalidCallback.has(key)) {
  3617. didWarnOnInvalidCallback.add(key);
  3618. error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
  3619. }
  3620. };
  3621. warnOnUndefinedDerivedState = function (type, partialState) {
  3622. if (partialState === undefined) {
  3623. var componentName = getComponentNameFromType(type) || 'Component';
  3624. if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
  3625. didWarnAboutUndefinedDerivedState.add(componentName);
  3626. error('%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
  3627. }
  3628. }
  3629. };
  3630. }
  3631. function warnNoop(publicInstance, callerName) {
  3632. {
  3633. var _constructor = publicInstance.constructor;
  3634. var componentName = _constructor && getComponentNameFromType(_constructor) || 'ReactClass';
  3635. var warningKey = componentName + '.' + callerName;
  3636. if (didWarnAboutNoopUpdateForComponent[warningKey]) {
  3637. return;
  3638. }
  3639. error('%s(...): Can only update a mounting component. ' + 'This usually means you called %s() outside componentWillMount() on the server. ' + 'This is a no-op.\n\nPlease check the code for the %s component.', callerName, callerName, componentName);
  3640. didWarnAboutNoopUpdateForComponent[warningKey] = true;
  3641. }
  3642. }
  3643. var classComponentUpdater = {
  3644. isMounted: function (inst) {
  3645. return false;
  3646. },
  3647. enqueueSetState: function (inst, payload, callback) {
  3648. var internals = get(inst);
  3649. if (internals.queue === null) {
  3650. warnNoop(inst, 'setState');
  3651. } else {
  3652. internals.queue.push(payload);
  3653. {
  3654. if (callback !== undefined && callback !== null) {
  3655. warnOnInvalidCallback(callback, 'setState');
  3656. }
  3657. }
  3658. }
  3659. },
  3660. enqueueReplaceState: function (inst, payload, callback) {
  3661. var internals = get(inst);
  3662. internals.replace = true;
  3663. internals.queue = [payload];
  3664. {
  3665. if (callback !== undefined && callback !== null) {
  3666. warnOnInvalidCallback(callback, 'setState');
  3667. }
  3668. }
  3669. },
  3670. enqueueForceUpdate: function (inst, callback) {
  3671. var internals = get(inst);
  3672. if (internals.queue === null) {
  3673. warnNoop(inst, 'forceUpdate');
  3674. } else {
  3675. {
  3676. if (callback !== undefined && callback !== null) {
  3677. warnOnInvalidCallback(callback, 'setState');
  3678. }
  3679. }
  3680. }
  3681. }
  3682. };
  3683. function applyDerivedStateFromProps(instance, ctor, getDerivedStateFromProps, prevState, nextProps) {
  3684. var partialState = getDerivedStateFromProps(nextProps, prevState);
  3685. {
  3686. warnOnUndefinedDerivedState(ctor, partialState);
  3687. } // Merge the partial state and the previous state.
  3688. var newState = partialState === null || partialState === undefined ? prevState : assign({}, prevState, partialState);
  3689. return newState;
  3690. }
  3691. function constructClassInstance(ctor, props, maskedLegacyContext) {
  3692. var context = emptyContextObject;
  3693. var contextType = ctor.contextType;
  3694. {
  3695. if ('contextType' in ctor) {
  3696. var isValid = // Allow null for conditional declaration
  3697. contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer>
  3698. if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
  3699. didWarnAboutInvalidateContextType.add(ctor);
  3700. var addendum = '';
  3701. if (contextType === undefined) {
  3702. addendum = ' However, it is set to undefined. ' + 'This can be caused by a typo or by mixing up named and default imports. ' + 'This can also happen due to a circular dependency, so ' + 'try moving the createContext() call to a separate file.';
  3703. } else if (typeof contextType !== 'object') {
  3704. addendum = ' However, it is set to a ' + typeof contextType + '.';
  3705. } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
  3706. addendum = ' Did you accidentally pass the Context.Provider instead?';
  3707. } else if (contextType._context !== undefined) {
  3708. // <Context.Consumer>
  3709. addendum = ' Did you accidentally pass the Context.Consumer instead?';
  3710. } else {
  3711. addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.';
  3712. }
  3713. error('%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentNameFromType(ctor) || 'Component', addendum);
  3714. }
  3715. }
  3716. }
  3717. if (typeof contextType === 'object' && contextType !== null) {
  3718. context = readContext(contextType);
  3719. } else {
  3720. context = maskedLegacyContext;
  3721. }
  3722. var instance = new ctor(props, context);
  3723. {
  3724. if (typeof ctor.getDerivedStateFromProps === 'function' && (instance.state === null || instance.state === undefined)) {
  3725. var componentName = getComponentNameFromType(ctor) || 'Component';
  3726. if (!didWarnAboutUninitializedState.has(componentName)) {
  3727. didWarnAboutUninitializedState.add(componentName);
  3728. error('`%s` uses `getDerivedStateFromProps` but its initial state is ' + '%s. This is not recommended. Instead, define the initial state by ' + 'assigning an object to `this.state` in the constructor of `%s`. ' + 'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.', componentName, instance.state === null ? 'null' : 'undefined', componentName);
  3729. }
  3730. } // If new component APIs are defined, "unsafe" lifecycles won't be called.
  3731. // Warn about these lifecycles if they are present.
  3732. // Don't warn about react-lifecycles-compat polyfilled methods though.
  3733. if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') {
  3734. var foundWillMountName = null;
  3735. var foundWillReceivePropsName = null;
  3736. var foundWillUpdateName = null;
  3737. if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
  3738. foundWillMountName = 'componentWillMount';
  3739. } else if (typeof instance.UNSAFE_componentWillMount === 'function') {
  3740. foundWillMountName = 'UNSAFE_componentWillMount';
  3741. }
  3742. if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
  3743. foundWillReceivePropsName = 'componentWillReceiveProps';
  3744. } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  3745. foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
  3746. }
  3747. if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
  3748. foundWillUpdateName = 'componentWillUpdate';
  3749. } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
  3750. foundWillUpdateName = 'UNSAFE_componentWillUpdate';
  3751. }
  3752. if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
  3753. var _componentName = getComponentNameFromType(ctor) || 'Component';
  3754. var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()';
  3755. if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) {
  3756. didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName);
  3757. error('Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' + '%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n' + 'The above lifecycles should be removed. Learn more about this warning here:\n' + 'https://reactjs.org/link/unsafe-component-lifecycles', _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : '', foundWillReceivePropsName !== null ? "\n " + foundWillReceivePropsName : '', foundWillUpdateName !== null ? "\n " + foundWillUpdateName : '');
  3758. }
  3759. }
  3760. }
  3761. }
  3762. return instance;
  3763. }
  3764. function checkClassInstance(instance, ctor, newProps) {
  3765. {
  3766. var name = getComponentNameFromType(ctor) || 'Component';
  3767. var renderPresent = instance.render;
  3768. if (!renderPresent) {
  3769. if (ctor.prototype && typeof ctor.prototype.render === 'function') {
  3770. error('%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
  3771. } else {
  3772. error('%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
  3773. }
  3774. }
  3775. if (instance.getInitialState && !instance.getInitialState.isReactClassApproved && !instance.state) {
  3776. error('getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name);
  3777. }
  3778. if (instance.getDefaultProps && !instance.getDefaultProps.isReactClassApproved) {
  3779. error('getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name);
  3780. }
  3781. if (instance.propTypes) {
  3782. error('propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name);
  3783. }
  3784. if (instance.contextType) {
  3785. error('contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name);
  3786. }
  3787. {
  3788. if (instance.contextTypes) {
  3789. error('contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name);
  3790. }
  3791. if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
  3792. didWarnAboutContextTypeAndContextTypes.add(ctor);
  3793. error('%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
  3794. }
  3795. }
  3796. if (typeof instance.componentShouldUpdate === 'function') {
  3797. error('%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name);
  3798. }
  3799. if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
  3800. error('%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentNameFromType(ctor) || 'A pure component');
  3801. }
  3802. if (typeof instance.componentDidUnmount === 'function') {
  3803. error('%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name);
  3804. }
  3805. if (typeof instance.componentDidReceiveProps === 'function') {
  3806. error('%s has a method called ' + 'componentDidReceiveProps(). But there is no such lifecycle method. ' + 'If you meant to update the state in response to changing props, ' + 'use componentWillReceiveProps(). If you meant to fetch data or ' + 'run side-effects or mutations after React has updated the UI, use componentDidUpdate().', name);
  3807. }
  3808. if (typeof instance.componentWillRecieveProps === 'function') {
  3809. error('%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name);
  3810. }
  3811. if (typeof instance.UNSAFE_componentWillRecieveProps === 'function') {
  3812. error('%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name);
  3813. }
  3814. var hasMutatedProps = instance.props !== newProps;
  3815. if (instance.props !== undefined && hasMutatedProps) {
  3816. error('%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name);
  3817. }
  3818. if (instance.defaultProps) {
  3819. error('Setting defaultProps as an instance property on %s is not supported and will be ignored.' + ' Instead, define defaultProps as a static property on %s.', name, name);
  3820. }
  3821. if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) {
  3822. didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor);
  3823. error('%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentNameFromType(ctor));
  3824. }
  3825. if (typeof instance.getDerivedStateFromProps === 'function') {
  3826. error('%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name);
  3827. }
  3828. if (typeof instance.getDerivedStateFromError === 'function') {
  3829. error('%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name);
  3830. }
  3831. if (typeof ctor.getSnapshotBeforeUpdate === 'function') {
  3832. error('%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name);
  3833. }
  3834. var _state = instance.state;
  3835. if (_state && (typeof _state !== 'object' || isArray(_state))) {
  3836. error('%s.state: must be set to an object or null', name);
  3837. }
  3838. if (typeof instance.getChildContext === 'function' && typeof ctor.childContextTypes !== 'object') {
  3839. error('%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name);
  3840. }
  3841. }
  3842. }
  3843. function callComponentWillMount(type, instance) {
  3844. var oldState = instance.state;
  3845. if (typeof instance.componentWillMount === 'function') {
  3846. {
  3847. if ( instance.componentWillMount.__suppressDeprecationWarning !== true) {
  3848. var componentName = getComponentNameFromType(type) || 'Unknown';
  3849. if (!didWarnAboutDeprecatedWillMount[componentName]) {
  3850. warn( // keep this warning in sync with ReactStrictModeWarning.js
  3851. 'componentWillMount has been renamed, and is not recommended for use. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move code from componentWillMount to componentDidMount (preferred in most cases) ' + 'or the constructor.\n' + '\nPlease update the following components: %s', componentName);
  3852. didWarnAboutDeprecatedWillMount[componentName] = true;
  3853. }
  3854. }
  3855. }
  3856. instance.componentWillMount();
  3857. }
  3858. if (typeof instance.UNSAFE_componentWillMount === 'function') {
  3859. instance.UNSAFE_componentWillMount();
  3860. }
  3861. if (oldState !== instance.state) {
  3862. {
  3863. error('%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentNameFromType(type) || 'Component');
  3864. }
  3865. classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
  3866. }
  3867. }
  3868. function processUpdateQueue(internalInstance, inst, props, maskedLegacyContext) {
  3869. if (internalInstance.queue !== null && internalInstance.queue.length > 0) {
  3870. var oldQueue = internalInstance.queue;
  3871. var oldReplace = internalInstance.replace;
  3872. internalInstance.queue = null;
  3873. internalInstance.replace = false;
  3874. if (oldReplace && oldQueue.length === 1) {
  3875. inst.state = oldQueue[0];
  3876. } else {
  3877. var nextState = oldReplace ? oldQueue[0] : inst.state;
  3878. var dontMutate = true;
  3879. for (var i = oldReplace ? 1 : 0; i < oldQueue.length; i++) {
  3880. var partial = oldQueue[i];
  3881. var partialState = typeof partial === 'function' ? partial.call(inst, nextState, props, maskedLegacyContext) : partial;
  3882. if (partialState != null) {
  3883. if (dontMutate) {
  3884. dontMutate = false;
  3885. nextState = assign({}, nextState, partialState);
  3886. } else {
  3887. assign(nextState, partialState);
  3888. }
  3889. }
  3890. }
  3891. inst.state = nextState;
  3892. }
  3893. } else {
  3894. internalInstance.queue = null;
  3895. }
  3896. } // Invokes the mount life-cycles on a previously never rendered instance.
  3897. function mountClassInstance(instance, ctor, newProps, maskedLegacyContext) {
  3898. {
  3899. checkClassInstance(instance, ctor, newProps);
  3900. }
  3901. var initialState = instance.state !== undefined ? instance.state : null;
  3902. instance.updater = classComponentUpdater;
  3903. instance.props = newProps;
  3904. instance.state = initialState; // We don't bother initializing the refs object on the server, since we're not going to resolve them anyway.
  3905. // The internal instance will be used to manage updates that happen during this mount.
  3906. var internalInstance = {
  3907. queue: [],
  3908. replace: false
  3909. };
  3910. set(instance, internalInstance);
  3911. var contextType = ctor.contextType;
  3912. if (typeof contextType === 'object' && contextType !== null) {
  3913. instance.context = readContext(contextType);
  3914. } else {
  3915. instance.context = maskedLegacyContext;
  3916. }
  3917. {
  3918. if (instance.state === newProps) {
  3919. var componentName = getComponentNameFromType(ctor) || 'Component';
  3920. if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) {
  3921. didWarnAboutDirectlyAssigningPropsToState.add(componentName);
  3922. error('%s: It is not recommended to assign props directly to state ' + "because updates to props won't be reflected in state. " + 'In most cases, it is better to use props directly.', componentName);
  3923. }
  3924. }
  3925. }
  3926. var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
  3927. if (typeof getDerivedStateFromProps === 'function') {
  3928. instance.state = applyDerivedStateFromProps(instance, ctor, getDerivedStateFromProps, initialState, newProps);
  3929. } // In order to support react-lifecycles-compat polyfilled components,
  3930. // Unsafe lifecycles should not be invoked for components using the new APIs.
  3931. if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
  3932. callComponentWillMount(ctor, instance); // If we had additional state updates during this life-cycle, let's
  3933. // process them now.
  3934. processUpdateQueue(internalInstance, instance, newProps, maskedLegacyContext);
  3935. }
  3936. }
  3937. // Ids are base 32 strings whose binary representation corresponds to the
  3938. // position of a node in a tree.
  3939. // Every time the tree forks into multiple children, we add additional bits to
  3940. // the left of the sequence that represent the position of the child within the
  3941. // current level of children.
  3942. //
  3943. // 00101 00010001011010101
  3944. // ╰─┬─╯ ╰───────┬───────╯
  3945. // Fork 5 of 20 Parent id
  3946. //
  3947. // The leading 0s are important. In the above example, you only need 3 bits to
  3948. // represent slot 5. However, you need 5 bits to represent all the forks at
  3949. // the current level, so we must account for the empty bits at the end.
  3950. //
  3951. // For this same reason, slots are 1-indexed instead of 0-indexed. Otherwise,
  3952. // the zeroth id at a level would be indistinguishable from its parent.
  3953. //
  3954. // If a node has only one child, and does not materialize an id (i.e. does not
  3955. // contain a useId hook), then we don't need to allocate any space in the
  3956. // sequence. It's treated as a transparent indirection. For example, these two
  3957. // trees produce the same ids:
  3958. //
  3959. // <> <>
  3960. // <Indirection> <A />
  3961. // <A /> <B />
  3962. // </Indirection> </>
  3963. // <B />
  3964. // </>
  3965. //
  3966. // However, we cannot skip any node that materializes an id. Otherwise, a parent
  3967. // id that does not fork would be indistinguishable from its child id. For
  3968. // example, this tree does not fork, but the parent and child must have
  3969. // different ids.
  3970. //
  3971. // <Parent>
  3972. // <Child />
  3973. // </Parent>
  3974. //
  3975. // To handle this scenario, every time we materialize an id, we allocate a
  3976. // new level with a single slot. You can think of this as a fork with only one
  3977. // prong, or an array of children with length 1.
  3978. //
  3979. // It's possible for the size of the sequence to exceed 32 bits, the max
  3980. // size for bitwise operations. When this happens, we make more room by
  3981. // converting the right part of the id to a string and storing it in an overflow
  3982. // variable. We use a base 32 string representation, because 32 is the largest
  3983. // power of 2 that is supported by toString(). We want the base to be large so
  3984. // that the resulting ids are compact, and we want the base to be a power of 2
  3985. // because every log2(base) bits corresponds to a single character, i.e. every
  3986. // log2(32) = 5 bits. That means we can lop bits off the end 5 at a time without
  3987. // affecting the final result.
  3988. var emptyTreeContext = {
  3989. id: 1,
  3990. overflow: ''
  3991. };
  3992. function getTreeId(context) {
  3993. var overflow = context.overflow;
  3994. var idWithLeadingBit = context.id;
  3995. var id = idWithLeadingBit & ~getLeadingBit(idWithLeadingBit);
  3996. return id.toString(32) + overflow;
  3997. }
  3998. function pushTreeContext(baseContext, totalChildren, index) {
  3999. var baseIdWithLeadingBit = baseContext.id;
  4000. var baseOverflow = baseContext.overflow; // The leftmost 1 marks the end of the sequence, non-inclusive. It's not part
  4001. // of the id; we use it to account for leading 0s.
  4002. var baseLength = getBitLength(baseIdWithLeadingBit) - 1;
  4003. var baseId = baseIdWithLeadingBit & ~(1 << baseLength);
  4004. var slot = index + 1;
  4005. var length = getBitLength(totalChildren) + baseLength; // 30 is the max length we can store without overflowing, taking into
  4006. // consideration the leading 1 we use to mark the end of the sequence.
  4007. if (length > 30) {
  4008. // We overflowed the bitwise-safe range. Fall back to slower algorithm.
  4009. // This branch assumes the length of the base id is greater than 5; it won't
  4010. // work for smaller ids, because you need 5 bits per character.
  4011. //
  4012. // We encode the id in multiple steps: first the base id, then the
  4013. // remaining digits.
  4014. //
  4015. // Each 5 bit sequence corresponds to a single base 32 character. So for
  4016. // example, if the current id is 23 bits long, we can convert 20 of those
  4017. // bits into a string of 4 characters, with 3 bits left over.
  4018. //
  4019. // First calculate how many bits in the base id represent a complete
  4020. // sequence of characters.
  4021. var numberOfOverflowBits = baseLength - baseLength % 5; // Then create a bitmask that selects only those bits.
  4022. var newOverflowBits = (1 << numberOfOverflowBits) - 1; // Select the bits, and convert them to a base 32 string.
  4023. var newOverflow = (baseId & newOverflowBits).toString(32); // Now we can remove those bits from the base id.
  4024. var restOfBaseId = baseId >> numberOfOverflowBits;
  4025. var restOfBaseLength = baseLength - numberOfOverflowBits; // Finally, encode the rest of the bits using the normal algorithm. Because
  4026. // we made more room, this time it won't overflow.
  4027. var restOfLength = getBitLength(totalChildren) + restOfBaseLength;
  4028. var restOfNewBits = slot << restOfBaseLength;
  4029. var id = restOfNewBits | restOfBaseId;
  4030. var overflow = newOverflow + baseOverflow;
  4031. return {
  4032. id: 1 << restOfLength | id,
  4033. overflow: overflow
  4034. };
  4035. } else {
  4036. // Normal path
  4037. var newBits = slot << baseLength;
  4038. var _id = newBits | baseId;
  4039. var _overflow = baseOverflow;
  4040. return {
  4041. id: 1 << length | _id,
  4042. overflow: _overflow
  4043. };
  4044. }
  4045. }
  4046. function getBitLength(number) {
  4047. return 32 - clz32(number);
  4048. }
  4049. function getLeadingBit(id) {
  4050. return 1 << getBitLength(id) - 1;
  4051. } // TODO: Math.clz32 is supported in Node 12+. Maybe we can drop the fallback.
  4052. var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback; // Count leading zeros.
  4053. // Based on:
  4054. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
  4055. var log = Math.log;
  4056. var LN2 = Math.LN2;
  4057. function clz32Fallback(x) {
  4058. var asUint = x >>> 0;
  4059. if (asUint === 0) {
  4060. return 32;
  4061. }
  4062. return 31 - (log(asUint) / LN2 | 0) | 0;
  4063. }
  4064. /**
  4065. * inlined Object.is polyfill to avoid requiring consumers ship their own
  4066. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  4067. */
  4068. function is(x, y) {
  4069. return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
  4070. ;
  4071. }
  4072. var objectIs = typeof Object.is === 'function' ? Object.is : is;
  4073. var currentlyRenderingComponent = null;
  4074. var currentlyRenderingTask = null;
  4075. var firstWorkInProgressHook = null;
  4076. var workInProgressHook = null; // Whether the work-in-progress hook is a re-rendered hook
  4077. var isReRender = false; // Whether an update was scheduled during the currently executing render pass.
  4078. var didScheduleRenderPhaseUpdate = false; // Counts the number of useId hooks in this component
  4079. var localIdCounter = 0; // Lazily created map of render-phase updates
  4080. var renderPhaseUpdates = null; // Counter to prevent infinite loops.
  4081. var numberOfReRenders = 0;
  4082. var RE_RENDER_LIMIT = 25;
  4083. var isInHookUserCodeInDev = false; // In DEV, this is the name of the currently executing primitive hook
  4084. var currentHookNameInDev;
  4085. function resolveCurrentlyRenderingComponent() {
  4086. if (currentlyRenderingComponent === null) {
  4087. throw new Error('Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' + ' one of the following reasons:\n' + '1. You might have mismatching versions of React and the renderer (such as React DOM)\n' + '2. You might be breaking the Rules of Hooks\n' + '3. You might have more than one copy of React in the same app\n' + 'See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.');
  4088. }
  4089. {
  4090. if (isInHookUserCodeInDev) {
  4091. error('Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. ' + 'You can only call Hooks at the top level of your React function. ' + 'For more information, see ' + 'https://reactjs.org/link/rules-of-hooks');
  4092. }
  4093. }
  4094. return currentlyRenderingComponent;
  4095. }
  4096. function areHookInputsEqual(nextDeps, prevDeps) {
  4097. if (prevDeps === null) {
  4098. {
  4099. error('%s received a final argument during this render, but not during ' + 'the previous render. Even though the final argument is optional, ' + 'its type cannot change between renders.', currentHookNameInDev);
  4100. }
  4101. return false;
  4102. }
  4103. {
  4104. // Don't bother comparing lengths in prod because these arrays should be
  4105. // passed inline.
  4106. if (nextDeps.length !== prevDeps.length) {
  4107. error('The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev, "[" + nextDeps.join(', ') + "]", "[" + prevDeps.join(', ') + "]");
  4108. }
  4109. }
  4110. for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
  4111. if (objectIs(nextDeps[i], prevDeps[i])) {
  4112. continue;
  4113. }
  4114. return false;
  4115. }
  4116. return true;
  4117. }
  4118. function createHook() {
  4119. if (numberOfReRenders > 0) {
  4120. throw new Error('Rendered more hooks than during the previous render');
  4121. }
  4122. return {
  4123. memoizedState: null,
  4124. queue: null,
  4125. next: null
  4126. };
  4127. }
  4128. function createWorkInProgressHook() {
  4129. if (workInProgressHook === null) {
  4130. // This is the first hook in the list
  4131. if (firstWorkInProgressHook === null) {
  4132. isReRender = false;
  4133. firstWorkInProgressHook = workInProgressHook = createHook();
  4134. } else {
  4135. // There's already a work-in-progress. Reuse it.
  4136. isReRender = true;
  4137. workInProgressHook = firstWorkInProgressHook;
  4138. }
  4139. } else {
  4140. if (workInProgressHook.next === null) {
  4141. isReRender = false; // Append to the end of the list
  4142. workInProgressHook = workInProgressHook.next = createHook();
  4143. } else {
  4144. // There's already a work-in-progress. Reuse it.
  4145. isReRender = true;
  4146. workInProgressHook = workInProgressHook.next;
  4147. }
  4148. }
  4149. return workInProgressHook;
  4150. }
  4151. function prepareToUseHooks(task, componentIdentity) {
  4152. currentlyRenderingComponent = componentIdentity;
  4153. currentlyRenderingTask = task;
  4154. {
  4155. isInHookUserCodeInDev = false;
  4156. } // The following should have already been reset
  4157. // didScheduleRenderPhaseUpdate = false;
  4158. // localIdCounter = 0;
  4159. // firstWorkInProgressHook = null;
  4160. // numberOfReRenders = 0;
  4161. // renderPhaseUpdates = null;
  4162. // workInProgressHook = null;
  4163. localIdCounter = 0;
  4164. }
  4165. function finishHooks(Component, props, children, refOrContext) {
  4166. // This must be called after every function component to prevent hooks from
  4167. // being used in classes.
  4168. while (didScheduleRenderPhaseUpdate) {
  4169. // Updates were scheduled during the render phase. They are stored in
  4170. // the `renderPhaseUpdates` map. Call the component again, reusing the
  4171. // work-in-progress hooks and applying the additional updates on top. Keep
  4172. // restarting until no more updates are scheduled.
  4173. didScheduleRenderPhaseUpdate = false;
  4174. localIdCounter = 0;
  4175. numberOfReRenders += 1; // Start over from the beginning of the list
  4176. workInProgressHook = null;
  4177. children = Component(props, refOrContext);
  4178. }
  4179. resetHooksState();
  4180. return children;
  4181. }
  4182. function checkDidRenderIdHook() {
  4183. // This should be called immediately after every finishHooks call.
  4184. // Conceptually, it's part of the return value of finishHooks; it's only a
  4185. // separate function to avoid using an array tuple.
  4186. var didRenderIdHook = localIdCounter !== 0;
  4187. return didRenderIdHook;
  4188. } // Reset the internal hooks state if an error occurs while rendering a component
  4189. function resetHooksState() {
  4190. {
  4191. isInHookUserCodeInDev = false;
  4192. }
  4193. currentlyRenderingComponent = null;
  4194. currentlyRenderingTask = null;
  4195. didScheduleRenderPhaseUpdate = false;
  4196. firstWorkInProgressHook = null;
  4197. numberOfReRenders = 0;
  4198. renderPhaseUpdates = null;
  4199. workInProgressHook = null;
  4200. }
  4201. function readContext$1(context) {
  4202. {
  4203. if (isInHookUserCodeInDev) {
  4204. error('Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().');
  4205. }
  4206. }
  4207. return readContext(context);
  4208. }
  4209. function useContext(context) {
  4210. {
  4211. currentHookNameInDev = 'useContext';
  4212. }
  4213. resolveCurrentlyRenderingComponent();
  4214. return readContext(context);
  4215. }
  4216. function basicStateReducer(state, action) {
  4217. // $FlowFixMe: Flow doesn't like mixed types
  4218. return typeof action === 'function' ? action(state) : action;
  4219. }
  4220. function useState(initialState) {
  4221. {
  4222. currentHookNameInDev = 'useState';
  4223. }
  4224. return useReducer(basicStateReducer, // useReducer has a special case to support lazy useState initializers
  4225. initialState);
  4226. }
  4227. function useReducer(reducer, initialArg, init) {
  4228. {
  4229. if (reducer !== basicStateReducer) {
  4230. currentHookNameInDev = 'useReducer';
  4231. }
  4232. }
  4233. currentlyRenderingComponent = resolveCurrentlyRenderingComponent();
  4234. workInProgressHook = createWorkInProgressHook();
  4235. if (isReRender) {
  4236. // This is a re-render. Apply the new render phase updates to the previous
  4237. // current hook.
  4238. var queue = workInProgressHook.queue;
  4239. var dispatch = queue.dispatch;
  4240. if (renderPhaseUpdates !== null) {
  4241. // Render phase updates are stored in a map of queue -> linked list
  4242. var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
  4243. if (firstRenderPhaseUpdate !== undefined) {
  4244. renderPhaseUpdates.delete(queue);
  4245. var newState = workInProgressHook.memoizedState;
  4246. var update = firstRenderPhaseUpdate;
  4247. do {
  4248. // Process this render phase update. We don't have to check the
  4249. // priority because it will always be the same as the current
  4250. // render's.
  4251. var action = update.action;
  4252. {
  4253. isInHookUserCodeInDev = true;
  4254. }
  4255. newState = reducer(newState, action);
  4256. {
  4257. isInHookUserCodeInDev = false;
  4258. }
  4259. update = update.next;
  4260. } while (update !== null);
  4261. workInProgressHook.memoizedState = newState;
  4262. return [newState, dispatch];
  4263. }
  4264. }
  4265. return [workInProgressHook.memoizedState, dispatch];
  4266. } else {
  4267. {
  4268. isInHookUserCodeInDev = true;
  4269. }
  4270. var initialState;
  4271. if (reducer === basicStateReducer) {
  4272. // Special case for `useState`.
  4273. initialState = typeof initialArg === 'function' ? initialArg() : initialArg;
  4274. } else {
  4275. initialState = init !== undefined ? init(initialArg) : initialArg;
  4276. }
  4277. {
  4278. isInHookUserCodeInDev = false;
  4279. }
  4280. workInProgressHook.memoizedState = initialState;
  4281. var _queue = workInProgressHook.queue = {
  4282. last: null,
  4283. dispatch: null
  4284. };
  4285. var _dispatch = _queue.dispatch = dispatchAction.bind(null, currentlyRenderingComponent, _queue);
  4286. return [workInProgressHook.memoizedState, _dispatch];
  4287. }
  4288. }
  4289. function useMemo(nextCreate, deps) {
  4290. currentlyRenderingComponent = resolveCurrentlyRenderingComponent();
  4291. workInProgressHook = createWorkInProgressHook();
  4292. var nextDeps = deps === undefined ? null : deps;
  4293. if (workInProgressHook !== null) {
  4294. var prevState = workInProgressHook.memoizedState;
  4295. if (prevState !== null) {
  4296. if (nextDeps !== null) {
  4297. var prevDeps = prevState[1];
  4298. if (areHookInputsEqual(nextDeps, prevDeps)) {
  4299. return prevState[0];
  4300. }
  4301. }
  4302. }
  4303. }
  4304. {
  4305. isInHookUserCodeInDev = true;
  4306. }
  4307. var nextValue = nextCreate();
  4308. {
  4309. isInHookUserCodeInDev = false;
  4310. }
  4311. workInProgressHook.memoizedState = [nextValue, nextDeps];
  4312. return nextValue;
  4313. }
  4314. function useRef(initialValue) {
  4315. currentlyRenderingComponent = resolveCurrentlyRenderingComponent();
  4316. workInProgressHook = createWorkInProgressHook();
  4317. var previousRef = workInProgressHook.memoizedState;
  4318. if (previousRef === null) {
  4319. var ref = {
  4320. current: initialValue
  4321. };
  4322. {
  4323. Object.seal(ref);
  4324. }
  4325. workInProgressHook.memoizedState = ref;
  4326. return ref;
  4327. } else {
  4328. return previousRef;
  4329. }
  4330. }
  4331. function useLayoutEffect(create, inputs) {
  4332. {
  4333. currentHookNameInDev = 'useLayoutEffect';
  4334. error('useLayoutEffect does nothing on the server, because its effect cannot ' + "be encoded into the server renderer's output format. This will lead " + 'to a mismatch between the initial, non-hydrated UI and the intended ' + 'UI. To avoid this, useLayoutEffect should only be used in ' + 'components that render exclusively on the client. ' + 'See https://reactjs.org/link/uselayouteffect-ssr for common fixes.');
  4335. }
  4336. }
  4337. function dispatchAction(componentIdentity, queue, action) {
  4338. if (numberOfReRenders >= RE_RENDER_LIMIT) {
  4339. throw new Error('Too many re-renders. React limits the number of renders to prevent ' + 'an infinite loop.');
  4340. }
  4341. if (componentIdentity === currentlyRenderingComponent) {
  4342. // This is a render phase update. Stash it in a lazily-created map of
  4343. // queue -> linked list of updates. After this render pass, we'll restart
  4344. // and apply the stashed updates on top of the work-in-progress hook.
  4345. didScheduleRenderPhaseUpdate = true;
  4346. var update = {
  4347. action: action,
  4348. next: null
  4349. };
  4350. if (renderPhaseUpdates === null) {
  4351. renderPhaseUpdates = new Map();
  4352. }
  4353. var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
  4354. if (firstRenderPhaseUpdate === undefined) {
  4355. renderPhaseUpdates.set(queue, update);
  4356. } else {
  4357. // Append the update to the end of the list.
  4358. var lastRenderPhaseUpdate = firstRenderPhaseUpdate;
  4359. while (lastRenderPhaseUpdate.next !== null) {
  4360. lastRenderPhaseUpdate = lastRenderPhaseUpdate.next;
  4361. }
  4362. lastRenderPhaseUpdate.next = update;
  4363. }
  4364. }
  4365. }
  4366. function useCallback(callback, deps) {
  4367. return useMemo(function () {
  4368. return callback;
  4369. }, deps);
  4370. } // TODO Decide on how to implement this hook for server rendering.
  4371. // If a mutation occurs during render, consider triggering a Suspense boundary
  4372. // and falling back to client rendering.
  4373. function useMutableSource(source, getSnapshot, subscribe) {
  4374. resolveCurrentlyRenderingComponent();
  4375. return getSnapshot(source._source);
  4376. }
  4377. function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
  4378. if (getServerSnapshot === undefined) {
  4379. throw new Error('Missing getServerSnapshot, which is required for ' + 'server-rendered content. Will revert to client rendering.');
  4380. }
  4381. return getServerSnapshot();
  4382. }
  4383. function useDeferredValue(value) {
  4384. resolveCurrentlyRenderingComponent();
  4385. return value;
  4386. }
  4387. function unsupportedStartTransition() {
  4388. throw new Error('startTransition cannot be called during server rendering.');
  4389. }
  4390. function useTransition() {
  4391. resolveCurrentlyRenderingComponent();
  4392. return [false, unsupportedStartTransition];
  4393. }
  4394. function useId() {
  4395. var task = currentlyRenderingTask;
  4396. var treeId = getTreeId(task.treeContext);
  4397. var responseState = currentResponseState;
  4398. if (responseState === null) {
  4399. throw new Error('Invalid hook call. Hooks can only be called inside of the body of a function component.');
  4400. }
  4401. var localId = localIdCounter++;
  4402. return makeId(responseState, treeId, localId);
  4403. }
  4404. function noop() {}
  4405. var Dispatcher = {
  4406. readContext: readContext$1,
  4407. useContext: useContext,
  4408. useMemo: useMemo,
  4409. useReducer: useReducer,
  4410. useRef: useRef,
  4411. useState: useState,
  4412. useInsertionEffect: noop,
  4413. useLayoutEffect: useLayoutEffect,
  4414. useCallback: useCallback,
  4415. // useImperativeHandle is not run in the server environment
  4416. useImperativeHandle: noop,
  4417. // Effects are not run in the server environment.
  4418. useEffect: noop,
  4419. // Debugging effect
  4420. useDebugValue: noop,
  4421. useDeferredValue: useDeferredValue,
  4422. useTransition: useTransition,
  4423. useId: useId,
  4424. // Subscriptions are not setup in a server environment.
  4425. useMutableSource: useMutableSource,
  4426. useSyncExternalStore: useSyncExternalStore
  4427. };
  4428. var currentResponseState = null;
  4429. function setCurrentResponseState(responseState) {
  4430. currentResponseState = responseState;
  4431. }
  4432. function getStackByComponentStackNode(componentStack) {
  4433. try {
  4434. var info = '';
  4435. var node = componentStack;
  4436. do {
  4437. switch (node.tag) {
  4438. case 0:
  4439. info += describeBuiltInComponentFrame(node.type, null, null);
  4440. break;
  4441. case 1:
  4442. info += describeFunctionComponentFrame(node.type, null, null);
  4443. break;
  4444. case 2:
  4445. info += describeClassComponentFrame(node.type, null, null);
  4446. break;
  4447. }
  4448. node = node.parent;
  4449. } while (node);
  4450. return info;
  4451. } catch (x) {
  4452. return '\nError generating stack: ' + x.message + '\n' + x.stack;
  4453. }
  4454. }
  4455. var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;
  4456. var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
  4457. var PENDING = 0;
  4458. var COMPLETED = 1;
  4459. var FLUSHED = 2;
  4460. var ABORTED = 3;
  4461. var ERRORED = 4;
  4462. var OPEN = 0;
  4463. var CLOSING = 1;
  4464. var CLOSED = 2;
  4465. // This is a default heuristic for how to split up the HTML content into progressive
  4466. // loading. Our goal is to be able to display additional new content about every 500ms.
  4467. // Faster than that is unnecessary and should be throttled on the client. It also
  4468. // adds unnecessary overhead to do more splits. We don't know if it's a higher or lower
  4469. // end device but higher end suffer less from the overhead than lower end does from
  4470. // not getting small enough pieces. We error on the side of low end.
  4471. // We base this on low end 3G speeds which is about 500kbits per second. We assume
  4472. // that there can be a reasonable drop off from max bandwidth which leaves you with
  4473. // as little as 80%. We can receive half of that each 500ms - at best. In practice,
  4474. // a little bandwidth is lost to processing and contention - e.g. CSS and images that
  4475. // are downloaded along with the main content. So we estimate about half of that to be
  4476. // the lower end throughput. In other words, we expect that you can at least show
  4477. // about 12.5kb of content per 500ms. Not counting starting latency for the first
  4478. // paint.
  4479. // 500 * 1024 / 8 * .8 * 0.5 / 2
  4480. var DEFAULT_PROGRESSIVE_CHUNK_SIZE = 12800;
  4481. function defaultErrorHandler(error) {
  4482. console['error'](error); // Don't transform to our wrapper
  4483. return null;
  4484. }
  4485. function noop$1() {}
  4486. function createRequest(children, responseState, rootFormatContext, progressiveChunkSize, onError, onAllReady, onShellReady, onShellError, onFatalError) {
  4487. var pingedTasks = [];
  4488. var abortSet = new Set();
  4489. var request = {
  4490. destination: null,
  4491. responseState: responseState,
  4492. progressiveChunkSize: progressiveChunkSize === undefined ? DEFAULT_PROGRESSIVE_CHUNK_SIZE : progressiveChunkSize,
  4493. status: OPEN,
  4494. fatalError: null,
  4495. nextSegmentId: 0,
  4496. allPendingTasks: 0,
  4497. pendingRootTasks: 0,
  4498. completedRootSegment: null,
  4499. abortableTasks: abortSet,
  4500. pingedTasks: pingedTasks,
  4501. clientRenderedBoundaries: [],
  4502. completedBoundaries: [],
  4503. partialBoundaries: [],
  4504. onError: onError === undefined ? defaultErrorHandler : onError,
  4505. onAllReady: onAllReady === undefined ? noop$1 : onAllReady,
  4506. onShellReady: onShellReady === undefined ? noop$1 : onShellReady,
  4507. onShellError: onShellError === undefined ? noop$1 : onShellError,
  4508. onFatalError: onFatalError === undefined ? noop$1 : onFatalError
  4509. }; // This segment represents the root fallback.
  4510. var rootSegment = createPendingSegment(request, 0, null, rootFormatContext, // Root segments are never embedded in Text on either edge
  4511. false, false); // There is no parent so conceptually, we're unblocked to flush this segment.
  4512. rootSegment.parentFlushed = true;
  4513. var rootTask = createTask(request, children, null, rootSegment, abortSet, emptyContextObject, rootContextSnapshot, emptyTreeContext);
  4514. pingedTasks.push(rootTask);
  4515. return request;
  4516. }
  4517. function pingTask(request, task) {
  4518. var pingedTasks = request.pingedTasks;
  4519. pingedTasks.push(task);
  4520. if (pingedTasks.length === 1) {
  4521. scheduleWork(function () {
  4522. return performWork(request);
  4523. });
  4524. }
  4525. }
  4526. function createSuspenseBoundary(request, fallbackAbortableTasks) {
  4527. return {
  4528. id: UNINITIALIZED_SUSPENSE_BOUNDARY_ID,
  4529. rootSegmentID: -1,
  4530. parentFlushed: false,
  4531. pendingTasks: 0,
  4532. forceClientRender: false,
  4533. completedSegments: [],
  4534. byteSize: 0,
  4535. fallbackAbortableTasks: fallbackAbortableTasks,
  4536. errorDigest: null
  4537. };
  4538. }
  4539. function createTask(request, node, blockedBoundary, blockedSegment, abortSet, legacyContext, context, treeContext) {
  4540. request.allPendingTasks++;
  4541. if (blockedBoundary === null) {
  4542. request.pendingRootTasks++;
  4543. } else {
  4544. blockedBoundary.pendingTasks++;
  4545. }
  4546. var task = {
  4547. node: node,
  4548. ping: function () {
  4549. return pingTask(request, task);
  4550. },
  4551. blockedBoundary: blockedBoundary,
  4552. blockedSegment: blockedSegment,
  4553. abortSet: abortSet,
  4554. legacyContext: legacyContext,
  4555. context: context,
  4556. treeContext: treeContext
  4557. };
  4558. {
  4559. task.componentStack = null;
  4560. }
  4561. abortSet.add(task);
  4562. return task;
  4563. }
  4564. function createPendingSegment(request, index, boundary, formatContext, lastPushedText, textEmbedded) {
  4565. return {
  4566. status: PENDING,
  4567. id: -1,
  4568. // lazily assigned later
  4569. index: index,
  4570. parentFlushed: false,
  4571. chunks: [],
  4572. children: [],
  4573. formatContext: formatContext,
  4574. boundary: boundary,
  4575. lastPushedText: lastPushedText,
  4576. textEmbedded: textEmbedded
  4577. };
  4578. } // DEV-only global reference to the currently executing task
  4579. var currentTaskInDEV = null;
  4580. function getCurrentStackInDEV() {
  4581. {
  4582. if (currentTaskInDEV === null || currentTaskInDEV.componentStack === null) {
  4583. return '';
  4584. }
  4585. return getStackByComponentStackNode(currentTaskInDEV.componentStack);
  4586. }
  4587. }
  4588. function pushBuiltInComponentStackInDEV(task, type) {
  4589. {
  4590. task.componentStack = {
  4591. tag: 0,
  4592. parent: task.componentStack,
  4593. type: type
  4594. };
  4595. }
  4596. }
  4597. function pushFunctionComponentStackInDEV(task, type) {
  4598. {
  4599. task.componentStack = {
  4600. tag: 1,
  4601. parent: task.componentStack,
  4602. type: type
  4603. };
  4604. }
  4605. }
  4606. function pushClassComponentStackInDEV(task, type) {
  4607. {
  4608. task.componentStack = {
  4609. tag: 2,
  4610. parent: task.componentStack,
  4611. type: type
  4612. };
  4613. }
  4614. }
  4615. function popComponentStackInDEV(task) {
  4616. {
  4617. if (task.componentStack === null) {
  4618. error('Unexpectedly popped too many stack frames. This is a bug in React.');
  4619. } else {
  4620. task.componentStack = task.componentStack.parent;
  4621. }
  4622. }
  4623. } // stash the component stack of an unwinding error until it is processed
  4624. var lastBoundaryErrorComponentStackDev = null;
  4625. function captureBoundaryErrorDetailsDev(boundary, error) {
  4626. {
  4627. var errorMessage;
  4628. if (typeof error === 'string') {
  4629. errorMessage = error;
  4630. } else if (error && typeof error.message === 'string') {
  4631. errorMessage = error.message;
  4632. } else {
  4633. // eslint-disable-next-line react-internal/safe-string-coercion
  4634. errorMessage = String(error);
  4635. }
  4636. var errorComponentStack = lastBoundaryErrorComponentStackDev || getCurrentStackInDEV();
  4637. lastBoundaryErrorComponentStackDev = null;
  4638. boundary.errorMessage = errorMessage;
  4639. boundary.errorComponentStack = errorComponentStack;
  4640. }
  4641. }
  4642. function logRecoverableError(request, error) {
  4643. // If this callback errors, we intentionally let that error bubble up to become a fatal error
  4644. // so that someone fixes the error reporting instead of hiding it.
  4645. var errorDigest = request.onError(error);
  4646. if (errorDigest != null && typeof errorDigest !== 'string') {
  4647. // eslint-disable-next-line react-internal/prod-error-codes
  4648. throw new Error("onError returned something with a type other than \"string\". onError should return a string and may return null or undefined but must not return anything else. It received something of type \"" + typeof errorDigest + "\" instead");
  4649. }
  4650. return errorDigest;
  4651. }
  4652. function fatalError(request, error) {
  4653. // This is called outside error handling code such as if the root errors outside
  4654. // a suspense boundary or if the root suspense boundary's fallback errors.
  4655. // It's also called if React itself or its host configs errors.
  4656. var onShellError = request.onShellError;
  4657. onShellError(error);
  4658. var onFatalError = request.onFatalError;
  4659. onFatalError(error);
  4660. if (request.destination !== null) {
  4661. request.status = CLOSED;
  4662. closeWithError(request.destination, error);
  4663. } else {
  4664. request.status = CLOSING;
  4665. request.fatalError = error;
  4666. }
  4667. }
  4668. function renderSuspenseBoundary(request, task, props) {
  4669. pushBuiltInComponentStackInDEV(task, 'Suspense');
  4670. var parentBoundary = task.blockedBoundary;
  4671. var parentSegment = task.blockedSegment; // Each time we enter a suspense boundary, we split out into a new segment for
  4672. // the fallback so that we can later replace that segment with the content.
  4673. // This also lets us split out the main content even if it doesn't suspend,
  4674. // in case it ends up generating a large subtree of content.
  4675. var fallback = props.fallback;
  4676. var content = props.children;
  4677. var fallbackAbortSet = new Set();
  4678. var newBoundary = createSuspenseBoundary(request, fallbackAbortSet);
  4679. var insertionIndex = parentSegment.chunks.length; // The children of the boundary segment is actually the fallback.
  4680. var boundarySegment = createPendingSegment(request, insertionIndex, newBoundary, parentSegment.formatContext, // boundaries never require text embedding at their edges because comment nodes bound them
  4681. false, false);
  4682. parentSegment.children.push(boundarySegment); // The parentSegment has a child Segment at this index so we reset the lastPushedText marker on the parent
  4683. parentSegment.lastPushedText = false; // This segment is the actual child content. We can start rendering that immediately.
  4684. var contentRootSegment = createPendingSegment(request, 0, null, parentSegment.formatContext, // boundaries never require text embedding at their edges because comment nodes bound them
  4685. false, false); // We mark the root segment as having its parent flushed. It's not really flushed but there is
  4686. // no parent segment so there's nothing to wait on.
  4687. contentRootSegment.parentFlushed = true; // Currently this is running synchronously. We could instead schedule this to pingedTasks.
  4688. // I suspect that there might be some efficiency benefits from not creating the suspended task
  4689. // and instead just using the stack if possible.
  4690. // TODO: Call this directly instead of messing with saving and restoring contexts.
  4691. // We can reuse the current context and task to render the content immediately without
  4692. // context switching. We just need to temporarily switch which boundary and which segment
  4693. // we're writing to. If something suspends, it'll spawn new suspended task with that context.
  4694. task.blockedBoundary = newBoundary;
  4695. task.blockedSegment = contentRootSegment;
  4696. try {
  4697. // We use the safe form because we don't handle suspending here. Only error handling.
  4698. renderNode(request, task, content);
  4699. pushSegmentFinale$1(contentRootSegment.chunks, request.responseState, contentRootSegment.lastPushedText, contentRootSegment.textEmbedded);
  4700. contentRootSegment.status = COMPLETED;
  4701. queueCompletedSegment(newBoundary, contentRootSegment);
  4702. if (newBoundary.pendingTasks === 0) {
  4703. // This must have been the last segment we were waiting on. This boundary is now complete.
  4704. // Therefore we won't need the fallback. We early return so that we don't have to create
  4705. // the fallback.
  4706. popComponentStackInDEV(task);
  4707. return;
  4708. }
  4709. } catch (error) {
  4710. contentRootSegment.status = ERRORED;
  4711. newBoundary.forceClientRender = true;
  4712. newBoundary.errorDigest = logRecoverableError(request, error);
  4713. {
  4714. captureBoundaryErrorDetailsDev(newBoundary, error);
  4715. } // We don't need to decrement any task numbers because we didn't spawn any new task.
  4716. // We don't need to schedule any task because we know the parent has written yet.
  4717. // We do need to fallthrough to create the fallback though.
  4718. } finally {
  4719. task.blockedBoundary = parentBoundary;
  4720. task.blockedSegment = parentSegment;
  4721. } // We create suspended task for the fallback because we don't want to actually work
  4722. // on it yet in case we finish the main content, so we queue for later.
  4723. var suspendedFallbackTask = createTask(request, fallback, parentBoundary, boundarySegment, fallbackAbortSet, task.legacyContext, task.context, task.treeContext);
  4724. {
  4725. suspendedFallbackTask.componentStack = task.componentStack;
  4726. } // TODO: This should be queued at a separate lower priority queue so that we only work
  4727. // on preparing fallbacks if we don't have any more main content to task on.
  4728. request.pingedTasks.push(suspendedFallbackTask);
  4729. popComponentStackInDEV(task);
  4730. }
  4731. function renderHostElement(request, task, type, props) {
  4732. pushBuiltInComponentStackInDEV(task, type);
  4733. var segment = task.blockedSegment;
  4734. var children = pushStartInstance(segment.chunks, type, props, request.responseState, segment.formatContext);
  4735. segment.lastPushedText = false;
  4736. var prevContext = segment.formatContext;
  4737. segment.formatContext = getChildFormatContext(prevContext, type, props); // We use the non-destructive form because if something suspends, we still
  4738. // need to pop back up and finish this subtree of HTML.
  4739. renderNode(request, task, children); // We expect that errors will fatal the whole task and that we don't need
  4740. // the correct context. Therefore this is not in a finally.
  4741. segment.formatContext = prevContext;
  4742. pushEndInstance(segment.chunks, type);
  4743. segment.lastPushedText = false;
  4744. popComponentStackInDEV(task);
  4745. }
  4746. function shouldConstruct$1(Component) {
  4747. return Component.prototype && Component.prototype.isReactComponent;
  4748. }
  4749. function renderWithHooks(request, task, Component, props, secondArg) {
  4750. var componentIdentity = {};
  4751. prepareToUseHooks(task, componentIdentity);
  4752. var result = Component(props, secondArg);
  4753. return finishHooks(Component, props, result, secondArg);
  4754. }
  4755. function finishClassComponent(request, task, instance, Component, props) {
  4756. var nextChildren = instance.render();
  4757. {
  4758. if (instance.props !== props) {
  4759. if (!didWarnAboutReassigningProps) {
  4760. error('It looks like %s is reassigning its own `this.props` while rendering. ' + 'This is not supported and can lead to confusing bugs.', getComponentNameFromType(Component) || 'a component');
  4761. }
  4762. didWarnAboutReassigningProps = true;
  4763. }
  4764. }
  4765. {
  4766. var childContextTypes = Component.childContextTypes;
  4767. if (childContextTypes !== null && childContextTypes !== undefined) {
  4768. var previousContext = task.legacyContext;
  4769. var mergedContext = processChildContext(instance, Component, previousContext, childContextTypes);
  4770. task.legacyContext = mergedContext;
  4771. renderNodeDestructive(request, task, nextChildren);
  4772. task.legacyContext = previousContext;
  4773. return;
  4774. }
  4775. }
  4776. renderNodeDestructive(request, task, nextChildren);
  4777. }
  4778. function renderClassComponent(request, task, Component, props) {
  4779. pushClassComponentStackInDEV(task, Component);
  4780. var maskedContext = getMaskedContext(Component, task.legacyContext) ;
  4781. var instance = constructClassInstance(Component, props, maskedContext);
  4782. mountClassInstance(instance, Component, props, maskedContext);
  4783. finishClassComponent(request, task, instance, Component, props);
  4784. popComponentStackInDEV(task);
  4785. }
  4786. var didWarnAboutBadClass = {};
  4787. var didWarnAboutModulePatternComponent = {};
  4788. var didWarnAboutContextTypeOnFunctionComponent = {};
  4789. var didWarnAboutGetDerivedStateOnFunctionComponent = {};
  4790. var didWarnAboutReassigningProps = false;
  4791. var didWarnAboutGenerators = false;
  4792. var didWarnAboutMaps = false;
  4793. var hasWarnedAboutUsingContextAsConsumer = false; // This would typically be a function component but we still support module pattern
  4794. // components for some reason.
  4795. function renderIndeterminateComponent(request, task, Component, props) {
  4796. var legacyContext;
  4797. {
  4798. legacyContext = getMaskedContext(Component, task.legacyContext);
  4799. }
  4800. pushFunctionComponentStackInDEV(task, Component);
  4801. {
  4802. if (Component.prototype && typeof Component.prototype.render === 'function') {
  4803. var componentName = getComponentNameFromType(Component) || 'Unknown';
  4804. if (!didWarnAboutBadClass[componentName]) {
  4805. error("The <%s /> component appears to have a render method, but doesn't extend React.Component. " + 'This is likely to cause errors. Change %s to extend React.Component instead.', componentName, componentName);
  4806. didWarnAboutBadClass[componentName] = true;
  4807. }
  4808. }
  4809. }
  4810. var value = renderWithHooks(request, task, Component, props, legacyContext);
  4811. var hasId = checkDidRenderIdHook();
  4812. {
  4813. // Support for module components is deprecated and is removed behind a flag.
  4814. // Whether or not it would crash later, we want to show a good message in DEV first.
  4815. if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
  4816. var _componentName = getComponentNameFromType(Component) || 'Unknown';
  4817. if (!didWarnAboutModulePatternComponent[_componentName]) {
  4818. error('The <%s /> component appears to be a function component that returns a class instance. ' + 'Change %s to a class that extends React.Component instead. ' + "If you can't use a class try assigning the prototype on the function as a workaround. " + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + 'cannot be called with `new` by React.', _componentName, _componentName, _componentName);
  4819. didWarnAboutModulePatternComponent[_componentName] = true;
  4820. }
  4821. }
  4822. }
  4823. if ( // Run these checks in production only if the flag is off.
  4824. // Eventually we'll delete this branch altogether.
  4825. typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
  4826. {
  4827. var _componentName2 = getComponentNameFromType(Component) || 'Unknown';
  4828. if (!didWarnAboutModulePatternComponent[_componentName2]) {
  4829. error('The <%s /> component appears to be a function component that returns a class instance. ' + 'Change %s to a class that extends React.Component instead. ' + "If you can't use a class try assigning the prototype on the function as a workaround. " + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + 'cannot be called with `new` by React.', _componentName2, _componentName2, _componentName2);
  4830. didWarnAboutModulePatternComponent[_componentName2] = true;
  4831. }
  4832. }
  4833. mountClassInstance(value, Component, props, legacyContext);
  4834. finishClassComponent(request, task, value, Component, props);
  4835. } else {
  4836. {
  4837. validateFunctionComponentInDev(Component);
  4838. } // We're now successfully past this task, and we don't have to pop back to
  4839. // the previous task every again, so we can use the destructive recursive form.
  4840. if (hasId) {
  4841. // This component materialized an id. We treat this as its own level, with
  4842. // a single "child" slot.
  4843. var prevTreeContext = task.treeContext;
  4844. var totalChildren = 1;
  4845. var index = 0;
  4846. task.treeContext = pushTreeContext(prevTreeContext, totalChildren, index);
  4847. try {
  4848. renderNodeDestructive(request, task, value);
  4849. } finally {
  4850. task.treeContext = prevTreeContext;
  4851. }
  4852. } else {
  4853. renderNodeDestructive(request, task, value);
  4854. }
  4855. }
  4856. popComponentStackInDEV(task);
  4857. }
  4858. function validateFunctionComponentInDev(Component) {
  4859. {
  4860. if (Component) {
  4861. if (Component.childContextTypes) {
  4862. error('%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component');
  4863. }
  4864. }
  4865. if (typeof Component.getDerivedStateFromProps === 'function') {
  4866. var _componentName3 = getComponentNameFromType(Component) || 'Unknown';
  4867. if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]) {
  4868. error('%s: Function components do not support getDerivedStateFromProps.', _componentName3);
  4869. didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] = true;
  4870. }
  4871. }
  4872. if (typeof Component.contextType === 'object' && Component.contextType !== null) {
  4873. var _componentName4 = getComponentNameFromType(Component) || 'Unknown';
  4874. if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) {
  4875. error('%s: Function components do not support contextType.', _componentName4);
  4876. didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true;
  4877. }
  4878. }
  4879. }
  4880. }
  4881. function resolveDefaultProps(Component, baseProps) {
  4882. if (Component && Component.defaultProps) {
  4883. // Resolve default props. Taken from ReactElement
  4884. var props = assign({}, baseProps);
  4885. var defaultProps = Component.defaultProps;
  4886. for (var propName in defaultProps) {
  4887. if (props[propName] === undefined) {
  4888. props[propName] = defaultProps[propName];
  4889. }
  4890. }
  4891. return props;
  4892. }
  4893. return baseProps;
  4894. }
  4895. function renderForwardRef(request, task, type, props, ref) {
  4896. pushFunctionComponentStackInDEV(task, type.render);
  4897. var children = renderWithHooks(request, task, type.render, props, ref);
  4898. var hasId = checkDidRenderIdHook();
  4899. if (hasId) {
  4900. // This component materialized an id. We treat this as its own level, with
  4901. // a single "child" slot.
  4902. var prevTreeContext = task.treeContext;
  4903. var totalChildren = 1;
  4904. var index = 0;
  4905. task.treeContext = pushTreeContext(prevTreeContext, totalChildren, index);
  4906. try {
  4907. renderNodeDestructive(request, task, children);
  4908. } finally {
  4909. task.treeContext = prevTreeContext;
  4910. }
  4911. } else {
  4912. renderNodeDestructive(request, task, children);
  4913. }
  4914. popComponentStackInDEV(task);
  4915. }
  4916. function renderMemo(request, task, type, props, ref) {
  4917. var innerType = type.type;
  4918. var resolvedProps = resolveDefaultProps(innerType, props);
  4919. renderElement(request, task, innerType, resolvedProps, ref);
  4920. }
  4921. function renderContextConsumer(request, task, context, props) {
  4922. // The logic below for Context differs depending on PROD or DEV mode. In
  4923. // DEV mode, we create a separate object for Context.Consumer that acts
  4924. // like a proxy to Context. This proxy object adds unnecessary code in PROD
  4925. // so we use the old behaviour (Context.Consumer references Context) to
  4926. // reduce size and overhead. The separate object references context via
  4927. // a property called "_context", which also gives us the ability to check
  4928. // in DEV mode if this property exists or not and warn if it does not.
  4929. {
  4930. if (context._context === undefined) {
  4931. // This may be because it's a Context (rather than a Consumer).
  4932. // Or it may be because it's older React where they're the same thing.
  4933. // We only want to warn if we're sure it's a new React.
  4934. if (context !== context.Consumer) {
  4935. if (!hasWarnedAboutUsingContextAsConsumer) {
  4936. hasWarnedAboutUsingContextAsConsumer = true;
  4937. error('Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
  4938. }
  4939. }
  4940. } else {
  4941. context = context._context;
  4942. }
  4943. }
  4944. var render = props.children;
  4945. {
  4946. if (typeof render !== 'function') {
  4947. error('A context consumer was rendered with multiple children, or a child ' + "that isn't a function. A context consumer expects a single child " + 'that is a function. If you did pass a function, make sure there ' + 'is no trailing or leading whitespace around it.');
  4948. }
  4949. }
  4950. var newValue = readContext(context);
  4951. var newChildren = render(newValue);
  4952. renderNodeDestructive(request, task, newChildren);
  4953. }
  4954. function renderContextProvider(request, task, type, props) {
  4955. var context = type._context;
  4956. var value = props.value;
  4957. var children = props.children;
  4958. var prevSnapshot;
  4959. {
  4960. prevSnapshot = task.context;
  4961. }
  4962. task.context = pushProvider(context, value);
  4963. renderNodeDestructive(request, task, children);
  4964. task.context = popProvider(context);
  4965. {
  4966. if (prevSnapshot !== task.context) {
  4967. error('Popping the context provider did not return back to the original snapshot. This is a bug in React.');
  4968. }
  4969. }
  4970. }
  4971. function renderLazyComponent(request, task, lazyComponent, props, ref) {
  4972. pushBuiltInComponentStackInDEV(task, 'Lazy');
  4973. var payload = lazyComponent._payload;
  4974. var init = lazyComponent._init;
  4975. var Component = init(payload);
  4976. var resolvedProps = resolveDefaultProps(Component, props);
  4977. renderElement(request, task, Component, resolvedProps, ref);
  4978. popComponentStackInDEV(task);
  4979. }
  4980. function renderElement(request, task, type, props, ref) {
  4981. if (typeof type === 'function') {
  4982. if (shouldConstruct$1(type)) {
  4983. renderClassComponent(request, task, type, props);
  4984. return;
  4985. } else {
  4986. renderIndeterminateComponent(request, task, type, props);
  4987. return;
  4988. }
  4989. }
  4990. if (typeof type === 'string') {
  4991. renderHostElement(request, task, type, props);
  4992. return;
  4993. }
  4994. switch (type) {
  4995. // TODO: LegacyHidden acts the same as a fragment. This only works
  4996. // because we currently assume that every instance of LegacyHidden is
  4997. // accompanied by a host component wrapper. In the hidden mode, the host
  4998. // component is given a `hidden` attribute, which ensures that the
  4999. // initial HTML is not visible. To support the use of LegacyHidden as a
  5000. // true fragment, without an extra DOM node, we would have to hide the
  5001. // initial HTML in some other way.
  5002. // TODO: Add REACT_OFFSCREEN_TYPE here too with the same capability.
  5003. case REACT_LEGACY_HIDDEN_TYPE:
  5004. case REACT_DEBUG_TRACING_MODE_TYPE:
  5005. case REACT_STRICT_MODE_TYPE:
  5006. case REACT_PROFILER_TYPE:
  5007. case REACT_FRAGMENT_TYPE:
  5008. {
  5009. renderNodeDestructive(request, task, props.children);
  5010. return;
  5011. }
  5012. case REACT_SUSPENSE_LIST_TYPE:
  5013. {
  5014. pushBuiltInComponentStackInDEV(task, 'SuspenseList'); // TODO: SuspenseList should control the boundaries.
  5015. renderNodeDestructive(request, task, props.children);
  5016. popComponentStackInDEV(task);
  5017. return;
  5018. }
  5019. case REACT_SCOPE_TYPE:
  5020. {
  5021. throw new Error('ReactDOMServer does not yet support scope components.');
  5022. }
  5023. // eslint-disable-next-line-no-fallthrough
  5024. case REACT_SUSPENSE_TYPE:
  5025. {
  5026. {
  5027. renderSuspenseBoundary(request, task, props);
  5028. }
  5029. return;
  5030. }
  5031. }
  5032. if (typeof type === 'object' && type !== null) {
  5033. switch (type.$$typeof) {
  5034. case REACT_FORWARD_REF_TYPE:
  5035. {
  5036. renderForwardRef(request, task, type, props, ref);
  5037. return;
  5038. }
  5039. case REACT_MEMO_TYPE:
  5040. {
  5041. renderMemo(request, task, type, props, ref);
  5042. return;
  5043. }
  5044. case REACT_PROVIDER_TYPE:
  5045. {
  5046. renderContextProvider(request, task, type, props);
  5047. return;
  5048. }
  5049. case REACT_CONTEXT_TYPE:
  5050. {
  5051. renderContextConsumer(request, task, type, props);
  5052. return;
  5053. }
  5054. case REACT_LAZY_TYPE:
  5055. {
  5056. renderLazyComponent(request, task, type, props);
  5057. return;
  5058. }
  5059. }
  5060. }
  5061. var info = '';
  5062. {
  5063. if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
  5064. info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and " + 'named imports.';
  5065. }
  5066. }
  5067. throw new Error('Element type is invalid: expected a string (for built-in ' + 'components) or a class/function (for composite components) ' + ("but got: " + (type == null ? type : typeof type) + "." + info));
  5068. }
  5069. function validateIterable(iterable, iteratorFn) {
  5070. {
  5071. // We don't support rendering Generators because it's a mutation.
  5072. // See https://github.com/facebook/react/issues/12995
  5073. if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag
  5074. iterable[Symbol.toStringTag] === 'Generator') {
  5075. if (!didWarnAboutGenerators) {
  5076. error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');
  5077. }
  5078. didWarnAboutGenerators = true;
  5079. } // Warn about using Maps as children
  5080. if (iterable.entries === iteratorFn) {
  5081. if (!didWarnAboutMaps) {
  5082. error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');
  5083. }
  5084. didWarnAboutMaps = true;
  5085. }
  5086. }
  5087. }
  5088. function renderNodeDestructive(request, task, node) {
  5089. {
  5090. // In Dev we wrap renderNodeDestructiveImpl in a try / catch so we can capture
  5091. // a component stack at the right place in the tree. We don't do this in renderNode
  5092. // becuase it is not called at every layer of the tree and we may lose frames
  5093. try {
  5094. return renderNodeDestructiveImpl(request, task, node);
  5095. } catch (x) {
  5096. if (typeof x === 'object' && x !== null && typeof x.then === 'function') ; else {
  5097. // This is an error, stash the component stack if it is null.
  5098. lastBoundaryErrorComponentStackDev = lastBoundaryErrorComponentStackDev !== null ? lastBoundaryErrorComponentStackDev : getCurrentStackInDEV();
  5099. } // rethrow so normal suspense logic can handle thrown value accordingly
  5100. throw x;
  5101. }
  5102. }
  5103. } // This function by it self renders a node and consumes the task by mutating it
  5104. // to update the current execution state.
  5105. function renderNodeDestructiveImpl(request, task, node) {
  5106. // Stash the node we're working on. We'll pick up from this task in case
  5107. // something suspends.
  5108. task.node = node; // Handle object types
  5109. if (typeof node === 'object' && node !== null) {
  5110. switch (node.$$typeof) {
  5111. case REACT_ELEMENT_TYPE:
  5112. {
  5113. var element = node;
  5114. var type = element.type;
  5115. var props = element.props;
  5116. var ref = element.ref;
  5117. renderElement(request, task, type, props, ref);
  5118. return;
  5119. }
  5120. case REACT_PORTAL_TYPE:
  5121. throw new Error('Portals are not currently supported by the server renderer. ' + 'Render them conditionally so that they only appear on the client render.');
  5122. // eslint-disable-next-line-no-fallthrough
  5123. case REACT_LAZY_TYPE:
  5124. {
  5125. var lazyNode = node;
  5126. var payload = lazyNode._payload;
  5127. var init = lazyNode._init;
  5128. var resolvedNode;
  5129. {
  5130. try {
  5131. resolvedNode = init(payload);
  5132. } catch (x) {
  5133. if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
  5134. // this Lazy initializer is suspending. push a temporary frame onto the stack so it can be
  5135. // popped off in spawnNewSuspendedTask. This aligns stack behavior between Lazy in element position
  5136. // vs Component position. We do not want the frame for Errors so we exclusively do this in
  5137. // the wakeable branch
  5138. pushBuiltInComponentStackInDEV(task, 'Lazy');
  5139. }
  5140. throw x;
  5141. }
  5142. }
  5143. renderNodeDestructive(request, task, resolvedNode);
  5144. return;
  5145. }
  5146. }
  5147. if (isArray(node)) {
  5148. renderChildrenArray(request, task, node);
  5149. return;
  5150. }
  5151. var iteratorFn = getIteratorFn(node);
  5152. if (iteratorFn) {
  5153. {
  5154. validateIterable(node, iteratorFn);
  5155. }
  5156. var iterator = iteratorFn.call(node);
  5157. if (iterator) {
  5158. // We need to know how many total children are in this set, so that we
  5159. // can allocate enough id slots to acommodate them. So we must exhaust
  5160. // the iterator before we start recursively rendering the children.
  5161. // TODO: This is not great but I think it's inherent to the id
  5162. // generation algorithm.
  5163. var step = iterator.next(); // If there are not entries, we need to push an empty so we start by checking that.
  5164. if (!step.done) {
  5165. var children = [];
  5166. do {
  5167. children.push(step.value);
  5168. step = iterator.next();
  5169. } while (!step.done);
  5170. renderChildrenArray(request, task, children);
  5171. return;
  5172. }
  5173. return;
  5174. }
  5175. }
  5176. var childString = Object.prototype.toString.call(node);
  5177. throw new Error("Objects are not valid as a React child (found: " + (childString === '[object Object]' ? 'object with keys {' + Object.keys(node).join(', ') + '}' : childString) + "). " + 'If you meant to render a collection of children, use an array ' + 'instead.');
  5178. }
  5179. if (typeof node === 'string') {
  5180. var segment = task.blockedSegment;
  5181. segment.lastPushedText = pushTextInstance$1(task.blockedSegment.chunks, node, request.responseState, segment.lastPushedText);
  5182. return;
  5183. }
  5184. if (typeof node === 'number') {
  5185. var _segment = task.blockedSegment;
  5186. _segment.lastPushedText = pushTextInstance$1(task.blockedSegment.chunks, '' + node, request.responseState, _segment.lastPushedText);
  5187. return;
  5188. }
  5189. {
  5190. if (typeof node === 'function') {
  5191. error('Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.');
  5192. }
  5193. }
  5194. }
  5195. function renderChildrenArray(request, task, children) {
  5196. var totalChildren = children.length;
  5197. for (var i = 0; i < totalChildren; i++) {
  5198. var prevTreeContext = task.treeContext;
  5199. task.treeContext = pushTreeContext(prevTreeContext, totalChildren, i);
  5200. try {
  5201. // We need to use the non-destructive form so that we can safely pop back
  5202. // up and render the sibling if something suspends.
  5203. renderNode(request, task, children[i]);
  5204. } finally {
  5205. task.treeContext = prevTreeContext;
  5206. }
  5207. }
  5208. }
  5209. function spawnNewSuspendedTask(request, task, x) {
  5210. // Something suspended, we'll need to create a new segment and resolve it later.
  5211. var segment = task.blockedSegment;
  5212. var insertionIndex = segment.chunks.length;
  5213. var newSegment = createPendingSegment(request, insertionIndex, null, segment.formatContext, // Adopt the parent segment's leading text embed
  5214. segment.lastPushedText, // Assume we are text embedded at the trailing edge
  5215. true);
  5216. segment.children.push(newSegment); // Reset lastPushedText for current Segment since the new Segment "consumed" it
  5217. segment.lastPushedText = false;
  5218. var newTask = createTask(request, task.node, task.blockedBoundary, newSegment, task.abortSet, task.legacyContext, task.context, task.treeContext);
  5219. {
  5220. if (task.componentStack !== null) {
  5221. // We pop one task off the stack because the node that suspended will be tried again,
  5222. // which will add it back onto the stack.
  5223. newTask.componentStack = task.componentStack.parent;
  5224. }
  5225. }
  5226. var ping = newTask.ping;
  5227. x.then(ping, ping);
  5228. } // This is a non-destructive form of rendering a node. If it suspends it spawns
  5229. // a new task and restores the context of this task to what it was before.
  5230. function renderNode(request, task, node) {
  5231. // TODO: Store segment.children.length here and reset it in case something
  5232. // suspended partially through writing something.
  5233. // Snapshot the current context in case something throws to interrupt the
  5234. // process.
  5235. var previousFormatContext = task.blockedSegment.formatContext;
  5236. var previousLegacyContext = task.legacyContext;
  5237. var previousContext = task.context;
  5238. var previousComponentStack = null;
  5239. {
  5240. previousComponentStack = task.componentStack;
  5241. }
  5242. try {
  5243. return renderNodeDestructive(request, task, node);
  5244. } catch (x) {
  5245. resetHooksState();
  5246. if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
  5247. spawnNewSuspendedTask(request, task, x); // Restore the context. We assume that this will be restored by the inner
  5248. // functions in case nothing throws so we don't use "finally" here.
  5249. task.blockedSegment.formatContext = previousFormatContext;
  5250. task.legacyContext = previousLegacyContext;
  5251. task.context = previousContext; // Restore all active ReactContexts to what they were before.
  5252. switchContext(previousContext);
  5253. {
  5254. task.componentStack = previousComponentStack;
  5255. }
  5256. return;
  5257. } else {
  5258. // Restore the context. We assume that this will be restored by the inner
  5259. // functions in case nothing throws so we don't use "finally" here.
  5260. task.blockedSegment.formatContext = previousFormatContext;
  5261. task.legacyContext = previousLegacyContext;
  5262. task.context = previousContext; // Restore all active ReactContexts to what they were before.
  5263. switchContext(previousContext);
  5264. {
  5265. task.componentStack = previousComponentStack;
  5266. } // We assume that we don't need the correct context.
  5267. // Let's terminate the rest of the tree and don't render any siblings.
  5268. throw x;
  5269. }
  5270. }
  5271. }
  5272. function erroredTask(request, boundary, segment, error) {
  5273. // Report the error to a global handler.
  5274. var errorDigest = logRecoverableError(request, error);
  5275. if (boundary === null) {
  5276. fatalError(request, error);
  5277. } else {
  5278. boundary.pendingTasks--;
  5279. if (!boundary.forceClientRender) {
  5280. boundary.forceClientRender = true;
  5281. boundary.errorDigest = errorDigest;
  5282. {
  5283. captureBoundaryErrorDetailsDev(boundary, error);
  5284. } // Regardless of what happens next, this boundary won't be displayed,
  5285. // so we can flush it, if the parent already flushed.
  5286. if (boundary.parentFlushed) {
  5287. // We don't have a preference where in the queue this goes since it's likely
  5288. // to error on the client anyway. However, intentionally client-rendered
  5289. // boundaries should be flushed earlier so that they can start on the client.
  5290. // We reuse the same queue for errors.
  5291. request.clientRenderedBoundaries.push(boundary);
  5292. }
  5293. }
  5294. }
  5295. request.allPendingTasks--;
  5296. if (request.allPendingTasks === 0) {
  5297. var onAllReady = request.onAllReady;
  5298. onAllReady();
  5299. }
  5300. }
  5301. function abortTaskSoft(task) {
  5302. // This aborts task without aborting the parent boundary that it blocks.
  5303. // It's used for when we didn't need this task to complete the tree.
  5304. // If task was needed, then it should use abortTask instead.
  5305. var request = this;
  5306. var boundary = task.blockedBoundary;
  5307. var segment = task.blockedSegment;
  5308. segment.status = ABORTED;
  5309. finishedTask(request, boundary, segment);
  5310. }
  5311. function abortTask(task, request, reason) {
  5312. // This aborts the task and aborts the parent that it blocks, putting it into
  5313. // client rendered mode.
  5314. var boundary = task.blockedBoundary;
  5315. var segment = task.blockedSegment;
  5316. segment.status = ABORTED;
  5317. if (boundary === null) {
  5318. request.allPendingTasks--; // We didn't complete the root so we have nothing to show. We can close
  5319. // the request;
  5320. if (request.status !== CLOSED) {
  5321. request.status = CLOSED;
  5322. if (request.destination !== null) {
  5323. close(request.destination);
  5324. }
  5325. }
  5326. } else {
  5327. boundary.pendingTasks--;
  5328. if (!boundary.forceClientRender) {
  5329. boundary.forceClientRender = true;
  5330. var _error = reason === undefined ? new Error('The render was aborted by the server without a reason.') : reason;
  5331. boundary.errorDigest = request.onError(_error);
  5332. {
  5333. var errorPrefix = 'The server did not finish this Suspense boundary: ';
  5334. if (_error && typeof _error.message === 'string') {
  5335. _error = errorPrefix + _error.message;
  5336. } else {
  5337. // eslint-disable-next-line react-internal/safe-string-coercion
  5338. _error = errorPrefix + String(_error);
  5339. }
  5340. var previousTaskInDev = currentTaskInDEV;
  5341. currentTaskInDEV = task;
  5342. try {
  5343. captureBoundaryErrorDetailsDev(boundary, _error);
  5344. } finally {
  5345. currentTaskInDEV = previousTaskInDev;
  5346. }
  5347. }
  5348. if (boundary.parentFlushed) {
  5349. request.clientRenderedBoundaries.push(boundary);
  5350. }
  5351. } // If this boundary was still pending then we haven't already cancelled its fallbacks.
  5352. // We'll need to abort the fallbacks, which will also error that parent boundary.
  5353. boundary.fallbackAbortableTasks.forEach(function (fallbackTask) {
  5354. return abortTask(fallbackTask, request, reason);
  5355. });
  5356. boundary.fallbackAbortableTasks.clear();
  5357. request.allPendingTasks--;
  5358. if (request.allPendingTasks === 0) {
  5359. var onAllReady = request.onAllReady;
  5360. onAllReady();
  5361. }
  5362. }
  5363. }
  5364. function queueCompletedSegment(boundary, segment) {
  5365. if (segment.chunks.length === 0 && segment.children.length === 1 && segment.children[0].boundary === null) {
  5366. // This is an empty segment. There's nothing to write, so we can instead transfer the ID
  5367. // to the child. That way any existing references point to the child.
  5368. var childSegment = segment.children[0];
  5369. childSegment.id = segment.id;
  5370. childSegment.parentFlushed = true;
  5371. if (childSegment.status === COMPLETED) {
  5372. queueCompletedSegment(boundary, childSegment);
  5373. }
  5374. } else {
  5375. var completedSegments = boundary.completedSegments;
  5376. completedSegments.push(segment);
  5377. }
  5378. }
  5379. function finishedTask(request, boundary, segment) {
  5380. if (boundary === null) {
  5381. if (segment.parentFlushed) {
  5382. if (request.completedRootSegment !== null) {
  5383. throw new Error('There can only be one root segment. This is a bug in React.');
  5384. }
  5385. request.completedRootSegment = segment;
  5386. }
  5387. request.pendingRootTasks--;
  5388. if (request.pendingRootTasks === 0) {
  5389. // We have completed the shell so the shell can't error anymore.
  5390. request.onShellError = noop$1;
  5391. var onShellReady = request.onShellReady;
  5392. onShellReady();
  5393. }
  5394. } else {
  5395. boundary.pendingTasks--;
  5396. if (boundary.forceClientRender) ; else if (boundary.pendingTasks === 0) {
  5397. // This must have been the last segment we were waiting on. This boundary is now complete.
  5398. if (segment.parentFlushed) {
  5399. // Our parent segment already flushed, so we need to schedule this segment to be emitted.
  5400. // If it is a segment that was aborted, we'll write other content instead so we don't need
  5401. // to emit it.
  5402. if (segment.status === COMPLETED) {
  5403. queueCompletedSegment(boundary, segment);
  5404. }
  5405. }
  5406. if (boundary.parentFlushed) {
  5407. // The segment might be part of a segment that didn't flush yet, but if the boundary's
  5408. // parent flushed, we need to schedule the boundary to be emitted.
  5409. request.completedBoundaries.push(boundary);
  5410. } // We can now cancel any pending task on the fallback since we won't need to show it anymore.
  5411. // This needs to happen after we read the parentFlushed flags because aborting can finish
  5412. // work which can trigger user code, which can start flushing, which can change those flags.
  5413. boundary.fallbackAbortableTasks.forEach(abortTaskSoft, request);
  5414. boundary.fallbackAbortableTasks.clear();
  5415. } else {
  5416. if (segment.parentFlushed) {
  5417. // Our parent already flushed, so we need to schedule this segment to be emitted.
  5418. // If it is a segment that was aborted, we'll write other content instead so we don't need
  5419. // to emit it.
  5420. if (segment.status === COMPLETED) {
  5421. queueCompletedSegment(boundary, segment);
  5422. var completedSegments = boundary.completedSegments;
  5423. if (completedSegments.length === 1) {
  5424. // This is the first time since we last flushed that we completed anything.
  5425. // We can schedule this boundary to emit its partially completed segments early
  5426. // in case the parent has already been flushed.
  5427. if (boundary.parentFlushed) {
  5428. request.partialBoundaries.push(boundary);
  5429. }
  5430. }
  5431. }
  5432. }
  5433. }
  5434. }
  5435. request.allPendingTasks--;
  5436. if (request.allPendingTasks === 0) {
  5437. // This needs to be called at the very end so that we can synchronously write the result
  5438. // in the callback if needed.
  5439. var onAllReady = request.onAllReady;
  5440. onAllReady();
  5441. }
  5442. }
  5443. function retryTask(request, task) {
  5444. var segment = task.blockedSegment;
  5445. if (segment.status !== PENDING) {
  5446. // We completed this by other means before we had a chance to retry it.
  5447. return;
  5448. } // We restore the context to what it was when we suspended.
  5449. // We don't restore it after we leave because it's likely that we'll end up
  5450. // needing a very similar context soon again.
  5451. switchContext(task.context);
  5452. var prevTaskInDEV = null;
  5453. {
  5454. prevTaskInDEV = currentTaskInDEV;
  5455. currentTaskInDEV = task;
  5456. }
  5457. try {
  5458. // We call the destructive form that mutates this task. That way if something
  5459. // suspends again, we can reuse the same task instead of spawning a new one.
  5460. renderNodeDestructive(request, task, task.node);
  5461. pushSegmentFinale$1(segment.chunks, request.responseState, segment.lastPushedText, segment.textEmbedded);
  5462. task.abortSet.delete(task);
  5463. segment.status = COMPLETED;
  5464. finishedTask(request, task.blockedBoundary, segment);
  5465. } catch (x) {
  5466. resetHooksState();
  5467. if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
  5468. // Something suspended again, let's pick it back up later.
  5469. var ping = task.ping;
  5470. x.then(ping, ping);
  5471. } else {
  5472. task.abortSet.delete(task);
  5473. segment.status = ERRORED;
  5474. erroredTask(request, task.blockedBoundary, segment, x);
  5475. }
  5476. } finally {
  5477. {
  5478. currentTaskInDEV = prevTaskInDEV;
  5479. }
  5480. }
  5481. }
  5482. function performWork(request) {
  5483. if (request.status === CLOSED) {
  5484. return;
  5485. }
  5486. var prevContext = getActiveContext();
  5487. var prevDispatcher = ReactCurrentDispatcher$1.current;
  5488. ReactCurrentDispatcher$1.current = Dispatcher;
  5489. var prevGetCurrentStackImpl;
  5490. {
  5491. prevGetCurrentStackImpl = ReactDebugCurrentFrame$1.getCurrentStack;
  5492. ReactDebugCurrentFrame$1.getCurrentStack = getCurrentStackInDEV;
  5493. }
  5494. var prevResponseState = currentResponseState;
  5495. setCurrentResponseState(request.responseState);
  5496. try {
  5497. var pingedTasks = request.pingedTasks;
  5498. var i;
  5499. for (i = 0; i < pingedTasks.length; i++) {
  5500. var task = pingedTasks[i];
  5501. retryTask(request, task);
  5502. }
  5503. pingedTasks.splice(0, i);
  5504. if (request.destination !== null) {
  5505. flushCompletedQueues(request, request.destination);
  5506. }
  5507. } catch (error) {
  5508. logRecoverableError(request, error);
  5509. fatalError(request, error);
  5510. } finally {
  5511. setCurrentResponseState(prevResponseState);
  5512. ReactCurrentDispatcher$1.current = prevDispatcher;
  5513. {
  5514. ReactDebugCurrentFrame$1.getCurrentStack = prevGetCurrentStackImpl;
  5515. }
  5516. if (prevDispatcher === Dispatcher) {
  5517. // This means that we were in a reentrant work loop. This could happen
  5518. // in a renderer that supports synchronous work like renderToString,
  5519. // when it's called from within another renderer.
  5520. // Normally we don't bother switching the contexts to their root/default
  5521. // values when leaving because we'll likely need the same or similar
  5522. // context again. However, when we're inside a synchronous loop like this
  5523. // we'll to restore the context to what it was before returning.
  5524. switchContext(prevContext);
  5525. }
  5526. }
  5527. }
  5528. function flushSubtree(request, destination, segment) {
  5529. segment.parentFlushed = true;
  5530. switch (segment.status) {
  5531. case PENDING:
  5532. {
  5533. // We're emitting a placeholder for this segment to be filled in later.
  5534. // Therefore we'll need to assign it an ID - to refer to it by.
  5535. var segmentID = segment.id = request.nextSegmentId++; // When this segment finally completes it won't be embedded in text since it will flush separately
  5536. segment.lastPushedText = false;
  5537. segment.textEmbedded = false;
  5538. return writePlaceholder(destination, request.responseState, segmentID);
  5539. }
  5540. case COMPLETED:
  5541. {
  5542. segment.status = FLUSHED;
  5543. var r = true;
  5544. var chunks = segment.chunks;
  5545. var chunkIdx = 0;
  5546. var children = segment.children;
  5547. for (var childIdx = 0; childIdx < children.length; childIdx++) {
  5548. var nextChild = children[childIdx]; // Write all the chunks up until the next child.
  5549. for (; chunkIdx < nextChild.index; chunkIdx++) {
  5550. writeChunk(destination, chunks[chunkIdx]);
  5551. }
  5552. r = flushSegment(request, destination, nextChild);
  5553. } // Finally just write all the remaining chunks
  5554. for (; chunkIdx < chunks.length - 1; chunkIdx++) {
  5555. writeChunk(destination, chunks[chunkIdx]);
  5556. }
  5557. if (chunkIdx < chunks.length) {
  5558. r = writeChunkAndReturn(destination, chunks[chunkIdx]);
  5559. }
  5560. return r;
  5561. }
  5562. default:
  5563. {
  5564. throw new Error('Aborted, errored or already flushed boundaries should not be flushed again. This is a bug in React.');
  5565. }
  5566. }
  5567. }
  5568. function flushSegment(request, destination, segment) {
  5569. var boundary = segment.boundary;
  5570. if (boundary === null) {
  5571. // Not a suspense boundary.
  5572. return flushSubtree(request, destination, segment);
  5573. }
  5574. boundary.parentFlushed = true; // This segment is a Suspense boundary. We need to decide whether to
  5575. // emit the content or the fallback now.
  5576. if (boundary.forceClientRender) {
  5577. // Emit a client rendered suspense boundary wrapper.
  5578. // We never queue the inner boundary so we'll never emit its content or partial segments.
  5579. writeStartClientRenderedSuspenseBoundary$1(destination, request.responseState, boundary.errorDigest, boundary.errorMessage, boundary.errorComponentStack); // Flush the fallback.
  5580. flushSubtree(request, destination, segment);
  5581. return writeEndClientRenderedSuspenseBoundary$1(destination, request.responseState);
  5582. } else if (boundary.pendingTasks > 0) {
  5583. // This boundary is still loading. Emit a pending suspense boundary wrapper.
  5584. // Assign an ID to refer to the future content by.
  5585. boundary.rootSegmentID = request.nextSegmentId++;
  5586. if (boundary.completedSegments.length > 0) {
  5587. // If this is at least partially complete, we can queue it to be partially emitted early.
  5588. request.partialBoundaries.push(boundary);
  5589. } /// This is the first time we should have referenced this ID.
  5590. var id = boundary.id = assignSuspenseBoundaryID(request.responseState);
  5591. writeStartPendingSuspenseBoundary(destination, request.responseState, id); // Flush the fallback.
  5592. flushSubtree(request, destination, segment);
  5593. return writeEndPendingSuspenseBoundary(destination, request.responseState);
  5594. } else if (boundary.byteSize > request.progressiveChunkSize) {
  5595. // This boundary is large and will be emitted separately so that we can progressively show
  5596. // other content. We add it to the queue during the flush because we have to ensure that
  5597. // the parent flushes first so that there's something to inject it into.
  5598. // We also have to make sure that it's emitted into the queue in a deterministic slot.
  5599. // I.e. we can't insert it here when it completes.
  5600. // Assign an ID to refer to the future content by.
  5601. boundary.rootSegmentID = request.nextSegmentId++;
  5602. request.completedBoundaries.push(boundary); // Emit a pending rendered suspense boundary wrapper.
  5603. writeStartPendingSuspenseBoundary(destination, request.responseState, boundary.id); // Flush the fallback.
  5604. flushSubtree(request, destination, segment);
  5605. return writeEndPendingSuspenseBoundary(destination, request.responseState);
  5606. } else {
  5607. // We can inline this boundary's content as a complete boundary.
  5608. writeStartCompletedSuspenseBoundary$1(destination, request.responseState);
  5609. var completedSegments = boundary.completedSegments;
  5610. if (completedSegments.length !== 1) {
  5611. throw new Error('A previously unvisited boundary must have exactly one root segment. This is a bug in React.');
  5612. }
  5613. var contentSegment = completedSegments[0];
  5614. flushSegment(request, destination, contentSegment);
  5615. return writeEndCompletedSuspenseBoundary$1(destination, request.responseState);
  5616. }
  5617. }
  5618. function flushClientRenderedBoundary(request, destination, boundary) {
  5619. return writeClientRenderBoundaryInstruction(destination, request.responseState, boundary.id, boundary.errorDigest, boundary.errorMessage, boundary.errorComponentStack);
  5620. }
  5621. function flushSegmentContainer(request, destination, segment) {
  5622. writeStartSegment(destination, request.responseState, segment.formatContext, segment.id);
  5623. flushSegment(request, destination, segment);
  5624. return writeEndSegment(destination, segment.formatContext);
  5625. }
  5626. function flushCompletedBoundary(request, destination, boundary) {
  5627. var completedSegments = boundary.completedSegments;
  5628. var i = 0;
  5629. for (; i < completedSegments.length; i++) {
  5630. var segment = completedSegments[i];
  5631. flushPartiallyCompletedSegment(request, destination, boundary, segment);
  5632. }
  5633. completedSegments.length = 0;
  5634. return writeCompletedBoundaryInstruction(destination, request.responseState, boundary.id, boundary.rootSegmentID);
  5635. }
  5636. function flushPartialBoundary(request, destination, boundary) {
  5637. var completedSegments = boundary.completedSegments;
  5638. var i = 0;
  5639. for (; i < completedSegments.length; i++) {
  5640. var segment = completedSegments[i];
  5641. if (!flushPartiallyCompletedSegment(request, destination, boundary, segment)) {
  5642. i++;
  5643. completedSegments.splice(0, i); // Only write as much as the buffer wants. Something higher priority
  5644. // might want to write later.
  5645. return false;
  5646. }
  5647. }
  5648. completedSegments.splice(0, i);
  5649. return true;
  5650. }
  5651. function flushPartiallyCompletedSegment(request, destination, boundary, segment) {
  5652. if (segment.status === FLUSHED) {
  5653. // We've already flushed this inline.
  5654. return true;
  5655. }
  5656. var segmentID = segment.id;
  5657. if (segmentID === -1) {
  5658. // This segment wasn't previously referred to. This happens at the root of
  5659. // a boundary. We make kind of a leap here and assume this is the root.
  5660. var rootSegmentID = segment.id = boundary.rootSegmentID;
  5661. if (rootSegmentID === -1) {
  5662. throw new Error('A root segment ID must have been assigned by now. This is a bug in React.');
  5663. }
  5664. return flushSegmentContainer(request, destination, segment);
  5665. } else {
  5666. flushSegmentContainer(request, destination, segment);
  5667. return writeCompletedSegmentInstruction(destination, request.responseState, segmentID);
  5668. }
  5669. }
  5670. function flushCompletedQueues(request, destination) {
  5671. try {
  5672. // The structure of this is to go through each queue one by one and write
  5673. // until the sink tells us to stop. When we should stop, we still finish writing
  5674. // that item fully and then yield. At that point we remove the already completed
  5675. // items up until the point we completed them.
  5676. // TODO: Emit preloading.
  5677. // TODO: It's kind of unfortunate to keep checking this array after we've already
  5678. // emitted the root.
  5679. var completedRootSegment = request.completedRootSegment;
  5680. if (completedRootSegment !== null && request.pendingRootTasks === 0) {
  5681. flushSegment(request, destination, completedRootSegment);
  5682. request.completedRootSegment = null;
  5683. writeCompletedRoot(destination, request.responseState);
  5684. } // We emit client rendering instructions for already emitted boundaries first.
  5685. // This is so that we can signal to the client to start client rendering them as
  5686. // soon as possible.
  5687. var clientRenderedBoundaries = request.clientRenderedBoundaries;
  5688. var i;
  5689. for (i = 0; i < clientRenderedBoundaries.length; i++) {
  5690. var boundary = clientRenderedBoundaries[i];
  5691. if (!flushClientRenderedBoundary(request, destination, boundary)) {
  5692. request.destination = null;
  5693. i++;
  5694. clientRenderedBoundaries.splice(0, i);
  5695. return;
  5696. }
  5697. }
  5698. clientRenderedBoundaries.splice(0, i); // Next we emit any complete boundaries. It's better to favor boundaries
  5699. // that are completely done since we can actually show them, than it is to emit
  5700. // any individual segments from a partially complete boundary.
  5701. var completedBoundaries = request.completedBoundaries;
  5702. for (i = 0; i < completedBoundaries.length; i++) {
  5703. var _boundary = completedBoundaries[i];
  5704. if (!flushCompletedBoundary(request, destination, _boundary)) {
  5705. request.destination = null;
  5706. i++;
  5707. completedBoundaries.splice(0, i);
  5708. return;
  5709. }
  5710. }
  5711. completedBoundaries.splice(0, i); // Allow anything written so far to flush to the underlying sink before
  5712. // we continue with lower priorities.
  5713. completeWriting(destination);
  5714. beginWriting(destination); // TODO: Here we'll emit data used by hydration.
  5715. // Next we emit any segments of any boundaries that are partially complete
  5716. // but not deeply complete.
  5717. var partialBoundaries = request.partialBoundaries;
  5718. for (i = 0; i < partialBoundaries.length; i++) {
  5719. var _boundary2 = partialBoundaries[i];
  5720. if (!flushPartialBoundary(request, destination, _boundary2)) {
  5721. request.destination = null;
  5722. i++;
  5723. partialBoundaries.splice(0, i);
  5724. return;
  5725. }
  5726. }
  5727. partialBoundaries.splice(0, i); // Next we check the completed boundaries again. This may have had
  5728. // boundaries added to it in case they were too larged to be inlined.
  5729. // New ones might be added in this loop.
  5730. var largeBoundaries = request.completedBoundaries;
  5731. for (i = 0; i < largeBoundaries.length; i++) {
  5732. var _boundary3 = largeBoundaries[i];
  5733. if (!flushCompletedBoundary(request, destination, _boundary3)) {
  5734. request.destination = null;
  5735. i++;
  5736. largeBoundaries.splice(0, i);
  5737. return;
  5738. }
  5739. }
  5740. largeBoundaries.splice(0, i);
  5741. } finally {
  5742. if (request.allPendingTasks === 0 && request.pingedTasks.length === 0 && request.clientRenderedBoundaries.length === 0 && request.completedBoundaries.length === 0 // We don't need to check any partially completed segments because
  5743. // either they have pending task or they're complete.
  5744. ) {
  5745. {
  5746. if (request.abortableTasks.size !== 0) {
  5747. error('There was still abortable task at the root when we closed. This is a bug in React.');
  5748. }
  5749. } // We're done.
  5750. close(destination);
  5751. }
  5752. }
  5753. }
  5754. function startWork(request) {
  5755. scheduleWork(function () {
  5756. return performWork(request);
  5757. });
  5758. }
  5759. function startFlowing(request, destination) {
  5760. if (request.status === CLOSING) {
  5761. request.status = CLOSED;
  5762. closeWithError(destination, request.fatalError);
  5763. return;
  5764. }
  5765. if (request.status === CLOSED) {
  5766. return;
  5767. }
  5768. if (request.destination !== null) {
  5769. // We're already flowing.
  5770. return;
  5771. }
  5772. request.destination = destination;
  5773. try {
  5774. flushCompletedQueues(request, destination);
  5775. } catch (error) {
  5776. logRecoverableError(request, error);
  5777. fatalError(request, error);
  5778. }
  5779. } // This is called to early terminate a request. It puts all pending boundaries in client rendered state.
  5780. function abort(request, reason) {
  5781. try {
  5782. var abortableTasks = request.abortableTasks;
  5783. abortableTasks.forEach(function (task) {
  5784. return abortTask(task, request, reason);
  5785. });
  5786. abortableTasks.clear();
  5787. if (request.destination !== null) {
  5788. flushCompletedQueues(request, request.destination);
  5789. }
  5790. } catch (error) {
  5791. logRecoverableError(request, error);
  5792. fatalError(request, error);
  5793. }
  5794. }
  5795. function onError() {// Non-fatal errors are ignored.
  5796. }
  5797. function renderToStringImpl(children, options, generateStaticMarkup, abortReason) {
  5798. var didFatal = false;
  5799. var fatalError = null;
  5800. var result = '';
  5801. var destination = {
  5802. push: function (chunk) {
  5803. if (chunk !== null) {
  5804. result += chunk;
  5805. }
  5806. return true;
  5807. },
  5808. destroy: function (error) {
  5809. didFatal = true;
  5810. fatalError = error;
  5811. }
  5812. };
  5813. var readyToStream = false;
  5814. function onShellReady() {
  5815. readyToStream = true;
  5816. }
  5817. var request = createRequest(children, createResponseState$1(generateStaticMarkup, options ? options.identifierPrefix : undefined), createRootFormatContext(), Infinity, onError, undefined, onShellReady, undefined, undefined);
  5818. startWork(request); // If anything suspended and is still pending, we'll abort it before writing.
  5819. // That way we write only client-rendered boundaries from the start.
  5820. abort(request, abortReason);
  5821. startFlowing(request, destination);
  5822. if (didFatal) {
  5823. throw fatalError;
  5824. }
  5825. if (!readyToStream) {
  5826. // Note: This error message is the one we use on the client. It doesn't
  5827. // really make sense here. But this is the legacy server renderer, anyway.
  5828. // We're going to delete it soon.
  5829. throw new Error('A component suspended while responding to synchronous input. This ' + 'will cause the UI to be replaced with a loading indicator. To fix, ' + 'updates that suspend should be wrapped with startTransition.');
  5830. }
  5831. return result;
  5832. }
  5833. function _inheritsLoose(subClass, superClass) {
  5834. subClass.prototype = Object.create(superClass.prototype);
  5835. subClass.prototype.constructor = subClass;
  5836. subClass.__proto__ = superClass;
  5837. }
  5838. var ReactMarkupReadableStream = /*#__PURE__*/function (_Readable) {
  5839. _inheritsLoose(ReactMarkupReadableStream, _Readable);
  5840. function ReactMarkupReadableStream() {
  5841. var _this;
  5842. // Calls the stream.Readable(options) constructor. Consider exposing built-in
  5843. // features like highWaterMark in the future.
  5844. _this = _Readable.call(this, {}) || this;
  5845. _this.request = null;
  5846. _this.startedFlowing = false;
  5847. return _this;
  5848. }
  5849. var _proto = ReactMarkupReadableStream.prototype;
  5850. _proto._destroy = function _destroy(err, callback) {
  5851. abort(this.request); // $FlowFixMe: The type definition for the callback should allow undefined and null.
  5852. callback(err);
  5853. };
  5854. _proto._read = function _read(size) {
  5855. if (this.startedFlowing) {
  5856. startFlowing(this.request, this);
  5857. }
  5858. };
  5859. return ReactMarkupReadableStream;
  5860. }(stream.Readable);
  5861. function onError$1() {// Non-fatal errors are ignored.
  5862. }
  5863. function renderToNodeStreamImpl(children, options, generateStaticMarkup) {
  5864. function onAllReady() {
  5865. // We wait until everything has loaded before starting to write.
  5866. // That way we only end up with fully resolved HTML even if we suspend.
  5867. destination.startedFlowing = true;
  5868. startFlowing(request, destination);
  5869. }
  5870. var destination = new ReactMarkupReadableStream();
  5871. var request = createRequest(children, createResponseState$1(false, options ? options.identifierPrefix : undefined), createRootFormatContext(), Infinity, onError$1, onAllReady, undefined, undefined);
  5872. destination.request = request;
  5873. startWork(request);
  5874. return destination;
  5875. }
  5876. function renderToNodeStream(children, options) {
  5877. {
  5878. error('renderToNodeStream is deprecated. Use renderToPipeableStream instead.');
  5879. }
  5880. return renderToNodeStreamImpl(children, options);
  5881. }
  5882. function renderToStaticNodeStream(children, options) {
  5883. return renderToNodeStreamImpl(children, options);
  5884. }
  5885. function renderToString(children, options) {
  5886. return renderToStringImpl(children, options, false, 'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToPipeableStream" which supports Suspense on the server');
  5887. }
  5888. function renderToStaticMarkup(children, options) {
  5889. return renderToStringImpl(children, options, true, 'The server used "renderToStaticMarkup" which does not support Suspense. If you intended to have the server wait for the suspended component please switch to "renderToPipeableStream" which supports Suspense on the server');
  5890. }
  5891. exports.renderToNodeStream = renderToNodeStream;
  5892. exports.renderToStaticMarkup = renderToStaticMarkup;
  5893. exports.renderToStaticNodeStream = renderToStaticNodeStream;
  5894. exports.renderToString = renderToString;
  5895. exports.version = ReactVersion;
  5896. })();
  5897. }