@mountaya/elements 0.0.0-stage → 0.1.0
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/CHANGELOG.md +235 -0
- package/LICENCE.fr.txt +280 -0
- package/LICENSE.txt +262 -0
- package/README.md +1509 -2
- package/THIRD-PARTY-NOTICES.txt +103 -0
- package/dist/accentColor-GNKBD2CW.js +4 -0
- package/dist/accentColor-GNKBD2CW.js.map +1 -0
- package/dist/accentColor-VX2JSMGE.cjs +17 -0
- package/dist/accentColor-VX2JSMGE.cjs.map +1 -0
- package/dist/agent/index.cjs +1964 -0
- package/dist/agent/index.cjs.map +1 -0
- package/dist/agent/index.d.cts +2016 -0
- package/dist/agent/index.d.ts +2016 -0
- package/dist/agent/index.js +1937 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/amenities-B3-qAjxu.d.cts +160 -0
- package/dist/amenities-B3-qAjxu.d.ts +160 -0
- package/dist/bundle-Je5zsRFg.d.cts +222 -0
- package/dist/bundle-xYrrbJTH.d.ts +222 -0
- package/dist/camera/index.cjs +3477 -0
- package/dist/camera/index.cjs.map +1 -0
- package/dist/camera/index.d.cts +1751 -0
- package/dist/camera/index.d.ts +1751 -0
- package/dist/camera/index.js +3328 -0
- package/dist/camera/index.js.map +1 -0
- package/dist/camera-BrFLU1DH.d.cts +549 -0
- package/dist/camera-C48Ykaxv.d.ts +549 -0
- package/dist/chunk-23PFRRB6.js +3 -0
- package/dist/chunk-23PFRRB6.js.map +1 -0
- package/dist/chunk-2GI5SAH2.js +71 -0
- package/dist/chunk-2GI5SAH2.js.map +1 -0
- package/dist/chunk-2MQK6A74.js +39 -0
- package/dist/chunk-2MQK6A74.js.map +1 -0
- package/dist/chunk-2RE7R4LD.js +73 -0
- package/dist/chunk-2RE7R4LD.js.map +1 -0
- package/dist/chunk-3JZQKN4O.js +6 -0
- package/dist/chunk-3JZQKN4O.js.map +1 -0
- package/dist/chunk-3NDXVUUI.js +50 -0
- package/dist/chunk-3NDXVUUI.js.map +1 -0
- package/dist/chunk-3R4GFTUM.cjs +59 -0
- package/dist/chunk-3R4GFTUM.cjs.map +1 -0
- package/dist/chunk-3RVUQ6JN.cjs +22 -0
- package/dist/chunk-3RVUQ6JN.cjs.map +1 -0
- package/dist/chunk-4F6BJMJC.cjs +49 -0
- package/dist/chunk-4F6BJMJC.cjs.map +1 -0
- package/dist/chunk-4NWQD4BX.js +132 -0
- package/dist/chunk-4NWQD4BX.js.map +1 -0
- package/dist/chunk-5K2MH3R6.js +10 -0
- package/dist/chunk-5K2MH3R6.js.map +1 -0
- package/dist/chunk-6ACRNQQQ.cjs +8 -0
- package/dist/chunk-6ACRNQQQ.cjs.map +1 -0
- package/dist/chunk-6D26E3IA.js +66 -0
- package/dist/chunk-6D26E3IA.js.map +1 -0
- package/dist/chunk-6ESAW35P.cjs +80 -0
- package/dist/chunk-6ESAW35P.cjs.map +1 -0
- package/dist/chunk-6LIW2A5M.cjs +1176 -0
- package/dist/chunk-6LIW2A5M.cjs.map +1 -0
- package/dist/chunk-6OTTWVCA.js +57 -0
- package/dist/chunk-6OTTWVCA.js.map +1 -0
- package/dist/chunk-6VROJ4UG.js +862 -0
- package/dist/chunk-6VROJ4UG.js.map +1 -0
- package/dist/chunk-6Y7FTGO4.js +23 -0
- package/dist/chunk-6Y7FTGO4.js.map +1 -0
- package/dist/chunk-75I4CG64.js +104 -0
- package/dist/chunk-75I4CG64.js.map +1 -0
- package/dist/chunk-7CUBXHAH.cjs +14 -0
- package/dist/chunk-7CUBXHAH.cjs.map +1 -0
- package/dist/chunk-7GTCURVY.js +52 -0
- package/dist/chunk-7GTCURVY.js.map +1 -0
- package/dist/chunk-7IWOL6AM.cjs +100 -0
- package/dist/chunk-7IWOL6AM.cjs.map +1 -0
- package/dist/chunk-7QN7M667.cjs +151 -0
- package/dist/chunk-7QN7M667.cjs.map +1 -0
- package/dist/chunk-A6KQDKLM.cjs +1197 -0
- package/dist/chunk-A6KQDKLM.cjs.map +1 -0
- package/dist/chunk-A77EA67G.js +354 -0
- package/dist/chunk-A77EA67G.js.map +1 -0
- package/dist/chunk-AFKOABJ4.cjs +7194 -0
- package/dist/chunk-AFKOABJ4.cjs.map +1 -0
- package/dist/chunk-AG6JV5Z2.cjs +183 -0
- package/dist/chunk-AG6JV5Z2.cjs.map +1 -0
- package/dist/chunk-APBK7NMS.js +30 -0
- package/dist/chunk-APBK7NMS.js.map +1 -0
- package/dist/chunk-AWO5YA7A.cjs +33 -0
- package/dist/chunk-AWO5YA7A.cjs.map +1 -0
- package/dist/chunk-AZATU6QW.js +108 -0
- package/dist/chunk-AZATU6QW.js.map +1 -0
- package/dist/chunk-BD2U3WST.cjs +623 -0
- package/dist/chunk-BD2U3WST.cjs.map +1 -0
- package/dist/chunk-BHBEOU6L.cjs +65 -0
- package/dist/chunk-BHBEOU6L.cjs.map +1 -0
- package/dist/chunk-CNOSNYNE.js +8 -0
- package/dist/chunk-CNOSNYNE.js.map +1 -0
- package/dist/chunk-CW3EFR4O.js +12 -0
- package/dist/chunk-CW3EFR4O.js.map +1 -0
- package/dist/chunk-DASVRNBK.js +7187 -0
- package/dist/chunk-DASVRNBK.js.map +1 -0
- package/dist/chunk-DJ6LCKYP.js +42 -0
- package/dist/chunk-DJ6LCKYP.js.map +1 -0
- package/dist/chunk-E5FHQAIO.cjs +45 -0
- package/dist/chunk-E5FHQAIO.cjs.map +1 -0
- package/dist/chunk-EOML5OTY.cjs +360 -0
- package/dist/chunk-EOML5OTY.cjs.map +1 -0
- package/dist/chunk-EP5CASHL.js +613 -0
- package/dist/chunk-EP5CASHL.js.map +1 -0
- package/dist/chunk-EP5OEEVZ.cjs +14 -0
- package/dist/chunk-EP5OEEVZ.cjs.map +1 -0
- package/dist/chunk-EUXI3FGQ.js +150 -0
- package/dist/chunk-EUXI3FGQ.js.map +1 -0
- package/dist/chunk-EWFSHCOS.js +40 -0
- package/dist/chunk-EWFSHCOS.js.map +1 -0
- package/dist/chunk-EX2C5K2T.cjs +25 -0
- package/dist/chunk-EX2C5K2T.cjs.map +1 -0
- package/dist/chunk-FEXWDQIZ.cjs +8 -0
- package/dist/chunk-FEXWDQIZ.cjs.map +1 -0
- package/dist/chunk-FEYBFY7H.cjs +358 -0
- package/dist/chunk-FEYBFY7H.cjs.map +1 -0
- package/dist/chunk-FRGAV6N6.cjs +34 -0
- package/dist/chunk-FRGAV6N6.cjs.map +1 -0
- package/dist/chunk-G5DHP5VF.js +6 -0
- package/dist/chunk-G5DHP5VF.js.map +1 -0
- package/dist/chunk-G5W2UHV2.js +99 -0
- package/dist/chunk-G5W2UHV2.js.map +1 -0
- package/dist/chunk-G7OP7O2C.cjs +39 -0
- package/dist/chunk-G7OP7O2C.cjs.map +1 -0
- package/dist/chunk-GE6CFCAM.cjs +25 -0
- package/dist/chunk-GE6CFCAM.cjs.map +1 -0
- package/dist/chunk-GIFALLHI.cjs +111 -0
- package/dist/chunk-GIFALLHI.cjs.map +1 -0
- package/dist/chunk-GLFET5GM.js +129 -0
- package/dist/chunk-GLFET5GM.js.map +1 -0
- package/dist/chunk-GQ6UFPFM.js +22 -0
- package/dist/chunk-GQ6UFPFM.js.map +1 -0
- package/dist/chunk-GQJWVMXS.js +129 -0
- package/dist/chunk-GQJWVMXS.js.map +1 -0
- package/dist/chunk-GVVJPUKC.js +80 -0
- package/dist/chunk-GVVJPUKC.js.map +1 -0
- package/dist/chunk-GZ2HOCQ2.cjs +134 -0
- package/dist/chunk-GZ2HOCQ2.cjs.map +1 -0
- package/dist/chunk-HCBOHXWP.js +37 -0
- package/dist/chunk-HCBOHXWP.js.map +1 -0
- package/dist/chunk-IBQJDVHF.cjs +281 -0
- package/dist/chunk-IBQJDVHF.cjs.map +1 -0
- package/dist/chunk-ISLB6Y5Q.cjs +106 -0
- package/dist/chunk-ISLB6Y5Q.cjs.map +1 -0
- package/dist/chunk-J55CRR4F.js +105 -0
- package/dist/chunk-J55CRR4F.js.map +1 -0
- package/dist/chunk-JBG6Z6MQ.cjs +28 -0
- package/dist/chunk-JBG6Z6MQ.cjs.map +1 -0
- package/dist/chunk-K3RQOZRU.js +61 -0
- package/dist/chunk-K3RQOZRU.js.map +1 -0
- package/dist/chunk-KDJYS4GB.cjs +703 -0
- package/dist/chunk-KDJYS4GB.cjs.map +1 -0
- package/dist/chunk-KMCAHUZM.cjs +4 -0
- package/dist/chunk-KMCAHUZM.cjs.map +1 -0
- package/dist/chunk-KUCBNPC6.js +87 -0
- package/dist/chunk-KUCBNPC6.js.map +1 -0
- package/dist/chunk-KV6UE5A4.js +50 -0
- package/dist/chunk-KV6UE5A4.js.map +1 -0
- package/dist/chunk-L6TZ2HQR.cjs +18 -0
- package/dist/chunk-L6TZ2HQR.cjs.map +1 -0
- package/dist/chunk-L7QHHGG2.cjs +141 -0
- package/dist/chunk-L7QHHGG2.cjs.map +1 -0
- package/dist/chunk-LHK3Y2AL.js +271 -0
- package/dist/chunk-LHK3Y2AL.js.map +1 -0
- package/dist/chunk-LO5RYRBH.cjs +6317 -0
- package/dist/chunk-LO5RYRBH.cjs.map +1 -0
- package/dist/chunk-LS5SJMUO.cjs +194 -0
- package/dist/chunk-LS5SJMUO.cjs.map +1 -0
- package/dist/chunk-LUGTMZFN.cjs +42 -0
- package/dist/chunk-LUGTMZFN.cjs.map +1 -0
- package/dist/chunk-LVUQU6D5.js +32 -0
- package/dist/chunk-LVUQU6D5.js.map +1 -0
- package/dist/chunk-M2QRC2GZ.js +166 -0
- package/dist/chunk-M2QRC2GZ.js.map +1 -0
- package/dist/chunk-M6QJYQIM.cjs +53 -0
- package/dist/chunk-M6QJYQIM.cjs.map +1 -0
- package/dist/chunk-MGCPH5EO.js +12 -0
- package/dist/chunk-MGCPH5EO.js.map +1 -0
- package/dist/chunk-MLVUWEZR.cjs +474 -0
- package/dist/chunk-MLVUWEZR.cjs.map +1 -0
- package/dist/chunk-MTAMJMZL.cjs +707 -0
- package/dist/chunk-MTAMJMZL.cjs.map +1 -0
- package/dist/chunk-MXL5AT3N.js +48 -0
- package/dist/chunk-MXL5AT3N.js.map +1 -0
- package/dist/chunk-MYEQSESM.cjs +75 -0
- package/dist/chunk-MYEQSESM.cjs.map +1 -0
- package/dist/chunk-N3VPF6ZD.js +427 -0
- package/dist/chunk-N3VPF6ZD.js.map +1 -0
- package/dist/chunk-N6VUAIGI.js +7 -0
- package/dist/chunk-N6VUAIGI.js.map +1 -0
- package/dist/chunk-N6XRLUN6.js +6286 -0
- package/dist/chunk-N6XRLUN6.js.map +1 -0
- package/dist/chunk-NOGDOZIT.cjs +114 -0
- package/dist/chunk-NOGDOZIT.cjs.map +1 -0
- package/dist/chunk-NUWXEISH.cjs +10 -0
- package/dist/chunk-NUWXEISH.cjs.map +1 -0
- package/dist/chunk-NZCZHXYN.cjs +161 -0
- package/dist/chunk-NZCZHXYN.cjs.map +1 -0
- package/dist/chunk-ODROSWQX.cjs +53 -0
- package/dist/chunk-ODROSWQX.cjs.map +1 -0
- package/dist/chunk-OE36AYKG.cjs +82 -0
- package/dist/chunk-OE36AYKG.cjs.map +1 -0
- package/dist/chunk-OLON7MO6.cjs +437 -0
- package/dist/chunk-OLON7MO6.cjs.map +1 -0
- package/dist/chunk-PBUOR2IT.js +277 -0
- package/dist/chunk-PBUOR2IT.js.map +1 -0
- package/dist/chunk-PC2ELXFF.cjs +225 -0
- package/dist/chunk-PC2ELXFF.cjs.map +1 -0
- package/dist/chunk-PCSGXLOC.js +71 -0
- package/dist/chunk-PCSGXLOC.js.map +1 -0
- package/dist/chunk-PFNMP6FQ.js +56 -0
- package/dist/chunk-PFNMP6FQ.js.map +1 -0
- package/dist/chunk-PIWSZTIP.js +690 -0
- package/dist/chunk-PIWSZTIP.js.map +1 -0
- package/dist/chunk-PKWHJ2GI.js +136 -0
- package/dist/chunk-PKWHJ2GI.js.map +1 -0
- package/dist/chunk-PLMVBX2A.cjs +76 -0
- package/dist/chunk-PLMVBX2A.cjs.map +1 -0
- package/dist/chunk-PM3XCD2G.cjs +113 -0
- package/dist/chunk-PM3XCD2G.cjs.map +1 -0
- package/dist/chunk-QAL4GZO7.cjs +143 -0
- package/dist/chunk-QAL4GZO7.cjs.map +1 -0
- package/dist/chunk-QDB2SEA2.js +74 -0
- package/dist/chunk-QDB2SEA2.js.map +1 -0
- package/dist/chunk-QOV7UNUN.js +25 -0
- package/dist/chunk-QOV7UNUN.js.map +1 -0
- package/dist/chunk-QQUWYLSF.cjs +50 -0
- package/dist/chunk-QQUWYLSF.cjs.map +1 -0
- package/dist/chunk-QUMBH3U4.cjs +9 -0
- package/dist/chunk-QUMBH3U4.cjs.map +1 -0
- package/dist/chunk-R4KA7OFQ.js +12 -0
- package/dist/chunk-R4KA7OFQ.js.map +1 -0
- package/dist/chunk-RBSGAZQQ.js +17 -0
- package/dist/chunk-RBSGAZQQ.js.map +1 -0
- package/dist/chunk-RM5YJWZI.js +46 -0
- package/dist/chunk-RM5YJWZI.js.map +1 -0
- package/dist/chunk-ROKNKXA4.cjs +8 -0
- package/dist/chunk-ROKNKXA4.cjs.map +1 -0
- package/dist/chunk-RQG6D546.cjs +75 -0
- package/dist/chunk-RQG6D546.cjs.map +1 -0
- package/dist/chunk-SG4YDD5L.cjs +74 -0
- package/dist/chunk-SG4YDD5L.cjs.map +1 -0
- package/dist/chunk-SNRCA7EO.js +56 -0
- package/dist/chunk-SNRCA7EO.js.map +1 -0
- package/dist/chunk-SO75R4WW.cjs +22 -0
- package/dist/chunk-SO75R4WW.cjs.map +1 -0
- package/dist/chunk-SP34NHFI.js +45 -0
- package/dist/chunk-SP34NHFI.js.map +1 -0
- package/dist/chunk-SSKSSBWJ.cjs +179 -0
- package/dist/chunk-SSKSSBWJ.cjs.map +1 -0
- package/dist/chunk-TB5663C2.js +1108 -0
- package/dist/chunk-TB5663C2.js.map +1 -0
- package/dist/chunk-TGH4NRES.js +220 -0
- package/dist/chunk-TGH4NRES.js.map +1 -0
- package/dist/chunk-TJ6ZPNID.js +189 -0
- package/dist/chunk-TJ6ZPNID.js.map +1 -0
- package/dist/chunk-U45T35N2.cjs +90 -0
- package/dist/chunk-U45T35N2.cjs.map +1 -0
- package/dist/chunk-UKVOPEZ2.js +442 -0
- package/dist/chunk-UKVOPEZ2.js.map +1 -0
- package/dist/chunk-UTB4NROA.cjs +887 -0
- package/dist/chunk-UTB4NROA.cjs.map +1 -0
- package/dist/chunk-UTW33B5V.js +6 -0
- package/dist/chunk-UTW33B5V.js.map +1 -0
- package/dist/chunk-UYUBSD2V.cjs +33 -0
- package/dist/chunk-UYUBSD2V.cjs.map +1 -0
- package/dist/chunk-V3JEP5AG.cjs +59 -0
- package/dist/chunk-V3JEP5AG.cjs.map +1 -0
- package/dist/chunk-VFAGJXHR.js +18 -0
- package/dist/chunk-VFAGJXHR.js.map +1 -0
- package/dist/chunk-VMEE57E5.cjs +58 -0
- package/dist/chunk-VMEE57E5.cjs.map +1 -0
- package/dist/chunk-VQVBEX3Y.cjs +113 -0
- package/dist/chunk-VQVBEX3Y.cjs.map +1 -0
- package/dist/chunk-VZDXX7TT.cjs +64 -0
- package/dist/chunk-VZDXX7TT.cjs.map +1 -0
- package/dist/chunk-WE5ZTI4D.js +346 -0
- package/dist/chunk-WE5ZTI4D.js.map +1 -0
- package/dist/chunk-WEFUVABP.js +19 -0
- package/dist/chunk-WEFUVABP.js.map +1 -0
- package/dist/chunk-WMU4LRKC.js +28 -0
- package/dist/chunk-WMU4LRKC.js.map +1 -0
- package/dist/chunk-WQ24RRHL.cjs +354 -0
- package/dist/chunk-WQ24RRHL.cjs.map +1 -0
- package/dist/chunk-WW4CGS7G.cjs +26 -0
- package/dist/chunk-WW4CGS7G.cjs.map +1 -0
- package/dist/chunk-WXE5WCTM.js +1144 -0
- package/dist/chunk-WXE5WCTM.js.map +1 -0
- package/dist/chunk-X23BGIYA.cjs +37 -0
- package/dist/chunk-X23BGIYA.cjs.map +1 -0
- package/dist/chunk-XEW4FTR2.js +98 -0
- package/dist/chunk-XEW4FTR2.js.map +1 -0
- package/dist/chunk-XIOI4IYW.js +167 -0
- package/dist/chunk-XIOI4IYW.js.map +1 -0
- package/dist/chunk-XLVPJ37V.cjs +44 -0
- package/dist/chunk-XLVPJ37V.cjs.map +1 -0
- package/dist/chunk-XOHAXXZA.cjs +51 -0
- package/dist/chunk-XOHAXXZA.cjs.map +1 -0
- package/dist/chunk-Y4NRIHK6.cjs +313 -0
- package/dist/chunk-Y4NRIHK6.cjs.map +1 -0
- package/dist/chunk-Y4YMMKL3.js +23 -0
- package/dist/chunk-Y4YMMKL3.js.map +1 -0
- package/dist/chunk-YJNYBVE3.cjs +14 -0
- package/dist/chunk-YJNYBVE3.cjs.map +1 -0
- package/dist/chunk-Z762QNQP.cjs +60 -0
- package/dist/chunk-Z762QNQP.cjs.map +1 -0
- package/dist/chunk-ZG5KMBOF.js +669 -0
- package/dist/chunk-ZG5KMBOF.js.map +1 -0
- package/dist/chunk-ZKONQEFA.js +344 -0
- package/dist/chunk-ZKONQEFA.js.map +1 -0
- package/dist/chunk-ZR5X7QMH.js +39 -0
- package/dist/chunk-ZR5X7QMH.js.map +1 -0
- package/dist/chunk-ZW4BJQ26.js +84 -0
- package/dist/chunk-ZW4BJQ26.js.map +1 -0
- package/dist/climbs-BhlWuu0x.d.ts +70 -0
- package/dist/climbs-DgBFwySV.d.cts +70 -0
- package/dist/collab/index.cjs +1283 -0
- package/dist/collab/index.cjs.map +1 -0
- package/dist/collab/index.d.cts +850 -0
- package/dist/collab/index.d.ts +850 -0
- package/dist/collab/index.js +1274 -0
- package/dist/collab/index.js.map +1 -0
- package/dist/data/index.cjs +132 -0
- package/dist/data/index.cjs.map +1 -0
- package/dist/data/index.d.cts +468 -0
- package/dist/data/index.d.ts +468 -0
- package/dist/data/index.js +15 -0
- package/dist/data/index.js.map +1 -0
- package/dist/editor/index.cjs +4506 -0
- package/dist/editor/index.cjs.map +1 -0
- package/dist/editor/index.d.cts +59 -0
- package/dist/editor/index.d.ts +59 -0
- package/dist/editor/index.js +4486 -0
- package/dist/editor/index.js.map +1 -0
- package/dist/elevationTiles-pmsb9wnU.d.cts +77 -0
- package/dist/elevationTiles-pmsb9wnU.d.ts +77 -0
- package/dist/errors/index.cjs +28 -0
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.d.cts +125 -0
- package/dist/errors/index.d.ts +125 -0
- package/dist/errors/index.js +3 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/geo/index.cjs +232 -0
- package/dist/geo/index.cjs.map +1 -0
- package/dist/geo/index.d.cts +821 -0
- package/dist/geo/index.d.ts +821 -0
- package/dist/geo/index.js +15 -0
- package/dist/geo/index.js.map +1 -0
- package/dist/geodesy-543qXKtI.d.cts +78 -0
- package/dist/geodesy-543qXKtI.d.ts +78 -0
- package/dist/geolocation-DDkQdWMN.d.cts +106 -0
- package/dist/geolocation-DDkQdWMN.d.ts +106 -0
- package/dist/i18n/fr/index.cjs +338 -0
- package/dist/i18n/fr/index.cjs.map +1 -0
- package/dist/i18n/fr/index.d.cts +25 -0
- package/dist/i18n/fr/index.d.ts +25 -0
- package/dist/i18n/fr/index.js +336 -0
- package/dist/i18n/fr/index.js.map +1 -0
- package/dist/i18n/index.cjs +464 -0
- package/dist/i18n/index.cjs.map +1 -0
- package/dist/i18n/index.d.cts +227 -0
- package/dist/i18n/index.d.ts +227 -0
- package/dist/i18n/index.js +430 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/icons/index.cjs +116 -0
- package/dist/icons/index.cjs.map +1 -0
- package/dist/icons/index.d.cts +457 -0
- package/dist/icons/index.d.ts +457 -0
- package/dist/icons/index.js +11 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/index.cjs +1869 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +251 -0
- package/dist/index.d.ts +251 -0
- package/dist/index.js +67 -0
- package/dist/index.js.map +1 -0
- package/dist/itinerary-Dp2ZnqgD.d.cts +178 -0
- package/dist/itinerary-Dp2ZnqgD.d.ts +178 -0
- package/dist/language-CEWQ5uYw.d.cts +69 -0
- package/dist/language-CEWQ5uYw.d.ts +69 -0
- package/dist/layers/index.cjs +318 -0
- package/dist/layers/index.cjs.map +1 -0
- package/dist/layers/index.d.cts +1555 -0
- package/dist/layers/index.d.ts +1555 -0
- package/dist/layers/index.js +17 -0
- package/dist/layers/index.js.map +1 -0
- package/dist/map-client/index.cjs +4 -0
- package/dist/map-client/index.cjs.map +1 -0
- package/dist/map-client/index.d.cts +1856 -0
- package/dist/map-client/index.d.ts +1856 -0
- package/dist/map-client/index.js +3 -0
- package/dist/map-client/index.js.map +1 -0
- package/dist/maplibre-worker.mjs +12 -0
- package/dist/markerSprite-DGBQF6PO.cjs +49 -0
- package/dist/markerSprite-DGBQF6PO.cjs.map +1 -0
- package/dist/markerSprite-DZLTR6F6.js +8 -0
- package/dist/markerSprite-DZLTR6F6.js.map +1 -0
- package/dist/mountayaMap-C9mxRFib.d.cts +3277 -0
- package/dist/mountayaMap-DgnlQ2fE.d.ts +3277 -0
- package/dist/navigation/index.cjs +699 -0
- package/dist/navigation/index.cjs.map +1 -0
- package/dist/navigation/index.d.cts +632 -0
- package/dist/navigation/index.d.ts +632 -0
- package/dist/navigation/index.js +689 -0
- package/dist/navigation/index.js.map +1 -0
- package/dist/order-BLhsGsH8.d.ts +132 -0
- package/dist/order-BZkUwMou.d.cts +132 -0
- package/dist/paint-BgUcj8l7.d.cts +118 -0
- package/dist/paint-Dx_qGNE_.d.ts +118 -0
- package/dist/profile/index.cjs +675 -0
- package/dist/profile/index.cjs.map +1 -0
- package/dist/profile/index.d.cts +2086 -0
- package/dist/profile/index.d.ts +2086 -0
- package/dist/profile/index.js +18 -0
- package/dist/profile/index.js.map +1 -0
- package/dist/provider-DM71XnLX.d.cts +121 -0
- package/dist/provider-DM71XnLX.d.ts +121 -0
- package/dist/roadAccess-D_rOE4xW.d.cts +86 -0
- package/dist/roadAccess-D_rOE4xW.d.ts +86 -0
- package/dist/routeProfile-BKfSfxx6.d.ts +210 -0
- package/dist/routeProfile-BsSUABXv.d.cts +210 -0
- package/dist/seams/index.cjs +39 -0
- package/dist/seams/index.cjs.map +1 -0
- package/dist/seams/index.d.cts +254 -0
- package/dist/seams/index.d.ts +254 -0
- package/dist/seams/index.js +6 -0
- package/dist/seams/index.js.map +1 -0
- package/dist/search/index.cjs +147 -0
- package/dist/search/index.cjs.map +1 -0
- package/dist/search/index.d.cts +888 -0
- package/dist/search/index.d.ts +888 -0
- package/dist/search/index.js +14 -0
- package/dist/search/index.js.map +1 -0
- package/dist/searchHighlight-DFE7LVIL.cjs +33 -0
- package/dist/searchHighlight-DFE7LVIL.cjs.map +1 -0
- package/dist/searchHighlight-MHAQZVWG.js +12 -0
- package/dist/searchHighlight-MHAQZVWG.js.map +1 -0
- package/dist/searchLimits-j99-NTXR.d.cts +24 -0
- package/dist/searchLimits-j99-NTXR.d.ts +24 -0
- package/dist/sections-CVlc2Inr.d.cts +953 -0
- package/dist/sections-CmtaduLc.d.ts +953 -0
- package/dist/segmentRoute-C5UL_5bp.d.ts +172 -0
- package/dist/segmentRoute-CIo6dR8Y.d.cts +172 -0
- package/dist/strings-30RSdIat.d.cts +552 -0
- package/dist/strings-DPTIbzT5.d.ts +552 -0
- package/dist/stripeImage-CQUXM2YI.js +14 -0
- package/dist/stripeImage-CQUXM2YI.js.map +1 -0
- package/dist/stripeImage-R43OPA6U.cjs +39 -0
- package/dist/stripeImage-R43OPA6U.cjs.map +1 -0
- package/dist/style/index.cjs +116 -0
- package/dist/style/index.cjs.map +1 -0
- package/dist/style/index.d.cts +538 -0
- package/dist/style/index.d.ts +538 -0
- package/dist/style/index.js +11 -0
- package/dist/style/index.js.map +1 -0
- package/dist/styles.css +11 -0
- package/dist/testing/index.cjs +629 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +265 -0
- package/dist/testing/index.d.ts +265 -0
- package/dist/testing/index.js +623 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/timezone/index.cjs +759 -0
- package/dist/timezone/index.cjs.map +1 -0
- package/dist/timezone/index.d.cts +53 -0
- package/dist/timezone/index.d.ts +53 -0
- package/dist/timezone/index.js +757 -0
- package/dist/timezone/index.js.map +1 -0
- package/dist/types-B034JMjl.d.ts +973 -0
- package/dist/types-B2NDLxQA.d.cts +21 -0
- package/dist/types-B2NDLxQA.d.ts +21 -0
- package/dist/types-BEv8V_8V.d.cts +55 -0
- package/dist/types-BEv8V_8V.d.ts +55 -0
- package/dist/types-C8aX5KMU.d.cts +973 -0
- package/dist/types-CTQwbSdA.d.cts +321 -0
- package/dist/types-nO2joeRk.d.ts +321 -0
- package/dist/units/index.cjs +99 -0
- package/dist/units/index.cjs.map +1 -0
- package/dist/units/index.d.cts +75 -0
- package/dist/units/index.d.ts +75 -0
- package/dist/units/index.js +6 -0
- package/dist/units/index.js.map +1 -0
- package/dist/units-D9mBrusY.d.cts +900 -0
- package/dist/units-D9mBrusY.d.ts +900 -0
- package/dist/video/index.cjs +2198 -0
- package/dist/video/index.cjs.map +1 -0
- package/dist/video/index.d.cts +873 -0
- package/dist/video/index.d.ts +873 -0
- package/dist/video/index.js +2173 -0
- package/dist/video/index.js.map +1 -0
- package/dist/videoOverlay-Dh_D5_Zs.d.cts +44 -0
- package/dist/videoOverlay-Dh_D5_Zs.d.ts +44 -0
- package/dist/view/index.cjs +43 -0
- package/dist/view/index.cjs.map +1 -0
- package/dist/view/index.d.cts +836 -0
- package/dist/view/index.d.ts +836 -0
- package/dist/view/index.js +34 -0
- package/dist/view/index.js.map +1 -0
- package/dist/zones-B05QA8fy.d.cts +75 -0
- package/dist/zones-B05QA8fy.d.ts +75 -0
- package/package.json +433 -4
- package/src/agent/engines/session.ts +2255 -0
- package/src/agent/index.ts +109 -0
- package/src/agent/rules/agentError.ts +128 -0
- package/src/agent/rules/boundedInputJson.ts +53 -0
- package/src/agent/rules/conversation.ts +629 -0
- package/src/agent/rules/conversationFaults.ts +349 -0
- package/src/agent/rules/conversationHost.ts +390 -0
- package/src/agent/rules/dispatcher.ts +102 -0
- package/src/agent/rules/errorCodes.ts +78 -0
- package/src/agent/rules/errorStatus.ts +65 -0
- package/src/agent/rules/scriptedTransport.ts +390 -0
- package/src/agent/rules/stickToBottom.ts +38 -0
- package/src/agent/rules/toolResultPayload.ts +197 -0
- package/src/auth/rules/clientHeader.ts +22 -0
- package/src/auth/rules/sentCredential.ts +76 -0
- package/src/auth/rules/transformRequest.ts +803 -0
- package/src/camera/engines/videoFlight.ts +1758 -0
- package/src/camera/index.ts +157 -0
- package/src/camera/rules/clearance.ts +1099 -0
- package/src/camera/rules/fit.ts +132 -0
- package/src/camera/rules/modes.ts +1023 -0
- package/src/camera/rules/plan.ts +478 -0
- package/src/camera/rules/planner.ts +129 -0
- package/src/camera/rules/poseRanges.ts +38 -0
- package/src/camera/rules/presets.ts +185 -0
- package/src/camera/rules/profileSamples.ts +243 -0
- package/src/camera/rules/route.ts +596 -0
- package/src/camera/rules/routeContent.ts +104 -0
- package/src/camera/rules/spline.ts +765 -0
- package/src/camera/rules/sweptViewports.ts +39 -0
- package/src/camera/rules/track.ts +1412 -0
- package/src/camera/rules/vocabulary.ts +130 -0
- package/src/camera/rules/zoom.ts +216 -0
- package/src/collab/engines/session.ts +1902 -0
- package/src/collab/engines/trailingThrottle.ts +151 -0
- package/src/collab/index.ts +56 -0
- package/src/collab/rules/dispatch.ts +143 -0
- package/src/collab/rules/peerNames.ts +51 -0
- package/src/collab/rules/scriptedTransport.ts +244 -0
- package/src/compose/engines/baseMapSwitch.ts +1136 -0
- package/src/compose/engines/events.ts +962 -0
- package/src/compose/engines/mountayaMap.ts +5674 -0
- package/src/compose/engines/sentCredentials.ts +146 -0
- package/src/compose/engines/slotRequests.ts +413 -0
- package/src/compose/rules/accessRefusal.ts +109 -0
- package/src/compose/rules/accessStanding.ts +75 -0
- package/src/compose/rules/analysisKinds.ts +331 -0
- package/src/compose/rules/analysisLayers.ts +176 -0
- package/src/compose/rules/cameraMoves.ts +38 -0
- package/src/compose/rules/carriedLayers.ts +87 -0
- package/src/compose/rules/developmentWarnings.ts +166 -0
- package/src/compose/rules/fitCamera.ts +54 -0
- package/src/compose/rules/geoJsonSlot.ts +61 -0
- package/src/compose/rules/geometrySlots.ts +155 -0
- package/src/compose/rules/glyphNode.ts +62 -0
- package/src/compose/rules/layerKeys.ts +92 -0
- package/src/compose/rules/layerOrder.ts +85 -0
- package/src/compose/rules/layersManifest.ts +26 -0
- package/src/compose/rules/mapOptions.ts +300 -0
- package/src/compose/rules/maplibreWorkerVersion.gen.ts +8 -0
- package/src/compose/rules/markerPin.ts +122 -0
- package/src/compose/rules/markerRegistry.ts +85 -0
- package/src/compose/rules/markerSprite.ts +382 -0
- package/src/compose/rules/maxBounds.ts +120 -0
- package/src/compose/rules/overlayLookup.ts +49 -0
- package/src/compose/rules/paintDiff.ts +38 -0
- package/src/compose/rules/panLock.ts +77 -0
- package/src/compose/rules/patch.ts +124 -0
- package/src/compose/rules/queriedFeature.ts +55 -0
- package/src/compose/rules/queryLayers.ts +46 -0
- package/src/compose/rules/searchHighlight.ts +313 -0
- package/src/compose/rules/slotNames.ts +19 -0
- package/src/compose/rules/stripeImage.ts +253 -0
- package/src/compose/rules/swapMarker.ts +66 -0
- package/src/compose/rules/terrainVariant.ts +88 -0
- package/src/compose/rules/types.ts +566 -0
- package/src/compose/rules/urlHash.ts +19 -0
- package/src/compose/rules/viewOptions.ts +451 -0
- package/src/compose/rules/workerUrl.ts +96 -0
- package/src/data/engines/itineraryResource.ts +643 -0
- package/src/data/index.ts +78 -0
- package/src/data/rules/adapt.ts +473 -0
- package/src/data/rules/editModes.ts +51 -0
- package/src/data/rules/itinerary.ts +168 -0
- package/src/data/rules/nullable.ts +63 -0
- package/src/data/rules/roadAccess.ts +169 -0
- package/src/data/rules/segmentGroups.ts +309 -0
- package/src/data/rules/selectors.ts +95 -0
- package/src/data/rules/zones.ts +79 -0
- package/src/draw/engines/boundaryEngine.ts +1003 -0
- package/src/draw/engines/framedAdapter.ts +198 -0
- package/src/draw/engines/pointerCursor.ts +205 -0
- package/src/draw/engines/segmentEngine.ts +1405 -0
- package/src/draw/engines/snapIndex.ts +254 -0
- package/src/draw/engines/waypointEngine.ts +574 -0
- package/src/draw/engines/zoneEngine.ts +1137 -0
- package/src/draw/rules/drawFrame.ts +123 -0
- package/src/draw/rules/insertVertex.ts +226 -0
- package/src/draw/rules/screenSpace.ts +62 -0
- package/src/draw/rules/seeds.ts +185 -0
- package/src/draw/rules/snap.ts +115 -0
- package/src/draw/rules/snapCameraKey.ts +50 -0
- package/src/draw/rules/terraDrawShared.ts +214 -0
- package/src/draw/rules/zoneOutline.ts +213 -0
- package/src/editing/engines/cursor.ts +505 -0
- package/src/editing/engines/draftMarker.ts +149 -0
- package/src/editing/rules/accent.ts +11 -0
- package/src/editing/rules/engine.ts +286 -0
- package/src/editing/rules/placement.ts +22 -0
- package/src/editing/rules/positions.ts +89 -0
- package/src/editing/rules/sources.ts +9 -0
- package/src/editing/rules/types.ts +457 -0
- package/src/editing/rules/vocabulary.ts +10 -0
- package/src/editing/rules/waypointCursor.ts +228 -0
- package/src/editor/engines/directionArrows.ts +459 -0
- package/src/editor/engines/directions.ts +1383 -0
- package/src/editor/engines/editorClient.ts +134 -0
- package/src/editor/engines/eventScope.ts +59 -0
- package/src/editor/engines/frameLoop.ts +159 -0
- package/src/editor/engines/itineraryPreview.ts +272 -0
- package/src/editor/engines/mapLockGuard.ts +66 -0
- package/src/editor/engines/overlayRenderer.ts +2696 -0
- package/src/editor/engines/peerDraft.ts +760 -0
- package/src/editor/engines/poiPick.ts +305 -0
- package/src/editor/engines/pointPick.ts +84 -0
- package/src/editor/engines/roadAccessLine.ts +140 -0
- package/src/editor/engines/searchHighlight.ts +183 -0
- package/src/editor/engines/viewClient.ts +4083 -0
- package/src/editor/engines/zoneBadges.ts +503 -0
- package/src/editor/index.ts +97 -0
- package/src/editor/rules/accentColor.ts +116 -0
- package/src/editor/rules/camera.ts +121 -0
- package/src/editor/rules/contract.ts +125 -0
- package/src/editor/rules/icons.ts +825 -0
- package/src/editor/rules/markerElements.ts +244 -0
- package/src/editor/rules/style.ts +51 -0
- package/src/editor/rules/terrain.ts +98 -0
- package/src/editor/rules/tileWarm.ts +191 -0
- package/src/editor/rules/tilesReload.ts +158 -0
- package/src/editor/rules/zoneBadgePlacement.ts +1832 -0
- package/src/editor/rules/zoneTimeStyling.ts +119 -0
- package/src/errors/index.ts +25 -0
- package/src/errors/rules/errors.ts +157 -0
- package/src/errors/rules/print.ts +129 -0
- package/src/geo/index.ts +94 -0
- package/src/geo/rules/boundaries.ts +105 -0
- package/src/geo/rules/camera.ts +496 -0
- package/src/geo/rules/corridor.ts +242 -0
- package/src/geo/rules/elevationTiles.ts +269 -0
- package/src/geo/rules/formatLngLat.ts +63 -0
- package/src/geo/rules/geodesy.ts +125 -0
- package/src/geo/rules/geometry.ts +362 -0
- package/src/geo/rules/lineWalk.ts +77 -0
- package/src/geo/rules/longitude.ts +99 -0
- package/src/geo/rules/searchLimits.ts +22 -0
- package/src/geo/rules/segmentGeometry.ts +80 -0
- package/src/geo/rules/terrain.ts +107 -0
- package/src/geo/rules/tuples.ts +124 -0
- package/src/geo/rules/types.ts +54 -0
- package/src/geo/rules/webMercator.ts +57 -0
- package/src/i18n/fr/index.ts +17 -0
- package/src/i18n/fr/rules/fr.ts +85 -0
- package/src/i18n/fr/rules/words.gen.ts +277 -0
- package/src/i18n/index.ts +81 -0
- package/src/i18n/rules/bundle.ts +378 -0
- package/src/i18n/rules/config.ts +71 -0
- package/src/i18n/rules/endonyms.gen.ts +19 -0
- package/src/i18n/rules/language.ts +92 -0
- package/src/i18n/rules/localizedName.ts +33 -0
- package/src/i18n/rules/merge.ts +106 -0
- package/src/i18n/rules/scope.ts +127 -0
- package/src/i18n/rules/strings.ts +632 -0
- package/src/i18n/rules/videoOverlay.ts +121 -0
- package/src/i18n/rules/wordForms.ts +95 -0
- package/src/i18n/rules/words.gen.ts +277 -0
- package/src/icons/index.ts +54 -0
- package/src/icons/rules/activities.ts +40 -0
- package/src/icons/rules/amenities.ts +250 -0
- package/src/icons/rules/artwork.gen.ts +83 -0
- package/src/icons/rules/artwork.ts +47 -0
- package/src/icons/rules/fallback.ts +21 -0
- package/src/icons/rules/lucideMarkers.gen.ts +112 -0
- package/src/icons/rules/lucideUi.gen.ts +197 -0
- package/src/icons/rules/paint.ts +107 -0
- package/src/icons/rules/parse.ts +475 -0
- package/src/icons/rules/provider.ts +373 -0
- package/src/icons/rules/sprites.ts +54 -0
- package/src/icons/rules/ui.ts +348 -0
- package/src/icons/rules/waypoints.ts +215 -0
- package/src/index.ts +1012 -0
- package/src/layers/engines/layersSelection.ts +515 -0
- package/src/layers/engines/readoutEngine.ts +131 -0
- package/src/layers/index.ts +151 -0
- package/src/layers/rules/analysis.ts +135 -0
- package/src/layers/rules/enrichment.ts +30 -0
- package/src/layers/rules/geoJson.ts +270 -0
- package/src/layers/rules/hover.ts +67 -0
- package/src/layers/rules/itineraries.ts +182 -0
- package/src/layers/rules/layersPanel.ts +237 -0
- package/src/layers/rules/order.ts +194 -0
- package/src/layers/rules/overlayInstant.ts +49 -0
- package/src/layers/rules/overlays.ts +52 -0
- package/src/layers/rules/poiPanel.ts +119 -0
- package/src/layers/rules/pois.ts +114 -0
- package/src/layers/rules/readout.ts +340 -0
- package/src/layers/rules/streetView.ts +16 -0
- package/src/layers/rules/tileTimestamp.ts +146 -0
- package/src/layers/rules/timeSlider.ts +192 -0
- package/src/layers/rules/timeWindow.ts +123 -0
- package/src/layers/rules/zones.ts +43 -0
- package/src/layers/rules/zoom.ts +77 -0
- package/src/map-client/index.ts +71 -0
- package/src/map-client/rules/mapClient.ts +1943 -0
- package/src/navigation/engines/navigation.ts +493 -0
- package/src/navigation/index.ts +51 -0
- package/src/navigation/rules/followedRoute.ts +78 -0
- package/src/navigation/rules/instructions.ts +89 -0
- package/src/navigation/rules/itineraryRoute.ts +232 -0
- package/src/navigation/rules/offRoute.ts +41 -0
- package/src/navigation/rules/progress.ts +230 -0
- package/src/navigation/rules/prompts.ts +217 -0
- package/src/navigation/rules/routeRequest.ts +98 -0
- package/src/navigation/rules/status.ts +142 -0
- package/src/navigation/rules/steps.ts +234 -0
- package/src/navigation/rules/types.ts +83 -0
- package/src/profile/index.ts +307 -0
- package/src/profile/rules/amenityBadge.ts +35 -0
- package/src/profile/rules/amenityFilter.ts +74 -0
- package/src/profile/rules/amenityStacks.ts +66 -0
- package/src/profile/rules/axis.ts +89 -0
- package/src/profile/rules/axisCulling.ts +83 -0
- package/src/profile/rules/axisLookup.ts +180 -0
- package/src/profile/rules/climbs.ts +292 -0
- package/src/profile/rules/cursorMarker.ts +122 -0
- package/src/profile/rules/cursorReadout.ts +104 -0
- package/src/profile/rules/curvePlacement.ts +216 -0
- package/src/profile/rules/dock.ts +293 -0
- package/src/profile/rules/elevation.ts +1263 -0
- package/src/profile/rules/instant.ts +89 -0
- package/src/profile/rules/intl.ts +237 -0
- package/src/profile/rules/legEmphasis.ts +53 -0
- package/src/profile/rules/profileColors.ts +66 -0
- package/src/profile/rules/profileLayout.ts +59 -0
- package/src/profile/rules/profileSlices.ts +55 -0
- package/src/profile/rules/routeProfile.ts +475 -0
- package/src/profile/rules/rowMatch.ts +50 -0
- package/src/profile/rules/scale.ts +650 -0
- package/src/profile/rules/scaleFrame.ts +171 -0
- package/src/profile/rules/sectionChips.ts +83 -0
- package/src/profile/rules/sections.ts +923 -0
- package/src/profile/rules/slopeRamp.ts +160 -0
- package/src/profile/rules/statStrip.ts +103 -0
- package/src/profile/rules/steepness.ts +51 -0
- package/src/profile/rules/tableCells.ts +269 -0
- package/src/profile/rules/tableCursor.ts +87 -0
- package/src/profile/rules/unitPatterns.ts +335 -0
- package/src/profile/rules/units.ts +1025 -0
- package/src/profile/rules/waypointCard.ts +593 -0
- package/src/profile/rules/webAddress.ts +130 -0
- package/src/profile/rules/windowSpans.ts +65 -0
- package/src/rules/asciiFold.ts +17 -0
- package/src/rules/inDevelopment.ts +54 -0
- package/src/rules/listeners.ts +62 -0
- package/src/rules/timers.ts +9 -0
- package/src/rules/types.ts +22 -0
- package/src/rules/uuid.ts +87 -0
- package/src/seams/engines/geolocateControl.ts +286 -0
- package/src/seams/index.ts +50 -0
- package/src/seams/rules/clock.ts +169 -0
- package/src/seams/rules/geolocation.ts +165 -0
- package/src/seams/rules/segmentRoute.ts +187 -0
- package/src/search/engines/search.ts +1093 -0
- package/src/search/index.ts +114 -0
- package/src/search/rules/describe.ts +383 -0
- package/src/search/rules/filters.ts +195 -0
- package/src/search/rules/highlight.ts +270 -0
- package/src/search/rules/pick.ts +90 -0
- package/src/search/rules/rows.ts +258 -0
- package/src/search/rules/searchFocus.ts +27 -0
- package/src/search/rules/searchViewport.ts +44 -0
- package/src/search/rules/shown.ts +77 -0
- package/src/search/rules/types.ts +340 -0
- package/src/stream/rules/reconnectSchedule.ts +83 -0
- package/src/style/engines/organizationRead.ts +80 -0
- package/src/style/index.ts +63 -0
- package/src/style/rules/apply.ts +268 -0
- package/src/style/rules/attribution.ts +119 -0
- package/src/style/rules/itineraryLine.ts +142 -0
- package/src/style/rules/language.ts +668 -0
- package/src/style/rules/layout.gen.ts +27 -0
- package/src/style/rules/organization.ts +96 -0
- package/src/style/rules/paint.ts +143 -0
- package/src/style/rules/panelLayout.ts +51 -0
- package/src/style/rules/roadAccessColors.ts +29 -0
- package/src/style/rules/roadAccessLine.ts +267 -0
- package/src/style/rules/segmentColors.ts +207 -0
- package/src/testing/catalogs.ts +103 -0
- package/src/testing/index.ts +30 -0
- package/src/testing/mapClient.ts +241 -0
- package/src/testing/mountayaMap.ts +741 -0
- package/src/timezone/index.ts +14 -0
- package/src/timezone/rules/viewport.ts +875 -0
- package/src/units/index.ts +55 -0
- package/src/units/rules/conversions.ts +620 -0
- package/src/units/rules/preferenceChoices.ts +124 -0
- package/src/units/rules/preferences.ts +77 -0
- package/src/units/rules/rounding.ts +69 -0
- package/src/video/engines/videoRun.ts +654 -0
- package/src/video/engines/viewClient.ts +6 -0
- package/src/video/index.ts +83 -0
- package/src/video/profileOverlay/rules/contract.ts +212 -0
- package/src/video/profileOverlay/rules/curve.ts +216 -0
- package/src/video/profileOverlay/rules/draw.ts +410 -0
- package/src/video/profileOverlay/rules/fonts.ts +54 -0
- package/src/video/profileOverlay/rules/graphDesign.ts +690 -0
- package/src/video/profileOverlay/rules/minimalDesign.ts +144 -0
- package/src/video/profileOverlay/rules/registry.ts +23 -0
- package/src/video/profileOverlay/rules/staticLayer.ts +582 -0
- package/src/video/profileOverlay/rules/stripDesign.ts +327 -0
- package/src/video/profileOverlay/rules/types.ts +78 -0
- package/src/video/rules/videoConstants.ts +250 -0
- package/src/video/rules/videoEncoder.ts +277 -0
- package/src/video/rules/videoFrames.ts +99 -0
- package/src/video/rules/videoPreview.ts +185 -0
- package/src/video/rules/videoRecorder.ts +746 -0
- package/src/video/rules/videoWatermark.ts +155 -0
- package/src/video/rules/watermarkMark.ts +40 -0
- package/src/view/engines/viewClient.ts +6 -0
- package/src/view/index.ts +20 -0
|
@@ -0,0 +1,1405 @@
|
|
|
1
|
+
import type { Position } from "geojson";
|
|
2
|
+
import type { MapLayerMouseEvent, Map as MapLibreMap } from "maplibre-gl";
|
|
3
|
+
import {
|
|
4
|
+
type GeoJSONStoreFeatures,
|
|
5
|
+
TerraDraw,
|
|
6
|
+
type TerraDrawEventListeners,
|
|
7
|
+
TerraDrawLineStringMode,
|
|
8
|
+
TerraDrawSelectMode,
|
|
9
|
+
} from "terra-draw";
|
|
10
|
+
|
|
11
|
+
import type { MapEventEngine } from "../../compose/engines/events.js";
|
|
12
|
+
import {
|
|
13
|
+
attachCursorReassert,
|
|
14
|
+
attachEditHoverCursor,
|
|
15
|
+
type CursorEngine,
|
|
16
|
+
} from "../../editing/engines/cursor.js";
|
|
17
|
+
import type {
|
|
18
|
+
EmitSegmentDraft,
|
|
19
|
+
EmitSegmentViaPrompt,
|
|
20
|
+
SegmentEditEngine,
|
|
21
|
+
} from "../../editing/rules/engine.js";
|
|
22
|
+
import { readEditColor } from "../../editing/rules/positions.js";
|
|
23
|
+
import type { DraftPhase, SegmentEditOptions } from "../../editing/rules/types.js";
|
|
24
|
+
import { SEGMENT_MIN_VIAS } from "../../geo/rules/segmentGeometry.js";
|
|
25
|
+
import { inDevelopment } from "../../rules/inDevelopment.js";
|
|
26
|
+
import { notifyListeners } from "../../rules/listeners.js";
|
|
27
|
+
import type { SegmentAnalyzeFn, SegmentRoute } from "../../seams/rules/segmentRoute.js";
|
|
28
|
+
import {
|
|
29
|
+
clampCoordinatePrecision,
|
|
30
|
+
nearestEdgeInsertion,
|
|
31
|
+
nearestVertex,
|
|
32
|
+
pointerPosition,
|
|
33
|
+
} from "../rules/insertVertex.js";
|
|
34
|
+
import { refuseSegmentSeed, samePoint } from "../rules/seeds.js";
|
|
35
|
+
import { SNAP_THRESHOLD_PX } from "../rules/snap.js";
|
|
36
|
+
import {
|
|
37
|
+
addDrawFeature,
|
|
38
|
+
applyHeldWrite,
|
|
39
|
+
copyPositions,
|
|
40
|
+
type DrawFactory,
|
|
41
|
+
type DrawRefusalSubject,
|
|
42
|
+
drawIdStrategy,
|
|
43
|
+
isProgrammaticChange,
|
|
44
|
+
SELECT_MODE,
|
|
45
|
+
TERRA_DRAW_MID_POINT_PROPERTY,
|
|
46
|
+
updateDrawGeometry,
|
|
47
|
+
} from "../rules/terraDrawShared.js";
|
|
48
|
+
import { FramedMapLibreAdapter } from "./framedAdapter.js";
|
|
49
|
+
|
|
50
|
+
// The TerraDraw mode name the editable line is registered under. A freehand
|
|
51
|
+
// linestring segment is a single LineString feature the user shapes directly —
|
|
52
|
+
// clicking to add points and dragging to reshape. The mode stays REGISTERED as
|
|
53
|
+
// the feature's home mode and the carrier of the start-vertex validation
|
|
54
|
+
// (addFeatures + every updateFeatureGeometry validate against it), but it is
|
|
55
|
+
// never entered: every gesture runs in the select mode below, so the line is
|
|
56
|
+
// built and reshaped through store-API writes rather than a native draw session.
|
|
57
|
+
const EDIT_MODE = "linestring";
|
|
58
|
+
// SELECT_MODE is the ONLY mode the engine ever enters: the editable feature lives selected in
|
|
59
|
+
// it so its vertices, midpoints, and drag/delete handles render, and every click-append/splice
|
|
60
|
+
// is a store-API write against the selected feature.
|
|
61
|
+
// The id prefix every TerraDraw-rendered source + layer is namespaced with,
|
|
62
|
+
// so a teardown leaves no orphan TerraDraw layer behind and the prefix never
|
|
63
|
+
// collides with the manifest tile layers.
|
|
64
|
+
const SEGMENT_TERRADRAW_PREFIX = "td-edit";
|
|
65
|
+
|
|
66
|
+
// The MapLibre layer id the TerraDraw adapter renders every point feature on
|
|
67
|
+
// — the editable linestring's own vertices, the select mode's selection-point
|
|
68
|
+
// handles, AND the insert-midpoints between vertices all share this layer (the
|
|
69
|
+
// adapter keys layer ids by geometry kind, not by feature role). The engine
|
|
70
|
+
// listens on it to layer the drag/insert affordance cursor over the base edit
|
|
71
|
+
// cross while the pointer sits on a handle, even though the cross stays locked
|
|
72
|
+
// underneath.
|
|
73
|
+
const SEGMENT_VERTEX_LAYER_ID = `${SEGMENT_TERRADRAW_PREFIX}-point`;
|
|
74
|
+
|
|
75
|
+
// The debounce window the freehand engine coalesces geometry changes into one
|
|
76
|
+
// analyzeFn round-trip over. A drag or a rapid vertex insert fires many `change`
|
|
77
|
+
// events in quick succession; analyzing each one would ship a redundant ORS
|
|
78
|
+
// round-trip per frame. Waiting out a short quiet period collapses a burst into
|
|
79
|
+
// a single analyze for the line's final shape. It mirrors the directions
|
|
80
|
+
// engine's per-via routing being naturally rate-limited by the SDK, here made
|
|
81
|
+
// explicit because TerraDraw emits a raw change per edit.
|
|
82
|
+
const ANALYZE_DEBOUNCE_MS = 300;
|
|
83
|
+
|
|
84
|
+
/** segmentRefusal names this engine and its shape in the error for a line TerraDraw refuses. */
|
|
85
|
+
const segmentRefusal: DrawRefusalSubject = {
|
|
86
|
+
engine: "TerraDrawLinestringSegmentEngine",
|
|
87
|
+
shape: "line",
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/** liesOn reads whether an end of a line is the point a pin names, where there are both. */
|
|
91
|
+
const liesOn = (end: Position | undefined, pin: Position | undefined): boolean =>
|
|
92
|
+
end !== undefined && pin !== undefined && samePoint(end, pin);
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* normalizeDraftLine collapses runs of consecutive identical coordinates in a
|
|
96
|
+
* draft line to a single vertex. The engine seeds and holds a degenerate
|
|
97
|
+
* two-identical-point LineString `[p, p]` while a chained or from-scratch segment
|
|
98
|
+
* has only its start committed (TerraDraw accepts `[p, p]` and renders its start
|
|
99
|
+
* handle), so the line reads as one effective point until a real second vertex
|
|
100
|
+
* lands. Normalizing before the two-point floor check makes that degenerate emit
|
|
101
|
+
* a single via — the below-floor branch — so Save stays closed and no analyze
|
|
102
|
+
* fires until the line genuinely has two distinct vertices. It is pure: the input
|
|
103
|
+
* is never mutated.
|
|
104
|
+
*/
|
|
105
|
+
const normalizeDraftLine = (line: readonly Position[]): Position[] => {
|
|
106
|
+
const collapsed: Position[] = [];
|
|
107
|
+
for (const coordinate of line) {
|
|
108
|
+
const previous = collapsed[collapsed.length - 1];
|
|
109
|
+
if (!previous || previous[0] !== coordinate[0] || previous[1] !== coordinate[1]) {
|
|
110
|
+
collapsed.push(coordinate);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return collapsed;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* pinFirstCoordinate is the start-vertex guard for the segment engine.
|
|
119
|
+
* TerraDraw has no per-coordinate-index lock, so pinning the first
|
|
120
|
+
* coordinate to the previous segment's end (the append-only chain's
|
|
121
|
+
* continuity) is expressed through the mode's `validation` callback: any
|
|
122
|
+
* interactive coordinate update is rejected when its result would move or
|
|
123
|
+
* remove the first coordinate, while every other coordinate stays free.
|
|
124
|
+
*
|
|
125
|
+
* The guard runs on every updateType TerraDraw reports — including the
|
|
126
|
+
* provisional updates a drag emits mid-gesture — so a start-vertex drag is
|
|
127
|
+
* rejected at every step rather than slipping through on a provisional
|
|
128
|
+
* frame; an update that leaves the head intact and moves only the tail
|
|
129
|
+
* validates true. The pinned reference is read through a getter so it
|
|
130
|
+
* tracks the feature's current head (re-seeded on `applyDraft`).
|
|
131
|
+
*/
|
|
132
|
+
const pinFirstCoordinate =
|
|
133
|
+
(firstCoordinate: () => Position | undefined) =>
|
|
134
|
+
(feature: GeoJSONStoreFeatures): { valid: boolean; reason?: string | undefined } => {
|
|
135
|
+
const pinned = firstCoordinate();
|
|
136
|
+
if (!pinned) {
|
|
137
|
+
return { valid: true };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const geometry = feature.geometry;
|
|
141
|
+
if (geometry.type !== "LineString") {
|
|
142
|
+
return { valid: true };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const head = geometry.coordinates[0];
|
|
146
|
+
if (!head) {
|
|
147
|
+
// The first coordinate was removed (a delete of vertex 0) — reject it.
|
|
148
|
+
return { reason: "vertex 0 is pinned", valid: false };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (!samePoint(head, pinned)) {
|
|
152
|
+
return { reason: "vertex 0 is pinned", valid: false };
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return { valid: true };
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* pinLastCoordinate is the end-vertex guard, the exact mirror of
|
|
160
|
+
* {@link pinFirstCoordinate}: it rejects any interactive update that would move or
|
|
161
|
+
* remove the final coordinate while the edit's end is pinned to the next segment's
|
|
162
|
+
* start. Set only for an insert; an append or a reshape leaves its tail free and
|
|
163
|
+
* passes no pin, so the guard reads undefined and admits everything.
|
|
164
|
+
*/
|
|
165
|
+
const pinLastCoordinate =
|
|
166
|
+
(lastCoordinate: () => Position | undefined) =>
|
|
167
|
+
(feature: GeoJSONStoreFeatures): { valid: boolean; reason?: string | undefined } => {
|
|
168
|
+
const pinned = lastCoordinate();
|
|
169
|
+
if (!pinned) {
|
|
170
|
+
return { valid: true };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const geometry = feature.geometry;
|
|
174
|
+
if (geometry.type !== "LineString") {
|
|
175
|
+
return { valid: true };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const tail = geometry.coordinates.at(-1);
|
|
179
|
+
if (!tail) {
|
|
180
|
+
// The last coordinate was removed (a delete of the end vertex) — reject it.
|
|
181
|
+
return { reason: "the last vertex is pinned", valid: false };
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (!samePoint(tail, pinned)) {
|
|
185
|
+
return { reason: "the last vertex is pinned", valid: false };
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return { valid: true };
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* bothBoundariesPinned composes the two boundary guards into the single
|
|
193
|
+
* `validation` callback TerraDraw accepts, so an insert can lock its start AND its
|
|
194
|
+
* end at once. An update must satisfy both; the first refusal wins, so the reason
|
|
195
|
+
* names the boundary that actually blocked it.
|
|
196
|
+
*/
|
|
197
|
+
const bothBoundariesPinned =
|
|
198
|
+
(
|
|
199
|
+
first: (feature: GeoJSONStoreFeatures) => { valid: boolean; reason?: string | undefined },
|
|
200
|
+
last: (feature: GeoJSONStoreFeatures) => { valid: boolean; reason?: string | undefined },
|
|
201
|
+
) =>
|
|
202
|
+
(feature: GeoJSONStoreFeatures): { valid: boolean; reason?: string | undefined } => {
|
|
203
|
+
const head = first(feature);
|
|
204
|
+
if (!head.valid) {
|
|
205
|
+
return head;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return last(feature);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* defaultSegmentDrawFactory builds the production TerraDraw for a segment
|
|
213
|
+
* edit: the MapLibre adapter namespaced by prefixId, a permissive id strategy
|
|
214
|
+
* that accepts the store's segment ids (TerraDraw rejects any non-UUID4 id
|
|
215
|
+
* by default), and the two modes the editor needs — the linestring mode as the
|
|
216
|
+
* editable feature's home + validation carrier (never entered), and a select
|
|
217
|
+
* mode whose coordinate flags expose draggable, deletable midpoints while the
|
|
218
|
+
* whole feature stays non-draggable (so only vertices and inserted midpoints
|
|
219
|
+
* move).
|
|
220
|
+
*/
|
|
221
|
+
const defaultSegmentDrawFactory: DrawFactory = ({ map, prefixId, validation }) =>
|
|
222
|
+
new TerraDraw({
|
|
223
|
+
adapter: new FramedMapLibreAdapter({ map, prefixId }, { longitude: 0 }),
|
|
224
|
+
idStrategy: drawIdStrategy,
|
|
225
|
+
modes: [
|
|
226
|
+
// The linestring mode is the editable feature's home mode and the carrier of
|
|
227
|
+
// the start-vertex pin validation, but it is never entered — the engine
|
|
228
|
+
// builds and reshapes the line through select-mode writes — so it needs no
|
|
229
|
+
// `editable` draw affordance.
|
|
230
|
+
new TerraDrawLineStringMode({ validation }),
|
|
231
|
+
new TerraDrawSelectMode({
|
|
232
|
+
// An empty-map click must NOT deselect the line: the click grammar keeps
|
|
233
|
+
// the feature selected for the whole edit so a click always appends/splices
|
|
234
|
+
// rather than dropping the selection (and its handles) out from under the
|
|
235
|
+
// next gesture. Midpoint insertion is unaffected by this flag.
|
|
236
|
+
allowManualDeselection: false,
|
|
237
|
+
flags: {
|
|
238
|
+
[EDIT_MODE]: {
|
|
239
|
+
feature: {
|
|
240
|
+
// Only individual coordinates and inserted midpoints move; the
|
|
241
|
+
// whole feature does not drag (that would translate the line
|
|
242
|
+
// wholesale). Deleting a coordinate is NOT TerraDraw's to do: a
|
|
243
|
+
// gesture on a handle is ambiguous (remove it, or route through it
|
|
244
|
+
// again to close a loop), so the engine intercepts it and asks
|
|
245
|
+
// instead — see attachClickInsert / attachVertexPrompt.
|
|
246
|
+
coordinates: { deletable: false, draggable: true, midpoints: true },
|
|
247
|
+
draggable: false,
|
|
248
|
+
validation,
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
// Null out the select mode's own key handling: Escape must cancel the edit
|
|
253
|
+
// at the app level (not silently deselect the feature) and Delete/Backspace
|
|
254
|
+
// must not wipe the whole line — a single-vertex delete goes through the
|
|
255
|
+
// engine's own ask-the-user prompt.
|
|
256
|
+
keyEvents: null,
|
|
257
|
+
}),
|
|
258
|
+
],
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* TerraDrawLinestringSegmentEngine implements the freehand-linestring
|
|
263
|
+
* segment-edit engine the MapLibreClient builds for a `linestring` edit. It owns
|
|
264
|
+
* one TerraDraw instance for the duration of the edit and emits draft coordinates
|
|
265
|
+
* through the injected sink. The engine gives freehand editing the directions
|
|
266
|
+
* grammar — a map click adds a point, Save completes the line — with no native
|
|
267
|
+
* draw session and no finish gesture. Everything runs in the select mode over one
|
|
268
|
+
* feature keyed on `featureId`: a from-scratch segment starts empty and the first
|
|
269
|
+
* click seeds it; a chained segment opens with the previous segment's end already
|
|
270
|
+
* pinned as a degenerate `[start, start]` line so the start handle is present from
|
|
271
|
+
* the first paint; an existing segment is seeded and reshaped. The pinned-start
|
|
272
|
+
* guard locks vertex 0 to the previous segment's end (the append-only chain's
|
|
273
|
+
* continuity), and `setDraftStyle` recolors the rendered scene live so a mid-edit
|
|
274
|
+
* color change reads instantly.
|
|
275
|
+
*/
|
|
276
|
+
export class TerraDrawLinestringSegmentEngine implements SegmentEditEngine {
|
|
277
|
+
private readonly draw: TerraDraw;
|
|
278
|
+
// The id the editable line lives under in the TerraDraw store for the whole
|
|
279
|
+
// edit. Every store read/write (currentLine, applyDraft, the click grammar,
|
|
280
|
+
// select) keys off it. The line is created directly under this id on the first
|
|
281
|
+
// click (or seeded under it), so there is no second TerraDraw-assigned id to
|
|
282
|
+
// reconcile the way a native draw session would produce.
|
|
283
|
+
private readonly featureId: string;
|
|
284
|
+
// The start-vertex lock the guard reads, set only when a pin is passed: a non-first
|
|
285
|
+
// reshape seeds the saved line with vertex 0 = the saved head, and a chained segment
|
|
286
|
+
// opens with vertex 0 = the previous segment's end, both pinning it from the first
|
|
287
|
+
// paint; a first segment (from-scratch or an existing reshape) passes no pin and
|
|
288
|
+
// leaves it undefined so vertex 0 stays freely draggable. applyDraft re-pins it to
|
|
289
|
+
// the restored head only while it is already locked, so the guard tracks the applied
|
|
290
|
+
// draft rather than a stale head.
|
|
291
|
+
private pinnedFirst: Position | undefined;
|
|
292
|
+
// The end-vertex lock, the mirror of pinnedFirst: set only for an insert, whose
|
|
293
|
+
// last vertex is the NEXT segment's start. It also redirects the click grammar,
|
|
294
|
+
// which splices in front of the pin rather than appending past it, so the drawn
|
|
295
|
+
// line always finishes on its neighbour. Undefined for every other edit, leaving
|
|
296
|
+
// the tail freely draggable. applyDraft re-pins it the same way as the head.
|
|
297
|
+
private pinnedLast: Position | undefined;
|
|
298
|
+
// The two boundaries the edit opened pinned on, as they are drawn, kept for the whole edit. The
|
|
299
|
+
// click that starts a line where an applied draft left none releases both locks, and an applied
|
|
300
|
+
// draft that puts the line back on one of these points locks that end again.
|
|
301
|
+
private readonly firstPinAtOpen: Position | undefined;
|
|
302
|
+
private readonly lastPinAtOpen: Position | undefined;
|
|
303
|
+
// The single boundary pin a one-sided insert or an append opens on, held so
|
|
304
|
+
// applyDraft can restore the degenerate `[pin, pin]` line when an undo steps the
|
|
305
|
+
// edit back to empty. Undefined for a from-scratch first segment (no neighbour),
|
|
306
|
+
// for a reshape (whose undo history never steps below the seeded line), and for a
|
|
307
|
+
// two-sided insert (which opens on a real two-point line, not a degenerate).
|
|
308
|
+
private readonly chainSeedPin: Position | undefined;
|
|
309
|
+
// True only while the engine itself is writing the line through the store API in
|
|
310
|
+
// response to a user click (create, tail-append, mid-edge splice, degenerate tail
|
|
311
|
+
// replace). TerraDraw tags every store-API write `{origin:"api"}`, which
|
|
312
|
+
// handleChange would otherwise read as programmatic and skip from undo history;
|
|
313
|
+
// this flag overrides that so a clicked point records as an interactive edit —
|
|
314
|
+
// directions parity, where every added via is its own undo step, and where a
|
|
315
|
+
// splice becomes individually undoable. It never wraps a genuinely programmatic
|
|
316
|
+
// write (applyDraft, a seed), so those stay out of history.
|
|
317
|
+
private interactiveWrite = false;
|
|
318
|
+
// True once an interactive (non-programmatic) change has landed since the last
|
|
319
|
+
// map mousedown — the signal that TerraDraw already consumed the current gesture
|
|
320
|
+
// (a vertex drag, a midpoint insert). The click grammar reads it to skip its own
|
|
321
|
+
// append/splice on that same gesture, so a midpoint-handle click inserts once
|
|
322
|
+
// (TerraDraw on pointerup) rather than twice (a second splice on the following
|
|
323
|
+
// map click). Reset on every mousedown.
|
|
324
|
+
private gestureConsumed = false;
|
|
325
|
+
// True while a TerraDraw gesture has emitted `live` frames that no `settled` draft has
|
|
326
|
+
// closed yet. TerraDraw's `finish` closes the gesture, and it fires on every pointer release
|
|
327
|
+
// in the select mode, a drag the pin guard refused at every step included, so the finish
|
|
328
|
+
// settles only a gesture that actually emitted a frame.
|
|
329
|
+
private gestureOpen = false;
|
|
330
|
+
// The stable change and finish listener references the engine registers on the TerraDraw
|
|
331
|
+
// instance, held so a style-reload replay can `off` the previous binding before `on`-ing
|
|
332
|
+
// again rather than stacking a duplicate listener per replay.
|
|
333
|
+
private readonly changeHandler: TerraDrawEventListeners["change"];
|
|
334
|
+
private readonly finishHandler: TerraDrawEventListeners["finish"];
|
|
335
|
+
// The line read off the store by {@link detachBeforeStyleReload}, held for the replay to
|
|
336
|
+
// re-seed from. It exists because stopping TerraDraw EMPTIES the store: `stop()`
|
|
337
|
+
// unregisters the adapter, whose base `unregister()` ends in its own `clear()`, which
|
|
338
|
+
// calls back through `onClear` into `_store.clear()`. So by the time the replay runs there
|
|
339
|
+
// is nothing left to read, and a replay that re-registered the adapter correctly still
|
|
340
|
+
// came back to empty layers. Null while no swap is in flight.
|
|
341
|
+
private detachedLine: Position[] | null = null;
|
|
342
|
+
// Whether TerraDraw is stopped for a style reload: raised by the detach, lowered by the replay.
|
|
343
|
+
// While it is raised the store is empty and refuses every write, so the engine reads and
|
|
344
|
+
// writes what it holds itself.
|
|
345
|
+
private detached = false;
|
|
346
|
+
// The latest draft applied while TerraDraw is stopped for a style reload, written when the
|
|
347
|
+
// replay ends. Undefined when none was applied.
|
|
348
|
+
private heldDraft: Position[] | undefined;
|
|
349
|
+
// Whether the edit is over. A disposed engine has no replay to come, so a draft applied to it
|
|
350
|
+
// inside the detach window is held by nothing.
|
|
351
|
+
private disposed = false;
|
|
352
|
+
// The current segment color the draft renders in, held so a base-map
|
|
353
|
+
// switch replay can re-apply it onto the fresh style.
|
|
354
|
+
private color: `#${string}`;
|
|
355
|
+
// The map event engine the hover cursor's listeners detach through; held so
|
|
356
|
+
// dispose/replay tears them down by reference rather than leaking onto the
|
|
357
|
+
// next edit's engine instance.
|
|
358
|
+
private readonly events: MapEventEngine;
|
|
359
|
+
// The cursor controller the hover cursor pushes onto; the base
|
|
360
|
+
// edit cross is locked one layer above this engine (the editing hook), and
|
|
361
|
+
// the override layers above that so leaving the vertex reverts to the
|
|
362
|
+
// cross rather than the OS default.
|
|
363
|
+
private readonly cursor: CursorEngine;
|
|
364
|
+
// Detaches the vertex-layer mouseenter/mouseleave listeners that drive the
|
|
365
|
+
// `move` cursor override; set on attach, cleared on dispose / replay so a
|
|
366
|
+
// teardown leaves no listener pointing at the stopped TerraDraw instance.
|
|
367
|
+
private detachVertexCursor: (() => void) | null = null;
|
|
368
|
+
// Detaches the map-level click + mousedown listeners that drive the click
|
|
369
|
+
// grammar; set on attach, cleared on dispose / replay so a teardown leaves no
|
|
370
|
+
// listener pointing at the stopped TerraDraw instance.
|
|
371
|
+
private detachClickInsert: (() => void) | null = null;
|
|
372
|
+
// Detaches the map-level contextmenu listener that raises the ask-the-user
|
|
373
|
+
// prompt for a right-clicked handle (TerraDraw's own coordinate delete is off);
|
|
374
|
+
// set on attach, cleared on dispose / replay.
|
|
375
|
+
private detachVertexPrompt: (() => void) | null = null;
|
|
376
|
+
// Whether the app currently holds a via prompt open. While true the click
|
|
377
|
+
// grammar is detached, so the click that dismisses the prompt cannot also
|
|
378
|
+
// append or splice a vertex.
|
|
379
|
+
private viaPromptPending = false;
|
|
380
|
+
// Detaches the shared map-level mousemove cursor re-assert; set on attach,
|
|
381
|
+
// cleared on dispose / replay. TerraDraw's select mode writes the canvas cursor
|
|
382
|
+
// only over a handle today, never on empty map, so the locked edit cross is
|
|
383
|
+
// untouched while the pointer roams free and this re-assert is a no-op write
|
|
384
|
+
// there (its value-changed guard skips it). It is the structural-consistency net
|
|
385
|
+
// every lock-holding engine shares: should a TerraDraw version start clobbering
|
|
386
|
+
// the cursor on a plain move, the re-pin already covers it.
|
|
387
|
+
private detachCursorReassert: (() => void) | null = null;
|
|
388
|
+
// The injected freehand elevation/analysis resolver (the linestring twin of
|
|
389
|
+
// the directions routeFn). Null when none is injected — a render-free test or
|
|
390
|
+
// a session with no data seam — so the engine still constructs and emits a
|
|
391
|
+
// route-less draft, the historical behavior.
|
|
392
|
+
private readonly analyzeFn: SegmentAnalyzeFn | null;
|
|
393
|
+
// The activity the analyzeFn resolves the profile for (the itinerary's, shared
|
|
394
|
+
// by every segment); empty when no analyzeFn is wired.
|
|
395
|
+
private readonly activitySlug: string;
|
|
396
|
+
// The most recent SegmentRoute the analyzeFn resolved for the current line,
|
|
397
|
+
// cached so an immediate `change` emit can carry the last-known profile while a
|
|
398
|
+
// fresh analyze is in flight — the panel keeps the previous profile rather than
|
|
399
|
+
// flashing empty. Null below the two-point floor or when no profile resolves.
|
|
400
|
+
private lastRoute: SegmentRoute | null = null;
|
|
401
|
+
// The pending debounce timer that coalesces a burst of geometry changes into
|
|
402
|
+
// one analyzeFn call; cleared when it fires, when a newer change supersedes it,
|
|
403
|
+
// and on dispose so a post-teardown analyze never runs.
|
|
404
|
+
private analyzeTimer: ReturnType<typeof setTimeout> | null = null;
|
|
405
|
+
// A monotonic token stamped on each analyze kickoff and re-read when it
|
|
406
|
+
// resolves: a newer change bumps the token, so an older in-flight analyze whose
|
|
407
|
+
// token no longer matches is dropped rather than emitting a stale profile. It
|
|
408
|
+
// is the race guard against an out-of-order resolution overwriting a newer one.
|
|
409
|
+
private analyzeToken = 0;
|
|
410
|
+
// Aborts the analyze in flight: a newer change and a dispose each abort it, so the host's
|
|
411
|
+
// call is told its answer is no longer read.
|
|
412
|
+
private analyzeController: AbortController | null = null;
|
|
413
|
+
// Whether this edit has already said in the console that its analyzeFn failed.
|
|
414
|
+
private analyzeFaultReported = false;
|
|
415
|
+
|
|
416
|
+
constructor(
|
|
417
|
+
private readonly map: MapLibreMap,
|
|
418
|
+
events: MapEventEngine,
|
|
419
|
+
cursor: CursorEngine,
|
|
420
|
+
options: SegmentEditOptions,
|
|
421
|
+
private readonly emitDraft: EmitSegmentDraft,
|
|
422
|
+
private readonly emitViaPrompt: EmitSegmentViaPrompt,
|
|
423
|
+
createDraw: DrawFactory = defaultSegmentDrawFactory,
|
|
424
|
+
) {
|
|
425
|
+
this.events = events;
|
|
426
|
+
this.cursor = cursor;
|
|
427
|
+
this.featureId = options.featureId;
|
|
428
|
+
this.color = readEditColor(options.color, segmentRefusal.engine);
|
|
429
|
+
this.analyzeFn = options.analyzeFn ?? null;
|
|
430
|
+
this.activitySlug = options.activitySlug ?? "";
|
|
431
|
+
|
|
432
|
+
// The seed is written as TerraDraw can hold it: each via as its longitude and latitude
|
|
433
|
+
// alone, at the nine decimals the library takes. A stored line can carry an elevation as a
|
|
434
|
+
// third ordinate or a tenth decimal, and the library refuses both.
|
|
435
|
+
const seed = (options.seedVias ?? []).map(clampCoordinatePrecision);
|
|
436
|
+
// Each pin is exactly the passed boundary, clamped to the write precision so it
|
|
437
|
+
// stays byte-identical to a seed via built from the same stored coordinate (the
|
|
438
|
+
// guards compare the two exactly). A start pin is passed for a chained segment
|
|
439
|
+
// (vertex 0 = the previous segment's end) and for a non-first reshape (vertex 0 =
|
|
440
|
+
// the saved head); an end pin is passed only for an insert (the last vertex = the
|
|
441
|
+
// next segment's start). A from-scratch first segment passes neither and leaves
|
|
442
|
+
// both boundaries free, matching the directions engine.
|
|
443
|
+
const rawStartPin = options.pinnedStart;
|
|
444
|
+
const rawEndPin = options.pinnedEnd;
|
|
445
|
+
const startPin = rawStartPin ? clampCoordinatePrecision(rawStartPin) : undefined;
|
|
446
|
+
const endPin = rawEndPin ? clampCoordinatePrecision(rawEndPin) : undefined;
|
|
447
|
+
|
|
448
|
+
// Before the library is built: a refusal here leaves nothing on the map to take off.
|
|
449
|
+
refuseSegmentSeed(options, segmentRefusal.engine);
|
|
450
|
+
|
|
451
|
+
this.pinnedFirst = startPin;
|
|
452
|
+
this.pinnedLast = endPin;
|
|
453
|
+
this.firstPinAtOpen = startPin;
|
|
454
|
+
this.lastPinAtOpen = endPin;
|
|
455
|
+
|
|
456
|
+
if (seed.length >= SEGMENT_MIN_VIAS) {
|
|
457
|
+
// The edit opens on a real line: a reshape's saved geometry, or an insert
|
|
458
|
+
// between two segments whose seed IS the two pinned boundaries. Either way the
|
|
459
|
+
// undo history never steps below that seed, so there is no degenerate to
|
|
460
|
+
// restore and chainSeedPin stays undefined.
|
|
461
|
+
this.chainSeedPin = undefined;
|
|
462
|
+
} else {
|
|
463
|
+
// One boundary at most. A chained append opens on the previous segment's end, a
|
|
464
|
+
// head insert on the next segment's start; both seed as a degenerate line so the
|
|
465
|
+
// handle is present the moment the edit opens and every clicked point chains
|
|
466
|
+
// onto it. chainSeedPin holds whichever it is so an undo back to empty restores
|
|
467
|
+
// the degenerate rather than nothing; a from-scratch first segment has neither
|
|
468
|
+
// and starts with no committed vertex.
|
|
469
|
+
this.chainSeedPin = startPin ?? endPin;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
this.changeHandler = (ids, _type, context) => {
|
|
473
|
+
// A property write moves no geometry, so it is no frame of any gesture. The select mode
|
|
474
|
+
// flags the feature it selects or deselects that way, with no origin, on every seed,
|
|
475
|
+
// replay and removal, and a frame read off it would open a gesture no pointer started.
|
|
476
|
+
if (context?.target === "properties") {
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
this.handleChange(ids, isProgrammaticChange(context));
|
|
481
|
+
};
|
|
482
|
+
this.finishHandler = (id) => {
|
|
483
|
+
this.handleFinish(id);
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
const validation = bothBoundariesPinned(
|
|
487
|
+
pinFirstCoordinate(() => this.pinnedFirst),
|
|
488
|
+
pinLastCoordinate(() => this.pinnedLast),
|
|
489
|
+
);
|
|
490
|
+
this.draw = createDraw({ map: this.map, prefixId: SEGMENT_TERRADRAW_PREFIX, validation });
|
|
491
|
+
|
|
492
|
+
// Attach the click grammar BEFORE draw.start() so MapLibre fires it ahead of
|
|
493
|
+
// any registration TerraDraw lands during start(). The click handler adds or
|
|
494
|
+
// splices a vertex through the store API; TerraDraw handles handle-level
|
|
495
|
+
// gestures (drag, midpoint insert) on the preceding pointerup, so our handler
|
|
496
|
+
// always runs after those on the same gesture.
|
|
497
|
+
this.detachClickInsert = this.attachClickInsert();
|
|
498
|
+
this.detachVertexPrompt = this.attachVertexPrompt();
|
|
499
|
+
|
|
500
|
+
this.draw.start();
|
|
501
|
+
this.draw.on("change", this.changeHandler);
|
|
502
|
+
this.draw.on("finish", this.finishHandler);
|
|
503
|
+
|
|
504
|
+
// Enter the select mode for the whole edit (the only mode the engine enters),
|
|
505
|
+
// then seed whatever the edit opens on: a reshape seeds the saved line, an insert
|
|
506
|
+
// between two segments seeds the two-point line spanning them, a one-sided
|
|
507
|
+
// insert or append seeds the pinned degenerate, and a from-scratch first segment
|
|
508
|
+
// seeds nothing — the select mode idles until the first click creates the line.
|
|
509
|
+
this.draw.setMode(SELECT_MODE);
|
|
510
|
+
try {
|
|
511
|
+
if (seed.length >= SEGMENT_MIN_VIAS) {
|
|
512
|
+
this.seedFeature(seed);
|
|
513
|
+
} else if (this.chainSeedPin) {
|
|
514
|
+
this.seedFeature([this.chainSeedPin, this.chainSeedPin]);
|
|
515
|
+
}
|
|
516
|
+
} catch (error) {
|
|
517
|
+
// No engine is handed back to dispose, so the click grammar already on the map and the
|
|
518
|
+
// instance started above come off here.
|
|
519
|
+
this.dispose();
|
|
520
|
+
throw error;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// The styling is driven through the mode options so the draft handles
|
|
524
|
+
// render in the segment color from the first paint; setDraftStyle
|
|
525
|
+
// updates the same options live when the color changes mid-edit.
|
|
526
|
+
this.applySegmentDraftStyle(this.color);
|
|
527
|
+
|
|
528
|
+
// Layer the `move` cursor over the locked edit cross whenever the
|
|
529
|
+
// pointer sits on an existing vertex of the editable line. The base
|
|
530
|
+
// cross stays pinned underneath; popping the override on leave reverts
|
|
531
|
+
// to it rather than the OS default.
|
|
532
|
+
this.detachVertexCursor = this.attachVertexCursor();
|
|
533
|
+
|
|
534
|
+
// Attach the shared map-level cursor re-assert LAST, after draw.start() has
|
|
535
|
+
// wired TerraDraw's own move handler, so MapLibre dispatches the re-pin after
|
|
536
|
+
// TerraDraw and it wins any listener-order race. TerraDraw's select mode does
|
|
537
|
+
// not clobber the cursor on empty map today, so this is a no-op write there; it
|
|
538
|
+
// is the uniform regression net every lock-holding engine holds.
|
|
539
|
+
this.detachCursorReassert = attachCursorReassert(this.events, this.cursor);
|
|
540
|
+
|
|
541
|
+
// Kick off an initial analyze for a seeded existing segment so its elevation
|
|
542
|
+
// profile resolves on open, the way the directions engine's seed setWaypoints
|
|
543
|
+
// triggers a first routeFn fetch. A new (unseeded) or chained (degenerate)
|
|
544
|
+
// segment has no two-vertex line yet, so nothing is scheduled until a real
|
|
545
|
+
// second vertex lands.
|
|
546
|
+
if (seed.length >= SEGMENT_MIN_VIAS) {
|
|
547
|
+
this.scheduleAnalyze();
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
setDraftStyle(style: { color: string }): void {
|
|
552
|
+
// The edit is over. A disposed engine writes and starts nothing, wherever it was disposed.
|
|
553
|
+
if (this.disposed) {
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
this.color = readEditColor(style.color, segmentRefusal.engine);
|
|
558
|
+
|
|
559
|
+
// A stopped instance refuses a mode's options. The replay styles the scene in the color
|
|
560
|
+
// held above.
|
|
561
|
+
if (this.detached) {
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
this.applySegmentDraftStyle(this.color);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
setViaPromptPending(pending: boolean): void {
|
|
569
|
+
// The edit is over. A disposed engine writes and starts nothing, wherever it was disposed.
|
|
570
|
+
if (this.disposed) {
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
if (this.viaPromptPending === pending) {
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
this.viaPromptPending = pending;
|
|
579
|
+
|
|
580
|
+
// Detaching the click grammar (rather than gating inside it) is what stops the
|
|
581
|
+
// click that dismisses the prompt from also appending a point: the listener is
|
|
582
|
+
// simply not there for that gesture. The right-click prompt listener stays
|
|
583
|
+
// attached — re-raising the prompt for a handle is harmless and keeps the
|
|
584
|
+
// gesture from falling through to the studio's readout menu.
|
|
585
|
+
if (pending) {
|
|
586
|
+
this.detachClickInsert?.();
|
|
587
|
+
this.detachClickInsert = null;
|
|
588
|
+
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
this.detachClickInsert ??= this.attachClickInsert();
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
readDraft(): Position[] | null {
|
|
596
|
+
// The edit is over, and a disposed engine holds no draft.
|
|
597
|
+
if (this.disposed) {
|
|
598
|
+
return null;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// The store is empty between the detach and the replay, so the line is the one the engine
|
|
602
|
+
// holds for the replay: the draft applied since the detach, or the line the detach read. It
|
|
603
|
+
// is answered as a copy, as a read off the store is.
|
|
604
|
+
if (this.detached) {
|
|
605
|
+
const line =
|
|
606
|
+
this.heldDraft === undefined ? this.detachedLine : this.lineForDraft(this.heldDraft);
|
|
607
|
+
|
|
608
|
+
return line === null ? null : copyPositions(line);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
return this.currentLine();
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
applyDraft(draft: Position[]): void {
|
|
615
|
+
// The edit is over. A disposed engine writes and starts nothing, wherever it was disposed.
|
|
616
|
+
if (this.disposed) {
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
// Written as TerraDraw can hold it, as a seed is, and before the pins are read off it, so
|
|
621
|
+
// the guard compares a pin with the very coordinate that is written.
|
|
622
|
+
const coordinates = draft.map(clampCoordinatePrecision);
|
|
623
|
+
|
|
624
|
+
// A stopped instance refuses every write, so a draft applied between the detach and the
|
|
625
|
+
// replay is held, the latest one alone, and the replay writes it when it ends.
|
|
626
|
+
if (this.detached) {
|
|
627
|
+
this.heldDraft = coordinates;
|
|
628
|
+
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
// Invalidate the cached route before writing the restored geometry — it belongs
|
|
633
|
+
// to the PREVIOUS line, so the synchronous {origin:"api"} change the write fires
|
|
634
|
+
// must not echo it: a stale route would overwrite the restored elevation the
|
|
635
|
+
// store just set (the "profile stuck after cmd+z" bug). The echo rides
|
|
636
|
+
// route:null; scheduleAnalyze emits the fresh route for the restored line when
|
|
637
|
+
// it resolves.
|
|
638
|
+
const lastRoute = this.lastRoute;
|
|
639
|
+
this.lastRoute = null;
|
|
640
|
+
|
|
641
|
+
// A draft the library refuses writes nothing, so the pins it moved go back to the line the
|
|
642
|
+
// store still holds: left on a head that line never took, the guard would refuse every drag
|
|
643
|
+
// that follows. The route goes back with them, since the line is the one it was resolved for.
|
|
644
|
+
const pinnedFirst = this.pinnedFirst;
|
|
645
|
+
const pinnedLast = this.pinnedLast;
|
|
646
|
+
try {
|
|
647
|
+
this.writeDraft(coordinates);
|
|
648
|
+
} catch (error) {
|
|
649
|
+
this.pinnedFirst = pinnedFirst;
|
|
650
|
+
this.pinnedLast = pinnedLast;
|
|
651
|
+
this.lastRoute = lastRoute;
|
|
652
|
+
throw error;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* lineForDraft answers the line an applied draft is held as: the draft itself from two points
|
|
658
|
+
* up, the degenerate `[point, point]` for a single point, and for none the degenerate line on
|
|
659
|
+
* the boundary pin the edit opened on, or null where it opened on none.
|
|
660
|
+
*/
|
|
661
|
+
private lineForDraft(coordinates: Position[]): Position[] | null {
|
|
662
|
+
if (coordinates.length >= SEGMENT_MIN_VIAS) {
|
|
663
|
+
return coordinates;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
// A single restored point cannot form a line; hold it as the degenerate
|
|
667
|
+
// `[p, p]` so its handle renders and the next click extends it — the same
|
|
668
|
+
// shape a chained segment opens on. An undo that steps a from-scratch line
|
|
669
|
+
// back to its first click lands here. With no point at all, the boundary pin
|
|
670
|
+
// takes its place so its handle survives an undo to empty.
|
|
671
|
+
const head = coordinates[0] ?? this.chainSeedPin;
|
|
672
|
+
|
|
673
|
+
return head === undefined ? null : [head, head];
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* writeDraft replaces the line with an applied draft, re-pinning the boundaries the edit holds
|
|
678
|
+
* pinned to the ends of the line the draft is held as before the write, so the write is judged
|
|
679
|
+
* against them. A boundary the click grammar released is pinned again where that line is back
|
|
680
|
+
* on the point the edit opened pinned on.
|
|
681
|
+
*/
|
|
682
|
+
private writeDraft(coordinates: Position[]): void {
|
|
683
|
+
const line = this.lineForDraft(coordinates);
|
|
684
|
+
|
|
685
|
+
// Zero points: remove the feature first. A from-scratch first segment (no
|
|
686
|
+
// chainSeedPin) is left with no feature until the next click re-creates it.
|
|
687
|
+
if (coordinates.length === 0 && this.draw.getSnapshotFeature(this.featureId)) {
|
|
688
|
+
this.draw.removeFeatures([this.featureId]);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
if (line === null) {
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
// Re-pin to the restored ends only when they are already locked (a chained or
|
|
696
|
+
// reshaped segment): the guard's reference then tracks the applied draft
|
|
697
|
+
// rather than a stale coordinate from before the restore. A first segment's
|
|
698
|
+
// head is free — never pinned — so a restore must not lock it, matching the
|
|
699
|
+
// directions engine and keeping vertex 0 draggable after an undo. The re-pin
|
|
700
|
+
// runs BEFORE the write so the write validates against the restored ends
|
|
701
|
+
// rather than being rejected on the stale pin.
|
|
702
|
+
//
|
|
703
|
+
// A boundary the click grammar released is locked again by a draft that puts the line back
|
|
704
|
+
// on the point the edit opened pinned on: that end is its neighbour's once more, whether or
|
|
705
|
+
// not a click came between.
|
|
706
|
+
const head = line[0];
|
|
707
|
+
if (this.pinnedFirst !== undefined || liesOn(head, this.firstPinAtOpen)) {
|
|
708
|
+
this.pinnedFirst = head;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
const tail = line.at(-1);
|
|
712
|
+
if (this.pinnedLast !== undefined || liesOn(tail, this.lastPinAtOpen)) {
|
|
713
|
+
this.pinnedLast = tail;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
this.writeOrSeedLine(line);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
dispose(): void {
|
|
720
|
+
// Drop the map-level cursor re-assert FIRST so a move landing during teardown
|
|
721
|
+
// cannot re-pin a lock for an edit that has ended — the same listeners-before-
|
|
722
|
+
// instance ordering every lock-holding engine uses.
|
|
723
|
+
this.detachCursorReassert?.();
|
|
724
|
+
this.detachCursorReassert = null;
|
|
725
|
+
|
|
726
|
+
// Drop the vertex-hover override + its detach so a popOverride landing after
|
|
727
|
+
// the teardown cannot tear the (still-locked) edit cross down with it.
|
|
728
|
+
this.detachVertexCursor?.();
|
|
729
|
+
this.detachVertexCursor = null;
|
|
730
|
+
this.cursor.popOverride();
|
|
731
|
+
|
|
732
|
+
// Drop the click grammar's listeners so a post-dispose click cannot fire a
|
|
733
|
+
// mutation against the stopped TerraDraw instance, and the right-click prompt
|
|
734
|
+
// with them so a stale gesture cannot raise a prompt for an ended edit.
|
|
735
|
+
this.detachClickInsert?.();
|
|
736
|
+
this.detachClickInsert = null;
|
|
737
|
+
this.detachVertexPrompt?.();
|
|
738
|
+
this.detachVertexPrompt = null;
|
|
739
|
+
|
|
740
|
+
// Cancel any pending debounced analyze and bump the token so an in-flight
|
|
741
|
+
// analyze that resolves after teardown is dropped rather than emitting
|
|
742
|
+
// against the disposed engine; drop the cached profile too.
|
|
743
|
+
this.cancelAnalyze();
|
|
744
|
+
this.analyzeToken += 1;
|
|
745
|
+
this.lastRoute = null;
|
|
746
|
+
|
|
747
|
+
// Drop the change listener by reference, then clear the store (removing the
|
|
748
|
+
// rendered features) and stop TerraDraw (removing its sources + layers from the
|
|
749
|
+
// style). The clear is guarded on `enabled` because `TerraDraw.clear()` runs
|
|
750
|
+
// `checkEnabled()` and throws on a stopped instance: a dispose landing inside the
|
|
751
|
+
// detach window — an edit ended while a base-map switch is still waiting for its
|
|
752
|
+
// style — reaches an instance `detachBeforeStyleReload` already stopped.
|
|
753
|
+
this.draw.off("change", this.changeHandler);
|
|
754
|
+
this.draw.off("finish", this.finishHandler);
|
|
755
|
+
if (this.draw.enabled) {
|
|
756
|
+
this.draw.clear();
|
|
757
|
+
}
|
|
758
|
+
this.draw.stop();
|
|
759
|
+
|
|
760
|
+
// A dispose inside the detach window ends an edit whose replay never comes, so what the
|
|
761
|
+
// engine held for it goes with the edit and a late read answers no line. The window's flag
|
|
762
|
+
// stays raised: a late write is dropped where the stopped library would refuse it.
|
|
763
|
+
this.disposed = true;
|
|
764
|
+
this.heldDraft = undefined;
|
|
765
|
+
this.detachedLine = null;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* detachBeforeStyleReload stops TerraDraw before the swap, so the replay's `start()`
|
|
770
|
+
* actually re-registers the adapter. See {@link EditEngine.detachBeforeStyleReload}
|
|
771
|
+
* for why the pair is needed and why the order is load-bearing: the adapter's
|
|
772
|
+
* `unregister()` removes five layers and three sources unguarded, which succeeds
|
|
773
|
+
* silently on the outgoing style and is noisy-then-fatal on the incoming one.
|
|
774
|
+
*
|
|
775
|
+
* The map-level click grammar is left alone: a map-level listener survives `setStyle`
|
|
776
|
+
* untouched, and the replay's own detach-then-re-attach is what re-establishes its
|
|
777
|
+
* dispatch order against the restarted instance.
|
|
778
|
+
*
|
|
779
|
+
* The line is read off the store FIRST, because `stop()` empties it — the adapter's base
|
|
780
|
+
* `unregister()` ends in its own `clear()`, which calls back through `onClear` into
|
|
781
|
+
* `_store.clear()`. And the change and finish listeners come off before that, so the
|
|
782
|
+
* deletion the clear emits is not turned into a draft saying the user erased their line
|
|
783
|
+
* mid-swap.
|
|
784
|
+
*/
|
|
785
|
+
detachBeforeStyleReload(): void {
|
|
786
|
+
// The edit is over. A disposed engine writes and starts nothing, wherever it was disposed.
|
|
787
|
+
if (this.disposed) {
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
// A second detach before the replay reads a store the first one emptied: the line held
|
|
792
|
+
// for the replay stands.
|
|
793
|
+
if (this.detached) {
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
this.detached = true;
|
|
798
|
+
this.detachedLine = this.currentLine();
|
|
799
|
+
this.draw.off("change", this.changeHandler);
|
|
800
|
+
this.draw.off("finish", this.finishHandler);
|
|
801
|
+
this.draw.stop();
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* replayAfterStyleReload re-renders the active edit's scene after a base-map
|
|
806
|
+
* switch wiped the style. It re-attaches what setStyle tore down: the library's
|
|
807
|
+
* layers + change listener, the editable feature, its color, and the hover cursor over its
|
|
808
|
+
* handles (its TerraDraw point layer is rebuilt).
|
|
809
|
+
*
|
|
810
|
+
* Unlike the waypoint engines — which leave their map-level pointer
|
|
811
|
+
* subscriptions alone because a map-level listener survives setStyle untouched
|
|
812
|
+
* — this engine detaches THEN re-attaches its map-level click grammar. The
|
|
813
|
+
* detach makes the re-attach net-zero (no double-bind), and re-attaching is
|
|
814
|
+
* deliberate: the listeners must re-register AFTER TerraDraw re-starts is wired,
|
|
815
|
+
* so MapLibre dispatches the click handler ahead of any registration TerraDraw
|
|
816
|
+
* lands during start() — the same ordering the constructor establishes.
|
|
817
|
+
*
|
|
818
|
+
* It is the second half of a pair: {@link detachBeforeStyleReload} must have stopped
|
|
819
|
+
* the instance before the swap, or the `start()` below returns early and re-registers
|
|
820
|
+
* nothing.
|
|
821
|
+
*/
|
|
822
|
+
replayAfterStyleReload(): void {
|
|
823
|
+
// The edit is over. A disposed engine writes and starts nothing, wherever it was disposed.
|
|
824
|
+
if (this.disposed) {
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
// The detach's snapshot first: `stop()` emptied the store, so reading it here answers
|
|
829
|
+
// null for every edit that was actually detached. The store read is the fallback for a
|
|
830
|
+
// replay reached without one.
|
|
831
|
+
const line = this.detachedLine ?? this.currentLine();
|
|
832
|
+
this.detachedLine = null;
|
|
833
|
+
this.detached = false;
|
|
834
|
+
|
|
835
|
+
// Detach then re-attach the click grammar around TerraDraw's re-start: the
|
|
836
|
+
// detach keeps the re-attach net-zero, and re-attaching ahead of start()
|
|
837
|
+
// mirrors the construction order so MapLibre fires us before any registration
|
|
838
|
+
// TerraDraw lands during start(). The right-click prompt rides the same
|
|
839
|
+
// re-attach so the pair stays in one order. A reload while a prompt is open
|
|
840
|
+
// leaves the click grammar suspended, exactly as it was before the reload.
|
|
841
|
+
this.detachClickInsert?.();
|
|
842
|
+
this.detachClickInsert = this.viaPromptPending ? null : this.attachClickInsert();
|
|
843
|
+
this.detachVertexPrompt?.();
|
|
844
|
+
this.detachVertexPrompt = this.attachVertexPrompt();
|
|
845
|
+
|
|
846
|
+
// Drop the previous change and finish bindings before re-starting so re-`on`
|
|
847
|
+
// re-registers a SINGLE listener each rather than stacking a duplicate on every
|
|
848
|
+
// base-map switch: a stacked finish listener would settle every gesture twice.
|
|
849
|
+
this.draw.off("change", this.changeHandler);
|
|
850
|
+
this.draw.off("finish", this.finishHandler);
|
|
851
|
+
this.draw.start();
|
|
852
|
+
this.draw.on("change", this.changeHandler);
|
|
853
|
+
this.draw.on("finish", this.finishHandler);
|
|
854
|
+
|
|
855
|
+
// Re-enter select mode and re-seed whatever line exists — a committed >= 2 line,
|
|
856
|
+
// or a degenerate start a chained/from-scratch edit opened on — so editing
|
|
857
|
+
// resumes on the fresh style; a first segment mid-line before its first click
|
|
858
|
+
// has no feature, so the select mode idles as it did on open.
|
|
859
|
+
this.draw.setMode(SELECT_MODE);
|
|
860
|
+
if (line) {
|
|
861
|
+
// Cleared before the re-seed, because the STORE survives a style swap while the
|
|
862
|
+
// adapter's layers do not. `addFeatures` reports an id already in the store
|
|
863
|
+
// invalid rather than throwing, so a bare re-seed would add nothing and the
|
|
864
|
+
// re-registered layers would stay empty. The line above was read before this ran.
|
|
865
|
+
this.draw.clear();
|
|
866
|
+
this.seedFeature(line);
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
this.applySegmentDraftStyle(this.color);
|
|
870
|
+
|
|
871
|
+
// Re-attach the vertex cursor override onto the rebuilt point layer; the
|
|
872
|
+
// previous detach already ran when the style reload tore the layers down,
|
|
873
|
+
// so this rewires a clean pair on the fresh style.
|
|
874
|
+
this.detachVertexCursor?.();
|
|
875
|
+
this.detachVertexCursor = this.attachVertexCursor();
|
|
876
|
+
|
|
877
|
+
// Rebuild the map-level cursor re-assert LAST, after the re-started TerraDraw
|
|
878
|
+
// re-wired its own move handler, so the re-pin keeps dispatching after it. The
|
|
879
|
+
// re-assert binds nothing to the torn-down scene, but detaching + re-attaching
|
|
880
|
+
// here re-establishes that listener-order against the rebuilt TerraDraw the way
|
|
881
|
+
// the constructor does, net-zero (the previous detach ran on the old wiring).
|
|
882
|
+
this.detachCursorReassert?.();
|
|
883
|
+
this.detachCursorReassert = attachCursorReassert(this.events, this.cursor);
|
|
884
|
+
|
|
885
|
+
// The draft applied while the instance was stopped lands last, on the scene the lines above
|
|
886
|
+
// rebuilt, as it would have landed outside the window.
|
|
887
|
+
const held = this.heldDraft;
|
|
888
|
+
this.heldDraft = undefined;
|
|
889
|
+
if (held !== undefined) {
|
|
890
|
+
applyHeldWrite(() => this.applyDraft(held));
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
/**
|
|
895
|
+
* handleChange is the single fan-out the per-edit change listener calls on every
|
|
896
|
+
* geometry change to the editable line — an interactive drag/insert, an engine
|
|
897
|
+
* click write, or a programmatic applyDraft/seed. A change under any other id is
|
|
898
|
+
* skipped. It emits IMMEDIATELY with the engine's CACHED route so the panel stays
|
|
899
|
+
* responsive — the line moved, but the last-known elevation profile holds rather
|
|
900
|
+
* than flashing empty — and, off the same change, schedules a debounced analyzeFn
|
|
901
|
+
* for the current line. When that analyze resolves it caches the fresh profile
|
|
902
|
+
* and emits again. Below the two-point floor (a degenerate start, an undo that
|
|
903
|
+
* stepped below it) the cached route is cleared and the draft carries an explicit
|
|
904
|
+
* null, the same below-floor behavior the directions engine has. The line is
|
|
905
|
+
* normalized first so the degenerate `[p, p]` reads as one via and the Save-closed
|
|
906
|
+
* floor holds.
|
|
907
|
+
*
|
|
908
|
+
* The phase follows the change's origin. A change TerraDraw makes under the pointer (a
|
|
909
|
+
* vertex drag, a midpoint insert) is one frame of a gesture its `finish` closes, so it is
|
|
910
|
+
* `live` and {@link handleFinish} settles it. A store-API write, the engine's own click
|
|
911
|
+
* write or a programmatic one, is whole when it lands, so it is `settled`.
|
|
912
|
+
*/
|
|
913
|
+
private handleChange(ids: (string | number)[], apiOrigin: boolean): void {
|
|
914
|
+
// Only the editable line's own changes drive the draft; a stray change for any
|
|
915
|
+
// other feature is ignored.
|
|
916
|
+
if (!ids.includes(this.featureId)) {
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
// A store-API write is programmatic UNLESS the engine flagged it as an
|
|
921
|
+
// interactive click write: an api-origin change during an interactiveWrite is a
|
|
922
|
+
// clicked point and records in history; a true applyDraft/seed write stays
|
|
923
|
+
// programmatic (api-origin would otherwise skip undo history). A genuine
|
|
924
|
+
// interactive drag/insert carries no api origin at all.
|
|
925
|
+
const programmatic = apiOrigin && !this.interactiveWrite;
|
|
926
|
+
const phase: DraftPhase = apiOrigin ? "settled" : "live";
|
|
927
|
+
|
|
928
|
+
// An interactive change means TerraDraw — or the engine's own click write —
|
|
929
|
+
// landed a real edit on this gesture; mark it so the click grammar's
|
|
930
|
+
// consumed-gesture guard skips a duplicate append/splice for the same pointer
|
|
931
|
+
// sequence (kills the midpoint-double-insert).
|
|
932
|
+
if (!programmatic) {
|
|
933
|
+
this.gestureConsumed = true;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
// A live frame opens the gesture its finish settles. A settled write closes any gesture
|
|
937
|
+
// still open: an interactive one records that gesture in the draft it emits, and a
|
|
938
|
+
// programmatic one (an undo or a redo landing mid-drag) replaces the line the gesture
|
|
939
|
+
// moved, so the release that follows has nothing left to record.
|
|
940
|
+
this.gestureOpen = phase === "live";
|
|
941
|
+
|
|
942
|
+
const line = normalizeDraftLine(this.currentLine() ?? []);
|
|
943
|
+
|
|
944
|
+
if (line.length < SEGMENT_MIN_VIAS) {
|
|
945
|
+
// A single effective point cannot form a line, so no profile applies. Clear
|
|
946
|
+
// the cache, cancel any in-flight analyze (bump the token so a late resolve is
|
|
947
|
+
// dropped), and emit the cleared route — the panel falls back to the persisted
|
|
948
|
+
// segment, matching the directions below-floor path.
|
|
949
|
+
this.lastRoute = null;
|
|
950
|
+
this.cancelAnalyze();
|
|
951
|
+
this.analyzeToken += 1;
|
|
952
|
+
notifyListeners([this.emitDraft], { phase, programmatic, route: null, vias: line });
|
|
953
|
+
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
// Responsive emit: carry the cached profile (possibly stale by one analyze)
|
|
958
|
+
// so the panel keeps the last elevation while the fresh one resolves.
|
|
959
|
+
notifyListeners([this.emitDraft], { phase, programmatic, route: this.lastRoute, vias: line });
|
|
960
|
+
|
|
961
|
+
this.scheduleAnalyze();
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
/**
|
|
965
|
+
* handleFinish settles the gesture TerraDraw just finished on the editable line: a
|
|
966
|
+
* coordinate drag, or a midpoint insert, both of which reach the draft as `live` frames. It
|
|
967
|
+
* emits the line as it stands once more, `settled` and interactive, so a history subscriber
|
|
968
|
+
* records the whole gesture as one step. A finish that closes no live frame emits nothing,
|
|
969
|
+
* because the select mode also finishes a drag the pin guard refused at every step, and that
|
|
970
|
+
* gesture changed nothing. The geometry did not move since the last frame, so the draft
|
|
971
|
+
* carries the route that frame carried.
|
|
972
|
+
*/
|
|
973
|
+
private handleFinish(id: string | number): void {
|
|
974
|
+
if (id !== this.featureId || !this.gestureOpen) {
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
this.gestureOpen = false;
|
|
979
|
+
const line = normalizeDraftLine(this.currentLine() ?? []);
|
|
980
|
+
const route = line.length < SEGMENT_MIN_VIAS ? null : this.lastRoute;
|
|
981
|
+
notifyListeners([this.emitDraft], { phase: "settled", programmatic: false, route, vias: line });
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* scheduleAnalyze debounces an analyzeFn call for the current line, coalescing a burst of
|
|
986
|
+
* rapid changes into a single round trip. Each call cancels the pending timer, aborts the
|
|
987
|
+
* analyze in flight and bumps the analyze token, so a newer change supersedes an older one:
|
|
988
|
+
* the host's call is handed a signal that aborts as it is superseded or the edit ends, and an
|
|
989
|
+
* answer that lands anyway is dropped by the token. The line is read when the timer fires, so a
|
|
990
|
+
* drag that changes it every frame copies it once. On a matching resolution it caches the route
|
|
991
|
+
* and emits a programmatic draft (the geometry did not change with the analyze, so a history
|
|
992
|
+
* subscriber must not record it) carrying the fresh profile. A null analyzeFn (a render-free
|
|
993
|
+
* test, no data seam) is a no-op. A resolved null (below floor, an absorbed query error) clears
|
|
994
|
+
* the cache and emits the cleared route. An analyzeFn that throws or rejects is read as no new
|
|
995
|
+
* profile: the edit stays open, and {@link warnOnAnalyzeFault} says so once.
|
|
996
|
+
*/
|
|
997
|
+
private scheduleAnalyze(): void {
|
|
998
|
+
if (!this.analyzeFn) {
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
// A new change supersedes any pending or in-flight analyze: cancel the timer, abort the call
|
|
1003
|
+
// and bump the token so a late resolution of the previous analyze is dropped.
|
|
1004
|
+
this.cancelAnalyze();
|
|
1005
|
+
this.analyzeToken += 1;
|
|
1006
|
+
const token = this.analyzeToken;
|
|
1007
|
+
|
|
1008
|
+
this.analyzeTimer = setTimeout(() => {
|
|
1009
|
+
this.analyzeTimer = null;
|
|
1010
|
+
const analyze = this.analyzeFn;
|
|
1011
|
+
if (!analyze) {
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
// Built as the call is made, so a drag that supersedes its own frames builds one.
|
|
1016
|
+
const controller = new AbortController();
|
|
1017
|
+
this.analyzeController = controller;
|
|
1018
|
+
const line = normalizeDraftLine(this.currentLine() ?? []);
|
|
1019
|
+
const answer = (async () =>
|
|
1020
|
+
analyze(this.activitySlug, line, { signal: controller.signal }))();
|
|
1021
|
+
void answer.then(
|
|
1022
|
+
(route) => {
|
|
1023
|
+
// Drop a stale resolution: a newer change bumped the token while this
|
|
1024
|
+
// analyze was in flight, so its result no longer describes the line.
|
|
1025
|
+
if (token !== this.analyzeToken) {
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
this.lastRoute = route;
|
|
1030
|
+
// The geometry is unchanged by the analyze, so flag the emit
|
|
1031
|
+
// programmatic: a history subscriber records interactive edits only and
|
|
1032
|
+
// must not push this profile-only update. Settled, as every programmatic
|
|
1033
|
+
// write is: nothing closes it later.
|
|
1034
|
+
notifyListeners([this.emitDraft], {
|
|
1035
|
+
phase: "settled",
|
|
1036
|
+
programmatic: true,
|
|
1037
|
+
route,
|
|
1038
|
+
vias: this.currentLine() ?? line,
|
|
1039
|
+
});
|
|
1040
|
+
},
|
|
1041
|
+
(fault: unknown) => {
|
|
1042
|
+
// An analyze the engine dropped answers nothing, whatever it answers.
|
|
1043
|
+
if (token === this.analyzeToken) {
|
|
1044
|
+
this.warnOnAnalyzeFault(fault);
|
|
1045
|
+
}
|
|
1046
|
+
},
|
|
1047
|
+
);
|
|
1048
|
+
}, ANALYZE_DEBOUNCE_MS);
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* warnOnAnalyzeFault says in the console, once per edit and in development only, that the
|
|
1053
|
+
* injected analyzeFn threw or rejected.
|
|
1054
|
+
*
|
|
1055
|
+
* The engine reads a fault as no new profile, so nothing the host holds rejects and the live
|
|
1056
|
+
* elevation simply does not refresh. Once per edit, because a drag asks for an analyze at every
|
|
1057
|
+
* line it settles on and an analyzer that is down fails each one for the same reason. A
|
|
1058
|
+
* production build says nothing: the fault is the host's to report through its own analyzer.
|
|
1059
|
+
*/
|
|
1060
|
+
private warnOnAnalyzeFault(fault: unknown): void {
|
|
1061
|
+
if (this.analyzeFaultReported || !inDevelopment()) {
|
|
1062
|
+
return;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
this.analyzeFaultReported = true;
|
|
1066
|
+
console.warn(
|
|
1067
|
+
"[@mountaya/elements] TerraDrawLinestringSegmentEngine: analyzeFn threw, so the edit shows " +
|
|
1068
|
+
"no fresh profile for this line. An analyzer that finds none resolves to null; one that " +
|
|
1069
|
+
"throws or rejects is read the same way and the edit stays open. The error it threw follows.",
|
|
1070
|
+
fault,
|
|
1071
|
+
);
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
/**
|
|
1075
|
+
* cancelAnalyze clears the pending debounce timer and aborts the analyze in flight, so no
|
|
1076
|
+
* scheduled analyze fires and the host's call is told it is no longer read; idempotent.
|
|
1077
|
+
*/
|
|
1078
|
+
private cancelAnalyze(): void {
|
|
1079
|
+
if (this.analyzeTimer !== null) {
|
|
1080
|
+
clearTimeout(this.analyzeTimer);
|
|
1081
|
+
this.analyzeTimer = null;
|
|
1082
|
+
}
|
|
1083
|
+
this.analyzeController?.abort();
|
|
1084
|
+
this.analyzeController = null;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
/** seedFeature adds the editable linestring feature under featureId, selects it, and shows its handles + midpoints. */
|
|
1088
|
+
private seedFeature(coordinates: Position[]): void {
|
|
1089
|
+
const feature: GeoJSONStoreFeatures = {
|
|
1090
|
+
geometry: { coordinates, type: "LineString" },
|
|
1091
|
+
id: this.featureId,
|
|
1092
|
+
properties: { mode: EDIT_MODE },
|
|
1093
|
+
type: "Feature",
|
|
1094
|
+
};
|
|
1095
|
+
// Read before anything follows it: a seed the library refuses is in no store to select.
|
|
1096
|
+
addDrawFeature(this.draw, feature, segmentRefusal);
|
|
1097
|
+
this.draw.setMode(SELECT_MODE);
|
|
1098
|
+
this.draw.selectFeature(this.featureId);
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
/**
|
|
1102
|
+
* writeOrSeedLine writes the given coordinates onto the editable feature, or
|
|
1103
|
+
* re-creates it through the seed path when it is absent. updateFeatureGeometry
|
|
1104
|
+
* THROWS when the feature is gone (an applyDraft that lands after an undo-to-empty
|
|
1105
|
+
* removed it), so a present feature takes the geometry update — which keeps the
|
|
1106
|
+
* selection + handles live via TerraDraw's afterFeatureUpdated refresh — while an
|
|
1107
|
+
* absent one is re-seeded and re-selected.
|
|
1108
|
+
*/
|
|
1109
|
+
private writeOrSeedLine(coordinates: Position[]): void {
|
|
1110
|
+
if (this.draw.getSnapshotFeature(this.featureId)) {
|
|
1111
|
+
updateDrawGeometry(
|
|
1112
|
+
this.draw,
|
|
1113
|
+
this.featureId,
|
|
1114
|
+
{ coordinates, type: "LineString" },
|
|
1115
|
+
segmentRefusal,
|
|
1116
|
+
);
|
|
1117
|
+
} else {
|
|
1118
|
+
this.seedFeature(coordinates);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
/**
|
|
1123
|
+
* applySegmentDraftStyle pushes the segment color onto the edit + select
|
|
1124
|
+
* mode styles so the draft line, its vertices, the selection handles, and
|
|
1125
|
+
* the midpoint-insert handles all render in the segment color.
|
|
1126
|
+
* updateModeOptions accepts a partial options object, so only the styling
|
|
1127
|
+
* keys are sent; it runs while the modes are started, recoloring live.
|
|
1128
|
+
* The color was held to `#rrggbb` as it was handed over ({@link readEditColor}).
|
|
1129
|
+
*/
|
|
1130
|
+
private applySegmentDraftStyle(hex: `#${string}`): void {
|
|
1131
|
+
// updateModeOptions is keyed by the mode NAME (the class's `mode`
|
|
1132
|
+
// property), with the class passed as the generic type argument so the
|
|
1133
|
+
// styling keys are type-checked against that mode's styling — passing
|
|
1134
|
+
// the class as the value throws "No mode with this name present" at
|
|
1135
|
+
// runtime.
|
|
1136
|
+
this.draw.updateModeOptions<typeof TerraDrawLineStringMode>(EDIT_MODE, {
|
|
1137
|
+
styles: {
|
|
1138
|
+
coordinatePointColor: hex,
|
|
1139
|
+
lineStringColor: hex,
|
|
1140
|
+
lineStringWidth: 4,
|
|
1141
|
+
},
|
|
1142
|
+
});
|
|
1143
|
+
this.draw.updateModeOptions<typeof TerraDrawSelectMode>(SELECT_MODE, {
|
|
1144
|
+
styles: {
|
|
1145
|
+
midPointColor: hex,
|
|
1146
|
+
selectedLineStringColor: hex,
|
|
1147
|
+
selectedPointColor: hex,
|
|
1148
|
+
selectionPointColor: hex,
|
|
1149
|
+
},
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
/** currentLine reads the editable line's current coordinates from the TerraDraw store, or null when it is gone. */
|
|
1154
|
+
private currentLine(): Position[] | null {
|
|
1155
|
+
return this.lineOf(this.featureId);
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
/**
|
|
1159
|
+
* lineOf reads one feature's coordinates from the TerraDraw store by id, narrowed
|
|
1160
|
+
* to a LineString, or null when the feature is gone or is not a line (a transient
|
|
1161
|
+
* store state). currentLine reads the editable line through it, so the narrowing
|
|
1162
|
+
* that keeps the draft honest lives in one place.
|
|
1163
|
+
*/
|
|
1164
|
+
private lineOf(id: string | number): Position[] | null {
|
|
1165
|
+
const feature = this.draw.getSnapshotFeature(id);
|
|
1166
|
+
if (feature?.geometry.type !== "LineString") {
|
|
1167
|
+
return null;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
return feature.geometry.coordinates;
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
/**
|
|
1174
|
+
* attachVertexCursor layers the drag/insert affordance over the locked edit cross whenever the
|
|
1175
|
+
* pointer sits on a handle of the editable line, through the shared
|
|
1176
|
+
* {@link attachEditHoverCursor}: the `move` cursor over a draggable vertex (a drag there
|
|
1177
|
+
* reshapes) and "pointer" over an insert-midpoint (a click there splits the line). The
|
|
1178
|
+
* TerraDraw point layer hosts both, distinguished by the midpoint property. The base cross
|
|
1179
|
+
* stays pinned underneath and shows again off the handles. The select-mode handler only writes
|
|
1180
|
+
* the canvas cursor over a handle, never on empty map, so the locked cross is untouched while
|
|
1181
|
+
* the pointer roams free.
|
|
1182
|
+
*/
|
|
1183
|
+
private attachVertexCursor(): () => void {
|
|
1184
|
+
return attachEditHoverCursor({
|
|
1185
|
+
cursor: this.cursor,
|
|
1186
|
+
events: this.events,
|
|
1187
|
+
layers: [
|
|
1188
|
+
{
|
|
1189
|
+
kind: "handle",
|
|
1190
|
+
layerId: SEGMENT_VERTEX_LAYER_ID,
|
|
1191
|
+
midpointProperty: TERRA_DRAW_MID_POINT_PROPERTY,
|
|
1192
|
+
},
|
|
1193
|
+
],
|
|
1194
|
+
map: this.map,
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
/**
|
|
1199
|
+
* attachClickInsert subscribes to canvas-level clicks so the engine can grow or
|
|
1200
|
+
* reshape the editable line with the directions click grammar, plus a mousedown
|
|
1201
|
+
* that resets the consumed-gesture guard at the start of every pointer sequence.
|
|
1202
|
+
* On a click the handler runs a three-way branch behind two guards:
|
|
1203
|
+
*
|
|
1204
|
+
* - Consumed-gesture guard: skip when TerraDraw already handled the gesture on
|
|
1205
|
+
* the preceding pointerup (a drag, a midpoint insert), so the engine does not
|
|
1206
|
+
* double the coordinate.
|
|
1207
|
+
* - Vertex-proximity guard: skip within the snap radius of an existing vertex —
|
|
1208
|
+
* that click belongs to TerraDraw (grab-to-drag, right-click delete).
|
|
1209
|
+
* - No feature yet → create the degenerate `[click, click]` and select it. A boundary
|
|
1210
|
+
* still pinned there (an applied draft emptied an edit that opened on a saved line) is
|
|
1211
|
+
* released, so the click starts a line as the first click of a fresh edit does. An applied
|
|
1212
|
+
* draft that puts the line back on a point the edit opened pinned on locks that end again.
|
|
1213
|
+
* - Degenerate line → replace its duplicate tail with the click.
|
|
1214
|
+
* - Real line → splice into the nearest edge within the snap radius, else append
|
|
1215
|
+
* the click to the tail (the reshape-extends behavior).
|
|
1216
|
+
*
|
|
1217
|
+
* Every write runs under {@link runInteractiveWrite} so it records as an undo
|
|
1218
|
+
* step, and clamps its coordinate to 9 dp so the store-API write never trips
|
|
1219
|
+
* TerraDraw's excessive-precision throw. A consumed click stops propagation so a
|
|
1220
|
+
* sibling MapLibre click listener does not also act on it. A write the library refuses, the
|
|
1221
|
+
* first click's seed or any after it, leaves the listener as this package's error with the
|
|
1222
|
+
* library's reason, and writes nothing.
|
|
1223
|
+
*/
|
|
1224
|
+
private attachClickInsert(): () => void {
|
|
1225
|
+
// Reset the consumed-gesture flag at the start of every pointer sequence so a
|
|
1226
|
+
// fresh click is judged only on what TerraDraw does during THIS gesture, not a
|
|
1227
|
+
// previous drag/insert.
|
|
1228
|
+
const onDown = (): void => {
|
|
1229
|
+
this.gestureConsumed = false;
|
|
1230
|
+
};
|
|
1231
|
+
|
|
1232
|
+
const onClick = (event: MapLayerMouseEvent): void => {
|
|
1233
|
+
// Between the detach and the replay the store holds no line to judge a click against and
|
|
1234
|
+
// refuses every write, so a click there draws nothing.
|
|
1235
|
+
if (this.gestureConsumed || this.detached) {
|
|
1236
|
+
return;
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
const clickLngLat = pointerPosition(event.lngLat);
|
|
1240
|
+
const line = this.currentLine() ?? [];
|
|
1241
|
+
|
|
1242
|
+
// A click that landed on an existing handle without TerraDraw consuming the
|
|
1243
|
+
// gesture (checked above) is a plain click on that vertex, not a drag. What
|
|
1244
|
+
// the user meant is ambiguous — remove it, or route through it again to close
|
|
1245
|
+
// a loop — so the engine asks instead of guessing, and adds nothing here.
|
|
1246
|
+
// nearestVertex reads Infinity before the first vertex exists, so this no-ops
|
|
1247
|
+
// on a from-scratch first click.
|
|
1248
|
+
const vertex = nearestVertex({ line, lngLat: clickLngLat, map: this.map });
|
|
1249
|
+
if (vertex.distancePx < SNAP_THRESHOLD_PX) {
|
|
1250
|
+
this.promptForVertex(line, vertex.index);
|
|
1251
|
+
this.consumeClick(event);
|
|
1252
|
+
|
|
1253
|
+
return;
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
// No feature yet: the first click on a from-scratch segment creates the line
|
|
1257
|
+
// as a degenerate `[click, click]` and selects it, so the next click extends it.
|
|
1258
|
+
if (line.length === 0) {
|
|
1259
|
+
// A pin still locked here names an end of a line that is gone: an applied draft
|
|
1260
|
+
// emptied an edit that opened on a saved line, which holds no boundary pin to fall
|
|
1261
|
+
// back on. The click starts a line of its own, as on a fresh edit, so the pins are
|
|
1262
|
+
// released with the line they held. Left locked, the guard would refuse this seed
|
|
1263
|
+
// and every click after it.
|
|
1264
|
+
this.pinnedFirst = undefined;
|
|
1265
|
+
this.pinnedLast = undefined;
|
|
1266
|
+
this.runInteractiveWrite(() => this.seedFeature([clickLngLat, clickLngLat]));
|
|
1267
|
+
this.consumeClick(event);
|
|
1268
|
+
|
|
1269
|
+
return;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
// Degenerate line (`[pin, pin]`): the first real vertex replaces the duplicate,
|
|
1273
|
+
// turning the single pinned boundary into a two-vertex line. Which side the
|
|
1274
|
+
// click takes follows which boundary is pinned — a pinned END keeps the pin
|
|
1275
|
+
// last and puts the click in front of it, so a head insert grows backwards from
|
|
1276
|
+
// its successor exactly as an append grows forwards from its predecessor.
|
|
1277
|
+
if (normalizeDraftLine(line).length < SEGMENT_MIN_VIAS) {
|
|
1278
|
+
const pin = line[0] ?? clickLngLat;
|
|
1279
|
+
const coordinates = this.pinnedLast !== undefined ? [clickLngLat, pin] : [pin, clickLngLat];
|
|
1280
|
+
this.runInteractiveWrite(() =>
|
|
1281
|
+
updateDrawGeometry(
|
|
1282
|
+
this.draw,
|
|
1283
|
+
this.featureId,
|
|
1284
|
+
{ coordinates, type: "LineString" },
|
|
1285
|
+
segmentRefusal,
|
|
1286
|
+
),
|
|
1287
|
+
);
|
|
1288
|
+
this.consumeClick(event);
|
|
1289
|
+
|
|
1290
|
+
return;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
// A real line: splice into the nearest edge when the click lands within the
|
|
1294
|
+
// snap radius of one (a mid-line insertion), otherwise append the click to the
|
|
1295
|
+
// tail (the reshape-extends behavior — a click far from the line grows it).
|
|
1296
|
+
const insertion = nearestEdgeInsertion({
|
|
1297
|
+
line,
|
|
1298
|
+
lngLat: clickLngLat,
|
|
1299
|
+
map: this.map,
|
|
1300
|
+
thresholdPx: SNAP_THRESHOLD_PX,
|
|
1301
|
+
});
|
|
1302
|
+
const next: Position[] = [...line];
|
|
1303
|
+
if (insertion) {
|
|
1304
|
+
// `index` is the END vertex of the matched edge, so splice(index, 0, …)
|
|
1305
|
+
// lands the new vertex BETWEEN the two endpoints rather than appending.
|
|
1306
|
+
next.splice(insertion.index, 0, insertion.lngLat);
|
|
1307
|
+
} else if (this.pinnedLast !== undefined) {
|
|
1308
|
+
// The pinned end IS the next segment's start and must stay last, so the click
|
|
1309
|
+
// is spliced in front of it. The line therefore always finishes on its
|
|
1310
|
+
// neighbour, however far from it the user clicks.
|
|
1311
|
+
next.splice(next.length - 1, 0, clickLngLat);
|
|
1312
|
+
} else {
|
|
1313
|
+
next.push(clickLngLat);
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
this.runInteractiveWrite(() =>
|
|
1317
|
+
updateDrawGeometry(
|
|
1318
|
+
this.draw,
|
|
1319
|
+
this.featureId,
|
|
1320
|
+
{ coordinates: next, type: "LineString" },
|
|
1321
|
+
segmentRefusal,
|
|
1322
|
+
),
|
|
1323
|
+
);
|
|
1324
|
+
this.consumeClick(event);
|
|
1325
|
+
};
|
|
1326
|
+
|
|
1327
|
+
const detachClick = this.events.on("click", onClick);
|
|
1328
|
+
const detachDown = this.events.on("mousedown", onDown);
|
|
1329
|
+
|
|
1330
|
+
return () => {
|
|
1331
|
+
detachClick();
|
|
1332
|
+
detachDown();
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
/**
|
|
1337
|
+
* attachVertexPrompt raises the ask-the-user prompt for a RIGHT-clicked handle.
|
|
1338
|
+
* Right-click was TerraDraw's own coordinate delete; the select mode's
|
|
1339
|
+
* `deletable` flag is off, so the gesture arrives here instead and the engine
|
|
1340
|
+
* asks what it meant rather than deleting. Scoped map-level (the vertex hit test
|
|
1341
|
+
* is the same screen-space radius the click grammar uses, so the two agree by
|
|
1342
|
+
* construction) and detached by reference on dispose / replay.
|
|
1343
|
+
*/
|
|
1344
|
+
private attachVertexPrompt(): () => void {
|
|
1345
|
+
return this.events.on("contextmenu", (event: MapLayerMouseEvent) => {
|
|
1346
|
+
const lngLat = pointerPosition(event.lngLat);
|
|
1347
|
+
const line = this.currentLine() ?? [];
|
|
1348
|
+
const vertex = nearestVertex({ line, lngLat, map: this.map });
|
|
1349
|
+
if (vertex.distancePx >= SNAP_THRESHOLD_PX) {
|
|
1350
|
+
return;
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
this.promptForVertex(line, vertex.index);
|
|
1354
|
+
// A right-click off a handle still belongs to the studio's own readout menu;
|
|
1355
|
+
// one landing ON a handle is this prompt's, so it is not also passed along.
|
|
1356
|
+
this.consumeClick(event);
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
/**
|
|
1361
|
+
* promptForVertex emits the ask-the-user prompt for the handle at `index`,
|
|
1362
|
+
* carrying the coordinate so the app can anchor the prompt on it. A no-op for an
|
|
1363
|
+
* index the line does not carry, so a stale hit test can never raise a prompt
|
|
1364
|
+
* against a vertex that is gone.
|
|
1365
|
+
*/
|
|
1366
|
+
private promptForVertex(line: readonly Position[], index: number): void {
|
|
1367
|
+
const vertex = line[index];
|
|
1368
|
+
if (!vertex) {
|
|
1369
|
+
return;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
notifyListeners([this.emitViaPrompt], { index, lngLat: [vertex[0] ?? 0, vertex[1] ?? 0] });
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
/**
|
|
1376
|
+
* runInteractiveWrite flags a store-API write as an interactive click write for
|
|
1377
|
+
* the duration of `write`, so handleChange emits its api-origin change as an
|
|
1378
|
+
* interactive draft (an undo step) rather than a skipped programmatic echo. The
|
|
1379
|
+
* flag is always cleared, even if the write throws (a validation rejection), so a
|
|
1380
|
+
* later programmatic write is never mis-flagged.
|
|
1381
|
+
*/
|
|
1382
|
+
private runInteractiveWrite(write: () => void): void {
|
|
1383
|
+
this.interactiveWrite = true;
|
|
1384
|
+
try {
|
|
1385
|
+
write();
|
|
1386
|
+
} finally {
|
|
1387
|
+
this.interactiveWrite = false;
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
/**
|
|
1392
|
+
* consumeClick blocks sibling MapLibre click listeners from also acting on a
|
|
1393
|
+
* click the engine turned into a vertex edit (a feature-select handler, say).
|
|
1394
|
+
* TerraDraw already handled its own handle gestures on the preceding pointerup,
|
|
1395
|
+
* so this does NOT gate TerraDraw — it only stops other MapLibre listeners on the
|
|
1396
|
+
* same synthetic click.
|
|
1397
|
+
*/
|
|
1398
|
+
private consumeClick(event: MapLayerMouseEvent): void {
|
|
1399
|
+
event.preventDefault();
|
|
1400
|
+
const originalEvent = event.originalEvent;
|
|
1401
|
+
if (originalEvent && typeof originalEvent.stopPropagation === "function") {
|
|
1402
|
+
originalEvent.stopPropagation();
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
}
|