index.js 170 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683
  1. import { basename, camelize, classify, deepClone, isBrowser, isNuxtApp, isUrlString, kebabize, target } from "@vue/devtools-shared";
  2. import { debounce } from "perfect-debounce";
  3. import { createHooks } from "hookable";
  4. import { createBirpc, createBirpcGroup } from "birpc";
  5. //#region \0rolldown/runtime.js
  6. var __create = Object.create;
  7. var __defProp = Object.defineProperty;
  8. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  9. var __getOwnPropNames = Object.getOwnPropertyNames;
  10. var __getProtoOf = Object.getPrototypeOf;
  11. var __hasOwnProp = Object.prototype.hasOwnProperty;
  12. var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
  13. var __copyProps = (to, from, except, desc) => {
  14. if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
  15. key = keys[i];
  16. if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
  17. get: ((k) => from[k]).bind(null, key),
  18. enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
  19. });
  20. }
  21. return to;
  22. };
  23. var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
  24. value: mod,
  25. enumerable: true
  26. }) : target, mod));
  27. //#endregion
  28. //#region src/compat/index.ts
  29. function onLegacyDevToolsPluginApiAvailable(cb) {
  30. if (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__) {
  31. cb();
  32. return;
  33. }
  34. Object.defineProperty(target, "__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__", {
  35. set(value) {
  36. if (value) cb();
  37. },
  38. configurable: true
  39. });
  40. }
  41. //#endregion
  42. //#region src/core/component/utils/index.ts
  43. function getComponentTypeName(options) {
  44. if (typeof options === "function") return options.displayName || options.name || options.__VUE_DEVTOOLS_COMPONENT_GUSSED_NAME__ || "";
  45. const name = options.name || options._componentTag || options.__VUE_DEVTOOLS_COMPONENT_GUSSED_NAME__ || options.__name;
  46. if (name === "index" && options.__file?.endsWith("index.vue")) return "";
  47. return name;
  48. }
  49. function getComponentFileName(options) {
  50. const file = options.__file;
  51. if (file) return classify(basename(file, ".vue"));
  52. }
  53. function getComponentName(options) {
  54. const name = options.displayName || options.name || options._componentTag;
  55. if (name) return name;
  56. return getComponentFileName(options);
  57. }
  58. function saveComponentGussedName(instance, name) {
  59. instance.type.__VUE_DEVTOOLS_COMPONENT_GUSSED_NAME__ = name;
  60. return name;
  61. }
  62. function getAppRecord(instance) {
  63. if (instance.__VUE_DEVTOOLS_NEXT_APP_RECORD__) return instance.__VUE_DEVTOOLS_NEXT_APP_RECORD__;
  64. else if (instance.root) return instance.appContext.app.__VUE_DEVTOOLS_NEXT_APP_RECORD__;
  65. }
  66. async function getComponentId(options) {
  67. const { app, uid, instance } = options;
  68. try {
  69. if (instance.__VUE_DEVTOOLS_NEXT_UID__) return instance.__VUE_DEVTOOLS_NEXT_UID__;
  70. const appRecord = await getAppRecord(app);
  71. if (!appRecord) return null;
  72. const isRoot = appRecord.rootInstance === instance;
  73. return `${appRecord.id}:${isRoot ? "root" : uid}`;
  74. } catch (e) {}
  75. }
  76. function isFragment(instance) {
  77. const subTreeType = instance.subTree?.type;
  78. const appRecord = getAppRecord(instance);
  79. if (appRecord) return appRecord?.types?.Fragment === subTreeType;
  80. return false;
  81. }
  82. function isBeingDestroyed(instance) {
  83. return instance._isBeingDestroyed || instance.isUnmounted;
  84. }
  85. /**
  86. * Get the appropriate display name for an instance.
  87. *
  88. * @param {Vue} instance
  89. * @return {string}
  90. */
  91. function getInstanceName(instance) {
  92. const name = getComponentTypeName(instance?.type || {});
  93. if (name) return name;
  94. if (instance?.root === instance) return "Root";
  95. for (const key in instance.parent?.type?.components) if (instance.parent.type.components[key] === instance?.type) return saveComponentGussedName(instance, key);
  96. for (const key in instance.appContext?.components) if (instance.appContext.components[key] === instance?.type) return saveComponentGussedName(instance, key);
  97. const fileName = getComponentFileName(instance?.type || {});
  98. if (fileName) return fileName;
  99. return "Anonymous Component";
  100. }
  101. /**
  102. * Returns a devtools unique id for instance.
  103. * @param {Vue} instance
  104. */
  105. function getUniqueComponentId(instance) {
  106. return `${instance?.appContext?.app?.__VUE_DEVTOOLS_NEXT_APP_RECORD_ID__ ?? 0}:${instance === instance?.root ? "root" : instance.uid}`;
  107. }
  108. function getRenderKey(value) {
  109. if (value == null) return "";
  110. if (typeof value === "number") return value;
  111. else if (typeof value === "string") return `'${value}'`;
  112. else if (Array.isArray(value)) return "Array";
  113. else return "Object";
  114. }
  115. function returnError(cb) {
  116. try {
  117. return cb();
  118. } catch (e) {
  119. return e;
  120. }
  121. }
  122. function getComponentInstance(appRecord, instanceId) {
  123. instanceId = instanceId || `${appRecord.id}:root`;
  124. return appRecord.instanceMap.get(instanceId) || appRecord.instanceMap.get(":root");
  125. }
  126. function ensurePropertyExists(obj, key, skipObjCheck = false) {
  127. return skipObjCheck ? key in obj : typeof obj === "object" && obj !== null ? key in obj : false;
  128. }
  129. //#endregion
  130. //#region src/core/component/state/bounding-rect.ts
  131. function createRect() {
  132. const rect = {
  133. top: 0,
  134. bottom: 0,
  135. left: 0,
  136. right: 0,
  137. get width() {
  138. return rect.right - rect.left;
  139. },
  140. get height() {
  141. return rect.bottom - rect.top;
  142. }
  143. };
  144. return rect;
  145. }
  146. let range;
  147. function getTextRect(node) {
  148. if (!range) range = document.createRange();
  149. range.selectNode(node);
  150. return range.getBoundingClientRect();
  151. }
  152. function getFragmentRect(vnode) {
  153. const rect = createRect();
  154. if (!vnode.children) return rect;
  155. for (let i = 0, l = vnode.children.length; i < l; i++) {
  156. const childVnode = vnode.children[i];
  157. let childRect;
  158. if (childVnode.component) childRect = getComponentBoundingRect(childVnode.component);
  159. else if (childVnode.el) {
  160. const el = childVnode.el;
  161. if (el.nodeType === 1 || el.getBoundingClientRect) childRect = el.getBoundingClientRect();
  162. else if (el.nodeType === 3 && el.data.trim()) childRect = getTextRect(el);
  163. }
  164. if (childRect) mergeRects(rect, childRect);
  165. }
  166. return rect;
  167. }
  168. function mergeRects(a, b) {
  169. if (!a.top || b.top < a.top) a.top = b.top;
  170. if (!a.bottom || b.bottom > a.bottom) a.bottom = b.bottom;
  171. if (!a.left || b.left < a.left) a.left = b.left;
  172. if (!a.right || b.right > a.right) a.right = b.right;
  173. return a;
  174. }
  175. const DEFAULT_RECT = {
  176. top: 0,
  177. left: 0,
  178. right: 0,
  179. bottom: 0,
  180. width: 0,
  181. height: 0
  182. };
  183. function getComponentBoundingRect(instance) {
  184. const el = instance.subTree.el;
  185. if (typeof window === "undefined") return DEFAULT_RECT;
  186. if (isFragment(instance)) return getFragmentRect(instance.subTree);
  187. else if (el?.nodeType === 1) return el?.getBoundingClientRect();
  188. else if (instance.subTree.component) return getComponentBoundingRect(instance.subTree.component);
  189. else return DEFAULT_RECT;
  190. }
  191. //#endregion
  192. //#region src/core/component/tree/el.ts
  193. function getRootElementsFromComponentInstance(instance) {
  194. if (isFragment(instance)) return getFragmentRootElements(instance.subTree);
  195. if (!instance.subTree) return [];
  196. return [instance.subTree.el];
  197. }
  198. function getFragmentRootElements(vnode) {
  199. if (!vnode.children) return [];
  200. const list = [];
  201. vnode.children.forEach((childVnode) => {
  202. if (childVnode.component) list.push(...getRootElementsFromComponentInstance(childVnode.component));
  203. else if (childVnode?.el) list.push(childVnode.el);
  204. });
  205. return list;
  206. }
  207. //#endregion
  208. //#region src/core/component-highlighter/index.ts
  209. const CONTAINER_ELEMENT_ID = "__vue-devtools-component-inspector__";
  210. const CARD_ELEMENT_ID = "__vue-devtools-component-inspector__card__";
  211. const COMPONENT_NAME_ELEMENT_ID = "__vue-devtools-component-inspector__name__";
  212. const INDICATOR_ELEMENT_ID = "__vue-devtools-component-inspector__indicator__";
  213. const containerStyles = {
  214. display: "block",
  215. zIndex: 2147483640,
  216. position: "fixed",
  217. backgroundColor: "#42b88325",
  218. border: "1px solid #42b88350",
  219. borderRadius: "5px",
  220. transition: "all 0.1s ease-in",
  221. pointerEvents: "none"
  222. };
  223. const cardStyles = {
  224. fontFamily: "Arial, Helvetica, sans-serif",
  225. padding: "5px 8px",
  226. borderRadius: "4px",
  227. textAlign: "left",
  228. position: "absolute",
  229. left: 0,
  230. color: "#e9e9e9",
  231. fontSize: "14px",
  232. fontWeight: 600,
  233. lineHeight: "24px",
  234. backgroundColor: "#42b883",
  235. boxShadow: "0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)"
  236. };
  237. const indicatorStyles = {
  238. display: "inline-block",
  239. fontWeight: 400,
  240. fontStyle: "normal",
  241. fontSize: "12px",
  242. opacity: .7
  243. };
  244. function getContainerElement() {
  245. return document.getElementById(CONTAINER_ELEMENT_ID);
  246. }
  247. function getCardElement() {
  248. return document.getElementById(CARD_ELEMENT_ID);
  249. }
  250. function getIndicatorElement() {
  251. return document.getElementById(INDICATOR_ELEMENT_ID);
  252. }
  253. function getNameElement() {
  254. return document.getElementById(COMPONENT_NAME_ELEMENT_ID);
  255. }
  256. function getStyles(bounds) {
  257. return {
  258. left: `${Math.round(bounds.left * 100) / 100}px`,
  259. top: `${Math.round(bounds.top * 100) / 100}px`,
  260. width: `${Math.round(bounds.width * 100) / 100}px`,
  261. height: `${Math.round(bounds.height * 100) / 100}px`
  262. };
  263. }
  264. function create(options) {
  265. const containerEl = document.createElement("div");
  266. containerEl.id = options.elementId ?? CONTAINER_ELEMENT_ID;
  267. Object.assign(containerEl.style, {
  268. ...containerStyles,
  269. ...getStyles(options.bounds),
  270. ...options.style
  271. });
  272. const cardEl = document.createElement("span");
  273. cardEl.id = CARD_ELEMENT_ID;
  274. Object.assign(cardEl.style, {
  275. ...cardStyles,
  276. top: options.bounds.top < 35 ? 0 : "-35px"
  277. });
  278. const nameEl = document.createElement("span");
  279. nameEl.id = COMPONENT_NAME_ELEMENT_ID;
  280. nameEl.innerHTML = `&lt;${options.name}&gt;&nbsp;&nbsp;`;
  281. const indicatorEl = document.createElement("i");
  282. indicatorEl.id = INDICATOR_ELEMENT_ID;
  283. indicatorEl.innerHTML = `${Math.round(options.bounds.width * 100) / 100} x ${Math.round(options.bounds.height * 100) / 100}`;
  284. Object.assign(indicatorEl.style, indicatorStyles);
  285. cardEl.appendChild(nameEl);
  286. cardEl.appendChild(indicatorEl);
  287. containerEl.appendChild(cardEl);
  288. document.body.appendChild(containerEl);
  289. return containerEl;
  290. }
  291. function update(options) {
  292. const containerEl = getContainerElement();
  293. const cardEl = getCardElement();
  294. const nameEl = getNameElement();
  295. const indicatorEl = getIndicatorElement();
  296. if (containerEl) {
  297. Object.assign(containerEl.style, {
  298. ...containerStyles,
  299. ...getStyles(options.bounds)
  300. });
  301. Object.assign(cardEl.style, { top: options.bounds.top < 35 ? 0 : "-35px" });
  302. nameEl.innerHTML = `&lt;${options.name}&gt;&nbsp;&nbsp;`;
  303. indicatorEl.innerHTML = `${Math.round(options.bounds.width * 100) / 100} x ${Math.round(options.bounds.height * 100) / 100}`;
  304. }
  305. }
  306. function highlight(instance) {
  307. const bounds = getComponentBoundingRect(instance);
  308. if (!bounds.width && !bounds.height) return;
  309. const name = getInstanceName(instance);
  310. getContainerElement() ? update({
  311. bounds,
  312. name
  313. }) : create({
  314. bounds,
  315. name
  316. });
  317. }
  318. function unhighlight() {
  319. const el = getContainerElement();
  320. if (el) el.style.display = "none";
  321. }
  322. let inspectInstance = null;
  323. function inspectFn(e) {
  324. const target = e.target;
  325. if (target) {
  326. const instance = target.__vueParentComponent;
  327. if (instance) {
  328. inspectInstance = instance;
  329. if (instance.vnode.el) {
  330. const bounds = getComponentBoundingRect(instance);
  331. const name = getInstanceName(instance);
  332. getContainerElement() ? update({
  333. bounds,
  334. name
  335. }) : create({
  336. bounds,
  337. name
  338. });
  339. }
  340. }
  341. }
  342. }
  343. function selectComponentFn(e, cb) {
  344. e.preventDefault();
  345. e.stopPropagation();
  346. if (inspectInstance) cb(getUniqueComponentId(inspectInstance));
  347. }
  348. let inspectComponentHighLighterSelectFn = null;
  349. function cancelInspectComponentHighLighter() {
  350. unhighlight();
  351. window.removeEventListener("mouseover", inspectFn);
  352. window.removeEventListener("click", inspectComponentHighLighterSelectFn, true);
  353. inspectComponentHighLighterSelectFn = null;
  354. }
  355. function inspectComponentHighLighter() {
  356. window.addEventListener("mouseover", inspectFn);
  357. return new Promise((resolve) => {
  358. function onSelect(e) {
  359. e.preventDefault();
  360. e.stopPropagation();
  361. selectComponentFn(e, (id) => {
  362. window.removeEventListener("click", onSelect, true);
  363. inspectComponentHighLighterSelectFn = null;
  364. window.removeEventListener("mouseover", inspectFn);
  365. const el = getContainerElement();
  366. if (el) el.style.display = "none";
  367. resolve(JSON.stringify({ id }));
  368. });
  369. }
  370. inspectComponentHighLighterSelectFn = onSelect;
  371. window.addEventListener("click", onSelect, true);
  372. });
  373. }
  374. function scrollToComponent(options) {
  375. const instance = getComponentInstance(activeAppRecord.value, options.id);
  376. if (instance) {
  377. const [el] = getRootElementsFromComponentInstance(instance);
  378. if (typeof el.scrollIntoView === "function") el.scrollIntoView({ behavior: "smooth" });
  379. else {
  380. const bounds = getComponentBoundingRect(instance);
  381. const scrollTarget = document.createElement("div");
  382. const styles = {
  383. ...getStyles(bounds),
  384. position: "absolute"
  385. };
  386. Object.assign(scrollTarget.style, styles);
  387. document.body.appendChild(scrollTarget);
  388. scrollTarget.scrollIntoView({ behavior: "smooth" });
  389. setTimeout(() => {
  390. document.body.removeChild(scrollTarget);
  391. }, 2e3);
  392. }
  393. setTimeout(() => {
  394. const bounds = getComponentBoundingRect(instance);
  395. if (bounds.width || bounds.height) {
  396. const name = getInstanceName(instance);
  397. const el = getContainerElement();
  398. el ? update({
  399. ...options,
  400. name,
  401. bounds
  402. }) : create({
  403. ...options,
  404. name,
  405. bounds
  406. });
  407. setTimeout(() => {
  408. if (el) el.style.display = "none";
  409. }, 1500);
  410. }
  411. }, 1200);
  412. }
  413. }
  414. //#endregion
  415. //#region src/core/component-inspector/index.ts
  416. target.__VUE_DEVTOOLS_COMPONENT_INSPECTOR_ENABLED__ ??= true;
  417. function toggleComponentInspectorEnabled(enabled) {
  418. target.__VUE_DEVTOOLS_COMPONENT_INSPECTOR_ENABLED__ = enabled;
  419. }
  420. function waitForInspectorInit(cb) {
  421. let total = 0;
  422. const timer = setInterval(() => {
  423. if (target.__VUE_INSPECTOR__) {
  424. clearInterval(timer);
  425. total += 30;
  426. cb();
  427. }
  428. if (total >= 5e3) clearInterval(timer);
  429. }, 30);
  430. }
  431. function setupInspector() {
  432. const inspector = target.__VUE_INSPECTOR__;
  433. const _openInEditor = inspector.openInEditor;
  434. inspector.openInEditor = async (...params) => {
  435. inspector.disable();
  436. _openInEditor(...params);
  437. };
  438. }
  439. function getComponentInspector() {
  440. return new Promise((resolve) => {
  441. function setup() {
  442. setupInspector();
  443. resolve(target.__VUE_INSPECTOR__);
  444. }
  445. if (!target.__VUE_INSPECTOR__) waitForInspectorInit(() => {
  446. setup();
  447. });
  448. else setup();
  449. });
  450. }
  451. //#endregion
  452. //#region src/shared/stub-vue.ts
  453. /**
  454. * To prevent include a **HUGE** vue package in the final bundle of chrome ext / electron
  455. * we stub the necessary vue module.
  456. * This implementation is based on the 1c3327a0fa5983aa9078e3f7bb2330f572435425 commit
  457. */
  458. /**
  459. * @from [@vue/reactivity](https://github.com/vuejs/core/blob/1c3327a0fa5983aa9078e3f7bb2330f572435425/packages/reactivity/src/constants.ts#L17-L23)
  460. */
  461. let ReactiveFlags = /* @__PURE__ */ function(ReactiveFlags) {
  462. ReactiveFlags["SKIP"] = "__v_skip";
  463. ReactiveFlags["IS_REACTIVE"] = "__v_isReactive";
  464. ReactiveFlags["IS_READONLY"] = "__v_isReadonly";
  465. ReactiveFlags["IS_SHALLOW"] = "__v_isShallow";
  466. ReactiveFlags["RAW"] = "__v_raw";
  467. return ReactiveFlags;
  468. }({});
  469. /**
  470. * @from [@vue/reactivity](https://github.com/vuejs/core/blob/1c3327a0fa5983aa9078e3f7bb2330f572435425/packages/reactivity/src/reactive.ts#L330-L332)
  471. */
  472. function isReadonly(value) {
  473. return !!(value && value[ReactiveFlags.IS_READONLY]);
  474. }
  475. /**
  476. * @from [@vue/reactivity](https://github.com/vuejs/core/blob/1c3327a0fa5983aa9078e3f7bb2330f572435425/packages/reactivity/src/reactive.ts#L312-L317)
  477. */
  478. function isReactive$1(value) {
  479. if (isReadonly(value)) return isReactive$1(value[ReactiveFlags.RAW]);
  480. return !!(value && value[ReactiveFlags.IS_REACTIVE]);
  481. }
  482. function isRef$1(r) {
  483. return !!(r && r.__v_isRef === true);
  484. }
  485. /**
  486. * @from [@vue/reactivity](https://github.com/vuejs/core/blob/1c3327a0fa5983aa9078e3f7bb2330f572435425/packages/reactivity/src/reactive.ts#L372-L375)
  487. */
  488. function toRaw$1(observed) {
  489. const raw = observed && observed[ReactiveFlags.RAW];
  490. return raw ? toRaw$1(raw) : observed;
  491. }
  492. //#endregion
  493. //#region src/core/component/state/editor.ts
  494. var StateEditor = class {
  495. constructor() {
  496. this.refEditor = new RefStateEditor();
  497. }
  498. set(object, path, value, cb) {
  499. const sections = Array.isArray(path) ? path : path.split(".");
  500. while (sections.length > 1) {
  501. const section = sections.shift();
  502. if (object instanceof Map) object = object.get(section);
  503. else if (object instanceof Set) object = Array.from(object.values())[section];
  504. else object = object[section];
  505. if (this.refEditor.isRef(object)) object = this.refEditor.get(object);
  506. }
  507. const field = sections[0];
  508. const item = this.refEditor.get(object)[field];
  509. if (cb) cb(object, field, value);
  510. else if (this.refEditor.isRef(item)) this.refEditor.set(item, value);
  511. else object[field] = value;
  512. }
  513. get(object, path) {
  514. const sections = Array.isArray(path) ? path : path.split(".");
  515. for (let i = 0; i < sections.length; i++) {
  516. if (object instanceof Map) object = object.get(sections[i]);
  517. else object = object[sections[i]];
  518. if (this.refEditor.isRef(object)) object = this.refEditor.get(object);
  519. if (!object) return void 0;
  520. }
  521. return object;
  522. }
  523. has(object, path, parent = false) {
  524. if (typeof object === "undefined") return false;
  525. const sections = Array.isArray(path) ? path.slice() : path.split(".");
  526. const size = !parent ? 1 : 2;
  527. while (object && sections.length > size) {
  528. const section = sections.shift();
  529. object = object[section];
  530. if (this.refEditor.isRef(object)) object = this.refEditor.get(object);
  531. }
  532. return object != null && Object.prototype.hasOwnProperty.call(object, sections[0]);
  533. }
  534. createDefaultSetCallback(state) {
  535. return (object, field, value) => {
  536. if (state.remove || state.newKey) if (Array.isArray(object)) object.splice(field, 1);
  537. else if (toRaw$1(object) instanceof Map) object.delete(field);
  538. else if (toRaw$1(object) instanceof Set) object.delete(Array.from(object.values())[field]);
  539. else Reflect.deleteProperty(object, field);
  540. if (!state.remove) {
  541. const target = object[state.newKey || field];
  542. if (this.refEditor.isRef(target)) this.refEditor.set(target, value);
  543. else if (toRaw$1(object) instanceof Map) object.set(state.newKey || field, value);
  544. else if (toRaw$1(object) instanceof Set) object.add(value);
  545. else object[state.newKey || field] = value;
  546. }
  547. };
  548. }
  549. };
  550. var RefStateEditor = class {
  551. set(ref, value) {
  552. if (isRef$1(ref)) ref.value = value;
  553. else {
  554. if (ref instanceof Set && Array.isArray(value)) {
  555. ref.clear();
  556. value.forEach((v) => ref.add(v));
  557. return;
  558. }
  559. const currentKeys = Object.keys(value);
  560. if (ref instanceof Map) {
  561. const previousKeysSet = new Set(ref.keys());
  562. currentKeys.forEach((key) => {
  563. ref.set(key, Reflect.get(value, key));
  564. previousKeysSet.delete(key);
  565. });
  566. previousKeysSet.forEach((key) => ref.delete(key));
  567. return;
  568. }
  569. const previousKeysSet = new Set(Object.keys(ref));
  570. currentKeys.forEach((key) => {
  571. Reflect.set(ref, key, Reflect.get(value, key));
  572. previousKeysSet.delete(key);
  573. });
  574. previousKeysSet.forEach((key) => Reflect.deleteProperty(ref, key));
  575. }
  576. }
  577. get(ref) {
  578. return isRef$1(ref) ? ref.value : ref;
  579. }
  580. isRef(ref) {
  581. return isRef$1(ref) || isReactive$1(ref);
  582. }
  583. };
  584. async function editComponentState(payload, stateEditor) {
  585. const { path, nodeId, state, type } = payload;
  586. const instance = getComponentInstance(activeAppRecord.value, nodeId);
  587. if (!instance) return;
  588. const targetPath = path.slice();
  589. let target;
  590. if (Object.keys(instance.props).includes(path[0])) target = instance.props;
  591. else if (instance.devtoolsRawSetupState && Object.keys(instance.devtoolsRawSetupState).includes(path[0])) target = instance.devtoolsRawSetupState;
  592. else if (instance.data && Object.keys(instance.data).includes(path[0])) target = instance.data;
  593. else target = instance.proxy;
  594. if (target && targetPath) {
  595. if (state.type === "object" && type === "reactive") {}
  596. stateEditor.set(target, targetPath, state.value, stateEditor.createDefaultSetCallback(state));
  597. }
  598. }
  599. const stateEditor = new StateEditor();
  600. async function editState(payload) {
  601. editComponentState(payload, stateEditor);
  602. }
  603. //#endregion
  604. //#region src/core/timeline/storage.ts
  605. const TIMELINE_LAYERS_STATE_STORAGE_ID = "__VUE_DEVTOOLS_KIT_TIMELINE_LAYERS_STATE__";
  606. function addTimelineLayersStateToStorage(state) {
  607. if (!isBrowser || typeof localStorage === "undefined" || localStorage === null) return;
  608. localStorage.setItem(TIMELINE_LAYERS_STATE_STORAGE_ID, JSON.stringify(state));
  609. }
  610. function getTimelineLayersStateFromStorage() {
  611. if (typeof window === "undefined" || !isBrowser || typeof localStorage === "undefined" || localStorage === null) return {
  612. recordingState: false,
  613. mouseEventEnabled: false,
  614. keyboardEventEnabled: false,
  615. componentEventEnabled: false,
  616. performanceEventEnabled: false,
  617. selected: ""
  618. };
  619. const state = typeof localStorage.getItem !== "undefined" ? localStorage.getItem(TIMELINE_LAYERS_STATE_STORAGE_ID) : null;
  620. return state ? JSON.parse(state) : {
  621. recordingState: false,
  622. mouseEventEnabled: false,
  623. keyboardEventEnabled: false,
  624. componentEventEnabled: false,
  625. performanceEventEnabled: false,
  626. selected: ""
  627. };
  628. }
  629. //#endregion
  630. //#region src/ctx/timeline.ts
  631. target.__VUE_DEVTOOLS_KIT_TIMELINE_LAYERS ??= [];
  632. const devtoolsTimelineLayers = new Proxy(target.__VUE_DEVTOOLS_KIT_TIMELINE_LAYERS, { get(target, prop, receiver) {
  633. return Reflect.get(target, prop, receiver);
  634. } });
  635. function addTimelineLayer(options, descriptor) {
  636. devtoolsState.timelineLayersState[descriptor.id] = false;
  637. devtoolsTimelineLayers.push({
  638. ...options,
  639. descriptorId: descriptor.id,
  640. appRecord: getAppRecord(descriptor.app)
  641. });
  642. }
  643. function updateTimelineLayersState(state) {
  644. const updatedState = {
  645. ...devtoolsState.timelineLayersState,
  646. ...state
  647. };
  648. addTimelineLayersStateToStorage(updatedState);
  649. updateDevToolsState({ timelineLayersState: updatedState });
  650. }
  651. //#endregion
  652. //#region src/ctx/inspector.ts
  653. target.__VUE_DEVTOOLS_KIT_INSPECTOR__ ??= [];
  654. const devtoolsInspector = new Proxy(target.__VUE_DEVTOOLS_KIT_INSPECTOR__, { get(target, prop, receiver) {
  655. return Reflect.get(target, prop, receiver);
  656. } });
  657. const callInspectorUpdatedHook = debounce(() => {
  658. devtoolsContext.hooks.callHook(DevToolsMessagingHookKeys.SEND_INSPECTOR_TO_CLIENT, getActiveInspectors());
  659. });
  660. function addInspector(inspector, descriptor) {
  661. devtoolsInspector.push({
  662. options: inspector,
  663. descriptor,
  664. treeFilterPlaceholder: inspector.treeFilterPlaceholder ?? "Search tree...",
  665. stateFilterPlaceholder: inspector.stateFilterPlaceholder ?? "Search state...",
  666. treeFilter: "",
  667. selectedNodeId: "",
  668. appRecord: getAppRecord(descriptor.app)
  669. });
  670. callInspectorUpdatedHook();
  671. }
  672. function getActiveInspectors() {
  673. return devtoolsInspector.filter((inspector) => inspector.descriptor.app === activeAppRecord.value.app).filter((inspector) => inspector.descriptor.id !== "components").map((inspector) => {
  674. const descriptor = inspector.descriptor;
  675. const options = inspector.options;
  676. return {
  677. id: options.id,
  678. label: options.label,
  679. logo: descriptor.logo,
  680. icon: `custom-ic-baseline-${options?.icon?.replace(/_/g, "-")}`,
  681. packageName: descriptor.packageName,
  682. homepage: descriptor.homepage,
  683. pluginId: descriptor.id
  684. };
  685. });
  686. }
  687. function getInspectorInfo(id) {
  688. const inspector = getInspector(id, activeAppRecord.value.app);
  689. if (!inspector) return;
  690. const descriptor = inspector.descriptor;
  691. const options = inspector.options;
  692. const timelineLayers = devtoolsTimelineLayers.filter((layer) => layer.descriptorId === descriptor.id).map((item) => ({
  693. id: item.id,
  694. label: item.label,
  695. color: item.color
  696. }));
  697. return {
  698. id: options.id,
  699. label: options.label,
  700. logo: descriptor.logo,
  701. packageName: descriptor.packageName,
  702. homepage: descriptor.homepage,
  703. timelineLayers,
  704. treeFilterPlaceholder: inspector.treeFilterPlaceholder,
  705. stateFilterPlaceholder: inspector.stateFilterPlaceholder
  706. };
  707. }
  708. function getInspector(id, app) {
  709. return devtoolsInspector.find((inspector) => inspector.options.id === id && (app ? inspector.descriptor.app === app : true));
  710. }
  711. function getInspectorActions(id) {
  712. return getInspector(id)?.options.actions;
  713. }
  714. function getInspectorNodeActions(id) {
  715. return getInspector(id)?.options.nodeActions;
  716. }
  717. //#endregion
  718. //#region src/ctx/hook.ts
  719. let DevToolsV6PluginAPIHookKeys = /* @__PURE__ */ function(DevToolsV6PluginAPIHookKeys) {
  720. DevToolsV6PluginAPIHookKeys["VISIT_COMPONENT_TREE"] = "visitComponentTree";
  721. DevToolsV6PluginAPIHookKeys["INSPECT_COMPONENT"] = "inspectComponent";
  722. DevToolsV6PluginAPIHookKeys["EDIT_COMPONENT_STATE"] = "editComponentState";
  723. DevToolsV6PluginAPIHookKeys["GET_INSPECTOR_TREE"] = "getInspectorTree";
  724. DevToolsV6PluginAPIHookKeys["GET_INSPECTOR_STATE"] = "getInspectorState";
  725. DevToolsV6PluginAPIHookKeys["EDIT_INSPECTOR_STATE"] = "editInspectorState";
  726. DevToolsV6PluginAPIHookKeys["INSPECT_TIMELINE_EVENT"] = "inspectTimelineEvent";
  727. DevToolsV6PluginAPIHookKeys["TIMELINE_CLEARED"] = "timelineCleared";
  728. DevToolsV6PluginAPIHookKeys["SET_PLUGIN_SETTINGS"] = "setPluginSettings";
  729. return DevToolsV6PluginAPIHookKeys;
  730. }({});
  731. let DevToolsContextHookKeys = /* @__PURE__ */ function(DevToolsContextHookKeys) {
  732. DevToolsContextHookKeys["ADD_INSPECTOR"] = "addInspector";
  733. DevToolsContextHookKeys["SEND_INSPECTOR_TREE"] = "sendInspectorTree";
  734. DevToolsContextHookKeys["SEND_INSPECTOR_STATE"] = "sendInspectorState";
  735. DevToolsContextHookKeys["CUSTOM_INSPECTOR_SELECT_NODE"] = "customInspectorSelectNode";
  736. DevToolsContextHookKeys["TIMELINE_LAYER_ADDED"] = "timelineLayerAdded";
  737. DevToolsContextHookKeys["TIMELINE_EVENT_ADDED"] = "timelineEventAdded";
  738. DevToolsContextHookKeys["GET_COMPONENT_INSTANCES"] = "getComponentInstances";
  739. DevToolsContextHookKeys["GET_COMPONENT_BOUNDS"] = "getComponentBounds";
  740. DevToolsContextHookKeys["GET_COMPONENT_NAME"] = "getComponentName";
  741. DevToolsContextHookKeys["COMPONENT_HIGHLIGHT"] = "componentHighlight";
  742. DevToolsContextHookKeys["COMPONENT_UNHIGHLIGHT"] = "componentUnhighlight";
  743. return DevToolsContextHookKeys;
  744. }({});
  745. let DevToolsMessagingHookKeys = /* @__PURE__ */ function(DevToolsMessagingHookKeys) {
  746. DevToolsMessagingHookKeys["SEND_INSPECTOR_TREE_TO_CLIENT"] = "sendInspectorTreeToClient";
  747. DevToolsMessagingHookKeys["SEND_INSPECTOR_STATE_TO_CLIENT"] = "sendInspectorStateToClient";
  748. DevToolsMessagingHookKeys["SEND_TIMELINE_EVENT_TO_CLIENT"] = "sendTimelineEventToClient";
  749. DevToolsMessagingHookKeys["SEND_INSPECTOR_TO_CLIENT"] = "sendInspectorToClient";
  750. DevToolsMessagingHookKeys["SEND_ACTIVE_APP_UNMOUNTED_TO_CLIENT"] = "sendActiveAppUpdatedToClient";
  751. DevToolsMessagingHookKeys["DEVTOOLS_STATE_UPDATED"] = "devtoolsStateUpdated";
  752. DevToolsMessagingHookKeys["DEVTOOLS_CONNECTED_UPDATED"] = "devtoolsConnectedUpdated";
  753. DevToolsMessagingHookKeys["ROUTER_INFO_UPDATED"] = "routerInfoUpdated";
  754. return DevToolsMessagingHookKeys;
  755. }({});
  756. function createDevToolsCtxHooks() {
  757. const hooks = createHooks();
  758. hooks.hook(DevToolsContextHookKeys.ADD_INSPECTOR, ({ inspector, plugin }) => {
  759. addInspector(inspector, plugin.descriptor);
  760. });
  761. const debounceSendInspectorTree = debounce(async ({ inspectorId, plugin }) => {
  762. if (!inspectorId || !plugin?.descriptor?.app || devtoolsState.highPerfModeEnabled) return;
  763. const inspector = getInspector(inspectorId, plugin.descriptor.app);
  764. const _payload = {
  765. app: plugin.descriptor.app,
  766. inspectorId,
  767. filter: inspector?.treeFilter || "",
  768. rootNodes: []
  769. };
  770. await new Promise((resolve) => {
  771. hooks.callHookWith(async (callbacks) => {
  772. await Promise.all(callbacks.map((cb) => cb(_payload)));
  773. resolve();
  774. }, DevToolsV6PluginAPIHookKeys.GET_INSPECTOR_TREE);
  775. });
  776. hooks.callHookWith(async (callbacks) => {
  777. await Promise.all(callbacks.map((cb) => cb({
  778. inspectorId,
  779. rootNodes: _payload.rootNodes
  780. })));
  781. }, DevToolsMessagingHookKeys.SEND_INSPECTOR_TREE_TO_CLIENT);
  782. }, 120);
  783. hooks.hook(DevToolsContextHookKeys.SEND_INSPECTOR_TREE, debounceSendInspectorTree);
  784. const debounceSendInspectorState = debounce(async ({ inspectorId, plugin }) => {
  785. if (!inspectorId || !plugin?.descriptor?.app || devtoolsState.highPerfModeEnabled) return;
  786. const inspector = getInspector(inspectorId, plugin.descriptor.app);
  787. const _payload = {
  788. app: plugin.descriptor.app,
  789. inspectorId,
  790. nodeId: inspector?.selectedNodeId || "",
  791. state: null
  792. };
  793. const ctx = { currentTab: `custom-inspector:${inspectorId}` };
  794. if (_payload.nodeId) await new Promise((resolve) => {
  795. hooks.callHookWith(async (callbacks) => {
  796. await Promise.all(callbacks.map((cb) => cb(_payload, ctx)));
  797. resolve();
  798. }, DevToolsV6PluginAPIHookKeys.GET_INSPECTOR_STATE);
  799. });
  800. hooks.callHookWith(async (callbacks) => {
  801. await Promise.all(callbacks.map((cb) => cb({
  802. inspectorId,
  803. nodeId: _payload.nodeId,
  804. state: _payload.state
  805. })));
  806. }, DevToolsMessagingHookKeys.SEND_INSPECTOR_STATE_TO_CLIENT);
  807. }, 120);
  808. hooks.hook(DevToolsContextHookKeys.SEND_INSPECTOR_STATE, debounceSendInspectorState);
  809. hooks.hook(DevToolsContextHookKeys.CUSTOM_INSPECTOR_SELECT_NODE, ({ inspectorId, nodeId, plugin }) => {
  810. const inspector = getInspector(inspectorId, plugin.descriptor.app);
  811. if (!inspector) return;
  812. inspector.selectedNodeId = nodeId;
  813. });
  814. hooks.hook(DevToolsContextHookKeys.TIMELINE_LAYER_ADDED, ({ options, plugin }) => {
  815. addTimelineLayer(options, plugin.descriptor);
  816. });
  817. hooks.hook(DevToolsContextHookKeys.TIMELINE_EVENT_ADDED, ({ options, plugin }) => {
  818. if (devtoolsState.highPerfModeEnabled || !devtoolsState.timelineLayersState?.[plugin.descriptor.id] && ![
  819. "performance",
  820. "component-event",
  821. "keyboard",
  822. "mouse"
  823. ].includes(options.layerId)) return;
  824. hooks.callHookWith(async (callbacks) => {
  825. await Promise.all(callbacks.map((cb) => cb(options)));
  826. }, DevToolsMessagingHookKeys.SEND_TIMELINE_EVENT_TO_CLIENT);
  827. });
  828. hooks.hook(DevToolsContextHookKeys.GET_COMPONENT_INSTANCES, async ({ app }) => {
  829. const appRecord = app.__VUE_DEVTOOLS_NEXT_APP_RECORD__;
  830. if (!appRecord) return null;
  831. const appId = appRecord.id.toString();
  832. return [...appRecord.instanceMap].filter(([key]) => key.split(":")[0] === appId).map(([, instance]) => instance);
  833. });
  834. hooks.hook(DevToolsContextHookKeys.GET_COMPONENT_BOUNDS, async ({ instance }) => {
  835. return getComponentBoundingRect(instance);
  836. });
  837. hooks.hook(DevToolsContextHookKeys.GET_COMPONENT_NAME, ({ instance }) => {
  838. return getInstanceName(instance);
  839. });
  840. hooks.hook(DevToolsContextHookKeys.COMPONENT_HIGHLIGHT, ({ uid }) => {
  841. const instance = activeAppRecord.value.instanceMap.get(uid);
  842. if (instance) highlight(instance);
  843. });
  844. hooks.hook(DevToolsContextHookKeys.COMPONENT_UNHIGHLIGHT, () => {
  845. unhighlight();
  846. });
  847. return hooks;
  848. }
  849. //#endregion
  850. //#region src/ctx/state.ts
  851. target.__VUE_DEVTOOLS_KIT_APP_RECORDS__ ??= [];
  852. target.__VUE_DEVTOOLS_KIT_ACTIVE_APP_RECORD__ ??= {};
  853. target.__VUE_DEVTOOLS_KIT_ACTIVE_APP_RECORD_ID__ ??= "";
  854. target.__VUE_DEVTOOLS_KIT_CUSTOM_TABS__ ??= [];
  855. target.__VUE_DEVTOOLS_KIT_CUSTOM_COMMANDS__ ??= [];
  856. const STATE_KEY = "__VUE_DEVTOOLS_KIT_GLOBAL_STATE__";
  857. function initStateFactory() {
  858. return {
  859. connected: false,
  860. clientConnected: false,
  861. vitePluginDetected: true,
  862. appRecords: [],
  863. activeAppRecordId: "",
  864. tabs: [],
  865. commands: [],
  866. highPerfModeEnabled: true,
  867. devtoolsClientDetected: {},
  868. perfUniqueGroupId: 0,
  869. timelineLayersState: getTimelineLayersStateFromStorage()
  870. };
  871. }
  872. target[STATE_KEY] ??= initStateFactory();
  873. const callStateUpdatedHook = debounce((state) => {
  874. devtoolsContext.hooks.callHook(DevToolsMessagingHookKeys.DEVTOOLS_STATE_UPDATED, { state });
  875. });
  876. const callConnectedUpdatedHook = debounce((state, oldState) => {
  877. devtoolsContext.hooks.callHook(DevToolsMessagingHookKeys.DEVTOOLS_CONNECTED_UPDATED, {
  878. state,
  879. oldState
  880. });
  881. });
  882. const devtoolsAppRecords = new Proxy(target.__VUE_DEVTOOLS_KIT_APP_RECORDS__, { get(_target, prop, receiver) {
  883. if (prop === "value") return target.__VUE_DEVTOOLS_KIT_APP_RECORDS__;
  884. return target.__VUE_DEVTOOLS_KIT_APP_RECORDS__[prop];
  885. } });
  886. const addDevToolsAppRecord = (app) => {
  887. target.__VUE_DEVTOOLS_KIT_APP_RECORDS__ = [...target.__VUE_DEVTOOLS_KIT_APP_RECORDS__, app];
  888. };
  889. const removeDevToolsAppRecord = (app) => {
  890. target.__VUE_DEVTOOLS_KIT_APP_RECORDS__ = devtoolsAppRecords.value.filter((record) => record.app !== app);
  891. };
  892. const activeAppRecord = new Proxy(target.__VUE_DEVTOOLS_KIT_ACTIVE_APP_RECORD__, { get(_target, prop, receiver) {
  893. if (prop === "value") return target.__VUE_DEVTOOLS_KIT_ACTIVE_APP_RECORD__;
  894. else if (prop === "id") return target.__VUE_DEVTOOLS_KIT_ACTIVE_APP_RECORD_ID__;
  895. return target.__VUE_DEVTOOLS_KIT_ACTIVE_APP_RECORD__[prop];
  896. } });
  897. function updateAllStates() {
  898. callStateUpdatedHook({
  899. ...target[STATE_KEY],
  900. appRecords: devtoolsAppRecords.value,
  901. activeAppRecordId: activeAppRecord.id,
  902. tabs: target.__VUE_DEVTOOLS_KIT_CUSTOM_TABS__,
  903. commands: target.__VUE_DEVTOOLS_KIT_CUSTOM_COMMANDS__
  904. });
  905. }
  906. function setActiveAppRecord(app) {
  907. target.__VUE_DEVTOOLS_KIT_ACTIVE_APP_RECORD__ = app;
  908. updateAllStates();
  909. }
  910. function setActiveAppRecordId(id) {
  911. target.__VUE_DEVTOOLS_KIT_ACTIVE_APP_RECORD_ID__ = id;
  912. updateAllStates();
  913. }
  914. const devtoolsState = new Proxy(target[STATE_KEY], {
  915. get(target$3, property) {
  916. if (property === "appRecords") return devtoolsAppRecords;
  917. else if (property === "activeAppRecordId") return activeAppRecord.id;
  918. else if (property === "tabs") return target.__VUE_DEVTOOLS_KIT_CUSTOM_TABS__;
  919. else if (property === "commands") return target.__VUE_DEVTOOLS_KIT_CUSTOM_COMMANDS__;
  920. return target[STATE_KEY][property];
  921. },
  922. deleteProperty(target, property) {
  923. delete target[property];
  924. return true;
  925. },
  926. set(target$4, property, value) {
  927. target$4[property] = value;
  928. target[STATE_KEY][property] = value;
  929. return true;
  930. }
  931. });
  932. function resetDevToolsState() {
  933. Object.assign(target[STATE_KEY], initStateFactory());
  934. }
  935. function updateDevToolsState(state) {
  936. const oldState = {
  937. ...target[STATE_KEY],
  938. appRecords: devtoolsAppRecords.value,
  939. activeAppRecordId: activeAppRecord.id
  940. };
  941. if (oldState.connected !== state.connected && state.connected || oldState.clientConnected !== state.clientConnected && state.clientConnected) callConnectedUpdatedHook(target[STATE_KEY], oldState);
  942. Object.assign(target[STATE_KEY], state);
  943. updateAllStates();
  944. }
  945. function onDevToolsConnected(fn) {
  946. return new Promise((resolve) => {
  947. if (devtoolsState.connected) {
  948. fn();
  949. resolve();
  950. }
  951. devtoolsContext.hooks.hook(DevToolsMessagingHookKeys.DEVTOOLS_CONNECTED_UPDATED, ({ state }) => {
  952. if (state.connected) {
  953. fn();
  954. resolve();
  955. }
  956. });
  957. });
  958. }
  959. const resolveIcon = (icon) => {
  960. if (!icon) return;
  961. if (icon.startsWith("baseline-")) return `custom-ic-${icon}`;
  962. if (icon.startsWith("i-") || isUrlString(icon)) return icon;
  963. return `custom-ic-baseline-${icon}`;
  964. };
  965. function addCustomTab(tab) {
  966. const tabs = target.__VUE_DEVTOOLS_KIT_CUSTOM_TABS__;
  967. if (tabs.some((t) => t.name === tab.name)) return;
  968. tabs.push({
  969. ...tab,
  970. icon: resolveIcon(tab.icon)
  971. });
  972. updateAllStates();
  973. }
  974. function addCustomCommand(action) {
  975. const commands = target.__VUE_DEVTOOLS_KIT_CUSTOM_COMMANDS__;
  976. if (commands.some((t) => t.id === action.id)) return;
  977. commands.push({
  978. ...action,
  979. icon: resolveIcon(action.icon),
  980. children: action.children ? action.children.map((child) => ({
  981. ...child,
  982. icon: resolveIcon(child.icon)
  983. })) : void 0
  984. });
  985. updateAllStates();
  986. }
  987. function removeCustomCommand(actionId) {
  988. const commands = target.__VUE_DEVTOOLS_KIT_CUSTOM_COMMANDS__;
  989. const index = commands.findIndex((t) => t.id === actionId);
  990. if (index === -1) return;
  991. commands.splice(index, 1);
  992. updateAllStates();
  993. }
  994. function toggleClientConnected(state) {
  995. updateDevToolsState({ clientConnected: state });
  996. }
  997. //#endregion
  998. //#region src/core/open-in-editor/index.ts
  999. function setOpenInEditorBaseUrl(url) {
  1000. target.__VUE_DEVTOOLS_OPEN_IN_EDITOR_BASE_URL__ = url;
  1001. }
  1002. function openInEditor(options = {}) {
  1003. const { file, host, baseUrl = window.location.origin, line = 0, column = 0 } = options;
  1004. if (file) {
  1005. if (host === "chrome-extension") {
  1006. const fileName = file.replace(/\\/g, "\\\\");
  1007. const _baseUrl = window.VUE_DEVTOOLS_CONFIG?.openInEditorHost ?? "/";
  1008. fetch(`${_baseUrl}__open-in-editor?file=${encodeURI(file)}`).then((response) => {
  1009. if (!response.ok) {
  1010. const msg = `Opening component ${fileName} failed`;
  1011. console.log(`%c${msg}`, "color:red");
  1012. }
  1013. });
  1014. } else if (devtoolsState.vitePluginDetected) {
  1015. const _baseUrl = target.__VUE_DEVTOOLS_OPEN_IN_EDITOR_BASE_URL__ ?? baseUrl;
  1016. target.__VUE_INSPECTOR__.openInEditor(_baseUrl, file, line, column);
  1017. }
  1018. }
  1019. }
  1020. //#endregion
  1021. //#region src/ctx/plugin.ts
  1022. target.__VUE_DEVTOOLS_KIT_PLUGIN_BUFFER__ ??= [];
  1023. const devtoolsPluginBuffer = new Proxy(target.__VUE_DEVTOOLS_KIT_PLUGIN_BUFFER__, { get(target, prop, receiver) {
  1024. return Reflect.get(target, prop, receiver);
  1025. } });
  1026. function addDevToolsPluginToBuffer(pluginDescriptor, setupFn) {
  1027. devtoolsPluginBuffer.push([pluginDescriptor, setupFn]);
  1028. }
  1029. //#endregion
  1030. //#region src/core/plugin/plugin-settings.ts
  1031. function _getSettings(settings) {
  1032. const _settings = {};
  1033. Object.keys(settings).forEach((key) => {
  1034. _settings[key] = settings[key].defaultValue;
  1035. });
  1036. return _settings;
  1037. }
  1038. function getPluginLocalKey(pluginId) {
  1039. return `__VUE_DEVTOOLS_NEXT_PLUGIN_SETTINGS__${pluginId}__`;
  1040. }
  1041. function getPluginSettingsOptions(pluginId) {
  1042. return (devtoolsPluginBuffer.find((item) => item[0].id === pluginId && !!item[0]?.settings)?.[0] ?? null)?.settings ?? null;
  1043. }
  1044. function getPluginSettings(pluginId, fallbackValue) {
  1045. const localKey = getPluginLocalKey(pluginId);
  1046. if (localKey) {
  1047. const localSettings = localStorage.getItem(localKey);
  1048. if (localSettings) return JSON.parse(localSettings);
  1049. }
  1050. if (pluginId) return _getSettings((devtoolsPluginBuffer.find((item) => item[0].id === pluginId)?.[0] ?? null)?.settings ?? {});
  1051. return _getSettings(fallbackValue);
  1052. }
  1053. function initPluginSettings(pluginId, settings) {
  1054. const localKey = getPluginLocalKey(pluginId);
  1055. if (!localStorage.getItem(localKey)) localStorage.setItem(localKey, JSON.stringify(_getSettings(settings)));
  1056. }
  1057. function setPluginSettings(pluginId, key, value) {
  1058. const localKey = getPluginLocalKey(pluginId);
  1059. const localSettings = localStorage.getItem(localKey);
  1060. const parsedLocalSettings = JSON.parse(localSettings || "{}");
  1061. const updated = {
  1062. ...parsedLocalSettings,
  1063. [key]: value
  1064. };
  1065. localStorage.setItem(localKey, JSON.stringify(updated));
  1066. devtoolsContext.hooks.callHookWith((callbacks) => {
  1067. callbacks.forEach((cb) => cb({
  1068. pluginId,
  1069. key,
  1070. oldValue: parsedLocalSettings[key],
  1071. newValue: value,
  1072. settings: updated
  1073. }));
  1074. }, DevToolsV6PluginAPIHookKeys.SET_PLUGIN_SETTINGS);
  1075. }
  1076. //#endregion
  1077. //#region src/types/hook.ts
  1078. let DevToolsHooks = /* @__PURE__ */ function(DevToolsHooks) {
  1079. DevToolsHooks["APP_INIT"] = "app:init";
  1080. DevToolsHooks["APP_UNMOUNT"] = "app:unmount";
  1081. DevToolsHooks["COMPONENT_UPDATED"] = "component:updated";
  1082. DevToolsHooks["COMPONENT_ADDED"] = "component:added";
  1083. DevToolsHooks["COMPONENT_REMOVED"] = "component:removed";
  1084. DevToolsHooks["COMPONENT_EMIT"] = "component:emit";
  1085. DevToolsHooks["PERFORMANCE_START"] = "perf:start";
  1086. DevToolsHooks["PERFORMANCE_END"] = "perf:end";
  1087. DevToolsHooks["ADD_ROUTE"] = "router:add-route";
  1088. DevToolsHooks["REMOVE_ROUTE"] = "router:remove-route";
  1089. DevToolsHooks["RENDER_TRACKED"] = "render:tracked";
  1090. DevToolsHooks["RENDER_TRIGGERED"] = "render:triggered";
  1091. DevToolsHooks["APP_CONNECTED"] = "app:connected";
  1092. DevToolsHooks["SETUP_DEVTOOLS_PLUGIN"] = "devtools-plugin:setup";
  1093. return DevToolsHooks;
  1094. }({});
  1095. //#endregion
  1096. //#region src/hook/index.ts
  1097. const devtoolsHooks = target.__VUE_DEVTOOLS_HOOK ??= createHooks();
  1098. const on = {
  1099. vueAppInit(fn) {
  1100. devtoolsHooks.hook(DevToolsHooks.APP_INIT, fn);
  1101. },
  1102. vueAppUnmount(fn) {
  1103. devtoolsHooks.hook(DevToolsHooks.APP_UNMOUNT, fn);
  1104. },
  1105. vueAppConnected(fn) {
  1106. devtoolsHooks.hook(DevToolsHooks.APP_CONNECTED, fn);
  1107. },
  1108. componentAdded(fn) {
  1109. return devtoolsHooks.hook(DevToolsHooks.COMPONENT_ADDED, fn);
  1110. },
  1111. componentEmit(fn) {
  1112. return devtoolsHooks.hook(DevToolsHooks.COMPONENT_EMIT, fn);
  1113. },
  1114. componentUpdated(fn) {
  1115. return devtoolsHooks.hook(DevToolsHooks.COMPONENT_UPDATED, fn);
  1116. },
  1117. componentRemoved(fn) {
  1118. return devtoolsHooks.hook(DevToolsHooks.COMPONENT_REMOVED, fn);
  1119. },
  1120. setupDevtoolsPlugin(fn) {
  1121. devtoolsHooks.hook(DevToolsHooks.SETUP_DEVTOOLS_PLUGIN, fn);
  1122. },
  1123. perfStart(fn) {
  1124. return devtoolsHooks.hook(DevToolsHooks.PERFORMANCE_START, fn);
  1125. },
  1126. perfEnd(fn) {
  1127. return devtoolsHooks.hook(DevToolsHooks.PERFORMANCE_END, fn);
  1128. }
  1129. };
  1130. function createDevToolsHook() {
  1131. return {
  1132. id: "vue-devtools-next",
  1133. devtoolsVersion: "7.0",
  1134. enabled: false,
  1135. appRecords: [],
  1136. apps: [],
  1137. events: /* @__PURE__ */ new Map(),
  1138. on(event, fn) {
  1139. if (!this.events.has(event)) this.events.set(event, []);
  1140. this.events.get(event)?.push(fn);
  1141. return () => this.off(event, fn);
  1142. },
  1143. once(event, fn) {
  1144. const onceFn = (...args) => {
  1145. this.off(event, onceFn);
  1146. fn(...args);
  1147. };
  1148. this.on(event, onceFn);
  1149. return [event, onceFn];
  1150. },
  1151. off(event, fn) {
  1152. if (this.events.has(event)) {
  1153. const eventCallbacks = this.events.get(event);
  1154. const index = eventCallbacks.indexOf(fn);
  1155. if (index !== -1) eventCallbacks.splice(index, 1);
  1156. }
  1157. },
  1158. emit(event, ...payload) {
  1159. if (this.events.has(event)) this.events.get(event).forEach((fn) => fn(...payload));
  1160. }
  1161. };
  1162. }
  1163. function subscribeDevToolsHook(hook) {
  1164. hook.on(DevToolsHooks.APP_INIT, (app, version, types) => {
  1165. if (app?._instance?.type?.devtools?.hide) return;
  1166. devtoolsHooks.callHook(DevToolsHooks.APP_INIT, app, version, types);
  1167. });
  1168. hook.on(DevToolsHooks.APP_UNMOUNT, (app) => {
  1169. devtoolsHooks.callHook(DevToolsHooks.APP_UNMOUNT, app);
  1170. });
  1171. hook.on(DevToolsHooks.COMPONENT_ADDED, async (app, uid, parentUid, component) => {
  1172. if (app?._instance?.type?.devtools?.hide || devtoolsState.highPerfModeEnabled) return;
  1173. if (!app || typeof uid !== "number" && !uid || !component) return;
  1174. devtoolsHooks.callHook(DevToolsHooks.COMPONENT_ADDED, app, uid, parentUid, component);
  1175. });
  1176. hook.on(DevToolsHooks.COMPONENT_UPDATED, (app, uid, parentUid, component) => {
  1177. if (!app || typeof uid !== "number" && !uid || !component || devtoolsState.highPerfModeEnabled) return;
  1178. devtoolsHooks.callHook(DevToolsHooks.COMPONENT_UPDATED, app, uid, parentUid, component);
  1179. });
  1180. hook.on(DevToolsHooks.COMPONENT_REMOVED, async (app, uid, parentUid, component) => {
  1181. if (!app || typeof uid !== "number" && !uid || !component || devtoolsState.highPerfModeEnabled) return;
  1182. devtoolsHooks.callHook(DevToolsHooks.COMPONENT_REMOVED, app, uid, parentUid, component);
  1183. });
  1184. hook.on(DevToolsHooks.COMPONENT_EMIT, async (app, instance, event, params) => {
  1185. if (!app || !instance || devtoolsState.highPerfModeEnabled) return;
  1186. devtoolsHooks.callHook(DevToolsHooks.COMPONENT_EMIT, app, instance, event, params);
  1187. });
  1188. hook.on(DevToolsHooks.PERFORMANCE_START, (app, uid, vm, type, time) => {
  1189. if (!app || devtoolsState.highPerfModeEnabled) return;
  1190. devtoolsHooks.callHook(DevToolsHooks.PERFORMANCE_START, app, uid, vm, type, time);
  1191. });
  1192. hook.on(DevToolsHooks.PERFORMANCE_END, (app, uid, vm, type, time) => {
  1193. if (!app || devtoolsState.highPerfModeEnabled) return;
  1194. devtoolsHooks.callHook(DevToolsHooks.PERFORMANCE_END, app, uid, vm, type, time);
  1195. });
  1196. hook.on(DevToolsHooks.SETUP_DEVTOOLS_PLUGIN, (pluginDescriptor, setupFn, options) => {
  1197. if (options?.target === "legacy") return;
  1198. devtoolsHooks.callHook(DevToolsHooks.SETUP_DEVTOOLS_PLUGIN, pluginDescriptor, setupFn);
  1199. });
  1200. }
  1201. const hook = {
  1202. on,
  1203. setupDevToolsPlugin(pluginDescriptor, setupFn) {
  1204. return devtoolsHooks.callHook(DevToolsHooks.SETUP_DEVTOOLS_PLUGIN, pluginDescriptor, setupFn);
  1205. }
  1206. };
  1207. //#endregion
  1208. //#region src/api/v6/index.ts
  1209. var DevToolsV6PluginAPI = class {
  1210. constructor({ plugin, ctx }) {
  1211. this.hooks = ctx.hooks;
  1212. this.plugin = plugin;
  1213. }
  1214. get on() {
  1215. return {
  1216. visitComponentTree: (handler) => {
  1217. this.hooks.hook(DevToolsV6PluginAPIHookKeys.VISIT_COMPONENT_TREE, handler);
  1218. },
  1219. inspectComponent: (handler) => {
  1220. this.hooks.hook(DevToolsV6PluginAPIHookKeys.INSPECT_COMPONENT, handler);
  1221. },
  1222. editComponentState: (handler) => {
  1223. this.hooks.hook(DevToolsV6PluginAPIHookKeys.EDIT_COMPONENT_STATE, handler);
  1224. },
  1225. getInspectorTree: (handler) => {
  1226. this.hooks.hook(DevToolsV6PluginAPIHookKeys.GET_INSPECTOR_TREE, handler);
  1227. },
  1228. getInspectorState: (handler) => {
  1229. this.hooks.hook(DevToolsV6PluginAPIHookKeys.GET_INSPECTOR_STATE, handler);
  1230. },
  1231. editInspectorState: (handler) => {
  1232. this.hooks.hook(DevToolsV6PluginAPIHookKeys.EDIT_INSPECTOR_STATE, handler);
  1233. },
  1234. inspectTimelineEvent: (handler) => {
  1235. this.hooks.hook(DevToolsV6PluginAPIHookKeys.INSPECT_TIMELINE_EVENT, handler);
  1236. },
  1237. timelineCleared: (handler) => {
  1238. this.hooks.hook(DevToolsV6PluginAPIHookKeys.TIMELINE_CLEARED, handler);
  1239. },
  1240. setPluginSettings: (handler) => {
  1241. this.hooks.hook(DevToolsV6PluginAPIHookKeys.SET_PLUGIN_SETTINGS, handler);
  1242. }
  1243. };
  1244. }
  1245. notifyComponentUpdate(instance) {
  1246. if (devtoolsState.highPerfModeEnabled) return;
  1247. const inspector = getActiveInspectors().find((i) => i.packageName === this.plugin.descriptor.packageName);
  1248. if (inspector?.id) {
  1249. if (instance) {
  1250. const args = [
  1251. instance.appContext.app,
  1252. instance.uid,
  1253. instance.parent?.uid,
  1254. instance
  1255. ];
  1256. devtoolsHooks.callHook(DevToolsHooks.COMPONENT_UPDATED, ...args);
  1257. } else devtoolsHooks.callHook(DevToolsHooks.COMPONENT_UPDATED);
  1258. this.hooks.callHook(DevToolsContextHookKeys.SEND_INSPECTOR_STATE, {
  1259. inspectorId: inspector.id,
  1260. plugin: this.plugin
  1261. });
  1262. }
  1263. }
  1264. addInspector(options) {
  1265. this.hooks.callHook(DevToolsContextHookKeys.ADD_INSPECTOR, {
  1266. inspector: options,
  1267. plugin: this.plugin
  1268. });
  1269. if (this.plugin.descriptor.settings) initPluginSettings(options.id, this.plugin.descriptor.settings);
  1270. }
  1271. sendInspectorTree(inspectorId) {
  1272. if (devtoolsState.highPerfModeEnabled) return;
  1273. this.hooks.callHook(DevToolsContextHookKeys.SEND_INSPECTOR_TREE, {
  1274. inspectorId,
  1275. plugin: this.plugin
  1276. });
  1277. }
  1278. sendInspectorState(inspectorId) {
  1279. if (devtoolsState.highPerfModeEnabled) return;
  1280. this.hooks.callHook(DevToolsContextHookKeys.SEND_INSPECTOR_STATE, {
  1281. inspectorId,
  1282. plugin: this.plugin
  1283. });
  1284. }
  1285. selectInspectorNode(inspectorId, nodeId) {
  1286. this.hooks.callHook(DevToolsContextHookKeys.CUSTOM_INSPECTOR_SELECT_NODE, {
  1287. inspectorId,
  1288. nodeId,
  1289. plugin: this.plugin
  1290. });
  1291. }
  1292. visitComponentTree(payload) {
  1293. return this.hooks.callHook(DevToolsV6PluginAPIHookKeys.VISIT_COMPONENT_TREE, payload);
  1294. }
  1295. now() {
  1296. if (devtoolsState.highPerfModeEnabled) return 0;
  1297. return Date.now();
  1298. }
  1299. addTimelineLayer(options) {
  1300. this.hooks.callHook(DevToolsContextHookKeys.TIMELINE_LAYER_ADDED, {
  1301. options,
  1302. plugin: this.plugin
  1303. });
  1304. }
  1305. addTimelineEvent(options) {
  1306. if (devtoolsState.highPerfModeEnabled) return;
  1307. this.hooks.callHook(DevToolsContextHookKeys.TIMELINE_EVENT_ADDED, {
  1308. options,
  1309. plugin: this.plugin
  1310. });
  1311. }
  1312. getSettings(pluginId) {
  1313. return getPluginSettings(pluginId ?? this.plugin.descriptor.id, this.plugin.descriptor.settings);
  1314. }
  1315. getComponentInstances(app) {
  1316. return this.hooks.callHook(DevToolsContextHookKeys.GET_COMPONENT_INSTANCES, { app });
  1317. }
  1318. getComponentBounds(instance) {
  1319. return this.hooks.callHook(DevToolsContextHookKeys.GET_COMPONENT_BOUNDS, { instance });
  1320. }
  1321. getComponentName(instance) {
  1322. return this.hooks.callHook(DevToolsContextHookKeys.GET_COMPONENT_NAME, { instance });
  1323. }
  1324. highlightElement(instance) {
  1325. const uid = instance.__VUE_DEVTOOLS_NEXT_UID__;
  1326. return this.hooks.callHook(DevToolsContextHookKeys.COMPONENT_HIGHLIGHT, { uid });
  1327. }
  1328. unhighlightElement() {
  1329. return this.hooks.callHook(DevToolsContextHookKeys.COMPONENT_UNHIGHLIGHT);
  1330. }
  1331. };
  1332. //#endregion
  1333. //#region src/api/index.ts
  1334. const DevToolsPluginAPI = DevToolsV6PluginAPI;
  1335. //#endregion
  1336. //#region src/core/component/state/constants.ts
  1337. const vueBuiltins = new Set([
  1338. "nextTick",
  1339. "defineComponent",
  1340. "defineAsyncComponent",
  1341. "defineCustomElement",
  1342. "ref",
  1343. "computed",
  1344. "reactive",
  1345. "readonly",
  1346. "watchEffect",
  1347. "watchPostEffect",
  1348. "watchSyncEffect",
  1349. "watch",
  1350. "isRef",
  1351. "unref",
  1352. "toRef",
  1353. "toRefs",
  1354. "isProxy",
  1355. "isReactive",
  1356. "isReadonly",
  1357. "shallowRef",
  1358. "triggerRef",
  1359. "customRef",
  1360. "shallowReactive",
  1361. "shallowReadonly",
  1362. "toRaw",
  1363. "markRaw",
  1364. "effectScope",
  1365. "getCurrentScope",
  1366. "onScopeDispose",
  1367. "onMounted",
  1368. "onUpdated",
  1369. "onUnmounted",
  1370. "onBeforeMount",
  1371. "onBeforeUpdate",
  1372. "onBeforeUnmount",
  1373. "onErrorCaptured",
  1374. "onRenderTracked",
  1375. "onRenderTriggered",
  1376. "onActivated",
  1377. "onDeactivated",
  1378. "onServerPrefetch",
  1379. "provide",
  1380. "inject",
  1381. "h",
  1382. "mergeProps",
  1383. "cloneVNode",
  1384. "isVNode",
  1385. "resolveComponent",
  1386. "resolveDirective",
  1387. "withDirectives",
  1388. "withModifiers"
  1389. ]);
  1390. const symbolRE = /^\[native Symbol Symbol\((.*)\)\]$/;
  1391. const rawTypeRE = /^\[object (\w+)\]$/;
  1392. const specialTypeRE = /^\[native (\w+) (.*?)(<>(([\s\S])*))?\]$/;
  1393. const fnTypeRE = /^(?:function|class) (\w+)/;
  1394. const MAX_STRING_SIZE = 1e4;
  1395. const MAX_ARRAY_SIZE = 5e3;
  1396. const UNDEFINED = "__vue_devtool_undefined__";
  1397. const INFINITY = "__vue_devtool_infinity__";
  1398. const NEGATIVE_INFINITY = "__vue_devtool_negative_infinity__";
  1399. const NAN = "__vue_devtool_nan__";
  1400. const ESC = {
  1401. "<": "&lt;",
  1402. ">": "&gt;",
  1403. "\"": "&quot;",
  1404. "&": "&amp;"
  1405. };
  1406. //#endregion
  1407. //#region src/core/component/state/is.ts
  1408. function isVueInstance(value) {
  1409. if (!ensurePropertyExists(value, "_")) return false;
  1410. if (!isPlainObject(value._)) return false;
  1411. return Object.keys(value._).includes("vnode");
  1412. }
  1413. function isPlainObject(obj) {
  1414. return Object.prototype.toString.call(obj) === "[object Object]";
  1415. }
  1416. function isPrimitive$1(data) {
  1417. if (data == null) return true;
  1418. const type = typeof data;
  1419. return type === "string" || type === "number" || type === "boolean";
  1420. }
  1421. function isRef(raw) {
  1422. return !!raw.__v_isRef;
  1423. }
  1424. function isComputed(raw) {
  1425. return isRef(raw) && !!raw.effect;
  1426. }
  1427. function isReactive(raw) {
  1428. return !!raw.__v_isReactive;
  1429. }
  1430. function isReadOnly(raw) {
  1431. return !!raw.__v_isReadonly;
  1432. }
  1433. //#endregion
  1434. //#region src/core/component/state/util.ts
  1435. const tokenMap = {
  1436. [UNDEFINED]: "undefined",
  1437. [NAN]: "NaN",
  1438. [INFINITY]: "Infinity",
  1439. [NEGATIVE_INFINITY]: "-Infinity"
  1440. };
  1441. const reversedTokenMap = Object.entries(tokenMap).reduce((acc, [key, value]) => {
  1442. acc[value] = key;
  1443. return acc;
  1444. }, {});
  1445. function internalStateTokenToString(value) {
  1446. if (value === null) return "null";
  1447. return typeof value === "string" && tokenMap[value] || false;
  1448. }
  1449. function replaceTokenToString(value) {
  1450. const replaceRegex = new RegExp(`"(${Object.keys(tokenMap).join("|")})"`, "g");
  1451. return value.replace(replaceRegex, (_, g1) => tokenMap[g1]);
  1452. }
  1453. function replaceStringToToken(value) {
  1454. const literalValue = reversedTokenMap[value.trim()];
  1455. if (literalValue) return `"${literalValue}"`;
  1456. const replaceRegex = new RegExp(`:\\s*(${Object.keys(reversedTokenMap).join("|")})`, "g");
  1457. return value.replace(replaceRegex, (_, g1) => `:"${reversedTokenMap[g1]}"`);
  1458. }
  1459. /**
  1460. * Convert prop type constructor to string.
  1461. */
  1462. function getPropType(type) {
  1463. if (Array.isArray(type)) return type.map((t) => getPropType(t)).join(" or ");
  1464. if (type == null) return "null";
  1465. const match = type.toString().match(fnTypeRE);
  1466. return typeof type === "function" ? match && match[1] || "any" : "any";
  1467. }
  1468. /**
  1469. * Sanitize data to be posted to the other side.
  1470. * Since the message posted is sent with structured clone,
  1471. * we need to filter out any types that might cause an error.
  1472. */
  1473. function sanitize(data) {
  1474. if (!isPrimitive$1(data) && !Array.isArray(data) && !isPlainObject(data)) return Object.prototype.toString.call(data);
  1475. else return data;
  1476. }
  1477. function getSetupStateType(raw) {
  1478. try {
  1479. return {
  1480. ref: isRef(raw),
  1481. computed: isComputed(raw),
  1482. reactive: isReactive(raw),
  1483. readonly: isReadOnly(raw)
  1484. };
  1485. } catch {
  1486. return {
  1487. ref: false,
  1488. computed: false,
  1489. reactive: false,
  1490. readonly: false
  1491. };
  1492. }
  1493. }
  1494. function toRaw(value) {
  1495. if (value?.__v_raw) return value.__v_raw;
  1496. return value;
  1497. }
  1498. function escape(s) {
  1499. return s.replace(/[<>"&]/g, (s) => {
  1500. return ESC[s] || s;
  1501. });
  1502. }
  1503. //#endregion
  1504. //#region src/core/component/state/process.ts
  1505. function mergeOptions(to, from, instance) {
  1506. if (typeof from === "function") from = from.options;
  1507. if (!from) return to;
  1508. const { mixins, extends: extendsOptions } = from;
  1509. extendsOptions && mergeOptions(to, extendsOptions, instance);
  1510. mixins && mixins.forEach((m) => mergeOptions(to, m, instance));
  1511. for (const key of ["computed", "inject"]) if (Object.prototype.hasOwnProperty.call(from, key)) {
  1512. to[key] ??= {};
  1513. Object.assign(to[key], from[key]);
  1514. }
  1515. return to;
  1516. }
  1517. function resolveMergedOptions(instance) {
  1518. const raw = instance?.type;
  1519. if (!raw) return {};
  1520. const { mixins, extends: extendsOptions } = raw;
  1521. const globalMixins = instance.appContext.mixins;
  1522. if (!globalMixins.length && !mixins && !extendsOptions) return raw;
  1523. const options = {};
  1524. globalMixins.forEach((m) => mergeOptions(options, m, instance));
  1525. mergeOptions(options, raw, instance);
  1526. return options;
  1527. }
  1528. /**
  1529. * Process the props of an instance.
  1530. * Make sure return a plain object because window.postMessage()
  1531. * will throw an Error if the passed object contains Functions.
  1532. *
  1533. */
  1534. function processProps(instance) {
  1535. const props = [];
  1536. const propDefinitions = instance?.type?.props;
  1537. for (const key in instance?.props) {
  1538. const propDefinition = propDefinitions ? propDefinitions[key] : null;
  1539. const camelizeKey = camelize(key);
  1540. props.push({
  1541. type: "props",
  1542. key: camelizeKey,
  1543. value: returnError(() => instance.props[key]),
  1544. editable: true,
  1545. meta: propDefinition ? {
  1546. type: propDefinition.type ? getPropType(propDefinition.type) : "any",
  1547. required: !!propDefinition.required,
  1548. ...propDefinition.default ? { default: propDefinition.default.toString() } : {}
  1549. } : { type: "invalid" }
  1550. });
  1551. }
  1552. return props;
  1553. }
  1554. /**
  1555. * Process state, filtering out props and "clean" the result
  1556. * with a JSON dance. This removes functions which can cause
  1557. * errors during structured clone used by window.postMessage.
  1558. *
  1559. */
  1560. function processState(instance) {
  1561. const type = instance.type;
  1562. const props = type?.props;
  1563. const getters = type.vuex && type.vuex.getters;
  1564. const computedDefs = type.computed;
  1565. const data = {
  1566. ...instance.data,
  1567. ...instance.renderContext
  1568. };
  1569. return Object.keys(data).filter((key) => !(props && key in props) && !(getters && key in getters) && !(computedDefs && key in computedDefs)).map((key) => ({
  1570. key,
  1571. type: "data",
  1572. value: returnError(() => data[key]),
  1573. editable: true
  1574. }));
  1575. }
  1576. function getStateTypeAndName(info) {
  1577. const stateType = info.computed ? "computed" : info.ref ? "ref" : info.reactive ? "reactive" : null;
  1578. return {
  1579. stateType,
  1580. stateTypeName: stateType ? `${stateType.charAt(0).toUpperCase()}${stateType.slice(1)}` : null
  1581. };
  1582. }
  1583. function processSetupState(instance) {
  1584. const raw = instance.devtoolsRawSetupState || {};
  1585. return Object.keys(instance.setupState).filter((key) => !vueBuiltins.has(key) && key.split(/(?=[A-Z])/)[0] !== "use").map((key) => {
  1586. const value = returnError(() => toRaw(instance.setupState[key]));
  1587. const accessError = value instanceof Error;
  1588. const rawData = raw[key];
  1589. let result;
  1590. let isOtherType = accessError || typeof value === "function" || ensurePropertyExists(value, "render") && typeof value.render === "function" || ensurePropertyExists(value, "__asyncLoader") && typeof value.__asyncLoader === "function" || typeof value === "object" && value && ("setup" in value || "props" in value) || /^v[A-Z]/.test(key);
  1591. if (rawData && !accessError) {
  1592. const info = getSetupStateType(rawData);
  1593. const { stateType, stateTypeName } = getStateTypeAndName(info);
  1594. const isState = info.ref || info.computed || info.reactive;
  1595. const raw = ensurePropertyExists(rawData, "effect") ? rawData.effect?.raw?.toString() || rawData.effect?.fn?.toString() : null;
  1596. if (stateType) isOtherType = false;
  1597. result = {
  1598. ...stateType ? {
  1599. stateType,
  1600. stateTypeName
  1601. } : {},
  1602. ...raw ? { raw } : {},
  1603. editable: isState && !info.readonly
  1604. };
  1605. }
  1606. return {
  1607. key,
  1608. value,
  1609. type: isOtherType ? "setup (other)" : "setup",
  1610. ...result
  1611. };
  1612. });
  1613. }
  1614. /**
  1615. * Process the computed properties of an instance.
  1616. */
  1617. function processComputed(instance, mergedType) {
  1618. const type = mergedType;
  1619. const computed = [];
  1620. const defs = type.computed || {};
  1621. for (const key in defs) {
  1622. const def = defs[key];
  1623. const type = typeof def === "function" && def.vuex ? "vuex bindings" : "computed";
  1624. computed.push({
  1625. type,
  1626. key,
  1627. value: returnError(() => instance?.proxy?.[key]),
  1628. editable: typeof def.set === "function"
  1629. });
  1630. }
  1631. return computed;
  1632. }
  1633. function processAttrs(instance) {
  1634. return Object.keys(instance.attrs).map((key) => ({
  1635. type: "attrs",
  1636. key,
  1637. value: returnError(() => instance.attrs[key])
  1638. }));
  1639. }
  1640. function processProvide(instance) {
  1641. return Reflect.ownKeys(instance.provides).map((key) => ({
  1642. type: "provided",
  1643. key: key.toString(),
  1644. value: returnError(() => instance.provides[key])
  1645. }));
  1646. }
  1647. function processInject(instance, mergedType) {
  1648. if (!mergedType?.inject) return [];
  1649. let keys = [];
  1650. let defaultValue;
  1651. if (Array.isArray(mergedType.inject)) keys = mergedType.inject.map((key) => ({
  1652. key,
  1653. originalKey: key
  1654. }));
  1655. else keys = Reflect.ownKeys(mergedType.inject).map((key) => {
  1656. const value = mergedType.inject[key];
  1657. let originalKey;
  1658. if (typeof value === "string" || typeof value === "symbol") originalKey = value;
  1659. else {
  1660. originalKey = value.from;
  1661. defaultValue = value.default;
  1662. }
  1663. return {
  1664. key,
  1665. originalKey
  1666. };
  1667. });
  1668. return keys.map(({ key, originalKey }) => ({
  1669. type: "injected",
  1670. key: originalKey && key !== originalKey ? `${originalKey.toString()} ➞ ${key.toString()}` : key.toString(),
  1671. value: returnError(() => instance.ctx.hasOwnProperty(key) ? instance.ctx[key] : instance.provides.hasOwnProperty(originalKey) ? instance.provides[originalKey] : defaultValue)
  1672. }));
  1673. }
  1674. function processRefs(instance) {
  1675. return Object.keys(instance.refs).map((key) => ({
  1676. type: "template refs",
  1677. key,
  1678. value: returnError(() => instance.refs[key])
  1679. }));
  1680. }
  1681. const vnodeEvents = new Set([
  1682. "vnode-before-mount",
  1683. "vnode-mounted",
  1684. "vnode-before-update",
  1685. "vnode-updated",
  1686. "vnode-before-unmount",
  1687. "vnode-unmounted"
  1688. ]);
  1689. function processEventListeners(instance) {
  1690. const emitsDefinition = instance.type.emits;
  1691. const declaredEmits = Array.isArray(emitsDefinition) ? emitsDefinition : Object.keys(emitsDefinition ?? {});
  1692. const keys = Object.keys(instance?.vnode?.props ?? {});
  1693. const result = [];
  1694. for (const key of keys) {
  1695. const [prefix, ...eventNameParts] = key.split(/(?=[A-Z])/);
  1696. if (prefix === "on") {
  1697. const eventName = eventNameParts.join("-").toLowerCase();
  1698. const isBuiltIn = vnodeEvents.has(eventName);
  1699. const isDeclared = declaredEmits.includes(eventName) || declaredEmits.includes(camelize(eventName));
  1700. const text = isBuiltIn ? "✅ Built-in" : isDeclared ? "✅ Declared" : "⚠️ Not declared";
  1701. result.push({
  1702. type: "event listeners",
  1703. key: eventName,
  1704. value: { _custom: {
  1705. displayText: text,
  1706. key: text,
  1707. value: text,
  1708. tooltipText: isBuiltIn ? `The event <code>${escape(eventName)}</code> is part of Vue and doesn't need to be declared by the component` : !isDeclared ? `The event <code>${escape(eventName)}</code> is not declared in the <code>emits</code> option. It will leak into the component's attributes (<code>$attrs</code>).` : null
  1709. } }
  1710. });
  1711. }
  1712. }
  1713. return result;
  1714. }
  1715. function processInstanceState(instance) {
  1716. const mergedType = resolveMergedOptions(instance);
  1717. return processProps(instance).concat(processState(instance), processSetupState(instance), processComputed(instance, mergedType), processAttrs(instance), processProvide(instance), processInject(instance, mergedType), processRefs(instance), processEventListeners(instance));
  1718. }
  1719. //#endregion
  1720. //#region src/core/component/state/index.ts
  1721. function getInstanceState(params) {
  1722. const instance = getComponentInstance(activeAppRecord.value, params.instanceId);
  1723. return {
  1724. id: getUniqueComponentId(instance),
  1725. name: getInstanceName(instance),
  1726. file: instance?.type?.__file,
  1727. state: processInstanceState(instance),
  1728. instance
  1729. };
  1730. }
  1731. //#endregion
  1732. //#region src/core/component/tree/filter.ts
  1733. var ComponentFilter = class {
  1734. constructor(filter) {
  1735. this.filter = filter || "";
  1736. }
  1737. /**
  1738. * Check if an instance is qualified.
  1739. *
  1740. * @param {Vue|Vnode} instance
  1741. * @return {boolean}
  1742. */
  1743. isQualified(instance) {
  1744. const name = getInstanceName(instance);
  1745. return classify(name).toLowerCase().includes(this.filter) || kebabize(name).toLowerCase().includes(this.filter);
  1746. }
  1747. };
  1748. function createComponentFilter(filterText) {
  1749. return new ComponentFilter(filterText);
  1750. }
  1751. //#endregion
  1752. //#region src/core/component/tree/walker.ts
  1753. var ComponentWalker = class {
  1754. constructor(options) {
  1755. this.captureIds = /* @__PURE__ */ new Map();
  1756. const { filterText = "", maxDepth, recursively, api } = options;
  1757. this.componentFilter = createComponentFilter(filterText);
  1758. this.maxDepth = maxDepth;
  1759. this.recursively = recursively;
  1760. this.api = api;
  1761. }
  1762. getComponentTree(instance) {
  1763. this.captureIds = /* @__PURE__ */ new Map();
  1764. return this.findQualifiedChildren(instance, 0);
  1765. }
  1766. getComponentParents(instance) {
  1767. this.captureIds = /* @__PURE__ */ new Map();
  1768. const parents = [];
  1769. this.captureId(instance);
  1770. let parent = instance;
  1771. while (parent = parent.parent) {
  1772. this.captureId(parent);
  1773. parents.push(parent);
  1774. }
  1775. return parents;
  1776. }
  1777. captureId(instance) {
  1778. if (!instance) return null;
  1779. const id = instance.__VUE_DEVTOOLS_NEXT_UID__ != null ? instance.__VUE_DEVTOOLS_NEXT_UID__ : getUniqueComponentId(instance);
  1780. instance.__VUE_DEVTOOLS_NEXT_UID__ = id;
  1781. if (this.captureIds.has(id)) return null;
  1782. else this.captureIds.set(id, void 0);
  1783. this.mark(instance);
  1784. return id;
  1785. }
  1786. /**
  1787. * Capture the meta information of an instance. (recursive)
  1788. *
  1789. * @param {Vue} instance
  1790. * @return {object}
  1791. */
  1792. async capture(instance, depth) {
  1793. if (!instance) return null;
  1794. const id = this.captureId(instance);
  1795. const name = getInstanceName(instance);
  1796. const children = this.getInternalInstanceChildren(instance.subTree).filter((child) => !isBeingDestroyed(child));
  1797. const parents = this.getComponentParents(instance) || [];
  1798. const inactive = !!instance.isDeactivated || parents.some((parent) => parent.isDeactivated);
  1799. const treeNode = {
  1800. uid: instance.uid,
  1801. id,
  1802. name,
  1803. renderKey: getRenderKey(instance.vnode ? instance.vnode.key : null),
  1804. inactive,
  1805. children: [],
  1806. hasChildren: !!children.length,
  1807. isFragment: isFragment(instance),
  1808. tags: typeof instance.type !== "function" ? [] : [{
  1809. label: "functional",
  1810. textColor: 5592405,
  1811. backgroundColor: 15658734
  1812. }],
  1813. autoOpen: this.recursively,
  1814. file: instance.type.__file || ""
  1815. };
  1816. if (depth < this.maxDepth || instance.type.__isKeepAlive || parents.some((parent) => parent.type.__isKeepAlive)) treeNode.children = await Promise.all(children.map((child) => this.capture(child, depth + 1)).filter(Boolean));
  1817. if (this.isKeepAlive(instance)) {
  1818. const cachedComponents = this.getKeepAliveCachedInstances(instance);
  1819. const childrenIds = children.map((child) => child.__VUE_DEVTOOLS_NEXT_UID__);
  1820. for (const cachedChild of cachedComponents) if (!childrenIds.includes(cachedChild.__VUE_DEVTOOLS_NEXT_UID__)) {
  1821. const node = await this.capture({
  1822. ...cachedChild,
  1823. isDeactivated: true
  1824. }, depth + 1);
  1825. if (node) treeNode.children.push(node);
  1826. }
  1827. }
  1828. const firstElement = getRootElementsFromComponentInstance(instance)[0];
  1829. if (firstElement?.parentElement) {
  1830. const parentInstance = instance.parent;
  1831. const parentRootElements = parentInstance ? getRootElementsFromComponentInstance(parentInstance) : [];
  1832. let el = firstElement;
  1833. const indexList = [];
  1834. do {
  1835. indexList.push(Array.from(el.parentElement.childNodes).indexOf(el));
  1836. el = el.parentElement;
  1837. } while (el.parentElement && parentRootElements.length && !parentRootElements.includes(el));
  1838. treeNode.domOrder = indexList.reverse();
  1839. } else treeNode.domOrder = [-1];
  1840. if (instance.suspense?.suspenseKey) {
  1841. treeNode.tags.push({
  1842. label: instance.suspense.suspenseKey,
  1843. backgroundColor: 14979812,
  1844. textColor: 16777215
  1845. });
  1846. this.mark(instance, true);
  1847. }
  1848. this.api.visitComponentTree({
  1849. treeNode,
  1850. componentInstance: instance,
  1851. app: instance.appContext.app,
  1852. filter: this.componentFilter.filter
  1853. });
  1854. return treeNode;
  1855. }
  1856. /**
  1857. * Find qualified children from a single instance.
  1858. * If the instance itself is qualified, just return itself.
  1859. * This is ok because [].concat works in both cases.
  1860. *
  1861. * @param {Vue|Vnode} instance
  1862. * @return {Vue|Array}
  1863. */
  1864. async findQualifiedChildren(instance, depth) {
  1865. if (this.componentFilter.isQualified(instance) && !instance.type.devtools?.hide) return [await this.capture(instance, depth)];
  1866. else if (instance.subTree) {
  1867. const list = this.isKeepAlive(instance) ? this.getKeepAliveCachedInstances(instance) : this.getInternalInstanceChildren(instance.subTree);
  1868. return this.findQualifiedChildrenFromList(list, depth);
  1869. } else return [];
  1870. }
  1871. /**
  1872. * Iterate through an array of instances and flatten it into
  1873. * an array of qualified instances. This is a depth-first
  1874. * traversal - e.g. if an instance is not matched, we will
  1875. * recursively go deeper until a qualified child is found.
  1876. *
  1877. * @param {Array} instances
  1878. * @return {Array}
  1879. */
  1880. async findQualifiedChildrenFromList(instances, depth) {
  1881. instances = instances.filter((child) => !isBeingDestroyed(child) && !child.type.devtools?.hide);
  1882. if (!this.componentFilter.filter) return Promise.all(instances.map((child) => this.capture(child, depth)));
  1883. else return Array.prototype.concat.apply([], await Promise.all(instances.map((i) => this.findQualifiedChildren(i, depth))));
  1884. }
  1885. /**
  1886. * Get children from a component instance.
  1887. */
  1888. getInternalInstanceChildren(subTree, suspense = null) {
  1889. const list = [];
  1890. if (subTree) {
  1891. if (subTree.component) !suspense ? list.push(subTree.component) : list.push({
  1892. ...subTree.component,
  1893. suspense
  1894. });
  1895. else if (subTree.suspense) {
  1896. const suspenseKey = !subTree.suspense.isInFallback ? "suspense default" : "suspense fallback";
  1897. list.push(...this.getInternalInstanceChildren(subTree.suspense.activeBranch, {
  1898. ...subTree.suspense,
  1899. suspenseKey
  1900. }));
  1901. } else if (Array.isArray(subTree.children)) subTree.children.forEach((childSubTree) => {
  1902. if (childSubTree.component) !suspense ? list.push(childSubTree.component) : list.push({
  1903. ...childSubTree.component,
  1904. suspense
  1905. });
  1906. else list.push(...this.getInternalInstanceChildren(childSubTree, suspense));
  1907. });
  1908. }
  1909. return list.filter((child) => !isBeingDestroyed(child) && !child.type.devtools?.hide);
  1910. }
  1911. /**
  1912. * Mark an instance as captured and store it in the instance map.
  1913. *
  1914. * @param {Vue} instance
  1915. */
  1916. mark(instance, force = false) {
  1917. const instanceMap = getAppRecord(instance).instanceMap;
  1918. if (force || !instanceMap.has(instance.__VUE_DEVTOOLS_NEXT_UID__)) {
  1919. instanceMap.set(instance.__VUE_DEVTOOLS_NEXT_UID__, instance);
  1920. activeAppRecord.value.instanceMap = instanceMap;
  1921. }
  1922. }
  1923. isKeepAlive(instance) {
  1924. return instance.type.__isKeepAlive && instance.__v_cache;
  1925. }
  1926. getKeepAliveCachedInstances(instance) {
  1927. return Array.from(instance.__v_cache.values()).map((vnode) => vnode.component).filter(Boolean);
  1928. }
  1929. };
  1930. //#endregion
  1931. //#region src/core/timeline/perf.ts
  1932. const markEndQueue = /* @__PURE__ */ new Map();
  1933. const PERFORMANCE_EVENT_LAYER_ID = "performance";
  1934. async function performanceMarkStart(api, app, uid, vm, type, time) {
  1935. const appRecord = await getAppRecord(app);
  1936. if (!appRecord) return;
  1937. const componentName = getInstanceName(vm) || "Unknown Component";
  1938. const groupId = devtoolsState.perfUniqueGroupId++;
  1939. const groupKey = `${uid}-${type}`;
  1940. appRecord.perfGroupIds.set(groupKey, {
  1941. groupId,
  1942. time
  1943. });
  1944. await api.addTimelineEvent({
  1945. layerId: PERFORMANCE_EVENT_LAYER_ID,
  1946. event: {
  1947. time: Date.now(),
  1948. data: {
  1949. component: componentName,
  1950. type,
  1951. measure: "start"
  1952. },
  1953. title: componentName,
  1954. subtitle: type,
  1955. groupId
  1956. }
  1957. });
  1958. if (markEndQueue.has(groupKey)) {
  1959. const { app, uid, instance, type, time } = markEndQueue.get(groupKey);
  1960. markEndQueue.delete(groupKey);
  1961. await performanceMarkEnd(api, app, uid, instance, type, time);
  1962. }
  1963. }
  1964. function performanceMarkEnd(api, app, uid, vm, type, time) {
  1965. const appRecord = getAppRecord(app);
  1966. if (!appRecord) return;
  1967. const componentName = getInstanceName(vm) || "Unknown Component";
  1968. const groupKey = `${uid}-${type}`;
  1969. const groupInfo = appRecord.perfGroupIds.get(groupKey);
  1970. if (groupInfo) {
  1971. const groupId = groupInfo.groupId;
  1972. const duration = time - groupInfo.time;
  1973. api.addTimelineEvent({
  1974. layerId: PERFORMANCE_EVENT_LAYER_ID,
  1975. event: {
  1976. time: Date.now(),
  1977. data: {
  1978. component: componentName,
  1979. type,
  1980. measure: "end",
  1981. duration: { _custom: {
  1982. type: "Duration",
  1983. value: duration,
  1984. display: `${duration} ms`
  1985. } }
  1986. },
  1987. title: componentName,
  1988. subtitle: type,
  1989. groupId
  1990. }
  1991. });
  1992. } else markEndQueue.set(groupKey, {
  1993. app,
  1994. uid,
  1995. instance: vm,
  1996. type,
  1997. time
  1998. });
  1999. }
  2000. //#endregion
  2001. //#region src/core/timeline/index.ts
  2002. const COMPONENT_EVENT_LAYER_ID = "component-event";
  2003. function setupBuiltinTimelineLayers(api) {
  2004. if (!isBrowser) return;
  2005. api.addTimelineLayer({
  2006. id: "mouse",
  2007. label: "Mouse",
  2008. color: 10768815
  2009. });
  2010. [
  2011. "mousedown",
  2012. "mouseup",
  2013. "click",
  2014. "dblclick"
  2015. ].forEach((eventType) => {
  2016. if (!devtoolsState.timelineLayersState.recordingState || !devtoolsState.timelineLayersState.mouseEventEnabled) return;
  2017. window.addEventListener(eventType, async (event) => {
  2018. await api.addTimelineEvent({
  2019. layerId: "mouse",
  2020. event: {
  2021. time: Date.now(),
  2022. data: {
  2023. type: eventType,
  2024. x: event.clientX,
  2025. y: event.clientY
  2026. },
  2027. title: eventType
  2028. }
  2029. });
  2030. }, {
  2031. capture: true,
  2032. passive: true
  2033. });
  2034. });
  2035. api.addTimelineLayer({
  2036. id: "keyboard",
  2037. label: "Keyboard",
  2038. color: 8475055
  2039. });
  2040. [
  2041. "keyup",
  2042. "keydown",
  2043. "keypress"
  2044. ].forEach((eventType) => {
  2045. window.addEventListener(eventType, async (event) => {
  2046. if (!devtoolsState.timelineLayersState.recordingState || !devtoolsState.timelineLayersState.keyboardEventEnabled) return;
  2047. await api.addTimelineEvent({
  2048. layerId: "keyboard",
  2049. event: {
  2050. time: Date.now(),
  2051. data: {
  2052. type: eventType,
  2053. key: event.key,
  2054. ctrlKey: event.ctrlKey,
  2055. shiftKey: event.shiftKey,
  2056. altKey: event.altKey,
  2057. metaKey: event.metaKey
  2058. },
  2059. title: event.key
  2060. }
  2061. });
  2062. }, {
  2063. capture: true,
  2064. passive: true
  2065. });
  2066. });
  2067. api.addTimelineLayer({
  2068. id: COMPONENT_EVENT_LAYER_ID,
  2069. label: "Component events",
  2070. color: 5226637
  2071. });
  2072. hook.on.componentEmit(async (app, instance, event, params) => {
  2073. if (!devtoolsState.timelineLayersState.recordingState || !devtoolsState.timelineLayersState.componentEventEnabled) return;
  2074. const appRecord = await getAppRecord(app);
  2075. if (!appRecord) return;
  2076. const componentId = `${appRecord.id}:${instance.uid}`;
  2077. const componentName = getInstanceName(instance) || "Unknown Component";
  2078. api.addTimelineEvent({
  2079. layerId: COMPONENT_EVENT_LAYER_ID,
  2080. event: {
  2081. time: Date.now(),
  2082. data: {
  2083. component: { _custom: {
  2084. type: "component-definition",
  2085. display: componentName
  2086. } },
  2087. event,
  2088. params
  2089. },
  2090. title: event,
  2091. subtitle: `by ${componentName}`,
  2092. meta: { componentId }
  2093. }
  2094. });
  2095. });
  2096. api.addTimelineLayer({
  2097. id: "performance",
  2098. label: PERFORMANCE_EVENT_LAYER_ID,
  2099. color: 4307050
  2100. });
  2101. hook.on.perfStart((app, uid, vm, type, time) => {
  2102. if (!devtoolsState.timelineLayersState.recordingState || !devtoolsState.timelineLayersState.performanceEventEnabled) return;
  2103. performanceMarkStart(api, app, uid, vm, type, time);
  2104. });
  2105. hook.on.perfEnd((app, uid, vm, type, time) => {
  2106. if (!devtoolsState.timelineLayersState.recordingState || !devtoolsState.timelineLayersState.performanceEventEnabled) return;
  2107. performanceMarkEnd(api, app, uid, vm, type, time);
  2108. });
  2109. }
  2110. //#endregion
  2111. //#region src/core/vm/index.ts
  2112. const MAX_$VM = 10;
  2113. const $vmQueue = [];
  2114. function exposeInstanceToWindow(componentInstance) {
  2115. if (typeof window === "undefined") return;
  2116. const win = window;
  2117. if (!componentInstance) return;
  2118. win.$vm = componentInstance;
  2119. if ($vmQueue[0] !== componentInstance) {
  2120. if ($vmQueue.length >= MAX_$VM) $vmQueue.pop();
  2121. for (let i = $vmQueue.length; i > 0; i--) win[`$vm${i}`] = $vmQueue[i] = $vmQueue[i - 1];
  2122. win.$vm0 = $vmQueue[0] = componentInstance;
  2123. }
  2124. }
  2125. //#endregion
  2126. //#region src/core/plugin/components.ts
  2127. const INSPECTOR_ID = "components";
  2128. function createComponentsDevToolsPlugin(app) {
  2129. const descriptor = {
  2130. id: INSPECTOR_ID,
  2131. label: "Components",
  2132. app
  2133. };
  2134. const setupFn = (api) => {
  2135. api.addInspector({
  2136. id: INSPECTOR_ID,
  2137. label: "Components",
  2138. treeFilterPlaceholder: "Search components"
  2139. });
  2140. setupBuiltinTimelineLayers(api);
  2141. api.on.getInspectorTree(async (payload) => {
  2142. if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
  2143. const instance = getComponentInstance(activeAppRecord.value, payload.instanceId);
  2144. if (instance) payload.rootNodes = await new ComponentWalker({
  2145. filterText: payload.filter,
  2146. maxDepth: 100,
  2147. recursively: false,
  2148. api
  2149. }).getComponentTree(instance);
  2150. }
  2151. });
  2152. api.on.getInspectorState(async (payload) => {
  2153. if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
  2154. const result = getInstanceState({ instanceId: payload.nodeId });
  2155. const componentInstance = result.instance;
  2156. const _payload = {
  2157. componentInstance,
  2158. app: result.instance?.appContext.app,
  2159. instanceData: result
  2160. };
  2161. devtoolsContext.hooks.callHookWith((callbacks) => {
  2162. callbacks.forEach((cb) => cb(_payload));
  2163. }, DevToolsV6PluginAPIHookKeys.INSPECT_COMPONENT);
  2164. payload.state = result;
  2165. exposeInstanceToWindow(componentInstance);
  2166. }
  2167. });
  2168. api.on.editInspectorState(async (payload) => {
  2169. if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
  2170. editState(payload);
  2171. await api.sendInspectorState("components");
  2172. }
  2173. });
  2174. const debounceSendInspectorTree = debounce(() => {
  2175. api.sendInspectorTree(INSPECTOR_ID);
  2176. }, 120);
  2177. const debounceSendInspectorState = debounce(() => {
  2178. api.sendInspectorState(INSPECTOR_ID);
  2179. }, 120);
  2180. hook.on.componentAdded(async (app, uid, parentUid, component) => {
  2181. if (devtoolsState.highPerfModeEnabled) return;
  2182. if (app?._instance?.type?.devtools?.hide) return;
  2183. if (!app || typeof uid !== "number" && !uid || !component) return;
  2184. const id = await getComponentId({
  2185. app,
  2186. uid,
  2187. instance: component
  2188. });
  2189. const appRecord = await getAppRecord(app);
  2190. if (component) {
  2191. if (component.__VUE_DEVTOOLS_NEXT_UID__ == null) component.__VUE_DEVTOOLS_NEXT_UID__ = id;
  2192. if (!appRecord?.instanceMap.has(id)) {
  2193. appRecord?.instanceMap.set(id, component);
  2194. if (activeAppRecord.value.id === appRecord?.id) activeAppRecord.value.instanceMap = appRecord.instanceMap;
  2195. }
  2196. }
  2197. if (!appRecord) return;
  2198. debounceSendInspectorTree();
  2199. });
  2200. hook.on.componentUpdated(async (app, uid, parentUid, component) => {
  2201. if (devtoolsState.highPerfModeEnabled) return;
  2202. if (app?._instance?.type?.devtools?.hide) return;
  2203. if (!app || typeof uid !== "number" && !uid || !component) return;
  2204. const id = await getComponentId({
  2205. app,
  2206. uid,
  2207. instance: component
  2208. });
  2209. const appRecord = await getAppRecord(app);
  2210. if (component) {
  2211. if (component.__VUE_DEVTOOLS_NEXT_UID__ == null) component.__VUE_DEVTOOLS_NEXT_UID__ = id;
  2212. if (!appRecord?.instanceMap.has(id)) {
  2213. appRecord?.instanceMap.set(id, component);
  2214. if (activeAppRecord.value.id === appRecord?.id) activeAppRecord.value.instanceMap = appRecord.instanceMap;
  2215. }
  2216. }
  2217. if (!appRecord) return;
  2218. debounceSendInspectorTree();
  2219. debounceSendInspectorState();
  2220. });
  2221. hook.on.componentRemoved(async (app, uid, parentUid, component) => {
  2222. if (devtoolsState.highPerfModeEnabled) return;
  2223. if (app?._instance?.type?.devtools?.hide) return;
  2224. if (!app || typeof uid !== "number" && !uid || !component) return;
  2225. const appRecord = await getAppRecord(app);
  2226. if (!appRecord) return;
  2227. const id = await getComponentId({
  2228. app,
  2229. uid,
  2230. instance: component
  2231. });
  2232. appRecord?.instanceMap.delete(id);
  2233. if (activeAppRecord.value.id === appRecord?.id) activeAppRecord.value.instanceMap = appRecord.instanceMap;
  2234. debounceSendInspectorTree();
  2235. });
  2236. };
  2237. return [descriptor, setupFn];
  2238. }
  2239. //#endregion
  2240. //#region src/core/plugin/index.ts
  2241. target.__VUE_DEVTOOLS_KIT__REGISTERED_PLUGIN_APPS__ ??= /* @__PURE__ */ new Set();
  2242. function setupDevToolsPlugin(pluginDescriptor, setupFn) {
  2243. return hook.setupDevToolsPlugin(pluginDescriptor, setupFn);
  2244. }
  2245. function callDevToolsPluginSetupFn(plugin, app) {
  2246. const [pluginDescriptor, setupFn] = plugin;
  2247. if (pluginDescriptor.app !== app) return;
  2248. const api = new DevToolsPluginAPI({
  2249. plugin: {
  2250. setupFn,
  2251. descriptor: pluginDescriptor
  2252. },
  2253. ctx: devtoolsContext
  2254. });
  2255. if (pluginDescriptor.packageName === "vuex") api.on.editInspectorState((payload) => {
  2256. api.sendInspectorState(payload.inspectorId);
  2257. });
  2258. setupFn(api);
  2259. }
  2260. function removeRegisteredPluginApp(app) {
  2261. target.__VUE_DEVTOOLS_KIT__REGISTERED_PLUGIN_APPS__.delete(app);
  2262. }
  2263. function registerDevToolsPlugin(app, options) {
  2264. if (target.__VUE_DEVTOOLS_KIT__REGISTERED_PLUGIN_APPS__.has(app)) return;
  2265. if (devtoolsState.highPerfModeEnabled && !options?.inspectingComponent) return;
  2266. target.__VUE_DEVTOOLS_KIT__REGISTERED_PLUGIN_APPS__.add(app);
  2267. devtoolsPluginBuffer.forEach((plugin) => {
  2268. callDevToolsPluginSetupFn(plugin, app);
  2269. });
  2270. }
  2271. //#endregion
  2272. //#region src/ctx/router.ts
  2273. const ROUTER_KEY = "__VUE_DEVTOOLS_ROUTER__";
  2274. const ROUTER_INFO_KEY = "__VUE_DEVTOOLS_ROUTER_INFO__";
  2275. target[ROUTER_INFO_KEY] ??= {
  2276. currentRoute: null,
  2277. routes: []
  2278. };
  2279. target[ROUTER_KEY] ??= {};
  2280. const devtoolsRouterInfo = new Proxy(target[ROUTER_INFO_KEY], { get(target$1, property) {
  2281. return target[ROUTER_INFO_KEY][property];
  2282. } });
  2283. const devtoolsRouter = new Proxy(target[ROUTER_KEY], { get(target$2, property) {
  2284. if (property === "value") return target[ROUTER_KEY];
  2285. } });
  2286. //#endregion
  2287. //#region src/core/router/index.ts
  2288. function getRoutes(router) {
  2289. const routesMap = /* @__PURE__ */ new Map();
  2290. return (router?.getRoutes() || []).filter((i) => !routesMap.has(i.path) && routesMap.set(i.path, 1));
  2291. }
  2292. function filterRoutes(routes) {
  2293. return routes.map((item) => {
  2294. let { path, name, children, meta } = item;
  2295. if (children?.length) children = filterRoutes(children);
  2296. return {
  2297. path,
  2298. name,
  2299. children,
  2300. meta
  2301. };
  2302. });
  2303. }
  2304. function filterCurrentRoute(route) {
  2305. if (route) {
  2306. const { fullPath, hash, href, path, name, matched, params, query } = route;
  2307. return {
  2308. fullPath,
  2309. hash,
  2310. href,
  2311. path,
  2312. name,
  2313. params,
  2314. query,
  2315. matched: filterRoutes(matched)
  2316. };
  2317. }
  2318. return route;
  2319. }
  2320. function normalizeRouterInfo(appRecord, activeAppRecord) {
  2321. function init() {
  2322. const router = appRecord.app?.config.globalProperties.$router;
  2323. const currentRoute = filterCurrentRoute(router?.currentRoute.value);
  2324. const routes = filterRoutes(getRoutes(router));
  2325. const c = console.warn;
  2326. console.warn = () => {};
  2327. target[ROUTER_INFO_KEY] = {
  2328. currentRoute: currentRoute ? deepClone(currentRoute) : {},
  2329. routes: deepClone(routes)
  2330. };
  2331. target[ROUTER_KEY] = router;
  2332. console.warn = c;
  2333. }
  2334. init();
  2335. hook.on.componentUpdated(debounce(() => {
  2336. if (activeAppRecord.value?.app !== appRecord.app) return;
  2337. init();
  2338. if (devtoolsState.highPerfModeEnabled) return;
  2339. devtoolsContext.hooks.callHook(DevToolsMessagingHookKeys.ROUTER_INFO_UPDATED, { state: target[ROUTER_INFO_KEY] });
  2340. }, 200));
  2341. }
  2342. //#endregion
  2343. //#region src/ctx/api.ts
  2344. function createDevToolsApi(hooks) {
  2345. return {
  2346. async getInspectorTree(payload) {
  2347. const _payload = {
  2348. ...payload,
  2349. app: activeAppRecord.value.app,
  2350. rootNodes: []
  2351. };
  2352. await new Promise((resolve) => {
  2353. hooks.callHookWith(async (callbacks) => {
  2354. await Promise.all(callbacks.map((cb) => cb(_payload)));
  2355. resolve();
  2356. }, DevToolsV6PluginAPIHookKeys.GET_INSPECTOR_TREE);
  2357. });
  2358. return _payload.rootNodes;
  2359. },
  2360. async getInspectorState(payload) {
  2361. const _payload = {
  2362. ...payload,
  2363. app: activeAppRecord.value.app,
  2364. state: null
  2365. };
  2366. const ctx = { currentTab: `custom-inspector:${payload.inspectorId}` };
  2367. await new Promise((resolve) => {
  2368. hooks.callHookWith(async (callbacks) => {
  2369. await Promise.all(callbacks.map((cb) => cb(_payload, ctx)));
  2370. resolve();
  2371. }, DevToolsV6PluginAPIHookKeys.GET_INSPECTOR_STATE);
  2372. });
  2373. return _payload.state;
  2374. },
  2375. editInspectorState(payload) {
  2376. const stateEditor = new StateEditor();
  2377. const _payload = {
  2378. ...payload,
  2379. app: activeAppRecord.value.app,
  2380. set: (obj, path = payload.path, value = payload.state.value, cb) => {
  2381. stateEditor.set(obj, path, value, cb || stateEditor.createDefaultSetCallback(payload.state));
  2382. }
  2383. };
  2384. hooks.callHookWith((callbacks) => {
  2385. callbacks.forEach((cb) => cb(_payload));
  2386. }, DevToolsV6PluginAPIHookKeys.EDIT_INSPECTOR_STATE);
  2387. },
  2388. sendInspectorState(inspectorId) {
  2389. const inspector = getInspector(inspectorId);
  2390. hooks.callHook(DevToolsContextHookKeys.SEND_INSPECTOR_STATE, {
  2391. inspectorId,
  2392. plugin: {
  2393. descriptor: inspector.descriptor,
  2394. setupFn: () => ({})
  2395. }
  2396. });
  2397. },
  2398. inspectComponentInspector() {
  2399. return inspectComponentHighLighter();
  2400. },
  2401. cancelInspectComponentInspector() {
  2402. return cancelInspectComponentHighLighter();
  2403. },
  2404. getComponentRenderCode(id) {
  2405. const instance = getComponentInstance(activeAppRecord.value, id);
  2406. if (instance) return !(typeof instance?.type === "function") ? instance.render.toString() : instance.type.toString();
  2407. },
  2408. scrollToComponent(id) {
  2409. return scrollToComponent({ id });
  2410. },
  2411. openInEditor,
  2412. getVueInspector: getComponentInspector,
  2413. toggleApp(id, options) {
  2414. const appRecord = devtoolsAppRecords.value.find((record) => record.id === id);
  2415. if (appRecord) {
  2416. setActiveAppRecordId(id);
  2417. setActiveAppRecord(appRecord);
  2418. normalizeRouterInfo(appRecord, activeAppRecord);
  2419. callInspectorUpdatedHook();
  2420. registerDevToolsPlugin(appRecord.app, options);
  2421. }
  2422. },
  2423. inspectDOM(instanceId) {
  2424. const instance = getComponentInstance(activeAppRecord.value, instanceId);
  2425. if (instance) {
  2426. const [el] = getRootElementsFromComponentInstance(instance);
  2427. if (el) target.__VUE_DEVTOOLS_INSPECT_DOM_TARGET__ = el;
  2428. }
  2429. },
  2430. updatePluginSettings(pluginId, key, value) {
  2431. setPluginSettings(pluginId, key, value);
  2432. },
  2433. getPluginSettings(pluginId) {
  2434. return {
  2435. options: getPluginSettingsOptions(pluginId),
  2436. values: getPluginSettings(pluginId)
  2437. };
  2438. }
  2439. };
  2440. }
  2441. //#endregion
  2442. //#region src/ctx/env.ts
  2443. target.__VUE_DEVTOOLS_ENV__ ??= { vitePluginDetected: false };
  2444. function getDevToolsEnv() {
  2445. return target.__VUE_DEVTOOLS_ENV__;
  2446. }
  2447. function setDevToolsEnv(env) {
  2448. target.__VUE_DEVTOOLS_ENV__ = {
  2449. ...target.__VUE_DEVTOOLS_ENV__,
  2450. ...env
  2451. };
  2452. }
  2453. //#endregion
  2454. //#region src/ctx/index.ts
  2455. const hooks = createDevToolsCtxHooks();
  2456. target.__VUE_DEVTOOLS_KIT_CONTEXT__ ??= {
  2457. hooks,
  2458. get state() {
  2459. return {
  2460. ...devtoolsState,
  2461. activeAppRecordId: activeAppRecord.id,
  2462. activeAppRecord: activeAppRecord.value,
  2463. appRecords: devtoolsAppRecords.value
  2464. };
  2465. },
  2466. api: createDevToolsApi(hooks)
  2467. };
  2468. const devtoolsContext = target.__VUE_DEVTOOLS_KIT_CONTEXT__;
  2469. //#endregion
  2470. //#region ../../node_modules/.pnpm/speakingurl@14.0.1/node_modules/speakingurl/lib/speakingurl.js
  2471. var require_speakingurl$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
  2472. (function(root) {
  2473. "use strict";
  2474. /**
  2475. * charMap
  2476. * @type {Object}
  2477. */
  2478. var charMap = {
  2479. "À": "A",
  2480. "Á": "A",
  2481. "Â": "A",
  2482. "Ã": "A",
  2483. "Ä": "Ae",
  2484. "Å": "A",
  2485. "Æ": "AE",
  2486. "Ç": "C",
  2487. "È": "E",
  2488. "É": "E",
  2489. "Ê": "E",
  2490. "Ë": "E",
  2491. "Ì": "I",
  2492. "Í": "I",
  2493. "Î": "I",
  2494. "Ï": "I",
  2495. "Ð": "D",
  2496. "Ñ": "N",
  2497. "Ò": "O",
  2498. "Ó": "O",
  2499. "Ô": "O",
  2500. "Õ": "O",
  2501. "Ö": "Oe",
  2502. "Ő": "O",
  2503. "Ø": "O",
  2504. "Ù": "U",
  2505. "Ú": "U",
  2506. "Û": "U",
  2507. "Ü": "Ue",
  2508. "Ű": "U",
  2509. "Ý": "Y",
  2510. "Þ": "TH",
  2511. "ß": "ss",
  2512. "à": "a",
  2513. "á": "a",
  2514. "â": "a",
  2515. "ã": "a",
  2516. "ä": "ae",
  2517. "å": "a",
  2518. "æ": "ae",
  2519. "ç": "c",
  2520. "è": "e",
  2521. "é": "e",
  2522. "ê": "e",
  2523. "ë": "e",
  2524. "ì": "i",
  2525. "í": "i",
  2526. "î": "i",
  2527. "ï": "i",
  2528. "ð": "d",
  2529. "ñ": "n",
  2530. "ò": "o",
  2531. "ó": "o",
  2532. "ô": "o",
  2533. "õ": "o",
  2534. "ö": "oe",
  2535. "ő": "o",
  2536. "ø": "o",
  2537. "ù": "u",
  2538. "ú": "u",
  2539. "û": "u",
  2540. "ü": "ue",
  2541. "ű": "u",
  2542. "ý": "y",
  2543. "þ": "th",
  2544. "ÿ": "y",
  2545. "ẞ": "SS",
  2546. "ا": "a",
  2547. "أ": "a",
  2548. "إ": "i",
  2549. "آ": "aa",
  2550. "ؤ": "u",
  2551. "ئ": "e",
  2552. "ء": "a",
  2553. "ب": "b",
  2554. "ت": "t",
  2555. "ث": "th",
  2556. "ج": "j",
  2557. "ح": "h",
  2558. "خ": "kh",
  2559. "د": "d",
  2560. "ذ": "th",
  2561. "ر": "r",
  2562. "ز": "z",
  2563. "س": "s",
  2564. "ش": "sh",
  2565. "ص": "s",
  2566. "ض": "dh",
  2567. "ط": "t",
  2568. "ظ": "z",
  2569. "ع": "a",
  2570. "غ": "gh",
  2571. "ف": "f",
  2572. "ق": "q",
  2573. "ك": "k",
  2574. "ل": "l",
  2575. "م": "m",
  2576. "ن": "n",
  2577. "ه": "h",
  2578. "و": "w",
  2579. "ي": "y",
  2580. "ى": "a",
  2581. "ة": "h",
  2582. "ﻻ": "la",
  2583. "ﻷ": "laa",
  2584. "ﻹ": "lai",
  2585. "ﻵ": "laa",
  2586. "گ": "g",
  2587. "چ": "ch",
  2588. "پ": "p",
  2589. "ژ": "zh",
  2590. "ک": "k",
  2591. "ی": "y",
  2592. "َ": "a",
  2593. "ً": "an",
  2594. "ِ": "e",
  2595. "ٍ": "en",
  2596. "ُ": "u",
  2597. "ٌ": "on",
  2598. "ْ": "",
  2599. "٠": "0",
  2600. "١": "1",
  2601. "٢": "2",
  2602. "٣": "3",
  2603. "٤": "4",
  2604. "٥": "5",
  2605. "٦": "6",
  2606. "٧": "7",
  2607. "٨": "8",
  2608. "٩": "9",
  2609. "۰": "0",
  2610. "۱": "1",
  2611. "۲": "2",
  2612. "۳": "3",
  2613. "۴": "4",
  2614. "۵": "5",
  2615. "۶": "6",
  2616. "۷": "7",
  2617. "۸": "8",
  2618. "۹": "9",
  2619. "က": "k",
  2620. "ခ": "kh",
  2621. "ဂ": "g",
  2622. "ဃ": "ga",
  2623. "င": "ng",
  2624. "စ": "s",
  2625. "ဆ": "sa",
  2626. "ဇ": "z",
  2627. "စျ": "za",
  2628. "ည": "ny",
  2629. "ဋ": "t",
  2630. "ဌ": "ta",
  2631. "ဍ": "d",
  2632. "ဎ": "da",
  2633. "ဏ": "na",
  2634. "တ": "t",
  2635. "ထ": "ta",
  2636. "ဒ": "d",
  2637. "ဓ": "da",
  2638. "န": "n",
  2639. "ပ": "p",
  2640. "ဖ": "pa",
  2641. "ဗ": "b",
  2642. "ဘ": "ba",
  2643. "မ": "m",
  2644. "ယ": "y",
  2645. "ရ": "ya",
  2646. "လ": "l",
  2647. "ဝ": "w",
  2648. "သ": "th",
  2649. "ဟ": "h",
  2650. "ဠ": "la",
  2651. "အ": "a",
  2652. "ြ": "y",
  2653. "ျ": "ya",
  2654. "ွ": "w",
  2655. "ြွ": "yw",
  2656. "ျွ": "ywa",
  2657. "ှ": "h",
  2658. "ဧ": "e",
  2659. "၏": "-e",
  2660. "ဣ": "i",
  2661. "ဤ": "-i",
  2662. "ဉ": "u",
  2663. "ဦ": "-u",
  2664. "ဩ": "aw",
  2665. "သြော": "aw",
  2666. "ဪ": "aw",
  2667. "၀": "0",
  2668. "၁": "1",
  2669. "၂": "2",
  2670. "၃": "3",
  2671. "၄": "4",
  2672. "၅": "5",
  2673. "၆": "6",
  2674. "၇": "7",
  2675. "၈": "8",
  2676. "၉": "9",
  2677. "္": "",
  2678. "့": "",
  2679. "း": "",
  2680. "č": "c",
  2681. "ď": "d",
  2682. "ě": "e",
  2683. "ň": "n",
  2684. "ř": "r",
  2685. "š": "s",
  2686. "ť": "t",
  2687. "ů": "u",
  2688. "ž": "z",
  2689. "Č": "C",
  2690. "Ď": "D",
  2691. "Ě": "E",
  2692. "Ň": "N",
  2693. "Ř": "R",
  2694. "Š": "S",
  2695. "Ť": "T",
  2696. "Ů": "U",
  2697. "Ž": "Z",
  2698. "ހ": "h",
  2699. "ށ": "sh",
  2700. "ނ": "n",
  2701. "ރ": "r",
  2702. "ބ": "b",
  2703. "ޅ": "lh",
  2704. "ކ": "k",
  2705. "އ": "a",
  2706. "ވ": "v",
  2707. "މ": "m",
  2708. "ފ": "f",
  2709. "ދ": "dh",
  2710. "ތ": "th",
  2711. "ލ": "l",
  2712. "ގ": "g",
  2713. "ޏ": "gn",
  2714. "ސ": "s",
  2715. "ޑ": "d",
  2716. "ޒ": "z",
  2717. "ޓ": "t",
  2718. "ޔ": "y",
  2719. "ޕ": "p",
  2720. "ޖ": "j",
  2721. "ޗ": "ch",
  2722. "ޘ": "tt",
  2723. "ޙ": "hh",
  2724. "ޚ": "kh",
  2725. "ޛ": "th",
  2726. "ޜ": "z",
  2727. "ޝ": "sh",
  2728. "ޞ": "s",
  2729. "ޟ": "d",
  2730. "ޠ": "t",
  2731. "ޡ": "z",
  2732. "ޢ": "a",
  2733. "ޣ": "gh",
  2734. "ޤ": "q",
  2735. "ޥ": "w",
  2736. "ަ": "a",
  2737. "ާ": "aa",
  2738. "ި": "i",
  2739. "ީ": "ee",
  2740. "ު": "u",
  2741. "ޫ": "oo",
  2742. "ެ": "e",
  2743. "ޭ": "ey",
  2744. "ޮ": "o",
  2745. "ޯ": "oa",
  2746. "ް": "",
  2747. "ა": "a",
  2748. "ბ": "b",
  2749. "გ": "g",
  2750. "დ": "d",
  2751. "ე": "e",
  2752. "ვ": "v",
  2753. "ზ": "z",
  2754. "თ": "t",
  2755. "ი": "i",
  2756. "კ": "k",
  2757. "ლ": "l",
  2758. "მ": "m",
  2759. "ნ": "n",
  2760. "ო": "o",
  2761. "პ": "p",
  2762. "ჟ": "zh",
  2763. "რ": "r",
  2764. "ს": "s",
  2765. "ტ": "t",
  2766. "უ": "u",
  2767. "ფ": "p",
  2768. "ქ": "k",
  2769. "ღ": "gh",
  2770. "ყ": "q",
  2771. "შ": "sh",
  2772. "ჩ": "ch",
  2773. "ც": "ts",
  2774. "ძ": "dz",
  2775. "წ": "ts",
  2776. "ჭ": "ch",
  2777. "ხ": "kh",
  2778. "ჯ": "j",
  2779. "ჰ": "h",
  2780. "α": "a",
  2781. "β": "v",
  2782. "γ": "g",
  2783. "δ": "d",
  2784. "ε": "e",
  2785. "ζ": "z",
  2786. "η": "i",
  2787. "θ": "th",
  2788. "ι": "i",
  2789. "κ": "k",
  2790. "λ": "l",
  2791. "μ": "m",
  2792. "ν": "n",
  2793. "ξ": "ks",
  2794. "ο": "o",
  2795. "π": "p",
  2796. "ρ": "r",
  2797. "σ": "s",
  2798. "τ": "t",
  2799. "υ": "y",
  2800. "φ": "f",
  2801. "χ": "x",
  2802. "ψ": "ps",
  2803. "ω": "o",
  2804. "ά": "a",
  2805. "έ": "e",
  2806. "ί": "i",
  2807. "ό": "o",
  2808. "ύ": "y",
  2809. "ή": "i",
  2810. "ώ": "o",
  2811. "ς": "s",
  2812. "ϊ": "i",
  2813. "ΰ": "y",
  2814. "ϋ": "y",
  2815. "ΐ": "i",
  2816. "Α": "A",
  2817. "Β": "B",
  2818. "Γ": "G",
  2819. "Δ": "D",
  2820. "Ε": "E",
  2821. "Ζ": "Z",
  2822. "Η": "I",
  2823. "Θ": "TH",
  2824. "Ι": "I",
  2825. "Κ": "K",
  2826. "Λ": "L",
  2827. "Μ": "M",
  2828. "Ν": "N",
  2829. "Ξ": "KS",
  2830. "Ο": "O",
  2831. "Π": "P",
  2832. "Ρ": "R",
  2833. "Σ": "S",
  2834. "Τ": "T",
  2835. "Υ": "Y",
  2836. "Φ": "F",
  2837. "Χ": "X",
  2838. "Ψ": "PS",
  2839. "Ω": "O",
  2840. "Ά": "A",
  2841. "Έ": "E",
  2842. "Ί": "I",
  2843. "Ό": "O",
  2844. "Ύ": "Y",
  2845. "Ή": "I",
  2846. "Ώ": "O",
  2847. "Ϊ": "I",
  2848. "Ϋ": "Y",
  2849. "ā": "a",
  2850. "ē": "e",
  2851. "ģ": "g",
  2852. "ī": "i",
  2853. "ķ": "k",
  2854. "ļ": "l",
  2855. "ņ": "n",
  2856. "ū": "u",
  2857. "Ā": "A",
  2858. "Ē": "E",
  2859. "Ģ": "G",
  2860. "Ī": "I",
  2861. "Ķ": "k",
  2862. "Ļ": "L",
  2863. "Ņ": "N",
  2864. "Ū": "U",
  2865. "Ќ": "Kj",
  2866. "ќ": "kj",
  2867. "Љ": "Lj",
  2868. "љ": "lj",
  2869. "Њ": "Nj",
  2870. "њ": "nj",
  2871. "Тс": "Ts",
  2872. "тс": "ts",
  2873. "ą": "a",
  2874. "ć": "c",
  2875. "ę": "e",
  2876. "ł": "l",
  2877. "ń": "n",
  2878. "ś": "s",
  2879. "ź": "z",
  2880. "ż": "z",
  2881. "Ą": "A",
  2882. "Ć": "C",
  2883. "Ę": "E",
  2884. "Ł": "L",
  2885. "Ń": "N",
  2886. "Ś": "S",
  2887. "Ź": "Z",
  2888. "Ż": "Z",
  2889. "Є": "Ye",
  2890. "І": "I",
  2891. "Ї": "Yi",
  2892. "Ґ": "G",
  2893. "є": "ye",
  2894. "і": "i",
  2895. "ї": "yi",
  2896. "ґ": "g",
  2897. "ă": "a",
  2898. "Ă": "A",
  2899. "ș": "s",
  2900. "Ș": "S",
  2901. "ț": "t",
  2902. "Ț": "T",
  2903. "ţ": "t",
  2904. "Ţ": "T",
  2905. "а": "a",
  2906. "б": "b",
  2907. "в": "v",
  2908. "г": "g",
  2909. "д": "d",
  2910. "е": "e",
  2911. "ё": "yo",
  2912. "ж": "zh",
  2913. "з": "z",
  2914. "и": "i",
  2915. "й": "i",
  2916. "к": "k",
  2917. "л": "l",
  2918. "м": "m",
  2919. "н": "n",
  2920. "о": "o",
  2921. "п": "p",
  2922. "р": "r",
  2923. "с": "s",
  2924. "т": "t",
  2925. "у": "u",
  2926. "ф": "f",
  2927. "х": "kh",
  2928. "ц": "c",
  2929. "ч": "ch",
  2930. "ш": "sh",
  2931. "щ": "sh",
  2932. "ъ": "",
  2933. "ы": "y",
  2934. "ь": "",
  2935. "э": "e",
  2936. "ю": "yu",
  2937. "я": "ya",
  2938. "А": "A",
  2939. "Б": "B",
  2940. "В": "V",
  2941. "Г": "G",
  2942. "Д": "D",
  2943. "Е": "E",
  2944. "Ё": "Yo",
  2945. "Ж": "Zh",
  2946. "З": "Z",
  2947. "И": "I",
  2948. "Й": "I",
  2949. "К": "K",
  2950. "Л": "L",
  2951. "М": "M",
  2952. "Н": "N",
  2953. "О": "O",
  2954. "П": "P",
  2955. "Р": "R",
  2956. "С": "S",
  2957. "Т": "T",
  2958. "У": "U",
  2959. "Ф": "F",
  2960. "Х": "Kh",
  2961. "Ц": "C",
  2962. "Ч": "Ch",
  2963. "Ш": "Sh",
  2964. "Щ": "Sh",
  2965. "Ъ": "",
  2966. "Ы": "Y",
  2967. "Ь": "",
  2968. "Э": "E",
  2969. "Ю": "Yu",
  2970. "Я": "Ya",
  2971. "ђ": "dj",
  2972. "ј": "j",
  2973. "ћ": "c",
  2974. "џ": "dz",
  2975. "Ђ": "Dj",
  2976. "Ј": "j",
  2977. "Ћ": "C",
  2978. "Џ": "Dz",
  2979. "ľ": "l",
  2980. "ĺ": "l",
  2981. "ŕ": "r",
  2982. "Ľ": "L",
  2983. "Ĺ": "L",
  2984. "Ŕ": "R",
  2985. "ş": "s",
  2986. "Ş": "S",
  2987. "ı": "i",
  2988. "İ": "I",
  2989. "ğ": "g",
  2990. "Ğ": "G",
  2991. "ả": "a",
  2992. "Ả": "A",
  2993. "ẳ": "a",
  2994. "Ẳ": "A",
  2995. "ẩ": "a",
  2996. "Ẩ": "A",
  2997. "đ": "d",
  2998. "Đ": "D",
  2999. "ẹ": "e",
  3000. "Ẹ": "E",
  3001. "ẽ": "e",
  3002. "Ẽ": "E",
  3003. "ẻ": "e",
  3004. "Ẻ": "E",
  3005. "ế": "e",
  3006. "Ế": "E",
  3007. "ề": "e",
  3008. "Ề": "E",
  3009. "ệ": "e",
  3010. "Ệ": "E",
  3011. "ễ": "e",
  3012. "Ễ": "E",
  3013. "ể": "e",
  3014. "Ể": "E",
  3015. "ỏ": "o",
  3016. "ọ": "o",
  3017. "Ọ": "o",
  3018. "ố": "o",
  3019. "Ố": "O",
  3020. "ồ": "o",
  3021. "Ồ": "O",
  3022. "ổ": "o",
  3023. "Ổ": "O",
  3024. "ộ": "o",
  3025. "Ộ": "O",
  3026. "ỗ": "o",
  3027. "Ỗ": "O",
  3028. "ơ": "o",
  3029. "Ơ": "O",
  3030. "ớ": "o",
  3031. "Ớ": "O",
  3032. "ờ": "o",
  3033. "Ờ": "O",
  3034. "ợ": "o",
  3035. "Ợ": "O",
  3036. "ỡ": "o",
  3037. "Ỡ": "O",
  3038. "Ở": "o",
  3039. "ở": "o",
  3040. "ị": "i",
  3041. "Ị": "I",
  3042. "ĩ": "i",
  3043. "Ĩ": "I",
  3044. "ỉ": "i",
  3045. "Ỉ": "i",
  3046. "ủ": "u",
  3047. "Ủ": "U",
  3048. "ụ": "u",
  3049. "Ụ": "U",
  3050. "ũ": "u",
  3051. "Ũ": "U",
  3052. "ư": "u",
  3053. "Ư": "U",
  3054. "ứ": "u",
  3055. "Ứ": "U",
  3056. "ừ": "u",
  3057. "Ừ": "U",
  3058. "ự": "u",
  3059. "Ự": "U",
  3060. "ữ": "u",
  3061. "Ữ": "U",
  3062. "ử": "u",
  3063. "Ử": "ư",
  3064. "ỷ": "y",
  3065. "Ỷ": "y",
  3066. "ỳ": "y",
  3067. "Ỳ": "Y",
  3068. "ỵ": "y",
  3069. "Ỵ": "Y",
  3070. "ỹ": "y",
  3071. "Ỹ": "Y",
  3072. "ạ": "a",
  3073. "Ạ": "A",
  3074. "ấ": "a",
  3075. "Ấ": "A",
  3076. "ầ": "a",
  3077. "Ầ": "A",
  3078. "ậ": "a",
  3079. "Ậ": "A",
  3080. "ẫ": "a",
  3081. "Ẫ": "A",
  3082. "ắ": "a",
  3083. "Ắ": "A",
  3084. "ằ": "a",
  3085. "Ằ": "A",
  3086. "ặ": "a",
  3087. "Ặ": "A",
  3088. "ẵ": "a",
  3089. "Ẵ": "A",
  3090. "⓪": "0",
  3091. "①": "1",
  3092. "②": "2",
  3093. "③": "3",
  3094. "④": "4",
  3095. "⑤": "5",
  3096. "⑥": "6",
  3097. "⑦": "7",
  3098. "⑧": "8",
  3099. "⑨": "9",
  3100. "⑩": "10",
  3101. "⑪": "11",
  3102. "⑫": "12",
  3103. "⑬": "13",
  3104. "⑭": "14",
  3105. "⑮": "15",
  3106. "⑯": "16",
  3107. "⑰": "17",
  3108. "⑱": "18",
  3109. "⑲": "18",
  3110. "⑳": "18",
  3111. "⓵": "1",
  3112. "⓶": "2",
  3113. "⓷": "3",
  3114. "⓸": "4",
  3115. "⓹": "5",
  3116. "⓺": "6",
  3117. "⓻": "7",
  3118. "⓼": "8",
  3119. "⓽": "9",
  3120. "⓾": "10",
  3121. "⓿": "0",
  3122. "⓫": "11",
  3123. "⓬": "12",
  3124. "⓭": "13",
  3125. "⓮": "14",
  3126. "⓯": "15",
  3127. "⓰": "16",
  3128. "⓱": "17",
  3129. "⓲": "18",
  3130. "⓳": "19",
  3131. "⓴": "20",
  3132. "Ⓐ": "A",
  3133. "Ⓑ": "B",
  3134. "Ⓒ": "C",
  3135. "Ⓓ": "D",
  3136. "Ⓔ": "E",
  3137. "Ⓕ": "F",
  3138. "Ⓖ": "G",
  3139. "Ⓗ": "H",
  3140. "Ⓘ": "I",
  3141. "Ⓙ": "J",
  3142. "Ⓚ": "K",
  3143. "Ⓛ": "L",
  3144. "Ⓜ": "M",
  3145. "Ⓝ": "N",
  3146. "Ⓞ": "O",
  3147. "Ⓟ": "P",
  3148. "Ⓠ": "Q",
  3149. "Ⓡ": "R",
  3150. "Ⓢ": "S",
  3151. "Ⓣ": "T",
  3152. "Ⓤ": "U",
  3153. "Ⓥ": "V",
  3154. "Ⓦ": "W",
  3155. "Ⓧ": "X",
  3156. "Ⓨ": "Y",
  3157. "Ⓩ": "Z",
  3158. "ⓐ": "a",
  3159. "ⓑ": "b",
  3160. "ⓒ": "c",
  3161. "ⓓ": "d",
  3162. "ⓔ": "e",
  3163. "ⓕ": "f",
  3164. "ⓖ": "g",
  3165. "ⓗ": "h",
  3166. "ⓘ": "i",
  3167. "ⓙ": "j",
  3168. "ⓚ": "k",
  3169. "ⓛ": "l",
  3170. "ⓜ": "m",
  3171. "ⓝ": "n",
  3172. "ⓞ": "o",
  3173. "ⓟ": "p",
  3174. "ⓠ": "q",
  3175. "ⓡ": "r",
  3176. "ⓢ": "s",
  3177. "ⓣ": "t",
  3178. "ⓤ": "u",
  3179. "ⓦ": "v",
  3180. "ⓥ": "w",
  3181. "ⓧ": "x",
  3182. "ⓨ": "y",
  3183. "ⓩ": "z",
  3184. "“": "\"",
  3185. "”": "\"",
  3186. "‘": "'",
  3187. "’": "'",
  3188. "∂": "d",
  3189. "ƒ": "f",
  3190. "™": "(TM)",
  3191. "©": "(C)",
  3192. "œ": "oe",
  3193. "Œ": "OE",
  3194. "®": "(R)",
  3195. "†": "+",
  3196. "℠": "(SM)",
  3197. "…": "...",
  3198. "˚": "o",
  3199. "º": "o",
  3200. "ª": "a",
  3201. "•": "*",
  3202. "၊": ",",
  3203. "။": ".",
  3204. "$": "USD",
  3205. "€": "EUR",
  3206. "₢": "BRN",
  3207. "₣": "FRF",
  3208. "£": "GBP",
  3209. "₤": "ITL",
  3210. "₦": "NGN",
  3211. "₧": "ESP",
  3212. "₩": "KRW",
  3213. "₪": "ILS",
  3214. "₫": "VND",
  3215. "₭": "LAK",
  3216. "₮": "MNT",
  3217. "₯": "GRD",
  3218. "₱": "ARS",
  3219. "₲": "PYG",
  3220. "₳": "ARA",
  3221. "₴": "UAH",
  3222. "₵": "GHS",
  3223. "¢": "cent",
  3224. "¥": "CNY",
  3225. "元": "CNY",
  3226. "円": "YEN",
  3227. "﷼": "IRR",
  3228. "₠": "EWE",
  3229. "฿": "THB",
  3230. "₨": "INR",
  3231. "₹": "INR",
  3232. "₰": "PF",
  3233. "₺": "TRY",
  3234. "؋": "AFN",
  3235. "₼": "AZN",
  3236. "лв": "BGN",
  3237. "៛": "KHR",
  3238. "₡": "CRC",
  3239. "₸": "KZT",
  3240. "ден": "MKD",
  3241. "zł": "PLN",
  3242. "₽": "RUB",
  3243. "₾": "GEL"
  3244. };
  3245. /**
  3246. * special look ahead character array
  3247. * These characters form with consonants to become 'single'/consonant combo
  3248. * @type [Array]
  3249. */
  3250. var lookAheadCharArray = ["်", "ް"];
  3251. /**
  3252. * diatricMap for languages where transliteration changes entirely as more diatrics are added
  3253. * @type {Object}
  3254. */
  3255. var diatricMap = {
  3256. "ာ": "a",
  3257. "ါ": "a",
  3258. "ေ": "e",
  3259. "ဲ": "e",
  3260. "ိ": "i",
  3261. "ီ": "i",
  3262. "ို": "o",
  3263. "ု": "u",
  3264. "ူ": "u",
  3265. "ေါင်": "aung",
  3266. "ော": "aw",
  3267. "ော်": "aw",
  3268. "ေါ": "aw",
  3269. "ေါ်": "aw",
  3270. "်": "်",
  3271. "က်": "et",
  3272. "ိုက်": "aik",
  3273. "ောက်": "auk",
  3274. "င်": "in",
  3275. "ိုင်": "aing",
  3276. "ောင်": "aung",
  3277. "စ်": "it",
  3278. "ည်": "i",
  3279. "တ်": "at",
  3280. "ိတ်": "eik",
  3281. "ုတ်": "ok",
  3282. "ွတ်": "ut",
  3283. "ေတ်": "it",
  3284. "ဒ်": "d",
  3285. "ိုဒ်": "ok",
  3286. "ုဒ်": "ait",
  3287. "န်": "an",
  3288. "ာန်": "an",
  3289. "ိန်": "ein",
  3290. "ုန်": "on",
  3291. "ွန်": "un",
  3292. "ပ်": "at",
  3293. "ိပ်": "eik",
  3294. "ုပ်": "ok",
  3295. "ွပ်": "ut",
  3296. "န်ုပ်": "nub",
  3297. "မ်": "an",
  3298. "ိမ်": "ein",
  3299. "ုမ်": "on",
  3300. "ွမ်": "un",
  3301. "ယ်": "e",
  3302. "ိုလ်": "ol",
  3303. "ဉ်": "in",
  3304. "ံ": "an",
  3305. "ိံ": "ein",
  3306. "ုံ": "on",
  3307. "ައް": "ah",
  3308. "ަށް": "ah"
  3309. };
  3310. /**
  3311. * langCharMap language specific characters translations
  3312. * @type {Object}
  3313. */
  3314. var langCharMap = {
  3315. "en": {},
  3316. "az": {
  3317. "ç": "c",
  3318. "ə": "e",
  3319. "ğ": "g",
  3320. "ı": "i",
  3321. "ö": "o",
  3322. "ş": "s",
  3323. "ü": "u",
  3324. "Ç": "C",
  3325. "Ə": "E",
  3326. "Ğ": "G",
  3327. "İ": "I",
  3328. "Ö": "O",
  3329. "Ş": "S",
  3330. "Ü": "U"
  3331. },
  3332. "cs": {
  3333. "č": "c",
  3334. "ď": "d",
  3335. "ě": "e",
  3336. "ň": "n",
  3337. "ř": "r",
  3338. "š": "s",
  3339. "ť": "t",
  3340. "ů": "u",
  3341. "ž": "z",
  3342. "Č": "C",
  3343. "Ď": "D",
  3344. "Ě": "E",
  3345. "Ň": "N",
  3346. "Ř": "R",
  3347. "Š": "S",
  3348. "Ť": "T",
  3349. "Ů": "U",
  3350. "Ž": "Z"
  3351. },
  3352. "fi": {
  3353. "ä": "a",
  3354. "Ä": "A",
  3355. "ö": "o",
  3356. "Ö": "O"
  3357. },
  3358. "hu": {
  3359. "ä": "a",
  3360. "Ä": "A",
  3361. "ö": "o",
  3362. "Ö": "O",
  3363. "ü": "u",
  3364. "Ü": "U",
  3365. "ű": "u",
  3366. "Ű": "U"
  3367. },
  3368. "lt": {
  3369. "ą": "a",
  3370. "č": "c",
  3371. "ę": "e",
  3372. "ė": "e",
  3373. "į": "i",
  3374. "š": "s",
  3375. "ų": "u",
  3376. "ū": "u",
  3377. "ž": "z",
  3378. "Ą": "A",
  3379. "Č": "C",
  3380. "Ę": "E",
  3381. "Ė": "E",
  3382. "Į": "I",
  3383. "Š": "S",
  3384. "Ų": "U",
  3385. "Ū": "U"
  3386. },
  3387. "lv": {
  3388. "ā": "a",
  3389. "č": "c",
  3390. "ē": "e",
  3391. "ģ": "g",
  3392. "ī": "i",
  3393. "ķ": "k",
  3394. "ļ": "l",
  3395. "ņ": "n",
  3396. "š": "s",
  3397. "ū": "u",
  3398. "ž": "z",
  3399. "Ā": "A",
  3400. "Č": "C",
  3401. "Ē": "E",
  3402. "Ģ": "G",
  3403. "Ī": "i",
  3404. "Ķ": "k",
  3405. "Ļ": "L",
  3406. "Ņ": "N",
  3407. "Š": "S",
  3408. "Ū": "u",
  3409. "Ž": "Z"
  3410. },
  3411. "pl": {
  3412. "ą": "a",
  3413. "ć": "c",
  3414. "ę": "e",
  3415. "ł": "l",
  3416. "ń": "n",
  3417. "ó": "o",
  3418. "ś": "s",
  3419. "ź": "z",
  3420. "ż": "z",
  3421. "Ą": "A",
  3422. "Ć": "C",
  3423. "Ę": "e",
  3424. "Ł": "L",
  3425. "Ń": "N",
  3426. "Ó": "O",
  3427. "Ś": "S",
  3428. "Ź": "Z",
  3429. "Ż": "Z"
  3430. },
  3431. "sv": {
  3432. "ä": "a",
  3433. "Ä": "A",
  3434. "ö": "o",
  3435. "Ö": "O"
  3436. },
  3437. "sk": {
  3438. "ä": "a",
  3439. "Ä": "A"
  3440. },
  3441. "sr": {
  3442. "љ": "lj",
  3443. "њ": "nj",
  3444. "Љ": "Lj",
  3445. "Њ": "Nj",
  3446. "đ": "dj",
  3447. "Đ": "Dj"
  3448. },
  3449. "tr": {
  3450. "Ü": "U",
  3451. "Ö": "O",
  3452. "ü": "u",
  3453. "ö": "o"
  3454. }
  3455. };
  3456. /**
  3457. * symbolMap language specific symbol translations
  3458. * translations must be transliterated already
  3459. * @type {Object}
  3460. */
  3461. var symbolMap = {
  3462. "ar": {
  3463. "∆": "delta",
  3464. "∞": "la-nihaya",
  3465. "♥": "hob",
  3466. "&": "wa",
  3467. "|": "aw",
  3468. "<": "aqal-men",
  3469. ">": "akbar-men",
  3470. "∑": "majmou",
  3471. "¤": "omla"
  3472. },
  3473. "az": {},
  3474. "ca": {
  3475. "∆": "delta",
  3476. "∞": "infinit",
  3477. "♥": "amor",
  3478. "&": "i",
  3479. "|": "o",
  3480. "<": "menys que",
  3481. ">": "mes que",
  3482. "∑": "suma dels",
  3483. "¤": "moneda"
  3484. },
  3485. "cs": {
  3486. "∆": "delta",
  3487. "∞": "nekonecno",
  3488. "♥": "laska",
  3489. "&": "a",
  3490. "|": "nebo",
  3491. "<": "mensi nez",
  3492. ">": "vetsi nez",
  3493. "∑": "soucet",
  3494. "¤": "mena"
  3495. },
  3496. "de": {
  3497. "∆": "delta",
  3498. "∞": "unendlich",
  3499. "♥": "Liebe",
  3500. "&": "und",
  3501. "|": "oder",
  3502. "<": "kleiner als",
  3503. ">": "groesser als",
  3504. "∑": "Summe von",
  3505. "¤": "Waehrung"
  3506. },
  3507. "dv": {
  3508. "∆": "delta",
  3509. "∞": "kolunulaa",
  3510. "♥": "loabi",
  3511. "&": "aai",
  3512. "|": "noonee",
  3513. "<": "ah vure kuda",
  3514. ">": "ah vure bodu",
  3515. "∑": "jumula",
  3516. "¤": "faisaa"
  3517. },
  3518. "en": {
  3519. "∆": "delta",
  3520. "∞": "infinity",
  3521. "♥": "love",
  3522. "&": "and",
  3523. "|": "or",
  3524. "<": "less than",
  3525. ">": "greater than",
  3526. "∑": "sum",
  3527. "¤": "currency"
  3528. },
  3529. "es": {
  3530. "∆": "delta",
  3531. "∞": "infinito",
  3532. "♥": "amor",
  3533. "&": "y",
  3534. "|": "u",
  3535. "<": "menos que",
  3536. ">": "mas que",
  3537. "∑": "suma de los",
  3538. "¤": "moneda"
  3539. },
  3540. "fa": {
  3541. "∆": "delta",
  3542. "∞": "bi-nahayat",
  3543. "♥": "eshgh",
  3544. "&": "va",
  3545. "|": "ya",
  3546. "<": "kamtar-az",
  3547. ">": "bishtar-az",
  3548. "∑": "majmooe",
  3549. "¤": "vahed"
  3550. },
  3551. "fi": {
  3552. "∆": "delta",
  3553. "∞": "aarettomyys",
  3554. "♥": "rakkaus",
  3555. "&": "ja",
  3556. "|": "tai",
  3557. "<": "pienempi kuin",
  3558. ">": "suurempi kuin",
  3559. "∑": "summa",
  3560. "¤": "valuutta"
  3561. },
  3562. "fr": {
  3563. "∆": "delta",
  3564. "∞": "infiniment",
  3565. "♥": "Amour",
  3566. "&": "et",
  3567. "|": "ou",
  3568. "<": "moins que",
  3569. ">": "superieure a",
  3570. "∑": "somme des",
  3571. "¤": "monnaie"
  3572. },
  3573. "ge": {
  3574. "∆": "delta",
  3575. "∞": "usasruloba",
  3576. "♥": "siqvaruli",
  3577. "&": "da",
  3578. "|": "an",
  3579. "<": "naklebi",
  3580. ">": "meti",
  3581. "∑": "jami",
  3582. "¤": "valuta"
  3583. },
  3584. "gr": {},
  3585. "hu": {
  3586. "∆": "delta",
  3587. "∞": "vegtelen",
  3588. "♥": "szerelem",
  3589. "&": "es",
  3590. "|": "vagy",
  3591. "<": "kisebb mint",
  3592. ">": "nagyobb mint",
  3593. "∑": "szumma",
  3594. "¤": "penznem"
  3595. },
  3596. "it": {
  3597. "∆": "delta",
  3598. "∞": "infinito",
  3599. "♥": "amore",
  3600. "&": "e",
  3601. "|": "o",
  3602. "<": "minore di",
  3603. ">": "maggiore di",
  3604. "∑": "somma",
  3605. "¤": "moneta"
  3606. },
  3607. "lt": {
  3608. "∆": "delta",
  3609. "∞": "begalybe",
  3610. "♥": "meile",
  3611. "&": "ir",
  3612. "|": "ar",
  3613. "<": "maziau nei",
  3614. ">": "daugiau nei",
  3615. "∑": "suma",
  3616. "¤": "valiuta"
  3617. },
  3618. "lv": {
  3619. "∆": "delta",
  3620. "∞": "bezgaliba",
  3621. "♥": "milestiba",
  3622. "&": "un",
  3623. "|": "vai",
  3624. "<": "mazak neka",
  3625. ">": "lielaks neka",
  3626. "∑": "summa",
  3627. "¤": "valuta"
  3628. },
  3629. "my": {
  3630. "∆": "kwahkhyaet",
  3631. "∞": "asaonasme",
  3632. "♥": "akhyait",
  3633. "&": "nhin",
  3634. "|": "tho",
  3635. "<": "ngethaw",
  3636. ">": "kyithaw",
  3637. "∑": "paungld",
  3638. "¤": "ngwekye"
  3639. },
  3640. "mk": {},
  3641. "nl": {
  3642. "∆": "delta",
  3643. "∞": "oneindig",
  3644. "♥": "liefde",
  3645. "&": "en",
  3646. "|": "of",
  3647. "<": "kleiner dan",
  3648. ">": "groter dan",
  3649. "∑": "som",
  3650. "¤": "valuta"
  3651. },
  3652. "pl": {
  3653. "∆": "delta",
  3654. "∞": "nieskonczonosc",
  3655. "♥": "milosc",
  3656. "&": "i",
  3657. "|": "lub",
  3658. "<": "mniejsze niz",
  3659. ">": "wieksze niz",
  3660. "∑": "suma",
  3661. "¤": "waluta"
  3662. },
  3663. "pt": {
  3664. "∆": "delta",
  3665. "∞": "infinito",
  3666. "♥": "amor",
  3667. "&": "e",
  3668. "|": "ou",
  3669. "<": "menor que",
  3670. ">": "maior que",
  3671. "∑": "soma",
  3672. "¤": "moeda"
  3673. },
  3674. "ro": {
  3675. "∆": "delta",
  3676. "∞": "infinit",
  3677. "♥": "dragoste",
  3678. "&": "si",
  3679. "|": "sau",
  3680. "<": "mai mic ca",
  3681. ">": "mai mare ca",
  3682. "∑": "suma",
  3683. "¤": "valuta"
  3684. },
  3685. "ru": {
  3686. "∆": "delta",
  3687. "∞": "beskonechno",
  3688. "♥": "lubov",
  3689. "&": "i",
  3690. "|": "ili",
  3691. "<": "menshe",
  3692. ">": "bolshe",
  3693. "∑": "summa",
  3694. "¤": "valjuta"
  3695. },
  3696. "sk": {
  3697. "∆": "delta",
  3698. "∞": "nekonecno",
  3699. "♥": "laska",
  3700. "&": "a",
  3701. "|": "alebo",
  3702. "<": "menej ako",
  3703. ">": "viac ako",
  3704. "∑": "sucet",
  3705. "¤": "mena"
  3706. },
  3707. "sr": {},
  3708. "tr": {
  3709. "∆": "delta",
  3710. "∞": "sonsuzluk",
  3711. "♥": "ask",
  3712. "&": "ve",
  3713. "|": "veya",
  3714. "<": "kucuktur",
  3715. ">": "buyuktur",
  3716. "∑": "toplam",
  3717. "¤": "para birimi"
  3718. },
  3719. "uk": {
  3720. "∆": "delta",
  3721. "∞": "bezkinechnist",
  3722. "♥": "lubov",
  3723. "&": "i",
  3724. "|": "abo",
  3725. "<": "menshe",
  3726. ">": "bilshe",
  3727. "∑": "suma",
  3728. "¤": "valjuta"
  3729. },
  3730. "vn": {
  3731. "∆": "delta",
  3732. "∞": "vo cuc",
  3733. "♥": "yeu",
  3734. "&": "va",
  3735. "|": "hoac",
  3736. "<": "nho hon",
  3737. ">": "lon hon",
  3738. "∑": "tong",
  3739. "¤": "tien te"
  3740. }
  3741. };
  3742. var uricChars = [
  3743. ";",
  3744. "?",
  3745. ":",
  3746. "@",
  3747. "&",
  3748. "=",
  3749. "+",
  3750. "$",
  3751. ",",
  3752. "/"
  3753. ].join("");
  3754. var uricNoSlashChars = [
  3755. ";",
  3756. "?",
  3757. ":",
  3758. "@",
  3759. "&",
  3760. "=",
  3761. "+",
  3762. "$",
  3763. ","
  3764. ].join("");
  3765. var markChars = [
  3766. ".",
  3767. "!",
  3768. "~",
  3769. "*",
  3770. "'",
  3771. "(",
  3772. ")"
  3773. ].join("");
  3774. /**
  3775. * getSlug
  3776. * @param {string} input input string
  3777. * @param {object|string} opts config object or separator string/char
  3778. * @api public
  3779. * @return {string} sluggified string
  3780. */
  3781. var getSlug = function getSlug(input, opts) {
  3782. var separator = "-";
  3783. var result = "";
  3784. var diatricString = "";
  3785. var convertSymbols = true;
  3786. var customReplacements = {};
  3787. var maintainCase;
  3788. var titleCase;
  3789. var truncate;
  3790. var uricFlag;
  3791. var uricNoSlashFlag;
  3792. var markFlag;
  3793. var symbol;
  3794. var langChar;
  3795. var lucky;
  3796. var i;
  3797. var ch;
  3798. var l;
  3799. var lastCharWasSymbol;
  3800. var lastCharWasDiatric;
  3801. var allowedChars = "";
  3802. if (typeof input !== "string") return "";
  3803. if (typeof opts === "string") separator = opts;
  3804. symbol = symbolMap.en;
  3805. langChar = langCharMap.en;
  3806. if (typeof opts === "object") {
  3807. maintainCase = opts.maintainCase || false;
  3808. customReplacements = opts.custom && typeof opts.custom === "object" ? opts.custom : customReplacements;
  3809. truncate = +opts.truncate > 1 && opts.truncate || false;
  3810. uricFlag = opts.uric || false;
  3811. uricNoSlashFlag = opts.uricNoSlash || false;
  3812. markFlag = opts.mark || false;
  3813. convertSymbols = opts.symbols === false || opts.lang === false ? false : true;
  3814. separator = opts.separator || separator;
  3815. if (uricFlag) allowedChars += uricChars;
  3816. if (uricNoSlashFlag) allowedChars += uricNoSlashChars;
  3817. if (markFlag) allowedChars += markChars;
  3818. symbol = opts.lang && symbolMap[opts.lang] && convertSymbols ? symbolMap[opts.lang] : convertSymbols ? symbolMap.en : {};
  3819. langChar = opts.lang && langCharMap[opts.lang] ? langCharMap[opts.lang] : opts.lang === false || opts.lang === true ? {} : langCharMap.en;
  3820. if (opts.titleCase && typeof opts.titleCase.length === "number" && Array.prototype.toString.call(opts.titleCase)) {
  3821. opts.titleCase.forEach(function(v) {
  3822. customReplacements[v + ""] = v + "";
  3823. });
  3824. titleCase = true;
  3825. } else titleCase = !!opts.titleCase;
  3826. if (opts.custom && typeof opts.custom.length === "number" && Array.prototype.toString.call(opts.custom)) opts.custom.forEach(function(v) {
  3827. customReplacements[v + ""] = v + "";
  3828. });
  3829. Object.keys(customReplacements).forEach(function(v) {
  3830. var r;
  3831. if (v.length > 1) r = new RegExp("\\b" + escapeChars(v) + "\\b", "gi");
  3832. else r = new RegExp(escapeChars(v), "gi");
  3833. input = input.replace(r, customReplacements[v]);
  3834. });
  3835. for (ch in customReplacements) allowedChars += ch;
  3836. }
  3837. allowedChars += separator;
  3838. allowedChars = escapeChars(allowedChars);
  3839. input = input.replace(/(^\s+|\s+$)/g, "");
  3840. lastCharWasSymbol = false;
  3841. lastCharWasDiatric = false;
  3842. for (i = 0, l = input.length; i < l; i++) {
  3843. ch = input[i];
  3844. if (isReplacedCustomChar(ch, customReplacements)) lastCharWasSymbol = false;
  3845. else if (langChar[ch]) {
  3846. ch = lastCharWasSymbol && langChar[ch].match(/[A-Za-z0-9]/) ? " " + langChar[ch] : langChar[ch];
  3847. lastCharWasSymbol = false;
  3848. } else if (ch in charMap) {
  3849. if (i + 1 < l && lookAheadCharArray.indexOf(input[i + 1]) >= 0) {
  3850. diatricString += ch;
  3851. ch = "";
  3852. } else if (lastCharWasDiatric === true) {
  3853. ch = diatricMap[diatricString] + charMap[ch];
  3854. diatricString = "";
  3855. } else ch = lastCharWasSymbol && charMap[ch].match(/[A-Za-z0-9]/) ? " " + charMap[ch] : charMap[ch];
  3856. lastCharWasSymbol = false;
  3857. lastCharWasDiatric = false;
  3858. } else if (ch in diatricMap) {
  3859. diatricString += ch;
  3860. ch = "";
  3861. if (i === l - 1) ch = diatricMap[diatricString];
  3862. lastCharWasDiatric = true;
  3863. } else if (symbol[ch] && !(uricFlag && uricChars.indexOf(ch) !== -1) && !(uricNoSlashFlag && uricNoSlashChars.indexOf(ch) !== -1)) {
  3864. ch = lastCharWasSymbol || result.substr(-1).match(/[A-Za-z0-9]/) ? separator + symbol[ch] : symbol[ch];
  3865. ch += input[i + 1] !== void 0 && input[i + 1].match(/[A-Za-z0-9]/) ? separator : "";
  3866. lastCharWasSymbol = true;
  3867. } else {
  3868. if (lastCharWasDiatric === true) {
  3869. ch = diatricMap[diatricString] + ch;
  3870. diatricString = "";
  3871. lastCharWasDiatric = false;
  3872. } else if (lastCharWasSymbol && (/[A-Za-z0-9]/.test(ch) || result.substr(-1).match(/A-Za-z0-9]/))) ch = " " + ch;
  3873. lastCharWasSymbol = false;
  3874. }
  3875. result += ch.replace(new RegExp("[^\\w\\s" + allowedChars + "_-]", "g"), separator);
  3876. }
  3877. if (titleCase) result = result.replace(/(\w)(\S*)/g, function(_, i, r) {
  3878. var j = i.toUpperCase() + (r !== null ? r : "");
  3879. return Object.keys(customReplacements).indexOf(j.toLowerCase()) < 0 ? j : j.toLowerCase();
  3880. });
  3881. result = result.replace(/\s+/g, separator).replace(new RegExp("\\" + separator + "+", "g"), separator).replace(new RegExp("(^\\" + separator + "+|\\" + separator + "+$)", "g"), "");
  3882. if (truncate && result.length > truncate) {
  3883. lucky = result.charAt(truncate) === separator;
  3884. result = result.slice(0, truncate);
  3885. if (!lucky) result = result.slice(0, result.lastIndexOf(separator));
  3886. }
  3887. if (!maintainCase && !titleCase) result = result.toLowerCase();
  3888. return result;
  3889. };
  3890. /**
  3891. * createSlug curried(opts)(input)
  3892. * @param {object|string} opts config object or input string
  3893. * @return {Function} function getSlugWithConfig()
  3894. **/
  3895. var createSlug = function createSlug(opts) {
  3896. /**
  3897. * getSlugWithConfig
  3898. * @param {string} input string
  3899. * @return {string} slug string
  3900. */
  3901. return function getSlugWithConfig(input) {
  3902. return getSlug(input, opts);
  3903. };
  3904. };
  3905. /**
  3906. * escape Chars
  3907. * @param {string} input string
  3908. */
  3909. var escapeChars = function escapeChars(input) {
  3910. return input.replace(/[-\\^$*+?.()|[\]{}\/]/g, "\\$&");
  3911. };
  3912. /**
  3913. * check if the char is an already converted char from custom list
  3914. * @param {char} ch character to check
  3915. * @param {object} customReplacements custom translation map
  3916. */
  3917. var isReplacedCustomChar = function(ch, customReplacements) {
  3918. for (var c in customReplacements) if (customReplacements[c] === ch) return true;
  3919. };
  3920. if (typeof module !== "undefined" && module.exports) {
  3921. module.exports = getSlug;
  3922. module.exports.createSlug = createSlug;
  3923. } else if (typeof define !== "undefined" && define.amd) define([], function() {
  3924. return getSlug;
  3925. });
  3926. else try {
  3927. if (root.getSlug || root.createSlug) throw "speakingurl: globals exists /(getSlug|createSlug)/";
  3928. else {
  3929. root.getSlug = getSlug;
  3930. root.createSlug = createSlug;
  3931. }
  3932. } catch (e) {}
  3933. })(exports);
  3934. }));
  3935. //#endregion
  3936. //#region src/core/app/index.ts
  3937. var import_speakingurl = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
  3938. module.exports = require_speakingurl$1();
  3939. })))(), 1);
  3940. const appRecordInfo = target.__VUE_DEVTOOLS_NEXT_APP_RECORD_INFO__ ??= {
  3941. id: 0,
  3942. appIds: /* @__PURE__ */ new Set()
  3943. };
  3944. function getAppRecordName(app, fallbackName) {
  3945. return app?._component?.name || `App ${fallbackName}`;
  3946. }
  3947. function getAppRootInstance(app) {
  3948. if (app._instance) return app._instance;
  3949. else if (app._container?._vnode?.component) return app._container?._vnode?.component;
  3950. }
  3951. function removeAppRecordId(app) {
  3952. const id = app.__VUE_DEVTOOLS_NEXT_APP_RECORD_ID__;
  3953. if (id != null) {
  3954. appRecordInfo.appIds.delete(id);
  3955. appRecordInfo.id--;
  3956. }
  3957. }
  3958. function getAppRecordId(app, defaultId) {
  3959. if (app.__VUE_DEVTOOLS_NEXT_APP_RECORD_ID__ != null) return app.__VUE_DEVTOOLS_NEXT_APP_RECORD_ID__;
  3960. let id = defaultId ?? (appRecordInfo.id++).toString();
  3961. if (defaultId && appRecordInfo.appIds.has(id)) {
  3962. let count = 1;
  3963. while (appRecordInfo.appIds.has(`${defaultId}_${count}`)) count++;
  3964. id = `${defaultId}_${count}`;
  3965. }
  3966. appRecordInfo.appIds.add(id);
  3967. app.__VUE_DEVTOOLS_NEXT_APP_RECORD_ID__ = id;
  3968. return id;
  3969. }
  3970. function createAppRecord(app, types) {
  3971. const rootInstance = getAppRootInstance(app);
  3972. if (rootInstance) {
  3973. appRecordInfo.id++;
  3974. const name = getAppRecordName(app, appRecordInfo.id.toString());
  3975. const id = getAppRecordId(app, (0, import_speakingurl.default)(name));
  3976. const [el] = getRootElementsFromComponentInstance(rootInstance);
  3977. const record = {
  3978. id,
  3979. name,
  3980. types,
  3981. instanceMap: /* @__PURE__ */ new Map(),
  3982. perfGroupIds: /* @__PURE__ */ new Map(),
  3983. rootInstance,
  3984. iframe: isBrowser && document !== el?.ownerDocument ? el?.ownerDocument?.location?.pathname : void 0
  3985. };
  3986. app.__VUE_DEVTOOLS_NEXT_APP_RECORD__ = record;
  3987. const rootId = `${record.id}:root`;
  3988. record.instanceMap.set(rootId, record.rootInstance);
  3989. record.rootInstance.__VUE_DEVTOOLS_NEXT_UID__ = rootId;
  3990. return record;
  3991. } else return {};
  3992. }
  3993. //#endregion
  3994. //#region src/core/iframe/index.ts
  3995. function detectIframeApp(target, inIframe = false) {
  3996. if (inIframe) {
  3997. function sendEventToParent(cb) {
  3998. try {
  3999. const hook = window.parent.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  4000. if (hook) cb(hook);
  4001. } catch (e) {}
  4002. }
  4003. const hook = {
  4004. id: "vue-devtools-next",
  4005. devtoolsVersion: "7.0",
  4006. on: (event, cb) => {
  4007. sendEventToParent((hook) => {
  4008. hook.on(event, cb);
  4009. });
  4010. },
  4011. once: (event, cb) => {
  4012. sendEventToParent((hook) => {
  4013. hook.once(event, cb);
  4014. });
  4015. },
  4016. off: (event, cb) => {
  4017. sendEventToParent((hook) => {
  4018. hook.off(event, cb);
  4019. });
  4020. },
  4021. emit: (event, ...payload) => {
  4022. sendEventToParent((hook) => {
  4023. hook.emit(event, ...payload);
  4024. });
  4025. }
  4026. };
  4027. Object.defineProperty(target, "__VUE_DEVTOOLS_GLOBAL_HOOK__", {
  4028. get() {
  4029. return hook;
  4030. },
  4031. configurable: true
  4032. });
  4033. }
  4034. function injectVueHookToIframe(iframe) {
  4035. if (iframe.__vdevtools__injected) return;
  4036. try {
  4037. iframe.__vdevtools__injected = true;
  4038. const inject = () => {
  4039. try {
  4040. iframe.contentWindow.__VUE_DEVTOOLS_IFRAME__ = iframe;
  4041. const script = iframe.contentDocument.createElement("script");
  4042. script.textContent = `;(${detectIframeApp.toString()})(window, true)`;
  4043. iframe.contentDocument.documentElement.appendChild(script);
  4044. script.parentNode.removeChild(script);
  4045. } catch (e) {}
  4046. };
  4047. inject();
  4048. iframe.addEventListener("load", () => inject());
  4049. } catch (e) {}
  4050. }
  4051. function injectVueHookToIframes() {
  4052. if (typeof window === "undefined") return;
  4053. const iframes = Array.from(document.querySelectorAll("iframe:not([data-vue-devtools-ignore])"));
  4054. for (const iframe of iframes) injectVueHookToIframe(iframe);
  4055. }
  4056. injectVueHookToIframes();
  4057. let iframeAppChecks = 0;
  4058. const iframeAppCheckTimer = setInterval(() => {
  4059. injectVueHookToIframes();
  4060. iframeAppChecks++;
  4061. if (iframeAppChecks >= 5) clearInterval(iframeAppCheckTimer);
  4062. }, 1e3);
  4063. }
  4064. //#endregion
  4065. //#region src/core/index.ts
  4066. function initDevTools() {
  4067. detectIframeApp(target);
  4068. updateDevToolsState({ vitePluginDetected: getDevToolsEnv().vitePluginDetected });
  4069. const isDevToolsNext = target.__VUE_DEVTOOLS_GLOBAL_HOOK__?.id === "vue-devtools-next";
  4070. if (target.__VUE_DEVTOOLS_GLOBAL_HOOK__ && isDevToolsNext) return;
  4071. const _devtoolsHook = createDevToolsHook();
  4072. if (target.__VUE_DEVTOOLS_HOOK_REPLAY__) try {
  4073. target.__VUE_DEVTOOLS_HOOK_REPLAY__.forEach((cb) => cb(_devtoolsHook));
  4074. target.__VUE_DEVTOOLS_HOOK_REPLAY__ = [];
  4075. } catch (e) {
  4076. console.error("[vue-devtools] Error during hook replay", e);
  4077. }
  4078. _devtoolsHook.once("init", (Vue) => {
  4079. target.__VUE_DEVTOOLS_VUE2_APP_DETECTED__ = true;
  4080. console.log("%c[_____Vue DevTools v7 log_____]", "color: red; font-bold: 600; font-size: 16px;");
  4081. console.log("%cVue DevTools v7 detected in your Vue2 project. v7 only supports Vue3 and will not work.", "font-bold: 500; font-size: 14px;");
  4082. const legacyChromeUrl = "https://chromewebstore.google.com/detail/vuejs-devtools/iaajmlceplecbljialhhkmedjlpdblhp";
  4083. const legacyFirefoxUrl = "https://addons.mozilla.org/firefox/addon/vue-js-devtools-v6-legacy";
  4084. console.log(`%cThe legacy version of chrome extension that supports both Vue 2 and Vue 3 has been moved to %c ${legacyChromeUrl}`, "font-size: 14px;", "text-decoration: underline; cursor: pointer;font-size: 14px;");
  4085. console.log(`%cThe legacy version of firefox extension that supports both Vue 2 and Vue 3 has been moved to %c ${legacyFirefoxUrl}`, "font-size: 14px;", "text-decoration: underline; cursor: pointer;font-size: 14px;");
  4086. console.log("%cPlease install and enable only the legacy version for your Vue2 app.", "font-bold: 500; font-size: 14px;");
  4087. console.log("%c[_____Vue DevTools v7 log_____]", "color: red; font-bold: 600; font-size: 16px;");
  4088. });
  4089. hook.on.setupDevtoolsPlugin((pluginDescriptor, setupFn) => {
  4090. addDevToolsPluginToBuffer(pluginDescriptor, setupFn);
  4091. const { app } = activeAppRecord ?? {};
  4092. if (pluginDescriptor.settings) initPluginSettings(pluginDescriptor.id, pluginDescriptor.settings);
  4093. if (!app) return;
  4094. callDevToolsPluginSetupFn([pluginDescriptor, setupFn], app);
  4095. });
  4096. onLegacyDevToolsPluginApiAvailable(() => {
  4097. devtoolsPluginBuffer.filter(([item]) => item.id !== "components").forEach(([pluginDescriptor, setupFn]) => {
  4098. _devtoolsHook.emit(DevToolsHooks.SETUP_DEVTOOLS_PLUGIN, pluginDescriptor, setupFn, { target: "legacy" });
  4099. });
  4100. });
  4101. hook.on.vueAppInit(async (app, version, types) => {
  4102. const normalizedAppRecord = {
  4103. ...createAppRecord(app, types),
  4104. app,
  4105. version
  4106. };
  4107. addDevToolsAppRecord(normalizedAppRecord);
  4108. if (devtoolsAppRecords.value.length === 1) {
  4109. setActiveAppRecord(normalizedAppRecord);
  4110. setActiveAppRecordId(normalizedAppRecord.id);
  4111. normalizeRouterInfo(normalizedAppRecord, activeAppRecord);
  4112. registerDevToolsPlugin(normalizedAppRecord.app);
  4113. }
  4114. setupDevToolsPlugin(...createComponentsDevToolsPlugin(normalizedAppRecord.app));
  4115. updateDevToolsState({ connected: true });
  4116. _devtoolsHook.apps.push(app);
  4117. });
  4118. hook.on.vueAppUnmount(async (app) => {
  4119. const activeRecords = devtoolsAppRecords.value.filter((appRecord) => appRecord.app !== app);
  4120. if (activeRecords.length === 0) updateDevToolsState({ connected: false });
  4121. removeDevToolsAppRecord(app);
  4122. removeAppRecordId(app);
  4123. if (activeAppRecord.value.app === app) {
  4124. setActiveAppRecord(activeRecords[0]);
  4125. devtoolsContext.hooks.callHook(DevToolsMessagingHookKeys.SEND_ACTIVE_APP_UNMOUNTED_TO_CLIENT);
  4126. }
  4127. target.__VUE_DEVTOOLS_GLOBAL_HOOK__.apps.splice(target.__VUE_DEVTOOLS_GLOBAL_HOOK__.apps.indexOf(app), 1);
  4128. removeRegisteredPluginApp(app);
  4129. });
  4130. subscribeDevToolsHook(_devtoolsHook);
  4131. if (!target.__VUE_DEVTOOLS_GLOBAL_HOOK__) Object.defineProperty(target, "__VUE_DEVTOOLS_GLOBAL_HOOK__", {
  4132. get() {
  4133. return _devtoolsHook;
  4134. },
  4135. configurable: true
  4136. });
  4137. else if (!isNuxtApp) Object.assign(__VUE_DEVTOOLS_GLOBAL_HOOK__, _devtoolsHook);
  4138. }
  4139. function onDevToolsClientConnected(fn) {
  4140. return new Promise((resolve) => {
  4141. if (devtoolsState.connected && devtoolsState.clientConnected) {
  4142. fn();
  4143. resolve();
  4144. return;
  4145. }
  4146. devtoolsContext.hooks.hook(DevToolsMessagingHookKeys.DEVTOOLS_CONNECTED_UPDATED, ({ state }) => {
  4147. if (state.connected && state.clientConnected) {
  4148. fn();
  4149. resolve();
  4150. }
  4151. });
  4152. });
  4153. }
  4154. //#endregion
  4155. //#region src/core/high-perf-mode/index.ts
  4156. function toggleHighPerfMode(state) {
  4157. devtoolsState.highPerfModeEnabled = state ?? !devtoolsState.highPerfModeEnabled;
  4158. if (!state && activeAppRecord.value) registerDevToolsPlugin(activeAppRecord.value.app);
  4159. }
  4160. //#endregion
  4161. //#region src/core/component/state/reviver.ts
  4162. function reviveSet(val) {
  4163. const result = /* @__PURE__ */ new Set();
  4164. const list = val._custom.value;
  4165. for (let i = 0; i < list.length; i++) {
  4166. const value = list[i];
  4167. result.add(revive(value));
  4168. }
  4169. return result;
  4170. }
  4171. function reviveMap(val) {
  4172. const result = /* @__PURE__ */ new Map();
  4173. const list = val._custom.value;
  4174. for (let i = 0; i < list.length; i++) {
  4175. const { key, value } = list[i];
  4176. result.set(key, revive(value));
  4177. }
  4178. return result;
  4179. }
  4180. function revive(val) {
  4181. if (val === "__vue_devtool_undefined__") return;
  4182. else if (val === "__vue_devtool_infinity__") return Number.POSITIVE_INFINITY;
  4183. else if (val === "__vue_devtool_negative_infinity__") return Number.NEGATIVE_INFINITY;
  4184. else if (val === "__vue_devtool_nan__") return NaN;
  4185. else if (val && val._custom) {
  4186. const { _custom: custom } = val;
  4187. if (custom.type === "component") return activeAppRecord.value.instanceMap.get(custom.id);
  4188. else if (custom.type === "map") return reviveMap(val);
  4189. else if (custom.type === "set") return reviveSet(val);
  4190. else if (custom.type === "bigint") return BigInt(custom.value);
  4191. else return revive(custom.value);
  4192. } else if (symbolRE.test(val)) {
  4193. const [, string] = symbolRE.exec(val);
  4194. return Symbol.for(string);
  4195. } else if (specialTypeRE.test(val)) {
  4196. const [, type, string, , details] = specialTypeRE.exec(val);
  4197. const result = new target[type](string);
  4198. if (type === "Error" && details) result.stack = details;
  4199. return result;
  4200. } else return val;
  4201. }
  4202. function reviver(key, value) {
  4203. return revive(value);
  4204. }
  4205. //#endregion
  4206. //#region src/core/component/state/format.ts
  4207. function getInspectorStateValueType(value, raw = true) {
  4208. const type = typeof value;
  4209. if (value == null || value === "__vue_devtool_undefined__" || value === "undefined") return "null";
  4210. else if (type === "boolean" || type === "number" || value === "__vue_devtool_infinity__" || value === "__vue_devtool_negative_infinity__" || value === "__vue_devtool_nan__") return "literal";
  4211. else if (value?._custom) if (raw || value._custom.display != null || value._custom.displayText != null) return "custom";
  4212. else return getInspectorStateValueType(value._custom.value);
  4213. else if (typeof value === "string") {
  4214. const typeMatch = specialTypeRE.exec(value);
  4215. if (typeMatch) {
  4216. const [, type] = typeMatch;
  4217. return `native ${type}`;
  4218. } else return "string";
  4219. } else if (Array.isArray(value) || value?._isArray) return "array";
  4220. else if (isPlainObject(value)) return "plain-object";
  4221. else return "unknown";
  4222. }
  4223. function formatInspectorStateValue(value, quotes = false, options) {
  4224. const { customClass } = options ?? {};
  4225. let result;
  4226. const type = getInspectorStateValueType(value, false);
  4227. if (type !== "custom" && value?._custom) value = value._custom.value;
  4228. if (result = internalStateTokenToString(value)) return result;
  4229. else if (type === "custom") return value._custom.value?._custom && formatInspectorStateValue(value._custom.value, quotes, options) || value._custom.displayText || value._custom.display;
  4230. else if (type === "array") return `Array[${value.length}]`;
  4231. else if (type === "plain-object") return `Object${Object.keys(value).length ? "" : " (empty)"}`;
  4232. else if (type?.includes("native")) return escape(specialTypeRE.exec(value)?.[2]);
  4233. else if (typeof value === "string") {
  4234. const typeMatch = value.match(rawTypeRE);
  4235. if (typeMatch) value = escapeString(typeMatch[1]);
  4236. else if (quotes) value = `<span>"</span>${customClass?.string ? `<span class=${customClass.string}>${escapeString(value)}</span>` : escapeString(value)}<span>"</span>`;
  4237. else value = customClass?.string ? `<span class="${customClass?.string ?? ""}">${escapeString(value)}</span>` : escapeString(value);
  4238. }
  4239. return value;
  4240. }
  4241. function escapeString(value) {
  4242. return escape(value).replace(/ /g, "&nbsp;").replace(/\n/g, "<span>\\n</span>");
  4243. }
  4244. function getRaw(value) {
  4245. let customType;
  4246. const isCustom = getInspectorStateValueType(value) === "custom";
  4247. let inherit = {};
  4248. if (isCustom) {
  4249. const data = value;
  4250. const customValue = data._custom?.value;
  4251. const currentCustomType = data._custom?.type;
  4252. const nestedCustom = typeof customValue === "object" && customValue !== null && "_custom" in customValue ? getRaw(customValue) : {
  4253. inherit: void 0,
  4254. value: void 0,
  4255. customType: void 0
  4256. };
  4257. inherit = nestedCustom.inherit || data._custom?.fields || {};
  4258. value = nestedCustom.value || customValue;
  4259. customType = nestedCustom.customType || currentCustomType;
  4260. }
  4261. if (value && value._isArray) value = value.items;
  4262. return {
  4263. value,
  4264. inherit,
  4265. customType
  4266. };
  4267. }
  4268. function toEdit(value, customType) {
  4269. if (customType === "bigint") return value;
  4270. if (customType === "date") return value;
  4271. return replaceTokenToString(JSON.stringify(value));
  4272. }
  4273. function toSubmit(value, customType) {
  4274. if (customType === "bigint") return BigInt(value);
  4275. if (customType === "date") return new Date(value);
  4276. return JSON.parse(replaceStringToToken(value), reviver);
  4277. }
  4278. //#endregion
  4279. //#region src/core/devtools-client/detected.ts
  4280. function updateDevToolsClientDetected(params) {
  4281. devtoolsState.devtoolsClientDetected = {
  4282. ...devtoolsState.devtoolsClientDetected,
  4283. ...params
  4284. };
  4285. toggleHighPerfMode(!Object.values(devtoolsState.devtoolsClientDetected).some(Boolean));
  4286. }
  4287. target.__VUE_DEVTOOLS_UPDATE_CLIENT_DETECTED__ ??= updateDevToolsClientDetected;
  4288. //#endregion
  4289. //#region ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/double-indexed-kv.js
  4290. var DoubleIndexedKV = class {
  4291. constructor() {
  4292. this.keyToValue = /* @__PURE__ */ new Map();
  4293. this.valueToKey = /* @__PURE__ */ new Map();
  4294. }
  4295. set(key, value) {
  4296. this.keyToValue.set(key, value);
  4297. this.valueToKey.set(value, key);
  4298. }
  4299. getByKey(key) {
  4300. return this.keyToValue.get(key);
  4301. }
  4302. getByValue(value) {
  4303. return this.valueToKey.get(value);
  4304. }
  4305. clear() {
  4306. this.keyToValue.clear();
  4307. this.valueToKey.clear();
  4308. }
  4309. };
  4310. //#endregion
  4311. //#region ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/registry.js
  4312. var Registry = class {
  4313. constructor(generateIdentifier) {
  4314. this.generateIdentifier = generateIdentifier;
  4315. this.kv = new DoubleIndexedKV();
  4316. }
  4317. register(value, identifier) {
  4318. if (this.kv.getByValue(value)) return;
  4319. if (!identifier) identifier = this.generateIdentifier(value);
  4320. this.kv.set(identifier, value);
  4321. }
  4322. clear() {
  4323. this.kv.clear();
  4324. }
  4325. getIdentifier(value) {
  4326. return this.kv.getByValue(value);
  4327. }
  4328. getValue(identifier) {
  4329. return this.kv.getByKey(identifier);
  4330. }
  4331. };
  4332. //#endregion
  4333. //#region ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/class-registry.js
  4334. var ClassRegistry = class extends Registry {
  4335. constructor() {
  4336. super((c) => c.name);
  4337. this.classToAllowedProps = /* @__PURE__ */ new Map();
  4338. }
  4339. register(value, options) {
  4340. if (typeof options === "object") {
  4341. if (options.allowProps) this.classToAllowedProps.set(value, options.allowProps);
  4342. super.register(value, options.identifier);
  4343. } else super.register(value, options);
  4344. }
  4345. getAllowedProps(value) {
  4346. return this.classToAllowedProps.get(value);
  4347. }
  4348. };
  4349. //#endregion
  4350. //#region ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/util.js
  4351. function valuesOfObj(record) {
  4352. if ("values" in Object) return Object.values(record);
  4353. const values = [];
  4354. for (const key in record) if (record.hasOwnProperty(key)) values.push(record[key]);
  4355. return values;
  4356. }
  4357. function find(record, predicate) {
  4358. const values = valuesOfObj(record);
  4359. if ("find" in values) return values.find(predicate);
  4360. const valuesNotNever = values;
  4361. for (let i = 0; i < valuesNotNever.length; i++) {
  4362. const value = valuesNotNever[i];
  4363. if (predicate(value)) return value;
  4364. }
  4365. }
  4366. function forEach(record, run) {
  4367. Object.entries(record).forEach(([key, value]) => run(value, key));
  4368. }
  4369. function includes(arr, value) {
  4370. return arr.indexOf(value) !== -1;
  4371. }
  4372. function findArr(record, predicate) {
  4373. for (let i = 0; i < record.length; i++) {
  4374. const value = record[i];
  4375. if (predicate(value)) return value;
  4376. }
  4377. }
  4378. //#endregion
  4379. //#region ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/custom-transformer-registry.js
  4380. var CustomTransformerRegistry = class {
  4381. constructor() {
  4382. this.transfomers = {};
  4383. }
  4384. register(transformer) {
  4385. this.transfomers[transformer.name] = transformer;
  4386. }
  4387. findApplicable(v) {
  4388. return find(this.transfomers, (transformer) => transformer.isApplicable(v));
  4389. }
  4390. findByName(name) {
  4391. return this.transfomers[name];
  4392. }
  4393. };
  4394. //#endregion
  4395. //#region ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/is.js
  4396. const getType$1 = (payload) => Object.prototype.toString.call(payload).slice(8, -1);
  4397. const isUndefined$1 = (payload) => typeof payload === "undefined";
  4398. const isNull$1 = (payload) => payload === null;
  4399. const isPlainObject$2 = (payload) => {
  4400. if (typeof payload !== "object" || payload === null) return false;
  4401. if (payload === Object.prototype) return false;
  4402. if (Object.getPrototypeOf(payload) === null) return true;
  4403. return Object.getPrototypeOf(payload) === Object.prototype;
  4404. };
  4405. const isEmptyObject = (payload) => isPlainObject$2(payload) && Object.keys(payload).length === 0;
  4406. const isArray$2 = (payload) => Array.isArray(payload);
  4407. const isString = (payload) => typeof payload === "string";
  4408. const isNumber = (payload) => typeof payload === "number" && !isNaN(payload);
  4409. const isBoolean = (payload) => typeof payload === "boolean";
  4410. const isRegExp = (payload) => payload instanceof RegExp;
  4411. const isMap = (payload) => payload instanceof Map;
  4412. const isSet = (payload) => payload instanceof Set;
  4413. const isSymbol = (payload) => getType$1(payload) === "Symbol";
  4414. const isDate = (payload) => payload instanceof Date && !isNaN(payload.valueOf());
  4415. const isError = (payload) => payload instanceof Error;
  4416. const isNaNValue = (payload) => typeof payload === "number" && isNaN(payload);
  4417. const isPrimitive = (payload) => isBoolean(payload) || isNull$1(payload) || isUndefined$1(payload) || isNumber(payload) || isString(payload) || isSymbol(payload);
  4418. const isBigint = (payload) => typeof payload === "bigint";
  4419. const isInfinite = (payload) => payload === Infinity || payload === -Infinity;
  4420. const isTypedArray = (payload) => ArrayBuffer.isView(payload) && !(payload instanceof DataView);
  4421. const isURL = (payload) => payload instanceof URL;
  4422. //#endregion
  4423. //#region ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/pathstringifier.js
  4424. const escapeKey = (key) => key.replace(/\./g, "\\.");
  4425. const stringifyPath = (path) => path.map(String).map(escapeKey).join(".");
  4426. const parsePath = (string) => {
  4427. const result = [];
  4428. let segment = "";
  4429. for (let i = 0; i < string.length; i++) {
  4430. let char = string.charAt(i);
  4431. if (char === "\\" && string.charAt(i + 1) === ".") {
  4432. segment += ".";
  4433. i++;
  4434. continue;
  4435. }
  4436. if (char === ".") {
  4437. result.push(segment);
  4438. segment = "";
  4439. continue;
  4440. }
  4441. segment += char;
  4442. }
  4443. const lastSegment = segment;
  4444. result.push(lastSegment);
  4445. return result;
  4446. };
  4447. //#endregion
  4448. //#region ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/transformer.js
  4449. function simpleTransformation(isApplicable, annotation, transform, untransform) {
  4450. return {
  4451. isApplicable,
  4452. annotation,
  4453. transform,
  4454. untransform
  4455. };
  4456. }
  4457. const simpleRules = [
  4458. simpleTransformation(isUndefined$1, "undefined", () => null, () => void 0),
  4459. simpleTransformation(isBigint, "bigint", (v) => v.toString(), (v) => {
  4460. if (typeof BigInt !== "undefined") return BigInt(v);
  4461. console.error("Please add a BigInt polyfill.");
  4462. return v;
  4463. }),
  4464. simpleTransformation(isDate, "Date", (v) => v.toISOString(), (v) => new Date(v)),
  4465. simpleTransformation(isError, "Error", (v, superJson) => {
  4466. const baseError = {
  4467. name: v.name,
  4468. message: v.message
  4469. };
  4470. superJson.allowedErrorProps.forEach((prop) => {
  4471. baseError[prop] = v[prop];
  4472. });
  4473. return baseError;
  4474. }, (v, superJson) => {
  4475. const e = new Error(v.message);
  4476. e.name = v.name;
  4477. e.stack = v.stack;
  4478. superJson.allowedErrorProps.forEach((prop) => {
  4479. e[prop] = v[prop];
  4480. });
  4481. return e;
  4482. }),
  4483. simpleTransformation(isRegExp, "regexp", (v) => "" + v, (regex) => {
  4484. const body = regex.slice(1, regex.lastIndexOf("/"));
  4485. const flags = regex.slice(regex.lastIndexOf("/") + 1);
  4486. return new RegExp(body, flags);
  4487. }),
  4488. simpleTransformation(isSet, "set", (v) => [...v.values()], (v) => new Set(v)),
  4489. simpleTransformation(isMap, "map", (v) => [...v.entries()], (v) => new Map(v)),
  4490. simpleTransformation((v) => isNaNValue(v) || isInfinite(v), "number", (v) => {
  4491. if (isNaNValue(v)) return "NaN";
  4492. if (v > 0) return "Infinity";
  4493. else return "-Infinity";
  4494. }, Number),
  4495. simpleTransformation((v) => v === 0 && 1 / v === -Infinity, "number", () => {
  4496. return "-0";
  4497. }, Number),
  4498. simpleTransformation(isURL, "URL", (v) => v.toString(), (v) => new URL(v))
  4499. ];
  4500. function compositeTransformation(isApplicable, annotation, transform, untransform) {
  4501. return {
  4502. isApplicable,
  4503. annotation,
  4504. transform,
  4505. untransform
  4506. };
  4507. }
  4508. const symbolRule = compositeTransformation((s, superJson) => {
  4509. if (isSymbol(s)) return !!superJson.symbolRegistry.getIdentifier(s);
  4510. return false;
  4511. }, (s, superJson) => {
  4512. return ["symbol", superJson.symbolRegistry.getIdentifier(s)];
  4513. }, (v) => v.description, (_, a, superJson) => {
  4514. const value = superJson.symbolRegistry.getValue(a[1]);
  4515. if (!value) throw new Error("Trying to deserialize unknown symbol");
  4516. return value;
  4517. });
  4518. const constructorToName = [
  4519. Int8Array,
  4520. Uint8Array,
  4521. Int16Array,
  4522. Uint16Array,
  4523. Int32Array,
  4524. Uint32Array,
  4525. Float32Array,
  4526. Float64Array,
  4527. Uint8ClampedArray
  4528. ].reduce((obj, ctor) => {
  4529. obj[ctor.name] = ctor;
  4530. return obj;
  4531. }, {});
  4532. const typedArrayRule = compositeTransformation(isTypedArray, (v) => ["typed-array", v.constructor.name], (v) => [...v], (v, a) => {
  4533. const ctor = constructorToName[a[1]];
  4534. if (!ctor) throw new Error("Trying to deserialize unknown typed array");
  4535. return new ctor(v);
  4536. });
  4537. function isInstanceOfRegisteredClass(potentialClass, superJson) {
  4538. if (potentialClass?.constructor) return !!superJson.classRegistry.getIdentifier(potentialClass.constructor);
  4539. return false;
  4540. }
  4541. const classRule = compositeTransformation(isInstanceOfRegisteredClass, (clazz, superJson) => {
  4542. return ["class", superJson.classRegistry.getIdentifier(clazz.constructor)];
  4543. }, (clazz, superJson) => {
  4544. const allowedProps = superJson.classRegistry.getAllowedProps(clazz.constructor);
  4545. if (!allowedProps) return { ...clazz };
  4546. const result = {};
  4547. allowedProps.forEach((prop) => {
  4548. result[prop] = clazz[prop];
  4549. });
  4550. return result;
  4551. }, (v, a, superJson) => {
  4552. const clazz = superJson.classRegistry.getValue(a[1]);
  4553. if (!clazz) throw new Error(`Trying to deserialize unknown class '${a[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
  4554. return Object.assign(Object.create(clazz.prototype), v);
  4555. });
  4556. const customRule = compositeTransformation((value, superJson) => {
  4557. return !!superJson.customTransformerRegistry.findApplicable(value);
  4558. }, (value, superJson) => {
  4559. return ["custom", superJson.customTransformerRegistry.findApplicable(value).name];
  4560. }, (value, superJson) => {
  4561. return superJson.customTransformerRegistry.findApplicable(value).serialize(value);
  4562. }, (v, a, superJson) => {
  4563. const transformer = superJson.customTransformerRegistry.findByName(a[1]);
  4564. if (!transformer) throw new Error("Trying to deserialize unknown custom value");
  4565. return transformer.deserialize(v);
  4566. });
  4567. const compositeRules = [
  4568. classRule,
  4569. symbolRule,
  4570. customRule,
  4571. typedArrayRule
  4572. ];
  4573. const transformValue = (value, superJson) => {
  4574. const applicableCompositeRule = findArr(compositeRules, (rule) => rule.isApplicable(value, superJson));
  4575. if (applicableCompositeRule) return {
  4576. value: applicableCompositeRule.transform(value, superJson),
  4577. type: applicableCompositeRule.annotation(value, superJson)
  4578. };
  4579. const applicableSimpleRule = findArr(simpleRules, (rule) => rule.isApplicable(value, superJson));
  4580. if (applicableSimpleRule) return {
  4581. value: applicableSimpleRule.transform(value, superJson),
  4582. type: applicableSimpleRule.annotation
  4583. };
  4584. };
  4585. const simpleRulesByAnnotation = {};
  4586. simpleRules.forEach((rule) => {
  4587. simpleRulesByAnnotation[rule.annotation] = rule;
  4588. });
  4589. const untransformValue = (json, type, superJson) => {
  4590. if (isArray$2(type)) switch (type[0]) {
  4591. case "symbol": return symbolRule.untransform(json, type, superJson);
  4592. case "class": return classRule.untransform(json, type, superJson);
  4593. case "custom": return customRule.untransform(json, type, superJson);
  4594. case "typed-array": return typedArrayRule.untransform(json, type, superJson);
  4595. default: throw new Error("Unknown transformation: " + type);
  4596. }
  4597. else {
  4598. const transformation = simpleRulesByAnnotation[type];
  4599. if (!transformation) throw new Error("Unknown transformation: " + type);
  4600. return transformation.untransform(json, superJson);
  4601. }
  4602. };
  4603. //#endregion
  4604. //#region ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/accessDeep.js
  4605. const getNthKey = (value, n) => {
  4606. if (n > value.size) throw new Error("index out of bounds");
  4607. const keys = value.keys();
  4608. while (n > 0) {
  4609. keys.next();
  4610. n--;
  4611. }
  4612. return keys.next().value;
  4613. };
  4614. function validatePath(path) {
  4615. if (includes(path, "__proto__")) throw new Error("__proto__ is not allowed as a property");
  4616. if (includes(path, "prototype")) throw new Error("prototype is not allowed as a property");
  4617. if (includes(path, "constructor")) throw new Error("constructor is not allowed as a property");
  4618. }
  4619. const getDeep = (object, path) => {
  4620. validatePath(path);
  4621. for (let i = 0; i < path.length; i++) {
  4622. const key = path[i];
  4623. if (isSet(object)) object = getNthKey(object, +key);
  4624. else if (isMap(object)) {
  4625. const row = +key;
  4626. const type = +path[++i] === 0 ? "key" : "value";
  4627. const keyOfRow = getNthKey(object, row);
  4628. switch (type) {
  4629. case "key":
  4630. object = keyOfRow;
  4631. break;
  4632. case "value":
  4633. object = object.get(keyOfRow);
  4634. break;
  4635. }
  4636. } else object = object[key];
  4637. }
  4638. return object;
  4639. };
  4640. const setDeep = (object, path, mapper) => {
  4641. validatePath(path);
  4642. if (path.length === 0) return mapper(object);
  4643. let parent = object;
  4644. for (let i = 0; i < path.length - 1; i++) {
  4645. const key = path[i];
  4646. if (isArray$2(parent)) {
  4647. const index = +key;
  4648. parent = parent[index];
  4649. } else if (isPlainObject$2(parent)) parent = parent[key];
  4650. else if (isSet(parent)) {
  4651. const row = +key;
  4652. parent = getNthKey(parent, row);
  4653. } else if (isMap(parent)) {
  4654. if (i === path.length - 2) break;
  4655. const row = +key;
  4656. const type = +path[++i] === 0 ? "key" : "value";
  4657. const keyOfRow = getNthKey(parent, row);
  4658. switch (type) {
  4659. case "key":
  4660. parent = keyOfRow;
  4661. break;
  4662. case "value":
  4663. parent = parent.get(keyOfRow);
  4664. break;
  4665. }
  4666. }
  4667. }
  4668. const lastKey = path[path.length - 1];
  4669. if (isArray$2(parent)) parent[+lastKey] = mapper(parent[+lastKey]);
  4670. else if (isPlainObject$2(parent)) parent[lastKey] = mapper(parent[lastKey]);
  4671. if (isSet(parent)) {
  4672. const oldValue = getNthKey(parent, +lastKey);
  4673. const newValue = mapper(oldValue);
  4674. if (oldValue !== newValue) {
  4675. parent.delete(oldValue);
  4676. parent.add(newValue);
  4677. }
  4678. }
  4679. if (isMap(parent)) {
  4680. const row = +path[path.length - 2];
  4681. const keyToRow = getNthKey(parent, row);
  4682. switch (+lastKey === 0 ? "key" : "value") {
  4683. case "key": {
  4684. const newKey = mapper(keyToRow);
  4685. parent.set(newKey, parent.get(keyToRow));
  4686. if (newKey !== keyToRow) parent.delete(keyToRow);
  4687. break;
  4688. }
  4689. case "value":
  4690. parent.set(keyToRow, mapper(parent.get(keyToRow)));
  4691. break;
  4692. }
  4693. }
  4694. return object;
  4695. };
  4696. //#endregion
  4697. //#region ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/plainer.js
  4698. function traverse(tree, walker, origin = []) {
  4699. if (!tree) return;
  4700. if (!isArray$2(tree)) {
  4701. forEach(tree, (subtree, key) => traverse(subtree, walker, [...origin, ...parsePath(key)]));
  4702. return;
  4703. }
  4704. const [nodeValue, children] = tree;
  4705. if (children) forEach(children, (child, key) => {
  4706. traverse(child, walker, [...origin, ...parsePath(key)]);
  4707. });
  4708. walker(nodeValue, origin);
  4709. }
  4710. function applyValueAnnotations(plain, annotations, superJson) {
  4711. traverse(annotations, (type, path) => {
  4712. plain = setDeep(plain, path, (v) => untransformValue(v, type, superJson));
  4713. });
  4714. return plain;
  4715. }
  4716. function applyReferentialEqualityAnnotations(plain, annotations) {
  4717. function apply(identicalPaths, path) {
  4718. const object = getDeep(plain, parsePath(path));
  4719. identicalPaths.map(parsePath).forEach((identicalObjectPath) => {
  4720. plain = setDeep(plain, identicalObjectPath, () => object);
  4721. });
  4722. }
  4723. if (isArray$2(annotations)) {
  4724. const [root, other] = annotations;
  4725. root.forEach((identicalPath) => {
  4726. plain = setDeep(plain, parsePath(identicalPath), () => plain);
  4727. });
  4728. if (other) forEach(other, apply);
  4729. } else forEach(annotations, apply);
  4730. return plain;
  4731. }
  4732. const isDeep = (object, superJson) => isPlainObject$2(object) || isArray$2(object) || isMap(object) || isSet(object) || isInstanceOfRegisteredClass(object, superJson);
  4733. function addIdentity(object, path, identities) {
  4734. const existingSet = identities.get(object);
  4735. if (existingSet) existingSet.push(path);
  4736. else identities.set(object, [path]);
  4737. }
  4738. function generateReferentialEqualityAnnotations(identitites, dedupe) {
  4739. const result = {};
  4740. let rootEqualityPaths = void 0;
  4741. identitites.forEach((paths) => {
  4742. if (paths.length <= 1) return;
  4743. if (!dedupe) paths = paths.map((path) => path.map(String)).sort((a, b) => a.length - b.length);
  4744. const [representativePath, ...identicalPaths] = paths;
  4745. if (representativePath.length === 0) rootEqualityPaths = identicalPaths.map(stringifyPath);
  4746. else result[stringifyPath(representativePath)] = identicalPaths.map(stringifyPath);
  4747. });
  4748. if (rootEqualityPaths) if (isEmptyObject(result)) return [rootEqualityPaths];
  4749. else return [rootEqualityPaths, result];
  4750. else return isEmptyObject(result) ? void 0 : result;
  4751. }
  4752. const walker = (object, identities, superJson, dedupe, path = [], objectsInThisPath = [], seenObjects = /* @__PURE__ */ new Map()) => {
  4753. const primitive = isPrimitive(object);
  4754. if (!primitive) {
  4755. addIdentity(object, path, identities);
  4756. const seen = seenObjects.get(object);
  4757. if (seen) return dedupe ? { transformedValue: null } : seen;
  4758. }
  4759. if (!isDeep(object, superJson)) {
  4760. const transformed = transformValue(object, superJson);
  4761. const result = transformed ? {
  4762. transformedValue: transformed.value,
  4763. annotations: [transformed.type]
  4764. } : { transformedValue: object };
  4765. if (!primitive) seenObjects.set(object, result);
  4766. return result;
  4767. }
  4768. if (includes(objectsInThisPath, object)) return { transformedValue: null };
  4769. const transformationResult = transformValue(object, superJson);
  4770. const transformed = transformationResult?.value ?? object;
  4771. const transformedValue = isArray$2(transformed) ? [] : {};
  4772. const innerAnnotations = {};
  4773. forEach(transformed, (value, index) => {
  4774. if (index === "__proto__" || index === "constructor" || index === "prototype") throw new Error(`Detected property ${index}. This is a prototype pollution risk, please remove it from your object.`);
  4775. const recursiveResult = walker(value, identities, superJson, dedupe, [...path, index], [...objectsInThisPath, object], seenObjects);
  4776. transformedValue[index] = recursiveResult.transformedValue;
  4777. if (isArray$2(recursiveResult.annotations)) innerAnnotations[index] = recursiveResult.annotations;
  4778. else if (isPlainObject$2(recursiveResult.annotations)) forEach(recursiveResult.annotations, (tree, key) => {
  4779. innerAnnotations[escapeKey(index) + "." + key] = tree;
  4780. });
  4781. });
  4782. const result = isEmptyObject(innerAnnotations) ? {
  4783. transformedValue,
  4784. annotations: !!transformationResult ? [transformationResult.type] : void 0
  4785. } : {
  4786. transformedValue,
  4787. annotations: !!transformationResult ? [transformationResult.type, innerAnnotations] : innerAnnotations
  4788. };
  4789. if (!primitive) seenObjects.set(object, result);
  4790. return result;
  4791. };
  4792. //#endregion
  4793. //#region ../../node_modules/.pnpm/is-what@4.1.16/node_modules/is-what/dist/index.js
  4794. function getType(payload) {
  4795. return Object.prototype.toString.call(payload).slice(8, -1);
  4796. }
  4797. function isArray$1(payload) {
  4798. return getType(payload) === "Array";
  4799. }
  4800. function isPlainObject$1(payload) {
  4801. if (getType(payload) !== "Object") return false;
  4802. const prototype = Object.getPrototypeOf(payload);
  4803. return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
  4804. }
  4805. function isNull(payload) {
  4806. return getType(payload) === "Null";
  4807. }
  4808. function isOneOf(a, b, c, d, e) {
  4809. return (value) => a(value) || b(value) || !!c && c(value) || !!d && d(value) || !!e && e(value);
  4810. }
  4811. function isUndefined(payload) {
  4812. return getType(payload) === "Undefined";
  4813. }
  4814. isOneOf(isNull, isUndefined);
  4815. //#endregion
  4816. //#region ../../node_modules/.pnpm/copy-anything@3.0.5/node_modules/copy-anything/dist/index.js
  4817. function assignProp(carry, key, newVal, originalObject, includeNonenumerable) {
  4818. const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable";
  4819. if (propType === "enumerable") carry[key] = newVal;
  4820. if (includeNonenumerable && propType === "nonenumerable") Object.defineProperty(carry, key, {
  4821. value: newVal,
  4822. enumerable: false,
  4823. writable: true,
  4824. configurable: true
  4825. });
  4826. }
  4827. function copy(target, options = {}) {
  4828. if (isArray$1(target)) return target.map((item) => copy(item, options));
  4829. if (!isPlainObject$1(target)) return target;
  4830. const props = Object.getOwnPropertyNames(target);
  4831. const symbols = Object.getOwnPropertySymbols(target);
  4832. return [...props, ...symbols].reduce((carry, key) => {
  4833. if (isArray$1(options.props) && !options.props.includes(key)) return carry;
  4834. const val = target[key];
  4835. assignProp(carry, key, copy(val, options), target, options.nonenumerable);
  4836. return carry;
  4837. }, {});
  4838. }
  4839. //#endregion
  4840. //#region ../../node_modules/.pnpm/superjson@2.2.2/node_modules/superjson/dist/index.js
  4841. var SuperJSON = class {
  4842. /**
  4843. * @param dedupeReferentialEqualities If true, SuperJSON will make sure only one instance of referentially equal objects are serialized and the rest are replaced with `null`.
  4844. */
  4845. constructor({ dedupe = false } = {}) {
  4846. this.classRegistry = new ClassRegistry();
  4847. this.symbolRegistry = new Registry((s) => s.description ?? "");
  4848. this.customTransformerRegistry = new CustomTransformerRegistry();
  4849. this.allowedErrorProps = [];
  4850. this.dedupe = dedupe;
  4851. }
  4852. serialize(object) {
  4853. const identities = /* @__PURE__ */ new Map();
  4854. const output = walker(object, identities, this, this.dedupe);
  4855. const res = { json: output.transformedValue };
  4856. if (output.annotations) res.meta = {
  4857. ...res.meta,
  4858. values: output.annotations
  4859. };
  4860. const equalityAnnotations = generateReferentialEqualityAnnotations(identities, this.dedupe);
  4861. if (equalityAnnotations) res.meta = {
  4862. ...res.meta,
  4863. referentialEqualities: equalityAnnotations
  4864. };
  4865. return res;
  4866. }
  4867. deserialize(payload) {
  4868. const { json, meta } = payload;
  4869. let result = copy(json);
  4870. if (meta?.values) result = applyValueAnnotations(result, meta.values, this);
  4871. if (meta?.referentialEqualities) result = applyReferentialEqualityAnnotations(result, meta.referentialEqualities);
  4872. return result;
  4873. }
  4874. stringify(object) {
  4875. return JSON.stringify(this.serialize(object));
  4876. }
  4877. parse(string) {
  4878. return this.deserialize(JSON.parse(string));
  4879. }
  4880. registerClass(v, options) {
  4881. this.classRegistry.register(v, options);
  4882. }
  4883. registerSymbol(v, identifier) {
  4884. this.symbolRegistry.register(v, identifier);
  4885. }
  4886. registerCustom(transformer, name) {
  4887. this.customTransformerRegistry.register({
  4888. name,
  4889. ...transformer
  4890. });
  4891. }
  4892. allowErrorProps(...props) {
  4893. this.allowedErrorProps.push(...props);
  4894. }
  4895. };
  4896. SuperJSON.defaultInstance = new SuperJSON();
  4897. SuperJSON.serialize = SuperJSON.defaultInstance.serialize.bind(SuperJSON.defaultInstance);
  4898. SuperJSON.deserialize = SuperJSON.defaultInstance.deserialize.bind(SuperJSON.defaultInstance);
  4899. SuperJSON.stringify = SuperJSON.defaultInstance.stringify.bind(SuperJSON.defaultInstance);
  4900. SuperJSON.parse = SuperJSON.defaultInstance.parse.bind(SuperJSON.defaultInstance);
  4901. SuperJSON.registerClass = SuperJSON.defaultInstance.registerClass.bind(SuperJSON.defaultInstance);
  4902. SuperJSON.registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(SuperJSON.defaultInstance);
  4903. SuperJSON.registerCustom = SuperJSON.defaultInstance.registerCustom.bind(SuperJSON.defaultInstance);
  4904. SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(SuperJSON.defaultInstance);
  4905. SuperJSON.serialize;
  4906. SuperJSON.deserialize;
  4907. SuperJSON.stringify;
  4908. SuperJSON.parse;
  4909. SuperJSON.registerClass;
  4910. SuperJSON.registerCustom;
  4911. SuperJSON.registerSymbol;
  4912. SuperJSON.allowErrorProps;
  4913. //#endregion
  4914. //#region src/messaging/presets/broadcast-channel/context.ts
  4915. const __DEVTOOLS_KIT_BROADCAST_MESSAGING_EVENT_KEY = "__devtools-kit-broadcast-messaging-event-key__";
  4916. //#endregion
  4917. //#region src/messaging/presets/broadcast-channel/index.ts
  4918. const BROADCAST_CHANNEL_NAME = "__devtools-kit:broadcast-channel__";
  4919. function createBroadcastChannel() {
  4920. const channel = new BroadcastChannel(BROADCAST_CHANNEL_NAME);
  4921. return {
  4922. post: (data) => {
  4923. channel.postMessage(SuperJSON.stringify({
  4924. event: __DEVTOOLS_KIT_BROADCAST_MESSAGING_EVENT_KEY,
  4925. data
  4926. }));
  4927. },
  4928. on: (handler) => {
  4929. channel.onmessage = (event) => {
  4930. const parsed = SuperJSON.parse(event.data);
  4931. if (parsed.event === "__devtools-kit-broadcast-messaging-event-key__") handler(parsed.data);
  4932. };
  4933. }
  4934. };
  4935. }
  4936. //#endregion
  4937. //#region src/messaging/presets/electron/context.ts
  4938. const __ELECTRON_CLIENT_CONTEXT__ = "electron:client-context";
  4939. const __ELECTRON_RPOXY_CONTEXT__ = "electron:proxy-context";
  4940. const __ELECTRON_SERVER_CONTEXT__ = "electron:server-context";
  4941. const __DEVTOOLS_KIT_ELECTRON_MESSAGING_EVENT_KEY__ = {
  4942. CLIENT_TO_PROXY: "client->proxy",
  4943. PROXY_TO_CLIENT: "proxy->client",
  4944. PROXY_TO_SERVER: "proxy->server",
  4945. SERVER_TO_PROXY: "server->proxy"
  4946. };
  4947. function getElectronClientContext() {
  4948. return target[__ELECTRON_CLIENT_CONTEXT__];
  4949. }
  4950. function setElectronClientContext(context) {
  4951. target[__ELECTRON_CLIENT_CONTEXT__] = context;
  4952. }
  4953. function getElectronProxyContext() {
  4954. return target[__ELECTRON_RPOXY_CONTEXT__];
  4955. }
  4956. function setElectronProxyContext(context) {
  4957. target[__ELECTRON_RPOXY_CONTEXT__] = context;
  4958. }
  4959. function getElectronServerContext() {
  4960. return target[__ELECTRON_SERVER_CONTEXT__];
  4961. }
  4962. function setElectronServerContext(context) {
  4963. target[__ELECTRON_SERVER_CONTEXT__] = context;
  4964. }
  4965. //#endregion
  4966. //#region src/messaging/presets/electron/client.ts
  4967. function createElectronClientChannel() {
  4968. const socket = getElectronClientContext();
  4969. return {
  4970. post: (data) => {
  4971. socket.emit(__DEVTOOLS_KIT_ELECTRON_MESSAGING_EVENT_KEY__.CLIENT_TO_PROXY, SuperJSON.stringify(data));
  4972. },
  4973. on: (handler) => {
  4974. socket.on(__DEVTOOLS_KIT_ELECTRON_MESSAGING_EVENT_KEY__.PROXY_TO_CLIENT, (e) => {
  4975. handler(SuperJSON.parse(e));
  4976. });
  4977. }
  4978. };
  4979. }
  4980. //#endregion
  4981. //#region src/messaging/presets/electron/proxy.ts
  4982. function createElectronProxyChannel() {
  4983. const socket = getElectronProxyContext();
  4984. return {
  4985. post: (data) => {},
  4986. on: (handler) => {
  4987. socket.on(__DEVTOOLS_KIT_ELECTRON_MESSAGING_EVENT_KEY__.SERVER_TO_PROXY, (data) => {
  4988. socket.broadcast.emit(__DEVTOOLS_KIT_ELECTRON_MESSAGING_EVENT_KEY__.PROXY_TO_CLIENT, data);
  4989. });
  4990. socket.on(__DEVTOOLS_KIT_ELECTRON_MESSAGING_EVENT_KEY__.CLIENT_TO_PROXY, (data) => {
  4991. socket.broadcast.emit(__DEVTOOLS_KIT_ELECTRON_MESSAGING_EVENT_KEY__.PROXY_TO_SERVER, data);
  4992. });
  4993. }
  4994. };
  4995. }
  4996. //#endregion
  4997. //#region src/messaging/presets/electron/server.ts
  4998. function createElectronServerChannel() {
  4999. const socket = getElectronServerContext();
  5000. return {
  5001. post: (data) => {
  5002. socket.emit(__DEVTOOLS_KIT_ELECTRON_MESSAGING_EVENT_KEY__.SERVER_TO_PROXY, SuperJSON.stringify(data));
  5003. },
  5004. on: (handler) => {
  5005. socket.on(__DEVTOOLS_KIT_ELECTRON_MESSAGING_EVENT_KEY__.PROXY_TO_SERVER, (data) => {
  5006. handler(SuperJSON.parse(data));
  5007. });
  5008. }
  5009. };
  5010. }
  5011. //#endregion
  5012. //#region src/messaging/presets/extension/context.ts
  5013. const __EXTENSION_CLIENT_CONTEXT__ = "electron:client-context";
  5014. const __DEVTOOLS_KIT_EXTENSION_MESSAGING_EVENT_KEY__ = {
  5015. CLIENT_TO_PROXY: "client->proxy",
  5016. PROXY_TO_CLIENT: "proxy->client",
  5017. PROXY_TO_SERVER: "proxy->server",
  5018. SERVER_TO_PROXY: "server->proxy"
  5019. };
  5020. function getExtensionClientContext() {
  5021. return target[__EXTENSION_CLIENT_CONTEXT__];
  5022. }
  5023. function setExtensionClientContext(context) {
  5024. target[__EXTENSION_CLIENT_CONTEXT__] = context;
  5025. }
  5026. //#endregion
  5027. //#region src/messaging/presets/extension/client.ts
  5028. function createExtensionClientChannel() {
  5029. let disconnected = false;
  5030. let port = null;
  5031. let reconnectTimer = null;
  5032. let onMessageHandler = null;
  5033. function connect() {
  5034. try {
  5035. clearTimeout(reconnectTimer);
  5036. port = chrome.runtime.connect({ name: `${chrome.devtools.inspectedWindow.tabId}` });
  5037. setExtensionClientContext(port);
  5038. disconnected = false;
  5039. port?.onMessage.addListener(onMessageHandler);
  5040. port.onDisconnect.addListener(() => {
  5041. disconnected = true;
  5042. port?.onMessage.removeListener(onMessageHandler);
  5043. reconnectTimer = setTimeout(connect, 1e3);
  5044. });
  5045. } catch (e) {
  5046. disconnected = true;
  5047. }
  5048. }
  5049. connect();
  5050. return {
  5051. post: (data) => {
  5052. if (disconnected) return;
  5053. port?.postMessage(SuperJSON.stringify(data));
  5054. },
  5055. on: (handler) => {
  5056. onMessageHandler = (data) => {
  5057. if (disconnected) return;
  5058. handler(SuperJSON.parse(data));
  5059. };
  5060. port?.onMessage.addListener(onMessageHandler);
  5061. }
  5062. };
  5063. }
  5064. //#endregion
  5065. //#region src/messaging/presets/extension/proxy.ts
  5066. function createExtensionProxyChannel() {
  5067. const port = chrome.runtime.connect({ name: "content-script" });
  5068. function sendMessageToUserApp(payload) {
  5069. window.postMessage({
  5070. source: __DEVTOOLS_KIT_EXTENSION_MESSAGING_EVENT_KEY__.PROXY_TO_SERVER,
  5071. payload
  5072. }, "*");
  5073. }
  5074. function sendMessageToDevToolsClient(e) {
  5075. if (e.data && e.data.source === __DEVTOOLS_KIT_EXTENSION_MESSAGING_EVENT_KEY__.SERVER_TO_PROXY) try {
  5076. port.postMessage(e.data.payload);
  5077. } catch (e) {}
  5078. }
  5079. port.onMessage.addListener(sendMessageToUserApp);
  5080. window.addEventListener("message", sendMessageToDevToolsClient);
  5081. port.onDisconnect.addListener(() => {
  5082. window.removeEventListener("message", sendMessageToDevToolsClient);
  5083. sendMessageToUserApp(SuperJSON.stringify({ event: "shutdown" }));
  5084. });
  5085. sendMessageToUserApp(SuperJSON.stringify({ event: "init" }));
  5086. return {
  5087. post: (data) => {},
  5088. on: (handler) => {}
  5089. };
  5090. }
  5091. //#endregion
  5092. //#region src/messaging/presets/extension/server.ts
  5093. function createExtensionServerChannel() {
  5094. return {
  5095. post: (data) => {
  5096. window.postMessage({
  5097. source: __DEVTOOLS_KIT_EXTENSION_MESSAGING_EVENT_KEY__.SERVER_TO_PROXY,
  5098. payload: SuperJSON.stringify(data)
  5099. }, "*");
  5100. },
  5101. on: (handler) => {
  5102. const listener = (event) => {
  5103. if (event.data.source === __DEVTOOLS_KIT_EXTENSION_MESSAGING_EVENT_KEY__.PROXY_TO_SERVER && event.data.payload) handler(SuperJSON.parse(event.data.payload));
  5104. };
  5105. window.addEventListener("message", listener);
  5106. return () => {
  5107. window.removeEventListener("message", listener);
  5108. };
  5109. }
  5110. };
  5111. }
  5112. //#endregion
  5113. //#region src/messaging/presets/iframe/context.ts
  5114. const __DEVTOOLS_KIT_IFRAME_MESSAGING_EVENT_KEY = "__devtools-kit-iframe-messaging-event-key__";
  5115. const __IFRAME_SERVER_CONTEXT__ = "iframe:server-context";
  5116. function getIframeServerContext() {
  5117. return target[__IFRAME_SERVER_CONTEXT__];
  5118. }
  5119. function setIframeServerContext(context) {
  5120. target[__IFRAME_SERVER_CONTEXT__] = context;
  5121. }
  5122. //#endregion
  5123. //#region src/messaging/presets/iframe/client.ts
  5124. function createIframeClientChannel() {
  5125. if (!isBrowser) return {
  5126. post: (data) => {},
  5127. on: (handler) => {}
  5128. };
  5129. return {
  5130. post: (data) => window.parent.postMessage(SuperJSON.stringify({
  5131. event: __DEVTOOLS_KIT_IFRAME_MESSAGING_EVENT_KEY,
  5132. data
  5133. }), "*"),
  5134. on: (handler) => window.addEventListener("message", (event) => {
  5135. try {
  5136. const parsed = SuperJSON.parse(event.data);
  5137. if (event.source === window.parent && parsed.event === "__devtools-kit-iframe-messaging-event-key__") handler(parsed.data);
  5138. } catch (e) {}
  5139. })
  5140. };
  5141. }
  5142. //#endregion
  5143. //#region src/messaging/presets/iframe/server.ts
  5144. function createIframeServerChannel() {
  5145. if (!isBrowser) return {
  5146. post: (data) => {},
  5147. on: (handler) => {}
  5148. };
  5149. return {
  5150. post: (data) => {
  5151. getIframeServerContext()?.contentWindow?.postMessage(SuperJSON.stringify({
  5152. event: __DEVTOOLS_KIT_IFRAME_MESSAGING_EVENT_KEY,
  5153. data
  5154. }), "*");
  5155. },
  5156. on: (handler) => {
  5157. window.addEventListener("message", (event) => {
  5158. const iframe = getIframeServerContext();
  5159. try {
  5160. const parsed = SuperJSON.parse(event.data);
  5161. if (event.source === iframe?.contentWindow && parsed.event === "__devtools-kit-iframe-messaging-event-key__") handler(parsed.data);
  5162. } catch (e) {}
  5163. });
  5164. }
  5165. };
  5166. }
  5167. //#endregion
  5168. //#region src/messaging/presets/vite/context.ts
  5169. const __DEVTOOLS_KIT_VITE_MESSAGING_EVENT_KEY = "__devtools-kit-vite-messaging-event-key__";
  5170. const __VITE_CLIENT_CONTEXT__ = "vite:client-context";
  5171. const __VITE_SERVER_CONTEXT__ = "vite:server-context";
  5172. function getViteClientContext() {
  5173. return target[__VITE_CLIENT_CONTEXT__];
  5174. }
  5175. function setViteClientContext(context) {
  5176. target[__VITE_CLIENT_CONTEXT__] = context;
  5177. }
  5178. function getViteServerContext() {
  5179. return target[__VITE_SERVER_CONTEXT__];
  5180. }
  5181. function setViteServerContext(context) {
  5182. target[__VITE_SERVER_CONTEXT__] = context;
  5183. }
  5184. //#endregion
  5185. //#region src/messaging/presets/vite/client.ts
  5186. function createViteClientChannel() {
  5187. const client = getViteClientContext();
  5188. return {
  5189. post: (data) => {
  5190. client?.send(__DEVTOOLS_KIT_VITE_MESSAGING_EVENT_KEY, SuperJSON.stringify(data));
  5191. },
  5192. on: (handler) => {
  5193. client?.on(__DEVTOOLS_KIT_VITE_MESSAGING_EVENT_KEY, (event) => {
  5194. handler(SuperJSON.parse(event));
  5195. });
  5196. }
  5197. };
  5198. }
  5199. //#endregion
  5200. //#region src/messaging/presets/vite/server.ts
  5201. function createViteServerChannel() {
  5202. const viteServer = getViteServerContext();
  5203. const ws = viteServer.hot ?? viteServer.ws;
  5204. return {
  5205. post: (data) => ws?.send(__DEVTOOLS_KIT_VITE_MESSAGING_EVENT_KEY, SuperJSON.stringify(data)),
  5206. on: (handler) => ws?.on(__DEVTOOLS_KIT_VITE_MESSAGING_EVENT_KEY, (event) => {
  5207. handler(SuperJSON.parse(event));
  5208. })
  5209. };
  5210. }
  5211. //#endregion
  5212. //#region src/messaging/index.ts
  5213. target.__VUE_DEVTOOLS_KIT_MESSAGE_CHANNELS__ ??= [];
  5214. target.__VUE_DEVTOOLS_KIT_RPC_CLIENT__ ??= null;
  5215. target.__VUE_DEVTOOLS_KIT_RPC_SERVER__ ??= null;
  5216. target.__VUE_DEVTOOLS_KIT_VITE_RPC_CLIENT__ ??= null;
  5217. target.__VUE_DEVTOOLS_KIT_VITE_RPC_SERVER__ ??= null;
  5218. target.__VUE_DEVTOOLS_KIT_BROADCAST_RPC_SERVER__ ??= null;
  5219. function setRpcClientToGlobal(rpc) {
  5220. target.__VUE_DEVTOOLS_KIT_RPC_CLIENT__ = rpc;
  5221. }
  5222. function setRpcServerToGlobal(rpc) {
  5223. target.__VUE_DEVTOOLS_KIT_RPC_SERVER__ = rpc;
  5224. }
  5225. function getRpcClient() {
  5226. return target.__VUE_DEVTOOLS_KIT_RPC_CLIENT__;
  5227. }
  5228. function getRpcServer() {
  5229. return target.__VUE_DEVTOOLS_KIT_RPC_SERVER__;
  5230. }
  5231. function setViteRpcClientToGlobal(rpc) {
  5232. target.__VUE_DEVTOOLS_KIT_VITE_RPC_CLIENT__ = rpc;
  5233. }
  5234. function setViteRpcServerToGlobal(rpc) {
  5235. target.__VUE_DEVTOOLS_KIT_VITE_RPC_SERVER__ = rpc;
  5236. }
  5237. function getViteRpcClient() {
  5238. return target.__VUE_DEVTOOLS_KIT_VITE_RPC_CLIENT__;
  5239. }
  5240. function getViteRpcServer() {
  5241. return target.__VUE_DEVTOOLS_KIT_VITE_RPC_SERVER__;
  5242. }
  5243. function getChannel(preset, host = "client") {
  5244. const channel = {
  5245. iframe: {
  5246. client: createIframeClientChannel,
  5247. server: createIframeServerChannel
  5248. }[host],
  5249. electron: {
  5250. client: createElectronClientChannel,
  5251. proxy: createElectronProxyChannel,
  5252. server: createElectronServerChannel
  5253. }[host],
  5254. vite: {
  5255. client: createViteClientChannel,
  5256. server: createViteServerChannel
  5257. }[host],
  5258. broadcast: {
  5259. client: createBroadcastChannel,
  5260. server: createBroadcastChannel
  5261. }[host],
  5262. extension: {
  5263. client: createExtensionClientChannel,
  5264. proxy: createExtensionProxyChannel,
  5265. server: createExtensionServerChannel
  5266. }[host]
  5267. }[preset];
  5268. return channel();
  5269. }
  5270. function createRpcClient(functions, options = {}) {
  5271. const { channel: _channel, options: _options, preset } = options;
  5272. const channel = preset ? getChannel(preset) : _channel;
  5273. const rpc = createBirpc(functions, {
  5274. ..._options,
  5275. ...channel,
  5276. timeout: -1
  5277. });
  5278. if (preset === "vite") {
  5279. setViteRpcClientToGlobal(rpc);
  5280. return;
  5281. }
  5282. setRpcClientToGlobal(rpc);
  5283. return rpc;
  5284. }
  5285. function createRpcServer(functions, options = {}) {
  5286. const { channel: _channel, options: _options, preset } = options;
  5287. const channel = preset ? getChannel(preset, "server") : _channel;
  5288. const rpcServer = getRpcServer();
  5289. if (!rpcServer) {
  5290. const group = createBirpcGroup(functions, [channel], {
  5291. ..._options,
  5292. timeout: -1
  5293. });
  5294. if (preset === "vite") {
  5295. setViteRpcServerToGlobal(group);
  5296. return;
  5297. }
  5298. setRpcServerToGlobal(group);
  5299. } else rpcServer.updateChannels((channels) => {
  5300. channels.push(channel);
  5301. });
  5302. }
  5303. function createRpcProxy(options = {}) {
  5304. const { channel: _channel, options: _options, preset } = options;
  5305. const channel = preset ? getChannel(preset, "proxy") : _channel;
  5306. return createBirpc({}, {
  5307. ..._options,
  5308. ...channel,
  5309. timeout: -1
  5310. });
  5311. }
  5312. //#endregion
  5313. //#region src/core/component/state/custom.ts
  5314. function getFunctionDetails(func) {
  5315. let string = "";
  5316. let matches = null;
  5317. try {
  5318. string = Function.prototype.toString.call(func);
  5319. matches = String.prototype.match.call(string, /\([\s\S]*?\)/);
  5320. } catch (e) {}
  5321. const match = matches && matches[0];
  5322. const args = typeof match === "string" ? match : "(?)";
  5323. return { _custom: {
  5324. type: "function",
  5325. displayText: `<span style="opacity:.8;margin-right:5px;">function</span> <span style="white-space:nowrap;">${escape(typeof func.name === "string" ? func.name : "")}${args}</span>`,
  5326. tooltipText: string.trim() ? `<pre>${escape(string)}</pre>` : null
  5327. } };
  5328. }
  5329. function getBigIntDetails(val) {
  5330. const stringifiedBigInt = BigInt.prototype.toString.call(val);
  5331. return { _custom: {
  5332. type: "bigint",
  5333. displayText: `BigInt(${stringifiedBigInt})`,
  5334. value: stringifiedBigInt
  5335. } };
  5336. }
  5337. function getDateDetails(val) {
  5338. const date = new Date(val.getTime());
  5339. date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
  5340. return { _custom: {
  5341. type: "date",
  5342. displayText: Date.prototype.toString.call(val),
  5343. value: date.toISOString().slice(0, -1)
  5344. } };
  5345. }
  5346. function getMapDetails(val) {
  5347. return { _custom: {
  5348. type: "map",
  5349. displayText: "Map",
  5350. value: Object.fromEntries(val),
  5351. readOnly: true,
  5352. fields: { abstract: true }
  5353. } };
  5354. }
  5355. function getSetDetails(val) {
  5356. const list = Array.from(val);
  5357. return { _custom: {
  5358. type: "set",
  5359. displayText: `Set[${list.length}]`,
  5360. value: list,
  5361. readOnly: true
  5362. } };
  5363. }
  5364. function getCaughtGetters(store) {
  5365. const getters = {};
  5366. const origGetters = store.getters || {};
  5367. const keys = Object.keys(origGetters);
  5368. for (let i = 0; i < keys.length; i++) {
  5369. const key = keys[i];
  5370. Object.defineProperty(getters, key, {
  5371. enumerable: true,
  5372. get: () => {
  5373. try {
  5374. return origGetters[key];
  5375. } catch (e) {
  5376. return e;
  5377. }
  5378. }
  5379. });
  5380. }
  5381. return getters;
  5382. }
  5383. function reduceStateList(list) {
  5384. if (!list.length) return void 0;
  5385. return list.reduce((map, item) => {
  5386. const key = item.type || "data";
  5387. const obj = map[key] = map[key] || {};
  5388. obj[item.key] = item.value;
  5389. return map;
  5390. }, {});
  5391. }
  5392. function namedNodeMapToObject(map) {
  5393. const result = {};
  5394. const l = map.length;
  5395. for (let i = 0; i < l; i++) {
  5396. const node = map.item(i);
  5397. result[node.name] = node.value;
  5398. }
  5399. return result;
  5400. }
  5401. function getStoreDetails(store) {
  5402. return { _custom: {
  5403. type: "store",
  5404. displayText: "Store",
  5405. value: {
  5406. state: store.state,
  5407. getters: getCaughtGetters(store)
  5408. },
  5409. fields: { abstract: true }
  5410. } };
  5411. }
  5412. function getRouterDetails(router) {
  5413. return { _custom: {
  5414. type: "router",
  5415. displayText: "VueRouter",
  5416. value: {
  5417. options: router.options,
  5418. currentRoute: router.currentRoute
  5419. },
  5420. fields: { abstract: true }
  5421. } };
  5422. }
  5423. function getInstanceDetails(instance) {
  5424. if (instance._) instance = instance._;
  5425. const state = processInstanceState(instance);
  5426. return { _custom: {
  5427. type: "component",
  5428. id: instance.__VUE_DEVTOOLS_NEXT_UID__,
  5429. displayText: getInstanceName(instance),
  5430. tooltipText: "Component instance",
  5431. value: reduceStateList(state),
  5432. fields: { abstract: true }
  5433. } };
  5434. }
  5435. function getComponentDefinitionDetails(definition) {
  5436. let display = getComponentName(definition);
  5437. if (display) {
  5438. if (definition.name && definition.__file) display += ` <span>(${definition.__file})</span>`;
  5439. } else display = "<i>Unknown Component</i>";
  5440. return { _custom: {
  5441. type: "component-definition",
  5442. displayText: display,
  5443. tooltipText: "Component definition",
  5444. ...definition.__file ? { file: definition.__file } : {}
  5445. } };
  5446. }
  5447. function getHTMLElementDetails(value) {
  5448. try {
  5449. return { _custom: {
  5450. type: "HTMLElement",
  5451. displayText: `<span class="opacity-30">&lt;</span><span class="text-blue-500">${value.tagName.toLowerCase()}</span><span class="opacity-30">&gt;</span>`,
  5452. value: namedNodeMapToObject(value.attributes)
  5453. } };
  5454. } catch (e) {
  5455. return { _custom: {
  5456. type: "HTMLElement",
  5457. displayText: `<span class="text-blue-500">${String(value)}</span>`
  5458. } };
  5459. }
  5460. }
  5461. /**
  5462. * - ObjectRefImpl, toRef({ foo: 'foo' }, 'foo'), `_value` is the actual value, (since 3.5.0)
  5463. * - GetterRefImpl, toRef(() => state.foo), `_value` is the actual value, (since 3.5.0)
  5464. * - RefImpl, ref('foo') / computed(() => 'foo'), `_value` is the actual value
  5465. */
  5466. function tryGetRefValue(ref) {
  5467. if (ensurePropertyExists(ref, "_value", true)) return ref._value;
  5468. if (ensurePropertyExists(ref, "value", true)) return ref.value;
  5469. }
  5470. function getObjectDetails(object) {
  5471. const info = getSetupStateType(object);
  5472. if (info.ref || info.computed || info.reactive) {
  5473. const stateTypeName = info.computed ? "Computed" : info.ref ? "Ref" : info.reactive ? "Reactive" : null;
  5474. const value = toRaw(info.reactive ? object : tryGetRefValue(object));
  5475. const raw = ensurePropertyExists(object, "effect") ? object.effect?.raw?.toString() || object.effect?.fn?.toString() : null;
  5476. return { _custom: {
  5477. type: stateTypeName?.toLowerCase(),
  5478. stateTypeName,
  5479. value,
  5480. ...raw ? { tooltipText: `<pre>${escape(raw)}</pre>` } : {}
  5481. } };
  5482. }
  5483. if (ensurePropertyExists(object, "__asyncLoader") && typeof object.__asyncLoader === "function") return { _custom: {
  5484. type: "component-definition",
  5485. display: "Async component definition"
  5486. } };
  5487. }
  5488. //#endregion
  5489. //#region src/core/component/state/replacer.ts
  5490. function stringifyReplacer(key, _value, depth, seenInstance) {
  5491. if (key === "compilerOptions") return;
  5492. const val = this[key];
  5493. const type = typeof val;
  5494. if (Array.isArray(val)) {
  5495. const l = val.length;
  5496. if (l > 5e3) return {
  5497. _isArray: true,
  5498. length: l,
  5499. items: val.slice(0, MAX_ARRAY_SIZE)
  5500. };
  5501. return val;
  5502. } else if (typeof val === "string") if (val.length > 1e4) return `${val.substring(0, MAX_STRING_SIZE)}... (${val.length} total length)`;
  5503. else return val;
  5504. else if (type === "undefined") return UNDEFINED;
  5505. else if (val === Number.POSITIVE_INFINITY) return INFINITY;
  5506. else if (val === Number.NEGATIVE_INFINITY) return NEGATIVE_INFINITY;
  5507. else if (typeof val === "function") return getFunctionDetails(val);
  5508. else if (type === "symbol") return `[native Symbol ${Symbol.prototype.toString.call(val)}]`;
  5509. else if (typeof val === "bigint") return getBigIntDetails(val);
  5510. else if (val !== null && typeof val === "object") {
  5511. const proto = Object.prototype.toString.call(val);
  5512. if (proto === "[object Map]") return getMapDetails(val);
  5513. else if (proto === "[object Set]") return getSetDetails(val);
  5514. else if (proto === "[object RegExp]") return `[native RegExp ${RegExp.prototype.toString.call(val)}]`;
  5515. else if (proto === "[object Date]") return getDateDetails(val);
  5516. else if (proto === "[object Error]") return `[native Error ${val.message}<>${val.stack}]`;
  5517. else if (ensurePropertyExists(val, "state", true) && ensurePropertyExists(val, "_vm", true)) return getStoreDetails(val);
  5518. else if (val.constructor && val.constructor.name === "VueRouter") return getRouterDetails(val);
  5519. else if (isVueInstance(val)) {
  5520. const componentVal = getInstanceDetails(val);
  5521. const parentInstanceDepth = seenInstance?.get(val);
  5522. if (parentInstanceDepth && parentInstanceDepth < depth) return `[[CircularRef]] <${componentVal._custom.displayText}>`;
  5523. seenInstance?.set(val, depth);
  5524. return componentVal;
  5525. } else if (ensurePropertyExists(val, "render", true) && typeof val.render === "function") return getComponentDefinitionDetails(val);
  5526. else if (val.constructor && val.constructor.name === "VNode") return `[native VNode <${val.tag}>]`;
  5527. else if (typeof HTMLElement !== "undefined" && val instanceof HTMLElement) return getHTMLElementDetails(val);
  5528. else if (val.constructor?.name === "Store" && "_wrappedGetters" in val) return "[object Store]";
  5529. else if (ensurePropertyExists(val, "currentRoute", true)) return "[object Router]";
  5530. const customDetails = getObjectDetails(val);
  5531. if (customDetails != null) return customDetails;
  5532. } else if (Number.isNaN(val)) return NAN;
  5533. return sanitize(val);
  5534. }
  5535. //#endregion
  5536. //#region src/shared/transfer.ts
  5537. const MAX_SERIALIZED_SIZE = 2 * 1024 * 1024;
  5538. function isObject(_data, proto) {
  5539. return proto === "[object Object]";
  5540. }
  5541. function isArray(_data, proto) {
  5542. return proto === "[object Array]";
  5543. }
  5544. function isVueReactiveLinkNode(node) {
  5545. const constructorName = node?.constructor?.name;
  5546. return constructorName === "Dep" && "activeLink" in node || constructorName === "Link" && "dep" in node;
  5547. }
  5548. /**
  5549. * This function is used to serialize object with handling circular references.
  5550. *
  5551. * ```ts
  5552. * const obj = { a: 1, b: { c: 2 }, d: obj }
  5553. * const result = stringifyCircularAutoChunks(obj) // call `encode` inside
  5554. * console.log(result) // [{"a":1,"b":2,"d":0},1,{"c":4},2]
  5555. * ```
  5556. *
  5557. * Each object is stored in a list and the index is used to reference the object.
  5558. * With seen map, we can check if the object is already stored in the list to avoid circular references.
  5559. *
  5560. * Note: here we have a special case for Vue instance.
  5561. * We check if a vue instance includes itself in its properties and skip it
  5562. * by using `seenVueInstance` and `depth` to avoid infinite loop.
  5563. */
  5564. function encode(data, replacer, list, seen, depth = 0, seenVueInstance = /* @__PURE__ */ new Map()) {
  5565. let stored;
  5566. let key;
  5567. let value;
  5568. let i;
  5569. let l;
  5570. const seenIndex = seen.get(data);
  5571. if (seenIndex != null) return seenIndex;
  5572. const index = list.length;
  5573. const proto = Object.prototype.toString.call(data);
  5574. if (isObject(data, proto)) {
  5575. if (isVueReactiveLinkNode(data)) return index;
  5576. stored = {};
  5577. seen.set(data, index);
  5578. list.push(stored);
  5579. const keys = Object.keys(data);
  5580. for (i = 0, l = keys.length; i < l; i++) {
  5581. key = keys[i];
  5582. if (key === "compilerOptions") return index;
  5583. value = data[key];
  5584. const isVm = value != null && isObject(value, Object.prototype.toString.call(data)) && isVueInstance(value);
  5585. try {
  5586. if (replacer) value = replacer.call(data, key, value, depth, seenVueInstance);
  5587. } catch (e) {
  5588. value = e;
  5589. }
  5590. stored[key] = encode(value, replacer, list, seen, depth + 1, seenVueInstance);
  5591. if (isVm) seenVueInstance.delete(value);
  5592. }
  5593. } else if (isArray(data, proto)) {
  5594. stored = [];
  5595. seen.set(data, index);
  5596. list.push(stored);
  5597. for (i = 0, l = data.length; i < l; i++) {
  5598. try {
  5599. value = data[i];
  5600. if (replacer) value = replacer.call(data, i, value, depth, seenVueInstance);
  5601. } catch (e) {
  5602. value = e;
  5603. }
  5604. stored[i] = encode(value, replacer, list, seen, depth + 1, seenVueInstance);
  5605. }
  5606. } else list.push(data);
  5607. return index;
  5608. }
  5609. function decode(list, reviver = null) {
  5610. let i = list.length;
  5611. let j, k, data, key, value, proto;
  5612. while (i--) {
  5613. data = list[i];
  5614. proto = Object.prototype.toString.call(data);
  5615. if (proto === "[object Object]") {
  5616. const keys = Object.keys(data);
  5617. for (j = 0, k = keys.length; j < k; j++) {
  5618. key = keys[j];
  5619. value = list[data[key]];
  5620. if (reviver) value = reviver.call(data, key, value);
  5621. data[key] = value;
  5622. }
  5623. } else if (proto === "[object Array]") for (j = 0, k = data.length; j < k; j++) {
  5624. value = list[data[j]];
  5625. if (reviver) value = reviver.call(data, j, value);
  5626. data[j] = value;
  5627. }
  5628. }
  5629. }
  5630. function stringifyCircularAutoChunks(data, replacer = null, space = null) {
  5631. let result;
  5632. try {
  5633. result = arguments.length === 1 ? JSON.stringify(data) : JSON.stringify(data, (k, v) => replacer?.(k, v)?.call(this), space);
  5634. } catch (e) {
  5635. result = stringifyStrictCircularAutoChunks(data, replacer, space);
  5636. }
  5637. if (result.length > MAX_SERIALIZED_SIZE) {
  5638. const chunkCount = Math.ceil(result.length / MAX_SERIALIZED_SIZE);
  5639. const chunks = [];
  5640. for (let i = 0; i < chunkCount; i++) chunks.push(result.slice(i * MAX_SERIALIZED_SIZE, (i + 1) * MAX_SERIALIZED_SIZE));
  5641. return chunks;
  5642. }
  5643. return result;
  5644. }
  5645. function stringifyStrictCircularAutoChunks(data, replacer = null, space = null) {
  5646. const list = [];
  5647. encode(data, replacer, list, /* @__PURE__ */ new Map());
  5648. return space ? ` ${JSON.stringify(list, null, space)}` : ` ${JSON.stringify(list)}`;
  5649. }
  5650. function parseCircularAutoChunks(data, reviver = null) {
  5651. if (Array.isArray(data)) data = data.join("");
  5652. if (!/^\s/.test(data)) return arguments.length === 1 ? JSON.parse(data) : JSON.parse(data, reviver);
  5653. else {
  5654. const list = JSON.parse(data);
  5655. decode(list, reviver);
  5656. return list[0];
  5657. }
  5658. }
  5659. //#endregion
  5660. //#region src/shared/util.ts
  5661. function stringify(data) {
  5662. return stringifyCircularAutoChunks(data, stringifyReplacer);
  5663. }
  5664. function parse(data, revive = false) {
  5665. if (data == void 0) return {};
  5666. return revive ? parseCircularAutoChunks(data, reviver) : parseCircularAutoChunks(data);
  5667. }
  5668. //#endregion
  5669. //#region src/index.ts
  5670. const devtools = {
  5671. hook,
  5672. init: () => {
  5673. initDevTools();
  5674. },
  5675. get ctx() {
  5676. return devtoolsContext;
  5677. },
  5678. get api() {
  5679. return devtoolsContext.api;
  5680. }
  5681. };
  5682. //#endregion
  5683. export { DevToolsContextHookKeys, DevToolsMessagingHookKeys, DevToolsV6PluginAPIHookKeys, INFINITY, NAN, NEGATIVE_INFINITY, ROUTER_INFO_KEY, ROUTER_KEY, UNDEFINED, activeAppRecord, addCustomCommand, addCustomTab, addDevToolsAppRecord, addDevToolsPluginToBuffer, addInspector, callConnectedUpdatedHook, callDevToolsPluginSetupFn, callInspectorUpdatedHook, callStateUpdatedHook, createComponentsDevToolsPlugin, createDevToolsApi, createDevToolsCtxHooks, createRpcClient, createRpcProxy, createRpcServer, devtools, devtoolsAppRecords, devtoolsContext, devtoolsInspector, devtoolsPluginBuffer, devtoolsRouter, devtoolsRouterInfo, devtoolsState, escape, formatInspectorStateValue, getActiveInspectors, getDevToolsEnv, getExtensionClientContext, getInspector, getInspectorActions, getInspectorInfo, getInspectorNodeActions, getInspectorStateValueType, getRaw, getRpcClient, getRpcServer, getViteRpcClient, getViteRpcServer, initDevTools, isPlainObject, onDevToolsClientConnected, onDevToolsConnected, parse, registerDevToolsPlugin, removeCustomCommand, removeDevToolsAppRecord, removeRegisteredPluginApp, resetDevToolsState, setActiveAppRecord, setActiveAppRecordId, setDevToolsEnv, setElectronClientContext, setElectronProxyContext, setElectronServerContext, setExtensionClientContext, setIframeServerContext, setOpenInEditorBaseUrl, setRpcServerToGlobal, setViteClientContext, setViteRpcClientToGlobal, setViteRpcServerToGlobal, setViteServerContext, setupDevToolsPlugin, stringify, toEdit, toSubmit, toggleClientConnected, toggleComponentInspectorEnabled, toggleHighPerfMode, updateDevToolsClientDetected, updateDevToolsState, updateTimelineLayersState };