@eturnity/eturnity_reusable_components 7.45.4 → 7.45.5--EPDM-12129.6
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/main.es.js +7 -0
- package/dist/main.es10.js +10 -0
- package/dist/main.es100.js +23 -0
- package/dist/main.es101.js +23 -0
- package/dist/main.es102.js +20 -0
- package/dist/main.es103.js +20 -0
- package/dist/main.es104.js +20 -0
- package/dist/main.es105.js +37 -0
- package/dist/main.es106.js +28 -0
- package/dist/main.es107.js +32 -0
- package/dist/main.es108.js +18 -0
- package/dist/main.es109.js +33 -0
- package/dist/main.es11.js +2484 -0
- package/dist/main.es110.js +41 -0
- package/dist/main.es111.js +36 -0
- package/dist/main.es112.js +35 -0
- package/dist/main.es113.js +20 -0
- package/dist/main.es114.js +23 -0
- package/dist/main.es115.js +30 -0
- package/dist/main.es116.js +23 -0
- package/dist/main.es117.js +32 -0
- package/dist/main.es118.js +23 -0
- package/dist/main.es119.js +29 -0
- package/dist/main.es12.js +133 -0
- package/dist/main.es120.js +25 -0
- package/dist/main.es121.js +23 -0
- package/dist/main.es122.js +28 -0
- package/dist/main.es123.js +28 -0
- package/dist/main.es124.js +39 -0
- package/dist/main.es125.js +37 -0
- package/dist/main.es126.js +23 -0
- package/dist/main.es127.js +25 -0
- package/dist/main.es128.js +23 -0
- package/dist/main.es129.js +23 -0
- package/dist/main.es13.js +261 -0
- package/dist/main.es130.js +23 -0
- package/dist/main.es131.js +28 -0
- package/dist/main.es132.js +29 -0
- package/dist/main.es133.js +29 -0
- package/dist/main.es134.js +21 -0
- package/dist/main.es135.js +20 -0
- package/dist/main.es136.js +28 -0
- package/dist/main.es137.js +24 -0
- package/dist/main.es138.js +28 -0
- package/dist/main.es139.js +23 -0
- package/dist/main.es14.js +26 -0
- package/dist/main.es140.js +33 -0
- package/dist/main.es141.js +30 -0
- package/dist/main.es142.js +23 -0
- package/dist/main.es143.js +20 -0
- package/dist/main.es144.js +19 -0
- package/dist/main.es145.js +23 -0
- package/dist/main.es146.js +29 -0
- package/dist/main.es147.js +28 -0
- package/dist/main.es148.js +35 -0
- package/dist/main.es149.js +25 -0
- package/dist/main.es15.js +1058 -0
- package/dist/main.es150.js +25 -0
- package/dist/main.es151.js +23 -0
- package/dist/main.es152.js +41 -0
- package/dist/main.es153.js +41 -0
- package/dist/main.es154.js +25 -0
- package/dist/main.es155.js +23 -0
- package/dist/main.es156.js +23 -0
- package/dist/main.es157.js +25 -0
- package/dist/main.es158.js +23 -0
- package/dist/main.es159.js +23 -0
- package/dist/main.es16.js +692 -0
- package/dist/main.es160.js +23 -0
- package/dist/main.es161.js +23 -0
- package/dist/main.es162.js +23 -0
- package/dist/main.es163.js +23 -0
- package/dist/main.es164.js +20 -0
- package/dist/main.es165.js +28 -0
- package/dist/main.es166.js +28 -0
- package/dist/main.es167.js +28 -0
- package/dist/main.es168.js +28 -0
- package/dist/main.es169.js +25 -0
- package/dist/main.es17.js +95 -0
- package/dist/main.es170.js +23 -0
- package/dist/main.es171.js +23 -0
- package/dist/main.es172.js +20 -0
- package/dist/main.es173.js +20 -0
- package/dist/main.es174.js +23 -0
- package/dist/main.es175.js +18 -0
- package/dist/main.es176.js +23 -0
- package/dist/main.es177.js +20 -0
- package/dist/main.es178.js +25 -0
- package/dist/main.es179.js +25 -0
- package/dist/main.es18.js +78 -0
- package/dist/main.es180.js +23 -0
- package/dist/main.es181.js +23 -0
- package/dist/main.es182.js +20 -0
- package/dist/main.es183.js +23 -0
- package/dist/main.es184.js +23 -0
- package/dist/main.es185.js +32 -0
- package/dist/main.es186.js +23 -0
- package/dist/main.es187.js +32 -0
- package/dist/main.es188.js +37 -0
- package/dist/main.es189.js +32 -0
- package/dist/main.es19.js +143 -0
- package/dist/main.es190.js +39 -0
- package/dist/main.es191.js +28 -0
- package/dist/main.es192.js +20 -0
- package/dist/main.es193.js +20 -0
- package/dist/main.es194.js +25 -0
- package/dist/main.es195.js +23 -0
- package/dist/main.es196.js +40 -0
- package/dist/main.es197.js +23 -0
- package/dist/main.es198.js +21 -0
- package/dist/main.es199.js +19 -0
- package/dist/main.es2.js +34 -0
- package/dist/main.es20.js +152 -0
- package/dist/main.es200.js +20 -0
- package/dist/main.es201.js +20 -0
- package/dist/main.es202.js +33 -0
- package/dist/main.es203.js +23 -0
- package/dist/main.es204.js +23 -0
- package/dist/main.es205.js +28 -0
- package/dist/main.es206.js +23 -0
- package/dist/main.es207.js +23 -0
- package/dist/main.es208.js +21 -0
- package/dist/main.es209.js +23 -0
- package/dist/main.es21.js +108 -0
- package/dist/main.es210.js +28 -0
- package/dist/main.es211.js +23 -0
- package/dist/main.es212.js +23 -0
- package/dist/main.es213.js +23 -0
- package/dist/main.es214.js +28 -0
- package/dist/main.es215.js +28 -0
- package/dist/main.es216.js +20 -0
- package/dist/main.es217.js +23 -0
- package/dist/main.es218.js +35 -0
- package/dist/main.es219.js +28 -0
- package/dist/main.es22.js +4 -0
- package/dist/main.es220.js +29 -0
- package/dist/main.es221.js +24 -0
- package/dist/main.es222.js +23 -0
- package/dist/main.es223.js +28 -0
- package/dist/main.es224.js +25 -0
- package/dist/main.es225.js +23 -0
- package/dist/main.es226.js +23 -0
- package/dist/main.es227.js +20 -0
- package/dist/main.es228.js +20 -0
- package/dist/main.es229.js +23 -0
- package/dist/main.es23.js +169 -0
- package/dist/main.es230.js +23 -0
- package/dist/main.es231.js +25 -0
- package/dist/main.es232.js +38 -0
- package/dist/main.es233.js +30 -0
- package/dist/main.es234.js +28 -0
- package/dist/main.es235.js +23 -0
- package/dist/main.es236.js +22 -0
- package/dist/main.es237.js +28 -0
- package/dist/main.es238.js +23 -0
- package/dist/main.es239.js +18 -0
- package/dist/main.es24.js +201 -0
- package/dist/main.es240.js +23 -0
- package/dist/main.es241.js +25 -0
- package/dist/main.es242.js +23 -0
- package/dist/main.es243.js +23 -0
- package/dist/main.es244.js +23 -0
- package/dist/main.es245.js +23 -0
- package/dist/main.es246.js +23 -0
- package/dist/main.es247.js +23 -0
- package/dist/main.es248.js +23 -0
- package/dist/main.es249.js +23 -0
- package/dist/main.es25.js +55 -0
- package/dist/main.es250.js +30 -0
- package/dist/main.es251.js +23 -0
- package/dist/main.es252.js +23 -0
- package/dist/main.es253.js +28 -0
- package/dist/main.es254.js +23 -0
- package/dist/main.es255.js +23 -0
- package/dist/main.es256.js +28 -0
- package/dist/main.es257.js +33 -0
- package/dist/main.es258.js +28 -0
- package/dist/main.es259.js +28 -0
- package/dist/main.es26.js +12 -0
- package/dist/main.es260.js +23 -0
- package/dist/main.es261.js +25 -0
- package/dist/main.es262.js +28 -0
- package/dist/main.es263.js +30 -0
- package/dist/main.es264.js +23 -0
- package/dist/main.es265.js +23 -0
- package/dist/main.es266.js +23 -0
- package/dist/main.es267.js +23 -0
- package/dist/main.es268.js +28 -0
- package/dist/main.es269.js +252 -0
- package/dist/main.es27.js +6 -0
- package/dist/main.es270.js +22 -0
- package/dist/main.es271.js +25 -0
- package/dist/main.es272.js +7 -0
- package/dist/main.es273.js +383 -0
- package/dist/main.es274.js +54 -0
- package/dist/main.es275.js +15 -0
- package/dist/main.es276.js +64 -0
- package/dist/main.es277.js +4 -0
- package/dist/main.es278.js +4 -0
- package/dist/main.es279.js +4 -0
- package/dist/main.es28.js +103 -0
- package/dist/main.es280.js +4 -0
- package/dist/main.es281.js +4 -0
- package/dist/main.es282.js +4 -0
- package/dist/main.es283.js +4 -0
- package/dist/main.es284.js +4 -0
- package/dist/main.es285.js +4 -0
- package/dist/main.es286.js +4 -0
- package/dist/main.es287.js +4 -0
- package/dist/main.es288.js +4 -0
- package/dist/main.es289.js +4 -0
- package/dist/main.es29.js +62 -0
- package/dist/main.es290.js +4 -0
- package/dist/main.es291.js +4 -0
- package/dist/main.es292.js +4 -0
- package/dist/main.es293.js +4 -0
- package/dist/main.es294.js +4 -0
- package/dist/main.es295.js +4 -0
- package/dist/main.es296.js +4 -0
- package/dist/main.es297.js +4 -0
- package/dist/main.es298.js +4 -0
- package/dist/main.es299.js +4 -0
- package/dist/main.es3.js +70 -0
- package/dist/main.es30.js +69 -0
- package/dist/main.es300.js +4 -0
- package/dist/main.es301.js +4 -0
- package/dist/main.es302.js +4 -0
- package/dist/main.es303.js +4 -0
- package/dist/main.es304.js +4 -0
- package/dist/main.es305.js +4 -0
- package/dist/main.es306.js +4 -0
- package/dist/main.es307.js +4 -0
- package/dist/main.es308.js +4 -0
- package/dist/main.es309.js +4 -0
- package/dist/main.es31.js +801 -0
- package/dist/main.es310.js +4 -0
- package/dist/main.es311.js +4 -0
- package/dist/main.es312.js +4 -0
- package/dist/main.es313.js +4 -0
- package/dist/main.es314.js +4 -0
- package/dist/main.es315.js +4 -0
- package/dist/main.es316.js +4 -0
- package/dist/main.es317.js +4 -0
- package/dist/main.es318.js +4 -0
- package/dist/main.es319.js +4 -0
- package/dist/main.es32.js +127 -0
- package/dist/main.es320.js +4 -0
- package/dist/main.es321.js +4 -0
- package/dist/main.es322.js +4 -0
- package/dist/main.es323.js +4 -0
- package/dist/main.es324.js +4 -0
- package/dist/main.es325.js +4 -0
- package/dist/main.es326.js +4 -0
- package/dist/main.es327.js +4 -0
- package/dist/main.es328.js +4 -0
- package/dist/main.es329.js +4 -0
- package/dist/main.es33.js +4 -0
- package/dist/main.es330.js +4 -0
- package/dist/main.es331.js +4 -0
- package/dist/main.es332.js +4 -0
- package/dist/main.es333.js +4 -0
- package/dist/main.es334.js +4 -0
- package/dist/main.es335.js +4 -0
- package/dist/main.es336.js +4 -0
- package/dist/main.es337.js +4 -0
- package/dist/main.es338.js +4 -0
- package/dist/main.es339.js +4 -0
- package/dist/main.es34.js +29 -0
- package/dist/main.es340.js +4 -0
- package/dist/main.es341.js +4 -0
- package/dist/main.es342.js +4 -0
- package/dist/main.es343.js +4 -0
- package/dist/main.es344.js +4 -0
- package/dist/main.es345.js +4 -0
- package/dist/main.es346.js +4 -0
- package/dist/main.es347.js +4 -0
- package/dist/main.es348.js +4 -0
- package/dist/main.es349.js +4 -0
- package/dist/main.es35.js +34 -0
- package/dist/main.es350.js +4 -0
- package/dist/main.es351.js +4 -0
- package/dist/main.es352.js +4 -0
- package/dist/main.es353.js +4 -0
- package/dist/main.es354.js +4 -0
- package/dist/main.es355.js +4 -0
- package/dist/main.es356.js +4 -0
- package/dist/main.es357.js +4 -0
- package/dist/main.es358.js +4 -0
- package/dist/main.es359.js +4 -0
- package/dist/main.es36.js +36 -0
- package/dist/main.es360.js +4 -0
- package/dist/main.es361.js +4 -0
- package/dist/main.es362.js +4 -0
- package/dist/main.es363.js +4 -0
- package/dist/main.es364.js +4 -0
- package/dist/main.es365.js +4 -0
- package/dist/main.es366.js +4 -0
- package/dist/main.es367.js +4 -0
- package/dist/main.es368.js +4 -0
- package/dist/main.es369.js +4 -0
- package/dist/main.es37.js +41 -0
- package/dist/main.es370.js +4 -0
- package/dist/main.es371.js +4 -0
- package/dist/main.es372.js +4 -0
- package/dist/main.es373.js +4 -0
- package/dist/main.es374.js +4 -0
- package/dist/main.es375.js +4 -0
- package/dist/main.es376.js +4 -0
- package/dist/main.es377.js +4 -0
- package/dist/main.es378.js +4 -0
- package/dist/main.es379.js +4 -0
- package/dist/main.es38.js +35 -0
- package/dist/main.es380.js +4 -0
- package/dist/main.es381.js +4 -0
- package/dist/main.es382.js +4 -0
- package/dist/main.es383.js +4 -0
- package/dist/main.es384.js +4 -0
- package/dist/main.es385.js +4 -0
- package/dist/main.es386.js +4 -0
- package/dist/main.es387.js +4 -0
- package/dist/main.es388.js +4 -0
- package/dist/main.es389.js +4 -0
- package/dist/main.es39.js +20 -0
- package/dist/main.es390.js +4 -0
- package/dist/main.es391.js +4 -0
- package/dist/main.es392.js +4 -0
- package/dist/main.es393.js +4 -0
- package/dist/main.es394.js +4 -0
- package/dist/main.es395.js +4 -0
- package/dist/main.es396.js +4 -0
- package/dist/main.es397.js +4 -0
- package/dist/main.es398.js +4 -0
- package/dist/main.es399.js +4 -0
- package/dist/main.es4.js +19 -0
- package/dist/main.es40.js +20 -0
- package/dist/main.es400.js +4 -0
- package/dist/main.es401.js +4 -0
- package/dist/main.es402.js +4 -0
- package/dist/main.es403.js +4 -0
- package/dist/main.es404.js +4 -0
- package/dist/main.es405.js +4 -0
- package/dist/main.es406.js +4 -0
- package/dist/main.es407.js +4 -0
- package/dist/main.es408.js +4 -0
- package/dist/main.es409.js +4 -0
- package/dist/main.es41.js +25 -0
- package/dist/main.es410.js +4 -0
- package/dist/main.es411.js +4 -0
- package/dist/main.es412.js +4 -0
- package/dist/main.es413.js +4 -0
- package/dist/main.es414.js +4 -0
- package/dist/main.es415.js +4 -0
- package/dist/main.es416.js +4 -0
- package/dist/main.es417.js +4 -0
- package/dist/main.es418.js +4 -0
- package/dist/main.es419.js +4 -0
- package/dist/main.es42.js +28 -0
- package/dist/main.es420.js +4 -0
- package/dist/main.es421.js +4 -0
- package/dist/main.es422.js +4 -0
- package/dist/main.es423.js +4 -0
- package/dist/main.es424.js +4 -0
- package/dist/main.es425.js +4 -0
- package/dist/main.es426.js +4 -0
- package/dist/main.es427.js +4 -0
- package/dist/main.es428.js +4 -0
- package/dist/main.es429.js +4 -0
- package/dist/main.es43.js +23 -0
- package/dist/main.es430.js +4 -0
- package/dist/main.es431.js +4 -0
- package/dist/main.es432.js +4 -0
- package/dist/main.es433.js +4 -0
- package/dist/main.es434.js +4 -0
- package/dist/main.es435.js +4 -0
- package/dist/main.es436.js +4 -0
- package/dist/main.es437.js +4 -0
- package/dist/main.es438.js +4 -0
- package/dist/main.es439.js +4 -0
- package/dist/main.es44.js +44 -0
- package/dist/main.es440.js +4 -0
- package/dist/main.es441.js +4 -0
- package/dist/main.es442.js +4 -0
- package/dist/main.es443.js +4 -0
- package/dist/main.es444.js +4 -0
- package/dist/main.es445.js +4 -0
- package/dist/main.es446.js +4 -0
- package/dist/main.es447.js +4 -0
- package/dist/main.es448.js +4 -0
- package/dist/main.es449.js +4 -0
- package/dist/main.es45.js +38 -0
- package/dist/main.es450.js +4 -0
- package/dist/main.es451.js +4 -0
- package/dist/main.es452.js +4 -0
- package/dist/main.es453.js +4 -0
- package/dist/main.es454.js +4 -0
- package/dist/main.es455.js +4 -0
- package/dist/main.es456.js +4 -0
- package/dist/main.es457.js +4 -0
- package/dist/main.es458.js +4 -0
- package/dist/main.es459.js +4 -0
- package/dist/main.es46.js +23 -0
- package/dist/main.es460.js +4 -0
- package/dist/main.es461.js +4 -0
- package/dist/main.es462.js +4 -0
- package/dist/main.es463.js +4 -0
- package/dist/main.es464.js +4 -0
- package/dist/main.es465.js +4 -0
- package/dist/main.es466.js +4 -0
- package/dist/main.es467.js +4 -0
- package/dist/main.es468.js +4 -0
- package/dist/main.es469.js +4 -0
- package/dist/main.es47.js +23 -0
- package/dist/main.es470.js +4 -0
- package/dist/main.es471.js +4 -0
- package/dist/main.es472.js +4 -0
- package/dist/main.es473.js +4 -0
- package/dist/main.es474.js +4 -0
- package/dist/main.es475.js +4 -0
- package/dist/main.es476.js +4 -0
- package/dist/main.es477.js +4 -0
- package/dist/main.es478.js +4 -0
- package/dist/main.es479.js +4 -0
- package/dist/main.es48.js +24 -0
- package/dist/main.es480.js +4 -0
- package/dist/main.es481.js +4 -0
- package/dist/main.es482.js +4 -0
- package/dist/main.es483.js +4 -0
- package/dist/main.es484.js +4 -0
- package/dist/main.es485.js +4 -0
- package/dist/main.es486.js +4 -0
- package/dist/main.es487.js +4 -0
- package/dist/main.es488.js +4 -0
- package/dist/main.es489.js +4 -0
- package/dist/main.es49.js +35 -0
- package/dist/main.es490.js +4 -0
- package/dist/main.es491.js +4 -0
- package/dist/main.es492.js +4 -0
- package/dist/main.es493.js +4 -0
- package/dist/main.es494.js +4 -0
- package/dist/main.es495.js +4 -0
- package/dist/main.es496.js +4 -0
- package/dist/main.es497.js +4 -0
- package/dist/main.es498.js +4 -0
- package/dist/main.es499.js +4 -0
- package/dist/main.es5.js +586 -0
- package/dist/main.es50.js +30 -0
- package/dist/main.es500.js +4 -0
- package/dist/main.es501.js +4 -0
- package/dist/main.es502.js +4 -0
- package/dist/main.es503.js +4 -0
- package/dist/main.es504.js +4 -0
- package/dist/main.es505.js +4 -0
- package/dist/main.es506.js +4 -0
- package/dist/main.es507.js +4 -0
- package/dist/main.es508.js +4 -0
- package/dist/main.es509.js +4 -0
- package/dist/main.es51.js +34 -0
- package/dist/main.es510.js +4 -0
- package/dist/main.es511.js +88 -0
- package/dist/main.es52.js +20 -0
- package/dist/main.es53.js +20 -0
- package/dist/main.es54.js +23 -0
- package/dist/main.es55.js +28 -0
- package/dist/main.es56.js +28 -0
- package/dist/main.es57.js +23 -0
- package/dist/main.es58.js +25 -0
- package/dist/main.es59.js +24 -0
- package/dist/main.es6.js +5872 -0
- package/dist/main.es60.js +23 -0
- package/dist/main.es61.js +23 -0
- package/dist/main.es62.js +23 -0
- package/dist/main.es63.js +23 -0
- package/dist/main.es64.js +23 -0
- package/dist/main.es65.js +20 -0
- package/dist/main.es66.js +23 -0
- package/dist/main.es67.js +23 -0
- package/dist/main.es68.js +21 -0
- package/dist/main.es69.js +20 -0
- package/dist/main.es7.js +1904 -0
- package/dist/main.es70.js +23 -0
- package/dist/main.es71.js +28 -0
- package/dist/main.es72.js +28 -0
- package/dist/main.es73.js +23 -0
- package/dist/main.es74.js +23 -0
- package/dist/main.es75.js +23 -0
- package/dist/main.es76.js +23 -0
- package/dist/main.es77.js +31 -0
- package/dist/main.es78.js +23 -0
- package/dist/main.es79.js +33 -0
- package/dist/main.es8.js +42 -0
- package/dist/main.es80.js +30 -0
- package/dist/main.es81.js +23 -0
- package/dist/main.es82.js +22 -0
- package/dist/main.es83.js +25 -0
- package/dist/main.es84.js +28 -0
- package/dist/main.es85.js +35 -0
- package/dist/main.es86.js +23 -0
- package/dist/main.es87.js +23 -0
- package/dist/main.es88.js +33 -0
- package/dist/main.es89.js +20 -0
- package/dist/main.es9.js +4 -0
- package/dist/main.es90.js +28 -0
- package/dist/main.es91.js +28 -0
- package/dist/main.es92.js +23 -0
- package/dist/main.es93.js +23 -0
- package/dist/main.es94.js +24 -0
- package/dist/main.es95.js +28 -0
- package/dist/main.es96.js +28 -0
- package/dist/main.es97.js +23 -0
- package/dist/main.es98.js +23 -0
- package/dist/main.es99.js +28 -0
- package/dist/style.css +1 -0
- package/package.json +1 -1
- package/src/components/addNewButton/index.vue +5 -1
- package/src/components/buttons/mainButton/index.vue +5 -0
- package/src/components/iconWrapper/index.vue +5 -0
- package/src/components/inputs/checkbox/index.vue +5 -0
- package/src/components/inputs/inputNumber/index.vue +10 -1
- package/src/components/inputs/inputText/index.vue +10 -0
- package/src/components/inputs/radioButton/index.vue +5 -0
- package/src/components/inputs/radioButton/radioButton.spec.js +4 -4
- package/src/components/inputs/searchInput/index.vue +6 -0
- package/src/components/inputs/select/index.vue +7 -1
- package/src/components/inputs/textAreaInput/index.vue +6 -0
- package/src/components/inputs/toggle/index.vue +5 -0
- package/src/components/rangeSlider/Slider.vue +5 -0
@@ -0,0 +1,2484 @@
|
|
1
|
+
import "./main.es3.js";
|
2
|
+
import { setupDevtoolsPlugin } from "./main.es14.js";
|
3
|
+
import { shallowRef, unref, reactive, ref } from "./main.es15.js";
|
4
|
+
import { computed, nextTick, defineComponent, watch, inject, h, provide, watchEffect, getCurrentInstance } from "./main.es6.js";
|
5
|
+
/*!
|
6
|
+
* vue-router v4.2.2
|
7
|
+
* (c) 2023 Eduardo San Martin Morote
|
8
|
+
* @license MIT
|
9
|
+
*/
|
10
|
+
const isBrowser = typeof window !== "undefined";
|
11
|
+
function isESModule(obj) {
|
12
|
+
return obj.__esModule || obj[Symbol.toStringTag] === "Module";
|
13
|
+
}
|
14
|
+
const assign = Object.assign;
|
15
|
+
function applyToParams(fn, params) {
|
16
|
+
const newParams = {};
|
17
|
+
for (const key in params) {
|
18
|
+
const value = params[key];
|
19
|
+
newParams[key] = isArray(value) ? value.map(fn) : fn(value);
|
20
|
+
}
|
21
|
+
return newParams;
|
22
|
+
}
|
23
|
+
const noop = () => {
|
24
|
+
};
|
25
|
+
const isArray = Array.isArray;
|
26
|
+
function warn(msg) {
|
27
|
+
const args = Array.from(arguments).slice(1);
|
28
|
+
console.warn.apply(console, ["[Vue Router warn]: " + msg].concat(args));
|
29
|
+
}
|
30
|
+
const TRAILING_SLASH_RE = /\/$/;
|
31
|
+
const removeTrailingSlash = (path) => path.replace(TRAILING_SLASH_RE, "");
|
32
|
+
function parseURL(parseQuery2, location2, currentLocation = "/") {
|
33
|
+
let path, query = {}, searchString = "", hash = "";
|
34
|
+
const hashPos = location2.indexOf("#");
|
35
|
+
let searchPos = location2.indexOf("?");
|
36
|
+
if (hashPos < searchPos && hashPos >= 0) {
|
37
|
+
searchPos = -1;
|
38
|
+
}
|
39
|
+
if (searchPos > -1) {
|
40
|
+
path = location2.slice(0, searchPos);
|
41
|
+
searchString = location2.slice(searchPos + 1, hashPos > -1 ? hashPos : location2.length);
|
42
|
+
query = parseQuery2(searchString);
|
43
|
+
}
|
44
|
+
if (hashPos > -1) {
|
45
|
+
path = path || location2.slice(0, hashPos);
|
46
|
+
hash = location2.slice(hashPos, location2.length);
|
47
|
+
}
|
48
|
+
path = resolveRelativePath(path != null ? path : location2, currentLocation);
|
49
|
+
return {
|
50
|
+
fullPath: path + (searchString && "?") + searchString + hash,
|
51
|
+
path,
|
52
|
+
query,
|
53
|
+
hash
|
54
|
+
};
|
55
|
+
}
|
56
|
+
function stringifyURL(stringifyQuery2, location2) {
|
57
|
+
const query = location2.query ? stringifyQuery2(location2.query) : "";
|
58
|
+
return location2.path + (query && "?") + query + (location2.hash || "");
|
59
|
+
}
|
60
|
+
function stripBase(pathname, base) {
|
61
|
+
if (!base || !pathname.toLowerCase().startsWith(base.toLowerCase()))
|
62
|
+
return pathname;
|
63
|
+
return pathname.slice(base.length) || "/";
|
64
|
+
}
|
65
|
+
function isSameRouteLocation(stringifyQuery2, a, b) {
|
66
|
+
const aLastIndex = a.matched.length - 1;
|
67
|
+
const bLastIndex = b.matched.length - 1;
|
68
|
+
return aLastIndex > -1 && aLastIndex === bLastIndex && isSameRouteRecord(a.matched[aLastIndex], b.matched[bLastIndex]) && isSameRouteLocationParams(a.params, b.params) && stringifyQuery2(a.query) === stringifyQuery2(b.query) && a.hash === b.hash;
|
69
|
+
}
|
70
|
+
function isSameRouteRecord(a, b) {
|
71
|
+
return (a.aliasOf || a) === (b.aliasOf || b);
|
72
|
+
}
|
73
|
+
function isSameRouteLocationParams(a, b) {
|
74
|
+
if (Object.keys(a).length !== Object.keys(b).length)
|
75
|
+
return false;
|
76
|
+
for (const key in a) {
|
77
|
+
if (!isSameRouteLocationParamsValue(a[key], b[key]))
|
78
|
+
return false;
|
79
|
+
}
|
80
|
+
return true;
|
81
|
+
}
|
82
|
+
function isSameRouteLocationParamsValue(a, b) {
|
83
|
+
return isArray(a) ? isEquivalentArray(a, b) : isArray(b) ? isEquivalentArray(b, a) : a === b;
|
84
|
+
}
|
85
|
+
function isEquivalentArray(a, b) {
|
86
|
+
return isArray(b) ? a.length === b.length && a.every((value, i) => value === b[i]) : a.length === 1 && a[0] === b;
|
87
|
+
}
|
88
|
+
function resolveRelativePath(to, from) {
|
89
|
+
if (to.startsWith("/"))
|
90
|
+
return to;
|
91
|
+
if (process.env.NODE_ENV !== "production" && !from.startsWith("/")) {
|
92
|
+
warn(`Cannot resolve a relative location without an absolute path. Trying to resolve "${to}" from "${from}". It should look like "/${from}".`);
|
93
|
+
return to;
|
94
|
+
}
|
95
|
+
if (!to)
|
96
|
+
return from;
|
97
|
+
const fromSegments = from.split("/");
|
98
|
+
const toSegments = to.split("/");
|
99
|
+
const lastToSegment = toSegments[toSegments.length - 1];
|
100
|
+
if (lastToSegment === ".." || lastToSegment === ".") {
|
101
|
+
toSegments.push("");
|
102
|
+
}
|
103
|
+
let position = fromSegments.length - 1;
|
104
|
+
let toPosition;
|
105
|
+
let segment;
|
106
|
+
for (toPosition = 0; toPosition < toSegments.length; toPosition++) {
|
107
|
+
segment = toSegments[toPosition];
|
108
|
+
if (segment === ".")
|
109
|
+
continue;
|
110
|
+
if (segment === "..") {
|
111
|
+
if (position > 1)
|
112
|
+
position--;
|
113
|
+
} else
|
114
|
+
break;
|
115
|
+
}
|
116
|
+
return fromSegments.slice(0, position).join("/") + "/" + toSegments.slice(toPosition - (toPosition === toSegments.length ? 1 : 0)).join("/");
|
117
|
+
}
|
118
|
+
var NavigationType;
|
119
|
+
(function(NavigationType2) {
|
120
|
+
NavigationType2["pop"] = "pop";
|
121
|
+
NavigationType2["push"] = "push";
|
122
|
+
})(NavigationType || (NavigationType = {}));
|
123
|
+
var NavigationDirection;
|
124
|
+
(function(NavigationDirection2) {
|
125
|
+
NavigationDirection2["back"] = "back";
|
126
|
+
NavigationDirection2["forward"] = "forward";
|
127
|
+
NavigationDirection2["unknown"] = "";
|
128
|
+
})(NavigationDirection || (NavigationDirection = {}));
|
129
|
+
function normalizeBase(base) {
|
130
|
+
if (!base) {
|
131
|
+
if (isBrowser) {
|
132
|
+
const baseEl = document.querySelector("base");
|
133
|
+
base = baseEl && baseEl.getAttribute("href") || "/";
|
134
|
+
base = base.replace(/^\w+:\/\/[^\/]+/, "");
|
135
|
+
} else {
|
136
|
+
base = "/";
|
137
|
+
}
|
138
|
+
}
|
139
|
+
if (base[0] !== "/" && base[0] !== "#")
|
140
|
+
base = "/" + base;
|
141
|
+
return removeTrailingSlash(base);
|
142
|
+
}
|
143
|
+
const BEFORE_HASH_RE = /^[^#]+#/;
|
144
|
+
function createHref(base, location2) {
|
145
|
+
return base.replace(BEFORE_HASH_RE, "#") + location2;
|
146
|
+
}
|
147
|
+
function getElementPosition(el, offset) {
|
148
|
+
const docRect = document.documentElement.getBoundingClientRect();
|
149
|
+
const elRect = el.getBoundingClientRect();
|
150
|
+
return {
|
151
|
+
behavior: offset.behavior,
|
152
|
+
left: elRect.left - docRect.left - (offset.left || 0),
|
153
|
+
top: elRect.top - docRect.top - (offset.top || 0)
|
154
|
+
};
|
155
|
+
}
|
156
|
+
const computeScrollPosition = () => ({
|
157
|
+
left: window.pageXOffset,
|
158
|
+
top: window.pageYOffset
|
159
|
+
});
|
160
|
+
function scrollToPosition(position) {
|
161
|
+
let scrollToOptions;
|
162
|
+
if ("el" in position) {
|
163
|
+
const positionEl = position.el;
|
164
|
+
const isIdSelector = typeof positionEl === "string" && positionEl.startsWith("#");
|
165
|
+
if (process.env.NODE_ENV !== "production" && typeof position.el === "string") {
|
166
|
+
if (!isIdSelector || !document.getElementById(position.el.slice(1))) {
|
167
|
+
try {
|
168
|
+
const foundEl = document.querySelector(position.el);
|
169
|
+
if (isIdSelector && foundEl) {
|
170
|
+
warn(`The selector "${position.el}" should be passed as "el: document.querySelector('${position.el}')" because it starts with "#".`);
|
171
|
+
return;
|
172
|
+
}
|
173
|
+
} catch (err) {
|
174
|
+
warn(`The selector "${position.el}" is invalid. If you are using an id selector, make sure to escape it. You can find more information about escaping characters in selectors at https://mathiasbynens.be/notes/css-escapes or use CSS.escape (https://developer.mozilla.org/en-US/docs/Web/API/CSS/escape).`);
|
175
|
+
return;
|
176
|
+
}
|
177
|
+
}
|
178
|
+
}
|
179
|
+
const el = typeof positionEl === "string" ? isIdSelector ? document.getElementById(positionEl.slice(1)) : document.querySelector(positionEl) : positionEl;
|
180
|
+
if (!el) {
|
181
|
+
process.env.NODE_ENV !== "production" && warn(`Couldn't find element using selector "${position.el}" returned by scrollBehavior.`);
|
182
|
+
return;
|
183
|
+
}
|
184
|
+
scrollToOptions = getElementPosition(el, position);
|
185
|
+
} else {
|
186
|
+
scrollToOptions = position;
|
187
|
+
}
|
188
|
+
if ("scrollBehavior" in document.documentElement.style)
|
189
|
+
window.scrollTo(scrollToOptions);
|
190
|
+
else {
|
191
|
+
window.scrollTo(scrollToOptions.left != null ? scrollToOptions.left : window.pageXOffset, scrollToOptions.top != null ? scrollToOptions.top : window.pageYOffset);
|
192
|
+
}
|
193
|
+
}
|
194
|
+
function getScrollKey(path, delta) {
|
195
|
+
const position = history.state ? history.state.position - delta : -1;
|
196
|
+
return position + path;
|
197
|
+
}
|
198
|
+
const scrollPositions = /* @__PURE__ */ new Map();
|
199
|
+
function saveScrollPosition(key, scrollPosition) {
|
200
|
+
scrollPositions.set(key, scrollPosition);
|
201
|
+
}
|
202
|
+
function getSavedScrollPosition(key) {
|
203
|
+
const scroll = scrollPositions.get(key);
|
204
|
+
scrollPositions.delete(key);
|
205
|
+
return scroll;
|
206
|
+
}
|
207
|
+
let createBaseLocation = () => location.protocol + "//" + location.host;
|
208
|
+
function createCurrentLocation(base, location2) {
|
209
|
+
const { pathname, search, hash } = location2;
|
210
|
+
const hashPos = base.indexOf("#");
|
211
|
+
if (hashPos > -1) {
|
212
|
+
let slicePos = hash.includes(base.slice(hashPos)) ? base.slice(hashPos).length : 1;
|
213
|
+
let pathFromHash = hash.slice(slicePos);
|
214
|
+
if (pathFromHash[0] !== "/")
|
215
|
+
pathFromHash = "/" + pathFromHash;
|
216
|
+
return stripBase(pathFromHash, "");
|
217
|
+
}
|
218
|
+
const path = stripBase(pathname, base);
|
219
|
+
return path + search + hash;
|
220
|
+
}
|
221
|
+
function useHistoryListeners(base, historyState, currentLocation, replace) {
|
222
|
+
let listeners = [];
|
223
|
+
let teardowns = [];
|
224
|
+
let pauseState = null;
|
225
|
+
const popStateHandler = ({ state }) => {
|
226
|
+
const to = createCurrentLocation(base, location);
|
227
|
+
const from = currentLocation.value;
|
228
|
+
const fromState = historyState.value;
|
229
|
+
let delta = 0;
|
230
|
+
if (state) {
|
231
|
+
currentLocation.value = to;
|
232
|
+
historyState.value = state;
|
233
|
+
if (pauseState && pauseState === from) {
|
234
|
+
pauseState = null;
|
235
|
+
return;
|
236
|
+
}
|
237
|
+
delta = fromState ? state.position - fromState.position : 0;
|
238
|
+
} else {
|
239
|
+
replace(to);
|
240
|
+
}
|
241
|
+
listeners.forEach((listener) => {
|
242
|
+
listener(currentLocation.value, from, {
|
243
|
+
delta,
|
244
|
+
type: NavigationType.pop,
|
245
|
+
direction: delta ? delta > 0 ? NavigationDirection.forward : NavigationDirection.back : NavigationDirection.unknown
|
246
|
+
});
|
247
|
+
});
|
248
|
+
};
|
249
|
+
function pauseListeners() {
|
250
|
+
pauseState = currentLocation.value;
|
251
|
+
}
|
252
|
+
function listen(callback) {
|
253
|
+
listeners.push(callback);
|
254
|
+
const teardown = () => {
|
255
|
+
const index = listeners.indexOf(callback);
|
256
|
+
if (index > -1)
|
257
|
+
listeners.splice(index, 1);
|
258
|
+
};
|
259
|
+
teardowns.push(teardown);
|
260
|
+
return teardown;
|
261
|
+
}
|
262
|
+
function beforeUnloadListener() {
|
263
|
+
const { history: history2 } = window;
|
264
|
+
if (!history2.state)
|
265
|
+
return;
|
266
|
+
history2.replaceState(assign({}, history2.state, { scroll: computeScrollPosition() }), "");
|
267
|
+
}
|
268
|
+
function destroy() {
|
269
|
+
for (const teardown of teardowns)
|
270
|
+
teardown();
|
271
|
+
teardowns = [];
|
272
|
+
window.removeEventListener("popstate", popStateHandler);
|
273
|
+
window.removeEventListener("beforeunload", beforeUnloadListener);
|
274
|
+
}
|
275
|
+
window.addEventListener("popstate", popStateHandler);
|
276
|
+
window.addEventListener("beforeunload", beforeUnloadListener, {
|
277
|
+
passive: true
|
278
|
+
});
|
279
|
+
return {
|
280
|
+
pauseListeners,
|
281
|
+
listen,
|
282
|
+
destroy
|
283
|
+
};
|
284
|
+
}
|
285
|
+
function buildState(back, current, forward, replaced = false, computeScroll = false) {
|
286
|
+
return {
|
287
|
+
back,
|
288
|
+
current,
|
289
|
+
forward,
|
290
|
+
replaced,
|
291
|
+
position: window.history.length,
|
292
|
+
scroll: computeScroll ? computeScrollPosition() : null
|
293
|
+
};
|
294
|
+
}
|
295
|
+
function useHistoryStateNavigation(base) {
|
296
|
+
const { history: history2, location: location2 } = window;
|
297
|
+
const currentLocation = {
|
298
|
+
value: createCurrentLocation(base, location2)
|
299
|
+
};
|
300
|
+
const historyState = { value: history2.state };
|
301
|
+
if (!historyState.value) {
|
302
|
+
changeLocation(currentLocation.value, {
|
303
|
+
back: null,
|
304
|
+
current: currentLocation.value,
|
305
|
+
forward: null,
|
306
|
+
// the length is off by one, we need to decrease it
|
307
|
+
position: history2.length - 1,
|
308
|
+
replaced: true,
|
309
|
+
// don't add a scroll as the user may have an anchor, and we want
|
310
|
+
// scrollBehavior to be triggered without a saved position
|
311
|
+
scroll: null
|
312
|
+
}, true);
|
313
|
+
}
|
314
|
+
function changeLocation(to, state, replace2) {
|
315
|
+
const hashIndex = base.indexOf("#");
|
316
|
+
const url = hashIndex > -1 ? (location2.host && document.querySelector("base") ? base : base.slice(hashIndex)) + to : createBaseLocation() + base + to;
|
317
|
+
try {
|
318
|
+
history2[replace2 ? "replaceState" : "pushState"](state, "", url);
|
319
|
+
historyState.value = state;
|
320
|
+
} catch (err) {
|
321
|
+
if (process.env.NODE_ENV !== "production") {
|
322
|
+
warn("Error with push/replace State", err);
|
323
|
+
} else {
|
324
|
+
console.error(err);
|
325
|
+
}
|
326
|
+
location2[replace2 ? "replace" : "assign"](url);
|
327
|
+
}
|
328
|
+
}
|
329
|
+
function replace(to, data) {
|
330
|
+
const state = assign({}, history2.state, buildState(
|
331
|
+
historyState.value.back,
|
332
|
+
// keep back and forward entries but override current position
|
333
|
+
to,
|
334
|
+
historyState.value.forward,
|
335
|
+
true
|
336
|
+
), data, { position: historyState.value.position });
|
337
|
+
changeLocation(to, state, true);
|
338
|
+
currentLocation.value = to;
|
339
|
+
}
|
340
|
+
function push(to, data) {
|
341
|
+
const currentState = assign(
|
342
|
+
{},
|
343
|
+
// use current history state to gracefully handle a wrong call to
|
344
|
+
// history.replaceState
|
345
|
+
// https://github.com/vuejs/router/issues/366
|
346
|
+
historyState.value,
|
347
|
+
history2.state,
|
348
|
+
{
|
349
|
+
forward: to,
|
350
|
+
scroll: computeScrollPosition()
|
351
|
+
}
|
352
|
+
);
|
353
|
+
if (process.env.NODE_ENV !== "production" && !history2.state) {
|
354
|
+
warn(`history.state seems to have been manually replaced without preserving the necessary values. Make sure to preserve existing history state if you are manually calling history.replaceState:
|
355
|
+
|
356
|
+
history.replaceState(history.state, '', url)
|
357
|
+
|
358
|
+
You can find more information at https://next.router.vuejs.org/guide/migration/#usage-of-history-state.`);
|
359
|
+
}
|
360
|
+
changeLocation(currentState.current, currentState, true);
|
361
|
+
const state = assign({}, buildState(currentLocation.value, to, null), { position: currentState.position + 1 }, data);
|
362
|
+
changeLocation(to, state, false);
|
363
|
+
currentLocation.value = to;
|
364
|
+
}
|
365
|
+
return {
|
366
|
+
location: currentLocation,
|
367
|
+
state: historyState,
|
368
|
+
push,
|
369
|
+
replace
|
370
|
+
};
|
371
|
+
}
|
372
|
+
function createWebHistory(base) {
|
373
|
+
base = normalizeBase(base);
|
374
|
+
const historyNavigation = useHistoryStateNavigation(base);
|
375
|
+
const historyListeners = useHistoryListeners(base, historyNavigation.state, historyNavigation.location, historyNavigation.replace);
|
376
|
+
function go(delta, triggerListeners = true) {
|
377
|
+
if (!triggerListeners)
|
378
|
+
historyListeners.pauseListeners();
|
379
|
+
history.go(delta);
|
380
|
+
}
|
381
|
+
const routerHistory = assign({
|
382
|
+
// it's overridden right after
|
383
|
+
location: "",
|
384
|
+
base,
|
385
|
+
go,
|
386
|
+
createHref: createHref.bind(null, base)
|
387
|
+
}, historyNavigation, historyListeners);
|
388
|
+
Object.defineProperty(routerHistory, "location", {
|
389
|
+
enumerable: true,
|
390
|
+
get: () => historyNavigation.location.value
|
391
|
+
});
|
392
|
+
Object.defineProperty(routerHistory, "state", {
|
393
|
+
enumerable: true,
|
394
|
+
get: () => historyNavigation.state.value
|
395
|
+
});
|
396
|
+
return routerHistory;
|
397
|
+
}
|
398
|
+
function isRouteLocation(route) {
|
399
|
+
return typeof route === "string" || route && typeof route === "object";
|
400
|
+
}
|
401
|
+
function isRouteName(name) {
|
402
|
+
return typeof name === "string" || typeof name === "symbol";
|
403
|
+
}
|
404
|
+
const START_LOCATION_NORMALIZED = {
|
405
|
+
path: "/",
|
406
|
+
name: void 0,
|
407
|
+
params: {},
|
408
|
+
query: {},
|
409
|
+
hash: "",
|
410
|
+
fullPath: "/",
|
411
|
+
matched: [],
|
412
|
+
meta: {},
|
413
|
+
redirectedFrom: void 0
|
414
|
+
};
|
415
|
+
const NavigationFailureSymbol = Symbol(process.env.NODE_ENV !== "production" ? "navigation failure" : "");
|
416
|
+
var NavigationFailureType;
|
417
|
+
(function(NavigationFailureType2) {
|
418
|
+
NavigationFailureType2[NavigationFailureType2["aborted"] = 4] = "aborted";
|
419
|
+
NavigationFailureType2[NavigationFailureType2["cancelled"] = 8] = "cancelled";
|
420
|
+
NavigationFailureType2[NavigationFailureType2["duplicated"] = 16] = "duplicated";
|
421
|
+
})(NavigationFailureType || (NavigationFailureType = {}));
|
422
|
+
const ErrorTypeMessages = {
|
423
|
+
[
|
424
|
+
1
|
425
|
+
/* ErrorTypes.MATCHER_NOT_FOUND */
|
426
|
+
]({ location: location2, currentLocation }) {
|
427
|
+
return `No match for
|
428
|
+
${JSON.stringify(location2)}${currentLocation ? "\nwhile being at\n" + JSON.stringify(currentLocation) : ""}`;
|
429
|
+
},
|
430
|
+
[
|
431
|
+
2
|
432
|
+
/* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
|
433
|
+
]({ from, to }) {
|
434
|
+
return `Redirected from "${from.fullPath}" to "${stringifyRoute(to)}" via a navigation guard.`;
|
435
|
+
},
|
436
|
+
[
|
437
|
+
4
|
438
|
+
/* ErrorTypes.NAVIGATION_ABORTED */
|
439
|
+
]({ from, to }) {
|
440
|
+
return `Navigation aborted from "${from.fullPath}" to "${to.fullPath}" via a navigation guard.`;
|
441
|
+
},
|
442
|
+
[
|
443
|
+
8
|
444
|
+
/* ErrorTypes.NAVIGATION_CANCELLED */
|
445
|
+
]({ from, to }) {
|
446
|
+
return `Navigation cancelled from "${from.fullPath}" to "${to.fullPath}" with a new navigation.`;
|
447
|
+
},
|
448
|
+
[
|
449
|
+
16
|
450
|
+
/* ErrorTypes.NAVIGATION_DUPLICATED */
|
451
|
+
]({ from, to }) {
|
452
|
+
return `Avoided redundant navigation to current location: "${from.fullPath}".`;
|
453
|
+
}
|
454
|
+
};
|
455
|
+
function createRouterError(type, params) {
|
456
|
+
if (process.env.NODE_ENV !== "production" || false) {
|
457
|
+
return assign(new Error(ErrorTypeMessages[type](params)), {
|
458
|
+
type,
|
459
|
+
[NavigationFailureSymbol]: true
|
460
|
+
}, params);
|
461
|
+
} else {
|
462
|
+
return assign(new Error(), {
|
463
|
+
type,
|
464
|
+
[NavigationFailureSymbol]: true
|
465
|
+
}, params);
|
466
|
+
}
|
467
|
+
}
|
468
|
+
function isNavigationFailure(error, type) {
|
469
|
+
return error instanceof Error && NavigationFailureSymbol in error && (type == null || !!(error.type & type));
|
470
|
+
}
|
471
|
+
const propertiesToLog = ["params", "query", "hash"];
|
472
|
+
function stringifyRoute(to) {
|
473
|
+
if (typeof to === "string")
|
474
|
+
return to;
|
475
|
+
if ("path" in to)
|
476
|
+
return to.path;
|
477
|
+
const location2 = {};
|
478
|
+
for (const key of propertiesToLog) {
|
479
|
+
if (key in to)
|
480
|
+
location2[key] = to[key];
|
481
|
+
}
|
482
|
+
return JSON.stringify(location2, null, 2);
|
483
|
+
}
|
484
|
+
const BASE_PARAM_PATTERN = "[^/]+?";
|
485
|
+
const BASE_PATH_PARSER_OPTIONS = {
|
486
|
+
sensitive: false,
|
487
|
+
strict: false,
|
488
|
+
start: true,
|
489
|
+
end: true
|
490
|
+
};
|
491
|
+
const REGEX_CHARS_RE = /[.+*?^${}()[\]/\\]/g;
|
492
|
+
function tokensToParser(segments, extraOptions) {
|
493
|
+
const options = assign({}, BASE_PATH_PARSER_OPTIONS, extraOptions);
|
494
|
+
const score = [];
|
495
|
+
let pattern = options.start ? "^" : "";
|
496
|
+
const keys = [];
|
497
|
+
for (const segment of segments) {
|
498
|
+
const segmentScores = segment.length ? [] : [
|
499
|
+
90
|
500
|
+
/* PathScore.Root */
|
501
|
+
];
|
502
|
+
if (options.strict && !segment.length)
|
503
|
+
pattern += "/";
|
504
|
+
for (let tokenIndex = 0; tokenIndex < segment.length; tokenIndex++) {
|
505
|
+
const token = segment[tokenIndex];
|
506
|
+
let subSegmentScore = 40 + (options.sensitive ? 0.25 : 0);
|
507
|
+
if (token.type === 0) {
|
508
|
+
if (!tokenIndex)
|
509
|
+
pattern += "/";
|
510
|
+
pattern += token.value.replace(REGEX_CHARS_RE, "\\$&");
|
511
|
+
subSegmentScore += 40;
|
512
|
+
} else if (token.type === 1) {
|
513
|
+
const { value, repeatable, optional, regexp } = token;
|
514
|
+
keys.push({
|
515
|
+
name: value,
|
516
|
+
repeatable,
|
517
|
+
optional
|
518
|
+
});
|
519
|
+
const re2 = regexp ? regexp : BASE_PARAM_PATTERN;
|
520
|
+
if (re2 !== BASE_PARAM_PATTERN) {
|
521
|
+
subSegmentScore += 10;
|
522
|
+
try {
|
523
|
+
new RegExp(`(${re2})`);
|
524
|
+
} catch (err) {
|
525
|
+
throw new Error(`Invalid custom RegExp for param "${value}" (${re2}): ` + err.message);
|
526
|
+
}
|
527
|
+
}
|
528
|
+
let subPattern = repeatable ? `((?:${re2})(?:/(?:${re2}))*)` : `(${re2})`;
|
529
|
+
if (!tokenIndex)
|
530
|
+
subPattern = // avoid an optional / if there are more segments e.g. /:p?-static
|
531
|
+
// or /:p?-:p2
|
532
|
+
optional && segment.length < 2 ? `(?:/${subPattern})` : "/" + subPattern;
|
533
|
+
if (optional)
|
534
|
+
subPattern += "?";
|
535
|
+
pattern += subPattern;
|
536
|
+
subSegmentScore += 20;
|
537
|
+
if (optional)
|
538
|
+
subSegmentScore += -8;
|
539
|
+
if (repeatable)
|
540
|
+
subSegmentScore += -20;
|
541
|
+
if (re2 === ".*")
|
542
|
+
subSegmentScore += -50;
|
543
|
+
}
|
544
|
+
segmentScores.push(subSegmentScore);
|
545
|
+
}
|
546
|
+
score.push(segmentScores);
|
547
|
+
}
|
548
|
+
if (options.strict && options.end) {
|
549
|
+
const i = score.length - 1;
|
550
|
+
score[i][score[i].length - 1] += 0.7000000000000001;
|
551
|
+
}
|
552
|
+
if (!options.strict)
|
553
|
+
pattern += "/?";
|
554
|
+
if (options.end)
|
555
|
+
pattern += "$";
|
556
|
+
else if (options.strict)
|
557
|
+
pattern += "(?:/|$)";
|
558
|
+
const re = new RegExp(pattern, options.sensitive ? "" : "i");
|
559
|
+
function parse(path) {
|
560
|
+
const match = path.match(re);
|
561
|
+
const params = {};
|
562
|
+
if (!match)
|
563
|
+
return null;
|
564
|
+
for (let i = 1; i < match.length; i++) {
|
565
|
+
const value = match[i] || "";
|
566
|
+
const key = keys[i - 1];
|
567
|
+
params[key.name] = value && key.repeatable ? value.split("/") : value;
|
568
|
+
}
|
569
|
+
return params;
|
570
|
+
}
|
571
|
+
function stringify(params) {
|
572
|
+
let path = "";
|
573
|
+
let avoidDuplicatedSlash = false;
|
574
|
+
for (const segment of segments) {
|
575
|
+
if (!avoidDuplicatedSlash || !path.endsWith("/"))
|
576
|
+
path += "/";
|
577
|
+
avoidDuplicatedSlash = false;
|
578
|
+
for (const token of segment) {
|
579
|
+
if (token.type === 0) {
|
580
|
+
path += token.value;
|
581
|
+
} else if (token.type === 1) {
|
582
|
+
const { value, repeatable, optional } = token;
|
583
|
+
const param = value in params ? params[value] : "";
|
584
|
+
if (isArray(param) && !repeatable) {
|
585
|
+
throw new Error(`Provided param "${value}" is an array but it is not repeatable (* or + modifiers)`);
|
586
|
+
}
|
587
|
+
const text = isArray(param) ? param.join("/") : param;
|
588
|
+
if (!text) {
|
589
|
+
if (optional) {
|
590
|
+
if (segment.length < 2) {
|
591
|
+
if (path.endsWith("/"))
|
592
|
+
path = path.slice(0, -1);
|
593
|
+
else
|
594
|
+
avoidDuplicatedSlash = true;
|
595
|
+
}
|
596
|
+
} else
|
597
|
+
throw new Error(`Missing required param "${value}"`);
|
598
|
+
}
|
599
|
+
path += text;
|
600
|
+
}
|
601
|
+
}
|
602
|
+
}
|
603
|
+
return path || "/";
|
604
|
+
}
|
605
|
+
return {
|
606
|
+
re,
|
607
|
+
score,
|
608
|
+
keys,
|
609
|
+
parse,
|
610
|
+
stringify
|
611
|
+
};
|
612
|
+
}
|
613
|
+
function compareScoreArray(a, b) {
|
614
|
+
let i = 0;
|
615
|
+
while (i < a.length && i < b.length) {
|
616
|
+
const diff = b[i] - a[i];
|
617
|
+
if (diff)
|
618
|
+
return diff;
|
619
|
+
i++;
|
620
|
+
}
|
621
|
+
if (a.length < b.length) {
|
622
|
+
return a.length === 1 && a[0] === 40 + 40 ? -1 : 1;
|
623
|
+
} else if (a.length > b.length) {
|
624
|
+
return b.length === 1 && b[0] === 40 + 40 ? 1 : -1;
|
625
|
+
}
|
626
|
+
return 0;
|
627
|
+
}
|
628
|
+
function comparePathParserScore(a, b) {
|
629
|
+
let i = 0;
|
630
|
+
const aScore = a.score;
|
631
|
+
const bScore = b.score;
|
632
|
+
while (i < aScore.length && i < bScore.length) {
|
633
|
+
const comp = compareScoreArray(aScore[i], bScore[i]);
|
634
|
+
if (comp)
|
635
|
+
return comp;
|
636
|
+
i++;
|
637
|
+
}
|
638
|
+
if (Math.abs(bScore.length - aScore.length) === 1) {
|
639
|
+
if (isLastScoreNegative(aScore))
|
640
|
+
return 1;
|
641
|
+
if (isLastScoreNegative(bScore))
|
642
|
+
return -1;
|
643
|
+
}
|
644
|
+
return bScore.length - aScore.length;
|
645
|
+
}
|
646
|
+
function isLastScoreNegative(score) {
|
647
|
+
const last = score[score.length - 1];
|
648
|
+
return score.length > 0 && last[last.length - 1] < 0;
|
649
|
+
}
|
650
|
+
const ROOT_TOKEN = {
|
651
|
+
type: 0,
|
652
|
+
value: ""
|
653
|
+
};
|
654
|
+
const VALID_PARAM_RE = /[a-zA-Z0-9_]/;
|
655
|
+
function tokenizePath(path) {
|
656
|
+
if (!path)
|
657
|
+
return [[]];
|
658
|
+
if (path === "/")
|
659
|
+
return [[ROOT_TOKEN]];
|
660
|
+
if (!path.startsWith("/")) {
|
661
|
+
throw new Error(process.env.NODE_ENV !== "production" ? `Route paths should start with a "/": "${path}" should be "/${path}".` : `Invalid path "${path}"`);
|
662
|
+
}
|
663
|
+
function crash(message) {
|
664
|
+
throw new Error(`ERR (${state})/"${buffer}": ${message}`);
|
665
|
+
}
|
666
|
+
let state = 0;
|
667
|
+
let previousState = state;
|
668
|
+
const tokens = [];
|
669
|
+
let segment;
|
670
|
+
function finalizeSegment() {
|
671
|
+
if (segment)
|
672
|
+
tokens.push(segment);
|
673
|
+
segment = [];
|
674
|
+
}
|
675
|
+
let i = 0;
|
676
|
+
let char;
|
677
|
+
let buffer = "";
|
678
|
+
let customRe = "";
|
679
|
+
function consumeBuffer() {
|
680
|
+
if (!buffer)
|
681
|
+
return;
|
682
|
+
if (state === 0) {
|
683
|
+
segment.push({
|
684
|
+
type: 0,
|
685
|
+
value: buffer
|
686
|
+
});
|
687
|
+
} else if (state === 1 || state === 2 || state === 3) {
|
688
|
+
if (segment.length > 1 && (char === "*" || char === "+"))
|
689
|
+
crash(`A repeatable param (${buffer}) must be alone in its segment. eg: '/:ids+.`);
|
690
|
+
segment.push({
|
691
|
+
type: 1,
|
692
|
+
value: buffer,
|
693
|
+
regexp: customRe,
|
694
|
+
repeatable: char === "*" || char === "+",
|
695
|
+
optional: char === "*" || char === "?"
|
696
|
+
});
|
697
|
+
} else {
|
698
|
+
crash("Invalid state to consume buffer");
|
699
|
+
}
|
700
|
+
buffer = "";
|
701
|
+
}
|
702
|
+
function addCharToBuffer() {
|
703
|
+
buffer += char;
|
704
|
+
}
|
705
|
+
while (i < path.length) {
|
706
|
+
char = path[i++];
|
707
|
+
if (char === "\\" && state !== 2) {
|
708
|
+
previousState = state;
|
709
|
+
state = 4;
|
710
|
+
continue;
|
711
|
+
}
|
712
|
+
switch (state) {
|
713
|
+
case 0:
|
714
|
+
if (char === "/") {
|
715
|
+
if (buffer) {
|
716
|
+
consumeBuffer();
|
717
|
+
}
|
718
|
+
finalizeSegment();
|
719
|
+
} else if (char === ":") {
|
720
|
+
consumeBuffer();
|
721
|
+
state = 1;
|
722
|
+
} else {
|
723
|
+
addCharToBuffer();
|
724
|
+
}
|
725
|
+
break;
|
726
|
+
case 4:
|
727
|
+
addCharToBuffer();
|
728
|
+
state = previousState;
|
729
|
+
break;
|
730
|
+
case 1:
|
731
|
+
if (char === "(") {
|
732
|
+
state = 2;
|
733
|
+
} else if (VALID_PARAM_RE.test(char)) {
|
734
|
+
addCharToBuffer();
|
735
|
+
} else {
|
736
|
+
consumeBuffer();
|
737
|
+
state = 0;
|
738
|
+
if (char !== "*" && char !== "?" && char !== "+")
|
739
|
+
i--;
|
740
|
+
}
|
741
|
+
break;
|
742
|
+
case 2:
|
743
|
+
if (char === ")") {
|
744
|
+
if (customRe[customRe.length - 1] == "\\")
|
745
|
+
customRe = customRe.slice(0, -1) + char;
|
746
|
+
else
|
747
|
+
state = 3;
|
748
|
+
} else {
|
749
|
+
customRe += char;
|
750
|
+
}
|
751
|
+
break;
|
752
|
+
case 3:
|
753
|
+
consumeBuffer();
|
754
|
+
state = 0;
|
755
|
+
if (char !== "*" && char !== "?" && char !== "+")
|
756
|
+
i--;
|
757
|
+
customRe = "";
|
758
|
+
break;
|
759
|
+
default:
|
760
|
+
crash("Unknown state");
|
761
|
+
break;
|
762
|
+
}
|
763
|
+
}
|
764
|
+
if (state === 2)
|
765
|
+
crash(`Unfinished custom RegExp for param "${buffer}"`);
|
766
|
+
consumeBuffer();
|
767
|
+
finalizeSegment();
|
768
|
+
return tokens;
|
769
|
+
}
|
770
|
+
function createRouteRecordMatcher(record, parent, options) {
|
771
|
+
const parser = tokensToParser(tokenizePath(record.path), options);
|
772
|
+
if (process.env.NODE_ENV !== "production") {
|
773
|
+
const existingKeys = /* @__PURE__ */ new Set();
|
774
|
+
for (const key of parser.keys) {
|
775
|
+
if (existingKeys.has(key.name))
|
776
|
+
warn(`Found duplicated params with name "${key.name}" for path "${record.path}". Only the last one will be available on "$route.params".`);
|
777
|
+
existingKeys.add(key.name);
|
778
|
+
}
|
779
|
+
}
|
780
|
+
const matcher = assign(parser, {
|
781
|
+
record,
|
782
|
+
parent,
|
783
|
+
// these needs to be populated by the parent
|
784
|
+
children: [],
|
785
|
+
alias: []
|
786
|
+
});
|
787
|
+
if (parent) {
|
788
|
+
if (!matcher.record.aliasOf === !parent.record.aliasOf)
|
789
|
+
parent.children.push(matcher);
|
790
|
+
}
|
791
|
+
return matcher;
|
792
|
+
}
|
793
|
+
function createRouterMatcher(routes, globalOptions) {
|
794
|
+
const matchers = [];
|
795
|
+
const matcherMap = /* @__PURE__ */ new Map();
|
796
|
+
globalOptions = mergeOptions({ strict: false, end: true, sensitive: false }, globalOptions);
|
797
|
+
function getRecordMatcher(name) {
|
798
|
+
return matcherMap.get(name);
|
799
|
+
}
|
800
|
+
function addRoute(record, parent, originalRecord) {
|
801
|
+
const isRootAdd = !originalRecord;
|
802
|
+
const mainNormalizedRecord = normalizeRouteRecord(record);
|
803
|
+
if (process.env.NODE_ENV !== "production") {
|
804
|
+
checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent);
|
805
|
+
}
|
806
|
+
mainNormalizedRecord.aliasOf = originalRecord && originalRecord.record;
|
807
|
+
const options = mergeOptions(globalOptions, record);
|
808
|
+
const normalizedRecords = [
|
809
|
+
mainNormalizedRecord
|
810
|
+
];
|
811
|
+
if ("alias" in record) {
|
812
|
+
const aliases = typeof record.alias === "string" ? [record.alias] : record.alias;
|
813
|
+
for (const alias of aliases) {
|
814
|
+
normalizedRecords.push(assign({}, mainNormalizedRecord, {
|
815
|
+
// this allows us to hold a copy of the `components` option
|
816
|
+
// so that async components cache is hold on the original record
|
817
|
+
components: originalRecord ? originalRecord.record.components : mainNormalizedRecord.components,
|
818
|
+
path: alias,
|
819
|
+
// we might be the child of an alias
|
820
|
+
aliasOf: originalRecord ? originalRecord.record : mainNormalizedRecord
|
821
|
+
// the aliases are always of the same kind as the original since they
|
822
|
+
// are defined on the same record
|
823
|
+
}));
|
824
|
+
}
|
825
|
+
}
|
826
|
+
let matcher;
|
827
|
+
let originalMatcher;
|
828
|
+
for (const normalizedRecord of normalizedRecords) {
|
829
|
+
const { path } = normalizedRecord;
|
830
|
+
if (parent && path[0] !== "/") {
|
831
|
+
const parentPath = parent.record.path;
|
832
|
+
const connectingSlash = parentPath[parentPath.length - 1] === "/" ? "" : "/";
|
833
|
+
normalizedRecord.path = parent.record.path + (path && connectingSlash + path);
|
834
|
+
}
|
835
|
+
if (process.env.NODE_ENV !== "production" && normalizedRecord.path === "*") {
|
836
|
+
throw new Error('Catch all routes ("*") must now be defined using a param with a custom regexp.\nSee more at https://next.router.vuejs.org/guide/migration/#removed-star-or-catch-all-routes.');
|
837
|
+
}
|
838
|
+
matcher = createRouteRecordMatcher(normalizedRecord, parent, options);
|
839
|
+
if (process.env.NODE_ENV !== "production" && parent && path[0] === "/")
|
840
|
+
checkMissingParamsInAbsolutePath(matcher, parent);
|
841
|
+
if (originalRecord) {
|
842
|
+
originalRecord.alias.push(matcher);
|
843
|
+
if (process.env.NODE_ENV !== "production") {
|
844
|
+
checkSameParams(originalRecord, matcher);
|
845
|
+
}
|
846
|
+
} else {
|
847
|
+
originalMatcher = originalMatcher || matcher;
|
848
|
+
if (originalMatcher !== matcher)
|
849
|
+
originalMatcher.alias.push(matcher);
|
850
|
+
if (isRootAdd && record.name && !isAliasRecord(matcher))
|
851
|
+
removeRoute(record.name);
|
852
|
+
}
|
853
|
+
if (mainNormalizedRecord.children) {
|
854
|
+
const children = mainNormalizedRecord.children;
|
855
|
+
for (let i = 0; i < children.length; i++) {
|
856
|
+
addRoute(children[i], matcher, originalRecord && originalRecord.children[i]);
|
857
|
+
}
|
858
|
+
}
|
859
|
+
originalRecord = originalRecord || matcher;
|
860
|
+
if (matcher.record.components && Object.keys(matcher.record.components).length || matcher.record.name || matcher.record.redirect) {
|
861
|
+
insertMatcher(matcher);
|
862
|
+
}
|
863
|
+
}
|
864
|
+
return originalMatcher ? () => {
|
865
|
+
removeRoute(originalMatcher);
|
866
|
+
} : noop;
|
867
|
+
}
|
868
|
+
function removeRoute(matcherRef) {
|
869
|
+
if (isRouteName(matcherRef)) {
|
870
|
+
const matcher = matcherMap.get(matcherRef);
|
871
|
+
if (matcher) {
|
872
|
+
matcherMap.delete(matcherRef);
|
873
|
+
matchers.splice(matchers.indexOf(matcher), 1);
|
874
|
+
matcher.children.forEach(removeRoute);
|
875
|
+
matcher.alias.forEach(removeRoute);
|
876
|
+
}
|
877
|
+
} else {
|
878
|
+
const index = matchers.indexOf(matcherRef);
|
879
|
+
if (index > -1) {
|
880
|
+
matchers.splice(index, 1);
|
881
|
+
if (matcherRef.record.name)
|
882
|
+
matcherMap.delete(matcherRef.record.name);
|
883
|
+
matcherRef.children.forEach(removeRoute);
|
884
|
+
matcherRef.alias.forEach(removeRoute);
|
885
|
+
}
|
886
|
+
}
|
887
|
+
}
|
888
|
+
function getRoutes() {
|
889
|
+
return matchers;
|
890
|
+
}
|
891
|
+
function insertMatcher(matcher) {
|
892
|
+
let i = 0;
|
893
|
+
while (i < matchers.length && comparePathParserScore(matcher, matchers[i]) >= 0 && // Adding children with empty path should still appear before the parent
|
894
|
+
// https://github.com/vuejs/router/issues/1124
|
895
|
+
(matcher.record.path !== matchers[i].record.path || !isRecordChildOf(matcher, matchers[i])))
|
896
|
+
i++;
|
897
|
+
matchers.splice(i, 0, matcher);
|
898
|
+
if (matcher.record.name && !isAliasRecord(matcher))
|
899
|
+
matcherMap.set(matcher.record.name, matcher);
|
900
|
+
}
|
901
|
+
function resolve(location2, currentLocation) {
|
902
|
+
let matcher;
|
903
|
+
let params = {};
|
904
|
+
let path;
|
905
|
+
let name;
|
906
|
+
if ("name" in location2 && location2.name) {
|
907
|
+
matcher = matcherMap.get(location2.name);
|
908
|
+
if (!matcher)
|
909
|
+
throw createRouterError(1, {
|
910
|
+
location: location2
|
911
|
+
});
|
912
|
+
if (process.env.NODE_ENV !== "production") {
|
913
|
+
const invalidParams = Object.keys(location2.params || {}).filter((paramName) => !matcher.keys.find((k) => k.name === paramName));
|
914
|
+
if (invalidParams.length) {
|
915
|
+
warn(`Discarded invalid param(s) "${invalidParams.join('", "')}" when navigating. See https://github.com/vuejs/router/blob/main/packages/router/CHANGELOG.md#414-2022-08-22 for more details.`);
|
916
|
+
}
|
917
|
+
}
|
918
|
+
name = matcher.record.name;
|
919
|
+
params = assign(
|
920
|
+
// paramsFromLocation is a new object
|
921
|
+
paramsFromLocation(
|
922
|
+
currentLocation.params,
|
923
|
+
// only keep params that exist in the resolved location
|
924
|
+
// TODO: only keep optional params coming from a parent record
|
925
|
+
matcher.keys.filter((k) => !k.optional).map((k) => k.name)
|
926
|
+
),
|
927
|
+
// discard any existing params in the current location that do not exist here
|
928
|
+
// #1497 this ensures better active/exact matching
|
929
|
+
location2.params && paramsFromLocation(location2.params, matcher.keys.map((k) => k.name))
|
930
|
+
);
|
931
|
+
path = matcher.stringify(params);
|
932
|
+
} else if ("path" in location2) {
|
933
|
+
path = location2.path;
|
934
|
+
if (process.env.NODE_ENV !== "production" && !path.startsWith("/")) {
|
935
|
+
warn(`The Matcher cannot resolve relative paths but received "${path}". Unless you directly called \`matcher.resolve("${path}")\`, this is probably a bug in vue-router. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/router.`);
|
936
|
+
}
|
937
|
+
matcher = matchers.find((m) => m.re.test(path));
|
938
|
+
if (matcher) {
|
939
|
+
params = matcher.parse(path);
|
940
|
+
name = matcher.record.name;
|
941
|
+
}
|
942
|
+
} else {
|
943
|
+
matcher = currentLocation.name ? matcherMap.get(currentLocation.name) : matchers.find((m) => m.re.test(currentLocation.path));
|
944
|
+
if (!matcher)
|
945
|
+
throw createRouterError(1, {
|
946
|
+
location: location2,
|
947
|
+
currentLocation
|
948
|
+
});
|
949
|
+
name = matcher.record.name;
|
950
|
+
params = assign({}, currentLocation.params, location2.params);
|
951
|
+
path = matcher.stringify(params);
|
952
|
+
}
|
953
|
+
const matched = [];
|
954
|
+
let parentMatcher = matcher;
|
955
|
+
while (parentMatcher) {
|
956
|
+
matched.unshift(parentMatcher.record);
|
957
|
+
parentMatcher = parentMatcher.parent;
|
958
|
+
}
|
959
|
+
return {
|
960
|
+
name,
|
961
|
+
path,
|
962
|
+
params,
|
963
|
+
matched,
|
964
|
+
meta: mergeMetaFields(matched)
|
965
|
+
};
|
966
|
+
}
|
967
|
+
routes.forEach((route) => addRoute(route));
|
968
|
+
return { addRoute, resolve, removeRoute, getRoutes, getRecordMatcher };
|
969
|
+
}
|
970
|
+
function paramsFromLocation(params, keys) {
|
971
|
+
const newParams = {};
|
972
|
+
for (const key of keys) {
|
973
|
+
if (key in params)
|
974
|
+
newParams[key] = params[key];
|
975
|
+
}
|
976
|
+
return newParams;
|
977
|
+
}
|
978
|
+
function normalizeRouteRecord(record) {
|
979
|
+
return {
|
980
|
+
path: record.path,
|
981
|
+
redirect: record.redirect,
|
982
|
+
name: record.name,
|
983
|
+
meta: record.meta || {},
|
984
|
+
aliasOf: void 0,
|
985
|
+
beforeEnter: record.beforeEnter,
|
986
|
+
props: normalizeRecordProps(record),
|
987
|
+
children: record.children || [],
|
988
|
+
instances: {},
|
989
|
+
leaveGuards: /* @__PURE__ */ new Set(),
|
990
|
+
updateGuards: /* @__PURE__ */ new Set(),
|
991
|
+
enterCallbacks: {},
|
992
|
+
components: "components" in record ? record.components || null : record.component && { default: record.component }
|
993
|
+
};
|
994
|
+
}
|
995
|
+
function normalizeRecordProps(record) {
|
996
|
+
const propsObject = {};
|
997
|
+
const props = record.props || false;
|
998
|
+
if ("component" in record) {
|
999
|
+
propsObject.default = props;
|
1000
|
+
} else {
|
1001
|
+
for (const name in record.components)
|
1002
|
+
propsObject[name] = typeof props === "boolean" ? props : props[name];
|
1003
|
+
}
|
1004
|
+
return propsObject;
|
1005
|
+
}
|
1006
|
+
function isAliasRecord(record) {
|
1007
|
+
while (record) {
|
1008
|
+
if (record.record.aliasOf)
|
1009
|
+
return true;
|
1010
|
+
record = record.parent;
|
1011
|
+
}
|
1012
|
+
return false;
|
1013
|
+
}
|
1014
|
+
function mergeMetaFields(matched) {
|
1015
|
+
return matched.reduce((meta, record) => assign(meta, record.meta), {});
|
1016
|
+
}
|
1017
|
+
function mergeOptions(defaults, partialOptions) {
|
1018
|
+
const options = {};
|
1019
|
+
for (const key in defaults) {
|
1020
|
+
options[key] = key in partialOptions ? partialOptions[key] : defaults[key];
|
1021
|
+
}
|
1022
|
+
return options;
|
1023
|
+
}
|
1024
|
+
function isSameParam(a, b) {
|
1025
|
+
return a.name === b.name && a.optional === b.optional && a.repeatable === b.repeatable;
|
1026
|
+
}
|
1027
|
+
function checkSameParams(a, b) {
|
1028
|
+
for (const key of a.keys) {
|
1029
|
+
if (!key.optional && !b.keys.find(isSameParam.bind(null, key)))
|
1030
|
+
return warn(`Alias "${b.record.path}" and the original record: "${a.record.path}" must have the exact same param named "${key.name}"`);
|
1031
|
+
}
|
1032
|
+
for (const key of b.keys) {
|
1033
|
+
if (!key.optional && !a.keys.find(isSameParam.bind(null, key)))
|
1034
|
+
return warn(`Alias "${b.record.path}" and the original record: "${a.record.path}" must have the exact same param named "${key.name}"`);
|
1035
|
+
}
|
1036
|
+
}
|
1037
|
+
function checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent) {
|
1038
|
+
if (parent && parent.record.name && !mainNormalizedRecord.name && !mainNormalizedRecord.path) {
|
1039
|
+
warn(`The route named "${String(parent.record.name)}" has a child without a name and an empty path. Using that name won't render the empty path child so you probably want to move the name to the child instead. If this is intentional, add a name to the child route to remove the warning.`);
|
1040
|
+
}
|
1041
|
+
}
|
1042
|
+
function checkMissingParamsInAbsolutePath(record, parent) {
|
1043
|
+
for (const key of parent.keys) {
|
1044
|
+
if (!record.keys.find(isSameParam.bind(null, key)))
|
1045
|
+
return warn(`Absolute path "${record.record.path}" must have the exact same param named "${key.name}" as its parent "${parent.record.path}".`);
|
1046
|
+
}
|
1047
|
+
}
|
1048
|
+
function isRecordChildOf(record, parent) {
|
1049
|
+
return parent.children.some((child) => child === record || isRecordChildOf(record, child));
|
1050
|
+
}
|
1051
|
+
const HASH_RE = /#/g;
|
1052
|
+
const AMPERSAND_RE = /&/g;
|
1053
|
+
const SLASH_RE = /\//g;
|
1054
|
+
const EQUAL_RE = /=/g;
|
1055
|
+
const IM_RE = /\?/g;
|
1056
|
+
const PLUS_RE = /\+/g;
|
1057
|
+
const ENC_BRACKET_OPEN_RE = /%5B/g;
|
1058
|
+
const ENC_BRACKET_CLOSE_RE = /%5D/g;
|
1059
|
+
const ENC_CARET_RE = /%5E/g;
|
1060
|
+
const ENC_BACKTICK_RE = /%60/g;
|
1061
|
+
const ENC_CURLY_OPEN_RE = /%7B/g;
|
1062
|
+
const ENC_PIPE_RE = /%7C/g;
|
1063
|
+
const ENC_CURLY_CLOSE_RE = /%7D/g;
|
1064
|
+
const ENC_SPACE_RE = /%20/g;
|
1065
|
+
function commonEncode(text) {
|
1066
|
+
return encodeURI("" + text).replace(ENC_PIPE_RE, "|").replace(ENC_BRACKET_OPEN_RE, "[").replace(ENC_BRACKET_CLOSE_RE, "]");
|
1067
|
+
}
|
1068
|
+
function encodeHash(text) {
|
1069
|
+
return commonEncode(text).replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
|
1070
|
+
}
|
1071
|
+
function encodeQueryValue(text) {
|
1072
|
+
return commonEncode(text).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
|
1073
|
+
}
|
1074
|
+
function encodeQueryKey(text) {
|
1075
|
+
return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
|
1076
|
+
}
|
1077
|
+
function encodePath(text) {
|
1078
|
+
return commonEncode(text).replace(HASH_RE, "%23").replace(IM_RE, "%3F");
|
1079
|
+
}
|
1080
|
+
function encodeParam(text) {
|
1081
|
+
return text == null ? "" : encodePath(text).replace(SLASH_RE, "%2F");
|
1082
|
+
}
|
1083
|
+
function decode(text) {
|
1084
|
+
try {
|
1085
|
+
return decodeURIComponent("" + text);
|
1086
|
+
} catch (err) {
|
1087
|
+
process.env.NODE_ENV !== "production" && warn(`Error decoding "${text}". Using original value`);
|
1088
|
+
}
|
1089
|
+
return "" + text;
|
1090
|
+
}
|
1091
|
+
function parseQuery(search) {
|
1092
|
+
const query = {};
|
1093
|
+
if (search === "" || search === "?")
|
1094
|
+
return query;
|
1095
|
+
const hasLeadingIM = search[0] === "?";
|
1096
|
+
const searchParams = (hasLeadingIM ? search.slice(1) : search).split("&");
|
1097
|
+
for (let i = 0; i < searchParams.length; ++i) {
|
1098
|
+
const searchParam = searchParams[i].replace(PLUS_RE, " ");
|
1099
|
+
const eqPos = searchParam.indexOf("=");
|
1100
|
+
const key = decode(eqPos < 0 ? searchParam : searchParam.slice(0, eqPos));
|
1101
|
+
const value = eqPos < 0 ? null : decode(searchParam.slice(eqPos + 1));
|
1102
|
+
if (key in query) {
|
1103
|
+
let currentValue = query[key];
|
1104
|
+
if (!isArray(currentValue)) {
|
1105
|
+
currentValue = query[key] = [currentValue];
|
1106
|
+
}
|
1107
|
+
currentValue.push(value);
|
1108
|
+
} else {
|
1109
|
+
query[key] = value;
|
1110
|
+
}
|
1111
|
+
}
|
1112
|
+
return query;
|
1113
|
+
}
|
1114
|
+
function stringifyQuery(query) {
|
1115
|
+
let search = "";
|
1116
|
+
for (let key in query) {
|
1117
|
+
const value = query[key];
|
1118
|
+
key = encodeQueryKey(key);
|
1119
|
+
if (value == null) {
|
1120
|
+
if (value !== void 0) {
|
1121
|
+
search += (search.length ? "&" : "") + key;
|
1122
|
+
}
|
1123
|
+
continue;
|
1124
|
+
}
|
1125
|
+
const values = isArray(value) ? value.map((v) => v && encodeQueryValue(v)) : [value && encodeQueryValue(value)];
|
1126
|
+
values.forEach((value2) => {
|
1127
|
+
if (value2 !== void 0) {
|
1128
|
+
search += (search.length ? "&" : "") + key;
|
1129
|
+
if (value2 != null)
|
1130
|
+
search += "=" + value2;
|
1131
|
+
}
|
1132
|
+
});
|
1133
|
+
}
|
1134
|
+
return search;
|
1135
|
+
}
|
1136
|
+
function normalizeQuery(query) {
|
1137
|
+
const normalizedQuery = {};
|
1138
|
+
for (const key in query) {
|
1139
|
+
const value = query[key];
|
1140
|
+
if (value !== void 0) {
|
1141
|
+
normalizedQuery[key] = isArray(value) ? value.map((v) => v == null ? null : "" + v) : value == null ? value : "" + value;
|
1142
|
+
}
|
1143
|
+
}
|
1144
|
+
return normalizedQuery;
|
1145
|
+
}
|
1146
|
+
const matchedRouteKey = Symbol(process.env.NODE_ENV !== "production" ? "router view location matched" : "");
|
1147
|
+
const viewDepthKey = Symbol(process.env.NODE_ENV !== "production" ? "router view depth" : "");
|
1148
|
+
const routerKey = Symbol(process.env.NODE_ENV !== "production" ? "router" : "");
|
1149
|
+
const routeLocationKey = Symbol(process.env.NODE_ENV !== "production" ? "route location" : "");
|
1150
|
+
const routerViewLocationKey = Symbol(process.env.NODE_ENV !== "production" ? "router view location" : "");
|
1151
|
+
function useCallbacks() {
|
1152
|
+
let handlers = [];
|
1153
|
+
function add(handler) {
|
1154
|
+
handlers.push(handler);
|
1155
|
+
return () => {
|
1156
|
+
const i = handlers.indexOf(handler);
|
1157
|
+
if (i > -1)
|
1158
|
+
handlers.splice(i, 1);
|
1159
|
+
};
|
1160
|
+
}
|
1161
|
+
function reset() {
|
1162
|
+
handlers = [];
|
1163
|
+
}
|
1164
|
+
return {
|
1165
|
+
add,
|
1166
|
+
list: () => handlers,
|
1167
|
+
reset
|
1168
|
+
};
|
1169
|
+
}
|
1170
|
+
function guardToPromiseFn(guard, to, from, record, name) {
|
1171
|
+
const enterCallbackArray = record && // name is defined if record is because of the function overload
|
1172
|
+
(record.enterCallbacks[name] = record.enterCallbacks[name] || []);
|
1173
|
+
return () => new Promise((resolve, reject) => {
|
1174
|
+
const next = (valid) => {
|
1175
|
+
if (valid === false) {
|
1176
|
+
reject(createRouterError(4, {
|
1177
|
+
from,
|
1178
|
+
to
|
1179
|
+
}));
|
1180
|
+
} else if (valid instanceof Error) {
|
1181
|
+
reject(valid);
|
1182
|
+
} else if (isRouteLocation(valid)) {
|
1183
|
+
reject(createRouterError(2, {
|
1184
|
+
from: to,
|
1185
|
+
to: valid
|
1186
|
+
}));
|
1187
|
+
} else {
|
1188
|
+
if (enterCallbackArray && // since enterCallbackArray is truthy, both record and name also are
|
1189
|
+
record.enterCallbacks[name] === enterCallbackArray && typeof valid === "function") {
|
1190
|
+
enterCallbackArray.push(valid);
|
1191
|
+
}
|
1192
|
+
resolve();
|
1193
|
+
}
|
1194
|
+
};
|
1195
|
+
const guardReturn = guard.call(record && record.instances[name], to, from, process.env.NODE_ENV !== "production" ? canOnlyBeCalledOnce(next, to, from) : next);
|
1196
|
+
let guardCall = Promise.resolve(guardReturn);
|
1197
|
+
if (guard.length < 3)
|
1198
|
+
guardCall = guardCall.then(next);
|
1199
|
+
if (process.env.NODE_ENV !== "production" && guard.length > 2) {
|
1200
|
+
const message = `The "next" callback was never called inside of ${guard.name ? '"' + guard.name + '"' : ""}:
|
1201
|
+
${guard.toString()}
|
1202
|
+
. If you are returning a value instead of calling "next", make sure to remove the "next" parameter from your function.`;
|
1203
|
+
if (typeof guardReturn === "object" && "then" in guardReturn) {
|
1204
|
+
guardCall = guardCall.then((resolvedValue) => {
|
1205
|
+
if (!next._called) {
|
1206
|
+
warn(message);
|
1207
|
+
return Promise.reject(new Error("Invalid navigation guard"));
|
1208
|
+
}
|
1209
|
+
return resolvedValue;
|
1210
|
+
});
|
1211
|
+
} else if (guardReturn !== void 0) {
|
1212
|
+
if (!next._called) {
|
1213
|
+
warn(message);
|
1214
|
+
reject(new Error("Invalid navigation guard"));
|
1215
|
+
return;
|
1216
|
+
}
|
1217
|
+
}
|
1218
|
+
}
|
1219
|
+
guardCall.catch((err) => reject(err));
|
1220
|
+
});
|
1221
|
+
}
|
1222
|
+
function canOnlyBeCalledOnce(next, to, from) {
|
1223
|
+
let called = 0;
|
1224
|
+
return function() {
|
1225
|
+
if (called++ === 1)
|
1226
|
+
warn(`The "next" callback was called more than once in one navigation guard when going from "${from.fullPath}" to "${to.fullPath}". It should be called exactly one time in each navigation guard. This will fail in production.`);
|
1227
|
+
next._called = true;
|
1228
|
+
if (called === 1)
|
1229
|
+
next.apply(null, arguments);
|
1230
|
+
};
|
1231
|
+
}
|
1232
|
+
function extractComponentsGuards(matched, guardType, to, from) {
|
1233
|
+
const guards = [];
|
1234
|
+
for (const record of matched) {
|
1235
|
+
if (process.env.NODE_ENV !== "production" && !record.components && !record.children.length) {
|
1236
|
+
warn(`Record with path "${record.path}" is either missing a "component(s)" or "children" property.`);
|
1237
|
+
}
|
1238
|
+
for (const name in record.components) {
|
1239
|
+
let rawComponent = record.components[name];
|
1240
|
+
if (process.env.NODE_ENV !== "production") {
|
1241
|
+
if (!rawComponent || typeof rawComponent !== "object" && typeof rawComponent !== "function") {
|
1242
|
+
warn(`Component "${name}" in record with path "${record.path}" is not a valid component. Received "${String(rawComponent)}".`);
|
1243
|
+
throw new Error("Invalid route component");
|
1244
|
+
} else if ("then" in rawComponent) {
|
1245
|
+
warn(`Component "${name}" in record with path "${record.path}" is a Promise instead of a function that returns a Promise. Did you write "import('./MyPage.vue')" instead of "() => import('./MyPage.vue')" ? This will break in production if not fixed.`);
|
1246
|
+
const promise = rawComponent;
|
1247
|
+
rawComponent = () => promise;
|
1248
|
+
} else if (rawComponent.__asyncLoader && // warn only once per component
|
1249
|
+
!rawComponent.__warnedDefineAsync) {
|
1250
|
+
rawComponent.__warnedDefineAsync = true;
|
1251
|
+
warn(`Component "${name}" in record with path "${record.path}" is defined using "defineAsyncComponent()". Write "() => import('./MyPage.vue')" instead of "defineAsyncComponent(() => import('./MyPage.vue'))".`);
|
1252
|
+
}
|
1253
|
+
}
|
1254
|
+
if (guardType !== "beforeRouteEnter" && !record.instances[name])
|
1255
|
+
continue;
|
1256
|
+
if (isRouteComponent(rawComponent)) {
|
1257
|
+
const options = rawComponent.__vccOpts || rawComponent;
|
1258
|
+
const guard = options[guardType];
|
1259
|
+
guard && guards.push(guardToPromiseFn(guard, to, from, record, name));
|
1260
|
+
} else {
|
1261
|
+
let componentPromise = rawComponent();
|
1262
|
+
if (process.env.NODE_ENV !== "production" && !("catch" in componentPromise)) {
|
1263
|
+
warn(`Component "${name}" in record with path "${record.path}" is a function that does not return a Promise. If you were passing a functional component, make sure to add a "displayName" to the component. This will break in production if not fixed.`);
|
1264
|
+
componentPromise = Promise.resolve(componentPromise);
|
1265
|
+
}
|
1266
|
+
guards.push(() => componentPromise.then((resolved) => {
|
1267
|
+
if (!resolved)
|
1268
|
+
return Promise.reject(new Error(`Couldn't resolve component "${name}" at "${record.path}"`));
|
1269
|
+
const resolvedComponent = isESModule(resolved) ? resolved.default : resolved;
|
1270
|
+
record.components[name] = resolvedComponent;
|
1271
|
+
const options = resolvedComponent.__vccOpts || resolvedComponent;
|
1272
|
+
const guard = options[guardType];
|
1273
|
+
return guard && guardToPromiseFn(guard, to, from, record, name)();
|
1274
|
+
}));
|
1275
|
+
}
|
1276
|
+
}
|
1277
|
+
}
|
1278
|
+
return guards;
|
1279
|
+
}
|
1280
|
+
function isRouteComponent(component) {
|
1281
|
+
return typeof component === "object" || "displayName" in component || "props" in component || "__vccOpts" in component;
|
1282
|
+
}
|
1283
|
+
function useLink(props) {
|
1284
|
+
const router = inject(routerKey);
|
1285
|
+
const currentRoute = inject(routeLocationKey);
|
1286
|
+
const route = computed(() => router.resolve(unref(props.to)));
|
1287
|
+
const activeRecordIndex = computed(() => {
|
1288
|
+
const { matched } = route.value;
|
1289
|
+
const { length } = matched;
|
1290
|
+
const routeMatched = matched[length - 1];
|
1291
|
+
const currentMatched = currentRoute.matched;
|
1292
|
+
if (!routeMatched || !currentMatched.length)
|
1293
|
+
return -1;
|
1294
|
+
const index = currentMatched.findIndex(isSameRouteRecord.bind(null, routeMatched));
|
1295
|
+
if (index > -1)
|
1296
|
+
return index;
|
1297
|
+
const parentRecordPath = getOriginalPath(matched[length - 2]);
|
1298
|
+
return (
|
1299
|
+
// we are dealing with nested routes
|
1300
|
+
length > 1 && // if the parent and matched route have the same path, this link is
|
1301
|
+
// referring to the empty child. Or we currently are on a different
|
1302
|
+
// child of the same parent
|
1303
|
+
getOriginalPath(routeMatched) === parentRecordPath && // avoid comparing the child with its parent
|
1304
|
+
currentMatched[currentMatched.length - 1].path !== parentRecordPath ? currentMatched.findIndex(isSameRouteRecord.bind(null, matched[length - 2])) : index
|
1305
|
+
);
|
1306
|
+
});
|
1307
|
+
const isActive = computed(() => activeRecordIndex.value > -1 && includesParams(currentRoute.params, route.value.params));
|
1308
|
+
const isExactActive = computed(() => activeRecordIndex.value > -1 && activeRecordIndex.value === currentRoute.matched.length - 1 && isSameRouteLocationParams(currentRoute.params, route.value.params));
|
1309
|
+
function navigate(e = {}) {
|
1310
|
+
if (guardEvent(e)) {
|
1311
|
+
return router[unref(props.replace) ? "replace" : "push"](
|
1312
|
+
unref(props.to)
|
1313
|
+
// avoid uncaught errors are they are logged anyway
|
1314
|
+
).catch(noop);
|
1315
|
+
}
|
1316
|
+
return Promise.resolve();
|
1317
|
+
}
|
1318
|
+
if ((process.env.NODE_ENV !== "production" || false) && isBrowser) {
|
1319
|
+
const instance = getCurrentInstance();
|
1320
|
+
if (instance) {
|
1321
|
+
const linkContextDevtools = {
|
1322
|
+
route: route.value,
|
1323
|
+
isActive: isActive.value,
|
1324
|
+
isExactActive: isExactActive.value
|
1325
|
+
};
|
1326
|
+
instance.__vrl_devtools = instance.__vrl_devtools || [];
|
1327
|
+
instance.__vrl_devtools.push(linkContextDevtools);
|
1328
|
+
watchEffect(() => {
|
1329
|
+
linkContextDevtools.route = route.value;
|
1330
|
+
linkContextDevtools.isActive = isActive.value;
|
1331
|
+
linkContextDevtools.isExactActive = isExactActive.value;
|
1332
|
+
}, { flush: "post" });
|
1333
|
+
}
|
1334
|
+
}
|
1335
|
+
return {
|
1336
|
+
route,
|
1337
|
+
href: computed(() => route.value.href),
|
1338
|
+
isActive,
|
1339
|
+
isExactActive,
|
1340
|
+
navigate
|
1341
|
+
};
|
1342
|
+
}
|
1343
|
+
const RouterLinkImpl = /* @__PURE__ */ defineComponent({
|
1344
|
+
name: "RouterLink",
|
1345
|
+
compatConfig: { MODE: 3 },
|
1346
|
+
props: {
|
1347
|
+
to: {
|
1348
|
+
type: [String, Object],
|
1349
|
+
required: true
|
1350
|
+
},
|
1351
|
+
replace: Boolean,
|
1352
|
+
activeClass: String,
|
1353
|
+
// inactiveClass: String,
|
1354
|
+
exactActiveClass: String,
|
1355
|
+
custom: Boolean,
|
1356
|
+
ariaCurrentValue: {
|
1357
|
+
type: String,
|
1358
|
+
default: "page"
|
1359
|
+
}
|
1360
|
+
},
|
1361
|
+
useLink,
|
1362
|
+
setup(props, { slots }) {
|
1363
|
+
const link = reactive(useLink(props));
|
1364
|
+
const { options } = inject(routerKey);
|
1365
|
+
const elClass = computed(() => ({
|
1366
|
+
[getLinkClass(props.activeClass, options.linkActiveClass, "router-link-active")]: link.isActive,
|
1367
|
+
// [getLinkClass(
|
1368
|
+
// props.inactiveClass,
|
1369
|
+
// options.linkInactiveClass,
|
1370
|
+
// 'router-link-inactive'
|
1371
|
+
// )]: !link.isExactActive,
|
1372
|
+
[getLinkClass(props.exactActiveClass, options.linkExactActiveClass, "router-link-exact-active")]: link.isExactActive
|
1373
|
+
}));
|
1374
|
+
return () => {
|
1375
|
+
const children = slots.default && slots.default(link);
|
1376
|
+
return props.custom ? children : h("a", {
|
1377
|
+
"aria-current": link.isExactActive ? props.ariaCurrentValue : null,
|
1378
|
+
href: link.href,
|
1379
|
+
// this would override user added attrs but Vue will still add
|
1380
|
+
// the listener, so we end up triggering both
|
1381
|
+
onClick: link.navigate,
|
1382
|
+
class: elClass.value
|
1383
|
+
}, children);
|
1384
|
+
};
|
1385
|
+
}
|
1386
|
+
});
|
1387
|
+
const RouterLink = RouterLinkImpl;
|
1388
|
+
function guardEvent(e) {
|
1389
|
+
if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)
|
1390
|
+
return;
|
1391
|
+
if (e.defaultPrevented)
|
1392
|
+
return;
|
1393
|
+
if (e.button !== void 0 && e.button !== 0)
|
1394
|
+
return;
|
1395
|
+
if (e.currentTarget && e.currentTarget.getAttribute) {
|
1396
|
+
const target = e.currentTarget.getAttribute("target");
|
1397
|
+
if (/\b_blank\b/i.test(target))
|
1398
|
+
return;
|
1399
|
+
}
|
1400
|
+
if (e.preventDefault)
|
1401
|
+
e.preventDefault();
|
1402
|
+
return true;
|
1403
|
+
}
|
1404
|
+
function includesParams(outer, inner) {
|
1405
|
+
for (const key in inner) {
|
1406
|
+
const innerValue = inner[key];
|
1407
|
+
const outerValue = outer[key];
|
1408
|
+
if (typeof innerValue === "string") {
|
1409
|
+
if (innerValue !== outerValue)
|
1410
|
+
return false;
|
1411
|
+
} else {
|
1412
|
+
if (!isArray(outerValue) || outerValue.length !== innerValue.length || innerValue.some((value, i) => value !== outerValue[i]))
|
1413
|
+
return false;
|
1414
|
+
}
|
1415
|
+
}
|
1416
|
+
return true;
|
1417
|
+
}
|
1418
|
+
function getOriginalPath(record) {
|
1419
|
+
return record ? record.aliasOf ? record.aliasOf.path : record.path : "";
|
1420
|
+
}
|
1421
|
+
const getLinkClass = (propClass, globalClass, defaultClass) => propClass != null ? propClass : globalClass != null ? globalClass : defaultClass;
|
1422
|
+
const RouterViewImpl = /* @__PURE__ */ defineComponent({
|
1423
|
+
name: "RouterView",
|
1424
|
+
// #674 we manually inherit them
|
1425
|
+
inheritAttrs: false,
|
1426
|
+
props: {
|
1427
|
+
name: {
|
1428
|
+
type: String,
|
1429
|
+
default: "default"
|
1430
|
+
},
|
1431
|
+
route: Object
|
1432
|
+
},
|
1433
|
+
// Better compat for @vue/compat users
|
1434
|
+
// https://github.com/vuejs/router/issues/1315
|
1435
|
+
compatConfig: { MODE: 3 },
|
1436
|
+
setup(props, { attrs, slots }) {
|
1437
|
+
process.env.NODE_ENV !== "production" && warnDeprecatedUsage();
|
1438
|
+
const injectedRoute = inject(routerViewLocationKey);
|
1439
|
+
const routeToDisplay = computed(() => props.route || injectedRoute.value);
|
1440
|
+
const injectedDepth = inject(viewDepthKey, 0);
|
1441
|
+
const depth = computed(() => {
|
1442
|
+
let initialDepth = unref(injectedDepth);
|
1443
|
+
const { matched } = routeToDisplay.value;
|
1444
|
+
let matchedRoute;
|
1445
|
+
while ((matchedRoute = matched[initialDepth]) && !matchedRoute.components) {
|
1446
|
+
initialDepth++;
|
1447
|
+
}
|
1448
|
+
return initialDepth;
|
1449
|
+
});
|
1450
|
+
const matchedRouteRef = computed(() => routeToDisplay.value.matched[depth.value]);
|
1451
|
+
provide(viewDepthKey, computed(() => depth.value + 1));
|
1452
|
+
provide(matchedRouteKey, matchedRouteRef);
|
1453
|
+
provide(routerViewLocationKey, routeToDisplay);
|
1454
|
+
const viewRef = ref();
|
1455
|
+
watch(() => [viewRef.value, matchedRouteRef.value, props.name], ([instance, to, name], [oldInstance, from, oldName]) => {
|
1456
|
+
if (to) {
|
1457
|
+
to.instances[name] = instance;
|
1458
|
+
if (from && from !== to && instance && instance === oldInstance) {
|
1459
|
+
if (!to.leaveGuards.size) {
|
1460
|
+
to.leaveGuards = from.leaveGuards;
|
1461
|
+
}
|
1462
|
+
if (!to.updateGuards.size) {
|
1463
|
+
to.updateGuards = from.updateGuards;
|
1464
|
+
}
|
1465
|
+
}
|
1466
|
+
}
|
1467
|
+
if (instance && to && // if there is no instance but to and from are the same this might be
|
1468
|
+
// the first visit
|
1469
|
+
(!from || !isSameRouteRecord(to, from) || !oldInstance)) {
|
1470
|
+
(to.enterCallbacks[name] || []).forEach((callback) => callback(instance));
|
1471
|
+
}
|
1472
|
+
}, { flush: "post" });
|
1473
|
+
return () => {
|
1474
|
+
const route = routeToDisplay.value;
|
1475
|
+
const currentName = props.name;
|
1476
|
+
const matchedRoute = matchedRouteRef.value;
|
1477
|
+
const ViewComponent = matchedRoute && matchedRoute.components[currentName];
|
1478
|
+
if (!ViewComponent) {
|
1479
|
+
return normalizeSlot(slots.default, { Component: ViewComponent, route });
|
1480
|
+
}
|
1481
|
+
const routePropsOption = matchedRoute.props[currentName];
|
1482
|
+
const routeProps = routePropsOption ? routePropsOption === true ? route.params : typeof routePropsOption === "function" ? routePropsOption(route) : routePropsOption : null;
|
1483
|
+
const onVnodeUnmounted = (vnode) => {
|
1484
|
+
if (vnode.component.isUnmounted) {
|
1485
|
+
matchedRoute.instances[currentName] = null;
|
1486
|
+
}
|
1487
|
+
};
|
1488
|
+
const component = h(ViewComponent, assign({}, routeProps, attrs, {
|
1489
|
+
onVnodeUnmounted,
|
1490
|
+
ref: viewRef
|
1491
|
+
}));
|
1492
|
+
if ((process.env.NODE_ENV !== "production" || false) && isBrowser && component.ref) {
|
1493
|
+
const info = {
|
1494
|
+
depth: depth.value,
|
1495
|
+
name: matchedRoute.name,
|
1496
|
+
path: matchedRoute.path,
|
1497
|
+
meta: matchedRoute.meta
|
1498
|
+
};
|
1499
|
+
const internalInstances = isArray(component.ref) ? component.ref.map((r) => r.i) : [component.ref.i];
|
1500
|
+
internalInstances.forEach((instance) => {
|
1501
|
+
instance.__vrv_devtools = info;
|
1502
|
+
});
|
1503
|
+
}
|
1504
|
+
return (
|
1505
|
+
// pass the vnode to the slot as a prop.
|
1506
|
+
// h and <component :is="..."> both accept vnodes
|
1507
|
+
normalizeSlot(slots.default, { Component: component, route }) || component
|
1508
|
+
);
|
1509
|
+
};
|
1510
|
+
}
|
1511
|
+
});
|
1512
|
+
function normalizeSlot(slot, data) {
|
1513
|
+
if (!slot)
|
1514
|
+
return null;
|
1515
|
+
const slotContent = slot(data);
|
1516
|
+
return slotContent.length === 1 ? slotContent[0] : slotContent;
|
1517
|
+
}
|
1518
|
+
const RouterView = RouterViewImpl;
|
1519
|
+
function warnDeprecatedUsage() {
|
1520
|
+
const instance = getCurrentInstance();
|
1521
|
+
const parentName = instance.parent && instance.parent.type.name;
|
1522
|
+
const parentSubTreeType = instance.parent && instance.parent.subTree && instance.parent.subTree.type;
|
1523
|
+
if (parentName && (parentName === "KeepAlive" || parentName.includes("Transition")) && typeof parentSubTreeType === "object" && parentSubTreeType.name === "RouterView") {
|
1524
|
+
const comp = parentName === "KeepAlive" ? "keep-alive" : "transition";
|
1525
|
+
warn(`<router-view> can no longer be used directly inside <transition> or <keep-alive>.
|
1526
|
+
Use slot props instead:
|
1527
|
+
|
1528
|
+
<router-view v-slot="{ Component }">
|
1529
|
+
<${comp}>
|
1530
|
+
<component :is="Component" />
|
1531
|
+
</${comp}>
|
1532
|
+
</router-view>`);
|
1533
|
+
}
|
1534
|
+
}
|
1535
|
+
function formatRouteLocation(routeLocation, tooltip) {
|
1536
|
+
const copy = assign({}, routeLocation, {
|
1537
|
+
// remove variables that can contain vue instances
|
1538
|
+
matched: routeLocation.matched.map((matched) => omit(matched, ["instances", "children", "aliasOf"]))
|
1539
|
+
});
|
1540
|
+
return {
|
1541
|
+
_custom: {
|
1542
|
+
type: null,
|
1543
|
+
readOnly: true,
|
1544
|
+
display: routeLocation.fullPath,
|
1545
|
+
tooltip,
|
1546
|
+
value: copy
|
1547
|
+
}
|
1548
|
+
};
|
1549
|
+
}
|
1550
|
+
function formatDisplay(display) {
|
1551
|
+
return {
|
1552
|
+
_custom: {
|
1553
|
+
display
|
1554
|
+
}
|
1555
|
+
};
|
1556
|
+
}
|
1557
|
+
let routerId = 0;
|
1558
|
+
function addDevtools(app, router, matcher) {
|
1559
|
+
if (router.__hasDevtools)
|
1560
|
+
return;
|
1561
|
+
router.__hasDevtools = true;
|
1562
|
+
const id = routerId++;
|
1563
|
+
setupDevtoolsPlugin({
|
1564
|
+
id: "org.vuejs.router" + (id ? "." + id : ""),
|
1565
|
+
label: "Vue Router",
|
1566
|
+
packageName: "vue-router",
|
1567
|
+
homepage: "https://router.vuejs.org",
|
1568
|
+
logo: "https://router.vuejs.org/logo.png",
|
1569
|
+
componentStateTypes: ["Routing"],
|
1570
|
+
app
|
1571
|
+
}, (api) => {
|
1572
|
+
if (typeof api.now !== "function") {
|
1573
|
+
console.warn("[Vue Router]: You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html.");
|
1574
|
+
}
|
1575
|
+
api.on.inspectComponent((payload, ctx) => {
|
1576
|
+
if (payload.instanceData) {
|
1577
|
+
payload.instanceData.state.push({
|
1578
|
+
type: "Routing",
|
1579
|
+
key: "$route",
|
1580
|
+
editable: false,
|
1581
|
+
value: formatRouteLocation(router.currentRoute.value, "Current Route")
|
1582
|
+
});
|
1583
|
+
}
|
1584
|
+
});
|
1585
|
+
api.on.visitComponentTree(({ treeNode: node, componentInstance }) => {
|
1586
|
+
if (componentInstance.__vrv_devtools) {
|
1587
|
+
const info = componentInstance.__vrv_devtools;
|
1588
|
+
node.tags.push({
|
1589
|
+
label: (info.name ? `${info.name.toString()}: ` : "") + info.path,
|
1590
|
+
textColor: 0,
|
1591
|
+
tooltip: "This component is rendered by <router-view>",
|
1592
|
+
backgroundColor: PINK_500
|
1593
|
+
});
|
1594
|
+
}
|
1595
|
+
if (isArray(componentInstance.__vrl_devtools)) {
|
1596
|
+
componentInstance.__devtoolsApi = api;
|
1597
|
+
componentInstance.__vrl_devtools.forEach((devtoolsData) => {
|
1598
|
+
let backgroundColor = ORANGE_400;
|
1599
|
+
let tooltip = "";
|
1600
|
+
if (devtoolsData.isExactActive) {
|
1601
|
+
backgroundColor = LIME_500;
|
1602
|
+
tooltip = "This is exactly active";
|
1603
|
+
} else if (devtoolsData.isActive) {
|
1604
|
+
backgroundColor = BLUE_600;
|
1605
|
+
tooltip = "This link is active";
|
1606
|
+
}
|
1607
|
+
node.tags.push({
|
1608
|
+
label: devtoolsData.route.path,
|
1609
|
+
textColor: 0,
|
1610
|
+
tooltip,
|
1611
|
+
backgroundColor
|
1612
|
+
});
|
1613
|
+
});
|
1614
|
+
}
|
1615
|
+
});
|
1616
|
+
watch(router.currentRoute, () => {
|
1617
|
+
refreshRoutesView();
|
1618
|
+
api.notifyComponentUpdate();
|
1619
|
+
api.sendInspectorTree(routerInspectorId);
|
1620
|
+
api.sendInspectorState(routerInspectorId);
|
1621
|
+
});
|
1622
|
+
const navigationsLayerId = "router:navigations:" + id;
|
1623
|
+
api.addTimelineLayer({
|
1624
|
+
id: navigationsLayerId,
|
1625
|
+
label: `Router${id ? " " + id : ""} Navigations`,
|
1626
|
+
color: 4237508
|
1627
|
+
});
|
1628
|
+
router.onError((error, to) => {
|
1629
|
+
api.addTimelineEvent({
|
1630
|
+
layerId: navigationsLayerId,
|
1631
|
+
event: {
|
1632
|
+
title: "Error during Navigation",
|
1633
|
+
subtitle: to.fullPath,
|
1634
|
+
logType: "error",
|
1635
|
+
time: api.now(),
|
1636
|
+
data: { error },
|
1637
|
+
groupId: to.meta.__navigationId
|
1638
|
+
}
|
1639
|
+
});
|
1640
|
+
});
|
1641
|
+
let navigationId = 0;
|
1642
|
+
router.beforeEach((to, from) => {
|
1643
|
+
const data = {
|
1644
|
+
guard: formatDisplay("beforeEach"),
|
1645
|
+
from: formatRouteLocation(from, "Current Location during this navigation"),
|
1646
|
+
to: formatRouteLocation(to, "Target location")
|
1647
|
+
};
|
1648
|
+
Object.defineProperty(to.meta, "__navigationId", {
|
1649
|
+
value: navigationId++
|
1650
|
+
});
|
1651
|
+
api.addTimelineEvent({
|
1652
|
+
layerId: navigationsLayerId,
|
1653
|
+
event: {
|
1654
|
+
time: api.now(),
|
1655
|
+
title: "Start of navigation",
|
1656
|
+
subtitle: to.fullPath,
|
1657
|
+
data,
|
1658
|
+
groupId: to.meta.__navigationId
|
1659
|
+
}
|
1660
|
+
});
|
1661
|
+
});
|
1662
|
+
router.afterEach((to, from, failure) => {
|
1663
|
+
const data = {
|
1664
|
+
guard: formatDisplay("afterEach")
|
1665
|
+
};
|
1666
|
+
if (failure) {
|
1667
|
+
data.failure = {
|
1668
|
+
_custom: {
|
1669
|
+
type: Error,
|
1670
|
+
readOnly: true,
|
1671
|
+
display: failure ? failure.message : "",
|
1672
|
+
tooltip: "Navigation Failure",
|
1673
|
+
value: failure
|
1674
|
+
}
|
1675
|
+
};
|
1676
|
+
data.status = formatDisplay("❌");
|
1677
|
+
} else {
|
1678
|
+
data.status = formatDisplay("✅");
|
1679
|
+
}
|
1680
|
+
data.from = formatRouteLocation(from, "Current Location during this navigation");
|
1681
|
+
data.to = formatRouteLocation(to, "Target location");
|
1682
|
+
api.addTimelineEvent({
|
1683
|
+
layerId: navigationsLayerId,
|
1684
|
+
event: {
|
1685
|
+
title: "End of navigation",
|
1686
|
+
subtitle: to.fullPath,
|
1687
|
+
time: api.now(),
|
1688
|
+
data,
|
1689
|
+
logType: failure ? "warning" : "default",
|
1690
|
+
groupId: to.meta.__navigationId
|
1691
|
+
}
|
1692
|
+
});
|
1693
|
+
});
|
1694
|
+
const routerInspectorId = "router-inspector:" + id;
|
1695
|
+
api.addInspector({
|
1696
|
+
id: routerInspectorId,
|
1697
|
+
label: "Routes" + (id ? " " + id : ""),
|
1698
|
+
icon: "book",
|
1699
|
+
treeFilterPlaceholder: "Search routes"
|
1700
|
+
});
|
1701
|
+
function refreshRoutesView() {
|
1702
|
+
if (!activeRoutesPayload)
|
1703
|
+
return;
|
1704
|
+
const payload = activeRoutesPayload;
|
1705
|
+
let routes = matcher.getRoutes().filter((route) => !route.parent);
|
1706
|
+
routes.forEach(resetMatchStateOnRouteRecord);
|
1707
|
+
if (payload.filter) {
|
1708
|
+
routes = routes.filter((route) => (
|
1709
|
+
// save matches state based on the payload
|
1710
|
+
isRouteMatching(route, payload.filter.toLowerCase())
|
1711
|
+
));
|
1712
|
+
}
|
1713
|
+
routes.forEach((route) => markRouteRecordActive(route, router.currentRoute.value));
|
1714
|
+
payload.rootNodes = routes.map(formatRouteRecordForInspector);
|
1715
|
+
}
|
1716
|
+
let activeRoutesPayload;
|
1717
|
+
api.on.getInspectorTree((payload) => {
|
1718
|
+
activeRoutesPayload = payload;
|
1719
|
+
if (payload.app === app && payload.inspectorId === routerInspectorId) {
|
1720
|
+
refreshRoutesView();
|
1721
|
+
}
|
1722
|
+
});
|
1723
|
+
api.on.getInspectorState((payload) => {
|
1724
|
+
if (payload.app === app && payload.inspectorId === routerInspectorId) {
|
1725
|
+
const routes = matcher.getRoutes();
|
1726
|
+
const route = routes.find((route2) => route2.record.__vd_id === payload.nodeId);
|
1727
|
+
if (route) {
|
1728
|
+
payload.state = {
|
1729
|
+
options: formatRouteRecordMatcherForStateInspector(route)
|
1730
|
+
};
|
1731
|
+
}
|
1732
|
+
}
|
1733
|
+
});
|
1734
|
+
api.sendInspectorTree(routerInspectorId);
|
1735
|
+
api.sendInspectorState(routerInspectorId);
|
1736
|
+
});
|
1737
|
+
}
|
1738
|
+
function modifierForKey(key) {
|
1739
|
+
if (key.optional) {
|
1740
|
+
return key.repeatable ? "*" : "?";
|
1741
|
+
} else {
|
1742
|
+
return key.repeatable ? "+" : "";
|
1743
|
+
}
|
1744
|
+
}
|
1745
|
+
function formatRouteRecordMatcherForStateInspector(route) {
|
1746
|
+
const { record } = route;
|
1747
|
+
const fields = [
|
1748
|
+
{ editable: false, key: "path", value: record.path }
|
1749
|
+
];
|
1750
|
+
if (record.name != null) {
|
1751
|
+
fields.push({
|
1752
|
+
editable: false,
|
1753
|
+
key: "name",
|
1754
|
+
value: record.name
|
1755
|
+
});
|
1756
|
+
}
|
1757
|
+
fields.push({ editable: false, key: "regexp", value: route.re });
|
1758
|
+
if (route.keys.length) {
|
1759
|
+
fields.push({
|
1760
|
+
editable: false,
|
1761
|
+
key: "keys",
|
1762
|
+
value: {
|
1763
|
+
_custom: {
|
1764
|
+
type: null,
|
1765
|
+
readOnly: true,
|
1766
|
+
display: route.keys.map((key) => `${key.name}${modifierForKey(key)}`).join(" "),
|
1767
|
+
tooltip: "Param keys",
|
1768
|
+
value: route.keys
|
1769
|
+
}
|
1770
|
+
}
|
1771
|
+
});
|
1772
|
+
}
|
1773
|
+
if (record.redirect != null) {
|
1774
|
+
fields.push({
|
1775
|
+
editable: false,
|
1776
|
+
key: "redirect",
|
1777
|
+
value: record.redirect
|
1778
|
+
});
|
1779
|
+
}
|
1780
|
+
if (route.alias.length) {
|
1781
|
+
fields.push({
|
1782
|
+
editable: false,
|
1783
|
+
key: "aliases",
|
1784
|
+
value: route.alias.map((alias) => alias.record.path)
|
1785
|
+
});
|
1786
|
+
}
|
1787
|
+
if (Object.keys(route.record.meta).length) {
|
1788
|
+
fields.push({
|
1789
|
+
editable: false,
|
1790
|
+
key: "meta",
|
1791
|
+
value: route.record.meta
|
1792
|
+
});
|
1793
|
+
}
|
1794
|
+
fields.push({
|
1795
|
+
key: "score",
|
1796
|
+
editable: false,
|
1797
|
+
value: {
|
1798
|
+
_custom: {
|
1799
|
+
type: null,
|
1800
|
+
readOnly: true,
|
1801
|
+
display: route.score.map((score) => score.join(", ")).join(" | "),
|
1802
|
+
tooltip: "Score used to sort routes",
|
1803
|
+
value: route.score
|
1804
|
+
}
|
1805
|
+
}
|
1806
|
+
});
|
1807
|
+
return fields;
|
1808
|
+
}
|
1809
|
+
const PINK_500 = 15485081;
|
1810
|
+
const BLUE_600 = 2450411;
|
1811
|
+
const LIME_500 = 8702998;
|
1812
|
+
const CYAN_400 = 2282478;
|
1813
|
+
const ORANGE_400 = 16486972;
|
1814
|
+
const DARK = 6710886;
|
1815
|
+
function formatRouteRecordForInspector(route) {
|
1816
|
+
const tags = [];
|
1817
|
+
const { record } = route;
|
1818
|
+
if (record.name != null) {
|
1819
|
+
tags.push({
|
1820
|
+
label: String(record.name),
|
1821
|
+
textColor: 0,
|
1822
|
+
backgroundColor: CYAN_400
|
1823
|
+
});
|
1824
|
+
}
|
1825
|
+
if (record.aliasOf) {
|
1826
|
+
tags.push({
|
1827
|
+
label: "alias",
|
1828
|
+
textColor: 0,
|
1829
|
+
backgroundColor: ORANGE_400
|
1830
|
+
});
|
1831
|
+
}
|
1832
|
+
if (route.__vd_match) {
|
1833
|
+
tags.push({
|
1834
|
+
label: "matches",
|
1835
|
+
textColor: 0,
|
1836
|
+
backgroundColor: PINK_500
|
1837
|
+
});
|
1838
|
+
}
|
1839
|
+
if (route.__vd_exactActive) {
|
1840
|
+
tags.push({
|
1841
|
+
label: "exact",
|
1842
|
+
textColor: 0,
|
1843
|
+
backgroundColor: LIME_500
|
1844
|
+
});
|
1845
|
+
}
|
1846
|
+
if (route.__vd_active) {
|
1847
|
+
tags.push({
|
1848
|
+
label: "active",
|
1849
|
+
textColor: 0,
|
1850
|
+
backgroundColor: BLUE_600
|
1851
|
+
});
|
1852
|
+
}
|
1853
|
+
if (record.redirect) {
|
1854
|
+
tags.push({
|
1855
|
+
label: typeof record.redirect === "string" ? `redirect: ${record.redirect}` : "redirects",
|
1856
|
+
textColor: 16777215,
|
1857
|
+
backgroundColor: DARK
|
1858
|
+
});
|
1859
|
+
}
|
1860
|
+
let id = record.__vd_id;
|
1861
|
+
if (id == null) {
|
1862
|
+
id = String(routeRecordId++);
|
1863
|
+
record.__vd_id = id;
|
1864
|
+
}
|
1865
|
+
return {
|
1866
|
+
id,
|
1867
|
+
label: record.path,
|
1868
|
+
tags,
|
1869
|
+
children: route.children.map(formatRouteRecordForInspector)
|
1870
|
+
};
|
1871
|
+
}
|
1872
|
+
let routeRecordId = 0;
|
1873
|
+
const EXTRACT_REGEXP_RE = /^\/(.*)\/([a-z]*)$/;
|
1874
|
+
function markRouteRecordActive(route, currentRoute) {
|
1875
|
+
const isExactActive = currentRoute.matched.length && isSameRouteRecord(currentRoute.matched[currentRoute.matched.length - 1], route.record);
|
1876
|
+
route.__vd_exactActive = route.__vd_active = isExactActive;
|
1877
|
+
if (!isExactActive) {
|
1878
|
+
route.__vd_active = currentRoute.matched.some((match) => isSameRouteRecord(match, route.record));
|
1879
|
+
}
|
1880
|
+
route.children.forEach((childRoute) => markRouteRecordActive(childRoute, currentRoute));
|
1881
|
+
}
|
1882
|
+
function resetMatchStateOnRouteRecord(route) {
|
1883
|
+
route.__vd_match = false;
|
1884
|
+
route.children.forEach(resetMatchStateOnRouteRecord);
|
1885
|
+
}
|
1886
|
+
function isRouteMatching(route, filter) {
|
1887
|
+
const found = String(route.re).match(EXTRACT_REGEXP_RE);
|
1888
|
+
route.__vd_match = false;
|
1889
|
+
if (!found || found.length < 3) {
|
1890
|
+
return false;
|
1891
|
+
}
|
1892
|
+
const nonEndingRE = new RegExp(found[1].replace(/\$$/, ""), found[2]);
|
1893
|
+
if (nonEndingRE.test(filter)) {
|
1894
|
+
route.children.forEach((child) => isRouteMatching(child, filter));
|
1895
|
+
if (route.record.path !== "/" || filter === "/") {
|
1896
|
+
route.__vd_match = route.re.test(filter);
|
1897
|
+
return true;
|
1898
|
+
}
|
1899
|
+
return false;
|
1900
|
+
}
|
1901
|
+
const path = route.record.path.toLowerCase();
|
1902
|
+
const decodedPath = decode(path);
|
1903
|
+
if (!filter.startsWith("/") && (decodedPath.includes(filter) || path.includes(filter)))
|
1904
|
+
return true;
|
1905
|
+
if (decodedPath.startsWith(filter) || path.startsWith(filter))
|
1906
|
+
return true;
|
1907
|
+
if (route.record.name && String(route.record.name).includes(filter))
|
1908
|
+
return true;
|
1909
|
+
return route.children.some((child) => isRouteMatching(child, filter));
|
1910
|
+
}
|
1911
|
+
function omit(obj, keys) {
|
1912
|
+
const ret = {};
|
1913
|
+
for (const key in obj) {
|
1914
|
+
if (!keys.includes(key)) {
|
1915
|
+
ret[key] = obj[key];
|
1916
|
+
}
|
1917
|
+
}
|
1918
|
+
return ret;
|
1919
|
+
}
|
1920
|
+
function createRouter(options) {
|
1921
|
+
const matcher = createRouterMatcher(options.routes, options);
|
1922
|
+
const parseQuery$1 = options.parseQuery || parseQuery;
|
1923
|
+
const stringifyQuery$1 = options.stringifyQuery || stringifyQuery;
|
1924
|
+
const routerHistory = options.history;
|
1925
|
+
if (process.env.NODE_ENV !== "production" && !routerHistory)
|
1926
|
+
throw new Error('Provide the "history" option when calling "createRouter()": https://next.router.vuejs.org/api/#history.');
|
1927
|
+
const beforeGuards = useCallbacks();
|
1928
|
+
const beforeResolveGuards = useCallbacks();
|
1929
|
+
const afterGuards = useCallbacks();
|
1930
|
+
const currentRoute = shallowRef(START_LOCATION_NORMALIZED);
|
1931
|
+
let pendingLocation = START_LOCATION_NORMALIZED;
|
1932
|
+
if (isBrowser && options.scrollBehavior && "scrollRestoration" in history) {
|
1933
|
+
history.scrollRestoration = "manual";
|
1934
|
+
}
|
1935
|
+
const normalizeParams = applyToParams.bind(null, (paramValue) => "" + paramValue);
|
1936
|
+
const encodeParams = applyToParams.bind(null, encodeParam);
|
1937
|
+
const decodeParams = (
|
1938
|
+
// @ts-expect-error: intentionally avoid the type check
|
1939
|
+
applyToParams.bind(null, decode)
|
1940
|
+
);
|
1941
|
+
function addRoute(parentOrRoute, route) {
|
1942
|
+
let parent;
|
1943
|
+
let record;
|
1944
|
+
if (isRouteName(parentOrRoute)) {
|
1945
|
+
parent = matcher.getRecordMatcher(parentOrRoute);
|
1946
|
+
record = route;
|
1947
|
+
} else {
|
1948
|
+
record = parentOrRoute;
|
1949
|
+
}
|
1950
|
+
return matcher.addRoute(record, parent);
|
1951
|
+
}
|
1952
|
+
function removeRoute(name) {
|
1953
|
+
const recordMatcher = matcher.getRecordMatcher(name);
|
1954
|
+
if (recordMatcher) {
|
1955
|
+
matcher.removeRoute(recordMatcher);
|
1956
|
+
} else if (process.env.NODE_ENV !== "production") {
|
1957
|
+
warn(`Cannot remove non-existent route "${String(name)}"`);
|
1958
|
+
}
|
1959
|
+
}
|
1960
|
+
function getRoutes() {
|
1961
|
+
return matcher.getRoutes().map((routeMatcher) => routeMatcher.record);
|
1962
|
+
}
|
1963
|
+
function hasRoute(name) {
|
1964
|
+
return !!matcher.getRecordMatcher(name);
|
1965
|
+
}
|
1966
|
+
function resolve(rawLocation, currentLocation) {
|
1967
|
+
currentLocation = assign({}, currentLocation || currentRoute.value);
|
1968
|
+
if (typeof rawLocation === "string") {
|
1969
|
+
const locationNormalized = parseURL(parseQuery$1, rawLocation, currentLocation.path);
|
1970
|
+
const matchedRoute2 = matcher.resolve({ path: locationNormalized.path }, currentLocation);
|
1971
|
+
const href2 = routerHistory.createHref(locationNormalized.fullPath);
|
1972
|
+
if (process.env.NODE_ENV !== "production") {
|
1973
|
+
if (href2.startsWith("//"))
|
1974
|
+
warn(`Location "${rawLocation}" resolved to "${href2}". A resolved location cannot start with multiple slashes.`);
|
1975
|
+
else if (!matchedRoute2.matched.length) {
|
1976
|
+
warn(`No match found for location with path "${rawLocation}"`);
|
1977
|
+
}
|
1978
|
+
}
|
1979
|
+
return assign(locationNormalized, matchedRoute2, {
|
1980
|
+
params: decodeParams(matchedRoute2.params),
|
1981
|
+
hash: decode(locationNormalized.hash),
|
1982
|
+
redirectedFrom: void 0,
|
1983
|
+
href: href2
|
1984
|
+
});
|
1985
|
+
}
|
1986
|
+
let matcherLocation;
|
1987
|
+
if ("path" in rawLocation) {
|
1988
|
+
if (process.env.NODE_ENV !== "production" && "params" in rawLocation && !("name" in rawLocation) && // @ts-expect-error: the type is never
|
1989
|
+
Object.keys(rawLocation.params).length) {
|
1990
|
+
warn(`Path "${rawLocation.path}" was passed with params but they will be ignored. Use a named route alongside params instead.`);
|
1991
|
+
}
|
1992
|
+
matcherLocation = assign({}, rawLocation, {
|
1993
|
+
path: parseURL(parseQuery$1, rawLocation.path, currentLocation.path).path
|
1994
|
+
});
|
1995
|
+
} else {
|
1996
|
+
const targetParams = assign({}, rawLocation.params);
|
1997
|
+
for (const key in targetParams) {
|
1998
|
+
if (targetParams[key] == null) {
|
1999
|
+
delete targetParams[key];
|
2000
|
+
}
|
2001
|
+
}
|
2002
|
+
matcherLocation = assign({}, rawLocation, {
|
2003
|
+
params: encodeParams(targetParams)
|
2004
|
+
});
|
2005
|
+
currentLocation.params = encodeParams(currentLocation.params);
|
2006
|
+
}
|
2007
|
+
const matchedRoute = matcher.resolve(matcherLocation, currentLocation);
|
2008
|
+
const hash = rawLocation.hash || "";
|
2009
|
+
if (process.env.NODE_ENV !== "production" && hash && !hash.startsWith("#")) {
|
2010
|
+
warn(`A \`hash\` should always start with the character "#". Replace "${hash}" with "#${hash}".`);
|
2011
|
+
}
|
2012
|
+
matchedRoute.params = normalizeParams(decodeParams(matchedRoute.params));
|
2013
|
+
const fullPath = stringifyURL(stringifyQuery$1, assign({}, rawLocation, {
|
2014
|
+
hash: encodeHash(hash),
|
2015
|
+
path: matchedRoute.path
|
2016
|
+
}));
|
2017
|
+
const href = routerHistory.createHref(fullPath);
|
2018
|
+
if (process.env.NODE_ENV !== "production") {
|
2019
|
+
if (href.startsWith("//")) {
|
2020
|
+
warn(`Location "${rawLocation}" resolved to "${href}". A resolved location cannot start with multiple slashes.`);
|
2021
|
+
} else if (!matchedRoute.matched.length) {
|
2022
|
+
warn(`No match found for location with path "${"path" in rawLocation ? rawLocation.path : rawLocation}"`);
|
2023
|
+
}
|
2024
|
+
}
|
2025
|
+
return assign({
|
2026
|
+
fullPath,
|
2027
|
+
// keep the hash encoded so fullPath is effectively path + encodedQuery +
|
2028
|
+
// hash
|
2029
|
+
hash,
|
2030
|
+
query: (
|
2031
|
+
// if the user is using a custom query lib like qs, we might have
|
2032
|
+
// nested objects, so we keep the query as is, meaning it can contain
|
2033
|
+
// numbers at `$route.query`, but at the point, the user will have to
|
2034
|
+
// use their own type anyway.
|
2035
|
+
// https://github.com/vuejs/router/issues/328#issuecomment-649481567
|
2036
|
+
stringifyQuery$1 === stringifyQuery ? normalizeQuery(rawLocation.query) : rawLocation.query || {}
|
2037
|
+
)
|
2038
|
+
}, matchedRoute, {
|
2039
|
+
redirectedFrom: void 0,
|
2040
|
+
href
|
2041
|
+
});
|
2042
|
+
}
|
2043
|
+
function locationAsObject(to) {
|
2044
|
+
return typeof to === "string" ? parseURL(parseQuery$1, to, currentRoute.value.path) : assign({}, to);
|
2045
|
+
}
|
2046
|
+
function checkCanceledNavigation(to, from) {
|
2047
|
+
if (pendingLocation !== to) {
|
2048
|
+
return createRouterError(8, {
|
2049
|
+
from,
|
2050
|
+
to
|
2051
|
+
});
|
2052
|
+
}
|
2053
|
+
}
|
2054
|
+
function push(to) {
|
2055
|
+
return pushWithRedirect(to);
|
2056
|
+
}
|
2057
|
+
function replace(to) {
|
2058
|
+
return push(assign(locationAsObject(to), { replace: true }));
|
2059
|
+
}
|
2060
|
+
function handleRedirectRecord(to) {
|
2061
|
+
const lastMatched = to.matched[to.matched.length - 1];
|
2062
|
+
if (lastMatched && lastMatched.redirect) {
|
2063
|
+
const { redirect } = lastMatched;
|
2064
|
+
let newTargetLocation = typeof redirect === "function" ? redirect(to) : redirect;
|
2065
|
+
if (typeof newTargetLocation === "string") {
|
2066
|
+
newTargetLocation = newTargetLocation.includes("?") || newTargetLocation.includes("#") ? newTargetLocation = locationAsObject(newTargetLocation) : (
|
2067
|
+
// force empty params
|
2068
|
+
{ path: newTargetLocation }
|
2069
|
+
);
|
2070
|
+
newTargetLocation.params = {};
|
2071
|
+
}
|
2072
|
+
if (process.env.NODE_ENV !== "production" && !("path" in newTargetLocation) && !("name" in newTargetLocation)) {
|
2073
|
+
warn(`Invalid redirect found:
|
2074
|
+
${JSON.stringify(newTargetLocation, null, 2)}
|
2075
|
+
when navigating to "${to.fullPath}". A redirect must contain a name or path. This will break in production.`);
|
2076
|
+
throw new Error("Invalid redirect");
|
2077
|
+
}
|
2078
|
+
return assign({
|
2079
|
+
query: to.query,
|
2080
|
+
hash: to.hash,
|
2081
|
+
// avoid transferring params if the redirect has a path
|
2082
|
+
params: "path" in newTargetLocation ? {} : to.params
|
2083
|
+
}, newTargetLocation);
|
2084
|
+
}
|
2085
|
+
}
|
2086
|
+
function pushWithRedirect(to, redirectedFrom) {
|
2087
|
+
const targetLocation = pendingLocation = resolve(to);
|
2088
|
+
const from = currentRoute.value;
|
2089
|
+
const data = to.state;
|
2090
|
+
const force = to.force;
|
2091
|
+
const replace2 = to.replace === true;
|
2092
|
+
const shouldRedirect = handleRedirectRecord(targetLocation);
|
2093
|
+
if (shouldRedirect)
|
2094
|
+
return pushWithRedirect(
|
2095
|
+
assign(locationAsObject(shouldRedirect), {
|
2096
|
+
state: typeof shouldRedirect === "object" ? assign({}, data, shouldRedirect.state) : data,
|
2097
|
+
force,
|
2098
|
+
replace: replace2
|
2099
|
+
}),
|
2100
|
+
// keep original redirectedFrom if it exists
|
2101
|
+
redirectedFrom || targetLocation
|
2102
|
+
);
|
2103
|
+
const toLocation = targetLocation;
|
2104
|
+
toLocation.redirectedFrom = redirectedFrom;
|
2105
|
+
let failure;
|
2106
|
+
if (!force && isSameRouteLocation(stringifyQuery$1, from, targetLocation)) {
|
2107
|
+
failure = createRouterError(16, { to: toLocation, from });
|
2108
|
+
handleScroll(
|
2109
|
+
from,
|
2110
|
+
from,
|
2111
|
+
// this is a push, the only way for it to be triggered from a
|
2112
|
+
// history.listen is with a redirect, which makes it become a push
|
2113
|
+
true,
|
2114
|
+
// This cannot be the first navigation because the initial location
|
2115
|
+
// cannot be manually navigated to
|
2116
|
+
false
|
2117
|
+
);
|
2118
|
+
}
|
2119
|
+
return (failure ? Promise.resolve(failure) : navigate(toLocation, from)).catch((error) => isNavigationFailure(error) ? (
|
2120
|
+
// navigation redirects still mark the router as ready
|
2121
|
+
isNavigationFailure(
|
2122
|
+
error,
|
2123
|
+
2
|
2124
|
+
/* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
|
2125
|
+
) ? error : markAsReady(error)
|
2126
|
+
) : (
|
2127
|
+
// reject any unknown error
|
2128
|
+
triggerError(error, toLocation, from)
|
2129
|
+
)).then((failure2) => {
|
2130
|
+
if (failure2) {
|
2131
|
+
if (isNavigationFailure(
|
2132
|
+
failure2,
|
2133
|
+
2
|
2134
|
+
/* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
|
2135
|
+
)) {
|
2136
|
+
if (process.env.NODE_ENV !== "production" && // we are redirecting to the same location we were already at
|
2137
|
+
isSameRouteLocation(stringifyQuery$1, resolve(failure2.to), toLocation) && // and we have done it a couple of times
|
2138
|
+
redirectedFrom && // @ts-expect-error: added only in dev
|
2139
|
+
(redirectedFrom._count = redirectedFrom._count ? (
|
2140
|
+
// @ts-expect-error
|
2141
|
+
redirectedFrom._count + 1
|
2142
|
+
) : 1) > 30) {
|
2143
|
+
warn(`Detected a possibly infinite redirection in a navigation guard when going from "${from.fullPath}" to "${toLocation.fullPath}". Aborting to avoid a Stack Overflow.
|
2144
|
+
Are you always returning a new location within a navigation guard? That would lead to this error. Only return when redirecting or aborting, that should fix this. This might break in production if not fixed.`);
|
2145
|
+
return Promise.reject(new Error("Infinite redirect in navigation guard"));
|
2146
|
+
}
|
2147
|
+
return pushWithRedirect(
|
2148
|
+
// keep options
|
2149
|
+
assign({
|
2150
|
+
// preserve an existing replacement but allow the redirect to override it
|
2151
|
+
replace: replace2
|
2152
|
+
}, locationAsObject(failure2.to), {
|
2153
|
+
state: typeof failure2.to === "object" ? assign({}, data, failure2.to.state) : data,
|
2154
|
+
force
|
2155
|
+
}),
|
2156
|
+
// preserve the original redirectedFrom if any
|
2157
|
+
redirectedFrom || toLocation
|
2158
|
+
);
|
2159
|
+
}
|
2160
|
+
} else {
|
2161
|
+
failure2 = finalizeNavigation(toLocation, from, true, replace2, data);
|
2162
|
+
}
|
2163
|
+
triggerAfterEach(toLocation, from, failure2);
|
2164
|
+
return failure2;
|
2165
|
+
});
|
2166
|
+
}
|
2167
|
+
function checkCanceledNavigationAndReject(to, from) {
|
2168
|
+
const error = checkCanceledNavigation(to, from);
|
2169
|
+
return error ? Promise.reject(error) : Promise.resolve();
|
2170
|
+
}
|
2171
|
+
function runWithContext(fn) {
|
2172
|
+
const app = installedApps.values().next().value;
|
2173
|
+
return app && typeof app.runWithContext === "function" ? app.runWithContext(fn) : fn();
|
2174
|
+
}
|
2175
|
+
function navigate(to, from) {
|
2176
|
+
let guards;
|
2177
|
+
const [leavingRecords, updatingRecords, enteringRecords] = extractChangingRecords(to, from);
|
2178
|
+
guards = extractComponentsGuards(leavingRecords.reverse(), "beforeRouteLeave", to, from);
|
2179
|
+
for (const record of leavingRecords) {
|
2180
|
+
record.leaveGuards.forEach((guard) => {
|
2181
|
+
guards.push(guardToPromiseFn(guard, to, from));
|
2182
|
+
});
|
2183
|
+
}
|
2184
|
+
const canceledNavigationCheck = checkCanceledNavigationAndReject.bind(null, to, from);
|
2185
|
+
guards.push(canceledNavigationCheck);
|
2186
|
+
return runGuardQueue(guards).then(() => {
|
2187
|
+
guards = [];
|
2188
|
+
for (const guard of beforeGuards.list()) {
|
2189
|
+
guards.push(guardToPromiseFn(guard, to, from));
|
2190
|
+
}
|
2191
|
+
guards.push(canceledNavigationCheck);
|
2192
|
+
return runGuardQueue(guards);
|
2193
|
+
}).then(() => {
|
2194
|
+
guards = extractComponentsGuards(updatingRecords, "beforeRouteUpdate", to, from);
|
2195
|
+
for (const record of updatingRecords) {
|
2196
|
+
record.updateGuards.forEach((guard) => {
|
2197
|
+
guards.push(guardToPromiseFn(guard, to, from));
|
2198
|
+
});
|
2199
|
+
}
|
2200
|
+
guards.push(canceledNavigationCheck);
|
2201
|
+
return runGuardQueue(guards);
|
2202
|
+
}).then(() => {
|
2203
|
+
guards = [];
|
2204
|
+
for (const record of to.matched) {
|
2205
|
+
if (record.beforeEnter && !from.matched.includes(record)) {
|
2206
|
+
if (isArray(record.beforeEnter)) {
|
2207
|
+
for (const beforeEnter of record.beforeEnter)
|
2208
|
+
guards.push(guardToPromiseFn(beforeEnter, to, from));
|
2209
|
+
} else {
|
2210
|
+
guards.push(guardToPromiseFn(record.beforeEnter, to, from));
|
2211
|
+
}
|
2212
|
+
}
|
2213
|
+
}
|
2214
|
+
guards.push(canceledNavigationCheck);
|
2215
|
+
return runGuardQueue(guards);
|
2216
|
+
}).then(() => {
|
2217
|
+
to.matched.forEach((record) => record.enterCallbacks = {});
|
2218
|
+
guards = extractComponentsGuards(enteringRecords, "beforeRouteEnter", to, from);
|
2219
|
+
guards.push(canceledNavigationCheck);
|
2220
|
+
return runGuardQueue(guards);
|
2221
|
+
}).then(() => {
|
2222
|
+
guards = [];
|
2223
|
+
for (const guard of beforeResolveGuards.list()) {
|
2224
|
+
guards.push(guardToPromiseFn(guard, to, from));
|
2225
|
+
}
|
2226
|
+
guards.push(canceledNavigationCheck);
|
2227
|
+
return runGuardQueue(guards);
|
2228
|
+
}).catch((err) => isNavigationFailure(
|
2229
|
+
err,
|
2230
|
+
8
|
2231
|
+
/* ErrorTypes.NAVIGATION_CANCELLED */
|
2232
|
+
) ? err : Promise.reject(err));
|
2233
|
+
}
|
2234
|
+
function triggerAfterEach(to, from, failure) {
|
2235
|
+
for (const guard of afterGuards.list()) {
|
2236
|
+
runWithContext(() => guard(to, from, failure));
|
2237
|
+
}
|
2238
|
+
}
|
2239
|
+
function finalizeNavigation(toLocation, from, isPush, replace2, data) {
|
2240
|
+
const error = checkCanceledNavigation(toLocation, from);
|
2241
|
+
if (error)
|
2242
|
+
return error;
|
2243
|
+
const isFirstNavigation = from === START_LOCATION_NORMALIZED;
|
2244
|
+
const state = !isBrowser ? {} : history.state;
|
2245
|
+
if (isPush) {
|
2246
|
+
if (replace2 || isFirstNavigation)
|
2247
|
+
routerHistory.replace(toLocation.fullPath, assign({
|
2248
|
+
scroll: isFirstNavigation && state && state.scroll
|
2249
|
+
}, data));
|
2250
|
+
else
|
2251
|
+
routerHistory.push(toLocation.fullPath, data);
|
2252
|
+
}
|
2253
|
+
currentRoute.value = toLocation;
|
2254
|
+
handleScroll(toLocation, from, isPush, isFirstNavigation);
|
2255
|
+
markAsReady();
|
2256
|
+
}
|
2257
|
+
let removeHistoryListener;
|
2258
|
+
function setupListeners() {
|
2259
|
+
if (removeHistoryListener)
|
2260
|
+
return;
|
2261
|
+
removeHistoryListener = routerHistory.listen((to, _from, info) => {
|
2262
|
+
if (!router.listening)
|
2263
|
+
return;
|
2264
|
+
const toLocation = resolve(to);
|
2265
|
+
const shouldRedirect = handleRedirectRecord(toLocation);
|
2266
|
+
if (shouldRedirect) {
|
2267
|
+
pushWithRedirect(assign(shouldRedirect, { replace: true }), toLocation).catch(noop);
|
2268
|
+
return;
|
2269
|
+
}
|
2270
|
+
pendingLocation = toLocation;
|
2271
|
+
const from = currentRoute.value;
|
2272
|
+
if (isBrowser) {
|
2273
|
+
saveScrollPosition(getScrollKey(from.fullPath, info.delta), computeScrollPosition());
|
2274
|
+
}
|
2275
|
+
navigate(toLocation, from).catch((error) => {
|
2276
|
+
if (isNavigationFailure(
|
2277
|
+
error,
|
2278
|
+
4 | 8
|
2279
|
+
/* ErrorTypes.NAVIGATION_CANCELLED */
|
2280
|
+
)) {
|
2281
|
+
return error;
|
2282
|
+
}
|
2283
|
+
if (isNavigationFailure(
|
2284
|
+
error,
|
2285
|
+
2
|
2286
|
+
/* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
|
2287
|
+
)) {
|
2288
|
+
pushWithRedirect(
|
2289
|
+
error.to,
|
2290
|
+
toLocation
|
2291
|
+
// avoid an uncaught rejection, let push call triggerError
|
2292
|
+
).then((failure) => {
|
2293
|
+
if (isNavigationFailure(
|
2294
|
+
failure,
|
2295
|
+
4 | 16
|
2296
|
+
/* ErrorTypes.NAVIGATION_DUPLICATED */
|
2297
|
+
) && !info.delta && info.type === NavigationType.pop) {
|
2298
|
+
routerHistory.go(-1, false);
|
2299
|
+
}
|
2300
|
+
}).catch(noop);
|
2301
|
+
return Promise.reject();
|
2302
|
+
}
|
2303
|
+
if (info.delta) {
|
2304
|
+
routerHistory.go(-info.delta, false);
|
2305
|
+
}
|
2306
|
+
return triggerError(error, toLocation, from);
|
2307
|
+
}).then((failure) => {
|
2308
|
+
failure = failure || finalizeNavigation(
|
2309
|
+
// after navigation, all matched components are resolved
|
2310
|
+
toLocation,
|
2311
|
+
from,
|
2312
|
+
false
|
2313
|
+
);
|
2314
|
+
if (failure) {
|
2315
|
+
if (info.delta && // a new navigation has been triggered, so we do not want to revert, that will change the current history
|
2316
|
+
// entry while a different route is displayed
|
2317
|
+
!isNavigationFailure(
|
2318
|
+
failure,
|
2319
|
+
8
|
2320
|
+
/* ErrorTypes.NAVIGATION_CANCELLED */
|
2321
|
+
)) {
|
2322
|
+
routerHistory.go(-info.delta, false);
|
2323
|
+
} else if (info.type === NavigationType.pop && isNavigationFailure(
|
2324
|
+
failure,
|
2325
|
+
4 | 16
|
2326
|
+
/* ErrorTypes.NAVIGATION_DUPLICATED */
|
2327
|
+
)) {
|
2328
|
+
routerHistory.go(-1, false);
|
2329
|
+
}
|
2330
|
+
}
|
2331
|
+
triggerAfterEach(toLocation, from, failure);
|
2332
|
+
}).catch(noop);
|
2333
|
+
});
|
2334
|
+
}
|
2335
|
+
let readyHandlers = useCallbacks();
|
2336
|
+
let errorHandlers = useCallbacks();
|
2337
|
+
let ready;
|
2338
|
+
function triggerError(error, to, from) {
|
2339
|
+
markAsReady(error);
|
2340
|
+
const list = errorHandlers.list();
|
2341
|
+
if (list.length) {
|
2342
|
+
list.forEach((handler) => handler(error, to, from));
|
2343
|
+
} else {
|
2344
|
+
if (process.env.NODE_ENV !== "production") {
|
2345
|
+
warn("uncaught error during route navigation:");
|
2346
|
+
}
|
2347
|
+
console.error(error);
|
2348
|
+
}
|
2349
|
+
return Promise.reject(error);
|
2350
|
+
}
|
2351
|
+
function isReady() {
|
2352
|
+
if (ready && currentRoute.value !== START_LOCATION_NORMALIZED)
|
2353
|
+
return Promise.resolve();
|
2354
|
+
return new Promise((resolve2, reject) => {
|
2355
|
+
readyHandlers.add([resolve2, reject]);
|
2356
|
+
});
|
2357
|
+
}
|
2358
|
+
function markAsReady(err) {
|
2359
|
+
if (!ready) {
|
2360
|
+
ready = !err;
|
2361
|
+
setupListeners();
|
2362
|
+
readyHandlers.list().forEach(([resolve2, reject]) => err ? reject(err) : resolve2());
|
2363
|
+
readyHandlers.reset();
|
2364
|
+
}
|
2365
|
+
return err;
|
2366
|
+
}
|
2367
|
+
function handleScroll(to, from, isPush, isFirstNavigation) {
|
2368
|
+
const { scrollBehavior } = options;
|
2369
|
+
if (!isBrowser || !scrollBehavior)
|
2370
|
+
return Promise.resolve();
|
2371
|
+
const scrollPosition = !isPush && getSavedScrollPosition(getScrollKey(to.fullPath, 0)) || (isFirstNavigation || !isPush) && history.state && history.state.scroll || null;
|
2372
|
+
return nextTick().then(() => scrollBehavior(to, from, scrollPosition)).then((position) => position && scrollToPosition(position)).catch((err) => triggerError(err, to, from));
|
2373
|
+
}
|
2374
|
+
const go = (delta) => routerHistory.go(delta);
|
2375
|
+
let started;
|
2376
|
+
const installedApps = /* @__PURE__ */ new Set();
|
2377
|
+
const router = {
|
2378
|
+
currentRoute,
|
2379
|
+
listening: true,
|
2380
|
+
addRoute,
|
2381
|
+
removeRoute,
|
2382
|
+
hasRoute,
|
2383
|
+
getRoutes,
|
2384
|
+
resolve,
|
2385
|
+
options,
|
2386
|
+
push,
|
2387
|
+
replace,
|
2388
|
+
go,
|
2389
|
+
back: () => go(-1),
|
2390
|
+
forward: () => go(1),
|
2391
|
+
beforeEach: beforeGuards.add,
|
2392
|
+
beforeResolve: beforeResolveGuards.add,
|
2393
|
+
afterEach: afterGuards.add,
|
2394
|
+
onError: errorHandlers.add,
|
2395
|
+
isReady,
|
2396
|
+
install(app) {
|
2397
|
+
const router2 = this;
|
2398
|
+
app.component("RouterLink", RouterLink);
|
2399
|
+
app.component("RouterView", RouterView);
|
2400
|
+
app.config.globalProperties.$router = router2;
|
2401
|
+
Object.defineProperty(app.config.globalProperties, "$route", {
|
2402
|
+
enumerable: true,
|
2403
|
+
get: () => unref(currentRoute)
|
2404
|
+
});
|
2405
|
+
if (isBrowser && // used for the initial navigation client side to avoid pushing
|
2406
|
+
// multiple times when the router is used in multiple apps
|
2407
|
+
!started && currentRoute.value === START_LOCATION_NORMALIZED) {
|
2408
|
+
started = true;
|
2409
|
+
push(routerHistory.location).catch((err) => {
|
2410
|
+
if (process.env.NODE_ENV !== "production")
|
2411
|
+
warn("Unexpected error when starting the router:", err);
|
2412
|
+
});
|
2413
|
+
}
|
2414
|
+
const reactiveRoute = {};
|
2415
|
+
for (const key in START_LOCATION_NORMALIZED) {
|
2416
|
+
reactiveRoute[key] = computed(() => currentRoute.value[key]);
|
2417
|
+
}
|
2418
|
+
app.provide(routerKey, router2);
|
2419
|
+
app.provide(routeLocationKey, reactive(reactiveRoute));
|
2420
|
+
app.provide(routerViewLocationKey, currentRoute);
|
2421
|
+
const unmountApp = app.unmount;
|
2422
|
+
installedApps.add(app);
|
2423
|
+
app.unmount = function() {
|
2424
|
+
installedApps.delete(app);
|
2425
|
+
if (installedApps.size < 1) {
|
2426
|
+
pendingLocation = START_LOCATION_NORMALIZED;
|
2427
|
+
removeHistoryListener && removeHistoryListener();
|
2428
|
+
removeHistoryListener = null;
|
2429
|
+
currentRoute.value = START_LOCATION_NORMALIZED;
|
2430
|
+
started = false;
|
2431
|
+
ready = false;
|
2432
|
+
}
|
2433
|
+
unmountApp();
|
2434
|
+
};
|
2435
|
+
if ((process.env.NODE_ENV !== "production" || false) && isBrowser) {
|
2436
|
+
addDevtools(app, router2, matcher);
|
2437
|
+
}
|
2438
|
+
}
|
2439
|
+
};
|
2440
|
+
function runGuardQueue(guards) {
|
2441
|
+
return guards.reduce((promise, guard) => promise.then(() => runWithContext(guard)), Promise.resolve());
|
2442
|
+
}
|
2443
|
+
return router;
|
2444
|
+
}
|
2445
|
+
function extractChangingRecords(to, from) {
|
2446
|
+
const leavingRecords = [];
|
2447
|
+
const updatingRecords = [];
|
2448
|
+
const enteringRecords = [];
|
2449
|
+
const len = Math.max(from.matched.length, to.matched.length);
|
2450
|
+
for (let i = 0; i < len; i++) {
|
2451
|
+
const recordFrom = from.matched[i];
|
2452
|
+
if (recordFrom) {
|
2453
|
+
if (to.matched.find((record) => isSameRouteRecord(record, recordFrom)))
|
2454
|
+
updatingRecords.push(recordFrom);
|
2455
|
+
else
|
2456
|
+
leavingRecords.push(recordFrom);
|
2457
|
+
}
|
2458
|
+
const recordTo = to.matched[i];
|
2459
|
+
if (recordTo) {
|
2460
|
+
if (!from.matched.find((record) => isSameRouteRecord(record, recordTo))) {
|
2461
|
+
enteringRecords.push(recordTo);
|
2462
|
+
}
|
2463
|
+
}
|
2464
|
+
}
|
2465
|
+
return [leavingRecords, updatingRecords, enteringRecords];
|
2466
|
+
}
|
2467
|
+
export {
|
2468
|
+
NavigationFailureType,
|
2469
|
+
RouterLink,
|
2470
|
+
RouterView,
|
2471
|
+
START_LOCATION_NORMALIZED as START_LOCATION,
|
2472
|
+
createRouter,
|
2473
|
+
createRouterMatcher,
|
2474
|
+
createWebHistory,
|
2475
|
+
isNavigationFailure,
|
2476
|
+
matchedRouteKey,
|
2477
|
+
parseQuery,
|
2478
|
+
routeLocationKey,
|
2479
|
+
routerKey,
|
2480
|
+
routerViewLocationKey,
|
2481
|
+
stringifyQuery,
|
2482
|
+
useLink,
|
2483
|
+
viewDepthKey
|
2484
|
+
};
|