react-grab 0.1.28 → 0.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -138
- package/dist/core/index.cjs +9 -1
- package/dist/core/index.d.cts +11 -3
- package/dist/core/index.d.ts +11 -3
- package/dist/core/index.js +9 -1
- package/dist/core--H_JZk7a.js +16 -0
- package/dist/core-1AoeBJ2R.cjs +4386 -0
- package/dist/core-4VC4A94S.js +4249 -0
- package/dist/core-5Q_6LVh_.cjs +16 -0
- package/dist/core-6sOn3YNs.js +16 -0
- package/dist/core-B3FYVaHv.cjs +16 -0
- package/dist/core-B3I0upO1.js +4250 -0
- package/dist/core-B3ndcALq.cjs +4386 -0
- package/dist/core-B9GWVp1Q.js +16 -0
- package/dist/core-BGIMywNa.js +16 -0
- package/dist/core-BGK4C6ju.js +16 -0
- package/dist/core-BGXprTx7.cjs +16 -0
- package/dist/core-BKt5SHzo.js +16 -0
- package/dist/core-BMObVYUv.cjs +16 -0
- package/dist/core-BNMx90Sn.js +16 -0
- package/dist/core-BWQ6C5g9.js +4268 -0
- package/dist/core-BcwRbSfO.js +16 -0
- package/dist/core-Be-1ubQn.cjs +16 -0
- package/dist/core-BfpPi7c6.cjs +16 -0
- package/dist/core-BiIoWLRk.js +16 -0
- package/dist/core-BjpyJHlW.js +16 -0
- package/dist/core-Bqf3D4Ra.cjs +16 -0
- package/dist/core-Bs0wekHY.cjs +4284 -0
- package/dist/core-Bvqgv6Zr.js +16 -0
- package/dist/core-Bw0-Cecq.cjs +16 -0
- package/dist/core-BzRpJ5QI.cjs +4284 -0
- package/dist/core-C0ZgNdUR.cjs +4386 -0
- package/dist/core-C191WXKe.cjs +16 -0
- package/dist/core-C4yYleJn.js +16 -0
- package/dist/core-C758xgeI.js +16 -0
- package/dist/core-CAZ8ENTv.js +16 -0
- package/dist/core-CBUFmwfx.cjs +4386 -0
- package/dist/core-CDV48I9C.js +4249 -0
- package/dist/core-CGXCsSkm.js +4280 -0
- package/dist/core-CHsFU9FZ.js +16 -0
- package/dist/core-CJOQfSzq.js +4495 -0
- package/dist/core-CLW9tl4L.js +4249 -0
- package/dist/core-CP1yCnSB.js +16 -0
- package/dist/core-CRLyvQCt.cjs +16 -0
- package/dist/core-CZX3EijL.js +16 -0
- package/dist/core-Ccli-yLf.cjs +16 -0
- package/dist/core-Ce4pBUSh.js +16 -0
- package/dist/core-CgCGjXfB.cjs +16 -0
- package/dist/core-CiQl2PfF.cjs +16 -0
- package/dist/core-CnPpGWUc.js +16 -0
- package/dist/core-Co9954wQ.cjs +16 -0
- package/dist/core-Cr4qVf2a.js +16 -0
- package/dist/core-CrQCbm00.js +16 -0
- package/dist/core-CsCg35MW.js +16 -0
- package/dist/core-Cshs0orb.js +16 -0
- package/dist/core-CthjfoZX.cjs +16 -0
- package/dist/core-CtvavOAt.cjs +16 -0
- package/dist/core-CvoFTVjy.cjs +16 -0
- package/dist/core-CzE8I9NL.cjs +16 -0
- package/dist/core-CzGijRTx.js +16 -0
- package/dist/core-CzosrDdO.cjs +16 -0
- package/dist/core-D--fM7Xq.cjs +16 -0
- package/dist/core-D-UGQb_Z.cjs +16 -0
- package/dist/core-D0UqPwu_.cjs +16 -0
- package/dist/core-D2LzIluw.js +4495 -0
- package/dist/core-D4z4W-Qz.cjs +16 -0
- package/dist/core-D7NwJuzy.js +16 -0
- package/dist/core-DCqMIKkK.js +16 -0
- package/dist/core-DFrvwczh.cjs +4284 -0
- package/dist/core-DGxxKKPR.cjs +16 -0
- package/dist/core-DGyQeEXa.js +4495 -0
- package/dist/core-DH8Uvag-.js +4249 -0
- package/dist/core-DHZBYfsC.js +16 -0
- package/dist/core-DKVj078o.js +4249 -0
- package/dist/core-DMRsaGr7.js +16 -0
- package/dist/core-DRUnXCNA.cjs +16 -0
- package/dist/core-DRlG4zYm.cjs +16 -0
- package/dist/core-DSqJwwdV.cjs +4284 -0
- package/dist/core-DXqmRz53.cjs +16 -0
- package/dist/core-DcRxqPad.js +16 -0
- package/dist/core-DdNOX4pt.js +16 -0
- package/dist/core-Df7CMRnd.cjs +4315 -0
- package/dist/core-DiIZA6Hx.js +4495 -0
- package/dist/core-DiVnlonK.cjs +4284 -0
- package/dist/core-Dj1WV911.js +4495 -0
- package/dist/core-DjPDxMID.cjs +16 -0
- package/dist/core-DjcnHWor.cjs +16 -0
- package/dist/core-DkWjrEUZ.cjs +16 -0
- package/dist/core-Dq-CCsij.cjs +4303 -0
- package/dist/core-DsVAkMs2.js +16 -0
- package/dist/core-DueMb4P6.js +4249 -0
- package/dist/core-DvJt5JmX.js +16 -0
- package/dist/core-Dz8Hrc33.js +4249 -0
- package/dist/core-ESHKG2mL.cjs +4285 -0
- package/dist/core-Ij_B_RWV.cjs +16 -0
- package/dist/core-JyczI7kP.cjs +16 -0
- package/dist/core-K0XuILjf.cjs +4284 -0
- package/dist/core-N9HyYpZv.cjs +16 -0
- package/dist/core-PW2DC2Tb.js +4495 -0
- package/dist/core-Q84EBsQ8.cjs +16 -0
- package/dist/core-TSuD8D7m.js +16 -0
- package/dist/core-WN76m9V0.cjs +16 -0
- package/dist/core-YRKn-0AV.js +16 -0
- package/dist/core-fC6GdbUJ.js +16 -0
- package/dist/core-h5q7bqH-.cjs +4284 -0
- package/dist/core-hkgBRD_T.js +16 -0
- package/dist/core-k9l5c9Hk.cjs +16 -0
- package/dist/core-mNhkpUYQ.cjs +16 -0
- package/dist/core-qCvYE9Ox.cjs +4386 -0
- package/dist/core-rvs2FEMH.js +16 -0
- package/dist/core-sXzUCmoJ.js +16 -0
- package/dist/core-t7gaYHyj.cjs +4386 -0
- package/dist/core-thci-YqL.js +16 -0
- package/dist/core-xokESdbC.cjs +16 -0
- package/dist/core-yW0MN96-.cjs +16 -0
- package/dist/core-ydFCYlV4.js +16 -0
- package/dist/core-zQ4jjKHw.cjs +16 -0
- package/dist/extract-element-css-B-R_28uM.cjs +10 -0
- package/dist/extract-element-css-B732tro7.js +10 -0
- package/dist/extract-element-css-B9Xh1wUd.js +10 -0
- package/dist/extract-element-css-BGZPWnck.js +10 -0
- package/dist/extract-element-css-BIniUwQh.js +319 -0
- package/dist/extract-element-css-BOQUDYB3.cjs +10 -0
- package/dist/extract-element-css-BTzDGIs3.cjs +336 -0
- package/dist/extract-element-css-BWUnsvjZ.js +10 -0
- package/dist/extract-element-css-BceTcL6y.cjs +10 -0
- package/dist/extract-element-css-Bi1y8V4z.cjs +336 -0
- package/dist/extract-element-css-Bra6hEzg.js +319 -0
- package/dist/extract-element-css-BuJ3zqGO.js +10 -0
- package/dist/extract-element-css-C8lBuGP7.js +10 -0
- package/dist/extract-element-css-CBHVjrBq.cjs +10 -0
- package/dist/extract-element-css-CGxXdwim.js +10 -0
- package/dist/extract-element-css-CJx4cesM.js +10 -0
- package/dist/extract-element-css-CQBJAbFD.cjs +10 -0
- package/dist/extract-element-css-CQV8FsMB.cjs +10 -0
- package/dist/extract-element-css-CQx4Biqa.cjs +336 -0
- package/dist/extract-element-css-CTy2pRfA.js +10 -0
- package/dist/extract-element-css-CchtITXx.cjs +336 -0
- package/dist/extract-element-css-CjY9vDS6.js +10 -0
- package/dist/extract-element-css-ClnG20sN.cjs +10 -0
- package/dist/extract-element-css-CmMetO-q.cjs +10 -0
- package/dist/extract-element-css-CmOD6UeE.cjs +10 -0
- package/dist/extract-element-css-CnY9b0vB.js +10 -0
- package/dist/extract-element-css-CoQLNjVI.js +10 -0
- package/dist/extract-element-css-CqjmXl0Y.cjs +10 -0
- package/dist/extract-element-css-Cr29xtzW.cjs +10 -0
- package/dist/extract-element-css-CzNVoJEM.js +319 -0
- package/dist/extract-element-css-CzgC7nM9.cjs +10 -0
- package/dist/extract-element-css-D3Dy-3Qz.js +10 -0
- package/dist/extract-element-css-D5qqKVc-.cjs +10 -0
- package/dist/extract-element-css-D5zsPw09.cjs +10 -0
- package/dist/extract-element-css-D6UwJjf4.cjs +336 -0
- package/dist/extract-element-css-DEuA2W6G.js +10 -0
- package/dist/extract-element-css-DKkUiIlS.cjs +10 -0
- package/dist/extract-element-css-DM0EhhXw.cjs +10 -0
- package/dist/extract-element-css-DPA6C_o-.cjs +10 -0
- package/dist/extract-element-css-DU45xRGh.js +10 -0
- package/dist/extract-element-css-DUvYlz4T.js +10 -0
- package/dist/extract-element-css-DVDr5Tn6.cjs +10 -0
- package/dist/extract-element-css-Di9hCigW.js +319 -0
- package/dist/extract-element-css-DivFxCRt.js +319 -0
- package/dist/extract-element-css-DlDbU4YM.cjs +10 -0
- package/dist/extract-element-css-DsssOqcQ.cjs +10 -0
- package/dist/extract-element-css-EnvrIHtf.cjs +336 -0
- package/dist/extract-element-css-FI71J_KB.js +10 -0
- package/dist/extract-element-css-GdDDlzTf.js +10 -0
- package/dist/extract-element-css-U3MgLHty.cjs +10 -0
- package/dist/extract-element-css-U4oxl-UP.js +10 -0
- package/dist/extract-element-css-VyMIgOZy.js +10 -0
- package/dist/extract-element-css-XGv0WWIL.js +319 -0
- package/dist/extract-element-css-Y-x4luJL.cjs +10 -0
- package/dist/extract-element-css-Zz_CgLqY.js +319 -0
- package/dist/extract-element-css-_aFPl5y4.cjs +336 -0
- package/dist/extract-element-css-_uZRVqCT.cjs +10 -0
- package/dist/extract-element-css-i8nzXODQ.js +10 -0
- package/dist/extract-element-css-jh1iLRzJ.js +10 -0
- package/dist/extract-element-css-nkJQc3j1.js +10 -0
- package/dist/freeze-updates--K1ecmFi.cjs +44 -0
- package/dist/freeze-updates-1FTXgIdb.js +44 -0
- package/dist/freeze-updates-3QjTocF-.cjs +2267 -0
- package/dist/freeze-updates-81f5sY45.js +44 -0
- package/dist/freeze-updates-B1mPDmJB.js +44 -0
- package/dist/freeze-updates-B5h8teL6.cjs +44 -0
- package/dist/freeze-updates-BAYe0Nlx.js +44 -0
- package/dist/freeze-updates-BDhlBp3V.js +44 -0
- package/dist/freeze-updates-BGa9CqrW.cjs +2267 -0
- package/dist/freeze-updates-BQH6Y8E1.cjs +44 -0
- package/dist/freeze-updates-BQjWBzy4.cjs +53 -0
- package/dist/freeze-updates-BSOSfpXo.js +44 -0
- package/dist/freeze-updates-BT-s67nK.js +53 -0
- package/dist/freeze-updates-BUJeYIm5.js +44 -0
- package/dist/freeze-updates-BVDrqUzf.js +2498 -0
- package/dist/freeze-updates-BVX0QSXz.cjs +44 -0
- package/dist/freeze-updates-BXMr6a9g.cjs +2912 -0
- package/dist/freeze-updates-BZpmCVDl.cjs +2267 -0
- package/dist/freeze-updates-BbbID39H.js +1866 -0
- package/dist/freeze-updates-BdnJ5RrP.js +1866 -0
- package/dist/freeze-updates-Bj59uWit.cjs +44 -0
- package/dist/freeze-updates-Bla3E0Kv.js +53 -0
- package/dist/freeze-updates-BoYyIB3V.cjs +44 -0
- package/dist/freeze-updates-C2TqDiTp.cjs +44 -0
- package/dist/freeze-updates-C6Tg4EoW.js +44 -0
- package/dist/freeze-updates-C7c9TRvJ.cjs +44 -0
- package/dist/freeze-updates-CPNAwtsl.cjs +2267 -0
- package/dist/freeze-updates-CTP39zuf.js +44 -0
- package/dist/freeze-updates-Cm3EVm_J.cjs +53 -0
- package/dist/freeze-updates-CnSZEKoI.cjs +44 -0
- package/dist/freeze-updates-CrKe4F0s.js +44 -0
- package/dist/freeze-updates-CtYFeM4D.cjs +2267 -0
- package/dist/freeze-updates-CxYFvPj9.cjs +53 -0
- package/dist/freeze-updates-D10Qj9Ec.cjs +44 -0
- package/dist/freeze-updates-D6o46vBw.cjs +44 -0
- package/dist/freeze-updates-D7XFQ3_T.js +53 -0
- package/dist/freeze-updates-D8H25gFt.js +44 -0
- package/dist/freeze-updates-DCpGX7lt.cjs +44 -0
- package/dist/freeze-updates-DG3hLEL2.cjs +44 -0
- package/dist/freeze-updates-DO_M76qf.js +44 -0
- package/dist/freeze-updates-Db4Id665.cjs +2267 -0
- package/dist/freeze-updates-DbL_EXkN.js +1866 -0
- package/dist/freeze-updates-DcvNGCcR.cjs +44 -0
- package/dist/freeze-updates-Dh4GiYXz.cjs +44 -0
- package/dist/freeze-updates-DkKJK_nh.cjs +44 -0
- package/dist/freeze-updates-DmB-ndqy.cjs +44 -0
- package/dist/freeze-updates-DnAA3QYp.cjs +44 -0
- package/dist/freeze-updates-Dpj8jndD.js +44 -0
- package/dist/freeze-updates-DuHXIi3M.js +44 -0
- package/dist/freeze-updates-DwERlFID.js +1866 -0
- package/dist/freeze-updates-HHyWtz8f.cjs +44 -0
- package/dist/freeze-updates-JRZCAR0q.js +1866 -0
- package/dist/freeze-updates-KLyCac_c.js +44 -0
- package/dist/freeze-updates-MaNDvTJS.js +1866 -0
- package/dist/freeze-updates-REe44rww.js +44 -0
- package/dist/freeze-updates-TPRkNnYY.js +44 -0
- package/dist/freeze-updates-WfKs4yF4.js +44 -0
- package/dist/freeze-updates-d9yH0V6A.cjs +44 -0
- package/dist/freeze-updates-nzZkxjqN.js +44 -0
- package/dist/freeze-updates-q_DMlHq7.js +44 -0
- package/dist/index-0hhKx6KA.d.ts +534 -0
- package/dist/index-5oOhE8Ae.d.cts +123 -0
- package/dist/index-BA23Z7zi.d.ts +77 -0
- package/dist/index-BAbHDCJb.d.ts +190 -0
- package/dist/index-BN1ZJhWK.d.cts +471 -0
- package/dist/index-BNt_9BO7.d.ts +77 -0
- package/dist/index-BQIO-ZFv.d.cts +190 -0
- package/dist/index-BTQxeAz1.d.cts +123 -0
- package/dist/index-BxsI0BlT.d.ts +471 -0
- package/dist/index-BzzHoNRc.d.cts +77 -0
- package/dist/index-C0Scq3kL.d.ts +458 -0
- package/dist/index-CAHLDDjY.d.ts +190 -0
- package/dist/index-CIJ7ossb.d.ts +190 -0
- package/dist/index-CJqujqsv.d.cts +190 -0
- package/dist/index-CJrVDk2d.d.ts +470 -0
- package/dist/index-CQBZI4f5.d.cts +458 -0
- package/dist/index-CS3VHZ8R.d.cts +77 -0
- package/dist/index-CWd5aKyK.d.ts +123 -0
- package/dist/index-DM3Ga1zc.d.ts +123 -0
- package/dist/index-DYp_9VQ_.d.cts +470 -0
- package/dist/index-DrK-HiGj.d.ts +203 -0
- package/dist/index-GwiDNOsl.d.ts +457 -0
- package/dist/index-QLMT7NRw.d.cts +203 -0
- package/dist/index-QLi1BtdI.d.cts +190 -0
- package/dist/index-sM3yy652.d.cts +534 -0
- package/dist/index-zvkV7Xwg.d.cts +457 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +21 -12
- package/dist/index.d.ts +21 -12
- package/dist/index.global.js +26 -101
- package/dist/index.iife.js +43 -0
- package/dist/index.js +2 -2
- package/dist/primitives.cjs +2 -2
- package/dist/primitives.d.cts +20 -13
- package/dist/primitives.d.ts +20 -13
- package/dist/primitives.js +2 -2
- package/dist/renderer--AVNuclr.js +9 -0
- package/dist/renderer--bWj0AZJ.js +4101 -0
- package/dist/renderer--cF4pvND.js +9 -0
- package/dist/renderer-0mo5bvxE.js +4126 -0
- package/dist/renderer-4Wa-UMC5.cjs +9 -0
- package/dist/renderer-6D9KbSAS.js +9 -0
- package/dist/renderer-7mjLlkgX.cjs +9 -0
- package/dist/renderer-B0v-2J0H.js +9 -0
- package/dist/renderer-B0yJsSRz.js +9 -0
- package/dist/renderer-B660bBKn.cjs +9 -0
- package/dist/renderer-B6m2pWq1.cjs +4102 -0
- package/dist/renderer-BA_yjKW4.cjs +9 -0
- package/dist/renderer-BDCne7IL.cjs +9 -0
- package/dist/renderer-BDKG-8eW.js +9 -0
- package/dist/renderer-BEisX7lt.js +9 -0
- package/dist/renderer-BEnSHrkN.cjs +9 -0
- package/dist/renderer-BJQHCki_.js +9 -0
- package/dist/renderer-BLEQ0lBg.js +9 -0
- package/dist/renderer-BQMe9vbO.cjs +9 -0
- package/dist/renderer-BZfQAWt2.cjs +9 -0
- package/dist/renderer-BZypunFM.cjs +9 -0
- package/dist/renderer-Be1I1mDW.cjs +9 -0
- package/dist/renderer-Bhrtihjr.cjs +9 -0
- package/dist/renderer-Bp3dRMPA.js +9 -0
- package/dist/renderer-BqYgf0tD.js +9 -0
- package/dist/renderer-BwD9ZaGr.cjs +9 -0
- package/dist/renderer-BxCRcsEK.cjs +4125 -0
- package/dist/renderer-C1Wrh8hn.js +9 -0
- package/dist/renderer-C6pztTyv.js +9 -0
- package/dist/renderer-C9bCr3pC.js +4101 -0
- package/dist/renderer-CEmrAuyA.js +9 -0
- package/dist/renderer-CG1lpM8J.cjs +9 -0
- package/dist/renderer-CIJhv1xD.js +9 -0
- package/dist/renderer-CJ3EovD7.js +9 -0
- package/dist/renderer-CJVIzi67.js +4114 -0
- package/dist/renderer-CKAmRN9i.cjs +9 -0
- package/dist/renderer-CNa9jW2d.js +9 -0
- package/dist/renderer-CS6q5sh-.cjs +4101 -0
- package/dist/renderer-CTip7L4z.cjs +4114 -0
- package/dist/renderer-Cdh6G3WO.cjs +4101 -0
- package/dist/renderer-Cfnc_J-x.js +9 -0
- package/dist/renderer-CidbOiiO.js +9 -0
- package/dist/renderer-CooL8OD4.cjs +9 -0
- package/dist/renderer-Cp8W_Vpj.cjs +4101 -0
- package/dist/renderer-Ctq4IL1w.cjs +9 -0
- package/dist/renderer-D0gZDp8v.js +9 -0
- package/dist/renderer-D2Ius1-3.cjs +9 -0
- package/dist/renderer-D2gUuAUv.cjs +9 -0
- package/dist/renderer-D6qQGrNF.js +9 -0
- package/dist/renderer-D9RBf9He.js +9 -0
- package/dist/renderer-DDpyudCh.js +9 -0
- package/dist/renderer-DEo9eIZj.cjs +9 -0
- package/dist/renderer-DHBz10-G.js +9 -0
- package/dist/renderer-DM6gVYD_.cjs +4126 -0
- package/dist/renderer-DS5wjL1R.cjs +9 -0
- package/dist/renderer-DWZQjHeF.cjs +4101 -0
- package/dist/renderer-DZ-EdxOj.cjs +9 -0
- package/dist/renderer-DblZTrea.js +9 -0
- package/dist/renderer-DcPiCh7r.js +4114 -0
- package/dist/renderer-Dfj6tfg9.cjs +4139 -0
- package/dist/renderer-DhoYb1PY.js +4103 -0
- package/dist/renderer-Dl6awT_I.cjs +9 -0
- package/dist/renderer-DmOXobMF.js +4101 -0
- package/dist/renderer-DmlAyeq6.cjs +4114 -0
- package/dist/renderer-DnwizF3I.cjs +9 -0
- package/dist/renderer-Dpzs-uao.js +4125 -0
- package/dist/renderer-Ds21virZ.cjs +4145 -0
- package/dist/renderer-DslAAsKS.js +4101 -0
- package/dist/renderer-DtBv4wTu.js +4102 -0
- package/dist/renderer-DxuOYfZN.cjs +9 -0
- package/dist/renderer-DyrsoA_r.js +9 -0
- package/dist/renderer-GlgUXTaV.js +9 -0
- package/dist/renderer-KL2bSyIW.cjs +9 -0
- package/dist/renderer-N_yFJNWi.cjs +9 -0
- package/dist/renderer-TkTQ8ZzV.cjs +4101 -0
- package/dist/renderer-WtWG_Uzr.js +4139 -0
- package/dist/renderer-YPWUo91d.cjs +9 -0
- package/dist/renderer-foaHR93_.js +9 -0
- package/dist/renderer-irss7gH9.js +9 -0
- package/dist/renderer-kNWgh9RH.js +9 -0
- package/dist/renderer-l2DsHbX5.js +4145 -0
- package/dist/renderer-lRGat4eI.js +9 -0
- package/dist/renderer-m1ynwV5m.cjs +9 -0
- package/dist/renderer-oDWZTt10.cjs +9 -0
- package/dist/renderer-ruVxrW9_.cjs +9 -0
- package/dist/renderer-tLg9bC5E.cjs +4103 -0
- package/dist/renderer-wKL03A96.cjs +9 -0
- package/dist/renderer-xY7WwwPb.cjs +9 -0
- package/dist/renderer-yNfPLGJa.js +4101 -0
- package/dist/renderer-zFA8Xsqn.js +9 -0
- package/dist/state-0zvRag7o.js +1832 -0
- package/dist/state-1bNOTRwX.js +9 -0
- package/dist/state-4KlM-876.cjs +9 -0
- package/dist/state-5YzsfKSg.js +9 -0
- package/dist/state-B2sO7SGs.cjs +9 -0
- package/dist/state-B30FVO9-.cjs +9 -0
- package/dist/state-BBF5Yd6R.cjs +1488 -0
- package/dist/state-BHM_hL69.cjs +9 -0
- package/dist/state-BKkU5MYC.js +9 -0
- package/dist/state-B_xrj8fC.js +9 -0
- package/dist/state-BaTqKR5-.js +1832 -0
- package/dist/state-Bb1Wechu.js +9 -0
- package/dist/state-BfgVpFaG.cjs +9 -0
- package/dist/state-BoRPcmmD.js +9 -0
- package/dist/state-BqB3gaPk.js +9 -0
- package/dist/state-Bt9zarML.js +1832 -0
- package/dist/state-Bw07Ecsm.js +9 -0
- package/dist/state-Bw9Y8zmt.js +9 -0
- package/dist/state-ByV_XBwX.js +9 -0
- package/dist/state-C4nNE_SS.js +9 -0
- package/dist/state-C4uusDVL.cjs +9 -0
- package/dist/state-CMwBL8Lh.cjs +9 -0
- package/dist/state-C_KJ10Ip.cjs +9 -0
- package/dist/state-ClLJ5ade.cjs +1488 -0
- package/dist/state-CpWrjvjx.js +277 -0
- package/dist/state-CwguFqss.cjs +9 -0
- package/dist/state-Cxj7mpyT.cjs +9 -0
- package/dist/state-CyWfuYBm.js +9 -0
- package/dist/state-Cz4euNVW.js +1832 -0
- package/dist/state-D1eYdbOV.js +9 -0
- package/dist/state-D231Xq-p.js +9 -0
- package/dist/state-D2nMXLig.cjs +9 -0
- package/dist/state-D3NnAU-G.js +9 -0
- package/dist/state-D4g0zX0j.cjs +9 -0
- package/dist/state-D5n1XOr-.cjs +372 -0
- package/dist/state-DPKTXrbJ.cjs +9 -0
- package/dist/state-DREKPmRw.cjs +9 -0
- package/dist/state-DT0Nzp9g.cjs +9 -0
- package/dist/state-Deun4HK-.cjs +9 -0
- package/dist/state-DfcZ51t9.js +9 -0
- package/dist/state-DgvhS6KW.cjs +1488 -0
- package/dist/state-DkjLMcvP.cjs +9 -0
- package/dist/state-DspBT1Sv.js +9 -0
- package/dist/state-DtgVqpBv.js +9 -0
- package/dist/state-DycsTHAk.cjs +9 -0
- package/dist/state-EWoHHdWu.js +9 -0
- package/dist/state-HWOltPgB.js +9 -0
- package/dist/state-JJNPE2tU.js +277 -0
- package/dist/state-KDd3Eouo.js +9 -0
- package/dist/state-Kmc6BtLp.cjs +9 -0
- package/dist/state-Q4M-6UjH.cjs +9 -0
- package/dist/state-U8yVy4Ad.cjs +9 -0
- package/dist/state-Uwm9KEi1.js +1832 -0
- package/dist/state-XYH8BGBU.cjs +372 -0
- package/dist/state-aBiYx-N-.cjs +9 -0
- package/dist/state-arg5pYvx.cjs +1488 -0
- package/dist/state-dFAAWOP9.cjs +1488 -0
- package/dist/state-daFKdtG6.js +9 -0
- package/dist/state-muKg33Sx.cjs +9 -0
- package/dist/state-wvjxc3BL.js +9 -0
- package/dist/styles.css +1 -1
- package/package.json +16 -23
- package/dist/chunk-5RMV2HA7.js +0 -101
- package/dist/chunk-QEVSATMF.cjs +0 -101
- package/dist/chunk-XWCIDYJD.cjs +0 -26
- package/dist/chunk-XYTXUEOE.js +0 -26
- package/dist/index-CN8HkCli.d.cts +0 -547
- package/dist/index-CN8HkCli.d.ts +0 -547
- package/scripts/postinstall.cjs +0 -23
|
@@ -0,0 +1,4249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license MIT
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 Aiden Bai
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
import { A as waitUntilNextFrame, I as DEFAULT_ACTION_ID, J as MOUNT_ROOT_RECHECK_DELAY_MS, K as MAX_SESSION_STORAGE_SIZE_BYTES, M as detectCspNonce, N as getTagName, O as nativeCancelAnimationFrame, P as ARROW_KEYS, R as DRAG_SELECTION_COVERAGE_THRESHOLD, S as getNearestComponentName, T as resolveSource, V as FEEDBACK_DURATION_MS, X as OFFSCREEN_POSITION, Y as NEXTJS_REVALIDATION_DELAY_MS, _ as isRootElement, a as freezeGlobalAnimations, b as getElementContext, c as clearElementPositionCache, ct as TOOLBAR_DEFAULT_POSITION_RATIO, d as freezePseudoStates, dt as VERSION, f as resumePointerEventsFreeze, ft as ZOOM_DETECTION_THRESHOLD, g as isValidGrabbableElement, h as clearVisibilityCache, i as freezeAnimations, j as hideFromThirdParties, k as nativeRequestAnimationFrame, l as getElementAtPosition, m as unfreezePseudoStates, n as logRecoverableError, o as unfreezeGlobalAnimations, p as suspendPointerEventsFreeze, pt as Z_INDEX_OVERLAY, q as MODIFIER_KEYS, r as freezeAllAnimations, s as openFile, t as freezeUpdates, u as getElementsAtPoint, v as checkIsNextProject, w as getStackContext, y as getComponentDisplayName } from "./freeze-updates-BVDrqUzf.js";
|
|
10
|
+
import { a as isMac, g as isElementConnected, h as isKeyboardEventTriggeredByInput, i as isEventFromOverlay, m as hasTextSelectionOnPage, n as saveToolbarState, p as hasTextSelectionInInput, r as resolveActionEnabled, s as clampToRange, t as loadToolbarState } from "./state-JJNPE2tU.js";
|
|
11
|
+
import { n as extractElementCss, r as createElementSelector, t as disposeBaselineStyles } from "./extract-element-css-DivFxCRt.js";
|
|
12
|
+
import { createComponent, memo, render } from "solid-js/web";
|
|
13
|
+
import { batch, createEffect, createMemo, createResource, createRoot, createSignal, on, onCleanup } from "solid-js";
|
|
14
|
+
import { createStore, produce } from "solid-js/store";
|
|
15
|
+
|
|
16
|
+
//#region dist/styles.css?css-text
|
|
17
|
+
var styles_default = "/*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */\n@layer properties;\n@layer theme, base, components, utilities;\n@layer theme {\n :root, :host {\n --font-sans: \"Geist\", ui-sans-serif, system-ui, sans-serif;\n --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\",\n \"Courier New\", monospace;\n --color-black: #000;\n --color-white: #fff;\n --spacing: 0.25rem;\n --font-weight-medium: 500;\n --font-weight-semibold: 600;\n --radius-sm: 0.25rem;\n --ease-out: cubic-bezier(0, 0, 0.2, 1);\n --default-transition-duration: 150ms;\n --default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n --default-font-family: var(--font-sans);\n --default-mono-font-family: var(--font-mono);\n --transition-fast: 100ms;\n --transition-normal: 150ms;\n }\n}\n@layer base {\n *, ::after, ::before, ::backdrop, ::file-selector-button {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n border: 0 solid;\n }\n html, :host {\n line-height: 1.5;\n -webkit-text-size-adjust: 100%;\n tab-size: 4;\n font-family: var(--default-font-family, ui-sans-serif, system-ui, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\");\n font-feature-settings: var(--default-font-feature-settings, normal);\n font-variation-settings: var(--default-font-variation-settings, normal);\n -webkit-tap-highlight-color: transparent;\n }\n hr {\n height: 0;\n color: inherit;\n border-top-width: 1px;\n }\n abbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n }\n h1, h2, h3, h4, h5, h6 {\n font-size: inherit;\n font-weight: inherit;\n }\n a {\n color: inherit;\n -webkit-text-decoration: inherit;\n text-decoration: inherit;\n }\n b, strong {\n font-weight: bolder;\n }\n code, kbd, samp, pre {\n font-family: var(--default-mono-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace);\n font-feature-settings: var(--default-mono-font-feature-settings, normal);\n font-variation-settings: var(--default-mono-font-variation-settings, normal);\n font-size: 1em;\n }\n small {\n font-size: 80%;\n }\n sub, sup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n }\n sub {\n bottom: -0.25em;\n }\n sup {\n top: -0.5em;\n }\n table {\n text-indent: 0;\n border-color: inherit;\n border-collapse: collapse;\n }\n :-moz-focusring {\n outline: auto;\n }\n progress {\n vertical-align: baseline;\n }\n summary {\n display: list-item;\n }\n ol, ul, menu {\n list-style: none;\n }\n img, svg, video, canvas, audio, iframe, embed, object {\n display: block;\n vertical-align: middle;\n }\n img, video {\n max-width: 100%;\n height: auto;\n }\n button, input, select, optgroup, textarea, ::file-selector-button {\n font: inherit;\n font-feature-settings: inherit;\n font-variation-settings: inherit;\n letter-spacing: inherit;\n color: inherit;\n border-radius: 0;\n background-color: transparent;\n opacity: 1;\n }\n :where(select:is([multiple], [size])) optgroup {\n font-weight: bolder;\n }\n :where(select:is([multiple], [size])) optgroup option {\n padding-inline-start: 20px;\n }\n ::file-selector-button {\n margin-inline-end: 4px;\n }\n ::placeholder {\n opacity: 1;\n }\n @supports (not (-webkit-appearance: -apple-pay-button)) or (contain-intrinsic-size: 1px) {\n ::placeholder {\n color: currentcolor;\n @supports (color: color-mix(in lab, red, red)) {\n color: color-mix(in oklab, currentcolor 50%, transparent);\n }\n }\n }\n textarea {\n resize: vertical;\n }\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n ::-webkit-date-and-time-value {\n min-height: 1lh;\n text-align: inherit;\n }\n ::-webkit-datetime-edit {\n display: inline-flex;\n }\n ::-webkit-datetime-edit-fields-wrapper {\n padding: 0;\n }\n ::-webkit-datetime-edit, ::-webkit-datetime-edit-year-field, ::-webkit-datetime-edit-month-field, ::-webkit-datetime-edit-day-field, ::-webkit-datetime-edit-hour-field, ::-webkit-datetime-edit-minute-field, ::-webkit-datetime-edit-second-field, ::-webkit-datetime-edit-millisecond-field, ::-webkit-datetime-edit-meridiem-field {\n padding-block: 0;\n }\n ::-webkit-calendar-picker-indicator {\n line-height: 1;\n }\n :-moz-ui-invalid {\n box-shadow: none;\n }\n button, input:where([type=\"button\"], [type=\"reset\"], [type=\"submit\"]), ::file-selector-button {\n appearance: button;\n }\n ::-webkit-inner-spin-button, ::-webkit-outer-spin-button {\n height: auto;\n }\n [hidden]:where(:not([hidden=\"until-found\"])) {\n display: none !important;\n }\n}\n@layer utilities {\n .pointer-events-auto {\n pointer-events: auto;\n }\n .pointer-events-none {\n pointer-events: none;\n }\n .invisible {\n visibility: hidden;\n }\n .visible {\n visibility: visible;\n }\n .touch-hitbox {\n position: relative;\n &::before {\n content: \"\";\n position: absolute;\n display: block;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 100%;\n height: 100%;\n min-height: 44px;\n min-width: 44px;\n }\n }\n .absolute {\n position: absolute;\n }\n .fixed {\n position: fixed;\n }\n .relative {\n position: relative;\n }\n .-top-1 {\n top: calc(var(--spacing) * -1);\n }\n .top-0 {\n top: calc(var(--spacing) * 0);\n }\n .top-0\\.5 {\n top: calc(var(--spacing) * 0.5);\n }\n .top-1\\/2 {\n top: calc(1/2 * 100%);\n }\n .top-full {\n top: 100%;\n }\n .-right-1 {\n right: calc(var(--spacing) * -1);\n }\n .right-full {\n right: 100%;\n }\n .bottom-full {\n bottom: 100%;\n }\n .left-0 {\n left: calc(var(--spacing) * 0);\n }\n .left-0\\.5 {\n left: calc(var(--spacing) * 0.5);\n }\n .left-1\\.5 {\n left: calc(var(--spacing) * 1.5);\n }\n .left-1\\/2 {\n left: calc(1/2 * 100%);\n }\n .left-2\\.5 {\n left: calc(var(--spacing) * 2.5);\n }\n .left-full {\n left: 100%;\n }\n .z-1 {\n z-index: 1;\n }\n .z-10 {\n z-index: 10;\n }\n .container {\n width: 100%;\n @media (width >= 40rem) {\n max-width: 40rem;\n }\n @media (width >= 48rem) {\n max-width: 48rem;\n }\n @media (width >= 64rem) {\n max-width: 64rem;\n }\n @media (width >= 80rem) {\n max-width: 80rem;\n }\n @media (width >= 96rem) {\n max-width: 96rem;\n }\n }\n .m-0 {\n margin: calc(var(--spacing) * 0);\n }\n .-mx-2 {\n margin-inline: calc(var(--spacing) * -2);\n }\n .mx-0\\.5 {\n margin-inline: calc(var(--spacing) * 0.5);\n }\n .-my-1\\.5 {\n margin-block: calc(var(--spacing) * -1.5);\n }\n .my-0\\.5 {\n margin-block: calc(var(--spacing) * 0.5);\n }\n .mt-0\\.5 {\n margin-top: calc(var(--spacing) * 0.5);\n }\n .mt-2\\.5 {\n margin-top: calc(var(--spacing) * 2.5);\n }\n .mr-0\\.5 {\n margin-right: calc(var(--spacing) * 0.5);\n }\n .mr-1\\.5 {\n margin-right: calc(var(--spacing) * 1.5);\n }\n .mr-2\\.5 {\n margin-right: calc(var(--spacing) * 2.5);\n }\n .mb-0\\.5 {\n margin-bottom: calc(var(--spacing) * 0.5);\n }\n .mb-1\\.5 {\n margin-bottom: calc(var(--spacing) * 1.5);\n }\n .mb-2\\.5 {\n margin-bottom: calc(var(--spacing) * 2.5);\n }\n .-ml-\\[2px\\] {\n margin-left: calc(2px * -1);\n }\n .ml-0\\.5 {\n margin-left: calc(var(--spacing) * 0.5);\n }\n .ml-1 {\n margin-left: calc(var(--spacing) * 1);\n }\n .ml-2\\.5 {\n margin-left: calc(var(--spacing) * 2.5);\n }\n .ml-4 {\n margin-left: calc(var(--spacing) * 4);\n }\n .line-clamp-5 {\n overflow: hidden;\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 5;\n }\n .block {\n display: block;\n }\n .flex {\n display: flex;\n }\n .grid {\n display: grid;\n }\n .hidden {\n display: none;\n }\n .inline {\n display: inline;\n }\n .inline-flex {\n display: inline-flex;\n }\n .size-4 {\n width: calc(var(--spacing) * 4);\n height: calc(var(--spacing) * 4);\n }\n .size-\\[18px\\] {\n width: 18px;\n height: 18px;\n }\n .h-0 {\n height: calc(var(--spacing) * 0);\n }\n .h-1\\.5 {\n height: calc(var(--spacing) * 1.5);\n }\n .h-2 {\n height: calc(var(--spacing) * 2);\n }\n .h-2\\.5 {\n height: calc(var(--spacing) * 2.5);\n }\n .h-3 {\n height: calc(var(--spacing) * 3);\n }\n .h-3\\.5 {\n height: calc(var(--spacing) * 3.5);\n }\n .h-\\[17px\\] {\n height: 17px;\n }\n .h-fit {\n height: fit-content;\n }\n .max-h-\\[240px\\] {\n max-height: 240px;\n }\n .min-h-0 {\n min-height: calc(var(--spacing) * 0);\n }\n .min-h-4 {\n min-height: calc(var(--spacing) * 4);\n }\n .w-0 {\n width: calc(var(--spacing) * 0);\n }\n .w-1\\.5 {\n width: calc(var(--spacing) * 1.5);\n }\n .w-2 {\n width: calc(var(--spacing) * 2);\n }\n .w-3\\.5 {\n width: calc(var(--spacing) * 3.5);\n }\n .w-5 {\n width: calc(var(--spacing) * 5);\n }\n .w-\\[calc\\(100\\%\\+16px\\)\\] {\n width: calc(100% + 16px);\n }\n .w-auto {\n width: auto;\n }\n .w-fit {\n width: fit-content;\n }\n .w-full {\n width: 100%;\n }\n .max-w-\\[280px\\] {\n max-width: 280px;\n }\n .max-w-full {\n max-width: 100%;\n }\n .min-w-0 {\n min-width: calc(var(--spacing) * 0);\n }\n .min-w-2\\.5 {\n min-width: calc(var(--spacing) * 2.5);\n }\n .min-w-\\[100px\\] {\n min-width: 100px;\n }\n .min-w-\\[150px\\] {\n min-width: 150px;\n }\n .flex-1 {\n flex: 1;\n }\n .flex-shrink {\n flex-shrink: 1;\n }\n .shrink {\n flex-shrink: 1;\n }\n .shrink-0 {\n flex-shrink: 0;\n }\n .flex-grow {\n flex-grow: 1;\n }\n .-translate-x-1\\/2 {\n --tw-translate-x: calc(calc(1/2 * 100%) * -1);\n translate: var(--tw-translate-x) var(--tw-translate-y);\n }\n .-translate-y-1\\/2 {\n --tw-translate-y: calc(calc(1/2 * 100%) * -1);\n translate: var(--tw-translate-x) var(--tw-translate-y);\n }\n .scale-75 {\n --tw-scale-x: 75%;\n --tw-scale-y: 75%;\n --tw-scale-z: 75%;\n scale: var(--tw-scale-x) var(--tw-scale-y);\n }\n .scale-100 {\n --tw-scale-x: 100%;\n --tw-scale-y: 100%;\n --tw-scale-z: 100%;\n scale: var(--tw-scale-x) var(--tw-scale-y);\n }\n .-rotate-90 {\n rotate: calc(90deg * -1);\n }\n .rotate-0 {\n rotate: 0deg;\n }\n .rotate-90 {\n rotate: 90deg;\n }\n .rotate-180 {\n rotate: 180deg;\n }\n .interactive-scale {\n transition-property: transform;\n transition-duration: var(--transition-normal);\n transition-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1);\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n transform: scale(1.05);\n }\n }\n &:active {\n transform: scale(0.97);\n }\n }\n .press-scale {\n transition-property: transform;\n transition-duration: var(--transition-fast);\n transition-timing-function: ease-out;\n &:active {\n transform: scale(0.97);\n }\n }\n .transform {\n transform: var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,);\n }\n .animate-\\[hint-flip-in_var\\(--transition-normal\\)_ease-out\\] {\n animation: hint-flip-in var(--transition-normal) ease-out;\n }\n .cursor-grab {\n cursor: grab;\n }\n .cursor-grabbing {\n cursor: grabbing;\n }\n .cursor-pointer {\n cursor: pointer;\n }\n .resize {\n resize: both;\n }\n .resize-none {\n resize: none;\n }\n .grid-cols-\\[0fr\\] {\n grid-template-columns: 0fr;\n }\n .grid-cols-\\[1fr\\] {\n grid-template-columns: 1fr;\n }\n .grid-rows-\\[0fr\\] {\n grid-template-rows: 0fr;\n }\n .grid-rows-\\[1fr\\] {\n grid-template-rows: 1fr;\n }\n .flex-col {\n flex-direction: column;\n }\n .flex-wrap {\n flex-wrap: wrap;\n }\n .items-center {\n align-items: center;\n }\n .items-end {\n align-items: flex-end;\n }\n .items-start {\n align-items: flex-start;\n }\n .justify-between {\n justify-content: space-between;\n }\n .justify-center {\n justify-content: center;\n }\n .justify-end {\n justify-content: flex-end;\n }\n .gap-0\\.5 {\n gap: calc(var(--spacing) * 0.5);\n }\n .gap-1 {\n gap: calc(var(--spacing) * 1);\n }\n .gap-1\\.5 {\n gap: calc(var(--spacing) * 1.5);\n }\n .gap-2 {\n gap: calc(var(--spacing) * 2);\n }\n .gap-\\[5px\\] {\n gap: 5px;\n }\n .self-stretch {\n align-self: stretch;\n }\n .truncate {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n .overflow-hidden {\n overflow: hidden;\n }\n .overflow-visible {\n overflow: visible;\n }\n .overflow-y-auto {\n overflow-y: auto;\n }\n .rounded-\\[10px\\] {\n border-radius: 10px;\n }\n .rounded-full {\n border-radius: calc(infinity * 1px);\n }\n .rounded-sm {\n border-radius: var(--radius-sm);\n }\n .rounded-t-\\[10px\\] {\n border-top-left-radius: 10px;\n border-top-right-radius: 10px;\n }\n .rounded-t-none {\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n }\n .rounded-l-\\[10px\\] {\n border-top-left-radius: 10px;\n border-bottom-left-radius: 10px;\n }\n .rounded-l-none {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n }\n .rounded-r-\\[10px\\] {\n border-top-right-radius: 10px;\n border-bottom-right-radius: 10px;\n }\n .rounded-r-none {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n }\n .rounded-b-\\[6px\\] {\n border-bottom-right-radius: 6px;\n border-bottom-left-radius: 6px;\n }\n .rounded-b-\\[10px\\] {\n border-bottom-right-radius: 10px;\n border-bottom-left-radius: 10px;\n }\n .rounded-b-none {\n border-bottom-right-radius: 0;\n border-bottom-left-radius: 0;\n }\n .border {\n border-style: var(--tw-border-style);\n border-width: 1px;\n }\n .\\[border-width\\:0\\.5px\\] {\n border-width: 0.5px;\n }\n .\\[border-top-width\\:0\\.5px\\] {\n border-top-width: 0.5px;\n }\n .border-none {\n --tw-border-style: none;\n border-style: none;\n }\n .border-solid {\n --tw-border-style: solid;\n border-style: solid;\n }\n .border-\\[\\#B3B3B3\\] {\n border-color: #B3B3B3;\n }\n .border-t-\\[\\#D9D9D9\\] {\n border-top-color: #D9D9D9;\n }\n .bg-\\[\\#FEF2F2\\] {\n background-color: #FEF2F2;\n }\n .bg-black {\n background-color: var(--color-black);\n }\n .bg-black\\/5 {\n background-color: color-mix(in srgb, #000 5%, transparent);\n @supports (color: color-mix(in lab, red, red)) {\n background-color: color-mix(in oklab, var(--color-black) 5%, transparent);\n }\n }\n .bg-black\\/25 {\n background-color: color-mix(in srgb, #000 25%, transparent);\n @supports (color: color-mix(in lab, red, red)) {\n background-color: color-mix(in oklab, var(--color-black) 25%, transparent);\n }\n }\n .bg-transparent {\n background-color: transparent;\n }\n .bg-white {\n background-color: var(--color-white);\n }\n .p-0 {\n padding: calc(var(--spacing) * 0);\n }\n .px-0\\.5 {\n padding-inline: calc(var(--spacing) * 0.5);\n }\n .px-0\\.25 {\n padding-inline: calc(var(--spacing) * 0.25);\n }\n .px-1\\.5 {\n padding-inline: calc(var(--spacing) * 1.5);\n }\n .px-2 {\n padding-inline: calc(var(--spacing) * 2);\n }\n .px-\\[3px\\] {\n padding-inline: 3px;\n }\n .py-0\\.5 {\n padding-block: calc(var(--spacing) * 0.5);\n }\n .py-0\\.25 {\n padding-block: calc(var(--spacing) * 0.25);\n }\n .py-1 {\n padding-block: calc(var(--spacing) * 1);\n }\n .py-1\\.5 {\n padding-block: calc(var(--spacing) * 1.5);\n }\n .py-2 {\n padding-block: calc(var(--spacing) * 2);\n }\n .py-px {\n padding-block: 1px;\n }\n .pt-1\\.5 {\n padding-top: calc(var(--spacing) * 1.5);\n }\n .pb-1 {\n padding-bottom: calc(var(--spacing) * 1);\n }\n .text-left {\n text-align: left;\n }\n .font-sans {\n font-family: var(--font-sans);\n }\n .text-\\[8px\\] {\n font-size: 8px;\n }\n .text-\\[10px\\] {\n font-size: 10px;\n }\n .text-\\[11px\\] {\n font-size: 11px;\n }\n .text-\\[12px\\] {\n font-size: 12px;\n }\n .text-\\[13px\\] {\n font-size: 13px;\n }\n .leading-3 {\n --tw-leading: calc(var(--spacing) * 3);\n line-height: calc(var(--spacing) * 3);\n }\n .leading-3\\.5 {\n --tw-leading: calc(var(--spacing) * 3.5);\n line-height: calc(var(--spacing) * 3.5);\n }\n .leading-4 {\n --tw-leading: calc(var(--spacing) * 4);\n line-height: calc(var(--spacing) * 4);\n }\n .leading-none {\n --tw-leading: 1;\n line-height: 1;\n }\n .font-medium {\n --tw-font-weight: var(--font-weight-medium);\n font-weight: var(--font-weight-medium);\n }\n .font-semibold {\n --tw-font-weight: var(--font-weight-semibold);\n font-weight: var(--font-weight-semibold);\n }\n .wrap-break-word {\n overflow-wrap: break-word;\n }\n .text-ellipsis {\n text-overflow: ellipsis;\n }\n .whitespace-nowrap {\n white-space: nowrap;\n }\n .text-\\[\\#71717a\\] {\n color: #71717a;\n }\n .text-\\[\\#B3B3B3\\] {\n color: #B3B3B3;\n }\n .text-\\[\\#B91C1C\\] {\n color: #B91C1C;\n }\n .text-\\[\\#B91C1C\\]\\/50 {\n color: color-mix(in oklab, #B91C1C 50%, transparent);\n }\n .text-black {\n color: var(--color-black);\n }\n .text-black\\/25 {\n color: color-mix(in srgb, #000 25%, transparent);\n @supports (color: color-mix(in lab, red, red)) {\n color: color-mix(in oklab, var(--color-black) 25%, transparent);\n }\n }\n .text-black\\/30 {\n color: color-mix(in srgb, #000 30%, transparent);\n @supports (color: color-mix(in lab, red, red)) {\n color: color-mix(in oklab, var(--color-black) 30%, transparent);\n }\n }\n .text-black\\/40 {\n color: color-mix(in srgb, #000 40%, transparent);\n @supports (color: color-mix(in lab, red, red)) {\n color: color-mix(in oklab, var(--color-black) 40%, transparent);\n }\n }\n .text-black\\/50 {\n color: color-mix(in srgb, #000 50%, transparent);\n @supports (color: color-mix(in lab, red, red)) {\n color: color-mix(in oklab, var(--color-black) 50%, transparent);\n }\n }\n .text-black\\/60 {\n color: color-mix(in srgb, #000 60%, transparent);\n @supports (color: color-mix(in lab, red, red)) {\n color: color-mix(in oklab, var(--color-black) 60%, transparent);\n }\n }\n .text-black\\/70 {\n color: color-mix(in srgb, #000 70%, transparent);\n @supports (color: color-mix(in lab, red, red)) {\n color: color-mix(in oklab, var(--color-black) 70%, transparent);\n }\n }\n .text-black\\/85 {\n color: color-mix(in srgb, #000 85%, transparent);\n @supports (color: color-mix(in lab, red, red)) {\n color: color-mix(in oklab, var(--color-black) 85%, transparent);\n }\n }\n .text-white {\n color: var(--color-white);\n }\n .tabular-nums {\n --tw-numeric-spacing: tabular-nums;\n font-variant-numeric: var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,);\n }\n .antialiased {\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n }\n .opacity-0 {\n opacity: 0%;\n }\n .opacity-40 {\n opacity: 40%;\n }\n .opacity-100 {\n opacity: 100%;\n }\n .shadow {\n --tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1));\n box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);\n }\n .outline {\n outline-style: var(--tw-outline-style);\n outline-width: 1px;\n }\n .blur {\n --tw-blur: blur(8px);\n filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);\n }\n .filter {\n filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);\n }\n .filter-\\[drop-shadow\\(0px_1px_2px_\\#51515140\\)\\] {\n filter: drop-shadow(0px 1px 2px #51515140);\n }\n .backdrop-filter {\n -webkit-backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);\n backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);\n }\n .transition {\n transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, -webkit-backdrop-filter, backdrop-filter, display, content-visibility, overlay, pointer-events;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-\\[grid-template-columns\\,opacity\\] {\n transition-property: grid-template-columns,opacity;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-\\[grid-template-columns\\] {\n transition-property: grid-template-columns;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-\\[grid-template-rows\\,opacity\\] {\n transition-property: grid-template-rows,opacity;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-\\[grid-template-rows\\] {\n transition-property: grid-template-rows;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-\\[opacity\\,transform\\] {\n transition-property: opacity,transform;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-\\[top\\,left\\,width\\,height\\,opacity\\] {\n transition-property: top,left,width,height,opacity;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-\\[transform\\,opacity\\] {\n transition-property: transform,opacity;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-all {\n transition-property: all;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-colors {\n transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-opacity {\n transition-property: opacity;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-transform {\n transition-property: transform, translate, scale, rotate;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .duration-75 {\n --tw-duration: 75ms;\n transition-duration: 75ms;\n }\n .duration-100 {\n --tw-duration: 100ms;\n transition-duration: 100ms;\n }\n .duration-150 {\n --tw-duration: 150ms;\n transition-duration: 150ms;\n }\n .duration-300 {\n --tw-duration: 300ms;\n transition-duration: 300ms;\n }\n .ease-out {\n --tw-ease: var(--ease-out);\n transition-timing-function: var(--ease-out);\n }\n .will-change-\\[opacity\\,transform\\] {\n will-change: opacity,transform;\n }\n .contain-layout {\n --tw-contain-layout: layout;\n contain: var(--tw-contain-size,) var(--tw-contain-layout,) var(--tw-contain-paint,) var(--tw-contain-style,);\n }\n .outline-none {\n --tw-outline-style: none;\n outline-style: none;\n }\n .select-none {\n -webkit-user-select: none;\n user-select: none;\n }\n .\\[animation-fill-mode\\:backwards\\] {\n animation-fill-mode: backwards;\n }\n .\\[corner-shape\\:superellipse\\(1\\.25\\)\\] {\n corner-shape: superellipse(1.25);\n }\n .\\[font-synthesis\\:none\\] {\n font-synthesis: none;\n }\n .\\[scrollbar-color\\:transparent_transparent\\] {\n scrollbar-color: transparent transparent;\n }\n .\\[scrollbar-width\\:thin\\] {\n scrollbar-width: thin;\n }\n .before\\:\\!min-h-full {\n &::before {\n content: var(--tw-content);\n min-height: 100% !important;\n }\n }\n .before\\:\\!min-w-full {\n &::before {\n content: var(--tw-content);\n min-width: 100% !important;\n }\n }\n .hover\\:bg-\\[\\#F5F5F5\\] {\n &:hover {\n @media (hover: hover) {\n background-color: #F5F5F5;\n }\n }\n }\n .hover\\:bg-\\[\\#FEE2E2\\] {\n &:hover {\n @media (hover: hover) {\n background-color: #FEE2E2;\n }\n }\n }\n .hover\\:bg-black\\/10 {\n &:hover {\n @media (hover: hover) {\n background-color: color-mix(in srgb, #000 10%, transparent);\n @supports (color: color-mix(in lab, red, red)) {\n background-color: color-mix(in oklab, var(--color-black) 10%, transparent);\n }\n }\n }\n }\n .hover\\:text-black {\n &:hover {\n @media (hover: hover) {\n color: var(--color-black);\n }\n }\n }\n .hover\\:opacity-100 {\n &:hover {\n @media (hover: hover) {\n opacity: 100%;\n }\n }\n }\n .hover\\:\\[scrollbar-color\\:rgba\\(0\\,0\\,0\\,0\\.15\\)_transparent\\] {\n &:hover {\n @media (hover: hover) {\n scrollbar-color: rgba(0,0,0,0.15) transparent;\n }\n }\n }\n .disabled\\:cursor-default {\n &:disabled {\n cursor: default;\n }\n }\n .disabled\\:opacity-40 {\n &:disabled {\n opacity: 40%;\n }\n }\n}\n:host {\n all: initial;\n direction: ltr;\n}\n@keyframes shake {\n 0%, 100% {\n transform: translateX(0);\n }\n 15% {\n transform: translateX(-3px);\n }\n 30% {\n transform: translateX(3px);\n }\n 45% {\n transform: translateX(-3px);\n }\n 60% {\n transform: translateX(3px);\n }\n 75% {\n transform: translateX(-2px);\n }\n 90% {\n transform: translateX(2px);\n }\n}\n@keyframes success-pop {\n 0% {\n transform: scale(0.9);\n opacity: 0;\n }\n 60% {\n transform: scale(1.1);\n opacity: 1;\n }\n 80% {\n transform: scale(0.95);\n }\n 100% {\n transform: scale(1);\n opacity: 1;\n }\n}\n@keyframes hint-flip-in {\n from {\n opacity: 0;\n transform: translateY(4px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n@keyframes tooltip-fade-in {\n from {\n opacity: 0;\n transform: scale(0.97);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n@keyframes icon-loader-spin {\n 0% {\n opacity: 1;\n }\n 50% {\n opacity: 0.5;\n }\n 100% {\n opacity: 0.2;\n }\n}\n.icon-loader-bar {\n animation: icon-loader-spin 0.5s linear infinite;\n}\n@keyframes shimmer {\n 0% {\n background-position: 200% 0;\n }\n 100% {\n background-position: -200% 0;\n }\n}\n.shimmer-text {\n background: linear-gradient( 90deg, #71717a 0%, #a1a1aa 25%, #71717a 50%, #a1a1aa 75%, #71717a 100% );\n background-size: 200% 100%;\n -webkit-background-clip: text;\n background-clip: text;\n color: transparent;\n animation: shimmer 2.5s linear infinite;\n}\n@keyframes clock-flash {\n 0% {\n transform: scale(1);\n }\n 25% {\n transform: scale(1.2);\n }\n 50% {\n transform: scale(0.92);\n }\n 75% {\n transform: scale(1.05);\n }\n 100% {\n transform: scale(1);\n }\n}\n.animate-clock-flash {\n animation: clock-flash 400ms ease-out;\n will-change: transform;\n}\n.animate-shake {\n animation: shake 0.3s ease-out;\n will-change: transform;\n}\n.animate-success-pop {\n animation: success-pop 250ms ease-out;\n will-change: transform, opacity;\n}\n.animate-tooltip-fade-in {\n animation: tooltip-fade-in var(--transition-fast) ease-out;\n will-change: transform, opacity;\n}\n@property --tw-translate-x {\n syntax: \"*\";\n inherits: false;\n initial-value: 0;\n}\n@property --tw-translate-y {\n syntax: \"*\";\n inherits: false;\n initial-value: 0;\n}\n@property --tw-translate-z {\n syntax: \"*\";\n inherits: false;\n initial-value: 0;\n}\n@property --tw-scale-x {\n syntax: \"*\";\n inherits: false;\n initial-value: 1;\n}\n@property --tw-scale-y {\n syntax: \"*\";\n inherits: false;\n initial-value: 1;\n}\n@property --tw-scale-z {\n syntax: \"*\";\n inherits: false;\n initial-value: 1;\n}\n@property --tw-rotate-x {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-rotate-y {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-rotate-z {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-skew-x {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-skew-y {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-border-style {\n syntax: \"*\";\n inherits: false;\n initial-value: solid;\n}\n@property --tw-leading {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-font-weight {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-ordinal {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-slashed-zero {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-numeric-figure {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-numeric-spacing {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-numeric-fraction {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n@property --tw-shadow-color {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-shadow-alpha {\n syntax: \"<percentage>\";\n inherits: false;\n initial-value: 100%;\n}\n@property --tw-inset-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n@property --tw-inset-shadow-color {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-inset-shadow-alpha {\n syntax: \"<percentage>\";\n inherits: false;\n initial-value: 100%;\n}\n@property --tw-ring-color {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-ring-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n@property --tw-inset-ring-color {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-inset-ring-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n@property --tw-ring-inset {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-ring-offset-width {\n syntax: \"<length>\";\n inherits: false;\n initial-value: 0px;\n}\n@property --tw-ring-offset-color {\n syntax: \"*\";\n inherits: false;\n initial-value: #fff;\n}\n@property --tw-ring-offset-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n@property --tw-outline-style {\n syntax: \"*\";\n inherits: false;\n initial-value: solid;\n}\n@property --tw-blur {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-brightness {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-contrast {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-grayscale {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-hue-rotate {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-invert {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-opacity {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-saturate {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-sepia {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-drop-shadow {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-drop-shadow-color {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-drop-shadow-alpha {\n syntax: \"<percentage>\";\n inherits: false;\n initial-value: 100%;\n}\n@property --tw-drop-shadow-size {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-backdrop-blur {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-backdrop-brightness {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-backdrop-contrast {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-backdrop-grayscale {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-backdrop-hue-rotate {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-backdrop-invert {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-backdrop-opacity {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-backdrop-saturate {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-backdrop-sepia {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-duration {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-ease {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-contain-size {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-contain-layout {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-contain-paint {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-contain-style {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-content {\n syntax: \"*\";\n initial-value: \"\";\n inherits: false;\n}\n@layer properties {\n @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {\n *, ::before, ::after, ::backdrop {\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-translate-z: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-scale-z: 1;\n --tw-rotate-x: initial;\n --tw-rotate-y: initial;\n --tw-rotate-z: initial;\n --tw-skew-x: initial;\n --tw-skew-y: initial;\n --tw-border-style: solid;\n --tw-leading: initial;\n --tw-font-weight: initial;\n --tw-ordinal: initial;\n --tw-slashed-zero: initial;\n --tw-numeric-figure: initial;\n --tw-numeric-spacing: initial;\n --tw-numeric-fraction: initial;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-color: initial;\n --tw-shadow-alpha: 100%;\n --tw-inset-shadow: 0 0 #0000;\n --tw-inset-shadow-color: initial;\n --tw-inset-shadow-alpha: 100%;\n --tw-ring-color: initial;\n --tw-ring-shadow: 0 0 #0000;\n --tw-inset-ring-color: initial;\n --tw-inset-ring-shadow: 0 0 #0000;\n --tw-ring-inset: initial;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-outline-style: solid;\n --tw-blur: initial;\n --tw-brightness: initial;\n --tw-contrast: initial;\n --tw-grayscale: initial;\n --tw-hue-rotate: initial;\n --tw-invert: initial;\n --tw-opacity: initial;\n --tw-saturate: initial;\n --tw-sepia: initial;\n --tw-drop-shadow: initial;\n --tw-drop-shadow-color: initial;\n --tw-drop-shadow-alpha: 100%;\n --tw-drop-shadow-size: initial;\n --tw-backdrop-blur: initial;\n --tw-backdrop-brightness: initial;\n --tw-backdrop-contrast: initial;\n --tw-backdrop-grayscale: initial;\n --tw-backdrop-hue-rotate: initial;\n --tw-backdrop-invert: initial;\n --tw-backdrop-opacity: initial;\n --tw-backdrop-saturate: initial;\n --tw-backdrop-sepia: initial;\n --tw-duration: initial;\n --tw-ease: initial;\n --tw-contain-size: initial;\n --tw-contain-layout: initial;\n --tw-contain-paint: initial;\n --tw-contain-style: initial;\n --tw-content: \"\";\n }\n }\n}\n";
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/utils/strip-translate-from-transform.ts
|
|
21
|
+
const isValidNumber = (value) => typeof value === "number" && !Number.isNaN(value) && Number.isFinite(value);
|
|
22
|
+
const parseMatrixValue = (value) => {
|
|
23
|
+
const trimmedValue = value.trim();
|
|
24
|
+
if (!trimmedValue) return null;
|
|
25
|
+
const parsedValue = parseFloat(trimmedValue);
|
|
26
|
+
return isValidNumber(parsedValue) ? parsedValue : null;
|
|
27
|
+
};
|
|
28
|
+
const parseMatrixValues = (valuesString, expectedLength) => {
|
|
29
|
+
const rawValues = valuesString.split(",");
|
|
30
|
+
if (rawValues.length !== expectedLength) return null;
|
|
31
|
+
const parsedValues = [];
|
|
32
|
+
for (const rawValue of rawValues) {
|
|
33
|
+
const parsedValue = parseMatrixValue(rawValue);
|
|
34
|
+
if (parsedValue === null) return null;
|
|
35
|
+
parsedValues.push(parsedValue);
|
|
36
|
+
}
|
|
37
|
+
return parsedValues;
|
|
38
|
+
};
|
|
39
|
+
const isIdentityMatrix2d = (a, b, c, d) => a === 1 && b === 0 && c === 0 && d === 1;
|
|
40
|
+
const isIdentityMatrix3d = (values) => values[0] === 1 && values[1] === 0 && values[2] === 0 && values[3] === 0 && values[4] === 0 && values[5] === 1 && values[6] === 0 && values[7] === 0 && values[8] === 0 && values[9] === 0 && values[10] === 1 && values[11] === 0 && values[15] === 1;
|
|
41
|
+
const stripTranslateFromTransformString = (transform) => {
|
|
42
|
+
if (!transform || transform === "none") return "none";
|
|
43
|
+
if (transform.startsWith("matrix")) if (transform.startsWith("matrix3d(")) {
|
|
44
|
+
const start = 9;
|
|
45
|
+
const end = transform.length - 1;
|
|
46
|
+
const values = parseMatrixValues(transform.slice(start, end), 16);
|
|
47
|
+
if (values) {
|
|
48
|
+
values[12] = 0;
|
|
49
|
+
values[13] = 0;
|
|
50
|
+
values[14] = 0;
|
|
51
|
+
if (isIdentityMatrix3d(values)) return "none";
|
|
52
|
+
return `matrix3d(${values[0]}, ${values[1]}, ${values[2]}, ${values[3]}, ${values[4]}, ${values[5]}, ${values[6]}, ${values[7]}, ${values[8]}, ${values[9]}, ${values[10]}, ${values[11]}, 0, 0, 0, ${values[15]})`;
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
const start = 7;
|
|
56
|
+
const end = transform.length - 1;
|
|
57
|
+
const values = parseMatrixValues(transform.slice(start, end), 6);
|
|
58
|
+
if (values) {
|
|
59
|
+
const scaleX = values[0];
|
|
60
|
+
const skewY = values[1];
|
|
61
|
+
const skewX = values[2];
|
|
62
|
+
const scaleY = values[3];
|
|
63
|
+
if (isIdentityMatrix2d(scaleX, skewY, skewX, scaleY)) return "none";
|
|
64
|
+
return `matrix(${scaleX}, ${skewY}, ${skewX}, ${scaleY}, 0, 0)`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return "none";
|
|
68
|
+
};
|
|
69
|
+
const stripTranslateFromMatrix = (matrix) => {
|
|
70
|
+
if (matrix.isIdentity) return "none";
|
|
71
|
+
if (matrix.is2D) {
|
|
72
|
+
if (isIdentityMatrix2d(matrix.a, matrix.b, matrix.c, matrix.d)) return "none";
|
|
73
|
+
return `matrix(${matrix.a}, ${matrix.b}, ${matrix.c}, ${matrix.d}, 0, 0)`;
|
|
74
|
+
}
|
|
75
|
+
if (matrix.m11 === 1 && matrix.m12 === 0 && matrix.m13 === 0 && matrix.m14 === 0 && matrix.m21 === 0 && matrix.m22 === 1 && matrix.m23 === 0 && matrix.m24 === 0 && matrix.m31 === 0 && matrix.m32 === 0 && matrix.m33 === 1 && matrix.m34 === 0 && matrix.m44 === 1) return "none";
|
|
76
|
+
return `matrix3d(${matrix.m11}, ${matrix.m12}, ${matrix.m13}, ${matrix.m14}, ${matrix.m21}, ${matrix.m22}, ${matrix.m23}, ${matrix.m24}, ${matrix.m31}, ${matrix.m32}, ${matrix.m33}, ${matrix.m34}, 0, 0, 0, ${matrix.m44})`;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/utils/create-element-bounds.ts
|
|
81
|
+
let boundsCache = /* @__PURE__ */ new WeakMap();
|
|
82
|
+
let ancestorTransformCache = /* @__PURE__ */ new WeakMap();
|
|
83
|
+
let borderRadiusCache = /* @__PURE__ */ new WeakMap();
|
|
84
|
+
const invalidateBoundsCache = () => {
|
|
85
|
+
boundsCache = /* @__PURE__ */ new WeakMap();
|
|
86
|
+
ancestorTransformCache = /* @__PURE__ */ new WeakMap();
|
|
87
|
+
borderRadiusCache = /* @__PURE__ */ new WeakMap();
|
|
88
|
+
};
|
|
89
|
+
const getAncestorTransformValue = (ancestor, now) => {
|
|
90
|
+
const cached = ancestorTransformCache.get(ancestor);
|
|
91
|
+
if (cached && now - cached.timestamp < 16) return cached.transform;
|
|
92
|
+
const transformValue = window.getComputedStyle(ancestor).transform;
|
|
93
|
+
const resolvedTransform = transformValue && transformValue !== "none" ? transformValue : "none";
|
|
94
|
+
ancestorTransformCache.set(ancestor, {
|
|
95
|
+
transform: resolvedTransform,
|
|
96
|
+
timestamp: now
|
|
97
|
+
});
|
|
98
|
+
return resolvedTransform;
|
|
99
|
+
};
|
|
100
|
+
const getAccumulatedTransform = (element, selfTransform, now) => {
|
|
101
|
+
const hasSelfTransform = selfTransform && selfTransform !== "none";
|
|
102
|
+
let accumulated = null;
|
|
103
|
+
let current = element.parentElement;
|
|
104
|
+
let depth = 0;
|
|
105
|
+
while (current && current !== document.documentElement && depth < 6) {
|
|
106
|
+
const transformValue = getAncestorTransformValue(current, now);
|
|
107
|
+
if (transformValue !== "none") accumulated = accumulated ? new DOMMatrix(transformValue).multiply(accumulated) : new DOMMatrix(transformValue);
|
|
108
|
+
else if (!hasSelfTransform && !accumulated && depth >= 3) return "none";
|
|
109
|
+
current = current.parentElement;
|
|
110
|
+
depth++;
|
|
111
|
+
}
|
|
112
|
+
if (!accumulated) return hasSelfTransform ? stripTranslateFromTransformString(selfTransform) : "none";
|
|
113
|
+
if (hasSelfTransform) accumulated = accumulated.multiply(new DOMMatrix(selfTransform));
|
|
114
|
+
return stripTranslateFromMatrix(accumulated);
|
|
115
|
+
};
|
|
116
|
+
const getCachedBorderRadius = (element, computedStyle, now) => {
|
|
117
|
+
const cached = borderRadiusCache.get(element);
|
|
118
|
+
if (cached && now - cached.timestamp < 200) return cached.borderRadius;
|
|
119
|
+
const borderRadius = (computedStyle ?? window.getComputedStyle(element)).borderRadius || "0px";
|
|
120
|
+
borderRadiusCache.set(element, {
|
|
121
|
+
borderRadius,
|
|
122
|
+
timestamp: now
|
|
123
|
+
});
|
|
124
|
+
return borderRadius;
|
|
125
|
+
};
|
|
126
|
+
const buildBoundsFromRect = (element, rect, style, now) => {
|
|
127
|
+
const transform = getAccumulatedTransform(element, style.transform, now);
|
|
128
|
+
const borderRadius = getCachedBorderRadius(element, style, now);
|
|
129
|
+
if (transform !== "none" && element instanceof HTMLElement) {
|
|
130
|
+
const offsetWidth = element.offsetWidth;
|
|
131
|
+
const offsetHeight = element.offsetHeight;
|
|
132
|
+
if (offsetWidth > 0 && offsetHeight > 0) {
|
|
133
|
+
const centerX = rect.left + rect.width * .5;
|
|
134
|
+
const centerY = rect.top + rect.height * .5;
|
|
135
|
+
return {
|
|
136
|
+
borderRadius,
|
|
137
|
+
height: offsetHeight,
|
|
138
|
+
transform,
|
|
139
|
+
width: offsetWidth,
|
|
140
|
+
x: centerX - offsetWidth * .5,
|
|
141
|
+
y: centerY - offsetHeight * .5
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
borderRadius,
|
|
147
|
+
height: rect.height,
|
|
148
|
+
transform,
|
|
149
|
+
width: rect.width,
|
|
150
|
+
x: rect.left,
|
|
151
|
+
y: rect.top
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
const createElementBounds = (element) => {
|
|
155
|
+
const now = performance.now();
|
|
156
|
+
const cached = boundsCache.get(element);
|
|
157
|
+
if (cached && now - cached.timestamp < 16) return cached.bounds;
|
|
158
|
+
const bounds = buildBoundsFromRect(element, element.getBoundingClientRect(), window.getComputedStyle(element), now);
|
|
159
|
+
boundsCache.set(element, {
|
|
160
|
+
bounds,
|
|
161
|
+
timestamp: now
|
|
162
|
+
});
|
|
163
|
+
return bounds;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/utils/get-bounds-center.ts
|
|
168
|
+
const getBoundsCenter = (bounds) => ({
|
|
169
|
+
x: bounds.x + bounds.width / 2,
|
|
170
|
+
y: bounds.y + bounds.height / 2
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/core/store.ts
|
|
175
|
+
const createInitialStore = (input) => ({
|
|
176
|
+
current: { state: "idle" },
|
|
177
|
+
wasActivatedByToggle: false,
|
|
178
|
+
pendingCommentMode: false,
|
|
179
|
+
keyHoldDuration: input.keyHoldDuration,
|
|
180
|
+
pointer: {
|
|
181
|
+
x: OFFSCREEN_POSITION,
|
|
182
|
+
y: OFFSCREEN_POSITION
|
|
183
|
+
},
|
|
184
|
+
dragStart: {
|
|
185
|
+
x: OFFSCREEN_POSITION,
|
|
186
|
+
y: OFFSCREEN_POSITION
|
|
187
|
+
},
|
|
188
|
+
copyStart: {
|
|
189
|
+
x: OFFSCREEN_POSITION,
|
|
190
|
+
y: OFFSCREEN_POSITION
|
|
191
|
+
},
|
|
192
|
+
copyOffsetFromCenterX: 0,
|
|
193
|
+
detectedElement: null,
|
|
194
|
+
frozenElement: null,
|
|
195
|
+
frozenElements: [],
|
|
196
|
+
frozenDragRect: null,
|
|
197
|
+
lastGrabbedElement: null,
|
|
198
|
+
lastCopiedElement: null,
|
|
199
|
+
selectionFilePath: null,
|
|
200
|
+
selectionLineNumber: null,
|
|
201
|
+
inputText: "",
|
|
202
|
+
viewportVersion: 0,
|
|
203
|
+
grabbedBoxes: [],
|
|
204
|
+
labelInstances: [],
|
|
205
|
+
isTouchMode: false,
|
|
206
|
+
theme: input.theme,
|
|
207
|
+
activationTimestamp: null,
|
|
208
|
+
previouslyFocusedElement: null,
|
|
209
|
+
contextMenuPosition: null,
|
|
210
|
+
contextMenuElement: null,
|
|
211
|
+
contextMenuClickOffset: null
|
|
212
|
+
});
|
|
213
|
+
const createGrabStore = (input) => {
|
|
214
|
+
const [store, setStore] = createStore(createInitialStore(input));
|
|
215
|
+
const clearFrozenElement = () => {
|
|
216
|
+
setStore(produce((draft) => {
|
|
217
|
+
draft.frozenElement = null;
|
|
218
|
+
draft.frozenElements = [];
|
|
219
|
+
draft.frozenDragRect = null;
|
|
220
|
+
}));
|
|
221
|
+
};
|
|
222
|
+
const setActivePhase = (phase) => {
|
|
223
|
+
setStore("current", produce((current) => {
|
|
224
|
+
if (current.state === "active") current.phase = phase;
|
|
225
|
+
}));
|
|
226
|
+
};
|
|
227
|
+
const actions = {
|
|
228
|
+
startHold: (duration) => {
|
|
229
|
+
if (duration !== void 0) setStore("keyHoldDuration", duration);
|
|
230
|
+
setStore("current", {
|
|
231
|
+
state: "holding",
|
|
232
|
+
startedAt: Date.now()
|
|
233
|
+
});
|
|
234
|
+
},
|
|
235
|
+
releaseHold: () => {
|
|
236
|
+
if (store.current.state === "holding") setStore("current", { state: "idle" });
|
|
237
|
+
},
|
|
238
|
+
activate: () => {
|
|
239
|
+
setStore(produce((draft) => {
|
|
240
|
+
draft.current = {
|
|
241
|
+
state: "active",
|
|
242
|
+
phase: "hovering",
|
|
243
|
+
isPromptMode: false,
|
|
244
|
+
isPendingDismiss: false
|
|
245
|
+
};
|
|
246
|
+
draft.activationTimestamp = Date.now();
|
|
247
|
+
draft.previouslyFocusedElement = document.activeElement;
|
|
248
|
+
}));
|
|
249
|
+
},
|
|
250
|
+
deactivate: () => {
|
|
251
|
+
setStore(produce((draft) => {
|
|
252
|
+
draft.current = { state: "idle" };
|
|
253
|
+
draft.wasActivatedByToggle = false;
|
|
254
|
+
draft.pendingCommentMode = false;
|
|
255
|
+
draft.inputText = "";
|
|
256
|
+
draft.frozenElement = null;
|
|
257
|
+
draft.frozenElements = [];
|
|
258
|
+
draft.frozenDragRect = null;
|
|
259
|
+
draft.activationTimestamp = null;
|
|
260
|
+
draft.previouslyFocusedElement = null;
|
|
261
|
+
draft.contextMenuPosition = null;
|
|
262
|
+
draft.contextMenuElement = null;
|
|
263
|
+
draft.contextMenuClickOffset = null;
|
|
264
|
+
draft.lastCopiedElement = null;
|
|
265
|
+
}));
|
|
266
|
+
},
|
|
267
|
+
toggle: () => {
|
|
268
|
+
if (store.activationTimestamp !== null) actions.deactivate();
|
|
269
|
+
else {
|
|
270
|
+
setStore("wasActivatedByToggle", true);
|
|
271
|
+
actions.activate();
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
freeze: () => {
|
|
275
|
+
if (store.current.state === "active") {
|
|
276
|
+
const elementToFreeze = store.frozenElement ?? store.detectedElement;
|
|
277
|
+
if (elementToFreeze) setStore("frozenElement", elementToFreeze);
|
|
278
|
+
setActivePhase("frozen");
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
unfreeze: () => {
|
|
282
|
+
if (store.current.state === "active") {
|
|
283
|
+
setStore(produce((draft) => {
|
|
284
|
+
draft.frozenElement = null;
|
|
285
|
+
draft.frozenElements = [];
|
|
286
|
+
draft.frozenDragRect = null;
|
|
287
|
+
}));
|
|
288
|
+
setActivePhase("hovering");
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
startDrag: (position) => {
|
|
292
|
+
if (store.current.state === "active") {
|
|
293
|
+
clearFrozenElement();
|
|
294
|
+
setStore("dragStart", {
|
|
295
|
+
x: position.x + window.scrollX,
|
|
296
|
+
y: position.y + window.scrollY
|
|
297
|
+
});
|
|
298
|
+
setActivePhase("dragging");
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
endDrag: () => {
|
|
302
|
+
if (store.current.state === "active" && store.current.phase === "dragging") {
|
|
303
|
+
setStore("dragStart", {
|
|
304
|
+
x: OFFSCREEN_POSITION,
|
|
305
|
+
y: OFFSCREEN_POSITION
|
|
306
|
+
});
|
|
307
|
+
setActivePhase("justDragged");
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
cancelDrag: () => {
|
|
311
|
+
if (store.current.state === "active" && store.current.phase === "dragging") {
|
|
312
|
+
setStore("dragStart", {
|
|
313
|
+
x: OFFSCREEN_POSITION,
|
|
314
|
+
y: OFFSCREEN_POSITION
|
|
315
|
+
});
|
|
316
|
+
setActivePhase("hovering");
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
finishJustDragged: () => {
|
|
320
|
+
if (store.current.state === "active" && store.current.phase === "justDragged") setActivePhase("hovering");
|
|
321
|
+
},
|
|
322
|
+
startCopy: () => {
|
|
323
|
+
const wasActive = store.current.state === "active";
|
|
324
|
+
setStore("current", {
|
|
325
|
+
state: "copying",
|
|
326
|
+
startedAt: Date.now(),
|
|
327
|
+
wasActive
|
|
328
|
+
});
|
|
329
|
+
},
|
|
330
|
+
completeCopy: (element) => {
|
|
331
|
+
if (element) setStore("lastCopiedElement", element);
|
|
332
|
+
const wasActive = store.current.state === "copying" ? store.current.wasActive : false;
|
|
333
|
+
setStore("current", {
|
|
334
|
+
state: "justCopied",
|
|
335
|
+
copiedAt: Date.now(),
|
|
336
|
+
wasActive
|
|
337
|
+
});
|
|
338
|
+
},
|
|
339
|
+
finishJustCopied: () => {
|
|
340
|
+
if (store.current.state === "justCopied") if (store.current.wasActive && !store.wasActivatedByToggle) {
|
|
341
|
+
clearFrozenElement();
|
|
342
|
+
setStore("current", {
|
|
343
|
+
state: "active",
|
|
344
|
+
phase: "hovering",
|
|
345
|
+
isPromptMode: false,
|
|
346
|
+
isPendingDismiss: false
|
|
347
|
+
});
|
|
348
|
+
} else actions.deactivate();
|
|
349
|
+
},
|
|
350
|
+
enterPromptMode: (position, element) => {
|
|
351
|
+
const { x: selectionCenterX } = getBoundsCenter(createElementBounds(element));
|
|
352
|
+
setStore("copyStart", position);
|
|
353
|
+
setStore("copyOffsetFromCenterX", position.x - selectionCenterX);
|
|
354
|
+
setStore("pointer", position);
|
|
355
|
+
setStore("frozenElement", element);
|
|
356
|
+
setStore("wasActivatedByToggle", true);
|
|
357
|
+
if (store.current.state !== "active") {
|
|
358
|
+
setStore("current", {
|
|
359
|
+
state: "active",
|
|
360
|
+
phase: "frozen",
|
|
361
|
+
isPromptMode: true,
|
|
362
|
+
isPendingDismiss: false
|
|
363
|
+
});
|
|
364
|
+
setStore("activationTimestamp", Date.now());
|
|
365
|
+
setStore("previouslyFocusedElement", document.activeElement);
|
|
366
|
+
} else setStore("current", produce((current) => {
|
|
367
|
+
if (current.state === "active") {
|
|
368
|
+
current.isPromptMode = true;
|
|
369
|
+
current.phase = "frozen";
|
|
370
|
+
}
|
|
371
|
+
}));
|
|
372
|
+
},
|
|
373
|
+
exitPromptMode: () => {
|
|
374
|
+
if (store.current.state === "active") setStore("current", produce((current) => {
|
|
375
|
+
if (current.state === "active") {
|
|
376
|
+
current.isPromptMode = false;
|
|
377
|
+
current.isPendingDismiss = false;
|
|
378
|
+
}
|
|
379
|
+
}));
|
|
380
|
+
},
|
|
381
|
+
setInputText: (value) => {
|
|
382
|
+
setStore("inputText", value);
|
|
383
|
+
},
|
|
384
|
+
clearInputText: () => {
|
|
385
|
+
setStore("inputText", "");
|
|
386
|
+
},
|
|
387
|
+
setPendingDismiss: (value) => {
|
|
388
|
+
if (store.current.state === "active") setStore("current", produce((current) => {
|
|
389
|
+
if (current.state === "active") current.isPendingDismiss = value;
|
|
390
|
+
}));
|
|
391
|
+
},
|
|
392
|
+
setPointer: (position) => {
|
|
393
|
+
setStore("pointer", position);
|
|
394
|
+
},
|
|
395
|
+
setDetectedElement: (element) => {
|
|
396
|
+
setStore("detectedElement", element);
|
|
397
|
+
},
|
|
398
|
+
setFrozenElement: (element) => {
|
|
399
|
+
setStore(produce((draft) => {
|
|
400
|
+
draft.frozenElement = element;
|
|
401
|
+
draft.frozenElements = [element];
|
|
402
|
+
draft.frozenDragRect = null;
|
|
403
|
+
}));
|
|
404
|
+
},
|
|
405
|
+
setFrozenElements: (elements) => {
|
|
406
|
+
setStore(produce((draft) => {
|
|
407
|
+
draft.frozenElements = elements;
|
|
408
|
+
draft.frozenElement = elements.length > 0 ? elements[0] : null;
|
|
409
|
+
draft.frozenDragRect = null;
|
|
410
|
+
}));
|
|
411
|
+
},
|
|
412
|
+
setFrozenDragRect: (rect) => {
|
|
413
|
+
setStore("frozenDragRect", rect);
|
|
414
|
+
},
|
|
415
|
+
setCopyStart: (position, element) => {
|
|
416
|
+
const { x: selectionCenterX } = getBoundsCenter(createElementBounds(element));
|
|
417
|
+
setStore("copyStart", position);
|
|
418
|
+
setStore("copyOffsetFromCenterX", position.x - selectionCenterX);
|
|
419
|
+
},
|
|
420
|
+
setLastGrabbed: (element) => {
|
|
421
|
+
setStore("lastGrabbedElement", element);
|
|
422
|
+
},
|
|
423
|
+
clearLastCopied: () => {
|
|
424
|
+
setStore("lastCopiedElement", null);
|
|
425
|
+
},
|
|
426
|
+
setWasActivatedByToggle: (value) => {
|
|
427
|
+
setStore("wasActivatedByToggle", value);
|
|
428
|
+
},
|
|
429
|
+
setPendingCommentMode: (value) => {
|
|
430
|
+
setStore("pendingCommentMode", value);
|
|
431
|
+
},
|
|
432
|
+
setTouchMode: (value) => {
|
|
433
|
+
setStore("isTouchMode", value);
|
|
434
|
+
},
|
|
435
|
+
setSelectionSource: (filePath, lineNumber) => {
|
|
436
|
+
setStore(produce((draft) => {
|
|
437
|
+
draft.selectionFilePath = filePath;
|
|
438
|
+
draft.selectionLineNumber = lineNumber;
|
|
439
|
+
}));
|
|
440
|
+
},
|
|
441
|
+
incrementViewportVersion: () => {
|
|
442
|
+
setStore("viewportVersion", (version) => version + 1);
|
|
443
|
+
},
|
|
444
|
+
addGrabbedBox: (box) => {
|
|
445
|
+
setStore("grabbedBoxes", (boxes) => [...boxes, box]);
|
|
446
|
+
},
|
|
447
|
+
removeGrabbedBox: (boxId) => {
|
|
448
|
+
setStore("grabbedBoxes", (boxes) => boxes.filter((box) => box.id !== boxId));
|
|
449
|
+
},
|
|
450
|
+
clearGrabbedBoxes: () => {
|
|
451
|
+
setStore("grabbedBoxes", []);
|
|
452
|
+
},
|
|
453
|
+
addLabelInstance: (instance) => {
|
|
454
|
+
setStore("labelInstances", (instances) => [...instances, instance]);
|
|
455
|
+
},
|
|
456
|
+
updateLabelInstance: (instanceId, status, errorMessage) => {
|
|
457
|
+
const index = store.labelInstances.findIndex((instance) => instance.id === instanceId);
|
|
458
|
+
if (index !== -1) setStore("labelInstances", index, produce((instance) => {
|
|
459
|
+
instance.status = status;
|
|
460
|
+
if (errorMessage !== void 0) instance.errorMessage = errorMessage;
|
|
461
|
+
}));
|
|
462
|
+
},
|
|
463
|
+
removeLabelInstance: (instanceId) => {
|
|
464
|
+
setStore("labelInstances", (instances) => instances.filter((instance) => instance.id !== instanceId));
|
|
465
|
+
},
|
|
466
|
+
clearLabelInstances: () => {
|
|
467
|
+
setStore("labelInstances", []);
|
|
468
|
+
},
|
|
469
|
+
showContextMenu: (position, element) => {
|
|
470
|
+
const { x: centerX, y: centerY } = getBoundsCenter(createElementBounds(element));
|
|
471
|
+
setStore(produce((draft) => {
|
|
472
|
+
draft.contextMenuPosition = position;
|
|
473
|
+
draft.contextMenuElement = element;
|
|
474
|
+
draft.contextMenuClickOffset = {
|
|
475
|
+
x: position.x - centerX,
|
|
476
|
+
y: position.y - centerY
|
|
477
|
+
};
|
|
478
|
+
}));
|
|
479
|
+
},
|
|
480
|
+
hideContextMenu: () => {
|
|
481
|
+
setStore(produce((draft) => {
|
|
482
|
+
draft.contextMenuPosition = null;
|
|
483
|
+
draft.contextMenuElement = null;
|
|
484
|
+
draft.contextMenuClickOffset = null;
|
|
485
|
+
}));
|
|
486
|
+
},
|
|
487
|
+
updateContextMenuPosition: () => {
|
|
488
|
+
const element = store.contextMenuElement;
|
|
489
|
+
const clickOffset = store.contextMenuClickOffset;
|
|
490
|
+
if (!element || !clickOffset) return;
|
|
491
|
+
if (!isElementConnected(element)) return;
|
|
492
|
+
const { x: newCenterX, y: newCenterY } = getBoundsCenter(createElementBounds(element));
|
|
493
|
+
setStore("contextMenuPosition", {
|
|
494
|
+
x: newCenterX + clickOffset.x,
|
|
495
|
+
y: newCenterY + clickOffset.y
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
return {
|
|
500
|
+
store,
|
|
501
|
+
actions
|
|
502
|
+
};
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region src/utils/mount-root.ts
|
|
507
|
+
const ATTRIBUTE_NAME = "data-react-grab";
|
|
508
|
+
const FONT_IMPORT = "@import url(\"https://fonts.googleapis.com/css2?family=Geist:wght@500&display=swap\");";
|
|
509
|
+
const mountRoot = (cssText) => {
|
|
510
|
+
const mountedHost = document.querySelector(`[${ATTRIBUTE_NAME}]`);
|
|
511
|
+
if (mountedHost) {
|
|
512
|
+
const mountedRoot = mountedHost.shadowRoot?.querySelector(`[${ATTRIBUTE_NAME}]`);
|
|
513
|
+
if (mountedRoot instanceof HTMLDivElement && mountedHost.shadowRoot) return mountedRoot;
|
|
514
|
+
}
|
|
515
|
+
const host = document.createElement("div");
|
|
516
|
+
host.setAttribute(ATTRIBUTE_NAME, "true");
|
|
517
|
+
hideFromThirdParties(host);
|
|
518
|
+
host.style.zIndex = String(Z_INDEX_OVERLAY);
|
|
519
|
+
host.style.position = "fixed";
|
|
520
|
+
host.style.inset = "0";
|
|
521
|
+
host.style.pointerEvents = "none";
|
|
522
|
+
host.style.contain = "strict";
|
|
523
|
+
const shadowRoot = host.attachShadow({ mode: "open" });
|
|
524
|
+
const styleElement = document.createElement("style");
|
|
525
|
+
const nonce = detectCspNonce();
|
|
526
|
+
if (nonce) styleElement.nonce = nonce;
|
|
527
|
+
styleElement.textContent = `${FONT_IMPORT}\n${cssText ?? ""}`;
|
|
528
|
+
shadowRoot.appendChild(styleElement);
|
|
529
|
+
const root = document.createElement("div");
|
|
530
|
+
root.setAttribute(ATTRIBUTE_NAME, "true");
|
|
531
|
+
shadowRoot.appendChild(root);
|
|
532
|
+
const doc = document.body ?? document.documentElement;
|
|
533
|
+
doc.appendChild(host);
|
|
534
|
+
setTimeout(() => {
|
|
535
|
+
doc.appendChild(host);
|
|
536
|
+
}, MOUNT_ROOT_RECHECK_DELAY_MS);
|
|
537
|
+
return root;
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
//#endregion
|
|
541
|
+
//#region src/core/noop-api.ts
|
|
542
|
+
const NOOP = () => {};
|
|
543
|
+
const createNoopApi = () => ({
|
|
544
|
+
activate: NOOP,
|
|
545
|
+
deactivate: NOOP,
|
|
546
|
+
toggle: NOOP,
|
|
547
|
+
comment: NOOP,
|
|
548
|
+
isActive: () => false,
|
|
549
|
+
isEnabled: () => false,
|
|
550
|
+
setEnabled: NOOP,
|
|
551
|
+
getToolbarState: () => null,
|
|
552
|
+
setToolbarState: NOOP,
|
|
553
|
+
onToolbarStateChange: () => NOOP,
|
|
554
|
+
dispose: NOOP,
|
|
555
|
+
copyElement: () => Promise.resolve(false),
|
|
556
|
+
getSource: () => Promise.resolve(null),
|
|
557
|
+
getStackContext: () => Promise.resolve(""),
|
|
558
|
+
getState: () => ({
|
|
559
|
+
isActive: false,
|
|
560
|
+
isDragging: false,
|
|
561
|
+
isCopying: false,
|
|
562
|
+
isPromptMode: false,
|
|
563
|
+
isSelectionBoxVisible: false,
|
|
564
|
+
isDragBoxVisible: false,
|
|
565
|
+
targetElement: null,
|
|
566
|
+
dragBounds: null,
|
|
567
|
+
grabbedBoxes: [],
|
|
568
|
+
labelInstances: [],
|
|
569
|
+
selectionFilePath: null,
|
|
570
|
+
toolbarState: null
|
|
571
|
+
}),
|
|
572
|
+
setOptions: NOOP,
|
|
573
|
+
registerPlugin: NOOP,
|
|
574
|
+
unregisterPlugin: NOOP,
|
|
575
|
+
getPlugins: () => [],
|
|
576
|
+
getDisplayName: () => null
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
//#endregion
|
|
580
|
+
//#region src/core/events.ts
|
|
581
|
+
const createEventListenerManager = () => {
|
|
582
|
+
const abortController = new AbortController();
|
|
583
|
+
const addWindowListener = (type, listener, options = {}) => {
|
|
584
|
+
window.addEventListener(type, listener, {
|
|
585
|
+
...options,
|
|
586
|
+
signal: abortController.signal
|
|
587
|
+
});
|
|
588
|
+
};
|
|
589
|
+
const addDocumentListener = (type, listener, options = {}) => {
|
|
590
|
+
document.addEventListener(type, listener, {
|
|
591
|
+
...options,
|
|
592
|
+
signal: abortController.signal
|
|
593
|
+
});
|
|
594
|
+
};
|
|
595
|
+
return {
|
|
596
|
+
signal: abortController.signal,
|
|
597
|
+
abort: () => abortController.abort(),
|
|
598
|
+
addWindowListener,
|
|
599
|
+
addDocumentListener
|
|
600
|
+
};
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
//#endregion
|
|
604
|
+
//#region src/utils/copy-content.ts
|
|
605
|
+
const REACT_GRAB_MIME_TYPE = "application/x-react-grab";
|
|
606
|
+
const escapeHtml = (text) => text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
607
|
+
const copyContent = (content, options) => {
|
|
608
|
+
const elementName = options?.componentName ?? "div";
|
|
609
|
+
const reactGrabMetadata = {
|
|
610
|
+
version: VERSION,
|
|
611
|
+
content,
|
|
612
|
+
entries: options?.entries ?? [{
|
|
613
|
+
tagName: options?.tagName,
|
|
614
|
+
componentName: elementName,
|
|
615
|
+
content,
|
|
616
|
+
commentText: options?.commentText
|
|
617
|
+
}],
|
|
618
|
+
timestamp: Date.now()
|
|
619
|
+
};
|
|
620
|
+
const copyHandler = (event) => {
|
|
621
|
+
event.preventDefault();
|
|
622
|
+
event.clipboardData?.setData("text/plain", content);
|
|
623
|
+
event.clipboardData?.setData("text/html", `<meta charset='utf-8'><pre><code>${escapeHtml(content)}</code></pre>`);
|
|
624
|
+
event.clipboardData?.setData(REACT_GRAB_MIME_TYPE, JSON.stringify(reactGrabMetadata));
|
|
625
|
+
};
|
|
626
|
+
document.addEventListener("copy", copyHandler);
|
|
627
|
+
const textarea = document.createElement("textarea");
|
|
628
|
+
textarea.value = content;
|
|
629
|
+
textarea.style.position = "fixed";
|
|
630
|
+
textarea.style.left = "-9999px";
|
|
631
|
+
textarea.ariaHidden = "true";
|
|
632
|
+
document.body.appendChild(textarea);
|
|
633
|
+
textarea.select();
|
|
634
|
+
try {
|
|
635
|
+
if (typeof document.execCommand !== "function") return false;
|
|
636
|
+
return document.execCommand("copy");
|
|
637
|
+
} finally {
|
|
638
|
+
document.removeEventListener("copy", copyHandler);
|
|
639
|
+
textarea.remove();
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
//#endregion
|
|
644
|
+
//#region src/utils/generate-snippet.ts
|
|
645
|
+
const generateSnippet = async (elements, options = {}) => {
|
|
646
|
+
return (await Promise.allSettled(elements.map((element) => getElementContext(element, options)))).map((result) => result.status === "fulfilled" ? result.value : "");
|
|
647
|
+
};
|
|
648
|
+
|
|
649
|
+
//#endregion
|
|
650
|
+
//#region src/utils/join-snippets.ts
|
|
651
|
+
const joinSnippets = (snippets) => {
|
|
652
|
+
if (snippets.length <= 1) return snippets[0] ?? "";
|
|
653
|
+
return snippets.map((snippet, index) => `[${index + 1}]\n${snippet}`).join("\n\n");
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
//#endregion
|
|
657
|
+
//#region src/utils/normalize-error.ts
|
|
658
|
+
const normalizeErrorMessage = (error, fallback = "Unknown error") => error instanceof Error && error.message ? error.message : fallback;
|
|
659
|
+
const normalizeError = (error) => error instanceof Error ? error : new Error(String(error));
|
|
660
|
+
|
|
661
|
+
//#endregion
|
|
662
|
+
//#region src/core/copy.ts
|
|
663
|
+
const tryCopyWithFallback = async (options, hooks, elements, extraPrompt) => {
|
|
664
|
+
let didCopy = false;
|
|
665
|
+
let copiedContent = "";
|
|
666
|
+
await hooks.onBeforeCopy(elements);
|
|
667
|
+
try {
|
|
668
|
+
let generatedContent;
|
|
669
|
+
let entries;
|
|
670
|
+
if (options.getContent) generatedContent = await options.getContent(elements);
|
|
671
|
+
else {
|
|
672
|
+
const rawSnippets = await generateSnippet(elements, { maxLines: options.maxContextLines });
|
|
673
|
+
const snippetElementPairs = (await Promise.all(rawSnippets.map((snippet, index) => snippet.trim() ? hooks.transformSnippet(snippet, elements[index]) : Promise.resolve("")))).map((snippet, index) => ({
|
|
674
|
+
snippet,
|
|
675
|
+
element: elements[index]
|
|
676
|
+
})).filter(({ snippet }) => snippet.trim());
|
|
677
|
+
generatedContent = joinSnippets(snippetElementPairs.map(({ snippet }) => snippet));
|
|
678
|
+
entries = snippetElementPairs.map(({ snippet, element }) => ({
|
|
679
|
+
tagName: element.localName,
|
|
680
|
+
content: snippet,
|
|
681
|
+
commentText: extraPrompt
|
|
682
|
+
}));
|
|
683
|
+
}
|
|
684
|
+
if (generatedContent.trim()) {
|
|
685
|
+
const transformedContent = await hooks.transformCopyContent(generatedContent, elements);
|
|
686
|
+
copiedContent = extraPrompt ? `${extraPrompt}\n\n${transformedContent}` : transformedContent;
|
|
687
|
+
didCopy = copyContent(copiedContent, {
|
|
688
|
+
componentName: options.componentName,
|
|
689
|
+
entries
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
} catch (error) {
|
|
693
|
+
hooks.onCopyError(normalizeError(error));
|
|
694
|
+
}
|
|
695
|
+
if (didCopy) hooks.onCopySuccess(elements, copiedContent);
|
|
696
|
+
hooks.onAfterCopy(elements, didCopy);
|
|
697
|
+
return didCopy;
|
|
698
|
+
};
|
|
699
|
+
|
|
700
|
+
//#endregion
|
|
701
|
+
//#region src/utils/get-elements-in-drag.ts
|
|
702
|
+
const calculateIntersectionArea = (rect1, rect2) => {
|
|
703
|
+
const intersectionLeft = Math.max(rect1.left, rect2.left);
|
|
704
|
+
const intersectionTop = Math.max(rect1.top, rect2.top);
|
|
705
|
+
const intersectionRight = Math.min(rect1.right, rect2.right);
|
|
706
|
+
const intersectionBottom = Math.min(rect1.bottom, rect2.bottom);
|
|
707
|
+
return Math.max(0, intersectionRight - intersectionLeft) * Math.max(0, intersectionBottom - intersectionTop);
|
|
708
|
+
};
|
|
709
|
+
const hasIntersection = (rect1, rect2) => {
|
|
710
|
+
return rect1.left < rect2.right && rect1.right > rect2.left && rect1.top < rect2.bottom && rect1.bottom > rect2.top;
|
|
711
|
+
};
|
|
712
|
+
const sortByDocumentOrder = (elements) => {
|
|
713
|
+
return elements.sort((leftElement, rightElement) => {
|
|
714
|
+
if (leftElement === rightElement) return 0;
|
|
715
|
+
const position = leftElement.compareDocumentPosition(rightElement);
|
|
716
|
+
if (position & Node.DOCUMENT_POSITION_FOLLOWING) return -1;
|
|
717
|
+
if (position & Node.DOCUMENT_POSITION_PRECEDING) return 1;
|
|
718
|
+
return 0;
|
|
719
|
+
});
|
|
720
|
+
};
|
|
721
|
+
const createSamplePoints = (dragRect) => {
|
|
722
|
+
if (dragRect.width <= 0 || dragRect.height <= 0) return [];
|
|
723
|
+
const viewportWidth = window.innerWidth;
|
|
724
|
+
const viewportHeight = window.innerHeight;
|
|
725
|
+
const left = dragRect.x;
|
|
726
|
+
const top = dragRect.y;
|
|
727
|
+
const right = dragRect.x + dragRect.width;
|
|
728
|
+
const bottom = dragRect.y + dragRect.height;
|
|
729
|
+
const centerX = left + dragRect.width / 2;
|
|
730
|
+
const centerY = top + dragRect.height / 2;
|
|
731
|
+
const xCount = clampToRange(Math.ceil(dragRect.width / 32), 3, 20);
|
|
732
|
+
const yCount = clampToRange(Math.ceil(dragRect.height / 32), 3, 20);
|
|
733
|
+
const totalGridPoints = xCount * yCount;
|
|
734
|
+
const scale = totalGridPoints > 100 ? Math.sqrt(100 / totalGridPoints) : 1;
|
|
735
|
+
const scaledXCount = clampToRange(Math.floor(xCount * scale), 3, 20);
|
|
736
|
+
const scaledYCount = clampToRange(Math.floor(yCount * scale), 3, 20);
|
|
737
|
+
const pointKeys = /* @__PURE__ */ new Set();
|
|
738
|
+
const points = [];
|
|
739
|
+
const addPoint = (x, y) => {
|
|
740
|
+
const clampedX = clampToRange(Math.round(x), 0, viewportWidth - 1);
|
|
741
|
+
const clampedY = clampToRange(Math.round(y), 0, viewportHeight - 1);
|
|
742
|
+
const key = `${clampedX}:${clampedY}`;
|
|
743
|
+
if (pointKeys.has(key)) return;
|
|
744
|
+
pointKeys.add(key);
|
|
745
|
+
points.push({
|
|
746
|
+
x: clampedX,
|
|
747
|
+
y: clampedY
|
|
748
|
+
});
|
|
749
|
+
};
|
|
750
|
+
addPoint(left + 1, top + 1);
|
|
751
|
+
addPoint(right - 1, top + 1);
|
|
752
|
+
addPoint(left + 1, bottom - 1);
|
|
753
|
+
addPoint(right - 1, bottom - 1);
|
|
754
|
+
addPoint(centerX, top + 1);
|
|
755
|
+
addPoint(centerX, bottom - 1);
|
|
756
|
+
addPoint(left + 1, centerY);
|
|
757
|
+
addPoint(right - 1, centerY);
|
|
758
|
+
addPoint(centerX, centerY);
|
|
759
|
+
for (let xIndex = 0; xIndex < scaledXCount; xIndex += 1) {
|
|
760
|
+
const sampleX = left + (xIndex + .5) / scaledXCount * dragRect.width;
|
|
761
|
+
for (let yIndex = 0; yIndex < scaledYCount; yIndex += 1) addPoint(sampleX, top + (yIndex + .5) / scaledYCount * dragRect.height);
|
|
762
|
+
}
|
|
763
|
+
return points;
|
|
764
|
+
};
|
|
765
|
+
const filterElementsInDrag = (dragRect, isValidGrabbableElement, shouldCheckCoverage) => {
|
|
766
|
+
const dragBounds = {
|
|
767
|
+
left: dragRect.x,
|
|
768
|
+
top: dragRect.y,
|
|
769
|
+
right: dragRect.x + dragRect.width,
|
|
770
|
+
bottom: dragRect.y + dragRect.height
|
|
771
|
+
};
|
|
772
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
773
|
+
const samplePoints = createSamplePoints(dragRect);
|
|
774
|
+
suspendPointerEventsFreeze();
|
|
775
|
+
try {
|
|
776
|
+
for (const point of samplePoints) {
|
|
777
|
+
const elementsAtPoint = document.elementsFromPoint(point.x, point.y);
|
|
778
|
+
for (const candidateElement of elementsAtPoint) candidates.add(candidateElement);
|
|
779
|
+
}
|
|
780
|
+
} finally {
|
|
781
|
+
resumePointerEventsFreeze();
|
|
782
|
+
}
|
|
783
|
+
const validCandidates = [];
|
|
784
|
+
for (const candidateElement of candidates) {
|
|
785
|
+
if (!shouldCheckCoverage && isRootElement(candidateElement)) continue;
|
|
786
|
+
if (!isValidGrabbableElement(candidateElement)) continue;
|
|
787
|
+
validCandidates.push(candidateElement);
|
|
788
|
+
}
|
|
789
|
+
const candidateRects = /* @__PURE__ */ new Map();
|
|
790
|
+
for (const candidateElement of validCandidates) candidateRects.set(candidateElement, candidateElement.getBoundingClientRect());
|
|
791
|
+
const matchingElements = [];
|
|
792
|
+
for (const candidateElement of validCandidates) {
|
|
793
|
+
const elementRect = candidateRects.get(candidateElement);
|
|
794
|
+
if (elementRect.width <= 0 || elementRect.height <= 0) continue;
|
|
795
|
+
const elementBounds = {
|
|
796
|
+
left: elementRect.left,
|
|
797
|
+
top: elementRect.top,
|
|
798
|
+
right: elementRect.left + elementRect.width,
|
|
799
|
+
bottom: elementRect.top + elementRect.height
|
|
800
|
+
};
|
|
801
|
+
if (shouldCheckCoverage) {
|
|
802
|
+
const intersectionArea = calculateIntersectionArea(dragBounds, elementBounds);
|
|
803
|
+
const elementArea = elementRect.width * elementRect.height;
|
|
804
|
+
if (elementArea > 0 && intersectionArea / elementArea >= .75) matchingElements.push(candidateElement);
|
|
805
|
+
} else if (hasIntersection(elementBounds, dragBounds)) matchingElements.push(candidateElement);
|
|
806
|
+
}
|
|
807
|
+
return sortByDocumentOrder(matchingElements);
|
|
808
|
+
};
|
|
809
|
+
const removeNestedElements = (elements) => {
|
|
810
|
+
return elements.filter((element) => {
|
|
811
|
+
return !elements.some((otherElement) => otherElement !== element && otherElement.contains(element));
|
|
812
|
+
});
|
|
813
|
+
};
|
|
814
|
+
const getElementsInDrag = (dragRect, isValidGrabbableElement, shouldCheckCoverage = true) => {
|
|
815
|
+
return removeNestedElements(filterElementsInDrag(dragRect, isValidGrabbableElement, shouldCheckCoverage));
|
|
816
|
+
};
|
|
817
|
+
|
|
818
|
+
//#endregion
|
|
819
|
+
//#region src/utils/get-ancestor-elements.ts
|
|
820
|
+
const getAncestorElements = (element) => {
|
|
821
|
+
const ancestors = [];
|
|
822
|
+
let current = element.parentElement;
|
|
823
|
+
while (current && !isRootElement(current)) {
|
|
824
|
+
ancestors.push(current);
|
|
825
|
+
current = current.parentElement;
|
|
826
|
+
}
|
|
827
|
+
return ancestors;
|
|
828
|
+
};
|
|
829
|
+
|
|
830
|
+
//#endregion
|
|
831
|
+
//#region src/utils/get-visible-bounds-center.ts
|
|
832
|
+
const getVisibleBoundsCenter = (bounds) => {
|
|
833
|
+
const viewportWidth = window.innerWidth;
|
|
834
|
+
const viewportHeight = window.innerHeight;
|
|
835
|
+
const visibleLeft = Math.max(0, bounds.x);
|
|
836
|
+
const visibleRight = Math.min(viewportWidth, bounds.x + bounds.width);
|
|
837
|
+
const visibleTop = Math.max(0, bounds.y);
|
|
838
|
+
const visibleBottom = Math.min(viewportHeight, bounds.y + bounds.height);
|
|
839
|
+
return {
|
|
840
|
+
x: (visibleLeft + visibleRight) / 2,
|
|
841
|
+
y: (visibleTop + visibleBottom) / 2
|
|
842
|
+
};
|
|
843
|
+
};
|
|
844
|
+
|
|
845
|
+
//#endregion
|
|
846
|
+
//#region src/utils/invalidate-interaction-caches.ts
|
|
847
|
+
const invalidateInteractionCaches = () => {
|
|
848
|
+
invalidateBoundsCache();
|
|
849
|
+
clearElementPositionCache();
|
|
850
|
+
clearVisibilityCache();
|
|
851
|
+
};
|
|
852
|
+
|
|
853
|
+
//#endregion
|
|
854
|
+
//#region src/utils/create-bounds-from-drag-rect.ts
|
|
855
|
+
const createBoundsFromDragRect = (dragRect) => ({
|
|
856
|
+
x: dragRect.pageX - window.scrollX,
|
|
857
|
+
y: dragRect.pageY - window.scrollY,
|
|
858
|
+
width: dragRect.width,
|
|
859
|
+
height: dragRect.height,
|
|
860
|
+
borderRadius: "0px",
|
|
861
|
+
transform: "none"
|
|
862
|
+
});
|
|
863
|
+
const createPageRectFromBounds = (bounds) => ({
|
|
864
|
+
pageX: bounds.x + window.scrollX,
|
|
865
|
+
pageY: bounds.y + window.scrollY,
|
|
866
|
+
width: bounds.width,
|
|
867
|
+
height: bounds.height
|
|
868
|
+
});
|
|
869
|
+
const createFlatOverlayBounds = (bounds) => ({
|
|
870
|
+
...bounds,
|
|
871
|
+
borderRadius: "0px",
|
|
872
|
+
transform: "none"
|
|
873
|
+
});
|
|
874
|
+
|
|
875
|
+
//#endregion
|
|
876
|
+
//#region src/utils/is-c-like-key.ts
|
|
877
|
+
const C_LIKE_CHARACTERS = new Set([
|
|
878
|
+
"c",
|
|
879
|
+
"C",
|
|
880
|
+
"с",
|
|
881
|
+
"С",
|
|
882
|
+
"ȼ",
|
|
883
|
+
"Ȼ",
|
|
884
|
+
"ↄ",
|
|
885
|
+
"Ↄ",
|
|
886
|
+
"ᴄ",
|
|
887
|
+
"ᶜ",
|
|
888
|
+
"ⱼ",
|
|
889
|
+
"ⅽ",
|
|
890
|
+
"Ⅽ",
|
|
891
|
+
"ç",
|
|
892
|
+
"Ç",
|
|
893
|
+
"ć",
|
|
894
|
+
"Ć",
|
|
895
|
+
"č",
|
|
896
|
+
"Č",
|
|
897
|
+
"ĉ",
|
|
898
|
+
"Ĉ",
|
|
899
|
+
"ċ",
|
|
900
|
+
"Ċ"
|
|
901
|
+
]);
|
|
902
|
+
const isCLikeKey = (key, code) => {
|
|
903
|
+
if (code === "KeyC") return true;
|
|
904
|
+
if (!key || key.length !== 1) return false;
|
|
905
|
+
return C_LIKE_CHARACTERS.has(key);
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
//#endregion
|
|
909
|
+
//#region src/utils/key-matches-code.ts
|
|
910
|
+
const keyMatchesCode = (targetKey, code) => {
|
|
911
|
+
const normalizedTarget = targetKey.toLowerCase();
|
|
912
|
+
if (code === "Space") return normalizedTarget === "space" || normalizedTarget === " ";
|
|
913
|
+
if (code.startsWith("Key")) return code.slice(3).toLowerCase() === normalizedTarget;
|
|
914
|
+
if (code.startsWith("Digit")) return code.slice(5) === normalizedTarget;
|
|
915
|
+
return false;
|
|
916
|
+
};
|
|
917
|
+
|
|
918
|
+
//#endregion
|
|
919
|
+
//#region src/utils/parse-activation-key.ts
|
|
920
|
+
const MODIFIER_MAP = {
|
|
921
|
+
meta: "metaKey",
|
|
922
|
+
cmd: "metaKey",
|
|
923
|
+
command: "metaKey",
|
|
924
|
+
win: "metaKey",
|
|
925
|
+
windows: "metaKey",
|
|
926
|
+
ctrl: "ctrlKey",
|
|
927
|
+
control: "ctrlKey",
|
|
928
|
+
shift: "shiftKey",
|
|
929
|
+
alt: "altKey",
|
|
930
|
+
option: "altKey",
|
|
931
|
+
opt: "altKey"
|
|
932
|
+
};
|
|
933
|
+
const parseString = (shortcut) => {
|
|
934
|
+
const parts = shortcut.split("+").map((part) => part.trim().toLowerCase());
|
|
935
|
+
const result = {
|
|
936
|
+
metaKey: false,
|
|
937
|
+
ctrlKey: false,
|
|
938
|
+
shiftKey: false,
|
|
939
|
+
altKey: false,
|
|
940
|
+
key: null
|
|
941
|
+
};
|
|
942
|
+
for (const part of parts) {
|
|
943
|
+
const modifierKey = MODIFIER_MAP[part];
|
|
944
|
+
if (modifierKey) result[modifierKey] = true;
|
|
945
|
+
else result.key = part;
|
|
946
|
+
}
|
|
947
|
+
return result;
|
|
948
|
+
};
|
|
949
|
+
const parseActivationKey = (activationKey) => {
|
|
950
|
+
if (typeof activationKey === "function") return activationKey;
|
|
951
|
+
const parsed = parseString(activationKey);
|
|
952
|
+
const targetKey = parsed.key;
|
|
953
|
+
return (event) => {
|
|
954
|
+
if (targetKey === null) {
|
|
955
|
+
const metaMatches = parsed.metaKey ? event.metaKey || event.key === "Meta" : true;
|
|
956
|
+
const ctrlMatches = parsed.ctrlKey ? event.ctrlKey || event.key === "Control" : true;
|
|
957
|
+
const shiftMatches = parsed.shiftKey ? event.shiftKey || event.key === "Shift" : true;
|
|
958
|
+
const altMatches = parsed.altKey ? event.altKey || event.key === "Alt" : true;
|
|
959
|
+
const allRequiredModifiersPressed = metaMatches && ctrlMatches && shiftMatches && altMatches;
|
|
960
|
+
const requiredModifierCount = [
|
|
961
|
+
parsed.metaKey,
|
|
962
|
+
parsed.ctrlKey,
|
|
963
|
+
parsed.shiftKey,
|
|
964
|
+
parsed.altKey
|
|
965
|
+
].filter(Boolean).length;
|
|
966
|
+
const pressedModifierCount = [
|
|
967
|
+
event.metaKey || event.key === "Meta",
|
|
968
|
+
event.ctrlKey || event.key === "Control",
|
|
969
|
+
event.shiftKey || event.key === "Shift",
|
|
970
|
+
event.altKey || event.key === "Alt"
|
|
971
|
+
].filter(Boolean).length;
|
|
972
|
+
return allRequiredModifiersPressed && pressedModifierCount >= requiredModifierCount;
|
|
973
|
+
}
|
|
974
|
+
const keyMatches = event.key?.toLowerCase() === targetKey || keyMatchesCode(targetKey, event.code);
|
|
975
|
+
const modifiersMatch = parsed.metaKey || parsed.ctrlKey || parsed.shiftKey || parsed.altKey ? (parsed.metaKey ? event.metaKey : true) && (parsed.ctrlKey ? event.ctrlKey : true) && (parsed.shiftKey ? event.shiftKey : true) && (parsed.altKey ? event.altKey : true) : !event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey;
|
|
976
|
+
return keyMatches && modifiersMatch;
|
|
977
|
+
};
|
|
978
|
+
};
|
|
979
|
+
const getModifiersFromActivationKey = (activationKey) => {
|
|
980
|
+
if (!activationKey || typeof activationKey === "function") return {
|
|
981
|
+
metaKey: isMac(),
|
|
982
|
+
ctrlKey: !isMac(),
|
|
983
|
+
shiftKey: false,
|
|
984
|
+
altKey: false,
|
|
985
|
+
key: null
|
|
986
|
+
};
|
|
987
|
+
return parseString(activationKey);
|
|
988
|
+
};
|
|
989
|
+
|
|
990
|
+
//#endregion
|
|
991
|
+
//#region src/utils/is-target-key-combination.ts
|
|
992
|
+
const isTargetKeyCombination = (event, options) => {
|
|
993
|
+
if (options.activationKey) return parseActivationKey(options.activationKey)(event);
|
|
994
|
+
const hasOnlyPlatformModifier = (isMac() ? event.metaKey : event.ctrlKey) && !event.shiftKey && !event.altKey;
|
|
995
|
+
return Boolean(event.key && hasOnlyPlatformModifier && isCLikeKey(event.key, event.code));
|
|
996
|
+
};
|
|
997
|
+
|
|
998
|
+
//#endregion
|
|
999
|
+
//#region src/utils/combine-bounds.ts
|
|
1000
|
+
const combineBounds = (boundsList) => {
|
|
1001
|
+
if (boundsList.length === 0) return {
|
|
1002
|
+
x: 0,
|
|
1003
|
+
y: 0,
|
|
1004
|
+
width: 0,
|
|
1005
|
+
height: 0
|
|
1006
|
+
};
|
|
1007
|
+
if (boundsList.length === 1) return boundsList[0];
|
|
1008
|
+
let minX = Infinity;
|
|
1009
|
+
let minY = Infinity;
|
|
1010
|
+
let maxX = -Infinity;
|
|
1011
|
+
let maxY = -Infinity;
|
|
1012
|
+
for (const bounds of boundsList) {
|
|
1013
|
+
minX = Math.min(minX, bounds.x);
|
|
1014
|
+
minY = Math.min(minY, bounds.y);
|
|
1015
|
+
maxX = Math.max(maxX, bounds.x + bounds.width);
|
|
1016
|
+
maxY = Math.max(maxY, bounds.y + bounds.height);
|
|
1017
|
+
}
|
|
1018
|
+
return {
|
|
1019
|
+
x: minX,
|
|
1020
|
+
y: minY,
|
|
1021
|
+
width: maxX - minX,
|
|
1022
|
+
height: maxY - minY
|
|
1023
|
+
};
|
|
1024
|
+
};
|
|
1025
|
+
|
|
1026
|
+
//#endregion
|
|
1027
|
+
//#region src/core/theme.ts
|
|
1028
|
+
const DEFAULT_THEME = {
|
|
1029
|
+
enabled: true,
|
|
1030
|
+
hue: 0,
|
|
1031
|
+
selectionBox: { enabled: true },
|
|
1032
|
+
dragBox: { enabled: true },
|
|
1033
|
+
grabbedBoxes: { enabled: true },
|
|
1034
|
+
elementLabel: { enabled: true },
|
|
1035
|
+
toolbar: { enabled: true }
|
|
1036
|
+
};
|
|
1037
|
+
const deepMergeTheme = (baseTheme, partialTheme) => ({
|
|
1038
|
+
enabled: partialTheme.enabled ?? baseTheme.enabled,
|
|
1039
|
+
hue: partialTheme.hue ?? baseTheme.hue,
|
|
1040
|
+
selectionBox: { enabled: partialTheme.selectionBox?.enabled ?? baseTheme.selectionBox.enabled },
|
|
1041
|
+
dragBox: { enabled: partialTheme.dragBox?.enabled ?? baseTheme.dragBox.enabled },
|
|
1042
|
+
grabbedBoxes: { enabled: partialTheme.grabbedBoxes?.enabled ?? baseTheme.grabbedBoxes.enabled },
|
|
1043
|
+
elementLabel: { enabled: partialTheme.elementLabel?.enabled ?? baseTheme.elementLabel.enabled },
|
|
1044
|
+
toolbar: { enabled: partialTheme.toolbar?.enabled ?? baseTheme.toolbar.enabled }
|
|
1045
|
+
});
|
|
1046
|
+
|
|
1047
|
+
//#endregion
|
|
1048
|
+
//#region src/core/plugin-registry.ts
|
|
1049
|
+
const DEFAULT_OPTIONS = {
|
|
1050
|
+
activationMode: "toggle",
|
|
1051
|
+
keyHoldDuration: 100,
|
|
1052
|
+
allowActivationInsideInput: true,
|
|
1053
|
+
maxContextLines: 3,
|
|
1054
|
+
activationKey: void 0,
|
|
1055
|
+
getContent: void 0,
|
|
1056
|
+
freezeReactUpdates: true
|
|
1057
|
+
};
|
|
1058
|
+
const createPluginRegistry = (initialOptions = {}) => {
|
|
1059
|
+
const plugins = /* @__PURE__ */ new Map();
|
|
1060
|
+
const directOptionOverrides = {};
|
|
1061
|
+
const [store, setStore] = createStore({
|
|
1062
|
+
theme: DEFAULT_THEME,
|
|
1063
|
+
options: {
|
|
1064
|
+
...DEFAULT_OPTIONS,
|
|
1065
|
+
...initialOptions
|
|
1066
|
+
},
|
|
1067
|
+
actions: []
|
|
1068
|
+
});
|
|
1069
|
+
const recomputeStore = () => {
|
|
1070
|
+
let mergedTheme = DEFAULT_THEME;
|
|
1071
|
+
let mergedOptions = {
|
|
1072
|
+
...DEFAULT_OPTIONS,
|
|
1073
|
+
...initialOptions
|
|
1074
|
+
};
|
|
1075
|
+
const allContextMenuActions = [];
|
|
1076
|
+
for (const { config } of plugins.values()) {
|
|
1077
|
+
if (config.theme) mergedTheme = deepMergeTheme(mergedTheme, config.theme);
|
|
1078
|
+
if (config.options) mergedOptions = {
|
|
1079
|
+
...mergedOptions,
|
|
1080
|
+
...config.options
|
|
1081
|
+
};
|
|
1082
|
+
if (config.actions) for (const action of config.actions) allContextMenuActions.push(action);
|
|
1083
|
+
}
|
|
1084
|
+
mergedOptions = {
|
|
1085
|
+
...mergedOptions,
|
|
1086
|
+
...directOptionOverrides
|
|
1087
|
+
};
|
|
1088
|
+
setStore("theme", mergedTheme);
|
|
1089
|
+
setStore("options", mergedOptions);
|
|
1090
|
+
setStore("actions", allContextMenuActions);
|
|
1091
|
+
};
|
|
1092
|
+
const setOption = (optionKey, optionValue) => {
|
|
1093
|
+
directOptionOverrides[optionKey] = optionValue;
|
|
1094
|
+
setStore("options", optionKey, optionValue);
|
|
1095
|
+
};
|
|
1096
|
+
const SETTABLE_OPTION_KEYS = [
|
|
1097
|
+
"activationMode",
|
|
1098
|
+
"keyHoldDuration",
|
|
1099
|
+
"allowActivationInsideInput",
|
|
1100
|
+
"maxContextLines",
|
|
1101
|
+
"activationKey",
|
|
1102
|
+
"getContent",
|
|
1103
|
+
"freezeReactUpdates"
|
|
1104
|
+
];
|
|
1105
|
+
const setOptions = (optionUpdates) => {
|
|
1106
|
+
for (const optionKey of SETTABLE_OPTION_KEYS) if (optionUpdates[optionKey] !== void 0) setOption(optionKey, optionUpdates[optionKey]);
|
|
1107
|
+
};
|
|
1108
|
+
const register = (plugin, api) => {
|
|
1109
|
+
if (plugins.has(plugin.name)) unregister(plugin.name);
|
|
1110
|
+
const config = plugin.setup?.(api, hooks) ?? {};
|
|
1111
|
+
if (plugin.theme) config.theme = config.theme ? deepMergeTheme(deepMergeTheme(DEFAULT_THEME, plugin.theme), config.theme) : plugin.theme;
|
|
1112
|
+
if (plugin.actions) config.actions = [...plugin.actions, ...config.actions ?? []];
|
|
1113
|
+
if (plugin.hooks) config.hooks = config.hooks ? {
|
|
1114
|
+
...plugin.hooks,
|
|
1115
|
+
...config.hooks
|
|
1116
|
+
} : plugin.hooks;
|
|
1117
|
+
if (plugin.options) config.options = config.options ? {
|
|
1118
|
+
...plugin.options,
|
|
1119
|
+
...config.options
|
|
1120
|
+
} : plugin.options;
|
|
1121
|
+
plugins.set(plugin.name, {
|
|
1122
|
+
plugin,
|
|
1123
|
+
config
|
|
1124
|
+
});
|
|
1125
|
+
recomputeStore();
|
|
1126
|
+
};
|
|
1127
|
+
const unregister = (name) => {
|
|
1128
|
+
const registered = plugins.get(name);
|
|
1129
|
+
if (!registered) return;
|
|
1130
|
+
if (registered.config.cleanup) registered.config.cleanup();
|
|
1131
|
+
plugins.delete(name);
|
|
1132
|
+
recomputeStore();
|
|
1133
|
+
};
|
|
1134
|
+
const getPluginNames = () => {
|
|
1135
|
+
return Array.from(plugins.keys());
|
|
1136
|
+
};
|
|
1137
|
+
const callHook = (hookName, ...args) => {
|
|
1138
|
+
for (const { config } of plugins.values()) {
|
|
1139
|
+
const hook = config.hooks?.[hookName];
|
|
1140
|
+
if (hook) hook(...args);
|
|
1141
|
+
}
|
|
1142
|
+
};
|
|
1143
|
+
const callHookWithHandled = (hookName, ...args) => {
|
|
1144
|
+
let handled = false;
|
|
1145
|
+
for (const { config } of plugins.values()) {
|
|
1146
|
+
const hook = config.hooks?.[hookName];
|
|
1147
|
+
if (hook) {
|
|
1148
|
+
if (hook(...args) === true) handled = true;
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
return handled;
|
|
1152
|
+
};
|
|
1153
|
+
const callHookAsync = async (hookName, ...args) => {
|
|
1154
|
+
for (const { config } of plugins.values()) {
|
|
1155
|
+
const hook = config.hooks?.[hookName];
|
|
1156
|
+
if (hook) await hook(...args);
|
|
1157
|
+
}
|
|
1158
|
+
};
|
|
1159
|
+
const callHookReduce = async (hookName, initialValue, ...extraArgs) => {
|
|
1160
|
+
let result = initialValue;
|
|
1161
|
+
for (const { config } of plugins.values()) {
|
|
1162
|
+
const hook = config.hooks?.[hookName];
|
|
1163
|
+
if (hook) result = await hook(result, ...extraArgs);
|
|
1164
|
+
}
|
|
1165
|
+
return result;
|
|
1166
|
+
};
|
|
1167
|
+
const callHookReduceSync = (hookName, initialValue, ...extraArgs) => {
|
|
1168
|
+
let result = initialValue;
|
|
1169
|
+
for (const { config } of plugins.values()) {
|
|
1170
|
+
const hook = config.hooks?.[hookName];
|
|
1171
|
+
if (hook) result = hook(result, ...extraArgs);
|
|
1172
|
+
}
|
|
1173
|
+
return result;
|
|
1174
|
+
};
|
|
1175
|
+
const hooks = {
|
|
1176
|
+
onActivate: () => callHook("onActivate"),
|
|
1177
|
+
onDeactivate: () => callHook("onDeactivate"),
|
|
1178
|
+
onElementHover: (element) => callHook("onElementHover", element),
|
|
1179
|
+
onElementSelect: (element) => {
|
|
1180
|
+
let wasIntercepted = false;
|
|
1181
|
+
let pendingResult;
|
|
1182
|
+
for (const { config } of plugins.values()) {
|
|
1183
|
+
const hook = config.hooks?.onElementSelect;
|
|
1184
|
+
if (hook) {
|
|
1185
|
+
const result = hook(element);
|
|
1186
|
+
if (result === true) wasIntercepted = true;
|
|
1187
|
+
else if (result instanceof Promise) {
|
|
1188
|
+
wasIntercepted = true;
|
|
1189
|
+
pendingResult = result;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
return {
|
|
1194
|
+
wasIntercepted,
|
|
1195
|
+
pendingResult
|
|
1196
|
+
};
|
|
1197
|
+
},
|
|
1198
|
+
onDragStart: (startX, startY) => callHook("onDragStart", startX, startY),
|
|
1199
|
+
onDragEnd: (elements, bounds) => callHook("onDragEnd", elements, bounds),
|
|
1200
|
+
onBeforeCopy: async (elements) => callHookAsync("onBeforeCopy", elements),
|
|
1201
|
+
transformCopyContent: async (content, elements) => callHookReduce("transformCopyContent", content, elements),
|
|
1202
|
+
onAfterCopy: (elements, success) => callHook("onAfterCopy", elements, success),
|
|
1203
|
+
onCopySuccess: (elements, content) => callHook("onCopySuccess", elements, content),
|
|
1204
|
+
onCopyError: (error) => callHook("onCopyError", error),
|
|
1205
|
+
onStateChange: (state) => callHook("onStateChange", state),
|
|
1206
|
+
onPromptModeChange: (isPromptMode, context) => callHook("onPromptModeChange", isPromptMode, context),
|
|
1207
|
+
onSelectionBox: (visible, bounds, element) => callHook("onSelectionBox", visible, bounds, element),
|
|
1208
|
+
onDragBox: (visible, bounds) => callHook("onDragBox", visible, bounds),
|
|
1209
|
+
onGrabbedBox: (bounds, element) => callHook("onGrabbedBox", bounds, element),
|
|
1210
|
+
onElementLabel: (visible, variant, context) => callHook("onElementLabel", visible, variant, context),
|
|
1211
|
+
onContextMenu: (element, position) => callHook("onContextMenu", element, position),
|
|
1212
|
+
onOpenFile: (filePath, lineNumber) => callHookWithHandled("onOpenFile", filePath, lineNumber),
|
|
1213
|
+
transformHtmlContent: async (html, elements) => callHookReduce("transformHtmlContent", html, elements),
|
|
1214
|
+
transformAgentContext: async (context, elements) => callHookReduce("transformAgentContext", context, elements),
|
|
1215
|
+
transformActionContext: (context) => callHookReduceSync("transformActionContext", context),
|
|
1216
|
+
transformOpenFileUrl: (url, filePath, lineNumber) => callHookReduceSync("transformOpenFileUrl", url, filePath, lineNumber),
|
|
1217
|
+
transformSnippet: async (snippet, element) => callHookReduce("transformSnippet", snippet, element)
|
|
1218
|
+
};
|
|
1219
|
+
return {
|
|
1220
|
+
register,
|
|
1221
|
+
unregister,
|
|
1222
|
+
getPluginNames,
|
|
1223
|
+
setOptions,
|
|
1224
|
+
store,
|
|
1225
|
+
hooks
|
|
1226
|
+
};
|
|
1227
|
+
};
|
|
1228
|
+
|
|
1229
|
+
//#endregion
|
|
1230
|
+
//#region src/core/arrow-navigation.ts
|
|
1231
|
+
const createArrowNavigator = (isValidGrabbableElement, createElementBounds) => {
|
|
1232
|
+
let navigationHistory = [];
|
|
1233
|
+
const findVerticalNext = (currentElement, direction) => {
|
|
1234
|
+
const probePoint = getVisibleBoundsCenter(createElementBounds(currentElement));
|
|
1235
|
+
const elementsAtPoint = getElementsAtPoint(probePoint.x, probePoint.y).filter(isValidGrabbableElement);
|
|
1236
|
+
const currentIndex = elementsAtPoint.indexOf(currentElement);
|
|
1237
|
+
if (currentIndex === -1) return null;
|
|
1238
|
+
return elementsAtPoint[currentIndex + direction] ?? null;
|
|
1239
|
+
};
|
|
1240
|
+
const findUp = (currentElement) => {
|
|
1241
|
+
const nextElement = findVerticalNext(currentElement, 1);
|
|
1242
|
+
if (nextElement) {
|
|
1243
|
+
navigationHistory.push(currentElement);
|
|
1244
|
+
if (navigationHistory.length > 50) navigationHistory = navigationHistory.slice(-50);
|
|
1245
|
+
}
|
|
1246
|
+
return nextElement;
|
|
1247
|
+
};
|
|
1248
|
+
const findDown = (currentElement) => {
|
|
1249
|
+
if (navigationHistory.length > 0) {
|
|
1250
|
+
const previousElement = navigationHistory.pop();
|
|
1251
|
+
if (isElementConnected(previousElement)) return previousElement;
|
|
1252
|
+
}
|
|
1253
|
+
return findVerticalNext(currentElement, -1);
|
|
1254
|
+
};
|
|
1255
|
+
const findHorizontal = (currentElement, isForward) => {
|
|
1256
|
+
const findEdgeDescendant = (parentElement) => {
|
|
1257
|
+
const children = Array.from(parentElement.children);
|
|
1258
|
+
const ordered = isForward ? children : children.reverse();
|
|
1259
|
+
for (const childElement of ordered) if (isForward) {
|
|
1260
|
+
if (isValidGrabbableElement(childElement)) return childElement;
|
|
1261
|
+
const descendant = findEdgeDescendant(childElement);
|
|
1262
|
+
if (descendant) return descendant;
|
|
1263
|
+
} else {
|
|
1264
|
+
const descendant = findEdgeDescendant(childElement);
|
|
1265
|
+
if (descendant) return descendant;
|
|
1266
|
+
if (isValidGrabbableElement(childElement)) return childElement;
|
|
1267
|
+
}
|
|
1268
|
+
return null;
|
|
1269
|
+
};
|
|
1270
|
+
const getSibling = (element) => isForward ? element.nextElementSibling : element.previousElementSibling;
|
|
1271
|
+
let nextElement = null;
|
|
1272
|
+
if (isForward) nextElement = findEdgeDescendant(currentElement);
|
|
1273
|
+
if (!nextElement) {
|
|
1274
|
+
let searchElement = currentElement;
|
|
1275
|
+
while (searchElement) {
|
|
1276
|
+
let sibling = getSibling(searchElement);
|
|
1277
|
+
while (sibling) {
|
|
1278
|
+
const descendant = findEdgeDescendant(sibling);
|
|
1279
|
+
if (descendant) {
|
|
1280
|
+
nextElement = descendant;
|
|
1281
|
+
break;
|
|
1282
|
+
}
|
|
1283
|
+
if (isValidGrabbableElement(sibling)) {
|
|
1284
|
+
nextElement = sibling;
|
|
1285
|
+
break;
|
|
1286
|
+
}
|
|
1287
|
+
sibling = getSibling(sibling);
|
|
1288
|
+
}
|
|
1289
|
+
if (nextElement) break;
|
|
1290
|
+
const parentElement = searchElement.parentElement;
|
|
1291
|
+
if (!isForward && parentElement && isValidGrabbableElement(parentElement)) {
|
|
1292
|
+
nextElement = parentElement;
|
|
1293
|
+
break;
|
|
1294
|
+
}
|
|
1295
|
+
searchElement = parentElement;
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
return nextElement;
|
|
1299
|
+
};
|
|
1300
|
+
const findNext = (key, currentElement) => {
|
|
1301
|
+
switch (key) {
|
|
1302
|
+
case "ArrowUp": return findUp(currentElement);
|
|
1303
|
+
case "ArrowDown": return findDown(currentElement);
|
|
1304
|
+
case "ArrowRight": return findHorizontal(currentElement, true);
|
|
1305
|
+
case "ArrowLeft": return findHorizontal(currentElement, false);
|
|
1306
|
+
default: return null;
|
|
1307
|
+
}
|
|
1308
|
+
};
|
|
1309
|
+
const clearHistory = () => {
|
|
1310
|
+
navigationHistory = [];
|
|
1311
|
+
};
|
|
1312
|
+
return {
|
|
1313
|
+
findNext,
|
|
1314
|
+
clearHistory
|
|
1315
|
+
};
|
|
1316
|
+
};
|
|
1317
|
+
|
|
1318
|
+
//#endregion
|
|
1319
|
+
//#region src/core/keyboard-handlers.ts
|
|
1320
|
+
const getRequiredModifiers = (options) => {
|
|
1321
|
+
const { metaKey, ctrlKey, shiftKey, altKey } = getModifiersFromActivationKey(options.activationKey);
|
|
1322
|
+
return {
|
|
1323
|
+
metaKey,
|
|
1324
|
+
ctrlKey,
|
|
1325
|
+
shiftKey,
|
|
1326
|
+
altKey
|
|
1327
|
+
};
|
|
1328
|
+
};
|
|
1329
|
+
const setupKeyboardEventClaimer = () => {
|
|
1330
|
+
const claimedEvents = /* @__PURE__ */ new WeakSet();
|
|
1331
|
+
const originalKeyDescriptor = Object.getOwnPropertyDescriptor(KeyboardEvent.prototype, "key");
|
|
1332
|
+
let didPatch = false;
|
|
1333
|
+
if (originalKeyDescriptor?.get && !originalKeyDescriptor.get.__reactGrabPatched) {
|
|
1334
|
+
didPatch = true;
|
|
1335
|
+
const originalGetter = originalKeyDescriptor.get;
|
|
1336
|
+
const patchedGetter = function() {
|
|
1337
|
+
if (claimedEvents.has(this)) return "";
|
|
1338
|
+
return originalGetter.call(this);
|
|
1339
|
+
};
|
|
1340
|
+
patchedGetter.__reactGrabPatched = true;
|
|
1341
|
+
Object.defineProperty(KeyboardEvent.prototype, "key", {
|
|
1342
|
+
get: patchedGetter,
|
|
1343
|
+
configurable: true
|
|
1344
|
+
});
|
|
1345
|
+
}
|
|
1346
|
+
const restore = () => {
|
|
1347
|
+
if (didPatch && originalKeyDescriptor) Object.defineProperty(KeyboardEvent.prototype, "key", originalKeyDescriptor);
|
|
1348
|
+
};
|
|
1349
|
+
return {
|
|
1350
|
+
claimedEvents,
|
|
1351
|
+
originalKeyDescriptor,
|
|
1352
|
+
restore
|
|
1353
|
+
};
|
|
1354
|
+
};
|
|
1355
|
+
|
|
1356
|
+
//#endregion
|
|
1357
|
+
//#region src/core/auto-scroll.ts
|
|
1358
|
+
const getAutoScrollDirection = (clientX, clientY) => {
|
|
1359
|
+
return {
|
|
1360
|
+
top: clientY < 25,
|
|
1361
|
+
bottom: clientY > window.innerHeight - 25,
|
|
1362
|
+
left: clientX < 25,
|
|
1363
|
+
right: clientX > window.innerWidth - 25
|
|
1364
|
+
};
|
|
1365
|
+
};
|
|
1366
|
+
const createAutoScroller = (getMousePosition, shouldContinue) => {
|
|
1367
|
+
let animationId = null;
|
|
1368
|
+
const scroll = () => {
|
|
1369
|
+
if (!shouldContinue()) {
|
|
1370
|
+
stop();
|
|
1371
|
+
return;
|
|
1372
|
+
}
|
|
1373
|
+
const position = getMousePosition();
|
|
1374
|
+
const direction = getAutoScrollDirection(position.x, position.y);
|
|
1375
|
+
if (direction.top) window.scrollBy(0, -10);
|
|
1376
|
+
if (direction.bottom) window.scrollBy(0, 10);
|
|
1377
|
+
if (direction.left) window.scrollBy(-10, 0);
|
|
1378
|
+
if (direction.right) window.scrollBy(10, 0);
|
|
1379
|
+
if (direction.top || direction.bottom || direction.left || direction.right) animationId = nativeRequestAnimationFrame(scroll);
|
|
1380
|
+
else animationId = null;
|
|
1381
|
+
};
|
|
1382
|
+
const stop = () => {
|
|
1383
|
+
if (animationId !== null) {
|
|
1384
|
+
nativeCancelAnimationFrame(animationId);
|
|
1385
|
+
animationId = null;
|
|
1386
|
+
}
|
|
1387
|
+
};
|
|
1388
|
+
const isActive = () => animationId !== null;
|
|
1389
|
+
return {
|
|
1390
|
+
start: scroll,
|
|
1391
|
+
stop,
|
|
1392
|
+
isActive
|
|
1393
|
+
};
|
|
1394
|
+
};
|
|
1395
|
+
|
|
1396
|
+
//#endregion
|
|
1397
|
+
//#region src/core/logo-svg.ts
|
|
1398
|
+
const LOGO_SVG = `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 294 294"><path fill="#ff40e0" d="M145 47c25-20 50-27 67-17 16 9 23 30 20 60 0 2-1 5-1 7l-2 13h-1l-12-4c-8-3-17-5-25-6l-17-3c-10-1-20-1-29-1-10 0-20 0-29 1-6 8-11 16-16 24-5 9-9 17-13 26 4 9 8 18 13 26s10 16 16 24l11 14c5 7 11 13 18 19l10 8s-1 0 0 0l-11 9c-17 14-35 22-49 22-6 0-13-2-18-5-16-9-23-30-20-59 1-3 1-5 1-8-30-12-48-29-48-50 0-18 14-35 41-47 2-1 5-2 7-3 0-2 0-5-1-7-3-30 4-51 20-60 18-10 42-3 68 17M71 201c-1 2-1 4-1 5-2 24 3 41 13 47h1c11 7 30 1 51-15-10-9-18-18-26-29-13-1-26-4-38-8m9-38c-3 9-5 17-7 26 8 2 17 4 25 6-3-5-6-10-9-16-3-5-6-10-9-16m-19-53c-2 1-3 1-5 2-21 10-34 23-34 35 0 13 14 27 39 37 3-12 7-25 12-37-5-12-9-24-12-37m37-10c-8 1-17 3-25 6 2 8 4 16 7 25 3-5 6-11 9-16zm-3-61c-4-1-8 0-12 2-10 7-15 24-13 47 0 2 0 3 1 5 12-4 25-6 38-8 8-10 16-20 26-29-15-11-29-17-40-17m111 2c-4-2-8-3-12-2-11 0-25 5-40 17 10 9 19 19 26 29 13 2 26 4 39 8v-5c3-23-2-40-13-47m-61 23c-7 6-13 13-19 19h37c-6-6-12-13-18-19"/><mask id="a"><path fill="#fff" d="m235 85-133 27 28 133 133-27Z"/></mask><path fill="#ff40e0" d="m137 130 76 11c8 1 9 11 3 15l-28 16-4 32c-1 8-10 10-14 4l-41-66c-3-6 1-13 8-12" mask="url(#a)"/></svg>`;
|
|
1399
|
+
|
|
1400
|
+
//#endregion
|
|
1401
|
+
//#region src/utils/is-extension-context.ts
|
|
1402
|
+
const isExtensionContext = () => {
|
|
1403
|
+
const global = globalThis;
|
|
1404
|
+
return Boolean(global.chrome?.runtime?.id || global.browser?.runtime?.id);
|
|
1405
|
+
};
|
|
1406
|
+
|
|
1407
|
+
//#endregion
|
|
1408
|
+
//#region src/core/log-intro.ts
|
|
1409
|
+
const logIntro = () => {
|
|
1410
|
+
try {
|
|
1411
|
+
const version = "[DEV]";
|
|
1412
|
+
const logoDataUri = `data:image/svg+xml;base64,${btoa(LOGO_SVG)}`;
|
|
1413
|
+
console.log(`%cReact Grab${` v${version}`}%c\nhttps://react-grab.com`, `background: #330039; color: #ffffff; border: 1px solid #d75fcb; padding: 4px 4px 4px 24px; border-radius: 4px; background-image: url("${logoDataUri}"); background-size: 16px 16px; background-repeat: no-repeat; background-position: 4px center; display: inline-block; margin-bottom: 4px;`, "");
|
|
1414
|
+
if (navigator.onLine && !isExtensionContext()) fetch(`https://www.react-grab.com/api/version?source=browser&v=${version}&t=${Date.now()}`, {
|
|
1415
|
+
referrerPolicy: "origin",
|
|
1416
|
+
keepalive: true,
|
|
1417
|
+
priority: "low",
|
|
1418
|
+
cache: "no-store"
|
|
1419
|
+
}).then((response) => response.text()).then((latestVersion) => {
|
|
1420
|
+
if (latestVersion && latestVersion !== version) console.warn(`[React Grab] v${version} is outdated (latest: v${latestVersion})`);
|
|
1421
|
+
}).catch(() => null);
|
|
1422
|
+
} catch {}
|
|
1423
|
+
};
|
|
1424
|
+
|
|
1425
|
+
//#endregion
|
|
1426
|
+
//#region src/utils/on-idle.ts
|
|
1427
|
+
const isBackgroundTaskScheduler = (value) => {
|
|
1428
|
+
if (typeof value !== "object" || value === null) return false;
|
|
1429
|
+
if (!("postTask" in value)) return false;
|
|
1430
|
+
return typeof value.postTask === "function";
|
|
1431
|
+
};
|
|
1432
|
+
const onIdle = (callback) => {
|
|
1433
|
+
if (typeof window !== "undefined") {
|
|
1434
|
+
const schedulerCandidate = window.scheduler;
|
|
1435
|
+
if (isBackgroundTaskScheduler(schedulerCandidate)) {
|
|
1436
|
+
schedulerCandidate.postTask(callback, { priority: "background" });
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
if ("requestIdleCallback" in window) {
|
|
1440
|
+
requestIdleCallback(callback);
|
|
1441
|
+
return;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
setTimeout(callback, 0);
|
|
1445
|
+
};
|
|
1446
|
+
|
|
1447
|
+
//#endregion
|
|
1448
|
+
//#region src/utils/get-script-options.ts
|
|
1449
|
+
const isObjectRecord = (value) => {
|
|
1450
|
+
return typeof value === "object" && value !== null;
|
|
1451
|
+
};
|
|
1452
|
+
const parseOptionsFromJson = (rawValue) => {
|
|
1453
|
+
if (!isObjectRecord(rawValue)) return null;
|
|
1454
|
+
const parsedOptions = {};
|
|
1455
|
+
if (typeof rawValue.enabled === "boolean") parsedOptions.enabled = rawValue.enabled;
|
|
1456
|
+
if (rawValue.activationMode === "toggle" || rawValue.activationMode === "hold") parsedOptions.activationMode = rawValue.activationMode;
|
|
1457
|
+
if (typeof rawValue.keyHoldDuration === "number" && Number.isFinite(rawValue.keyHoldDuration)) parsedOptions.keyHoldDuration = rawValue.keyHoldDuration;
|
|
1458
|
+
if (typeof rawValue.allowActivationInsideInput === "boolean") parsedOptions.allowActivationInsideInput = rawValue.allowActivationInsideInput;
|
|
1459
|
+
if (typeof rawValue.maxContextLines === "number" && Number.isFinite(rawValue.maxContextLines)) parsedOptions.maxContextLines = rawValue.maxContextLines;
|
|
1460
|
+
if (typeof rawValue.activationKey === "string") parsedOptions.activationKey = rawValue.activationKey;
|
|
1461
|
+
if (typeof rawValue.freezeReactUpdates === "boolean") parsedOptions.freezeReactUpdates = rawValue.freezeReactUpdates;
|
|
1462
|
+
if (Object.keys(parsedOptions).length === 0) return null;
|
|
1463
|
+
return parsedOptions;
|
|
1464
|
+
};
|
|
1465
|
+
const getScriptOptions = () => {
|
|
1466
|
+
if (typeof window === "undefined") return null;
|
|
1467
|
+
try {
|
|
1468
|
+
const dataOptions = (document.currentScript instanceof HTMLScriptElement ? document.currentScript : null)?.getAttribute("data-options");
|
|
1469
|
+
if (!dataOptions) return null;
|
|
1470
|
+
return parseOptionsFromJson(JSON.parse(dataOptions));
|
|
1471
|
+
} catch {
|
|
1472
|
+
return null;
|
|
1473
|
+
}
|
|
1474
|
+
};
|
|
1475
|
+
|
|
1476
|
+
//#endregion
|
|
1477
|
+
//#region src/utils/is-enter-code.ts
|
|
1478
|
+
const isEnterCode = (code) => code === "Enter" || code === "NumpadEnter";
|
|
1479
|
+
|
|
1480
|
+
//#endregion
|
|
1481
|
+
//#region src/core/plugins/create-pending-selection-plugin.ts
|
|
1482
|
+
const createPendingSelectionPlugin = (config) => ({
|
|
1483
|
+
name: config.name,
|
|
1484
|
+
setup: (api, hooks) => {
|
|
1485
|
+
return {
|
|
1486
|
+
actions: [typeof config.contextMenuAction === "function" ? config.contextMenuAction(api, hooks) : config.contextMenuAction],
|
|
1487
|
+
cleanup: config.cleanup
|
|
1488
|
+
};
|
|
1489
|
+
}
|
|
1490
|
+
});
|
|
1491
|
+
|
|
1492
|
+
//#endregion
|
|
1493
|
+
//#region src/core/plugins/copy.ts
|
|
1494
|
+
const copyPlugin = createPendingSelectionPlugin({
|
|
1495
|
+
name: "copy",
|
|
1496
|
+
contextMenuAction: {
|
|
1497
|
+
id: "copy",
|
|
1498
|
+
label: "Copy",
|
|
1499
|
+
shortcut: "C",
|
|
1500
|
+
showInToolbarMenu: true,
|
|
1501
|
+
onAction: (context) => {
|
|
1502
|
+
context.copy?.();
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
});
|
|
1506
|
+
|
|
1507
|
+
//#endregion
|
|
1508
|
+
//#region src/core/plugins/comment.ts
|
|
1509
|
+
const commentPlugin = {
|
|
1510
|
+
name: "comment",
|
|
1511
|
+
setup: () => ({ actions: [{
|
|
1512
|
+
id: "comment",
|
|
1513
|
+
label: "Comment",
|
|
1514
|
+
shortcut: "Enter",
|
|
1515
|
+
showInToolbarMenu: true,
|
|
1516
|
+
onAction: (context) => {
|
|
1517
|
+
context.enterPromptMode?.();
|
|
1518
|
+
}
|
|
1519
|
+
}] })
|
|
1520
|
+
};
|
|
1521
|
+
|
|
1522
|
+
//#endregion
|
|
1523
|
+
//#region src/core/plugins/open.ts
|
|
1524
|
+
const openPlugin = {
|
|
1525
|
+
name: "open",
|
|
1526
|
+
actions: [{
|
|
1527
|
+
id: "open",
|
|
1528
|
+
label: "Open",
|
|
1529
|
+
shortcut: "O",
|
|
1530
|
+
enabled: (context) => Boolean(context.filePath),
|
|
1531
|
+
onAction: (context) => {
|
|
1532
|
+
if (!context.filePath) return;
|
|
1533
|
+
if (!context.hooks.onOpenFile(context.filePath, context.lineNumber)) openFile(context.filePath, context.lineNumber, context.hooks.transformOpenFileUrl);
|
|
1534
|
+
context.hideContextMenu();
|
|
1535
|
+
context.cleanup();
|
|
1536
|
+
}
|
|
1537
|
+
}]
|
|
1538
|
+
};
|
|
1539
|
+
|
|
1540
|
+
//#endregion
|
|
1541
|
+
//#region src/utils/append-stack-context.ts
|
|
1542
|
+
const appendStackContext = (content, stackContext) => {
|
|
1543
|
+
if (!stackContext) return content;
|
|
1544
|
+
return `${content}\n${stackContext}`;
|
|
1545
|
+
};
|
|
1546
|
+
|
|
1547
|
+
//#endregion
|
|
1548
|
+
//#region src/core/plugins/copy-html.ts
|
|
1549
|
+
const copyHtmlPlugin = createPendingSelectionPlugin({
|
|
1550
|
+
name: "copy-html",
|
|
1551
|
+
contextMenuAction: (api) => ({
|
|
1552
|
+
id: "copy-html",
|
|
1553
|
+
label: "Copy HTML",
|
|
1554
|
+
showInToolbarMenu: true,
|
|
1555
|
+
onAction: async (context) => {
|
|
1556
|
+
await context.performWithFeedback(async () => {
|
|
1557
|
+
const combinedHtml = context.elements.map((element) => element.outerHTML).join("\n\n");
|
|
1558
|
+
const transformedHtml = await context.hooks.transformHtmlContent(combinedHtml, context.elements);
|
|
1559
|
+
if (!transformedHtml) return false;
|
|
1560
|
+
return copyContent(appendStackContext(transformedHtml, await api.getStackContext(context.element)), {
|
|
1561
|
+
componentName: context.componentName,
|
|
1562
|
+
tagName: context.tagName
|
|
1563
|
+
});
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
1566
|
+
})
|
|
1567
|
+
});
|
|
1568
|
+
|
|
1569
|
+
//#endregion
|
|
1570
|
+
//#region src/core/plugins/copy-styles.ts
|
|
1571
|
+
const copyStylesPlugin = createPendingSelectionPlugin({
|
|
1572
|
+
name: "copy-styles",
|
|
1573
|
+
contextMenuAction: (api) => ({
|
|
1574
|
+
id: "copy-styles",
|
|
1575
|
+
label: "Copy styles",
|
|
1576
|
+
showInToolbarMenu: true,
|
|
1577
|
+
onAction: async (context) => {
|
|
1578
|
+
await context.performWithFeedback(async () => {
|
|
1579
|
+
return copyContent(appendStackContext(context.elements.map(extractElementCss).join("\n\n"), await api.getStackContext(context.element)), {
|
|
1580
|
+
componentName: context.componentName,
|
|
1581
|
+
tagName: context.tagName
|
|
1582
|
+
});
|
|
1583
|
+
});
|
|
1584
|
+
}
|
|
1585
|
+
}),
|
|
1586
|
+
cleanup: disposeBaselineStyles
|
|
1587
|
+
});
|
|
1588
|
+
|
|
1589
|
+
//#endregion
|
|
1590
|
+
//#region src/utils/generate-id.ts
|
|
1591
|
+
const generateId = (prefix) => `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
1592
|
+
|
|
1593
|
+
//#endregion
|
|
1594
|
+
//#region src/utils/comment-storage.ts
|
|
1595
|
+
const COMMENT_ITEMS_KEY = "react-grab-comment-items";
|
|
1596
|
+
const LEGACY_COMMENT_ITEMS_KEY = "react-grab-history-items";
|
|
1597
|
+
const CLEAR_CONFIRMED_KEY = "react-grab-clear-confirmed";
|
|
1598
|
+
const migrateFromLegacyStorage = () => {
|
|
1599
|
+
try {
|
|
1600
|
+
const legacyData = sessionStorage.getItem(LEGACY_COMMENT_ITEMS_KEY);
|
|
1601
|
+
if (legacyData && !sessionStorage.getItem(COMMENT_ITEMS_KEY)) sessionStorage.setItem(COMMENT_ITEMS_KEY, legacyData);
|
|
1602
|
+
sessionStorage.removeItem(LEGACY_COMMENT_ITEMS_KEY);
|
|
1603
|
+
} catch {}
|
|
1604
|
+
};
|
|
1605
|
+
const loadFromSessionStorage = () => {
|
|
1606
|
+
try {
|
|
1607
|
+
const serialized = sessionStorage.getItem(COMMENT_ITEMS_KEY);
|
|
1608
|
+
if (!serialized) return [];
|
|
1609
|
+
return JSON.parse(serialized).map((commentItem) => ({
|
|
1610
|
+
...commentItem,
|
|
1611
|
+
elementsCount: Math.max(1, commentItem.elementsCount ?? 1),
|
|
1612
|
+
previewBounds: commentItem.previewBounds ?? [],
|
|
1613
|
+
elementSelectors: commentItem.elementSelectors ?? []
|
|
1614
|
+
}));
|
|
1615
|
+
} catch (error) {
|
|
1616
|
+
logRecoverableError("Failed to load comments from sessionStorage", error);
|
|
1617
|
+
return [];
|
|
1618
|
+
}
|
|
1619
|
+
};
|
|
1620
|
+
const readSessionFlag = (key) => {
|
|
1621
|
+
try {
|
|
1622
|
+
return sessionStorage.getItem(key) === "1";
|
|
1623
|
+
} catch {
|
|
1624
|
+
return false;
|
|
1625
|
+
}
|
|
1626
|
+
};
|
|
1627
|
+
const trimToSizeLimit = (items) => {
|
|
1628
|
+
let trimmedItems = items;
|
|
1629
|
+
while (trimmedItems.length > 0) {
|
|
1630
|
+
const serialized = JSON.stringify(trimmedItems);
|
|
1631
|
+
if (new Blob([serialized]).size <= 2097152) return trimmedItems;
|
|
1632
|
+
trimmedItems = trimmedItems.slice(0, -1);
|
|
1633
|
+
}
|
|
1634
|
+
return trimmedItems;
|
|
1635
|
+
};
|
|
1636
|
+
const persistCommentItems = (nextItems) => {
|
|
1637
|
+
commentItems = trimToSizeLimit(nextItems);
|
|
1638
|
+
try {
|
|
1639
|
+
sessionStorage.setItem(COMMENT_ITEMS_KEY, JSON.stringify(commentItems));
|
|
1640
|
+
} catch (error) {
|
|
1641
|
+
logRecoverableError("Failed to save comments to sessionStorage", error);
|
|
1642
|
+
}
|
|
1643
|
+
return commentItems;
|
|
1644
|
+
};
|
|
1645
|
+
migrateFromLegacyStorage();
|
|
1646
|
+
let commentItems = loadFromSessionStorage();
|
|
1647
|
+
let didConfirmClear = readSessionFlag(CLEAR_CONFIRMED_KEY);
|
|
1648
|
+
const loadComments = () => commentItems;
|
|
1649
|
+
const addCommentItem = (item) => persistCommentItems([{
|
|
1650
|
+
...item,
|
|
1651
|
+
id: generateId("comment")
|
|
1652
|
+
}, ...commentItems].slice(0, 20));
|
|
1653
|
+
const removeCommentItem = (itemId) => {
|
|
1654
|
+
persistCommentItems(commentItems.filter((innerItem) => innerItem.id !== itemId));
|
|
1655
|
+
};
|
|
1656
|
+
const clearComments = () => persistCommentItems([]);
|
|
1657
|
+
const isClearConfirmed = () => didConfirmClear;
|
|
1658
|
+
const confirmClear = () => {
|
|
1659
|
+
didConfirmClear = true;
|
|
1660
|
+
try {
|
|
1661
|
+
sessionStorage.setItem(CLEAR_CONFIRMED_KEY, "1");
|
|
1662
|
+
} catch (error) {
|
|
1663
|
+
logRecoverableError("Failed to save clear preference to sessionStorage", error);
|
|
1664
|
+
}
|
|
1665
|
+
};
|
|
1666
|
+
|
|
1667
|
+
//#endregion
|
|
1668
|
+
//#region src/utils/lock-viewport-zoom.ts
|
|
1669
|
+
const lockViewportZoom = () => {
|
|
1670
|
+
let meta = document.querySelector("meta[name=\"viewport\"]");
|
|
1671
|
+
const originalContent = meta?.getAttribute("content") ?? null;
|
|
1672
|
+
if (!meta) {
|
|
1673
|
+
meta = document.createElement("meta");
|
|
1674
|
+
meta.name = "viewport";
|
|
1675
|
+
document.head.appendChild(meta);
|
|
1676
|
+
}
|
|
1677
|
+
const content = originalContent ?? "";
|
|
1678
|
+
meta.content = /maximum-scale/.test(content) ? content.replace(/maximum-scale\s*=\s*[\d.]+/, "maximum-scale=1") : `${content}${content ? ", " : ""}maximum-scale=1`;
|
|
1679
|
+
return () => {
|
|
1680
|
+
if (originalContent !== null) meta.content = originalContent;
|
|
1681
|
+
else meta.remove();
|
|
1682
|
+
};
|
|
1683
|
+
};
|
|
1684
|
+
|
|
1685
|
+
//#endregion
|
|
1686
|
+
//#region src/utils/get-nearest-edge.ts
|
|
1687
|
+
const getNearestEdge = (rect) => {
|
|
1688
|
+
const centerX = rect.left + rect.width / 2;
|
|
1689
|
+
const centerY = rect.top + rect.height / 2;
|
|
1690
|
+
const distanceToTop = centerY;
|
|
1691
|
+
const distanceToBottom = window.innerHeight - centerY;
|
|
1692
|
+
const distanceToLeft = centerX;
|
|
1693
|
+
const distanceToRight = window.innerWidth - centerX;
|
|
1694
|
+
const minimumDistance = Math.min(distanceToTop, distanceToBottom, distanceToLeft, distanceToRight);
|
|
1695
|
+
if (minimumDistance === distanceToTop) return "top";
|
|
1696
|
+
if (minimumDistance === distanceToLeft) return "left";
|
|
1697
|
+
if (minimumDistance === distanceToRight) return "right";
|
|
1698
|
+
return "bottom";
|
|
1699
|
+
};
|
|
1700
|
+
|
|
1701
|
+
//#endregion
|
|
1702
|
+
//#region src/core/index.tsx
|
|
1703
|
+
const builtInPlugins = [
|
|
1704
|
+
copyPlugin,
|
|
1705
|
+
commentPlugin,
|
|
1706
|
+
copyHtmlPlugin,
|
|
1707
|
+
copyStylesPlugin,
|
|
1708
|
+
openPlugin
|
|
1709
|
+
];
|
|
1710
|
+
let hasInited = false;
|
|
1711
|
+
const toolbarStateChangeCallbacks = /* @__PURE__ */ new Set();
|
|
1712
|
+
const init = (rawOptions) => {
|
|
1713
|
+
if (typeof window === "undefined") return createNoopApi();
|
|
1714
|
+
const initialOptions = {
|
|
1715
|
+
enabled: true,
|
|
1716
|
+
activationMode: "toggle",
|
|
1717
|
+
keyHoldDuration: 100,
|
|
1718
|
+
allowActivationInsideInput: true,
|
|
1719
|
+
maxContextLines: 3,
|
|
1720
|
+
...getScriptOptions(),
|
|
1721
|
+
...rawOptions
|
|
1722
|
+
};
|
|
1723
|
+
if (initialOptions.enabled === false || hasInited) return createNoopApi();
|
|
1724
|
+
hasInited = true;
|
|
1725
|
+
logIntro();
|
|
1726
|
+
const { enabled: _enabled, ...settableOptions } = initialOptions;
|
|
1727
|
+
return createRoot((dispose) => {
|
|
1728
|
+
let disposed = false;
|
|
1729
|
+
let disposeRenderer;
|
|
1730
|
+
const pluginRegistry = createPluginRegistry(settableOptions);
|
|
1731
|
+
const { store, actions } = createGrabStore({
|
|
1732
|
+
theme: DEFAULT_THEME,
|
|
1733
|
+
keyHoldDuration: pluginRegistry.store.options.keyHoldDuration ?? 100
|
|
1734
|
+
});
|
|
1735
|
+
const isHoldingKeys = createMemo(() => store.current.state === "holding");
|
|
1736
|
+
const isActivated = createMemo(() => store.current.state === "active");
|
|
1737
|
+
const isFrozenPhase = createMemo(() => store.current.state === "active" && store.current.phase === "frozen");
|
|
1738
|
+
const isDragging = createMemo(() => store.current.state === "active" && store.current.phase === "dragging");
|
|
1739
|
+
const didJustDrag = createMemo(() => store.current.state === "active" && store.current.phase === "justDragged");
|
|
1740
|
+
const isCopying = createMemo(() => store.current.state === "copying");
|
|
1741
|
+
const didJustCopy = createMemo(() => store.current.state === "justCopied");
|
|
1742
|
+
const isPromptMode = createMemo(() => store.current.state === "active" && Boolean(store.current.isPromptMode));
|
|
1743
|
+
const isCommentMode = createMemo(() => store.pendingCommentMode || isPromptMode());
|
|
1744
|
+
const isPendingDismiss = createMemo(() => store.current.state === "active" && Boolean(store.current.isPromptMode) && Boolean(store.current.isPendingDismiss));
|
|
1745
|
+
let unlockViewportZoom = null;
|
|
1746
|
+
createEffect(on(isActivated, (activated, previousActivated) => {
|
|
1747
|
+
if (activated && !previousActivated) {
|
|
1748
|
+
freezePseudoStates();
|
|
1749
|
+
freezeGlobalAnimations();
|
|
1750
|
+
document.body.style.touchAction = "none";
|
|
1751
|
+
unlockViewportZoom = lockViewportZoom();
|
|
1752
|
+
} else if (!activated && previousActivated) {
|
|
1753
|
+
unfreezePseudoStates();
|
|
1754
|
+
unfreezeGlobalAnimations();
|
|
1755
|
+
document.body.style.touchAction = "";
|
|
1756
|
+
unlockViewportZoom?.();
|
|
1757
|
+
unlockViewportZoom = null;
|
|
1758
|
+
}
|
|
1759
|
+
}));
|
|
1760
|
+
const savedToolbarState = loadToolbarState();
|
|
1761
|
+
const [isEnabled, setIsEnabled] = createSignal(savedToolbarState?.enabled ?? true);
|
|
1762
|
+
const [toolbarShakeCount, setToolbarShakeCount] = createSignal(0);
|
|
1763
|
+
const [selectionLabelShakeCount, setSelectionLabelShakeCount] = createSignal(0);
|
|
1764
|
+
const [currentToolbarState, setCurrentToolbarState] = createSignal(savedToolbarState);
|
|
1765
|
+
const [isToolbarSelectHovered, setIsToolbarSelectHovered] = createSignal(false);
|
|
1766
|
+
const [commentItems, setCommentItems] = createSignal(loadComments());
|
|
1767
|
+
const [commentsDropdownPosition, setCommentsDropdownPosition] = createSignal(null);
|
|
1768
|
+
const [toolbarMenuPosition, setToolbarMenuPosition] = createSignal(null);
|
|
1769
|
+
const [clearPromptPosition, setClearPromptPosition] = createSignal(null);
|
|
1770
|
+
let toolbarElement;
|
|
1771
|
+
let dropdownTrackingFrameId = null;
|
|
1772
|
+
const commentElementMap = /* @__PURE__ */ new Map();
|
|
1773
|
+
const [clockFlashTrigger, setClockFlashTrigger] = createSignal(0);
|
|
1774
|
+
const [isCommentsHoverOpen, setIsCommentsHoverOpen] = createSignal(false);
|
|
1775
|
+
let commentsHoverPreviews = [];
|
|
1776
|
+
const updateToolbarState = (updates) => {
|
|
1777
|
+
const currentState = currentToolbarState() ?? loadToolbarState();
|
|
1778
|
+
const newState = {
|
|
1779
|
+
edge: currentState?.edge ?? "bottom",
|
|
1780
|
+
ratio: currentState?.ratio ?? .5,
|
|
1781
|
+
collapsed: currentState?.collapsed ?? false,
|
|
1782
|
+
enabled: currentState?.enabled ?? true,
|
|
1783
|
+
defaultAction: currentState?.defaultAction ?? "comment",
|
|
1784
|
+
...updates
|
|
1785
|
+
};
|
|
1786
|
+
saveToolbarState(newState);
|
|
1787
|
+
setCurrentToolbarState(newState);
|
|
1788
|
+
for (const callback of toolbarStateChangeCallbacks) callback(newState);
|
|
1789
|
+
};
|
|
1790
|
+
const getMappedCommentElements = (commentItemId) => commentElementMap.get(commentItemId) ?? [];
|
|
1791
|
+
const reacquireCommentElements = (commentItem) => {
|
|
1792
|
+
const selectors = commentItem.elementSelectors ?? [];
|
|
1793
|
+
if (selectors.length === 0) return [];
|
|
1794
|
+
const reacquiredElements = [];
|
|
1795
|
+
for (const selector of selectors) {
|
|
1796
|
+
if (!selector) continue;
|
|
1797
|
+
try {
|
|
1798
|
+
const reacquiredElement = document.querySelector(selector);
|
|
1799
|
+
if (isElementConnected(reacquiredElement)) reacquiredElements.push(reacquiredElement);
|
|
1800
|
+
} catch (error) {
|
|
1801
|
+
logRecoverableError("Invalid stored selector", error);
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
return reacquiredElements;
|
|
1805
|
+
};
|
|
1806
|
+
const getConnectedCommentElements = (commentItem) => {
|
|
1807
|
+
const mappedElements = getMappedCommentElements(commentItem.id);
|
|
1808
|
+
const connectedMappedElements = mappedElements.filter((mappedElement) => isElementConnected(mappedElement));
|
|
1809
|
+
if (mappedElements.length > 0 && connectedMappedElements.length === mappedElements.length) return connectedMappedElements;
|
|
1810
|
+
const reacquiredElements = reacquireCommentElements(commentItem);
|
|
1811
|
+
if (reacquiredElements.length > 0) {
|
|
1812
|
+
commentElementMap.set(commentItem.id, reacquiredElements);
|
|
1813
|
+
return reacquiredElements;
|
|
1814
|
+
}
|
|
1815
|
+
return connectedMappedElements;
|
|
1816
|
+
};
|
|
1817
|
+
const getFirstConnectedCommentElement = (commentItem) => getConnectedCommentElements(commentItem)[0];
|
|
1818
|
+
const commentsDisconnectedItemIds = createMemo(() => {
|
|
1819
|
+
commentsDropdownPosition();
|
|
1820
|
+
const disconnectedIds = /* @__PURE__ */ new Set();
|
|
1821
|
+
for (const item of commentItems()) if (getConnectedCommentElements(item).length === 0) disconnectedIds.add(item.id);
|
|
1822
|
+
return disconnectedIds;
|
|
1823
|
+
}, void 0, { equals: (prev, next) => {
|
|
1824
|
+
if (prev.size !== next.size) return false;
|
|
1825
|
+
for (const id of next) if (!prev.has(id)) return false;
|
|
1826
|
+
return true;
|
|
1827
|
+
} });
|
|
1828
|
+
const clearHoldTimer = () => {
|
|
1829
|
+
if (activationHoldState.timerId !== null) {
|
|
1830
|
+
clearTimeout(activationHoldState.timerId);
|
|
1831
|
+
activationHoldState.timerId = null;
|
|
1832
|
+
}
|
|
1833
|
+
};
|
|
1834
|
+
const resetCopyConfirmation = () => {
|
|
1835
|
+
activationHoldState.copyWaiting = false;
|
|
1836
|
+
activationHoldState.holdTimerFired = false;
|
|
1837
|
+
activationHoldState.startTimestamp = null;
|
|
1838
|
+
};
|
|
1839
|
+
createEffect(() => {
|
|
1840
|
+
if (store.current.state !== "holding") {
|
|
1841
|
+
clearHoldTimer();
|
|
1842
|
+
return;
|
|
1843
|
+
}
|
|
1844
|
+
activationHoldState.startTimestamp = Date.now();
|
|
1845
|
+
activationHoldState.timerId = window.setTimeout(() => {
|
|
1846
|
+
activationHoldState.timerId = null;
|
|
1847
|
+
if (activationHoldState.copyWaiting) {
|
|
1848
|
+
activationHoldState.holdTimerFired = true;
|
|
1849
|
+
return;
|
|
1850
|
+
}
|
|
1851
|
+
actions.activate();
|
|
1852
|
+
}, store.keyHoldDuration);
|
|
1853
|
+
onCleanup(clearHoldTimer);
|
|
1854
|
+
});
|
|
1855
|
+
createEffect(() => {
|
|
1856
|
+
if (store.current.state !== "active" || store.current.phase !== "justDragged") return;
|
|
1857
|
+
const timerId = setTimeout(() => {
|
|
1858
|
+
actions.finishJustDragged();
|
|
1859
|
+
}, FEEDBACK_DURATION_MS);
|
|
1860
|
+
onCleanup(() => clearTimeout(timerId));
|
|
1861
|
+
});
|
|
1862
|
+
createEffect(() => {
|
|
1863
|
+
if (store.current.state !== "justCopied") return;
|
|
1864
|
+
const timerId = setTimeout(() => {
|
|
1865
|
+
actions.finishJustCopied();
|
|
1866
|
+
}, FEEDBACK_DURATION_MS);
|
|
1867
|
+
onCleanup(() => clearTimeout(timerId));
|
|
1868
|
+
});
|
|
1869
|
+
createEffect(on(isHoldingKeys, (currentlyHolding, previouslyHolding = false) => {
|
|
1870
|
+
if (!previouslyHolding || currentlyHolding || !isActivated()) return;
|
|
1871
|
+
if (pluginRegistry.store.options.activationMode !== "hold") actions.setWasActivatedByToggle(true);
|
|
1872
|
+
pluginRegistry.hooks.onActivate();
|
|
1873
|
+
}));
|
|
1874
|
+
const preparePromptMode = (element, positionX, positionY) => {
|
|
1875
|
+
setCopyStartPosition(element, positionX, positionY);
|
|
1876
|
+
actions.clearInputText();
|
|
1877
|
+
};
|
|
1878
|
+
const activatePromptMode = () => {
|
|
1879
|
+
const element = store.frozenElement || targetElement();
|
|
1880
|
+
if (element) actions.enterPromptMode({
|
|
1881
|
+
x: store.pointer.x,
|
|
1882
|
+
y: store.pointer.y
|
|
1883
|
+
}, element);
|
|
1884
|
+
};
|
|
1885
|
+
const setCopyStartPosition = (element, positionX, positionY) => {
|
|
1886
|
+
actions.setCopyStart({
|
|
1887
|
+
x: positionX,
|
|
1888
|
+
y: positionY
|
|
1889
|
+
}, element);
|
|
1890
|
+
};
|
|
1891
|
+
const elementDetectionState = {
|
|
1892
|
+
lastDetectionTimestamp: 0,
|
|
1893
|
+
pendingDetectionScheduledAt: 0,
|
|
1894
|
+
latestPointerX: 0,
|
|
1895
|
+
latestPointerY: 0
|
|
1896
|
+
};
|
|
1897
|
+
let dragPreviewDebounceTimerId = null;
|
|
1898
|
+
const [debouncedDragPointer, setDebouncedDragPointer] = createSignal(null);
|
|
1899
|
+
const scheduleDragPreviewUpdate = (clientX, clientY) => {
|
|
1900
|
+
if (dragPreviewDebounceTimerId !== null) clearTimeout(dragPreviewDebounceTimerId);
|
|
1901
|
+
setDebouncedDragPointer(null);
|
|
1902
|
+
dragPreviewDebounceTimerId = window.setTimeout(() => {
|
|
1903
|
+
setDebouncedDragPointer({
|
|
1904
|
+
x: clientX,
|
|
1905
|
+
y: clientY
|
|
1906
|
+
});
|
|
1907
|
+
dragPreviewDebounceTimerId = null;
|
|
1908
|
+
}, 32);
|
|
1909
|
+
};
|
|
1910
|
+
let keydownSpamTimerId = null;
|
|
1911
|
+
const activationHoldState = {
|
|
1912
|
+
timerId: null,
|
|
1913
|
+
startTimestamp: null,
|
|
1914
|
+
copyWaiting: false,
|
|
1915
|
+
holdTimerFired: false
|
|
1916
|
+
};
|
|
1917
|
+
const [isInspectMode, setIsInspectMode] = createSignal(false);
|
|
1918
|
+
let lastWindowFocusTimestamp = 0;
|
|
1919
|
+
let isCopyFeedbackCooldownActive = false;
|
|
1920
|
+
let copyFeedbackCooldownTimerId = null;
|
|
1921
|
+
const startCopyFeedbackCooldown = () => {
|
|
1922
|
+
isCopyFeedbackCooldownActive = true;
|
|
1923
|
+
if (copyFeedbackCooldownTimerId !== null) window.clearTimeout(copyFeedbackCooldownTimerId);
|
|
1924
|
+
copyFeedbackCooldownTimerId = window.setTimeout(() => {
|
|
1925
|
+
isCopyFeedbackCooldownActive = false;
|
|
1926
|
+
copyFeedbackCooldownTimerId = null;
|
|
1927
|
+
}, FEEDBACK_DURATION_MS);
|
|
1928
|
+
};
|
|
1929
|
+
const clearCopyFeedbackCooldown = () => {
|
|
1930
|
+
if (copyFeedbackCooldownTimerId !== null) {
|
|
1931
|
+
window.clearTimeout(copyFeedbackCooldownTimerId);
|
|
1932
|
+
copyFeedbackCooldownTimerId = null;
|
|
1933
|
+
}
|
|
1934
|
+
isCopyFeedbackCooldownActive = false;
|
|
1935
|
+
};
|
|
1936
|
+
let actionCycleIdleTimeoutId = null;
|
|
1937
|
+
let selectionSourceRequestVersion = 0;
|
|
1938
|
+
let componentNameRequestVersion = 0;
|
|
1939
|
+
let componentNameDebounceTimerId = null;
|
|
1940
|
+
let keyboardSelectedElement = null;
|
|
1941
|
+
let isPendingContextMenuSelect = false;
|
|
1942
|
+
let pendingDefaultActionId = null;
|
|
1943
|
+
const [debouncedElementForComponentName, setDebouncedElementForComponentName] = createSignal(null);
|
|
1944
|
+
const [resolvedComponentName, setResolvedComponentName] = createSignal(void 0);
|
|
1945
|
+
const [actionCycleItems, setActionCycleItems] = createSignal([]);
|
|
1946
|
+
const [actionCycleActiveIndex, setActionCycleActiveIndex] = createSignal(null);
|
|
1947
|
+
const [arrowNavigationElements, setArrowNavigationElements] = createSignal([]);
|
|
1948
|
+
const [arrowNavigationActiveIndex, setArrowNavigationActiveIndex] = createSignal(0);
|
|
1949
|
+
const arrowNavigator = createArrowNavigator(isValidGrabbableElement, createElementBounds);
|
|
1950
|
+
const autoScroller = createAutoScroller(() => store.pointer, () => isDragging());
|
|
1951
|
+
const isRendererActive = createMemo(() => isActivated() && !isCopying());
|
|
1952
|
+
const grabbedBoxTimeouts = /* @__PURE__ */ new Map();
|
|
1953
|
+
const showTemporaryGrabbedBox = (bounds, element) => {
|
|
1954
|
+
const boxId = generateId("grabbed");
|
|
1955
|
+
const newBox = {
|
|
1956
|
+
id: boxId,
|
|
1957
|
+
bounds,
|
|
1958
|
+
createdAt: Date.now(),
|
|
1959
|
+
element
|
|
1960
|
+
};
|
|
1961
|
+
actions.addGrabbedBox(newBox);
|
|
1962
|
+
pluginRegistry.hooks.onGrabbedBox(bounds, element);
|
|
1963
|
+
const timeoutId = window.setTimeout(() => {
|
|
1964
|
+
grabbedBoxTimeouts.delete(boxId);
|
|
1965
|
+
actions.removeGrabbedBox(boxId);
|
|
1966
|
+
}, FEEDBACK_DURATION_MS);
|
|
1967
|
+
grabbedBoxTimeouts.set(boxId, timeoutId);
|
|
1968
|
+
};
|
|
1969
|
+
const notifyElementsSelected = async (elements) => {
|
|
1970
|
+
const elementsPayload = await Promise.all(elements.map(async (element) => {
|
|
1971
|
+
const source = await resolveSource(element);
|
|
1972
|
+
let componentName = source?.componentName ?? null;
|
|
1973
|
+
const filePath = source?.filePath;
|
|
1974
|
+
const lineNumber = source?.lineNumber ?? void 0;
|
|
1975
|
+
const columnNumber = source?.columnNumber ?? void 0;
|
|
1976
|
+
if (!componentName) componentName = getComponentDisplayName(element);
|
|
1977
|
+
const textContent = element instanceof HTMLElement ? element.innerText?.slice(0, 100) : void 0;
|
|
1978
|
+
return {
|
|
1979
|
+
tagName: getTagName(element),
|
|
1980
|
+
id: element.id || void 0,
|
|
1981
|
+
className: element.getAttribute("class") || void 0,
|
|
1982
|
+
textContent,
|
|
1983
|
+
componentName: componentName ?? void 0,
|
|
1984
|
+
filePath,
|
|
1985
|
+
lineNumber,
|
|
1986
|
+
columnNumber
|
|
1987
|
+
};
|
|
1988
|
+
}));
|
|
1989
|
+
window.dispatchEvent(new CustomEvent("react-grab:element-selected", { detail: { elements: elementsPayload } }));
|
|
1990
|
+
};
|
|
1991
|
+
const labelFadeTimeouts = /* @__PURE__ */ new Map();
|
|
1992
|
+
const cancelLabelFade = (instanceId) => {
|
|
1993
|
+
const existingTimeout = labelFadeTimeouts.get(instanceId);
|
|
1994
|
+
if (existingTimeout !== void 0) {
|
|
1995
|
+
window.clearTimeout(existingTimeout);
|
|
1996
|
+
labelFadeTimeouts.delete(instanceId);
|
|
1997
|
+
}
|
|
1998
|
+
};
|
|
1999
|
+
const cancelAllLabelFades = () => {
|
|
2000
|
+
for (const timeoutId of labelFadeTimeouts.values()) window.clearTimeout(timeoutId);
|
|
2001
|
+
labelFadeTimeouts.clear();
|
|
2002
|
+
};
|
|
2003
|
+
const scheduleLabelFade = (instanceId) => {
|
|
2004
|
+
cancelLabelFade(instanceId);
|
|
2005
|
+
const timeoutId = window.setTimeout(() => {
|
|
2006
|
+
labelFadeTimeouts.delete(instanceId);
|
|
2007
|
+
actions.updateLabelInstance(instanceId, "fading");
|
|
2008
|
+
setTimeout(() => {
|
|
2009
|
+
labelFadeTimeouts.delete(instanceId);
|
|
2010
|
+
actions.removeLabelInstance(instanceId);
|
|
2011
|
+
}, 150);
|
|
2012
|
+
}, FEEDBACK_DURATION_MS);
|
|
2013
|
+
labelFadeTimeouts.set(instanceId, timeoutId);
|
|
2014
|
+
};
|
|
2015
|
+
const handleLabelInstanceHoverChange = (instanceId, isHovered) => {
|
|
2016
|
+
if (isHovered) cancelLabelFade(instanceId);
|
|
2017
|
+
else {
|
|
2018
|
+
const instance = store.labelInstances.find((labelInstance) => labelInstance.id === instanceId);
|
|
2019
|
+
if (instance && instance.status === "copied") scheduleLabelFade(instanceId);
|
|
2020
|
+
}
|
|
2021
|
+
};
|
|
2022
|
+
const createLabelInstance = (bounds, tagName, componentName, status, options) => {
|
|
2023
|
+
actions.clearLabelInstances();
|
|
2024
|
+
cancelAllLabelFades();
|
|
2025
|
+
const instanceId = generateId("label");
|
|
2026
|
+
const boundsCenterX = bounds.x + bounds.width / 2;
|
|
2027
|
+
const boundsHalfWidth = bounds.width / 2;
|
|
2028
|
+
const mouseX = options?.mouseX;
|
|
2029
|
+
const mouseXOffset = mouseX !== void 0 ? mouseX - boundsCenterX : void 0;
|
|
2030
|
+
const instance = {
|
|
2031
|
+
id: instanceId,
|
|
2032
|
+
bounds,
|
|
2033
|
+
boundsMultiple: options?.boundsMultiple,
|
|
2034
|
+
tagName,
|
|
2035
|
+
componentName,
|
|
2036
|
+
status,
|
|
2037
|
+
createdAt: Date.now(),
|
|
2038
|
+
element: options?.element,
|
|
2039
|
+
elements: options?.elements,
|
|
2040
|
+
mouseX,
|
|
2041
|
+
mouseXOffsetFromCenter: mouseXOffset,
|
|
2042
|
+
mouseXOffsetRatio: mouseXOffset !== void 0 && boundsHalfWidth > 0 ? mouseXOffset / boundsHalfWidth : void 0,
|
|
2043
|
+
hideArrow: options?.hideArrow
|
|
2044
|
+
};
|
|
2045
|
+
actions.addLabelInstance(instance);
|
|
2046
|
+
return instanceId;
|
|
2047
|
+
};
|
|
2048
|
+
const clearAllLabels = () => {
|
|
2049
|
+
cancelAllLabelFades();
|
|
2050
|
+
actions.clearLabelInstances();
|
|
2051
|
+
};
|
|
2052
|
+
const updateLabelAfterCopy = (labelInstanceId, didSucceed, errorMessage) => {
|
|
2053
|
+
if (didSucceed) actions.updateLabelInstance(labelInstanceId, "copied");
|
|
2054
|
+
else actions.updateLabelInstance(labelInstanceId, "error", errorMessage || "Unknown error");
|
|
2055
|
+
scheduleLabelFade(labelInstanceId);
|
|
2056
|
+
};
|
|
2057
|
+
const executeCopyOperation = async (clipboardOperation, labelInstanceId, copiedElement, shouldDeactivateAfter) => {
|
|
2058
|
+
clearCopyFeedbackCooldown();
|
|
2059
|
+
if (store.current.state !== "copying") actions.startCopy();
|
|
2060
|
+
let didSucceed = false;
|
|
2061
|
+
let errorMessage;
|
|
2062
|
+
try {
|
|
2063
|
+
await clipboardOperation();
|
|
2064
|
+
didSucceed = true;
|
|
2065
|
+
} catch (error) {
|
|
2066
|
+
errorMessage = normalizeErrorMessage(error, "Action failed");
|
|
2067
|
+
}
|
|
2068
|
+
if (labelInstanceId) updateLabelAfterCopy(labelInstanceId, didSucceed, errorMessage);
|
|
2069
|
+
if (store.current.state !== "copying") return;
|
|
2070
|
+
if (didSucceed) actions.completeCopy(copiedElement);
|
|
2071
|
+
if (shouldDeactivateAfter) deactivateRenderer();
|
|
2072
|
+
else if (didSucceed) {
|
|
2073
|
+
actions.activate();
|
|
2074
|
+
startCopyFeedbackCooldown();
|
|
2075
|
+
} else actions.unfreeze();
|
|
2076
|
+
};
|
|
2077
|
+
const handleCopySuccessWithComments = (options) => {
|
|
2078
|
+
const { copiedElements, content, extraPrompt, elementName, tagName, componentName } = options;
|
|
2079
|
+
pluginRegistry.hooks.onCopySuccess(copiedElements, content);
|
|
2080
|
+
if (!extraPrompt) return;
|
|
2081
|
+
const hasCopiedElements = copiedElements.length > 0;
|
|
2082
|
+
if (hasCopiedElements) {
|
|
2083
|
+
const currentItems = commentItems();
|
|
2084
|
+
for (const [existingItemId, mappedElements] of commentElementMap.entries()) {
|
|
2085
|
+
if (!(mappedElements.length === copiedElements.length && mappedElements.every((mappedElement, index) => mappedElement === copiedElements[index]))) continue;
|
|
2086
|
+
const existingItem = currentItems.find((item) => item.id === existingItemId);
|
|
2087
|
+
if (!existingItem) continue;
|
|
2088
|
+
if (existingItem.commentText === extraPrompt) {
|
|
2089
|
+
removeCommentItem(existingItemId);
|
|
2090
|
+
commentElementMap.delete(existingItemId);
|
|
2091
|
+
break;
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2095
|
+
const elementSelectors = copiedElements.map((copiedElement, index) => createElementSelector(copiedElement, index === 0));
|
|
2096
|
+
const updatedCommentItems = addCommentItem({
|
|
2097
|
+
content,
|
|
2098
|
+
elementName: elementName ?? "element",
|
|
2099
|
+
tagName: tagName ?? "div",
|
|
2100
|
+
componentName: componentName ?? void 0,
|
|
2101
|
+
elementsCount: copiedElements.length,
|
|
2102
|
+
previewBounds: copiedElements.map((copiedElement) => createElementBounds(copiedElement)),
|
|
2103
|
+
elementSelectors,
|
|
2104
|
+
commentText: extraPrompt,
|
|
2105
|
+
timestamp: Date.now()
|
|
2106
|
+
});
|
|
2107
|
+
setCommentItems(updatedCommentItems);
|
|
2108
|
+
setClockFlashTrigger((previous) => previous + 1);
|
|
2109
|
+
const newestCommentItem = updatedCommentItems[0];
|
|
2110
|
+
if (newestCommentItem && hasCopiedElements) commentElementMap.set(newestCommentItem.id, [...copiedElements]);
|
|
2111
|
+
const currentItemIds = new Set(updatedCommentItems.map((item) => item.id));
|
|
2112
|
+
for (const mapItemId of commentElementMap.keys()) if (!currentItemIds.has(mapItemId)) commentElementMap.delete(mapItemId);
|
|
2113
|
+
};
|
|
2114
|
+
const copyWithFallback = (elements, extraPrompt, resolvedComponentName) => {
|
|
2115
|
+
const firstElement = elements[0];
|
|
2116
|
+
const componentName = resolvedComponentName ?? (firstElement ? getComponentDisplayName(firstElement) : null);
|
|
2117
|
+
const tagName = firstElement ? getTagName(firstElement) : null;
|
|
2118
|
+
const elementName = componentName ?? tagName ?? void 0;
|
|
2119
|
+
return tryCopyWithFallback({
|
|
2120
|
+
maxContextLines: pluginRegistry.store.options.maxContextLines,
|
|
2121
|
+
getContent: pluginRegistry.store.options.getContent,
|
|
2122
|
+
componentName: elementName
|
|
2123
|
+
}, {
|
|
2124
|
+
onBeforeCopy: pluginRegistry.hooks.onBeforeCopy,
|
|
2125
|
+
transformSnippet: pluginRegistry.hooks.transformSnippet,
|
|
2126
|
+
transformCopyContent: pluginRegistry.hooks.transformCopyContent,
|
|
2127
|
+
onAfterCopy: pluginRegistry.hooks.onAfterCopy,
|
|
2128
|
+
onCopySuccess: (copiedElements, content) => {
|
|
2129
|
+
handleCopySuccessWithComments({
|
|
2130
|
+
copiedElements,
|
|
2131
|
+
content,
|
|
2132
|
+
extraPrompt,
|
|
2133
|
+
elementName,
|
|
2134
|
+
tagName,
|
|
2135
|
+
componentName
|
|
2136
|
+
});
|
|
2137
|
+
},
|
|
2138
|
+
onCopyError: pluginRegistry.hooks.onCopyError
|
|
2139
|
+
}, elements, extraPrompt);
|
|
2140
|
+
};
|
|
2141
|
+
const copyElementsToClipboard = async (targetElements, extraPrompt, resolvedComponentName) => {
|
|
2142
|
+
if (targetElements.length === 0) return;
|
|
2143
|
+
const unhandledElements = [];
|
|
2144
|
+
const pendingResults = [];
|
|
2145
|
+
for (const element of targetElements) {
|
|
2146
|
+
const { wasIntercepted, pendingResult } = pluginRegistry.hooks.onElementSelect(element);
|
|
2147
|
+
if (!wasIntercepted) unhandledElements.push(element);
|
|
2148
|
+
if (pendingResult) pendingResults.push(pendingResult);
|
|
2149
|
+
if (pluginRegistry.store.theme.grabbedBoxes.enabled) showTemporaryGrabbedBox(createElementBounds(element), element);
|
|
2150
|
+
}
|
|
2151
|
+
await waitUntilNextFrame();
|
|
2152
|
+
if (unhandledElements.length > 0) await copyWithFallback(unhandledElements, extraPrompt, resolvedComponentName);
|
|
2153
|
+
else if (pendingResults.length > 0) {
|
|
2154
|
+
if (!(await Promise.all(pendingResults)).every(Boolean)) throw new Error("Failed to copy");
|
|
2155
|
+
}
|
|
2156
|
+
notifyElementsSelected(targetElements);
|
|
2157
|
+
};
|
|
2158
|
+
const performCopyWithLabel = (options) => {
|
|
2159
|
+
const { element, cursorX, selectedElements, extraPrompt, shouldDeactivateAfter, onComplete, dragRect: passedDragRect } = options;
|
|
2160
|
+
const allTargetElements = selectedElements ?? [element];
|
|
2161
|
+
const dragRect = passedDragRect ?? store.frozenDragRect;
|
|
2162
|
+
const isMultiSelect = allTargetElements.length > 1;
|
|
2163
|
+
const selectionBounds = dragRect && isMultiSelect ? createBoundsFromDragRect(dragRect) : createFlatOverlayBounds(createElementBounds(element));
|
|
2164
|
+
const labelCursorX = isMultiSelect ? selectionBounds.x + selectionBounds.width / 2 : cursorX;
|
|
2165
|
+
const tagName = getTagName(element);
|
|
2166
|
+
clearCopyFeedbackCooldown();
|
|
2167
|
+
actions.startCopy();
|
|
2168
|
+
const labelInstanceId = tagName ? createLabelInstance(selectionBounds, tagName, void 0, "copying", {
|
|
2169
|
+
element,
|
|
2170
|
+
mouseX: labelCursorX,
|
|
2171
|
+
elements: selectedElements
|
|
2172
|
+
}) : null;
|
|
2173
|
+
getNearestComponentName(element).then(async (componentName) => {
|
|
2174
|
+
await executeCopyOperation(() => copyElementsToClipboard(allTargetElements, extraPrompt, componentName ?? void 0), labelInstanceId, element, shouldDeactivateAfter);
|
|
2175
|
+
onComplete?.();
|
|
2176
|
+
}).catch((error) => {
|
|
2177
|
+
logRecoverableError("Copy operation failed", error);
|
|
2178
|
+
if (labelInstanceId) updateLabelAfterCopy(labelInstanceId, false, normalizeErrorMessage(error, "Action failed"));
|
|
2179
|
+
if (store.current.state === "copying") actions.unfreeze();
|
|
2180
|
+
});
|
|
2181
|
+
};
|
|
2182
|
+
const targetElement = createMemo(() => {
|
|
2183
|
+
store.viewportVersion;
|
|
2184
|
+
if (!isRendererActive() || isDragging()) return null;
|
|
2185
|
+
const element = store.detectedElement;
|
|
2186
|
+
if (!isElementConnected(element)) return null;
|
|
2187
|
+
return element;
|
|
2188
|
+
});
|
|
2189
|
+
const effectiveElement = createMemo(() => store.frozenElement || (isFrozenPhase() ? null : targetElement()));
|
|
2190
|
+
createEffect(() => {
|
|
2191
|
+
const element = store.detectedElement;
|
|
2192
|
+
if (!element) return;
|
|
2193
|
+
const intervalId = setInterval(() => {
|
|
2194
|
+
if (!isElementConnected(element)) actions.setDetectedElement(null);
|
|
2195
|
+
}, 100);
|
|
2196
|
+
onCleanup(() => clearInterval(intervalId));
|
|
2197
|
+
});
|
|
2198
|
+
createEffect(on(effectiveElement, (element) => {
|
|
2199
|
+
if (componentNameDebounceTimerId !== null) {
|
|
2200
|
+
clearTimeout(componentNameDebounceTimerId);
|
|
2201
|
+
componentNameDebounceTimerId = null;
|
|
2202
|
+
}
|
|
2203
|
+
if (!element) {
|
|
2204
|
+
setDebouncedElementForComponentName(null);
|
|
2205
|
+
return;
|
|
2206
|
+
}
|
|
2207
|
+
componentNameDebounceTimerId = window.setTimeout(() => {
|
|
2208
|
+
componentNameDebounceTimerId = null;
|
|
2209
|
+
setDebouncedElementForComponentName(element);
|
|
2210
|
+
}, 100);
|
|
2211
|
+
}));
|
|
2212
|
+
onCleanup(() => {
|
|
2213
|
+
if (componentNameDebounceTimerId !== null) {
|
|
2214
|
+
clearTimeout(componentNameDebounceTimerId);
|
|
2215
|
+
componentNameDebounceTimerId = null;
|
|
2216
|
+
}
|
|
2217
|
+
});
|
|
2218
|
+
createEffect(() => {
|
|
2219
|
+
const elements = store.frozenElements;
|
|
2220
|
+
onCleanup(freezeAnimations(elements));
|
|
2221
|
+
});
|
|
2222
|
+
createEffect(on(isActivated, (activated) => {
|
|
2223
|
+
if (!activated) return;
|
|
2224
|
+
if (!pluginRegistry.store.options.freezeReactUpdates) return;
|
|
2225
|
+
onCleanup(freezeUpdates());
|
|
2226
|
+
}));
|
|
2227
|
+
const getSelectionElement = () => {
|
|
2228
|
+
if (store.isTouchMode && isDragging()) {
|
|
2229
|
+
const detected = store.detectedElement;
|
|
2230
|
+
if (!detected || isRootElement(detected)) return void 0;
|
|
2231
|
+
return detected;
|
|
2232
|
+
}
|
|
2233
|
+
const element = effectiveElement();
|
|
2234
|
+
if (!element || isRootElement(element)) return void 0;
|
|
2235
|
+
return element;
|
|
2236
|
+
};
|
|
2237
|
+
const selectionElement = createMemo(() => getSelectionElement());
|
|
2238
|
+
const isSelectionElementVisible = () => {
|
|
2239
|
+
if (!selectionElement()) return false;
|
|
2240
|
+
if (store.isTouchMode && isDragging()) return isRendererActive();
|
|
2241
|
+
return isRendererActive() && !isDragging();
|
|
2242
|
+
};
|
|
2243
|
+
const frozenElementsBounds = createMemo(() => {
|
|
2244
|
+
store.viewportVersion;
|
|
2245
|
+
const frozenElements = store.frozenElements;
|
|
2246
|
+
if (frozenElements.length === 0) return [];
|
|
2247
|
+
const dragRect = store.frozenDragRect;
|
|
2248
|
+
if (dragRect && frozenElements.length > 1) return [createBoundsFromDragRect(dragRect)];
|
|
2249
|
+
return frozenElements.filter((element) => element !== null).map((element) => createElementBounds(element));
|
|
2250
|
+
});
|
|
2251
|
+
const selectionBounds = createMemo(() => {
|
|
2252
|
+
store.viewportVersion;
|
|
2253
|
+
const frozenElements = store.frozenElements;
|
|
2254
|
+
if (frozenElements.length > 0) {
|
|
2255
|
+
const frozenBounds = frozenElementsBounds();
|
|
2256
|
+
if (frozenElements.length === 1) {
|
|
2257
|
+
const firstBounds = frozenBounds[0];
|
|
2258
|
+
if (firstBounds) return firstBounds;
|
|
2259
|
+
}
|
|
2260
|
+
const dragRect = store.frozenDragRect;
|
|
2261
|
+
if (dragRect) return frozenBounds[0] ?? createBoundsFromDragRect(dragRect);
|
|
2262
|
+
return createFlatOverlayBounds(combineBounds(frozenBounds));
|
|
2263
|
+
}
|
|
2264
|
+
const element = selectionElement();
|
|
2265
|
+
if (!element) return void 0;
|
|
2266
|
+
return createElementBounds(element);
|
|
2267
|
+
});
|
|
2268
|
+
const toPageCoordinates = (clientX, clientY) => ({
|
|
2269
|
+
pageX: clientX + window.scrollX,
|
|
2270
|
+
pageY: clientY + window.scrollY
|
|
2271
|
+
});
|
|
2272
|
+
const calculateDragDistance = (endX, endY) => {
|
|
2273
|
+
const { pageX: endPageX, pageY: endPageY } = toPageCoordinates(endX, endY);
|
|
2274
|
+
return {
|
|
2275
|
+
x: Math.abs(endPageX - store.dragStart.x),
|
|
2276
|
+
y: Math.abs(endPageY - store.dragStart.y)
|
|
2277
|
+
};
|
|
2278
|
+
};
|
|
2279
|
+
const isDraggingBeyondThreshold = createMemo(() => {
|
|
2280
|
+
if (!isDragging()) return false;
|
|
2281
|
+
const dragDistance = calculateDragDistance(store.pointer.x, store.pointer.y);
|
|
2282
|
+
return dragDistance.x > 2 || dragDistance.y > 2;
|
|
2283
|
+
});
|
|
2284
|
+
const calculateDragRectangle = (endX, endY) => {
|
|
2285
|
+
const { pageX: endPageX, pageY: endPageY } = toPageCoordinates(endX, endY);
|
|
2286
|
+
const dragPageX = Math.min(store.dragStart.x, endPageX);
|
|
2287
|
+
const dragPageY = Math.min(store.dragStart.y, endPageY);
|
|
2288
|
+
const dragWidth = Math.abs(endPageX - store.dragStart.x);
|
|
2289
|
+
const dragHeight = Math.abs(endPageY - store.dragStart.y);
|
|
2290
|
+
return {
|
|
2291
|
+
x: dragPageX - window.scrollX,
|
|
2292
|
+
y: dragPageY - window.scrollY,
|
|
2293
|
+
width: dragWidth,
|
|
2294
|
+
height: dragHeight
|
|
2295
|
+
};
|
|
2296
|
+
};
|
|
2297
|
+
const dragBounds = createMemo(() => {
|
|
2298
|
+
store.viewportVersion;
|
|
2299
|
+
if (!isDraggingBeyondThreshold()) return void 0;
|
|
2300
|
+
const drag = calculateDragRectangle(store.pointer.x, store.pointer.y);
|
|
2301
|
+
return {
|
|
2302
|
+
borderRadius: "0px",
|
|
2303
|
+
height: drag.height,
|
|
2304
|
+
transform: "none",
|
|
2305
|
+
width: drag.width,
|
|
2306
|
+
x: drag.x,
|
|
2307
|
+
y: drag.y
|
|
2308
|
+
};
|
|
2309
|
+
});
|
|
2310
|
+
const dragPreviewBounds = createMemo(() => {
|
|
2311
|
+
store.viewportVersion;
|
|
2312
|
+
if (!isDraggingBeyondThreshold()) return [];
|
|
2313
|
+
const pointer = debouncedDragPointer();
|
|
2314
|
+
if (!pointer) return [];
|
|
2315
|
+
const drag = calculateDragRectangle(pointer.x, pointer.y);
|
|
2316
|
+
const elements = getElementsInDrag(drag, isValidGrabbableElement);
|
|
2317
|
+
return (elements.length > 0 ? elements : getElementsInDrag(drag, isValidGrabbableElement, false)).map((element) => createElementBounds(element));
|
|
2318
|
+
});
|
|
2319
|
+
const selectionBoundsMultiple = createMemo(() => {
|
|
2320
|
+
const previewBounds = dragPreviewBounds();
|
|
2321
|
+
if (previewBounds.length > 0) return previewBounds;
|
|
2322
|
+
return frozenElementsBounds();
|
|
2323
|
+
});
|
|
2324
|
+
const inspectBounds = createMemo(() => {
|
|
2325
|
+
if (!isInspectMode()) return [];
|
|
2326
|
+
const element = effectiveElement();
|
|
2327
|
+
if (!element) return [];
|
|
2328
|
+
store.viewportVersion;
|
|
2329
|
+
return [...getAncestorElements(element), element].map((ancestor) => createElementBounds(ancestor));
|
|
2330
|
+
});
|
|
2331
|
+
const cursorPosition = createMemo(() => {
|
|
2332
|
+
if (isCopying() || isPromptMode()) {
|
|
2333
|
+
store.viewportVersion;
|
|
2334
|
+
const element = store.frozenElement || targetElement();
|
|
2335
|
+
if (element) return {
|
|
2336
|
+
x: getBoundsCenter(createElementBounds(element)).x + store.copyOffsetFromCenterX,
|
|
2337
|
+
y: store.copyStart.y
|
|
2338
|
+
};
|
|
2339
|
+
return {
|
|
2340
|
+
x: store.copyStart.x,
|
|
2341
|
+
y: store.copyStart.y
|
|
2342
|
+
};
|
|
2343
|
+
}
|
|
2344
|
+
return {
|
|
2345
|
+
x: store.pointer.x,
|
|
2346
|
+
y: store.pointer.y
|
|
2347
|
+
};
|
|
2348
|
+
});
|
|
2349
|
+
createEffect(on(() => [targetElement(), store.lastGrabbedElement], ([currentElement, lastElement]) => {
|
|
2350
|
+
if (lastElement && currentElement && lastElement !== currentElement) actions.setLastGrabbed(null);
|
|
2351
|
+
if (currentElement) pluginRegistry.hooks.onElementHover(currentElement);
|
|
2352
|
+
}));
|
|
2353
|
+
createEffect(on(() => targetElement(), (element) => {
|
|
2354
|
+
const currentVersion = ++selectionSourceRequestVersion;
|
|
2355
|
+
const clearSource = () => {
|
|
2356
|
+
if (selectionSourceRequestVersion === currentVersion) actions.setSelectionSource(null, null);
|
|
2357
|
+
};
|
|
2358
|
+
if (!element) {
|
|
2359
|
+
clearSource();
|
|
2360
|
+
return;
|
|
2361
|
+
}
|
|
2362
|
+
resolveSource(element).then((source) => {
|
|
2363
|
+
if (selectionSourceRequestVersion !== currentVersion) return;
|
|
2364
|
+
if (!source) {
|
|
2365
|
+
clearSource();
|
|
2366
|
+
return;
|
|
2367
|
+
}
|
|
2368
|
+
actions.setSelectionSource(source.filePath, source.lineNumber);
|
|
2369
|
+
}).catch(() => {
|
|
2370
|
+
if (selectionSourceRequestVersion === currentVersion) actions.setSelectionSource(null, null);
|
|
2371
|
+
});
|
|
2372
|
+
}));
|
|
2373
|
+
const publicGrabbedBoxes = createMemo(() => store.grabbedBoxes.map((box) => ({
|
|
2374
|
+
id: box.id,
|
|
2375
|
+
bounds: box.bounds,
|
|
2376
|
+
createdAt: box.createdAt
|
|
2377
|
+
})));
|
|
2378
|
+
const publicLabelInstances = createMemo(() => store.labelInstances.map((instance) => ({
|
|
2379
|
+
id: instance.id,
|
|
2380
|
+
status: instance.status,
|
|
2381
|
+
tagName: instance.tagName,
|
|
2382
|
+
componentName: instance.componentName,
|
|
2383
|
+
createdAt: instance.createdAt
|
|
2384
|
+
})));
|
|
2385
|
+
createEffect(on(createMemo(() => {
|
|
2386
|
+
const active = isActivated();
|
|
2387
|
+
const dragging = isDragging();
|
|
2388
|
+
const copying = isCopying();
|
|
2389
|
+
const inputMode = isPromptMode();
|
|
2390
|
+
const target = targetElement();
|
|
2391
|
+
const drag = dragBounds();
|
|
2392
|
+
const themeEnabled = pluginRegistry.store.theme.enabled;
|
|
2393
|
+
const selectionBoxEnabled = pluginRegistry.store.theme.selectionBox.enabled;
|
|
2394
|
+
const dragBoxEnabled = pluginRegistry.store.theme.dragBox.enabled;
|
|
2395
|
+
const draggingBeyondThreshold = isDraggingBeyondThreshold();
|
|
2396
|
+
const effectiveTarget = effectiveElement();
|
|
2397
|
+
const justCopied = didJustCopy();
|
|
2398
|
+
return {
|
|
2399
|
+
isActive: active,
|
|
2400
|
+
isDragging: dragging,
|
|
2401
|
+
isCopying: copying,
|
|
2402
|
+
isPromptMode: inputMode,
|
|
2403
|
+
isSelectionBoxVisible: Boolean(themeEnabled && selectionBoxEnabled && active && !copying && !justCopied && !dragging && effectiveTarget != null),
|
|
2404
|
+
isDragBoxVisible: Boolean(themeEnabled && dragBoxEnabled && active && !copying && draggingBeyondThreshold),
|
|
2405
|
+
targetElement: target,
|
|
2406
|
+
dragBounds: drag ? {
|
|
2407
|
+
x: drag.x,
|
|
2408
|
+
y: drag.y,
|
|
2409
|
+
width: drag.width,
|
|
2410
|
+
height: drag.height
|
|
2411
|
+
} : null,
|
|
2412
|
+
grabbedBoxes: [...publicGrabbedBoxes()],
|
|
2413
|
+
labelInstances: [...publicLabelInstances()],
|
|
2414
|
+
selectionFilePath: store.selectionFilePath,
|
|
2415
|
+
toolbarState: currentToolbarState()
|
|
2416
|
+
};
|
|
2417
|
+
}), (state) => {
|
|
2418
|
+
pluginRegistry.hooks.onStateChange(state);
|
|
2419
|
+
}));
|
|
2420
|
+
createEffect(on(() => [
|
|
2421
|
+
isPromptMode(),
|
|
2422
|
+
store.pointer.x,
|
|
2423
|
+
store.pointer.y,
|
|
2424
|
+
targetElement()
|
|
2425
|
+
], ([inputMode, x, y, target]) => {
|
|
2426
|
+
pluginRegistry.hooks.onPromptModeChange(inputMode, {
|
|
2427
|
+
x,
|
|
2428
|
+
y,
|
|
2429
|
+
targetElement: target
|
|
2430
|
+
});
|
|
2431
|
+
}));
|
|
2432
|
+
createEffect(on(() => [
|
|
2433
|
+
selectionVisible(),
|
|
2434
|
+
selectionBounds(),
|
|
2435
|
+
targetElement()
|
|
2436
|
+
], ([visible, bounds, element]) => {
|
|
2437
|
+
pluginRegistry.hooks.onSelectionBox(Boolean(visible), bounds ?? null, element);
|
|
2438
|
+
}));
|
|
2439
|
+
createEffect(on(() => [dragVisible(), dragBounds()], ([visible, bounds]) => {
|
|
2440
|
+
pluginRegistry.hooks.onDragBox(Boolean(visible), bounds ?? null);
|
|
2441
|
+
}));
|
|
2442
|
+
createEffect(on(() => [
|
|
2443
|
+
labelVisible(),
|
|
2444
|
+
labelVariant(),
|
|
2445
|
+
cursorPosition(),
|
|
2446
|
+
targetElement(),
|
|
2447
|
+
store.selectionFilePath,
|
|
2448
|
+
store.selectionLineNumber
|
|
2449
|
+
], ([visible, variant, position, element, filePath, lineNumber]) => {
|
|
2450
|
+
pluginRegistry.hooks.onElementLabel(Boolean(visible), variant, {
|
|
2451
|
+
x: position.x,
|
|
2452
|
+
y: position.y,
|
|
2453
|
+
content: "",
|
|
2454
|
+
element: element ?? void 0,
|
|
2455
|
+
tagName: element ? getTagName(element) || void 0 : void 0,
|
|
2456
|
+
filePath: filePath ?? void 0,
|
|
2457
|
+
lineNumber: lineNumber ?? void 0
|
|
2458
|
+
});
|
|
2459
|
+
}));
|
|
2460
|
+
let cursorStyleElement = null;
|
|
2461
|
+
const setCursorOverride = (cursor) => {
|
|
2462
|
+
if (cursor) {
|
|
2463
|
+
if (!cursorStyleElement) {
|
|
2464
|
+
cursorStyleElement = document.createElement("style");
|
|
2465
|
+
cursorStyleElement.setAttribute("data-react-grab-cursor", "");
|
|
2466
|
+
const nonce = detectCspNonce();
|
|
2467
|
+
if (nonce) cursorStyleElement.nonce = nonce;
|
|
2468
|
+
hideFromThirdParties(cursorStyleElement);
|
|
2469
|
+
document.head.appendChild(cursorStyleElement);
|
|
2470
|
+
}
|
|
2471
|
+
cursorStyleElement.textContent = `* { cursor: ${cursor} !important; }`;
|
|
2472
|
+
} else if (cursorStyleElement) {
|
|
2473
|
+
cursorStyleElement.remove();
|
|
2474
|
+
cursorStyleElement = null;
|
|
2475
|
+
}
|
|
2476
|
+
};
|
|
2477
|
+
createEffect(on(() => [
|
|
2478
|
+
isActivated(),
|
|
2479
|
+
isCopying(),
|
|
2480
|
+
isPromptMode()
|
|
2481
|
+
], ([activated, copying, promptMode]) => {
|
|
2482
|
+
if (copying) setCursorOverride("progress");
|
|
2483
|
+
else if (activated && !promptMode) setCursorOverride("crosshair");
|
|
2484
|
+
else setCursorOverride(null);
|
|
2485
|
+
}));
|
|
2486
|
+
const activateRenderer = () => {
|
|
2487
|
+
const wasInHoldingState = isHoldingKeys();
|
|
2488
|
+
actions.activate();
|
|
2489
|
+
if (!wasInHoldingState) pluginRegistry.hooks.onActivate();
|
|
2490
|
+
};
|
|
2491
|
+
const deactivateRenderer = () => {
|
|
2492
|
+
const wasDragging = isDragging();
|
|
2493
|
+
const previousFocused = store.previouslyFocusedElement;
|
|
2494
|
+
actions.deactivate();
|
|
2495
|
+
setIsInspectMode(false);
|
|
2496
|
+
clearArrowNavigation();
|
|
2497
|
+
keyboardSelectedElement = null;
|
|
2498
|
+
isPendingContextMenuSelect = false;
|
|
2499
|
+
if (wasDragging) document.body.style.userSelect = "";
|
|
2500
|
+
if (keydownSpamTimerId) window.clearTimeout(keydownSpamTimerId);
|
|
2501
|
+
autoScroller.stop();
|
|
2502
|
+
if (previousFocused instanceof HTMLElement && isElementConnected(previousFocused)) previousFocused.focus();
|
|
2503
|
+
pluginRegistry.hooks.onDeactivate();
|
|
2504
|
+
};
|
|
2505
|
+
const forceDeactivateAll = () => {
|
|
2506
|
+
if (isHoldingKeys()) actions.releaseHold();
|
|
2507
|
+
if (isActivated()) deactivateRenderer();
|
|
2508
|
+
clearCopyFeedbackCooldown();
|
|
2509
|
+
};
|
|
2510
|
+
const toggleActivate = () => {
|
|
2511
|
+
actions.setWasActivatedByToggle(true);
|
|
2512
|
+
activateRenderer();
|
|
2513
|
+
};
|
|
2514
|
+
const handleInputSubmit = () => {
|
|
2515
|
+
actions.clearLastCopied();
|
|
2516
|
+
const frozenElements = [...store.frozenElements];
|
|
2517
|
+
const element = store.frozenElement || targetElement();
|
|
2518
|
+
const prompt = isPromptMode() ? store.inputText.trim() : "";
|
|
2519
|
+
if (!element) {
|
|
2520
|
+
deactivateRenderer();
|
|
2521
|
+
return;
|
|
2522
|
+
}
|
|
2523
|
+
const elements = frozenElements.length > 0 ? frozenElements : [element];
|
|
2524
|
+
const firstBounds = elements.map((selectedElement) => createElementBounds(selectedElement))[0];
|
|
2525
|
+
const { x: currentX, y: currentY } = getBoundsCenter(firstBounds);
|
|
2526
|
+
const labelPositionX = currentX + store.copyOffsetFromCenterX;
|
|
2527
|
+
actions.setPointer({
|
|
2528
|
+
x: currentX,
|
|
2529
|
+
y: currentY
|
|
2530
|
+
});
|
|
2531
|
+
actions.exitPromptMode();
|
|
2532
|
+
actions.clearInputText();
|
|
2533
|
+
performCopyWithLabel({
|
|
2534
|
+
element,
|
|
2535
|
+
cursorX: labelPositionX,
|
|
2536
|
+
selectedElements: elements,
|
|
2537
|
+
extraPrompt: prompt || void 0,
|
|
2538
|
+
shouldDeactivateAfter: true
|
|
2539
|
+
});
|
|
2540
|
+
};
|
|
2541
|
+
const handleInputCancel = () => {
|
|
2542
|
+
actions.clearLastCopied();
|
|
2543
|
+
if (!isPromptMode()) return;
|
|
2544
|
+
if (isPendingDismiss()) {
|
|
2545
|
+
actions.clearInputText();
|
|
2546
|
+
deactivateRenderer();
|
|
2547
|
+
return;
|
|
2548
|
+
}
|
|
2549
|
+
actions.setPendingDismiss(true);
|
|
2550
|
+
setSelectionLabelShakeCount((count) => count + 1);
|
|
2551
|
+
};
|
|
2552
|
+
const handleConfirmDismiss = () => {
|
|
2553
|
+
actions.clearInputText();
|
|
2554
|
+
deactivateRenderer();
|
|
2555
|
+
};
|
|
2556
|
+
const handleCancelDismiss = () => {
|
|
2557
|
+
actions.setPendingDismiss(false);
|
|
2558
|
+
};
|
|
2559
|
+
const handleToggleExpand = () => {
|
|
2560
|
+
const element = store.frozenElement || targetElement();
|
|
2561
|
+
if (element) preparePromptMode(element, store.pointer.x, store.pointer.y);
|
|
2562
|
+
activatePromptMode();
|
|
2563
|
+
};
|
|
2564
|
+
const handleToggleActive = () => {
|
|
2565
|
+
if (isActivated()) deactivateRenderer();
|
|
2566
|
+
else if (isEnabled()) {
|
|
2567
|
+
const defaultActionId = currentToolbarState()?.defaultAction ?? "comment";
|
|
2568
|
+
if (defaultActionId === "comment") actions.setPendingCommentMode(true);
|
|
2569
|
+
else {
|
|
2570
|
+
pendingDefaultActionId = defaultActionId;
|
|
2571
|
+
isPendingContextMenuSelect = true;
|
|
2572
|
+
}
|
|
2573
|
+
toggleActivate();
|
|
2574
|
+
}
|
|
2575
|
+
};
|
|
2576
|
+
const enterCommentModeForElement = (element, positionX, positionY) => {
|
|
2577
|
+
actions.setPendingCommentMode(false);
|
|
2578
|
+
actions.clearInputText();
|
|
2579
|
+
actions.enterPromptMode({
|
|
2580
|
+
x: positionX,
|
|
2581
|
+
y: positionY
|
|
2582
|
+
}, element);
|
|
2583
|
+
};
|
|
2584
|
+
const openContextMenu = (element, position) => {
|
|
2585
|
+
actions.showContextMenu(position, element);
|
|
2586
|
+
clearArrowNavigation();
|
|
2587
|
+
dismissAllPopups();
|
|
2588
|
+
pluginRegistry.hooks.onContextMenu(element, position);
|
|
2589
|
+
};
|
|
2590
|
+
const runPendingDefaultAction = (element, position) => {
|
|
2591
|
+
const actionId = pendingDefaultActionId;
|
|
2592
|
+
pendingDefaultActionId = null;
|
|
2593
|
+
if (!actionId) return;
|
|
2594
|
+
const action = pluginRegistry.store.actions.find((registeredAction) => registeredAction.id === actionId);
|
|
2595
|
+
if (!action) {
|
|
2596
|
+
handleSetDefaultAction(DEFAULT_ACTION_ID);
|
|
2597
|
+
openContextMenu(element, position);
|
|
2598
|
+
return;
|
|
2599
|
+
}
|
|
2600
|
+
const elementBounds = createElementBounds(element);
|
|
2601
|
+
const context = buildActionContext({
|
|
2602
|
+
element,
|
|
2603
|
+
filePath: store.selectionFilePath ?? void 0,
|
|
2604
|
+
lineNumber: store.selectionLineNumber ?? void 0,
|
|
2605
|
+
tagName: getTagName(element) || void 0,
|
|
2606
|
+
componentName: resolvedComponentName(),
|
|
2607
|
+
position,
|
|
2608
|
+
shouldDeferHideContextMenu: false,
|
|
2609
|
+
performWithFeedbackOptions: {
|
|
2610
|
+
fallbackBounds: elementBounds,
|
|
2611
|
+
fallbackSelectionBounds: [elementBounds],
|
|
2612
|
+
position
|
|
2613
|
+
}
|
|
2614
|
+
});
|
|
2615
|
+
action.onAction(context);
|
|
2616
|
+
};
|
|
2617
|
+
const handleComment = () => {
|
|
2618
|
+
if (!isEnabled()) return;
|
|
2619
|
+
if (isActivated() && isCommentMode()) {
|
|
2620
|
+
deactivateRenderer();
|
|
2621
|
+
return;
|
|
2622
|
+
}
|
|
2623
|
+
actions.setPendingCommentMode(true);
|
|
2624
|
+
if (!isActivated()) toggleActivate();
|
|
2625
|
+
};
|
|
2626
|
+
const handleToggleEnabled = () => {
|
|
2627
|
+
const newEnabled = !isEnabled();
|
|
2628
|
+
setIsEnabled(newEnabled);
|
|
2629
|
+
updateToolbarState({ enabled: newEnabled });
|
|
2630
|
+
if (!newEnabled) {
|
|
2631
|
+
forceDeactivateAll();
|
|
2632
|
+
dismissAllPopups();
|
|
2633
|
+
}
|
|
2634
|
+
};
|
|
2635
|
+
const handlePointerMove = (clientX, clientY) => {
|
|
2636
|
+
if (!isEnabled() || isPromptMode() || isFrozenPhase() || store.contextMenuPosition !== null) return;
|
|
2637
|
+
actions.setPointer({
|
|
2638
|
+
x: clientX,
|
|
2639
|
+
y: clientY
|
|
2640
|
+
});
|
|
2641
|
+
elementDetectionState.latestPointerX = clientX;
|
|
2642
|
+
elementDetectionState.latestPointerY = clientY;
|
|
2643
|
+
const now = performance.now();
|
|
2644
|
+
const isDetectionPending = elementDetectionState.pendingDetectionScheduledAt > 0 && now - elementDetectionState.pendingDetectionScheduledAt < 200;
|
|
2645
|
+
if (now - elementDetectionState.lastDetectionTimestamp >= 32 && !isDetectionPending) {
|
|
2646
|
+
elementDetectionState.lastDetectionTimestamp = now;
|
|
2647
|
+
elementDetectionState.pendingDetectionScheduledAt = now;
|
|
2648
|
+
onIdle(() => {
|
|
2649
|
+
const candidate = getElementAtPosition(elementDetectionState.latestPointerX, elementDetectionState.latestPointerY);
|
|
2650
|
+
if (candidate !== store.detectedElement) actions.setDetectedElement(candidate);
|
|
2651
|
+
elementDetectionState.pendingDetectionScheduledAt = 0;
|
|
2652
|
+
});
|
|
2653
|
+
}
|
|
2654
|
+
if (isDragging()) {
|
|
2655
|
+
scheduleDragPreviewUpdate(clientX, clientY);
|
|
2656
|
+
const direction = getAutoScrollDirection(clientX, clientY);
|
|
2657
|
+
const isNearEdge = direction.top || direction.bottom || direction.left || direction.right;
|
|
2658
|
+
if (isNearEdge && !autoScroller.isActive()) autoScroller.start();
|
|
2659
|
+
else if (!isNearEdge && autoScroller.isActive()) autoScroller.stop();
|
|
2660
|
+
}
|
|
2661
|
+
};
|
|
2662
|
+
const handlePointerDown = (clientX, clientY) => {
|
|
2663
|
+
if (!isRendererActive() || isCopying()) return false;
|
|
2664
|
+
actions.startDrag({
|
|
2665
|
+
x: clientX,
|
|
2666
|
+
y: clientY
|
|
2667
|
+
});
|
|
2668
|
+
actions.setPointer({
|
|
2669
|
+
x: clientX,
|
|
2670
|
+
y: clientY
|
|
2671
|
+
});
|
|
2672
|
+
document.body.style.userSelect = "none";
|
|
2673
|
+
scheduleDragPreviewUpdate(clientX, clientY);
|
|
2674
|
+
pluginRegistry.hooks.onDragStart(clientX + window.scrollX, clientY + window.scrollY);
|
|
2675
|
+
return true;
|
|
2676
|
+
};
|
|
2677
|
+
const handleDragSelection = (dragSelectionRect, hasModifierKeyHeld) => {
|
|
2678
|
+
const elements = getElementsInDrag(dragSelectionRect, isValidGrabbableElement);
|
|
2679
|
+
const selectedElements = elements.length > 0 ? elements : getElementsInDrag(dragSelectionRect, isValidGrabbableElement, false);
|
|
2680
|
+
if (selectedElements.length === 0) return;
|
|
2681
|
+
freezeAllAnimations(selectedElements);
|
|
2682
|
+
pluginRegistry.hooks.onDragEnd(selectedElements, dragSelectionRect);
|
|
2683
|
+
const firstElement = selectedElements[0];
|
|
2684
|
+
const center = getBoundsCenter(createElementBounds(firstElement));
|
|
2685
|
+
actions.setPointer(center);
|
|
2686
|
+
actions.setFrozenElements(selectedElements);
|
|
2687
|
+
const dragRect = createPageRectFromBounds(dragSelectionRect);
|
|
2688
|
+
actions.setFrozenDragRect(dragRect);
|
|
2689
|
+
actions.freeze();
|
|
2690
|
+
actions.setLastGrabbed(firstElement);
|
|
2691
|
+
if (store.pendingCommentMode) {
|
|
2692
|
+
enterCommentModeForElement(firstElement, center.x, center.y);
|
|
2693
|
+
return;
|
|
2694
|
+
}
|
|
2695
|
+
if (isPendingContextMenuSelect) {
|
|
2696
|
+
isPendingContextMenuSelect = false;
|
|
2697
|
+
if (pendingDefaultActionId) runPendingDefaultAction(firstElement, center);
|
|
2698
|
+
else openContextMenu(firstElement, center);
|
|
2699
|
+
return;
|
|
2700
|
+
}
|
|
2701
|
+
const shouldDeactivateAfter = store.wasActivatedByToggle && !hasModifierKeyHeld;
|
|
2702
|
+
performCopyWithLabel({
|
|
2703
|
+
element: firstElement,
|
|
2704
|
+
cursorX: center.x,
|
|
2705
|
+
selectedElements,
|
|
2706
|
+
shouldDeactivateAfter,
|
|
2707
|
+
dragRect
|
|
2708
|
+
});
|
|
2709
|
+
};
|
|
2710
|
+
const handleSingleClick = (clientX, clientY, hasModifierKeyHeld) => {
|
|
2711
|
+
const validFrozenElement = isElementConnected(store.frozenElement) ? store.frozenElement : null;
|
|
2712
|
+
const validKeyboardSelectedElement = isElementConnected(keyboardSelectedElement) ? keyboardSelectedElement : null;
|
|
2713
|
+
const element = validFrozenElement ?? validKeyboardSelectedElement ?? getElementAtPosition(clientX, clientY) ?? (isElementConnected(store.detectedElement) ? store.detectedElement : null);
|
|
2714
|
+
if (!element) return;
|
|
2715
|
+
const didSelectViaKeyboard = !validFrozenElement && validKeyboardSelectedElement === element;
|
|
2716
|
+
let positionX;
|
|
2717
|
+
let positionY;
|
|
2718
|
+
if (validFrozenElement) {
|
|
2719
|
+
positionX = store.pointer.x;
|
|
2720
|
+
positionY = store.pointer.y;
|
|
2721
|
+
} else if (didSelectViaKeyboard) {
|
|
2722
|
+
const elementCenter = getBoundsCenter(createElementBounds(element));
|
|
2723
|
+
positionX = elementCenter.x;
|
|
2724
|
+
positionY = elementCenter.y;
|
|
2725
|
+
} else {
|
|
2726
|
+
positionX = clientX;
|
|
2727
|
+
positionY = clientY;
|
|
2728
|
+
}
|
|
2729
|
+
keyboardSelectedElement = null;
|
|
2730
|
+
if (store.pendingCommentMode) {
|
|
2731
|
+
enterCommentModeForElement(element, positionX, positionY);
|
|
2732
|
+
return;
|
|
2733
|
+
}
|
|
2734
|
+
if (isPendingContextMenuSelect) {
|
|
2735
|
+
isPendingContextMenuSelect = false;
|
|
2736
|
+
const { wasIntercepted } = pluginRegistry.hooks.onElementSelect(element);
|
|
2737
|
+
if (wasIntercepted) return;
|
|
2738
|
+
freezeAllAnimations([element]);
|
|
2739
|
+
actions.setFrozenElement(element);
|
|
2740
|
+
const position = {
|
|
2741
|
+
x: positionX,
|
|
2742
|
+
y: positionY
|
|
2743
|
+
};
|
|
2744
|
+
actions.setPointer(position);
|
|
2745
|
+
actions.freeze();
|
|
2746
|
+
if (pendingDefaultActionId) runPendingDefaultAction(element, position);
|
|
2747
|
+
else openContextMenu(element, position);
|
|
2748
|
+
return;
|
|
2749
|
+
}
|
|
2750
|
+
const shouldDeactivateAfter = store.wasActivatedByToggle && !hasModifierKeyHeld;
|
|
2751
|
+
actions.setLastGrabbed(element);
|
|
2752
|
+
performCopyWithLabel({
|
|
2753
|
+
element,
|
|
2754
|
+
cursorX: positionX,
|
|
2755
|
+
shouldDeactivateAfter
|
|
2756
|
+
});
|
|
2757
|
+
};
|
|
2758
|
+
const cancelActiveDrag = () => {
|
|
2759
|
+
if (!isDragging()) return;
|
|
2760
|
+
actions.cancelDrag();
|
|
2761
|
+
autoScroller.stop();
|
|
2762
|
+
document.body.style.userSelect = "";
|
|
2763
|
+
};
|
|
2764
|
+
const handlePointerUp = (clientX, clientY, hasModifierKeyHeld) => {
|
|
2765
|
+
if (!isDragging()) return;
|
|
2766
|
+
if (dragPreviewDebounceTimerId !== null) {
|
|
2767
|
+
clearTimeout(dragPreviewDebounceTimerId);
|
|
2768
|
+
dragPreviewDebounceTimerId = null;
|
|
2769
|
+
}
|
|
2770
|
+
setDebouncedDragPointer(null);
|
|
2771
|
+
const dragDistance = calculateDragDistance(clientX, clientY);
|
|
2772
|
+
const wasDragGesture = dragDistance.x > 2 || dragDistance.y > 2;
|
|
2773
|
+
const dragSelectionRect = wasDragGesture ? calculateDragRectangle(clientX, clientY) : null;
|
|
2774
|
+
if (wasDragGesture) actions.endDrag();
|
|
2775
|
+
else actions.cancelDrag();
|
|
2776
|
+
autoScroller.stop();
|
|
2777
|
+
document.body.style.userSelect = "";
|
|
2778
|
+
if (dragSelectionRect) handleDragSelection(dragSelectionRect, hasModifierKeyHeld);
|
|
2779
|
+
else handleSingleClick(clientX, clientY, hasModifierKeyHeld);
|
|
2780
|
+
};
|
|
2781
|
+
const eventListenerManager = createEventListenerManager();
|
|
2782
|
+
const keyboardClaimer = setupKeyboardEventClaimer();
|
|
2783
|
+
const blockEnterIfNeeded = (event) => {
|
|
2784
|
+
let originalKey;
|
|
2785
|
+
try {
|
|
2786
|
+
originalKey = keyboardClaimer.originalKeyDescriptor?.get ? keyboardClaimer.originalKeyDescriptor.get.call(event) : event.key;
|
|
2787
|
+
} catch {
|
|
2788
|
+
return false;
|
|
2789
|
+
}
|
|
2790
|
+
const isEnterKey = originalKey === "Enter" || isEnterCode(event.code);
|
|
2791
|
+
const isOverlayActive = isActivated() || isHoldingKeys();
|
|
2792
|
+
if (isEnterKey && isOverlayActive && !isPromptMode() && !store.wasActivatedByToggle && clearPromptPosition() === null) {
|
|
2793
|
+
keyboardClaimer.claimedEvents.add(event);
|
|
2794
|
+
event.preventDefault();
|
|
2795
|
+
event.stopImmediatePropagation();
|
|
2796
|
+
return true;
|
|
2797
|
+
}
|
|
2798
|
+
return false;
|
|
2799
|
+
};
|
|
2800
|
+
eventListenerManager.addDocumentListener("keydown", blockEnterIfNeeded, { capture: true });
|
|
2801
|
+
eventListenerManager.addDocumentListener("keyup", blockEnterIfNeeded, { capture: true });
|
|
2802
|
+
eventListenerManager.addDocumentListener("keypress", blockEnterIfNeeded, { capture: true });
|
|
2803
|
+
const clearArrowNavigation = () => {
|
|
2804
|
+
setArrowNavigationElements([]);
|
|
2805
|
+
setArrowNavigationActiveIndex(0);
|
|
2806
|
+
arrowNavigator.clearHistory();
|
|
2807
|
+
};
|
|
2808
|
+
const selectAndFocusElement = (element) => {
|
|
2809
|
+
actions.setFrozenElement(element);
|
|
2810
|
+
actions.freeze();
|
|
2811
|
+
keyboardSelectedElement = element;
|
|
2812
|
+
const center = getBoundsCenter(createElementBounds(element));
|
|
2813
|
+
actions.setPointer(center);
|
|
2814
|
+
if (store.contextMenuPosition !== null) actions.showContextMenu(center, element);
|
|
2815
|
+
};
|
|
2816
|
+
const openArrowNavigationMenu = (anchorElement) => {
|
|
2817
|
+
const probePoint = getVisibleBoundsCenter(createElementBounds(anchorElement));
|
|
2818
|
+
const elementsAtPoint = getElementsAtPoint(probePoint.x, probePoint.y).filter(isValidGrabbableElement).reverse();
|
|
2819
|
+
setArrowNavigationElements(elementsAtPoint);
|
|
2820
|
+
setArrowNavigationActiveIndex(Math.max(0, elementsAtPoint.indexOf(anchorElement)));
|
|
2821
|
+
};
|
|
2822
|
+
const handleArrowNavigationSelect = (index) => {
|
|
2823
|
+
const targetElement = arrowNavigationElements()[index];
|
|
2824
|
+
if (!targetElement) return;
|
|
2825
|
+
setArrowNavigationActiveIndex(index);
|
|
2826
|
+
arrowNavigator.clearHistory();
|
|
2827
|
+
selectAndFocusElement(targetElement);
|
|
2828
|
+
};
|
|
2829
|
+
const handleArrowNavigation = (event) => {
|
|
2830
|
+
if (!isActivated() || isPromptMode()) return false;
|
|
2831
|
+
if (!ARROW_KEYS.has(event.key)) return false;
|
|
2832
|
+
let currentElement = effectiveElement();
|
|
2833
|
+
const isInitialSelection = !currentElement;
|
|
2834
|
+
if (!currentElement) currentElement = getElementAtPosition(window.innerWidth / 2, window.innerHeight / 2);
|
|
2835
|
+
if (!currentElement) return false;
|
|
2836
|
+
if (!(event.key === "ArrowUp" || event.key === "ArrowDown")) {
|
|
2837
|
+
clearArrowNavigation();
|
|
2838
|
+
const nextElement = arrowNavigator.findNext(event.key, currentElement);
|
|
2839
|
+
if (!nextElement && !isInitialSelection) return false;
|
|
2840
|
+
event.preventDefault();
|
|
2841
|
+
event.stopPropagation();
|
|
2842
|
+
selectAndFocusElement(nextElement ?? currentElement);
|
|
2843
|
+
return true;
|
|
2844
|
+
}
|
|
2845
|
+
if (arrowNavigationElements().length === 0) openArrowNavigationMenu(currentElement);
|
|
2846
|
+
const elementToSelect = arrowNavigator.findNext(event.key, currentElement) ?? currentElement;
|
|
2847
|
+
event.preventDefault();
|
|
2848
|
+
event.stopPropagation();
|
|
2849
|
+
selectAndFocusElement(elementToSelect);
|
|
2850
|
+
const newIndex = arrowNavigationElements().indexOf(elementToSelect);
|
|
2851
|
+
if (newIndex !== -1) setArrowNavigationActiveIndex(newIndex);
|
|
2852
|
+
else openArrowNavigationMenu(elementToSelect);
|
|
2853
|
+
return true;
|
|
2854
|
+
};
|
|
2855
|
+
const handleEnterKeyActivation = (event) => {
|
|
2856
|
+
if (!isEnterCode(event.code)) return false;
|
|
2857
|
+
if (isKeyboardEventTriggeredByInput(event)) return false;
|
|
2858
|
+
const copiedElement = store.lastCopiedElement;
|
|
2859
|
+
if (!isHoldingKeys() && !isPromptMode() && !isActivated() && copiedElement && isElementConnected(copiedElement) && !store.labelInstances.some((instance) => instance.status === "copied" || instance.status === "fading")) {
|
|
2860
|
+
event.preventDefault();
|
|
2861
|
+
event.stopImmediatePropagation();
|
|
2862
|
+
const center = getBoundsCenter(createElementBounds(copiedElement));
|
|
2863
|
+
actions.setPointer(center);
|
|
2864
|
+
preparePromptMode(copiedElement, center.x, center.y);
|
|
2865
|
+
actions.setFrozenElement(copiedElement);
|
|
2866
|
+
actions.clearLastCopied();
|
|
2867
|
+
activatePromptMode();
|
|
2868
|
+
if (!isActivated()) activateRenderer();
|
|
2869
|
+
return true;
|
|
2870
|
+
}
|
|
2871
|
+
if (isHoldingKeys() && !isPromptMode()) {
|
|
2872
|
+
event.preventDefault();
|
|
2873
|
+
event.stopImmediatePropagation();
|
|
2874
|
+
const element = store.frozenElement || targetElement();
|
|
2875
|
+
if (element) preparePromptMode(element, store.pointer.x, store.pointer.y);
|
|
2876
|
+
actions.setPointer({
|
|
2877
|
+
x: store.pointer.x,
|
|
2878
|
+
y: store.pointer.y
|
|
2879
|
+
});
|
|
2880
|
+
if (element) actions.setFrozenElement(element);
|
|
2881
|
+
activatePromptMode();
|
|
2882
|
+
if (keydownSpamTimerId !== null) {
|
|
2883
|
+
window.clearTimeout(keydownSpamTimerId);
|
|
2884
|
+
keydownSpamTimerId = null;
|
|
2885
|
+
}
|
|
2886
|
+
if (!isActivated()) activateRenderer();
|
|
2887
|
+
return true;
|
|
2888
|
+
}
|
|
2889
|
+
return false;
|
|
2890
|
+
};
|
|
2891
|
+
const handleOpenFileShortcut = (event) => {
|
|
2892
|
+
if (event.key?.toLowerCase() !== "o" || isPromptMode()) return false;
|
|
2893
|
+
if (!isActivated() || !(event.metaKey || event.ctrlKey)) return false;
|
|
2894
|
+
const filePath = store.selectionFilePath;
|
|
2895
|
+
const lineNumber = store.selectionLineNumber;
|
|
2896
|
+
if (!filePath) return false;
|
|
2897
|
+
event.preventDefault();
|
|
2898
|
+
event.stopPropagation();
|
|
2899
|
+
if (!pluginRegistry.hooks.onOpenFile(filePath, lineNumber ?? void 0)) openFile(filePath, lineNumber ?? void 0, pluginRegistry.hooks.transformOpenFileUrl);
|
|
2900
|
+
return true;
|
|
2901
|
+
};
|
|
2902
|
+
const clearActionCycleIdleTimeout = () => {
|
|
2903
|
+
if (actionCycleIdleTimeoutId !== null) {
|
|
2904
|
+
window.clearTimeout(actionCycleIdleTimeoutId);
|
|
2905
|
+
actionCycleIdleTimeoutId = null;
|
|
2906
|
+
}
|
|
2907
|
+
};
|
|
2908
|
+
const resetActionCycle = () => {
|
|
2909
|
+
clearActionCycleIdleTimeout();
|
|
2910
|
+
setActionCycleItems([]);
|
|
2911
|
+
setActionCycleActiveIndex(null);
|
|
2912
|
+
};
|
|
2913
|
+
const canCycleActions = createMemo(() => {
|
|
2914
|
+
const element = selectionElement();
|
|
2915
|
+
return Boolean(element) && isRendererActive() && !isPromptMode() && !isDragging() && store.contextMenuPosition === null;
|
|
2916
|
+
});
|
|
2917
|
+
const activationBaseKey = createMemo(() => {
|
|
2918
|
+
const { key } = getModifiersFromActivationKey(pluginRegistry.store.options.activationKey);
|
|
2919
|
+
return (key ?? "c").toUpperCase();
|
|
2920
|
+
});
|
|
2921
|
+
const actionCycleState = createMemo(() => ({
|
|
2922
|
+
items: actionCycleItems(),
|
|
2923
|
+
activeIndex: actionCycleActiveIndex(),
|
|
2924
|
+
isVisible: actionCycleActiveIndex() !== null && actionCycleItems().length > 0 && !isCommentMode()
|
|
2925
|
+
}));
|
|
2926
|
+
const arrowNavigationItems = createMemo(() => arrowNavigationElements().map((element) => ({
|
|
2927
|
+
tagName: getTagName(element) || "element",
|
|
2928
|
+
componentName: getComponentDisplayName(element) ?? void 0
|
|
2929
|
+
})));
|
|
2930
|
+
const arrowNavigationState = createMemo(() => ({
|
|
2931
|
+
items: arrowNavigationItems(),
|
|
2932
|
+
activeIndex: arrowNavigationActiveIndex(),
|
|
2933
|
+
isVisible: arrowNavigationElements().length > 0
|
|
2934
|
+
}));
|
|
2935
|
+
const inspectAncestorElements = createMemo(() => {
|
|
2936
|
+
if (!isInspectMode()) return [];
|
|
2937
|
+
const element = effectiveElement();
|
|
2938
|
+
if (!element) return [];
|
|
2939
|
+
return [...getAncestorElements(element).reverse(), element];
|
|
2940
|
+
});
|
|
2941
|
+
const inspectNavigationItems = createMemo(() => inspectAncestorElements().map((element) => ({
|
|
2942
|
+
tagName: getTagName(element) || "element",
|
|
2943
|
+
componentName: getComponentDisplayName(element) ?? void 0
|
|
2944
|
+
})));
|
|
2945
|
+
const [inspectActiveIndex, setInspectActiveIndex] = createSignal(-1);
|
|
2946
|
+
createEffect(on(inspectAncestorElements, (elements) => {
|
|
2947
|
+
setInspectActiveIndex(elements.length - 1);
|
|
2948
|
+
}));
|
|
2949
|
+
const inspectNavigationState = createMemo(() => {
|
|
2950
|
+
const elements = inspectAncestorElements();
|
|
2951
|
+
return {
|
|
2952
|
+
items: inspectNavigationItems(),
|
|
2953
|
+
activeIndex: inspectActiveIndex(),
|
|
2954
|
+
isVisible: isInspectMode() && elements.length > 0
|
|
2955
|
+
};
|
|
2956
|
+
});
|
|
2957
|
+
const handleInspectSelect = (index) => {
|
|
2958
|
+
setInspectActiveIndex(index);
|
|
2959
|
+
};
|
|
2960
|
+
createEffect(on(selectionElement, () => {
|
|
2961
|
+
resetActionCycle();
|
|
2962
|
+
}));
|
|
2963
|
+
createEffect(on(canCycleActions, (isEnabled) => {
|
|
2964
|
+
if (!isEnabled) resetActionCycle();
|
|
2965
|
+
}));
|
|
2966
|
+
const getActionById = (actionId) => pluginRegistry.store.actions.find((action) => action.id === actionId);
|
|
2967
|
+
const getActionCycleContext = () => {
|
|
2968
|
+
const element = selectionElement();
|
|
2969
|
+
if (!element) return void 0;
|
|
2970
|
+
const fallbackBounds = selectionBounds();
|
|
2971
|
+
return buildActionContext({
|
|
2972
|
+
element,
|
|
2973
|
+
filePath: store.selectionFilePath ?? void 0,
|
|
2974
|
+
lineNumber: store.selectionLineNumber ?? void 0,
|
|
2975
|
+
tagName: getTagName(element) || void 0,
|
|
2976
|
+
componentName: resolvedComponentName(),
|
|
2977
|
+
position: store.pointer,
|
|
2978
|
+
performWithFeedbackOptions: {
|
|
2979
|
+
fallbackBounds,
|
|
2980
|
+
fallbackSelectionBounds: fallbackBounds ? [fallbackBounds] : []
|
|
2981
|
+
},
|
|
2982
|
+
shouldDeferHideContextMenu: false,
|
|
2983
|
+
onBeforePrompt: resetActionCycle
|
|
2984
|
+
});
|
|
2985
|
+
};
|
|
2986
|
+
const availableActionCycleItems = createMemo(() => {
|
|
2987
|
+
if (!selectionElement()) return [];
|
|
2988
|
+
const cycleItems = [];
|
|
2989
|
+
for (const action of pluginRegistry.store.actions) {
|
|
2990
|
+
if (typeof action.enabled === "boolean" && !action.enabled) continue;
|
|
2991
|
+
if (action.shortcut && action.shortcut.toUpperCase() !== activationBaseKey()) continue;
|
|
2992
|
+
cycleItems.push({
|
|
2993
|
+
id: action.id,
|
|
2994
|
+
label: action.label,
|
|
2995
|
+
shortcut: action.shortcut
|
|
2996
|
+
});
|
|
2997
|
+
}
|
|
2998
|
+
return cycleItems;
|
|
2999
|
+
});
|
|
3000
|
+
const scheduleActionCycleActivation = () => {
|
|
3001
|
+
clearActionCycleIdleTimeout();
|
|
3002
|
+
actionCycleIdleTimeoutId = window.setTimeout(() => {
|
|
3003
|
+
actionCycleIdleTimeoutId = null;
|
|
3004
|
+
const activeIndex = actionCycleActiveIndex();
|
|
3005
|
+
const items = actionCycleItems();
|
|
3006
|
+
if (activeIndex === null || items.length === 0) return;
|
|
3007
|
+
const selectedItem = items[activeIndex];
|
|
3008
|
+
if (!selectedItem) return;
|
|
3009
|
+
const action = getActionById(selectedItem.id);
|
|
3010
|
+
if (!action) {
|
|
3011
|
+
resetActionCycle();
|
|
3012
|
+
return;
|
|
3013
|
+
}
|
|
3014
|
+
const context = getActionCycleContext();
|
|
3015
|
+
if (!context || !resolveActionEnabled(action, context)) {
|
|
3016
|
+
resetActionCycle();
|
|
3017
|
+
return;
|
|
3018
|
+
}
|
|
3019
|
+
resetActionCycle();
|
|
3020
|
+
if (action.onAction(context) instanceof Promise) {}
|
|
3021
|
+
}, 600);
|
|
3022
|
+
};
|
|
3023
|
+
const advanceActionCycle = () => {
|
|
3024
|
+
if (!canCycleActions()) return false;
|
|
3025
|
+
const cycleItems = availableActionCycleItems();
|
|
3026
|
+
if (cycleItems.length === 0) return false;
|
|
3027
|
+
setActionCycleItems(cycleItems);
|
|
3028
|
+
const currentIndex = actionCycleActiveIndex();
|
|
3029
|
+
setActionCycleActiveIndex(currentIndex !== null && currentIndex < cycleItems.length ? (currentIndex + 1) % cycleItems.length : 0);
|
|
3030
|
+
scheduleActionCycleActivation();
|
|
3031
|
+
return true;
|
|
3032
|
+
};
|
|
3033
|
+
const handleActionCycleKey = (event) => {
|
|
3034
|
+
if (!keyMatchesCode(activationBaseKey(), event.code)) return false;
|
|
3035
|
+
if (event.altKey || event.repeat) return false;
|
|
3036
|
+
if (isKeyboardEventTriggeredByInput(event)) return false;
|
|
3037
|
+
if (!advanceActionCycle()) return false;
|
|
3038
|
+
event.preventDefault();
|
|
3039
|
+
event.stopPropagation();
|
|
3040
|
+
if (event.metaKey || event.ctrlKey) event.stopImmediatePropagation();
|
|
3041
|
+
return true;
|
|
3042
|
+
};
|
|
3043
|
+
const handleActivationKeys = (event) => {
|
|
3044
|
+
if (!pluginRegistry.store.options.allowActivationInsideInput && isKeyboardEventTriggeredByInput(event)) return;
|
|
3045
|
+
if (!isTargetKeyCombination(event, pluginRegistry.store.options)) {
|
|
3046
|
+
if ((event.metaKey || event.ctrlKey) && !MODIFIER_KEYS.includes(event.key) && !isEnterCode(event.code)) {
|
|
3047
|
+
if (isActivated() && !store.wasActivatedByToggle) deactivateRenderer();
|
|
3048
|
+
else if (isHoldingKeys()) {
|
|
3049
|
+
clearHoldTimer();
|
|
3050
|
+
resetCopyConfirmation();
|
|
3051
|
+
actions.releaseHold();
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
if (!isEnterCode(event.code) || !isHoldingKeys()) return;
|
|
3055
|
+
}
|
|
3056
|
+
if ((isActivated() || isHoldingKeys()) && !isPromptMode()) {
|
|
3057
|
+
event.preventDefault();
|
|
3058
|
+
if (isEnterCode(event.code)) event.stopImmediatePropagation();
|
|
3059
|
+
}
|
|
3060
|
+
if (isActivated()) {
|
|
3061
|
+
if (store.wasActivatedByToggle && pluginRegistry.store.options.activationMode !== "hold") return;
|
|
3062
|
+
if (event.repeat) return;
|
|
3063
|
+
if (keydownSpamTimerId !== null) window.clearTimeout(keydownSpamTimerId);
|
|
3064
|
+
keydownSpamTimerId = window.setTimeout(() => {
|
|
3065
|
+
deactivateRenderer();
|
|
3066
|
+
}, 200);
|
|
3067
|
+
return;
|
|
3068
|
+
}
|
|
3069
|
+
if (isHoldingKeys() && event.repeat) {
|
|
3070
|
+
if (activationHoldState.copyWaiting) {
|
|
3071
|
+
const shouldActivate = activationHoldState.holdTimerFired;
|
|
3072
|
+
resetCopyConfirmation();
|
|
3073
|
+
if (shouldActivate) actions.activate();
|
|
3074
|
+
}
|
|
3075
|
+
return;
|
|
3076
|
+
}
|
|
3077
|
+
if (isCopying() || didJustCopy()) return;
|
|
3078
|
+
if (!isHoldingKeys()) {
|
|
3079
|
+
let activationDuration = pluginRegistry.store.options.keyHoldDuration ?? 100;
|
|
3080
|
+
if (isKeyboardEventTriggeredByInput(event)) if (hasTextSelectionInInput(event)) activationDuration += 600;
|
|
3081
|
+
else activationDuration += 400;
|
|
3082
|
+
else if (hasTextSelectionOnPage()) activationDuration += 600;
|
|
3083
|
+
resetCopyConfirmation();
|
|
3084
|
+
actions.startHold(activationDuration);
|
|
3085
|
+
}
|
|
3086
|
+
};
|
|
3087
|
+
eventListenerManager.addWindowListener("keydown", (event) => {
|
|
3088
|
+
blockEnterIfNeeded(event);
|
|
3089
|
+
if (event.key === "Shift" && !event.repeat && isActivated()) {
|
|
3090
|
+
setIsInspectMode(true);
|
|
3091
|
+
if (isFrozenPhase()) {
|
|
3092
|
+
actions.unfreeze();
|
|
3093
|
+
clearArrowNavigation();
|
|
3094
|
+
}
|
|
3095
|
+
}
|
|
3096
|
+
if (!isEnabled()) {
|
|
3097
|
+
if (isTargetKeyCombination(event, pluginRegistry.store.options) && !event.repeat) setToolbarShakeCount((count) => count + 1);
|
|
3098
|
+
return;
|
|
3099
|
+
}
|
|
3100
|
+
const isEnterToActivateInput = isEnterCode(event.code) && isHoldingKeys() && !isPromptMode();
|
|
3101
|
+
const isFromReactGrabInput = isEventFromOverlay(event, "data-react-grab-input");
|
|
3102
|
+
if (isPromptMode() && isTargetKeyCombination(event, pluginRegistry.store.options) && !event.repeat && !isFromReactGrabInput) {
|
|
3103
|
+
event.preventDefault();
|
|
3104
|
+
event.stopPropagation();
|
|
3105
|
+
handleInputCancel();
|
|
3106
|
+
return;
|
|
3107
|
+
}
|
|
3108
|
+
if (event.key === "Escape" && clearPromptPosition() !== null) return;
|
|
3109
|
+
if (event.key === "Escape" && commentsDropdownPosition() !== null) {
|
|
3110
|
+
dismissCommentsDropdown();
|
|
3111
|
+
return;
|
|
3112
|
+
}
|
|
3113
|
+
if (event.key === "Escape" && toolbarMenuPosition() !== null) {
|
|
3114
|
+
dismissToolbarMenu();
|
|
3115
|
+
return;
|
|
3116
|
+
}
|
|
3117
|
+
const isFromOverlay = isEventFromOverlay(event, "data-react-grab-ignore-events") && !isEnterToActivateInput;
|
|
3118
|
+
if (isPromptMode() || isFromOverlay) {
|
|
3119
|
+
if (event.key === "Escape") {
|
|
3120
|
+
if (isPromptMode()) handleInputCancel();
|
|
3121
|
+
else if (store.wasActivatedByToggle) deactivateRenderer();
|
|
3122
|
+
}
|
|
3123
|
+
if (isFromOverlay && ARROW_KEYS.has(event.key)) {
|
|
3124
|
+
if (handleArrowNavigation(event)) return;
|
|
3125
|
+
}
|
|
3126
|
+
return;
|
|
3127
|
+
}
|
|
3128
|
+
if (event.key === "Escape") {
|
|
3129
|
+
if (isHoldingKeys() || store.wasActivatedByToggle) {
|
|
3130
|
+
deactivateRenderer();
|
|
3131
|
+
return;
|
|
3132
|
+
}
|
|
3133
|
+
}
|
|
3134
|
+
const didWindowJustRegainFocus = Date.now() - lastWindowFocusTimestamp < 200;
|
|
3135
|
+
if (!didWindowJustRegainFocus && handleActionCycleKey(event)) return;
|
|
3136
|
+
if (handleArrowNavigation(event)) return;
|
|
3137
|
+
if (handleEnterKeyActivation(event)) return;
|
|
3138
|
+
if (handleOpenFileShortcut(event)) return;
|
|
3139
|
+
if (!didWindowJustRegainFocus) handleActivationKeys(event);
|
|
3140
|
+
}, { capture: true });
|
|
3141
|
+
eventListenerManager.addWindowListener("keyup", (event) => {
|
|
3142
|
+
if (blockEnterIfNeeded(event)) return;
|
|
3143
|
+
if (event.key === "Shift") setIsInspectMode(false);
|
|
3144
|
+
const requiredModifiers = getRequiredModifiers(pluginRegistry.store.options);
|
|
3145
|
+
const isReleasingModifier = requiredModifiers.metaKey || requiredModifiers.ctrlKey ? isMac() ? !event.metaKey : !event.ctrlKey : requiredModifiers.shiftKey && !event.shiftKey || requiredModifiers.altKey && !event.altKey;
|
|
3146
|
+
const isReleasingActivationKey = pluginRegistry.store.options.activationKey ? typeof pluginRegistry.store.options.activationKey === "function" ? pluginRegistry.store.options.activationKey(event) : parseActivationKey(pluginRegistry.store.options.activationKey)(event) : isCLikeKey(event.key, event.code);
|
|
3147
|
+
if (didJustCopy() || isCopyFeedbackCooldownActive) {
|
|
3148
|
+
if (isReleasingActivationKey || isReleasingModifier) {
|
|
3149
|
+
clearCopyFeedbackCooldown();
|
|
3150
|
+
deactivateRenderer();
|
|
3151
|
+
}
|
|
3152
|
+
return;
|
|
3153
|
+
}
|
|
3154
|
+
if (!isHoldingKeys() && !isActivated()) return;
|
|
3155
|
+
if (isPromptMode()) return;
|
|
3156
|
+
const hasCustomShortcut = Boolean(pluginRegistry.store.options.activationKey);
|
|
3157
|
+
const isHoldMode = pluginRegistry.store.options.activationMode === "hold";
|
|
3158
|
+
if (isActivated()) {
|
|
3159
|
+
const hasContextMenu = store.contextMenuPosition !== null;
|
|
3160
|
+
if (isReleasingModifier) {
|
|
3161
|
+
if (store.wasActivatedByToggle && pluginRegistry.store.options.activationMode !== "hold") return;
|
|
3162
|
+
if (hasContextMenu) return;
|
|
3163
|
+
deactivateRenderer();
|
|
3164
|
+
} else if (isHoldMode && isReleasingActivationKey) {
|
|
3165
|
+
if (keydownSpamTimerId !== null) {
|
|
3166
|
+
window.clearTimeout(keydownSpamTimerId);
|
|
3167
|
+
keydownSpamTimerId = null;
|
|
3168
|
+
}
|
|
3169
|
+
if (hasContextMenu) return;
|
|
3170
|
+
deactivateRenderer();
|
|
3171
|
+
} else if (!hasCustomShortcut && isReleasingActivationKey && keydownSpamTimerId !== null) {
|
|
3172
|
+
window.clearTimeout(keydownSpamTimerId);
|
|
3173
|
+
keydownSpamTimerId = null;
|
|
3174
|
+
}
|
|
3175
|
+
return;
|
|
3176
|
+
}
|
|
3177
|
+
if (isReleasingActivationKey || isReleasingModifier) {
|
|
3178
|
+
if (store.wasActivatedByToggle && pluginRegistry.store.options.activationMode !== "hold") return;
|
|
3179
|
+
if (isHoldingKeys() || activationHoldState.holdTimerFired && isReleasingModifier) {
|
|
3180
|
+
clearHoldTimer();
|
|
3181
|
+
const heldLongEnoughForActivation = (activationHoldState.startTimestamp ? Date.now() - activationHoldState.startTimestamp : 0) >= 200;
|
|
3182
|
+
const shouldActivateAfterCopy = activationHoldState.holdTimerFired && heldLongEnoughForActivation && (pluginRegistry.store.options.allowActivationInsideInput || !isKeyboardEventTriggeredByInput(event));
|
|
3183
|
+
resetCopyConfirmation();
|
|
3184
|
+
if (shouldActivateAfterCopy) actions.activate();
|
|
3185
|
+
else actions.releaseHold();
|
|
3186
|
+
} else deactivateRenderer();
|
|
3187
|
+
}
|
|
3188
|
+
}, { capture: true });
|
|
3189
|
+
eventListenerManager.addDocumentListener("copy", () => {
|
|
3190
|
+
if (isHoldingKeys()) activationHoldState.copyWaiting = true;
|
|
3191
|
+
});
|
|
3192
|
+
eventListenerManager.addWindowListener("keypress", blockEnterIfNeeded, { capture: true });
|
|
3193
|
+
eventListenerManager.addWindowListener("pointermove", (event) => {
|
|
3194
|
+
if (!event.isPrimary) return;
|
|
3195
|
+
const isTouchPointer = event.pointerType === "touch";
|
|
3196
|
+
actions.setTouchMode(isTouchPointer);
|
|
3197
|
+
if (isEventFromOverlay(event, "data-react-grab-ignore-events")) return;
|
|
3198
|
+
if (store.contextMenuPosition !== null) return;
|
|
3199
|
+
if (isTouchPointer && !isHoldingKeys() && !isActivated()) return;
|
|
3200
|
+
if ((isTouchPointer ? isHoldingKeys() : isActivated()) && !isPromptMode() && isFrozenPhase()) {
|
|
3201
|
+
actions.unfreeze();
|
|
3202
|
+
clearArrowNavigation();
|
|
3203
|
+
}
|
|
3204
|
+
handlePointerMove(event.clientX, event.clientY);
|
|
3205
|
+
}, { passive: true });
|
|
3206
|
+
eventListenerManager.addWindowListener("pointerdown", (event) => {
|
|
3207
|
+
if (event.button !== 0) return;
|
|
3208
|
+
if (!event.isPrimary) return;
|
|
3209
|
+
actions.setTouchMode(event.pointerType === "touch");
|
|
3210
|
+
if (isEventFromOverlay(event, "data-react-grab-ignore-events")) return;
|
|
3211
|
+
if (store.contextMenuPosition !== null) return;
|
|
3212
|
+
if (toolbarMenuPosition() !== null) return;
|
|
3213
|
+
if (isPromptMode()) {
|
|
3214
|
+
const bounds = selectionBounds();
|
|
3215
|
+
if (bounds && event.clientX >= bounds.x && event.clientX <= bounds.x + bounds.width && event.clientY >= bounds.y && event.clientY <= bounds.y + bounds.height) handleInputSubmit();
|
|
3216
|
+
else handleInputCancel();
|
|
3217
|
+
return;
|
|
3218
|
+
}
|
|
3219
|
+
if (handlePointerDown(event.clientX, event.clientY)) {
|
|
3220
|
+
document.documentElement.setPointerCapture(event.pointerId);
|
|
3221
|
+
event.preventDefault();
|
|
3222
|
+
event.stopImmediatePropagation();
|
|
3223
|
+
}
|
|
3224
|
+
}, { capture: true });
|
|
3225
|
+
eventListenerManager.addWindowListener("pointerup", (event) => {
|
|
3226
|
+
if (event.button !== 0) return;
|
|
3227
|
+
if (!event.isPrimary) return;
|
|
3228
|
+
if (isEventFromOverlay(event, "data-react-grab-ignore-events")) return;
|
|
3229
|
+
if (store.contextMenuPosition !== null) return;
|
|
3230
|
+
const isActive = isRendererActive() || isCopying() || isDragging();
|
|
3231
|
+
const hasModifierKeyHeld = event.metaKey || event.ctrlKey;
|
|
3232
|
+
handlePointerUp(event.clientX, event.clientY, hasModifierKeyHeld);
|
|
3233
|
+
if (isActive) {
|
|
3234
|
+
event.preventDefault();
|
|
3235
|
+
event.stopImmediatePropagation();
|
|
3236
|
+
}
|
|
3237
|
+
}, { capture: true });
|
|
3238
|
+
eventListenerManager.addWindowListener("contextmenu", (event) => {
|
|
3239
|
+
if (!isRendererActive() || isCopying() || isPromptMode()) return;
|
|
3240
|
+
const isFromOverlay = isEventFromOverlay(event, "data-react-grab-ignore-events");
|
|
3241
|
+
if (isFromOverlay && arrowNavigationElements().length > 0) clearArrowNavigation();
|
|
3242
|
+
else if (isFromOverlay) return;
|
|
3243
|
+
if (store.contextMenuPosition !== null) {
|
|
3244
|
+
event.preventDefault();
|
|
3245
|
+
return;
|
|
3246
|
+
}
|
|
3247
|
+
event.preventDefault();
|
|
3248
|
+
event.stopPropagation();
|
|
3249
|
+
const element = getElementAtPosition(event.clientX, event.clientY);
|
|
3250
|
+
if (!element) return;
|
|
3251
|
+
const existingFrozenElements = store.frozenElements;
|
|
3252
|
+
if (existingFrozenElements.length > 1 && existingFrozenElements.includes(element)) freezeAllAnimations(existingFrozenElements);
|
|
3253
|
+
else {
|
|
3254
|
+
freezeAllAnimations([element]);
|
|
3255
|
+
actions.setFrozenElement(element);
|
|
3256
|
+
}
|
|
3257
|
+
const position = {
|
|
3258
|
+
x: event.clientX,
|
|
3259
|
+
y: event.clientY
|
|
3260
|
+
};
|
|
3261
|
+
actions.setPointer(position);
|
|
3262
|
+
actions.freeze();
|
|
3263
|
+
openContextMenu(element, position);
|
|
3264
|
+
}, { capture: true });
|
|
3265
|
+
eventListenerManager.addWindowListener("pointercancel", (event) => {
|
|
3266
|
+
if (!event.isPrimary) return;
|
|
3267
|
+
cancelActiveDrag();
|
|
3268
|
+
});
|
|
3269
|
+
eventListenerManager.addWindowListener("click", (event) => {
|
|
3270
|
+
if (isEventFromOverlay(event, "data-react-grab-ignore-events")) return;
|
|
3271
|
+
if (store.contextMenuPosition !== null) return;
|
|
3272
|
+
if (isRendererActive() || isCopying() || didJustDrag()) {
|
|
3273
|
+
event.preventDefault();
|
|
3274
|
+
event.stopImmediatePropagation();
|
|
3275
|
+
if (store.wasActivatedByToggle && !isCopying() && !isPromptMode()) if (!isHoldingKeys()) deactivateRenderer();
|
|
3276
|
+
else actions.setWasActivatedByToggle(false);
|
|
3277
|
+
}
|
|
3278
|
+
}, { capture: true });
|
|
3279
|
+
eventListenerManager.addDocumentListener("visibilitychange", () => {
|
|
3280
|
+
if (document.hidden) {
|
|
3281
|
+
actions.clearGrabbedBoxes();
|
|
3282
|
+
const storeActivationTimestamp = store.activationTimestamp;
|
|
3283
|
+
if (isActivated() && !isPromptMode() && storeActivationTimestamp !== null && Date.now() - storeActivationTimestamp > 500) deactivateRenderer();
|
|
3284
|
+
}
|
|
3285
|
+
});
|
|
3286
|
+
eventListenerManager.addWindowListener("blur", () => {
|
|
3287
|
+
cancelActiveDrag();
|
|
3288
|
+
if (isHoldingKeys()) {
|
|
3289
|
+
clearHoldTimer();
|
|
3290
|
+
actions.releaseHold();
|
|
3291
|
+
resetCopyConfirmation();
|
|
3292
|
+
}
|
|
3293
|
+
});
|
|
3294
|
+
eventListenerManager.addWindowListener("focus", () => {
|
|
3295
|
+
lastWindowFocusTimestamp = Date.now();
|
|
3296
|
+
});
|
|
3297
|
+
eventListenerManager.addWindowListener("focusin", (event) => {
|
|
3298
|
+
if (isEventFromOverlay(event, "data-react-grab")) event.stopPropagation();
|
|
3299
|
+
}, { capture: true });
|
|
3300
|
+
const redetectElementUnderPointer = () => {
|
|
3301
|
+
if (store.isTouchMode && !isHoldingKeys() && !isActivated()) return;
|
|
3302
|
+
if (isEnabled() && !isPromptMode() && !isFrozenPhase() && !isDragging() && store.contextMenuPosition === null && store.frozenElements.length === 0) {
|
|
3303
|
+
const candidate = getElementAtPosition(store.pointer.x, store.pointer.y);
|
|
3304
|
+
actions.setDetectedElement(candidate);
|
|
3305
|
+
}
|
|
3306
|
+
};
|
|
3307
|
+
let boundsRecalcIntervalId = null;
|
|
3308
|
+
let viewportChangeFrameId = null;
|
|
3309
|
+
const handleViewportChange = () => {
|
|
3310
|
+
invalidateInteractionCaches();
|
|
3311
|
+
redetectElementUnderPointer();
|
|
3312
|
+
actions.incrementViewportVersion();
|
|
3313
|
+
actions.updateContextMenuPosition();
|
|
3314
|
+
};
|
|
3315
|
+
eventListenerManager.addWindowListener("scroll", handleViewportChange, { capture: true });
|
|
3316
|
+
let previousViewportWidth = window.innerWidth;
|
|
3317
|
+
let previousViewportHeight = window.innerHeight;
|
|
3318
|
+
eventListenerManager.addWindowListener("resize", () => {
|
|
3319
|
+
const currentViewportWidth = window.innerWidth;
|
|
3320
|
+
const currentViewportHeight = window.innerHeight;
|
|
3321
|
+
if (previousViewportWidth > 0 && previousViewportHeight > 0) {
|
|
3322
|
+
const scaleX = currentViewportWidth / previousViewportWidth;
|
|
3323
|
+
const scaleY = currentViewportHeight / previousViewportHeight;
|
|
3324
|
+
const isUniformScale = Math.abs(scaleX - scaleY) < ZOOM_DETECTION_THRESHOLD;
|
|
3325
|
+
const hasScaleChanged = Math.abs(scaleX - 1) > ZOOM_DETECTION_THRESHOLD;
|
|
3326
|
+
if (isUniformScale && hasScaleChanged) actions.setPointer({
|
|
3327
|
+
x: store.pointer.x * scaleX,
|
|
3328
|
+
y: store.pointer.y * scaleY
|
|
3329
|
+
});
|
|
3330
|
+
}
|
|
3331
|
+
previousViewportWidth = currentViewportWidth;
|
|
3332
|
+
previousViewportHeight = currentViewportHeight;
|
|
3333
|
+
handleViewportChange();
|
|
3334
|
+
});
|
|
3335
|
+
const visualViewport = window.visualViewport;
|
|
3336
|
+
if (visualViewport) {
|
|
3337
|
+
const { signal } = eventListenerManager;
|
|
3338
|
+
visualViewport.addEventListener("resize", handleViewportChange, { signal });
|
|
3339
|
+
visualViewport.addEventListener("scroll", handleViewportChange, { signal });
|
|
3340
|
+
}
|
|
3341
|
+
const scheduleBoundsSync = () => {
|
|
3342
|
+
if (viewportChangeFrameId !== null) return;
|
|
3343
|
+
viewportChangeFrameId = nativeRequestAnimationFrame(() => {
|
|
3344
|
+
viewportChangeFrameId = null;
|
|
3345
|
+
actions.incrementViewportVersion();
|
|
3346
|
+
});
|
|
3347
|
+
};
|
|
3348
|
+
createEffect(() => {
|
|
3349
|
+
if (pluginRegistry.store.theme.enabled && (isActivated() || isCopying() || store.labelInstances.length > 0 || store.grabbedBoxes.length > 0)) {
|
|
3350
|
+
if (boundsRecalcIntervalId !== null) return;
|
|
3351
|
+
boundsRecalcIntervalId = window.setInterval(() => {
|
|
3352
|
+
scheduleBoundsSync();
|
|
3353
|
+
}, 100);
|
|
3354
|
+
return;
|
|
3355
|
+
}
|
|
3356
|
+
if (boundsRecalcIntervalId !== null) {
|
|
3357
|
+
window.clearInterval(boundsRecalcIntervalId);
|
|
3358
|
+
boundsRecalcIntervalId = null;
|
|
3359
|
+
}
|
|
3360
|
+
if (viewportChangeFrameId !== null) {
|
|
3361
|
+
nativeCancelAnimationFrame(viewportChangeFrameId);
|
|
3362
|
+
viewportChangeFrameId = null;
|
|
3363
|
+
}
|
|
3364
|
+
});
|
|
3365
|
+
onCleanup(() => {
|
|
3366
|
+
if (boundsRecalcIntervalId !== null) window.clearInterval(boundsRecalcIntervalId);
|
|
3367
|
+
if (viewportChangeFrameId !== null) nativeCancelAnimationFrame(viewportChangeFrameId);
|
|
3368
|
+
});
|
|
3369
|
+
eventListenerManager.addDocumentListener("copy", (event) => {
|
|
3370
|
+
if (isPromptMode() || isEventFromOverlay(event, "data-react-grab-ignore-events")) return;
|
|
3371
|
+
if (isRendererActive() || isCopying()) event.preventDefault();
|
|
3372
|
+
}, { capture: true });
|
|
3373
|
+
onCleanup(() => {
|
|
3374
|
+
eventListenerManager.abort();
|
|
3375
|
+
if (dragPreviewDebounceTimerId !== null) window.clearTimeout(dragPreviewDebounceTimerId);
|
|
3376
|
+
if (keydownSpamTimerId) window.clearTimeout(keydownSpamTimerId);
|
|
3377
|
+
clearCopyFeedbackCooldown();
|
|
3378
|
+
if (actionCycleIdleTimeoutId) window.clearTimeout(actionCycleIdleTimeoutId);
|
|
3379
|
+
if (dropdownTrackingFrameId !== null) nativeCancelAnimationFrame(dropdownTrackingFrameId);
|
|
3380
|
+
grabbedBoxTimeouts.forEach((timeoutId) => window.clearTimeout(timeoutId));
|
|
3381
|
+
grabbedBoxTimeouts.clear();
|
|
3382
|
+
cancelAllLabelFades();
|
|
3383
|
+
autoScroller.stop();
|
|
3384
|
+
document.body.style.userSelect = "";
|
|
3385
|
+
document.body.style.touchAction = "";
|
|
3386
|
+
unlockViewportZoom?.();
|
|
3387
|
+
unlockViewportZoom = null;
|
|
3388
|
+
setCursorOverride(null);
|
|
3389
|
+
keyboardClaimer.restore();
|
|
3390
|
+
});
|
|
3391
|
+
const rendererRoot = mountRoot(typeof "/*! tailwindcss v4.1.17 | MIT License | https://tailwindcss.com */\n@layer properties;\n@layer theme, base, components, utilities;\n@layer theme {\n :root, :host {\n --font-sans: \"Geist\", ui-sans-serif, system-ui, sans-serif;\n --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\",\n \"Courier New\", monospace;\n --color-black: #000;\n --color-white: #fff;\n --spacing: 0.25rem;\n --font-weight-medium: 500;\n --font-weight-semibold: 600;\n --radius-sm: 0.25rem;\n --ease-out: cubic-bezier(0, 0, 0.2, 1);\n --default-transition-duration: 150ms;\n --default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n --default-font-family: var(--font-sans);\n --default-mono-font-family: var(--font-mono);\n --transition-fast: 100ms;\n --transition-normal: 150ms;\n }\n}\n@layer base {\n *, ::after, ::before, ::backdrop, ::file-selector-button {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n border: 0 solid;\n }\n html, :host {\n line-height: 1.5;\n -webkit-text-size-adjust: 100%;\n tab-size: 4;\n font-family: var(--default-font-family, ui-sans-serif, system-ui, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\");\n font-feature-settings: var(--default-font-feature-settings, normal);\n font-variation-settings: var(--default-font-variation-settings, normal);\n -webkit-tap-highlight-color: transparent;\n }\n hr {\n height: 0;\n color: inherit;\n border-top-width: 1px;\n }\n abbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n }\n h1, h2, h3, h4, h5, h6 {\n font-size: inherit;\n font-weight: inherit;\n }\n a {\n color: inherit;\n -webkit-text-decoration: inherit;\n text-decoration: inherit;\n }\n b, strong {\n font-weight: bolder;\n }\n code, kbd, samp, pre {\n font-family: var(--default-mono-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace);\n font-feature-settings: var(--default-mono-font-feature-settings, normal);\n font-variation-settings: var(--default-mono-font-variation-settings, normal);\n font-size: 1em;\n }\n small {\n font-size: 80%;\n }\n sub, sup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n }\n sub {\n bottom: -0.25em;\n }\n sup {\n top: -0.5em;\n }\n table {\n text-indent: 0;\n border-color: inherit;\n border-collapse: collapse;\n }\n :-moz-focusring {\n outline: auto;\n }\n progress {\n vertical-align: baseline;\n }\n summary {\n display: list-item;\n }\n ol, ul, menu {\n list-style: none;\n }\n img, svg, video, canvas, audio, iframe, embed, object {\n display: block;\n vertical-align: middle;\n }\n img, video {\n max-width: 100%;\n height: auto;\n }\n button, input, select, optgroup, textarea, ::file-selector-button {\n font: inherit;\n font-feature-settings: inherit;\n font-variation-settings: inherit;\n letter-spacing: inherit;\n color: inherit;\n border-radius: 0;\n background-color: transparent;\n opacity: 1;\n }\n :where(select:is([multiple], [size])) optgroup {\n font-weight: bolder;\n }\n :where(select:is([multiple], [size])) optgroup option {\n padding-inline-start: 20px;\n }\n ::file-selector-button {\n margin-inline-end: 4px;\n }\n ::placeholder {\n opacity: 1;\n }\n @supports (not (-webkit-appearance: -apple-pay-button)) or (contain-intrinsic-size: 1px) {\n ::placeholder {\n color: currentcolor;\n @supports (color: color-mix(in lab, red, red)) {\n color: color-mix(in oklab, currentcolor 50%, transparent);\n }\n }\n }\n textarea {\n resize: vertical;\n }\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n ::-webkit-date-and-time-value {\n min-height: 1lh;\n text-align: inherit;\n }\n ::-webkit-datetime-edit {\n display: inline-flex;\n }\n ::-webkit-datetime-edit-fields-wrapper {\n padding: 0;\n }\n ::-webkit-datetime-edit, ::-webkit-datetime-edit-year-field, ::-webkit-datetime-edit-month-field, ::-webkit-datetime-edit-day-field, ::-webkit-datetime-edit-hour-field, ::-webkit-datetime-edit-minute-field, ::-webkit-datetime-edit-second-field, ::-webkit-datetime-edit-millisecond-field, ::-webkit-datetime-edit-meridiem-field {\n padding-block: 0;\n }\n ::-webkit-calendar-picker-indicator {\n line-height: 1;\n }\n :-moz-ui-invalid {\n box-shadow: none;\n }\n button, input:where([type=\"button\"], [type=\"reset\"], [type=\"submit\"]), ::file-selector-button {\n appearance: button;\n }\n ::-webkit-inner-spin-button, ::-webkit-outer-spin-button {\n height: auto;\n }\n [hidden]:where(:not([hidden=\"until-found\"])) {\n display: none !important;\n }\n}\n@layer utilities {\n .pointer-events-auto {\n pointer-events: auto;\n }\n .pointer-events-none {\n pointer-events: none;\n }\n .invisible {\n visibility: hidden;\n }\n .visible {\n visibility: visible;\n }\n .touch-hitbox {\n position: relative;\n &::before {\n content: \"\";\n position: absolute;\n display: block;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 100%;\n height: 100%;\n min-height: 44px;\n min-width: 44px;\n }\n }\n .absolute {\n position: absolute;\n }\n .fixed {\n position: fixed;\n }\n .relative {\n position: relative;\n }\n .-top-1 {\n top: calc(var(--spacing) * -1);\n }\n .top-0 {\n top: calc(var(--spacing) * 0);\n }\n .top-0\\.5 {\n top: calc(var(--spacing) * 0.5);\n }\n .top-1\\/2 {\n top: calc(1/2 * 100%);\n }\n .top-full {\n top: 100%;\n }\n .-right-1 {\n right: calc(var(--spacing) * -1);\n }\n .right-full {\n right: 100%;\n }\n .bottom-full {\n bottom: 100%;\n }\n .left-0 {\n left: calc(var(--spacing) * 0);\n }\n .left-0\\.5 {\n left: calc(var(--spacing) * 0.5);\n }\n .left-1\\.5 {\n left: calc(var(--spacing) * 1.5);\n }\n .left-1\\/2 {\n left: calc(1/2 * 100%);\n }\n .left-2\\.5 {\n left: calc(var(--spacing) * 2.5);\n }\n .left-full {\n left: 100%;\n }\n .z-1 {\n z-index: 1;\n }\n .z-10 {\n z-index: 10;\n }\n .container {\n width: 100%;\n @media (width >= 40rem) {\n max-width: 40rem;\n }\n @media (width >= 48rem) {\n max-width: 48rem;\n }\n @media (width >= 64rem) {\n max-width: 64rem;\n }\n @media (width >= 80rem) {\n max-width: 80rem;\n }\n @media (width >= 96rem) {\n max-width: 96rem;\n }\n }\n .m-0 {\n margin: calc(var(--spacing) * 0);\n }\n .-mx-2 {\n margin-inline: calc(var(--spacing) * -2);\n }\n .mx-0\\.5 {\n margin-inline: calc(var(--spacing) * 0.5);\n }\n .-my-1\\.5 {\n margin-block: calc(var(--spacing) * -1.5);\n }\n .my-0\\.5 {\n margin-block: calc(var(--spacing) * 0.5);\n }\n .mt-0\\.5 {\n margin-top: calc(var(--spacing) * 0.5);\n }\n .mt-2\\.5 {\n margin-top: calc(var(--spacing) * 2.5);\n }\n .mr-0\\.5 {\n margin-right: calc(var(--spacing) * 0.5);\n }\n .mr-1\\.5 {\n margin-right: calc(var(--spacing) * 1.5);\n }\n .mr-2\\.5 {\n margin-right: calc(var(--spacing) * 2.5);\n }\n .mb-0\\.5 {\n margin-bottom: calc(var(--spacing) * 0.5);\n }\n .mb-1\\.5 {\n margin-bottom: calc(var(--spacing) * 1.5);\n }\n .mb-2\\.5 {\n margin-bottom: calc(var(--spacing) * 2.5);\n }\n .-ml-\\[2px\\] {\n margin-left: calc(2px * -1);\n }\n .ml-0\\.5 {\n margin-left: calc(var(--spacing) * 0.5);\n }\n .ml-1 {\n margin-left: calc(var(--spacing) * 1);\n }\n .ml-2\\.5 {\n margin-left: calc(var(--spacing) * 2.5);\n }\n .ml-4 {\n margin-left: calc(var(--spacing) * 4);\n }\n .line-clamp-5 {\n overflow: hidden;\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 5;\n }\n .block {\n display: block;\n }\n .flex {\n display: flex;\n }\n .grid {\n display: grid;\n }\n .hidden {\n display: none;\n }\n .inline {\n display: inline;\n }\n .inline-flex {\n display: inline-flex;\n }\n .size-4 {\n width: calc(var(--spacing) * 4);\n height: calc(var(--spacing) * 4);\n }\n .size-\\[18px\\] {\n width: 18px;\n height: 18px;\n }\n .h-0 {\n height: calc(var(--spacing) * 0);\n }\n .h-1\\.5 {\n height: calc(var(--spacing) * 1.5);\n }\n .h-2 {\n height: calc(var(--spacing) * 2);\n }\n .h-2\\.5 {\n height: calc(var(--spacing) * 2.5);\n }\n .h-3 {\n height: calc(var(--spacing) * 3);\n }\n .h-3\\.5 {\n height: calc(var(--spacing) * 3.5);\n }\n .h-\\[17px\\] {\n height: 17px;\n }\n .h-fit {\n height: fit-content;\n }\n .max-h-\\[240px\\] {\n max-height: 240px;\n }\n .min-h-0 {\n min-height: calc(var(--spacing) * 0);\n }\n .min-h-4 {\n min-height: calc(var(--spacing) * 4);\n }\n .w-0 {\n width: calc(var(--spacing) * 0);\n }\n .w-1\\.5 {\n width: calc(var(--spacing) * 1.5);\n }\n .w-2 {\n width: calc(var(--spacing) * 2);\n }\n .w-3\\.5 {\n width: calc(var(--spacing) * 3.5);\n }\n .w-5 {\n width: calc(var(--spacing) * 5);\n }\n .w-\\[calc\\(100\\%\\+16px\\)\\] {\n width: calc(100% + 16px);\n }\n .w-auto {\n width: auto;\n }\n .w-fit {\n width: fit-content;\n }\n .w-full {\n width: 100%;\n }\n .max-w-\\[280px\\] {\n max-width: 280px;\n }\n .max-w-full {\n max-width: 100%;\n }\n .min-w-0 {\n min-width: calc(var(--spacing) * 0);\n }\n .min-w-2\\.5 {\n min-width: calc(var(--spacing) * 2.5);\n }\n .min-w-\\[100px\\] {\n min-width: 100px;\n }\n .min-w-\\[150px\\] {\n min-width: 150px;\n }\n .flex-1 {\n flex: 1;\n }\n .flex-shrink {\n flex-shrink: 1;\n }\n .shrink {\n flex-shrink: 1;\n }\n .shrink-0 {\n flex-shrink: 0;\n }\n .flex-grow {\n flex-grow: 1;\n }\n .-translate-x-1\\/2 {\n --tw-translate-x: calc(calc(1/2 * 100%) * -1);\n translate: var(--tw-translate-x) var(--tw-translate-y);\n }\n .-translate-y-1\\/2 {\n --tw-translate-y: calc(calc(1/2 * 100%) * -1);\n translate: var(--tw-translate-x) var(--tw-translate-y);\n }\n .scale-75 {\n --tw-scale-x: 75%;\n --tw-scale-y: 75%;\n --tw-scale-z: 75%;\n scale: var(--tw-scale-x) var(--tw-scale-y);\n }\n .scale-100 {\n --tw-scale-x: 100%;\n --tw-scale-y: 100%;\n --tw-scale-z: 100%;\n scale: var(--tw-scale-x) var(--tw-scale-y);\n }\n .-rotate-90 {\n rotate: calc(90deg * -1);\n }\n .rotate-0 {\n rotate: 0deg;\n }\n .rotate-90 {\n rotate: 90deg;\n }\n .rotate-180 {\n rotate: 180deg;\n }\n .interactive-scale {\n transition-property: transform;\n transition-duration: var(--transition-normal);\n transition-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1);\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n transform: scale(1.05);\n }\n }\n &:active {\n transform: scale(0.97);\n }\n }\n .press-scale {\n transition-property: transform;\n transition-duration: var(--transition-fast);\n transition-timing-function: ease-out;\n &:active {\n transform: scale(0.97);\n }\n }\n .transform {\n transform: var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,);\n }\n .animate-\\[hint-flip-in_var\\(--transition-normal\\)_ease-out\\] {\n animation: hint-flip-in var(--transition-normal) ease-out;\n }\n .cursor-grab {\n cursor: grab;\n }\n .cursor-grabbing {\n cursor: grabbing;\n }\n .cursor-pointer {\n cursor: pointer;\n }\n .resize {\n resize: both;\n }\n .resize-none {\n resize: none;\n }\n .grid-cols-\\[0fr\\] {\n grid-template-columns: 0fr;\n }\n .grid-cols-\\[1fr\\] {\n grid-template-columns: 1fr;\n }\n .grid-rows-\\[0fr\\] {\n grid-template-rows: 0fr;\n }\n .grid-rows-\\[1fr\\] {\n grid-template-rows: 1fr;\n }\n .flex-col {\n flex-direction: column;\n }\n .flex-wrap {\n flex-wrap: wrap;\n }\n .items-center {\n align-items: center;\n }\n .items-end {\n align-items: flex-end;\n }\n .items-start {\n align-items: flex-start;\n }\n .justify-between {\n justify-content: space-between;\n }\n .justify-center {\n justify-content: center;\n }\n .justify-end {\n justify-content: flex-end;\n }\n .gap-0\\.5 {\n gap: calc(var(--spacing) * 0.5);\n }\n .gap-1 {\n gap: calc(var(--spacing) * 1);\n }\n .gap-1\\.5 {\n gap: calc(var(--spacing) * 1.5);\n }\n .gap-2 {\n gap: calc(var(--spacing) * 2);\n }\n .gap-\\[5px\\] {\n gap: 5px;\n }\n .self-stretch {\n align-self: stretch;\n }\n .truncate {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n .overflow-hidden {\n overflow: hidden;\n }\n .overflow-visible {\n overflow: visible;\n }\n .overflow-y-auto {\n overflow-y: auto;\n }\n .rounded-\\[10px\\] {\n border-radius: 10px;\n }\n .rounded-full {\n border-radius: calc(infinity * 1px);\n }\n .rounded-sm {\n border-radius: var(--radius-sm);\n }\n .rounded-t-\\[10px\\] {\n border-top-left-radius: 10px;\n border-top-right-radius: 10px;\n }\n .rounded-t-none {\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n }\n .rounded-l-\\[10px\\] {\n border-top-left-radius: 10px;\n border-bottom-left-radius: 10px;\n }\n .rounded-l-none {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n }\n .rounded-r-\\[10px\\] {\n border-top-right-radius: 10px;\n border-bottom-right-radius: 10px;\n }\n .rounded-r-none {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n }\n .rounded-b-\\[6px\\] {\n border-bottom-right-radius: 6px;\n border-bottom-left-radius: 6px;\n }\n .rounded-b-\\[10px\\] {\n border-bottom-right-radius: 10px;\n border-bottom-left-radius: 10px;\n }\n .rounded-b-none {\n border-bottom-right-radius: 0;\n border-bottom-left-radius: 0;\n }\n .border {\n border-style: var(--tw-border-style);\n border-width: 1px;\n }\n .\\[border-width\\:0\\.5px\\] {\n border-width: 0.5px;\n }\n .\\[border-top-width\\:0\\.5px\\] {\n border-top-width: 0.5px;\n }\n .border-none {\n --tw-border-style: none;\n border-style: none;\n }\n .border-solid {\n --tw-border-style: solid;\n border-style: solid;\n }\n .border-\\[\\#B3B3B3\\] {\n border-color: #B3B3B3;\n }\n .border-t-\\[\\#D9D9D9\\] {\n border-top-color: #D9D9D9;\n }\n .bg-\\[\\#FEF2F2\\] {\n background-color: #FEF2F2;\n }\n .bg-black {\n background-color: var(--color-black);\n }\n .bg-black\\/5 {\n background-color: color-mix(in srgb, #000 5%, transparent);\n @supports (color: color-mix(in lab, red, red)) {\n background-color: color-mix(in oklab, var(--color-black) 5%, transparent);\n }\n }\n .bg-black\\/25 {\n background-color: color-mix(in srgb, #000 25%, transparent);\n @supports (color: color-mix(in lab, red, red)) {\n background-color: color-mix(in oklab, var(--color-black) 25%, transparent);\n }\n }\n .bg-transparent {\n background-color: transparent;\n }\n .bg-white {\n background-color: var(--color-white);\n }\n .p-0 {\n padding: calc(var(--spacing) * 0);\n }\n .px-0\\.5 {\n padding-inline: calc(var(--spacing) * 0.5);\n }\n .px-0\\.25 {\n padding-inline: calc(var(--spacing) * 0.25);\n }\n .px-1\\.5 {\n padding-inline: calc(var(--spacing) * 1.5);\n }\n .px-2 {\n padding-inline: calc(var(--spacing) * 2);\n }\n .px-\\[3px\\] {\n padding-inline: 3px;\n }\n .py-0\\.5 {\n padding-block: calc(var(--spacing) * 0.5);\n }\n .py-0\\.25 {\n padding-block: calc(var(--spacing) * 0.25);\n }\n .py-1 {\n padding-block: calc(var(--spacing) * 1);\n }\n .py-1\\.5 {\n padding-block: calc(var(--spacing) * 1.5);\n }\n .py-2 {\n padding-block: calc(var(--spacing) * 2);\n }\n .py-px {\n padding-block: 1px;\n }\n .pt-1\\.5 {\n padding-top: calc(var(--spacing) * 1.5);\n }\n .pb-1 {\n padding-bottom: calc(var(--spacing) * 1);\n }\n .text-left {\n text-align: left;\n }\n .font-sans {\n font-family: var(--font-sans);\n }\n .text-\\[8px\\] {\n font-size: 8px;\n }\n .text-\\[10px\\] {\n font-size: 10px;\n }\n .text-\\[11px\\] {\n font-size: 11px;\n }\n .text-\\[12px\\] {\n font-size: 12px;\n }\n .text-\\[13px\\] {\n font-size: 13px;\n }\n .leading-3 {\n --tw-leading: calc(var(--spacing) * 3);\n line-height: calc(var(--spacing) * 3);\n }\n .leading-3\\.5 {\n --tw-leading: calc(var(--spacing) * 3.5);\n line-height: calc(var(--spacing) * 3.5);\n }\n .leading-4 {\n --tw-leading: calc(var(--spacing) * 4);\n line-height: calc(var(--spacing) * 4);\n }\n .leading-none {\n --tw-leading: 1;\n line-height: 1;\n }\n .font-medium {\n --tw-font-weight: var(--font-weight-medium);\n font-weight: var(--font-weight-medium);\n }\n .font-semibold {\n --tw-font-weight: var(--font-weight-semibold);\n font-weight: var(--font-weight-semibold);\n }\n .wrap-break-word {\n overflow-wrap: break-word;\n }\n .text-ellipsis {\n text-overflow: ellipsis;\n }\n .whitespace-nowrap {\n white-space: nowrap;\n }\n .text-\\[\\#71717a\\] {\n color: #71717a;\n }\n .text-\\[\\#B3B3B3\\] {\n color: #B3B3B3;\n }\n .text-\\[\\#B91C1C\\] {\n color: #B91C1C;\n }\n .text-\\[\\#B91C1C\\]\\/50 {\n color: color-mix(in oklab, #B91C1C 50%, transparent);\n }\n .text-black {\n color: var(--color-black);\n }\n .text-black\\/25 {\n color: color-mix(in srgb, #000 25%, transparent);\n @supports (color: color-mix(in lab, red, red)) {\n color: color-mix(in oklab, var(--color-black) 25%, transparent);\n }\n }\n .text-black\\/30 {\n color: color-mix(in srgb, #000 30%, transparent);\n @supports (color: color-mix(in lab, red, red)) {\n color: color-mix(in oklab, var(--color-black) 30%, transparent);\n }\n }\n .text-black\\/40 {\n color: color-mix(in srgb, #000 40%, transparent);\n @supports (color: color-mix(in lab, red, red)) {\n color: color-mix(in oklab, var(--color-black) 40%, transparent);\n }\n }\n .text-black\\/50 {\n color: color-mix(in srgb, #000 50%, transparent);\n @supports (color: color-mix(in lab, red, red)) {\n color: color-mix(in oklab, var(--color-black) 50%, transparent);\n }\n }\n .text-black\\/60 {\n color: color-mix(in srgb, #000 60%, transparent);\n @supports (color: color-mix(in lab, red, red)) {\n color: color-mix(in oklab, var(--color-black) 60%, transparent);\n }\n }\n .text-black\\/70 {\n color: color-mix(in srgb, #000 70%, transparent);\n @supports (color: color-mix(in lab, red, red)) {\n color: color-mix(in oklab, var(--color-black) 70%, transparent);\n }\n }\n .text-black\\/85 {\n color: color-mix(in srgb, #000 85%, transparent);\n @supports (color: color-mix(in lab, red, red)) {\n color: color-mix(in oklab, var(--color-black) 85%, transparent);\n }\n }\n .text-white {\n color: var(--color-white);\n }\n .tabular-nums {\n --tw-numeric-spacing: tabular-nums;\n font-variant-numeric: var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,);\n }\n .antialiased {\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n }\n .opacity-0 {\n opacity: 0%;\n }\n .opacity-40 {\n opacity: 40%;\n }\n .opacity-100 {\n opacity: 100%;\n }\n .shadow {\n --tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1));\n box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);\n }\n .outline {\n outline-style: var(--tw-outline-style);\n outline-width: 1px;\n }\n .blur {\n --tw-blur: blur(8px);\n filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);\n }\n .filter {\n filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);\n }\n .filter-\\[drop-shadow\\(0px_1px_2px_\\#51515140\\)\\] {\n filter: drop-shadow(0px 1px 2px #51515140);\n }\n .backdrop-filter {\n -webkit-backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);\n backdrop-filter: var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);\n }\n .transition {\n transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, -webkit-backdrop-filter, backdrop-filter, display, content-visibility, overlay, pointer-events;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-\\[grid-template-columns\\,opacity\\] {\n transition-property: grid-template-columns,opacity;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-\\[grid-template-columns\\] {\n transition-property: grid-template-columns;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-\\[grid-template-rows\\,opacity\\] {\n transition-property: grid-template-rows,opacity;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-\\[grid-template-rows\\] {\n transition-property: grid-template-rows;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-\\[opacity\\,transform\\] {\n transition-property: opacity,transform;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-\\[top\\,left\\,width\\,height\\,opacity\\] {\n transition-property: top,left,width,height,opacity;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-\\[transform\\,opacity\\] {\n transition-property: transform,opacity;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-all {\n transition-property: all;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-colors {\n transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-opacity {\n transition-property: opacity;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .transition-transform {\n transition-property: transform, translate, scale, rotate;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n .duration-75 {\n --tw-duration: 75ms;\n transition-duration: 75ms;\n }\n .duration-100 {\n --tw-duration: 100ms;\n transition-duration: 100ms;\n }\n .duration-150 {\n --tw-duration: 150ms;\n transition-duration: 150ms;\n }\n .duration-300 {\n --tw-duration: 300ms;\n transition-duration: 300ms;\n }\n .ease-out {\n --tw-ease: var(--ease-out);\n transition-timing-function: var(--ease-out);\n }\n .will-change-\\[opacity\\,transform\\] {\n will-change: opacity,transform;\n }\n .contain-layout {\n --tw-contain-layout: layout;\n contain: var(--tw-contain-size,) var(--tw-contain-layout,) var(--tw-contain-paint,) var(--tw-contain-style,);\n }\n .outline-none {\n --tw-outline-style: none;\n outline-style: none;\n }\n .select-none {\n -webkit-user-select: none;\n user-select: none;\n }\n .\\[animation-fill-mode\\:backwards\\] {\n animation-fill-mode: backwards;\n }\n .\\[corner-shape\\:superellipse\\(1\\.25\\)\\] {\n corner-shape: superellipse(1.25);\n }\n .\\[font-synthesis\\:none\\] {\n font-synthesis: none;\n }\n .\\[scrollbar-color\\:transparent_transparent\\] {\n scrollbar-color: transparent transparent;\n }\n .\\[scrollbar-width\\:thin\\] {\n scrollbar-width: thin;\n }\n .before\\:\\!min-h-full {\n &::before {\n content: var(--tw-content);\n min-height: 100% !important;\n }\n }\n .before\\:\\!min-w-full {\n &::before {\n content: var(--tw-content);\n min-width: 100% !important;\n }\n }\n .hover\\:bg-\\[\\#F5F5F5\\] {\n &:hover {\n @media (hover: hover) {\n background-color: #F5F5F5;\n }\n }\n }\n .hover\\:bg-\\[\\#FEE2E2\\] {\n &:hover {\n @media (hover: hover) {\n background-color: #FEE2E2;\n }\n }\n }\n .hover\\:bg-black\\/10 {\n &:hover {\n @media (hover: hover) {\n background-color: color-mix(in srgb, #000 10%, transparent);\n @supports (color: color-mix(in lab, red, red)) {\n background-color: color-mix(in oklab, var(--color-black) 10%, transparent);\n }\n }\n }\n }\n .hover\\:text-black {\n &:hover {\n @media (hover: hover) {\n color: var(--color-black);\n }\n }\n }\n .hover\\:opacity-100 {\n &:hover {\n @media (hover: hover) {\n opacity: 100%;\n }\n }\n }\n .hover\\:\\[scrollbar-color\\:rgba\\(0\\,0\\,0\\,0\\.15\\)_transparent\\] {\n &:hover {\n @media (hover: hover) {\n scrollbar-color: rgba(0,0,0,0.15) transparent;\n }\n }\n }\n .disabled\\:cursor-default {\n &:disabled {\n cursor: default;\n }\n }\n .disabled\\:opacity-40 {\n &:disabled {\n opacity: 40%;\n }\n }\n}\n:host {\n all: initial;\n direction: ltr;\n}\n@keyframes shake {\n 0%, 100% {\n transform: translateX(0);\n }\n 15% {\n transform: translateX(-3px);\n }\n 30% {\n transform: translateX(3px);\n }\n 45% {\n transform: translateX(-3px);\n }\n 60% {\n transform: translateX(3px);\n }\n 75% {\n transform: translateX(-2px);\n }\n 90% {\n transform: translateX(2px);\n }\n}\n@keyframes success-pop {\n 0% {\n transform: scale(0.9);\n opacity: 0;\n }\n 60% {\n transform: scale(1.1);\n opacity: 1;\n }\n 80% {\n transform: scale(0.95);\n }\n 100% {\n transform: scale(1);\n opacity: 1;\n }\n}\n@keyframes hint-flip-in {\n from {\n opacity: 0;\n transform: translateY(4px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n@keyframes tooltip-fade-in {\n from {\n opacity: 0;\n transform: scale(0.97);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n@keyframes icon-loader-spin {\n 0% {\n opacity: 1;\n }\n 50% {\n opacity: 0.5;\n }\n 100% {\n opacity: 0.2;\n }\n}\n.icon-loader-bar {\n animation: icon-loader-spin 0.5s linear infinite;\n}\n@keyframes shimmer {\n 0% {\n background-position: 200% 0;\n }\n 100% {\n background-position: -200% 0;\n }\n}\n.shimmer-text {\n background: linear-gradient( 90deg, #71717a 0%, #a1a1aa 25%, #71717a 50%, #a1a1aa 75%, #71717a 100% );\n background-size: 200% 100%;\n -webkit-background-clip: text;\n background-clip: text;\n color: transparent;\n animation: shimmer 2.5s linear infinite;\n}\n@keyframes clock-flash {\n 0% {\n transform: scale(1);\n }\n 25% {\n transform: scale(1.2);\n }\n 50% {\n transform: scale(0.92);\n }\n 75% {\n transform: scale(1.05);\n }\n 100% {\n transform: scale(1);\n }\n}\n.animate-clock-flash {\n animation: clock-flash 400ms ease-out;\n will-change: transform;\n}\n.animate-shake {\n animation: shake 0.3s ease-out;\n will-change: transform;\n}\n.animate-success-pop {\n animation: success-pop 250ms ease-out;\n will-change: transform, opacity;\n}\n.animate-tooltip-fade-in {\n animation: tooltip-fade-in var(--transition-fast) ease-out;\n will-change: transform, opacity;\n}\n@property --tw-translate-x {\n syntax: \"*\";\n inherits: false;\n initial-value: 0;\n}\n@property --tw-translate-y {\n syntax: \"*\";\n inherits: false;\n initial-value: 0;\n}\n@property --tw-translate-z {\n syntax: \"*\";\n inherits: false;\n initial-value: 0;\n}\n@property --tw-scale-x {\n syntax: \"*\";\n inherits: false;\n initial-value: 1;\n}\n@property --tw-scale-y {\n syntax: \"*\";\n inherits: false;\n initial-value: 1;\n}\n@property --tw-scale-z {\n syntax: \"*\";\n inherits: false;\n initial-value: 1;\n}\n@property --tw-rotate-x {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-rotate-y {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-rotate-z {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-skew-x {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-skew-y {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-border-style {\n syntax: \"*\";\n inherits: false;\n initial-value: solid;\n}\n@property --tw-leading {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-font-weight {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-ordinal {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-slashed-zero {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-numeric-figure {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-numeric-spacing {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-numeric-fraction {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n@property --tw-shadow-color {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-shadow-alpha {\n syntax: \"<percentage>\";\n inherits: false;\n initial-value: 100%;\n}\n@property --tw-inset-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n@property --tw-inset-shadow-color {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-inset-shadow-alpha {\n syntax: \"<percentage>\";\n inherits: false;\n initial-value: 100%;\n}\n@property --tw-ring-color {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-ring-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n@property --tw-inset-ring-color {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-inset-ring-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n@property --tw-ring-inset {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-ring-offset-width {\n syntax: \"<length>\";\n inherits: false;\n initial-value: 0px;\n}\n@property --tw-ring-offset-color {\n syntax: \"*\";\n inherits: false;\n initial-value: #fff;\n}\n@property --tw-ring-offset-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n@property --tw-outline-style {\n syntax: \"*\";\n inherits: false;\n initial-value: solid;\n}\n@property --tw-blur {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-brightness {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-contrast {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-grayscale {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-hue-rotate {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-invert {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-opacity {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-saturate {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-sepia {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-drop-shadow {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-drop-shadow-color {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-drop-shadow-alpha {\n syntax: \"<percentage>\";\n inherits: false;\n initial-value: 100%;\n}\n@property --tw-drop-shadow-size {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-backdrop-blur {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-backdrop-brightness {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-backdrop-contrast {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-backdrop-grayscale {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-backdrop-hue-rotate {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-backdrop-invert {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-backdrop-opacity {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-backdrop-saturate {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-backdrop-sepia {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-duration {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-ease {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-contain-size {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-contain-layout {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-contain-paint {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-contain-style {\n syntax: \"*\";\n inherits: false;\n}\n@property --tw-content {\n syntax: \"*\";\n initial-value: \"\";\n inherits: false;\n}\n@layer properties {\n @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {\n *, ::before, ::after, ::backdrop {\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-translate-z: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-scale-z: 1;\n --tw-rotate-x: initial;\n --tw-rotate-y: initial;\n --tw-rotate-z: initial;\n --tw-skew-x: initial;\n --tw-skew-y: initial;\n --tw-border-style: solid;\n --tw-leading: initial;\n --tw-font-weight: initial;\n --tw-ordinal: initial;\n --tw-slashed-zero: initial;\n --tw-numeric-figure: initial;\n --tw-numeric-spacing: initial;\n --tw-numeric-fraction: initial;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-color: initial;\n --tw-shadow-alpha: 100%;\n --tw-inset-shadow: 0 0 #0000;\n --tw-inset-shadow-color: initial;\n --tw-inset-shadow-alpha: 100%;\n --tw-ring-color: initial;\n --tw-ring-shadow: 0 0 #0000;\n --tw-inset-ring-color: initial;\n --tw-inset-ring-shadow: 0 0 #0000;\n --tw-ring-inset: initial;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-outline-style: solid;\n --tw-blur: initial;\n --tw-brightness: initial;\n --tw-contrast: initial;\n --tw-grayscale: initial;\n --tw-hue-rotate: initial;\n --tw-invert: initial;\n --tw-opacity: initial;\n --tw-saturate: initial;\n --tw-sepia: initial;\n --tw-drop-shadow: initial;\n --tw-drop-shadow-color: initial;\n --tw-drop-shadow-alpha: 100%;\n --tw-drop-shadow-size: initial;\n --tw-backdrop-blur: initial;\n --tw-backdrop-brightness: initial;\n --tw-backdrop-contrast: initial;\n --tw-backdrop-grayscale: initial;\n --tw-backdrop-hue-rotate: initial;\n --tw-backdrop-invert: initial;\n --tw-backdrop-opacity: initial;\n --tw-backdrop-saturate: initial;\n --tw-backdrop-sepia: initial;\n --tw-duration: initial;\n --tw-ease: initial;\n --tw-contain-size: initial;\n --tw-contain-layout: initial;\n --tw-contain-paint: initial;\n --tw-contain-style: initial;\n --tw-content: \"\";\n }\n }\n}\n" === "string" ? styles_default : "");
|
|
3392
|
+
const isThemeEnabled = createMemo(() => pluginRegistry.store.theme.enabled);
|
|
3393
|
+
const isSelectionBoxThemeEnabled = createMemo(() => pluginRegistry.store.theme.selectionBox.enabled);
|
|
3394
|
+
const isElementLabelThemeEnabled = createMemo(() => pluginRegistry.store.theme.elementLabel.enabled);
|
|
3395
|
+
const isDragBoxThemeEnabled = createMemo(() => pluginRegistry.store.theme.dragBox.enabled);
|
|
3396
|
+
const isSelectionSuppressed = createMemo(() => didJustCopy() || isToolbarSelectHovered() && !isFrozenPhase());
|
|
3397
|
+
const hasDragPreviewBounds = createMemo(() => dragPreviewBounds().length > 0);
|
|
3398
|
+
const selectionVisible = createMemo(() => {
|
|
3399
|
+
if (!isThemeEnabled()) return false;
|
|
3400
|
+
if (!isSelectionBoxThemeEnabled()) return false;
|
|
3401
|
+
if (isSelectionSuppressed()) return false;
|
|
3402
|
+
if (hasDragPreviewBounds()) return true;
|
|
3403
|
+
return isSelectionElementVisible();
|
|
3404
|
+
});
|
|
3405
|
+
const selectionTagName = createMemo(() => {
|
|
3406
|
+
const element = selectionElement();
|
|
3407
|
+
if (!element) return void 0;
|
|
3408
|
+
return getTagName(element) || void 0;
|
|
3409
|
+
});
|
|
3410
|
+
createEffect(on(() => debouncedElementForComponentName(), (element) => {
|
|
3411
|
+
const currentVersion = ++componentNameRequestVersion;
|
|
3412
|
+
if (!element) {
|
|
3413
|
+
setResolvedComponentName(void 0);
|
|
3414
|
+
return;
|
|
3415
|
+
}
|
|
3416
|
+
getNearestComponentName(element).then((name) => {
|
|
3417
|
+
if (componentNameRequestVersion !== currentVersion) return;
|
|
3418
|
+
setResolvedComponentName(name ?? void 0);
|
|
3419
|
+
}).catch(() => {
|
|
3420
|
+
if (componentNameRequestVersion !== currentVersion) return;
|
|
3421
|
+
setResolvedComponentName(void 0);
|
|
3422
|
+
});
|
|
3423
|
+
}));
|
|
3424
|
+
const selectionLabelVisible = createMemo(() => {
|
|
3425
|
+
if (store.contextMenuPosition !== null) return false;
|
|
3426
|
+
if (!isElementLabelThemeEnabled()) return false;
|
|
3427
|
+
if (isSelectionSuppressed()) return false;
|
|
3428
|
+
return isSelectionElementVisible();
|
|
3429
|
+
});
|
|
3430
|
+
const labelInstanceCache = /* @__PURE__ */ new Map();
|
|
3431
|
+
const recomputeLabelInstance = (instance) => {
|
|
3432
|
+
const hasMultipleElements = instance.elements && instance.elements.length > 1;
|
|
3433
|
+
const instanceElement = instance.element;
|
|
3434
|
+
const newBounds = !hasMultipleElements && instanceElement && document.body.contains(instanceElement) ? createElementBounds(instanceElement) : instance.bounds;
|
|
3435
|
+
const previousInstance = labelInstanceCache.get(instance.id);
|
|
3436
|
+
const boundsUnchanged = previousInstance && previousInstance.bounds.x === newBounds.x && previousInstance.bounds.y === newBounds.y && previousInstance.bounds.width === newBounds.width && previousInstance.bounds.height === newBounds.height;
|
|
3437
|
+
if (previousInstance && previousInstance.status === instance.status && previousInstance.errorMessage === instance.errorMessage && boundsUnchanged) return previousInstance;
|
|
3438
|
+
const newBoundsCenterX = newBounds.x + newBounds.width / 2;
|
|
3439
|
+
const newBoundsHalfWidth = newBounds.width / 2;
|
|
3440
|
+
let newMouseX;
|
|
3441
|
+
if (instance.mouseXOffsetRatio !== void 0 && newBoundsHalfWidth > 0) newMouseX = newBoundsCenterX + instance.mouseXOffsetRatio * newBoundsHalfWidth;
|
|
3442
|
+
else if (instance.mouseXOffsetFromCenter !== void 0) newMouseX = newBoundsCenterX + instance.mouseXOffsetFromCenter;
|
|
3443
|
+
else newMouseX = instance.mouseX ?? newBoundsCenterX;
|
|
3444
|
+
const newCached = {
|
|
3445
|
+
...instance,
|
|
3446
|
+
bounds: newBounds,
|
|
3447
|
+
mouseX: newMouseX
|
|
3448
|
+
};
|
|
3449
|
+
labelInstanceCache.set(instance.id, newCached);
|
|
3450
|
+
return newCached;
|
|
3451
|
+
};
|
|
3452
|
+
const computedLabelInstances = createMemo(() => {
|
|
3453
|
+
if (!isThemeEnabled()) return [];
|
|
3454
|
+
if (!pluginRegistry.store.theme.grabbedBoxes.enabled) return [];
|
|
3455
|
+
store.viewportVersion;
|
|
3456
|
+
const currentIds = new Set(store.labelInstances.map((instance) => instance.id));
|
|
3457
|
+
for (const cachedId of labelInstanceCache.keys()) if (!currentIds.has(cachedId)) labelInstanceCache.delete(cachedId);
|
|
3458
|
+
return store.labelInstances.map(recomputeLabelInstance);
|
|
3459
|
+
});
|
|
3460
|
+
const computedGrabbedBoxes = createMemo(() => {
|
|
3461
|
+
if (!isThemeEnabled()) return [];
|
|
3462
|
+
if (!pluginRegistry.store.theme.grabbedBoxes.enabled) return [];
|
|
3463
|
+
store.viewportVersion;
|
|
3464
|
+
return store.grabbedBoxes.map((box) => {
|
|
3465
|
+
if (!box.element || !document.body.contains(box.element)) return box;
|
|
3466
|
+
return {
|
|
3467
|
+
...box,
|
|
3468
|
+
bounds: createElementBounds(box.element)
|
|
3469
|
+
};
|
|
3470
|
+
});
|
|
3471
|
+
});
|
|
3472
|
+
const dragVisible = createMemo(() => isThemeEnabled() && isDragBoxThemeEnabled() && isRendererActive() && isDraggingBeyondThreshold());
|
|
3473
|
+
const labelVariant = createMemo(() => isCopying() ? "processing" : "hover");
|
|
3474
|
+
const labelVisible = createMemo(() => {
|
|
3475
|
+
if (!isThemeEnabled()) return false;
|
|
3476
|
+
const themeEnabled = isElementLabelThemeEnabled();
|
|
3477
|
+
const inPromptMode = isPromptMode();
|
|
3478
|
+
const copying = isCopying();
|
|
3479
|
+
const rendererActive = isRendererActive();
|
|
3480
|
+
const dragging = isDragging();
|
|
3481
|
+
const hasElement = Boolean(effectiveElement());
|
|
3482
|
+
const toolbarSelectHovered = isToolbarSelectHovered();
|
|
3483
|
+
const frozen = isFrozenPhase();
|
|
3484
|
+
if (!themeEnabled) return false;
|
|
3485
|
+
if (inPromptMode) return false;
|
|
3486
|
+
if (toolbarSelectHovered && !frozen) return false;
|
|
3487
|
+
if (copying) return true;
|
|
3488
|
+
return rendererActive && !dragging && hasElement;
|
|
3489
|
+
});
|
|
3490
|
+
const contextMenuBounds = createMemo(() => {
|
|
3491
|
+
store.viewportVersion;
|
|
3492
|
+
const element = store.contextMenuElement;
|
|
3493
|
+
if (!element) return null;
|
|
3494
|
+
return createElementBounds(element);
|
|
3495
|
+
});
|
|
3496
|
+
const contextMenuPosition = createMemo(() => {
|
|
3497
|
+
store.viewportVersion;
|
|
3498
|
+
return store.contextMenuPosition;
|
|
3499
|
+
});
|
|
3500
|
+
const contextMenuTagName = createMemo(() => {
|
|
3501
|
+
const element = store.contextMenuElement;
|
|
3502
|
+
if (!element) return void 0;
|
|
3503
|
+
const frozenCount = store.frozenElements.length;
|
|
3504
|
+
if (frozenCount > 1) return `${frozenCount} elements`;
|
|
3505
|
+
return getTagName(element) || void 0;
|
|
3506
|
+
});
|
|
3507
|
+
const [contextMenuComponentName] = createResource(() => ({
|
|
3508
|
+
element: store.contextMenuElement,
|
|
3509
|
+
frozenCount: store.frozenElements.length
|
|
3510
|
+
}), async ({ element, frozenCount }) => {
|
|
3511
|
+
if (!element) return void 0;
|
|
3512
|
+
if (frozenCount > 1) return void 0;
|
|
3513
|
+
return await getNearestComponentName(element) ?? void 0;
|
|
3514
|
+
});
|
|
3515
|
+
const [contextMenuFilePath] = createResource(() => store.contextMenuElement, async (element) => {
|
|
3516
|
+
if (!element) return null;
|
|
3517
|
+
return resolveSource(element);
|
|
3518
|
+
});
|
|
3519
|
+
const createPerformWithFeedback = (element, elements, tagName, componentName, options) => {
|
|
3520
|
+
return async (action) => {
|
|
3521
|
+
const fallbackBounds = options?.fallbackBounds ?? null;
|
|
3522
|
+
const fallbackSelectionBounds = options?.fallbackSelectionBounds ?? [];
|
|
3523
|
+
const position = options?.position ?? store.contextMenuPosition ?? store.pointer;
|
|
3524
|
+
const frozenBounds = frozenElementsBounds();
|
|
3525
|
+
const singleElementBounds = contextMenuBounds() ?? fallbackBounds;
|
|
3526
|
+
const hasMultipleElements = elements.length > 1;
|
|
3527
|
+
const labelBounds = hasMultipleElements ? createFlatOverlayBounds(combineBounds(frozenBounds)) : singleElementBounds;
|
|
3528
|
+
const shouldDeactivateAfter = store.wasActivatedByToggle;
|
|
3529
|
+
let selectionBoundsForLabel;
|
|
3530
|
+
if (hasMultipleElements) selectionBoundsForLabel = frozenBounds;
|
|
3531
|
+
else if (singleElementBounds) selectionBoundsForLabel = [singleElementBounds];
|
|
3532
|
+
else selectionBoundsForLabel = fallbackSelectionBounds;
|
|
3533
|
+
actions.hideContextMenu();
|
|
3534
|
+
if (labelBounds) {
|
|
3535
|
+
const labelCursorX = hasMultipleElements ? labelBounds.x + labelBounds.width / 2 : position.x;
|
|
3536
|
+
const labelInstanceId = createLabelInstance(labelBounds, tagName || "element", componentName, "copying", {
|
|
3537
|
+
element,
|
|
3538
|
+
mouseX: labelCursorX,
|
|
3539
|
+
elements: hasMultipleElements ? elements : void 0,
|
|
3540
|
+
boundsMultiple: selectionBoundsForLabel
|
|
3541
|
+
});
|
|
3542
|
+
let didSucceed = false;
|
|
3543
|
+
let errorMessage;
|
|
3544
|
+
try {
|
|
3545
|
+
didSucceed = await action();
|
|
3546
|
+
if (!didSucceed) errorMessage = "Failed to copy";
|
|
3547
|
+
} catch (error) {
|
|
3548
|
+
errorMessage = normalizeErrorMessage(error, "Action failed");
|
|
3549
|
+
}
|
|
3550
|
+
updateLabelAfterCopy(labelInstanceId, didSucceed, errorMessage);
|
|
3551
|
+
} else try {
|
|
3552
|
+
await action();
|
|
3553
|
+
} catch (error) {
|
|
3554
|
+
logRecoverableError("Action failed without feedback bounds", error);
|
|
3555
|
+
}
|
|
3556
|
+
if (shouldDeactivateAfter) deactivateRenderer();
|
|
3557
|
+
else actions.unfreeze();
|
|
3558
|
+
};
|
|
3559
|
+
};
|
|
3560
|
+
const deferHideContextMenu = () => {
|
|
3561
|
+
setTimeout(() => {
|
|
3562
|
+
actions.hideContextMenu();
|
|
3563
|
+
}, 0);
|
|
3564
|
+
};
|
|
3565
|
+
const buildActionContext = (options) => {
|
|
3566
|
+
const { element, filePath, lineNumber, tagName, componentName, position, performWithFeedbackOptions, shouldDeferHideContextMenu, onBeforeCopy, onBeforePrompt, customEnterPromptMode } = options;
|
|
3567
|
+
const elements = store.frozenElements.length > 0 ? store.frozenElements : [element];
|
|
3568
|
+
const hideContextMenuAction = shouldDeferHideContextMenu ? deferHideContextMenu : actions.hideContextMenu;
|
|
3569
|
+
const copyAction = () => {
|
|
3570
|
+
onBeforeCopy?.();
|
|
3571
|
+
performCopyWithLabel({
|
|
3572
|
+
element,
|
|
3573
|
+
cursorX: position.x,
|
|
3574
|
+
selectedElements: elements.length > 1 ? elements : void 0,
|
|
3575
|
+
shouldDeactivateAfter: store.wasActivatedByToggle
|
|
3576
|
+
});
|
|
3577
|
+
hideContextMenuAction();
|
|
3578
|
+
};
|
|
3579
|
+
const defaultEnterPromptMode = () => {
|
|
3580
|
+
clearAllLabels();
|
|
3581
|
+
onBeforePrompt?.();
|
|
3582
|
+
preparePromptMode(element, position.x, position.y);
|
|
3583
|
+
actions.setPointer({
|
|
3584
|
+
x: position.x,
|
|
3585
|
+
y: position.y
|
|
3586
|
+
});
|
|
3587
|
+
actions.setFrozenElement(element);
|
|
3588
|
+
activatePromptMode();
|
|
3589
|
+
if (!isActivated()) activateRenderer();
|
|
3590
|
+
hideContextMenuAction();
|
|
3591
|
+
};
|
|
3592
|
+
const context = {
|
|
3593
|
+
element,
|
|
3594
|
+
elements,
|
|
3595
|
+
filePath,
|
|
3596
|
+
lineNumber,
|
|
3597
|
+
componentName,
|
|
3598
|
+
tagName,
|
|
3599
|
+
enterPromptMode: customEnterPromptMode ?? defaultEnterPromptMode,
|
|
3600
|
+
copy: copyAction,
|
|
3601
|
+
hooks: {
|
|
3602
|
+
transformHtmlContent: pluginRegistry.hooks.transformHtmlContent,
|
|
3603
|
+
onOpenFile: pluginRegistry.hooks.onOpenFile,
|
|
3604
|
+
transformOpenFileUrl: pluginRegistry.hooks.transformOpenFileUrl
|
|
3605
|
+
},
|
|
3606
|
+
performWithFeedback: createPerformWithFeedback(element, elements, tagName, componentName, performWithFeedbackOptions),
|
|
3607
|
+
hideContextMenu: hideContextMenuAction,
|
|
3608
|
+
cleanup: () => {
|
|
3609
|
+
if (store.wasActivatedByToggle) deactivateRenderer();
|
|
3610
|
+
else actions.unfreeze();
|
|
3611
|
+
}
|
|
3612
|
+
};
|
|
3613
|
+
const transformedContext = pluginRegistry.hooks.transformActionContext(context);
|
|
3614
|
+
return {
|
|
3615
|
+
...context,
|
|
3616
|
+
...transformedContext
|
|
3617
|
+
};
|
|
3618
|
+
};
|
|
3619
|
+
const contextMenuActionContext = createMemo(() => {
|
|
3620
|
+
const element = store.contextMenuElement;
|
|
3621
|
+
if (!element) return void 0;
|
|
3622
|
+
const fileInfo = contextMenuFilePath();
|
|
3623
|
+
const position = store.contextMenuPosition ?? store.pointer;
|
|
3624
|
+
return buildActionContext({
|
|
3625
|
+
element,
|
|
3626
|
+
filePath: fileInfo?.filePath,
|
|
3627
|
+
lineNumber: fileInfo?.lineNumber ?? void 0,
|
|
3628
|
+
tagName: contextMenuTagName(),
|
|
3629
|
+
componentName: contextMenuComponentName(),
|
|
3630
|
+
position,
|
|
3631
|
+
shouldDeferHideContextMenu: true,
|
|
3632
|
+
onBeforeCopy: () => {
|
|
3633
|
+
keyboardSelectedElement = null;
|
|
3634
|
+
},
|
|
3635
|
+
customEnterPromptMode: () => {
|
|
3636
|
+
clearAllLabels();
|
|
3637
|
+
actions.clearInputText();
|
|
3638
|
+
actions.enterPromptMode(position, element);
|
|
3639
|
+
deferHideContextMenu();
|
|
3640
|
+
}
|
|
3641
|
+
});
|
|
3642
|
+
});
|
|
3643
|
+
const handleContextMenuDismiss = () => {
|
|
3644
|
+
setTimeout(() => {
|
|
3645
|
+
actions.hideContextMenu();
|
|
3646
|
+
deactivateRenderer();
|
|
3647
|
+
}, 0);
|
|
3648
|
+
};
|
|
3649
|
+
const clearCommentsHoverPreviews = () => {
|
|
3650
|
+
for (const { boxId, labelId } of commentsHoverPreviews) {
|
|
3651
|
+
actions.removeGrabbedBox(boxId);
|
|
3652
|
+
if (labelId) actions.removeLabelInstance(labelId);
|
|
3653
|
+
}
|
|
3654
|
+
commentsHoverPreviews = [];
|
|
3655
|
+
};
|
|
3656
|
+
const addCommentItemPreview = (item, previewBounds, previewElements, idPrefix) => {
|
|
3657
|
+
if (previewBounds.length === 0) return;
|
|
3658
|
+
for (const [index, bounds] of previewBounds.entries()) {
|
|
3659
|
+
const previewElement = previewElements[index];
|
|
3660
|
+
const boxId = `${idPrefix}-${item.id}-${index}`;
|
|
3661
|
+
actions.addGrabbedBox({
|
|
3662
|
+
id: boxId,
|
|
3663
|
+
bounds,
|
|
3664
|
+
createdAt: 0,
|
|
3665
|
+
element: previewElement
|
|
3666
|
+
});
|
|
3667
|
+
let labelId = null;
|
|
3668
|
+
if (index === 0) {
|
|
3669
|
+
labelId = `${idPrefix}-label-${item.id}`;
|
|
3670
|
+
actions.addLabelInstance({
|
|
3671
|
+
id: labelId,
|
|
3672
|
+
bounds,
|
|
3673
|
+
tagName: item.tagName,
|
|
3674
|
+
componentName: item.componentName,
|
|
3675
|
+
elementsCount: item.elementsCount,
|
|
3676
|
+
status: "idle",
|
|
3677
|
+
isPromptMode: Boolean(item.commentText),
|
|
3678
|
+
inputValue: item.commentText ?? void 0,
|
|
3679
|
+
createdAt: 0,
|
|
3680
|
+
element: previewElement,
|
|
3681
|
+
mouseX: bounds.x + bounds.width / 2
|
|
3682
|
+
});
|
|
3683
|
+
}
|
|
3684
|
+
commentsHoverPreviews.push({
|
|
3685
|
+
boxId,
|
|
3686
|
+
labelId
|
|
3687
|
+
});
|
|
3688
|
+
}
|
|
3689
|
+
};
|
|
3690
|
+
const showCommentItemPreview = (item, idPrefix) => {
|
|
3691
|
+
const connectedElements = getConnectedCommentElements(item);
|
|
3692
|
+
addCommentItemPreview(item, connectedElements.map((element) => createElementBounds(element)), connectedElements, idPrefix);
|
|
3693
|
+
};
|
|
3694
|
+
const stopTrackingDropdownPosition = () => {
|
|
3695
|
+
if (dropdownTrackingFrameId !== null) {
|
|
3696
|
+
nativeCancelAnimationFrame(dropdownTrackingFrameId);
|
|
3697
|
+
dropdownTrackingFrameId = null;
|
|
3698
|
+
}
|
|
3699
|
+
};
|
|
3700
|
+
const startTrackingDropdownPosition = (computePosition) => {
|
|
3701
|
+
stopTrackingDropdownPosition();
|
|
3702
|
+
const updatePosition = () => {
|
|
3703
|
+
computePosition();
|
|
3704
|
+
dropdownTrackingFrameId = nativeRequestAnimationFrame(updatePosition);
|
|
3705
|
+
};
|
|
3706
|
+
updatePosition();
|
|
3707
|
+
};
|
|
3708
|
+
const computeDropdownAnchor = () => {
|
|
3709
|
+
if (!toolbarElement) return null;
|
|
3710
|
+
const toolbarRect = toolbarElement.getBoundingClientRect();
|
|
3711
|
+
const edge = getNearestEdge(toolbarRect);
|
|
3712
|
+
if (edge === "left" || edge === "right") return {
|
|
3713
|
+
x: edge === "left" ? toolbarRect.right : toolbarRect.left,
|
|
3714
|
+
y: toolbarRect.top + toolbarRect.height / 2,
|
|
3715
|
+
edge,
|
|
3716
|
+
toolbarWidth: toolbarRect.width
|
|
3717
|
+
};
|
|
3718
|
+
return {
|
|
3719
|
+
x: toolbarRect.left + toolbarRect.width / 2,
|
|
3720
|
+
y: edge === "top" ? toolbarRect.bottom : toolbarRect.top,
|
|
3721
|
+
edge,
|
|
3722
|
+
toolbarWidth: toolbarRect.width
|
|
3723
|
+
};
|
|
3724
|
+
};
|
|
3725
|
+
const openTrackedDropdown = (setPosition) => {
|
|
3726
|
+
startTrackingDropdownPosition(() => {
|
|
3727
|
+
const anchor = computeDropdownAnchor();
|
|
3728
|
+
if (anchor) setPosition(anchor);
|
|
3729
|
+
});
|
|
3730
|
+
};
|
|
3731
|
+
const dismissCommentsDropdown = () => {
|
|
3732
|
+
cancelCommentsHoverOpenTimeout();
|
|
3733
|
+
cancelCommentsHoverCloseTimeout();
|
|
3734
|
+
stopTrackingDropdownPosition();
|
|
3735
|
+
clearCommentsHoverPreviews();
|
|
3736
|
+
setCommentsDropdownPosition(null);
|
|
3737
|
+
setIsCommentsHoverOpen(false);
|
|
3738
|
+
};
|
|
3739
|
+
const dismissToolbarMenu = () => {
|
|
3740
|
+
stopTrackingDropdownPosition();
|
|
3741
|
+
setToolbarMenuPosition(null);
|
|
3742
|
+
};
|
|
3743
|
+
const openCommentsDropdown = () => {
|
|
3744
|
+
actions.hideContextMenu();
|
|
3745
|
+
dismissToolbarMenu();
|
|
3746
|
+
dismissClearPrompt();
|
|
3747
|
+
setCommentItems(loadComments());
|
|
3748
|
+
openTrackedDropdown(setCommentsDropdownPosition);
|
|
3749
|
+
};
|
|
3750
|
+
let commentsHoverOpenTimeoutId = null;
|
|
3751
|
+
let commentsHoverCloseTimeoutId = null;
|
|
3752
|
+
const cancelCommentsHoverOpenTimeout = () => {
|
|
3753
|
+
if (commentsHoverOpenTimeoutId !== null) {
|
|
3754
|
+
clearTimeout(commentsHoverOpenTimeoutId);
|
|
3755
|
+
commentsHoverOpenTimeoutId = null;
|
|
3756
|
+
}
|
|
3757
|
+
};
|
|
3758
|
+
const cancelCommentsHoverCloseTimeout = () => {
|
|
3759
|
+
if (commentsHoverCloseTimeoutId !== null) {
|
|
3760
|
+
clearTimeout(commentsHoverCloseTimeoutId);
|
|
3761
|
+
commentsHoverCloseTimeoutId = null;
|
|
3762
|
+
}
|
|
3763
|
+
};
|
|
3764
|
+
const scheduleCommentsHoverClose = () => {
|
|
3765
|
+
commentsHoverCloseTimeoutId = setTimeout(() => {
|
|
3766
|
+
commentsHoverCloseTimeoutId = null;
|
|
3767
|
+
dismissCommentsDropdown();
|
|
3768
|
+
}, 200);
|
|
3769
|
+
};
|
|
3770
|
+
const showClearPrompt = () => {
|
|
3771
|
+
dismissCommentsDropdown();
|
|
3772
|
+
dismissToolbarMenu();
|
|
3773
|
+
openTrackedDropdown(setClearPromptPosition);
|
|
3774
|
+
};
|
|
3775
|
+
const dismissClearPrompt = () => {
|
|
3776
|
+
stopTrackingDropdownPosition();
|
|
3777
|
+
setClearPromptPosition(null);
|
|
3778
|
+
};
|
|
3779
|
+
const dismissAllPopups = () => {
|
|
3780
|
+
dismissCommentsDropdown();
|
|
3781
|
+
dismissToolbarMenu();
|
|
3782
|
+
dismissClearPrompt();
|
|
3783
|
+
};
|
|
3784
|
+
const handleToggleToolbarMenu = () => {
|
|
3785
|
+
if (toolbarMenuPosition() !== null) dismissToolbarMenu();
|
|
3786
|
+
else {
|
|
3787
|
+
actions.hideContextMenu();
|
|
3788
|
+
dismissCommentsDropdown();
|
|
3789
|
+
dismissClearPrompt();
|
|
3790
|
+
openTrackedDropdown(setToolbarMenuPosition);
|
|
3791
|
+
}
|
|
3792
|
+
};
|
|
3793
|
+
const handleSetDefaultAction = (actionId) => {
|
|
3794
|
+
updateToolbarState({ defaultAction: actionId });
|
|
3795
|
+
};
|
|
3796
|
+
const handleToggleComments = () => {
|
|
3797
|
+
cancelCommentsHoverOpenTimeout();
|
|
3798
|
+
cancelCommentsHoverCloseTimeout();
|
|
3799
|
+
if (commentsDropdownPosition() !== null) if (isCommentsHoverOpen()) {
|
|
3800
|
+
clearCommentsHoverPreviews();
|
|
3801
|
+
setIsCommentsHoverOpen(false);
|
|
3802
|
+
} else dismissCommentsDropdown();
|
|
3803
|
+
else {
|
|
3804
|
+
clearCommentsHoverPreviews();
|
|
3805
|
+
openCommentsDropdown();
|
|
3806
|
+
}
|
|
3807
|
+
};
|
|
3808
|
+
const copyCommentItemContent = (item) => {
|
|
3809
|
+
copyContent(item.content, {
|
|
3810
|
+
tagName: item.tagName,
|
|
3811
|
+
componentName: item.componentName ?? item.elementName,
|
|
3812
|
+
commentText: item.commentText
|
|
3813
|
+
});
|
|
3814
|
+
const element = getFirstConnectedCommentElement(item);
|
|
3815
|
+
if (!element) return;
|
|
3816
|
+
clearAllLabels();
|
|
3817
|
+
nativeRequestAnimationFrame(() => {
|
|
3818
|
+
if (!isElementConnected(element)) return;
|
|
3819
|
+
const bounds = createElementBounds(element);
|
|
3820
|
+
const labelId = createLabelInstance(bounds, item.tagName, item.componentName, "copied", {
|
|
3821
|
+
element,
|
|
3822
|
+
mouseX: bounds.x + bounds.width / 2
|
|
3823
|
+
});
|
|
3824
|
+
if (labelId) scheduleLabelFade(labelId);
|
|
3825
|
+
});
|
|
3826
|
+
};
|
|
3827
|
+
const handleCommentItemSelect = (item) => {
|
|
3828
|
+
clearCommentsHoverPreviews();
|
|
3829
|
+
if (isPromptMode()) {
|
|
3830
|
+
actions.exitPromptMode();
|
|
3831
|
+
actions.clearInputText();
|
|
3832
|
+
}
|
|
3833
|
+
const element = getFirstConnectedCommentElement(item);
|
|
3834
|
+
if (item.commentText && element) {
|
|
3835
|
+
const center = getBoundsCenter(createElementBounds(element));
|
|
3836
|
+
actions.enterPromptMode(center, element);
|
|
3837
|
+
actions.setInputText(item.commentText);
|
|
3838
|
+
} else copyCommentItemContent(item);
|
|
3839
|
+
};
|
|
3840
|
+
const handleCommentsCopyAll = () => {
|
|
3841
|
+
clearCommentsHoverPreviews();
|
|
3842
|
+
const currentCommentItems = commentItems();
|
|
3843
|
+
if (currentCommentItems.length === 0) return;
|
|
3844
|
+
const combinedContent = joinSnippets(currentCommentItems.map((commentItem) => commentItem.content));
|
|
3845
|
+
const firstItem = currentCommentItems[0];
|
|
3846
|
+
copyContent(combinedContent, {
|
|
3847
|
+
componentName: firstItem.componentName ?? firstItem.tagName,
|
|
3848
|
+
entries: currentCommentItems.map((commentItem) => ({
|
|
3849
|
+
tagName: commentItem.tagName,
|
|
3850
|
+
componentName: commentItem.componentName ?? commentItem.elementName,
|
|
3851
|
+
content: commentItem.content,
|
|
3852
|
+
commentText: commentItem.commentText
|
|
3853
|
+
}))
|
|
3854
|
+
});
|
|
3855
|
+
if (isClearConfirmed()) handleCommentsClear();
|
|
3856
|
+
else showClearPrompt();
|
|
3857
|
+
clearAllLabels();
|
|
3858
|
+
nativeRequestAnimationFrame(() => {
|
|
3859
|
+
batch(() => {
|
|
3860
|
+
for (const commentItem of currentCommentItems) {
|
|
3861
|
+
const connectedElements = getConnectedCommentElements(commentItem);
|
|
3862
|
+
for (const element of connectedElements) {
|
|
3863
|
+
const bounds = createElementBounds(element);
|
|
3864
|
+
const labelId = generateId("label");
|
|
3865
|
+
actions.addLabelInstance({
|
|
3866
|
+
id: labelId,
|
|
3867
|
+
bounds,
|
|
3868
|
+
tagName: commentItem.tagName,
|
|
3869
|
+
componentName: commentItem.componentName,
|
|
3870
|
+
status: "copied",
|
|
3871
|
+
createdAt: Date.now(),
|
|
3872
|
+
element,
|
|
3873
|
+
mouseX: bounds.x + bounds.width / 2
|
|
3874
|
+
});
|
|
3875
|
+
scheduleLabelFade(labelId);
|
|
3876
|
+
}
|
|
3877
|
+
}
|
|
3878
|
+
});
|
|
3879
|
+
});
|
|
3880
|
+
};
|
|
3881
|
+
const handleCommentItemHover = (commentItemId) => {
|
|
3882
|
+
clearCommentsHoverPreviews();
|
|
3883
|
+
if (!commentItemId) return;
|
|
3884
|
+
const item = commentItems().find((innerItem) => innerItem.id === commentItemId);
|
|
3885
|
+
if (!item) return;
|
|
3886
|
+
showCommentItemPreview(item, "comment-hover");
|
|
3887
|
+
};
|
|
3888
|
+
const handleCommentsButtonHover = (isHovered) => {
|
|
3889
|
+
cancelCommentsHoverOpenTimeout();
|
|
3890
|
+
clearCommentsHoverPreviews();
|
|
3891
|
+
if (isHovered) {
|
|
3892
|
+
cancelCommentsHoverCloseTimeout();
|
|
3893
|
+
if (commentsDropdownPosition() === null && clearPromptPosition() === null) {
|
|
3894
|
+
showAllCommentItemPreviews();
|
|
3895
|
+
commentsHoverOpenTimeoutId = setTimeout(() => {
|
|
3896
|
+
commentsHoverOpenTimeoutId = null;
|
|
3897
|
+
setIsCommentsHoverOpen(true);
|
|
3898
|
+
openCommentsDropdown();
|
|
3899
|
+
}, 200);
|
|
3900
|
+
}
|
|
3901
|
+
} else if (isCommentsHoverOpen()) scheduleCommentsHoverClose();
|
|
3902
|
+
};
|
|
3903
|
+
const handleCommentsDropdownHover = (isHovered) => {
|
|
3904
|
+
if (isHovered) cancelCommentsHoverCloseTimeout();
|
|
3905
|
+
else if (isCommentsHoverOpen()) scheduleCommentsHoverClose();
|
|
3906
|
+
};
|
|
3907
|
+
const handleCommentsCopyAllHover = (isHovered) => {
|
|
3908
|
+
clearCommentsHoverPreviews();
|
|
3909
|
+
if (isHovered) {
|
|
3910
|
+
cancelCommentsHoverCloseTimeout();
|
|
3911
|
+
showAllCommentItemPreviews();
|
|
3912
|
+
} else if (isCommentsHoverOpen()) scheduleCommentsHoverClose();
|
|
3913
|
+
};
|
|
3914
|
+
const showAllCommentItemPreviews = () => {
|
|
3915
|
+
for (const item of commentItems()) showCommentItemPreview(item, "comment-all-hover");
|
|
3916
|
+
};
|
|
3917
|
+
const handleCommentsClear = () => {
|
|
3918
|
+
commentElementMap.clear();
|
|
3919
|
+
setCommentItems(clearComments());
|
|
3920
|
+
dismissCommentsDropdown();
|
|
3921
|
+
};
|
|
3922
|
+
const handleShowContextMenuInstance = (instanceId) => {
|
|
3923
|
+
const instance = store.labelInstances.find((labelInstance) => labelInstance.id === instanceId);
|
|
3924
|
+
if (!instance?.element) return;
|
|
3925
|
+
if (!isElementConnected(instance.element)) return;
|
|
3926
|
+
const contextMenuElement = instance.element;
|
|
3927
|
+
const center = getBoundsCenter(createElementBounds(contextMenuElement));
|
|
3928
|
+
const position = {
|
|
3929
|
+
x: instance.mouseX ?? center.x,
|
|
3930
|
+
y: center.y
|
|
3931
|
+
};
|
|
3932
|
+
const elementsToFreeze = instance.elements && instance.elements.length > 0 ? instance.elements.filter((element) => isElementConnected(element)) : [contextMenuElement];
|
|
3933
|
+
setTimeout(() => {
|
|
3934
|
+
if (!isActivated()) {
|
|
3935
|
+
actions.setWasActivatedByToggle(true);
|
|
3936
|
+
activateRenderer();
|
|
3937
|
+
}
|
|
3938
|
+
actions.setPointer(position);
|
|
3939
|
+
actions.setFrozenElements(elementsToFreeze);
|
|
3940
|
+
if (elementsToFreeze.length > 1 && instance.bounds) actions.setFrozenDragRect(createPageRectFromBounds(instance.bounds));
|
|
3941
|
+
actions.freeze();
|
|
3942
|
+
actions.showContextMenu(position, contextMenuElement);
|
|
3943
|
+
}, 0);
|
|
3944
|
+
};
|
|
3945
|
+
createEffect(() => {
|
|
3946
|
+
const hue = pluginRegistry.store.theme.hue;
|
|
3947
|
+
if (hue !== 0) rendererRoot.style.filter = `hue-rotate(${hue}deg)`;
|
|
3948
|
+
else rendererRoot.style.filter = "";
|
|
3949
|
+
});
|
|
3950
|
+
if (pluginRegistry.store.theme.enabled) import("./renderer-0mo5bvxE.js").then(({ ReactGrabRenderer }) => {
|
|
3951
|
+
if (disposed) return;
|
|
3952
|
+
disposeRenderer = render(() => {
|
|
3953
|
+
return createComponent(ReactGrabRenderer, {
|
|
3954
|
+
get selectionVisible() {
|
|
3955
|
+
return selectionVisible();
|
|
3956
|
+
},
|
|
3957
|
+
get selectionBounds() {
|
|
3958
|
+
return selectionBounds();
|
|
3959
|
+
},
|
|
3960
|
+
get selectionBoundsMultiple() {
|
|
3961
|
+
return selectionBoundsMultiple();
|
|
3962
|
+
},
|
|
3963
|
+
get selectionShouldSnap() {
|
|
3964
|
+
return store.frozenElements.length > 0 || dragPreviewBounds().length > 0;
|
|
3965
|
+
},
|
|
3966
|
+
get inspectVisible() {
|
|
3967
|
+
return memo(() => !!isInspectMode())() && inspectBounds().length > 0;
|
|
3968
|
+
},
|
|
3969
|
+
get inspectBounds() {
|
|
3970
|
+
return inspectBounds();
|
|
3971
|
+
},
|
|
3972
|
+
get selectionElementsCount() {
|
|
3973
|
+
return store.frozenElements.length;
|
|
3974
|
+
},
|
|
3975
|
+
get selectionFilePath() {
|
|
3976
|
+
return store.selectionFilePath ?? void 0;
|
|
3977
|
+
},
|
|
3978
|
+
get selectionLineNumber() {
|
|
3979
|
+
return store.selectionLineNumber ?? void 0;
|
|
3980
|
+
},
|
|
3981
|
+
get selectionTagName() {
|
|
3982
|
+
return selectionTagName();
|
|
3983
|
+
},
|
|
3984
|
+
get selectionComponentName() {
|
|
3985
|
+
return resolvedComponentName();
|
|
3986
|
+
},
|
|
3987
|
+
get selectionLabelVisible() {
|
|
3988
|
+
return selectionLabelVisible();
|
|
3989
|
+
},
|
|
3990
|
+
selectionLabelStatus: "idle",
|
|
3991
|
+
get selectionActionCycleState() {
|
|
3992
|
+
return actionCycleState();
|
|
3993
|
+
},
|
|
3994
|
+
get selectionArrowNavigationState() {
|
|
3995
|
+
return arrowNavigationState();
|
|
3996
|
+
},
|
|
3997
|
+
onArrowNavigationSelect: handleArrowNavigationSelect,
|
|
3998
|
+
get inspectNavigationState() {
|
|
3999
|
+
return inspectNavigationState();
|
|
4000
|
+
},
|
|
4001
|
+
onInspectSelect: handleInspectSelect,
|
|
4002
|
+
get labelInstances() {
|
|
4003
|
+
return computedLabelInstances();
|
|
4004
|
+
},
|
|
4005
|
+
get dragVisible() {
|
|
4006
|
+
return dragVisible();
|
|
4007
|
+
},
|
|
4008
|
+
get dragBounds() {
|
|
4009
|
+
return dragBounds();
|
|
4010
|
+
},
|
|
4011
|
+
get grabbedBoxes() {
|
|
4012
|
+
return computedGrabbedBoxes();
|
|
4013
|
+
},
|
|
4014
|
+
get mouseX() {
|
|
4015
|
+
return memo(() => store.frozenElements.length > 1)() ? void 0 : cursorPosition().x;
|
|
4016
|
+
},
|
|
4017
|
+
get isFrozen() {
|
|
4018
|
+
return isFrozenPhase() || isActivated() || isToolbarSelectHovered();
|
|
4019
|
+
},
|
|
4020
|
+
get inputValue() {
|
|
4021
|
+
return store.inputText;
|
|
4022
|
+
},
|
|
4023
|
+
get isPromptMode() {
|
|
4024
|
+
return isPromptMode();
|
|
4025
|
+
},
|
|
4026
|
+
onShowContextMenuInstance: handleShowContextMenuInstance,
|
|
4027
|
+
onLabelInstanceHoverChange: handleLabelInstanceHoverChange,
|
|
4028
|
+
get onInputChange() {
|
|
4029
|
+
return actions.setInputText;
|
|
4030
|
+
},
|
|
4031
|
+
onInputSubmit: () => void handleInputSubmit(),
|
|
4032
|
+
onToggleExpand: handleToggleExpand,
|
|
4033
|
+
get isPendingDismiss() {
|
|
4034
|
+
return isPendingDismiss();
|
|
4035
|
+
},
|
|
4036
|
+
get selectionLabelShakeCount() {
|
|
4037
|
+
return selectionLabelShakeCount();
|
|
4038
|
+
},
|
|
4039
|
+
onConfirmDismiss: handleConfirmDismiss,
|
|
4040
|
+
onCancelDismiss: handleCancelDismiss,
|
|
4041
|
+
get toolbarVisible() {
|
|
4042
|
+
return pluginRegistry.store.theme.toolbar.enabled;
|
|
4043
|
+
},
|
|
4044
|
+
get isActive() {
|
|
4045
|
+
return isActivated();
|
|
4046
|
+
},
|
|
4047
|
+
onToggleActive: handleToggleActive,
|
|
4048
|
+
get enabled() {
|
|
4049
|
+
return isEnabled();
|
|
4050
|
+
},
|
|
4051
|
+
onToggleEnabled: handleToggleEnabled,
|
|
4052
|
+
get shakeCount() {
|
|
4053
|
+
return toolbarShakeCount();
|
|
4054
|
+
},
|
|
4055
|
+
onToolbarStateChange: (state) => {
|
|
4056
|
+
setCurrentToolbarState(state);
|
|
4057
|
+
toolbarStateChangeCallbacks.forEach((callback) => callback(state));
|
|
4058
|
+
},
|
|
4059
|
+
onSubscribeToToolbarStateChanges: (callback) => {
|
|
4060
|
+
toolbarStateChangeCallbacks.add(callback);
|
|
4061
|
+
return () => {
|
|
4062
|
+
toolbarStateChangeCallbacks.delete(callback);
|
|
4063
|
+
};
|
|
4064
|
+
},
|
|
4065
|
+
onToolbarSelectHoverChange: setIsToolbarSelectHovered,
|
|
4066
|
+
onToolbarRef: (element) => {
|
|
4067
|
+
toolbarElement = element;
|
|
4068
|
+
},
|
|
4069
|
+
get contextMenuPosition() {
|
|
4070
|
+
return contextMenuPosition();
|
|
4071
|
+
},
|
|
4072
|
+
get contextMenuBounds() {
|
|
4073
|
+
return contextMenuBounds();
|
|
4074
|
+
},
|
|
4075
|
+
get contextMenuTagName() {
|
|
4076
|
+
return contextMenuTagName();
|
|
4077
|
+
},
|
|
4078
|
+
get contextMenuComponentName() {
|
|
4079
|
+
return contextMenuComponentName();
|
|
4080
|
+
},
|
|
4081
|
+
get contextMenuHasFilePath() {
|
|
4082
|
+
return Boolean(contextMenuFilePath()?.filePath);
|
|
4083
|
+
},
|
|
4084
|
+
get actions() {
|
|
4085
|
+
return pluginRegistry.store.actions;
|
|
4086
|
+
},
|
|
4087
|
+
get actionContext() {
|
|
4088
|
+
return contextMenuActionContext();
|
|
4089
|
+
},
|
|
4090
|
+
onContextMenuDismiss: handleContextMenuDismiss,
|
|
4091
|
+
onContextMenuHide: deferHideContextMenu,
|
|
4092
|
+
get commentItems() {
|
|
4093
|
+
return commentItems();
|
|
4094
|
+
},
|
|
4095
|
+
get commentsDisconnectedItemIds() {
|
|
4096
|
+
return commentsDisconnectedItemIds();
|
|
4097
|
+
},
|
|
4098
|
+
get commentItemCount() {
|
|
4099
|
+
return commentItems().length;
|
|
4100
|
+
},
|
|
4101
|
+
get clockFlashTrigger() {
|
|
4102
|
+
return clockFlashTrigger();
|
|
4103
|
+
},
|
|
4104
|
+
get commentsDropdownPosition() {
|
|
4105
|
+
return commentsDropdownPosition();
|
|
4106
|
+
},
|
|
4107
|
+
get isCommentsPinned() {
|
|
4108
|
+
return memo(() => commentsDropdownPosition() !== null)() && !isCommentsHoverOpen();
|
|
4109
|
+
},
|
|
4110
|
+
onToggleComments: handleToggleComments,
|
|
4111
|
+
onCopyAll: handleCommentsCopyAll,
|
|
4112
|
+
onCopyAllHover: handleCommentsCopyAllHover,
|
|
4113
|
+
onCommentsButtonHover: handleCommentsButtonHover,
|
|
4114
|
+
onCommentItemSelect: handleCommentItemSelect,
|
|
4115
|
+
onCommentItemHover: handleCommentItemHover,
|
|
4116
|
+
onCommentsCopyAll: handleCommentsCopyAll,
|
|
4117
|
+
onCommentsCopyAllHover: handleCommentsCopyAllHover,
|
|
4118
|
+
onCommentsClear: handleCommentsClear,
|
|
4119
|
+
onCommentsDismiss: dismissCommentsDropdown,
|
|
4120
|
+
onCommentsDropdownHover: handleCommentsDropdownHover,
|
|
4121
|
+
get toolbarMenuPosition() {
|
|
4122
|
+
return toolbarMenuPosition();
|
|
4123
|
+
},
|
|
4124
|
+
get toolbarMenuActions() {
|
|
4125
|
+
return pluginRegistry.store.actions.filter((action) => action.showInToolbarMenu === true);
|
|
4126
|
+
},
|
|
4127
|
+
get defaultActionId() {
|
|
4128
|
+
return currentToolbarState()?.defaultAction ?? "comment";
|
|
4129
|
+
},
|
|
4130
|
+
onSetDefaultAction: handleSetDefaultAction,
|
|
4131
|
+
onToggleToolbarMenu: handleToggleToolbarMenu,
|
|
4132
|
+
onToolbarMenuDismiss: dismissToolbarMenu,
|
|
4133
|
+
get clearPromptPosition() {
|
|
4134
|
+
return clearPromptPosition();
|
|
4135
|
+
},
|
|
4136
|
+
onClearCommentsConfirm: () => {
|
|
4137
|
+
confirmClear();
|
|
4138
|
+
dismissClearPrompt();
|
|
4139
|
+
handleCommentsClear();
|
|
4140
|
+
},
|
|
4141
|
+
onClearCommentsCancel: dismissClearPrompt
|
|
4142
|
+
});
|
|
4143
|
+
}, rendererRoot);
|
|
4144
|
+
}).catch((error) => {
|
|
4145
|
+
console.warn("[react-grab] Failed to load renderer:", error);
|
|
4146
|
+
});
|
|
4147
|
+
const copyElementAPI = async (elements) => {
|
|
4148
|
+
const elementsArray = Array.isArray(elements) ? elements : [elements];
|
|
4149
|
+
if (elementsArray.length === 0) return false;
|
|
4150
|
+
return await copyWithFallback(elementsArray);
|
|
4151
|
+
};
|
|
4152
|
+
const api = {
|
|
4153
|
+
activate: () => {
|
|
4154
|
+
actions.setPendingCommentMode(false);
|
|
4155
|
+
if (!isActivated() && isEnabled()) toggleActivate();
|
|
4156
|
+
},
|
|
4157
|
+
deactivate: () => {
|
|
4158
|
+
if (isActivated() || isCopying()) deactivateRenderer();
|
|
4159
|
+
},
|
|
4160
|
+
toggle: () => {
|
|
4161
|
+
if (isActivated()) deactivateRenderer();
|
|
4162
|
+
else if (isEnabled()) toggleActivate();
|
|
4163
|
+
},
|
|
4164
|
+
comment: handleComment,
|
|
4165
|
+
isActive: () => isActivated(),
|
|
4166
|
+
isEnabled: () => isEnabled(),
|
|
4167
|
+
setEnabled: (enabled) => {
|
|
4168
|
+
if (enabled === isEnabled()) return;
|
|
4169
|
+
setIsEnabled(enabled);
|
|
4170
|
+
if (!enabled) forceDeactivateAll();
|
|
4171
|
+
},
|
|
4172
|
+
getToolbarState: () => loadToolbarState(),
|
|
4173
|
+
setToolbarState: (state) => {
|
|
4174
|
+
const currentState = loadToolbarState();
|
|
4175
|
+
const newState = {
|
|
4176
|
+
edge: state.edge ?? currentState?.edge ?? "bottom",
|
|
4177
|
+
ratio: state.ratio ?? currentState?.ratio ?? .5,
|
|
4178
|
+
collapsed: state.collapsed ?? currentState?.collapsed ?? false,
|
|
4179
|
+
enabled: state.enabled ?? currentState?.enabled ?? true,
|
|
4180
|
+
defaultAction: state.defaultAction ?? currentState?.defaultAction ?? "comment"
|
|
4181
|
+
};
|
|
4182
|
+
saveToolbarState(newState);
|
|
4183
|
+
setCurrentToolbarState(newState);
|
|
4184
|
+
if (state.enabled !== void 0 && state.enabled !== isEnabled()) setIsEnabled(state.enabled);
|
|
4185
|
+
toolbarStateChangeCallbacks.forEach((callback) => callback(newState));
|
|
4186
|
+
},
|
|
4187
|
+
onToolbarStateChange: (callback) => {
|
|
4188
|
+
toolbarStateChangeCallbacks.add(callback);
|
|
4189
|
+
return () => {
|
|
4190
|
+
toolbarStateChangeCallbacks.delete(callback);
|
|
4191
|
+
};
|
|
4192
|
+
},
|
|
4193
|
+
dispose: () => {
|
|
4194
|
+
disposed = true;
|
|
4195
|
+
hasInited = false;
|
|
4196
|
+
disposeRenderer?.();
|
|
4197
|
+
cancelCommentsHoverOpenTimeout();
|
|
4198
|
+
cancelCommentsHoverCloseTimeout();
|
|
4199
|
+
stopTrackingDropdownPosition();
|
|
4200
|
+
toolbarStateChangeCallbacks.clear();
|
|
4201
|
+
dispose();
|
|
4202
|
+
},
|
|
4203
|
+
copyElement: copyElementAPI,
|
|
4204
|
+
getSource: async (element) => {
|
|
4205
|
+
const source = await resolveSource(element);
|
|
4206
|
+
if (!source) return null;
|
|
4207
|
+
return {
|
|
4208
|
+
filePath: source.filePath,
|
|
4209
|
+
lineNumber: source.lineNumber,
|
|
4210
|
+
componentName: source.componentName
|
|
4211
|
+
};
|
|
4212
|
+
},
|
|
4213
|
+
getStackContext,
|
|
4214
|
+
getState: () => ({
|
|
4215
|
+
isActive: isActivated(),
|
|
4216
|
+
isDragging: isDragging(),
|
|
4217
|
+
isCopying: isCopying(),
|
|
4218
|
+
isPromptMode: isPromptMode(),
|
|
4219
|
+
isSelectionBoxVisible: Boolean(selectionVisible()),
|
|
4220
|
+
isDragBoxVisible: Boolean(dragVisible()),
|
|
4221
|
+
targetElement: targetElement(),
|
|
4222
|
+
dragBounds: dragBounds() ?? null,
|
|
4223
|
+
grabbedBoxes: [...publicGrabbedBoxes()],
|
|
4224
|
+
labelInstances: [...publicLabelInstances()],
|
|
4225
|
+
selectionFilePath: store.selectionFilePath,
|
|
4226
|
+
toolbarState: currentToolbarState()
|
|
4227
|
+
}),
|
|
4228
|
+
setOptions: (newOptions) => {
|
|
4229
|
+
pluginRegistry.setOptions(newOptions);
|
|
4230
|
+
},
|
|
4231
|
+
registerPlugin: (plugin) => {
|
|
4232
|
+
pluginRegistry.register(plugin, api);
|
|
4233
|
+
},
|
|
4234
|
+
unregisterPlugin: (name) => {
|
|
4235
|
+
pluginRegistry.unregister(name);
|
|
4236
|
+
},
|
|
4237
|
+
getPlugins: () => pluginRegistry.getPluginNames(),
|
|
4238
|
+
getDisplayName: getComponentDisplayName
|
|
4239
|
+
};
|
|
4240
|
+
for (const plugin of builtInPlugins) pluginRegistry.register(plugin, api);
|
|
4241
|
+
setTimeout(() => {
|
|
4242
|
+
checkIsNextProject(true);
|
|
4243
|
+
}, NEXTJS_REVALIDATION_DELAY_MS);
|
|
4244
|
+
return api;
|
|
4245
|
+
});
|
|
4246
|
+
};
|
|
4247
|
+
|
|
4248
|
+
//#endregion
|
|
4249
|
+
export { generateSnippet as a, DEFAULT_THEME as i, openPlugin as n, copyContent as o, commentPlugin as r, init as t };
|